@octanejs/aria 0.0.40 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE-2.0 +201 -0
- package/README.md +20 -7
- package/UPSTREAM.md +108 -0
- package/package.json +10 -6
- package/src/calendar/useCalendar.tsx +36 -0
- package/src/calendar/useCalendarBase.tsx +142 -0
- package/src/calendar/useCalendarCell.tsx +416 -0
- package/src/calendar/useCalendarGrid.tsx +202 -0
- package/src/calendar/useCalendarHeading.tsx +85 -0
- package/src/calendar/useCalendarMonthPicker.tsx +92 -0
- package/src/calendar/useCalendarYearPicker.tsx +127 -0
- package/src/calendar/useRangeCalendar.tsx +121 -0
- package/src/calendar/utils.tsx +183 -0
- package/src/color/useColorArea.tsx +599 -0
- package/src/color/useColorAreaGradient.tsx +157 -0
- package/src/color/useColorChannelField.tsx +53 -0
- package/src/color/useColorField.tsx +170 -0
- package/src/color/useColorSlider.tsx +177 -0
- package/src/color/useColorSwatch.tsx +83 -0
- package/src/color/useColorWheel.tsx +401 -0
- package/src/compat/react.ts +111 -0
- package/src/components/Calendar.tsx +842 -0
- package/src/components/ColorArea.tsx +120 -0
- package/src/components/ColorField.tsx +304 -0
- package/src/components/ColorPicker.tsx +86 -0
- package/src/components/ColorSlider.tsx +144 -0
- package/src/components/ColorSwatch.tsx +72 -0
- package/src/components/ColorSwatchPicker.tsx +176 -0
- package/src/components/ColorThumb.tsx +140 -0
- package/src/components/ColorWheel.tsx +163 -0
- package/src/components/DateField.tsx +580 -0
- package/src/components/DatePicker.tsx +386 -0
- package/src/components/DropZone.tsx +181 -0
- package/src/components/FileTrigger.tsx +96 -0
- package/src/components/GridLayout.tsx +33 -0
- package/src/components/HiddenDateInput.tsx +169 -0
- package/src/components/TableLayout.tsx +39 -0
- package/src/components/Toast.tsx +336 -0
- package/src/components/Virtualizer.tsx +219 -0
- package/src/components/index.ts +257 -7
- package/src/components/useDragAndDrop.tsx +221 -0
- package/src/components/utils.ts +12 -89
- package/src/datepicker/useDateField.tsx +272 -0
- package/src/datepicker/useDatePicker.tsx +229 -0
- package/src/datepicker/useDatePickerGroup.tsx +147 -0
- package/src/datepicker/useDateRangePicker.tsx +288 -0
- package/src/datepicker/useDateSegment.tsx +439 -0
- package/src/datepicker/useDisplayNames.tsx +53 -0
- package/src/dnd/DragManager.tsx +718 -0
- package/src/dnd/DragPreview.tsx +100 -0
- package/src/dnd/DropTargetKeyboardNavigation.tsx +317 -0
- package/src/dnd/ListDropTargetDelegate.tsx +215 -0
- package/src/dnd/constants.tsx +93 -0
- package/src/dnd/useAutoScroll.tsx +116 -0
- package/src/dnd/useClipboard.tsx +160 -0
- package/src/dnd/useDrag.tsx +437 -0
- package/src/dnd/useDraggableCollection.tsx +35 -0
- package/src/dnd/useDraggableItem.tsx +168 -0
- package/src/dnd/useDrop.tsx +518 -0
- package/src/dnd/useDropIndicator.tsx +129 -0
- package/src/dnd/useDroppableCollection.tsx +808 -0
- package/src/dnd/useDroppableItem.tsx +99 -0
- package/src/dnd/useVirtualDrop.tsx +52 -0
- package/src/dnd/utils.tsx +430 -0
- package/src/intl/calendar/ar-AE.json +14 -0
- package/src/intl/calendar/bg-BG.json +14 -0
- package/src/intl/calendar/cs-CZ.json +14 -0
- package/src/intl/calendar/da-DK.json +14 -0
- package/src/intl/calendar/de-DE.json +14 -0
- package/src/intl/calendar/el-GR.json +14 -0
- package/src/intl/calendar/en-US.json +14 -0
- package/src/intl/calendar/es-ES.json +14 -0
- package/src/intl/calendar/et-EE.json +14 -0
- package/src/intl/calendar/fi-FI.json +14 -0
- package/src/intl/calendar/fr-FR.json +14 -0
- package/src/intl/calendar/he-IL.json +14 -0
- package/src/intl/calendar/hr-HR.json +14 -0
- package/src/intl/calendar/hu-HU.json +14 -0
- package/src/intl/calendar/index.ts +73 -0
- package/src/intl/calendar/it-IT.json +14 -0
- package/src/intl/calendar/ja-JP.json +14 -0
- package/src/intl/calendar/ko-KR.json +14 -0
- package/src/intl/calendar/lt-LT.json +14 -0
- package/src/intl/calendar/lv-LV.json +14 -0
- package/src/intl/calendar/nb-NO.json +14 -0
- package/src/intl/calendar/nl-NL.json +14 -0
- package/src/intl/calendar/pl-PL.json +14 -0
- package/src/intl/calendar/pt-BR.json +14 -0
- package/src/intl/calendar/pt-PT.json +14 -0
- package/src/intl/calendar/ro-RO.json +14 -0
- package/src/intl/calendar/ru-RU.json +14 -0
- package/src/intl/calendar/sk-SK.json +14 -0
- package/src/intl/calendar/sl-SI.json +14 -0
- package/src/intl/calendar/sr-SP.json +14 -0
- package/src/intl/calendar/sv-SE.json +14 -0
- package/src/intl/calendar/tr-TR.json +14 -0
- package/src/intl/calendar/uk-UA.json +14 -0
- package/src/intl/calendar/zh-CN.json +14 -0
- package/src/intl/calendar/zh-TW.json +14 -0
- package/src/intl/color/ar-AE.json +8 -0
- package/src/intl/color/bg-BG.json +8 -0
- package/src/intl/color/cs-CZ.json +8 -0
- package/src/intl/color/da-DK.json +8 -0
- package/src/intl/color/de-DE.json +8 -0
- package/src/intl/color/el-GR.json +8 -0
- package/src/intl/color/en-US.json +8 -0
- package/src/intl/color/es-ES.json +8 -0
- package/src/intl/color/et-EE.json +8 -0
- package/src/intl/color/fi-FI.json +8 -0
- package/src/intl/color/fr-FR.json +8 -0
- package/src/intl/color/he-IL.json +8 -0
- package/src/intl/color/hr-HR.json +8 -0
- package/src/intl/color/hu-HU.json +8 -0
- package/src/intl/color/index.ts +73 -0
- package/src/intl/color/it-IT.json +8 -0
- package/src/intl/color/ja-JP.json +8 -0
- package/src/intl/color/ko-KR.json +8 -0
- package/src/intl/color/lt-LT.json +8 -0
- package/src/intl/color/lv-LV.json +8 -0
- package/src/intl/color/nb-NO.json +8 -0
- package/src/intl/color/nl-NL.json +8 -0
- package/src/intl/color/pl-PL.json +8 -0
- package/src/intl/color/pt-BR.json +8 -0
- package/src/intl/color/pt-PT.json +8 -0
- package/src/intl/color/ro-RO.json +8 -0
- package/src/intl/color/ru-RU.json +8 -0
- package/src/intl/color/sk-SK.json +8 -0
- package/src/intl/color/sl-SI.json +8 -0
- package/src/intl/color/sr-SP.json +8 -0
- package/src/intl/color/sv-SE.json +8 -0
- package/src/intl/color/tr-TR.json +8 -0
- package/src/intl/color/uk-UA.json +8 -0
- package/src/intl/color/zh-CN.json +8 -0
- package/src/intl/color/zh-TW.json +8 -0
- package/src/intl/datepicker/ar-AE.json +18 -0
- package/src/intl/datepicker/bg-BG.json +18 -0
- package/src/intl/datepicker/cs-CZ.json +18 -0
- package/src/intl/datepicker/da-DK.json +18 -0
- package/src/intl/datepicker/de-DE.json +18 -0
- package/src/intl/datepicker/el-GR.json +18 -0
- package/src/intl/datepicker/en-US.json +18 -0
- package/src/intl/datepicker/es-ES.json +18 -0
- package/src/intl/datepicker/et-EE.json +18 -0
- package/src/intl/datepicker/fi-FI.json +18 -0
- package/src/intl/datepicker/fr-FR.json +18 -0
- package/src/intl/datepicker/he-IL.json +18 -0
- package/src/intl/datepicker/hr-HR.json +18 -0
- package/src/intl/datepicker/hu-HU.json +18 -0
- package/src/intl/datepicker/index.ts +73 -0
- package/src/intl/datepicker/it-IT.json +18 -0
- package/src/intl/datepicker/ja-JP.json +18 -0
- package/src/intl/datepicker/ko-KR.json +18 -0
- package/src/intl/datepicker/lt-LT.json +18 -0
- package/src/intl/datepicker/lv-LV.json +18 -0
- package/src/intl/datepicker/nb-NO.json +18 -0
- package/src/intl/datepicker/nl-NL.json +18 -0
- package/src/intl/datepicker/pl-PL.json +18 -0
- package/src/intl/datepicker/pt-BR.json +18 -0
- package/src/intl/datepicker/pt-PT.json +18 -0
- package/src/intl/datepicker/ro-RO.json +18 -0
- package/src/intl/datepicker/ru-RU.json +18 -0
- package/src/intl/datepicker/sk-SK.json +18 -0
- package/src/intl/datepicker/sl-SI.json +18 -0
- package/src/intl/datepicker/sr-SP.json +18 -0
- package/src/intl/datepicker/sv-SE.json +18 -0
- package/src/intl/datepicker/tr-TR.json +18 -0
- package/src/intl/datepicker/uk-UA.json +18 -0
- package/src/intl/datepicker/zh-CN.json +18 -0
- package/src/intl/datepicker/zh-TW.json +18 -0
- package/src/intl/dnd/ar-AE.json +29 -0
- package/src/intl/dnd/bg-BG.json +29 -0
- package/src/intl/dnd/cs-CZ.json +29 -0
- package/src/intl/dnd/da-DK.json +29 -0
- package/src/intl/dnd/de-DE.json +29 -0
- package/src/intl/dnd/el-GR.json +29 -0
- package/src/intl/dnd/en-US.json +29 -0
- package/src/intl/dnd/es-ES.json +29 -0
- package/src/intl/dnd/et-EE.json +29 -0
- package/src/intl/dnd/fi-FI.json +29 -0
- package/src/intl/dnd/fr-FR.json +29 -0
- package/src/intl/dnd/he-IL.json +29 -0
- package/src/intl/dnd/hr-HR.json +29 -0
- package/src/intl/dnd/hu-HU.json +29 -0
- package/src/intl/dnd/index.ts +73 -0
- package/src/intl/dnd/it-IT.json +29 -0
- package/src/intl/dnd/ja-JP.json +29 -0
- package/src/intl/dnd/ko-KR.json +29 -0
- package/src/intl/dnd/lt-LT.json +29 -0
- package/src/intl/dnd/lv-LV.json +29 -0
- package/src/intl/dnd/nb-NO.json +29 -0
- package/src/intl/dnd/nl-NL.json +29 -0
- package/src/intl/dnd/pl-PL.json +29 -0
- package/src/intl/dnd/pt-BR.json +29 -0
- package/src/intl/dnd/pt-PT.json +29 -0
- package/src/intl/dnd/ro-RO.json +29 -0
- package/src/intl/dnd/ru-RU.json +29 -0
- package/src/intl/dnd/sk-SK.json +29 -0
- package/src/intl/dnd/sl-SI.json +29 -0
- package/src/intl/dnd/sr-SP.json +29 -0
- package/src/intl/dnd/sv-SE.json +29 -0
- package/src/intl/dnd/tr-TR.json +29 -0
- package/src/intl/dnd/uk-UA.json +29 -0
- package/src/intl/dnd/zh-CN.json +29 -0
- package/src/intl/dnd/zh-TW.json +29 -0
- package/src/intl/react-aria-components/ar-AE.json +6 -0
- package/src/intl/react-aria-components/bg-BG.json +6 -0
- package/src/intl/react-aria-components/cs-CZ.json +6 -0
- package/src/intl/react-aria-components/da-DK.json +6 -0
- package/src/intl/react-aria-components/de-DE.json +6 -0
- package/src/intl/react-aria-components/el-GR.json +6 -0
- package/src/intl/react-aria-components/en-US.json +6 -0
- package/src/intl/react-aria-components/es-ES.json +6 -0
- package/src/intl/react-aria-components/et-EE.json +6 -0
- package/src/intl/react-aria-components/fi-FI.json +6 -0
- package/src/intl/react-aria-components/fr-FR.json +6 -0
- package/src/intl/react-aria-components/he-IL.json +6 -0
- package/src/intl/react-aria-components/hr-HR.json +6 -0
- package/src/intl/react-aria-components/hu-HU.json +6 -0
- package/src/intl/react-aria-components/index.ts +73 -0
- package/src/intl/react-aria-components/it-IT.json +6 -0
- package/src/intl/react-aria-components/ja-JP.json +6 -0
- package/src/intl/react-aria-components/ko-KR.json +6 -0
- package/src/intl/react-aria-components/lt-LT.json +6 -0
- package/src/intl/react-aria-components/lv-LV.json +6 -0
- package/src/intl/react-aria-components/nb-NO.json +6 -0
- package/src/intl/react-aria-components/nl-NL.json +6 -0
- package/src/intl/react-aria-components/pl-PL.json +6 -0
- package/src/intl/react-aria-components/pt-BR.json +6 -0
- package/src/intl/react-aria-components/pt-PT.json +6 -0
- package/src/intl/react-aria-components/ro-RO.json +6 -0
- package/src/intl/react-aria-components/ru-RU.json +6 -0
- package/src/intl/react-aria-components/sk-SK.json +6 -0
- package/src/intl/react-aria-components/sl-SI.json +6 -0
- package/src/intl/react-aria-components/sr-SP.json +6 -0
- package/src/intl/react-aria-components/sv-SE.json +6 -0
- package/src/intl/react-aria-components/tr-TR.json +6 -0
- package/src/intl/react-aria-components/uk-UA.json +6 -0
- package/src/intl/react-aria-components/zh-CN.json +6 -0
- package/src/intl/react-aria-components/zh-TW.json +6 -0
- package/src/intl/stately-color/ar-AE.json +39 -0
- package/src/intl/stately-color/bg-BG.json +39 -0
- package/src/intl/stately-color/cs-CZ.json +39 -0
- package/src/intl/stately-color/da-DK.json +39 -0
- package/src/intl/stately-color/de-DE.json +39 -0
- package/src/intl/stately-color/el-GR.json +39 -0
- package/src/intl/stately-color/en-US.json +39 -0
- package/src/intl/stately-color/es-ES.json +39 -0
- package/src/intl/stately-color/et-EE.json +39 -0
- package/src/intl/stately-color/fi-FI.json +39 -0
- package/src/intl/stately-color/fr-FR.json +39 -0
- package/src/intl/stately-color/he-IL.json +39 -0
- package/src/intl/stately-color/hr-HR.json +39 -0
- package/src/intl/stately-color/hu-HU.json +39 -0
- package/src/intl/stately-color/index.ts +73 -0
- package/src/intl/stately-color/it-IT.json +39 -0
- package/src/intl/stately-color/ja-JP.json +39 -0
- package/src/intl/stately-color/ko-KR.json +39 -0
- package/src/intl/stately-color/lt-LT.json +39 -0
- package/src/intl/stately-color/lv-LV.json +39 -0
- package/src/intl/stately-color/nb-NO.json +39 -0
- package/src/intl/stately-color/nl-NL.json +39 -0
- package/src/intl/stately-color/pl-PL.json +39 -0
- package/src/intl/stately-color/pt-BR.json +39 -0
- package/src/intl/stately-color/pt-PT.json +39 -0
- package/src/intl/stately-color/ro-RO.json +39 -0
- package/src/intl/stately-color/ru-RU.json +39 -0
- package/src/intl/stately-color/sk-SK.json +39 -0
- package/src/intl/stately-color/sl-SI.json +39 -0
- package/src/intl/stately-color/sr-SP.json +39 -0
- package/src/intl/stately-color/sv-SE.json +39 -0
- package/src/intl/stately-color/tr-TR.json +39 -0
- package/src/intl/stately-color/uk-UA.json +39 -0
- package/src/intl/stately-color/zh-CN.json +39 -0
- package/src/intl/stately-color/zh-TW.json +39 -0
- package/src/intl/toast/ar-AE.json +4 -0
- package/src/intl/toast/bg-BG.json +4 -0
- package/src/intl/toast/cs-CZ.json +4 -0
- package/src/intl/toast/da-DK.json +4 -0
- package/src/intl/toast/de-DE.json +4 -0
- package/src/intl/toast/el-GR.json +4 -0
- package/src/intl/toast/en-US.json +4 -0
- package/src/intl/toast/es-ES.json +4 -0
- package/src/intl/toast/et-EE.json +4 -0
- package/src/intl/toast/fi-FI.json +4 -0
- package/src/intl/toast/fr-FR.json +4 -0
- package/src/intl/toast/he-IL.json +4 -0
- package/src/intl/toast/hr-HR.json +4 -0
- package/src/intl/toast/hu-HU.json +4 -0
- package/src/intl/toast/index.ts +73 -0
- package/src/intl/toast/it-IT.json +4 -0
- package/src/intl/toast/ja-JP.json +4 -0
- package/src/intl/toast/ko-KR.json +4 -0
- package/src/intl/toast/lt-LT.json +4 -0
- package/src/intl/toast/lv-LV.json +4 -0
- package/src/intl/toast/nb-NO.json +4 -0
- package/src/intl/toast/nl-NL.json +4 -0
- package/src/intl/toast/pl-PL.json +4 -0
- package/src/intl/toast/pt-BR.json +4 -0
- package/src/intl/toast/pt-PT.json +4 -0
- package/src/intl/toast/ro-RO.json +4 -0
- package/src/intl/toast/ru-RU.json +4 -0
- package/src/intl/toast/sk-SK.json +4 -0
- package/src/intl/toast/sl-SI.json +4 -0
- package/src/intl/toast/sr-SP.json +4 -0
- package/src/intl/toast/sv-SE.json +4 -0
- package/src/intl/toast/tr-TR.json +4 -0
- package/src/intl/toast/uk-UA.json +4 -0
- package/src/intl/toast/zh-CN.json +4 -0
- package/src/intl/toast/zh-TW.json +4 -0
- package/src/landmark/useLandmark.tsx +569 -0
- package/src/stately/calendar/types.tsx +239 -0
- package/src/stately/calendar/useCalendarState.tsx +527 -0
- package/src/stately/calendar/useRangeCalendarState.tsx +323 -0
- package/src/stately/calendar/utils.tsx +175 -0
- package/src/stately/color/Color.tsx +889 -0
- package/src/stately/color/types.tsx +82 -0
- package/src/stately/color/useColor.tsx +30 -0
- package/src/stately/color/useColorAreaState.tsx +255 -0
- package/src/stately/color/useColorChannelFieldState.tsx +86 -0
- package/src/stately/color/useColorFieldState.tsx +220 -0
- package/src/stately/color/useColorPickerState.tsx +31 -0
- package/src/stately/color/useColorSliderState.tsx +143 -0
- package/src/stately/color/useColorWheelState.tsx +225 -0
- package/src/stately/data/useAsyncList.tsx +382 -0
- package/src/stately/data/useListData.tsx +447 -0
- package/src/stately/data/useTreeData.tsx +603 -0
- package/src/stately/datepicker/IncompleteDate.tsx +427 -0
- package/src/stately/datepicker/placeholders.tsx +116 -0
- package/src/stately/datepicker/types.tsx +169 -0
- package/src/stately/datepicker/useDateFieldState.tsx +564 -0
- package/src/stately/datepicker/useDatePickerState.tsx +244 -0
- package/src/stately/datepicker/useDateRangePickerState.tsx +397 -0
- package/src/stately/datepicker/useTimeFieldState.tsx +123 -0
- package/src/stately/datepicker/utils.tsx +316 -0
- package/src/stately/dnd/useDraggableCollectionState.tsx +191 -0
- package/src/stately/dnd/useDroppableCollectionState.tsx +288 -0
- package/src/stately/layout/GridLayout.tsx +449 -0
- package/src/stately/layout/ListLayout.tsx +872 -0
- package/src/stately/layout/TableLayout.tsx +793 -0
- package/src/stately/layout/WaterfallLayout.tsx +399 -0
- package/src/stately/toast/useToastState.tsx +219 -0
- package/src/stately/virtualizer/Layout.tsx +105 -0
- package/src/stately/virtualizer/LayoutInfo.tsx +127 -0
- package/src/stately/virtualizer/OverscanManager.tsx +56 -0
- package/src/stately/virtualizer/Point.tsx +47 -0
- package/src/stately/virtualizer/Rect.tsx +194 -0
- package/src/stately/virtualizer/ReusableView.tsx +101 -0
- package/src/stately/virtualizer/Size.tsx +48 -0
- package/src/stately/virtualizer/Virtualizer.tsx +408 -0
- package/src/stately/virtualizer/types.tsx +48 -0
- package/src/stately/virtualizer/useVirtualizerState.tsx +138 -0
- package/src/stately/virtualizer/utils.tsx +32 -0
- package/src/textfield/useTextField.ts +3 -0
- package/src/toast/useToast.tsx +105 -0
- package/src/toast/useToastRegion.tsx +223 -0
- package/src/upstream-exports/react-aria/I18nProvider.tsx +17 -0
- package/src/upstream-exports/react-aria/ListDropTargetDelegate.tsx +15 -0
- package/src/upstream-exports/react-aria/PortalProvider.tsx +19 -0
- package/src/upstream-exports/react-aria/SSRProvider.tsx +15 -0
- package/src/upstream-exports/react-aria/VisuallyHidden.tsx +15 -0
- package/src/upstream-exports/react-aria/filterDOMProps.tsx +3 -0
- package/src/upstream-exports/react-aria/mergeProps.tsx +14 -0
- package/src/upstream-exports/react-aria/private/dnd/DragManager.tsx +3 -0
- package/src/upstream-exports/react-aria/private/interactions/PressResponder.tsx +3 -0
- package/src/upstream-exports/react-aria/private/utils/isFocusable.tsx +3 -0
- package/src/upstream-exports/react-aria/private/utils/shadowdom/DOMFunctions.tsx +8 -0
- package/src/upstream-exports/react-aria/private/utils/useId.tsx +3 -0
- package/src/upstream-exports/react-aria/private/utils/useLabels.tsx +3 -0
- package/src/upstream-exports/react-aria/private/virtualizer/ScrollView.tsx +3 -0
- package/src/upstream-exports/react-aria/private/virtualizer/VirtualizerItem.tsx +3 -0
- package/src/upstream-exports/react-aria/useButton.tsx +22 -0
- package/src/upstream-exports/react-aria/useCalendar.tsx +37 -0
- package/src/upstream-exports/react-aria/useClipboard.tsx +23 -0
- package/src/upstream-exports/react-aria/useColorArea.tsx +19 -0
- package/src/upstream-exports/react-aria/useColorField.tsx +20 -0
- package/src/upstream-exports/react-aria/useColorSlider.tsx +19 -0
- package/src/upstream-exports/react-aria/useColorSwatch.tsx +15 -0
- package/src/upstream-exports/react-aria/useColorWheel.tsx +19 -0
- package/src/upstream-exports/react-aria/useDateField.tsx +23 -0
- package/src/upstream-exports/react-aria/useDatePicker.tsx +17 -0
- package/src/upstream-exports/react-aria/useDateRangePicker.tsx +24 -0
- package/src/upstream-exports/react-aria/useDraggableCollection.tsx +31 -0
- package/src/upstream-exports/react-aria/useDrop.tsx +33 -0
- package/src/upstream-exports/react-aria/useDroppableCollection.tsx +47 -0
- package/src/upstream-exports/react-aria/useFocusRing.tsx +16 -0
- package/src/upstream-exports/react-aria/useHover.tsx +17 -0
- package/src/upstream-exports/react-aria/useLocalizedStringFormatter.tsx +19 -0
- package/src/upstream-exports/react-aria/useObjectRef.tsx +14 -0
- package/src/upstream-exports/react-aria/useRangeCalendar.tsx +38 -0
- package/src/upstream-exports/react-aria/useTimeField.tsx +23 -0
- package/src/upstream-exports/react-aria/useToast.tsx +18 -0
- package/src/upstream-exports/react-stately/Color.tsx +23 -0
- package/src/upstream-exports/react-stately/private/form/useFormValidationState.tsx +11 -0
- package/src/upstream-exports/react-stately/useCalendarState.tsx +24 -0
- package/src/upstream-exports/react-stately/useColorAreaState.tsx +24 -0
- package/src/upstream-exports/react-stately/useColorFieldState.tsx +22 -0
- package/src/upstream-exports/react-stately/useColorPickerState.tsx +25 -0
- package/src/upstream-exports/react-stately/useColorSliderState.tsx +25 -0
- package/src/upstream-exports/react-stately/useColorWheelState.tsx +24 -0
- package/src/upstream-exports/react-stately/useDateFieldState.tsx +29 -0
- package/src/upstream-exports/react-stately/useDatePickerState.tsx +25 -0
- package/src/upstream-exports/react-stately/useDateRangePickerState.tsx +26 -0
- package/src/upstream-exports/react-stately/useDraggableCollectionState.tsx +19 -0
- package/src/upstream-exports/react-stately/useDroppableCollectionState.tsx +19 -0
- package/src/upstream-exports/react-stately/useRangeCalendarState.tsx +27 -0
- package/src/upstream-exports/react-stately/useTimeFieldState.tsx +26 -0
- package/src/upstream-exports/react-stately/useToastState.tsx +21 -0
- package/src/upstream-exports/react-stately/useVirtualizerState.tsx +22 -0
- package/src/utils/useLoadMore.tsx +89 -0
- package/src/virtualizer/ScrollView.tsx +401 -0
- package/src/virtualizer/Virtualizer.tsx +147 -0
- package/src/virtualizer/VirtualizerItem.tsx +108 -0
- package/src/virtualizer/useVirtualizerItem.tsx +57 -0
- package/src/virtualizer/utils.tsx +105 -0
- package/LICENSE +0 -21
- package/src/components/useDragAndDrop.ts +0 -164
|
@@ -0,0 +1,842 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-aria-components/src/Calendar.tsx).
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
import {
|
|
15
|
+
CalendarHeadingProps as AriaCalendarHeadingProps,
|
|
16
|
+
CalendarMonthPickerProps as AriaCalendarMonthPickerProps,
|
|
17
|
+
AriaCalendarProps,
|
|
18
|
+
CalendarYearPickerProps as AriaCalendarYearPickerProps,
|
|
19
|
+
CalendarMonthPickerAria,
|
|
20
|
+
CalendarYearPickerAria,
|
|
21
|
+
useCalendar,
|
|
22
|
+
useCalendarCell,
|
|
23
|
+
useCalendarGrid,
|
|
24
|
+
useCalendarHeading,
|
|
25
|
+
useCalendarMonthPicker,
|
|
26
|
+
useCalendarYearPicker,
|
|
27
|
+
} from '../upstream-exports/react-aria/useCalendar';
|
|
28
|
+
import {
|
|
29
|
+
AriaRangeCalendarProps,
|
|
30
|
+
useRangeCalendar,
|
|
31
|
+
} from '../upstream-exports/react-aria/useRangeCalendar';
|
|
32
|
+
import { ButtonContext } from './Button';
|
|
33
|
+
import {
|
|
34
|
+
CalendarDate,
|
|
35
|
+
CalendarIdentifier,
|
|
36
|
+
createCalendar,
|
|
37
|
+
DateDuration,
|
|
38
|
+
endOfMonth,
|
|
39
|
+
Calendar as ICalendar,
|
|
40
|
+
isSameDay,
|
|
41
|
+
isSameMonth,
|
|
42
|
+
isToday,
|
|
43
|
+
} from '@internationalized/date';
|
|
44
|
+
import {
|
|
45
|
+
CalendarSelectionMode,
|
|
46
|
+
CalendarState,
|
|
47
|
+
} from '../upstream-exports/react-stately/useCalendarState';
|
|
48
|
+
import {
|
|
49
|
+
ClassNameOrFunction,
|
|
50
|
+
ContextValue,
|
|
51
|
+
dom,
|
|
52
|
+
DOMProps,
|
|
53
|
+
DOMRenderProps,
|
|
54
|
+
Provider,
|
|
55
|
+
RenderProps,
|
|
56
|
+
SlotProps,
|
|
57
|
+
StyleProps,
|
|
58
|
+
useContextProps,
|
|
59
|
+
useRenderProps,
|
|
60
|
+
useSlottedContext,
|
|
61
|
+
} from './utils';
|
|
62
|
+
import {
|
|
63
|
+
DateValue,
|
|
64
|
+
useRangeCalendarState,
|
|
65
|
+
} from '../upstream-exports/react-stately/useRangeCalendarState';
|
|
66
|
+
import {
|
|
67
|
+
DOMAttributes,
|
|
68
|
+
FocusableElement,
|
|
69
|
+
forwardRefType,
|
|
70
|
+
GlobalDOMAttributes,
|
|
71
|
+
HoverEvents,
|
|
72
|
+
} from '@react-types/shared';
|
|
73
|
+
import { filterDOMProps } from '../upstream-exports/react-aria/filterDOMProps';
|
|
74
|
+
import { Heading, HeadingContext, HeadingProps } from './Heading';
|
|
75
|
+
import { mergeProps } from '../upstream-exports/react-aria/mergeProps';
|
|
76
|
+
import { RangeCalendarState } from '../upstream-exports/react-stately/useRangeCalendarState';
|
|
77
|
+
import React, {
|
|
78
|
+
createContext,
|
|
79
|
+
ForwardedRef,
|
|
80
|
+
forwardRef,
|
|
81
|
+
JSX,
|
|
82
|
+
ReactElement,
|
|
83
|
+
useContext,
|
|
84
|
+
useRef,
|
|
85
|
+
} from '../compat/react';
|
|
86
|
+
import { TextContext } from './Text';
|
|
87
|
+
import { useCalendarState } from '../upstream-exports/react-stately/useCalendarState';
|
|
88
|
+
import { useFocusRing } from '../upstream-exports/react-aria/useFocusRing';
|
|
89
|
+
import { useHover } from '../upstream-exports/react-aria/useHover';
|
|
90
|
+
import { useLocale } from '../upstream-exports/react-aria/I18nProvider';
|
|
91
|
+
import { VisuallyHidden } from '../upstream-exports/react-aria/VisuallyHidden';
|
|
92
|
+
|
|
93
|
+
export interface CalendarRenderProps<M extends CalendarSelectionMode = 'single'> {
|
|
94
|
+
/**
|
|
95
|
+
* Whether the calendar is disabled.
|
|
96
|
+
*
|
|
97
|
+
* @selector [data-disabled]
|
|
98
|
+
*/
|
|
99
|
+
isDisabled: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* State of the calendar.
|
|
102
|
+
*/
|
|
103
|
+
state: CalendarState<M>;
|
|
104
|
+
/**
|
|
105
|
+
* Whether the calendar is invalid.
|
|
106
|
+
*
|
|
107
|
+
* @selector [data-invalid]
|
|
108
|
+
*/
|
|
109
|
+
isInvalid: boolean;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface RangeCalendarRenderProps extends Omit<CalendarRenderProps, 'state'> {
|
|
113
|
+
/**
|
|
114
|
+
* State of the range calendar.
|
|
115
|
+
*/
|
|
116
|
+
state: RangeCalendarState;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface CalendarProps<T extends DateValue, M extends CalendarSelectionMode = 'single'>
|
|
120
|
+
extends
|
|
121
|
+
Omit<AriaCalendarProps<T, M>, 'errorMessage' | 'validationState'>,
|
|
122
|
+
RenderProps<CalendarRenderProps<M>, 'div'>,
|
|
123
|
+
SlotProps,
|
|
124
|
+
GlobalDOMAttributes<HTMLDivElement> {
|
|
125
|
+
/**
|
|
126
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
127
|
+
* element. A function may be provided to compute the class based on component state.
|
|
128
|
+
*
|
|
129
|
+
* @default 'react-aria-Calendar'
|
|
130
|
+
*/
|
|
131
|
+
className?: ClassNameOrFunction<CalendarRenderProps<M>>;
|
|
132
|
+
/**
|
|
133
|
+
* The amount of days that will be displayed at once. This affects how pagination works.
|
|
134
|
+
*
|
|
135
|
+
* @default { months: 1 }
|
|
136
|
+
*/
|
|
137
|
+
visibleDuration?: DateDuration;
|
|
138
|
+
/**
|
|
139
|
+
* A function to create a new
|
|
140
|
+
* [Calendar](https://react-spectrum.adobe.com/internationalized/date/Calendar.html) object for a
|
|
141
|
+
* given calendar identifier. If not provided, the `createCalendar` function from
|
|
142
|
+
* `@internationalized/date` will be used.
|
|
143
|
+
*/
|
|
144
|
+
createCalendar?: (identifier: CalendarIdentifier) => ICalendar;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface RangeCalendarProps<T extends DateValue>
|
|
148
|
+
extends
|
|
149
|
+
Omit<AriaRangeCalendarProps<T>, 'errorMessage' | 'validationState'>,
|
|
150
|
+
RenderProps<RangeCalendarRenderProps, 'div'>,
|
|
151
|
+
SlotProps,
|
|
152
|
+
GlobalDOMAttributes<HTMLDivElement> {
|
|
153
|
+
/**
|
|
154
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
155
|
+
* element. A function may be provided to compute the class based on component state.
|
|
156
|
+
*
|
|
157
|
+
* @default 'react-aria-RangeCalendar'
|
|
158
|
+
*/
|
|
159
|
+
className?: ClassNameOrFunction<RangeCalendarRenderProps>;
|
|
160
|
+
/**
|
|
161
|
+
* The amount of days that will be displayed at once. This affects how pagination works.
|
|
162
|
+
*
|
|
163
|
+
* @default { months: 1 }
|
|
164
|
+
*/
|
|
165
|
+
visibleDuration?: DateDuration;
|
|
166
|
+
/**
|
|
167
|
+
* A function to create a new
|
|
168
|
+
* [Calendar](https://react-spectrum.adobe.com/internationalized/date/Calendar.html) object for a
|
|
169
|
+
* given calendar identifier. If not provided, the `createCalendar` function from
|
|
170
|
+
* `@internationalized/date` will be used.
|
|
171
|
+
*/
|
|
172
|
+
createCalendar?: (identifier: CalendarIdentifier) => ICalendar;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export const CalendarContext =
|
|
176
|
+
createContext<ContextValue<CalendarProps<any, CalendarSelectionMode>, HTMLDivElement>>(null);
|
|
177
|
+
export const RangeCalendarContext =
|
|
178
|
+
createContext<ContextValue<RangeCalendarProps<any>, HTMLDivElement>>(null);
|
|
179
|
+
export const CalendarStateContext = createContext<CalendarState<CalendarSelectionMode> | null>(
|
|
180
|
+
null,
|
|
181
|
+
);
|
|
182
|
+
export const RangeCalendarStateContext = createContext<RangeCalendarState | null>(null);
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* A calendar displays one or more date grids and allows users to select a single date.
|
|
186
|
+
*/
|
|
187
|
+
export const Calendar = /*#__PURE__*/ (forwardRef as any)(function Calendar<
|
|
188
|
+
T extends DateValue,
|
|
189
|
+
M extends CalendarSelectionMode = 'single',
|
|
190
|
+
>(props: CalendarProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {
|
|
191
|
+
[props, ref] = useContextProps(props, ref, CalendarContext);
|
|
192
|
+
let { locale } = useLocale();
|
|
193
|
+
let state = useCalendarState({
|
|
194
|
+
...props,
|
|
195
|
+
locale,
|
|
196
|
+
createCalendar: props.createCalendar || createCalendar,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
let { calendarProps, prevButtonProps, nextButtonProps, errorMessageProps, title } = useCalendar(
|
|
200
|
+
props,
|
|
201
|
+
state,
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
let renderProps = useRenderProps({
|
|
205
|
+
...props,
|
|
206
|
+
values: {
|
|
207
|
+
state,
|
|
208
|
+
isDisabled: props.isDisabled || false,
|
|
209
|
+
isInvalid: state.isValueInvalid,
|
|
210
|
+
},
|
|
211
|
+
defaultClassName: 'react-aria-Calendar',
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
let DOMProps = filterDOMProps(props, { global: true });
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<dom.div
|
|
218
|
+
{...mergeProps(DOMProps, renderProps, calendarProps)}
|
|
219
|
+
ref={ref}
|
|
220
|
+
slot={props.slot || undefined}
|
|
221
|
+
data-disabled={props.isDisabled || undefined}
|
|
222
|
+
data-invalid={state.isValueInvalid || undefined}
|
|
223
|
+
>
|
|
224
|
+
<Provider
|
|
225
|
+
values={[
|
|
226
|
+
[
|
|
227
|
+
ButtonContext,
|
|
228
|
+
{
|
|
229
|
+
slots: {
|
|
230
|
+
previous: prevButtonProps,
|
|
231
|
+
next: nextButtonProps,
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
[HeadingContext, { 'aria-hidden': true, level: 2, children: title }],
|
|
236
|
+
[CalendarStateContext, state],
|
|
237
|
+
[CalendarContext, props as any],
|
|
238
|
+
[
|
|
239
|
+
TextContext,
|
|
240
|
+
{
|
|
241
|
+
slots: {
|
|
242
|
+
errorMessage: errorMessageProps,
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
]}
|
|
247
|
+
>
|
|
248
|
+
{/* Add a screen reader only description of the entire visible range rather than
|
|
249
|
+
* a separate heading above each month grid. This is placed first in the DOM order
|
|
250
|
+
* so that it is the first thing a touch screen reader user encounters.
|
|
251
|
+
* In addition, VoiceOver on iOS does not announce the aria-label of the grid
|
|
252
|
+
* elements, so the aria-label of the Calendar is included here as well. */}
|
|
253
|
+
<VisuallyHidden>
|
|
254
|
+
<h2>{calendarProps['aria-label']}</h2>
|
|
255
|
+
</VisuallyHidden>
|
|
256
|
+
{renderProps.children}
|
|
257
|
+
{/* For touch screen readers, add a visually hidden next button after the month grid
|
|
258
|
+
* so it's easy to navigate after reaching the end without going all the way
|
|
259
|
+
* back to the start of the month. */}
|
|
260
|
+
<VisuallyHidden>
|
|
261
|
+
<button
|
|
262
|
+
aria-label={nextButtonProps['aria-label']}
|
|
263
|
+
disabled={nextButtonProps.isDisabled}
|
|
264
|
+
onClick={() => state.focusNextPage()}
|
|
265
|
+
tabIndex={-1}
|
|
266
|
+
/>
|
|
267
|
+
</VisuallyHidden>
|
|
268
|
+
</Provider>
|
|
269
|
+
</dom.div>
|
|
270
|
+
);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* A range calendar displays one or more date grids and allows users to select a contiguous range of
|
|
275
|
+
* dates.
|
|
276
|
+
*/
|
|
277
|
+
export const RangeCalendar = /*#__PURE__*/ (forwardRef as any)(function RangeCalendar<
|
|
278
|
+
T extends DateValue,
|
|
279
|
+
>(props: RangeCalendarProps<T>, ref: ForwardedRef<HTMLDivElement>) {
|
|
280
|
+
[props, ref] = useContextProps(props, ref, RangeCalendarContext);
|
|
281
|
+
let { locale } = useLocale();
|
|
282
|
+
let state = useRangeCalendarState({
|
|
283
|
+
...props,
|
|
284
|
+
locale,
|
|
285
|
+
createCalendar: props.createCalendar || createCalendar,
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
let { calendarProps, prevButtonProps, nextButtonProps, errorMessageProps, title } =
|
|
289
|
+
useRangeCalendar(props, state, ref);
|
|
290
|
+
|
|
291
|
+
let renderProps = useRenderProps({
|
|
292
|
+
...props,
|
|
293
|
+
values: {
|
|
294
|
+
state,
|
|
295
|
+
isDisabled: props.isDisabled || false,
|
|
296
|
+
isInvalid: state.isValueInvalid,
|
|
297
|
+
},
|
|
298
|
+
defaultClassName: 'react-aria-RangeCalendar',
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
let DOMProps = filterDOMProps(props, { global: true });
|
|
302
|
+
|
|
303
|
+
return (
|
|
304
|
+
<dom.div
|
|
305
|
+
{...mergeProps(renderProps, DOMProps, calendarProps)}
|
|
306
|
+
ref={ref}
|
|
307
|
+
slot={props.slot || undefined}
|
|
308
|
+
data-disabled={props.isDisabled || undefined}
|
|
309
|
+
data-invalid={state.isValueInvalid || undefined}
|
|
310
|
+
>
|
|
311
|
+
<Provider
|
|
312
|
+
values={[
|
|
313
|
+
[
|
|
314
|
+
ButtonContext,
|
|
315
|
+
{
|
|
316
|
+
slots: {
|
|
317
|
+
previous: prevButtonProps,
|
|
318
|
+
next: nextButtonProps,
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
],
|
|
322
|
+
[HeadingContext, { 'aria-hidden': true, level: 2, children: title }],
|
|
323
|
+
[RangeCalendarStateContext, state],
|
|
324
|
+
[RangeCalendarContext, props as RangeCalendarProps<any>],
|
|
325
|
+
[
|
|
326
|
+
TextContext,
|
|
327
|
+
{
|
|
328
|
+
slots: {
|
|
329
|
+
errorMessage: errorMessageProps,
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
]}
|
|
334
|
+
>
|
|
335
|
+
{/* Add a screen reader only description of the entire visible range rather than
|
|
336
|
+
* a separate heading above each month grid. This is placed first in the DOM order
|
|
337
|
+
* so that it is the first thing a touch screen reader user encounters.
|
|
338
|
+
* In addition, VoiceOver on iOS does not announce the aria-label of the grid
|
|
339
|
+
* elements, so the aria-label of the Calendar is included here as well. */}
|
|
340
|
+
<VisuallyHidden>
|
|
341
|
+
<h2>{calendarProps['aria-label']}</h2>
|
|
342
|
+
</VisuallyHidden>
|
|
343
|
+
{renderProps.children}
|
|
344
|
+
{/* For touch screen readers, add a visually hidden next button after the month grid
|
|
345
|
+
* so it's easy to navigate after reaching the end without going all the way
|
|
346
|
+
* back to the start of the month. */}
|
|
347
|
+
<VisuallyHidden>
|
|
348
|
+
<button
|
|
349
|
+
aria-label={nextButtonProps['aria-label']}
|
|
350
|
+
disabled={nextButtonProps.isDisabled}
|
|
351
|
+
onClick={() => state.focusNextPage()}
|
|
352
|
+
tabIndex={-1}
|
|
353
|
+
/>
|
|
354
|
+
</VisuallyHidden>
|
|
355
|
+
</Provider>
|
|
356
|
+
</dom.div>
|
|
357
|
+
);
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
export interface CalendarCellRenderProps {
|
|
361
|
+
/** The date that the cell represents. */
|
|
362
|
+
date: CalendarDate;
|
|
363
|
+
/** The day number formatted according to the current locale. */
|
|
364
|
+
formattedDate: string;
|
|
365
|
+
/**
|
|
366
|
+
* Whether the cell is currently hovered with a mouse.
|
|
367
|
+
*
|
|
368
|
+
* @selector [data-hovered]
|
|
369
|
+
*/
|
|
370
|
+
isHovered: boolean;
|
|
371
|
+
/**
|
|
372
|
+
* Whether the cell is currently being pressed.
|
|
373
|
+
*
|
|
374
|
+
* @selector [data-pressed]
|
|
375
|
+
*/
|
|
376
|
+
isPressed: boolean;
|
|
377
|
+
/**
|
|
378
|
+
* Whether the cell is selected.
|
|
379
|
+
*
|
|
380
|
+
* @selector [data-selected]
|
|
381
|
+
*/
|
|
382
|
+
isSelected: boolean;
|
|
383
|
+
/**
|
|
384
|
+
* Whether the cell is the first date in a range selection.
|
|
385
|
+
*
|
|
386
|
+
* @selector [data-selection-start]
|
|
387
|
+
*/
|
|
388
|
+
isSelectionStart: boolean;
|
|
389
|
+
/**
|
|
390
|
+
* Whether the cell is the last date in a range selection.
|
|
391
|
+
*
|
|
392
|
+
* @selector [data-selection-end]
|
|
393
|
+
*/
|
|
394
|
+
isSelectionEnd: boolean;
|
|
395
|
+
/**
|
|
396
|
+
* Whether the cell is focused.
|
|
397
|
+
*
|
|
398
|
+
* @selector [data-focused]
|
|
399
|
+
*/
|
|
400
|
+
isFocused: boolean;
|
|
401
|
+
/**
|
|
402
|
+
* Whether the cell is keyboard focused.
|
|
403
|
+
*
|
|
404
|
+
* @selector [data-focus-visible]
|
|
405
|
+
*/
|
|
406
|
+
isFocusVisible: boolean;
|
|
407
|
+
/**
|
|
408
|
+
* Whether the cell is disabled, according to the calendar's `minValue`, `maxValue`, and
|
|
409
|
+
* `isDisabled` props. Disabled dates are not focusable, and cannot be selected by the user. They
|
|
410
|
+
* are typically displayed with a dimmed appearance.
|
|
411
|
+
*
|
|
412
|
+
* @selector [data-disabled]
|
|
413
|
+
*/
|
|
414
|
+
isDisabled: boolean;
|
|
415
|
+
/**
|
|
416
|
+
* Whether the cell is outside the visible range of the calendar.
|
|
417
|
+
* For example, dates before the first day of a month in the same week.
|
|
418
|
+
*
|
|
419
|
+
* @selector [data-outside-visible-range]
|
|
420
|
+
*/
|
|
421
|
+
isOutsideVisibleRange: boolean;
|
|
422
|
+
/**
|
|
423
|
+
* Whether the cell is outside the current month.
|
|
424
|
+
*
|
|
425
|
+
* @selector [data-outside-month]
|
|
426
|
+
*/
|
|
427
|
+
isOutsideMonth: boolean;
|
|
428
|
+
/**
|
|
429
|
+
* Whether the cell is unavailable, according to the calendar's `isDateUnavailable` prop.
|
|
430
|
+
* Unavailable dates remain focusable, but cannot be selected by the user. They should be
|
|
431
|
+
* displayed with a visual affordance to indicate they are unavailable, such as a different color
|
|
432
|
+
* or a strikethrough.
|
|
433
|
+
*
|
|
434
|
+
* Note that because they are focusable, unavailable dates must meet a 4.5:1 color contrast ratio,
|
|
435
|
+
* [as defined by WCAG](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html).
|
|
436
|
+
*
|
|
437
|
+
* @selector [data-unavailable]
|
|
438
|
+
*/
|
|
439
|
+
isUnavailable: boolean;
|
|
440
|
+
/**
|
|
441
|
+
* Whether the cell is part of an invalid selection.
|
|
442
|
+
*
|
|
443
|
+
* @selector [data-invalid]
|
|
444
|
+
*/
|
|
445
|
+
isInvalid: boolean;
|
|
446
|
+
/**
|
|
447
|
+
* Whether the cell is today.
|
|
448
|
+
*
|
|
449
|
+
* @selector [data-today]
|
|
450
|
+
*/
|
|
451
|
+
isToday: boolean;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export interface CalendarGridProps
|
|
455
|
+
extends StyleProps, DOMRenderProps<'table', undefined>, GlobalDOMAttributes<HTMLTableElement> {
|
|
456
|
+
/**
|
|
457
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
458
|
+
* element.
|
|
459
|
+
*
|
|
460
|
+
* @default 'react-aria-CalendarGrid'
|
|
461
|
+
*/
|
|
462
|
+
className?: string;
|
|
463
|
+
/**
|
|
464
|
+
* Either a function to render calendar cells for each date in the month,
|
|
465
|
+
* or children containing a `<CalendarGridHeader>`` and `<CalendarGridBody>`
|
|
466
|
+
* when additional customization is needed.
|
|
467
|
+
*/
|
|
468
|
+
children?: ReactElement | ReactElement[] | ((date: CalendarDate) => ReactElement);
|
|
469
|
+
/**
|
|
470
|
+
* An offset from the beginning of the visible date range that this
|
|
471
|
+
* CalendarGrid should display. Useful when displaying more than one
|
|
472
|
+
* month at a time.
|
|
473
|
+
*/
|
|
474
|
+
offset?: DateDuration;
|
|
475
|
+
/**
|
|
476
|
+
* The style of weekday names to display in the calendar grid header,
|
|
477
|
+
* e.g. single letter, abbreviation, or full day name.
|
|
478
|
+
*
|
|
479
|
+
* @default 'narrow'
|
|
480
|
+
*/
|
|
481
|
+
weekdayStyle?: 'narrow' | 'short' | 'long';
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
interface InternalCalendarGridContextValue {
|
|
485
|
+
headerProps: DOMAttributes<FocusableElement>;
|
|
486
|
+
weekDays: string[];
|
|
487
|
+
startDate: CalendarDate;
|
|
488
|
+
weeksInMonth: number;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
const InternalCalendarGridContext = createContext<InternalCalendarGridContextValue | null>(null);
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* A calendar grid displays a single grid of days within a calendar or range calendar which
|
|
495
|
+
* can be keyboard navigated and selected by the user.
|
|
496
|
+
*/
|
|
497
|
+
export const CalendarGrid = /*#__PURE__*/ (forwardRef as any)(function CalendarGrid(
|
|
498
|
+
props: CalendarGridProps,
|
|
499
|
+
ref: ForwardedRef<HTMLTableElement>,
|
|
500
|
+
) {
|
|
501
|
+
let calendarState = useContext(CalendarStateContext);
|
|
502
|
+
let rangeCalendarState = useContext(RangeCalendarStateContext);
|
|
503
|
+
let calenderProps = useSlottedContext(CalendarContext)!;
|
|
504
|
+
let rangeCalenderProps = useSlottedContext(RangeCalendarContext)!;
|
|
505
|
+
let state = calendarState ?? rangeCalendarState!;
|
|
506
|
+
let startDate = state.visibleRange.start;
|
|
507
|
+
if (props.offset) {
|
|
508
|
+
startDate = startDate.add(props.offset);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
let firstDayOfWeek = calenderProps?.firstDayOfWeek ?? rangeCalenderProps?.firstDayOfWeek;
|
|
512
|
+
|
|
513
|
+
let { gridProps, headerProps, weekDays, weeksInMonth } = useCalendarGrid(
|
|
514
|
+
{
|
|
515
|
+
startDate,
|
|
516
|
+
endDate: endOfMonth(startDate),
|
|
517
|
+
weekdayStyle: props.weekdayStyle,
|
|
518
|
+
firstDayOfWeek,
|
|
519
|
+
},
|
|
520
|
+
state,
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
let DOMProps = filterDOMProps(props, { global: true });
|
|
524
|
+
|
|
525
|
+
return (
|
|
526
|
+
<InternalCalendarGridContext.Provider
|
|
527
|
+
value={{ headerProps, weekDays, startDate, weeksInMonth }}
|
|
528
|
+
>
|
|
529
|
+
<dom.table
|
|
530
|
+
render={props.render}
|
|
531
|
+
{...mergeProps(DOMProps, gridProps)}
|
|
532
|
+
ref={ref}
|
|
533
|
+
style={props.style}
|
|
534
|
+
cellPadding={0}
|
|
535
|
+
className={props.className ?? 'react-aria-CalendarGrid'}
|
|
536
|
+
>
|
|
537
|
+
{typeof props.children !== 'function' ? (
|
|
538
|
+
props.children
|
|
539
|
+
) : (
|
|
540
|
+
<>
|
|
541
|
+
<CalendarGridHeaderForwardRef>
|
|
542
|
+
{(day: string) => <CalendarHeaderCellForwardRef>{day}</CalendarHeaderCellForwardRef>}
|
|
543
|
+
</CalendarGridHeaderForwardRef>
|
|
544
|
+
<CalendarGridBodyForwardRef>{props.children}</CalendarGridBodyForwardRef>
|
|
545
|
+
</>
|
|
546
|
+
)}
|
|
547
|
+
</dom.table>
|
|
548
|
+
</InternalCalendarGridContext.Provider>
|
|
549
|
+
);
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
export interface CalendarGridHeaderProps
|
|
553
|
+
extends
|
|
554
|
+
StyleProps,
|
|
555
|
+
DOMRenderProps<'thead', undefined>,
|
|
556
|
+
GlobalDOMAttributes<HTMLTableSectionElement> {
|
|
557
|
+
/**
|
|
558
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
559
|
+
* element.
|
|
560
|
+
*
|
|
561
|
+
* @default 'react-aria-CalendarGridHeader'
|
|
562
|
+
*/
|
|
563
|
+
className?: string;
|
|
564
|
+
/** A function to render a `<CalendarHeaderCell>` for a weekday name. */
|
|
565
|
+
children: (day: string) => ReactElement;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
function CalendarGridHeader(
|
|
569
|
+
props: CalendarGridHeaderProps,
|
|
570
|
+
ref: ForwardedRef<HTMLTableSectionElement>,
|
|
571
|
+
) {
|
|
572
|
+
let { children, style, className } = props;
|
|
573
|
+
let { headerProps, weekDays } = useContext(InternalCalendarGridContext)!;
|
|
574
|
+
let DOMProps = filterDOMProps(props, { global: true });
|
|
575
|
+
|
|
576
|
+
return (
|
|
577
|
+
<dom.thead
|
|
578
|
+
render={props.render}
|
|
579
|
+
{...mergeProps(DOMProps, headerProps)}
|
|
580
|
+
ref={ref}
|
|
581
|
+
style={style}
|
|
582
|
+
className={className ?? 'react-aria-CalendarGridHeader'}
|
|
583
|
+
>
|
|
584
|
+
<tr>{weekDays.map((day, key) => React.cloneElement(children(day), { key }))}</tr>
|
|
585
|
+
</dom.thead>
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* A calendar grid header displays a row of week day names at the top of a month.
|
|
591
|
+
*/
|
|
592
|
+
const CalendarGridHeaderForwardRef = /*#__PURE__*/ (forwardRef as any)(CalendarGridHeader);
|
|
593
|
+
export { CalendarGridHeaderForwardRef as CalendarGridHeader };
|
|
594
|
+
|
|
595
|
+
export interface CalendarHeaderCellProps
|
|
596
|
+
extends
|
|
597
|
+
DOMProps,
|
|
598
|
+
DOMRenderProps<'th', undefined>,
|
|
599
|
+
GlobalDOMAttributes<HTMLTableHeaderCellElement> {
|
|
600
|
+
/**
|
|
601
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
602
|
+
* element.
|
|
603
|
+
*
|
|
604
|
+
* @default 'react-aria-CalendarHeaderCell'
|
|
605
|
+
*/
|
|
606
|
+
className?: string;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function CalendarHeaderCell(
|
|
610
|
+
props: CalendarHeaderCellProps,
|
|
611
|
+
ref: ForwardedRef<HTMLTableCellElement>,
|
|
612
|
+
) {
|
|
613
|
+
let { children, style, className } = props;
|
|
614
|
+
let DOMProps = filterDOMProps(props, { global: true });
|
|
615
|
+
return (
|
|
616
|
+
<dom.th
|
|
617
|
+
render={props.render}
|
|
618
|
+
{...DOMProps}
|
|
619
|
+
ref={ref}
|
|
620
|
+
style={style}
|
|
621
|
+
className={className || 'react-aria-CalendarHeaderCell'}
|
|
622
|
+
>
|
|
623
|
+
{children}
|
|
624
|
+
</dom.th>
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* A calendar header cell displays a week day name at the top of a column within a calendar.
|
|
630
|
+
*/
|
|
631
|
+
const CalendarHeaderCellForwardRef = forwardRef(CalendarHeaderCell);
|
|
632
|
+
export { CalendarHeaderCellForwardRef as CalendarHeaderCell };
|
|
633
|
+
|
|
634
|
+
export interface CalendarGridBodyProps
|
|
635
|
+
extends
|
|
636
|
+
StyleProps,
|
|
637
|
+
DOMRenderProps<'tbody', undefined>,
|
|
638
|
+
GlobalDOMAttributes<HTMLTableSectionElement> {
|
|
639
|
+
/**
|
|
640
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
641
|
+
* element.
|
|
642
|
+
*
|
|
643
|
+
* @default 'react-aria-CalendarGridBody'
|
|
644
|
+
*/
|
|
645
|
+
className?: string;
|
|
646
|
+
/** A function to render a `<CalendarCell>` for a given date. */
|
|
647
|
+
children: (date: CalendarDate) => ReactElement;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function CalendarGridBody(
|
|
651
|
+
props: CalendarGridBodyProps,
|
|
652
|
+
ref: ForwardedRef<HTMLTableSectionElement>,
|
|
653
|
+
) {
|
|
654
|
+
let { children, style, className } = props;
|
|
655
|
+
let calendarState = useContext(CalendarStateContext);
|
|
656
|
+
let rangeCalendarState = useContext(RangeCalendarStateContext);
|
|
657
|
+
let state = calendarState ?? rangeCalendarState!;
|
|
658
|
+
let { startDate, weeksInMonth } = useContext(InternalCalendarGridContext)!;
|
|
659
|
+
let DOMProps = filterDOMProps(props, { global: true });
|
|
660
|
+
|
|
661
|
+
return (
|
|
662
|
+
<dom.tbody
|
|
663
|
+
render={props.render}
|
|
664
|
+
{...DOMProps}
|
|
665
|
+
ref={ref}
|
|
666
|
+
style={style}
|
|
667
|
+
className={className ?? 'react-aria-CalendarGridBody'}
|
|
668
|
+
>
|
|
669
|
+
{[...new Array(weeksInMonth).keys()].map((weekIndex) => (
|
|
670
|
+
<tr key={weekIndex}>
|
|
671
|
+
{state
|
|
672
|
+
.getDatesInWeek(weekIndex, startDate)
|
|
673
|
+
.map((date, i) =>
|
|
674
|
+
date ? React.cloneElement(children(date), { key: i }) : <td key={i} />,
|
|
675
|
+
)}
|
|
676
|
+
</tr>
|
|
677
|
+
))}
|
|
678
|
+
</dom.tbody>
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* A calendar grid body displays a grid of calendar cells within a month.
|
|
684
|
+
*/
|
|
685
|
+
const CalendarGridBodyForwardRef = /*#__PURE__*/ (forwardRef as any)(CalendarGridBody);
|
|
686
|
+
export { CalendarGridBodyForwardRef as CalendarGridBody };
|
|
687
|
+
|
|
688
|
+
export interface CalendarCellProps
|
|
689
|
+
extends
|
|
690
|
+
RenderProps<CalendarCellRenderProps, 'div'>,
|
|
691
|
+
HoverEvents,
|
|
692
|
+
GlobalDOMAttributes<HTMLTableCellElement> {
|
|
693
|
+
/**
|
|
694
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
695
|
+
* element. A function may be provided to compute the class based on component state.
|
|
696
|
+
*
|
|
697
|
+
* @default 'react-aria-CalendarCell'
|
|
698
|
+
*/
|
|
699
|
+
className?: ClassNameOrFunction<CalendarCellRenderProps>;
|
|
700
|
+
/** The date to render in the cell. */
|
|
701
|
+
date: CalendarDate;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* A calendar cell displays a date cell within a calendar grid which can be selected by the user.
|
|
706
|
+
*/
|
|
707
|
+
export const CalendarCell = /*#__PURE__*/ (forwardRef as any)(function CalendarCell(
|
|
708
|
+
{ date, ...otherProps }: CalendarCellProps,
|
|
709
|
+
ref: ForwardedRef<HTMLTableCellElement>,
|
|
710
|
+
) {
|
|
711
|
+
let calendarState = useContext(CalendarStateContext);
|
|
712
|
+
let rangeCalendarState = useContext(RangeCalendarStateContext);
|
|
713
|
+
let state = calendarState ?? rangeCalendarState!;
|
|
714
|
+
let { startDate: currentMonth } = useContext(InternalCalendarGridContext) ?? {
|
|
715
|
+
startDate: state.visibleRange.start,
|
|
716
|
+
};
|
|
717
|
+
let isOutsideMonth =
|
|
718
|
+
state.visibleDuration.days || state.visibleDuration.weeks
|
|
719
|
+
? false
|
|
720
|
+
: !isSameMonth(currentMonth, date);
|
|
721
|
+
let istoday = isToday(date, state.timeZone);
|
|
722
|
+
|
|
723
|
+
let buttonRef = useRef<HTMLDivElement>(null);
|
|
724
|
+
let { cellProps, buttonProps, ...states } = useCalendarCell(
|
|
725
|
+
{ date, isOutsideMonth },
|
|
726
|
+
state,
|
|
727
|
+
buttonRef,
|
|
728
|
+
);
|
|
729
|
+
|
|
730
|
+
let { hoverProps, isHovered } = useHover({
|
|
731
|
+
...otherProps,
|
|
732
|
+
isDisabled: states.isDisabled || states.isUnavailable,
|
|
733
|
+
});
|
|
734
|
+
let { focusProps, isFocusVisible } = useFocusRing();
|
|
735
|
+
isFocusVisible &&= states.isFocused;
|
|
736
|
+
let isSelectionStart = false;
|
|
737
|
+
let isSelectionEnd = false;
|
|
738
|
+
if ('highlightedRange' in state && state.highlightedRange) {
|
|
739
|
+
isSelectionStart = isSameDay(date, state.highlightedRange.start);
|
|
740
|
+
isSelectionEnd = isSameDay(date, state.highlightedRange.end);
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
let renderProps = useRenderProps({
|
|
744
|
+
...otherProps,
|
|
745
|
+
defaultChildren: states.formattedDate,
|
|
746
|
+
defaultClassName: 'react-aria-CalendarCell',
|
|
747
|
+
values: {
|
|
748
|
+
date,
|
|
749
|
+
isHovered,
|
|
750
|
+
isOutsideMonth,
|
|
751
|
+
isFocusVisible,
|
|
752
|
+
isSelectionStart,
|
|
753
|
+
isSelectionEnd,
|
|
754
|
+
isToday: istoday,
|
|
755
|
+
...states,
|
|
756
|
+
},
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
let dataAttrs = {
|
|
760
|
+
'data-focused': states.isFocused || undefined,
|
|
761
|
+
'data-hovered': isHovered || undefined,
|
|
762
|
+
'data-pressed': states.isPressed || undefined,
|
|
763
|
+
'data-unavailable': states.isUnavailable || undefined,
|
|
764
|
+
'data-disabled': states.isDisabled || undefined,
|
|
765
|
+
'data-focus-visible': isFocusVisible || undefined,
|
|
766
|
+
'data-outside-visible-range': states.isOutsideVisibleRange || undefined,
|
|
767
|
+
'data-outside-month': isOutsideMonth || undefined,
|
|
768
|
+
'data-selected': states.isSelected || undefined,
|
|
769
|
+
'data-selection-start': isSelectionStart || undefined,
|
|
770
|
+
'data-selection-end': isSelectionEnd || undefined,
|
|
771
|
+
'data-invalid': states.isInvalid || undefined,
|
|
772
|
+
'data-today': istoday || undefined,
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
let DOMProps = filterDOMProps(otherProps, { global: true });
|
|
776
|
+
|
|
777
|
+
return (
|
|
778
|
+
<dom.td {...cellProps} ref={ref}>
|
|
779
|
+
<dom.div
|
|
780
|
+
{...mergeProps(DOMProps, buttonProps, focusProps, hoverProps, dataAttrs, renderProps)}
|
|
781
|
+
ref={buttonRef}
|
|
782
|
+
/>
|
|
783
|
+
</dom.td>
|
|
784
|
+
);
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
export interface CalendarYearPickerProps extends AriaCalendarYearPickerProps {
|
|
788
|
+
/**
|
|
789
|
+
* A function to render the year picker.
|
|
790
|
+
*/
|
|
791
|
+
children: (renderProps: CalendarYearPickerAria) => JSX.Element;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
export function CalendarYearPicker(props: CalendarYearPickerProps): JSX.Element {
|
|
795
|
+
let calendarState = useContext(CalendarStateContext);
|
|
796
|
+
let rangeCalendarState = useContext(RangeCalendarStateContext);
|
|
797
|
+
let state = calendarState || rangeCalendarState!;
|
|
798
|
+
let aria = useCalendarYearPicker(props, state);
|
|
799
|
+
return props.children(aria);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
export interface CalendarMonthPickerProps extends AriaCalendarMonthPickerProps {
|
|
803
|
+
/**
|
|
804
|
+
* A function to render the month picker.
|
|
805
|
+
*/
|
|
806
|
+
children: (renderProps: CalendarMonthPickerAria) => JSX.Element;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
export function CalendarMonthPicker(props: CalendarMonthPickerProps): JSX.Element {
|
|
810
|
+
let calendarState = useContext(CalendarStateContext);
|
|
811
|
+
let rangeCalendarState = useContext(RangeCalendarStateContext);
|
|
812
|
+
let state = calendarState || rangeCalendarState!;
|
|
813
|
+
let aria = useCalendarMonthPicker(props, state);
|
|
814
|
+
return props.children(aria);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
export interface CalendarHeadingProps extends AriaCalendarHeadingProps, HeadingProps {
|
|
818
|
+
/**
|
|
819
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
820
|
+
* element.
|
|
821
|
+
*
|
|
822
|
+
* @default 'react-aria-CalendarHeading'
|
|
823
|
+
*/
|
|
824
|
+
className?: string;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
export const CalendarHeading = forwardRef(function CalendarHeading(
|
|
828
|
+
props: CalendarHeadingProps,
|
|
829
|
+
ref: ForwardedRef<HTMLHeadingElement>,
|
|
830
|
+
) {
|
|
831
|
+
let { offset, format, className = 'react-aria-CalendarHeading', ...headingProps } = props;
|
|
832
|
+
let calendarState = useContext(CalendarStateContext);
|
|
833
|
+
let rangeCalendarState = useContext(RangeCalendarStateContext);
|
|
834
|
+
let state = calendarState || rangeCalendarState!;
|
|
835
|
+
let aria = useCalendarHeading({ offset, format }, state);
|
|
836
|
+
|
|
837
|
+
return (
|
|
838
|
+
<Heading {...headingProps} className={className} ref={ref}>
|
|
839
|
+
{aria}
|
|
840
|
+
</Heading>
|
|
841
|
+
);
|
|
842
|
+
});
|