@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,72 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-aria-components/src/ColorSwatch.tsx).
|
|
3
|
+
import {
|
|
4
|
+
AriaColorSwatchProps,
|
|
5
|
+
useColorSwatch,
|
|
6
|
+
} from '../upstream-exports/react-aria/useColorSwatch';
|
|
7
|
+
import {
|
|
8
|
+
ClassNameOrFunction,
|
|
9
|
+
ContextValue,
|
|
10
|
+
dom,
|
|
11
|
+
SlotProps,
|
|
12
|
+
StyleRenderProps,
|
|
13
|
+
useContextProps,
|
|
14
|
+
useRenderProps,
|
|
15
|
+
} from './utils';
|
|
16
|
+
import { Color } from '../upstream-exports/react-stately/Color';
|
|
17
|
+
import { filterDOMProps } from '../upstream-exports/react-aria/filterDOMProps';
|
|
18
|
+
import { GlobalDOMAttributes } from '@react-types/shared';
|
|
19
|
+
import { mergeProps } from '../upstream-exports/react-aria/mergeProps';
|
|
20
|
+
import React, { createContext, ForwardedRef, forwardRef } from '../compat/react';
|
|
21
|
+
|
|
22
|
+
export interface ColorSwatchRenderProps {
|
|
23
|
+
/** The color of the swatch. */
|
|
24
|
+
color: Color;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ColorSwatchProps
|
|
28
|
+
extends
|
|
29
|
+
AriaColorSwatchProps,
|
|
30
|
+
StyleRenderProps<ColorSwatchRenderProps>,
|
|
31
|
+
SlotProps,
|
|
32
|
+
GlobalDOMAttributes<HTMLDivElement> {
|
|
33
|
+
/**
|
|
34
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
35
|
+
* element. A function may be provided to compute the class based on component state.
|
|
36
|
+
*
|
|
37
|
+
* @default 'react-aria-ColorSwatch'
|
|
38
|
+
*/
|
|
39
|
+
className?: ClassNameOrFunction<ColorSwatchRenderProps>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const ColorSwatchContext =
|
|
43
|
+
createContext<ContextValue<ColorSwatchProps, HTMLDivElement>>(null);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A ColorSwatch displays a preview of a selected color.
|
|
47
|
+
*/
|
|
48
|
+
export const ColorSwatch = forwardRef(function ColorSwatch(
|
|
49
|
+
props: ColorSwatchProps,
|
|
50
|
+
ref: ForwardedRef<HTMLDivElement>,
|
|
51
|
+
) {
|
|
52
|
+
[props, ref] = useContextProps(props, ref, ColorSwatchContext);
|
|
53
|
+
let { colorSwatchProps, color } = useColorSwatch(props);
|
|
54
|
+
let renderProps = useRenderProps({
|
|
55
|
+
...props,
|
|
56
|
+
defaultClassName: 'react-aria-ColorSwatch',
|
|
57
|
+
defaultStyle: colorSwatchProps.style,
|
|
58
|
+
values: {
|
|
59
|
+
color,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
let DOMProps = filterDOMProps(props, { global: true });
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<dom.div
|
|
67
|
+
{...mergeProps(DOMProps, colorSwatchProps, renderProps)}
|
|
68
|
+
slot={props.slot || undefined}
|
|
69
|
+
ref={ref}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
});
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-aria-components/src/ColorSwatchPicker.tsx).
|
|
3
|
+
import { isChildrenBlock } from 'octane';
|
|
4
|
+
import {
|
|
5
|
+
AriaLabelingProps,
|
|
6
|
+
GlobalDOMAttributes,
|
|
7
|
+
HoverEvents,
|
|
8
|
+
PressEvents,
|
|
9
|
+
ValueBase,
|
|
10
|
+
} from '@react-types/shared';
|
|
11
|
+
import {
|
|
12
|
+
ClassNameOrFunction,
|
|
13
|
+
composeRenderProps,
|
|
14
|
+
ContextValue,
|
|
15
|
+
RenderProps,
|
|
16
|
+
StyleRenderProps,
|
|
17
|
+
useContextProps,
|
|
18
|
+
} from './utils';
|
|
19
|
+
import { Color } from '../upstream-exports/react-stately/Color';
|
|
20
|
+
import { ColorSwatchContext } from './ColorSwatch';
|
|
21
|
+
import { filterDOMProps } from '../upstream-exports/react-aria/filterDOMProps';
|
|
22
|
+
import intlMessages from '../intl/react-aria-components/index';
|
|
23
|
+
import { ListBox, ListBoxItem, ListBoxItemRenderProps, ListBoxRenderProps } from './ListBox';
|
|
24
|
+
import { parseColor } from '../upstream-exports/react-stately/Color';
|
|
25
|
+
import React, {
|
|
26
|
+
createContext,
|
|
27
|
+
ForwardedRef,
|
|
28
|
+
forwardRef,
|
|
29
|
+
ReactNode,
|
|
30
|
+
useContext,
|
|
31
|
+
useEffect,
|
|
32
|
+
useMemo,
|
|
33
|
+
} from '../compat/react';
|
|
34
|
+
import { useColorPickerState } from '../upstream-exports/react-stately/useColorPickerState';
|
|
35
|
+
import { useLocale } from '../upstream-exports/react-aria/I18nProvider';
|
|
36
|
+
import { useLocalizedStringFormatter } from '../upstream-exports/react-aria/useLocalizedStringFormatter';
|
|
37
|
+
|
|
38
|
+
export interface ColorSwatchPickerRenderProps extends Omit<ListBoxRenderProps, 'isDropTarget'> {}
|
|
39
|
+
export interface ColorSwatchPickerProps
|
|
40
|
+
extends
|
|
41
|
+
ValueBase<string | Color, Color>,
|
|
42
|
+
AriaLabelingProps,
|
|
43
|
+
StyleRenderProps<ColorSwatchPickerRenderProps>,
|
|
44
|
+
GlobalDOMAttributes<HTMLDivElement> {
|
|
45
|
+
/**
|
|
46
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
47
|
+
* element. A function may be provided to compute the class based on component state.
|
|
48
|
+
*
|
|
49
|
+
* @default 'react-aria-ColorSwatchPicker'
|
|
50
|
+
*/
|
|
51
|
+
className?: ClassNameOrFunction<ColorSwatchPickerRenderProps>;
|
|
52
|
+
/** The children of the ColorSwatchPicker. */
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the items are arranged in a stack or grid.
|
|
56
|
+
*
|
|
57
|
+
* @default 'grid'
|
|
58
|
+
*/
|
|
59
|
+
layout?: 'grid' | 'stack';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const ColorSwatchPickerContext =
|
|
63
|
+
createContext<ContextValue<ColorSwatchPickerProps, HTMLDivElement>>(null);
|
|
64
|
+
const ColorMapContext = createContext<Map<string, Color> | null>(null);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* A ColorSwatchPicker displays a list of color swatches and allows a user to select one of them.
|
|
68
|
+
*/
|
|
69
|
+
export const ColorSwatchPicker = forwardRef(function ColorSwatchPicker(
|
|
70
|
+
props: ColorSwatchPickerProps,
|
|
71
|
+
ref: ForwardedRef<HTMLDivElement>,
|
|
72
|
+
) {
|
|
73
|
+
[props, ref] = useContextProps(props, ref, ColorSwatchPickerContext);
|
|
74
|
+
let state = useColorPickerState(props);
|
|
75
|
+
let colorMap = useMemo(() => new Map(), []);
|
|
76
|
+
let formatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<ListBox
|
|
80
|
+
{...filterDOMProps(props, { labelable: true })}
|
|
81
|
+
ref={ref}
|
|
82
|
+
className={props.className || 'react-aria-ColorSwatchPicker'}
|
|
83
|
+
style={props.style}
|
|
84
|
+
aria-label={
|
|
85
|
+
props['aria-label'] ||
|
|
86
|
+
(!props['aria-labelledby'] ? formatter.format('colorSwatchPicker') : undefined)
|
|
87
|
+
}
|
|
88
|
+
layout={props.layout || 'grid'}
|
|
89
|
+
selectionMode="single"
|
|
90
|
+
selectedKeys={[state.color.toString('hexa')]}
|
|
91
|
+
onSelectionChange={(keys) => {
|
|
92
|
+
// single select, 'all' cannot occur. appease typescript.
|
|
93
|
+
if (keys !== 'all') {
|
|
94
|
+
state.setColor(colorMap.get([...keys][0]));
|
|
95
|
+
}
|
|
96
|
+
}}
|
|
97
|
+
disallowEmptySelection
|
|
98
|
+
>
|
|
99
|
+
<ColorMapContext.Provider value={colorMap}>{props.children}</ColorMapContext.Provider>
|
|
100
|
+
</ListBox>
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export interface ColorSwatchPickerItemRenderProps extends Omit<
|
|
105
|
+
ListBoxItemRenderProps,
|
|
106
|
+
'selectionMode' | 'selectionBehavior'
|
|
107
|
+
> {
|
|
108
|
+
/** The color of the swatch. */
|
|
109
|
+
color: Color;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface ColorSwatchPickerItemProps
|
|
113
|
+
extends
|
|
114
|
+
RenderProps<ColorSwatchPickerItemRenderProps>,
|
|
115
|
+
HoverEvents,
|
|
116
|
+
PressEvents,
|
|
117
|
+
Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {
|
|
118
|
+
/**
|
|
119
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
120
|
+
* element. A function may be provided to compute the class based on component state.
|
|
121
|
+
*
|
|
122
|
+
* @default 'react-aria-ColorSwatchPickerItem'
|
|
123
|
+
*/
|
|
124
|
+
className?: ClassNameOrFunction<ColorSwatchPickerItemRenderProps>;
|
|
125
|
+
/** The color of the swatch. */
|
|
126
|
+
color: string | Color;
|
|
127
|
+
/** Whether the color swatch is disabled. */
|
|
128
|
+
isDisabled?: boolean;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export const ColorSwatchPickerItem = forwardRef(function ColorSwatchPickerItem(
|
|
132
|
+
props: ColorSwatchPickerItemProps,
|
|
133
|
+
ref: ForwardedRef<HTMLDivElement>,
|
|
134
|
+
) {
|
|
135
|
+
let propColor = props.color || '#0000';
|
|
136
|
+
let color = useMemo(
|
|
137
|
+
() => (typeof propColor === 'string' ? parseColor(propColor) : propColor),
|
|
138
|
+
[propColor],
|
|
139
|
+
);
|
|
140
|
+
let { locale } = useLocale();
|
|
141
|
+
let map = useContext(ColorMapContext)!;
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
let key = color.toString('hexa');
|
|
144
|
+
map.set(key, color);
|
|
145
|
+
return () => {
|
|
146
|
+
map.delete(key);
|
|
147
|
+
};
|
|
148
|
+
}, [color, map]);
|
|
149
|
+
|
|
150
|
+
let wrap = (v: any) => {
|
|
151
|
+
// A `.tsrx` `@{ … }` body compiles children to a tagged BLOCK function,
|
|
152
|
+
// which is not a render prop. Wrapping it would strip the block tag and
|
|
153
|
+
// cause composeRenderProps to invoke it with render values.
|
|
154
|
+
if (typeof v === 'function' && !isChildrenBlock(v)) {
|
|
155
|
+
return (renderProps: any) => v({ ...renderProps, color });
|
|
156
|
+
}
|
|
157
|
+
return v;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<ListBoxItem
|
|
162
|
+
{...props}
|
|
163
|
+
// ColorSwatchPickerItem is never a link.
|
|
164
|
+
render={props.render as any}
|
|
165
|
+
ref={ref}
|
|
166
|
+
id={color.toString('hexa')}
|
|
167
|
+
textValue={color.getColorName(locale)}
|
|
168
|
+
className={wrap(props.className || 'react-aria-ColorSwatchPickerItem')}
|
|
169
|
+
style={wrap(props.style)}
|
|
170
|
+
>
|
|
171
|
+
{composeRenderProps(wrap(props.children), (children) => (
|
|
172
|
+
<ColorSwatchContext.Provider value={{ color }}>{children}</ColorSwatchContext.Provider>
|
|
173
|
+
))}
|
|
174
|
+
</ListBoxItem>
|
|
175
|
+
);
|
|
176
|
+
});
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-aria-components/src/ColorThumb.tsx).
|
|
3
|
+
import { ClassNameOrFunction, dom, RenderProps, useRenderProps } from './utils';
|
|
4
|
+
import { Color } from '../upstream-exports/react-stately/Color';
|
|
5
|
+
import { filterDOMProps } from '../upstream-exports/react-aria/filterDOMProps';
|
|
6
|
+
import { GlobalDOMAttributes, HoverEvents, RefObject } from '@react-types/shared';
|
|
7
|
+
import { mergeProps } from '../upstream-exports/react-aria/mergeProps';
|
|
8
|
+
import React, {
|
|
9
|
+
createContext,
|
|
10
|
+
ForwardedRef,
|
|
11
|
+
forwardRef,
|
|
12
|
+
HTMLAttributes,
|
|
13
|
+
InputHTMLAttributes,
|
|
14
|
+
useContext,
|
|
15
|
+
} from '../compat/react';
|
|
16
|
+
import { useFocusRing } from '../upstream-exports/react-aria/useFocusRing';
|
|
17
|
+
import { useHover } from '../upstream-exports/react-aria/useHover';
|
|
18
|
+
|
|
19
|
+
interface ColorState {
|
|
20
|
+
getDisplayColor(): Color;
|
|
21
|
+
isDragging: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface InternalColorThumbContextValue {
|
|
25
|
+
state: ColorState;
|
|
26
|
+
thumbProps: HTMLAttributes<HTMLElement>;
|
|
27
|
+
inputXRef: RefObject<HTMLInputElement | null>;
|
|
28
|
+
inputYRef?: RefObject<HTMLInputElement | null>;
|
|
29
|
+
xInputProps: InputHTMLAttributes<HTMLInputElement>;
|
|
30
|
+
yInputProps?: InputHTMLAttributes<HTMLInputElement>;
|
|
31
|
+
isDisabled?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const InternalColorThumbContext = createContext<InternalColorThumbContextValue | null>(null);
|
|
35
|
+
|
|
36
|
+
export interface ColorThumbRenderProps {
|
|
37
|
+
/**
|
|
38
|
+
* The selected color, excluding the alpha channel.
|
|
39
|
+
*/
|
|
40
|
+
color: Color;
|
|
41
|
+
/**
|
|
42
|
+
* Whether this thumb is currently being dragged.
|
|
43
|
+
*
|
|
44
|
+
* @selector [data-dragging]
|
|
45
|
+
*/
|
|
46
|
+
isDragging: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the thumb is currently hovered with a mouse.
|
|
49
|
+
*
|
|
50
|
+
* @selector [data-hovered]
|
|
51
|
+
*/
|
|
52
|
+
isHovered: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether the thumb is currently focused.
|
|
55
|
+
*
|
|
56
|
+
* @selector [data-focused]
|
|
57
|
+
*/
|
|
58
|
+
isFocused: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the thumb is keyboard focused.
|
|
61
|
+
*
|
|
62
|
+
* @selector [data-focus-visible]
|
|
63
|
+
*/
|
|
64
|
+
isFocusVisible: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the thumb is disabled.
|
|
67
|
+
*
|
|
68
|
+
* @selector [data-disabled]
|
|
69
|
+
*/
|
|
70
|
+
isDisabled: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface ColorThumbProps
|
|
74
|
+
extends HoverEvents, RenderProps<ColorThumbRenderProps>, GlobalDOMAttributes<HTMLDivElement> {
|
|
75
|
+
/**
|
|
76
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
77
|
+
* element. A function may be provided to compute the class based on component state.
|
|
78
|
+
*
|
|
79
|
+
* @default 'react-aria-ColorThumb'
|
|
80
|
+
*/
|
|
81
|
+
className?: ClassNameOrFunction<ColorThumbRenderProps>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A color thumb appears within a ColorArea, ColorSlider, or ColorWheel and allows a user to drag to
|
|
86
|
+
* adjust the color value.
|
|
87
|
+
*/
|
|
88
|
+
export const ColorThumb = forwardRef(function ColorThumb(
|
|
89
|
+
props: ColorThumbProps,
|
|
90
|
+
ref: ForwardedRef<HTMLDivElement>,
|
|
91
|
+
) {
|
|
92
|
+
let {
|
|
93
|
+
state,
|
|
94
|
+
thumbProps,
|
|
95
|
+
inputXRef,
|
|
96
|
+
inputYRef,
|
|
97
|
+
xInputProps,
|
|
98
|
+
yInputProps,
|
|
99
|
+
isDisabled = false,
|
|
100
|
+
} = useContext(InternalColorThumbContext)!;
|
|
101
|
+
let { focusProps, isFocused, isFocusVisible } = useFocusRing();
|
|
102
|
+
let { hoverProps, isHovered } = useHover(props);
|
|
103
|
+
|
|
104
|
+
let renderProps = useRenderProps({
|
|
105
|
+
...props,
|
|
106
|
+
defaultClassName: 'react-aria-ColorThumb',
|
|
107
|
+
defaultStyle: {
|
|
108
|
+
...thumbProps.style,
|
|
109
|
+
backgroundColor: state.getDisplayColor().toString(),
|
|
110
|
+
},
|
|
111
|
+
values: {
|
|
112
|
+
color: state.getDisplayColor(),
|
|
113
|
+
isHovered,
|
|
114
|
+
isDragging: state.isDragging,
|
|
115
|
+
isFocused,
|
|
116
|
+
isFocusVisible,
|
|
117
|
+
isDisabled,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
let DOMProps = filterDOMProps(props, { global: true });
|
|
122
|
+
delete DOMProps.id;
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<dom.div
|
|
126
|
+
{...mergeProps(thumbProps, hoverProps, DOMProps)}
|
|
127
|
+
{...renderProps}
|
|
128
|
+
ref={ref}
|
|
129
|
+
data-hovered={isHovered || undefined}
|
|
130
|
+
data-dragging={state.isDragging || undefined}
|
|
131
|
+
data-focused={isFocused || undefined}
|
|
132
|
+
data-focus-visible={isFocusVisible || undefined}
|
|
133
|
+
data-disabled={isDisabled || undefined}
|
|
134
|
+
>
|
|
135
|
+
<input ref={inputXRef} {...xInputProps} {...focusProps} />
|
|
136
|
+
{yInputProps && <input ref={inputYRef} {...yInputProps} {...focusProps} />}
|
|
137
|
+
{renderProps.children}
|
|
138
|
+
</dom.div>
|
|
139
|
+
);
|
|
140
|
+
});
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-aria-components/src/ColorWheel.tsx).
|
|
3
|
+
import { AriaColorWheelOptions, useColorWheel } from '../upstream-exports/react-aria/useColorWheel';
|
|
4
|
+
import {
|
|
5
|
+
ClassNameOrFunction,
|
|
6
|
+
ContextValue,
|
|
7
|
+
dom,
|
|
8
|
+
Provider,
|
|
9
|
+
RenderProps,
|
|
10
|
+
SlotProps,
|
|
11
|
+
StyleRenderProps,
|
|
12
|
+
useContextProps,
|
|
13
|
+
useRenderProps,
|
|
14
|
+
} from './utils';
|
|
15
|
+
import {
|
|
16
|
+
ColorWheelState,
|
|
17
|
+
useColorWheelState,
|
|
18
|
+
} from '../upstream-exports/react-stately/useColorWheelState';
|
|
19
|
+
import { filterDOMProps } from '../upstream-exports/react-aria/filterDOMProps';
|
|
20
|
+
import { GlobalDOMAttributes } from '@react-types/shared';
|
|
21
|
+
import { InternalColorThumbContext } from './ColorThumb';
|
|
22
|
+
import React, {
|
|
23
|
+
createContext,
|
|
24
|
+
ForwardedRef,
|
|
25
|
+
forwardRef,
|
|
26
|
+
HTMLAttributes,
|
|
27
|
+
useContext,
|
|
28
|
+
useRef,
|
|
29
|
+
} from '../compat/react';
|
|
30
|
+
|
|
31
|
+
export interface ColorWheelRenderProps {
|
|
32
|
+
/**
|
|
33
|
+
* Whether the color wheel is disabled.
|
|
34
|
+
*
|
|
35
|
+
* @selector [data-disabled]
|
|
36
|
+
*/
|
|
37
|
+
isDisabled: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* State of the color wheel.
|
|
40
|
+
*/
|
|
41
|
+
state: ColorWheelState;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ColorWheelProps
|
|
45
|
+
extends
|
|
46
|
+
AriaColorWheelOptions,
|
|
47
|
+
RenderProps<ColorWheelRenderProps>,
|
|
48
|
+
SlotProps,
|
|
49
|
+
GlobalDOMAttributes<HTMLDivElement> {
|
|
50
|
+
/**
|
|
51
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
52
|
+
* element. A function may be provided to compute the class based on component state.
|
|
53
|
+
*
|
|
54
|
+
* @default 'react-aria-ColorWheel'
|
|
55
|
+
*/
|
|
56
|
+
className?: ClassNameOrFunction<ColorWheelRenderProps>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const ColorWheelContext =
|
|
60
|
+
createContext<ContextValue<Partial<ColorWheelProps>, HTMLDivElement>>(null);
|
|
61
|
+
export const ColorWheelStateContext = createContext<ColorWheelState | null>(null);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A color wheel allows users to adjust the hue of an HSL or HSB color value on a circular track.
|
|
65
|
+
*/
|
|
66
|
+
export const ColorWheel = forwardRef(function ColorWheel(
|
|
67
|
+
props: ColorWheelProps,
|
|
68
|
+
ref: ForwardedRef<HTMLDivElement>,
|
|
69
|
+
) {
|
|
70
|
+
[props, ref] = useContextProps(props, ref, ColorWheelContext);
|
|
71
|
+
let state = useColorWheelState(props);
|
|
72
|
+
let inputRef = useRef(null);
|
|
73
|
+
let { trackProps, inputProps, thumbProps } = useColorWheel(props, state, inputRef);
|
|
74
|
+
|
|
75
|
+
let renderProps = useRenderProps({
|
|
76
|
+
...props,
|
|
77
|
+
values: {
|
|
78
|
+
state,
|
|
79
|
+
isDisabled: props.isDisabled || false,
|
|
80
|
+
},
|
|
81
|
+
defaultClassName: 'react-aria-ColorWheel',
|
|
82
|
+
defaultStyle: {
|
|
83
|
+
position: 'relative',
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
let DOMProps = filterDOMProps(props, { global: true });
|
|
88
|
+
delete DOMProps.id;
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<dom.div
|
|
92
|
+
{...DOMProps}
|
|
93
|
+
{...renderProps}
|
|
94
|
+
ref={ref}
|
|
95
|
+
slot={props.slot || undefined}
|
|
96
|
+
data-disabled={props.isDisabled || undefined}
|
|
97
|
+
>
|
|
98
|
+
<Provider
|
|
99
|
+
values={[
|
|
100
|
+
[ColorWheelStateContext, state],
|
|
101
|
+
[ColorWheelTrackContext, trackProps],
|
|
102
|
+
[
|
|
103
|
+
InternalColorThumbContext,
|
|
104
|
+
{
|
|
105
|
+
state,
|
|
106
|
+
thumbProps,
|
|
107
|
+
inputXRef: inputRef,
|
|
108
|
+
xInputProps: inputProps,
|
|
109
|
+
isDisabled: props.isDisabled,
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
]}
|
|
113
|
+
>
|
|
114
|
+
{renderProps.children}
|
|
115
|
+
</Provider>
|
|
116
|
+
</dom.div>
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
export interface ColorWheelTrackRenderProps extends ColorWheelRenderProps {}
|
|
121
|
+
export interface ColorWheelTrackProps
|
|
122
|
+
extends StyleRenderProps<ColorWheelTrackRenderProps>, GlobalDOMAttributes<HTMLDivElement> {
|
|
123
|
+
/**
|
|
124
|
+
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the
|
|
125
|
+
* element. A function may be provided to compute the class based on component state.
|
|
126
|
+
*
|
|
127
|
+
* @default 'react-aria-ColorWheelTrack'
|
|
128
|
+
*/
|
|
129
|
+
className?: ClassNameOrFunction<ColorWheelTrackRenderProps>;
|
|
130
|
+
}
|
|
131
|
+
interface ColorWheelTrackContextValue
|
|
132
|
+
extends
|
|
133
|
+
Omit<HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'>,
|
|
134
|
+
StyleRenderProps<ColorWheelTrackRenderProps> {}
|
|
135
|
+
|
|
136
|
+
export const ColorWheelTrackContext =
|
|
137
|
+
createContext<ContextValue<ColorWheelTrackContextValue, HTMLDivElement>>(null);
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* A color wheel track renders a circular gradient track.
|
|
141
|
+
*/
|
|
142
|
+
export const ColorWheelTrack = forwardRef(function ColorWheelTrack(
|
|
143
|
+
props: ColorWheelTrackProps,
|
|
144
|
+
ref: ForwardedRef<HTMLDivElement>,
|
|
145
|
+
) {
|
|
146
|
+
[props, ref] = useContextProps(props, ref, ColorWheelTrackContext);
|
|
147
|
+
let state = useContext(ColorWheelStateContext)!;
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
149
|
+
let { className, style, ...rest } = props;
|
|
150
|
+
|
|
151
|
+
let renderProps = useRenderProps({
|
|
152
|
+
...props,
|
|
153
|
+
defaultClassName: 'react-aria-ColorWheelTrack',
|
|
154
|
+
values: {
|
|
155
|
+
isDisabled: state.isDisabled,
|
|
156
|
+
state,
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<dom.div {...rest} {...renderProps} ref={ref} data-disabled={state.isDisabled || undefined} />
|
|
162
|
+
);
|
|
163
|
+
});
|