@base-ui/react 1.4.1 → 1.5.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 +125 -8
- package/README.md +1 -1
- package/accordion/item/AccordionItem.d.ts +4 -0
- package/accordion/item/AccordionItem.js +5 -4
- package/accordion/panel/AccordionPanel.js +29 -51
- package/accordion/root/AccordionRoot.js +5 -6
- package/accordion/trigger/AccordionTrigger.js +3 -4
- package/alert-dialog/handle.d.ts +14 -1
- package/alert-dialog/handle.js +22 -5
- package/alert-dialog/index.d.ts +1 -1
- package/alert-dialog/index.parts.d.ts +2 -3
- package/alert-dialog/index.parts.js +4 -5
- package/alert-dialog/root/AlertDialogRoot.d.ts +7 -7
- package/alert-dialog/root/AlertDialogRoot.js +2 -56
- package/alert-dialog/trigger/AlertDialogTrigger.d.ts +25 -0
- package/alert-dialog/trigger/AlertDialogTrigger.js +15 -0
- package/alert-dialog/trigger/AlertDialogTriggerDataAttributes.d.ts +10 -0
- package/alert-dialog/trigger/AlertDialogTriggerDataAttributes.js +18 -0
- package/autocomplete/root/AutocompleteRoot.js +9 -10
- package/avatar/image/AvatarImage.js +4 -4
- package/checkbox/indicator/CheckboxIndicator.js +2 -2
- package/checkbox/root/CheckboxRoot.js +49 -11
- package/checkbox-group/CheckboxGroup.js +1 -5
- package/collapsible/panel/CollapsiblePanel.js +29 -51
- package/collapsible/panel/useCollapsiblePanel.d.ts +9 -23
- package/collapsible/panel/useCollapsiblePanel.js +308 -268
- package/collapsible/root/CollapsibleRoot.d.ts +1 -1
- package/collapsible/root/CollapsibleRootContext.d.ts +0 -2
- package/collapsible/root/useCollapsibleRoot.d.ts +0 -27
- package/collapsible/root/useCollapsibleRoot.js +2 -64
- package/collapsible/trigger/CollapsibleTrigger.js +5 -6
- package/combobox/arrow/ComboboxArrow.js +1 -1
- package/combobox/backdrop/ComboboxBackdrop.js +1 -1
- package/combobox/chip/ComboboxChip.js +7 -2
- package/combobox/clear/ComboboxClear.d.ts +4 -0
- package/combobox/clear/ComboboxClear.js +1 -0
- package/combobox/clear/ComboboxClearDataAttributes.d.ts +4 -0
- package/combobox/clear/ComboboxClearDataAttributes.js +4 -0
- package/combobox/icon/ComboboxIcon.js +1 -1
- package/combobox/input/ComboboxInput.js +15 -6
- package/combobox/item/ComboboxItem.js +8 -14
- package/combobox/item-indicator/ComboboxItemIndicator.js +1 -2
- package/combobox/root/AriaCombobox.js +61 -28
- package/combobox/store.d.ts +4 -8
- package/combobox/store.js +2 -1
- package/combobox/utils/ComboboxInternalDismissButton.js +2 -3
- package/csp-provider/CSPProvider.js +1 -1
- package/dialog/close/DialogClose.js +6 -6
- package/dialog/popup/DialogPopup.js +9 -4
- package/dialog/root/DialogRoot.d.ts +1 -2
- package/dialog/root/DialogRoot.js +3 -73
- package/dialog/root/DialogRootContext.d.ts +1 -0
- package/dialog/root/DialogRootContext.js +3 -1
- package/dialog/root/useDialogRoot.d.ts +12 -4
- package/dialog/root/useDialogRoot.js +27 -25
- package/dialog/root/useRenderDialogRoot.d.ts +4 -0
- package/dialog/root/useRenderDialogRoot.js +96 -0
- package/dialog/store/DialogHandle.d.ts +1 -1
- package/dialog/store/DialogHandle.js +2 -2
- package/dialog/store/DialogStore.d.ts +88 -1
- package/dialog/store/DialogStore.js +12 -17
- package/dialog/trigger/DialogTrigger.d.ts +1 -1
- package/dialog/trigger/DialogTrigger.js +11 -4
- package/dialog/viewport/DialogViewport.js +4 -3
- package/drawer/popup/DrawerPopup.js +13 -9
- package/drawer/root/DrawerRoot.js +11 -11
- package/drawer/root/DrawerRootContext.d.ts +1 -1
- package/drawer/swipe-area/DrawerSwipeArea.js +6 -5
- package/drawer/viewport/DrawerViewport.js +13 -14
- package/esm/accordion/item/AccordionItem.d.ts +4 -0
- package/esm/accordion/item/AccordionItem.js +5 -4
- package/esm/accordion/panel/AccordionPanel.js +29 -51
- package/esm/accordion/root/AccordionRoot.js +5 -6
- package/esm/accordion/trigger/AccordionTrigger.js +4 -5
- package/esm/alert-dialog/handle.d.ts +14 -1
- package/esm/alert-dialog/handle.js +20 -5
- package/esm/alert-dialog/index.d.ts +1 -1
- package/esm/alert-dialog/index.parts.d.ts +2 -3
- package/esm/alert-dialog/index.parts.js +2 -3
- package/esm/alert-dialog/root/AlertDialogRoot.d.ts +7 -7
- package/esm/alert-dialog/root/AlertDialogRoot.js +2 -55
- package/esm/alert-dialog/trigger/AlertDialogTrigger.d.ts +25 -0
- package/esm/alert-dialog/trigger/AlertDialogTrigger.js +10 -0
- package/esm/alert-dialog/trigger/AlertDialogTriggerDataAttributes.d.ts +10 -0
- package/esm/alert-dialog/trigger/AlertDialogTriggerDataAttributes.js +12 -0
- package/esm/autocomplete/root/AutocompleteRoot.js +9 -10
- package/esm/avatar/image/AvatarImage.js +4 -4
- package/esm/checkbox/indicator/CheckboxIndicator.js +2 -2
- package/esm/checkbox/root/CheckboxRoot.js +49 -11
- package/esm/checkbox-group/CheckboxGroup.js +1 -5
- package/esm/collapsible/panel/CollapsiblePanel.js +29 -51
- package/esm/collapsible/panel/useCollapsiblePanel.d.ts +9 -23
- package/esm/collapsible/panel/useCollapsiblePanel.js +309 -269
- package/esm/collapsible/root/CollapsibleRoot.d.ts +1 -1
- package/esm/collapsible/root/CollapsibleRootContext.d.ts +0 -2
- package/esm/collapsible/root/useCollapsibleRoot.d.ts +0 -27
- package/esm/collapsible/root/useCollapsibleRoot.js +2 -64
- package/esm/collapsible/trigger/CollapsibleTrigger.js +5 -6
- package/esm/combobox/arrow/ComboboxArrow.js +1 -1
- package/esm/combobox/backdrop/ComboboxBackdrop.js +1 -1
- package/esm/combobox/chip/ComboboxChip.js +7 -2
- package/esm/combobox/clear/ComboboxClear.d.ts +4 -0
- package/esm/combobox/clear/ComboboxClear.js +1 -0
- package/esm/combobox/clear/ComboboxClearDataAttributes.d.ts +4 -0
- package/esm/combobox/clear/ComboboxClearDataAttributes.js +4 -0
- package/esm/combobox/icon/ComboboxIcon.js +1 -1
- package/esm/combobox/input/ComboboxInput.js +16 -7
- package/esm/combobox/item/ComboboxItem.js +8 -14
- package/esm/combobox/item-indicator/ComboboxItemIndicator.js +1 -2
- package/esm/combobox/root/AriaCombobox.js +62 -29
- package/esm/combobox/store.d.ts +4 -8
- package/esm/combobox/store.js +2 -1
- package/esm/combobox/utils/ComboboxInternalDismissButton.js +2 -3
- package/esm/csp-provider/CSPProvider.js +1 -1
- package/esm/dialog/close/DialogClose.js +6 -6
- package/esm/dialog/popup/DialogPopup.js +9 -4
- package/esm/dialog/root/DialogRoot.d.ts +1 -2
- package/esm/dialog/root/DialogRoot.js +4 -72
- package/esm/dialog/root/DialogRootContext.d.ts +1 -0
- package/esm/dialog/root/DialogRootContext.js +2 -0
- package/esm/dialog/root/useDialogRoot.d.ts +12 -4
- package/esm/dialog/root/useDialogRoot.js +28 -27
- package/esm/dialog/root/useRenderDialogRoot.d.ts +4 -0
- package/esm/dialog/root/useRenderDialogRoot.js +90 -0
- package/esm/dialog/store/DialogHandle.d.ts +1 -1
- package/esm/dialog/store/DialogHandle.js +2 -2
- package/esm/dialog/store/DialogStore.d.ts +88 -1
- package/esm/dialog/store/DialogStore.js +13 -18
- package/esm/dialog/trigger/DialogTrigger.d.ts +1 -1
- package/esm/dialog/trigger/DialogTrigger.js +12 -5
- package/esm/dialog/viewport/DialogViewport.js +4 -3
- package/esm/drawer/popup/DrawerPopup.js +14 -9
- package/esm/drawer/root/DrawerRoot.js +11 -11
- package/esm/drawer/root/DrawerRootContext.d.ts +1 -1
- package/esm/drawer/swipe-area/DrawerSwipeArea.js +6 -5
- package/esm/drawer/viewport/DrawerViewport.js +13 -14
- package/esm/field/control/FieldControl.js +2 -6
- package/esm/field/item/FieldItem.js +1 -4
- package/esm/field/root/FieldRoot.js +11 -3
- package/esm/field/root/useFieldValidation.d.ts +1 -0
- package/esm/field/root/useFieldValidation.js +23 -20
- package/esm/field/utils/getCombinedFieldValidityData.d.ts +1 -1
- package/esm/field/validity/FieldValidity.d.ts +1 -1
- package/esm/floating-ui-react/components/FloatingDelayGroup.js +3 -3
- package/esm/floating-ui-react/components/FloatingFocusManager.d.ts +1 -1
- package/esm/floating-ui-react/components/FloatingFocusManager.js +20 -8
- package/esm/floating-ui-react/components/FloatingPortal.js +3 -3
- package/esm/floating-ui-react/hooks/useClick.js +83 -74
- package/esm/floating-ui-react/hooks/useClientPoint.js +29 -20
- package/esm/floating-ui-react/hooks/useDismiss.d.ts +1 -1
- package/esm/floating-ui-react/hooks/useDismiss.js +82 -93
- package/esm/floating-ui-react/hooks/useFloating.js +37 -32
- package/esm/floating-ui-react/hooks/useFloatingRootContext.d.ts +1 -1
- package/esm/floating-ui-react/hooks/useFloatingRootContext.js +2 -2
- package/esm/floating-ui-react/hooks/useFocus.js +84 -81
- package/esm/floating-ui-react/hooks/useHover.js +72 -76
- package/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js +49 -44
- package/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js +1 -1
- package/esm/floating-ui-react/hooks/useHoverReferenceInteraction.d.ts +7 -2
- package/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js +44 -39
- package/esm/floating-ui-react/hooks/useHoverShared.d.ts +2 -1
- package/esm/floating-ui-react/hooks/useHoverShared.js +4 -0
- package/esm/floating-ui-react/hooks/useListNavigation.d.ts +1 -3
- package/esm/floating-ui-react/hooks/useListNavigation.js +83 -74
- package/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.d.ts +9 -6
- package/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js +25 -20
- package/esm/floating-ui-react/hooks/useTypeahead.d.ts +2 -2
- package/esm/floating-ui-react/hooks/useTypeahead.js +33 -52
- package/esm/floating-ui-react/index.d.ts +0 -2
- package/esm/floating-ui-react/index.js +0 -2
- package/esm/floating-ui-react/types.d.ts +2 -7
- package/esm/floating-ui-react/utils/composite.js +2 -0
- package/esm/floating-ui-react/utils/enqueueFocus.d.ts +1 -1
- package/esm/floating-ui-react/utils/enqueueFocus.js +10 -7
- package/esm/floating-ui-react/utils/getEmptyRootContext.js +1 -1
- package/esm/form/Form.js +2 -2
- package/esm/index.js +1 -1
- package/esm/internals/composite/composite.d.ts +0 -1
- package/esm/internals/composite/composite.js +1 -2
- package/esm/internals/composite/root/useCompositeRoot.js +2 -2
- package/esm/internals/createBaseUIEventDetails.d.ts +2 -0
- package/esm/internals/csp-context/index.d.ts +2 -0
- package/esm/internals/csp-context/index.js +1 -0
- package/esm/internals/field-register-control/index.d.ts +0 -1
- package/esm/internals/field-register-control/useFieldControlRegistration.d.ts +2 -1
- package/esm/internals/field-register-control/useFieldControlRegistration.js +11 -14
- package/esm/internals/field-register-control/useRegisterFieldControl.d.ts +1 -4
- package/esm/internals/field-register-control/useRegisterFieldControl.js +6 -11
- package/esm/internals/field-root-context/FieldRootContext.d.ts +1 -0
- package/esm/internals/field-root-context/FieldRootContext.js +3 -2
- package/esm/internals/form-context/FormContext.d.ts +5 -1
- package/esm/internals/reason-parts.d.ts +2 -0
- package/esm/internals/reason-parts.js +2 -0
- package/esm/internals/types.d.ts +1 -0
- package/esm/internals/use-button/useButton.js +4 -4
- package/esm/internals/usePressAndHold.js +2 -2
- package/esm/internals/useRenderElement.js +2 -0
- package/esm/menu/arrow/MenuArrow.js +1 -1
- package/esm/menu/backdrop/MenuBackdrop.js +1 -1
- package/esm/menu/checkbox-item/MenuCheckboxItem.js +5 -7
- package/esm/menu/group/MenuGroup.js +1 -4
- package/esm/menu/group/MenuGroupContext.d.ts +1 -3
- package/esm/menu/group/MenuGroupContext.js +1 -1
- package/esm/menu/group-label/MenuGroupLabel.js +4 -6
- package/esm/menu/link-item/MenuLinkItem.js +2 -2
- package/esm/menu/popup/MenuPopup.js +5 -5
- package/esm/menu/radio-group/MenuRadioGroup.js +11 -5
- package/esm/menu/radio-item/MenuRadioItem.js +5 -7
- package/esm/menu/root/MenuRoot.js +63 -68
- package/esm/menu/store/MenuHandle.js +1 -1
- package/esm/menu/store/MenuStore.d.ts +87 -0
- package/esm/menu/submenu-trigger/MenuSubmenuTrigger.js +8 -5
- package/esm/menu/trigger/MenuTrigger.js +13 -10
- package/esm/menu/viewport/MenuViewport.d.ts +2 -2
- package/esm/menu/viewport/MenuViewport.js +2 -2
- package/esm/navigation-menu/arrow/NavigationMenuArrow.js +1 -1
- package/esm/navigation-menu/backdrop/NavigationMenuBackdrop.js +1 -1
- package/esm/navigation-menu/content/NavigationMenuContent.js +8 -5
- package/esm/navigation-menu/icon/NavigationMenuIcon.js +1 -1
- package/esm/navigation-menu/item/NavigationMenuItem.js +2 -2
- package/esm/navigation-menu/list/NavigationMenuList.js +1 -1
- package/esm/navigation-menu/popup/NavigationMenuPopup.js +2 -2
- package/esm/navigation-menu/root/NavigationMenuRoot.js +1 -3
- package/esm/navigation-menu/trigger/NavigationMenuTrigger.js +24 -17
- package/esm/navigation-menu/utils/isOutsideMenuEvent.d.ts +0 -1
- package/esm/navigation-menu/utils/isOutsideMenuEvent.js +1 -5
- package/esm/navigation-menu/viewport/NavigationMenuViewport.js +2 -3
- package/esm/number-field/input/NumberFieldInput.js +3 -5
- package/esm/number-field/root/NumberFieldRoot.js +5 -2
- package/esm/number-field/scrub-area/NumberFieldScrubArea.js +7 -3
- package/esm/otp-field/input/OTPFieldInput.js +43 -29
- package/esm/otp-field/root/OTPFieldRoot.d.ts +17 -8
- package/esm/otp-field/root/OTPFieldRoot.js +33 -33
- package/esm/otp-field/root/OTPFieldRootContext.d.ts +1 -1
- package/esm/otp-field/utils/otp.d.ts +5 -4
- package/esm/otp-field/utils/otp.js +23 -12
- package/esm/popover/arrow/PopoverArrow.js +1 -1
- package/esm/popover/backdrop/PopoverBackdrop.js +1 -1
- package/esm/popover/close/PopoverClose.js +2 -2
- package/esm/popover/description/PopoverDescription.js +1 -7
- package/esm/popover/popup/PopoverPopup.d.ts +1 -1
- package/esm/popover/popup/PopoverPopup.js +16 -10
- package/esm/popover/popup/PopoverPopupDataAttributes.d.ts +1 -1
- package/esm/popover/popup/PopoverPopupDataAttributes.js +1 -1
- package/esm/popover/positioner/PopoverPositioner.js +5 -5
- package/esm/popover/root/PopoverRoot.d.ts +1 -1
- package/esm/popover/root/PopoverRoot.js +42 -47
- package/esm/popover/store/PopoverHandle.js +1 -1
- package/esm/popover/store/PopoverStore.d.ts +91 -4
- package/esm/popover/store/PopoverStore.js +17 -18
- package/esm/popover/title/PopoverTitle.js +1 -7
- package/esm/popover/trigger/PopoverTrigger.js +24 -17
- package/esm/popover/viewport/PopoverViewport.d.ts +3 -3
- package/esm/popover/viewport/PopoverViewport.js +2 -2
- package/esm/popover/viewport/PopoverViewportDataAttributes.d.ts +1 -1
- package/esm/popover/viewport/PopoverViewportDataAttributes.js +1 -1
- package/esm/preview-card/positioner/PreviewCardPositioner.js +11 -1
- package/esm/preview-card/root/PreviewCardRoot.d.ts +1 -1
- package/esm/preview-card/root/PreviewCardRoot.js +32 -22
- package/esm/preview-card/store/PreviewCardHandle.js +1 -1
- package/esm/preview-card/store/PreviewCardStore.d.ts +90 -2
- package/esm/preview-card/store/PreviewCardStore.js +19 -31
- package/esm/preview-card/trigger/PreviewCardTrigger.js +6 -3
- package/esm/preview-card/viewport/PreviewCardViewport.d.ts +2 -2
- package/esm/preview-card/viewport/PreviewCardViewport.js +2 -2
- package/esm/preview-card/viewport/PreviewCardViewportDataAttributes.d.ts +2 -2
- package/esm/preview-card/viewport/PreviewCardViewportDataAttributes.js +2 -2
- package/esm/progress/indicator/ProgressIndicator.js +6 -11
- package/esm/progress/root/ProgressRoot.d.ts +1 -1
- package/esm/radio/root/RadioRoot.js +7 -3
- package/esm/radio-group/RadioGroup.js +4 -11
- package/esm/radio-group/RadioGroupContext.d.ts +0 -1
- package/esm/scroll-area/content/ScrollAreaContent.js +4 -4
- package/esm/scroll-area/root/ScrollAreaRoot.js +1 -1
- package/esm/scroll-area/scrollbar/ScrollAreaScrollbar.js +16 -20
- package/esm/scroll-area/viewport/ScrollAreaViewport.js +6 -10
- package/esm/select/arrow/SelectArrow.js +1 -1
- package/esm/select/backdrop/SelectBackdrop.js +1 -1
- package/esm/select/group/SelectGroup.js +1 -1
- package/esm/select/group-label/SelectGroupLabel.js +2 -2
- package/esm/select/icon/SelectIcon.js +1 -1
- package/esm/select/item/SelectItem.js +46 -32
- package/esm/select/item/SelectItemContext.d.ts +1 -1
- package/esm/select/item-indicator/SelectItemIndicator.js +1 -2
- package/esm/select/item-text/SelectItemText.js +9 -6
- package/esm/select/list/SelectList.js +1 -1
- package/esm/select/popup/SelectPopup.js +8 -3
- package/esm/select/positioner/SelectPositioner.js +3 -0
- package/esm/select/root/SelectRoot.js +46 -40
- package/esm/select/root/SelectRootContext.d.ts +4 -5
- package/esm/select/store.d.ts +3 -0
- package/esm/select/store.js +1 -0
- package/esm/select/trigger/SelectTrigger.d.ts +5 -0
- package/esm/select/trigger/SelectTrigger.js +19 -33
- package/esm/select/trigger/SelectTriggerDataAttributes.d.ts +5 -0
- package/esm/select/trigger/SelectTriggerDataAttributes.js +5 -0
- package/esm/slider/control/SliderControl.js +10 -12
- package/esm/slider/root/SliderRoot.js +1 -4
- package/esm/slider/thumb/SliderThumb.js +32 -30
- package/esm/slider/value/SliderValue.js +7 -15
- package/esm/switch/root/SwitchRoot.js +10 -10
- package/esm/switch/thumb/SwitchThumb.js +1 -9
- package/esm/tabs/indicator/TabsIndicator.js +14 -19
- package/esm/tabs/list/TabsList.js +4 -10
- package/esm/tabs/list/TabsListContext.d.ts +2 -1
- package/esm/tabs/panel/TabsPanel.js +1 -1
- package/esm/tabs/root/TabsRoot.d.ts +16 -1
- package/esm/tabs/root/TabsRoot.js +73 -25
- package/esm/tabs/root/TabsRootContext.d.ts +0 -2
- package/esm/toast/provider/ToastProvider.js +1 -1
- package/esm/toast/root/ToastRoot.d.ts +1 -1
- package/esm/toast/root/ToastRoot.js +108 -131
- package/esm/toast/root/ToastRootDataAttributes.d.ts +1 -1
- package/esm/toast/root/ToastRootDataAttributes.js +1 -1
- package/esm/toast/store.d.ts +9 -1
- package/esm/toast/store.js +19 -13
- package/esm/toast/useToastManager.d.ts +1 -1
- package/esm/toast/viewport/ToastViewport.js +1 -1
- package/esm/toggle/Toggle.js +5 -9
- package/esm/toggle-group/ToggleGroup.d.ts +2 -2
- package/esm/toggle-group/ToggleGroup.js +6 -13
- package/esm/toolbar/link/ToolbarLink.d.ts +1 -1
- package/esm/toolbar/link/ToolbarLink.js +1 -2
- package/esm/tooltip/arrow/TooltipArrow.js +3 -3
- package/esm/tooltip/popup/TooltipPopup.js +5 -4
- package/esm/tooltip/root/TooltipRoot.js +35 -26
- package/esm/tooltip/store/TooltipHandle.js +1 -1
- package/esm/tooltip/store/TooltipStore.d.ts +90 -2
- package/esm/tooltip/store/TooltipStore.js +18 -31
- package/esm/tooltip/trigger/TooltipTrigger.js +151 -20
- package/esm/tooltip/viewport/TooltipViewport.d.ts +2 -2
- package/esm/tooltip/viewport/TooltipViewport.js +2 -2
- package/esm/tooltip/viewport/TooltipViewportDataAttributes.d.ts +1 -1
- package/esm/tooltip/viewport/TooltipViewportDataAttributes.js +1 -1
- package/esm/unstable-use-media-query/index.js +1 -1
- package/esm/utils/popups/index.d.ts +1 -0
- package/esm/utils/popups/index.js +1 -0
- package/esm/utils/popups/inlineRect.d.ts +15 -0
- package/esm/utils/popups/inlineRect.js +191 -0
- package/esm/utils/popups/popupStoreUtils.d.ts +28 -10
- package/esm/utils/popups/popupStoreUtils.js +105 -20
- package/esm/utils/popups/popupTriggerMap.js +2 -0
- package/esm/utils/popups/store.d.ts +15 -2
- package/esm/utils/popups/store.js +38 -2
- package/esm/utils/popups/useTriggerFocusGuards.js +4 -5
- package/esm/utils/useAnchorPositioning.d.ts +5 -0
- package/esm/utils/useAnchorPositioning.js +12 -9
- package/esm/utils/useOpenInteractionType.d.ts +4 -0
- package/esm/utils/useOpenInteractionType.js +23 -18
- package/field/control/FieldControl.js +2 -6
- package/field/item/FieldItem.js +1 -4
- package/field/root/FieldRoot.js +11 -3
- package/field/root/useFieldValidation.d.ts +1 -0
- package/field/root/useFieldValidation.js +23 -20
- package/field/utils/getCombinedFieldValidityData.d.ts +1 -1
- package/field/validity/FieldValidity.d.ts +1 -1
- package/floating-ui-react/components/FloatingDelayGroup.js +3 -3
- package/floating-ui-react/components/FloatingFocusManager.d.ts +1 -1
- package/floating-ui-react/components/FloatingFocusManager.js +20 -8
- package/floating-ui-react/components/FloatingPortal.js +3 -3
- package/floating-ui-react/hooks/useClick.js +82 -73
- package/floating-ui-react/hooks/useClientPoint.js +29 -20
- package/floating-ui-react/hooks/useDismiss.d.ts +1 -1
- package/floating-ui-react/hooks/useDismiss.js +82 -92
- package/floating-ui-react/hooks/useFloating.js +36 -32
- package/floating-ui-react/hooks/useFloatingRootContext.d.ts +1 -1
- package/floating-ui-react/hooks/useFloatingRootContext.js +2 -2
- package/floating-ui-react/hooks/useFocus.js +84 -81
- package/floating-ui-react/hooks/useHover.js +74 -78
- package/floating-ui-react/hooks/useHoverFloatingInteraction.js +48 -43
- package/floating-ui-react/hooks/useHoverInteractionSharedState.js +1 -1
- package/floating-ui-react/hooks/useHoverReferenceInteraction.d.ts +7 -2
- package/floating-ui-react/hooks/useHoverReferenceInteraction.js +43 -38
- package/floating-ui-react/hooks/useHoverShared.d.ts +2 -1
- package/floating-ui-react/hooks/useHoverShared.js +11 -0
- package/floating-ui-react/hooks/useListNavigation.d.ts +1 -3
- package/floating-ui-react/hooks/useListNavigation.js +83 -74
- package/floating-ui-react/hooks/useSyncedFloatingRootContext.d.ts +9 -6
- package/floating-ui-react/hooks/useSyncedFloatingRootContext.js +26 -20
- package/floating-ui-react/hooks/useTypeahead.d.ts +2 -2
- package/floating-ui-react/hooks/useTypeahead.js +33 -52
- package/floating-ui-react/index.d.ts +0 -2
- package/floating-ui-react/index.js +0 -14
- package/floating-ui-react/types.d.ts +2 -7
- package/floating-ui-react/utils/composite.js +2 -0
- package/floating-ui-react/utils/enqueueFocus.d.ts +1 -1
- package/floating-ui-react/utils/enqueueFocus.js +10 -7
- package/floating-ui-react/utils/getEmptyRootContext.js +1 -1
- package/form/Form.js +2 -2
- package/index.js +1 -1
- package/internals/composite/composite.d.ts +0 -1
- package/internals/composite/composite.js +2 -3
- package/internals/composite/root/useCompositeRoot.js +1 -1
- package/internals/createBaseUIEventDetails.d.ts +2 -0
- package/internals/csp-context/index.d.ts +2 -0
- package/internals/csp-context/index.js +18 -0
- package/internals/field-register-control/index.d.ts +0 -1
- package/internals/field-register-control/useFieldControlRegistration.d.ts +2 -1
- package/internals/field-register-control/useFieldControlRegistration.js +11 -14
- package/internals/field-register-control/useRegisterFieldControl.d.ts +1 -4
- package/internals/field-register-control/useRegisterFieldControl.js +6 -11
- package/internals/field-root-context/FieldRootContext.d.ts +1 -0
- package/internals/field-root-context/FieldRootContext.js +4 -3
- package/internals/form-context/FormContext.d.ts +5 -1
- package/internals/reason-parts.d.ts +2 -0
- package/internals/reason-parts.js +3 -1
- package/internals/types.d.ts +1 -0
- package/internals/use-button/useButton.js +4 -4
- package/internals/usePressAndHold.js +2 -2
- package/internals/useRenderElement.js +2 -0
- package/menu/arrow/MenuArrow.js +1 -1
- package/menu/backdrop/MenuBackdrop.js +1 -1
- package/menu/checkbox-item/MenuCheckboxItem.js +5 -7
- package/menu/group/MenuGroup.js +1 -4
- package/menu/group/MenuGroupContext.d.ts +1 -3
- package/menu/group/MenuGroupContext.js +1 -1
- package/menu/group-label/MenuGroupLabel.js +4 -6
- package/menu/link-item/MenuLinkItem.js +2 -2
- package/menu/popup/MenuPopup.js +5 -5
- package/menu/radio-group/MenuRadioGroup.js +11 -5
- package/menu/radio-item/MenuRadioItem.js +5 -7
- package/menu/root/MenuRoot.js +60 -65
- package/menu/store/MenuHandle.js +1 -1
- package/menu/store/MenuStore.d.ts +87 -0
- package/menu/submenu-trigger/MenuSubmenuTrigger.js +7 -4
- package/menu/trigger/MenuTrigger.js +12 -9
- package/menu/viewport/MenuViewport.d.ts +2 -2
- package/menu/viewport/MenuViewport.js +2 -2
- package/navigation-menu/arrow/NavigationMenuArrow.js +1 -1
- package/navigation-menu/backdrop/NavigationMenuBackdrop.js +1 -1
- package/navigation-menu/content/NavigationMenuContent.js +8 -5
- package/navigation-menu/icon/NavigationMenuIcon.js +1 -1
- package/navigation-menu/item/NavigationMenuItem.js +2 -2
- package/navigation-menu/list/NavigationMenuList.js +1 -1
- package/navigation-menu/popup/NavigationMenuPopup.js +2 -2
- package/navigation-menu/root/NavigationMenuRoot.js +1 -3
- package/navigation-menu/trigger/NavigationMenuTrigger.js +23 -16
- package/navigation-menu/utils/isOutsideMenuEvent.d.ts +0 -1
- package/navigation-menu/utils/isOutsideMenuEvent.js +1 -5
- package/navigation-menu/viewport/NavigationMenuViewport.js +2 -3
- package/number-field/input/NumberFieldInput.js +3 -5
- package/number-field/root/NumberFieldRoot.js +5 -2
- package/number-field/scrub-area/NumberFieldScrubArea.js +7 -3
- package/otp-field/input/OTPFieldInput.js +42 -28
- package/otp-field/root/OTPFieldRoot.d.ts +17 -8
- package/otp-field/root/OTPFieldRoot.js +32 -32
- package/otp-field/root/OTPFieldRootContext.d.ts +1 -1
- package/otp-field/utils/otp.d.ts +5 -4
- package/otp-field/utils/otp.js +24 -12
- package/package.json +331 -317
- package/popover/arrow/PopoverArrow.js +1 -1
- package/popover/backdrop/PopoverBackdrop.js +1 -1
- package/popover/close/PopoverClose.js +2 -2
- package/popover/description/PopoverDescription.js +1 -7
- package/popover/popup/PopoverPopup.d.ts +1 -1
- package/popover/popup/PopoverPopup.js +16 -10
- package/popover/popup/PopoverPopupDataAttributes.d.ts +1 -1
- package/popover/popup/PopoverPopupDataAttributes.js +1 -1
- package/popover/positioner/PopoverPositioner.js +5 -5
- package/popover/root/PopoverRoot.d.ts +1 -1
- package/popover/root/PopoverRoot.js +39 -44
- package/popover/store/PopoverHandle.js +1 -1
- package/popover/store/PopoverStore.d.ts +91 -4
- package/popover/store/PopoverStore.js +16 -19
- package/popover/title/PopoverTitle.js +1 -7
- package/popover/trigger/PopoverTrigger.js +23 -16
- package/popover/viewport/PopoverViewport.d.ts +3 -3
- package/popover/viewport/PopoverViewport.js +2 -2
- package/popover/viewport/PopoverViewportDataAttributes.d.ts +1 -1
- package/popover/viewport/PopoverViewportDataAttributes.js +1 -1
- package/preview-card/positioner/PreviewCardPositioner.js +11 -1
- package/preview-card/root/PreviewCardRoot.d.ts +1 -1
- package/preview-card/root/PreviewCardRoot.js +30 -20
- package/preview-card/store/PreviewCardHandle.js +1 -1
- package/preview-card/store/PreviewCardStore.d.ts +90 -2
- package/preview-card/store/PreviewCardStore.js +18 -30
- package/preview-card/trigger/PreviewCardTrigger.js +5 -2
- package/preview-card/viewport/PreviewCardViewport.d.ts +2 -2
- package/preview-card/viewport/PreviewCardViewport.js +2 -2
- package/preview-card/viewport/PreviewCardViewportDataAttributes.d.ts +2 -2
- package/preview-card/viewport/PreviewCardViewportDataAttributes.js +2 -2
- package/progress/indicator/ProgressIndicator.js +6 -11
- package/progress/root/ProgressRoot.d.ts +1 -1
- package/radio/root/RadioRoot.js +7 -3
- package/radio-group/RadioGroup.js +4 -11
- package/radio-group/RadioGroupContext.d.ts +0 -1
- package/scroll-area/content/ScrollAreaContent.js +4 -4
- package/scroll-area/root/ScrollAreaRoot.js +1 -1
- package/scroll-area/scrollbar/ScrollAreaScrollbar.js +16 -20
- package/scroll-area/viewport/ScrollAreaViewport.js +6 -10
- package/select/arrow/SelectArrow.js +1 -1
- package/select/backdrop/SelectBackdrop.js +1 -1
- package/select/group/SelectGroup.js +1 -1
- package/select/group-label/SelectGroupLabel.js +2 -2
- package/select/icon/SelectIcon.js +1 -1
- package/select/item/SelectItem.js +46 -32
- package/select/item/SelectItemContext.d.ts +1 -1
- package/select/item-indicator/SelectItemIndicator.js +1 -2
- package/select/item-text/SelectItemText.js +9 -6
- package/select/list/SelectList.js +1 -1
- package/select/popup/SelectPopup.js +8 -3
- package/select/positioner/SelectPositioner.js +3 -0
- package/select/root/SelectRoot.js +45 -39
- package/select/root/SelectRootContext.d.ts +4 -5
- package/select/store.d.ts +3 -0
- package/select/store.js +1 -0
- package/select/trigger/SelectTrigger.d.ts +5 -0
- package/select/trigger/SelectTrigger.js +19 -33
- package/select/trigger/SelectTriggerDataAttributes.d.ts +5 -0
- package/select/trigger/SelectTriggerDataAttributes.js +5 -0
- package/slider/control/SliderControl.js +9 -11
- package/slider/root/SliderRoot.js +1 -4
- package/slider/thumb/SliderThumb.js +32 -30
- package/slider/value/SliderValue.js +7 -15
- package/switch/root/SwitchRoot.js +10 -10
- package/switch/thumb/SwitchThumb.js +1 -9
- package/tabs/indicator/TabsIndicator.js +14 -19
- package/tabs/list/TabsList.js +4 -10
- package/tabs/list/TabsListContext.d.ts +2 -1
- package/tabs/panel/TabsPanel.js +1 -1
- package/tabs/root/TabsRoot.d.ts +16 -1
- package/tabs/root/TabsRoot.js +71 -24
- package/tabs/root/TabsRootContext.d.ts +0 -2
- package/toast/provider/ToastProvider.js +1 -1
- package/toast/root/ToastRoot.d.ts +1 -1
- package/toast/root/ToastRoot.js +110 -133
- package/toast/root/ToastRootDataAttributes.d.ts +1 -1
- package/toast/root/ToastRootDataAttributes.js +1 -1
- package/toast/store.d.ts +9 -1
- package/toast/store.js +18 -12
- package/toast/useToastManager.d.ts +1 -1
- package/toast/viewport/ToastViewport.js +1 -1
- package/toggle/Toggle.js +5 -9
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +6 -13
- package/toolbar/link/ToolbarLink.d.ts +1 -1
- package/toolbar/link/ToolbarLink.js +1 -2
- package/tooltip/arrow/TooltipArrow.js +3 -3
- package/tooltip/popup/TooltipPopup.js +5 -4
- package/tooltip/root/TooltipRoot.js +32 -23
- package/tooltip/store/TooltipHandle.js +1 -1
- package/tooltip/store/TooltipStore.d.ts +90 -2
- package/tooltip/store/TooltipStore.js +17 -30
- package/tooltip/trigger/TooltipTrigger.js +152 -20
- package/tooltip/viewport/TooltipViewport.d.ts +2 -2
- package/tooltip/viewport/TooltipViewport.js +2 -2
- package/tooltip/viewport/TooltipViewportDataAttributes.d.ts +1 -1
- package/tooltip/viewport/TooltipViewportDataAttributes.js +1 -1
- package/unstable-use-media-query/index.js +1 -1
- package/utils/popups/index.d.ts +1 -0
- package/utils/popups/index.js +11 -0
- package/utils/popups/inlineRect.d.ts +15 -0
- package/utils/popups/inlineRect.js +198 -0
- package/utils/popups/popupStoreUtils.d.ts +28 -10
- package/utils/popups/popupStoreUtils.js +110 -20
- package/utils/popups/popupTriggerMap.js +2 -0
- package/utils/popups/store.d.ts +15 -2
- package/utils/popups/store.js +39 -2
- package/utils/popups/useTriggerFocusGuards.js +4 -5
- package/utils/useAnchorPositioning.d.ts +5 -0
- package/utils/useAnchorPositioning.js +12 -9
- package/utils/useOpenInteractionType.d.ts +4 -0
- package/utils/useOpenInteractionType.js +24 -17
- package/checkbox-group/index.parts.d.ts +0 -1
- package/checkbox-group/index.parts.js +0 -12
- package/esm/checkbox-group/index.parts.d.ts +0 -1
- package/esm/checkbox-group/index.parts.js +0 -1
- package/esm/floating-ui-react/hooks/useInteractions.d.ts +0 -20
- package/esm/floating-ui-react/hooks/useInteractions.js +0 -88
- package/esm/floating-ui-react/hooks/useRole.d.ts +0 -17
- package/esm/floating-ui-react/hooks/useRole.js +0 -113
- package/floating-ui-react/hooks/useInteractions.d.ts +0 -20
- package/floating-ui-react/hooks/useInteractions.js +0 -95
- package/floating-ui-react/hooks/useRole.d.ts +0 -17
- package/floating-ui-react/hooks/useRole.js +0 -120
- /package/{csp-provider → esm/internals/csp-context}/CSPContext.d.ts +0 -0
- /package/esm/{csp-provider → internals/csp-context}/CSPContext.js +0 -0
- /package/{esm/csp-provider → internals/csp-context}/CSPContext.d.ts +0 -0
- /package/{csp-provider → internals/csp-context}/CSPContext.js +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import * as ReactDOM from 'react-dom';
|
|
5
5
|
import { addEventListener } from '@base-ui/utils/addEventListener';
|
|
6
|
-
import { ownerDocument
|
|
6
|
+
import { ownerDocument } from '@base-ui/utils/owner';
|
|
7
7
|
import { inertValue } from '@base-ui/utils/inertValue';
|
|
8
8
|
import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
|
|
9
9
|
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
@@ -15,6 +15,7 @@ import { useRenderElement } from "../../internals/useRenderElement.js";
|
|
|
15
15
|
import { useOpenChangeComplete } from "../../internals/useOpenChangeComplete.js";
|
|
16
16
|
import { ToastRootCssVars } from "./ToastRootCssVars.js";
|
|
17
17
|
import { BASE_UI_SWIPE_IGNORE_SELECTOR, LEGACY_SWIPE_IGNORE_SELECTOR } from "../../internals/constants.js";
|
|
18
|
+
import { getDisplacement, getElementTransform } from "../../utils/useSwipeDismiss.js";
|
|
18
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
20
|
const stateAttributesMapping = {
|
|
20
21
|
...transitionStatusMapping,
|
|
@@ -29,47 +30,6 @@ const REVERSE_CANCEL_THRESHOLD = 10;
|
|
|
29
30
|
const OPPOSITE_DIRECTION_DAMPING_FACTOR = 0.5;
|
|
30
31
|
const MIN_DRAG_THRESHOLD = 1;
|
|
31
32
|
const TOAST_SWIPE_IGNORE_SELECTOR = `${BASE_UI_SWIPE_IGNORE_SELECTOR},${LEGACY_SWIPE_IGNORE_SELECTOR}`;
|
|
32
|
-
function getDisplacement(direction, deltaX, deltaY) {
|
|
33
|
-
switch (direction) {
|
|
34
|
-
case 'up':
|
|
35
|
-
return -deltaY;
|
|
36
|
-
case 'down':
|
|
37
|
-
return deltaY;
|
|
38
|
-
case 'left':
|
|
39
|
-
return -deltaX;
|
|
40
|
-
case 'right':
|
|
41
|
-
return deltaX;
|
|
42
|
-
default:
|
|
43
|
-
return 0;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function getElementTransform(element) {
|
|
47
|
-
const computedStyle = ownerWindow(element).getComputedStyle(element);
|
|
48
|
-
const transform = computedStyle.transform;
|
|
49
|
-
let translateX = 0;
|
|
50
|
-
let translateY = 0;
|
|
51
|
-
let scale = 1;
|
|
52
|
-
if (transform && transform !== 'none') {
|
|
53
|
-
const matrix = transform.match(/matrix(?:3d)?\(([^)]+)\)/);
|
|
54
|
-
if (matrix) {
|
|
55
|
-
const values = matrix[1].split(', ').map(parseFloat);
|
|
56
|
-
if (values.length === 6) {
|
|
57
|
-
translateX = values[4];
|
|
58
|
-
translateY = values[5];
|
|
59
|
-
scale = Math.sqrt(values[0] * values[0] + values[1] * values[1]);
|
|
60
|
-
} else if (values.length === 16) {
|
|
61
|
-
translateX = values[12];
|
|
62
|
-
translateY = values[13];
|
|
63
|
-
scale = values[0];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
x: translateX,
|
|
69
|
-
y: translateY,
|
|
70
|
-
scale
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
33
|
|
|
74
34
|
/**
|
|
75
35
|
* Groups all parts of an individual toast.
|
|
@@ -127,6 +87,12 @@ export const ToastRoot = /*#__PURE__*/React.forwardRef(function ToastRoot(compon
|
|
|
127
87
|
y: 0
|
|
128
88
|
});
|
|
129
89
|
const isFirstPointerMoveRef = React.useRef(false);
|
|
90
|
+
const dragOffsetRef = React.useRef({
|
|
91
|
+
x: 0,
|
|
92
|
+
y: 0
|
|
93
|
+
});
|
|
94
|
+
const activePointerIdRef = React.useRef(null);
|
|
95
|
+
const dragAbortControllerRef = React.useRef(null);
|
|
130
96
|
const domIndex = store.useState('toastIndex', toast.id);
|
|
131
97
|
const visibleIndex = store.useState('toastVisibleIndex', toast.id);
|
|
132
98
|
const offsetY = store.useState('toastOffsetY', toast.id);
|
|
@@ -142,11 +108,8 @@ export const ToastRoot = /*#__PURE__*/React.forwardRef(function ToastRoot(compon
|
|
|
142
108
|
}
|
|
143
109
|
});
|
|
144
110
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
* @param flushSync Whether to flush the update synchronously. Use in observer
|
|
148
|
-
* callbacks to avoid visual flickers.
|
|
149
|
-
*/
|
|
111
|
+
// Recalculates the natural height of the toast and updates it in the toast manager.
|
|
112
|
+
// `flushSync` avoids visual flickers when called from observer callbacks.
|
|
150
113
|
const recalculateHeight = useStableCallback((flushSync = false) => {
|
|
151
114
|
const element = rootRef.current;
|
|
152
115
|
if (!element) {
|
|
@@ -172,6 +135,15 @@ export const ToastRoot = /*#__PURE__*/React.forwardRef(function ToastRoot(compon
|
|
|
172
135
|
}
|
|
173
136
|
});
|
|
174
137
|
useIsoLayoutEffect(recalculateHeight, [recalculateHeight]);
|
|
138
|
+
function setResolvedDragOffset(nextDragOffset) {
|
|
139
|
+
dragOffsetRef.current = nextDragOffset;
|
|
140
|
+
setDragOffset(nextDragOffset);
|
|
141
|
+
}
|
|
142
|
+
useIsoLayoutEffect(() => {
|
|
143
|
+
return () => {
|
|
144
|
+
dragAbortControllerRef.current?.abort();
|
|
145
|
+
};
|
|
146
|
+
}, []);
|
|
175
147
|
function applyDirectionalDamping(deltaX, deltaY) {
|
|
176
148
|
let newDeltaX = deltaX;
|
|
177
149
|
let newDeltaY = deltaY;
|
|
@@ -200,6 +172,75 @@ export const ToastRoot = /*#__PURE__*/React.forwardRef(function ToastRoot(compon
|
|
|
200
172
|
y: newDeltaY
|
|
201
173
|
};
|
|
202
174
|
}
|
|
175
|
+
const handleSwipeEnd = useStableCallback(event => {
|
|
176
|
+
if (event.pointerId !== activePointerIdRef.current) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
activePointerIdRef.current = null;
|
|
180
|
+
dragAbortControllerRef.current?.abort();
|
|
181
|
+
dragAbortControllerRef.current = null;
|
|
182
|
+
setIsSwiping(false);
|
|
183
|
+
setIsRealSwipe(false);
|
|
184
|
+
setLockedDirection(null);
|
|
185
|
+
const resolvedInitialTransform = initialTransformRef.current;
|
|
186
|
+
if (event.type === 'pointercancel' || cancelledSwipeRef.current) {
|
|
187
|
+
setResolvedDragOffset({
|
|
188
|
+
x: resolvedInitialTransform.x,
|
|
189
|
+
y: resolvedInitialTransform.y
|
|
190
|
+
});
|
|
191
|
+
setCurrentSwipeDirection(undefined);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
let shouldClose = false;
|
|
195
|
+
const resolvedDragOffset = dragOffsetRef.current;
|
|
196
|
+
const deltaX = resolvedDragOffset.x - resolvedInitialTransform.x;
|
|
197
|
+
const deltaY = resolvedDragOffset.y - resolvedInitialTransform.y;
|
|
198
|
+
let dismissDirection;
|
|
199
|
+
for (const direction of swipeDirections) {
|
|
200
|
+
switch (direction) {
|
|
201
|
+
case 'right':
|
|
202
|
+
if (deltaX > SWIPE_THRESHOLD) {
|
|
203
|
+
shouldClose = true;
|
|
204
|
+
dismissDirection = 'right';
|
|
205
|
+
}
|
|
206
|
+
break;
|
|
207
|
+
case 'left':
|
|
208
|
+
if (deltaX < -SWIPE_THRESHOLD) {
|
|
209
|
+
shouldClose = true;
|
|
210
|
+
dismissDirection = 'left';
|
|
211
|
+
}
|
|
212
|
+
break;
|
|
213
|
+
case 'down':
|
|
214
|
+
if (deltaY > SWIPE_THRESHOLD) {
|
|
215
|
+
shouldClose = true;
|
|
216
|
+
dismissDirection = 'down';
|
|
217
|
+
}
|
|
218
|
+
break;
|
|
219
|
+
case 'up':
|
|
220
|
+
if (deltaY < -SWIPE_THRESHOLD) {
|
|
221
|
+
shouldClose = true;
|
|
222
|
+
dismissDirection = 'up';
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
default:
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
if (shouldClose) {
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (shouldClose) {
|
|
233
|
+
setCurrentSwipeDirection(dismissDirection);
|
|
234
|
+
setDragDismissed(true);
|
|
235
|
+
store.closeToast(toast.id);
|
|
236
|
+
} else {
|
|
237
|
+
setResolvedDragOffset({
|
|
238
|
+
x: resolvedInitialTransform.x,
|
|
239
|
+
y: resolvedInitialTransform.y
|
|
240
|
+
});
|
|
241
|
+
setCurrentSwipeDirection(undefined);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
203
244
|
function handlePointerDown(event) {
|
|
204
245
|
if (event.button !== 0) {
|
|
205
246
|
return;
|
|
@@ -215,6 +256,7 @@ export const ToastRoot = /*#__PURE__*/React.forwardRef(function ToastRoot(compon
|
|
|
215
256
|
cancelledSwipeRef.current = false;
|
|
216
257
|
intendedSwipeDirectionRef.current = undefined;
|
|
217
258
|
maxSwipeDisplacementRef.current = 0;
|
|
259
|
+
activePointerIdRef.current = event.pointerId;
|
|
218
260
|
dragStartPosRef.current = {
|
|
219
261
|
x: event.clientX,
|
|
220
262
|
y: event.clientY
|
|
@@ -224,7 +266,7 @@ export const ToastRoot = /*#__PURE__*/React.forwardRef(function ToastRoot(compon
|
|
|
224
266
|
const transform = getElementTransform(rootRef.current);
|
|
225
267
|
initialTransformRef.current = transform;
|
|
226
268
|
setInitialTransform(transform);
|
|
227
|
-
|
|
269
|
+
setResolvedDragOffset({
|
|
228
270
|
x: transform.x,
|
|
229
271
|
y: transform.y
|
|
230
272
|
});
|
|
@@ -234,10 +276,23 @@ export const ToastRoot = /*#__PURE__*/React.forwardRef(function ToastRoot(compon
|
|
|
234
276
|
setIsRealSwipe(false);
|
|
235
277
|
setLockedDirection(null);
|
|
236
278
|
isFirstPointerMoveRef.current = true;
|
|
237
|
-
rootRef.current
|
|
279
|
+
const element = rootRef.current;
|
|
280
|
+
if (element) {
|
|
281
|
+
dragAbortControllerRef.current?.abort();
|
|
282
|
+
const dragAbortController = new AbortController();
|
|
283
|
+
dragAbortControllerRef.current = dragAbortController;
|
|
284
|
+
const doc = ownerDocument(element);
|
|
285
|
+
doc.addEventListener('pointerup', handleSwipeEnd, {
|
|
286
|
+
signal: dragAbortController.signal
|
|
287
|
+
});
|
|
288
|
+
doc.addEventListener('pointercancel', handleSwipeEnd, {
|
|
289
|
+
signal: dragAbortController.signal
|
|
290
|
+
});
|
|
291
|
+
element.setPointerCapture?.(event.pointerId);
|
|
292
|
+
}
|
|
238
293
|
}
|
|
239
294
|
function handlePointerMove(event) {
|
|
240
|
-
if (
|
|
295
|
+
if (event.pointerId !== activePointerIdRef.current) {
|
|
241
296
|
return;
|
|
242
297
|
}
|
|
243
298
|
|
|
@@ -343,89 +398,11 @@ export const ToastRoot = /*#__PURE__*/React.forwardRef(function ToastRoot(compon
|
|
|
343
398
|
newOffsetY += dampedDelta.y;
|
|
344
399
|
}
|
|
345
400
|
}
|
|
346
|
-
|
|
401
|
+
setResolvedDragOffset({
|
|
347
402
|
x: newOffsetX,
|
|
348
403
|
y: newOffsetY
|
|
349
404
|
});
|
|
350
405
|
}
|
|
351
|
-
function handlePointerUp(event) {
|
|
352
|
-
if (!isSwiping) {
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
setIsSwiping(false);
|
|
356
|
-
setIsRealSwipe(false);
|
|
357
|
-
setLockedDirection(null);
|
|
358
|
-
rootRef.current?.releasePointerCapture(event.pointerId);
|
|
359
|
-
if (cancelledSwipeRef.current) {
|
|
360
|
-
setDragOffset({
|
|
361
|
-
x: initialTransform.x,
|
|
362
|
-
y: initialTransform.y
|
|
363
|
-
});
|
|
364
|
-
setCurrentSwipeDirection(undefined);
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
let shouldClose = false;
|
|
368
|
-
const deltaX = dragOffset.x - initialTransform.x;
|
|
369
|
-
const deltaY = dragOffset.y - initialTransform.y;
|
|
370
|
-
let dismissDirection;
|
|
371
|
-
for (const direction of swipeDirections) {
|
|
372
|
-
switch (direction) {
|
|
373
|
-
case 'right':
|
|
374
|
-
if (deltaX > SWIPE_THRESHOLD) {
|
|
375
|
-
shouldClose = true;
|
|
376
|
-
dismissDirection = 'right';
|
|
377
|
-
}
|
|
378
|
-
break;
|
|
379
|
-
case 'left':
|
|
380
|
-
if (deltaX < -SWIPE_THRESHOLD) {
|
|
381
|
-
shouldClose = true;
|
|
382
|
-
dismissDirection = 'left';
|
|
383
|
-
}
|
|
384
|
-
break;
|
|
385
|
-
case 'down':
|
|
386
|
-
if (deltaY > SWIPE_THRESHOLD) {
|
|
387
|
-
shouldClose = true;
|
|
388
|
-
dismissDirection = 'down';
|
|
389
|
-
}
|
|
390
|
-
break;
|
|
391
|
-
case 'up':
|
|
392
|
-
if (deltaY < -SWIPE_THRESHOLD) {
|
|
393
|
-
shouldClose = true;
|
|
394
|
-
dismissDirection = 'up';
|
|
395
|
-
}
|
|
396
|
-
break;
|
|
397
|
-
default:
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
if (shouldClose) {
|
|
401
|
-
break;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
if (shouldClose) {
|
|
405
|
-
setCurrentSwipeDirection(dismissDirection);
|
|
406
|
-
setDragDismissed(true);
|
|
407
|
-
store.closeToast(toast.id);
|
|
408
|
-
} else {
|
|
409
|
-
setDragOffset({
|
|
410
|
-
x: initialTransform.x,
|
|
411
|
-
y: initialTransform.y
|
|
412
|
-
});
|
|
413
|
-
setCurrentSwipeDirection(undefined);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
function handlePointerCancel() {
|
|
417
|
-
if (!isSwiping) {
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
setIsSwiping(false);
|
|
421
|
-
setIsRealSwipe(false);
|
|
422
|
-
setLockedDirection(null);
|
|
423
|
-
setDragOffset({
|
|
424
|
-
x: initialTransform.x,
|
|
425
|
-
y: initialTransform.y
|
|
426
|
-
});
|
|
427
|
-
setCurrentSwipeDirection(undefined);
|
|
428
|
-
}
|
|
429
406
|
function handleKeyDown(event) {
|
|
430
407
|
if (event.key === 'Escape') {
|
|
431
408
|
if (!rootRef.current || !contains(rootRef.current, activeElement(ownerDocument(rootRef.current)))) {
|
|
@@ -479,8 +456,8 @@ export const ToastRoot = /*#__PURE__*/React.forwardRef(function ToastRoot(compon
|
|
|
479
456
|
'aria-hidden': isHighPriority && !focused ? true : undefined,
|
|
480
457
|
onPointerDown: swipeEnabled ? handlePointerDown : undefined,
|
|
481
458
|
onPointerMove: swipeEnabled ? handlePointerMove : undefined,
|
|
482
|
-
onPointerUp: swipeEnabled ?
|
|
483
|
-
onPointerCancel: swipeEnabled ?
|
|
459
|
+
onPointerUp: swipeEnabled ? handleSwipeEnd : undefined,
|
|
460
|
+
onPointerCancel: swipeEnabled ? handleSwipeEnd : undefined,
|
|
484
461
|
onKeyDown: handleKeyDown,
|
|
485
462
|
inert: inertValue(toast.limited),
|
|
486
463
|
style: {
|
|
@@ -5,7 +5,7 @@ export declare enum ToastRootDataAttributes {
|
|
|
5
5
|
*/
|
|
6
6
|
expanded = "data-expanded",
|
|
7
7
|
/**
|
|
8
|
-
* Present when the toast was
|
|
8
|
+
* Present when the toast was limited because the toast limit was exceeded.
|
|
9
9
|
* @type {boolean}
|
|
10
10
|
*/
|
|
11
11
|
limited = "data-limited",
|
|
@@ -6,7 +6,7 @@ export let ToastRootDataAttributes = function (ToastRootDataAttributes) {
|
|
|
6
6
|
*/
|
|
7
7
|
ToastRootDataAttributes["expanded"] = "data-expanded";
|
|
8
8
|
/**
|
|
9
|
-
* Present when the toast was
|
|
9
|
+
* Present when the toast was limited because the toast limit was exceeded.
|
|
10
10
|
* @type {boolean}
|
|
11
11
|
*/
|
|
12
12
|
ToastRootDataAttributes["limited"] = "data-limited";
|
package/esm/toast/store.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ type RemoveToastBehavior = {
|
|
|
10
10
|
};
|
|
11
11
|
export type State = {
|
|
12
12
|
toasts: ToastObject<any>[];
|
|
13
|
+
toastMetadata: Map<string, ToastMetadata>;
|
|
13
14
|
hovering: boolean;
|
|
14
15
|
focused: boolean;
|
|
15
16
|
timeout: number;
|
|
@@ -18,6 +19,13 @@ export type State = {
|
|
|
18
19
|
viewport: HTMLElement | null;
|
|
19
20
|
prevFocusElement: HTMLElement | null;
|
|
20
21
|
};
|
|
22
|
+
type ToastMetadata = {
|
|
23
|
+
value: ToastObject<any>;
|
|
24
|
+
domIndex: number;
|
|
25
|
+
visibleIndex: number;
|
|
26
|
+
offsetY: number;
|
|
27
|
+
};
|
|
28
|
+
type InitialState = Omit<State, 'toastMetadata'>;
|
|
21
29
|
export declare const selectors: {
|
|
22
30
|
toasts: (state: State) => ToastObject<any>[];
|
|
23
31
|
isEmpty: (state: State) => boolean;
|
|
@@ -34,7 +42,7 @@ export declare const selectors: {
|
|
|
34
42
|
export declare class ToastStore extends ReactStore<State, {}, typeof selectors> {
|
|
35
43
|
private timers;
|
|
36
44
|
private areTimersPaused;
|
|
37
|
-
constructor(initialState:
|
|
45
|
+
constructor(initialState: InitialState);
|
|
38
46
|
setFocused(focused: boolean): void;
|
|
39
47
|
setHovering(hovering: boolean): void;
|
|
40
48
|
setIsWindowFocused(isWindowFocused: boolean): void;
|
package/esm/toast/store.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { ReactStore, createSelector
|
|
1
|
+
import { ReactStore, createSelector } from '@base-ui/utils/store';
|
|
2
2
|
import { generateId } from '@base-ui/utils/generateId';
|
|
3
3
|
import { ownerDocument } from '@base-ui/utils/owner';
|
|
4
4
|
import { Timeout } from '@base-ui/utils/useTimeout';
|
|
5
5
|
import { resolvePromiseOptions } from "./utils/resolvePromiseOptions.js";
|
|
6
6
|
import { activeElement, contains, getTarget } from "../floating-ui-react/utils.js";
|
|
7
7
|
import { isFocusVisible } from "./utils/focusVisible.js";
|
|
8
|
-
|
|
9
|
-
const
|
|
8
|
+
function createToastMetadata(toasts) {
|
|
9
|
+
const metadata = new Map();
|
|
10
10
|
let visibleIndex = 0;
|
|
11
11
|
let offsetY = 0;
|
|
12
12
|
toasts.forEach((toast, toastIndex) => {
|
|
13
13
|
const isEnding = toast.transitionStatus === 'ending';
|
|
14
|
-
|
|
14
|
+
metadata.set(toast.id, {
|
|
15
15
|
value: toast,
|
|
16
16
|
domIndex: toastIndex,
|
|
17
17
|
visibleIndex: isEnding ? -1 : visibleIndex,
|
|
@@ -22,15 +22,16 @@ const toastMapSelector = createSelectorMemoized(state => state.toasts, toasts =>
|
|
|
22
22
|
visibleIndex += 1;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
return
|
|
26
|
-
}
|
|
25
|
+
return metadata;
|
|
26
|
+
}
|
|
27
|
+
const toastMetadataSelector = state => state.toastMetadata;
|
|
27
28
|
export const selectors = {
|
|
28
29
|
toasts: createSelector(state => state.toasts),
|
|
29
30
|
isEmpty: createSelector(state => state.toasts.length === 0),
|
|
30
|
-
toast: createSelector(
|
|
31
|
-
toastIndex: createSelector(
|
|
32
|
-
toastOffsetY: createSelector(
|
|
33
|
-
toastVisibleIndex: createSelector(
|
|
31
|
+
toast: createSelector(toastMetadataSelector, (toastMetadata, id) => toastMetadata.get(id)?.value),
|
|
32
|
+
toastIndex: createSelector(toastMetadataSelector, (toastMetadata, id) => toastMetadata.get(id)?.domIndex ?? -1),
|
|
33
|
+
toastOffsetY: createSelector(toastMetadataSelector, (toastMetadata, id) => toastMetadata.get(id)?.offsetY ?? 0),
|
|
34
|
+
toastVisibleIndex: createSelector(toastMetadataSelector, (toastMetadata, id) => toastMetadata.get(id)?.visibleIndex ?? -1),
|
|
34
35
|
hovering: createSelector(state => state.hovering),
|
|
35
36
|
focused: createSelector(state => state.focused),
|
|
36
37
|
expanded: createSelector(state => state.hovering || state.focused),
|
|
@@ -41,7 +42,10 @@ export class ToastStore extends ReactStore {
|
|
|
41
42
|
timers = new Map();
|
|
42
43
|
areTimersPaused = false;
|
|
43
44
|
constructor(initialState) {
|
|
44
|
-
super(
|
|
45
|
+
super({
|
|
46
|
+
...initialState,
|
|
47
|
+
toastMetadata: createToastMetadata(initialState.toasts)
|
|
48
|
+
}, {}, selectors);
|
|
45
49
|
}
|
|
46
50
|
setFocused(focused) {
|
|
47
51
|
this.set('focused', focused);
|
|
@@ -246,7 +250,8 @@ export class ToastStore extends ReactStore {
|
|
|
246
250
|
} : item;
|
|
247
251
|
});
|
|
248
252
|
const updates = {
|
|
249
|
-
toasts: newToasts
|
|
253
|
+
toasts: newToasts,
|
|
254
|
+
toastMetadata: createToastMetadata(newToasts)
|
|
250
255
|
};
|
|
251
256
|
if (closeAll || toasts.length === 1) {
|
|
252
257
|
updates.hovering = false;
|
|
@@ -358,7 +363,8 @@ export class ToastStore extends ReactStore {
|
|
|
358
363
|
}
|
|
359
364
|
setToasts(newToasts) {
|
|
360
365
|
const updates = {
|
|
361
|
-
toasts: newToasts
|
|
366
|
+
toasts: newToasts,
|
|
367
|
+
toastMetadata: createToastMetadata(newToasts)
|
|
362
368
|
};
|
|
363
369
|
if (newToasts.length === 0) {
|
|
364
370
|
updates.hovering = false;
|
|
@@ -48,7 +48,7 @@ export interface ToastObject<Data extends object> {
|
|
|
48
48
|
*/
|
|
49
49
|
updateKey?: number | undefined;
|
|
50
50
|
/**
|
|
51
|
-
* Determines if the toast was
|
|
51
|
+
* Determines if the toast was limited because the toast limit was exceeded.
|
|
52
52
|
*/
|
|
53
53
|
limited?: boolean | undefined;
|
|
54
54
|
/**
|
|
@@ -40,6 +40,7 @@ export const ToastViewport = /*#__PURE__*/React.forwardRef(function ToastViewpor
|
|
|
40
40
|
const prevFocusElement = store.useState('prevFocusElement');
|
|
41
41
|
const frontmostHeight = toasts[0]?.height ?? 0;
|
|
42
42
|
const hasTransitioningToasts = React.useMemo(() => toasts.some(toast => toast.transitionStatus === 'ending'), [toasts]);
|
|
43
|
+
const highPriorityToasts = React.useMemo(() => toasts.filter(toast => toast.priority === 'high'), [toasts]);
|
|
43
44
|
|
|
44
45
|
// Listen globally for F6 so we can force-focus the viewport.
|
|
45
46
|
React.useEffect(() => {
|
|
@@ -229,7 +230,6 @@ export const ToastViewport = /*#__PURE__*/React.forwardRef(function ToastViewpor
|
|
|
229
230
|
})
|
|
230
231
|
}]
|
|
231
232
|
});
|
|
232
|
-
const highPriorityToasts = React.useMemo(() => toasts.filter(toast => toast.priority === 'high'), [toasts]);
|
|
233
233
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
234
234
|
children: [!isEmpty && prevFocusElement && /*#__PURE__*/_jsx(FocusGuard, {
|
|
235
235
|
onFocus: handleFocusGuard
|
package/esm/toggle/Toggle.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
5
4
|
import { useControlled } from '@base-ui/utils/useControlled';
|
|
6
5
|
import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
|
|
7
6
|
import { error } from '@base-ui/utils/error';
|
|
@@ -27,7 +26,7 @@ export const Toggle = /*#__PURE__*/React.forwardRef(function Toggle(componentPro
|
|
|
27
26
|
disabled: disabledProp = false,
|
|
28
27
|
form,
|
|
29
28
|
// never participates in form validation
|
|
30
|
-
onPressedChange
|
|
29
|
+
onPressedChange,
|
|
31
30
|
pressed: pressedProp,
|
|
32
31
|
render,
|
|
33
32
|
type,
|
|
@@ -58,12 +57,6 @@ export const Toggle = /*#__PURE__*/React.forwardRef(function Toggle(componentPro
|
|
|
58
57
|
name: 'Toggle',
|
|
59
58
|
state: 'pressed'
|
|
60
59
|
});
|
|
61
|
-
const onPressedChange = useStableCallback((nextPressed, eventDetails) => {
|
|
62
|
-
if (value) {
|
|
63
|
-
groupContext?.setGroupValue?.(value, nextPressed, eventDetails);
|
|
64
|
-
}
|
|
65
|
-
onPressedChangeProp?.(nextPressed, eventDetails);
|
|
66
|
-
});
|
|
67
60
|
const {
|
|
68
61
|
getButtonProps,
|
|
69
62
|
buttonRef
|
|
@@ -81,7 +74,10 @@ export const Toggle = /*#__PURE__*/React.forwardRef(function Toggle(componentPro
|
|
|
81
74
|
onClick(event) {
|
|
82
75
|
const nextPressed = !pressed;
|
|
83
76
|
const details = createChangeEventDetails(REASONS.none, event.nativeEvent);
|
|
84
|
-
|
|
77
|
+
if (value) {
|
|
78
|
+
groupContext?.setGroupValue?.(value, nextPressed, details);
|
|
79
|
+
}
|
|
80
|
+
onPressedChange?.(nextPressed, details);
|
|
85
81
|
if (details.isCanceled) {
|
|
86
82
|
return;
|
|
87
83
|
}
|
|
@@ -29,13 +29,13 @@ export interface ToggleGroupState {
|
|
|
29
29
|
}
|
|
30
30
|
export interface ToggleGroupProps<Value extends string> extends BaseUIComponentProps<'div', ToggleGroupState> {
|
|
31
31
|
/**
|
|
32
|
-
* The
|
|
32
|
+
* The pressed state of the toggle group represented by an array of
|
|
33
33
|
* the values of all pressed toggle buttons.
|
|
34
34
|
* This is the controlled counterpart of `defaultValue`.
|
|
35
35
|
*/
|
|
36
36
|
value?: readonly Value[] | undefined;
|
|
37
37
|
/**
|
|
38
|
-
* The
|
|
38
|
+
* The pressed state of the toggle group represented by an array of
|
|
39
39
|
* the values of all pressed toggle buttons.
|
|
40
40
|
* This is the uncontrolled counterpart of `value`.
|
|
41
41
|
*/
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
5
5
|
import { useControlled } from '@base-ui/utils/useControlled';
|
|
6
|
+
import { EMPTY_ARRAY } from '@base-ui/utils/empty';
|
|
6
7
|
import { useRenderElement } from "../internals/useRenderElement.js";
|
|
7
8
|
import { CompositeRoot } from "../internals/composite/root/CompositeRoot.js";
|
|
8
9
|
import { useToolbarRootContext } from "../toolbar/root/ToolbarRootContext.js";
|
|
@@ -40,17 +41,11 @@ export const ToggleGroup = /*#__PURE__*/React.forwardRef(function ToggleGroup(co
|
|
|
40
41
|
...elementProps
|
|
41
42
|
} = componentProps;
|
|
42
43
|
const toolbarContext = useToolbarRootContext(true);
|
|
43
|
-
const defaultValue = React.useMemo(() => {
|
|
44
|
-
if (valueProp === undefined) {
|
|
45
|
-
return defaultValueProp ?? [];
|
|
46
|
-
}
|
|
47
|
-
return undefined;
|
|
48
|
-
}, [valueProp, defaultValueProp]);
|
|
49
44
|
const isValueInitialized = React.useMemo(() => valueProp !== undefined || defaultValueProp !== undefined, [valueProp, defaultValueProp]);
|
|
50
45
|
const disabled = (toolbarContext?.disabled ?? false) || disabledProp;
|
|
51
46
|
const [groupValue, setValueState] = useControlled({
|
|
52
47
|
controlled: valueProp,
|
|
53
|
-
default:
|
|
48
|
+
default: valueProp === undefined ? defaultValueProp ?? EMPTY_ARRAY : undefined,
|
|
54
49
|
name: 'ToggleGroup',
|
|
55
50
|
state: 'value'
|
|
56
51
|
});
|
|
@@ -66,13 +61,11 @@ export const ToggleGroup = /*#__PURE__*/React.forwardRef(function ToggleGroup(co
|
|
|
66
61
|
} else {
|
|
67
62
|
newGroupValue = nextPressed ? [newValue] : [];
|
|
68
63
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
setValueState(newGroupValue);
|
|
64
|
+
onValueChange?.(newGroupValue, eventDetails);
|
|
65
|
+
if (eventDetails.isCanceled) {
|
|
66
|
+
return;
|
|
75
67
|
}
|
|
68
|
+
setValueState(newGroupValue);
|
|
76
69
|
});
|
|
77
70
|
const state = {
|
|
78
71
|
disabled,
|
|
@@ -5,8 +5,7 @@ import { useToolbarRootContext } from "../root/ToolbarRootContext.js";
|
|
|
5
5
|
import { CompositeItem } from "../../internals/composite/item/CompositeItem.js";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
const TOOLBAR_LINK_METADATA = {
|
|
8
|
-
//
|
|
9
|
-
// TODO: better name
|
|
8
|
+
// Links cannot be disabled, but they still occupy a focusable composite item slot.
|
|
10
9
|
focusableWhenDisabled: true
|
|
11
10
|
};
|
|
12
11
|
|
|
@@ -14,14 +14,12 @@ import { useTooltipRootContext } from "../root/TooltipRootContext.js";
|
|
|
14
14
|
*/
|
|
15
15
|
export const TooltipArrow = /*#__PURE__*/React.forwardRef(function TooltipArrow(componentProps, forwardedRef) {
|
|
16
16
|
const {
|
|
17
|
-
className,
|
|
18
17
|
render,
|
|
18
|
+
className,
|
|
19
19
|
style,
|
|
20
20
|
...elementProps
|
|
21
21
|
} = componentProps;
|
|
22
22
|
const store = useTooltipRootContext();
|
|
23
|
-
const open = store.useState('open');
|
|
24
|
-
const instantType = store.useState('instantType');
|
|
25
23
|
const {
|
|
26
24
|
arrowRef,
|
|
27
25
|
side,
|
|
@@ -29,6 +27,8 @@ export const TooltipArrow = /*#__PURE__*/React.forwardRef(function TooltipArrow(
|
|
|
29
27
|
arrowUncentered,
|
|
30
28
|
arrowStyles
|
|
31
29
|
} = useTooltipPositionerContext();
|
|
30
|
+
const open = store.useState('open');
|
|
31
|
+
const instantType = store.useState('instantType');
|
|
32
32
|
const state = {
|
|
33
33
|
open,
|
|
34
34
|
side,
|
|
@@ -22,8 +22,8 @@ const stateAttributesMapping = {
|
|
|
22
22
|
*/
|
|
23
23
|
export const TooltipPopup = /*#__PURE__*/React.forwardRef(function TooltipPopup(componentProps, forwardedRef) {
|
|
24
24
|
const {
|
|
25
|
-
className,
|
|
26
25
|
render,
|
|
26
|
+
className,
|
|
27
27
|
style,
|
|
28
28
|
...elementProps
|
|
29
29
|
} = componentProps;
|
|
@@ -37,6 +37,8 @@ export const TooltipPopup = /*#__PURE__*/React.forwardRef(function TooltipPopup(
|
|
|
37
37
|
const transitionStatus = store.useState('transitionStatus');
|
|
38
38
|
const popupProps = store.useState('popupProps');
|
|
39
39
|
const floatingContext = store.useState('floatingRootContext');
|
|
40
|
+
const disabled = store.useState('disabled');
|
|
41
|
+
const closeDelay = store.useState('closeDelay');
|
|
40
42
|
useOpenChangeComplete({
|
|
41
43
|
open,
|
|
42
44
|
ref: store.context.popupRef,
|
|
@@ -46,12 +48,11 @@ export const TooltipPopup = /*#__PURE__*/React.forwardRef(function TooltipPopup(
|
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
});
|
|
49
|
-
const disabled = store.useState('disabled');
|
|
50
|
-
const closeDelay = store.useState('closeDelay');
|
|
51
51
|
useHoverFloatingInteraction(floatingContext, {
|
|
52
52
|
enabled: !disabled,
|
|
53
53
|
closeDelay
|
|
54
54
|
});
|
|
55
|
+
const setPopupElement = store.useStateSetter('popupElement');
|
|
55
56
|
const state = {
|
|
56
57
|
open,
|
|
57
58
|
side,
|
|
@@ -61,7 +62,7 @@ export const TooltipPopup = /*#__PURE__*/React.forwardRef(function TooltipPopup(
|
|
|
61
62
|
};
|
|
62
63
|
const element = useRenderElement('div', componentProps, {
|
|
63
64
|
state,
|
|
64
|
-
ref: [forwardedRef, store.context.popupRef,
|
|
65
|
+
ref: [forwardedRef, store.context.popupRef, setPopupElement],
|
|
65
66
|
props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
|
|
66
67
|
stateAttributesMapping
|
|
67
68
|
});
|