@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
|
@@ -14,6 +14,7 @@ import { COMPOSITE_KEYS } from "../../internals/composite/composite.js";
|
|
|
14
14
|
import { useToolbarRootContext } from "../../toolbar/root/ToolbarRootContext.js";
|
|
15
15
|
import { getDisabledMountTransitionStyles } from "../../utils/getDisabledMountTransitionStyles.js";
|
|
16
16
|
import { ClosePartProvider, useClosePartCount } from "../../utils/closePart.js";
|
|
17
|
+
import { FOCUSABLE_POPUP_PROPS } from "../../utils/popups/index.js";
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
19
|
const stateAttributesMapping = {
|
|
19
20
|
...baseMapping,
|
|
@@ -28,11 +29,11 @@ const stateAttributesMapping = {
|
|
|
28
29
|
*/
|
|
29
30
|
export const PopoverPopup = /*#__PURE__*/React.forwardRef(function PopoverPopup(componentProps, forwardedRef) {
|
|
30
31
|
const {
|
|
31
|
-
className,
|
|
32
32
|
render,
|
|
33
|
+
className,
|
|
34
|
+
style,
|
|
33
35
|
initialFocus,
|
|
34
36
|
finalFocus,
|
|
35
|
-
style,
|
|
36
37
|
...elementProps
|
|
37
38
|
} = componentProps;
|
|
38
39
|
const {
|
|
@@ -56,6 +57,11 @@ export const PopoverPopup = /*#__PURE__*/React.forwardRef(function PopoverPopup(
|
|
|
56
57
|
const openReason = store.useState('openChangeReason');
|
|
57
58
|
const activeTriggerElement = store.useState('activeTriggerElement');
|
|
58
59
|
const floatingContext = store.useState('floatingRootContext');
|
|
60
|
+
const floatingId = floatingContext.useState('floatingId');
|
|
61
|
+
const disabled = store.useState('disabled');
|
|
62
|
+
const openOnHover = store.useState('openOnHover');
|
|
63
|
+
const closeDelay = store.useState('closeDelay');
|
|
64
|
+
const popupId = elementProps.id ?? floatingId;
|
|
59
65
|
useOpenChangeComplete({
|
|
60
66
|
open,
|
|
61
67
|
ref: store.context.popupRef,
|
|
@@ -65,9 +71,6 @@ export const PopoverPopup = /*#__PURE__*/React.forwardRef(function PopoverPopup(
|
|
|
65
71
|
}
|
|
66
72
|
}
|
|
67
73
|
});
|
|
68
|
-
const disabled = store.useState('disabled');
|
|
69
|
-
const openOnHover = store.useState('openOnHover');
|
|
70
|
-
const closeDelay = store.useState('closeDelay');
|
|
71
74
|
useHoverFloatingInteraction(floatingContext, {
|
|
72
75
|
enabled: openOnHover && !disabled,
|
|
73
76
|
closeDelay
|
|
@@ -83,6 +86,11 @@ export const PopoverPopup = /*#__PURE__*/React.forwardRef(function PopoverPopup(
|
|
|
83
86
|
return true;
|
|
84
87
|
}
|
|
85
88
|
const resolvedInitialFocus = initialFocus === undefined ? defaultInitialFocus : initialFocus;
|
|
89
|
+
const focusManagerModal = modal !== false && hasClosePart;
|
|
90
|
+
store.useSyncedValue('focusManagerModal', focusManagerModal);
|
|
91
|
+
const setPopupElement = React.useCallback(element => {
|
|
92
|
+
store.set('popupElement', element);
|
|
93
|
+
}, [store]);
|
|
86
94
|
const state = {
|
|
87
95
|
open,
|
|
88
96
|
side: positioner.side,
|
|
@@ -90,15 +98,13 @@ export const PopoverPopup = /*#__PURE__*/React.forwardRef(function PopoverPopup(
|
|
|
90
98
|
instant: instantType,
|
|
91
99
|
transitionStatus
|
|
92
100
|
};
|
|
93
|
-
const focusManagerModal = modal !== false && hasClosePart;
|
|
94
|
-
store.useSyncedValue('focusManagerModal', focusManagerModal);
|
|
95
|
-
const setPopupElement = React.useCallback(element => {
|
|
96
|
-
store.set('popupElement', element);
|
|
97
|
-
}, [store]);
|
|
98
101
|
const element = useRenderElement('div', componentProps, {
|
|
99
102
|
state,
|
|
100
103
|
ref: [forwardedRef, store.context.popupRef, setPopupElement],
|
|
101
104
|
props: [popupProps, {
|
|
105
|
+
id: popupId,
|
|
106
|
+
role: 'dialog',
|
|
107
|
+
...FOCUSABLE_POPUP_PROPS,
|
|
102
108
|
'aria-labelledby': titleId,
|
|
103
109
|
'aria-describedby': descriptionId,
|
|
104
110
|
onKeyDown(event) {
|
|
@@ -27,7 +27,7 @@ export declare enum PopoverPopupDataAttributes {
|
|
|
27
27
|
align = "data-align",
|
|
28
28
|
/**
|
|
29
29
|
* Present if animations should be instant.
|
|
30
|
-
* @type {'click' | 'dismiss'}
|
|
30
|
+
* @type {'click' | 'dismiss' | 'focus' | 'trigger-change'}
|
|
31
31
|
*/
|
|
32
32
|
instant = "data-instant",
|
|
33
33
|
}
|
|
@@ -28,7 +28,7 @@ export let PopoverPopupDataAttributes = function (PopoverPopupDataAttributes) {
|
|
|
28
28
|
PopoverPopupDataAttributes["align"] = "data-align";
|
|
29
29
|
/**
|
|
30
30
|
* Present if animations should be instant.
|
|
31
|
-
* @type {'click' | 'dismiss'}
|
|
31
|
+
* @type {'click' | 'dismiss' | 'focus' | 'trigger-change'}
|
|
32
32
|
*/
|
|
33
33
|
PopoverPopupDataAttributes["instant"] = "data-instant";
|
|
34
34
|
return PopoverPopupDataAttributes;
|
|
@@ -27,6 +27,7 @@ export const PopoverPositioner = /*#__PURE__*/React.forwardRef(function PopoverP
|
|
|
27
27
|
const {
|
|
28
28
|
render,
|
|
29
29
|
className,
|
|
30
|
+
style,
|
|
30
31
|
anchor,
|
|
31
32
|
positionMethod = 'absolute',
|
|
32
33
|
side = 'bottom',
|
|
@@ -39,7 +40,6 @@ export const PopoverPositioner = /*#__PURE__*/React.forwardRef(function PopoverP
|
|
|
39
40
|
sticky = false,
|
|
40
41
|
disableAnchorTracking = false,
|
|
41
42
|
collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
|
|
42
|
-
style,
|
|
43
43
|
...elementProps
|
|
44
44
|
} = componentProps;
|
|
45
45
|
const {
|
|
@@ -101,6 +101,10 @@ export const PopoverPositioner = /*#__PURE__*/React.forwardRef(function PopoverP
|
|
|
101
101
|
}
|
|
102
102
|
return undefined;
|
|
103
103
|
}, [domReference, runOnceAnimationsFinish, store]);
|
|
104
|
+
useAnchoredPopupScrollLock(open && modal === true && openReason !== REASONS.triggerHover, openMethod === 'touch', positionerElement, triggerElement);
|
|
105
|
+
const setPositionerElement = React.useCallback(element => {
|
|
106
|
+
store.set('positionerElement', element);
|
|
107
|
+
}, [store]);
|
|
104
108
|
const state = {
|
|
105
109
|
open,
|
|
106
110
|
side: positioning.side,
|
|
@@ -108,10 +112,6 @@ export const PopoverPositioner = /*#__PURE__*/React.forwardRef(function PopoverP
|
|
|
108
112
|
anchorHidden: positioning.anchorHidden,
|
|
109
113
|
instant: instantType
|
|
110
114
|
};
|
|
111
|
-
useAnchoredPopupScrollLock(open && modal === true && openReason !== REASONS.triggerHover, openMethod === 'touch', positionerElement, triggerElement);
|
|
112
|
-
const setPositionerElement = React.useCallback(element => {
|
|
113
|
-
store.set('positionerElement', element);
|
|
114
|
-
}, [store]);
|
|
115
115
|
const element = usePositioner(componentProps, state, {
|
|
116
116
|
styles: positioning.positionerStyles,
|
|
117
117
|
transitionStatus,
|
|
@@ -36,7 +36,7 @@ export interface PopoverRootProps<Payload = unknown> {
|
|
|
36
36
|
* - `unmount`: When specified, the popover will not be unmounted when closed.
|
|
37
37
|
* Instead, the `unmount` function must be called to unmount the popover manually.
|
|
38
38
|
* Useful when the popover's animation is controlled by an external library.
|
|
39
|
-
* - `close`: Closes the
|
|
39
|
+
* - `close`: Closes the popover imperatively when called.
|
|
40
40
|
*/
|
|
41
41
|
actionsRef?: React.RefObject<PopoverRoot.Actions | null> | undefined;
|
|
42
42
|
/**
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
import { EMPTY_OBJECT } from '@base-ui/utils/empty';
|
|
4
5
|
import { useOnFirstRender } from '@base-ui/utils/useOnFirstRender';
|
|
5
|
-
import { useDismiss,
|
|
6
|
+
import { useDismiss, FloatingTree, useFloatingParentNodeId } from "../../floating-ui-react/index.js";
|
|
6
7
|
import { PopoverRootContext, usePopoverRootContext } from "./PopoverRootContext.js";
|
|
7
8
|
import { PopoverStore } from "../store/PopoverStore.js";
|
|
8
9
|
import { createChangeEventDetails } from "../../internals/createBaseUIEventDetails.js";
|
|
9
10
|
import { REASONS } from "../../internals/reasons.js";
|
|
10
|
-
import { useImplicitActiveTrigger, useOpenStateTransitions } from "../../utils/popups/index.js";
|
|
11
|
-
import {
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { FOCUSABLE_POPUP_PROPS, useImplicitActiveTrigger, useOpenStateTransitions, usePopupInteractionProps, usePopupRootSync } from "../../utils/popups/index.js";
|
|
12
|
+
import { mergeProps } from "../../merge-props/index.js";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
function PopoverRootComponent({
|
|
14
15
|
props
|
|
15
16
|
}) {
|
|
@@ -44,13 +45,12 @@ function PopoverRootComponent({
|
|
|
44
45
|
store.useControlledProp('openProp', openProp);
|
|
45
46
|
store.useControlledProp('triggerIdProp', triggerIdProp);
|
|
46
47
|
const open = store.useState('open');
|
|
48
|
+
const mounted = store.useState('mounted');
|
|
47
49
|
const payload = store.useState('payload');
|
|
50
|
+
const nested = useFloatingParentNodeId() != null;
|
|
48
51
|
store.useContextCallback('onOpenChange', onOpenChange);
|
|
49
52
|
store.useContextCallback('onOpenChangeComplete', onOpenChangeComplete);
|
|
50
|
-
|
|
51
|
-
openMethod,
|
|
52
|
-
triggerProps: interactionTypeTriggerProps
|
|
53
|
-
} = useOpenInteractionType(open);
|
|
53
|
+
usePopupRootSync(store, open);
|
|
54
54
|
useImplicitActiveTrigger(store);
|
|
55
55
|
const {
|
|
56
56
|
forceUnmount
|
|
@@ -60,6 +60,10 @@ function PopoverRootComponent({
|
|
|
60
60
|
openChangeReason: null
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
|
+
store.useSyncedValues({
|
|
64
|
+
modal,
|
|
65
|
+
nested
|
|
66
|
+
});
|
|
63
67
|
React.useEffect(() => {
|
|
64
68
|
if (!open) {
|
|
65
69
|
store.context.stickIfOpenTimeout.clear();
|
|
@@ -72,50 +76,18 @@ function PopoverRootComponent({
|
|
|
72
76
|
unmount: forceUnmount,
|
|
73
77
|
close: handleImperativeClose
|
|
74
78
|
}), [forceUnmount, handleImperativeClose]);
|
|
75
|
-
const
|
|
76
|
-
popupStore: store,
|
|
77
|
-
onOpenChange: store.setOpen
|
|
78
|
-
});
|
|
79
|
-
const dismiss = useDismiss(floatingRootContext, {
|
|
80
|
-
outsidePressEvent: {
|
|
81
|
-
// Ensure `aria-hidden` on outside elements is removed immediately
|
|
82
|
-
// on outside press when trapping focus.
|
|
83
|
-
mouse: modal === 'trap-focus' ? 'sloppy' : 'intentional',
|
|
84
|
-
touch: 'sloppy'
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
const role = useRole(floatingRootContext);
|
|
88
|
-
const {
|
|
89
|
-
getReferenceProps,
|
|
90
|
-
getFloatingProps,
|
|
91
|
-
getTriggerProps
|
|
92
|
-
} = useInteractions([dismiss, role]);
|
|
93
|
-
const activeTriggerProps = React.useMemo(() => {
|
|
94
|
-
return getReferenceProps(interactionTypeTriggerProps);
|
|
95
|
-
}, [getReferenceProps, interactionTypeTriggerProps]);
|
|
96
|
-
const inactiveTriggerProps = React.useMemo(() => {
|
|
97
|
-
return getTriggerProps(interactionTypeTriggerProps);
|
|
98
|
-
}, [getTriggerProps, interactionTypeTriggerProps]);
|
|
99
|
-
const popupProps = React.useMemo(() => {
|
|
100
|
-
return getFloatingProps();
|
|
101
|
-
}, [getFloatingProps]);
|
|
102
|
-
store.useSyncedValues({
|
|
103
|
-
modal,
|
|
104
|
-
openMethod,
|
|
105
|
-
activeTriggerProps,
|
|
106
|
-
inactiveTriggerProps,
|
|
107
|
-
popupProps,
|
|
108
|
-
floatingRootContext,
|
|
109
|
-
nested: useFloatingParentNodeId() != null
|
|
110
|
-
});
|
|
79
|
+
const shouldRenderInteractions = open || mounted;
|
|
111
80
|
const popoverContext = React.useMemo(() => ({
|
|
112
81
|
store
|
|
113
82
|
}), [store]);
|
|
114
|
-
return /*#__PURE__*/
|
|
83
|
+
return /*#__PURE__*/_jsxs(PopoverRootContext.Provider, {
|
|
115
84
|
value: popoverContext,
|
|
116
|
-
children:
|
|
85
|
+
children: [shouldRenderInteractions && /*#__PURE__*/_jsx(PopoverInteractions, {
|
|
86
|
+
store: store,
|
|
87
|
+
modal: modal
|
|
88
|
+
}), typeof children === 'function' ? children({
|
|
117
89
|
payload
|
|
118
|
-
}) : children
|
|
90
|
+
}) : children]
|
|
119
91
|
});
|
|
120
92
|
}
|
|
121
93
|
|
|
@@ -136,4 +108,27 @@ export function PopoverRoot(props) {
|
|
|
136
108
|
props: props
|
|
137
109
|
})
|
|
138
110
|
});
|
|
111
|
+
}
|
|
112
|
+
function PopoverInteractions({
|
|
113
|
+
store,
|
|
114
|
+
modal
|
|
115
|
+
}) {
|
|
116
|
+
const floatingRootContext = store.useState('floatingRootContext');
|
|
117
|
+
const dismiss = useDismiss(floatingRootContext, {
|
|
118
|
+
outsidePressEvent: {
|
|
119
|
+
// Ensure `aria-hidden` on outside elements is removed immediately
|
|
120
|
+
// on outside press when trapping focus.
|
|
121
|
+
mouse: modal === 'trap-focus' ? 'sloppy' : 'intentional',
|
|
122
|
+
touch: 'sloppy'
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
const activeTriggerProps = dismiss.reference ?? EMPTY_OBJECT;
|
|
126
|
+
const inactiveTriggerProps = dismiss.trigger ?? EMPTY_OBJECT;
|
|
127
|
+
const popupProps = React.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, dismiss.floating), [dismiss.floating]);
|
|
128
|
+
usePopupInteractionProps(store, {
|
|
129
|
+
activeTriggerProps,
|
|
130
|
+
inactiveTriggerProps,
|
|
131
|
+
popupProps
|
|
132
|
+
});
|
|
133
|
+
return null;
|
|
139
134
|
}
|
|
@@ -2,11 +2,11 @@ import * as React from 'react';
|
|
|
2
2
|
import { ReactStore } from '@base-ui/utils/store';
|
|
3
3
|
import { Timeout } from '@base-ui/utils/useTimeout';
|
|
4
4
|
import { type InteractionType } from '@base-ui/utils/useEnhancedClickHandler';
|
|
5
|
-
import { PopoverRoot } from "../root/PopoverRoot.js";
|
|
5
|
+
import { type PopoverRoot } from "../root/PopoverRoot.js";
|
|
6
6
|
import { PopupStoreContext, PopupStoreState } from "../../utils/popups/index.js";
|
|
7
7
|
export type State<Payload> = PopupStoreState<Payload> & {
|
|
8
8
|
disabled: boolean;
|
|
9
|
-
instantType: 'dismiss' | 'click' | undefined;
|
|
9
|
+
instantType: 'dismiss' | 'click' | 'focus' | 'trigger-change' | undefined;
|
|
10
10
|
modal: boolean | 'trap-focus';
|
|
11
11
|
focusManagerModal: boolean;
|
|
12
12
|
openMethod: InteractionType | null;
|
|
@@ -29,7 +29,7 @@ type Context = PopupStoreContext<PopoverRoot.ChangeEventDetails> & {
|
|
|
29
29
|
};
|
|
30
30
|
declare const selectors: {
|
|
31
31
|
disabled: (state: State<unknown>) => boolean;
|
|
32
|
-
instantType: (state: State<unknown>) => "click" | "dismiss" | undefined;
|
|
32
|
+
instantType: (state: State<unknown>) => "click" | "focus" | "dismiss" | "trigger-change" | undefined;
|
|
33
33
|
openMethod: (state: State<unknown>) => InteractionType | null;
|
|
34
34
|
openChangeReason: (state: State<unknown>) => import("../index.js").PopoverRootChangeEventReason | null;
|
|
35
35
|
modal: (state: State<unknown>) => boolean | "trap-focus";
|
|
@@ -46,6 +46,8 @@ declare const selectors: {
|
|
|
46
46
|
mounted: boolean;
|
|
47
47
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
48
48
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
49
|
+
floatingId: string | undefined;
|
|
50
|
+
triggerCount: number;
|
|
49
51
|
preventUnmountingOnClose: boolean;
|
|
50
52
|
payload: unknown;
|
|
51
53
|
activeTriggerId: string | null;
|
|
@@ -63,6 +65,8 @@ declare const selectors: {
|
|
|
63
65
|
mounted: boolean;
|
|
64
66
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
65
67
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
68
|
+
floatingId: string | undefined;
|
|
69
|
+
triggerCount: number;
|
|
66
70
|
preventUnmountingOnClose: boolean;
|
|
67
71
|
payload: unknown;
|
|
68
72
|
activeTriggerId: string | null;
|
|
@@ -80,6 +84,8 @@ declare const selectors: {
|
|
|
80
84
|
mounted: boolean;
|
|
81
85
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
82
86
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
87
|
+
floatingId: string | undefined;
|
|
88
|
+
triggerCount: number;
|
|
83
89
|
preventUnmountingOnClose: boolean;
|
|
84
90
|
payload: unknown;
|
|
85
91
|
activeTriggerId: string | null;
|
|
@@ -97,6 +103,8 @@ declare const selectors: {
|
|
|
97
103
|
mounted: boolean;
|
|
98
104
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
99
105
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
106
|
+
floatingId: string | undefined;
|
|
107
|
+
triggerCount: number;
|
|
100
108
|
preventUnmountingOnClose: boolean;
|
|
101
109
|
payload: unknown;
|
|
102
110
|
activeTriggerId: string | null;
|
|
@@ -108,12 +116,33 @@ declare const selectors: {
|
|
|
108
116
|
inactiveTriggerProps: import("../../index.js").HTMLProps;
|
|
109
117
|
popupProps: import("../../index.js").HTMLProps;
|
|
110
118
|
}) => import("../../floating-ui-react/components/FloatingRootStore.js").FloatingRootStore;
|
|
119
|
+
triggerCount: (state: {
|
|
120
|
+
open: boolean;
|
|
121
|
+
readonly openProp: boolean | undefined;
|
|
122
|
+
mounted: boolean;
|
|
123
|
+
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
124
|
+
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
125
|
+
floatingId: string | undefined;
|
|
126
|
+
triggerCount: number;
|
|
127
|
+
preventUnmountingOnClose: boolean;
|
|
128
|
+
payload: unknown;
|
|
129
|
+
activeTriggerId: string | null;
|
|
130
|
+
activeTriggerElement: Element | null;
|
|
131
|
+
readonly triggerIdProp: string | null | undefined;
|
|
132
|
+
popupElement: HTMLElement | null;
|
|
133
|
+
positionerElement: HTMLElement | null;
|
|
134
|
+
activeTriggerProps: import("../../index.js").HTMLProps;
|
|
135
|
+
inactiveTriggerProps: import("../../index.js").HTMLProps;
|
|
136
|
+
popupProps: import("../../index.js").HTMLProps;
|
|
137
|
+
}) => number;
|
|
111
138
|
preventUnmountingOnClose: (state: {
|
|
112
139
|
open: boolean;
|
|
113
140
|
readonly openProp: boolean | undefined;
|
|
114
141
|
mounted: boolean;
|
|
115
142
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
116
143
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
144
|
+
floatingId: string | undefined;
|
|
145
|
+
triggerCount: number;
|
|
117
146
|
preventUnmountingOnClose: boolean;
|
|
118
147
|
payload: unknown;
|
|
119
148
|
activeTriggerId: string | null;
|
|
@@ -131,6 +160,8 @@ declare const selectors: {
|
|
|
131
160
|
mounted: boolean;
|
|
132
161
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
133
162
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
163
|
+
floatingId: string | undefined;
|
|
164
|
+
triggerCount: number;
|
|
134
165
|
preventUnmountingOnClose: boolean;
|
|
135
166
|
payload: unknown;
|
|
136
167
|
activeTriggerId: string | null;
|
|
@@ -148,6 +179,8 @@ declare const selectors: {
|
|
|
148
179
|
mounted: boolean;
|
|
149
180
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
150
181
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
182
|
+
floatingId: string | undefined;
|
|
183
|
+
triggerCount: number;
|
|
151
184
|
preventUnmountingOnClose: boolean;
|
|
152
185
|
payload: unknown;
|
|
153
186
|
activeTriggerId: string | null;
|
|
@@ -165,6 +198,8 @@ declare const selectors: {
|
|
|
165
198
|
mounted: boolean;
|
|
166
199
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
167
200
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
201
|
+
floatingId: string | undefined;
|
|
202
|
+
triggerCount: number;
|
|
168
203
|
preventUnmountingOnClose: boolean;
|
|
169
204
|
payload: unknown;
|
|
170
205
|
activeTriggerId: string | null;
|
|
@@ -176,12 +211,33 @@ declare const selectors: {
|
|
|
176
211
|
inactiveTriggerProps: import("../../index.js").HTMLProps;
|
|
177
212
|
popupProps: import("../../index.js").HTMLProps;
|
|
178
213
|
}) => Element | null;
|
|
214
|
+
popupId: (state: {
|
|
215
|
+
open: boolean;
|
|
216
|
+
readonly openProp: boolean | undefined;
|
|
217
|
+
mounted: boolean;
|
|
218
|
+
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
219
|
+
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
220
|
+
floatingId: string | undefined;
|
|
221
|
+
triggerCount: number;
|
|
222
|
+
preventUnmountingOnClose: boolean;
|
|
223
|
+
payload: unknown;
|
|
224
|
+
activeTriggerId: string | null;
|
|
225
|
+
activeTriggerElement: Element | null;
|
|
226
|
+
readonly triggerIdProp: string | null | undefined;
|
|
227
|
+
popupElement: HTMLElement | null;
|
|
228
|
+
positionerElement: HTMLElement | null;
|
|
229
|
+
activeTriggerProps: import("../../index.js").HTMLProps;
|
|
230
|
+
inactiveTriggerProps: import("../../index.js").HTMLProps;
|
|
231
|
+
popupProps: import("../../index.js").HTMLProps;
|
|
232
|
+
}) => string | undefined;
|
|
179
233
|
isTriggerActive: (state: {
|
|
180
234
|
open: boolean;
|
|
181
235
|
readonly openProp: boolean | undefined;
|
|
182
236
|
mounted: boolean;
|
|
183
237
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
184
238
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
239
|
+
floatingId: string | undefined;
|
|
240
|
+
triggerCount: number;
|
|
185
241
|
preventUnmountingOnClose: boolean;
|
|
186
242
|
payload: unknown;
|
|
187
243
|
activeTriggerId: string | null;
|
|
@@ -199,6 +255,8 @@ declare const selectors: {
|
|
|
199
255
|
mounted: boolean;
|
|
200
256
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
201
257
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
258
|
+
floatingId: string | undefined;
|
|
259
|
+
triggerCount: number;
|
|
202
260
|
preventUnmountingOnClose: boolean;
|
|
203
261
|
payload: unknown;
|
|
204
262
|
activeTriggerId: string | null;
|
|
@@ -216,6 +274,8 @@ declare const selectors: {
|
|
|
216
274
|
mounted: boolean;
|
|
217
275
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
218
276
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
277
|
+
floatingId: string | undefined;
|
|
278
|
+
triggerCount: number;
|
|
219
279
|
preventUnmountingOnClose: boolean;
|
|
220
280
|
payload: unknown;
|
|
221
281
|
activeTriggerId: string | null;
|
|
@@ -233,6 +293,8 @@ declare const selectors: {
|
|
|
233
293
|
mounted: boolean;
|
|
234
294
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
235
295
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
296
|
+
floatingId: string | undefined;
|
|
297
|
+
triggerCount: number;
|
|
236
298
|
preventUnmountingOnClose: boolean;
|
|
237
299
|
payload: unknown;
|
|
238
300
|
activeTriggerId: string | null;
|
|
@@ -244,12 +306,33 @@ declare const selectors: {
|
|
|
244
306
|
inactiveTriggerProps: import("../../index.js").HTMLProps;
|
|
245
307
|
popupProps: import("../../index.js").HTMLProps;
|
|
246
308
|
}, isActive: boolean) => import("../../index.js").HTMLProps;
|
|
309
|
+
triggerPopupId: (state: {
|
|
310
|
+
open: boolean;
|
|
311
|
+
readonly openProp: boolean | undefined;
|
|
312
|
+
mounted: boolean;
|
|
313
|
+
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
314
|
+
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
315
|
+
floatingId: string | undefined;
|
|
316
|
+
triggerCount: number;
|
|
317
|
+
preventUnmountingOnClose: boolean;
|
|
318
|
+
payload: unknown;
|
|
319
|
+
activeTriggerId: string | null;
|
|
320
|
+
activeTriggerElement: Element | null;
|
|
321
|
+
readonly triggerIdProp: string | null | undefined;
|
|
322
|
+
popupElement: HTMLElement | null;
|
|
323
|
+
positionerElement: HTMLElement | null;
|
|
324
|
+
activeTriggerProps: import("../../index.js").HTMLProps;
|
|
325
|
+
inactiveTriggerProps: import("../../index.js").HTMLProps;
|
|
326
|
+
popupProps: import("../../index.js").HTMLProps;
|
|
327
|
+
}, triggerId: string | undefined) => string | undefined;
|
|
247
328
|
popupProps: (state: {
|
|
248
329
|
open: boolean;
|
|
249
330
|
readonly openProp: boolean | undefined;
|
|
250
331
|
mounted: boolean;
|
|
251
332
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
252
333
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
334
|
+
floatingId: string | undefined;
|
|
335
|
+
triggerCount: number;
|
|
253
336
|
preventUnmountingOnClose: boolean;
|
|
254
337
|
payload: unknown;
|
|
255
338
|
activeTriggerId: string | null;
|
|
@@ -267,6 +350,8 @@ declare const selectors: {
|
|
|
267
350
|
mounted: boolean;
|
|
268
351
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
269
352
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
353
|
+
floatingId: string | undefined;
|
|
354
|
+
triggerCount: number;
|
|
270
355
|
preventUnmountingOnClose: boolean;
|
|
271
356
|
payload: unknown;
|
|
272
357
|
activeTriggerId: string | null;
|
|
@@ -284,6 +369,8 @@ declare const selectors: {
|
|
|
284
369
|
mounted: boolean;
|
|
285
370
|
transitionStatus: import("../../internals/useTransitionStatus.js").TransitionStatus;
|
|
286
371
|
floatingRootContext: import("../../floating-ui-react/index.js").FloatingRootContext;
|
|
372
|
+
floatingId: string | undefined;
|
|
373
|
+
triggerCount: number;
|
|
287
374
|
preventUnmountingOnClose: boolean;
|
|
288
375
|
payload: unknown;
|
|
289
376
|
activeTriggerId: string | null;
|
|
@@ -297,7 +384,7 @@ declare const selectors: {
|
|
|
297
384
|
}) => HTMLElement | null;
|
|
298
385
|
};
|
|
299
386
|
export declare class PopoverStore<Payload> extends ReactStore<Readonly<State<Payload>>, Context, Selectors> {
|
|
300
|
-
constructor(initialState?: Partial<State<Payload
|
|
387
|
+
constructor(initialState?: Partial<State<Payload>>, floatingId?: string | undefined, nested?: boolean);
|
|
301
388
|
setOpen: (nextOpen: boolean, eventDetails: Omit<PopoverRoot.ChangeEventDetails, "preventUnmountOnClose">) => void;
|
|
302
389
|
static useStore<Payload>(externalStore: PopoverStore<Payload> | undefined, initialState: Partial<State<Payload>>): PopoverStore<Payload>;
|
|
303
390
|
private disposeEffect;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import * as ReactDOM from 'react-dom';
|
|
4
6
|
import { ReactStore, createSelector } from '@base-ui/utils/store';
|
|
5
7
|
import { Timeout } from '@base-ui/utils/useTimeout';
|
|
6
|
-
import { useRefWithInit } from '@base-ui/utils/useRefWithInit';
|
|
7
|
-
import { useOnMount } from '@base-ui/utils/useOnMount';
|
|
8
8
|
import { REASONS } from "../../internals/reasons.js";
|
|
9
|
-
import { createInitialPopupStoreState, popupStoreSelectors, PopupTriggerMap } from "../../utils/popups/index.js";
|
|
9
|
+
import { createPopupFloatingRootContext, createInitialPopupStoreState, popupStoreSelectors, PopupTriggerMap, setOpenTriggerState, usePopupStore } from "../../utils/popups/index.js";
|
|
10
10
|
import { PATIENT_CLICK_THRESHOLD } from "../../internals/constants.js";
|
|
11
11
|
function createInitialState() {
|
|
12
12
|
return {
|
|
@@ -42,14 +42,16 @@ const selectors = {
|
|
|
42
42
|
hasViewport: createSelector(state => state.hasViewport)
|
|
43
43
|
};
|
|
44
44
|
export class PopoverStore extends ReactStore {
|
|
45
|
-
constructor(initialState) {
|
|
45
|
+
constructor(initialState, floatingId, nested = false) {
|
|
46
46
|
const initial = {
|
|
47
47
|
...createInitialState(),
|
|
48
48
|
...initialState
|
|
49
49
|
};
|
|
50
|
+
const triggerElements = new PopupTriggerMap();
|
|
50
51
|
if (initial.open && initialState?.mounted === undefined) {
|
|
51
52
|
initial.mounted = true;
|
|
52
53
|
}
|
|
54
|
+
initial.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
|
|
53
55
|
super(initial, {
|
|
54
56
|
popupRef: /*#__PURE__*/React.createRef(),
|
|
55
57
|
backdropRef: /*#__PURE__*/React.createRef(),
|
|
@@ -59,7 +61,7 @@ export class PopoverStore extends ReactStore {
|
|
|
59
61
|
triggerFocusTargetRef: /*#__PURE__*/React.createRef(),
|
|
60
62
|
beforeContentFocusGuardRef: /*#__PURE__*/React.createRef(),
|
|
61
63
|
stickIfOpenTimeout: new Timeout(),
|
|
62
|
-
triggerElements
|
|
64
|
+
triggerElements
|
|
63
65
|
}, selectors);
|
|
64
66
|
}
|
|
65
67
|
setOpen = (nextOpen, eventDetails) => {
|
|
@@ -69,6 +71,10 @@ export class PopoverStore extends ReactStore {
|
|
|
69
71
|
eventDetails.preventUnmountOnClose = () => {
|
|
70
72
|
this.set('preventUnmountingOnClose', true);
|
|
71
73
|
};
|
|
74
|
+
const activeTriggerId = this.select('activeTriggerId');
|
|
75
|
+
if (!nextOpen && eventDetails.reason === REASONS.closePress && eventDetails.trigger == null && activeTriggerId != null) {
|
|
76
|
+
eventDetails.trigger = this.context.triggerElements.getById(activeTriggerId) ?? this.select('activeTriggerElement') ?? undefined;
|
|
77
|
+
}
|
|
72
78
|
this.context.onOpenChange?.(nextOpen, eventDetails);
|
|
73
79
|
if (eventDetails.isCanceled) {
|
|
74
80
|
return;
|
|
@@ -79,14 +85,7 @@ export class PopoverStore extends ReactStore {
|
|
|
79
85
|
open: nextOpen,
|
|
80
86
|
openChangeReason: eventDetails.reason
|
|
81
87
|
};
|
|
82
|
-
|
|
83
|
-
// If a popup is closing, the `trigger` may be null.
|
|
84
|
-
// We want to keep the previous value so that exit animations are played and focus is returned correctly.
|
|
85
|
-
const newTriggerId = eventDetails.trigger?.id ?? null;
|
|
86
|
-
if (newTriggerId || nextOpen) {
|
|
87
|
-
updatedState.activeTriggerId = newTriggerId;
|
|
88
|
-
updatedState.activeTriggerElement = eventDetails.trigger ?? null;
|
|
89
|
-
}
|
|
88
|
+
setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger);
|
|
90
89
|
this.update(updatedState);
|
|
91
90
|
};
|
|
92
91
|
if (isHover) {
|
|
@@ -109,11 +108,11 @@ export class PopoverStore extends ReactStore {
|
|
|
109
108
|
}
|
|
110
109
|
};
|
|
111
110
|
static useStore(externalStore, initialState) {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
const {
|
|
112
|
+
store,
|
|
113
|
+
internalStore
|
|
114
|
+
} = usePopupStore(externalStore, (floatingId, nested) => new PopoverStore(initialState, floatingId, nested));
|
|
115
|
+
React.useEffect(() => internalStore?.disposeEffect(), [internalStore]);
|
|
117
116
|
return store;
|
|
118
117
|
}
|
|
119
118
|
disposeEffect = () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
|
|
5
4
|
import { usePopoverRootContext } from "../root/PopoverRootContext.js";
|
|
6
5
|
import { useRenderElement } from "../../internals/useRenderElement.js";
|
|
7
6
|
import { useBaseUiId } from "../../internals/useBaseUiId.js";
|
|
@@ -23,12 +22,7 @@ export const PopoverTitle = /*#__PURE__*/React.forwardRef(function PopoverTitle(
|
|
|
23
22
|
store
|
|
24
23
|
} = usePopoverRootContext();
|
|
25
24
|
const id = useBaseUiId(elementProps.id);
|
|
26
|
-
|
|
27
|
-
store.set('titleElementId', id);
|
|
28
|
-
return () => {
|
|
29
|
-
store.set('titleElementId', undefined);
|
|
30
|
-
};
|
|
31
|
-
}, [store, id]);
|
|
25
|
+
store.useSyncedValueWithCleanup('titleElementId', id);
|
|
32
26
|
const element = useRenderElement('h2', componentProps, {
|
|
33
27
|
ref: forwardedRef,
|
|
34
28
|
props: [{
|