@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
|
@@ -11,7 +11,7 @@ import { visuallyHidden, visuallyHiddenInput } from '@base-ui/utils/visuallyHidd
|
|
|
11
11
|
import { useRefWithInit } from '@base-ui/utils/useRefWithInit';
|
|
12
12
|
import { Store, useStore } from '@base-ui/utils/store';
|
|
13
13
|
import { EMPTY_ARRAY, EMPTY_OBJECT } from '@base-ui/utils/empty';
|
|
14
|
-
import { useDismiss, useFloatingRootContext,
|
|
14
|
+
import { useDismiss, useFloatingRootContext, useListNavigation, useClick } from "../../floating-ui-react/index.js";
|
|
15
15
|
import { contains, getTarget } from "../../floating-ui-react/utils.js";
|
|
16
16
|
import { createChangeEventDetails, createGenericEventDetails } from "../../internals/createBaseUIEventDetails.js";
|
|
17
17
|
import { REASONS } from "../../internals/reasons.js";
|
|
@@ -28,9 +28,12 @@ import { useTransitionStatus } from "../../internals/useTransitionStatus.js";
|
|
|
28
28
|
import { useOpenInteractionType } from "../../utils/useOpenInteractionType.js";
|
|
29
29
|
import { useValueChanged } from "../../internals/useValueChanged.js";
|
|
30
30
|
import { NOOP } from "../../internals/noop.js";
|
|
31
|
+
import { FOCUSABLE_POPUP_PROPS } from "../../utils/popups/index.js";
|
|
32
|
+
import { mergeProps } from "../../merge-props/index.js";
|
|
31
33
|
import { stringifyAsLabel, stringifyAsValue, isGroupedItems } from "../../internals/resolveValueLabel.js";
|
|
32
34
|
import { compareItemEquality, defaultItemEquality, findItemIndex, removeItem, selectedValueIncludes } from "../../internals/itemEquality.js";
|
|
33
35
|
import { INITIAL_LAST_HIGHLIGHT, NO_ACTIVE_VALUE } from "./utils/constants.js";
|
|
36
|
+
import { useDirection } from "../../internals/direction-context/DirectionContext.js";
|
|
34
37
|
|
|
35
38
|
/**
|
|
36
39
|
* @internal
|
|
@@ -92,6 +95,7 @@ export function AriaCombobox(props) {
|
|
|
92
95
|
validationMode,
|
|
93
96
|
validation
|
|
94
97
|
} = useFieldRootContext();
|
|
98
|
+
const direction = useDirection();
|
|
95
99
|
const id = useLabelableId({
|
|
96
100
|
id: idProp
|
|
97
101
|
});
|
|
@@ -302,6 +306,7 @@ export function AriaCombobox(props) {
|
|
|
302
306
|
popupProps: {},
|
|
303
307
|
inputProps: {},
|
|
304
308
|
triggerProps: {},
|
|
309
|
+
itemProps: EMPTY_OBJECT,
|
|
305
310
|
positionerElement: null,
|
|
306
311
|
listElement: null,
|
|
307
312
|
triggerElement: null,
|
|
@@ -310,6 +315,9 @@ export function AriaCombobox(props) {
|
|
|
310
315
|
popupSide: null,
|
|
311
316
|
openMethod: null,
|
|
312
317
|
inputInsidePopup: true,
|
|
318
|
+
// Avoid duplicate names in the server HTML. Popup inputs aren't rendered
|
|
319
|
+
// until after hydration, so the hidden input takes over then if needed.
|
|
320
|
+
inputOwnsFormValue: selectionMode === 'none',
|
|
313
321
|
onOpenChangeComplete: onOpenChangeCompleteProp || NOOP,
|
|
314
322
|
// Placeholder callbacks replaced on first render
|
|
315
323
|
setOpen: NOOP,
|
|
@@ -318,7 +326,6 @@ export function AriaCombobox(props) {
|
|
|
318
326
|
setIndices: NOOP,
|
|
319
327
|
onItemHighlighted: NOOP,
|
|
320
328
|
handleSelection: NOOP,
|
|
321
|
-
getItemProps: () => EMPTY_OBJECT,
|
|
322
329
|
forceMount: NOOP,
|
|
323
330
|
requestSubmit: NOOP
|
|
324
331
|
})).current;
|
|
@@ -343,6 +350,7 @@ export function AriaCombobox(props) {
|
|
|
343
350
|
const inputGroupElement = useStore(store, selectors.inputGroupElement);
|
|
344
351
|
const inline = useStore(store, selectors.inline);
|
|
345
352
|
const inputInsidePopup = useStore(store, selectors.inputInsidePopup);
|
|
353
|
+
const inputOwnsFormValue = useStore(store, selectors.inputOwnsFormValue);
|
|
346
354
|
const triggerRef = useValueAsRef(triggerElement);
|
|
347
355
|
const {
|
|
348
356
|
mounted,
|
|
@@ -353,12 +361,8 @@ export function AriaCombobox(props) {
|
|
|
353
361
|
openMethod,
|
|
354
362
|
triggerProps
|
|
355
363
|
} = useOpenInteractionType(open);
|
|
356
|
-
const
|
|
357
|
-
useRegisterFieldControl(inputInsidePopup ? triggerRef : inputRef,
|
|
358
|
-
id,
|
|
359
|
-
value: fieldRawValue,
|
|
360
|
-
getValue: getFieldValue
|
|
361
|
-
});
|
|
364
|
+
const getStringifiedValueForForm = useStableCallback(() => fieldStringValue);
|
|
365
|
+
useRegisterFieldControl(inputInsidePopup ? triggerRef : inputRef, id, fieldRawValue, getStringifiedValueForForm);
|
|
362
366
|
const forceMount = useStableCallback(() => {
|
|
363
367
|
if (items) {
|
|
364
368
|
// Ensure typeahead works on a closed list.
|
|
@@ -445,6 +449,16 @@ export function AriaCombobox(props) {
|
|
|
445
449
|
if (eventDetails.isCanceled) {
|
|
446
450
|
return;
|
|
447
451
|
}
|
|
452
|
+
|
|
453
|
+
// If reopening interrupts the close animation, handleUnmount won't run to clear the
|
|
454
|
+
// frozen closeQuery and pending popup input.
|
|
455
|
+
if (nextOpen && multiple && inputInsidePopup && !inline && closeQuery !== null) {
|
|
456
|
+
setQueryChangedAfterOpen(false);
|
|
457
|
+
setCloseQuery(null);
|
|
458
|
+
if (inputValue !== '') {
|
|
459
|
+
setInputValue('', createChangeEventDetails(REASONS.inputClear, eventDetails.event));
|
|
460
|
+
}
|
|
461
|
+
}
|
|
448
462
|
if (!nextOpen && queryChangedAfterOpen) {
|
|
449
463
|
if (single) {
|
|
450
464
|
if (!inline) {
|
|
@@ -455,17 +469,22 @@ export function AriaCombobox(props) {
|
|
|
455
469
|
setQueryChangedAfterOpen(false);
|
|
456
470
|
}
|
|
457
471
|
} else if (multiple) {
|
|
458
|
-
if (inline
|
|
472
|
+
if (!inline) {
|
|
473
|
+
// Freeze the current query so filtering remains stable while exiting.
|
|
474
|
+
setCloseQuery(query);
|
|
475
|
+
}
|
|
476
|
+
if (inputInsidePopup) {
|
|
459
477
|
setIndices({
|
|
460
478
|
activeIndex: null
|
|
461
479
|
});
|
|
462
|
-
} else {
|
|
463
|
-
// Freeze the current query so filtering remains stable while exiting.
|
|
464
|
-
setCloseQuery(query);
|
|
465
480
|
}
|
|
481
|
+
|
|
466
482
|
// Clear the input immediately on close while retaining filtering via closeQuery for exit animations
|
|
467
|
-
// if the input is outside the popup.
|
|
468
|
-
|
|
483
|
+
// if the input is outside the popup. When the input is inside the popup, defer the clear until
|
|
484
|
+
// unmount so the filtered list doesn't flash to unfiltered during the exit animation.
|
|
485
|
+
if (!inputInsidePopup || inline) {
|
|
486
|
+
setInputValue('', createChangeEventDetails(REASONS.inputClear, eventDetails.event));
|
|
487
|
+
}
|
|
469
488
|
}
|
|
470
489
|
}
|
|
471
490
|
setOpenUnwrapped(nextOpen);
|
|
@@ -834,6 +853,7 @@ export function AriaCombobox(props) {
|
|
|
834
853
|
// Floating UI tests don't require `role="row"` wrappers, so retains the number API.
|
|
835
854
|
cols: grid ? 2 : 1,
|
|
836
855
|
orientation: grid ? 'horizontal' : undefined,
|
|
856
|
+
rtl: direction === 'rtl',
|
|
837
857
|
disabledIndices: EMPTY_ARRAY,
|
|
838
858
|
onNavigate(nextActiveIndex, event) {
|
|
839
859
|
// Retain the highlight only while actually transitioning out or closed.
|
|
@@ -852,18 +872,28 @@ export function AriaCombobox(props) {
|
|
|
852
872
|
}
|
|
853
873
|
}
|
|
854
874
|
});
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
875
|
+
const inputProps = React.useMemo(() => mergeProps(listNavigation.reference, dismiss.reference, click.reference, role.reference), [listNavigation.reference, dismiss.reference, click.reference, role.reference]);
|
|
876
|
+
const popupProps = React.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, listNavigation.floating, dismiss.floating, role.floating), [listNavigation.floating, dismiss.floating, role.floating]);
|
|
877
|
+
const itemProps = React.useMemo(() => {
|
|
878
|
+
const listNavigationItemProps = listNavigation.item;
|
|
879
|
+
if (!listNavigationItemProps) {
|
|
880
|
+
return EMPTY_OBJECT;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
// Combobox keeps focus on the input; item focus would incorrectly sync
|
|
884
|
+
// list navigation state from DOM focus.
|
|
885
|
+
return {
|
|
886
|
+
...listNavigationItemProps,
|
|
887
|
+
onFocus: undefined
|
|
888
|
+
};
|
|
889
|
+
}, [listNavigation.item]);
|
|
860
890
|
useOnFirstRender(() => {
|
|
861
891
|
store.update({
|
|
862
892
|
inline: inlineProp,
|
|
863
|
-
popupProps
|
|
864
|
-
inputProps
|
|
893
|
+
popupProps,
|
|
894
|
+
inputProps,
|
|
865
895
|
triggerProps,
|
|
866
|
-
|
|
896
|
+
itemProps,
|
|
867
897
|
setOpen,
|
|
868
898
|
setInputValue,
|
|
869
899
|
setSelectedValue,
|
|
@@ -883,11 +913,11 @@ export function AriaCombobox(props) {
|
|
|
883
913
|
transitionStatus,
|
|
884
914
|
items,
|
|
885
915
|
inline: inlineProp,
|
|
886
|
-
popupProps
|
|
887
|
-
inputProps
|
|
916
|
+
popupProps,
|
|
917
|
+
inputProps,
|
|
888
918
|
triggerProps,
|
|
889
919
|
openMethod,
|
|
890
|
-
|
|
920
|
+
itemProps,
|
|
891
921
|
selectionMode,
|
|
892
922
|
name,
|
|
893
923
|
form,
|
|
@@ -905,9 +935,10 @@ export function AriaCombobox(props) {
|
|
|
905
935
|
isItemEqualToValue,
|
|
906
936
|
submitOnItemClick,
|
|
907
937
|
hasInputValue,
|
|
908
|
-
requestSubmit
|
|
938
|
+
requestSubmit,
|
|
939
|
+
inputOwnsFormValue: selectionMode === 'none' && (inlineProp || !store.state.inputInsidePopup)
|
|
909
940
|
});
|
|
910
|
-
}, [store, id, selectedValue, open, mounted, transitionStatus, items,
|
|
941
|
+
}, [store, id, selectedValue, open, mounted, transitionStatus, items, popupProps, inputProps, itemProps, openMethod, triggerProps, selectionMode, name, disabled, readOnly, required, validation, grid, isGrouped, virtualized, onOpenChangeComplete, openOnInputClick, itemToStringLabel, modal, isItemEqualToValue, submitOnItemClick, hasInputValue, inlineProp, requestSubmit, autoHighlightMode, form]);
|
|
911
942
|
const hiddenInputRef = useMergedRefs(inputRefProp, validation.inputRef);
|
|
912
943
|
const itemsContextValue = React.useMemo(() => ({
|
|
913
944
|
query,
|
|
@@ -922,7 +953,7 @@ export function AriaCombobox(props) {
|
|
|
922
953
|
return stringifyAsValue(fieldRawValue, itemToStringValue);
|
|
923
954
|
}, [fieldRawValue, itemToStringValue]);
|
|
924
955
|
const hasMultipleSelection = multiple && Array.isArray(selectedValue) && selectedValue.length > 0;
|
|
925
|
-
const hiddenInputName = multiple || selectionMode === 'none' ? undefined : name;
|
|
956
|
+
const hiddenInputName = multiple || selectionMode === 'none' && inputOwnsFormValue ? undefined : name;
|
|
926
957
|
const hiddenInputs = React.useMemo(() => {
|
|
927
958
|
if (!multiple || !Array.isArray(selectedValue) || !name) {
|
|
928
959
|
return null;
|
|
@@ -951,7 +982,9 @@ export function AriaCombobox(props) {
|
|
|
951
982
|
// Handle browser autofill.
|
|
952
983
|
onChange(event) {
|
|
953
984
|
// Workaround for https://github.com/facebook/react/issues/9023
|
|
954
|
-
if (event.nativeEvent.defaultPrevented) {
|
|
985
|
+
if (event.nativeEvent.defaultPrevented || disabled || readOnly) {
|
|
986
|
+
// Outside Field.Root, the event is not wrapped by mergeProps.
|
|
987
|
+
event.preventBaseUIHandler?.();
|
|
955
988
|
return;
|
|
956
989
|
}
|
|
957
990
|
const nextValue = event.currentTarget.value;
|
package/esm/combobox/store.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export type State = {
|
|
|
21
21
|
popupProps: HTMLProps;
|
|
22
22
|
inputProps: HTMLProps;
|
|
23
23
|
triggerProps: HTMLProps;
|
|
24
|
+
itemProps: HTMLProps;
|
|
24
25
|
positionerElement: HTMLElement | null;
|
|
25
26
|
listElement: HTMLElement | null;
|
|
26
27
|
triggerElement: HTMLElement | null;
|
|
@@ -29,6 +30,7 @@ export type State = {
|
|
|
29
30
|
popupSide: Side | null;
|
|
30
31
|
openMethod: InteractionType | null;
|
|
31
32
|
inputInsidePopup: boolean;
|
|
33
|
+
inputOwnsFormValue: boolean;
|
|
32
34
|
selectionMode: 'single' | 'multiple' | 'none';
|
|
33
35
|
listRef: React.RefObject<Array<HTMLElement | null>>;
|
|
34
36
|
labelsRef: React.RefObject<Array<string | null>>;
|
|
@@ -54,10 +56,6 @@ export type State = {
|
|
|
54
56
|
onItemHighlighted: (item: any, eventDetails: AriaCombobox.HighlightEventDetails) => void;
|
|
55
57
|
forceMount: () => void;
|
|
56
58
|
handleSelection: (event: MouseEvent | PointerEvent | KeyboardEvent, passedValue?: any) => void;
|
|
57
|
-
getItemProps: (props?: HTMLProps & {
|
|
58
|
-
active?: boolean | undefined;
|
|
59
|
-
selected?: boolean | undefined;
|
|
60
|
-
}) => Record<string, unknown>;
|
|
61
59
|
requestSubmit: () => void;
|
|
62
60
|
name: string | undefined;
|
|
63
61
|
form: string | undefined;
|
|
@@ -97,10 +95,7 @@ export declare const selectors: {
|
|
|
97
95
|
popupProps: (state: State) => HTMLProps;
|
|
98
96
|
inputProps: (state: State) => HTMLProps;
|
|
99
97
|
triggerProps: (state: State) => HTMLProps;
|
|
100
|
-
|
|
101
|
-
active?: boolean | undefined;
|
|
102
|
-
selected?: boolean | undefined;
|
|
103
|
-
}) => Record<string, unknown>;
|
|
98
|
+
itemProps: (state: State) => HTMLProps;
|
|
104
99
|
positionerElement: (state: State) => HTMLElement | null;
|
|
105
100
|
listElement: (state: State) => HTMLElement | null;
|
|
106
101
|
triggerElement: (state: State) => HTMLElement | null;
|
|
@@ -109,6 +104,7 @@ export declare const selectors: {
|
|
|
109
104
|
popupSide: (state: State) => Side | null;
|
|
110
105
|
openMethod: (state: State) => InteractionType | null;
|
|
111
106
|
inputInsidePopup: (state: State) => boolean;
|
|
107
|
+
inputOwnsFormValue: (state: State) => boolean;
|
|
112
108
|
selectionMode: (state: State) => "none" | "multiple" | "single";
|
|
113
109
|
name: (state: State) => string | undefined;
|
|
114
110
|
form: (state: State) => string | undefined;
|
package/esm/combobox/store.js
CHANGED
|
@@ -45,7 +45,7 @@ export const selectors = {
|
|
|
45
45
|
popupProps: createSelector(state => state.popupProps),
|
|
46
46
|
inputProps: createSelector(state => state.inputProps),
|
|
47
47
|
triggerProps: createSelector(state => state.triggerProps),
|
|
48
|
-
|
|
48
|
+
itemProps: createSelector(state => state.itemProps),
|
|
49
49
|
positionerElement: createSelector(state => state.positionerElement),
|
|
50
50
|
listElement: createSelector(state => state.listElement),
|
|
51
51
|
triggerElement: createSelector(state => state.triggerElement),
|
|
@@ -54,6 +54,7 @@ export const selectors = {
|
|
|
54
54
|
popupSide: createSelector(state => state.popupSide),
|
|
55
55
|
openMethod: createSelector(state => state.openMethod),
|
|
56
56
|
inputInsidePopup: createSelector(state => state.inputInsidePopup),
|
|
57
|
+
inputOwnsFormValue: createSelector(state => state.inputOwnsFormValue),
|
|
57
58
|
selectionMode: createSelector(state => state.selectionMode),
|
|
58
59
|
name: createSelector(state => state.name),
|
|
59
60
|
form: createSelector(state => state.form),
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useMergedRefs } from '@base-ui/utils/useMergedRefs';
|
|
5
|
-
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
6
5
|
import { visuallyHiddenInput } from '@base-ui/utils/visuallyHidden';
|
|
7
6
|
import { useButton } from "../../internals/use-button/index.js";
|
|
8
7
|
import { createChangeEventDetails } from "../../internals/createBaseUIEventDetails.js";
|
|
@@ -21,9 +20,9 @@ export const ComboboxInternalDismissButton = /*#__PURE__*/React.forwardRef(funct
|
|
|
21
20
|
native: false
|
|
22
21
|
});
|
|
23
22
|
const mergedRef = useMergedRefs(forwardedRef, buttonRef);
|
|
24
|
-
|
|
23
|
+
function handleDismiss(event) {
|
|
25
24
|
store.state.setOpen(false, createChangeEventDetails(REASONS.closePress, event.nativeEvent, event.currentTarget));
|
|
26
|
-
}
|
|
25
|
+
}
|
|
27
26
|
const dismissProps = getButtonProps({
|
|
28
27
|
onClick: handleDismiss
|
|
29
28
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { CSPContext } from "
|
|
4
|
+
import { CSPContext } from "../internals/csp-context/CSPContext.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Provides a default Content Security Policy (CSP) configuration for Base UI components that
|
|
@@ -17,20 +17,15 @@ export const DialogClose = /*#__PURE__*/React.forwardRef(function DialogClose(co
|
|
|
17
17
|
const {
|
|
18
18
|
render,
|
|
19
19
|
className,
|
|
20
|
+
style,
|
|
20
21
|
disabled = false,
|
|
21
22
|
nativeButton = true,
|
|
22
|
-
style,
|
|
23
23
|
...elementProps
|
|
24
24
|
} = componentProps;
|
|
25
25
|
const {
|
|
26
26
|
store
|
|
27
27
|
} = useDialogRootContext();
|
|
28
28
|
const open = store.useState('open');
|
|
29
|
-
function handleClick(event) {
|
|
30
|
-
if (open) {
|
|
31
|
-
store.setOpen(false, createChangeEventDetails(REASONS.closePress, event.nativeEvent));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
29
|
const {
|
|
35
30
|
getButtonProps,
|
|
36
31
|
buttonRef
|
|
@@ -41,6 +36,11 @@ export const DialogClose = /*#__PURE__*/React.forwardRef(function DialogClose(co
|
|
|
41
36
|
const state = {
|
|
42
37
|
disabled
|
|
43
38
|
};
|
|
39
|
+
function handleClick(event) {
|
|
40
|
+
if (open) {
|
|
41
|
+
store.setOpen(false, createChangeEventDetails(REASONS.closePress, event.nativeEvent));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
44
|
return useRenderElement('button', componentProps, {
|
|
45
45
|
state,
|
|
46
46
|
ref: [forwardedRef, buttonRef],
|
|
@@ -11,6 +11,7 @@ import { DialogPopupDataAttributes } from "./DialogPopupDataAttributes.js";
|
|
|
11
11
|
import { useDialogPortalContext } from "../portal/DialogPortalContext.js";
|
|
12
12
|
import { useOpenChangeComplete } from "../../internals/useOpenChangeComplete.js";
|
|
13
13
|
import { COMPOSITE_KEYS } from "../../internals/composite/composite.js";
|
|
14
|
+
import { FOCUSABLE_POPUP_PROPS } from "../../utils/popups/index.js";
|
|
14
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
16
|
const stateAttributesMapping = {
|
|
16
17
|
...baseMapping,
|
|
@@ -30,11 +31,11 @@ const stateAttributesMapping = {
|
|
|
30
31
|
*/
|
|
31
32
|
export const DialogPopup = /*#__PURE__*/React.forwardRef(function DialogPopup(componentProps, forwardedRef) {
|
|
32
33
|
const {
|
|
34
|
+
render,
|
|
33
35
|
className,
|
|
36
|
+
style,
|
|
34
37
|
finalFocus,
|
|
35
38
|
initialFocus,
|
|
36
|
-
render,
|
|
37
|
-
style,
|
|
38
39
|
...elementProps
|
|
39
40
|
} = componentProps;
|
|
40
41
|
const {
|
|
@@ -53,6 +54,8 @@ export const DialogPopup = /*#__PURE__*/React.forwardRef(function DialogPopup(co
|
|
|
53
54
|
const titleElementId = store.useState('titleElementId');
|
|
54
55
|
const transitionStatus = store.useState('transitionStatus');
|
|
55
56
|
const role = store.useState('role');
|
|
57
|
+
const floatingId = floatingRootContext.useState('floatingId');
|
|
58
|
+
const popupId = elementProps.id ?? floatingId;
|
|
56
59
|
useDialogPortalContext();
|
|
57
60
|
useOpenChangeComplete({
|
|
58
61
|
open,
|
|
@@ -75,6 +78,7 @@ export const DialogPopup = /*#__PURE__*/React.forwardRef(function DialogPopup(co
|
|
|
75
78
|
}
|
|
76
79
|
const resolvedInitialFocus = initialFocus === undefined ? defaultInitialFocus : initialFocus;
|
|
77
80
|
const nestedDialogOpen = nestedOpenDialogCount > 0;
|
|
81
|
+
const setPopupElement = store.useStateSetter('popupElement');
|
|
78
82
|
const state = {
|
|
79
83
|
open,
|
|
80
84
|
nested,
|
|
@@ -84,10 +88,11 @@ export const DialogPopup = /*#__PURE__*/React.forwardRef(function DialogPopup(co
|
|
|
84
88
|
const element = useRenderElement('div', componentProps, {
|
|
85
89
|
state,
|
|
86
90
|
props: [rootPopupProps, {
|
|
91
|
+
id: popupId,
|
|
87
92
|
'aria-labelledby': titleElementId ?? undefined,
|
|
88
93
|
'aria-describedby': descriptionElementId ?? undefined,
|
|
89
94
|
role,
|
|
90
|
-
|
|
95
|
+
...FOCUSABLE_POPUP_PROPS,
|
|
91
96
|
hidden: !mounted,
|
|
92
97
|
onKeyDown(event) {
|
|
93
98
|
if (COMPOSITE_KEYS.has(event.key)) {
|
|
@@ -98,7 +103,7 @@ export const DialogPopup = /*#__PURE__*/React.forwardRef(function DialogPopup(co
|
|
|
98
103
|
[DialogPopupCssVars.nestedDialogs]: nestedOpenDialogCount
|
|
99
104
|
}
|
|
100
105
|
}, elementProps],
|
|
101
|
-
ref: [forwardedRef, store.context.popupRef,
|
|
106
|
+
ref: [forwardedRef, store.context.popupRef, setPopupElement],
|
|
102
107
|
stateAttributesMapping
|
|
103
108
|
});
|
|
104
109
|
return /*#__PURE__*/_jsx(FloatingFocusManager, {
|
|
@@ -3,7 +3,6 @@ import type { BaseUIChangeEventDetails } from "../../internals/createBaseUIEvent
|
|
|
3
3
|
import { REASONS } from "../../internals/reasons.js";
|
|
4
4
|
import { DialogHandle } from "../store/DialogHandle.js";
|
|
5
5
|
import { type PayloadChildRenderFunction } from "../../utils/popups/index.js";
|
|
6
|
-
export declare const IsDrawerContext: React.Context<boolean>;
|
|
7
6
|
/**
|
|
8
7
|
* Groups all parts of the dialog.
|
|
9
8
|
* Doesn't render its own HTML element.
|
|
@@ -70,7 +69,7 @@ export interface DialogRootProps<Payload = unknown> {
|
|
|
70
69
|
/**
|
|
71
70
|
* ID of the trigger that the dialog is associated with.
|
|
72
71
|
* This is useful in conjunction with the `open` prop to create a controlled dialog.
|
|
73
|
-
* There's no need to specify this prop when the
|
|
72
|
+
* There's no need to specify this prop when the dialog is uncontrolled (that is, when the `open` prop is not set).
|
|
74
73
|
*/
|
|
75
74
|
triggerId?: string | null | undefined;
|
|
76
75
|
/**
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { DialogRootContext, useDialogRootContext } from "./DialogRootContext.js";
|
|
7
|
-
import { DialogStore } from "../store/DialogStore.js";
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
export const IsDrawerContext = /*#__PURE__*/React.createContext(false);
|
|
4
|
+
import { IsDrawerContext } from "./DialogRootContext.js";
|
|
5
|
+
import { useRenderDialogRoot } from "./useRenderDialogRoot.js";
|
|
10
6
|
|
|
11
7
|
/**
|
|
12
8
|
* Groups all parts of the dialog.
|
|
@@ -14,71 +10,7 @@ export const IsDrawerContext = /*#__PURE__*/React.createContext(false);
|
|
|
14
10
|
*
|
|
15
11
|
* Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
|
|
16
12
|
*/
|
|
17
|
-
if (process.env.NODE_ENV !== "production") IsDrawerContext.displayName = "IsDrawerContext";
|
|
18
13
|
export function DialogRoot(props) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
open: openProp,
|
|
22
|
-
defaultOpen = false,
|
|
23
|
-
onOpenChange,
|
|
24
|
-
onOpenChangeComplete,
|
|
25
|
-
disablePointerDismissal = false,
|
|
26
|
-
modal = true,
|
|
27
|
-
actionsRef,
|
|
28
|
-
handle,
|
|
29
|
-
triggerId: triggerIdProp,
|
|
30
|
-
defaultTriggerId: defaultTriggerIdProp = null
|
|
31
|
-
} = props;
|
|
32
|
-
const parentDialogRootContext = useDialogRootContext(true);
|
|
33
|
-
const isDrawer = React.useContext(IsDrawerContext);
|
|
34
|
-
const nested = Boolean(parentDialogRootContext);
|
|
35
|
-
const store = DialogStore.useStore(handle?.store, {
|
|
36
|
-
open: defaultOpen,
|
|
37
|
-
openProp,
|
|
38
|
-
activeTriggerId: defaultTriggerIdProp,
|
|
39
|
-
triggerIdProp,
|
|
40
|
-
modal,
|
|
41
|
-
disablePointerDismissal,
|
|
42
|
-
nested
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Support initially open state when uncontrolled
|
|
46
|
-
useOnFirstRender(() => {
|
|
47
|
-
if (openProp === undefined && store.state.open === false && defaultOpen === true) {
|
|
48
|
-
store.update({
|
|
49
|
-
open: true,
|
|
50
|
-
activeTriggerId: defaultTriggerIdProp
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
store.useControlledProp('openProp', openProp);
|
|
55
|
-
store.useControlledProp('triggerIdProp', triggerIdProp);
|
|
56
|
-
store.useSyncedValues({
|
|
57
|
-
disablePointerDismissal,
|
|
58
|
-
nested,
|
|
59
|
-
modal
|
|
60
|
-
});
|
|
61
|
-
store.useContextCallback('onOpenChange', onOpenChange);
|
|
62
|
-
store.useContextCallback('onOpenChangeComplete', onOpenChangeComplete);
|
|
63
|
-
const payload = store.useState('payload');
|
|
64
|
-
useDialogRoot({
|
|
65
|
-
store,
|
|
66
|
-
actionsRef,
|
|
67
|
-
parentContext: parentDialogRootContext?.store.context,
|
|
68
|
-
isDrawer,
|
|
69
|
-
onOpenChange,
|
|
70
|
-
triggerIdProp
|
|
71
|
-
});
|
|
72
|
-
const contextValue = React.useMemo(() => ({
|
|
73
|
-
store
|
|
74
|
-
}), [store]);
|
|
75
|
-
return /*#__PURE__*/_jsx(IsDrawerContext.Provider, {
|
|
76
|
-
value: false,
|
|
77
|
-
children: /*#__PURE__*/_jsx(DialogRootContext.Provider, {
|
|
78
|
-
value: contextValue,
|
|
79
|
-
children: typeof children === 'function' ? children({
|
|
80
|
-
payload
|
|
81
|
-
}) : children
|
|
82
|
-
})
|
|
83
|
-
});
|
|
14
|
+
const mode = React.useContext(IsDrawerContext) ? 'drawer' : 'dialog';
|
|
15
|
+
return useRenderDialogRoot(props, mode);
|
|
84
16
|
}
|
|
@@ -3,6 +3,7 @@ import { DialogStore } from "../store/DialogStore.js";
|
|
|
3
3
|
export interface DialogRootContext<Payload = unknown> {
|
|
4
4
|
store: DialogStore<Payload>;
|
|
5
5
|
}
|
|
6
|
+
export declare const IsDrawerContext: React.Context<boolean>;
|
|
6
7
|
export declare const DialogRootContext: React.Context<DialogRootContext<unknown> | undefined>;
|
|
7
8
|
export declare function useDialogRootContext(optional?: false): DialogRootContext;
|
|
8
9
|
export declare function useDialogRootContext(optional: true): DialogRootContext | undefined;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import _formatErrorMessage from "@base-ui/utils/formatErrorMessage";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
export const IsDrawerContext = /*#__PURE__*/React.createContext(false);
|
|
6
|
+
if (process.env.NODE_ENV !== "production") IsDrawerContext.displayName = "IsDrawerContext";
|
|
5
7
|
export const DialogRootContext = /*#__PURE__*/React.createContext(undefined);
|
|
6
8
|
if (process.env.NODE_ENV !== "production") DialogRootContext.displayName = "DialogRootContext";
|
|
7
9
|
export function useDialogRootContext(optional) {
|
|
@@ -6,9 +6,17 @@ export interface UseDialogRootParameters {
|
|
|
6
6
|
store: DialogStore<any>;
|
|
7
7
|
actionsRef?: DialogRoot.Props['actionsRef'] | undefined;
|
|
8
8
|
parentContext?: DialogStore<unknown>['context'] | undefined;
|
|
9
|
-
onOpenChange: DialogRoot.Props['onOpenChange'];
|
|
10
9
|
isDrawer: boolean;
|
|
11
|
-
triggerIdProp?: string | null | undefined;
|
|
12
10
|
}
|
|
13
|
-
export
|
|
14
|
-
|
|
11
|
+
export interface UseDialogRootReturnValue {
|
|
12
|
+
parentContext: DialogStore<unknown>['context'] | undefined;
|
|
13
|
+
isDrawer: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface UseDialogRootState {}
|
|
16
|
+
export declare function DialogInteractions({
|
|
17
|
+
store,
|
|
18
|
+
dialogRoot
|
|
19
|
+
}: {
|
|
20
|
+
store: DialogStore<any>;
|
|
21
|
+
dialogRoot: UseDialogRootReturnValue;
|
|
22
|
+
}): null;
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useScrollLock } from '@base-ui/utils/useScrollLock';
|
|
5
|
-
import {
|
|
5
|
+
import { EMPTY_OBJECT } from '@base-ui/utils/empty';
|
|
6
|
+
import { mergeProps } from "../../merge-props/index.js";
|
|
7
|
+
import { useDismiss } from "../../floating-ui-react/index.js";
|
|
6
8
|
import { contains, getTarget } from "../../floating-ui-react/utils.js";
|
|
7
|
-
import { useOpenInteractionType } from "../../utils/useOpenInteractionType.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 { FOCUSABLE_POPUP_PROPS, useImplicitActiveTrigger, useOpenStateTransitions, usePopupInteractionProps, usePopupRootSync } from "../../utils/popups/index.js";
|
|
11
12
|
export function useDialogRoot(params) {
|
|
12
13
|
const {
|
|
13
14
|
store,
|
|
@@ -16,13 +17,7 @@ export function useDialogRoot(params) {
|
|
|
16
17
|
isDrawer
|
|
17
18
|
} = params;
|
|
18
19
|
const open = store.useState('open');
|
|
19
|
-
|
|
20
|
-
const modal = store.useState('modal');
|
|
21
|
-
const popupElement = store.useState('popupElement');
|
|
22
|
-
const {
|
|
23
|
-
openMethod,
|
|
24
|
-
triggerProps
|
|
25
|
-
} = useOpenInteractionType(open);
|
|
20
|
+
usePopupRootSync(store, open);
|
|
26
21
|
useImplicitActiveTrigger(store);
|
|
27
22
|
const {
|
|
28
23
|
forceUnmount
|
|
@@ -34,15 +29,27 @@ export function useDialogRoot(params) {
|
|
|
34
29
|
unmount: forceUnmount,
|
|
35
30
|
close: handleImperativeClose
|
|
36
31
|
}), [forceUnmount, handleImperativeClose]);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
return {
|
|
33
|
+
parentContext,
|
|
34
|
+
isDrawer
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function DialogInteractions({
|
|
38
|
+
store,
|
|
39
|
+
dialogRoot
|
|
40
|
+
}) {
|
|
41
|
+
const {
|
|
42
|
+
parentContext,
|
|
43
|
+
isDrawer
|
|
44
|
+
} = dialogRoot;
|
|
45
|
+
const open = store.useState('open');
|
|
46
|
+
const disablePointerDismissal = store.useState('disablePointerDismissal');
|
|
47
|
+
const modal = store.useState('modal');
|
|
48
|
+
const popupElement = store.useState('popupElement');
|
|
49
|
+
const floatingRootContext = store.useState('floatingRootContext');
|
|
42
50
|
const [ownNestedOpenDialogs, setOwnNestedOpenDialogs] = React.useState(0);
|
|
43
51
|
const [ownNestedOpenDrawers, setOwnNestedOpenDrawers] = React.useState(0);
|
|
44
52
|
const isTopmost = ownNestedOpenDialogs === 0;
|
|
45
|
-
const role = useRole(floatingRootContext);
|
|
46
53
|
const dismiss = useDismiss(floatingRootContext, {
|
|
47
54
|
outsidePressEvent() {
|
|
48
55
|
if (store.context.internalBackdropRef.current || store.context.backdropRef.current) {
|
|
@@ -84,11 +91,6 @@ export function useDialogRoot(params) {
|
|
|
84
91
|
escapeKey: isTopmost
|
|
85
92
|
});
|
|
86
93
|
useScrollLock(open && modal === true, popupElement);
|
|
87
|
-
const {
|
|
88
|
-
getReferenceProps,
|
|
89
|
-
getFloatingProps,
|
|
90
|
-
getTriggerProps
|
|
91
|
-
} = useInteractions([role, dismiss]);
|
|
92
94
|
|
|
93
95
|
// Listen for nested open/close events on this store to maintain the counts.
|
|
94
96
|
store.useContextCallback('onNestedDialogOpen', (dialogCount, drawerCount) => {
|
|
@@ -114,16 +116,15 @@ export function useDialogRoot(params) {
|
|
|
114
116
|
}
|
|
115
117
|
};
|
|
116
118
|
}, [isDrawer, open, ownNestedOpenDialogs, ownNestedOpenDrawers, parentContext]);
|
|
117
|
-
const activeTriggerProps =
|
|
118
|
-
const inactiveTriggerProps =
|
|
119
|
-
const popupProps = React.useMemo(() =>
|
|
120
|
-
store
|
|
121
|
-
openMethod,
|
|
119
|
+
const activeTriggerProps = dismiss.reference ?? EMPTY_OBJECT;
|
|
120
|
+
const inactiveTriggerProps = dismiss.trigger ?? EMPTY_OBJECT;
|
|
121
|
+
const popupProps = React.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, dismiss.floating), [dismiss.floating]);
|
|
122
|
+
usePopupInteractionProps(store, {
|
|
122
123
|
activeTriggerProps,
|
|
123
124
|
inactiveTriggerProps,
|
|
124
125
|
popupProps,
|
|
125
|
-
floatingRootContext,
|
|
126
126
|
nestedOpenDialogCount: ownNestedOpenDialogs,
|
|
127
127
|
nestedOpenDrawerCount: ownNestedOpenDrawers
|
|
128
128
|
});
|
|
129
|
+
return null;
|
|
129
130
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DialogRootProps } from "./DialogRoot.js";
|
|
2
|
+
export declare function useRenderDialogRoot<Payload>(props: DialogRootProps<Payload>, mode?: DialogRootMode): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
type DialogRootMode = 'dialog' | 'drawer' | 'alert-dialog';
|
|
4
|
+
export {};
|