({errorMessage, ...props}: CalendarProps<T>)
| 38 | } |
| 39 | |
| 40 | export function Calendar<T extends DateValue>({errorMessage, ...props}: CalendarProps<T>) { |
| 41 | let {direction} = useLocale(); |
| 42 | let months = props.visibleDuration?.months || 1; |
| 43 | return ( |
| 44 | <AriaCalendar |
| 45 | {...props} |
| 46 | className={composeTailwindRenderProps( |
| 47 | props.className, |
| 48 | 'flex font-sans w-full max-w-fit overflow-auto gap-3' |
| 49 | )}> |
| 50 | {Array.from({length: months}, (_, i) => ( |
| 51 | <div key={i} className="@container flex flex-col w-[calc(9*var(--spacing)*7)]"> |
| 52 | <header className="flex items-center mb-4"> |
| 53 | {i === 0 && ( |
| 54 | <Button variant="quiet" slot="previous"> |
| 55 | {direction === 'rtl' ? ( |
| 56 | <ChevronRight aria-hidden size={18} /> |
| 57 | ) : ( |
| 58 | <ChevronLeft aria-hidden size={18} /> |
| 59 | )} |
| 60 | </Button> |
| 61 | )} |
| 62 | <CalendarHeading |
| 63 | offset={{months: i}} |
| 64 | className="flex-1 font-sans font-semibold [font-variation-settings:normal] text-base text-center mx-2 my-0 text-neutral-900 dark:text-neutral-200" |
| 65 | /> |
| 66 | {i === months - 1 && ( |
| 67 | <Button variant="quiet" slot="next"> |
| 68 | {direction === 'rtl' ? ( |
| 69 | <ChevronLeft aria-hidden size={18} /> |
| 70 | ) : ( |
| 71 | <ChevronRight aria-hidden size={18} /> |
| 72 | )} |
| 73 | </Button> |
| 74 | )} |
| 75 | </header> |
| 76 | <CalendarGrid offset={{months: i}} className="border-spacing-0"> |
| 77 | <CalendarGridHeader /> |
| 78 | <CalendarGridBody> |
| 79 | {date => <CalendarCell date={date} className={cellStyles} />} |
| 80 | </CalendarGridBody> |
| 81 | </CalendarGrid> |
| 82 | </div> |
| 83 | ))} |
| 84 | {errorMessage && ( |
| 85 | <Text slot="errorMessage" className="text-sm text-red-600"> |
| 86 | {errorMessage} |
| 87 | </Text> |
| 88 | )} |
| 89 | </AriaCalendar> |
| 90 | ); |
| 91 | } |
| 92 | |
| 93 | export function CalendarGridHeader() { |
| 94 | return ( |
nothing calls this directly
no test coverage detected