@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
|
@@ -66,11 +66,11 @@ function resolveTouchAction(direction) {
|
|
|
66
66
|
*/
|
|
67
67
|
export const DrawerSwipeArea = /*#__PURE__*/React.forwardRef(function DrawerSwipeArea(componentProps, forwardedRef) {
|
|
68
68
|
const {
|
|
69
|
-
className,
|
|
70
69
|
render,
|
|
70
|
+
className,
|
|
71
|
+
style,
|
|
71
72
|
disabled = false,
|
|
72
73
|
swipeDirection: swipeDirectionProp,
|
|
73
|
-
style,
|
|
74
74
|
...elementProps
|
|
75
75
|
} = componentProps;
|
|
76
76
|
const {
|
|
@@ -96,13 +96,13 @@ export const DrawerSwipeArea = /*#__PURE__*/React.forwardRef(function DrawerSwip
|
|
|
96
96
|
const swipeAreaId = useBaseUiId(componentProps.id);
|
|
97
97
|
const registerTrigger = useTriggerRegistration(swipeAreaId, store);
|
|
98
98
|
const open = store.useState('open');
|
|
99
|
-
const resolvedSwipeDirection = swipeDirectionProp ?? oppositeSwipeDirection[swipeDirection];
|
|
100
|
-
const dismissDirection = oppositeSwipeDirection[resolvedSwipeDirection];
|
|
101
|
-
const enabled = !disabled && (!open || swipeActive);
|
|
102
99
|
const resetDragDelta = useStableCallback(() => {
|
|
103
100
|
dragDeltaRef.current.x = 0;
|
|
104
101
|
dragDeltaRef.current.y = 0;
|
|
105
102
|
});
|
|
103
|
+
const resolvedSwipeDirection = swipeDirectionProp ?? oppositeSwipeDirection[swipeDirection];
|
|
104
|
+
const dismissDirection = oppositeSwipeDirection[resolvedSwipeDirection];
|
|
105
|
+
const enabled = !disabled && (!open || swipeActive);
|
|
106
106
|
function disableDismissForSwipe() {
|
|
107
107
|
releaseDismissTimeout.clear();
|
|
108
108
|
store.context.outsidePressEnabledRef.current = false;
|
|
@@ -355,6 +355,7 @@ export const DrawerSwipeArea = /*#__PURE__*/React.forwardRef(function DrawerSwip
|
|
|
355
355
|
return;
|
|
356
356
|
}
|
|
357
357
|
swipePointerProps.onPointerDown?.(event);
|
|
358
|
+
|
|
358
359
|
// Prevent native text selection/drag gestures from competing with swipe-open dragging.
|
|
359
360
|
if (event.cancelable) {
|
|
360
361
|
event.preventDefault();
|
|
@@ -48,8 +48,8 @@ const DRAWER_CONTENT_SELECTOR = `[${DRAWER_CONTENT_ATTRIBUTE}]`;
|
|
|
48
48
|
*/
|
|
49
49
|
export const DrawerViewport = /*#__PURE__*/React.forwardRef(function DrawerViewport(props, forwardedRef) {
|
|
50
50
|
const {
|
|
51
|
-
className,
|
|
52
51
|
render,
|
|
52
|
+
className,
|
|
53
53
|
style,
|
|
54
54
|
children,
|
|
55
55
|
...elementProps
|
|
@@ -65,25 +65,25 @@ export const DrawerViewport = /*#__PURE__*/React.forwardRef(function DrawerViewp
|
|
|
65
65
|
snapToSequentialPoints
|
|
66
66
|
} = useDrawerRootContext();
|
|
67
67
|
const providerContext = useDrawerProviderContext(true);
|
|
68
|
-
const
|
|
68
|
+
const {
|
|
69
|
+
snapPoints,
|
|
70
|
+
resolvedSnapPoints,
|
|
71
|
+
activeSnapPoint,
|
|
72
|
+
activeSnapPointOffset,
|
|
73
|
+
setActiveSnapPoint,
|
|
74
|
+
popupHeight
|
|
75
|
+
} = useDrawerSnapPoints();
|
|
69
76
|
const open = store.useState('open');
|
|
70
77
|
const mounted = store.useState('mounted');
|
|
71
78
|
const nested = store.useState('nested');
|
|
72
79
|
const nestedOpenDrawerCount = store.useState('nestedOpenDrawerCount');
|
|
73
80
|
const viewportElement = store.useState('viewportElement');
|
|
74
81
|
const popupElementState = store.useState('popupElement');
|
|
82
|
+
const visualStateStore = providerContext?.visualStateStore;
|
|
75
83
|
const nestedDrawerOpen = nestedOpenDrawerCount > 0;
|
|
76
84
|
const scrollAxis = swipeDirection === 'left' || swipeDirection === 'right' ? 'horizontal' : 'vertical';
|
|
77
85
|
const isVerticalScrollAxis = scrollAxis === 'vertical';
|
|
78
86
|
const crossScrollAxis = isVerticalScrollAxis ? 'horizontal' : 'vertical';
|
|
79
|
-
const {
|
|
80
|
-
snapPoints,
|
|
81
|
-
resolvedSnapPoints,
|
|
82
|
-
activeSnapPoint,
|
|
83
|
-
activeSnapPointOffset,
|
|
84
|
-
setActiveSnapPoint,
|
|
85
|
-
popupHeight
|
|
86
|
-
} = useDrawerSnapPoints();
|
|
87
87
|
const [swipeRelease, setSwipeRelease] = React.useState(null);
|
|
88
88
|
const pendingSwipeCloseSnapPointRef = React.useRef(undefined);
|
|
89
89
|
const resetSwipeRef = React.useRef(null);
|
|
@@ -696,10 +696,8 @@ export const DrawerViewport = /*#__PURE__*/React.forwardRef(function DrawerViewp
|
|
|
696
696
|
swiping: swipe.swiping,
|
|
697
697
|
getDragStyles: swipe.getDragStyles,
|
|
698
698
|
swipeStrength: swipeRelease ?? null,
|
|
699
|
-
setSwipeDismissed
|
|
700
|
-
|
|
701
|
-
}
|
|
702
|
-
}), [store, swipe.getDragStyles, swipe.swiping, swipeRelease]);
|
|
699
|
+
setSwipeDismissed
|
|
700
|
+
}), [setSwipeDismissed, swipe.getDragStyles, swipe.swiping, swipeRelease]);
|
|
703
701
|
function resetTouchTrackingState() {
|
|
704
702
|
ignoreTouchSwipeRef.current = false;
|
|
705
703
|
touchScrollStateRef.current = null;
|
|
@@ -709,6 +707,7 @@ export const DrawerViewport = /*#__PURE__*/React.forwardRef(function DrawerViewp
|
|
|
709
707
|
return /*#__PURE__*/_jsx(DialogViewport, {
|
|
710
708
|
ref: forwardedRef,
|
|
711
709
|
className: className,
|
|
710
|
+
style: style,
|
|
712
711
|
render: render,
|
|
713
712
|
...mergeProps(elementProps, {
|
|
714
713
|
onPointerDown(event) {
|
|
@@ -85,12 +85,8 @@ export const FieldControl = /*#__PURE__*/React.forwardRef(function FieldControl(
|
|
|
85
85
|
});
|
|
86
86
|
const isControlled = valueProp !== undefined;
|
|
87
87
|
const value = isControlled ? valueUnwrapped : undefined;
|
|
88
|
-
const
|
|
89
|
-
useRegisterFieldControl(validation.inputRef,
|
|
90
|
-
id,
|
|
91
|
-
value,
|
|
92
|
-
getValue: getFieldValue
|
|
93
|
-
});
|
|
88
|
+
const getValueFromInput = useStableCallback(() => validation.inputRef.current?.value);
|
|
89
|
+
useRegisterFieldControl(validation.inputRef, id, value, getValueFromInput);
|
|
94
90
|
const element = useRenderElement('input', componentProps, {
|
|
95
91
|
ref: [forwardedRef, inputRef],
|
|
96
92
|
state,
|
|
@@ -29,11 +29,8 @@ export const FieldItem = /*#__PURE__*/React.forwardRef(function FieldItem(compon
|
|
|
29
29
|
} = useFieldRootContext(false);
|
|
30
30
|
const disabled = rootDisabled || disabledProp;
|
|
31
31
|
const checkboxGroupContext = useCheckboxGroupContext();
|
|
32
|
-
// checkboxGroupContext.parent is truthy even if no parent checkbox is involved
|
|
33
|
-
const parentId = checkboxGroupContext?.parent.id;
|
|
34
|
-
// this a more reliable check
|
|
35
32
|
const hasParentCheckbox = checkboxGroupContext?.allValues !== undefined;
|
|
36
|
-
const controlId = hasParentCheckbox ?
|
|
33
|
+
const controlId = hasParentCheckbox ? checkboxGroupContext?.parent.id : undefined;
|
|
37
34
|
const fieldItemContext = React.useMemo(() => ({
|
|
38
35
|
disabled
|
|
39
36
|
}), [disabled]);
|
|
@@ -48,6 +48,11 @@ const FieldRootInner = /*#__PURE__*/React.forwardRef(function FieldRootInner(com
|
|
|
48
48
|
const dirty = dirtyProp ?? dirtyState;
|
|
49
49
|
const touched = touchedProp ?? touchedState;
|
|
50
50
|
const markedDirtyRef = React.useRef(false);
|
|
51
|
+
const registeredFieldIdRef = React.useRef(undefined);
|
|
52
|
+
const getRegisteredFieldId = React.useCallback(() => registeredFieldIdRef.current, []);
|
|
53
|
+
const setRegisteredFieldId = React.useCallback(id => {
|
|
54
|
+
registeredFieldIdRef.current = id;
|
|
55
|
+
}, []);
|
|
51
56
|
const setDirty = useStableCallback(value => {
|
|
52
57
|
if (dirtyProp !== undefined) {
|
|
53
58
|
return;
|
|
@@ -91,17 +96,20 @@ const FieldRootInner = /*#__PURE__*/React.forwardRef(function FieldRootInner(com
|
|
|
91
96
|
markedDirtyRef,
|
|
92
97
|
state,
|
|
93
98
|
name,
|
|
94
|
-
shouldValidateOnChange
|
|
99
|
+
shouldValidateOnChange,
|
|
100
|
+
getRegisteredFieldId
|
|
95
101
|
});
|
|
102
|
+
const validityValue = validityData.value;
|
|
96
103
|
const handleImperativeValidate = React.useCallback(() => {
|
|
97
104
|
markedDirtyRef.current = true;
|
|
98
|
-
validation.commit(
|
|
99
|
-
}, [validation,
|
|
105
|
+
validation.commit(validityValue);
|
|
106
|
+
}, [validation, validityValue]);
|
|
100
107
|
const registerFieldControl = useFieldControlRegistration({
|
|
101
108
|
commit: validation.commit,
|
|
102
109
|
invalid,
|
|
103
110
|
markedDirtyRef,
|
|
104
111
|
name,
|
|
112
|
+
setRegisteredFieldId,
|
|
105
113
|
setValidityData,
|
|
106
114
|
validityData
|
|
107
115
|
});
|
|
@@ -13,6 +13,7 @@ export interface UseFieldValidationParameters {
|
|
|
13
13
|
state: FieldRootState;
|
|
14
14
|
name: string | undefined;
|
|
15
15
|
shouldValidateOnChange: () => boolean;
|
|
16
|
+
getRegisteredFieldId: () => string | undefined;
|
|
16
17
|
}
|
|
17
18
|
export interface UseFieldValidationReturnValue {
|
|
18
19
|
getValidationProps: (props?: HTMLProps) => HTMLProps;
|
|
@@ -42,7 +42,8 @@ export function useFieldValidation(params) {
|
|
|
42
42
|
markedDirtyRef,
|
|
43
43
|
state,
|
|
44
44
|
name,
|
|
45
|
-
shouldValidateOnChange
|
|
45
|
+
shouldValidateOnChange,
|
|
46
|
+
getRegisteredFieldId
|
|
46
47
|
} = params;
|
|
47
48
|
const {
|
|
48
49
|
controlId,
|
|
@@ -55,6 +56,21 @@ export function useFieldValidation(params) {
|
|
|
55
56
|
if (!element) {
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
59
|
+
function updateRegisteredFieldValidity(nextValidityData, externalInvalid = invalid) {
|
|
60
|
+
const fieldId = getRegisteredFieldId() ?? controlId;
|
|
61
|
+
if (fieldId == null) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const currentFieldData = formRef.current.fields.get(fieldId);
|
|
65
|
+
if (!currentFieldData) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const validityDataWithFormErrors = getCombinedFieldValidityData(nextValidityData, externalInvalid);
|
|
69
|
+
formRef.current.fields.set(fieldId, {
|
|
70
|
+
...currentFieldData,
|
|
71
|
+
validityData: validityDataWithFormErrors
|
|
72
|
+
});
|
|
73
|
+
}
|
|
58
74
|
if (revalidate) {
|
|
59
75
|
if (state.valid !== false) {
|
|
60
76
|
return;
|
|
@@ -75,15 +91,9 @@ export function useFieldValidation(params) {
|
|
|
75
91
|
initialValue: validityData.initialValue
|
|
76
92
|
};
|
|
77
93
|
element.setCustomValidity('');
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
formRef.current.fields.set(controlId, {
|
|
82
|
-
...currentFieldData,
|
|
83
|
-
...getCombinedFieldValidityData(nextValidityData, false) // invalid = false
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
94
|
+
|
|
95
|
+
// The required value is now present; ignore stale external invalid state for this pass.
|
|
96
|
+
updateRegisteredFieldValidity(nextValidityData, false);
|
|
87
97
|
setValidityData(nextValidityData);
|
|
88
98
|
return;
|
|
89
99
|
}
|
|
@@ -186,16 +196,9 @@ export function useFieldValidation(params) {
|
|
|
186
196
|
errors: validationErrors,
|
|
187
197
|
initialValue: validityData.initialValue
|
|
188
198
|
};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
formRef.current.fields.set(controlId, {
|
|
193
|
-
...currentFieldData,
|
|
194
|
-
// Keep Form-level errors part of overall field validity for submit blocking/focus logic.
|
|
195
|
-
...getCombinedFieldValidityData(nextValidityData, invalid)
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
+
|
|
200
|
+
// Keep Form-level errors part of overall field validity for submit blocking/focus logic.
|
|
201
|
+
updateRegisteredFieldValidity(nextValidityData);
|
|
199
202
|
setValidityData(nextValidityData);
|
|
200
203
|
});
|
|
201
204
|
const getValidationProps = React.useCallback((externalProps = {}) => mergeProps(getDescriptionProps, state.valid === false ? {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { FieldValidityData } from "../root/FieldRoot.js";
|
|
2
|
+
import type { FieldValidityData } from "../root/FieldRoot.js";
|
|
3
3
|
import { type TransitionStatus } from "../../internals/useTransitionStatus.js";
|
|
4
4
|
/**
|
|
5
5
|
* Used to display a custom message based on the field's validity.
|
|
@@ -68,11 +68,11 @@ export function FloatingDelayGroup(props) {
|
|
|
68
68
|
export function useDelayGroup(context, options = {
|
|
69
69
|
open: false
|
|
70
70
|
}) {
|
|
71
|
-
const store = 'rootStore' in context ? context.rootStore : context;
|
|
72
|
-
const floatingId = store.useState('floatingId');
|
|
73
71
|
const {
|
|
74
72
|
open
|
|
75
73
|
} = options;
|
|
74
|
+
const store = 'rootStore' in context ? context.rootStore : context;
|
|
75
|
+
const floatingId = store.useState('floatingId');
|
|
76
76
|
const groupContext = React.useContext(FloatingDelayGroupContext);
|
|
77
77
|
const {
|
|
78
78
|
currentIdRef,
|
|
@@ -141,7 +141,7 @@ export function useDelayGroup(context, options = {
|
|
|
141
141
|
setIsInstantPhase(false);
|
|
142
142
|
prevContext?.setIsInstantPhase(false);
|
|
143
143
|
}
|
|
144
|
-
}, [open, floatingId, store, currentIdRef, delayRef,
|
|
144
|
+
}, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
|
|
145
145
|
useIsoLayoutEffect(() => {
|
|
146
146
|
return () => {
|
|
147
147
|
currentContextRef.current = null;
|
|
@@ -83,7 +83,7 @@ export interface FloatingFocusManagerProps {
|
|
|
83
83
|
*/
|
|
84
84
|
beforeContentFocusGuardRef?: React.RefObject<HTMLSpanElement | null> | undefined;
|
|
85
85
|
/**
|
|
86
|
-
* External
|
|
86
|
+
* External FloatingTree to use when the one provided by context can't be used.
|
|
87
87
|
*/
|
|
88
88
|
externalTree?: FloatingTreeStore | undefined;
|
|
89
89
|
/**
|
|
@@ -180,7 +180,7 @@ export function FloatingFocusManager(props) {
|
|
|
180
180
|
}
|
|
181
181
|
const doc = ownerDocument(floatingFocusElement);
|
|
182
182
|
return addEventListener(doc, 'keydown', onKeyDown);
|
|
183
|
-
}, [disabled,
|
|
183
|
+
}, [disabled, floatingFocusElement, modal, isUntrappedTypeableCombobox, getTabbableContent]);
|
|
184
184
|
|
|
185
185
|
// Track pointer/keyboard interactions to disambiguate focus and outside presses.
|
|
186
186
|
React.useEffect(() => {
|
|
@@ -329,7 +329,7 @@ export function FloatingFocusManager(props) {
|
|
|
329
329
|
markerCleanup();
|
|
330
330
|
ariaHiddenCleanup();
|
|
331
331
|
};
|
|
332
|
-
}, [open, disabled, domReference, floating, modal,
|
|
332
|
+
}, [open, disabled, domReference, floating, modal, portalContext, isUntrappedTypeableCombobox, tree, getNodeId, nextFocusableElement, previousFocusableElement, getResolvedInsideElements]);
|
|
333
333
|
|
|
334
334
|
// Focus the initial element when the floating element opens.
|
|
335
335
|
useIsoLayoutEffect(() => {
|
|
@@ -366,11 +366,20 @@ export function FloatingFocusManager(props) {
|
|
|
366
366
|
elToFocus = resolveRef(resolvedInitialFocus);
|
|
367
367
|
}
|
|
368
368
|
elToFocus = elToFocus || getDefaultFocusElement();
|
|
369
|
+
const hadFocusInside = contains(floatingFocusElement, activeElement(doc));
|
|
369
370
|
enqueueFocus(elToFocus, {
|
|
370
|
-
preventScroll: elToFocus === floatingFocusElement
|
|
371
|
+
preventScroll: elToFocus === floatingFocusElement,
|
|
372
|
+
shouldFocus() {
|
|
373
|
+
if (hadFocusInside) {
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
const currentActiveElement = activeElement(doc);
|
|
377
|
+
const focusMovedInside = currentActiveElement !== elToFocus && contains(floatingFocusElement, currentActiveElement);
|
|
378
|
+
return !focusMovedInside;
|
|
379
|
+
}
|
|
371
380
|
});
|
|
372
381
|
});
|
|
373
|
-
}, [disabled, open, floatingFocusElement,
|
|
382
|
+
}, [disabled, open, floatingFocusElement, getTabbableContent, initialFocusRef, openInteractionTypeRef]);
|
|
374
383
|
|
|
375
384
|
// Track return focus targets and restore focus on unmount/close.
|
|
376
385
|
useIsoLayoutEffect(() => {
|
|
@@ -425,10 +434,12 @@ export function FloatingFocusManager(props) {
|
|
|
425
434
|
resolvedReturnFocusValue = true;
|
|
426
435
|
}
|
|
427
436
|
if (typeof resolvedReturnFocusValue === 'boolean') {
|
|
428
|
-
|
|
429
|
-
|
|
437
|
+
if (domReference?.isConnected) {
|
|
438
|
+
return domReference;
|
|
439
|
+
}
|
|
440
|
+
return getPreviouslyFocusedElement() || null;
|
|
430
441
|
}
|
|
431
|
-
const fallback = domReference
|
|
442
|
+
const fallback = domReference?.isConnected ? domReference : getPreviouslyFocusedElement();
|
|
432
443
|
return resolveRef(resolvedReturnFocusValue) || fallback || null;
|
|
433
444
|
}
|
|
434
445
|
return () => {
|
|
@@ -456,7 +467,7 @@ export function FloatingFocusManager(props) {
|
|
|
456
467
|
preventReturnFocusRef.current = false;
|
|
457
468
|
});
|
|
458
469
|
};
|
|
459
|
-
}, [disabled, floating, floatingFocusElement, returnFocusRef,
|
|
470
|
+
}, [disabled, floating, floatingFocusElement, returnFocusRef, events, tree, domReference, getNodeId, getResolvedInsideElements]);
|
|
460
471
|
|
|
461
472
|
// Safari may randomly scroll to the bottom of the page if an input inside a popup has focus
|
|
462
473
|
// when the popup unmounts from the DOM.
|
|
@@ -473,6 +484,7 @@ export function FloatingFocusManager(props) {
|
|
|
473
484
|
activeEl.blur();
|
|
474
485
|
}
|
|
475
486
|
}, [open, floating]);
|
|
487
|
+
|
|
476
488
|
// Synchronize the `context` & `modal` value to the FloatingPortal context.
|
|
477
489
|
// It will decide whether or not it needs to render its own guards.
|
|
478
490
|
useIsoLayoutEffect(() => {
|
|
@@ -100,12 +100,12 @@ export function useFloatingPortalNode(props = {}) {
|
|
|
100
100
|
*/
|
|
101
101
|
export const FloatingPortal = /*#__PURE__*/React.forwardRef(function FloatingPortal(componentProps, forwardedRef) {
|
|
102
102
|
const {
|
|
103
|
+
render,
|
|
104
|
+
className,
|
|
105
|
+
style,
|
|
103
106
|
children,
|
|
104
107
|
container,
|
|
105
|
-
className,
|
|
106
|
-
render,
|
|
107
108
|
renderGuards,
|
|
108
|
-
style,
|
|
109
109
|
...elementProps
|
|
110
110
|
} = componentProps;
|
|
111
111
|
const {
|
|
@@ -5,7 +5,7 @@ import { useAnimationFrame } from '@base-ui/utils/useAnimationFrame';
|
|
|
5
5
|
import { useTimeout } from '@base-ui/utils/useTimeout';
|
|
6
6
|
import { EMPTY_OBJECT } from '@base-ui/utils/empty';
|
|
7
7
|
import { getTarget, isTypeableElement } from "../utils/element.js";
|
|
8
|
-
import {
|
|
8
|
+
import { isMouseLikePointerType } from "../utils/event.js";
|
|
9
9
|
import { createChangeEventDetails } from "../../internals/createBaseUIEventDetails.js";
|
|
10
10
|
import { REASONS } from "../../internals/reasons.js";
|
|
11
11
|
/**
|
|
@@ -13,8 +13,6 @@ import { REASONS } from "../../internals/reasons.js";
|
|
|
13
13
|
* @see https://floating-ui.com/docs/useClick
|
|
14
14
|
*/
|
|
15
15
|
export function useClick(context, props = {}) {
|
|
16
|
-
const store = 'rootStore' in context ? context.rootStore : context;
|
|
17
|
-
const dataRef = store.context.dataRef;
|
|
18
16
|
const {
|
|
19
17
|
enabled = true,
|
|
20
18
|
event: eventOption = 'click',
|
|
@@ -24,89 +22,100 @@ export function useClick(context, props = {}) {
|
|
|
24
22
|
touchOpenDelay = 0,
|
|
25
23
|
reason = REASONS.triggerPress
|
|
26
24
|
} = props;
|
|
25
|
+
const store = 'rootStore' in context ? context.rootStore : context;
|
|
26
|
+
const dataRef = store.context.dataRef;
|
|
27
27
|
const pointerTypeRef = React.useRef(undefined);
|
|
28
28
|
const frame = useAnimationFrame();
|
|
29
29
|
const touchOpenTimeout = useTimeout();
|
|
30
|
-
const reference = React.useMemo(() =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// Ignore all buttons except for the "main" button.
|
|
40
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
|
|
41
|
-
if (event.button !== 0 || eventOption === 'click' || isMouseLikePointerType(pointerType, true) && ignoreMouse) {
|
|
42
|
-
return;
|
|
30
|
+
const reference = React.useMemo(() => {
|
|
31
|
+
function setOpenWithTouchDelay(nextOpen, nativeEvent, target, pointerType) {
|
|
32
|
+
const details = createChangeEventDetails(reason, nativeEvent, target);
|
|
33
|
+
if (nextOpen && pointerType === 'touch' && touchOpenDelay > 0) {
|
|
34
|
+
touchOpenTimeout.start(touchOpenDelay, () => {
|
|
35
|
+
store.setOpen(true, details);
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
store.setOpen(nextOpen, details);
|
|
43
39
|
}
|
|
40
|
+
}
|
|
41
|
+
function getNextOpen(open, currentTarget, isClickLikeOpenEvent) {
|
|
44
42
|
const openEvent = dataRef.current.openEvent;
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
const hasClickedOnInactiveTrigger = store.select('domReferenceElement') !== currentTarget;
|
|
44
|
+
if (open && hasClickedOnInactiveTrigger) {
|
|
45
|
+
// Moving between triggers should always open the newly active one.
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
if (!open) {
|
|
49
|
+
// A closed popup should open on the next press.
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if (!toggle) {
|
|
53
|
+
// Non-toggle mode never closes on a repeated trigger press.
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
if (openEvent && stickIfOpen) {
|
|
57
|
+
// Preserve hover/focus-opened popups until the matching click-like event closes them.
|
|
58
|
+
return !isClickLikeOpenEvent(openEvent.type);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Otherwise, a repeated click toggles the popup closed.
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
onPointerDown(event) {
|
|
66
|
+
pointerTypeRef.current = event.pointerType;
|
|
67
|
+
},
|
|
68
|
+
onMouseDown(event) {
|
|
69
|
+
const pointerType = pointerTypeRef.current;
|
|
70
|
+
const nativeEvent = event.nativeEvent;
|
|
71
|
+
const open = store.select('open');
|
|
48
72
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
// Ignore all buttons except for the "main" button.
|
|
74
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
|
|
75
|
+
if (event.button !== 0 || eventOption === 'click' || isMouseLikePointerType(pointerType, true) && ignoreMouse) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const nextOpen = getNextOpen(open, event.currentTarget, openEventType => openEventType === 'click' || openEventType === 'mousedown');
|
|
79
|
+
|
|
80
|
+
// Animations sometimes won't run on a typeable element if using a rAF.
|
|
81
|
+
// Focus is always set on these elements. For touch, we may delay opening.
|
|
82
|
+
const target = getTarget(nativeEvent);
|
|
83
|
+
if (isTypeableElement(target)) {
|
|
84
|
+
setOpenWithTouchDelay(nextOpen, nativeEvent, target, pointerType);
|
|
85
|
+
return;
|
|
60
86
|
}
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
87
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
88
|
+
// Capture the currentTarget before the rAF.
|
|
89
|
+
// as React sets it to null after the event handler completes.
|
|
90
|
+
const eventCurrentTarget = event.currentTarget;
|
|
67
91
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
store.setOpen(nextOpen, details);
|
|
92
|
+
// Wait until focus is set on the element. This is an alternative to
|
|
93
|
+
// `event.preventDefault()` to avoid :focus-visible from appearing when using a pointer.
|
|
94
|
+
frame.request(() => {
|
|
95
|
+
setOpenWithTouchDelay(nextOpen, nativeEvent, eventCurrentTarget, pointerType);
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
onClick(event) {
|
|
99
|
+
if (eventOption === 'mousedown-only') {
|
|
100
|
+
return;
|
|
78
101
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
102
|
+
const pointerType = pointerTypeRef.current;
|
|
103
|
+
if (eventOption === 'mousedown' && pointerType) {
|
|
104
|
+
pointerTypeRef.current = undefined;
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (isMouseLikePointerType(pointerType, true) && ignoreMouse) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const open = store.select('open');
|
|
111
|
+
const nextOpen = getNextOpen(open, event.currentTarget, openEventType => openEventType === 'click' || openEventType === 'mousedown' || openEventType === 'keydown' || openEventType === 'keyup');
|
|
112
|
+
setOpenWithTouchDelay(nextOpen, event.nativeEvent, event.currentTarget, pointerType);
|
|
113
|
+
},
|
|
114
|
+
onKeyDown() {
|
|
87
115
|
pointerTypeRef.current = undefined;
|
|
88
|
-
return;
|
|
89
116
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
const open = store.select('open');
|
|
94
|
-
const openEvent = dataRef.current.openEvent;
|
|
95
|
-
const hasClickedOnInactiveTrigger = store.select('domReferenceElement') !== event.currentTarget;
|
|
96
|
-
const nextOpen = open && hasClickedOnInactiveTrigger || !(open && toggle && (openEvent && stickIfOpen ? isClickLikeEvent(openEvent) : true));
|
|
97
|
-
const details = createChangeEventDetails(reason, event.nativeEvent, event.currentTarget);
|
|
98
|
-
if (nextOpen && pointerType === 'touch' && touchOpenDelay > 0) {
|
|
99
|
-
touchOpenTimeout.start(touchOpenDelay, () => {
|
|
100
|
-
store.setOpen(true, details);
|
|
101
|
-
});
|
|
102
|
-
} else {
|
|
103
|
-
store.setOpen(nextOpen, details);
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
onKeyDown() {
|
|
107
|
-
pointerTypeRef.current = undefined;
|
|
108
|
-
}
|
|
109
|
-
}), [dataRef, eventOption, ignoreMouse, store, stickIfOpen, toggle, frame, touchOpenTimeout, touchOpenDelay, reason]);
|
|
117
|
+
};
|
|
118
|
+
}, [dataRef, eventOption, ignoreMouse, reason, store, stickIfOpen, toggle, frame, touchOpenTimeout, touchOpenDelay]);
|
|
110
119
|
return React.useMemo(() => enabled ? {
|
|
111
120
|
reference
|
|
112
121
|
} : EMPTY_OBJECT, [enabled, reference]);
|