@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,19 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/exports/useDraggableCollectionState.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
|
+
export type {
|
|
16
|
+
DraggableCollectionStateOptions,
|
|
17
|
+
DraggableCollectionState,
|
|
18
|
+
} from '../../stately/dnd/useDraggableCollectionState';
|
|
19
|
+
export { useDraggableCollectionState } from '../../stately/dnd/useDraggableCollectionState';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/exports/useDroppableCollectionState.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
|
+
export type {
|
|
16
|
+
DroppableCollectionStateOptions,
|
|
17
|
+
DroppableCollectionState,
|
|
18
|
+
} from '../../stately/dnd/useDroppableCollectionState';
|
|
19
|
+
export { useDroppableCollectionState } from '../../stately/dnd/useDroppableCollectionState';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/exports/useRangeCalendarState.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
|
+
export { useRangeCalendarState } from '../../stately/calendar/useRangeCalendarState';
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
DateRange,
|
|
19
|
+
RangeCalendarProps,
|
|
20
|
+
RangeCalendarStateOptions,
|
|
21
|
+
} from '../../stately/calendar/useRangeCalendarState';
|
|
22
|
+
export type {
|
|
23
|
+
DateValue,
|
|
24
|
+
RangeCalendarState,
|
|
25
|
+
CalendarPropsBase,
|
|
26
|
+
PageBehavior,
|
|
27
|
+
} from '../../stately/calendar/types';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/exports/useTimeFieldState.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
|
+
export { useTimeFieldState } from '../../stately/datepicker/useTimeFieldState';
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
TimeFieldStateOptions,
|
|
19
|
+
TimeFieldState,
|
|
20
|
+
} from '../../stately/datepicker/useTimeFieldState';
|
|
21
|
+
export type {
|
|
22
|
+
TimeValue,
|
|
23
|
+
TimePickerProps,
|
|
24
|
+
Granularity,
|
|
25
|
+
MappedTimeValue,
|
|
26
|
+
} from '../../stately/datepicker/types';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/exports/useToastState.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
|
+
export { useToastState, ToastQueue, useToastQueue } from '../../stately/toast/useToastState';
|
|
15
|
+
|
|
16
|
+
export type {
|
|
17
|
+
ToastState,
|
|
18
|
+
QueuedToast,
|
|
19
|
+
ToastStateProps,
|
|
20
|
+
ToastOptions,
|
|
21
|
+
} from '../../stately/toast/useToastState';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/exports/useVirtualizerState.ts).
|
|
3
|
+
export {
|
|
4
|
+
useVirtualizerState,
|
|
5
|
+
type VirtualizerState,
|
|
6
|
+
} from '../../stately/virtualizer/useVirtualizerState';
|
|
7
|
+
export { Layout } from '../../stately/virtualizer/Layout';
|
|
8
|
+
export { LayoutInfo } from '../../stately/virtualizer/LayoutInfo';
|
|
9
|
+
export { Point } from '../../stately/virtualizer/Point';
|
|
10
|
+
export { Rect, type RectCorner } from '../../stately/virtualizer/Rect';
|
|
11
|
+
export { ReusableView } from '../../stately/virtualizer/ReusableView';
|
|
12
|
+
export { Size } from '../../stately/virtualizer/Size';
|
|
13
|
+
export { type InvalidationContext } from '../../stately/virtualizer/types';
|
|
14
|
+
|
|
15
|
+
export { GridLayout, type GridLayoutOptions } from '../../stately/layout/GridLayout';
|
|
16
|
+
export {
|
|
17
|
+
ListLayout,
|
|
18
|
+
type ListLayoutOptions,
|
|
19
|
+
type LayoutNode,
|
|
20
|
+
} from '../../stately/layout/ListLayout';
|
|
21
|
+
export { TableLayout, type TableLayoutProps } from '../../stately/layout/TableLayout';
|
|
22
|
+
export { WaterfallLayout, type WaterfallLayoutOptions } from '../../stately/layout/WaterfallLayout';
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-aria/src/utils/useLoadMore.ts).
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2024 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 { RefObject, useCallback, useRef } from '../compat/react';
|
|
16
|
+
import { useEvent } from './useEvent';
|
|
17
|
+
|
|
18
|
+
import { useLayoutEffect } from './useLayoutEffect';
|
|
19
|
+
|
|
20
|
+
export interface LoadMoreProps {
|
|
21
|
+
/** Whether data is currently being loaded. */
|
|
22
|
+
isLoading?: boolean;
|
|
23
|
+
/** Handler that is called when more items should be loaded, e.g. while scrolling near the bottom. */
|
|
24
|
+
onLoadMore?: () => void;
|
|
25
|
+
/**
|
|
26
|
+
* The amount of offset from the bottom of your scrollable region that should trigger load more.
|
|
27
|
+
* Uses a percentage value relative to the scroll body's client height. Load more is then
|
|
28
|
+
* triggered when your current scroll position's distance from the bottom of the currently loaded
|
|
29
|
+
* list of items is less than or equal to the provided value. (e.g. 1 = 100% of the scroll
|
|
30
|
+
* region's height).
|
|
31
|
+
*
|
|
32
|
+
* @default 1
|
|
33
|
+
*/
|
|
34
|
+
scrollOffset?: number;
|
|
35
|
+
/** The data currently loaded. */
|
|
36
|
+
items?: any;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function useLoadMore(props: LoadMoreProps, ref: RefObject<HTMLElement | null>): void {
|
|
40
|
+
let { isLoading, onLoadMore, scrollOffset = 1, items } = props;
|
|
41
|
+
|
|
42
|
+
// Handle scrolling, and call onLoadMore when nearing the bottom.
|
|
43
|
+
let isLoadingRef = useRef(isLoading);
|
|
44
|
+
let prevProps = useRef(props);
|
|
45
|
+
let onScroll = useCallback(() => {
|
|
46
|
+
if (ref.current && !isLoadingRef.current && onLoadMore) {
|
|
47
|
+
let shouldLoadMore =
|
|
48
|
+
ref.current.scrollHeight - ref.current.scrollTop - ref.current.clientHeight <
|
|
49
|
+
ref.current.clientHeight * scrollOffset;
|
|
50
|
+
|
|
51
|
+
if (shouldLoadMore) {
|
|
52
|
+
isLoadingRef.current = true;
|
|
53
|
+
onLoadMore();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, [onLoadMore, ref, scrollOffset]);
|
|
57
|
+
|
|
58
|
+
let lastItems = useRef(items);
|
|
59
|
+
useLayoutEffect(() => {
|
|
60
|
+
// Only update isLoadingRef if props object actually changed,
|
|
61
|
+
// not if a local state change occurred.
|
|
62
|
+
if (props !== prevProps.current) {
|
|
63
|
+
isLoadingRef.current = isLoading;
|
|
64
|
+
prevProps.current = props;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// TODO: Eventually this hook will move back into RAC during which we will accept the collection as a option to this hook.
|
|
68
|
+
// We will only load more if the collection has changed after the last load to prevent multiple onLoadMore from being called
|
|
69
|
+
// while the data from the last onLoadMore is being processed by RAC collection.
|
|
70
|
+
let shouldLoadMore =
|
|
71
|
+
ref?.current &&
|
|
72
|
+
!isLoadingRef.current &&
|
|
73
|
+
onLoadMore &&
|
|
74
|
+
(!items || items !== lastItems.current) &&
|
|
75
|
+
ref.current.clientHeight === ref.current.scrollHeight;
|
|
76
|
+
|
|
77
|
+
if (shouldLoadMore) {
|
|
78
|
+
isLoadingRef.current = true;
|
|
79
|
+
onLoadMore?.();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
lastItems.current = items;
|
|
83
|
+
}, [isLoading, onLoadMore, props, ref, items]);
|
|
84
|
+
|
|
85
|
+
// TODO: maybe this should still just return scroll props?
|
|
86
|
+
// Test against case where the ref isn't defined when this is called
|
|
87
|
+
// Think this was a problem when trying to attach to the scrollable body of the table in OnLoadMoreTableBodyScroll
|
|
88
|
+
useEvent(ref, 'scroll', onScroll);
|
|
89
|
+
}
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-aria/src/virtualizer/ScrollView.tsx).
|
|
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
|
+
// @ts-ignore
|
|
16
|
+
import { flushSync } from 'octane';
|
|
17
|
+
import { getEventTarget, nodeContains } from '../utils/shadowdom/DOMFunctions';
|
|
18
|
+
import { getScrollLeft } from './utils';
|
|
19
|
+
import { Point, Rect, Size } from '../upstream-exports/react-stately/useVirtualizerState';
|
|
20
|
+
import React, {
|
|
21
|
+
CSSProperties,
|
|
22
|
+
ForwardedRef,
|
|
23
|
+
HTMLAttributes,
|
|
24
|
+
ReactNode,
|
|
25
|
+
RefObject,
|
|
26
|
+
useCallback,
|
|
27
|
+
useEffect,
|
|
28
|
+
useRef,
|
|
29
|
+
useState,
|
|
30
|
+
} from '../compat/react';
|
|
31
|
+
import { useEffectEvent } from '../utils/useEffectEvent';
|
|
32
|
+
import { useLayoutEffect } from '../utils/useLayoutEffect';
|
|
33
|
+
import { useLocale } from '../i18n/I18nProvider';
|
|
34
|
+
import { useObjectRef } from '../utils/useObjectRef';
|
|
35
|
+
import { useResizeObserver } from '../utils/useResizeObserver';
|
|
36
|
+
|
|
37
|
+
interface ScrollViewProps extends Omit<HTMLAttributes<HTMLElement>, 'onScroll'> {
|
|
38
|
+
contentSize: Size;
|
|
39
|
+
onVisibleRectChange: (rect: Rect) => void;
|
|
40
|
+
onSizeChange?: (size: Size) => void;
|
|
41
|
+
children?: ReactNode;
|
|
42
|
+
innerStyle?: CSSProperties;
|
|
43
|
+
onScrollStart?: () => void;
|
|
44
|
+
onScrollEnd?: () => void;
|
|
45
|
+
scrollDirection?: 'horizontal' | 'vertical' | 'both';
|
|
46
|
+
onScroll?: (e: Event) => void;
|
|
47
|
+
allowsWindowScrolling?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function ScrollView(props: ScrollViewProps, ref: ForwardedRef<HTMLDivElement | null>) {
|
|
51
|
+
ref = useObjectRef(ref);
|
|
52
|
+
let { scrollViewProps, contentProps } = useScrollView(props, ref);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div role="presentation" {...scrollViewProps} ref={ref}>
|
|
56
|
+
<div {...contentProps}>{props.children}</div>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const ScrollViewForwardRef: React.ForwardRefExoticComponent<
|
|
62
|
+
ScrollViewProps & React.RefAttributes<HTMLDivElement | null>
|
|
63
|
+
> = React.forwardRef(ScrollView);
|
|
64
|
+
export { ScrollViewForwardRef as ScrollView };
|
|
65
|
+
|
|
66
|
+
interface ScrollViewAria {
|
|
67
|
+
isScrolling: boolean;
|
|
68
|
+
scrollViewProps: HTMLAttributes<HTMLElement>;
|
|
69
|
+
contentProps: HTMLAttributes<HTMLElement>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function useScrollView(
|
|
73
|
+
props: ScrollViewProps,
|
|
74
|
+
ref: RefObject<HTMLElement | null>,
|
|
75
|
+
): ScrollViewAria {
|
|
76
|
+
let {
|
|
77
|
+
contentSize,
|
|
78
|
+
onVisibleRectChange,
|
|
79
|
+
onSizeChange,
|
|
80
|
+
innerStyle,
|
|
81
|
+
onScrollStart,
|
|
82
|
+
onScrollEnd,
|
|
83
|
+
scrollDirection = 'both',
|
|
84
|
+
onScroll: onScrollProp,
|
|
85
|
+
allowsWindowScrolling,
|
|
86
|
+
...otherProps
|
|
87
|
+
} = props;
|
|
88
|
+
|
|
89
|
+
let state = useRef({
|
|
90
|
+
// Internal scroll position of the scroll view.
|
|
91
|
+
scrollPosition: new Point(),
|
|
92
|
+
// Size of the scroll view.
|
|
93
|
+
size: new Size(),
|
|
94
|
+
// Offset of the scroll view relative to the window viewport.
|
|
95
|
+
viewportOffset: new Point(),
|
|
96
|
+
// Size of the window viewport.
|
|
97
|
+
viewportSize: new Size(),
|
|
98
|
+
scrollEndTime: 0,
|
|
99
|
+
scrollTimeout: null as ReturnType<typeof setTimeout> | null,
|
|
100
|
+
isScrolling: false,
|
|
101
|
+
lastVisibleRect: new Rect(),
|
|
102
|
+
}).current;
|
|
103
|
+
let { direction } = useLocale();
|
|
104
|
+
|
|
105
|
+
let updateVisibleRect = useCallback(() => {
|
|
106
|
+
// Intersect the window viewport with the scroll view itself to find the actual visible rectangle.
|
|
107
|
+
// This allows virtualized components to have unbounded height but still virtualize when scrolled with the page.
|
|
108
|
+
// While there may be other scrollable elements between the <body> and the scroll view, we do not take
|
|
109
|
+
// their sizes into account for performance reasons. Their scroll positions are accounted for in viewportOffset
|
|
110
|
+
// though (due to getBoundingClientRect). This may result in more rows than absolutely necessary being rendered,
|
|
111
|
+
// but no more than the entire height of the viewport which is good enough for virtualization use cases.
|
|
112
|
+
let visibleRect = allowsWindowScrolling
|
|
113
|
+
? new Rect(
|
|
114
|
+
state.viewportOffset.x + state.scrollPosition.x,
|
|
115
|
+
state.viewportOffset.y + state.scrollPosition.y,
|
|
116
|
+
Math.max(
|
|
117
|
+
0,
|
|
118
|
+
Math.min(state.size.width - state.viewportOffset.x, state.viewportSize.width),
|
|
119
|
+
),
|
|
120
|
+
Math.max(
|
|
121
|
+
0,
|
|
122
|
+
Math.min(state.size.height - state.viewportOffset.y, state.viewportSize.height),
|
|
123
|
+
),
|
|
124
|
+
)
|
|
125
|
+
: new Rect(
|
|
126
|
+
state.scrollPosition.x,
|
|
127
|
+
state.scrollPosition.y,
|
|
128
|
+
state.size.width,
|
|
129
|
+
state.size.height,
|
|
130
|
+
);
|
|
131
|
+
// Don't emit updates if the visible area is zero and the last emitted area was also zero.
|
|
132
|
+
if (visibleRect.area > 0 || state.lastVisibleRect.area > 0) {
|
|
133
|
+
onVisibleRectChange(visibleRect);
|
|
134
|
+
state.lastVisibleRect = visibleRect;
|
|
135
|
+
}
|
|
136
|
+
}, [state, allowsWindowScrolling, onVisibleRectChange]);
|
|
137
|
+
|
|
138
|
+
let [isScrolling, setScrolling] = useState(false);
|
|
139
|
+
|
|
140
|
+
let onScroll = useCallback(
|
|
141
|
+
(e: Event) => {
|
|
142
|
+
let target = getEventTarget(e) as Element;
|
|
143
|
+
if (!nodeContains(target, ref.current!)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (onScrollProp && target === ref.current) {
|
|
148
|
+
onScrollProp(e);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (target !== ref.current) {
|
|
152
|
+
// An ancestor element or the window was scrolled. Update the position of the scroll view relative to the viewport.
|
|
153
|
+
let boundingRect = ref.current!.getBoundingClientRect();
|
|
154
|
+
let x = boundingRect.x < 0 ? -boundingRect.x : 0;
|
|
155
|
+
let y = boundingRect.y < 0 ? -boundingRect.y : 0;
|
|
156
|
+
if (x === state.viewportOffset.x && y === state.viewportOffset.y) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
state.viewportOffset = new Point(x, y);
|
|
161
|
+
} else {
|
|
162
|
+
// The scroll view itself was scrolled. Update the local scroll position.
|
|
163
|
+
// Prevent rubber band scrolling from shaking when scrolling out of bounds
|
|
164
|
+
let scrollTop = target.scrollTop;
|
|
165
|
+
let scrollLeft = getScrollLeft(target, direction);
|
|
166
|
+
state.scrollPosition = new Point(
|
|
167
|
+
Math.max(0, Math.min(scrollLeft, contentSize.width - state.size.width)),
|
|
168
|
+
Math.max(0, Math.min(scrollTop, contentSize.height - state.size.height)),
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
flushSync(() => {
|
|
173
|
+
updateVisibleRect();
|
|
174
|
+
|
|
175
|
+
if (!state.isScrolling) {
|
|
176
|
+
state.isScrolling = true;
|
|
177
|
+
setScrolling(true);
|
|
178
|
+
|
|
179
|
+
// Pause typekit MutationObserver during scrolling.
|
|
180
|
+
window.dispatchEvent(new Event('tk.disconnect-observer'));
|
|
181
|
+
if (onScrollStart) {
|
|
182
|
+
onScrollStart();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// So we don't constantly call clearTimeout and setTimeout,
|
|
187
|
+
// keep track of the current timeout time and only reschedule
|
|
188
|
+
// the timer when it is getting close.
|
|
189
|
+
let now = Date.now();
|
|
190
|
+
if (state.scrollEndTime <= now + 50) {
|
|
191
|
+
state.scrollEndTime = now + 300;
|
|
192
|
+
|
|
193
|
+
if (state.scrollTimeout != null) {
|
|
194
|
+
clearTimeout(state.scrollTimeout);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
state.scrollTimeout = setTimeout(() => {
|
|
198
|
+
state.isScrolling = false;
|
|
199
|
+
setScrolling(false);
|
|
200
|
+
state.scrollTimeout = null;
|
|
201
|
+
|
|
202
|
+
window.dispatchEvent(new Event('tk.connect-observer'));
|
|
203
|
+
if (onScrollEnd) {
|
|
204
|
+
onScrollEnd();
|
|
205
|
+
}
|
|
206
|
+
}, 300);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
[
|
|
211
|
+
onScrollProp,
|
|
212
|
+
ref,
|
|
213
|
+
direction,
|
|
214
|
+
state,
|
|
215
|
+
contentSize,
|
|
216
|
+
updateVisibleRect,
|
|
217
|
+
onScrollStart,
|
|
218
|
+
onScrollEnd,
|
|
219
|
+
],
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
// Attach a document-level capturing scroll listener so we can account for scrollable ancestors.
|
|
223
|
+
useEffect(() => {
|
|
224
|
+
document.addEventListener('scroll', onScroll, true);
|
|
225
|
+
return () => document.removeEventListener('scroll', onScroll, true);
|
|
226
|
+
}, [onScroll]);
|
|
227
|
+
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
return () => {
|
|
230
|
+
if (state.scrollTimeout != null) {
|
|
231
|
+
clearTimeout(state.scrollTimeout);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (state.isScrolling) {
|
|
235
|
+
window.dispatchEvent(new Event('tk.connect-observer'));
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
239
|
+
}, []);
|
|
240
|
+
|
|
241
|
+
let isUpdatingSize = useRef(false);
|
|
242
|
+
let updateSize = useCallback(
|
|
243
|
+
(flush: typeof flushSync) => {
|
|
244
|
+
let dom = ref.current;
|
|
245
|
+
if (!dom || isUpdatingSize.current) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Prevent reentrancy when resize observer fires, triggers re-layout that results in
|
|
250
|
+
// content size update, causing below layout effect to fire. This avoids infinite loops.
|
|
251
|
+
isUpdatingSize.current = true;
|
|
252
|
+
|
|
253
|
+
let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;
|
|
254
|
+
let isClientWidthMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes(
|
|
255
|
+
'clientWidth',
|
|
256
|
+
);
|
|
257
|
+
let isClientHeightMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes(
|
|
258
|
+
'clientHeight',
|
|
259
|
+
);
|
|
260
|
+
let clientWidth = dom.clientWidth;
|
|
261
|
+
let clientHeight = dom.clientHeight;
|
|
262
|
+
let w = isTestEnv && !isClientWidthMocked ? Infinity : clientWidth;
|
|
263
|
+
let h = isTestEnv && !isClientHeightMocked ? Infinity : clientHeight;
|
|
264
|
+
|
|
265
|
+
// Update the window viewport size.
|
|
266
|
+
let viewportWidth = window.innerWidth;
|
|
267
|
+
let viewportHeight = window.innerHeight;
|
|
268
|
+
let viewportSizeChanged =
|
|
269
|
+
state.viewportSize.width !== viewportWidth || state.viewportSize.height !== viewportHeight;
|
|
270
|
+
if (viewportSizeChanged) {
|
|
271
|
+
state.viewportSize = new Size(viewportWidth, viewportHeight);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (state.size.width !== w || state.size.height !== h || viewportSizeChanged) {
|
|
275
|
+
state.size = new Size(w, h);
|
|
276
|
+
flush(() => {
|
|
277
|
+
updateVisibleRect();
|
|
278
|
+
onSizeChange?.(state.size);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// If the clientWidth or clientHeight changed, scrollbars appeared or disappeared as
|
|
282
|
+
// a result of the layout update. In this case, re-layout again to account for the
|
|
283
|
+
// adjusted space. In very specific cases this might result in the scrollbars disappearing
|
|
284
|
+
// again, resulting in extra padding. We stop after a maximum of two layout passes to avoid
|
|
285
|
+
// an infinite loop. This matches how browsers behavior with native CSS grid layout.
|
|
286
|
+
if ((!isTestEnv && clientWidth !== dom.clientWidth) || clientHeight !== dom.clientHeight) {
|
|
287
|
+
state.size = new Size(dom.clientWidth, dom.clientHeight);
|
|
288
|
+
flush(() => {
|
|
289
|
+
updateVisibleRect();
|
|
290
|
+
onSizeChange?.(state.size);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
isUpdatingSize.current = false;
|
|
296
|
+
},
|
|
297
|
+
[ref, state, updateVisibleRect, onSizeChange],
|
|
298
|
+
);
|
|
299
|
+
let updateSizeEvent = useEffectEvent(updateSize);
|
|
300
|
+
|
|
301
|
+
// Track the size of the entire window viewport, which is used to bound the size of the virtualizer's visible rectangle.
|
|
302
|
+
useLayoutEffect(() => {
|
|
303
|
+
// Initialize viewportRect before updating size for the first time.
|
|
304
|
+
state.viewportSize = new Size(window.innerWidth, window.innerHeight);
|
|
305
|
+
|
|
306
|
+
let onWindowResize = () => {
|
|
307
|
+
updateSizeEvent(flushSync);
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
window.addEventListener('resize', onWindowResize);
|
|
311
|
+
return () => window.removeEventListener('resize', onWindowResize);
|
|
312
|
+
}, [state]);
|
|
313
|
+
|
|
314
|
+
// Update visible rect when the content size changes, in case scrollbars need to appear or disappear.
|
|
315
|
+
let lastContentSize = useRef<Size | null>(null);
|
|
316
|
+
let [update, setUpdate] = useState({});
|
|
317
|
+
// We only contain a call to setState in here for testing environments.
|
|
318
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
319
|
+
useLayoutEffect(() => {
|
|
320
|
+
if (
|
|
321
|
+
!isUpdatingSize.current &&
|
|
322
|
+
(lastContentSize.current == null || !contentSize.equals(lastContentSize.current))
|
|
323
|
+
) {
|
|
324
|
+
// React doesn't allow flushSync inside effects, so queue a microtask.
|
|
325
|
+
// We also need to wait until all refs are set (e.g. when passing a ref down from a parent).
|
|
326
|
+
// If we are in an `act` environment, update immediately without a microtask so you don't need
|
|
327
|
+
// to mock timers in tests. In this case, the update is synchronous already.
|
|
328
|
+
// IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global.
|
|
329
|
+
// https://github.com/reactwg/react-18/discussions/102
|
|
330
|
+
if (
|
|
331
|
+
// @ts-ignore
|
|
332
|
+
typeof IS_REACT_ACT_ENVIRONMENT === 'boolean'
|
|
333
|
+
? // @ts-ignore
|
|
334
|
+
IS_REACT_ACT_ENVIRONMENT
|
|
335
|
+
: typeof (globalThis as any).jest !== 'undefined'
|
|
336
|
+
) {
|
|
337
|
+
// This is so we update size in a separate render but within the same act. Needs to be setState instead of refs
|
|
338
|
+
// due to strict mode.
|
|
339
|
+
setUpdate({});
|
|
340
|
+
lastContentSize.current = contentSize;
|
|
341
|
+
return;
|
|
342
|
+
} else {
|
|
343
|
+
queueMicrotask(() => updateSizeEvent(flushSync));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
lastContentSize.current = contentSize;
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
// Will only run in tests, needs to be in separate effect so it is properly run in the next render in strict mode.
|
|
351
|
+
useLayoutEffect(() => {
|
|
352
|
+
updateSizeEvent((fn) => fn());
|
|
353
|
+
}, [update]);
|
|
354
|
+
|
|
355
|
+
let onResize = useCallback(() => {
|
|
356
|
+
updateSize(flushSync);
|
|
357
|
+
}, [updateSize]);
|
|
358
|
+
|
|
359
|
+
// Watch border-box instead of of content-box so that we don't go into
|
|
360
|
+
// an infinite loop when scrollbars appear or disappear.
|
|
361
|
+
useResizeObserver({ ref, box: 'border-box', onResize });
|
|
362
|
+
|
|
363
|
+
let style: React.CSSProperties = {
|
|
364
|
+
// Reset padding so that relative positioning works correctly. Padding will be done in JS layout.
|
|
365
|
+
padding: 0,
|
|
366
|
+
...otherProps.style,
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
if (scrollDirection === 'horizontal') {
|
|
370
|
+
style.overflowX = 'auto';
|
|
371
|
+
style.overflowY = 'hidden';
|
|
372
|
+
} else if (scrollDirection === 'vertical' || contentSize.width === state.size.width) {
|
|
373
|
+
// Set overflow-x: hidden if content size is equal to the width of the scroll view.
|
|
374
|
+
// This prevents horizontal scrollbars from flickering during resizing due to resize observer
|
|
375
|
+
// firing slower than the frame rate, which may cause an infinite re-render loop.
|
|
376
|
+
style.overflowY = 'auto';
|
|
377
|
+
style.overflowX = 'hidden';
|
|
378
|
+
} else {
|
|
379
|
+
style.overflow = 'auto';
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
innerStyle = {
|
|
383
|
+
width: Number.isFinite(contentSize.width) ? contentSize.width : undefined,
|
|
384
|
+
height: Number.isFinite(contentSize.height) ? contentSize.height : undefined,
|
|
385
|
+
pointerEvents: isScrolling ? 'none' : 'auto',
|
|
386
|
+
position: 'relative',
|
|
387
|
+
...innerStyle,
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
return {
|
|
391
|
+
isScrolling,
|
|
392
|
+
scrollViewProps: {
|
|
393
|
+
...otherProps,
|
|
394
|
+
style,
|
|
395
|
+
},
|
|
396
|
+
contentProps: {
|
|
397
|
+
role: 'presentation',
|
|
398
|
+
style: innerStyle,
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
}
|