@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,88 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ACTIVE_KEY, FOCUSABLE_ATTRIBUTE, SELECTED_KEY } from "../utils/constants.js";
|
|
3
|
-
/**
|
|
4
|
-
* Merges an array of interaction hooks' props into prop getters, allowing
|
|
5
|
-
* event handler functions to be composed together without overwriting one
|
|
6
|
-
* another.
|
|
7
|
-
* @see https://floating-ui.com/docs/useInteractions
|
|
8
|
-
*/
|
|
9
|
-
export function useInteractions(propsList = []) {
|
|
10
|
-
const referenceDeps = propsList.map(key => key?.reference);
|
|
11
|
-
const floatingDeps = propsList.map(key => key?.floating);
|
|
12
|
-
const itemDeps = propsList.map(key => key?.item);
|
|
13
|
-
const triggerDeps = propsList.map(key => key?.trigger);
|
|
14
|
-
const getReferenceProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'reference'),
|
|
15
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
16
|
-
referenceDeps);
|
|
17
|
-
const getFloatingProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'floating'),
|
|
18
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
-
floatingDeps);
|
|
20
|
-
const getItemProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'item'),
|
|
21
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22
|
-
itemDeps);
|
|
23
|
-
const getTriggerProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'trigger'),
|
|
24
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
|
-
triggerDeps);
|
|
26
|
-
return React.useMemo(() => ({
|
|
27
|
-
getReferenceProps,
|
|
28
|
-
getFloatingProps,
|
|
29
|
-
getItemProps,
|
|
30
|
-
getTriggerProps
|
|
31
|
-
}), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/* eslint-disable guard-for-in */
|
|
35
|
-
|
|
36
|
-
function mergeProps(userProps, propsList, elementKey) {
|
|
37
|
-
const eventHandlers = new Map();
|
|
38
|
-
const isItem = elementKey === 'item';
|
|
39
|
-
const outputProps = {};
|
|
40
|
-
if (elementKey === 'floating') {
|
|
41
|
-
outputProps.tabIndex = -1;
|
|
42
|
-
outputProps[FOCUSABLE_ATTRIBUTE] = '';
|
|
43
|
-
}
|
|
44
|
-
for (const key in userProps) {
|
|
45
|
-
if (isItem && userProps) {
|
|
46
|
-
if (key === ACTIVE_KEY || key === SELECTED_KEY) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
outputProps[key] = userProps[key];
|
|
51
|
-
}
|
|
52
|
-
for (let i = 0; i < propsList.length; i += 1) {
|
|
53
|
-
let props;
|
|
54
|
-
const propsOrGetProps = propsList[i]?.[elementKey];
|
|
55
|
-
if (typeof propsOrGetProps === 'function') {
|
|
56
|
-
props = userProps ? propsOrGetProps(userProps) : null;
|
|
57
|
-
} else {
|
|
58
|
-
props = propsOrGetProps;
|
|
59
|
-
}
|
|
60
|
-
if (!props) {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
mutablyMergeProps(outputProps, props, isItem, eventHandlers);
|
|
64
|
-
}
|
|
65
|
-
mutablyMergeProps(outputProps, userProps, isItem, eventHandlers);
|
|
66
|
-
return outputProps;
|
|
67
|
-
}
|
|
68
|
-
function mutablyMergeProps(outputProps, props, isItem, eventHandlers) {
|
|
69
|
-
for (const key in props) {
|
|
70
|
-
const value = props[key];
|
|
71
|
-
if (isItem && (key === ACTIVE_KEY || key === SELECTED_KEY)) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (!key.startsWith('on')) {
|
|
75
|
-
outputProps[key] = value;
|
|
76
|
-
} else {
|
|
77
|
-
if (!eventHandlers.has(key)) {
|
|
78
|
-
eventHandlers.set(key, []);
|
|
79
|
-
}
|
|
80
|
-
if (typeof value === 'function') {
|
|
81
|
-
eventHandlers.get(key)?.push(value);
|
|
82
|
-
outputProps[key] = (...args) => {
|
|
83
|
-
return eventHandlers.get(key)?.map(fn => fn(...args)).find(val => val !== undefined);
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ElementProps, FloatingContext, FloatingRootContext } from "../types.js";
|
|
2
|
-
type AriaRole = 'tooltip' | 'dialog' | 'alertdialog' | 'menu' | 'listbox' | 'grid' | 'tree';
|
|
3
|
-
type ComponentRole = 'select' | 'label' | 'combobox';
|
|
4
|
-
export interface UseRoleProps {
|
|
5
|
-
/**
|
|
6
|
-
* The role of the floating element.
|
|
7
|
-
* @default 'dialog'
|
|
8
|
-
*/
|
|
9
|
-
role?: AriaRole | ComponentRole | undefined;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Adds base screen reader props to the reference and floating elements for a
|
|
13
|
-
* given floating element `role`.
|
|
14
|
-
* @see https://floating-ui.com/docs/useRole
|
|
15
|
-
*/
|
|
16
|
-
export declare function useRole(context: FloatingRootContext | FloatingContext, props?: UseRoleProps): ElementProps;
|
|
17
|
-
export {};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useId } from '@base-ui/utils/useId';
|
|
3
|
-
import { EMPTY_OBJECT } from '@base-ui/utils/empty';
|
|
4
|
-
import { getFloatingFocusElement } from "../utils/element.js";
|
|
5
|
-
import { useFloatingParentNodeId } from "../components/FloatingTree.js";
|
|
6
|
-
const componentRoleToAriaRoleMap = new Map([['select', 'listbox'], ['combobox', 'listbox'], ['label', false]]);
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Adds base screen reader props to the reference and floating elements for a
|
|
10
|
-
* given floating element `role`.
|
|
11
|
-
* @see https://floating-ui.com/docs/useRole
|
|
12
|
-
*/
|
|
13
|
-
export function useRole(context, props = {}) {
|
|
14
|
-
const store = 'rootStore' in context ? context.rootStore : context;
|
|
15
|
-
const open = store.useState('open');
|
|
16
|
-
const defaultFloatingId = store.useState('floatingId');
|
|
17
|
-
const domReference = store.useState('domReferenceElement');
|
|
18
|
-
const floatingElement = store.useState('floatingElement');
|
|
19
|
-
const {
|
|
20
|
-
role = 'dialog'
|
|
21
|
-
} = props;
|
|
22
|
-
const defaultReferenceId = useId();
|
|
23
|
-
const referenceId = domReference?.id || defaultReferenceId;
|
|
24
|
-
const floatingId = React.useMemo(() => getFloatingFocusElement(floatingElement)?.id || defaultFloatingId, [floatingElement, defaultFloatingId]);
|
|
25
|
-
const ariaRole = componentRoleToAriaRoleMap.get(role) ?? role;
|
|
26
|
-
const parentId = useFloatingParentNodeId();
|
|
27
|
-
const isNested = parentId != null;
|
|
28
|
-
const trigger = React.useMemo(() => {
|
|
29
|
-
if (ariaRole === 'tooltip' || role === 'label') {
|
|
30
|
-
return EMPTY_OBJECT;
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
'aria-haspopup': ariaRole === 'alertdialog' ? 'dialog' : ariaRole,
|
|
34
|
-
'aria-expanded': 'false',
|
|
35
|
-
...(ariaRole === 'listbox' && {
|
|
36
|
-
role: 'combobox'
|
|
37
|
-
}),
|
|
38
|
-
...(ariaRole === 'menu' && isNested && {
|
|
39
|
-
role: 'menuitem'
|
|
40
|
-
}),
|
|
41
|
-
...(role === 'select' && {
|
|
42
|
-
'aria-autocomplete': 'none'
|
|
43
|
-
}),
|
|
44
|
-
...(role === 'combobox' && {
|
|
45
|
-
'aria-autocomplete': 'list'
|
|
46
|
-
})
|
|
47
|
-
};
|
|
48
|
-
}, [ariaRole, isNested, role]);
|
|
49
|
-
const reference = React.useMemo(() => {
|
|
50
|
-
if (ariaRole === 'tooltip' || role === 'label') {
|
|
51
|
-
return {
|
|
52
|
-
[`aria-${role === 'label' ? 'labelledby' : 'describedby'}`]: open ? floatingId : undefined
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
const triggerProps = trigger;
|
|
56
|
-
return {
|
|
57
|
-
...triggerProps,
|
|
58
|
-
'aria-expanded': open ? 'true' : 'false',
|
|
59
|
-
'aria-controls': open ? floatingId : undefined,
|
|
60
|
-
...(ariaRole === 'menu' && {
|
|
61
|
-
id: referenceId
|
|
62
|
-
})
|
|
63
|
-
};
|
|
64
|
-
}, [ariaRole, floatingId, open, referenceId, role, trigger]);
|
|
65
|
-
const floating = React.useMemo(() => {
|
|
66
|
-
const floatingProps = {
|
|
67
|
-
id: floatingId,
|
|
68
|
-
...(ariaRole && {
|
|
69
|
-
role: ariaRole
|
|
70
|
-
})
|
|
71
|
-
};
|
|
72
|
-
if (ariaRole === 'tooltip' || role === 'label') {
|
|
73
|
-
return floatingProps;
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
...floatingProps,
|
|
77
|
-
...(ariaRole === 'menu' && {
|
|
78
|
-
'aria-labelledby': referenceId
|
|
79
|
-
})
|
|
80
|
-
};
|
|
81
|
-
}, [ariaRole, floatingId, referenceId, role]);
|
|
82
|
-
const item = React.useCallback(({
|
|
83
|
-
active,
|
|
84
|
-
selected
|
|
85
|
-
}) => {
|
|
86
|
-
const commonProps = {
|
|
87
|
-
role: 'option',
|
|
88
|
-
...(active && {
|
|
89
|
-
id: `${floatingId}-fui-option`
|
|
90
|
-
})
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// For `menu`, we are unable to tell if the item is a `menuitemradio`
|
|
94
|
-
// or `menuitemcheckbox`. For backwards-compatibility reasons, also
|
|
95
|
-
// avoid defaulting to `menuitem` as it may overwrite custom role props.
|
|
96
|
-
switch (role) {
|
|
97
|
-
case 'select':
|
|
98
|
-
case 'combobox':
|
|
99
|
-
return {
|
|
100
|
-
...commonProps,
|
|
101
|
-
'aria-selected': selected
|
|
102
|
-
};
|
|
103
|
-
default:
|
|
104
|
-
}
|
|
105
|
-
return {};
|
|
106
|
-
}, [floatingId, role]);
|
|
107
|
-
return React.useMemo(() => ({
|
|
108
|
-
reference,
|
|
109
|
-
floating,
|
|
110
|
-
item,
|
|
111
|
-
trigger
|
|
112
|
-
}), [reference, floating, trigger, item]);
|
|
113
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { ElementProps } from "../types.js";
|
|
3
|
-
import { ACTIVE_KEY, SELECTED_KEY } from "../utils/constants.js";
|
|
4
|
-
export type ExtendedUserProps = {
|
|
5
|
-
[ACTIVE_KEY]?: boolean | undefined;
|
|
6
|
-
[SELECTED_KEY]?: boolean | undefined;
|
|
7
|
-
};
|
|
8
|
-
export interface UseInteractionsReturn {
|
|
9
|
-
getReferenceProps: (userProps?: React.HTMLProps<Element>) => Record<string, unknown>;
|
|
10
|
-
getFloatingProps: (userProps?: React.HTMLProps<HTMLElement>) => Record<string, unknown>;
|
|
11
|
-
getItemProps: (userProps?: Omit<React.HTMLProps<HTMLElement>, 'selected' | 'active'> & ExtendedUserProps) => Record<string, unknown>;
|
|
12
|
-
getTriggerProps: (userProps?: React.HTMLProps<Element>) => Record<string, unknown>;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Merges an array of interaction hooks' props into prop getters, allowing
|
|
16
|
-
* event handler functions to be composed together without overwriting one
|
|
17
|
-
* another.
|
|
18
|
-
* @see https://floating-ui.com/docs/useInteractions
|
|
19
|
-
*/
|
|
20
|
-
export declare function useInteractions(propsList?: Array<ElementProps | void>): UseInteractionsReturn;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.useInteractions = useInteractions;
|
|
8
|
-
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _constants = require("../utils/constants");
|
|
10
|
-
/**
|
|
11
|
-
* Merges an array of interaction hooks' props into prop getters, allowing
|
|
12
|
-
* event handler functions to be composed together without overwriting one
|
|
13
|
-
* another.
|
|
14
|
-
* @see https://floating-ui.com/docs/useInteractions
|
|
15
|
-
*/
|
|
16
|
-
function useInteractions(propsList = []) {
|
|
17
|
-
const referenceDeps = propsList.map(key => key?.reference);
|
|
18
|
-
const floatingDeps = propsList.map(key => key?.floating);
|
|
19
|
-
const itemDeps = propsList.map(key => key?.item);
|
|
20
|
-
const triggerDeps = propsList.map(key => key?.trigger);
|
|
21
|
-
const getReferenceProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'reference'),
|
|
22
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
-
referenceDeps);
|
|
24
|
-
const getFloatingProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'floating'),
|
|
25
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
-
floatingDeps);
|
|
27
|
-
const getItemProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'item'),
|
|
28
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
-
itemDeps);
|
|
30
|
-
const getTriggerProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'trigger'),
|
|
31
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
-
triggerDeps);
|
|
33
|
-
return React.useMemo(() => ({
|
|
34
|
-
getReferenceProps,
|
|
35
|
-
getFloatingProps,
|
|
36
|
-
getItemProps,
|
|
37
|
-
getTriggerProps
|
|
38
|
-
}), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/* eslint-disable guard-for-in */
|
|
42
|
-
|
|
43
|
-
function mergeProps(userProps, propsList, elementKey) {
|
|
44
|
-
const eventHandlers = new Map();
|
|
45
|
-
const isItem = elementKey === 'item';
|
|
46
|
-
const outputProps = {};
|
|
47
|
-
if (elementKey === 'floating') {
|
|
48
|
-
outputProps.tabIndex = -1;
|
|
49
|
-
outputProps[_constants.FOCUSABLE_ATTRIBUTE] = '';
|
|
50
|
-
}
|
|
51
|
-
for (const key in userProps) {
|
|
52
|
-
if (isItem && userProps) {
|
|
53
|
-
if (key === _constants.ACTIVE_KEY || key === _constants.SELECTED_KEY) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
outputProps[key] = userProps[key];
|
|
58
|
-
}
|
|
59
|
-
for (let i = 0; i < propsList.length; i += 1) {
|
|
60
|
-
let props;
|
|
61
|
-
const propsOrGetProps = propsList[i]?.[elementKey];
|
|
62
|
-
if (typeof propsOrGetProps === 'function') {
|
|
63
|
-
props = userProps ? propsOrGetProps(userProps) : null;
|
|
64
|
-
} else {
|
|
65
|
-
props = propsOrGetProps;
|
|
66
|
-
}
|
|
67
|
-
if (!props) {
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
mutablyMergeProps(outputProps, props, isItem, eventHandlers);
|
|
71
|
-
}
|
|
72
|
-
mutablyMergeProps(outputProps, userProps, isItem, eventHandlers);
|
|
73
|
-
return outputProps;
|
|
74
|
-
}
|
|
75
|
-
function mutablyMergeProps(outputProps, props, isItem, eventHandlers) {
|
|
76
|
-
for (const key in props) {
|
|
77
|
-
const value = props[key];
|
|
78
|
-
if (isItem && (key === _constants.ACTIVE_KEY || key === _constants.SELECTED_KEY)) {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
if (!key.startsWith('on')) {
|
|
82
|
-
outputProps[key] = value;
|
|
83
|
-
} else {
|
|
84
|
-
if (!eventHandlers.has(key)) {
|
|
85
|
-
eventHandlers.set(key, []);
|
|
86
|
-
}
|
|
87
|
-
if (typeof value === 'function') {
|
|
88
|
-
eventHandlers.get(key)?.push(value);
|
|
89
|
-
outputProps[key] = (...args) => {
|
|
90
|
-
return eventHandlers.get(key)?.map(fn => fn(...args)).find(val => val !== undefined);
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ElementProps, FloatingContext, FloatingRootContext } from "../types.js";
|
|
2
|
-
type AriaRole = 'tooltip' | 'dialog' | 'alertdialog' | 'menu' | 'listbox' | 'grid' | 'tree';
|
|
3
|
-
type ComponentRole = 'select' | 'label' | 'combobox';
|
|
4
|
-
export interface UseRoleProps {
|
|
5
|
-
/**
|
|
6
|
-
* The role of the floating element.
|
|
7
|
-
* @default 'dialog'
|
|
8
|
-
*/
|
|
9
|
-
role?: AriaRole | ComponentRole | undefined;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Adds base screen reader props to the reference and floating elements for a
|
|
13
|
-
* given floating element `role`.
|
|
14
|
-
* @see https://floating-ui.com/docs/useRole
|
|
15
|
-
*/
|
|
16
|
-
export declare function useRole(context: FloatingRootContext | FloatingContext, props?: UseRoleProps): ElementProps;
|
|
17
|
-
export {};
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.useRole = useRole;
|
|
8
|
-
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _useId = require("@base-ui/utils/useId");
|
|
10
|
-
var _empty = require("@base-ui/utils/empty");
|
|
11
|
-
var _element = require("../utils/element");
|
|
12
|
-
var _FloatingTree = require("../components/FloatingTree");
|
|
13
|
-
const componentRoleToAriaRoleMap = new Map([['select', 'listbox'], ['combobox', 'listbox'], ['label', false]]);
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Adds base screen reader props to the reference and floating elements for a
|
|
17
|
-
* given floating element `role`.
|
|
18
|
-
* @see https://floating-ui.com/docs/useRole
|
|
19
|
-
*/
|
|
20
|
-
function useRole(context, props = {}) {
|
|
21
|
-
const store = 'rootStore' in context ? context.rootStore : context;
|
|
22
|
-
const open = store.useState('open');
|
|
23
|
-
const defaultFloatingId = store.useState('floatingId');
|
|
24
|
-
const domReference = store.useState('domReferenceElement');
|
|
25
|
-
const floatingElement = store.useState('floatingElement');
|
|
26
|
-
const {
|
|
27
|
-
role = 'dialog'
|
|
28
|
-
} = props;
|
|
29
|
-
const defaultReferenceId = (0, _useId.useId)();
|
|
30
|
-
const referenceId = domReference?.id || defaultReferenceId;
|
|
31
|
-
const floatingId = React.useMemo(() => (0, _element.getFloatingFocusElement)(floatingElement)?.id || defaultFloatingId, [floatingElement, defaultFloatingId]);
|
|
32
|
-
const ariaRole = componentRoleToAriaRoleMap.get(role) ?? role;
|
|
33
|
-
const parentId = (0, _FloatingTree.useFloatingParentNodeId)();
|
|
34
|
-
const isNested = parentId != null;
|
|
35
|
-
const trigger = React.useMemo(() => {
|
|
36
|
-
if (ariaRole === 'tooltip' || role === 'label') {
|
|
37
|
-
return _empty.EMPTY_OBJECT;
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
'aria-haspopup': ariaRole === 'alertdialog' ? 'dialog' : ariaRole,
|
|
41
|
-
'aria-expanded': 'false',
|
|
42
|
-
...(ariaRole === 'listbox' && {
|
|
43
|
-
role: 'combobox'
|
|
44
|
-
}),
|
|
45
|
-
...(ariaRole === 'menu' && isNested && {
|
|
46
|
-
role: 'menuitem'
|
|
47
|
-
}),
|
|
48
|
-
...(role === 'select' && {
|
|
49
|
-
'aria-autocomplete': 'none'
|
|
50
|
-
}),
|
|
51
|
-
...(role === 'combobox' && {
|
|
52
|
-
'aria-autocomplete': 'list'
|
|
53
|
-
})
|
|
54
|
-
};
|
|
55
|
-
}, [ariaRole, isNested, role]);
|
|
56
|
-
const reference = React.useMemo(() => {
|
|
57
|
-
if (ariaRole === 'tooltip' || role === 'label') {
|
|
58
|
-
return {
|
|
59
|
-
[`aria-${role === 'label' ? 'labelledby' : 'describedby'}`]: open ? floatingId : undefined
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
const triggerProps = trigger;
|
|
63
|
-
return {
|
|
64
|
-
...triggerProps,
|
|
65
|
-
'aria-expanded': open ? 'true' : 'false',
|
|
66
|
-
'aria-controls': open ? floatingId : undefined,
|
|
67
|
-
...(ariaRole === 'menu' && {
|
|
68
|
-
id: referenceId
|
|
69
|
-
})
|
|
70
|
-
};
|
|
71
|
-
}, [ariaRole, floatingId, open, referenceId, role, trigger]);
|
|
72
|
-
const floating = React.useMemo(() => {
|
|
73
|
-
const floatingProps = {
|
|
74
|
-
id: floatingId,
|
|
75
|
-
...(ariaRole && {
|
|
76
|
-
role: ariaRole
|
|
77
|
-
})
|
|
78
|
-
};
|
|
79
|
-
if (ariaRole === 'tooltip' || role === 'label') {
|
|
80
|
-
return floatingProps;
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
...floatingProps,
|
|
84
|
-
...(ariaRole === 'menu' && {
|
|
85
|
-
'aria-labelledby': referenceId
|
|
86
|
-
})
|
|
87
|
-
};
|
|
88
|
-
}, [ariaRole, floatingId, referenceId, role]);
|
|
89
|
-
const item = React.useCallback(({
|
|
90
|
-
active,
|
|
91
|
-
selected
|
|
92
|
-
}) => {
|
|
93
|
-
const commonProps = {
|
|
94
|
-
role: 'option',
|
|
95
|
-
...(active && {
|
|
96
|
-
id: `${floatingId}-fui-option`
|
|
97
|
-
})
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// For `menu`, we are unable to tell if the item is a `menuitemradio`
|
|
101
|
-
// or `menuitemcheckbox`. For backwards-compatibility reasons, also
|
|
102
|
-
// avoid defaulting to `menuitem` as it may overwrite custom role props.
|
|
103
|
-
switch (role) {
|
|
104
|
-
case 'select':
|
|
105
|
-
case 'combobox':
|
|
106
|
-
return {
|
|
107
|
-
...commonProps,
|
|
108
|
-
'aria-selected': selected
|
|
109
|
-
};
|
|
110
|
-
default:
|
|
111
|
-
}
|
|
112
|
-
return {};
|
|
113
|
-
}, [floatingId, role]);
|
|
114
|
-
return React.useMemo(() => ({
|
|
115
|
-
reference,
|
|
116
|
-
floating,
|
|
117
|
-
item,
|
|
118
|
-
trigger
|
|
119
|
-
}), [reference, floating, trigger, item]);
|
|
120
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|