@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSelector } from '@base-ui/utils/store';
|
|
2
2
|
import { EMPTY_OBJECT } from '@base-ui/utils/empty';
|
|
3
|
+
import { FloatingRootStore } from "../../floating-ui-react/components/FloatingRootStore.js";
|
|
3
4
|
import { getEmptyRootContext } from "../../floating-ui-react/utils/getEmptyRootContext.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -13,6 +14,8 @@ export function createInitialPopupStoreState() {
|
|
|
13
14
|
mounted: false,
|
|
14
15
|
transitionStatus: undefined,
|
|
15
16
|
floatingRootContext: getEmptyRootContext(),
|
|
17
|
+
floatingId: undefined,
|
|
18
|
+
triggerCount: 0,
|
|
16
19
|
preventUnmountingOnClose: false,
|
|
17
20
|
payload: undefined,
|
|
18
21
|
activeTriggerId: null,
|
|
@@ -25,16 +28,45 @@ export function createInitialPopupStoreState() {
|
|
|
25
28
|
popupProps: EMPTY_OBJECT
|
|
26
29
|
};
|
|
27
30
|
}
|
|
31
|
+
export function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
|
|
32
|
+
return new FloatingRootStore({
|
|
33
|
+
open: false,
|
|
34
|
+
transitionStatus: undefined,
|
|
35
|
+
floatingElement: null,
|
|
36
|
+
referenceElement: null,
|
|
37
|
+
triggerElements,
|
|
38
|
+
floatingId,
|
|
39
|
+
syncOnly: true,
|
|
40
|
+
nested,
|
|
41
|
+
onOpenChange: undefined
|
|
42
|
+
});
|
|
43
|
+
}
|
|
28
44
|
const activeTriggerIdSelector = createSelector(state => state.triggerIdProp ?? state.activeTriggerId);
|
|
45
|
+
const openSelector = createSelector(state => state.openProp ?? state.open);
|
|
46
|
+
const popupIdSelector = createSelector(state => {
|
|
47
|
+
const popupId = state.popupElement?.id ?? state.floatingId;
|
|
48
|
+
return popupId || undefined;
|
|
49
|
+
});
|
|
50
|
+
function triggerOwnsOpenPopup(state, triggerId) {
|
|
51
|
+
return triggerId !== undefined && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
|
|
52
|
+
}
|
|
53
|
+
function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
|
|
54
|
+
if (triggerOwnsOpenPopup(state, triggerId)) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return triggerId !== undefined && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
|
|
58
|
+
}
|
|
29
59
|
export const popupStoreSelectors = {
|
|
30
|
-
open:
|
|
60
|
+
open: openSelector,
|
|
31
61
|
mounted: createSelector(state => state.mounted),
|
|
32
62
|
transitionStatus: createSelector(state => state.transitionStatus),
|
|
33
63
|
floatingRootContext: createSelector(state => state.floatingRootContext),
|
|
64
|
+
triggerCount: createSelector(state => state.triggerCount),
|
|
34
65
|
preventUnmountingOnClose: createSelector(state => state.preventUnmountingOnClose),
|
|
35
66
|
payload: createSelector(state => state.payload),
|
|
36
67
|
activeTriggerId: activeTriggerIdSelector,
|
|
37
68
|
activeTriggerElement: createSelector(state => state.mounted ? state.activeTriggerElement : null),
|
|
69
|
+
popupId: popupIdSelector,
|
|
38
70
|
/**
|
|
39
71
|
* Whether the trigger with the given ID was used to open the popup.
|
|
40
72
|
*/
|
|
@@ -42,12 +74,16 @@ export const popupStoreSelectors = {
|
|
|
42
74
|
/**
|
|
43
75
|
* Whether the popup is open and was activated by a trigger with the given ID.
|
|
44
76
|
*/
|
|
45
|
-
isOpenedByTrigger: createSelector((state, triggerId) =>
|
|
77
|
+
isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
|
|
46
78
|
/**
|
|
47
79
|
* Whether the popup is mounted and was activated by a trigger with the given ID.
|
|
48
80
|
*/
|
|
49
81
|
isMountedByTrigger: createSelector((state, triggerId) => triggerId !== undefined && activeTriggerIdSelector(state) === triggerId && state.mounted),
|
|
50
82
|
triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
|
|
83
|
+
/**
|
|
84
|
+
* Popup id for the trigger that currently owns the open popup.
|
|
85
|
+
*/
|
|
86
|
+
triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : undefined),
|
|
51
87
|
popupProps: createSelector(state => state.popupProps),
|
|
52
88
|
popupElement: createSelector(state => state.popupElement),
|
|
53
89
|
positionerElement: createSelector(state => state.positionerElement)
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import * as ReactDOM from 'react-dom';
|
|
5
|
-
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
6
5
|
import { contains, getNextTabbable, getTabbableAfterElement, getTabbableBeforeElement, isOutsideEvent } from "../../floating-ui-react/utils.js";
|
|
7
6
|
import { createChangeEventDetails } from "../../internals/createBaseUIEventDetails.js";
|
|
8
7
|
import { REASONS } from "../../internals/reasons.js";
|
|
@@ -21,14 +20,14 @@ import { REASONS } from "../../internals/reasons.js";
|
|
|
21
20
|
*/
|
|
22
21
|
export function useTriggerFocusGuards(store, triggerElementRef) {
|
|
23
22
|
const preFocusGuardRef = React.useRef(null);
|
|
24
|
-
|
|
23
|
+
function handlePreFocusGuardFocus(event) {
|
|
25
24
|
ReactDOM.flushSync(() => {
|
|
26
25
|
store.setOpen(false, createChangeEventDetails(REASONS.focusOut, event.nativeEvent, event.currentTarget));
|
|
27
26
|
});
|
|
28
27
|
const previousTabbable = getTabbableBeforeElement(preFocusGuardRef.current);
|
|
29
28
|
previousTabbable?.focus();
|
|
30
|
-
}
|
|
31
|
-
|
|
29
|
+
}
|
|
30
|
+
function handleFocusTargetFocus(event) {
|
|
32
31
|
const positionerElement = store.select('positionerElement');
|
|
33
32
|
if (positionerElement && isOutsideEvent(event, positionerElement)) {
|
|
34
33
|
store.context.beforeContentFocusGuardRef.current?.focus();
|
|
@@ -46,7 +45,7 @@ export function useTriggerFocusGuards(store, triggerElementRef) {
|
|
|
46
45
|
}
|
|
47
46
|
nextTabbable?.focus();
|
|
48
47
|
}
|
|
49
|
-
}
|
|
48
|
+
}
|
|
50
49
|
return {
|
|
51
50
|
preFocusGuardRef,
|
|
52
51
|
handlePreFocusGuardFocus,
|
|
@@ -220,6 +220,11 @@ export interface UseAnchorPositioningParameters extends UseAnchorPositioningShar
|
|
|
220
220
|
shiftCrossAxis?: boolean | undefined;
|
|
221
221
|
lazyFlip?: boolean | undefined;
|
|
222
222
|
externalTree?: FloatingTreeStore | undefined;
|
|
223
|
+
/**
|
|
224
|
+
* Optional middleware that can replace the measured reference rect before offsets and collision
|
|
225
|
+
* middleware run. Used by Preview Card to position against a specific inline line box.
|
|
226
|
+
*/
|
|
227
|
+
inline?: Middleware | undefined;
|
|
223
228
|
}
|
|
224
229
|
export interface UseAnchorPositioningReturnValue {
|
|
225
230
|
positionerStyles: React.CSSProperties;
|
|
@@ -59,6 +59,7 @@ export function useAnchorPositioning(params) {
|
|
|
59
59
|
sticky = false,
|
|
60
60
|
arrowPadding = 5,
|
|
61
61
|
disableAnchorTracking = false,
|
|
62
|
+
inline: inlineMiddleware,
|
|
62
63
|
// Private parameters
|
|
63
64
|
keepMounted = false,
|
|
64
65
|
floatingRootContext,
|
|
@@ -133,7 +134,11 @@ export function useAnchorPositioning(params) {
|
|
|
133
134
|
const alignOffsetRef = useValueAsRef(alignOffset);
|
|
134
135
|
const sideOffsetDep = typeof sideOffset !== 'function' ? sideOffset : 0;
|
|
135
136
|
const alignOffsetDep = typeof alignOffset !== 'function' ? alignOffset : 0;
|
|
136
|
-
const middleware = [
|
|
137
|
+
const middleware = [];
|
|
138
|
+
if (inlineMiddleware) {
|
|
139
|
+
middleware.push(inlineMiddleware);
|
|
140
|
+
}
|
|
141
|
+
middleware.push(offset(state => {
|
|
137
142
|
const data = getOffsetData(state, sideParam, isRtl);
|
|
138
143
|
const sideAxis = typeof sideOffsetRef.current === 'function' ? sideOffsetRef.current(data) : sideOffsetRef.current;
|
|
139
144
|
const alignAxis = typeof alignOffsetRef.current === 'function' ? alignOffsetRef.current(data) : alignOffsetRef.current;
|
|
@@ -142,7 +147,7 @@ export function useAnchorPositioning(params) {
|
|
|
142
147
|
crossAxis: alignAxis,
|
|
143
148
|
alignmentAxis: alignAxis
|
|
144
149
|
};
|
|
145
|
-
}, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])
|
|
150
|
+
}, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
|
|
146
151
|
const shiftDisabled = collisionAvoidanceAlign === 'none' && collisionAvoidanceSide !== 'shift';
|
|
147
152
|
const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === 'shift');
|
|
148
153
|
const flipMiddleware = collisionAvoidanceSide === 'none' ? null : flip({
|
|
@@ -227,10 +232,10 @@ export function useAnchorPositioning(params) {
|
|
|
227
232
|
floatingStyle.setProperty('--anchor-width', `${anchorWidth}px`);
|
|
228
233
|
floatingStyle.setProperty('--anchor-height', `${anchorHeight}px`);
|
|
229
234
|
}
|
|
230
|
-
}), arrow(
|
|
235
|
+
}), arrow(state => ({
|
|
231
236
|
// `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
|
|
232
237
|
// we'll create a fake element.
|
|
233
|
-
element: arrowRef.current || ownerDocument(
|
|
238
|
+
element: arrowRef.current || ownerDocument(state.elements.floating).createElement('div'),
|
|
234
239
|
padding: arrowPadding,
|
|
235
240
|
offsetParent: 'floating'
|
|
236
241
|
}), [arrowPadding]), {
|
|
@@ -367,11 +372,9 @@ export function useAnchorPositioning(params) {
|
|
|
367
372
|
const renderedAlign = getAlignment(renderedPlacement) || 'center';
|
|
368
373
|
const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
|
|
369
374
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
* the size of the popup dynamically to avoid unwanted flipping when typing.
|
|
374
|
-
*/
|
|
375
|
+
// Locks the flip (makes it "sticky") so it doesn't prefer a given placement
|
|
376
|
+
// and flips back lazily, not eagerly. Ideal for filtered lists that change
|
|
377
|
+
// the size of the popup dynamically to avoid unwanted flipping when typing.
|
|
375
378
|
useIsoLayoutEffect(() => {
|
|
376
379
|
if (lazyFlip && mounted && isPositioned) {
|
|
377
380
|
setMountSide(renderedSide);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { InteractionType } from '@base-ui/utils/useEnhancedClickHandler';
|
|
3
|
+
export declare function useOpenMethodTriggerProps(open: boolean | (() => boolean), setOpenMethod: (interactionType: InteractionType | null) => void): {
|
|
4
|
+
onClick: (event: React.MouseEvent | React.PointerEvent) => void;
|
|
5
|
+
onPointerDown: (event: React.PointerEvent) => void;
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* Determines the interaction type (keyboard, mouse, touch, etc.) that opened the component.
|
|
5
9
|
*
|
|
@@ -5,16 +5,10 @@ import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
|
5
5
|
import { useEnhancedClickHandler } from '@base-ui/utils/useEnhancedClickHandler';
|
|
6
6
|
import { isIOS } from '@base-ui/utils/detectBrowser';
|
|
7
7
|
import { useValueChanged } from "../internals/useValueChanged.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Determines the interaction type (keyboard, mouse, touch, etc.) that opened the component.
|
|
11
|
-
*
|
|
12
|
-
* @param open The open state of the component.
|
|
13
|
-
*/
|
|
14
|
-
export function useOpenInteractionType(open) {
|
|
15
|
-
const [openMethod, setOpenMethod] = React.useState(null);
|
|
8
|
+
export function useOpenMethodTriggerProps(open, setOpenMethod) {
|
|
16
9
|
const handleTriggerClick = useStableCallback((_, interactionType) => {
|
|
17
|
-
|
|
10
|
+
const isOpen = typeof open === 'function' ? open() : open;
|
|
11
|
+
if (!isOpen) {
|
|
18
12
|
setOpenMethod(interactionType || (
|
|
19
13
|
// On iOS Safari, the hitslop around touch targets means tapping outside an element's
|
|
20
14
|
// bounds does not fire `pointerdown` but does fire `mousedown`. The `interactionType`
|
|
@@ -22,20 +16,31 @@ export function useOpenInteractionType(open) {
|
|
|
22
16
|
isIOS ? 'touch' : ''));
|
|
23
17
|
}
|
|
24
18
|
});
|
|
19
|
+
const {
|
|
20
|
+
onClick,
|
|
21
|
+
onPointerDown
|
|
22
|
+
} = useEnhancedClickHandler(handleTriggerClick);
|
|
23
|
+
return React.useMemo(() => ({
|
|
24
|
+
onClick,
|
|
25
|
+
onPointerDown
|
|
26
|
+
}), [onClick, onPointerDown]);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Determines the interaction type (keyboard, mouse, touch, etc.) that opened the component.
|
|
31
|
+
*
|
|
32
|
+
* @param open The open state of the component.
|
|
33
|
+
*/
|
|
34
|
+
export function useOpenInteractionType(open) {
|
|
35
|
+
const [openMethod, setOpenMethod] = React.useState(null);
|
|
36
|
+
const triggerProps = useOpenMethodTriggerProps(open, setOpenMethod);
|
|
25
37
|
useValueChanged(open, previousOpen => {
|
|
26
38
|
if (previousOpen && !open) {
|
|
27
39
|
setOpenMethod(null);
|
|
28
40
|
}
|
|
29
41
|
});
|
|
30
|
-
const {
|
|
31
|
-
onClick,
|
|
32
|
-
onPointerDown
|
|
33
|
-
} = useEnhancedClickHandler(handleTriggerClick);
|
|
34
42
|
return React.useMemo(() => ({
|
|
35
43
|
openMethod,
|
|
36
|
-
triggerProps
|
|
37
|
-
|
|
38
|
-
onPointerDown
|
|
39
|
-
}
|
|
40
|
-
}), [openMethod, onClick, onPointerDown]);
|
|
44
|
+
triggerProps
|
|
45
|
+
}), [openMethod, triggerProps]);
|
|
41
46
|
}
|
|
@@ -90,12 +90,8 @@ const FieldControl = exports.FieldControl = /*#__PURE__*/React.forwardRef(functi
|
|
|
90
90
|
});
|
|
91
91
|
const isControlled = valueProp !== undefined;
|
|
92
92
|
const value = isControlled ? valueUnwrapped : undefined;
|
|
93
|
-
const
|
|
94
|
-
(0, _useRegisterFieldControl.useRegisterFieldControl)(validation.inputRef,
|
|
95
|
-
id,
|
|
96
|
-
value,
|
|
97
|
-
getValue: getFieldValue
|
|
98
|
-
});
|
|
93
|
+
const getValueFromInput = (0, _useStableCallback.useStableCallback)(() => validation.inputRef.current?.value);
|
|
94
|
+
(0, _useRegisterFieldControl.useRegisterFieldControl)(validation.inputRef, id, value, getValueFromInput);
|
|
99
95
|
const element = (0, _useRenderElement.useRenderElement)('input', componentProps, {
|
|
100
96
|
ref: [forwardedRef, inputRef],
|
|
101
97
|
state,
|
package/field/item/FieldItem.js
CHANGED
|
@@ -34,11 +34,8 @@ const FieldItem = exports.FieldItem = /*#__PURE__*/React.forwardRef(function Fie
|
|
|
34
34
|
} = (0, _FieldRootContext.useFieldRootContext)(false);
|
|
35
35
|
const disabled = rootDisabled || disabledProp;
|
|
36
36
|
const checkboxGroupContext = (0, _CheckboxGroupContext.useCheckboxGroupContext)();
|
|
37
|
-
// checkboxGroupContext.parent is truthy even if no parent checkbox is involved
|
|
38
|
-
const parentId = checkboxGroupContext?.parent.id;
|
|
39
|
-
// this a more reliable check
|
|
40
37
|
const hasParentCheckbox = checkboxGroupContext?.allValues !== undefined;
|
|
41
|
-
const controlId = hasParentCheckbox ?
|
|
38
|
+
const controlId = hasParentCheckbox ? checkboxGroupContext?.parent.id : undefined;
|
|
42
39
|
const fieldItemContext = React.useMemo(() => ({
|
|
43
40
|
disabled
|
|
44
41
|
}), [disabled]);
|
package/field/root/FieldRoot.js
CHANGED
|
@@ -52,6 +52,11 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
52
52
|
const dirty = dirtyProp ?? dirtyState;
|
|
53
53
|
const touched = touchedProp ?? touchedState;
|
|
54
54
|
const markedDirtyRef = React.useRef(false);
|
|
55
|
+
const registeredFieldIdRef = React.useRef(undefined);
|
|
56
|
+
const getRegisteredFieldId = React.useCallback(() => registeredFieldIdRef.current, []);
|
|
57
|
+
const setRegisteredFieldId = React.useCallback(id => {
|
|
58
|
+
registeredFieldIdRef.current = id;
|
|
59
|
+
}, []);
|
|
55
60
|
const setDirty = (0, _useStableCallback.useStableCallback)(value => {
|
|
56
61
|
if (dirtyProp !== undefined) {
|
|
57
62
|
return;
|
|
@@ -95,17 +100,20 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
95
100
|
markedDirtyRef,
|
|
96
101
|
state,
|
|
97
102
|
name,
|
|
98
|
-
shouldValidateOnChange
|
|
103
|
+
shouldValidateOnChange,
|
|
104
|
+
getRegisteredFieldId
|
|
99
105
|
});
|
|
106
|
+
const validityValue = validityData.value;
|
|
100
107
|
const handleImperativeValidate = React.useCallback(() => {
|
|
101
108
|
markedDirtyRef.current = true;
|
|
102
|
-
validation.commit(
|
|
103
|
-
}, [validation,
|
|
109
|
+
validation.commit(validityValue);
|
|
110
|
+
}, [validation, validityValue]);
|
|
104
111
|
const registerFieldControl = (0, _useFieldControlRegistration.useFieldControlRegistration)({
|
|
105
112
|
commit: validation.commit,
|
|
106
113
|
invalid,
|
|
107
114
|
markedDirtyRef,
|
|
108
115
|
name,
|
|
116
|
+
setRegisteredFieldId,
|
|
109
117
|
setValidityData,
|
|
110
118
|
validityData
|
|
111
119
|
});
|
|
@@ -13,6 +13,7 @@ export interface UseFieldValidationParameters {
|
|
|
13
13
|
state: FieldRootState;
|
|
14
14
|
name: string | undefined;
|
|
15
15
|
shouldValidateOnChange: () => boolean;
|
|
16
|
+
getRegisteredFieldId: () => string | undefined;
|
|
16
17
|
}
|
|
17
18
|
export interface UseFieldValidationReturnValue {
|
|
18
19
|
getValidationProps: (props?: HTMLProps) => HTMLProps;
|
|
@@ -48,7 +48,8 @@ function useFieldValidation(params) {
|
|
|
48
48
|
markedDirtyRef,
|
|
49
49
|
state,
|
|
50
50
|
name,
|
|
51
|
-
shouldValidateOnChange
|
|
51
|
+
shouldValidateOnChange,
|
|
52
|
+
getRegisteredFieldId
|
|
52
53
|
} = params;
|
|
53
54
|
const {
|
|
54
55
|
controlId,
|
|
@@ -61,6 +62,21 @@ function useFieldValidation(params) {
|
|
|
61
62
|
if (!element) {
|
|
62
63
|
return;
|
|
63
64
|
}
|
|
65
|
+
function updateRegisteredFieldValidity(nextValidityData, externalInvalid = invalid) {
|
|
66
|
+
const fieldId = getRegisteredFieldId() ?? controlId;
|
|
67
|
+
if (fieldId == null) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const currentFieldData = formRef.current.fields.get(fieldId);
|
|
71
|
+
if (!currentFieldData) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const validityDataWithFormErrors = (0, _getCombinedFieldValidityData.getCombinedFieldValidityData)(nextValidityData, externalInvalid);
|
|
75
|
+
formRef.current.fields.set(fieldId, {
|
|
76
|
+
...currentFieldData,
|
|
77
|
+
validityData: validityDataWithFormErrors
|
|
78
|
+
});
|
|
79
|
+
}
|
|
64
80
|
if (revalidate) {
|
|
65
81
|
if (state.valid !== false) {
|
|
66
82
|
return;
|
|
@@ -81,15 +97,9 @@ function useFieldValidation(params) {
|
|
|
81
97
|
initialValue: validityData.initialValue
|
|
82
98
|
};
|
|
83
99
|
element.setCustomValidity('');
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
formRef.current.fields.set(controlId, {
|
|
88
|
-
...currentFieldData,
|
|
89
|
-
...(0, _getCombinedFieldValidityData.getCombinedFieldValidityData)(nextValidityData, false) // invalid = false
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
100
|
+
|
|
101
|
+
// The required value is now present; ignore stale external invalid state for this pass.
|
|
102
|
+
updateRegisteredFieldValidity(nextValidityData, false);
|
|
93
103
|
setValidityData(nextValidityData);
|
|
94
104
|
return;
|
|
95
105
|
}
|
|
@@ -192,16 +202,9 @@ function useFieldValidation(params) {
|
|
|
192
202
|
errors: validationErrors,
|
|
193
203
|
initialValue: validityData.initialValue
|
|
194
204
|
};
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
formRef.current.fields.set(controlId, {
|
|
199
|
-
...currentFieldData,
|
|
200
|
-
// Keep Form-level errors part of overall field validity for submit blocking/focus logic.
|
|
201
|
-
...(0, _getCombinedFieldValidityData.getCombinedFieldValidityData)(nextValidityData, invalid)
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
+
|
|
206
|
+
// Keep Form-level errors part of overall field validity for submit blocking/focus logic.
|
|
207
|
+
updateRegisteredFieldValidity(nextValidityData);
|
|
205
208
|
setValidityData(nextValidityData);
|
|
206
209
|
});
|
|
207
210
|
const getValidationProps = React.useCallback((externalProps = {}) => (0, _mergeProps.mergeProps)(getDescriptionProps, state.valid === false ? {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { FieldValidityData } from "../root/FieldRoot.js";
|
|
2
|
+
import type { FieldValidityData } from "../root/FieldRoot.js";
|
|
3
3
|
import { type TransitionStatus } from "../../internals/useTransitionStatus.js";
|
|
4
4
|
/**
|
|
5
5
|
* Used to display a custom message based on the field's validity.
|
|
@@ -75,11 +75,11 @@ function FloatingDelayGroup(props) {
|
|
|
75
75
|
function useDelayGroup(context, options = {
|
|
76
76
|
open: false
|
|
77
77
|
}) {
|
|
78
|
-
const store = 'rootStore' in context ? context.rootStore : context;
|
|
79
|
-
const floatingId = store.useState('floatingId');
|
|
80
78
|
const {
|
|
81
79
|
open
|
|
82
80
|
} = options;
|
|
81
|
+
const store = 'rootStore' in context ? context.rootStore : context;
|
|
82
|
+
const floatingId = store.useState('floatingId');
|
|
83
83
|
const groupContext = React.useContext(FloatingDelayGroupContext);
|
|
84
84
|
const {
|
|
85
85
|
currentIdRef,
|
|
@@ -148,7 +148,7 @@ function useDelayGroup(context, options = {
|
|
|
148
148
|
setIsInstantPhase(false);
|
|
149
149
|
prevContext?.setIsInstantPhase(false);
|
|
150
150
|
}
|
|
151
|
-
}, [open, floatingId, store, currentIdRef, delayRef,
|
|
151
|
+
}, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
|
|
152
152
|
(0, _useIsoLayoutEffect.useIsoLayoutEffect)(() => {
|
|
153
153
|
return () => {
|
|
154
154
|
currentContextRef.current = null;
|
|
@@ -83,7 +83,7 @@ export interface FloatingFocusManagerProps {
|
|
|
83
83
|
*/
|
|
84
84
|
beforeContentFocusGuardRef?: React.RefObject<HTMLSpanElement | null> | undefined;
|
|
85
85
|
/**
|
|
86
|
-
* External
|
|
86
|
+
* External FloatingTree to use when the one provided by context can't be used.
|
|
87
87
|
*/
|
|
88
88
|
externalTree?: FloatingTreeStore | undefined;
|
|
89
89
|
/**
|
|
@@ -186,7 +186,7 @@ function FloatingFocusManager(props) {
|
|
|
186
186
|
}
|
|
187
187
|
const doc = (0, _owner.ownerDocument)(floatingFocusElement);
|
|
188
188
|
return (0, _addEventListener.addEventListener)(doc, 'keydown', onKeyDown);
|
|
189
|
-
}, [disabled,
|
|
189
|
+
}, [disabled, floatingFocusElement, modal, isUntrappedTypeableCombobox, getTabbableContent]);
|
|
190
190
|
|
|
191
191
|
// Track pointer/keyboard interactions to disambiguate focus and outside presses.
|
|
192
192
|
React.useEffect(() => {
|
|
@@ -335,7 +335,7 @@ function FloatingFocusManager(props) {
|
|
|
335
335
|
markerCleanup();
|
|
336
336
|
ariaHiddenCleanup();
|
|
337
337
|
};
|
|
338
|
-
}, [open, disabled, domReference, floating, modal,
|
|
338
|
+
}, [open, disabled, domReference, floating, modal, portalContext, isUntrappedTypeableCombobox, tree, getNodeId, nextFocusableElement, previousFocusableElement, getResolvedInsideElements]);
|
|
339
339
|
|
|
340
340
|
// Focus the initial element when the floating element opens.
|
|
341
341
|
(0, _useIsoLayoutEffect.useIsoLayoutEffect)(() => {
|
|
@@ -372,11 +372,20 @@ function FloatingFocusManager(props) {
|
|
|
372
372
|
elToFocus = (0, _resolveRef.resolveRef)(resolvedInitialFocus);
|
|
373
373
|
}
|
|
374
374
|
elToFocus = elToFocus || getDefaultFocusElement();
|
|
375
|
+
const hadFocusInside = (0, _element.contains)(floatingFocusElement, (0, _element.activeElement)(doc));
|
|
375
376
|
(0, _enqueueFocus.enqueueFocus)(elToFocus, {
|
|
376
|
-
preventScroll: elToFocus === floatingFocusElement
|
|
377
|
+
preventScroll: elToFocus === floatingFocusElement,
|
|
378
|
+
shouldFocus() {
|
|
379
|
+
if (hadFocusInside) {
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
const currentActiveElement = (0, _element.activeElement)(doc);
|
|
383
|
+
const focusMovedInside = currentActiveElement !== elToFocus && (0, _element.contains)(floatingFocusElement, currentActiveElement);
|
|
384
|
+
return !focusMovedInside;
|
|
385
|
+
}
|
|
377
386
|
});
|
|
378
387
|
});
|
|
379
|
-
}, [disabled, open, floatingFocusElement,
|
|
388
|
+
}, [disabled, open, floatingFocusElement, getTabbableContent, initialFocusRef, openInteractionTypeRef]);
|
|
380
389
|
|
|
381
390
|
// Track return focus targets and restore focus on unmount/close.
|
|
382
391
|
(0, _useIsoLayoutEffect.useIsoLayoutEffect)(() => {
|
|
@@ -431,10 +440,12 @@ function FloatingFocusManager(props) {
|
|
|
431
440
|
resolvedReturnFocusValue = true;
|
|
432
441
|
}
|
|
433
442
|
if (typeof resolvedReturnFocusValue === 'boolean') {
|
|
434
|
-
|
|
435
|
-
|
|
443
|
+
if (domReference?.isConnected) {
|
|
444
|
+
return domReference;
|
|
445
|
+
}
|
|
446
|
+
return getPreviouslyFocusedElement() || null;
|
|
436
447
|
}
|
|
437
|
-
const fallback = domReference
|
|
448
|
+
const fallback = domReference?.isConnected ? domReference : getPreviouslyFocusedElement();
|
|
438
449
|
return (0, _resolveRef.resolveRef)(resolvedReturnFocusValue) || fallback || null;
|
|
439
450
|
}
|
|
440
451
|
return () => {
|
|
@@ -462,7 +473,7 @@ function FloatingFocusManager(props) {
|
|
|
462
473
|
preventReturnFocusRef.current = false;
|
|
463
474
|
});
|
|
464
475
|
};
|
|
465
|
-
}, [disabled, floating, floatingFocusElement, returnFocusRef,
|
|
476
|
+
}, [disabled, floating, floatingFocusElement, returnFocusRef, events, tree, domReference, getNodeId, getResolvedInsideElements]);
|
|
466
477
|
|
|
467
478
|
// Safari may randomly scroll to the bottom of the page if an input inside a popup has focus
|
|
468
479
|
// when the popup unmounts from the DOM.
|
|
@@ -479,6 +490,7 @@ function FloatingFocusManager(props) {
|
|
|
479
490
|
activeEl.blur();
|
|
480
491
|
}
|
|
481
492
|
}, [open, floating]);
|
|
493
|
+
|
|
482
494
|
// Synchronize the `context` & `modal` value to the FloatingPortal context.
|
|
483
495
|
// It will decide whether or not it needs to render its own guards.
|
|
484
496
|
(0, _useIsoLayoutEffect.useIsoLayoutEffect)(() => {
|
|
@@ -109,12 +109,12 @@ function useFloatingPortalNode(props = {}) {
|
|
|
109
109
|
*/
|
|
110
110
|
const FloatingPortal = exports.FloatingPortal = /*#__PURE__*/React.forwardRef(function FloatingPortal(componentProps, forwardedRef) {
|
|
111
111
|
const {
|
|
112
|
+
render,
|
|
113
|
+
className,
|
|
114
|
+
style,
|
|
112
115
|
children,
|
|
113
116
|
container,
|
|
114
|
-
className,
|
|
115
|
-
render,
|
|
116
117
|
renderGuards,
|
|
117
|
-
style,
|
|
118
118
|
...elementProps
|
|
119
119
|
} = componentProps;
|
|
120
120
|
const {
|