@octanejs/aria 0.0.40 → 0.0.41
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,105 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/src/virtualizer/Layout.ts).
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { InvalidationContext } from './types';
|
|
16
|
+
import { ItemDropTarget, Key, LayoutDelegate, Node } from '@react-types/shared';
|
|
17
|
+
import { LayoutInfo } from './LayoutInfo';
|
|
18
|
+
import { Rect } from './Rect';
|
|
19
|
+
import { Size } from './Size';
|
|
20
|
+
import { Virtualizer } from './Virtualizer';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Virtualizer supports arbitrary layout objects, which compute what items are visible, and how
|
|
24
|
+
* to position and style them. However, layouts do not render items directly. Instead,
|
|
25
|
+
* layouts produce lightweight LayoutInfo objects which describe various properties of an item,
|
|
26
|
+
* such as its position and size. The Virtualizer is then responsible for creating the actual
|
|
27
|
+
* views as needed, based on this layout information.
|
|
28
|
+
*
|
|
29
|
+
* Every layout extends from the Layout abstract base class. Layouts must implement the
|
|
30
|
+
* `getVisibleLayoutInfos`, `getLayoutInfo`, and `getContentSize` methods. All other methods can be
|
|
31
|
+
* optionally overridden to implement custom behavior.
|
|
32
|
+
*/
|
|
33
|
+
export abstract class Layout<T extends object = Node<any>, O = any> implements LayoutDelegate {
|
|
34
|
+
/** The Virtualizer the layout is currently attached to. */
|
|
35
|
+
virtualizer: Virtualizer<T, any> | null = null;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Returns an array of `LayoutInfo` objects which are inside the given rectangle.
|
|
39
|
+
* Should be implemented by subclasses.
|
|
40
|
+
*
|
|
41
|
+
* @param rect The rectangle that should contain the returned LayoutInfo objects.
|
|
42
|
+
*/
|
|
43
|
+
abstract getVisibleLayoutInfos(rect: Rect): LayoutInfo[];
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Returns a `LayoutInfo` for the given key.
|
|
47
|
+
* Should be implemented by subclasses.
|
|
48
|
+
*
|
|
49
|
+
* @param key The key of the LayoutInfo to retrieve.
|
|
50
|
+
*/
|
|
51
|
+
abstract getLayoutInfo(key: Key): LayoutInfo | null;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Returns size of the content. By default, it returns virtualizer's size.
|
|
55
|
+
*/
|
|
56
|
+
abstract getContentSize(): Size;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Returns whether the layout should invalidate in response to
|
|
60
|
+
* visible rectangle changes. By default, it only invalidates
|
|
61
|
+
* when the virtualizer's size changes. Return true always
|
|
62
|
+
* to make the layout invalidate while scrolling (e.g. sticky headers).
|
|
63
|
+
*/
|
|
64
|
+
shouldInvalidate(newRect: Rect, oldRect: Rect): boolean {
|
|
65
|
+
// By default, invalidate when the size changes
|
|
66
|
+
return newRect.width !== oldRect.width || newRect.height !== oldRect.height;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Returns whether the layout should invalidate when the layout options change.
|
|
71
|
+
* By default it invalidates when the object identity changes. Override this
|
|
72
|
+
* method to optimize layout updates based on specific option changes.
|
|
73
|
+
*/
|
|
74
|
+
shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {
|
|
75
|
+
return newOptions !== oldOptions;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* This method allows the layout to perform any pre-computation
|
|
80
|
+
* it needs to in order to prepare LayoutInfos for retrieval.
|
|
81
|
+
* Called by the virtualizer before `getVisibleLayoutInfos`
|
|
82
|
+
* or `getLayoutInfo` are called.
|
|
83
|
+
*/
|
|
84
|
+
update(invalidationContext: InvalidationContext<O>): void {} // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Updates the size of the given item.
|
|
88
|
+
*/
|
|
89
|
+
updateItemSize?(key: Key, size: Size): boolean;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Returns a `LayoutInfo` for the given drop target.
|
|
93
|
+
*/
|
|
94
|
+
getDropTargetLayoutInfo?(target: ItemDropTarget): LayoutInfo;
|
|
95
|
+
|
|
96
|
+
/** @private */
|
|
97
|
+
getItemRect(key: Key): Rect | null {
|
|
98
|
+
return this.getLayoutInfo(key)?.rect ?? null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** @private */
|
|
102
|
+
getVisibleRect(): Rect {
|
|
103
|
+
return this.virtualizer!.visibleRect;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/src/virtualizer/LayoutInfo.ts).
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { Key } from '@react-types/shared';
|
|
16
|
+
import { Rect } from './Rect';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Instances of this lightweight class are created by `Layout` subclasses
|
|
20
|
+
* to represent each item in the `Virtualizer`. LayoutInfo objects describe
|
|
21
|
+
* various properties of an item, such as its position and size, and style information.
|
|
22
|
+
* The virtualizer uses this information when creating actual DOM elements to display.
|
|
23
|
+
*/
|
|
24
|
+
export class LayoutInfo {
|
|
25
|
+
/**
|
|
26
|
+
* The type of element represented by this LayoutInfo. Should match the `type` of the
|
|
27
|
+
* corresponding collection node.
|
|
28
|
+
*/
|
|
29
|
+
type: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A unique key for this LayoutInfo. Should match the `key` of the corresponding collection node.
|
|
33
|
+
*/
|
|
34
|
+
key: Key;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The key for a parent LayoutInfo, if any.
|
|
38
|
+
*/
|
|
39
|
+
parentKey: Key | null;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Content for this item if it was generated by the layout rather than coming from the Collection.
|
|
43
|
+
*/
|
|
44
|
+
content: any | null;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The rectangle describing the size and position of this element.
|
|
48
|
+
*/
|
|
49
|
+
rect: Rect;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether the size is estimated. `false` by default.
|
|
53
|
+
* Items with estimated sizes will be measured the first time they are added to the DOM.
|
|
54
|
+
* The estimated size is used to calculate the size and position of the scrollbar.
|
|
55
|
+
*
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
estimatedSize: boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Whether the layout info sticks to the viewport when scrolling.
|
|
62
|
+
*
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
isSticky: boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The element's opacity.
|
|
69
|
+
*
|
|
70
|
+
* @default 1
|
|
71
|
+
*/
|
|
72
|
+
opacity: number;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A CSS transform string to apply to the element. `null` by default.
|
|
76
|
+
*/
|
|
77
|
+
transform: string | null;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The z-index of the element. 0 by default.
|
|
81
|
+
*/
|
|
82
|
+
zIndex: number;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Whether the element allows its contents to overflow its container.
|
|
86
|
+
*
|
|
87
|
+
* @default false
|
|
88
|
+
*/
|
|
89
|
+
allowOverflow: boolean;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param type The type of element represented by this LayoutInfo. Should match the `type` of the
|
|
93
|
+
* corresponding collection node.
|
|
94
|
+
* @param key A unique key for this LayoutInfo. Should match the `key` of the corresponding
|
|
95
|
+
* collection node.
|
|
96
|
+
* @param rect The rectangle describing the size and position of this element.
|
|
97
|
+
*/
|
|
98
|
+
constructor(type: string, key: Key, rect: Rect) {
|
|
99
|
+
this.type = type;
|
|
100
|
+
this.key = key;
|
|
101
|
+
this.parentKey = null;
|
|
102
|
+
this.content = null;
|
|
103
|
+
this.rect = rect;
|
|
104
|
+
this.estimatedSize = false;
|
|
105
|
+
this.isSticky = false;
|
|
106
|
+
this.opacity = 1;
|
|
107
|
+
this.transform = null;
|
|
108
|
+
this.zIndex = 0;
|
|
109
|
+
this.allowOverflow = false;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Returns a copy of the LayoutInfo.
|
|
114
|
+
*/
|
|
115
|
+
copy(): LayoutInfo {
|
|
116
|
+
let res = new LayoutInfo(this.type, this.key, this.rect.copy());
|
|
117
|
+
res.estimatedSize = this.estimatedSize;
|
|
118
|
+
res.opacity = this.opacity;
|
|
119
|
+
res.transform = this.transform;
|
|
120
|
+
res.parentKey = this.parentKey;
|
|
121
|
+
res.content = this.content;
|
|
122
|
+
res.isSticky = this.isSticky;
|
|
123
|
+
res.zIndex = this.zIndex;
|
|
124
|
+
res.allowOverflow = this.allowOverflow;
|
|
125
|
+
return res;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/src/virtualizer/OverscanManager.ts).
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { Point } from './Point';
|
|
16
|
+
import { Rect } from './Rect';
|
|
17
|
+
|
|
18
|
+
export class OverscanManager {
|
|
19
|
+
private startTime = 0;
|
|
20
|
+
private velocity = new Point(0, 0);
|
|
21
|
+
private visibleRect = new Rect();
|
|
22
|
+
|
|
23
|
+
setVisibleRect(rect: Rect): void {
|
|
24
|
+
let time = performance.now() - this.startTime;
|
|
25
|
+
if (time < 500) {
|
|
26
|
+
if (rect.x !== this.visibleRect.x && time > 0) {
|
|
27
|
+
this.velocity.x = (rect.x - this.visibleRect.x) / time;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (rect.y !== this.visibleRect.y && time > 0) {
|
|
31
|
+
this.velocity.y = (rect.y - this.visibleRect.y) / time;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.startTime = performance.now();
|
|
36
|
+
this.visibleRect = rect;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getOverscannedRect(): Rect {
|
|
40
|
+
let overscanned = this.visibleRect.copy();
|
|
41
|
+
|
|
42
|
+
let overscanY = this.visibleRect.height / 3;
|
|
43
|
+
overscanned.height += overscanY;
|
|
44
|
+
if (this.velocity.y < 0) {
|
|
45
|
+
overscanned.y -= overscanY;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let overscanX = this.visibleRect.width / 3;
|
|
49
|
+
overscanned.width += overscanX;
|
|
50
|
+
if (this.velocity.x < 0) {
|
|
51
|
+
overscanned.x -= overscanX;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return overscanned;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/src/virtualizer/Point.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 class Point {
|
|
16
|
+
/** The x-coordinate of the point. */
|
|
17
|
+
x: number;
|
|
18
|
+
|
|
19
|
+
/** The y-coordinate of the point. */
|
|
20
|
+
y: number;
|
|
21
|
+
|
|
22
|
+
constructor(x = 0, y = 0) {
|
|
23
|
+
this.x = x;
|
|
24
|
+
this.y = y;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns a copy of this point.
|
|
29
|
+
*/
|
|
30
|
+
copy(): Point {
|
|
31
|
+
return new Point(this.x, this.y);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Checks if two points are equal.
|
|
36
|
+
*/
|
|
37
|
+
equals(point: Point): boolean {
|
|
38
|
+
return this.x === point.x && this.y === point.y;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns true if this point is the origin.
|
|
43
|
+
*/
|
|
44
|
+
isOrigin(): boolean {
|
|
45
|
+
return this.x === 0 && this.y === 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/src/virtualizer/Rect.ts).
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { Point } from './Point';
|
|
16
|
+
import { Size } from './Size';
|
|
17
|
+
|
|
18
|
+
export type RectCorner = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
|
|
19
|
+
|
|
20
|
+
export interface Rect {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents a rectangle.
|
|
26
|
+
*/
|
|
27
|
+
export class Rect {
|
|
28
|
+
/** The x-coordinate of the rectangle. */
|
|
29
|
+
x: number;
|
|
30
|
+
|
|
31
|
+
/** The y-coordinate of the rectangle. */
|
|
32
|
+
y: number;
|
|
33
|
+
|
|
34
|
+
/** The width of the rectangle. */
|
|
35
|
+
width: number;
|
|
36
|
+
|
|
37
|
+
/** The height of the rectangle. */
|
|
38
|
+
height: number;
|
|
39
|
+
|
|
40
|
+
constructor(x = 0, y = 0, width = 0, height = 0) {
|
|
41
|
+
this.x = x;
|
|
42
|
+
this.y = y;
|
|
43
|
+
this.width = width;
|
|
44
|
+
this.height = height;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The maximum x-coordinate in the rectangle.
|
|
49
|
+
*/
|
|
50
|
+
get maxX(): number {
|
|
51
|
+
return this.x + this.width;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The maximum y-coordinate in the rectangle.
|
|
56
|
+
*/
|
|
57
|
+
get maxY(): number {
|
|
58
|
+
return this.y + this.height;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The area of the rectangle.
|
|
63
|
+
*/
|
|
64
|
+
get area(): number {
|
|
65
|
+
return this.width * this.height;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The top left corner of the rectangle.
|
|
70
|
+
*/
|
|
71
|
+
get topLeft(): Point {
|
|
72
|
+
return new Point(this.x, this.y);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The top right corner of the rectangle.
|
|
77
|
+
*/
|
|
78
|
+
get topRight(): Point {
|
|
79
|
+
return new Point(this.maxX, this.y);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The bottom left corner of the rectangle.
|
|
84
|
+
*/
|
|
85
|
+
get bottomLeft(): Point {
|
|
86
|
+
return new Point(this.x, this.maxY);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The bottom right corner of the rectangle.
|
|
91
|
+
*/
|
|
92
|
+
get bottomRight(): Point {
|
|
93
|
+
return new Point(this.maxX, this.maxY);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns whether this rectangle intersects another rectangle.
|
|
98
|
+
*
|
|
99
|
+
* @param rect - The rectangle to check.
|
|
100
|
+
*/
|
|
101
|
+
intersects(rect: Rect): boolean {
|
|
102
|
+
let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;
|
|
103
|
+
return (
|
|
104
|
+
(isTestEnv || (this.area > 0 && rect.area > 0)) &&
|
|
105
|
+
this.x <= rect.x + rect.width &&
|
|
106
|
+
rect.x <= this.x + this.width &&
|
|
107
|
+
this.y <= rect.y + rect.height &&
|
|
108
|
+
rect.y <= this.y + this.height
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Returns whether this rectangle fully contains another rectangle.
|
|
114
|
+
*
|
|
115
|
+
* @param rect - The rectangle to check.
|
|
116
|
+
*/
|
|
117
|
+
containsRect(rect: Rect): boolean {
|
|
118
|
+
return this.x <= rect.x && this.y <= rect.y && this.maxX >= rect.maxX && this.maxY >= rect.maxY;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Returns whether the rectangle contains the given point.
|
|
123
|
+
*
|
|
124
|
+
* @param point - The point to check.
|
|
125
|
+
*/
|
|
126
|
+
containsPoint(point: Point): boolean {
|
|
127
|
+
return this.x <= point.x && this.y <= point.y && this.maxX >= point.x && this.maxY >= point.y;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Returns the first corner of this rectangle (from top to bottom, left to right)
|
|
132
|
+
* that is contained in the given rectangle, or null of the rectangles do not intersect.
|
|
133
|
+
*
|
|
134
|
+
* @param rect - The rectangle to check.
|
|
135
|
+
*/
|
|
136
|
+
getCornerInRect(rect: Rect): RectCorner | null {
|
|
137
|
+
for (let key of ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']) {
|
|
138
|
+
if (rect.containsPoint(this[key])) {
|
|
139
|
+
return key as RectCorner;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
equals(rect: Rect): boolean {
|
|
147
|
+
return (
|
|
148
|
+
rect.x === this.x &&
|
|
149
|
+
rect.y === this.y &&
|
|
150
|
+
rect.width === this.width &&
|
|
151
|
+
rect.height === this.height
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
pointEquals(point: Point | Rect): boolean {
|
|
156
|
+
return this.x === point.x && this.y === point.y;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
sizeEquals(size: Size | Rect): boolean {
|
|
160
|
+
return this.width === size.width && this.height === size.height;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Returns the union of this Rect and another.
|
|
165
|
+
*/
|
|
166
|
+
union(other: Rect): Rect {
|
|
167
|
+
let x = Math.min(this.x, other.x);
|
|
168
|
+
let y = Math.min(this.y, other.y);
|
|
169
|
+
let width = Math.max(this.maxX, other.maxX) - x;
|
|
170
|
+
let height = Math.max(this.maxY, other.maxY) - y;
|
|
171
|
+
return new Rect(x, y, width, height);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Returns the intersection of this Rect with another.
|
|
176
|
+
* If the rectangles do not intersect, an all zero Rect is returned.
|
|
177
|
+
*/
|
|
178
|
+
intersection(other: Rect): Rect {
|
|
179
|
+
if (!this.intersects(other)) {
|
|
180
|
+
return new Rect(0, 0, 0, 0);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
let x = Math.max(this.x, other.x);
|
|
184
|
+
let y = Math.max(this.y, other.y);
|
|
185
|
+
return new Rect(x, y, Math.min(this.maxX, other.maxX) - x, Math.min(this.maxY, other.maxY) - y);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Returns a copy of this rectangle.
|
|
190
|
+
*/
|
|
191
|
+
copy(): Rect {
|
|
192
|
+
return new Rect(this.x, this.y, this.width, this.height);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/src/virtualizer/ReusableView.ts).
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { Key } from '@react-types/shared';
|
|
16
|
+
import { LayoutInfo } from './LayoutInfo';
|
|
17
|
+
import { Virtualizer } from './Virtualizer';
|
|
18
|
+
|
|
19
|
+
let KEY = 0;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* `Virtualizer` creates instances of the `ReusableView` class to
|
|
23
|
+
* represent views currently being displayed.
|
|
24
|
+
*/
|
|
25
|
+
export class ReusableView<T extends object, V> {
|
|
26
|
+
/** The Virtualizer this view is a part of. */
|
|
27
|
+
virtualizer: Virtualizer<T, V>;
|
|
28
|
+
|
|
29
|
+
/** The LayoutInfo this view is currently representing. */
|
|
30
|
+
layoutInfo: LayoutInfo | null;
|
|
31
|
+
|
|
32
|
+
/** The content currently being displayed by this view, set by the virtualizer. */
|
|
33
|
+
content: T | null;
|
|
34
|
+
|
|
35
|
+
rendered: V | null;
|
|
36
|
+
|
|
37
|
+
viewType: string;
|
|
38
|
+
key: Key;
|
|
39
|
+
|
|
40
|
+
children: Set<ChildView<T, V>>;
|
|
41
|
+
reusableViews: Map<string, ChildView<T, V>[]>;
|
|
42
|
+
|
|
43
|
+
constructor(virtualizer: Virtualizer<T, V>, viewType: string) {
|
|
44
|
+
this.virtualizer = virtualizer;
|
|
45
|
+
this.key = ++KEY;
|
|
46
|
+
this.viewType = viewType;
|
|
47
|
+
this.children = new Set();
|
|
48
|
+
this.reusableViews = new Map();
|
|
49
|
+
this.layoutInfo = null;
|
|
50
|
+
this.content = null;
|
|
51
|
+
this.rendered = null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Prepares the view for reuse. Called just before the view is removed from the DOM.
|
|
56
|
+
*/
|
|
57
|
+
prepareForReuse(): void {
|
|
58
|
+
this.content = null;
|
|
59
|
+
this.rendered = null;
|
|
60
|
+
this.layoutInfo = null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getReusableView(reuseType: string): ChildView<T, V> {
|
|
64
|
+
// Reusable view queue should be FIFO so that DOM order remains consistent during scrolling.
|
|
65
|
+
// For example, cells within a row should remain in the same order even if the row changes contents.
|
|
66
|
+
// The cells within a row are removed from their parent in order. If the row is reused, the cells
|
|
67
|
+
// should be reused in the new row in the same order they were before.
|
|
68
|
+
let reusable = this.reusableViews.get(reuseType);
|
|
69
|
+
let view =
|
|
70
|
+
reusable && reusable.length > 0
|
|
71
|
+
? reusable.shift()!
|
|
72
|
+
: new ChildView<T, V>(this.virtualizer, this, reuseType);
|
|
73
|
+
|
|
74
|
+
return view;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
reuseChild(child: ChildView<T, V>): void {
|
|
78
|
+
child.prepareForReuse();
|
|
79
|
+
let reusable = this.reusableViews.get(child.viewType);
|
|
80
|
+
if (!reusable) {
|
|
81
|
+
reusable = [];
|
|
82
|
+
this.reusableViews.set(child.viewType, reusable);
|
|
83
|
+
}
|
|
84
|
+
reusable.push(child);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export class RootView<T extends object, V> extends ReusableView<T, V> {
|
|
89
|
+
constructor(virtualizer: Virtualizer<T, V>) {
|
|
90
|
+
super(virtualizer, 'root');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class ChildView<T extends object, V> extends ReusableView<T, V> {
|
|
95
|
+
parent: ReusableView<T, V>;
|
|
96
|
+
|
|
97
|
+
constructor(virtualizer: Virtualizer<T, V>, parent: ReusableView<T, V>, viewType: string) {
|
|
98
|
+
super(virtualizer, viewType);
|
|
99
|
+
this.parent = parent;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
// Ported from adobe/react-spectrum@1c84a49a1faf50b571c84e00bcf9c60b22ddd03e (packages/react-stately/src/virtualizer/Size.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 interface Size {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class Size {
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
|
|
23
|
+
constructor(width = 0, height = 0) {
|
|
24
|
+
this.width = Math.max(width, 0);
|
|
25
|
+
this.height = Math.max(height, 0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns a copy of this size.
|
|
30
|
+
*/
|
|
31
|
+
copy(): Size {
|
|
32
|
+
return new Size(this.width, this.height);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns whether this size is equal to another one.
|
|
37
|
+
*/
|
|
38
|
+
equals(other: Size): boolean {
|
|
39
|
+
return this.width === other.width && this.height === other.height;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The total area of the Size.
|
|
44
|
+
*/
|
|
45
|
+
get area(): number {
|
|
46
|
+
return this.width * this.height;
|
|
47
|
+
}
|
|
48
|
+
}
|