@base-ui/react 1.1.0 → 1.2.0
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/CHANGELOG.md +173 -0
- package/accordion/item/AccordionItem.d.ts +1 -1
- package/accordion/item/AccordionItemContext.d.ts +1 -1
- package/accordion/root/AccordionRoot.d.ts +9 -9
- package/alert-dialog/root/AlertDialogRoot.d.ts +3 -3
- package/alert-dialog/root/AlertDialogRoot.js +6 -4
- package/autocomplete/index.parts.d.ts +2 -1
- package/autocomplete/index.parts.js +8 -1
- package/autocomplete/root/AutocompleteRoot.d.ts +19 -14
- package/autocomplete/root/AutocompleteRoot.js +4 -6
- package/avatar/fallback/AvatarFallback.d.ts +7 -2
- package/avatar/fallback/AvatarFallback.js +34 -6
- package/avatar/image/AvatarImage.d.ts +7 -2
- package/avatar/image/AvatarImage.js +35 -6
- package/avatar/image/useImageLoadingStatus.d.ts +2 -2
- package/avatar/root/AvatarRoot.js +2 -2
- package/button/Button.d.ts +1 -1
- package/button/Button.js +2 -2
- package/checkbox/indicator/CheckboxIndicator.d.ts +1 -1
- package/checkbox/indicator/CheckboxIndicator.js +4 -4
- package/checkbox/root/CheckboxRoot.d.ts +13 -13
- package/checkbox/root/CheckboxRoot.js +31 -8
- package/checkbox-group/CheckboxGroup.d.ts +5 -5
- package/checkbox-group/CheckboxGroup.js +2 -2
- package/checkbox-group/useCheckboxGroupParent.d.ts +3 -3
- package/collapsible/panel/CollapsiblePanel.d.ts +2 -2
- package/collapsible/root/CollapsibleRoot.d.ts +4 -4
- package/collapsible/root/useCollapsibleRoot.d.ts +2 -2
- package/combobox/arrow/ComboboxArrow.js +2 -2
- package/combobox/arrow/ComboboxArrowDataAttributes.js +2 -2
- package/combobox/backdrop/ComboboxBackdrop.js +2 -2
- package/combobox/chip/ComboboxChip.js +6 -3
- package/combobox/chip/ComboboxChipContext.js +1 -0
- package/combobox/chip-remove/ComboboxChipRemove.js +28 -33
- package/combobox/chips/ComboboxChipsContext.js +1 -0
- package/combobox/clear/ComboboxClear.d.ts +2 -2
- package/combobox/clear/ComboboxClear.js +2 -3
- package/combobox/group/ComboboxGroup.d.ts +1 -1
- package/combobox/group/ComboboxGroupContext.d.ts +1 -1
- package/combobox/group/ComboboxGroupContext.js +1 -0
- package/combobox/icon/ComboboxIcon.d.ts +1 -1
- package/combobox/index.parts.d.ts +2 -1
- package/combobox/index.parts.js +8 -1
- package/combobox/input/ComboboxInput.d.ts +1 -1
- package/combobox/input/ComboboxInput.js +38 -8
- package/combobox/item/ComboboxItem.d.ts +3 -3
- package/combobox/item/ComboboxItem.js +15 -15
- package/combobox/item/ComboboxItemContext.js +1 -0
- package/combobox/item-indicator/ComboboxItemIndicator.d.ts +1 -1
- package/combobox/item-indicator/ComboboxItemIndicator.js +2 -2
- package/combobox/list/ComboboxList.js +2 -2
- package/combobox/popup/ComboboxPopup.d.ts +2 -2
- package/combobox/popup/ComboboxPopup.js +3 -4
- package/combobox/popup/ComboboxPopupDataAttributes.js +2 -2
- package/combobox/portal/ComboboxPortal.d.ts +1 -1
- package/combobox/portal/ComboboxPortalContext.js +1 -0
- package/combobox/positioner/ComboboxPositioner.js +5 -3
- package/combobox/positioner/ComboboxPositionerDataAttributes.js +2 -2
- package/combobox/root/AriaCombobox.d.ts +49 -44
- package/combobox/root/AriaCombobox.js +44 -62
- package/combobox/root/ComboboxRoot.d.ts +19 -14
- package/combobox/root/ComboboxRoot.js +3 -1
- package/combobox/root/ComboboxRootContext.d.ts +1 -0
- package/combobox/root/ComboboxRootContext.js +1 -0
- package/combobox/root/utils/useFilter.d.ts +2 -2
- package/combobox/root/utils/useFilteredItems.d.ts +4 -0
- package/combobox/root/utils/useFilteredItems.js +14 -0
- package/combobox/row/ComboboxRowContext.js +1 -0
- package/combobox/store.d.ts +11 -11
- package/combobox/store.js +3 -3
- package/combobox/trigger/ComboboxTrigger.d.ts +1 -1
- package/combobox/trigger/ComboboxTrigger.js +3 -4
- package/composite/item/CompositeItem.d.ts +6 -6
- package/composite/list/CompositeList.d.ts +3 -3
- package/composite/list/CompositeListContext.d.ts +1 -1
- package/composite/list/useCompositeListItem.d.ts +5 -5
- package/composite/root/CompositeRoot.d.ts +19 -19
- package/composite/root/useCompositeRoot.d.ts +12 -12
- package/context-menu/index.d.ts +1 -0
- package/context-menu/index.parts.d.ts +1 -0
- package/context-menu/index.parts.js +7 -0
- package/context-menu/root/ContextMenuRoot.d.ts +1 -1
- package/context-menu/root/ContextMenuRootContext.js +1 -0
- package/context-menu/trigger/ContextMenuTrigger.js +13 -3
- package/csp-provider/CSPContext.d.ts +2 -2
- package/csp-provider/CSPProvider.d.ts +2 -2
- package/dialog/backdrop/DialogBackdrop.d.ts +1 -1
- package/dialog/backdrop/DialogBackdrop.js +2 -2
- package/dialog/close/DialogClose.js +2 -2
- package/dialog/popup/DialogPopup.d.ts +2 -2
- package/dialog/popup/DialogPopup.js +2 -2
- package/dialog/portal/DialogPortal.d.ts +2 -2
- package/dialog/portal/DialogPortalContext.js +1 -0
- package/dialog/root/DialogRoot.d.ts +10 -10
- package/dialog/root/DialogRoot.js +17 -4
- package/dialog/root/useDialogRoot.d.ts +3 -3
- package/dialog/root/useDialogRoot.js +4 -0
- package/dialog/store/DialogStore.d.ts +258 -17
- package/dialog/store/DialogStore.js +3 -0
- package/dialog/trigger/DialogTrigger.d.ts +3 -3
- package/dialog/trigger/DialogTrigger.js +3 -3
- package/dialog/viewport/DialogViewport.js +5 -2
- package/direction-provider/DirectionProvider.d.ts +1 -1
- package/drawer/backdrop/DrawerBackdrop.d.ts +28 -0
- package/drawer/backdrop/DrawerBackdrop.js +63 -0
- package/drawer/backdrop/DrawerBackdropCssVars.d.ts +7 -0
- package/drawer/backdrop/DrawerBackdropCssVars.js +14 -0
- package/drawer/close/DrawerClose.d.ts +23 -0
- package/drawer/close/DrawerClose.js +15 -0
- package/drawer/content/DrawerContent.d.ts +15 -0
- package/drawer/content/DrawerContent.js +32 -0
- package/drawer/description/DrawerDescription.d.ts +18 -0
- package/drawer/description/DrawerDescription.js +15 -0
- package/drawer/indent/DrawerIndent.d.ts +20 -0
- package/drawer/indent/DrawerIndent.js +87 -0
- package/drawer/indent-background/DrawerIndentBackground.d.ts +18 -0
- package/drawer/indent-background/DrawerIndentBackground.js +47 -0
- package/drawer/index.d.ts +14 -0
- package/drawer/index.js +9 -0
- package/drawer/index.parts.d.ts +14 -0
- package/drawer/index.parts.js +109 -0
- package/drawer/popup/DrawerPopup.d.ts +69 -0
- package/drawer/popup/DrawerPopup.js +291 -0
- package/drawer/popup/DrawerPopupCssVars.d.ts +37 -0
- package/drawer/popup/DrawerPopupCssVars.js +44 -0
- package/drawer/popup/DrawerPopupDataAttributes.d.ts +27 -0
- package/drawer/popup/DrawerPopupDataAttributes.js +34 -0
- package/drawer/portal/DrawerPortal.d.ts +29 -0
- package/drawer/portal/DrawerPortal.js +16 -0
- package/drawer/provider/DrawerProvider.d.ts +16 -0
- package/drawer/provider/DrawerProvider.js +100 -0
- package/drawer/provider/DrawerProviderContext.d.ts +19 -0
- package/drawer/provider/DrawerProviderContext.js +21 -0
- package/drawer/root/DrawerRoot.d.ts +124 -0
- package/drawer/root/DrawerRoot.js +235 -0
- package/drawer/root/DrawerRootContext.d.ts +89 -0
- package/drawer/root/DrawerRootContext.js +21 -0
- package/drawer/root/useDrawerSnapPoints.d.ts +15 -0
- package/drawer/root/useDrawerSnapPoints.js +155 -0
- package/drawer/swipe-area/DrawerSwipeArea.d.ts +45 -0
- package/drawer/swipe-area/DrawerSwipeArea.js +385 -0
- package/drawer/title/DrawerTitle.d.ts +18 -0
- package/drawer/title/DrawerTitle.js +15 -0
- package/drawer/trigger/DrawerTrigger.d.ts +43 -0
- package/drawer/trigger/DrawerTrigger.js +15 -0
- package/drawer/viewport/DrawerViewport.d.ts +30 -0
- package/drawer/viewport/DrawerViewport.js +873 -0
- package/drawer/viewport/DrawerViewportContext.d.ts +11 -0
- package/drawer/viewport/DrawerViewportContext.js +21 -0
- package/esm/accordion/item/AccordionItem.d.ts +1 -1
- package/esm/accordion/item/AccordionItemContext.d.ts +1 -1
- package/esm/accordion/root/AccordionRoot.d.ts +9 -9
- package/esm/alert-dialog/root/AlertDialogRoot.d.ts +3 -3
- package/esm/alert-dialog/root/AlertDialogRoot.js +6 -4
- package/esm/autocomplete/index.parts.d.ts +2 -1
- package/esm/autocomplete/index.parts.js +2 -1
- package/esm/autocomplete/root/AutocompleteRoot.d.ts +19 -14
- package/esm/autocomplete/root/AutocompleteRoot.js +4 -6
- package/esm/avatar/fallback/AvatarFallback.d.ts +7 -2
- package/esm/avatar/fallback/AvatarFallback.js +33 -6
- package/esm/avatar/image/AvatarImage.d.ts +7 -2
- package/esm/avatar/image/AvatarImage.js +34 -6
- package/esm/avatar/image/useImageLoadingStatus.d.ts +2 -2
- package/esm/avatar/root/AvatarRoot.js +2 -2
- package/esm/button/Button.d.ts +1 -1
- package/esm/button/Button.js +2 -2
- package/esm/checkbox/indicator/CheckboxIndicator.d.ts +1 -1
- package/esm/checkbox/indicator/CheckboxIndicator.js +4 -4
- package/esm/checkbox/root/CheckboxRoot.d.ts +13 -13
- package/esm/checkbox/root/CheckboxRoot.js +31 -8
- package/esm/checkbox-group/CheckboxGroup.d.ts +5 -5
- package/esm/checkbox-group/CheckboxGroup.js +2 -2
- package/esm/checkbox-group/useCheckboxGroupParent.d.ts +3 -3
- package/esm/collapsible/panel/CollapsiblePanel.d.ts +2 -2
- package/esm/collapsible/root/CollapsibleRoot.d.ts +4 -4
- package/esm/collapsible/root/useCollapsibleRoot.d.ts +2 -2
- package/esm/combobox/arrow/ComboboxArrow.js +2 -2
- package/esm/combobox/arrow/ComboboxArrowDataAttributes.js +2 -2
- package/esm/combobox/backdrop/ComboboxBackdrop.js +2 -2
- package/esm/combobox/chip/ComboboxChip.js +6 -3
- package/esm/combobox/chip/ComboboxChipContext.js +2 -0
- package/esm/combobox/chip-remove/ComboboxChipRemove.js +28 -33
- package/esm/combobox/chips/ComboboxChipsContext.js +2 -0
- package/esm/combobox/clear/ComboboxClear.d.ts +2 -2
- package/esm/combobox/clear/ComboboxClear.js +2 -3
- package/esm/combobox/group/ComboboxGroup.d.ts +1 -1
- package/esm/combobox/group/ComboboxGroupContext.d.ts +1 -1
- package/esm/combobox/group/ComboboxGroupContext.js +2 -0
- package/esm/combobox/icon/ComboboxIcon.d.ts +1 -1
- package/esm/combobox/index.parts.d.ts +2 -1
- package/esm/combobox/index.parts.js +2 -1
- package/esm/combobox/input/ComboboxInput.d.ts +1 -1
- package/esm/combobox/input/ComboboxInput.js +38 -8
- package/esm/combobox/item/ComboboxItem.d.ts +3 -3
- package/esm/combobox/item/ComboboxItem.js +15 -15
- package/esm/combobox/item/ComboboxItemContext.js +2 -0
- package/esm/combobox/item-indicator/ComboboxItemIndicator.d.ts +1 -1
- package/esm/combobox/item-indicator/ComboboxItemIndicator.js +2 -2
- package/esm/combobox/list/ComboboxList.js +2 -2
- package/esm/combobox/popup/ComboboxPopup.d.ts +2 -2
- package/esm/combobox/popup/ComboboxPopup.js +3 -4
- package/esm/combobox/popup/ComboboxPopupDataAttributes.js +2 -2
- package/esm/combobox/portal/ComboboxPortal.d.ts +1 -1
- package/esm/combobox/portal/ComboboxPortalContext.js +2 -0
- package/esm/combobox/positioner/ComboboxPositioner.js +5 -3
- package/esm/combobox/positioner/ComboboxPositionerDataAttributes.js +2 -2
- package/esm/combobox/root/AriaCombobox.d.ts +49 -44
- package/esm/combobox/root/AriaCombobox.js +45 -63
- package/esm/combobox/root/ComboboxRoot.d.ts +19 -14
- package/esm/combobox/root/ComboboxRoot.js +3 -1
- package/esm/combobox/root/ComboboxRootContext.d.ts +1 -0
- package/esm/combobox/root/ComboboxRootContext.js +2 -0
- package/esm/combobox/root/utils/useFilter.d.ts +2 -2
- package/esm/combobox/root/utils/useFilteredItems.d.ts +4 -0
- package/esm/combobox/root/utils/useFilteredItems.js +9 -0
- package/esm/combobox/row/ComboboxRowContext.js +2 -0
- package/esm/combobox/store.d.ts +11 -11
- package/esm/combobox/store.js +3 -3
- package/esm/combobox/trigger/ComboboxTrigger.d.ts +1 -1
- package/esm/combobox/trigger/ComboboxTrigger.js +3 -4
- package/esm/composite/item/CompositeItem.d.ts +6 -6
- package/esm/composite/list/CompositeList.d.ts +3 -3
- package/esm/composite/list/CompositeListContext.d.ts +1 -1
- package/esm/composite/list/useCompositeListItem.d.ts +5 -5
- package/esm/composite/root/CompositeRoot.d.ts +19 -19
- package/esm/composite/root/useCompositeRoot.d.ts +12 -12
- package/esm/context-menu/index.d.ts +1 -0
- package/esm/context-menu/index.parts.d.ts +1 -0
- package/esm/context-menu/index.parts.js +1 -0
- package/esm/context-menu/root/ContextMenuRoot.d.ts +1 -1
- package/esm/context-menu/root/ContextMenuRootContext.js +2 -0
- package/esm/context-menu/trigger/ContextMenuTrigger.js +13 -3
- package/esm/csp-provider/CSPContext.d.ts +2 -2
- package/esm/csp-provider/CSPProvider.d.ts +2 -2
- package/esm/dialog/backdrop/DialogBackdrop.d.ts +1 -1
- package/esm/dialog/backdrop/DialogBackdrop.js +2 -2
- package/esm/dialog/close/DialogClose.js +2 -2
- package/esm/dialog/popup/DialogPopup.d.ts +2 -2
- package/esm/dialog/popup/DialogPopup.js +2 -2
- package/esm/dialog/portal/DialogPortal.d.ts +2 -2
- package/esm/dialog/portal/DialogPortalContext.js +2 -0
- package/esm/dialog/root/DialogRoot.d.ts +10 -10
- package/esm/dialog/root/DialogRoot.js +17 -4
- package/esm/dialog/root/useDialogRoot.d.ts +3 -3
- package/esm/dialog/root/useDialogRoot.js +4 -0
- package/esm/dialog/store/DialogStore.d.ts +258 -17
- package/esm/dialog/store/DialogStore.js +3 -0
- package/esm/dialog/trigger/DialogTrigger.d.ts +3 -3
- package/esm/dialog/trigger/DialogTrigger.js +2 -2
- package/esm/dialog/viewport/DialogViewport.js +5 -2
- package/esm/direction-provider/DirectionProvider.d.ts +1 -1
- package/esm/drawer/backdrop/DrawerBackdrop.d.ts +28 -0
- package/esm/drawer/backdrop/DrawerBackdrop.js +57 -0
- package/esm/drawer/backdrop/DrawerBackdropCssVars.d.ts +7 -0
- package/esm/drawer/backdrop/DrawerBackdropCssVars.js +8 -0
- package/esm/drawer/close/DrawerClose.d.ts +23 -0
- package/esm/drawer/close/DrawerClose.js +10 -0
- package/esm/drawer/content/DrawerContent.d.ts +15 -0
- package/esm/drawer/content/DrawerContent.js +27 -0
- package/esm/drawer/description/DrawerDescription.d.ts +18 -0
- package/esm/drawer/description/DrawerDescription.js +10 -0
- package/esm/drawer/indent/DrawerIndent.d.ts +20 -0
- package/esm/drawer/indent/DrawerIndent.js +81 -0
- package/esm/drawer/indent-background/DrawerIndentBackground.d.ts +18 -0
- package/esm/drawer/indent-background/DrawerIndentBackground.js +41 -0
- package/esm/drawer/index.d.ts +14 -0
- package/esm/drawer/index.js +1 -0
- package/esm/drawer/index.parts.d.ts +14 -0
- package/esm/drawer/index.parts.js +14 -0
- package/esm/drawer/popup/DrawerPopup.d.ts +69 -0
- package/esm/drawer/popup/DrawerPopup.js +285 -0
- package/esm/drawer/popup/DrawerPopupCssVars.d.ts +37 -0
- package/esm/drawer/popup/DrawerPopupCssVars.js +38 -0
- package/esm/drawer/popup/DrawerPopupDataAttributes.d.ts +27 -0
- package/esm/drawer/popup/DrawerPopupDataAttributes.js +28 -0
- package/esm/drawer/portal/DrawerPortal.d.ts +29 -0
- package/esm/drawer/portal/DrawerPortal.js +11 -0
- package/esm/drawer/provider/DrawerProvider.d.ts +16 -0
- package/esm/drawer/provider/DrawerProvider.js +95 -0
- package/esm/drawer/provider/DrawerProviderContext.d.ts +19 -0
- package/esm/drawer/provider/DrawerProviderContext.js +13 -0
- package/esm/drawer/root/DrawerRoot.d.ts +124 -0
- package/esm/drawer/root/DrawerRoot.js +229 -0
- package/esm/drawer/root/DrawerRootContext.d.ts +89 -0
- package/esm/drawer/root/DrawerRootContext.js +13 -0
- package/esm/drawer/root/useDrawerSnapPoints.d.ts +15 -0
- package/esm/drawer/root/useDrawerSnapPoints.js +149 -0
- package/esm/drawer/swipe-area/DrawerSwipeArea.d.ts +45 -0
- package/esm/drawer/swipe-area/DrawerSwipeArea.js +379 -0
- package/esm/drawer/title/DrawerTitle.d.ts +18 -0
- package/esm/drawer/title/DrawerTitle.js +10 -0
- package/esm/drawer/trigger/DrawerTrigger.d.ts +43 -0
- package/esm/drawer/trigger/DrawerTrigger.js +10 -0
- package/esm/drawer/viewport/DrawerViewport.d.ts +30 -0
- package/esm/drawer/viewport/DrawerViewport.js +867 -0
- package/esm/drawer/viewport/DrawerViewportContext.d.ts +11 -0
- package/esm/drawer/viewport/DrawerViewportContext.js +13 -0
- package/esm/field/control/FieldControl.d.ts +3 -3
- package/esm/field/control/FieldControl.js +22 -20
- package/esm/field/error/FieldError.d.ts +5 -2
- package/esm/field/error/FieldError.js +50 -7
- package/esm/field/item/FieldItem.d.ts +1 -1
- package/esm/field/item/FieldItemContext.js +2 -0
- package/esm/field/label/FieldLabel.d.ts +1 -1
- package/esm/field/label/FieldLabel.js +7 -2
- package/esm/field/root/FieldRoot.d.ts +9 -9
- package/esm/field/root/FieldRootContext.d.ts +1 -1
- package/esm/field/useField.d.ts +1 -1
- package/esm/field/useField.js +2 -0
- package/esm/field/validity/FieldValidity.d.ts +2 -0
- package/esm/field/validity/FieldValidity.js +11 -4
- package/esm/fieldset/legend/FieldsetLegend.js +2 -2
- package/esm/fieldset/root/FieldsetRoot.d.ts +1 -1
- package/esm/fieldset/root/FieldsetRoot.js +3 -3
- package/esm/floating-ui-react/components/FloatingDelayGroup.d.ts +2 -7
- package/esm/floating-ui-react/components/FloatingDelayGroup.js +2 -9
- package/esm/floating-ui-react/components/FloatingFocusManager.d.ts +11 -21
- package/esm/floating-ui-react/components/FloatingFocusManager.js +63 -76
- package/esm/floating-ui-react/components/FloatingPortal.d.ts +8 -9
- package/esm/floating-ui-react/components/FloatingPortal.js +1 -3
- package/esm/floating-ui-react/components/FloatingTree.d.ts +1 -1
- package/esm/floating-ui-react/hooks/useClick.d.ts +12 -6
- package/esm/floating-ui-react/hooks/useClick.js +6 -5
- package/esm/floating-ui-react/hooks/useClientPoint.d.ts +2 -12
- package/esm/floating-ui-react/hooks/useClientPoint.js +5 -16
- package/esm/floating-ui-react/hooks/useDismiss.d.ts +15 -15
- package/esm/floating-ui-react/hooks/useDismiss.js +6 -3
- package/esm/floating-ui-react/hooks/useFloating.js +2 -0
- package/esm/floating-ui-react/hooks/useFloatingRootContext.d.ts +4 -10
- package/esm/floating-ui-react/hooks/useFloatingRootContext.js +5 -3
- package/esm/floating-ui-react/hooks/useFocus.d.ts +2 -8
- package/esm/floating-ui-react/hooks/useFocus.js +11 -12
- package/esm/floating-ui-react/hooks/useHover.d.ts +7 -30
- package/esm/floating-ui-react/hooks/useHover.js +20 -37
- package/esm/floating-ui-react/hooks/useHoverFloatingInteraction.d.ts +2 -7
- package/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js +35 -40
- package/esm/floating-ui-react/hooks/useHoverInteractionSharedState.d.ts +17 -14
- package/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js +36 -30
- package/esm/floating-ui-react/hooks/useHoverReferenceInteraction.d.ts +7 -3
- package/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js +57 -60
- package/esm/floating-ui-react/hooks/useInteractions.d.ts +2 -2
- package/esm/floating-ui-react/hooks/useListNavigation.d.ts +19 -35
- package/esm/floating-ui-react/hooks/useListNavigation.js +13 -12
- package/esm/floating-ui-react/hooks/useRole.d.ts +1 -7
- package/esm/floating-ui-react/hooks/useRole.js +2 -3
- package/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.d.ts +2 -2
- package/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js +2 -0
- package/esm/floating-ui-react/hooks/useTypeahead.d.ts +6 -16
- package/esm/floating-ui-react/hooks/useTypeahead.js +48 -16
- package/esm/floating-ui-react/middleware/arrow.d.ts +1 -1
- package/esm/floating-ui-react/safePolygon.d.ts +3 -3
- package/esm/floating-ui-react/types.d.ts +14 -14
- package/esm/floating-ui-react/utils/composite.d.ts +5 -5
- package/esm/floating-ui-react/utils/composite.js +1 -2
- package/esm/floating-ui-react/utils/element.d.ts +2 -1
- package/esm/floating-ui-react/utils/element.js +16 -4
- package/esm/floating-ui-react/utils/enqueueFocus.d.ts +3 -3
- package/esm/floating-ui-react/utils/event.js +2 -4
- package/esm/floating-ui-react/utils/markOthers.js +2 -2
- package/esm/floating-ui-react/utils/tabbable.js +6 -5
- package/esm/form/Form.d.ts +5 -5
- package/esm/index.d.ts +1 -0
- package/esm/index.js +2 -1
- package/esm/input/Input.d.ts +3 -3
- package/esm/labelable-provider/LabelableContext.d.ts +1 -1
- package/esm/labelable-provider/LabelableContext.js +1 -1
- package/esm/labelable-provider/LabelableProvider.js +33 -3
- package/esm/labelable-provider/useLabelableId.d.ts +3 -2
- package/esm/labelable-provider/useLabelableId.js +38 -12
- package/esm/menu/arrow/MenuArrow.js +2 -2
- package/esm/menu/arrow/MenuArrowDataAttributes.js +2 -2
- package/esm/menu/backdrop/MenuBackdrop.js +2 -2
- package/esm/menu/checkbox-item/MenuCheckboxItem.d.ts +8 -8
- package/esm/menu/checkbox-item/MenuCheckboxItemContext.js +2 -0
- package/esm/menu/checkbox-item-indicator/MenuCheckboxItemIndicator.d.ts +2 -2
- package/esm/menu/checkbox-item-indicator/MenuCheckboxItemIndicator.js +3 -3
- package/esm/menu/group/MenuGroupContext.js +2 -0
- package/esm/menu/index.d.ts +2 -1
- package/esm/menu/index.parts.d.ts +1 -0
- package/esm/menu/index.parts.js +1 -0
- package/esm/menu/item/MenuItem.d.ts +5 -5
- package/esm/menu/item/MenuItem.js +2 -2
- package/esm/menu/item/useMenuItem.js +12 -48
- package/esm/menu/item/useMenuItemCommonProps.d.ts +43 -0
- package/esm/menu/item/useMenuItemCommonProps.js +66 -0
- package/esm/menu/link-item/MenuLinkItem.d.ts +34 -0
- package/esm/menu/link-item/MenuLinkItem.js +55 -0
- package/esm/menu/link-item/MenuLinkItemDataAttributes.d.ts +6 -0
- package/esm/menu/link-item/MenuLinkItemDataAttributes.js +7 -0
- package/esm/menu/popup/MenuPopup.d.ts +3 -2
- package/esm/menu/popup/MenuPopup.js +2 -2
- package/esm/menu/popup/MenuPopupDataAttributes.js +2 -2
- package/esm/menu/portal/MenuPortal.d.ts +1 -1
- package/esm/menu/portal/MenuPortalContext.js +2 -0
- package/esm/menu/positioner/MenuPositioner.js +6 -12
- package/esm/menu/positioner/MenuPositionerDataAttributes.js +2 -2
- package/esm/menu/radio-group/MenuRadioGroup.d.ts +2 -2
- package/esm/menu/radio-group/MenuRadioGroup.js +2 -2
- package/esm/menu/radio-group/MenuRadioGroupContext.js +2 -0
- package/esm/menu/radio-item/MenuRadioItem.d.ts +5 -5
- package/esm/menu/radio-item/MenuRadioItemContext.js +2 -0
- package/esm/menu/radio-item-indicator/MenuRadioItemIndicator.d.ts +2 -2
- package/esm/menu/radio-item-indicator/MenuRadioItemIndicator.js +3 -3
- package/esm/menu/root/MenuRoot.d.ts +15 -15
- package/esm/menu/root/MenuRoot.js +38 -36
- package/esm/menu/store/MenuStore.d.ts +255 -15
- package/esm/menu/store/MenuStore.js +2 -11
- package/esm/menu/submenu-root/MenuSubmenuRoot.d.ts +2 -2
- package/esm/menu/submenu-root/MenuSubmenuRootContext.js +2 -0
- package/esm/menu/submenu-trigger/MenuSubmenuTrigger.d.ts +22 -22
- package/esm/menu/submenu-trigger/MenuSubmenuTrigger.js +9 -7
- package/esm/menu/trigger/MenuTrigger.d.ts +10 -6
- package/esm/menu/trigger/MenuTrigger.js +4 -3
- package/esm/menubar/Menubar.d.ts +4 -4
- package/esm/menubar/Menubar.js +2 -2
- package/esm/meter/root/MeterRoot.d.ts +6 -6
- package/esm/meter/root/MeterRoot.js +3 -11
- package/esm/meter/value/MeterValue.d.ts +1 -1
- package/esm/navigation-menu/arrow/NavigationMenuArrow.js +2 -2
- package/esm/navigation-menu/arrow/NavigationMenuArrowDataAttributes.js +2 -2
- package/esm/navigation-menu/backdrop/NavigationMenuBackdrop.js +2 -2
- package/esm/navigation-menu/content/NavigationMenuContent.d.ts +8 -1
- package/esm/navigation-menu/content/NavigationMenuContent.js +26 -5
- package/esm/navigation-menu/icon/NavigationMenuIcon.d.ts +1 -1
- package/esm/navigation-menu/icon/NavigationMenuIcon.js +2 -2
- package/esm/navigation-menu/item/NavigationMenuItem.d.ts +1 -1
- package/esm/navigation-menu/item/NavigationMenuItemContext.js +2 -0
- package/esm/navigation-menu/link/NavigationMenuLink.d.ts +2 -2
- package/esm/navigation-menu/link/NavigationMenuLink.js +2 -2
- package/esm/navigation-menu/list/NavigationMenuDismissContext.js +2 -0
- package/esm/navigation-menu/list/NavigationMenuList.d.ts +1 -1
- package/esm/navigation-menu/list/NavigationMenuList.js +2 -2
- package/esm/navigation-menu/popup/NavigationMenuPopup.d.ts +13 -0
- package/esm/navigation-menu/popup/NavigationMenuPopup.js +2 -2
- package/esm/navigation-menu/popup/NavigationMenuPopupDataAttributes.js +2 -2
- package/esm/navigation-menu/portal/NavigationMenuPortal.d.ts +2 -2
- package/esm/navigation-menu/portal/NavigationMenuPortalContext.js +2 -0
- package/esm/navigation-menu/positioner/NavigationMenuPositioner.js +2 -2
- package/esm/navigation-menu/positioner/NavigationPositionerDataAttributes.js +2 -2
- package/esm/navigation-menu/root/NavigationMenuRoot.d.ts +6 -6
- package/esm/navigation-menu/root/NavigationMenuRoot.js +2 -2
- package/esm/navigation-menu/root/NavigationMenuRootContext.js +2 -0
- package/esm/navigation-menu/trigger/NavigationMenuTrigger.js +8 -124
- package/esm/navigation-menu/utils/isOutsideMenuEvent.d.ts +1 -1
- package/esm/navigation-menu/viewport/NavigationMenuViewport.js +21 -1
- package/esm/number-field/input/NumberFieldInput.js +3 -11
- package/esm/number-field/root/NumberFieldRoot.d.ts +27 -20
- package/esm/number-field/root/NumberFieldRoot.js +22 -7
- package/esm/number-field/root/NumberFieldRootContext.d.ts +2 -2
- package/esm/number-field/root/useNumberFieldButton.d.ts +3 -3
- package/esm/number-field/root/useNumberFieldButton.js +12 -7
- package/esm/number-field/scrub-area/NumberFieldScrubArea.d.ts +2 -2
- package/esm/number-field/scrub-area/NumberFieldScrubArea.js +16 -0
- package/esm/number-field/scrub-area/NumberFieldScrubAreaContext.js +2 -0
- package/esm/number-field/utils/stateAttributesMapping.js +3 -1
- package/esm/number-field/utils/subscribeToVisualViewportResize.d.ts +1 -1
- package/esm/number-field/utils/types.d.ts +5 -5
- package/esm/number-field/utils/validate.d.ts +3 -1
- package/esm/number-field/utils/validate.js +3 -2
- package/esm/popover/arrow/PopoverArrow.js +2 -2
- package/esm/popover/arrow/PopoverArrowDataAttributes.js +2 -2
- package/esm/popover/backdrop/PopoverBackdrop.js +2 -2
- package/esm/popover/popup/PopoverPopup.d.ts +3 -2
- package/esm/popover/popup/PopoverPopup.js +2 -2
- package/esm/popover/portal/PopoverPortal.d.ts +1 -1
- package/esm/popover/portal/PopoverPortal.js +1 -2
- package/esm/popover/portal/PopoverPortalContext.js +2 -0
- package/esm/popover/positioner/PopoverPositioner.js +3 -3
- package/esm/popover/positioner/PopoverPositionerDataAttributes.js +2 -2
- package/esm/popover/root/PopoverRoot.d.ts +9 -9
- package/esm/popover/root/PopoverRoot.js +18 -5
- package/esm/popover/store/PopoverStore.d.ts +255 -15
- package/esm/popover/trigger/PopoverTrigger.d.ts +7 -7
- package/esm/popover/trigger/PopoverTrigger.js +2 -2
- package/esm/popover/viewport/PopoverViewport.d.ts +9 -1
- package/esm/popover/viewport/PopoverViewport.js +19 -196
- package/esm/popover/viewport/PopoverViewportDataAttributes.d.ts +5 -0
- package/esm/popover/viewport/PopoverViewportDataAttributes.js +5 -0
- package/esm/preview-card/arrow/PreviewCardArrow.js +2 -2
- package/esm/preview-card/arrow/PreviewCardArrowDataAttributes.js +2 -2
- package/esm/preview-card/backdrop/PreviewCardBackdrop.js +2 -2
- package/esm/preview-card/popup/PreviewCardPopup.js +2 -2
- package/esm/preview-card/popup/PreviewCardPopupDataAttributes.js +2 -2
- package/esm/preview-card/portal/PreviewCardPortal.d.ts +1 -1
- package/esm/preview-card/portal/PreviewCardPortalContext.js +2 -0
- package/esm/preview-card/positioner/PreviewCardPositioner.js +2 -2
- package/esm/preview-card/positioner/PreviewCardPositionerContext.d.ts +1 -1
- package/esm/preview-card/positioner/PreviewCardPositionerDataAttributes.js +2 -2
- package/esm/preview-card/root/PreviewCardRoot.d.ts +8 -8
- package/esm/preview-card/root/PreviewCardRoot.js +17 -4
- package/esm/preview-card/store/PreviewCardStore.d.ts +255 -15
- package/esm/preview-card/trigger/PreviewCardTrigger.d.ts +4 -4
- package/esm/preview-card/trigger/PreviewCardTrigger.js +2 -2
- package/esm/preview-card/viewport/PreviewCardViewport.d.ts +6 -1
- package/esm/preview-card/viewport/PreviewCardViewport.js +14 -230
- package/esm/progress/root/ProgressRoot.d.ts +6 -6
- package/esm/progress/root/ProgressRoot.js +2 -13
- package/esm/progress/value/ProgressValue.d.ts +1 -1
- package/esm/radio/indicator/RadioIndicator.d.ts +1 -1
- package/esm/radio/indicator/RadioIndicator.js +4 -4
- package/esm/radio/root/RadioRoot.d.ts +37 -17
- package/esm/radio/root/RadioRoot.js +45 -11
- package/esm/radio-group/RadioGroup.d.ts +18 -12
- package/esm/radio-group/RadioGroup.js +69 -62
- package/esm/radio-group/RadioGroupContext.d.ts +9 -8
- package/esm/radio-group/RadioGroupContext.js +1 -13
- package/esm/scroll-area/root/ScrollAreaRoot.d.ts +4 -2
- package/esm/scroll-area/root/ScrollAreaRoot.js +2 -1
- package/esm/scroll-area/root/ScrollAreaRootContext.js +2 -0
- package/esm/scroll-area/root/ScrollAreaRootDataAttributes.d.ts +4 -0
- package/esm/scroll-area/root/ScrollAreaRootDataAttributes.js +4 -0
- package/esm/scroll-area/scrollbar/ScrollAreaScrollbar.d.ts +2 -2
- package/esm/scroll-area/scrollbar/ScrollAreaScrollbar.js +2 -2
- package/esm/scroll-area/scrollbar/ScrollAreaScrollbarContext.js +2 -0
- package/esm/scroll-area/scrollbar/ScrollAreaScrollbarDataAttributes.d.ts +1 -1
- package/esm/scroll-area/scrollbar/ScrollAreaScrollbarDataAttributes.js +1 -1
- package/esm/scroll-area/thumb/ScrollAreaThumb.d.ts +1 -1
- package/esm/scroll-area/thumb/ScrollAreaThumb.js +2 -2
- package/esm/scroll-area/utils/scrollEdges.d.ts +2 -0
- package/esm/scroll-area/utils/scrollEdges.js +22 -0
- package/esm/scroll-area/viewport/ScrollAreaViewport.js +18 -15
- package/esm/scroll-area/viewport/ScrollAreaViewportContext.js +2 -0
- package/esm/scroll-area/viewport/ScrollAreaViewportDataAttributes.d.ts +4 -0
- package/esm/scroll-area/viewport/ScrollAreaViewportDataAttributes.js +4 -0
- package/esm/select/arrow/SelectArrow.js +2 -2
- package/esm/select/arrow/SelectArrowDataAttributes.js +2 -2
- package/esm/select/backdrop/SelectBackdrop.js +2 -2
- package/esm/select/group/SelectGroupContext.js +2 -0
- package/esm/select/icon/SelectIcon.js +2 -2
- package/esm/select/item/SelectItem.d.ts +2 -2
- package/esm/select/item/SelectItem.js +13 -13
- package/esm/select/item/SelectItemContext.js +2 -0
- package/esm/select/item-indicator/SelectItemIndicator.d.ts +1 -1
- package/esm/select/item-indicator/SelectItemIndicator.js +2 -2
- package/esm/select/popup/SelectPopup.d.ts +11 -0
- package/esm/select/popup/SelectPopup.js +64 -35
- package/esm/select/popup/SelectPopupDataAttributes.js +2 -2
- package/esm/select/portal/SelectPortalContext.js +2 -0
- package/esm/select/positioner/SelectPositioner.d.ts +1 -1
- package/esm/select/positioner/SelectPositioner.js +14 -11
- package/esm/select/positioner/SelectPositionerContext.js +2 -0
- package/esm/select/positioner/SelectPositionerDataAttributes.js +2 -2
- package/esm/select/root/SelectRoot.d.ts +27 -22
- package/esm/select/root/SelectRoot.js +2 -0
- package/esm/select/root/SelectRootContext.d.ts +14 -14
- package/esm/select/root/SelectRootContext.js +2 -0
- package/esm/select/scroll-arrow/SelectScrollArrow.d.ts +1 -1
- package/esm/select/scroll-arrow/SelectScrollArrow.js +2 -2
- package/esm/select/scroll-down-arrow/SelectScrollDownArrow.d.ts +1 -1
- package/esm/select/scroll-down-arrow/SelectScrollDownArrowDataAttributes.js +1 -1
- package/esm/select/scroll-up-arrow/SelectScrollUpArrow.d.ts +1 -1
- package/esm/select/scroll-up-arrow/SelectScrollUpArrowDataAttributes.js +1 -1
- package/esm/select/store.d.ts +3 -3
- package/esm/select/store.js +3 -3
- package/esm/select/trigger/SelectTrigger.d.ts +1 -1
- package/esm/select/trigger/SelectTrigger.js +2 -2
- package/esm/select/value/SelectValue.d.ts +4 -0
- package/esm/select/value/SelectValue.js +2 -2
- package/esm/separator/Separator.d.ts +1 -1
- package/esm/separator/Separator.js +2 -2
- package/esm/slider/root/SliderRoot.d.ts +17 -17
- package/esm/slider/root/SliderRoot.js +3 -2
- package/esm/slider/root/SliderRootContext.d.ts +2 -2
- package/esm/slider/root/stateAttributesMapping.js +3 -1
- package/esm/slider/thumb/SliderThumb.d.ts +7 -7
- package/esm/slider/utils/getPushedThumbValues.d.ts +1 -1
- package/esm/slider/utils/resolveThumbCollision.d.ts +2 -2
- package/esm/slider/value/SliderValue.d.ts +1 -1
- package/esm/switch/root/SwitchRoot.d.ts +11 -11
- package/esm/switch/root/SwitchRoot.js +7 -1
- package/esm/switch/root/SwitchRootContext.js +2 -0
- package/esm/tabs/indicator/TabsIndicator.d.ts +1 -1
- package/esm/tabs/indicator/TabsIndicator.js +2 -2
- package/esm/tabs/list/TabsList.d.ts +2 -2
- package/esm/tabs/list/TabsList.js +2 -2
- package/esm/tabs/panel/TabsPanel.d.ts +4 -2
- package/esm/tabs/panel/TabsPanel.js +35 -9
- package/esm/tabs/root/TabsRoot.d.ts +4 -4
- package/esm/tabs/root/TabsRootContext.d.ts +1 -1
- package/esm/tabs/tab/TabsTab.d.ts +1 -1
- package/esm/tabs/tab/TabsTab.js +2 -2
- package/esm/toast/action/ToastAction.js +2 -2
- package/esm/toast/arrow/ToastArrow.js +2 -2
- package/esm/toast/arrow/ToastArrowDataAttributes.js +4 -3
- package/esm/toast/close/ToastClose.js +6 -8
- package/esm/toast/content/ToastContent.js +2 -2
- package/esm/toast/createToastManager.d.ts +5 -5
- package/esm/toast/createToastManager.js +3 -6
- package/esm/toast/description/ToastDescription.js +4 -6
- package/esm/toast/positioner/ToastPositioner.d.ts +2 -2
- package/esm/toast/positioner/ToastPositioner.js +6 -7
- package/esm/toast/positioner/ToastPositionerDataAttributes.js +2 -2
- package/esm/toast/provider/ToastProvider.d.ts +3 -3
- package/esm/toast/provider/ToastProvider.js +26 -285
- package/esm/toast/provider/ToastProviderContext.d.ts +4 -25
- package/esm/toast/provider/ToastProviderContext.js +3 -1
- package/esm/toast/root/ToastRoot.d.ts +1 -1
- package/esm/toast/root/ToastRoot.js +19 -27
- package/esm/toast/root/ToastRootContext.js +2 -0
- package/esm/toast/store.d.ts +51 -0
- package/esm/toast/store.js +355 -0
- package/esm/toast/title/ToastTitle.js +4 -6
- package/esm/toast/useToastManager.d.ts +20 -21
- package/esm/toast/useToastManager.js +8 -14
- package/esm/toast/viewport/ToastViewport.js +66 -92
- package/esm/toggle/Toggle.d.ts +10 -8
- package/esm/toggle/Toggle.js +13 -3
- package/esm/toggle-group/ToggleGroup.d.ts +22 -10
- package/esm/toggle-group/ToggleGroup.js +8 -5
- package/esm/toggle-group/ToggleGroupContext.d.ts +10 -5
- package/esm/toolbar/button/ToolbarButton.d.ts +2 -2
- package/esm/toolbar/button/ToolbarButton.js +2 -2
- package/esm/toolbar/group/ToolbarGroup.d.ts +1 -1
- package/esm/toolbar/group/ToolbarGroup.js +2 -2
- package/esm/toolbar/group/ToolbarGroupContext.js +2 -0
- package/esm/toolbar/input/ToolbarInput.d.ts +3 -3
- package/esm/toolbar/input/ToolbarInput.js +2 -2
- package/esm/toolbar/link/ToolbarLink.js +2 -2
- package/esm/toolbar/root/ToolbarRoot.d.ts +3 -3
- package/esm/toolbar/root/ToolbarRoot.js +2 -2
- package/esm/tooltip/arrow/TooltipArrow.d.ts +1 -0
- package/esm/tooltip/arrow/TooltipArrow.js +2 -2
- package/esm/tooltip/arrow/TooltipArrowDataAttributes.js +2 -2
- package/esm/tooltip/popup/TooltipPopup.js +2 -2
- package/esm/tooltip/popup/TooltipPopupDataAttributes.js +2 -2
- package/esm/tooltip/portal/TooltipPortal.d.ts +1 -1
- package/esm/tooltip/portal/TooltipPortalContext.js +2 -0
- package/esm/tooltip/positioner/TooltipPositioner.d.ts +1 -1
- package/esm/tooltip/positioner/TooltipPositionerContext.d.ts +1 -1
- package/esm/tooltip/positioner/TooltipPositionerDataAttributes.js +2 -2
- package/esm/tooltip/provider/TooltipProvider.d.ts +3 -3
- package/esm/tooltip/provider/TooltipProviderContext.js +2 -0
- package/esm/tooltip/root/TooltipRoot.d.ts +12 -12
- package/esm/tooltip/root/TooltipRoot.js +23 -11
- package/esm/tooltip/store/TooltipStore.d.ts +256 -16
- package/esm/tooltip/trigger/TooltipTrigger.d.ts +11 -4
- package/esm/tooltip/trigger/TooltipTrigger.js +12 -6
- package/esm/tooltip/trigger/TooltipTriggerDataAttributes.d.ts +4 -0
- package/esm/tooltip/trigger/TooltipTriggerDataAttributes.js +4 -0
- package/esm/tooltip/viewport/TooltipViewport.d.ts +9 -1
- package/esm/tooltip/viewport/TooltipViewport.js +14 -195
- package/esm/unstable-use-media-query/index.d.ts +5 -5
- package/esm/use-button/useButton.d.ts +4 -4
- package/esm/use-button/useButton.js +7 -2
- package/esm/use-render/useRender.d.ts +9 -9
- package/esm/utils/InternalBackdrop.d.ts +1 -1
- package/esm/utils/createBaseUIEventDetails.d.ts +3 -0
- package/esm/utils/formatNumber.d.ts +2 -1
- package/esm/utils/formatNumber.js +11 -0
- package/esm/utils/getDisabledMountTransitionStyles.d.ts +1 -1
- package/esm/utils/getPseudoElementBounds.js +1 -1
- package/esm/utils/itemEquality.d.ts +5 -5
- package/esm/utils/itemEquality.js +17 -17
- package/esm/utils/popupStateMapping.d.ts +10 -0
- package/esm/utils/popupStateMapping.js +10 -0
- package/esm/utils/popups/popupStoreUtils.js +2 -0
- package/esm/utils/popups/popupTriggerMap.d.ts +14 -1
- package/esm/utils/popups/popupTriggerMap.js +27 -9
- package/esm/utils/popups/store.d.ts +28 -18
- package/esm/utils/popups/store.js +8 -5
- package/esm/utils/reason-parts.d.ts +3 -0
- package/esm/utils/reason-parts.js +3 -0
- package/esm/utils/scrollable.d.ts +4 -0
- package/esm/utils/scrollable.js +32 -0
- package/esm/utils/types.d.ts +6 -6
- package/esm/utils/useAnchorPositioning.d.ts +26 -26
- package/esm/utils/useAnchorPositioning.js +19 -16
- package/esm/utils/useFocusableWhenDisabled.d.ts +4 -4
- package/esm/utils/useMixedToggleClickHandler.d.ts +1 -1
- package/esm/utils/useMixedToggleClickHandler.js +2 -0
- package/esm/utils/useOpenChangeComplete.d.ts +2 -2
- package/esm/utils/usePopupAutoResize.d.ts +3 -3
- package/esm/utils/usePopupAutoResize.js +3 -1
- package/esm/utils/usePopupViewport.d.ts +58 -0
- package/esm/utils/usePopupViewport.js +247 -0
- package/esm/utils/useRenderElement.d.ts +9 -9
- package/esm/utils/useRenderElement.js +28 -1
- package/esm/utils/useSwipeDismiss.d.ts +108 -0
- package/esm/utils/useSwipeDismiss.js +944 -0
- package/esm/utils/useValueChanged.js +2 -0
- package/field/control/FieldControl.d.ts +3 -3
- package/field/control/FieldControl.js +21 -20
- package/field/error/FieldError.d.ts +5 -2
- package/field/error/FieldError.js +51 -7
- package/field/item/FieldItem.d.ts +1 -1
- package/field/item/FieldItemContext.js +1 -0
- package/field/label/FieldLabel.d.ts +1 -1
- package/field/label/FieldLabel.js +7 -2
- package/field/root/FieldRoot.d.ts +9 -9
- package/field/root/FieldRootContext.d.ts +1 -1
- package/field/useField.d.ts +1 -1
- package/field/useField.js +1 -0
- package/field/validity/FieldValidity.d.ts +2 -0
- package/field/validity/FieldValidity.js +9 -3
- package/fieldset/legend/FieldsetLegend.js +2 -2
- package/fieldset/root/FieldsetRoot.d.ts +1 -1
- package/fieldset/root/FieldsetRoot.js +3 -3
- package/floating-ui-react/components/FloatingDelayGroup.d.ts +2 -7
- package/floating-ui-react/components/FloatingDelayGroup.js +2 -9
- package/floating-ui-react/components/FloatingFocusManager.d.ts +11 -21
- package/floating-ui-react/components/FloatingFocusManager.js +61 -74
- package/floating-ui-react/components/FloatingPortal.d.ts +8 -9
- package/floating-ui-react/components/FloatingPortal.js +1 -3
- package/floating-ui-react/components/FloatingTree.d.ts +1 -1
- package/floating-ui-react/hooks/useClick.d.ts +12 -6
- package/floating-ui-react/hooks/useClick.js +6 -5
- package/floating-ui-react/hooks/useClientPoint.d.ts +2 -12
- package/floating-ui-react/hooks/useClientPoint.js +4 -16
- package/floating-ui-react/hooks/useDismiss.d.ts +15 -15
- package/floating-ui-react/hooks/useDismiss.js +4 -2
- package/floating-ui-react/hooks/useFloating.js +1 -0
- package/floating-ui-react/hooks/useFloatingRootContext.d.ts +4 -10
- package/floating-ui-react/hooks/useFloatingRootContext.js +4 -3
- package/floating-ui-react/hooks/useFocus.d.ts +2 -8
- package/floating-ui-react/hooks/useFocus.js +9 -11
- package/floating-ui-react/hooks/useHover.d.ts +7 -30
- package/floating-ui-react/hooks/useHover.js +18 -36
- package/floating-ui-react/hooks/useHoverFloatingInteraction.d.ts +2 -7
- package/floating-ui-react/hooks/useHoverFloatingInteraction.js +33 -39
- package/floating-ui-react/hooks/useHoverInteractionSharedState.d.ts +17 -14
- package/floating-ui-react/hooks/useHoverInteractionSharedState.js +36 -30
- package/floating-ui-react/hooks/useHoverReferenceInteraction.d.ts +7 -3
- package/floating-ui-react/hooks/useHoverReferenceInteraction.js +55 -59
- package/floating-ui-react/hooks/useInteractions.d.ts +2 -2
- package/floating-ui-react/hooks/useListNavigation.d.ts +19 -35
- package/floating-ui-react/hooks/useListNavigation.js +11 -11
- package/floating-ui-react/hooks/useRole.d.ts +1 -7
- package/floating-ui-react/hooks/useRole.js +2 -3
- package/floating-ui-react/hooks/useSyncedFloatingRootContext.d.ts +2 -2
- package/floating-ui-react/hooks/useSyncedFloatingRootContext.js +1 -0
- package/floating-ui-react/hooks/useTypeahead.d.ts +6 -16
- package/floating-ui-react/hooks/useTypeahead.js +46 -15
- package/floating-ui-react/middleware/arrow.d.ts +1 -1
- package/floating-ui-react/safePolygon.d.ts +3 -3
- package/floating-ui-react/types.d.ts +14 -14
- package/floating-ui-react/utils/composite.d.ts +5 -5
- package/floating-ui-react/utils/composite.js +1 -3
- package/floating-ui-react/utils/element.d.ts +2 -1
- package/floating-ui-react/utils/element.js +16 -4
- package/floating-ui-react/utils/enqueueFocus.d.ts +3 -3
- package/floating-ui-react/utils/event.js +2 -4
- package/floating-ui-react/utils/markOthers.js +2 -2
- package/floating-ui-react/utils/tabbable.js +5 -4
- package/form/Form.d.ts +5 -5
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/input/Input.d.ts +3 -3
- package/labelable-provider/LabelableContext.d.ts +1 -1
- package/labelable-provider/LabelableContext.js +1 -1
- package/labelable-provider/LabelableProvider.js +33 -3
- package/labelable-provider/useLabelableId.d.ts +3 -2
- package/labelable-provider/useLabelableId.js +39 -12
- package/menu/arrow/MenuArrow.js +2 -2
- package/menu/arrow/MenuArrowDataAttributes.js +2 -2
- package/menu/backdrop/MenuBackdrop.js +2 -2
- package/menu/checkbox-item/MenuCheckboxItem.d.ts +8 -8
- package/menu/checkbox-item/MenuCheckboxItemContext.js +1 -0
- package/menu/checkbox-item-indicator/MenuCheckboxItemIndicator.d.ts +2 -2
- package/menu/checkbox-item-indicator/MenuCheckboxItemIndicator.js +3 -3
- package/menu/group/MenuGroupContext.js +1 -0
- package/menu/index.d.ts +2 -1
- package/menu/index.parts.d.ts +1 -0
- package/menu/index.parts.js +7 -0
- package/menu/item/MenuItem.d.ts +5 -5
- package/menu/item/MenuItem.js +2 -2
- package/menu/item/useMenuItem.js +12 -48
- package/menu/item/useMenuItemCommonProps.d.ts +43 -0
- package/menu/item/useMenuItemCommonProps.js +72 -0
- package/menu/link-item/MenuLinkItem.d.ts +34 -0
- package/menu/link-item/MenuLinkItem.js +60 -0
- package/menu/link-item/MenuLinkItemDataAttributes.d.ts +6 -0
- package/menu/link-item/MenuLinkItemDataAttributes.js +13 -0
- package/menu/popup/MenuPopup.d.ts +3 -2
- package/menu/popup/MenuPopup.js +2 -2
- package/menu/popup/MenuPopupDataAttributes.js +2 -2
- package/menu/portal/MenuPortal.d.ts +1 -1
- package/menu/portal/MenuPortalContext.js +1 -0
- package/menu/positioner/MenuPositioner.js +6 -12
- package/menu/positioner/MenuPositionerDataAttributes.js +2 -2
- package/menu/radio-group/MenuRadioGroup.d.ts +2 -2
- package/menu/radio-group/MenuRadioGroup.js +2 -2
- package/menu/radio-group/MenuRadioGroupContext.js +1 -0
- package/menu/radio-item/MenuRadioItem.d.ts +5 -5
- package/menu/radio-item/MenuRadioItemContext.js +1 -0
- package/menu/radio-item-indicator/MenuRadioItemIndicator.d.ts +2 -2
- package/menu/radio-item-indicator/MenuRadioItemIndicator.js +3 -3
- package/menu/root/MenuRoot.d.ts +15 -15
- package/menu/root/MenuRoot.js +39 -37
- package/menu/store/MenuStore.d.ts +255 -15
- package/menu/store/MenuStore.js +2 -11
- package/menu/submenu-root/MenuSubmenuRoot.d.ts +2 -2
- package/menu/submenu-root/MenuSubmenuRootContext.js +1 -0
- package/menu/submenu-trigger/MenuSubmenuTrigger.d.ts +22 -22
- package/menu/submenu-trigger/MenuSubmenuTrigger.js +10 -8
- package/menu/trigger/MenuTrigger.d.ts +10 -6
- package/menu/trigger/MenuTrigger.js +5 -4
- package/menubar/Menubar.d.ts +4 -4
- package/menubar/Menubar.js +2 -2
- package/meter/root/MeterRoot.d.ts +6 -6
- package/meter/root/MeterRoot.js +1 -10
- package/meter/value/MeterValue.d.ts +1 -1
- package/navigation-menu/arrow/NavigationMenuArrow.js +2 -2
- package/navigation-menu/arrow/NavigationMenuArrowDataAttributes.js +2 -2
- package/navigation-menu/backdrop/NavigationMenuBackdrop.js +2 -2
- package/navigation-menu/content/NavigationMenuContent.d.ts +8 -1
- package/navigation-menu/content/NavigationMenuContent.js +26 -5
- package/navigation-menu/icon/NavigationMenuIcon.d.ts +1 -1
- package/navigation-menu/icon/NavigationMenuIcon.js +2 -2
- package/navigation-menu/item/NavigationMenuItem.d.ts +1 -1
- package/navigation-menu/item/NavigationMenuItemContext.js +1 -0
- package/navigation-menu/link/NavigationMenuLink.d.ts +2 -2
- package/navigation-menu/link/NavigationMenuLink.js +2 -2
- package/navigation-menu/list/NavigationMenuDismissContext.js +1 -0
- package/navigation-menu/list/NavigationMenuList.d.ts +1 -1
- package/navigation-menu/list/NavigationMenuList.js +2 -2
- package/navigation-menu/popup/NavigationMenuPopup.d.ts +13 -0
- package/navigation-menu/popup/NavigationMenuPopup.js +2 -2
- package/navigation-menu/popup/NavigationMenuPopupDataAttributes.js +2 -2
- package/navigation-menu/portal/NavigationMenuPortal.d.ts +2 -2
- package/navigation-menu/portal/NavigationMenuPortalContext.js +1 -0
- package/navigation-menu/positioner/NavigationMenuPositioner.js +2 -2
- package/navigation-menu/positioner/NavigationPositionerDataAttributes.js +2 -2
- package/navigation-menu/root/NavigationMenuRoot.d.ts +6 -6
- package/navigation-menu/root/NavigationMenuRoot.js +2 -2
- package/navigation-menu/root/NavigationMenuRootContext.js +1 -0
- package/navigation-menu/trigger/NavigationMenuTrigger.js +7 -124
- package/navigation-menu/utils/isOutsideMenuEvent.d.ts +1 -1
- package/navigation-menu/viewport/NavigationMenuViewport.js +21 -1
- package/number-field/input/NumberFieldInput.js +3 -11
- package/number-field/root/NumberFieldRoot.d.ts +27 -20
- package/number-field/root/NumberFieldRoot.js +22 -7
- package/number-field/root/NumberFieldRootContext.d.ts +2 -2
- package/number-field/root/useNumberFieldButton.d.ts +3 -3
- package/number-field/root/useNumberFieldButton.js +12 -7
- package/number-field/scrub-area/NumberFieldScrubArea.d.ts +2 -2
- package/number-field/scrub-area/NumberFieldScrubArea.js +16 -0
- package/number-field/scrub-area/NumberFieldScrubAreaContext.js +1 -0
- package/number-field/utils/stateAttributesMapping.js +3 -1
- package/number-field/utils/subscribeToVisualViewportResize.d.ts +1 -1
- package/number-field/utils/types.d.ts +5 -5
- package/number-field/utils/validate.d.ts +3 -1
- package/number-field/utils/validate.js +3 -2
- package/package.json +13 -4
- package/popover/arrow/PopoverArrow.js +2 -2
- package/popover/arrow/PopoverArrowDataAttributes.js +2 -2
- package/popover/backdrop/PopoverBackdrop.js +2 -2
- package/popover/popup/PopoverPopup.d.ts +3 -2
- package/popover/popup/PopoverPopup.js +2 -2
- package/popover/portal/PopoverPortal.d.ts +1 -1
- package/popover/portal/PopoverPortal.js +1 -2
- package/popover/portal/PopoverPortalContext.js +1 -0
- package/popover/positioner/PopoverPositioner.js +3 -3
- package/popover/positioner/PopoverPositionerDataAttributes.js +2 -2
- package/popover/root/PopoverRoot.d.ts +9 -9
- package/popover/root/PopoverRoot.js +18 -5
- package/popover/store/PopoverStore.d.ts +255 -15
- package/popover/trigger/PopoverTrigger.d.ts +7 -7
- package/popover/trigger/PopoverTrigger.js +3 -3
- package/popover/viewport/PopoverViewport.d.ts +9 -1
- package/popover/viewport/PopoverViewport.js +19 -196
- package/popover/viewport/PopoverViewportDataAttributes.d.ts +5 -0
- package/popover/viewport/PopoverViewportDataAttributes.js +5 -0
- package/preview-card/arrow/PreviewCardArrow.js +2 -2
- package/preview-card/arrow/PreviewCardArrowDataAttributes.js +2 -2
- package/preview-card/backdrop/PreviewCardBackdrop.js +2 -2
- package/preview-card/popup/PreviewCardPopup.js +2 -2
- package/preview-card/popup/PreviewCardPopupDataAttributes.js +2 -2
- package/preview-card/portal/PreviewCardPortal.d.ts +1 -1
- package/preview-card/portal/PreviewCardPortalContext.js +1 -0
- package/preview-card/positioner/PreviewCardPositioner.js +2 -2
- package/preview-card/positioner/PreviewCardPositionerContext.d.ts +1 -1
- package/preview-card/positioner/PreviewCardPositionerDataAttributes.js +2 -2
- package/preview-card/root/PreviewCardRoot.d.ts +8 -8
- package/preview-card/root/PreviewCardRoot.js +17 -4
- package/preview-card/store/PreviewCardStore.d.ts +255 -15
- package/preview-card/trigger/PreviewCardTrigger.d.ts +4 -4
- package/preview-card/trigger/PreviewCardTrigger.js +3 -3
- package/preview-card/viewport/PreviewCardViewport.d.ts +6 -1
- package/preview-card/viewport/PreviewCardViewport.js +14 -230
- package/progress/root/ProgressRoot.d.ts +6 -6
- package/progress/root/ProgressRoot.js +1 -12
- package/progress/value/ProgressValue.d.ts +1 -1
- package/radio/indicator/RadioIndicator.d.ts +1 -1
- package/radio/indicator/RadioIndicator.js +4 -4
- package/radio/root/RadioRoot.d.ts +37 -17
- package/radio/root/RadioRoot.js +45 -11
- package/radio-group/RadioGroup.d.ts +18 -12
- package/radio-group/RadioGroup.js +68 -61
- package/radio-group/RadioGroupContext.d.ts +9 -8
- package/radio-group/RadioGroupContext.js +1 -13
- package/scroll-area/root/ScrollAreaRoot.d.ts +4 -2
- package/scroll-area/root/ScrollAreaRoot.js +2 -1
- package/scroll-area/root/ScrollAreaRootContext.js +1 -0
- package/scroll-area/root/ScrollAreaRootDataAttributes.d.ts +4 -0
- package/scroll-area/root/ScrollAreaRootDataAttributes.js +4 -0
- package/scroll-area/scrollbar/ScrollAreaScrollbar.d.ts +2 -2
- package/scroll-area/scrollbar/ScrollAreaScrollbar.js +2 -2
- package/scroll-area/scrollbar/ScrollAreaScrollbarContext.js +1 -0
- package/scroll-area/scrollbar/ScrollAreaScrollbarDataAttributes.d.ts +1 -1
- package/scroll-area/scrollbar/ScrollAreaScrollbarDataAttributes.js +1 -1
- package/scroll-area/thumb/ScrollAreaThumb.d.ts +1 -1
- package/scroll-area/thumb/ScrollAreaThumb.js +2 -2
- package/scroll-area/utils/scrollEdges.d.ts +2 -0
- package/scroll-area/utils/scrollEdges.js +29 -0
- package/scroll-area/viewport/ScrollAreaViewport.js +18 -15
- package/scroll-area/viewport/ScrollAreaViewportContext.js +1 -0
- package/scroll-area/viewport/ScrollAreaViewportDataAttributes.d.ts +4 -0
- package/scroll-area/viewport/ScrollAreaViewportDataAttributes.js +4 -0
- package/select/arrow/SelectArrow.js +2 -2
- package/select/arrow/SelectArrowDataAttributes.js +2 -2
- package/select/backdrop/SelectBackdrop.js +2 -2
- package/select/group/SelectGroupContext.js +1 -0
- package/select/icon/SelectIcon.js +2 -2
- package/select/item/SelectItem.d.ts +2 -2
- package/select/item/SelectItem.js +13 -13
- package/select/item/SelectItemContext.js +1 -0
- package/select/item-indicator/SelectItemIndicator.d.ts +1 -1
- package/select/item-indicator/SelectItemIndicator.js +2 -2
- package/select/popup/SelectPopup.d.ts +11 -0
- package/select/popup/SelectPopup.js +64 -35
- package/select/popup/SelectPopupDataAttributes.js +2 -2
- package/select/portal/SelectPortalContext.js +1 -0
- package/select/positioner/SelectPositioner.d.ts +1 -1
- package/select/positioner/SelectPositioner.js +13 -10
- package/select/positioner/SelectPositionerContext.js +1 -0
- package/select/positioner/SelectPositionerDataAttributes.js +2 -2
- package/select/root/SelectRoot.d.ts +27 -22
- package/select/root/SelectRoot.js +2 -0
- package/select/root/SelectRootContext.d.ts +14 -14
- package/select/root/SelectRootContext.js +1 -0
- package/select/scroll-arrow/SelectScrollArrow.d.ts +1 -1
- package/select/scroll-arrow/SelectScrollArrow.js +2 -2
- package/select/scroll-down-arrow/SelectScrollDownArrow.d.ts +1 -1
- package/select/scroll-down-arrow/SelectScrollDownArrowDataAttributes.js +1 -1
- package/select/scroll-up-arrow/SelectScrollUpArrow.d.ts +1 -1
- package/select/scroll-up-arrow/SelectScrollUpArrowDataAttributes.js +1 -1
- package/select/store.d.ts +3 -3
- package/select/store.js +3 -3
- package/select/trigger/SelectTrigger.d.ts +1 -1
- package/select/trigger/SelectTrigger.js +2 -2
- package/select/value/SelectValue.d.ts +4 -0
- package/select/value/SelectValue.js +2 -2
- package/separator/Separator.d.ts +1 -1
- package/separator/Separator.js +2 -2
- package/slider/root/SliderRoot.d.ts +17 -17
- package/slider/root/SliderRoot.js +3 -2
- package/slider/root/SliderRootContext.d.ts +2 -2
- package/slider/root/stateAttributesMapping.js +3 -1
- package/slider/thumb/SliderThumb.d.ts +7 -7
- package/slider/utils/getPushedThumbValues.d.ts +1 -1
- package/slider/utils/resolveThumbCollision.d.ts +2 -2
- package/slider/value/SliderValue.d.ts +1 -1
- package/switch/root/SwitchRoot.d.ts +11 -11
- package/switch/root/SwitchRoot.js +7 -1
- package/switch/root/SwitchRootContext.js +1 -0
- package/tabs/indicator/TabsIndicator.d.ts +1 -1
- package/tabs/indicator/TabsIndicator.js +2 -2
- package/tabs/list/TabsList.d.ts +2 -2
- package/tabs/list/TabsList.js +2 -2
- package/tabs/panel/TabsPanel.d.ts +4 -2
- package/tabs/panel/TabsPanel.js +37 -10
- package/tabs/root/TabsRoot.d.ts +4 -4
- package/tabs/root/TabsRootContext.d.ts +1 -1
- package/tabs/tab/TabsTab.d.ts +1 -1
- package/tabs/tab/TabsTab.js +2 -2
- package/toast/action/ToastAction.js +2 -2
- package/toast/arrow/ToastArrow.js +2 -2
- package/toast/arrow/ToastArrowDataAttributes.js +4 -3
- package/toast/close/ToastClose.js +5 -7
- package/toast/content/ToastContent.js +2 -2
- package/toast/createToastManager.d.ts +5 -5
- package/toast/createToastManager.js +3 -6
- package/toast/description/ToastDescription.js +4 -6
- package/toast/positioner/ToastPositioner.d.ts +2 -2
- package/toast/positioner/ToastPositioner.js +5 -6
- package/toast/positioner/ToastPositionerDataAttributes.js +2 -2
- package/toast/provider/ToastProvider.d.ts +3 -3
- package/toast/provider/ToastProvider.js +24 -284
- package/toast/provider/ToastProviderContext.d.ts +4 -25
- package/toast/provider/ToastProviderContext.js +3 -2
- package/toast/root/ToastRoot.d.ts +1 -1
- package/toast/root/ToastRoot.js +18 -26
- package/toast/root/ToastRootContext.js +1 -0
- package/toast/store.d.ts +51 -0
- package/toast/store.js +362 -0
- package/toast/title/ToastTitle.js +4 -6
- package/toast/useToastManager.d.ts +20 -21
- package/toast/useToastManager.js +8 -14
- package/toast/viewport/ToastViewport.js +65 -91
- package/toggle/Toggle.d.ts +10 -8
- package/toggle/Toggle.js +13 -3
- package/toggle-group/ToggleGroup.d.ts +22 -10
- package/toggle-group/ToggleGroup.js +8 -5
- package/toggle-group/ToggleGroupContext.d.ts +10 -5
- package/toolbar/button/ToolbarButton.d.ts +2 -2
- package/toolbar/button/ToolbarButton.js +2 -2
- package/toolbar/group/ToolbarGroup.d.ts +1 -1
- package/toolbar/group/ToolbarGroup.js +2 -2
- package/toolbar/group/ToolbarGroupContext.js +1 -0
- package/toolbar/input/ToolbarInput.d.ts +3 -3
- package/toolbar/input/ToolbarInput.js +2 -2
- package/toolbar/link/ToolbarLink.js +2 -2
- package/toolbar/root/ToolbarRoot.d.ts +3 -3
- package/toolbar/root/ToolbarRoot.js +2 -2
- package/tooltip/arrow/TooltipArrow.d.ts +1 -0
- package/tooltip/arrow/TooltipArrow.js +2 -2
- package/tooltip/arrow/TooltipArrowDataAttributes.js +2 -2
- package/tooltip/popup/TooltipPopup.js +2 -2
- package/tooltip/popup/TooltipPopupDataAttributes.js +2 -2
- package/tooltip/portal/TooltipPortal.d.ts +1 -1
- package/tooltip/portal/TooltipPortalContext.js +1 -0
- package/tooltip/positioner/TooltipPositioner.d.ts +1 -1
- package/tooltip/positioner/TooltipPositionerContext.d.ts +1 -1
- package/tooltip/positioner/TooltipPositionerDataAttributes.js +2 -2
- package/tooltip/provider/TooltipProvider.d.ts +3 -3
- package/tooltip/provider/TooltipProviderContext.js +1 -0
- package/tooltip/root/TooltipRoot.d.ts +12 -12
- package/tooltip/root/TooltipRoot.js +23 -11
- package/tooltip/store/TooltipStore.d.ts +256 -16
- package/tooltip/trigger/TooltipTrigger.d.ts +11 -4
- package/tooltip/trigger/TooltipTrigger.js +12 -6
- package/tooltip/trigger/TooltipTriggerDataAttributes.d.ts +4 -0
- package/tooltip/trigger/TooltipTriggerDataAttributes.js +4 -0
- package/tooltip/viewport/TooltipViewport.d.ts +9 -1
- package/tooltip/viewport/TooltipViewport.js +14 -195
- package/unstable-use-media-query/index.d.ts +5 -5
- package/use-button/useButton.d.ts +4 -4
- package/use-button/useButton.js +7 -2
- package/use-render/useRender.d.ts +9 -9
- package/utils/InternalBackdrop.d.ts +1 -1
- package/utils/createBaseUIEventDetails.d.ts +3 -0
- package/utils/formatNumber.d.ts +2 -1
- package/utils/formatNumber.js +12 -0
- package/utils/getDisabledMountTransitionStyles.d.ts +1 -1
- package/utils/getPseudoElementBounds.js +1 -1
- package/utils/itemEquality.d.ts +5 -5
- package/utils/itemEquality.js +18 -18
- package/utils/popupStateMapping.d.ts +10 -0
- package/utils/popupStateMapping.js +10 -0
- package/utils/popups/popupStoreUtils.js +1 -0
- package/utils/popups/popupTriggerMap.d.ts +14 -1
- package/utils/popups/popupTriggerMap.js +27 -10
- package/utils/popups/store.d.ts +28 -18
- package/utils/popups/store.js +8 -5
- package/utils/reason-parts.d.ts +3 -0
- package/utils/reason-parts.js +4 -1
- package/utils/scrollable.d.ts +4 -0
- package/utils/scrollable.js +40 -0
- package/utils/types.d.ts +6 -6
- package/utils/useAnchorPositioning.d.ts +26 -26
- package/utils/useAnchorPositioning.js +19 -16
- package/utils/useFocusableWhenDisabled.d.ts +4 -4
- package/utils/useMixedToggleClickHandler.d.ts +1 -1
- package/utils/useMixedToggleClickHandler.js +1 -0
- package/utils/useOpenChangeComplete.d.ts +2 -2
- package/utils/usePopupAutoResize.d.ts +3 -3
- package/utils/usePopupAutoResize.js +2 -1
- package/utils/usePopupViewport.d.ts +58 -0
- package/utils/usePopupViewport.js +253 -0
- package/utils/useRenderElement.d.ts +9 -9
- package/utils/useRenderElement.js +28 -1
- package/utils/useSwipeDismiss.d.ts +108 -0
- package/utils/useSwipeDismiss.js +952 -0
- package/utils/useValueChanged.js +1 -0
- package/esm/toast/viewport/ToastViewportContext.d.ts +0 -6
- package/esm/toast/viewport/ToastViewportContext.js +0 -11
- package/toast/viewport/ToastViewportContext.d.ts +0 -6
- package/toast/viewport/ToastViewportContext.js +0 -20
|
@@ -0,0 +1,944 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
5
|
+
import { ownerDocument } from '@base-ui/utils/owner';
|
|
6
|
+
import { contains, getTarget } from "../floating-ui-react/utils.js";
|
|
7
|
+
import { findScrollableTouchTarget, hasScrollableAncestor } from "./scrollable.js";
|
|
8
|
+
import { clamp } from "./clamp.js";
|
|
9
|
+
const DEFAULT_SWIPE_THRESHOLD = 40;
|
|
10
|
+
const REVERSE_CANCEL_THRESHOLD = 10;
|
|
11
|
+
const MIN_DRAG_THRESHOLD = 1;
|
|
12
|
+
const MIN_VELOCITY_DURATION_MS = 50;
|
|
13
|
+
const MIN_RELEASE_VELOCITY_DURATION_MS = 16;
|
|
14
|
+
const MAX_RELEASE_VELOCITY_AGE_MS = 80;
|
|
15
|
+
const DEFAULT_IGNORE_SELECTOR = 'button,a,input,select,textarea,label,[role="button"]';
|
|
16
|
+
export function getDisplacement(direction, deltaX, deltaY) {
|
|
17
|
+
switch (direction) {
|
|
18
|
+
case 'up':
|
|
19
|
+
return -deltaY;
|
|
20
|
+
case 'down':
|
|
21
|
+
return deltaY;
|
|
22
|
+
case 'left':
|
|
23
|
+
return -deltaX;
|
|
24
|
+
case 'right':
|
|
25
|
+
return deltaX;
|
|
26
|
+
default:
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function getElementTransform(element) {
|
|
31
|
+
const computedStyle = window.getComputedStyle(element);
|
|
32
|
+
const transform = computedStyle.transform;
|
|
33
|
+
let translateX = 0;
|
|
34
|
+
let translateY = 0;
|
|
35
|
+
let scale = 1;
|
|
36
|
+
if (transform && transform !== 'none') {
|
|
37
|
+
const matrix = transform.match(/matrix(?:3d)?\(([^)]+)\)/);
|
|
38
|
+
if (matrix) {
|
|
39
|
+
const values = matrix[1].split(', ').map(parseFloat);
|
|
40
|
+
if (values.length === 6) {
|
|
41
|
+
translateX = values[4];
|
|
42
|
+
translateY = values[5];
|
|
43
|
+
scale = Math.sqrt(values[0] * values[0] + values[1] * values[1]);
|
|
44
|
+
} else if (values.length === 16) {
|
|
45
|
+
translateX = values[12];
|
|
46
|
+
translateY = values[13];
|
|
47
|
+
scale = values[0];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
x: translateX,
|
|
53
|
+
y: translateY,
|
|
54
|
+
scale
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function getValidTimeStamp(timeStamp) {
|
|
58
|
+
return Number.isFinite(timeStamp) && timeStamp > 0 ? timeStamp : null;
|
|
59
|
+
}
|
|
60
|
+
function hasPrimaryMouseButton(buttons) {
|
|
61
|
+
return buttons % 2 === 1;
|
|
62
|
+
}
|
|
63
|
+
function safelyChangePointerCapture(element, pointerId, method) {
|
|
64
|
+
const pointerCaptureMethod = element[method];
|
|
65
|
+
if (typeof pointerCaptureMethod !== 'function') {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
pointerCaptureMethod.call(element, pointerId);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
if (error && typeof error === 'object' && 'name' in error && error.name === 'NotFoundError') {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function useSwipeDismiss(options) {
|
|
78
|
+
const {
|
|
79
|
+
enabled,
|
|
80
|
+
directions,
|
|
81
|
+
elementRef,
|
|
82
|
+
movementCssVars,
|
|
83
|
+
canStart,
|
|
84
|
+
ignoreSelectorWhenTouch = true,
|
|
85
|
+
ignoreScrollableAncestors = false,
|
|
86
|
+
swipeThreshold: swipeThresholdProp,
|
|
87
|
+
onDismiss,
|
|
88
|
+
onProgress,
|
|
89
|
+
onSwipeStart,
|
|
90
|
+
onRelease,
|
|
91
|
+
onSwipingChange,
|
|
92
|
+
trackDrag = true
|
|
93
|
+
} = options;
|
|
94
|
+
const ignoreSelector = DEFAULT_IGNORE_SELECTOR;
|
|
95
|
+
const primaryDirection = directions.length === 1 ? directions[0] : undefined;
|
|
96
|
+
const swipeThresholdDefault = Math.max(0, typeof swipeThresholdProp === 'number' ? swipeThresholdProp : DEFAULT_SWIPE_THRESHOLD);
|
|
97
|
+
const allowLeft = directions.includes('left');
|
|
98
|
+
const allowRight = directions.includes('right');
|
|
99
|
+
const allowUp = directions.includes('up');
|
|
100
|
+
const allowDown = directions.includes('down');
|
|
101
|
+
const hasHorizontal = allowLeft || allowRight;
|
|
102
|
+
const hasVertical = allowUp || allowDown;
|
|
103
|
+
const scrollAxes = React.useMemo(() => {
|
|
104
|
+
const axes = [];
|
|
105
|
+
if (hasVertical) {
|
|
106
|
+
axes.push('vertical');
|
|
107
|
+
}
|
|
108
|
+
if (hasHorizontal) {
|
|
109
|
+
axes.push('horizontal');
|
|
110
|
+
}
|
|
111
|
+
return axes;
|
|
112
|
+
}, [hasHorizontal, hasVertical]);
|
|
113
|
+
const [currentSwipeDirection, setCurrentSwipeDirection] = React.useState(undefined);
|
|
114
|
+
const [isSwiping, setIsSwiping] = React.useState(false);
|
|
115
|
+
const [isRealSwipe, setIsRealSwipe] = React.useState(false);
|
|
116
|
+
const [dragDismissed, setDragDismissed] = React.useState(false);
|
|
117
|
+
const [dragOffset, setDragOffset] = React.useState({
|
|
118
|
+
x: 0,
|
|
119
|
+
y: 0
|
|
120
|
+
});
|
|
121
|
+
const [initialTransform, setInitialTransform] = React.useState({
|
|
122
|
+
x: 0,
|
|
123
|
+
y: 0,
|
|
124
|
+
scale: 1
|
|
125
|
+
});
|
|
126
|
+
const [lockedDirection, setLockedDirection] = React.useState(null);
|
|
127
|
+
const dragStartPosRef = React.useRef({
|
|
128
|
+
x: 0,
|
|
129
|
+
y: 0
|
|
130
|
+
});
|
|
131
|
+
const dragOffsetRef = React.useRef({
|
|
132
|
+
x: 0,
|
|
133
|
+
y: 0
|
|
134
|
+
});
|
|
135
|
+
const lastMovePosRef = React.useRef(null);
|
|
136
|
+
const initialTransformRef = React.useRef({
|
|
137
|
+
x: 0,
|
|
138
|
+
y: 0,
|
|
139
|
+
scale: 1
|
|
140
|
+
});
|
|
141
|
+
const intendedSwipeDirectionRef = React.useRef(undefined);
|
|
142
|
+
const maxSwipeDisplacementRef = React.useRef(0);
|
|
143
|
+
const cancelledSwipeRef = React.useRef(false);
|
|
144
|
+
const swipeCancelBaselineRef = React.useRef({
|
|
145
|
+
x: 0,
|
|
146
|
+
y: 0
|
|
147
|
+
});
|
|
148
|
+
const isFirstPointerMoveRef = React.useRef(false);
|
|
149
|
+
const pendingSwipeRef = React.useRef(false);
|
|
150
|
+
const pendingSwipeStartPosRef = React.useRef(null);
|
|
151
|
+
const swipeFromScrollableRef = React.useRef(false);
|
|
152
|
+
const sawPrimaryButtonsOnMoveRef = React.useRef(false);
|
|
153
|
+
const elementSizeRef = React.useRef({
|
|
154
|
+
width: 0,
|
|
155
|
+
height: 0
|
|
156
|
+
});
|
|
157
|
+
const swipeProgressRef = React.useRef(0);
|
|
158
|
+
const swipeThresholdRef = React.useRef(swipeThresholdDefault);
|
|
159
|
+
const swipeStartTimeRef = React.useRef(null);
|
|
160
|
+
const lastDragSampleRef = React.useRef(null);
|
|
161
|
+
const lastDragVelocityRef = React.useRef({
|
|
162
|
+
x: 0,
|
|
163
|
+
y: 0
|
|
164
|
+
});
|
|
165
|
+
const lastProgressDetailsRef = React.useRef(null);
|
|
166
|
+
const isSwipingRef = React.useRef(false);
|
|
167
|
+
const setSwiping = useStableCallback(nextSwiping => {
|
|
168
|
+
if (isSwipingRef.current === nextSwiping) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
isSwipingRef.current = nextSwiping;
|
|
172
|
+
setIsSwiping(nextSwiping);
|
|
173
|
+
onSwipingChange?.(nextSwiping);
|
|
174
|
+
});
|
|
175
|
+
function resolveSwipeThreshold(direction) {
|
|
176
|
+
if (!direction) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (typeof swipeThresholdProp !== 'function') {
|
|
180
|
+
swipeThresholdRef.current = swipeThresholdDefault;
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const element = elementRef.current;
|
|
184
|
+
if (!element) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const value = swipeThresholdProp({
|
|
188
|
+
element,
|
|
189
|
+
direction
|
|
190
|
+
});
|
|
191
|
+
swipeThresholdRef.current = Math.max(0, value);
|
|
192
|
+
}
|
|
193
|
+
const updateSwipeProgress = useStableCallback((progress, details) => {
|
|
194
|
+
const nextProgress = Number.isFinite(progress) ? clamp(progress, 0, 1) : 0;
|
|
195
|
+
const progressChanged = nextProgress !== swipeProgressRef.current;
|
|
196
|
+
let detailsChanged = false;
|
|
197
|
+
if (details) {
|
|
198
|
+
const lastDetails = lastProgressDetailsRef.current;
|
|
199
|
+
detailsChanged = !lastDetails || lastDetails.deltaX !== details.deltaX || lastDetails.deltaY !== details.deltaY || lastDetails.direction !== details.direction;
|
|
200
|
+
}
|
|
201
|
+
if (!progressChanged && !detailsChanged) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
swipeProgressRef.current = nextProgress;
|
|
205
|
+
if (details) {
|
|
206
|
+
lastProgressDetailsRef.current = details;
|
|
207
|
+
} else if (progressChanged) {
|
|
208
|
+
lastProgressDetailsRef.current = null;
|
|
209
|
+
}
|
|
210
|
+
onProgress?.(nextProgress, details);
|
|
211
|
+
});
|
|
212
|
+
function recordDragSample(offset, timeStamp) {
|
|
213
|
+
if (timeStamp === null) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const lastSample = lastDragSampleRef.current;
|
|
217
|
+
if (lastSample && timeStamp > lastSample.time) {
|
|
218
|
+
const durationMs = Math.max(timeStamp - lastSample.time, MIN_RELEASE_VELOCITY_DURATION_MS);
|
|
219
|
+
lastDragVelocityRef.current = {
|
|
220
|
+
x: (offset.x - lastSample.x) / durationMs,
|
|
221
|
+
y: (offset.y - lastSample.y) / durationMs
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
lastDragSampleRef.current = {
|
|
225
|
+
x: offset.x,
|
|
226
|
+
y: offset.y,
|
|
227
|
+
time: timeStamp
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
const reset = React.useCallback(() => {
|
|
231
|
+
setCurrentSwipeDirection(undefined);
|
|
232
|
+
setSwiping(false);
|
|
233
|
+
setIsRealSwipe(false);
|
|
234
|
+
setDragDismissed(false);
|
|
235
|
+
setDragOffset({
|
|
236
|
+
x: 0,
|
|
237
|
+
y: 0
|
|
238
|
+
});
|
|
239
|
+
setInitialTransform({
|
|
240
|
+
x: 0,
|
|
241
|
+
y: 0,
|
|
242
|
+
scale: 1
|
|
243
|
+
});
|
|
244
|
+
setLockedDirection(null);
|
|
245
|
+
updateSwipeProgress(0);
|
|
246
|
+
swipeThresholdRef.current = swipeThresholdDefault;
|
|
247
|
+
dragStartPosRef.current = {
|
|
248
|
+
x: 0,
|
|
249
|
+
y: 0
|
|
250
|
+
};
|
|
251
|
+
dragOffsetRef.current = {
|
|
252
|
+
x: 0,
|
|
253
|
+
y: 0
|
|
254
|
+
};
|
|
255
|
+
initialTransformRef.current = {
|
|
256
|
+
x: 0,
|
|
257
|
+
y: 0,
|
|
258
|
+
scale: 1
|
|
259
|
+
};
|
|
260
|
+
intendedSwipeDirectionRef.current = undefined;
|
|
261
|
+
maxSwipeDisplacementRef.current = 0;
|
|
262
|
+
cancelledSwipeRef.current = false;
|
|
263
|
+
swipeCancelBaselineRef.current = {
|
|
264
|
+
x: 0,
|
|
265
|
+
y: 0
|
|
266
|
+
};
|
|
267
|
+
isFirstPointerMoveRef.current = false;
|
|
268
|
+
lastMovePosRef.current = null;
|
|
269
|
+
pendingSwipeRef.current = false;
|
|
270
|
+
pendingSwipeStartPosRef.current = null;
|
|
271
|
+
swipeFromScrollableRef.current = false;
|
|
272
|
+
sawPrimaryButtonsOnMoveRef.current = false;
|
|
273
|
+
elementSizeRef.current = {
|
|
274
|
+
width: 0,
|
|
275
|
+
height: 0
|
|
276
|
+
};
|
|
277
|
+
swipeStartTimeRef.current = null;
|
|
278
|
+
lastDragSampleRef.current = null;
|
|
279
|
+
lastDragVelocityRef.current = {
|
|
280
|
+
x: 0,
|
|
281
|
+
y: 0
|
|
282
|
+
};
|
|
283
|
+
lastProgressDetailsRef.current = null;
|
|
284
|
+
}, [setSwiping, swipeThresholdDefault, updateSwipeProgress]);
|
|
285
|
+
React.useEffect(() => {
|
|
286
|
+
if (typeof swipeThresholdProp !== 'function') {
|
|
287
|
+
swipeThresholdRef.current = swipeThresholdDefault;
|
|
288
|
+
}
|
|
289
|
+
}, [swipeThresholdDefault, swipeThresholdProp]);
|
|
290
|
+
function getPrimaryPointerPosition(event) {
|
|
291
|
+
if ('touches' in event) {
|
|
292
|
+
const touch = event.touches[0];
|
|
293
|
+
return touch ? {
|
|
294
|
+
x: touch.clientX,
|
|
295
|
+
y: touch.clientY
|
|
296
|
+
} : null;
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
x: event.clientX,
|
|
300
|
+
y: event.clientY
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function isTouchLikeEvent(event) {
|
|
304
|
+
if ('touches' in event) {
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
return event.pointerType === 'touch';
|
|
308
|
+
}
|
|
309
|
+
function getTargetAtPoint(position, nativeEvent) {
|
|
310
|
+
const doc = ownerDocument(elementRef.current);
|
|
311
|
+
const elementAtPoint = typeof doc?.elementFromPoint === 'function' ? doc.elementFromPoint(position.x, position.y) : null;
|
|
312
|
+
const target = elementAtPoint ?? getTarget(nativeEvent);
|
|
313
|
+
return target;
|
|
314
|
+
}
|
|
315
|
+
function findGestureScrollableTouchTarget(target, root) {
|
|
316
|
+
if (hasHorizontal && !hasVertical) {
|
|
317
|
+
return findScrollableTouchTarget(target, root, 'horizontal');
|
|
318
|
+
}
|
|
319
|
+
if (hasVertical && !hasHorizontal) {
|
|
320
|
+
return findScrollableTouchTarget(target, root, 'vertical');
|
|
321
|
+
}
|
|
322
|
+
return findScrollableTouchTarget(target, root, 'vertical') ?? findScrollableTouchTarget(target, root, 'horizontal');
|
|
323
|
+
}
|
|
324
|
+
function startSwipeAtPosition(event, position, startOptions) {
|
|
325
|
+
swipeFromScrollableRef.current = false;
|
|
326
|
+
const touchLike = isTouchLikeEvent(event);
|
|
327
|
+
const target = getTargetAtPoint(position, event.nativeEvent);
|
|
328
|
+
const doc = ownerDocument(elementRef.current);
|
|
329
|
+
const body = doc.body;
|
|
330
|
+
const scrollableTarget = touchLike && body ? findGestureScrollableTouchTarget(target, body) : null;
|
|
331
|
+
const ignoreScrollableTarget = startOptions?.ignoreScrollableTarget ?? false;
|
|
332
|
+
if (scrollableTarget && !ignoreScrollableTarget) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
swipeFromScrollableRef.current = Boolean(scrollableTarget && ignoreScrollableTarget);
|
|
336
|
+
const isInteractiveElement = target ? target.closest(ignoreSelector) : false;
|
|
337
|
+
if (isInteractiveElement && (!touchLike || ignoreSelectorWhenTouch)) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
const element = elementRef.current;
|
|
341
|
+
if (ignoreScrollableAncestors && element && target && scrollAxes.length > 0) {
|
|
342
|
+
const ignoreAncestors = startOptions?.ignoreScrollableAncestors ?? false;
|
|
343
|
+
if (!ignoreAncestors && hasScrollableAncestor(target, element, scrollAxes)) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
cancelledSwipeRef.current = false;
|
|
348
|
+
intendedSwipeDirectionRef.current = undefined;
|
|
349
|
+
maxSwipeDisplacementRef.current = 0;
|
|
350
|
+
dragStartPosRef.current = position;
|
|
351
|
+
swipeStartTimeRef.current = getValidTimeStamp(event.timeStamp);
|
|
352
|
+
swipeCancelBaselineRef.current = position;
|
|
353
|
+
lastMovePosRef.current = position;
|
|
354
|
+
if (element) {
|
|
355
|
+
elementSizeRef.current = {
|
|
356
|
+
width: element.offsetWidth,
|
|
357
|
+
height: element.offsetHeight
|
|
358
|
+
};
|
|
359
|
+
resolveSwipeThreshold(primaryDirection);
|
|
360
|
+
const transform = getElementTransform(element);
|
|
361
|
+
initialTransformRef.current = transform;
|
|
362
|
+
dragOffsetRef.current = {
|
|
363
|
+
x: transform.x,
|
|
364
|
+
y: transform.y
|
|
365
|
+
};
|
|
366
|
+
setInitialTransform(transform);
|
|
367
|
+
setDragOffset({
|
|
368
|
+
x: transform.x,
|
|
369
|
+
y: transform.y
|
|
370
|
+
});
|
|
371
|
+
recordDragSample({
|
|
372
|
+
x: transform.x,
|
|
373
|
+
y: transform.y
|
|
374
|
+
}, swipeStartTimeRef.current);
|
|
375
|
+
if (!('touches' in event)) {
|
|
376
|
+
safelyChangePointerCapture(element, event.pointerId, 'setPointerCapture');
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
onSwipeStart?.(event.nativeEvent);
|
|
380
|
+
setSwiping(true);
|
|
381
|
+
setIsRealSwipe(false);
|
|
382
|
+
setLockedDirection(null);
|
|
383
|
+
isFirstPointerMoveRef.current = true;
|
|
384
|
+
updateSwipeProgress(0);
|
|
385
|
+
return true;
|
|
386
|
+
}
|
|
387
|
+
function resetPendingSwipeState() {
|
|
388
|
+
clearPendingSwipeStartState();
|
|
389
|
+
swipeFromScrollableRef.current = false;
|
|
390
|
+
lastMovePosRef.current = null;
|
|
391
|
+
}
|
|
392
|
+
function clearPendingSwipeStartState() {
|
|
393
|
+
pendingSwipeRef.current = false;
|
|
394
|
+
pendingSwipeStartPosRef.current = null;
|
|
395
|
+
}
|
|
396
|
+
function cancelSwipeInteraction(event) {
|
|
397
|
+
resetPendingSwipeState();
|
|
398
|
+
if (!isSwipingRef.current) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
setSwiping(false);
|
|
402
|
+
setIsRealSwipe(false);
|
|
403
|
+
setLockedDirection(null);
|
|
404
|
+
const resolvedInitialTransform = trackDrag ? initialTransform : initialTransformRef.current;
|
|
405
|
+
dragOffsetRef.current = {
|
|
406
|
+
x: resolvedInitialTransform.x,
|
|
407
|
+
y: resolvedInitialTransform.y
|
|
408
|
+
};
|
|
409
|
+
setDragOffset({
|
|
410
|
+
x: resolvedInitialTransform.x,
|
|
411
|
+
y: resolvedInitialTransform.y
|
|
412
|
+
});
|
|
413
|
+
setCurrentSwipeDirection(undefined);
|
|
414
|
+
sawPrimaryButtonsOnMoveRef.current = false;
|
|
415
|
+
const element = elementRef.current;
|
|
416
|
+
if (element) {
|
|
417
|
+
safelyChangePointerCapture(element, event.pointerId, 'releasePointerCapture');
|
|
418
|
+
}
|
|
419
|
+
updateSwipeProgress(0, {
|
|
420
|
+
deltaX: 0,
|
|
421
|
+
deltaY: 0,
|
|
422
|
+
direction: undefined
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
function applyDirectionalDamping(deltaX, deltaY) {
|
|
426
|
+
const exponent = value => value >= 0 ? value ** 0.5 : -(Math.abs(value) ** 0.5);
|
|
427
|
+
const dampAxis = (delta, allowNegative, allowPositive) => {
|
|
428
|
+
if (!allowNegative && delta < 0) {
|
|
429
|
+
return exponent(delta);
|
|
430
|
+
}
|
|
431
|
+
if (!allowPositive && delta > 0) {
|
|
432
|
+
return exponent(delta);
|
|
433
|
+
}
|
|
434
|
+
return delta;
|
|
435
|
+
};
|
|
436
|
+
const newDeltaX = hasHorizontal ? dampAxis(deltaX, allowLeft, allowRight) : exponent(deltaX);
|
|
437
|
+
const newDeltaY = hasVertical ? dampAxis(deltaY, allowUp, allowDown) : exponent(deltaY);
|
|
438
|
+
return {
|
|
439
|
+
x: newDeltaX,
|
|
440
|
+
y: newDeltaY
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
function canSwipeFromScrollEdgeOnPendingMove(scrollTarget, deltaX, deltaY) {
|
|
444
|
+
const absDeltaX = Math.abs(deltaX);
|
|
445
|
+
const absDeltaY = Math.abs(deltaY);
|
|
446
|
+
const useVerticalAxis = hasVertical && deltaY !== 0 && (!hasHorizontal || absDeltaY >= absDeltaX);
|
|
447
|
+
if (useVerticalAxis) {
|
|
448
|
+
const maxScrollTop = Math.max(0, scrollTarget.scrollHeight - scrollTarget.clientHeight);
|
|
449
|
+
const atTop = scrollTarget.scrollTop <= 0;
|
|
450
|
+
const atBottom = scrollTarget.scrollTop >= maxScrollTop;
|
|
451
|
+
const movingDown = deltaY > 0;
|
|
452
|
+
const movingUp = deltaY < 0;
|
|
453
|
+
const canSwipeDown = movingDown && atTop && allowDown;
|
|
454
|
+
const canSwipeUp = movingUp && atBottom && allowUp;
|
|
455
|
+
return canSwipeDown || canSwipeUp;
|
|
456
|
+
}
|
|
457
|
+
const useHorizontalAxis = hasHorizontal && deltaX !== 0 && (!hasVertical || absDeltaX > absDeltaY);
|
|
458
|
+
if (useHorizontalAxis) {
|
|
459
|
+
const maxScrollLeft = Math.max(0, scrollTarget.scrollWidth - scrollTarget.clientWidth);
|
|
460
|
+
const atLeft = scrollTarget.scrollLeft <= 0;
|
|
461
|
+
const atRight = scrollTarget.scrollLeft >= maxScrollLeft;
|
|
462
|
+
const movingRight = deltaX > 0;
|
|
463
|
+
const movingLeft = deltaX < 0;
|
|
464
|
+
const canSwipeRight = movingRight && atLeft && allowRight;
|
|
465
|
+
const canSwipeLeft = movingLeft && atRight && allowLeft;
|
|
466
|
+
return canSwipeRight || canSwipeLeft;
|
|
467
|
+
}
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
470
|
+
const handleStart = useStableCallback(event => {
|
|
471
|
+
if (!enabled) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (event.defaultPrevented || event.nativeEvent.defaultPrevented) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
if (!('touches' in event) && event.button !== 0) {
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
const startPos = getPrimaryPointerPosition(event);
|
|
481
|
+
if (!startPos) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
pendingSwipeRef.current = true;
|
|
485
|
+
pendingSwipeStartPosRef.current = startPos;
|
|
486
|
+
swipeFromScrollableRef.current = false;
|
|
487
|
+
sawPrimaryButtonsOnMoveRef.current = false;
|
|
488
|
+
const allowedToStart = canStart ? canStart(startPos, {
|
|
489
|
+
nativeEvent: event.nativeEvent,
|
|
490
|
+
direction: primaryDirection
|
|
491
|
+
}) : true;
|
|
492
|
+
if (!allowedToStart) {
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
if (startSwipeAtPosition(event, startPos)) {
|
|
496
|
+
clearPendingSwipeStartState();
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
function handleMoveCore(event, position, movement) {
|
|
500
|
+
if (!enabled || !isSwipingRef.current) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
const target = getTarget(event.nativeEvent);
|
|
504
|
+
if (isTouchLikeEvent(event) && !swipeFromScrollableRef.current) {
|
|
505
|
+
const boundaryElement = event.currentTarget;
|
|
506
|
+
if (findGestureScrollableTouchTarget(target, boundaryElement)) {
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (!('touches' in event)) {
|
|
511
|
+
// Prevent text selection on Safari
|
|
512
|
+
event.preventDefault();
|
|
513
|
+
}
|
|
514
|
+
if (isFirstPointerMoveRef.current) {
|
|
515
|
+
// Adjust the starting position to the current position on the first move
|
|
516
|
+
// to account for the delay between pointerdown and the first pointermove on iOS.
|
|
517
|
+
dragStartPosRef.current = position;
|
|
518
|
+
const moveTime = getValidTimeStamp(event.timeStamp);
|
|
519
|
+
if (moveTime !== null) {
|
|
520
|
+
swipeStartTimeRef.current = moveTime;
|
|
521
|
+
}
|
|
522
|
+
isFirstPointerMoveRef.current = false;
|
|
523
|
+
}
|
|
524
|
+
const clientX = position.x;
|
|
525
|
+
const clientY = position.y;
|
|
526
|
+
const movementX = movement.x;
|
|
527
|
+
const movementY = movement.y;
|
|
528
|
+
if (movementY < 0 && clientY > swipeCancelBaselineRef.current.y || movementY > 0 && clientY < swipeCancelBaselineRef.current.y) {
|
|
529
|
+
swipeCancelBaselineRef.current = {
|
|
530
|
+
x: swipeCancelBaselineRef.current.x,
|
|
531
|
+
y: clientY
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
if (movementX < 0 && clientX > swipeCancelBaselineRef.current.x || movementX > 0 && clientX < swipeCancelBaselineRef.current.x) {
|
|
535
|
+
swipeCancelBaselineRef.current = {
|
|
536
|
+
x: clientX,
|
|
537
|
+
y: swipeCancelBaselineRef.current.y
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
const deltaX = clientX - dragStartPosRef.current.x;
|
|
541
|
+
const deltaY = clientY - dragStartPosRef.current.y;
|
|
542
|
+
const cancelDeltaY = clientY - swipeCancelBaselineRef.current.y;
|
|
543
|
+
const cancelDeltaX = clientX - swipeCancelBaselineRef.current.x;
|
|
544
|
+
if (!isRealSwipe) {
|
|
545
|
+
const movementDistance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
546
|
+
if (movementDistance >= MIN_DRAG_THRESHOLD) {
|
|
547
|
+
setIsRealSwipe(true);
|
|
548
|
+
if (lockedDirection === null) {
|
|
549
|
+
if (hasHorizontal && hasVertical) {
|
|
550
|
+
const absX = Math.abs(deltaX);
|
|
551
|
+
const absY = Math.abs(deltaY);
|
|
552
|
+
setLockedDirection(absX > absY ? 'horizontal' : 'vertical');
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
let candidate;
|
|
558
|
+
if (!intendedSwipeDirectionRef.current) {
|
|
559
|
+
if (lockedDirection === 'vertical') {
|
|
560
|
+
if (deltaY > 0) {
|
|
561
|
+
candidate = 'down';
|
|
562
|
+
} else if (deltaY < 0) {
|
|
563
|
+
candidate = 'up';
|
|
564
|
+
}
|
|
565
|
+
} else if (lockedDirection === 'horizontal') {
|
|
566
|
+
if (deltaX > 0) {
|
|
567
|
+
candidate = 'right';
|
|
568
|
+
} else if (deltaX < 0) {
|
|
569
|
+
candidate = 'left';
|
|
570
|
+
}
|
|
571
|
+
} else if (Math.abs(deltaX) >= Math.abs(deltaY)) {
|
|
572
|
+
candidate = deltaX > 0 ? 'right' : 'left';
|
|
573
|
+
} else {
|
|
574
|
+
candidate = deltaY > 0 ? 'down' : 'up';
|
|
575
|
+
}
|
|
576
|
+
if (candidate) {
|
|
577
|
+
const isAllowed = candidate === 'left' && allowLeft || candidate === 'right' && allowRight || candidate === 'up' && allowUp || candidate === 'down' && allowDown;
|
|
578
|
+
if (isAllowed) {
|
|
579
|
+
intendedSwipeDirectionRef.current = candidate;
|
|
580
|
+
maxSwipeDisplacementRef.current = getDisplacement(candidate, deltaX, deltaY);
|
|
581
|
+
setCurrentSwipeDirection(candidate);
|
|
582
|
+
resolveSwipeThreshold(candidate);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
} else {
|
|
586
|
+
const direction = intendedSwipeDirectionRef.current;
|
|
587
|
+
const currentDisplacement = getDisplacement(direction, cancelDeltaX, cancelDeltaY);
|
|
588
|
+
if (currentDisplacement > swipeThresholdRef.current) {
|
|
589
|
+
cancelledSwipeRef.current = false;
|
|
590
|
+
setCurrentSwipeDirection(direction);
|
|
591
|
+
} else if (!(allowLeft && allowRight) && !(allowUp && allowDown) && maxSwipeDisplacementRef.current - currentDisplacement >= REVERSE_CANCEL_THRESHOLD) {
|
|
592
|
+
// Mark that a change-of-mind has occurred
|
|
593
|
+
cancelledSwipeRef.current = true;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
const dampedDelta = applyDirectionalDamping(deltaX, deltaY);
|
|
597
|
+
let newOffsetX = initialTransformRef.current.x;
|
|
598
|
+
let newOffsetY = initialTransformRef.current.y;
|
|
599
|
+
if (lockedDirection === 'horizontal') {
|
|
600
|
+
if (hasHorizontal) {
|
|
601
|
+
newOffsetX += dampedDelta.x;
|
|
602
|
+
}
|
|
603
|
+
} else if (lockedDirection === 'vertical') {
|
|
604
|
+
if (hasVertical) {
|
|
605
|
+
newOffsetY += dampedDelta.y;
|
|
606
|
+
}
|
|
607
|
+
} else {
|
|
608
|
+
if (hasHorizontal) {
|
|
609
|
+
newOffsetX += dampedDelta.x;
|
|
610
|
+
}
|
|
611
|
+
if (hasVertical) {
|
|
612
|
+
newOffsetY += dampedDelta.y;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
dragOffsetRef.current = {
|
|
616
|
+
x: newOffsetX,
|
|
617
|
+
y: newOffsetY
|
|
618
|
+
};
|
|
619
|
+
if (trackDrag) {
|
|
620
|
+
setDragOffset({
|
|
621
|
+
x: newOffsetX,
|
|
622
|
+
y: newOffsetY
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
recordDragSample({
|
|
626
|
+
x: newOffsetX,
|
|
627
|
+
y: newOffsetY
|
|
628
|
+
}, getValidTimeStamp(event.timeStamp));
|
|
629
|
+
const dragDeltaX = newOffsetX - initialTransformRef.current.x;
|
|
630
|
+
const dragDeltaY = newOffsetY - initialTransformRef.current.y;
|
|
631
|
+
const swipeDirectionDetails = intendedSwipeDirectionRef.current;
|
|
632
|
+
const progressDirection = primaryDirection ?? intendedSwipeDirectionRef.current;
|
|
633
|
+
if (!progressDirection) {
|
|
634
|
+
updateSwipeProgress(0, {
|
|
635
|
+
deltaX: dragDeltaX,
|
|
636
|
+
deltaY: dragDeltaY,
|
|
637
|
+
direction: swipeDirectionDetails
|
|
638
|
+
});
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
const size = progressDirection === 'left' || progressDirection === 'right' ? elementSizeRef.current.width : elementSizeRef.current.height;
|
|
642
|
+
const scale = initialTransformRef.current.scale || 1;
|
|
643
|
+
if (size <= 0 || scale <= 0) {
|
|
644
|
+
updateSwipeProgress(0, {
|
|
645
|
+
deltaX: dragDeltaX,
|
|
646
|
+
deltaY: dragDeltaY,
|
|
647
|
+
direction: swipeDirectionDetails
|
|
648
|
+
});
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
const progressDisplacement = getDisplacement(progressDirection, newOffsetX - initialTransformRef.current.x, newOffsetY - initialTransformRef.current.y);
|
|
652
|
+
if (progressDisplacement <= 0) {
|
|
653
|
+
updateSwipeProgress(0, {
|
|
654
|
+
deltaX: dragDeltaX,
|
|
655
|
+
deltaY: dragDeltaY,
|
|
656
|
+
direction: swipeDirectionDetails
|
|
657
|
+
});
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
updateSwipeProgress(progressDisplacement / (size * scale), {
|
|
661
|
+
deltaX: dragDeltaX,
|
|
662
|
+
deltaY: dragDeltaY,
|
|
663
|
+
direction: swipeDirectionDetails
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
const handleMove = useStableCallback(event => {
|
|
667
|
+
const currentPos = getPrimaryPointerPosition(event);
|
|
668
|
+
if (!currentPos) {
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
if (!('touches' in event)) {
|
|
672
|
+
const hasPrimaryButton = hasPrimaryMouseButton(event.buttons);
|
|
673
|
+
if (hasPrimaryButton) {
|
|
674
|
+
sawPrimaryButtonsOnMoveRef.current = true;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
// Cancel the swipe if a non-primary button takes over the interaction.
|
|
678
|
+
// This handles cases where a right-click interrupts dragging.
|
|
679
|
+
const lostPrimaryButtonDuringSwipe = event.buttons === 0 && sawPrimaryButtonsOnMoveRef.current;
|
|
680
|
+
if (event.buttons !== 0 && !hasPrimaryButton || lostPrimaryButtonDuringSwipe) {
|
|
681
|
+
cancelSwipeInteraction(event);
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
if (!isSwiping && pendingSwipeRef.current) {
|
|
686
|
+
if (!isTouchLikeEvent(event) && (event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
|
|
687
|
+
resetPendingSwipeState();
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
const allowedToStart = canStart ? canStart(currentPos, {
|
|
691
|
+
nativeEvent: event.nativeEvent,
|
|
692
|
+
direction: primaryDirection
|
|
693
|
+
}) : true;
|
|
694
|
+
if (allowedToStart) {
|
|
695
|
+
const pendingStartPos = pendingSwipeStartPosRef.current;
|
|
696
|
+
let ignoreScrollableOnStart = false;
|
|
697
|
+
if (isTouchLikeEvent(event)) {
|
|
698
|
+
const element = elementRef.current;
|
|
699
|
+
if (pendingStartPos && element) {
|
|
700
|
+
const target = getTargetAtPoint(currentPos, event.nativeEvent);
|
|
701
|
+
const doc = ownerDocument(element);
|
|
702
|
+
const body = doc.body;
|
|
703
|
+
const scrollTarget = body ? findGestureScrollableTouchTarget(target, body) : null;
|
|
704
|
+
if (scrollTarget && (contains(element, scrollTarget) || contains(scrollTarget, element))) {
|
|
705
|
+
const deltaX = currentPos.x - pendingStartPos.x;
|
|
706
|
+
const deltaY = currentPos.y - pendingStartPos.y;
|
|
707
|
+
const canSwipeFromEdge = canSwipeFromScrollEdgeOnPendingMove(scrollTarget, deltaX, deltaY);
|
|
708
|
+
if (canSwipeFromEdge === false) {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
if (canSwipeFromEdge === true) {
|
|
712
|
+
ignoreScrollableOnStart = true;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
const started = startSwipeAtPosition(event, currentPos, {
|
|
718
|
+
ignoreScrollableTarget: ignoreScrollableOnStart,
|
|
719
|
+
ignoreScrollableAncestors: ignoreScrollableOnStart
|
|
720
|
+
});
|
|
721
|
+
if (started) {
|
|
722
|
+
if (pendingStartPos && ignoreScrollableOnStart) {
|
|
723
|
+
// Preserve displacement between touchstart and the move that activates swipe from
|
|
724
|
+
// a scroll-edge so quick flicks can dismiss.
|
|
725
|
+
clearPendingSwipeStartState();
|
|
726
|
+
dragStartPosRef.current = pendingStartPos;
|
|
727
|
+
swipeCancelBaselineRef.current = pendingStartPos;
|
|
728
|
+
lastMovePosRef.current = pendingStartPos;
|
|
729
|
+
isFirstPointerMoveRef.current = false;
|
|
730
|
+
} else {
|
|
731
|
+
// Start from the current in-bounds position without dropping follow-up move
|
|
732
|
+
// displacement; this avoids jumps when entering from outside the element while
|
|
733
|
+
// keeping swipe tracking responsive on the next move.
|
|
734
|
+
clearPendingSwipeStartState();
|
|
735
|
+
swipeFromScrollableRef.current = false;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
const previousPos = lastMovePosRef.current;
|
|
741
|
+
const movement = previousPos === null ? {
|
|
742
|
+
x: 0,
|
|
743
|
+
y: 0
|
|
744
|
+
} : {
|
|
745
|
+
x: currentPos.x - previousPos.x,
|
|
746
|
+
y: currentPos.y - previousPos.y
|
|
747
|
+
};
|
|
748
|
+
lastMovePosRef.current = currentPos;
|
|
749
|
+
handleMoveCore(event, currentPos, movement);
|
|
750
|
+
});
|
|
751
|
+
const handleEnd = useStableCallback(event => {
|
|
752
|
+
if (!enabled) {
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
const resolvedDragOffset = dragOffsetRef.current;
|
|
756
|
+
const resolvedInitialTransform = initialTransformRef.current;
|
|
757
|
+
const releaseDeltaX = resolvedDragOffset.x - resolvedInitialTransform.x;
|
|
758
|
+
const releaseDeltaY = resolvedDragOffset.y - resolvedInitialTransform.y;
|
|
759
|
+
const progressDetails = {
|
|
760
|
+
deltaX: releaseDeltaX,
|
|
761
|
+
deltaY: releaseDeltaY,
|
|
762
|
+
direction: currentSwipeDirection ?? intendedSwipeDirectionRef.current
|
|
763
|
+
};
|
|
764
|
+
if (!isSwipingRef.current) {
|
|
765
|
+
resetPendingSwipeState();
|
|
766
|
+
updateSwipeProgress(0, progressDetails);
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
setSwiping(false);
|
|
770
|
+
setIsRealSwipe(false);
|
|
771
|
+
setLockedDirection(null);
|
|
772
|
+
resetPendingSwipeState();
|
|
773
|
+
sawPrimaryButtonsOnMoveRef.current = false;
|
|
774
|
+
const element = elementRef.current;
|
|
775
|
+
if (element) {
|
|
776
|
+
if (!('touches' in event)) {
|
|
777
|
+
safelyChangePointerCapture(element, event.pointerId, 'releasePointerCapture');
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
const deltaX = releaseDeltaX;
|
|
781
|
+
const deltaY = releaseDeltaY;
|
|
782
|
+
const startTime = swipeStartTimeRef.current;
|
|
783
|
+
const endTime = getValidTimeStamp(event.timeStamp);
|
|
784
|
+
const durationMs = startTime !== null && endTime !== null && endTime > startTime ? endTime - startTime : 0;
|
|
785
|
+
const velocityDurationMs = durationMs > 0 ? Math.max(durationMs, MIN_VELOCITY_DURATION_MS) : 0;
|
|
786
|
+
const velocityX = velocityDurationMs > 0 ? deltaX / velocityDurationMs : 0;
|
|
787
|
+
const velocityY = velocityDurationMs > 0 ? deltaY / velocityDurationMs : 0;
|
|
788
|
+
let releaseVelocityX = lastDragVelocityRef.current.x;
|
|
789
|
+
let releaseVelocityY = lastDragVelocityRef.current.y;
|
|
790
|
+
const lastSample = lastDragSampleRef.current;
|
|
791
|
+
if (lastSample && endTime !== null && endTime >= lastSample.time) {
|
|
792
|
+
const ageMs = endTime - lastSample.time;
|
|
793
|
+
if (ageMs <= MAX_RELEASE_VELOCITY_AGE_MS) {
|
|
794
|
+
const sampleDurationMs = Math.max(ageMs, MIN_RELEASE_VELOCITY_DURATION_MS);
|
|
795
|
+
const deltaFromLastSampleX = resolvedDragOffset.x - lastSample.x;
|
|
796
|
+
const deltaFromLastSampleY = resolvedDragOffset.y - lastSample.y;
|
|
797
|
+
const sampleVelocityX = deltaFromLastSampleX / sampleDurationMs;
|
|
798
|
+
const sampleVelocityY = deltaFromLastSampleY / sampleDurationMs;
|
|
799
|
+
if (sampleVelocityX !== 0) {
|
|
800
|
+
releaseVelocityX = sampleVelocityX;
|
|
801
|
+
}
|
|
802
|
+
if (sampleVelocityY !== 0) {
|
|
803
|
+
releaseVelocityY = sampleVelocityY;
|
|
804
|
+
}
|
|
805
|
+
} else {
|
|
806
|
+
releaseVelocityX = 0;
|
|
807
|
+
releaseVelocityY = 0;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
const releaseDecision = onRelease?.({
|
|
811
|
+
event: event.nativeEvent,
|
|
812
|
+
direction: currentSwipeDirection ?? intendedSwipeDirectionRef.current,
|
|
813
|
+
deltaX,
|
|
814
|
+
deltaY,
|
|
815
|
+
velocityX,
|
|
816
|
+
velocityY,
|
|
817
|
+
releaseVelocityX,
|
|
818
|
+
releaseVelocityY
|
|
819
|
+
});
|
|
820
|
+
const hasReleaseDecision = typeof releaseDecision === 'boolean';
|
|
821
|
+
if (cancelledSwipeRef.current && !hasReleaseDecision) {
|
|
822
|
+
dragOffsetRef.current = {
|
|
823
|
+
x: resolvedInitialTransform.x,
|
|
824
|
+
y: resolvedInitialTransform.y
|
|
825
|
+
};
|
|
826
|
+
setDragOffset({
|
|
827
|
+
x: resolvedInitialTransform.x,
|
|
828
|
+
y: resolvedInitialTransform.y
|
|
829
|
+
});
|
|
830
|
+
setCurrentSwipeDirection(undefined);
|
|
831
|
+
updateSwipeProgress(0, progressDetails);
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
let shouldClose = false;
|
|
835
|
+
let dismissDirection;
|
|
836
|
+
if (hasReleaseDecision) {
|
|
837
|
+
shouldClose = releaseDecision;
|
|
838
|
+
dismissDirection = currentSwipeDirection ?? intendedSwipeDirectionRef.current ?? primaryDirection;
|
|
839
|
+
} else {
|
|
840
|
+
for (const direction of directions) {
|
|
841
|
+
switch (direction) {
|
|
842
|
+
case 'right':
|
|
843
|
+
if (deltaX > swipeThresholdRef.current) {
|
|
844
|
+
shouldClose = true;
|
|
845
|
+
dismissDirection = 'right';
|
|
846
|
+
}
|
|
847
|
+
break;
|
|
848
|
+
case 'left':
|
|
849
|
+
if (deltaX < -swipeThresholdRef.current) {
|
|
850
|
+
shouldClose = true;
|
|
851
|
+
dismissDirection = 'left';
|
|
852
|
+
}
|
|
853
|
+
break;
|
|
854
|
+
case 'down':
|
|
855
|
+
if (deltaY > swipeThresholdRef.current) {
|
|
856
|
+
shouldClose = true;
|
|
857
|
+
dismissDirection = 'down';
|
|
858
|
+
}
|
|
859
|
+
break;
|
|
860
|
+
case 'up':
|
|
861
|
+
if (deltaY < -swipeThresholdRef.current) {
|
|
862
|
+
shouldClose = true;
|
|
863
|
+
dismissDirection = 'up';
|
|
864
|
+
}
|
|
865
|
+
break;
|
|
866
|
+
default:
|
|
867
|
+
break;
|
|
868
|
+
}
|
|
869
|
+
if (shouldClose) {
|
|
870
|
+
break;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
if (shouldClose && dismissDirection) {
|
|
875
|
+
setCurrentSwipeDirection(dismissDirection);
|
|
876
|
+
setDragDismissed(true);
|
|
877
|
+
onDismiss?.(event.nativeEvent, {
|
|
878
|
+
direction: dismissDirection
|
|
879
|
+
});
|
|
880
|
+
} else {
|
|
881
|
+
dragOffsetRef.current = {
|
|
882
|
+
x: resolvedInitialTransform.x,
|
|
883
|
+
y: resolvedInitialTransform.y
|
|
884
|
+
};
|
|
885
|
+
setDragOffset({
|
|
886
|
+
x: resolvedInitialTransform.x,
|
|
887
|
+
y: resolvedInitialTransform.y
|
|
888
|
+
});
|
|
889
|
+
setCurrentSwipeDirection(undefined);
|
|
890
|
+
updateSwipeProgress(0, progressDetails);
|
|
891
|
+
}
|
|
892
|
+
});
|
|
893
|
+
const getDragStyles = React.useCallback(() => {
|
|
894
|
+
const resolvedDragOffset = trackDrag ? dragOffset : dragOffsetRef.current;
|
|
895
|
+
const resolvedInitialTransform = trackDrag ? initialTransform : initialTransformRef.current;
|
|
896
|
+
if (!isSwiping && resolvedDragOffset.x === resolvedInitialTransform.x && resolvedDragOffset.y === resolvedInitialTransform.y && !dragDismissed) {
|
|
897
|
+
return {
|
|
898
|
+
[movementCssVars.x]: '0px',
|
|
899
|
+
[movementCssVars.y]: '0px'
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
const deltaX = resolvedDragOffset.x - resolvedInitialTransform.x;
|
|
903
|
+
const deltaY = resolvedDragOffset.y - resolvedInitialTransform.y;
|
|
904
|
+
return {
|
|
905
|
+
transition: isSwiping ? 'none' : undefined,
|
|
906
|
+
// While swiping, freeze the element at its current visual transform so it doesn't snap to the
|
|
907
|
+
// end position.
|
|
908
|
+
transform: isSwiping ? `translateX(${resolvedDragOffset.x}px) translateY(${resolvedDragOffset.y}px) scale(${resolvedInitialTransform.scale})` : undefined,
|
|
909
|
+
[movementCssVars.x]: `${deltaX}px`,
|
|
910
|
+
[movementCssVars.y]: `${deltaY}px`
|
|
911
|
+
};
|
|
912
|
+
}, [dragDismissed, dragOffset, initialTransform, isSwiping, movementCssVars, trackDrag]);
|
|
913
|
+
const getPointerProps = React.useCallback(() => {
|
|
914
|
+
if (!enabled) {
|
|
915
|
+
return {};
|
|
916
|
+
}
|
|
917
|
+
return {
|
|
918
|
+
onPointerDown: handleStart,
|
|
919
|
+
onPointerMove: handleMove,
|
|
920
|
+
onPointerUp: handleEnd,
|
|
921
|
+
onPointerCancel: handleEnd
|
|
922
|
+
};
|
|
923
|
+
}, [enabled, handleEnd, handleMove, handleStart]);
|
|
924
|
+
const getTouchProps = React.useCallback(() => {
|
|
925
|
+
if (!enabled) {
|
|
926
|
+
return {};
|
|
927
|
+
}
|
|
928
|
+
return {
|
|
929
|
+
onTouchStart: handleStart,
|
|
930
|
+
onTouchMove: handleMove,
|
|
931
|
+
onTouchEnd: handleEnd,
|
|
932
|
+
onTouchCancel: handleEnd
|
|
933
|
+
};
|
|
934
|
+
}, [enabled, handleEnd, handleMove, handleStart]);
|
|
935
|
+
return {
|
|
936
|
+
swiping: isSwiping,
|
|
937
|
+
swipeDirection: currentSwipeDirection,
|
|
938
|
+
dragDismissed,
|
|
939
|
+
getPointerProps,
|
|
940
|
+
getTouchProps,
|
|
941
|
+
getDragStyles,
|
|
942
|
+
reset
|
|
943
|
+
};
|
|
944
|
+
}
|