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

Function useCalendarGrid

packages/react-aria/src/calendar/useCalendarGrid.ts:70–199  ·  view source on GitHub ↗
(
  props: AriaCalendarGridProps,
  state: CalendarState<CalendarSelectionMode> | RangeCalendarState
)

Source from the content-addressed store, hash-verified

68 * can be keyboard navigated and selected by the user.
69 */
70export function useCalendarGrid(
71 props: AriaCalendarGridProps,
72 state: CalendarState<CalendarSelectionMode> | RangeCalendarState
73): CalendarGridAria {
74 let {
75 startDate = state.visibleRange.start,
76 endDate = state.visibleRange.end,
77 firstDayOfWeek
78 } = props;
79
80 let {direction} = useLocale();
81
82 let {keyboardProps} = useKeyboard({
83 shortcuts: {
84 End: () => {
85 state.focusSectionEnd();
86 },
87 Home: () => {
88 state.focusSectionStart();
89 },
90 Escape: () => {
91 // Cancel the selection.
92 if ('setAnchorDate' in state) {
93 state.setAnchorDate(null);
94 }
95 return false; // TODO: is this really correct? or should it return true when we cancel and only propagate if there's nothing to do
96 }
97 }
98 });
99
100 let {keyboardProps: repeatKeyboardProps} = useKeyboard({
101 shortcuts: {
102 Enter: () => {
103 state.selectFocusedDate();
104 },
105 ' ': () => {
106 state.selectFocusedDate();
107 },
108 PageUp: () => {
109 state.focusPreviousSection();
110 },
111 'Shift+PageUp': () => {
112 state.focusPreviousSection(true);
113 },
114 PageDown: () => {
115 state.focusNextSection();
116 },
117 'Shift+PageDown': () => {
118 state.focusNextSection(true);
119 },
120 ArrowLeft: () => {
121 if (direction === 'rtl') {
122 state.focusNextDay();
123 } else {
124 state.focusPreviousDay();
125 }
126 },
127 ArrowUp: () => {

Callers 6

CalendarGridFunction · 0.90
Calendar.tsxFile · 0.90
CalendarMonthFunction · 0.90
CalendarGridFunction · 0.90
CalendarGridFunction · 0.85

Calls 15

useLocaleFunction · 0.90
useKeyboardFunction · 0.90
useLabelsFunction · 0.90
useDateFormatterFunction · 0.90
startOfWeekFunction · 0.90
todayFunction · 0.90
mergePropsFunction · 0.90
focusSectionEndMethod · 0.80
focusSectionStartMethod · 0.80
setAnchorDateMethod · 0.80
selectFocusedDateMethod · 0.80

Tested by

no test coverage detected