@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
|
@@ -34,9 +34,12 @@ var _useTransitionStatus = require("../../internals/useTransitionStatus");
|
|
|
34
34
|
var _useOpenInteractionType = require("../../utils/useOpenInteractionType");
|
|
35
35
|
var _useValueChanged = require("../../internals/useValueChanged");
|
|
36
36
|
var _noop = require("../../internals/noop");
|
|
37
|
+
var _popups = require("../../utils/popups");
|
|
38
|
+
var _mergeProps = require("../../merge-props");
|
|
37
39
|
var _resolveValueLabel = require("../../internals/resolveValueLabel");
|
|
38
40
|
var _itemEquality = require("../../internals/itemEquality");
|
|
39
41
|
var _constants = require("./utils/constants");
|
|
42
|
+
var _DirectionContext = require("../../internals/direction-context/DirectionContext");
|
|
40
43
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
41
44
|
/**
|
|
42
45
|
* @internal
|
|
@@ -98,6 +101,7 @@ function AriaCombobox(props) {
|
|
|
98
101
|
validationMode,
|
|
99
102
|
validation
|
|
100
103
|
} = (0, _FieldRootContext.useFieldRootContext)();
|
|
104
|
+
const direction = (0, _DirectionContext.useDirection)();
|
|
101
105
|
const id = (0, _useLabelableId.useLabelableId)({
|
|
102
106
|
id: idProp
|
|
103
107
|
});
|
|
@@ -308,6 +312,7 @@ function AriaCombobox(props) {
|
|
|
308
312
|
popupProps: {},
|
|
309
313
|
inputProps: {},
|
|
310
314
|
triggerProps: {},
|
|
315
|
+
itemProps: _empty.EMPTY_OBJECT,
|
|
311
316
|
positionerElement: null,
|
|
312
317
|
listElement: null,
|
|
313
318
|
triggerElement: null,
|
|
@@ -316,6 +321,9 @@ function AriaCombobox(props) {
|
|
|
316
321
|
popupSide: null,
|
|
317
322
|
openMethod: null,
|
|
318
323
|
inputInsidePopup: true,
|
|
324
|
+
// Avoid duplicate names in the server HTML. Popup inputs aren't rendered
|
|
325
|
+
// until after hydration, so the hidden input takes over then if needed.
|
|
326
|
+
inputOwnsFormValue: selectionMode === 'none',
|
|
319
327
|
onOpenChangeComplete: onOpenChangeCompleteProp || _noop.NOOP,
|
|
320
328
|
// Placeholder callbacks replaced on first render
|
|
321
329
|
setOpen: _noop.NOOP,
|
|
@@ -324,7 +332,6 @@ function AriaCombobox(props) {
|
|
|
324
332
|
setIndices: _noop.NOOP,
|
|
325
333
|
onItemHighlighted: _noop.NOOP,
|
|
326
334
|
handleSelection: _noop.NOOP,
|
|
327
|
-
getItemProps: () => _empty.EMPTY_OBJECT,
|
|
328
335
|
forceMount: _noop.NOOP,
|
|
329
336
|
requestSubmit: _noop.NOOP
|
|
330
337
|
})).current;
|
|
@@ -349,6 +356,7 @@ function AriaCombobox(props) {
|
|
|
349
356
|
const inputGroupElement = (0, _store.useStore)(store, _store2.selectors.inputGroupElement);
|
|
350
357
|
const inline = (0, _store.useStore)(store, _store2.selectors.inline);
|
|
351
358
|
const inputInsidePopup = (0, _store.useStore)(store, _store2.selectors.inputInsidePopup);
|
|
359
|
+
const inputOwnsFormValue = (0, _store.useStore)(store, _store2.selectors.inputOwnsFormValue);
|
|
352
360
|
const triggerRef = (0, _useValueAsRef.useValueAsRef)(triggerElement);
|
|
353
361
|
const {
|
|
354
362
|
mounted,
|
|
@@ -359,12 +367,8 @@ function AriaCombobox(props) {
|
|
|
359
367
|
openMethod,
|
|
360
368
|
triggerProps
|
|
361
369
|
} = (0, _useOpenInteractionType.useOpenInteractionType)(open);
|
|
362
|
-
const
|
|
363
|
-
(0, _useRegisterFieldControl.useRegisterFieldControl)(inputInsidePopup ? triggerRef : inputRef,
|
|
364
|
-
id,
|
|
365
|
-
value: fieldRawValue,
|
|
366
|
-
getValue: getFieldValue
|
|
367
|
-
});
|
|
370
|
+
const getStringifiedValueForForm = (0, _useStableCallback.useStableCallback)(() => fieldStringValue);
|
|
371
|
+
(0, _useRegisterFieldControl.useRegisterFieldControl)(inputInsidePopup ? triggerRef : inputRef, id, fieldRawValue, getStringifiedValueForForm);
|
|
368
372
|
const forceMount = (0, _useStableCallback.useStableCallback)(() => {
|
|
369
373
|
if (items) {
|
|
370
374
|
// Ensure typeahead works on a closed list.
|
|
@@ -451,6 +455,16 @@ function AriaCombobox(props) {
|
|
|
451
455
|
if (eventDetails.isCanceled) {
|
|
452
456
|
return;
|
|
453
457
|
}
|
|
458
|
+
|
|
459
|
+
// If reopening interrupts the close animation, handleUnmount won't run to clear the
|
|
460
|
+
// frozen closeQuery and pending popup input.
|
|
461
|
+
if (nextOpen && multiple && inputInsidePopup && !inline && closeQuery !== null) {
|
|
462
|
+
setQueryChangedAfterOpen(false);
|
|
463
|
+
setCloseQuery(null);
|
|
464
|
+
if (inputValue !== '') {
|
|
465
|
+
setInputValue('', (0, _createBaseUIEventDetails.createChangeEventDetails)(_reasons.REASONS.inputClear, eventDetails.event));
|
|
466
|
+
}
|
|
467
|
+
}
|
|
454
468
|
if (!nextOpen && queryChangedAfterOpen) {
|
|
455
469
|
if (single) {
|
|
456
470
|
if (!inline) {
|
|
@@ -461,17 +475,22 @@ function AriaCombobox(props) {
|
|
|
461
475
|
setQueryChangedAfterOpen(false);
|
|
462
476
|
}
|
|
463
477
|
} else if (multiple) {
|
|
464
|
-
if (inline
|
|
478
|
+
if (!inline) {
|
|
479
|
+
// Freeze the current query so filtering remains stable while exiting.
|
|
480
|
+
setCloseQuery(query);
|
|
481
|
+
}
|
|
482
|
+
if (inputInsidePopup) {
|
|
465
483
|
setIndices({
|
|
466
484
|
activeIndex: null
|
|
467
485
|
});
|
|
468
|
-
} else {
|
|
469
|
-
// Freeze the current query so filtering remains stable while exiting.
|
|
470
|
-
setCloseQuery(query);
|
|
471
486
|
}
|
|
487
|
+
|
|
472
488
|
// Clear the input immediately on close while retaining filtering via closeQuery for exit animations
|
|
473
|
-
// if the input is outside the popup.
|
|
474
|
-
|
|
489
|
+
// if the input is outside the popup. When the input is inside the popup, defer the clear until
|
|
490
|
+
// unmount so the filtered list doesn't flash to unfiltered during the exit animation.
|
|
491
|
+
if (!inputInsidePopup || inline) {
|
|
492
|
+
setInputValue('', (0, _createBaseUIEventDetails.createChangeEventDetails)(_reasons.REASONS.inputClear, eventDetails.event));
|
|
493
|
+
}
|
|
475
494
|
}
|
|
476
495
|
}
|
|
477
496
|
setOpenUnwrapped(nextOpen);
|
|
@@ -840,6 +859,7 @@ function AriaCombobox(props) {
|
|
|
840
859
|
// Floating UI tests don't require `role="row"` wrappers, so retains the number API.
|
|
841
860
|
cols: grid ? 2 : 1,
|
|
842
861
|
orientation: grid ? 'horizontal' : undefined,
|
|
862
|
+
rtl: direction === 'rtl',
|
|
843
863
|
disabledIndices: _empty.EMPTY_ARRAY,
|
|
844
864
|
onNavigate(nextActiveIndex, event) {
|
|
845
865
|
// Retain the highlight only while actually transitioning out or closed.
|
|
@@ -858,18 +878,28 @@ function AriaCombobox(props) {
|
|
|
858
878
|
}
|
|
859
879
|
}
|
|
860
880
|
});
|
|
861
|
-
const
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
881
|
+
const inputProps = React.useMemo(() => (0, _mergeProps.mergeProps)(listNavigation.reference, dismiss.reference, click.reference, role.reference), [listNavigation.reference, dismiss.reference, click.reference, role.reference]);
|
|
882
|
+
const popupProps = React.useMemo(() => (0, _mergeProps.mergeProps)(_popups.FOCUSABLE_POPUP_PROPS, listNavigation.floating, dismiss.floating, role.floating), [listNavigation.floating, dismiss.floating, role.floating]);
|
|
883
|
+
const itemProps = React.useMemo(() => {
|
|
884
|
+
const listNavigationItemProps = listNavigation.item;
|
|
885
|
+
if (!listNavigationItemProps) {
|
|
886
|
+
return _empty.EMPTY_OBJECT;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
// Combobox keeps focus on the input; item focus would incorrectly sync
|
|
890
|
+
// list navigation state from DOM focus.
|
|
891
|
+
return {
|
|
892
|
+
...listNavigationItemProps,
|
|
893
|
+
onFocus: undefined
|
|
894
|
+
};
|
|
895
|
+
}, [listNavigation.item]);
|
|
866
896
|
(0, _useOnFirstRender.useOnFirstRender)(() => {
|
|
867
897
|
store.update({
|
|
868
898
|
inline: inlineProp,
|
|
869
|
-
popupProps
|
|
870
|
-
inputProps
|
|
899
|
+
popupProps,
|
|
900
|
+
inputProps,
|
|
871
901
|
triggerProps,
|
|
872
|
-
|
|
902
|
+
itemProps,
|
|
873
903
|
setOpen,
|
|
874
904
|
setInputValue,
|
|
875
905
|
setSelectedValue,
|
|
@@ -889,11 +919,11 @@ function AriaCombobox(props) {
|
|
|
889
919
|
transitionStatus,
|
|
890
920
|
items,
|
|
891
921
|
inline: inlineProp,
|
|
892
|
-
popupProps
|
|
893
|
-
inputProps
|
|
922
|
+
popupProps,
|
|
923
|
+
inputProps,
|
|
894
924
|
triggerProps,
|
|
895
925
|
openMethod,
|
|
896
|
-
|
|
926
|
+
itemProps,
|
|
897
927
|
selectionMode,
|
|
898
928
|
name,
|
|
899
929
|
form,
|
|
@@ -911,9 +941,10 @@ function AriaCombobox(props) {
|
|
|
911
941
|
isItemEqualToValue,
|
|
912
942
|
submitOnItemClick,
|
|
913
943
|
hasInputValue,
|
|
914
|
-
requestSubmit
|
|
944
|
+
requestSubmit,
|
|
945
|
+
inputOwnsFormValue: selectionMode === 'none' && (inlineProp || !store.state.inputInsidePopup)
|
|
915
946
|
});
|
|
916
|
-
}, [store, id, selectedValue, open, mounted, transitionStatus, items,
|
|
947
|
+
}, [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]);
|
|
917
948
|
const hiddenInputRef = (0, _useMergedRefs.useMergedRefs)(inputRefProp, validation.inputRef);
|
|
918
949
|
const itemsContextValue = React.useMemo(() => ({
|
|
919
950
|
query,
|
|
@@ -928,7 +959,7 @@ function AriaCombobox(props) {
|
|
|
928
959
|
return (0, _resolveValueLabel.stringifyAsValue)(fieldRawValue, itemToStringValue);
|
|
929
960
|
}, [fieldRawValue, itemToStringValue]);
|
|
930
961
|
const hasMultipleSelection = multiple && Array.isArray(selectedValue) && selectedValue.length > 0;
|
|
931
|
-
const hiddenInputName = multiple || selectionMode === 'none' ? undefined : name;
|
|
962
|
+
const hiddenInputName = multiple || selectionMode === 'none' && inputOwnsFormValue ? undefined : name;
|
|
932
963
|
const hiddenInputs = React.useMemo(() => {
|
|
933
964
|
if (!multiple || !Array.isArray(selectedValue) || !name) {
|
|
934
965
|
return null;
|
|
@@ -957,7 +988,9 @@ function AriaCombobox(props) {
|
|
|
957
988
|
// Handle browser autofill.
|
|
958
989
|
onChange(event) {
|
|
959
990
|
// Workaround for https://github.com/facebook/react/issues/9023
|
|
960
|
-
if (event.nativeEvent.defaultPrevented) {
|
|
991
|
+
if (event.nativeEvent.defaultPrevented || disabled || readOnly) {
|
|
992
|
+
// Outside Field.Root, the event is not wrapped by mergeProps.
|
|
993
|
+
event.preventBaseUIHandler?.();
|
|
961
994
|
return;
|
|
962
995
|
}
|
|
963
996
|
const nextValue = event.currentTarget.value;
|
package/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/combobox/store.js
CHANGED
|
@@ -51,7 +51,7 @@ const selectors = exports.selectors = {
|
|
|
51
51
|
popupProps: (0, _store.createSelector)(state => state.popupProps),
|
|
52
52
|
inputProps: (0, _store.createSelector)(state => state.inputProps),
|
|
53
53
|
triggerProps: (0, _store.createSelector)(state => state.triggerProps),
|
|
54
|
-
|
|
54
|
+
itemProps: (0, _store.createSelector)(state => state.itemProps),
|
|
55
55
|
positionerElement: (0, _store.createSelector)(state => state.positionerElement),
|
|
56
56
|
listElement: (0, _store.createSelector)(state => state.listElement),
|
|
57
57
|
triggerElement: (0, _store.createSelector)(state => state.triggerElement),
|
|
@@ -60,6 +60,7 @@ const selectors = exports.selectors = {
|
|
|
60
60
|
popupSide: (0, _store.createSelector)(state => state.popupSide),
|
|
61
61
|
openMethod: (0, _store.createSelector)(state => state.openMethod),
|
|
62
62
|
inputInsidePopup: (0, _store.createSelector)(state => state.inputInsidePopup),
|
|
63
|
+
inputOwnsFormValue: (0, _store.createSelector)(state => state.inputOwnsFormValue),
|
|
63
64
|
selectionMode: (0, _store.createSelector)(state => state.selectionMode),
|
|
64
65
|
name: (0, _store.createSelector)(state => state.name),
|
|
65
66
|
form: (0, _store.createSelector)(state => state.form),
|
|
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.ComboboxInternalDismissButton = void 0;
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _useMergedRefs = require("@base-ui/utils/useMergedRefs");
|
|
11
|
-
var _useStableCallback = require("@base-ui/utils/useStableCallback");
|
|
12
11
|
var _visuallyHidden = require("@base-ui/utils/visuallyHidden");
|
|
13
12
|
var _useButton = require("../../internals/use-button");
|
|
14
13
|
var _createBaseUIEventDetails = require("../../internals/createBaseUIEventDetails");
|
|
@@ -27,9 +26,9 @@ const ComboboxInternalDismissButton = exports.ComboboxInternalDismissButton = /*
|
|
|
27
26
|
native: false
|
|
28
27
|
});
|
|
29
28
|
const mergedRef = (0, _useMergedRefs.useMergedRefs)(forwardedRef, buttonRef);
|
|
30
|
-
|
|
29
|
+
function handleDismiss(event) {
|
|
31
30
|
store.state.setOpen(false, (0, _createBaseUIEventDetails.createChangeEventDetails)(_reasons.REASONS.closePress, event.nativeEvent, event.currentTarget));
|
|
32
|
-
}
|
|
31
|
+
}
|
|
33
32
|
const dismissProps = getButtonProps({
|
|
34
33
|
onClick: handleDismiss
|
|
35
34
|
});
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.CSPProvider = CSPProvider;
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _CSPContext = require("
|
|
10
|
+
var _CSPContext = require("../internals/csp-context/CSPContext");
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
/**
|
|
13
13
|
* Provides a default Content Security Policy (CSP) configuration for Base UI components that
|
|
@@ -22,20 +22,15 @@ const DialogClose = exports.DialogClose = /*#__PURE__*/React.forwardRef(function
|
|
|
22
22
|
const {
|
|
23
23
|
render,
|
|
24
24
|
className,
|
|
25
|
+
style,
|
|
25
26
|
disabled = false,
|
|
26
27
|
nativeButton = true,
|
|
27
|
-
style,
|
|
28
28
|
...elementProps
|
|
29
29
|
} = componentProps;
|
|
30
30
|
const {
|
|
31
31
|
store
|
|
32
32
|
} = (0, _DialogRootContext.useDialogRootContext)();
|
|
33
33
|
const open = store.useState('open');
|
|
34
|
-
function handleClick(event) {
|
|
35
|
-
if (open) {
|
|
36
|
-
store.setOpen(false, (0, _createBaseUIEventDetails.createChangeEventDetails)(_reasons.REASONS.closePress, event.nativeEvent));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
34
|
const {
|
|
40
35
|
getButtonProps,
|
|
41
36
|
buttonRef
|
|
@@ -46,6 +41,11 @@ const DialogClose = exports.DialogClose = /*#__PURE__*/React.forwardRef(function
|
|
|
46
41
|
const state = {
|
|
47
42
|
disabled
|
|
48
43
|
};
|
|
44
|
+
function handleClick(event) {
|
|
45
|
+
if (open) {
|
|
46
|
+
store.setOpen(false, (0, _createBaseUIEventDetails.createChangeEventDetails)(_reasons.REASONS.closePress, event.nativeEvent));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
49
|
return (0, _useRenderElement.useRenderElement)('button', componentProps, {
|
|
50
50
|
state,
|
|
51
51
|
ref: [forwardedRef, buttonRef],
|
|
@@ -17,6 +17,7 @@ var _DialogPopupDataAttributes = require("./DialogPopupDataAttributes");
|
|
|
17
17
|
var _DialogPortalContext = require("../portal/DialogPortalContext");
|
|
18
18
|
var _useOpenChangeComplete = require("../../internals/useOpenChangeComplete");
|
|
19
19
|
var _composite = require("../../internals/composite/composite");
|
|
20
|
+
var _popups = require("../../utils/popups");
|
|
20
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
22
|
const stateAttributesMapping = {
|
|
22
23
|
..._popupStateMapping.popupStateMapping,
|
|
@@ -36,11 +37,11 @@ const stateAttributesMapping = {
|
|
|
36
37
|
*/
|
|
37
38
|
const DialogPopup = exports.DialogPopup = /*#__PURE__*/React.forwardRef(function DialogPopup(componentProps, forwardedRef) {
|
|
38
39
|
const {
|
|
40
|
+
render,
|
|
39
41
|
className,
|
|
42
|
+
style,
|
|
40
43
|
finalFocus,
|
|
41
44
|
initialFocus,
|
|
42
|
-
render,
|
|
43
|
-
style,
|
|
44
45
|
...elementProps
|
|
45
46
|
} = componentProps;
|
|
46
47
|
const {
|
|
@@ -59,6 +60,8 @@ const DialogPopup = exports.DialogPopup = /*#__PURE__*/React.forwardRef(function
|
|
|
59
60
|
const titleElementId = store.useState('titleElementId');
|
|
60
61
|
const transitionStatus = store.useState('transitionStatus');
|
|
61
62
|
const role = store.useState('role');
|
|
63
|
+
const floatingId = floatingRootContext.useState('floatingId');
|
|
64
|
+
const popupId = elementProps.id ?? floatingId;
|
|
62
65
|
(0, _DialogPortalContext.useDialogPortalContext)();
|
|
63
66
|
(0, _useOpenChangeComplete.useOpenChangeComplete)({
|
|
64
67
|
open,
|
|
@@ -81,6 +84,7 @@ const DialogPopup = exports.DialogPopup = /*#__PURE__*/React.forwardRef(function
|
|
|
81
84
|
}
|
|
82
85
|
const resolvedInitialFocus = initialFocus === undefined ? defaultInitialFocus : initialFocus;
|
|
83
86
|
const nestedDialogOpen = nestedOpenDialogCount > 0;
|
|
87
|
+
const setPopupElement = store.useStateSetter('popupElement');
|
|
84
88
|
const state = {
|
|
85
89
|
open,
|
|
86
90
|
nested,
|
|
@@ -90,10 +94,11 @@ const DialogPopup = exports.DialogPopup = /*#__PURE__*/React.forwardRef(function
|
|
|
90
94
|
const element = (0, _useRenderElement.useRenderElement)('div', componentProps, {
|
|
91
95
|
state,
|
|
92
96
|
props: [rootPopupProps, {
|
|
97
|
+
id: popupId,
|
|
93
98
|
'aria-labelledby': titleElementId ?? undefined,
|
|
94
99
|
'aria-describedby': descriptionElementId ?? undefined,
|
|
95
100
|
role,
|
|
96
|
-
|
|
101
|
+
..._popups.FOCUSABLE_POPUP_PROPS,
|
|
97
102
|
hidden: !mounted,
|
|
98
103
|
onKeyDown(event) {
|
|
99
104
|
if (_composite.COMPOSITE_KEYS.has(event.key)) {
|
|
@@ -104,7 +109,7 @@ const DialogPopup = exports.DialogPopup = /*#__PURE__*/React.forwardRef(function
|
|
|
104
109
|
[_DialogPopupCssVars.DialogPopupCssVars.nestedDialogs]: nestedOpenDialogCount
|
|
105
110
|
}
|
|
106
111
|
}, elementProps],
|
|
107
|
-
ref: [forwardedRef, store.context.popupRef,
|
|
112
|
+
ref: [forwardedRef, store.context.popupRef, setPopupElement],
|
|
108
113
|
stateAttributesMapping
|
|
109
114
|
});
|
|
110
115
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_floatingUiReact.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
|
/**
|
|
@@ -6,86 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.DialogRoot = DialogRoot;
|
|
9
|
-
exports.IsDrawerContext = void 0;
|
|
10
9
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _useOnFirstRender = require("@base-ui/utils/useOnFirstRender");
|
|
12
|
-
var _useDialogRoot = require("./useDialogRoot");
|
|
13
10
|
var _DialogRootContext = require("./DialogRootContext");
|
|
14
|
-
var
|
|
15
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
const IsDrawerContext = exports.IsDrawerContext = /*#__PURE__*/React.createContext(false);
|
|
17
|
-
|
|
11
|
+
var _useRenderDialogRoot = require("./useRenderDialogRoot");
|
|
18
12
|
/**
|
|
19
13
|
* Groups all parts of the dialog.
|
|
20
14
|
* Doesn't render its own HTML element.
|
|
21
15
|
*
|
|
22
16
|
* Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
|
|
23
17
|
*/
|
|
24
|
-
if (process.env.NODE_ENV !== "production") IsDrawerContext.displayName = "IsDrawerContext";
|
|
25
18
|
function DialogRoot(props) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
open: openProp,
|
|
29
|
-
defaultOpen = false,
|
|
30
|
-
onOpenChange,
|
|
31
|
-
onOpenChangeComplete,
|
|
32
|
-
disablePointerDismissal = false,
|
|
33
|
-
modal = true,
|
|
34
|
-
actionsRef,
|
|
35
|
-
handle,
|
|
36
|
-
triggerId: triggerIdProp,
|
|
37
|
-
defaultTriggerId: defaultTriggerIdProp = null
|
|
38
|
-
} = props;
|
|
39
|
-
const parentDialogRootContext = (0, _DialogRootContext.useDialogRootContext)(true);
|
|
40
|
-
const isDrawer = React.useContext(IsDrawerContext);
|
|
41
|
-
const nested = Boolean(parentDialogRootContext);
|
|
42
|
-
const store = _DialogStore.DialogStore.useStore(handle?.store, {
|
|
43
|
-
open: defaultOpen,
|
|
44
|
-
openProp,
|
|
45
|
-
activeTriggerId: defaultTriggerIdProp,
|
|
46
|
-
triggerIdProp,
|
|
47
|
-
modal,
|
|
48
|
-
disablePointerDismissal,
|
|
49
|
-
nested
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Support initially open state when uncontrolled
|
|
53
|
-
(0, _useOnFirstRender.useOnFirstRender)(() => {
|
|
54
|
-
if (openProp === undefined && store.state.open === false && defaultOpen === true) {
|
|
55
|
-
store.update({
|
|
56
|
-
open: true,
|
|
57
|
-
activeTriggerId: defaultTriggerIdProp
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
store.useControlledProp('openProp', openProp);
|
|
62
|
-
store.useControlledProp('triggerIdProp', triggerIdProp);
|
|
63
|
-
store.useSyncedValues({
|
|
64
|
-
disablePointerDismissal,
|
|
65
|
-
nested,
|
|
66
|
-
modal
|
|
67
|
-
});
|
|
68
|
-
store.useContextCallback('onOpenChange', onOpenChange);
|
|
69
|
-
store.useContextCallback('onOpenChangeComplete', onOpenChangeComplete);
|
|
70
|
-
const payload = store.useState('payload');
|
|
71
|
-
(0, _useDialogRoot.useDialogRoot)({
|
|
72
|
-
store,
|
|
73
|
-
actionsRef,
|
|
74
|
-
parentContext: parentDialogRootContext?.store.context,
|
|
75
|
-
isDrawer,
|
|
76
|
-
onOpenChange,
|
|
77
|
-
triggerIdProp
|
|
78
|
-
});
|
|
79
|
-
const contextValue = React.useMemo(() => ({
|
|
80
|
-
store
|
|
81
|
-
}), [store]);
|
|
82
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(IsDrawerContext.Provider, {
|
|
83
|
-
value: false,
|
|
84
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogRootContext.DialogRootContext.Provider, {
|
|
85
|
-
value: contextValue,
|
|
86
|
-
children: typeof children === 'function' ? children({
|
|
87
|
-
payload
|
|
88
|
-
}) : children
|
|
89
|
-
})
|
|
90
|
-
});
|
|
19
|
+
const mode = React.useContext(_DialogRootContext.IsDrawerContext) ? 'drawer' : 'dialog';
|
|
20
|
+
return (0, _useRenderDialogRoot.useRenderDialogRoot)(props, mode);
|
|
91
21
|
}
|
|
@@ -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;
|
|
@@ -6,10 +6,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.DialogRootContext = void 0;
|
|
9
|
+
exports.IsDrawerContext = exports.DialogRootContext = void 0;
|
|
10
10
|
exports.useDialogRootContext = useDialogRootContext;
|
|
11
11
|
var _formatErrorMessage2 = _interopRequireDefault(require("@base-ui/utils/formatErrorMessage"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
const IsDrawerContext = exports.IsDrawerContext = /*#__PURE__*/React.createContext(false);
|
|
14
|
+
if (process.env.NODE_ENV !== "production") IsDrawerContext.displayName = "IsDrawerContext";
|
|
13
15
|
const DialogRootContext = exports.DialogRootContext = /*#__PURE__*/React.createContext(undefined);
|
|
14
16
|
if (process.env.NODE_ENV !== "production") DialogRootContext.displayName = "DialogRootContext";
|
|
15
17
|
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;
|
|
@@ -5,12 +5,14 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.DialogInteractions = DialogInteractions;
|
|
8
9
|
exports.useDialogRoot = useDialogRoot;
|
|
9
10
|
var React = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _useScrollLock = require("@base-ui/utils/useScrollLock");
|
|
12
|
+
var _empty = require("@base-ui/utils/empty");
|
|
13
|
+
var _mergeProps = require("../../merge-props");
|
|
11
14
|
var _floatingUiReact = require("../../floating-ui-react");
|
|
12
15
|
var _utils = require("../../floating-ui-react/utils");
|
|
13
|
-
var _useOpenInteractionType = require("../../utils/useOpenInteractionType");
|
|
14
16
|
var _createBaseUIEventDetails = require("../../internals/createBaseUIEventDetails");
|
|
15
17
|
var _reasons = require("../../internals/reasons");
|
|
16
18
|
var _popups = require("../../utils/popups");
|
|
@@ -22,13 +24,7 @@ function useDialogRoot(params) {
|
|
|
22
24
|
isDrawer
|
|
23
25
|
} = params;
|
|
24
26
|
const open = store.useState('open');
|
|
25
|
-
|
|
26
|
-
const modal = store.useState('modal');
|
|
27
|
-
const popupElement = store.useState('popupElement');
|
|
28
|
-
const {
|
|
29
|
-
openMethod,
|
|
30
|
-
triggerProps
|
|
31
|
-
} = (0, _useOpenInteractionType.useOpenInteractionType)(open);
|
|
27
|
+
(0, _popups.usePopupRootSync)(store, open);
|
|
32
28
|
(0, _popups.useImplicitActiveTrigger)(store);
|
|
33
29
|
const {
|
|
34
30
|
forceUnmount
|
|
@@ -40,15 +36,27 @@ function useDialogRoot(params) {
|
|
|
40
36
|
unmount: forceUnmount,
|
|
41
37
|
close: handleImperativeClose
|
|
42
38
|
}), [forceUnmount, handleImperativeClose]);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
return {
|
|
40
|
+
parentContext,
|
|
41
|
+
isDrawer
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function DialogInteractions({
|
|
45
|
+
store,
|
|
46
|
+
dialogRoot
|
|
47
|
+
}) {
|
|
48
|
+
const {
|
|
49
|
+
parentContext,
|
|
50
|
+
isDrawer
|
|
51
|
+
} = dialogRoot;
|
|
52
|
+
const open = store.useState('open');
|
|
53
|
+
const disablePointerDismissal = store.useState('disablePointerDismissal');
|
|
54
|
+
const modal = store.useState('modal');
|
|
55
|
+
const popupElement = store.useState('popupElement');
|
|
56
|
+
const floatingRootContext = store.useState('floatingRootContext');
|
|
48
57
|
const [ownNestedOpenDialogs, setOwnNestedOpenDialogs] = React.useState(0);
|
|
49
58
|
const [ownNestedOpenDrawers, setOwnNestedOpenDrawers] = React.useState(0);
|
|
50
59
|
const isTopmost = ownNestedOpenDialogs === 0;
|
|
51
|
-
const role = (0, _floatingUiReact.useRole)(floatingRootContext);
|
|
52
60
|
const dismiss = (0, _floatingUiReact.useDismiss)(floatingRootContext, {
|
|
53
61
|
outsidePressEvent() {
|
|
54
62
|
if (store.context.internalBackdropRef.current || store.context.backdropRef.current) {
|
|
@@ -90,11 +98,6 @@ function useDialogRoot(params) {
|
|
|
90
98
|
escapeKey: isTopmost
|
|
91
99
|
});
|
|
92
100
|
(0, _useScrollLock.useScrollLock)(open && modal === true, popupElement);
|
|
93
|
-
const {
|
|
94
|
-
getReferenceProps,
|
|
95
|
-
getFloatingProps,
|
|
96
|
-
getTriggerProps
|
|
97
|
-
} = (0, _floatingUiReact.useInteractions)([role, dismiss]);
|
|
98
101
|
|
|
99
102
|
// Listen for nested open/close events on this store to maintain the counts.
|
|
100
103
|
store.useContextCallback('onNestedDialogOpen', (dialogCount, drawerCount) => {
|
|
@@ -120,16 +123,15 @@ function useDialogRoot(params) {
|
|
|
120
123
|
}
|
|
121
124
|
};
|
|
122
125
|
}, [isDrawer, open, ownNestedOpenDialogs, ownNestedOpenDrawers, parentContext]);
|
|
123
|
-
const activeTriggerProps =
|
|
124
|
-
const inactiveTriggerProps =
|
|
125
|
-
const popupProps = React.useMemo(() =>
|
|
126
|
-
|
|
127
|
-
openMethod,
|
|
126
|
+
const activeTriggerProps = dismiss.reference ?? _empty.EMPTY_OBJECT;
|
|
127
|
+
const inactiveTriggerProps = dismiss.trigger ?? _empty.EMPTY_OBJECT;
|
|
128
|
+
const popupProps = React.useMemo(() => (0, _mergeProps.mergeProps)(_popups.FOCUSABLE_POPUP_PROPS, dismiss.floating), [dismiss.floating]);
|
|
129
|
+
(0, _popups.usePopupInteractionProps)(store, {
|
|
128
130
|
activeTriggerProps,
|
|
129
131
|
inactiveTriggerProps,
|
|
130
132
|
popupProps,
|
|
131
|
-
floatingRootContext,
|
|
132
133
|
nestedOpenDialogCount: ownNestedOpenDialogs,
|
|
133
134
|
nestedOpenDrawerCount: ownNestedOpenDrawers
|
|
134
135
|
});
|
|
136
|
+
return null;
|
|
135
137
|
}
|
|
@@ -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 {};
|