@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,62 +1,34 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
5
4
|
import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
|
|
5
|
+
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
6
6
|
import { useTimeout } from '@base-ui/utils/useTimeout';
|
|
7
|
+
import { isElementVisible } from "../utils/composite.js";
|
|
7
8
|
import { contains } from "../utils/element.js";
|
|
8
9
|
import { stopEvent } from "../utils/event.js";
|
|
9
|
-
import { isElementVisible } from "../utils/composite.js";
|
|
10
10
|
/**
|
|
11
11
|
* Provides a matching callback that can be used to focus an item as the user
|
|
12
12
|
* types, often used in tandem with `useListNavigation()`.
|
|
13
13
|
* @see https://floating-ui.com/docs/useTypeahead
|
|
14
14
|
*/
|
|
15
15
|
export function useTypeahead(context, props) {
|
|
16
|
-
const store = 'rootStore' in context ? context.rootStore : context;
|
|
17
|
-
const dataRef = store.context.dataRef;
|
|
18
|
-
const open = store.useState('open');
|
|
19
16
|
const {
|
|
20
17
|
listRef,
|
|
21
18
|
elementsRef,
|
|
22
19
|
activeIndex,
|
|
23
20
|
onMatch: onMatchProp,
|
|
24
|
-
|
|
21
|
+
onTyping,
|
|
25
22
|
enabled = true,
|
|
26
23
|
resetMs = 750,
|
|
27
24
|
selectedIndex = null
|
|
28
25
|
} = props;
|
|
26
|
+
const store = 'rootStore' in context ? context.rootStore : context;
|
|
27
|
+
const open = store.useState('open');
|
|
29
28
|
const timeout = useTimeout();
|
|
30
29
|
const stringRef = React.useRef('');
|
|
31
30
|
const prevIndexRef = React.useRef(selectedIndex ?? activeIndex ?? -1);
|
|
32
31
|
const matchIndexRef = React.useRef(null);
|
|
33
|
-
useIsoLayoutEffect(() => {
|
|
34
|
-
if (!open && selectedIndex !== null) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
timeout.clear();
|
|
38
|
-
matchIndexRef.current = null;
|
|
39
|
-
if (stringRef.current !== '') {
|
|
40
|
-
stringRef.current = '';
|
|
41
|
-
}
|
|
42
|
-
}, [open, selectedIndex, timeout]);
|
|
43
|
-
useIsoLayoutEffect(() => {
|
|
44
|
-
// Sync arrow key navigation but not typeahead navigation.
|
|
45
|
-
if (open && stringRef.current === '') {
|
|
46
|
-
prevIndexRef.current = selectedIndex ?? activeIndex ?? -1;
|
|
47
|
-
}
|
|
48
|
-
}, [open, selectedIndex, activeIndex]);
|
|
49
|
-
const setTypingChange = useStableCallback(value => {
|
|
50
|
-
if (value) {
|
|
51
|
-
if (!dataRef.current.typing) {
|
|
52
|
-
dataRef.current.typing = value;
|
|
53
|
-
onTypingChange?.(value);
|
|
54
|
-
}
|
|
55
|
-
} else if (dataRef.current.typing) {
|
|
56
|
-
dataRef.current.typing = value;
|
|
57
|
-
onTypingChange?.(value);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
32
|
const onKeyDown = useStableCallback(event => {
|
|
61
33
|
function isVisible(index) {
|
|
62
34
|
const element = elementsRef?.current[index];
|
|
@@ -82,11 +54,11 @@ export function useTypeahead(context, props) {
|
|
|
82
54
|
if (stringRef.current.length > 0 && event.key === ' ') {
|
|
83
55
|
// Space should continue the in-progress typeahead session.
|
|
84
56
|
stopEvent(event);
|
|
85
|
-
|
|
57
|
+
onTyping?.(true);
|
|
86
58
|
}
|
|
87
59
|
if (stringRef.current.length > 0 && stringRef.current[0] !== ' ') {
|
|
88
60
|
if (getMatchingIndex(listContent, stringRef.current) === -1 && event.key !== ' ') {
|
|
89
|
-
|
|
61
|
+
onTyping?.(false);
|
|
90
62
|
}
|
|
91
63
|
}
|
|
92
64
|
if (listContent == null ||
|
|
@@ -98,7 +70,7 @@ export function useTypeahead(context, props) {
|
|
|
98
70
|
}
|
|
99
71
|
if (open && event.key !== ' ') {
|
|
100
72
|
stopEvent(event);
|
|
101
|
-
|
|
73
|
+
onTyping?.(true);
|
|
102
74
|
}
|
|
103
75
|
|
|
104
76
|
// Capture whether this is a new typing session before mutating the string.
|
|
@@ -121,7 +93,7 @@ export function useTypeahead(context, props) {
|
|
|
121
93
|
timeout.start(resetMs, () => {
|
|
122
94
|
stringRef.current = '';
|
|
123
95
|
prevIndexRef.current = matchIndexRef.current;
|
|
124
|
-
|
|
96
|
+
onTyping?.(false);
|
|
125
97
|
});
|
|
126
98
|
|
|
127
99
|
// Compute the starting index for this search.
|
|
@@ -135,18 +107,17 @@ export function useTypeahead(context, props) {
|
|
|
135
107
|
matchIndexRef.current = index;
|
|
136
108
|
} else if (event.key !== ' ') {
|
|
137
109
|
stringRef.current = '';
|
|
138
|
-
|
|
110
|
+
onTyping?.(false);
|
|
139
111
|
}
|
|
140
112
|
});
|
|
141
113
|
const onBlur = useStableCallback(event => {
|
|
142
114
|
const next = event.relatedTarget;
|
|
143
115
|
const currentDomReferenceElement = store.select('domReferenceElement');
|
|
144
116
|
const currentFloatingElement = store.select('floatingElement');
|
|
145
|
-
const
|
|
146
|
-
const withinFloating = contains(currentFloatingElement, next);
|
|
117
|
+
const withinComposite = contains(currentDomReferenceElement, next) || contains(currentFloatingElement, next);
|
|
147
118
|
|
|
148
119
|
// Keep the session if focus moves within the composite (reference <-> floating).
|
|
149
|
-
if (
|
|
120
|
+
if (withinComposite) {
|
|
150
121
|
return;
|
|
151
122
|
}
|
|
152
123
|
|
|
@@ -154,20 +125,30 @@ export function useTypeahead(context, props) {
|
|
|
154
125
|
timeout.clear();
|
|
155
126
|
stringRef.current = '';
|
|
156
127
|
prevIndexRef.current = matchIndexRef.current;
|
|
157
|
-
|
|
128
|
+
onTyping?.(false);
|
|
158
129
|
});
|
|
159
|
-
|
|
130
|
+
useIsoLayoutEffect(() => {
|
|
131
|
+
if (!open && selectedIndex !== null) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
timeout.clear();
|
|
135
|
+
matchIndexRef.current = null;
|
|
136
|
+
if (stringRef.current !== '') {
|
|
137
|
+
stringRef.current = '';
|
|
138
|
+
}
|
|
139
|
+
}, [open, selectedIndex, timeout]);
|
|
140
|
+
useIsoLayoutEffect(() => {
|
|
141
|
+
// Sync arrow key navigation but not typeahead navigation.
|
|
142
|
+
if (open && stringRef.current === '') {
|
|
143
|
+
prevIndexRef.current = selectedIndex ?? activeIndex ?? -1;
|
|
144
|
+
}
|
|
145
|
+
}, [open, selectedIndex, activeIndex]);
|
|
146
|
+
const sharedProps = React.useMemo(() => ({
|
|
160
147
|
onKeyDown,
|
|
161
148
|
onBlur
|
|
162
149
|
}), [onKeyDown, onBlur]);
|
|
163
|
-
const floating = React.useMemo(() => {
|
|
164
|
-
return {
|
|
165
|
-
onKeyDown,
|
|
166
|
-
onBlur
|
|
167
|
-
};
|
|
168
|
-
}, [onKeyDown, onBlur]);
|
|
169
150
|
return React.useMemo(() => enabled ? {
|
|
170
|
-
reference,
|
|
171
|
-
floating
|
|
172
|
-
} : {}, [enabled,
|
|
151
|
+
reference: sharedProps,
|
|
152
|
+
floating: sharedProps
|
|
153
|
+
} : {}, [enabled, sharedProps]);
|
|
173
154
|
}
|
|
@@ -13,9 +13,7 @@ export { useFocus } from "./hooks/useFocus.js";
|
|
|
13
13
|
export { useHoverFloatingInteraction } from "./hooks/useHoverFloatingInteraction.js";
|
|
14
14
|
export { useHoverReferenceInteraction } from "./hooks/useHoverReferenceInteraction.js";
|
|
15
15
|
export { useHover } from "./hooks/useHover.js";
|
|
16
|
-
export { useInteractions } from "./hooks/useInteractions.js";
|
|
17
16
|
export { useListNavigation } from "./hooks/useListNavigation.js";
|
|
18
|
-
export { useRole } from "./hooks/useRole.js";
|
|
19
17
|
export { useTypeahead } from "./hooks/useTypeahead.js";
|
|
20
18
|
export { safePolygon } from "./safePolygon.js";
|
|
21
19
|
export type * from "./types.js";
|
|
@@ -13,9 +13,7 @@ export { useFocus } from "./hooks/useFocus.js";
|
|
|
13
13
|
export { useHoverFloatingInteraction } from "./hooks/useHoverFloatingInteraction.js";
|
|
14
14
|
export { useHoverReferenceInteraction } from "./hooks/useHoverReferenceInteraction.js";
|
|
15
15
|
export { useHover } from "./hooks/useHover.js";
|
|
16
|
-
export { useInteractions } from "./hooks/useInteractions.js";
|
|
17
16
|
export { useListNavigation } from "./hooks/useListNavigation.js";
|
|
18
|
-
export { useRole } from "./hooks/useRole.js";
|
|
19
17
|
export { useTypeahead } from "./hooks/useTypeahead.js";
|
|
20
18
|
export { safePolygon } from "./safePolygon.js";
|
|
21
19
|
export { arrow, autoPlacement, autoUpdate, computePosition, detectOverflow, flip, getOverflowAncestors, hide, inline, limitShift, offset, platform, shift, size } from '@floating-ui/react-dom';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { UseFloatingOptions as UsePositionOptions, UseFloatingReturn as UsePositionFloatingReturn, VirtualElement } from '@floating-ui/react-dom';
|
|
2
2
|
import type * as React from 'react';
|
|
3
3
|
import type { BaseUIChangeEventDetails } from "../internals/createBaseUIEventDetails.js";
|
|
4
|
-
import type { ExtendedUserProps } from "./hooks/useInteractions.js";
|
|
5
4
|
import type { FloatingTreeStore } from "./components/FloatingTreeStore.js";
|
|
6
5
|
import type { FloatingRootStore } from "./components/FloatingRootStore.js";
|
|
7
6
|
export * from "./index.js";
|
|
@@ -16,10 +15,8 @@ export type { HandleCloseContext, HandleClose } from "./hooks/useHoverShared.js"
|
|
|
16
15
|
export type { UseHoverFloatingInteractionProps } from "./hooks/useHoverFloatingInteraction.js";
|
|
17
16
|
export type { UseHoverReferenceInteractionProps } from "./hooks/useHoverReferenceInteraction.js";
|
|
18
17
|
export type { UseListNavigationProps } from "./hooks/useListNavigation.js";
|
|
19
|
-
export type { UseRoleProps } from "./hooks/useRole.js";
|
|
20
18
|
export type { UseTypeaheadProps } from "./hooks/useTypeahead.js";
|
|
21
19
|
export type { UseFloatingRootContextOptions } from "./hooks/useFloatingRootContext.js";
|
|
22
|
-
export type { UseInteractionsReturn } from "./hooks/useInteractions.js";
|
|
23
20
|
export type { SafePolygonOptions } from "./safePolygon.js";
|
|
24
21
|
export type { FloatingTreeProps, FloatingNodeProps } from "./components/FloatingTree.js";
|
|
25
22
|
export type { AlignedPlacement, Alignment, ArrowOptions, AutoPlacementOptions, AutoUpdateOptions, Axis, Boundary, ClientRectObject, ComputePositionConfig, ComputePositionReturn, Coords, DetectOverflowOptions, Dimensions, ElementContext, ElementRects, Elements, FlipOptions, FloatingElement, HideOptions, InlineOptions, Length, Middleware, MiddlewareArguments, MiddlewareData, MiddlewareReturn, MiddlewareState, NodeScroll, OffsetOptions, Padding, Placement, Platform, Rect, ReferenceElement, RootBoundary, ShiftOptions, Side, SideObject, SizeOptions, Strategy, VirtualElement } from '@floating-ui/react-dom';
|
|
@@ -51,8 +48,6 @@ export interface FloatingEvents {
|
|
|
51
48
|
export interface ContextData {
|
|
52
49
|
openEvent?: Event | undefined;
|
|
53
50
|
floatingContext?: FloatingContext | undefined;
|
|
54
|
-
/** @deprecated use `onTypingChange` prop in `useTypeahead` */
|
|
55
|
-
typing?: boolean | undefined;
|
|
56
51
|
[key: string]: any;
|
|
57
52
|
}
|
|
58
53
|
export type FloatingRootContext = FloatingRootStore;
|
|
@@ -76,7 +71,7 @@ export type FloatingTreeType = FloatingTreeStore;
|
|
|
76
71
|
export interface ElementProps {
|
|
77
72
|
reference?: React.HTMLProps<Element> | undefined;
|
|
78
73
|
floating?: React.HTMLProps<HTMLElement> | undefined;
|
|
79
|
-
item?: React.HTMLProps<HTMLElement> |
|
|
74
|
+
item?: React.HTMLProps<HTMLElement> | undefined;
|
|
80
75
|
trigger?: React.HTMLProps<Element> | undefined;
|
|
81
76
|
}
|
|
82
77
|
export type ReferenceType = Element | VirtualElement;
|
|
@@ -117,7 +112,7 @@ export interface UseFloatingOptions extends Omit<UsePositionOptions, 'elements'>
|
|
|
117
112
|
*/
|
|
118
113
|
nodeId?: string | undefined;
|
|
119
114
|
/**
|
|
120
|
-
* External
|
|
115
|
+
* External FloatingTree to use when the one provided by context can't be used.
|
|
121
116
|
*/
|
|
122
117
|
externalTree?: FloatingTreeStore | undefined;
|
|
123
118
|
}
|
|
@@ -296,6 +296,8 @@ export function createGridCellMap(sizes, cols, dense) {
|
|
|
296
296
|
}, index) => {
|
|
297
297
|
if (width > cols) {
|
|
298
298
|
if (process.env.NODE_ENV !== 'production') {
|
|
299
|
+
// TODO: fix mui/no-guarded-throw
|
|
300
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
299
301
|
throw new Error(`[Floating UI]: Invalid grid - item width at index ${index} is greater than grid columns`);
|
|
300
302
|
}
|
|
301
303
|
}
|
|
@@ -2,8 +2,8 @@ import { NOOP } from '@base-ui/utils/empty';
|
|
|
2
2
|
import type { FocusableElement } from "./tabbable.js";
|
|
3
3
|
interface Options {
|
|
4
4
|
preventScroll?: boolean | undefined;
|
|
5
|
-
cancelPrevious?: boolean | undefined;
|
|
6
5
|
sync?: boolean | undefined;
|
|
6
|
+
shouldFocus?: (() => boolean) | undefined;
|
|
7
7
|
}
|
|
8
8
|
export declare function enqueueFocus(el: FocusableElement | null, options?: Options): typeof NOOP;
|
|
9
9
|
export {};
|
|
@@ -3,15 +3,18 @@ let rafId = 0;
|
|
|
3
3
|
export function enqueueFocus(el, options = {}) {
|
|
4
4
|
const {
|
|
5
5
|
preventScroll = false,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
sync = false,
|
|
7
|
+
shouldFocus
|
|
8
8
|
} = options;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
cancelAnimationFrame(rafId);
|
|
10
|
+
function exec() {
|
|
11
|
+
if (shouldFocus && !shouldFocus()) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
el?.focus({
|
|
15
|
+
preventScroll
|
|
16
|
+
});
|
|
11
17
|
}
|
|
12
|
-
const exec = () => el?.focus({
|
|
13
|
-
preventScroll
|
|
14
|
-
});
|
|
15
18
|
if (sync) {
|
|
16
19
|
exec();
|
|
17
20
|
return NOOP;
|
package/esm/form/Form.js
CHANGED
|
@@ -61,11 +61,11 @@ export const Form = /*#__PURE__*/React.forwardRef(function Form(componentProps,
|
|
|
61
61
|
if (fieldName) {
|
|
62
62
|
const namedField = values.find(field => field.name === fieldName);
|
|
63
63
|
if (namedField) {
|
|
64
|
-
namedField.validate(
|
|
64
|
+
namedField.validate();
|
|
65
65
|
}
|
|
66
66
|
} else {
|
|
67
67
|
values.forEach(field => {
|
|
68
|
-
field.validate(
|
|
68
|
+
field.validate();
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
}, []);
|
package/esm/index.js
CHANGED
|
@@ -17,7 +17,6 @@ export declare const HORIZONTAL_KEYS_WITH_EXTRA_KEYS: Set<string>;
|
|
|
17
17
|
export declare const VERTICAL_KEYS: Set<string>;
|
|
18
18
|
export declare const VERTICAL_KEYS_WITH_EXTRA_KEYS: Set<string>;
|
|
19
19
|
export declare const ARROW_KEYS: Set<string>;
|
|
20
|
-
export declare const ALL_KEYS: Set<string>;
|
|
21
20
|
export declare const COMPOSITE_KEYS: Set<string>;
|
|
22
21
|
export declare const SHIFT: "Shift";
|
|
23
22
|
export declare const CONTROL: "Control";
|
|
@@ -13,8 +13,7 @@ export const HORIZONTAL_KEYS_WITH_EXTRA_KEYS = new Set([ARROW_LEFT, ARROW_RIGHT,
|
|
|
13
13
|
export const VERTICAL_KEYS = new Set([ARROW_UP, ARROW_DOWN]);
|
|
14
14
|
export const VERTICAL_KEYS_WITH_EXTRA_KEYS = new Set([ARROW_UP, ARROW_DOWN, HOME, END]);
|
|
15
15
|
export const ARROW_KEYS = new Set([...HORIZONTAL_KEYS, ...VERTICAL_KEYS]);
|
|
16
|
-
export const
|
|
17
|
-
export const COMPOSITE_KEYS = new Set([ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, HOME, END]);
|
|
16
|
+
export const COMPOSITE_KEYS = new Set([...ARROW_KEYS, HOME, END]);
|
|
18
17
|
export const SHIFT = 'Shift';
|
|
19
18
|
export const CONTROL = 'Control';
|
|
20
19
|
export const ALT = 'Alt';
|
|
@@ -4,7 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import { isElementDisabled } from '@base-ui/utils/isElementDisabled';
|
|
5
5
|
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
6
6
|
import { useMergedRefs } from '@base-ui/utils/useMergedRefs';
|
|
7
|
-
import {
|
|
7
|
+
import { COMPOSITE_KEYS, ARROW_DOWN, ARROW_KEYS, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, END, HOME, HORIZONTAL_KEYS, HORIZONTAL_KEYS_WITH_EXTRA_KEYS, MODIFIER_KEYS, VERTICAL_KEYS, VERTICAL_KEYS_WITH_EXTRA_KEYS, createGridCellMap, findNonDisabledListIndex, getGridCellIndexOfCorner, getGridCellIndices, getGridNavigatedIndex, getMaxListIndex, getMinListIndex, isListIndexDisabled, isIndexOutOfListBounds, isNativeInput, scrollIntoViewIfNeeded } from "../composite.js";
|
|
8
8
|
import { ACTIVE_COMPOSITE_ITEM } from "../constants.js";
|
|
9
9
|
import { getTarget } from "../../../floating-ui-react/utils.js";
|
|
10
10
|
const EMPTY_ARRAY = [];
|
|
@@ -71,7 +71,7 @@ export function useCompositeRoot(params) {
|
|
|
71
71
|
target.setSelectionRange(0, target.value.length ?? 0);
|
|
72
72
|
},
|
|
73
73
|
onKeyDown(event) {
|
|
74
|
-
const RELEVANT_KEYS = enableHomeAndEndKeys ?
|
|
74
|
+
const RELEVANT_KEYS = enableHomeAndEndKeys ? COMPOSITE_KEYS : ARROW_KEYS;
|
|
75
75
|
if (!RELEVANT_KEYS.has(event.key)) {
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
@@ -31,6 +31,8 @@ interface ReasonToEventMap {
|
|
|
31
31
|
[REASONS.cancelOpen]: MouseEvent;
|
|
32
32
|
[REASONS.siblingOpen]: Event;
|
|
33
33
|
[REASONS.disabled]: Event;
|
|
34
|
+
[REASONS.missing]: Event;
|
|
35
|
+
[REASONS.initial]: Event;
|
|
34
36
|
[REASONS.imperativeAction]: Event;
|
|
35
37
|
[REASONS.windowResize]: UIEvent;
|
|
36
38
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CSPContext, useCSPContext } from "./CSPContext.js";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { useRegisterFieldControl } from "./useRegisterFieldControl.js";
|
|
2
|
-
export type { UseRegisterFieldControlParameters } from "./useRegisterFieldControl.js";
|
|
3
2
|
export { useFieldControlRegistration } from "./useFieldControlRegistration.js";
|
|
4
3
|
export type { FieldControlRegistration, UseFieldControlRegistrationParameters } from "./useFieldControlRegistration.js";
|
|
@@ -2,8 +2,8 @@ import * as React from 'react';
|
|
|
2
2
|
import type { FieldValidityData } from "../../field/root/FieldRoot.js";
|
|
3
3
|
export interface FieldControlRegistration {
|
|
4
4
|
controlRef: React.RefObject<any>;
|
|
5
|
-
getValue?: (() => unknown) | undefined;
|
|
6
5
|
id: string | undefined;
|
|
6
|
+
getValue?: (() => unknown) | undefined;
|
|
7
7
|
value: unknown;
|
|
8
8
|
}
|
|
9
9
|
export declare function useFieldControlRegistration(params: UseFieldControlRegistrationParameters): (source: symbol, registration: FieldControlRegistration | undefined) => void;
|
|
@@ -12,6 +12,7 @@ export interface UseFieldControlRegistrationParameters {
|
|
|
12
12
|
invalid: boolean;
|
|
13
13
|
markedDirtyRef: React.RefObject<boolean>;
|
|
14
14
|
name: string | undefined;
|
|
15
|
+
setRegisteredFieldId: (id: string | undefined) => void;
|
|
15
16
|
setValidityData: React.Dispatch<React.SetStateAction<FieldValidityData>>;
|
|
16
17
|
validityData: FieldValidityData;
|
|
17
18
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import * as ReactDOM from 'react-dom';
|
|
5
4
|
import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
|
|
6
5
|
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
7
6
|
import { getCombinedFieldValidityData } from "../../field/utils/getCombinedFieldValidityData.js";
|
|
@@ -12,6 +11,7 @@ export function useFieldControlRegistration(params) {
|
|
|
12
11
|
invalid,
|
|
13
12
|
markedDirtyRef,
|
|
14
13
|
name,
|
|
14
|
+
setRegisteredFieldId,
|
|
15
15
|
setValidityData,
|
|
16
16
|
validityData
|
|
17
17
|
} = params;
|
|
@@ -21,7 +21,7 @@ export function useFieldControlRegistration(params) {
|
|
|
21
21
|
const activeFieldControlSourceRef = React.useRef(null);
|
|
22
22
|
const registrationRef = React.useRef(null);
|
|
23
23
|
const fallbackControlRef = React.useRef(null);
|
|
24
|
-
const
|
|
24
|
+
const getValueForForm = useStableCallback(() => {
|
|
25
25
|
const registration = registrationRef.current;
|
|
26
26
|
if (!registration) {
|
|
27
27
|
return undefined;
|
|
@@ -31,22 +31,17 @@ export function useFieldControlRegistration(params) {
|
|
|
31
31
|
}
|
|
32
32
|
return registration.value;
|
|
33
33
|
});
|
|
34
|
-
const validate = useStableCallback((
|
|
34
|
+
const validate = useStableCallback(() => {
|
|
35
35
|
const registration = registrationRef.current;
|
|
36
36
|
if (!registration) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
let nextValue = registration.value;
|
|
40
40
|
if (nextValue === undefined) {
|
|
41
|
-
nextValue =
|
|
41
|
+
nextValue = getValueForForm();
|
|
42
42
|
}
|
|
43
43
|
markedDirtyRef.current = true;
|
|
44
|
-
|
|
45
|
-
commit(nextValue);
|
|
46
|
-
} else {
|
|
47
|
-
// Synchronously update the validity state so the submit event can be prevented.
|
|
48
|
-
ReactDOM.flushSync(() => commit(nextValue));
|
|
49
|
-
}
|
|
44
|
+
commit(nextValue);
|
|
50
45
|
});
|
|
51
46
|
function refreshRegistration() {
|
|
52
47
|
const registration = registrationRef.current;
|
|
@@ -54,7 +49,7 @@ export function useFieldControlRegistration(params) {
|
|
|
54
49
|
return;
|
|
55
50
|
}
|
|
56
51
|
formRef.current.fields.set(registration.id, {
|
|
57
|
-
getValue,
|
|
52
|
+
getValue: getValueForForm,
|
|
58
53
|
name,
|
|
59
54
|
controlRef: registration.controlRef ?? fallbackControlRef,
|
|
60
55
|
validityData: getCombinedFieldValidityData(validityData, invalid),
|
|
@@ -73,7 +68,7 @@ export function useFieldControlRegistration(params) {
|
|
|
73
68
|
}
|
|
74
69
|
let initialValue = registration.value;
|
|
75
70
|
if (initialValue === undefined) {
|
|
76
|
-
initialValue =
|
|
71
|
+
initialValue = getValueForForm();
|
|
77
72
|
}
|
|
78
73
|
if (validityData.initialValue === null && initialValue !== null) {
|
|
79
74
|
setValidityData(prev => ({
|
|
@@ -88,13 +83,13 @@ export function useFieldControlRegistration(params) {
|
|
|
88
83
|
return;
|
|
89
84
|
}
|
|
90
85
|
formRef.current.fields.set(registration.id, {
|
|
91
|
-
getValue,
|
|
86
|
+
getValue: getValueForForm,
|
|
92
87
|
name,
|
|
93
88
|
controlRef: registration.controlRef ?? fallbackControlRef,
|
|
94
89
|
validityData: getCombinedFieldValidityData(validityData, invalid),
|
|
95
90
|
validate
|
|
96
91
|
});
|
|
97
|
-
}, [formRef,
|
|
92
|
+
}, [formRef, getValueForForm, invalid, name, validate, validityData]);
|
|
98
93
|
useIsoLayoutEffect(() => {
|
|
99
94
|
const fields = formRef.current.fields;
|
|
100
95
|
return () => {
|
|
@@ -110,12 +105,14 @@ export function useFieldControlRegistration(params) {
|
|
|
110
105
|
activeFieldControlSourceRef.current = null;
|
|
111
106
|
deleteRegistration();
|
|
112
107
|
registrationRef.current = null;
|
|
108
|
+
setRegisteredFieldId(undefined);
|
|
113
109
|
}
|
|
114
110
|
return;
|
|
115
111
|
}
|
|
116
112
|
const previousId = registrationRef.current?.id;
|
|
117
113
|
activeFieldControlSourceRef.current = source;
|
|
118
114
|
registrationRef.current = registration;
|
|
115
|
+
setRegisteredFieldId(registration.id);
|
|
119
116
|
if (previousId && previousId !== registration.id) {
|
|
120
117
|
deleteRegistration(previousId);
|
|
121
118
|
}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import type { FieldControlRegistration } from "./useFieldControlRegistration.js";
|
|
2
|
-
export
|
|
3
|
-
enabled?: boolean | undefined;
|
|
4
|
-
}
|
|
5
|
-
export declare function useRegisterFieldControl(controlRef: FieldControlRegistration['controlRef'], params: Omit<UseRegisterFieldControlParameters, 'controlRef'>): void;
|
|
2
|
+
export declare function useRegisterFieldControl(controlRef: FieldControlRegistration['controlRef'], id: FieldControlRegistration['id'], value: FieldControlRegistration['value'], getFormValueOverride?: FieldControlRegistration['getValue'], enabled?: boolean): void;
|
|
@@ -3,13 +3,7 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
|
|
5
5
|
import { useFieldRootContext } from "../field-root-context/FieldRootContext.js";
|
|
6
|
-
export function useRegisterFieldControl(controlRef,
|
|
7
|
-
const {
|
|
8
|
-
enabled = true,
|
|
9
|
-
getValue,
|
|
10
|
-
id,
|
|
11
|
-
value
|
|
12
|
-
} = params;
|
|
6
|
+
export function useRegisterFieldControl(controlRef, id, value, getFormValueOverride, enabled = true) {
|
|
13
7
|
const {
|
|
14
8
|
registerFieldControl
|
|
15
9
|
} = useFieldRootContext();
|
|
@@ -22,14 +16,15 @@ export function useRegisterFieldControl(controlRef, params) {
|
|
|
22
16
|
if (!source || !enabled) {
|
|
23
17
|
return undefined;
|
|
24
18
|
}
|
|
25
|
-
|
|
19
|
+
const registration = {
|
|
26
20
|
controlRef,
|
|
27
|
-
getValue,
|
|
21
|
+
getValue: getFormValueOverride,
|
|
28
22
|
id,
|
|
29
23
|
value
|
|
30
|
-
}
|
|
24
|
+
};
|
|
25
|
+
registerFieldControl(source, registration);
|
|
31
26
|
return () => {
|
|
32
27
|
registerFieldControl(source, undefined);
|
|
33
28
|
};
|
|
34
|
-
}, [controlRef, enabled,
|
|
29
|
+
}, [controlRef, enabled, getFormValueOverride, id, registerFieldControl, value]);
|
|
35
30
|
}
|
|
@@ -26,5 +26,6 @@ export interface FieldRootContext {
|
|
|
26
26
|
registerFieldControl: (source: symbol, registration: FieldControlRegistration | undefined) => void;
|
|
27
27
|
validation: UseFieldValidationReturnValue;
|
|
28
28
|
}
|
|
29
|
+
export declare const DEFAULT_FIELD_ROOT_CONTEXT: FieldRootContext;
|
|
29
30
|
export declare const FieldRootContext: React.Context<FieldRootContext>;
|
|
30
31
|
export declare function useFieldRootContext(optional?: boolean): FieldRootContext;
|
|
@@ -5,7 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import { EMPTY_OBJECT } from '@base-ui/utils/empty';
|
|
6
6
|
import { NOOP } from "../noop.js";
|
|
7
7
|
import { DEFAULT_FIELD_ROOT_STATE, DEFAULT_FIELD_STATE_ATTRIBUTES, DEFAULT_VALIDITY_STATE } from "../field-constants/constants.js";
|
|
8
|
-
export const
|
|
8
|
+
export const DEFAULT_FIELD_ROOT_CONTEXT = {
|
|
9
9
|
invalid: undefined,
|
|
10
10
|
name: undefined,
|
|
11
11
|
validityData: {
|
|
@@ -42,7 +42,8 @@ export const FieldRootContext = /*#__PURE__*/React.createContext({
|
|
|
42
42
|
},
|
|
43
43
|
commit: async () => {}
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
};
|
|
46
|
+
export const FieldRootContext = /*#__PURE__*/React.createContext(DEFAULT_FIELD_ROOT_CONTEXT);
|
|
46
47
|
if (process.env.NODE_ENV !== "production") FieldRootContext.displayName = "FieldRootContext";
|
|
47
48
|
export function useFieldRootContext(optional = true) {
|
|
48
49
|
const context = React.useContext(FieldRootContext);
|
|
@@ -8,7 +8,11 @@ export interface FormContext {
|
|
|
8
8
|
formRef: React.RefObject<{
|
|
9
9
|
fields: Map<string, {
|
|
10
10
|
name: string | undefined;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* After this returns, the field registry entry reflects the latest synchronous
|
|
13
|
+
* validity verdict. Async validators do not block submit.
|
|
14
|
+
*/
|
|
15
|
+
validate: () => void;
|
|
12
16
|
validityData: FieldValidityData;
|
|
13
17
|
controlRef: React.RefObject<HTMLElement | null>;
|
|
14
18
|
getValue: () => unknown;
|
|
@@ -28,6 +28,8 @@ export declare const scrub: "scrub";
|
|
|
28
28
|
export declare const cancelOpen: "cancel-open";
|
|
29
29
|
export declare const siblingOpen: "sibling-open";
|
|
30
30
|
export declare const disabled: "disabled";
|
|
31
|
+
export declare const missing: "missing";
|
|
32
|
+
export declare const initial: "initial";
|
|
31
33
|
export declare const imperativeAction: "imperative-action";
|
|
32
34
|
export declare const swipe: "swipe";
|
|
33
35
|
export declare const windowResize: "window-resize";
|
|
@@ -28,6 +28,8 @@ export const scrub = 'scrub';
|
|
|
28
28
|
export const cancelOpen = 'cancel-open';
|
|
29
29
|
export const siblingOpen = 'sibling-open';
|
|
30
30
|
export const disabled = 'disabled';
|
|
31
|
+
export const missing = 'missing';
|
|
32
|
+
export const initial = 'initial';
|
|
31
33
|
export const imperativeAction = 'imperative-action';
|
|
32
34
|
export const swipe = 'swipe';
|
|
33
35
|
export const windowResize = 'window-resize';
|
package/esm/internals/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
2
|
import type { BaseUIEvent, ComponentRenderFn, HTMLProps } from "../types/index.js";
|
|
3
3
|
export type { HTMLProps, BaseUIEvent, ComponentRenderFn };
|
|
4
|
+
export type MaybeBaseUIEvent<E extends React.SyntheticEvent<Element, Event>> = E & Partial<Pick<BaseUIEvent<E>, 'preventBaseUIHandler' | 'baseUIHandlerPrevented'>>;
|
|
4
5
|
export interface FloatingUIOpenChangeDetails {
|
|
5
6
|
open: boolean;
|
|
6
7
|
reason: string;
|
|
@@ -73,9 +73,7 @@ export function useButton(parameters = {}) {
|
|
|
73
73
|
onPointerDown: externalOnPointerDown,
|
|
74
74
|
...otherExternalProps
|
|
75
75
|
} = externalProps;
|
|
76
|
-
const type = isNativeButton ? 'button' : undefined;
|
|
77
76
|
return mergeProps({
|
|
78
|
-
type,
|
|
79
77
|
onClick(event) {
|
|
80
78
|
if (disabled) {
|
|
81
79
|
event.preventDefault();
|
|
@@ -160,9 +158,11 @@ export function useButton(parameters = {}) {
|
|
|
160
158
|
}
|
|
161
159
|
externalOnPointerDown?.(event);
|
|
162
160
|
}
|
|
163
|
-
},
|
|
161
|
+
}, isNativeButton ? {
|
|
162
|
+
type: 'button'
|
|
163
|
+
} : {
|
|
164
164
|
role: 'button'
|
|
165
|
-
}
|
|
165
|
+
}, focusableWhenDisabledProps, otherExternalProps);
|
|
166
166
|
}, [disabled, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);
|
|
167
167
|
const buttonRef = useStableCallback(element => {
|
|
168
168
|
elementRef.current = element;
|
|
@@ -55,7 +55,7 @@ export function usePressAndHold(params) {
|
|
|
55
55
|
unsubscribeFromGlobalContextMenuRef.current();
|
|
56
56
|
movesAfterTouchRef.current = 0;
|
|
57
57
|
});
|
|
58
|
-
|
|
58
|
+
function startAutoChange(triggerNativeEvent) {
|
|
59
59
|
stopAutoChange();
|
|
60
60
|
const element = elementRef.current;
|
|
61
61
|
if (!element) {
|
|
@@ -87,7 +87,7 @@ export function usePressAndHold(params) {
|
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
89
|
});
|
|
90
|
-
}
|
|
90
|
+
}
|
|
91
91
|
React.useEffect(() => () => stopAutoChange(), [stopAutoChange]);
|
|
92
92
|
const pointerHandlers = {
|
|
93
93
|
onTouchStart() {
|