MCPcopy Create free account
hub / github.com/adobe/react-spectrum / CalendarGrid

Function CalendarGrid

packages/react-aria/stories/calendar/Example.tsx:81–114  ·  view source on GitHub ↗
({
  state,
  visibleDuration,
  offset = {}
}: {
  state: CalendarState | RangeCalendarState;
  visibleDuration: DateDuration;
  offset?: DateDuration;
})

Source from the content-addressed store, hash-verified

79}
80
81function 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
116function Cell(props) {
117 let ref = useRef<HTMLSpanElement | null>(null);

Callers

nothing calls this directly

Calls 4

useLocaleFunction · 0.90
useCalendarGridFunction · 0.90
startOfWeekFunction · 0.90
addMethod · 0.65

Tested by

no test coverage detected