@@ -8,7 +8,7 @@ import RhMicronsCaretLeftIcon from '@patternfly/react-icons/dist/esm/icons/rh-mi
88import RhMicronsCaretRightIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-caret-right-icon' ;
99import { css } from '@patternfly/react-styles' ;
1010import styles from '@patternfly/react-styles/css/components/CalendarMonth/calendar-month' ;
11- import { useSSRSafeId } from '../../helpers' ;
11+ import { useSSRSafeId , useOUIAProps , OUIAProps } from '../../helpers' ;
1212import { isValidDate } from '../../helpers/datetimeUtils' ;
1313
1414export enum Weekday {
@@ -63,7 +63,7 @@ export interface CalendarFormat {
6363 inlineProps ?: CalendarMonthInlineProps ;
6464}
6565
66- export interface CalendarProps extends CalendarFormat , Omit < React . HTMLProps < HTMLDivElement > , 'onChange' > {
66+ export interface CalendarProps extends CalendarFormat , Omit < React . HTMLProps < HTMLDivElement > , 'onChange' > , OUIAProps {
6767 /** Additional classes to add to the outer div of the calendar month. */
6868 className ?: string ;
6969 /** Month/year to base other dates around. */
@@ -88,6 +88,10 @@ export interface CalendarProps extends CalendarFormat, Omit<React.HTMLProps<HTML
8888 * monthAppendTo={document.getElementById('target')}
8989 */
9090 monthAppendTo ?: HTMLElement | ( ( ref ?: HTMLElement ) => HTMLElement ) | 'inline' ;
91+ /** Value to overwrite the randomly generated data-ouia-component-id.*/
92+ ouiaId ?: number | string ;
93+ /** Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. */
94+ ouiaSafe ?: boolean ;
9195}
9296
9397const buildCalendar = ( year : number , month : number , weekStart : number , validators : ( ( date : Date ) => boolean ) [ ] ) => {
@@ -151,8 +155,11 @@ export const CalendarMonth = ({
151155 isDateFocused = false ,
152156 inlineProps,
153157 monthAppendTo = 'inline' ,
158+ ouiaId,
159+ ouiaSafe = true ,
154160 ...props
155161} : CalendarProps ) => {
162+ const ouiaProps = useOUIAProps ( CalendarMonth . displayName , ouiaId , ouiaSafe ) ;
156163 const longMonths = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 ]
157164 . map ( ( monthNum ) => new Date ( 1990 , monthNum ) )
158165 . map ( monthFormat ) ;
@@ -293,7 +300,7 @@ export const CalendarMonth = ({
293300 const monthFormatted = monthFormat ( focusedDate ) ;
294301
295302 const calendarToRender = (
296- < div className = { css ( styles . calendarMonth , className ) } { ...props } >
303+ < div className = { css ( styles . calendarMonth , className ) } { ...props } { ... ouiaProps } >
297304 < div className = { styles . calendarMonthHeader } >
298305 < div className = { css ( styles . calendarMonthHeaderNavControl , 'pf-m-prev-month' ) } >
299306 < Button
0 commit comments