( props: AriaCalendarGridProps, state: CalendarState<CalendarSelectionMode> | RangeCalendarState )
| 68 | * can be keyboard navigated and selected by the user. |
| 69 | */ |
| 70 | export 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: () => { |
no test coverage detected