@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
|
@@ -121,6 +121,8 @@ function evaluateRenderProp(element, render, props, state) {
|
|
|
121
121
|
// so we can throw before with custom message.
|
|
122
122
|
if (process.env.NODE_ENV !== 'production') {
|
|
123
123
|
if (! /*#__PURE__*/React.isValidElement(newElement)) {
|
|
124
|
+
// TODO: fix mui/no-guarded-throw
|
|
125
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
124
126
|
throw new Error(['Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.', 'A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.', 'https://base-ui.com/r/invalid-render-prop'].join('\n'));
|
|
125
127
|
}
|
|
126
128
|
}
|
|
@@ -14,8 +14,8 @@ import { popupStateMapping } from "../../utils/popupStateMapping.js";
|
|
|
14
14
|
*/
|
|
15
15
|
export const MenuArrow = /*#__PURE__*/React.forwardRef(function MenuArrow(componentProps, forwardedRef) {
|
|
16
16
|
const {
|
|
17
|
-
className,
|
|
18
17
|
render,
|
|
18
|
+
className,
|
|
19
19
|
style,
|
|
20
20
|
...elementProps
|
|
21
21
|
} = componentProps;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
5
4
|
import { useControlled } from '@base-ui/utils/useControlled';
|
|
6
5
|
import { MenuCheckboxItemContext } from "./MenuCheckboxItemContext.js";
|
|
7
6
|
import { REGULAR_ITEM, useMenuItem } from "../item/useMenuItem.js";
|
|
@@ -69,17 +68,16 @@ export const MenuCheckboxItem = /*#__PURE__*/React.forwardRef(function MenuCheck
|
|
|
69
68
|
highlighted,
|
|
70
69
|
checked
|
|
71
70
|
}), [disabled, highlighted, checked]);
|
|
72
|
-
|
|
73
|
-
const details = {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
71
|
+
function handleClick(event) {
|
|
72
|
+
const details = createChangeEventDetails(REASONS.itemPress, event.nativeEvent, undefined, {
|
|
73
|
+
preventUnmountOnClose() {}
|
|
74
|
+
});
|
|
77
75
|
onCheckedChange?.(!checked, details);
|
|
78
76
|
if (details.isCanceled) {
|
|
79
77
|
return;
|
|
80
78
|
}
|
|
81
79
|
setChecked(currentlyChecked => !currentlyChecked);
|
|
82
|
-
}
|
|
80
|
+
}
|
|
83
81
|
const element = useRenderElement('div', componentProps, {
|
|
84
82
|
state,
|
|
85
83
|
stateAttributesMapping: itemMapping,
|
|
@@ -19,9 +19,6 @@ export const MenuGroup = /*#__PURE__*/React.forwardRef(function MenuGroup(compon
|
|
|
19
19
|
...elementProps
|
|
20
20
|
} = componentProps;
|
|
21
21
|
const [labelId, setLabelId] = React.useState(undefined);
|
|
22
|
-
const context = React.useMemo(() => ({
|
|
23
|
-
setLabelId
|
|
24
|
-
}), [setLabelId]);
|
|
25
22
|
const element = useRenderElement('div', componentProps, {
|
|
26
23
|
ref: forwardedRef,
|
|
27
24
|
props: {
|
|
@@ -31,7 +28,7 @@ export const MenuGroup = /*#__PURE__*/React.forwardRef(function MenuGroup(compon
|
|
|
31
28
|
}
|
|
32
29
|
});
|
|
33
30
|
return /*#__PURE__*/_jsx(MenuGroupContext.Provider, {
|
|
34
|
-
value:
|
|
31
|
+
value: setLabelId,
|
|
35
32
|
children: element
|
|
36
33
|
});
|
|
37
34
|
});
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export
|
|
3
|
-
setLabelId: (id: string | undefined) => void;
|
|
4
|
-
}
|
|
2
|
+
export type MenuGroupContext = (id: string | undefined) => void;
|
|
5
3
|
export declare const MenuGroupContext: React.Context<MenuGroupContext | undefined>;
|
|
6
4
|
export declare function useMenuGroupRootContext(): MenuGroupContext;
|
|
@@ -7,7 +7,7 @@ if (process.env.NODE_ENV !== "production") MenuGroupContext.displayName = "MenuG
|
|
|
7
7
|
export function useMenuGroupRootContext() {
|
|
8
8
|
const context = React.useContext(MenuGroupContext);
|
|
9
9
|
if (context === undefined) {
|
|
10
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI:
|
|
10
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: MenuGroupContext is missing. Menu group parts must be used within <Menu.Group> or <Menu.RadioGroup>.' : _formatErrorMessage(31));
|
|
11
11
|
}
|
|
12
12
|
return context;
|
|
13
13
|
}
|
|
@@ -12,18 +12,16 @@ import { useMenuGroupRootContext } from "../group/MenuGroupContext.js";
|
|
|
12
12
|
*
|
|
13
13
|
* Documentation: [Base UI Menu](https://base-ui.com/react/components/menu)
|
|
14
14
|
*/
|
|
15
|
-
export const MenuGroupLabel = /*#__PURE__*/React.forwardRef(function
|
|
15
|
+
export const MenuGroupLabel = /*#__PURE__*/React.forwardRef(function MenuGroupLabel(componentProps, forwardedRef) {
|
|
16
16
|
const {
|
|
17
|
-
className,
|
|
18
17
|
render,
|
|
19
|
-
|
|
18
|
+
className,
|
|
20
19
|
style,
|
|
20
|
+
id: idProp,
|
|
21
21
|
...elementProps
|
|
22
22
|
} = componentProps;
|
|
23
23
|
const id = useBaseUiId(idProp);
|
|
24
|
-
const
|
|
25
|
-
setLabelId
|
|
26
|
-
} = useMenuGroupRootContext();
|
|
24
|
+
const setLabelId = useMenuGroupRootContext();
|
|
27
25
|
useIsoLayoutEffect(() => {
|
|
28
26
|
setLabelId(id);
|
|
29
27
|
return () => {
|
|
@@ -58,9 +58,9 @@ export const MenuLinkItem = /*#__PURE__*/React.forwardRef(function MenuLinkItem(
|
|
|
58
58
|
function getItemProps(externalProps) {
|
|
59
59
|
return mergeProps(commonProps, externalProps, getButtonProps);
|
|
60
60
|
}
|
|
61
|
-
const state =
|
|
61
|
+
const state = {
|
|
62
62
|
highlighted
|
|
63
|
-
}
|
|
63
|
+
};
|
|
64
64
|
return useRenderElement('a', componentProps, {
|
|
65
65
|
state,
|
|
66
66
|
props: [itemProps, elementProps, getItemProps],
|
|
@@ -54,6 +54,8 @@ export const MenuPopup = /*#__PURE__*/React.forwardRef(function MenuPopup(compon
|
|
|
54
54
|
const floatingTreeRoot = store.useState('floatingTreeRoot');
|
|
55
55
|
const closeDelay = store.useState('closeDelay');
|
|
56
56
|
const activeTriggerElement = store.useState('activeTriggerElement');
|
|
57
|
+
const hoverEnabled = store.useState('hoverEnabled');
|
|
58
|
+
const disabled = store.useState('disabled');
|
|
57
59
|
const isContextMenu = parent.type === 'context-menu';
|
|
58
60
|
useOpenChangeComplete({
|
|
59
61
|
open,
|
|
@@ -73,12 +75,13 @@ export const MenuPopup = /*#__PURE__*/React.forwardRef(function MenuPopup(compon
|
|
|
73
75
|
floatingTreeRoot.events.off('close', handleClose);
|
|
74
76
|
};
|
|
75
77
|
}, [floatingTreeRoot.events, store]);
|
|
76
|
-
const hoverEnabled = store.useState('hoverEnabled');
|
|
77
|
-
const disabled = store.useState('disabled');
|
|
78
78
|
useHoverFloatingInteraction(floatingContext, {
|
|
79
79
|
enabled: hoverEnabled && !disabled && !isContextMenu && parent.type !== 'menubar',
|
|
80
80
|
closeDelay
|
|
81
81
|
});
|
|
82
|
+
const setPopupElement = React.useCallback(element => {
|
|
83
|
+
store.set('popupElement', element);
|
|
84
|
+
}, [store]);
|
|
82
85
|
const state = {
|
|
83
86
|
transitionStatus,
|
|
84
87
|
side,
|
|
@@ -87,9 +90,6 @@ export const MenuPopup = /*#__PURE__*/React.forwardRef(function MenuPopup(compon
|
|
|
87
90
|
nested: parent.type === 'menu',
|
|
88
91
|
instant: instantType
|
|
89
92
|
};
|
|
90
|
-
const setPopupElement = React.useCallback(element => {
|
|
91
|
-
store.set('popupElement', element);
|
|
92
|
-
}, [store]);
|
|
93
93
|
const element = useRenderElement('div', componentProps, {
|
|
94
94
|
state,
|
|
95
95
|
ref: [forwardedRef, store.context.popupRef, setPopupElement],
|
|
@@ -4,6 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import { useControlled } from '@base-ui/utils/useControlled';
|
|
5
5
|
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
6
6
|
import { MenuRadioGroupContext } from "./MenuRadioGroupContext.js";
|
|
7
|
+
import { MenuGroupContext } from "../group/MenuGroupContext.js";
|
|
7
8
|
import { useRenderElement } from "../../internals/useRenderElement.js";
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
/**
|
|
@@ -21,16 +22,17 @@ export const MenuRadioGroup = /*#__PURE__*/React.memo(/*#__PURE__*/React.forward
|
|
|
21
22
|
onValueChange: onValueChangeProp,
|
|
22
23
|
disabled = false,
|
|
23
24
|
style,
|
|
25
|
+
'aria-labelledby': ariaLabelledByProp,
|
|
24
26
|
...elementProps
|
|
25
27
|
} = componentProps;
|
|
28
|
+
const [labelId, setLabelId] = React.useState(undefined);
|
|
26
29
|
const [value, setValueUnwrapped] = useControlled({
|
|
27
30
|
controlled: valueProp,
|
|
28
31
|
default: defaultValue,
|
|
29
32
|
name: 'MenuRadioGroup'
|
|
30
33
|
});
|
|
31
|
-
const onValueChange = useStableCallback(onValueChangeProp);
|
|
32
34
|
const setValue = useStableCallback((newValue, eventDetails) => {
|
|
33
|
-
|
|
35
|
+
onValueChangeProp?.(newValue, eventDetails);
|
|
34
36
|
if (eventDetails.isCanceled) {
|
|
35
37
|
return;
|
|
36
38
|
}
|
|
@@ -44,6 +46,7 @@ export const MenuRadioGroup = /*#__PURE__*/React.memo(/*#__PURE__*/React.forward
|
|
|
44
46
|
ref: forwardedRef,
|
|
45
47
|
props: {
|
|
46
48
|
role: 'group',
|
|
49
|
+
'aria-labelledby': ariaLabelledByProp ?? labelId,
|
|
47
50
|
'aria-disabled': disabled || undefined,
|
|
48
51
|
...elementProps
|
|
49
52
|
}
|
|
@@ -53,9 +56,12 @@ export const MenuRadioGroup = /*#__PURE__*/React.memo(/*#__PURE__*/React.forward
|
|
|
53
56
|
setValue,
|
|
54
57
|
disabled
|
|
55
58
|
}), [value, setValue, disabled]);
|
|
56
|
-
return /*#__PURE__*/_jsx(
|
|
57
|
-
value:
|
|
58
|
-
children:
|
|
59
|
+
return /*#__PURE__*/_jsx(MenuGroupContext.Provider, {
|
|
60
|
+
value: setLabelId,
|
|
61
|
+
children: /*#__PURE__*/_jsx(MenuRadioGroupContext.Provider, {
|
|
62
|
+
value: context,
|
|
63
|
+
children: element
|
|
64
|
+
})
|
|
59
65
|
});
|
|
60
66
|
}));
|
|
61
67
|
if (process.env.NODE_ENV !== "production") MenuRadioGroup.displayName = "MenuRadioGroup";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
5
4
|
import { useMenuRootContext } from "../root/MenuRootContext.js";
|
|
6
5
|
import { useRenderElement } from "../../internals/useRenderElement.js";
|
|
7
6
|
import { useBaseUiId } from "../../internals/useBaseUiId.js";
|
|
@@ -69,13 +68,12 @@ export const MenuRadioItem = /*#__PURE__*/React.forwardRef(function MenuRadioIte
|
|
|
69
68
|
highlighted,
|
|
70
69
|
checked
|
|
71
70
|
}), [disabled, highlighted, checked]);
|
|
72
|
-
|
|
73
|
-
const details = {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
71
|
+
function handleClick(event) {
|
|
72
|
+
const details = createChangeEventDetails(REASONS.itemPress, event.nativeEvent, undefined, {
|
|
73
|
+
preventUnmountOnClose() {}
|
|
74
|
+
});
|
|
77
75
|
setSelectedValue(value, details);
|
|
78
|
-
}
|
|
76
|
+
}
|
|
79
77
|
const element = useRenderElement('div', componentProps, {
|
|
80
78
|
state,
|
|
81
79
|
stateAttributesMapping: itemMapping,
|
|
@@ -6,9 +6,9 @@ import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
|
6
6
|
import { useId } from '@base-ui/utils/useId';
|
|
7
7
|
import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
|
|
8
8
|
import { useOnFirstRender } from '@base-ui/utils/useOnFirstRender';
|
|
9
|
-
import { EMPTY_ARRAY } from '@base-ui/utils/empty';
|
|
9
|
+
import { EMPTY_ARRAY, EMPTY_OBJECT } from '@base-ui/utils/empty';
|
|
10
10
|
import { fastComponent } from '@base-ui/utils/fastHooks';
|
|
11
|
-
import { FloatingTree, useDismiss, useFloatingNodeId, useFloatingParentNodeId,
|
|
11
|
+
import { FloatingTree, useDismiss, useFloatingNodeId, useFloatingParentNodeId, useListNavigation, useTypeahead, useSyncedFloatingRootContext } from "../../floating-ui-react/index.js";
|
|
12
12
|
import { MenuRootContext, useMenuRootContext } from "./MenuRootContext.js";
|
|
13
13
|
import { useMenubarContext } from "../../menubar/MenubarContext.js";
|
|
14
14
|
import { TYPEAHEAD_RESET_MS } from "../../internals/constants.js";
|
|
@@ -19,7 +19,7 @@ import { REASONS } from "../../internals/reasons.js";
|
|
|
19
19
|
import { useContextMenuRootContext } from "../../context-menu/root/ContextMenuRootContext.js";
|
|
20
20
|
import { mergeProps } from "../../merge-props/index.js";
|
|
21
21
|
import { MenuStore } from "../store/MenuStore.js";
|
|
22
|
-
import { useImplicitActiveTrigger, useOpenStateTransitions } from "../../utils/popups/index.js";
|
|
22
|
+
import { FOCUSABLE_POPUP_PROPS, useImplicitActiveTrigger, useOpenStateTransitions, usePopupInteractionProps } from "../../utils/popups/index.js";
|
|
23
23
|
import { useMenuSubmenuRootContext } from "../submenu-root/MenuSubmenuRootContext.js";
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -98,28 +98,11 @@ export const MenuRoot = fastComponent(function MenuRoot(props) {
|
|
|
98
98
|
store.useControlledProp('openProp', openProp);
|
|
99
99
|
store.useControlledProp('triggerIdProp', triggerIdProp);
|
|
100
100
|
store.useContextCallback('onOpenChangeComplete', onOpenChangeComplete);
|
|
101
|
+
const rootId = useId();
|
|
102
|
+
const floatingId = useId();
|
|
101
103
|
const floatingTreeRoot = store.useState('floatingTreeRoot');
|
|
102
104
|
const floatingNodeIdFromContext = useFloatingNodeId(floatingTreeRoot);
|
|
103
105
|
const floatingParentNodeIdFromContext = useFloatingParentNodeId();
|
|
104
|
-
useIsoLayoutEffect(() => {
|
|
105
|
-
if (contextMenuContext && !parentMenuRootContext) {
|
|
106
|
-
// This is a context menu root.
|
|
107
|
-
// It doesn't support detached triggers yet, so we have to sync the parent context manually.
|
|
108
|
-
store.update({
|
|
109
|
-
parent: {
|
|
110
|
-
type: 'context-menu',
|
|
111
|
-
context: contextMenuContext
|
|
112
|
-
},
|
|
113
|
-
floatingNodeId: floatingNodeIdFromContext,
|
|
114
|
-
floatingParentNodeId: floatingParentNodeIdFromContext
|
|
115
|
-
});
|
|
116
|
-
} else if (parentMenuRootContext) {
|
|
117
|
-
store.update({
|
|
118
|
-
floatingNodeId: floatingNodeIdFromContext,
|
|
119
|
-
floatingParentNodeId: floatingParentNodeIdFromContext
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}, [contextMenuContext, parentMenuRootContext, floatingNodeIdFromContext, floatingParentNodeIdFromContext, store]);
|
|
123
106
|
const open = store.useState('open');
|
|
124
107
|
const activeTriggerElement = store.useState('activeTriggerElement');
|
|
125
108
|
const positionerElement = store.useState('positionerElement');
|
|
@@ -131,6 +114,10 @@ export const MenuRoot = fastComponent(function MenuRoot(props) {
|
|
|
131
114
|
const payload = store.useState('payload');
|
|
132
115
|
const floatingParentNodeId = store.useState('floatingParentNodeId');
|
|
133
116
|
const openEventRef = React.useRef(null);
|
|
117
|
+
const allowOutsidePressDismissalRef = React.useRef(parent.type !== 'context-menu');
|
|
118
|
+
const allowOutsidePressDismissalTimeout = useTimeout();
|
|
119
|
+
const allowTouchToCloseRef = React.useRef(true);
|
|
120
|
+
const allowTouchToCloseTimeout = useTimeout();
|
|
134
121
|
const nested = floatingParentNodeId != null;
|
|
135
122
|
if (process.env.NODE_ENV !== 'production') {
|
|
136
123
|
if (parent.type !== undefined && modalProp !== undefined) {
|
|
@@ -145,7 +132,7 @@ export const MenuRoot = fastComponent(function MenuRoot(props) {
|
|
|
145
132
|
disabled: disabledProp,
|
|
146
133
|
modal: parent.type === undefined ? modalProp : undefined,
|
|
147
134
|
openMethod,
|
|
148
|
-
rootId
|
|
135
|
+
rootId
|
|
149
136
|
});
|
|
150
137
|
useImplicitActiveTrigger(store);
|
|
151
138
|
const {
|
|
@@ -156,8 +143,25 @@ export const MenuRoot = fastComponent(function MenuRoot(props) {
|
|
|
156
143
|
stickIfOpen: true
|
|
157
144
|
});
|
|
158
145
|
});
|
|
159
|
-
|
|
160
|
-
|
|
146
|
+
useIsoLayoutEffect(() => {
|
|
147
|
+
if (contextMenuContext && !parentMenuRootContext) {
|
|
148
|
+
// This is a context menu root.
|
|
149
|
+
// It doesn't support detached triggers yet, so we have to sync the parent context manually.
|
|
150
|
+
store.update({
|
|
151
|
+
parent: {
|
|
152
|
+
type: 'context-menu',
|
|
153
|
+
context: contextMenuContext
|
|
154
|
+
},
|
|
155
|
+
floatingNodeId: floatingNodeIdFromContext,
|
|
156
|
+
floatingParentNodeId: floatingParentNodeIdFromContext
|
|
157
|
+
});
|
|
158
|
+
} else if (parentMenuRootContext) {
|
|
159
|
+
store.update({
|
|
160
|
+
floatingNodeId: floatingNodeIdFromContext,
|
|
161
|
+
floatingParentNodeId: floatingParentNodeIdFromContext
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}, [contextMenuContext, parentMenuRootContext, floatingNodeIdFromContext, floatingParentNodeIdFromContext, store]);
|
|
161
165
|
React.useEffect(() => {
|
|
162
166
|
if (!open) {
|
|
163
167
|
openEventRef.current = null;
|
|
@@ -183,8 +187,6 @@ export const MenuRoot = fastComponent(function MenuRoot(props) {
|
|
|
183
187
|
store.set('hoverEnabled', true);
|
|
184
188
|
}
|
|
185
189
|
}, [open, hoverEnabled, store]);
|
|
186
|
-
const allowTouchToCloseRef = React.useRef(true);
|
|
187
|
-
const allowTouchToCloseTimeout = useTimeout();
|
|
188
190
|
const setOpen = useStableCallback((nextOpen, eventDetails) => {
|
|
189
191
|
const reason = eventDetails.reason;
|
|
190
192
|
if (open === nextOpen && eventDetails.trigger === activeTriggerElement && lastOpenChangeReason === reason) {
|
|
@@ -258,23 +260,10 @@ export const MenuRoot = fastComponent(function MenuRoot(props) {
|
|
|
258
260
|
store.set('instantType', undefined);
|
|
259
261
|
}
|
|
260
262
|
});
|
|
261
|
-
const handleImperativeClose = React.useCallback(() => {
|
|
262
|
-
store.setOpen(false, createChangeEventDetails(REASONS.imperativeAction));
|
|
263
|
-
}, [store]);
|
|
264
|
-
React.useImperativeHandle(actionsRef, () => ({
|
|
265
|
-
unmount: forceUnmount,
|
|
266
|
-
close: handleImperativeClose
|
|
267
|
-
}), [forceUnmount, handleImperativeClose]);
|
|
268
|
-
let ctx;
|
|
269
|
-
if (parent.type === 'context-menu') {
|
|
270
|
-
ctx = parent.context;
|
|
271
|
-
}
|
|
272
|
-
React.useImperativeHandle(ctx?.positionerRef, () => positionerElement, [positionerElement]);
|
|
273
|
-
React.useImperativeHandle(ctx?.actionsRef, () => ({
|
|
274
|
-
setOpen
|
|
275
|
-
}), [setOpen]);
|
|
276
263
|
const floatingRootContext = useSyncedFloatingRootContext({
|
|
277
264
|
popupStore: store,
|
|
265
|
+
floatingId,
|
|
266
|
+
nested: floatingParentNodeIdFromContext != null,
|
|
278
267
|
onOpenChange: setOpen
|
|
279
268
|
});
|
|
280
269
|
const floatingEvents = floatingRootContext.context.events;
|
|
@@ -288,6 +277,21 @@ export const MenuRoot = fastComponent(function MenuRoot(props) {
|
|
|
288
277
|
floatingEvents?.off('setOpen', handleSetOpenEvent);
|
|
289
278
|
};
|
|
290
279
|
}, [floatingEvents, setOpen]);
|
|
280
|
+
const handleImperativeClose = React.useCallback(() => {
|
|
281
|
+
store.setOpen(false, createChangeEventDetails(REASONS.imperativeAction));
|
|
282
|
+
}, [store]);
|
|
283
|
+
React.useImperativeHandle(actionsRef, () => ({
|
|
284
|
+
unmount: forceUnmount,
|
|
285
|
+
close: handleImperativeClose
|
|
286
|
+
}), [forceUnmount, handleImperativeClose]);
|
|
287
|
+
let ctx;
|
|
288
|
+
if (parent.type === 'context-menu') {
|
|
289
|
+
ctx = parent.context;
|
|
290
|
+
}
|
|
291
|
+
React.useImperativeHandle(ctx?.positionerRef, () => positionerElement, [positionerElement]);
|
|
292
|
+
React.useImperativeHandle(ctx?.actionsRef, () => ({
|
|
293
|
+
setOpen
|
|
294
|
+
}), [setOpen]);
|
|
291
295
|
const dismiss = useDismiss(floatingRootContext, {
|
|
292
296
|
enabled: !disabled,
|
|
293
297
|
bubbles: {
|
|
@@ -301,9 +305,6 @@ export const MenuRoot = fastComponent(function MenuRoot(props) {
|
|
|
301
305
|
},
|
|
302
306
|
externalTree: nested ? floatingTreeRoot : undefined
|
|
303
307
|
});
|
|
304
|
-
const role = useRole(floatingRootContext, {
|
|
305
|
-
role: 'menu'
|
|
306
|
-
});
|
|
307
308
|
const direction = useDirection();
|
|
308
309
|
const setActiveIndex = React.useCallback(index => {
|
|
309
310
|
if (store.select('activeIndex') === index) {
|
|
@@ -326,7 +327,7 @@ export const MenuRoot = fastComponent(function MenuRoot(props) {
|
|
|
326
327
|
externalTree: nested ? floatingTreeRoot : undefined,
|
|
327
328
|
focusItemOnHover: highlightItemOnHover
|
|
328
329
|
});
|
|
329
|
-
const
|
|
330
|
+
const onTyping = React.useCallback(nextTyping => {
|
|
330
331
|
store.context.typingRef.current = nextTyping;
|
|
331
332
|
}, [store]);
|
|
332
333
|
const typeahead = useTypeahead(floatingRootContext, {
|
|
@@ -339,34 +340,28 @@ export const MenuRoot = fastComponent(function MenuRoot(props) {
|
|
|
339
340
|
store.set('activeIndex', index);
|
|
340
341
|
}
|
|
341
342
|
},
|
|
342
|
-
|
|
343
|
+
onTyping
|
|
343
344
|
});
|
|
344
|
-
const {
|
|
345
|
-
getReferenceProps,
|
|
346
|
-
getFloatingProps,
|
|
347
|
-
getItemProps,
|
|
348
|
-
getTriggerProps
|
|
349
|
-
} = useInteractions([dismiss, role, listNavigation, typeahead]);
|
|
350
345
|
const activeTriggerProps = React.useMemo(() => {
|
|
351
|
-
const mergedProps = mergeProps(
|
|
346
|
+
const mergedProps = mergeProps(typeahead.reference, listNavigation.reference, dismiss.reference, {
|
|
352
347
|
onMouseMove() {
|
|
353
348
|
store.set('allowMouseEnter', true);
|
|
354
349
|
}
|
|
355
350
|
}, interactionTypeProps);
|
|
356
|
-
|
|
351
|
+
mergedProps['aria-haspopup'] = 'menu';
|
|
352
|
+
mergedProps['aria-expanded'] = open;
|
|
357
353
|
return mergedProps;
|
|
358
|
-
}, [
|
|
354
|
+
}, [store, typeahead.reference, listNavigation.reference, dismiss.reference, interactionTypeProps, open]);
|
|
359
355
|
const inactiveTriggerProps = React.useMemo(() => {
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
const mergedProps = mergeProps(triggerProps, interactionTypeProps);
|
|
365
|
-
delete mergedProps.role;
|
|
366
|
-
delete mergedProps['aria-controls'];
|
|
356
|
+
const mergedProps = mergeProps(listNavigation.trigger, dismiss.trigger, interactionTypeProps);
|
|
357
|
+
mergedProps['aria-haspopup'] = 'menu';
|
|
358
|
+
mergedProps['aria-expanded'] = false;
|
|
367
359
|
return mergedProps;
|
|
368
|
-
}, [
|
|
369
|
-
const popupProps = React.useMemo(() =>
|
|
360
|
+
}, [listNavigation.trigger, dismiss.trigger, interactionTypeProps]);
|
|
361
|
+
const popupProps = React.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, {
|
|
362
|
+
id: floatingId,
|
|
363
|
+
role: 'menu',
|
|
364
|
+
'aria-labelledby': activeTriggerElement?.id,
|
|
370
365
|
onMouseMove() {
|
|
371
366
|
store.set('allowMouseEnter', true);
|
|
372
367
|
if (parent.type === 'menu') {
|
|
@@ -387,9 +382,9 @@ export const MenuRoot = fastComponent(function MenuRoot(props) {
|
|
|
387
382
|
relay(event);
|
|
388
383
|
}
|
|
389
384
|
}
|
|
390
|
-
}), [
|
|
391
|
-
const itemProps =
|
|
392
|
-
store
|
|
385
|
+
}, typeahead.floating, listNavigation.floating, dismiss.floating), [activeTriggerElement, floatingId, parent.type, store, typeahead.floating, listNavigation.floating, dismiss.floating]);
|
|
386
|
+
const itemProps = listNavigation.item ?? EMPTY_OBJECT;
|
|
387
|
+
usePopupInteractionProps(store, {
|
|
393
388
|
floatingRootContext,
|
|
394
389
|
activeTriggerProps,
|
|
395
390
|
inactiveTriggerProps,
|