@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,427 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/src/datepicker/IncompleteDate.ts).
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2026 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
|
+
|
|
15
|
+
import { AnyDateTime, Calendar, CalendarDate, ZonedDateTime } from '@internationalized/date';
|
|
16
|
+
import { DateSegmentType } from './useDateFieldState';
|
|
17
|
+
import { DateValue } from './types';
|
|
18
|
+
|
|
19
|
+
type HourCycle = 'h12' | 'h11' | 'h23' | 'h24';
|
|
20
|
+
|
|
21
|
+
export interface IncompleteDate {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* This class represents a date that is incomplete or otherwise invalid as a result of user editing.
|
|
27
|
+
* For example, it can represent temporary dates such as February 31st if the user edits the day
|
|
28
|
+
* before the month. Times are represented according to an hour cycle rather than always in 24 hour
|
|
29
|
+
* time. This enables the user to adjust the day period (e.g. am/pm) independently from the hour.
|
|
30
|
+
*/
|
|
31
|
+
export class IncompleteDate {
|
|
32
|
+
calendar: Calendar;
|
|
33
|
+
era: string | null;
|
|
34
|
+
year: number | null;
|
|
35
|
+
month: number | null;
|
|
36
|
+
day: number | null;
|
|
37
|
+
hour: number | null;
|
|
38
|
+
hourCycle: HourCycle;
|
|
39
|
+
dayPeriod: number | null;
|
|
40
|
+
minute: number | null;
|
|
41
|
+
second: number | null;
|
|
42
|
+
millisecond: number | null;
|
|
43
|
+
offset: number | null;
|
|
44
|
+
|
|
45
|
+
constructor(
|
|
46
|
+
calendar: Calendar,
|
|
47
|
+
hourCycle: HourCycle,
|
|
48
|
+
dateValue?: Partial<Omit<AnyDateTime, 'copy'>> | null,
|
|
49
|
+
) {
|
|
50
|
+
this.era = dateValue?.era ?? null;
|
|
51
|
+
this.calendar = calendar;
|
|
52
|
+
this.year = dateValue?.year ?? null;
|
|
53
|
+
this.month = dateValue?.month ?? null;
|
|
54
|
+
this.day = dateValue?.day ?? null;
|
|
55
|
+
this.hour = dateValue?.hour ?? null;
|
|
56
|
+
this.hourCycle = hourCycle;
|
|
57
|
+
this.dayPeriod = null;
|
|
58
|
+
this.minute = dateValue?.minute ?? null;
|
|
59
|
+
this.second = dateValue?.second ?? null;
|
|
60
|
+
this.millisecond = dateValue?.millisecond ?? null;
|
|
61
|
+
this.offset = 'offset' in (dateValue ?? {}) ? (dateValue as any).offset : null;
|
|
62
|
+
|
|
63
|
+
// Convert the hour from 24 hour time to the given hour cycle.
|
|
64
|
+
if (this.hour != null) {
|
|
65
|
+
let [dayPeriod, hour] = toHourCycle(this.hour, hourCycle);
|
|
66
|
+
this.dayPeriod = dayPeriod;
|
|
67
|
+
this.hour = hour;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
copy(): IncompleteDate {
|
|
72
|
+
let res = new IncompleteDate(this.calendar, this.hourCycle);
|
|
73
|
+
res.era = this.era;
|
|
74
|
+
res.year = this.year;
|
|
75
|
+
res.month = this.month;
|
|
76
|
+
res.day = this.day;
|
|
77
|
+
res.hour = this.hour;
|
|
78
|
+
res.dayPeriod = this.dayPeriod;
|
|
79
|
+
res.minute = this.minute;
|
|
80
|
+
res.second = this.second;
|
|
81
|
+
res.millisecond = this.millisecond;
|
|
82
|
+
res.offset = this.offset;
|
|
83
|
+
return res;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Checks whether all the specified segments have a value. */
|
|
87
|
+
isComplete(segments: DateSegmentType[]) {
|
|
88
|
+
return segments.every((segment) => (this as any)[segment] != null);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Checks whether the given date value matches this value for the specified segments. */
|
|
92
|
+
validate(dt: DateValue, segments: DateSegmentType[]) {
|
|
93
|
+
return segments.every((segment) => {
|
|
94
|
+
if ((segment === 'hour' || segment === 'dayPeriod') && 'hour' in dt) {
|
|
95
|
+
let [dayPeriod, hour] = toHourCycle(dt.hour, this.hourCycle);
|
|
96
|
+
return this.dayPeriod === dayPeriod && this.hour === hour;
|
|
97
|
+
}
|
|
98
|
+
return (this as any)[segment] === (dt as any)[segment];
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Checks if the date is empty (i.e. all specified segments are null). */
|
|
103
|
+
isCleared(segments: DateSegmentType[]): boolean {
|
|
104
|
+
return segments.every((segment) => (this as any)[segment] === null);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Sets the given field. */
|
|
108
|
+
set(field: DateSegmentType, value: number | string, placeholder: DateValue): IncompleteDate {
|
|
109
|
+
let result = this.copy();
|
|
110
|
+
(result as any)[field] = value;
|
|
111
|
+
if (field === 'hour' && result.dayPeriod == null && 'hour' in placeholder) {
|
|
112
|
+
result.dayPeriod = toHourCycle(placeholder.hour, this.hourCycle)[0];
|
|
113
|
+
}
|
|
114
|
+
if (field === 'year' && result.era == null) {
|
|
115
|
+
result.era = placeholder.era;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// clear offset when a date/time field changes since it may no longer be valid
|
|
119
|
+
if (field !== 'second' && field !== 'literal' && field !== 'timeZoneName') {
|
|
120
|
+
result.offset = null;
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Sets the given field to null. */
|
|
126
|
+
clear(field: DateSegmentType): IncompleteDate {
|
|
127
|
+
let result = this.copy();
|
|
128
|
+
// @ts-ignore
|
|
129
|
+
(result as any)[field] = null;
|
|
130
|
+
if (field === 'year') {
|
|
131
|
+
result.era = null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// clear offset when a field is cleared since it may no longer be valid
|
|
135
|
+
result.offset = null;
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Increments or decrements the given field. If it is null, then it is set to the placeholder
|
|
141
|
+
* value.
|
|
142
|
+
*/
|
|
143
|
+
cycle(
|
|
144
|
+
field: DateSegmentType,
|
|
145
|
+
amount: number,
|
|
146
|
+
placeholder: DateValue,
|
|
147
|
+
displaySegments: DateSegmentType[],
|
|
148
|
+
): IncompleteDate {
|
|
149
|
+
let res = this.copy();
|
|
150
|
+
|
|
151
|
+
// If field is null, default to placeholder.
|
|
152
|
+
if ((res as any)[field] == null && field !== 'dayPeriod' && field !== 'era') {
|
|
153
|
+
if (field === 'hour' && 'hour' in placeholder) {
|
|
154
|
+
let [dayPeriod, hour] = toHourCycle(placeholder.hour, this.hourCycle);
|
|
155
|
+
res.dayPeriod = dayPeriod;
|
|
156
|
+
res.hour = hour;
|
|
157
|
+
} else {
|
|
158
|
+
(res as any)[field] = (placeholder as any)[field];
|
|
159
|
+
}
|
|
160
|
+
if (field === 'year' && res.era == null) {
|
|
161
|
+
res.era = placeholder.era;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return res;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
switch (field) {
|
|
168
|
+
case 'era': {
|
|
169
|
+
let eras = this.calendar.getEras();
|
|
170
|
+
let index = eras.indexOf(res.era!);
|
|
171
|
+
index = cycleValue(index, amount, 0, eras.length - 1);
|
|
172
|
+
res.era = eras[index];
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
case 'year': {
|
|
176
|
+
// Use CalendarDate to cycle so that we update the era when going between 1 AD and 1 BC.
|
|
177
|
+
let date = new CalendarDate(
|
|
178
|
+
this.calendar,
|
|
179
|
+
this.era ?? placeholder.era,
|
|
180
|
+
this.year ?? placeholder.year,
|
|
181
|
+
this.month ?? 1,
|
|
182
|
+
this.day ?? 1,
|
|
183
|
+
);
|
|
184
|
+
date = date.cycle(field, amount, { round: field === 'year' });
|
|
185
|
+
res.era = date.era;
|
|
186
|
+
res.year = date.year;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
case 'month':
|
|
190
|
+
res.month = cycleValue(res.month ?? 1, amount, 1, this.calendar.getMaximumMonthsInYear());
|
|
191
|
+
break;
|
|
192
|
+
case 'day':
|
|
193
|
+
// Allow incrementing up to the maximum number of days in any month.
|
|
194
|
+
res.day = cycleValue(res.day ?? 1, amount, 1, this.calendar.getMaximumDaysInMonth());
|
|
195
|
+
break;
|
|
196
|
+
case 'hour': {
|
|
197
|
+
// if date is fully defined or it is just a time field, and we have a time zone, use toValue to get a ZonedDateTime to cycle
|
|
198
|
+
// so DST fallback is properly handled
|
|
199
|
+
let hasDateSegements = displaySegments.some((s) => ['year', 'month', 'day'].includes(s));
|
|
200
|
+
if (
|
|
201
|
+
'timeZone' in placeholder &&
|
|
202
|
+
(!hasDateSegements || (res.year != null && res.month != null && res.day != null))
|
|
203
|
+
) {
|
|
204
|
+
let date = this.toValue(placeholder) as ZonedDateTime;
|
|
205
|
+
date = date.cycle('hour', amount, {
|
|
206
|
+
hourCycle: this.hourCycle === 'h12' ? 12 : 24,
|
|
207
|
+
round: false,
|
|
208
|
+
});
|
|
209
|
+
let [dayPeriod, adjustedHour] = toHourCycle(date.hour, this.hourCycle);
|
|
210
|
+
res.hour = adjustedHour;
|
|
211
|
+
res.dayPeriod = dayPeriod;
|
|
212
|
+
res.offset = date.offset;
|
|
213
|
+
} else {
|
|
214
|
+
let hours = res.hour ?? 0;
|
|
215
|
+
let limits = this.getSegmentLimits('hour')!;
|
|
216
|
+
res.hour = cycleValue(hours, amount, limits.minValue, limits.maxValue);
|
|
217
|
+
if (res.dayPeriod == null && 'hour' in placeholder) {
|
|
218
|
+
res.dayPeriod = toHourCycle(placeholder.hour, this.hourCycle)[0];
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
case 'dayPeriod':
|
|
224
|
+
res.dayPeriod = cycleValue(res.dayPeriod ?? 0, amount, 0, 1);
|
|
225
|
+
break;
|
|
226
|
+
case 'minute':
|
|
227
|
+
res.minute = cycleValue(res.minute ?? 0, amount, 0, 59, true);
|
|
228
|
+
break;
|
|
229
|
+
case 'second':
|
|
230
|
+
res.second = cycleValue(res.second ?? 0, amount, 0, 59, true);
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return res;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Converts the incomplete date to a full date value, using the provided value for any unset
|
|
239
|
+
* fields.
|
|
240
|
+
*/
|
|
241
|
+
toValue(value: DateValue): DateValue {
|
|
242
|
+
if ('hour' in value) {
|
|
243
|
+
let hour = this.hour;
|
|
244
|
+
if (hour != null) {
|
|
245
|
+
hour = fromHourCycle(hour, this.dayPeriod ?? 0, this.hourCycle);
|
|
246
|
+
} else if (this.hourCycle === 'h12' || this.hourCycle === 'h11') {
|
|
247
|
+
hour = this.dayPeriod === 1 ? 12 : 0;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
let res = value.set({
|
|
251
|
+
era: this.era ?? value.era,
|
|
252
|
+
year: this.year ?? value.year,
|
|
253
|
+
month: this.month ?? value.month,
|
|
254
|
+
day: this.day ?? value.day,
|
|
255
|
+
hour: hour ?? value.hour,
|
|
256
|
+
minute: this.minute ?? value.minute,
|
|
257
|
+
second: this.second ?? value.second,
|
|
258
|
+
millisecond: this.millisecond ?? value.millisecond,
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
if ('offset' in res && this.offset != null && res.offset !== this.offset) {
|
|
262
|
+
res = res.add({ milliseconds: res.offset - this.offset });
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return res;
|
|
266
|
+
} else {
|
|
267
|
+
return value.set({
|
|
268
|
+
era: this.era ?? value.era,
|
|
269
|
+
year: this.year ?? value.year,
|
|
270
|
+
month: this.month ?? value.month,
|
|
271
|
+
day: this.day ?? value.day,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
getSegmentLimits(
|
|
277
|
+
type: string,
|
|
278
|
+
): { value: number | null; minValue: number; maxValue: number } | undefined {
|
|
279
|
+
switch (type) {
|
|
280
|
+
case 'era': {
|
|
281
|
+
let eras = this.calendar.getEras();
|
|
282
|
+
return {
|
|
283
|
+
value: this.era != null ? eras.indexOf(this.era) : eras.length - 1,
|
|
284
|
+
minValue: 0,
|
|
285
|
+
maxValue: eras.length - 1,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
case 'year':
|
|
289
|
+
return {
|
|
290
|
+
value: this.year,
|
|
291
|
+
minValue: 1,
|
|
292
|
+
maxValue: 9999,
|
|
293
|
+
};
|
|
294
|
+
case 'month':
|
|
295
|
+
return {
|
|
296
|
+
value: this.month,
|
|
297
|
+
minValue: 1,
|
|
298
|
+
maxValue: this.calendar.getMaximumMonthsInYear(),
|
|
299
|
+
};
|
|
300
|
+
case 'day':
|
|
301
|
+
return {
|
|
302
|
+
value: this.day,
|
|
303
|
+
minValue: 1,
|
|
304
|
+
maxValue: this.calendar.getMaximumDaysInMonth(),
|
|
305
|
+
};
|
|
306
|
+
case 'dayPeriod': {
|
|
307
|
+
return {
|
|
308
|
+
value: this.dayPeriod,
|
|
309
|
+
minValue: 0,
|
|
310
|
+
maxValue: 1,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
case 'hour': {
|
|
314
|
+
let minValue = 0;
|
|
315
|
+
let maxValue = 23;
|
|
316
|
+
if (this.hourCycle === 'h12') {
|
|
317
|
+
minValue = 1;
|
|
318
|
+
maxValue = 12;
|
|
319
|
+
} else if (this.hourCycle === 'h11') {
|
|
320
|
+
minValue = 0;
|
|
321
|
+
maxValue = 11;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return {
|
|
325
|
+
value: this.hour,
|
|
326
|
+
minValue,
|
|
327
|
+
maxValue,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
case 'minute':
|
|
331
|
+
return {
|
|
332
|
+
value: this.minute,
|
|
333
|
+
minValue: 0,
|
|
334
|
+
maxValue: 59,
|
|
335
|
+
};
|
|
336
|
+
case 'second':
|
|
337
|
+
return {
|
|
338
|
+
value: this.second,
|
|
339
|
+
minValue: 0,
|
|
340
|
+
maxValue: 59,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function cycleValue(value: number, amount: number, min: number, max: number, round = false) {
|
|
347
|
+
if (round) {
|
|
348
|
+
value += Math.sign(amount);
|
|
349
|
+
|
|
350
|
+
if (value < min) {
|
|
351
|
+
value = max;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
let div = Math.abs(amount);
|
|
355
|
+
if (amount > 0) {
|
|
356
|
+
value = Math.ceil(value / div) * div;
|
|
357
|
+
} else {
|
|
358
|
+
value = Math.floor(value / div) * div;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (value > max) {
|
|
362
|
+
value = min;
|
|
363
|
+
}
|
|
364
|
+
} else {
|
|
365
|
+
value += amount;
|
|
366
|
+
if (value < min) {
|
|
367
|
+
value = max - (min - value - 1);
|
|
368
|
+
} else if (value > max) {
|
|
369
|
+
value = min + (value - max - 1);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return value;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function toHourCycle(hour: number, hourCycle: HourCycle): [number | null, number] {
|
|
377
|
+
let dayPeriod: number | null = hour >= 12 ? 1 : 0;
|
|
378
|
+
switch (hourCycle) {
|
|
379
|
+
case 'h11':
|
|
380
|
+
// Hours are numbered from 0 to 11. Used in Japan.
|
|
381
|
+
if (hour >= 12) {
|
|
382
|
+
hour -= 12;
|
|
383
|
+
}
|
|
384
|
+
break;
|
|
385
|
+
case 'h12':
|
|
386
|
+
// Hours are numbered from 12 (representing 0) to 11.
|
|
387
|
+
if (hour === 0) {
|
|
388
|
+
hour = 12;
|
|
389
|
+
} else if (hour > 12) {
|
|
390
|
+
hour -= 12;
|
|
391
|
+
}
|
|
392
|
+
break;
|
|
393
|
+
case 'h23':
|
|
394
|
+
// 24 hour time, numbered 0 to 23.
|
|
395
|
+
dayPeriod = null;
|
|
396
|
+
break;
|
|
397
|
+
case 'h24':
|
|
398
|
+
// 24 hour time numbered 24 to 23. Unused but supported by Intl.DateTimeFormat.
|
|
399
|
+
hour += 1;
|
|
400
|
+
dayPeriod = null;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return [dayPeriod, hour];
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function fromHourCycle(hour: number, dayPeriod: number, hourCycle: HourCycle): number {
|
|
407
|
+
switch (hourCycle) {
|
|
408
|
+
case 'h11':
|
|
409
|
+
if (dayPeriod === 1) {
|
|
410
|
+
hour += 12;
|
|
411
|
+
}
|
|
412
|
+
break;
|
|
413
|
+
case 'h12':
|
|
414
|
+
if (hour === 12) {
|
|
415
|
+
hour = 0;
|
|
416
|
+
}
|
|
417
|
+
if (dayPeriod === 1) {
|
|
418
|
+
hour += 12;
|
|
419
|
+
}
|
|
420
|
+
break;
|
|
421
|
+
case 'h24':
|
|
422
|
+
hour -= 1;
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return hour;
|
|
427
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/src/datepicker/placeholders.ts).
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 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
|
+
|
|
15
|
+
import { LocalizedStringDictionary } from '@internationalized/string';
|
|
16
|
+
|
|
17
|
+
// These placeholders are based on the strings used by the <input type="date">
|
|
18
|
+
// implementations in Chrome and Firefox. Additional languages are supported
|
|
19
|
+
// here than React Spectrum's typical translations.
|
|
20
|
+
const placeholders = new LocalizedStringDictionary(
|
|
21
|
+
{
|
|
22
|
+
ach: { year: 'mwaka', month: 'dwe', day: 'nino' },
|
|
23
|
+
af: { year: 'jjjj', month: 'mm', day: 'dd' },
|
|
24
|
+
am: { year: 'ዓዓዓዓ', month: 'ሚሜ', day: 'ቀቀ' },
|
|
25
|
+
an: { year: 'aaaa', month: 'mm', day: 'dd' },
|
|
26
|
+
ar: { year: 'سنة', month: 'شهر', day: 'يوم' },
|
|
27
|
+
ast: { year: 'aaaa', month: 'mm', day: 'dd' },
|
|
28
|
+
az: { year: 'iiii', month: 'aa', day: 'gg' },
|
|
29
|
+
be: { year: 'гггг', month: 'мм', day: 'дд' },
|
|
30
|
+
bg: { year: 'гггг', month: 'мм', day: 'дд' },
|
|
31
|
+
bn: { year: 'yyyy', month: 'মিমি', day: 'dd' },
|
|
32
|
+
br: { year: 'bbbb', month: 'mm', day: 'dd' },
|
|
33
|
+
bs: { year: 'gggg', month: 'mm', day: 'dd' },
|
|
34
|
+
ca: { year: 'aaaa', month: 'mm', day: 'dd' },
|
|
35
|
+
cak: { year: 'jjjj', month: 'ii', day: "q'q'" },
|
|
36
|
+
ckb: { year: 'ساڵ', month: 'مانگ', day: 'ڕۆژ' },
|
|
37
|
+
cs: { year: 'rrrr', month: 'mm', day: 'dd' },
|
|
38
|
+
cy: { year: 'bbbb', month: 'mm', day: 'dd' },
|
|
39
|
+
da: { year: 'åååå', month: 'mm', day: 'dd' },
|
|
40
|
+
de: { year: 'jjjj', month: 'mm', day: 'tt' },
|
|
41
|
+
dsb: { year: 'llll', month: 'mm', day: 'źź' },
|
|
42
|
+
el: { year: 'εεεε', month: 'μμ', day: 'ηη' },
|
|
43
|
+
en: { year: 'yyyy', month: 'mm', day: 'dd' },
|
|
44
|
+
eo: { year: 'jjjj', month: 'mm', day: 'tt' },
|
|
45
|
+
es: { year: 'aaaa', month: 'mm', day: 'dd' },
|
|
46
|
+
et: { year: 'aaaa', month: 'kk', day: 'pp' },
|
|
47
|
+
eu: { year: 'uuuu', month: 'hh', day: 'ee' },
|
|
48
|
+
fa: { year: 'سال', month: 'ماه', day: 'روز' },
|
|
49
|
+
ff: { year: 'hhhh', month: 'll', day: 'ññ' },
|
|
50
|
+
fi: { year: 'vvvv', month: 'kk', day: 'pp' },
|
|
51
|
+
fr: { year: 'aaaa', month: 'mm', day: 'jj' },
|
|
52
|
+
fy: { year: 'jjjj', month: 'mm', day: 'dd' },
|
|
53
|
+
ga: { year: 'bbbb', month: 'mm', day: 'll' },
|
|
54
|
+
gd: { year: 'bbbb', month: 'mm', day: 'll' },
|
|
55
|
+
gl: { year: 'aaaa', month: 'mm', day: 'dd' },
|
|
56
|
+
he: { year: 'שנה', month: 'חודש', day: 'יום' },
|
|
57
|
+
hr: { year: 'gggg', month: 'mm', day: 'dd' },
|
|
58
|
+
hsb: { year: 'llll', month: 'mm', day: 'dd' },
|
|
59
|
+
hu: { year: 'éééé', month: 'hh', day: 'nn' },
|
|
60
|
+
ia: { year: 'aaaa', month: 'mm', day: 'dd' },
|
|
61
|
+
id: { year: 'tttt', month: 'bb', day: 'hh' },
|
|
62
|
+
is: { year: 'áááá', month: 'mm', day: 'dd' },
|
|
63
|
+
it: { year: 'aaaa', month: 'mm', day: 'gg' },
|
|
64
|
+
ja: { year: '年', month: '月', day: '日' },
|
|
65
|
+
ka: { year: 'წწწწ', month: 'თთ', day: 'რრ' },
|
|
66
|
+
kk: { year: 'жжжж', month: 'аа', day: 'кк' },
|
|
67
|
+
kn: { year: 'ವವವವ', month: 'ಮಿಮೀ', day: 'ದಿದಿ' },
|
|
68
|
+
ko: { year: '연도', month: '월', day: '일' },
|
|
69
|
+
lb: { year: 'jjjj', month: 'mm', day: 'dd' },
|
|
70
|
+
lo: { year: 'ປປປປ', month: 'ດດ', day: 'ວວ' },
|
|
71
|
+
lt: { year: 'mmmm', month: 'mm', day: 'dd' },
|
|
72
|
+
lv: { year: 'gggg', month: 'mm', day: 'dd' },
|
|
73
|
+
meh: { year: 'aaaa', month: 'mm', day: 'dd' },
|
|
74
|
+
ml: { year: 'വർഷം', month: 'മാസം', day: 'തീയതി' },
|
|
75
|
+
ms: { year: 'tttt', month: 'mm', day: 'hh' },
|
|
76
|
+
nb: { year: 'åååå', month: 'mm', day: 'dd' },
|
|
77
|
+
nl: { year: 'jjjj', month: 'mm', day: 'dd' },
|
|
78
|
+
nn: { year: 'åååå', month: 'mm', day: 'dd' },
|
|
79
|
+
no: { year: 'åååå', month: 'mm', day: 'dd' },
|
|
80
|
+
oc: { year: 'aaaa', month: 'mm', day: 'jj' },
|
|
81
|
+
pl: { year: 'rrrr', month: 'mm', day: 'dd' },
|
|
82
|
+
pt: { year: 'aaaa', month: 'mm', day: 'dd' },
|
|
83
|
+
rm: { year: 'oooo', month: 'mm', day: 'dd' },
|
|
84
|
+
ro: { year: 'aaaa', month: 'll', day: 'zz' },
|
|
85
|
+
ru: { year: 'гггг', month: 'мм', day: 'дд' },
|
|
86
|
+
sc: { year: 'aaaa', month: 'mm', day: 'dd' },
|
|
87
|
+
scn: { year: 'aaaa', month: 'mm', day: 'jj' },
|
|
88
|
+
sk: { year: 'rrrr', month: 'mm', day: 'dd' },
|
|
89
|
+
sl: { year: 'llll', month: 'mm', day: 'dd' },
|
|
90
|
+
sr: { year: 'гггг', month: 'мм', day: 'дд' },
|
|
91
|
+
'sr-Latn': { year: 'gggg', month: 'mm', day: 'dd' },
|
|
92
|
+
sv: { year: 'åååå', month: 'mm', day: 'dd' },
|
|
93
|
+
szl: { year: 'rrrr', month: 'mm', day: 'dd' },
|
|
94
|
+
tg: { year: 'сссс', month: 'мм', day: 'рр' },
|
|
95
|
+
th: { year: 'ปปปป', month: 'ดด', day: 'วว' },
|
|
96
|
+
tr: { year: 'yyyy', month: 'aa', day: 'gg' },
|
|
97
|
+
uk: { year: 'рррр', month: 'мм', day: 'дд' },
|
|
98
|
+
'zh-CN': { year: '年', month: '月', day: '日' },
|
|
99
|
+
'zh-TW': { year: '年', month: '月', day: '日' },
|
|
100
|
+
},
|
|
101
|
+
'en',
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
export function getPlaceholder(field: string, value: string, locale: string): string {
|
|
105
|
+
// Use the actual placeholder value for the era and day period fields.
|
|
106
|
+
if (field === 'era' || field === 'dayPeriod') {
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (field === 'year' || field === 'month' || field === 'day') {
|
|
111
|
+
return placeholders.getStringForLocale(field, locale);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// For time fields (e.g. hour, minute, etc.), use two dashes as the placeholder.
|
|
115
|
+
return '––';
|
|
116
|
+
}
|