({
state,
visibleDuration,
offset = {}
}: {
state: CalendarState | RangeCalendarState;
visibleDuration: DateDuration;
offset?: DateDuration;
})
| 79 | } |
| 80 | |
| 81 | function CalendarGrid({ |
| 82 | state, |
| 83 | visibleDuration, |
| 84 | offset = {} |
| 85 | }: { |
| 86 | state: CalendarState | RangeCalendarState; |
| 87 | visibleDuration: DateDuration; |
| 88 | offset?: DateDuration; |
| 89 | }) { |
| 90 | let {locale} = useLocale(); |
| 91 | let {gridProps, weeksInMonth} = useCalendarGrid({}, state); |
| 92 | |
| 93 | let weeks = visibleDuration.weeks ?? 1; |
| 94 | let startDate = state.visibleRange.start.add(offset); |
| 95 | if (visibleDuration.months) { |
| 96 | weeks = weeksInMonth; |
| 97 | startDate = startOfWeek(startDate, locale); |
| 98 | } |
| 99 | return ( |
| 100 | <div {...gridProps}> |
| 101 | {[...new Array(weeks).keys()].map(weekIndex => ( |
| 102 | <div key={weekIndex} role="row"> |
| 103 | {[...new Array(visibleDuration.days ?? 7).keys()].map(dayIndex => ( |
| 104 | <Cell |
| 105 | key={dayIndex} |
| 106 | state={state} |
| 107 | date={startDate.add({weeks: weekIndex, days: dayIndex})} |
| 108 | /> |
| 109 | ))} |
| 110 | </div> |
| 111 | ))} |
| 112 | </div> |
| 113 | ); |
| 114 | } |
| 115 | |
| 116 | function Cell(props) { |
| 117 | let ref = useRef<HTMLSpanElement | null>(null); |
nothing calls this directly
no test coverage detected