(
props: AriaCalendarProps<T> & {visibleDuration: DateDuration}
)
| 23 | import {useLocale} from '../../src/i18n/I18nProvider'; |
| 24 | |
| 25 | export function Example<T extends DateValue | CalendarDate>( |
| 26 | props: AriaCalendarProps<T> & {visibleDuration: DateDuration} |
| 27 | ): JSX.Element { |
| 28 | let {locale} = useLocale(); |
| 29 | const {visibleDuration} = props; |
| 30 | |
| 31 | let state = useCalendarState({ |
| 32 | createCalendar, |
| 33 | ...props, |
| 34 | locale |
| 35 | }); |
| 36 | |
| 37 | let {calendarProps, prevButtonProps, nextButtonProps} = useCalendar(props, state); |
| 38 | |
| 39 | let grids = useMemo(() => { |
| 40 | let gridCount = 1; |
| 41 | if (visibleDuration.months && visibleDuration.months > 0) { |
| 42 | gridCount = visibleDuration.months; |
| 43 | } |
| 44 | |
| 45 | let components: Array<ReactElement> = []; |
| 46 | for (let i = 0; i < gridCount; i++) { |
| 47 | components.push( |
| 48 | <CalendarGrid |
| 49 | key={i} |
| 50 | state={state} |
| 51 | visibleDuration={visibleDuration} |
| 52 | offset={{months: i}} |
| 53 | /> |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | return components; |
| 58 | }, [visibleDuration, state]); |
| 59 | |
| 60 | return ( |
| 61 | <div {...calendarProps}> |
| 62 | <div style={{textAlign: 'center'}} data-testid={'range'}> |
| 63 | {calendarProps['aria-label']} |
| 64 | </div> |
| 65 | <div |
| 66 | style={{display: 'grid', gridTemplateColumns: `repeat(${grids.length}, 1fr)`, gap: '1em'}}> |
| 67 | {grids} |
| 68 | </div> |
| 69 | <div> |
| 70 | <Button variant={'secondary'} {...prevButtonProps}> |
| 71 | prev |
| 72 | </Button> |
| 73 | <Button variant={'secondary'} {...nextButtonProps}> |
| 74 | next |
| 75 | </Button> |
| 76 | </div> |
| 77 | </div> |
| 78 | ); |
| 79 | } |
| 80 | |
| 81 | function CalendarGrid({ |
| 82 | state, |
nothing calls this directly
no test coverage detected