@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
|
@@ -31,8 +31,7 @@ export const SelectItemIndicator = /*#__PURE__*/React.forwardRef(function Select
|
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
* costs unless the element needs to be mounted. */
|
|
34
|
+
// Split the core implementation to avoid paying the hook costs unless the element needs to mount.
|
|
36
35
|
if (process.env.NODE_ENV !== "production") SelectItemIndicator.displayName = "SelectItemIndicator";
|
|
37
36
|
const Inner = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef((componentProps, forwardedRef) => {
|
|
38
37
|
const {
|
|
@@ -13,29 +13,32 @@ import { useRenderElement } from "../../internals/useRenderElement.js";
|
|
|
13
13
|
*/
|
|
14
14
|
export const SelectItemText = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(function SelectItemText(componentProps, forwardedRef) {
|
|
15
15
|
const {
|
|
16
|
-
|
|
16
|
+
index,
|
|
17
17
|
textRef,
|
|
18
18
|
selectedByFocus,
|
|
19
19
|
hasRegistered
|
|
20
20
|
} = useSelectItemContext();
|
|
21
21
|
const {
|
|
22
|
+
firstItemTextRef,
|
|
22
23
|
selectedItemTextRef
|
|
23
24
|
} = useSelectRootContext();
|
|
24
25
|
const {
|
|
25
|
-
className,
|
|
26
26
|
render,
|
|
27
|
+
className,
|
|
27
28
|
style,
|
|
28
29
|
...elementProps
|
|
29
30
|
} = componentProps;
|
|
30
31
|
const localRef = React.useCallback(node => {
|
|
31
|
-
if (!node
|
|
32
|
+
if (!node) {
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
if (hasRegistered && index === 0) {
|
|
36
|
+
firstItemTextRef.current = node;
|
|
37
|
+
}
|
|
38
|
+
if (hasRegistered && selectedByFocus) {
|
|
36
39
|
selectedItemTextRef.current = node;
|
|
37
40
|
}
|
|
38
|
-
}, [selectedItemTextRef,
|
|
41
|
+
}, [firstItemTextRef, selectedItemTextRef, index, selectedByFocus, hasRegistered]);
|
|
39
42
|
const element = useRenderElement('div', componentProps, {
|
|
40
43
|
ref: [localRef, forwardedRef, textRef],
|
|
41
44
|
props: elementProps
|
|
@@ -18,8 +18,8 @@ import { selectors } from "../store.js";
|
|
|
18
18
|
*/
|
|
19
19
|
export const SelectList = /*#__PURE__*/React.forwardRef(function SelectList(componentProps, forwardedRef) {
|
|
20
20
|
const {
|
|
21
|
-
className,
|
|
22
21
|
render,
|
|
22
|
+
className,
|
|
23
23
|
style,
|
|
24
24
|
...elementProps
|
|
25
25
|
} = componentProps;
|
|
@@ -26,7 +26,7 @@ import { COMPOSITE_KEYS } from "../../internals/composite/composite.js";
|
|
|
26
26
|
import { getDisabledMountTransitionStyles } from "../../utils/getDisabledMountTransitionStyles.js";
|
|
27
27
|
import { clamp } from "../../internals/clamp.js";
|
|
28
28
|
import { getMaxScrollOffset, SCROLL_EDGE_TOLERANCE_PX } from "../../utils/scrollEdges.js";
|
|
29
|
-
import { useCSPContext } from "../../csp-
|
|
29
|
+
import { useCSPContext } from "../../internals/csp-context/CSPContext.js";
|
|
30
30
|
import { useDirection } from "../../internals/direction-context/DirectionContext.js";
|
|
31
31
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
32
32
|
const stateAttributesMapping = {
|
|
@@ -54,6 +54,7 @@ export const SelectPopup = /*#__PURE__*/React.forwardRef(function SelectPopup(co
|
|
|
54
54
|
onOpenChangeComplete,
|
|
55
55
|
setOpen,
|
|
56
56
|
valueRef,
|
|
57
|
+
firstItemTextRef,
|
|
57
58
|
selectedItemTextRef,
|
|
58
59
|
keyboardActiveRef,
|
|
59
60
|
multiple,
|
|
@@ -233,7 +234,11 @@ export const SelectPopup = /*#__PURE__*/React.forwardRef(function SelectPopup(co
|
|
|
233
234
|
const restoreTransformStyles = unsetTransformStyles(popupElement);
|
|
234
235
|
popupElement.style.removeProperty('--transform-origin');
|
|
235
236
|
try {
|
|
236
|
-
|
|
237
|
+
let textElement = selectedItemTextRef.current;
|
|
238
|
+
if (!textElement?.isConnected) {
|
|
239
|
+
const hasSelectedValue = selectors.hasSelectedValue(store.state);
|
|
240
|
+
textElement = !hasSelectedValue && firstItemTextRef.current?.isConnected ? firstItemTextRef.current : null;
|
|
241
|
+
}
|
|
237
242
|
const valueElement = valueRef.current;
|
|
238
243
|
const positionerStyles = getComputedStyle(positionerElement);
|
|
239
244
|
const popupStyles = getComputedStyle(popupElement);
|
|
@@ -325,7 +330,7 @@ export const SelectPopup = /*#__PURE__*/React.forwardRef(function SelectPopup(co
|
|
|
325
330
|
} finally {
|
|
326
331
|
restoreTransformStyles();
|
|
327
332
|
}
|
|
328
|
-
}, [store, open, positionerElement, triggerElement, valueRef, selectedItemTextRef, popupRef, handleScrollArrowVisibility, alignItemWithTriggerActive, setControlledAlignItemWithTrigger, scrollArrowFrame, scrollDownArrowRef, scrollUpArrowRef, listElement, listRef, highlightItemOnHover, direction, isPositioned]);
|
|
333
|
+
}, [store, open, positionerElement, triggerElement, valueRef, firstItemTextRef, selectedItemTextRef, popupRef, handleScrollArrowVisibility, alignItemWithTriggerActive, setControlledAlignItemWithTrigger, scrollArrowFrame, scrollDownArrowRef, scrollUpArrowRef, listElement, listRef, highlightItemOnHover, direction, isPositioned]);
|
|
329
334
|
React.useEffect(() => {
|
|
330
335
|
if (!alignItemWithTriggerActive || !positionerElement || !open) {
|
|
331
336
|
return undefined;
|
|
@@ -114,6 +114,9 @@ export const SelectPositioner = /*#__PURE__*/React.forwardRef(function SelectPos
|
|
|
114
114
|
align: positioning.align,
|
|
115
115
|
anchorHidden: positioning.anchorHidden
|
|
116
116
|
};
|
|
117
|
+
useIsoLayoutEffect(() => {
|
|
118
|
+
store.set('popupSide', positioning.side);
|
|
119
|
+
}, [store, positioning.side]);
|
|
117
120
|
const setPositionerElement = useStableCallback(element => {
|
|
118
121
|
store.set('positionerElement', element);
|
|
119
122
|
});
|
|
@@ -12,7 +12,7 @@ import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
|
12
12
|
import { useValueAsRef } from '@base-ui/utils/useValueAsRef';
|
|
13
13
|
import { useStore, Store } from '@base-ui/utils/store';
|
|
14
14
|
import { EMPTY_ARRAY, EMPTY_OBJECT } from '@base-ui/utils/empty';
|
|
15
|
-
import { useClick, useDismiss, useFloatingRootContext,
|
|
15
|
+
import { useClick, useDismiss, useFloatingRootContext, useListNavigation, useTypeahead } from "../../floating-ui-react/index.js";
|
|
16
16
|
import { SelectRootContext, SelectFloatingContext } from "./SelectRootContext.js";
|
|
17
17
|
import { useFieldRootContext } from "../../internals/field-root-context/FieldRootContext.js";
|
|
18
18
|
import { useRegisterFieldControl } from "../../internals/field-register-control/useRegisterFieldControl.js";
|
|
@@ -28,6 +28,7 @@ import { defaultItemEquality, findItemIndex } from "../../internals/itemEquality
|
|
|
28
28
|
import { useValueChanged } from "../../internals/useValueChanged.js";
|
|
29
29
|
import { useOpenInteractionType } from "../../utils/useOpenInteractionType.js";
|
|
30
30
|
import { getMaxScrollOffset, normalizeScrollOffset } from "../../utils/scrollEdges.js";
|
|
31
|
+
import { FOCUSABLE_POPUP_PROPS } from "../../utils/popups/index.js";
|
|
31
32
|
import { mergeProps } from "../../merge-props/index.js";
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -105,10 +106,12 @@ export function SelectRoot(props) {
|
|
|
105
106
|
const valuesRef = React.useRef([]);
|
|
106
107
|
const typingRef = React.useRef(false);
|
|
107
108
|
const keyboardActiveRef = React.useRef(false);
|
|
109
|
+
const firstItemTextRef = React.useRef(null);
|
|
108
110
|
const selectedItemTextRef = React.useRef(null);
|
|
109
111
|
const selectionRef = React.useRef({
|
|
110
112
|
allowSelectedMouseUp: false,
|
|
111
|
-
allowUnselectedMouseUp: false
|
|
113
|
+
allowUnselectedMouseUp: false,
|
|
114
|
+
dragY: 0
|
|
112
115
|
});
|
|
113
116
|
const alignItemWithTriggerActiveRef = React.useRef(false);
|
|
114
117
|
const {
|
|
@@ -142,6 +145,7 @@ export function SelectRoot(props) {
|
|
|
142
145
|
triggerElement: null,
|
|
143
146
|
positionerElement: null,
|
|
144
147
|
listElement: null,
|
|
148
|
+
popupSide: null,
|
|
145
149
|
scrollUpArrowVisible: false,
|
|
146
150
|
scrollDownArrowVisible: false,
|
|
147
151
|
hasScrollArrows: false
|
|
@@ -165,13 +169,10 @@ export function SelectRoot(props) {
|
|
|
165
169
|
return stringifyAsValue(value, itemToStringValue);
|
|
166
170
|
}, [multiple, value, itemToStringValue]);
|
|
167
171
|
const controlRef = useValueAsRef(store.state.triggerElement);
|
|
168
|
-
const
|
|
169
|
-
useRegisterFieldControl(controlRef,
|
|
170
|
-
id: generatedId,
|
|
171
|
-
value,
|
|
172
|
-
getValue: getFieldValue
|
|
173
|
-
});
|
|
172
|
+
const getStringifiedValueForForm = useStableCallback(() => fieldStringValue);
|
|
173
|
+
useRegisterFieldControl(controlRef, generatedId, value, getStringifiedValueForForm);
|
|
174
174
|
const initialValueRef = React.useRef(value);
|
|
175
|
+
const hasSelectedValue = multiple ? Array.isArray(value) && value.length > 0 : value != null;
|
|
175
176
|
useIsoLayoutEffect(() => {
|
|
176
177
|
// Ensure the values and labels are registered for programmatic value changes.
|
|
177
178
|
if (value !== initialValueRef.current) {
|
|
@@ -179,27 +180,32 @@ export function SelectRoot(props) {
|
|
|
179
180
|
}
|
|
180
181
|
}, [store, value]);
|
|
181
182
|
useIsoLayoutEffect(() => {
|
|
182
|
-
setFilled(
|
|
183
|
-
}, [
|
|
183
|
+
setFilled(hasSelectedValue);
|
|
184
|
+
}, [hasSelectedValue, setFilled]);
|
|
184
185
|
useIsoLayoutEffect(function syncSelectedIndex() {
|
|
185
|
-
if (open) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
186
|
const registry = valuesRef.current;
|
|
187
|
+
let nextIndex;
|
|
189
188
|
if (multiple) {
|
|
190
189
|
const currentValue = Array.isArray(value) ? value : [];
|
|
191
190
|
if (currentValue.length === 0) {
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
nextIndex = null;
|
|
192
|
+
} else {
|
|
193
|
+
const lastValue = currentValue[currentValue.length - 1];
|
|
194
|
+
const lastIndex = findItemIndex(registry, lastValue, isItemEqualToValue);
|
|
195
|
+
nextIndex = lastIndex === -1 ? null : lastIndex;
|
|
194
196
|
}
|
|
195
|
-
|
|
196
|
-
const
|
|
197
|
-
|
|
197
|
+
} else {
|
|
198
|
+
const index = findItemIndex(registry, value, isItemEqualToValue);
|
|
199
|
+
nextIndex = index === -1 ? null : index;
|
|
200
|
+
}
|
|
201
|
+
if (nextIndex === null) {
|
|
202
|
+
selectedItemTextRef.current = null;
|
|
203
|
+
}
|
|
204
|
+
if (open) {
|
|
198
205
|
return;
|
|
199
206
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}, [multiple, open, value, valuesRef, isItemEqualToValue, store]);
|
|
207
|
+
store.set('selectedIndex', nextIndex);
|
|
208
|
+
}, [hasSelectedValue, multiple, open, value, valuesRef, isItemEqualToValue, store, selectedItemTextRef]);
|
|
203
209
|
useValueChanged(value, () => {
|
|
204
210
|
clearErrors(name);
|
|
205
211
|
setDirty(value !== validityData.initialValue);
|
|
@@ -293,9 +299,7 @@ export function SelectRoot(props) {
|
|
|
293
299
|
enabled: !readOnly && !disabled,
|
|
294
300
|
event: 'mousedown'
|
|
295
301
|
});
|
|
296
|
-
const dismiss = useDismiss(floatingContext
|
|
297
|
-
bubbles: false
|
|
298
|
-
});
|
|
302
|
+
const dismiss = useDismiss(floatingContext);
|
|
299
303
|
const listNavigation = useListNavigation(floatingContext, {
|
|
300
304
|
enabled: !readOnly && !disabled,
|
|
301
305
|
listRef,
|
|
@@ -323,23 +327,22 @@ export function SelectRoot(props) {
|
|
|
323
327
|
setValue(valuesRef.current[index], createChangeEventDetails('none'));
|
|
324
328
|
}
|
|
325
329
|
},
|
|
326
|
-
|
|
330
|
+
onTyping(typing) {
|
|
327
331
|
typingRef.current = typing;
|
|
328
332
|
}
|
|
329
333
|
});
|
|
330
|
-
const {
|
|
331
|
-
getReferenceProps,
|
|
332
|
-
getFloatingProps,
|
|
333
|
-
getItemProps
|
|
334
|
-
} = useInteractions([click, dismiss, listNavigation, typeahead]);
|
|
335
334
|
const mergedTriggerProps = React.useMemo(() => {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
335
|
+
const triggerInteractionProps = mergeProps(typeahead.reference, listNavigation.reference, dismiss.reference, click.reference, interactionTypeProps);
|
|
336
|
+
if (generatedId) {
|
|
337
|
+
triggerInteractionProps.id = generatedId;
|
|
338
|
+
}
|
|
339
|
+
return triggerInteractionProps;
|
|
340
|
+
}, [click.reference, typeahead.reference, listNavigation.reference, dismiss.reference, interactionTypeProps, generatedId]);
|
|
341
|
+
const popupProps = React.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, typeahead.floating, listNavigation.floating, dismiss.floating), [typeahead.floating, listNavigation.floating, dismiss.floating]);
|
|
342
|
+
const itemProps = listNavigation.item ?? EMPTY_OBJECT;
|
|
340
343
|
useOnFirstRender(() => {
|
|
341
344
|
store.update({
|
|
342
|
-
popupProps
|
|
345
|
+
popupProps,
|
|
343
346
|
triggerProps: mergedTriggerProps
|
|
344
347
|
});
|
|
345
348
|
});
|
|
@@ -352,7 +355,7 @@ export function SelectRoot(props) {
|
|
|
352
355
|
open,
|
|
353
356
|
mounted,
|
|
354
357
|
transitionStatus,
|
|
355
|
-
popupProps
|
|
358
|
+
popupProps,
|
|
356
359
|
triggerProps: mergedTriggerProps,
|
|
357
360
|
items,
|
|
358
361
|
itemToStringLabel,
|
|
@@ -360,7 +363,7 @@ export function SelectRoot(props) {
|
|
|
360
363
|
isItemEqualToValue,
|
|
361
364
|
openMethod: renderedOpenMethod
|
|
362
365
|
});
|
|
363
|
-
}, [store, generatedId, modal, multiple, value, open, mounted, transitionStatus,
|
|
366
|
+
}, [store, generatedId, modal, multiple, value, open, mounted, transitionStatus, popupProps, mergedTriggerProps, items, itemToStringLabel, itemToStringValue, isItemEqualToValue, renderedOpenMethod]);
|
|
364
367
|
const contextValue = React.useMemo(() => ({
|
|
365
368
|
store,
|
|
366
369
|
name,
|
|
@@ -376,20 +379,21 @@ export function SelectRoot(props) {
|
|
|
376
379
|
scrollHandlerRef,
|
|
377
380
|
handleScrollArrowVisibility,
|
|
378
381
|
scrollArrowsMountedCountRef,
|
|
379
|
-
|
|
382
|
+
itemProps,
|
|
380
383
|
events: floatingContext.context.events,
|
|
381
384
|
valueRef,
|
|
382
385
|
valuesRef,
|
|
383
386
|
labelsRef,
|
|
384
387
|
typingRef,
|
|
385
388
|
selectionRef,
|
|
389
|
+
firstItemTextRef,
|
|
386
390
|
selectedItemTextRef,
|
|
387
391
|
validation,
|
|
388
392
|
onOpenChangeComplete,
|
|
389
393
|
keyboardActiveRef,
|
|
390
394
|
alignItemWithTriggerActiveRef,
|
|
391
395
|
initialValueRef
|
|
392
|
-
}), [store, name, required, disabled, readOnly, multiple, highlightItemOnHover, setValue, setOpen,
|
|
396
|
+
}), [store, name, required, disabled, readOnly, multiple, highlightItemOnHover, setValue, setOpen, itemProps, floatingContext.context.events, validation, onOpenChangeComplete, handleScrollArrowVisibility]);
|
|
393
397
|
const ref = useMergedRefs(inputRef, validation.inputRef);
|
|
394
398
|
const hasMultipleSelection = multiple && Array.isArray(value) && value.length > 0;
|
|
395
399
|
const hiddenInputName = multiple ? undefined : name;
|
|
@@ -423,7 +427,9 @@ export function SelectRoot(props) {
|
|
|
423
427
|
// Handle browser autofill.
|
|
424
428
|
onChange(event) {
|
|
425
429
|
// Workaround for https://github.com/facebook/react/issues/9023
|
|
426
|
-
if (event.nativeEvent.defaultPrevented) {
|
|
430
|
+
if (event.nativeEvent.defaultPrevented || disabled || readOnly) {
|
|
431
|
+
// Outside Field.Root, the event is not wrapped by mergeProps.
|
|
432
|
+
event.preventBaseUIHandler?.();
|
|
427
433
|
return;
|
|
428
434
|
}
|
|
429
435
|
const nextValue = event.currentTarget.value;
|
|
@@ -19,10 +19,7 @@ export interface SelectRootContext {
|
|
|
19
19
|
scrollHandlerRef: React.RefObject<((el: HTMLDivElement) => void) | null>;
|
|
20
20
|
handleScrollArrowVisibility: () => void;
|
|
21
21
|
scrollArrowsMountedCountRef: React.RefObject<number>;
|
|
22
|
-
|
|
23
|
-
active?: boolean | undefined;
|
|
24
|
-
selected?: boolean | undefined;
|
|
25
|
-
}) => Record<string, unknown>;
|
|
22
|
+
itemProps: HTMLProps;
|
|
26
23
|
events: FloatingEvents;
|
|
27
24
|
valueRef: React.RefObject<HTMLSpanElement | null>;
|
|
28
25
|
valuesRef: React.RefObject<Array<any>>;
|
|
@@ -31,8 +28,10 @@ export interface SelectRootContext {
|
|
|
31
28
|
selectionRef: React.RefObject<{
|
|
32
29
|
allowUnselectedMouseUp: boolean;
|
|
33
30
|
allowSelectedMouseUp: boolean;
|
|
31
|
+
dragY: number;
|
|
34
32
|
}>;
|
|
35
|
-
|
|
33
|
+
firstItemTextRef: React.RefObject<HTMLElement | null>;
|
|
34
|
+
selectedItemTextRef: React.RefObject<HTMLElement | null>;
|
|
36
35
|
validation: UseFieldValidationReturnValue;
|
|
37
36
|
onOpenChangeComplete?: ((open: boolean) => void) | undefined;
|
|
38
37
|
keyboardActiveRef: React.RefObject<boolean>;
|
package/esm/select/store.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Store } from '@base-ui/utils/store';
|
|
|
2
2
|
import { type InteractionType } from '@base-ui/utils/useEnhancedClickHandler';
|
|
3
3
|
import type { TransitionStatus } from "../internals/useTransitionStatus.js";
|
|
4
4
|
import type { HTMLProps } from "../internals/types.js";
|
|
5
|
+
import type { Side } from "../utils/useAnchorPositioning.js";
|
|
5
6
|
import { type Group } from "../internals/resolveValueLabel.js";
|
|
6
7
|
export type State = {
|
|
7
8
|
id: string | undefined;
|
|
@@ -28,6 +29,7 @@ export type State = {
|
|
|
28
29
|
triggerElement: HTMLElement | null;
|
|
29
30
|
positionerElement: HTMLElement | null;
|
|
30
31
|
listElement: HTMLDivElement | null;
|
|
32
|
+
popupSide: Side | null;
|
|
31
33
|
scrollUpArrowVisible: boolean;
|
|
32
34
|
scrollDownArrowVisible: boolean;
|
|
33
35
|
hasScrollArrows: boolean;
|
|
@@ -63,6 +65,7 @@ export declare const selectors: {
|
|
|
63
65
|
triggerElement: (state: State) => HTMLElement | null;
|
|
64
66
|
positionerElement: (state: State) => HTMLElement | null;
|
|
65
67
|
listElement: (state: State) => HTMLDivElement | null;
|
|
68
|
+
popupSide: (state: State) => Side | null;
|
|
66
69
|
scrollUpArrowVisible: (state: State) => boolean;
|
|
67
70
|
scrollDownArrowVisible: (state: State) => boolean;
|
|
68
71
|
hasScrollArrows: (state: State) => boolean;
|
package/esm/select/store.js
CHANGED
|
@@ -58,6 +58,7 @@ export const selectors = {
|
|
|
58
58
|
triggerElement: createSelector(state => state.triggerElement),
|
|
59
59
|
positionerElement: createSelector(state => state.positionerElement),
|
|
60
60
|
listElement: createSelector(state => state.listElement),
|
|
61
|
+
popupSide: createSelector(state => state.popupSide),
|
|
61
62
|
scrollUpArrowVisible: createSelector(state => state.scrollUpArrowVisible),
|
|
62
63
|
scrollDownArrowVisible: createSelector(state => state.scrollDownArrowVisible),
|
|
63
64
|
hasScrollArrows: createSelector(state => state.hasScrollArrows)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BaseUIComponentProps, NativeButtonProps } from "../../internals/types.js";
|
|
3
3
|
import type { FieldRootState } from "../../field/root/FieldRoot.js";
|
|
4
|
+
import type { Side } from "../../utils/useAnchorPositioning.js";
|
|
4
5
|
/**
|
|
5
6
|
* A button that opens the select popup.
|
|
6
7
|
* Renders a `<button>` element.
|
|
@@ -17,6 +18,10 @@ export interface SelectTriggerState extends FieldRootState {
|
|
|
17
18
|
* Whether the select popup is readonly.
|
|
18
19
|
*/
|
|
19
20
|
readOnly: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Indicates which side the corresponding popup is positioned relative to its anchor.
|
|
23
|
+
*/
|
|
24
|
+
popupSide: Side | null;
|
|
20
25
|
/**
|
|
21
26
|
* The value of the currently selected item.
|
|
22
27
|
*/
|
|
@@ -24,10 +24,12 @@ import { useLabelableId } from "../../internals/labelable-provider/useLabelableI
|
|
|
24
24
|
import { resolveAriaLabelledBy } from "../../utils/resolveAriaLabelledBy.js";
|
|
25
25
|
const BOUNDARY_OFFSET = 2;
|
|
26
26
|
const SELECTED_DELAY = 400;
|
|
27
|
-
const UNSELECTED_DELAY = 200;
|
|
28
27
|
const stateAttributesMapping = {
|
|
29
28
|
...pressableTriggerOpenStateMapping,
|
|
30
29
|
...fieldValidityMapping,
|
|
30
|
+
popupSide: side => side ? {
|
|
31
|
+
'data-popup-side': side
|
|
32
|
+
} : null,
|
|
31
33
|
value: () => null
|
|
32
34
|
};
|
|
33
35
|
|
|
@@ -70,15 +72,16 @@ export const SelectTrigger = /*#__PURE__*/React.forwardRef(function SelectTrigge
|
|
|
70
72
|
} = useSelectRootContext();
|
|
71
73
|
const disabled = fieldDisabled || selectDisabled || disabledProp;
|
|
72
74
|
const open = useStore(store, selectors.open);
|
|
75
|
+
const mounted = useStore(store, selectors.mounted);
|
|
73
76
|
const value = useStore(store, selectors.value);
|
|
74
77
|
const triggerProps = useStore(store, selectors.triggerProps);
|
|
75
78
|
const positionerElement = useStore(store, selectors.positionerElement);
|
|
76
79
|
const listElement = useStore(store, selectors.listElement);
|
|
80
|
+
const popupSideValue = useStore(store, selectors.popupSide);
|
|
77
81
|
const rootId = useStore(store, selectors.id);
|
|
78
82
|
const selectLabelId = useStore(store, selectors.labelId);
|
|
79
83
|
const hasSelectedValue = useStore(store, selectors.hasSelectedValue);
|
|
80
|
-
const
|
|
81
|
-
const hasNullItemLabel = useStore(store, selectors.hasNullItemLabel, shouldCheckNullItemLabel);
|
|
84
|
+
const popupSide = mounted && positionerElement ? popupSideValue : null;
|
|
82
85
|
const id = idProp ?? rootId;
|
|
83
86
|
const ariaLabelledBy = resolveAriaLabelledBy(fieldLabelId, selectLabelId);
|
|
84
87
|
useLabelableId({
|
|
@@ -100,52 +103,34 @@ export const SelectTrigger = /*#__PURE__*/React.forwardRef(function SelectTrigge
|
|
|
100
103
|
const timeoutFocus = useTimeout();
|
|
101
104
|
const timeoutMouseDown = useTimeout();
|
|
102
105
|
const selectedDelayTimeout = useTimeout();
|
|
103
|
-
const unselectedDelayTimeout = useTimeout();
|
|
104
106
|
React.useEffect(() => {
|
|
105
107
|
if (open) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
//
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
selectionRef.current.allowUnselectedMouseUp = true;
|
|
115
|
-
selectionRef.current.allowSelectedMouseUp = true;
|
|
116
|
-
});
|
|
117
|
-
} else {
|
|
118
|
-
// mousedown -> move to unselected item -> mouseup should not select within 200ms.
|
|
119
|
-
unselectedDelayTimeout.start(UNSELECTED_DELAY, () => {
|
|
120
|
-
selectionRef.current.allowUnselectedMouseUp = true;
|
|
121
|
-
|
|
122
|
-
// mousedown -> mouseup on selected item should not select within 400ms.
|
|
123
|
-
selectedDelayTimeout.start(UNSELECTED_DELAY, () => {
|
|
124
|
-
selectionRef.current.allowSelectedMouseUp = true;
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
}
|
|
108
|
+
// A mousedown on the trigger can open the popup under the cursor. Keep mouseup selection
|
|
109
|
+
// disabled briefly so releasing over either the selected item or a neighboring item doesn't
|
|
110
|
+
// commit an accidental selection. SelectItem can still opt into unselected mouseup sooner
|
|
111
|
+
// after a real drag over the item.
|
|
112
|
+
selectedDelayTimeout.start(SELECTED_DELAY, () => {
|
|
113
|
+
selectionRef.current.allowUnselectedMouseUp = true;
|
|
114
|
+
selectionRef.current.allowSelectedMouseUp = true;
|
|
115
|
+
});
|
|
128
116
|
return () => {
|
|
129
117
|
selectedDelayTimeout.clear();
|
|
130
|
-
unselectedDelayTimeout.clear();
|
|
131
118
|
};
|
|
132
119
|
}
|
|
133
120
|
selectionRef.current = {
|
|
134
121
|
allowSelectedMouseUp: false,
|
|
135
|
-
allowUnselectedMouseUp: false
|
|
122
|
+
allowUnselectedMouseUp: false,
|
|
123
|
+
dragY: 0
|
|
136
124
|
};
|
|
137
125
|
timeoutMouseDown.clear();
|
|
138
126
|
return undefined;
|
|
139
|
-
}, [open,
|
|
140
|
-
const ariaControlsId = React.useMemo(() => {
|
|
141
|
-
return listElement?.id ?? getFloatingFocusElement(positionerElement)?.id;
|
|
142
|
-
}, [listElement, positionerElement]);
|
|
127
|
+
}, [open, selectionRef, timeoutMouseDown, selectedDelayTimeout]);
|
|
143
128
|
const props = mergeProps(triggerProps, {
|
|
144
129
|
id,
|
|
145
130
|
role: 'combobox',
|
|
146
131
|
'aria-expanded': open ? 'true' : 'false',
|
|
147
132
|
'aria-haspopup': 'listbox',
|
|
148
|
-
'aria-controls': open ?
|
|
133
|
+
'aria-controls': open ? listElement?.id ?? getFloatingFocusElement(positionerElement)?.id : undefined,
|
|
149
134
|
'aria-labelledby': ariaLabelledBy,
|
|
150
135
|
'aria-readonly': readOnly || undefined,
|
|
151
136
|
'aria-required': required || undefined,
|
|
@@ -225,6 +210,7 @@ export const SelectTrigger = /*#__PURE__*/React.forwardRef(function SelectTrigge
|
|
|
225
210
|
disabled,
|
|
226
211
|
value,
|
|
227
212
|
readOnly,
|
|
213
|
+
popupSide,
|
|
228
214
|
placeholder: !hasSelectedValue
|
|
229
215
|
};
|
|
230
216
|
return useRenderElement('button', componentProps, {
|
|
@@ -15,6 +15,11 @@ export declare enum SelectTriggerDataAttributes {
|
|
|
15
15
|
* Present when the select is readonly.
|
|
16
16
|
*/
|
|
17
17
|
readonly = "data-readonly",
|
|
18
|
+
/**
|
|
19
|
+
* Indicates which side the corresponding popup is positioned relative to its anchor.
|
|
20
|
+
* @type {'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | null}
|
|
21
|
+
*/
|
|
22
|
+
popupSide = "data-popup-side",
|
|
18
23
|
/**
|
|
19
24
|
* Present when the select is required.
|
|
20
25
|
*/
|
|
@@ -16,6 +16,11 @@ export let SelectTriggerDataAttributes = function (SelectTriggerDataAttributes)
|
|
|
16
16
|
* Present when the select is readonly.
|
|
17
17
|
*/
|
|
18
18
|
SelectTriggerDataAttributes["readonly"] = "data-readonly";
|
|
19
|
+
/**
|
|
20
|
+
* Indicates which side the corresponding popup is positioned relative to its anchor.
|
|
21
|
+
* @type {'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | null}
|
|
22
|
+
*/
|
|
23
|
+
SelectTriggerDataAttributes["popupSide"] = "data-popup-side";
|
|
19
24
|
/**
|
|
20
25
|
* Present when the select is required.
|
|
21
26
|
*/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { isElement } from '@floating-ui/utils/dom';
|
|
5
5
|
import { addEventListener } from '@base-ui/utils/addEventListener';
|
|
6
|
-
import { ownerDocument } from '@base-ui/utils/owner';
|
|
6
|
+
import { ownerDocument, ownerWindow } from '@base-ui/utils/owner';
|
|
7
7
|
import { useAnimationFrame } from '@base-ui/utils/useAnimationFrame';
|
|
8
8
|
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
9
9
|
import { useValueAsRef } from '@base-ui/utils/useValueAsRef';
|
|
@@ -107,9 +107,7 @@ export const SliderControl = /*#__PURE__*/React.forwardRef(function SliderContro
|
|
|
107
107
|
const stylesRef = React.useRef(null);
|
|
108
108
|
const setStylesRef = useStableCallback(element => {
|
|
109
109
|
if (element && stylesRef.current == null) {
|
|
110
|
-
|
|
111
|
-
stylesRef.current = getComputedStyle(element);
|
|
112
|
-
}
|
|
110
|
+
stylesRef.current = ownerWindow(element).getComputedStyle(element);
|
|
113
111
|
}
|
|
114
112
|
});
|
|
115
113
|
|
|
@@ -121,7 +119,7 @@ export const SliderControl = /*#__PURE__*/React.forwardRef(function SliderContro
|
|
|
121
119
|
// This value should be equal to the radius or half the width/height of the thumb.
|
|
122
120
|
const insetThumbOffsetRef = React.useRef(0);
|
|
123
121
|
const latestValuesRef = useValueAsRef(values);
|
|
124
|
-
|
|
122
|
+
function updatePressedThumb(nextIndex) {
|
|
125
123
|
if (pressedThumbIndexRef.current !== nextIndex) {
|
|
126
124
|
pressedThumbIndexRef.current = nextIndex;
|
|
127
125
|
}
|
|
@@ -132,8 +130,8 @@ export const SliderControl = /*#__PURE__*/React.forwardRef(function SliderContro
|
|
|
132
130
|
return;
|
|
133
131
|
}
|
|
134
132
|
pressedInputRef.current = thumbElement.querySelector('input[type="range"]');
|
|
135
|
-
}
|
|
136
|
-
|
|
133
|
+
}
|
|
134
|
+
function getFingerState(fingerCoords) {
|
|
137
135
|
const control = controlRef.current;
|
|
138
136
|
if (!control) {
|
|
139
137
|
return null;
|
|
@@ -186,8 +184,8 @@ export const SliderControl = /*#__PURE__*/React.forwardRef(function SliderContro
|
|
|
186
184
|
pressedThumbIndexRef.current = collisionResult.thumbIndex;
|
|
187
185
|
}
|
|
188
186
|
return collisionResult;
|
|
189
|
-
}
|
|
190
|
-
|
|
187
|
+
}
|
|
188
|
+
function startPressing(fingerCoords) {
|
|
191
189
|
pressedValuesRef.current = range ? values.slice() : null;
|
|
192
190
|
latestValuesRef.current = values;
|
|
193
191
|
const pressedThumbIndex = pressedThumbIndexRef.current;
|
|
@@ -228,8 +226,8 @@ export const SliderControl = /*#__PURE__*/React.forwardRef(function SliderContro
|
|
|
228
226
|
insetThumbOffsetRef.current = thumbRect[side] / 2;
|
|
229
227
|
}
|
|
230
228
|
}
|
|
231
|
-
}
|
|
232
|
-
|
|
229
|
+
}
|
|
230
|
+
function focusThumb(thumbIndex) {
|
|
233
231
|
const input = thumbRefs.current?.[thumbIndex]?.querySelector('input[type="range"]');
|
|
234
232
|
if (!input) {
|
|
235
233
|
return;
|
|
@@ -240,7 +238,7 @@ export const SliderControl = /*#__PURE__*/React.forwardRef(function SliderContro
|
|
|
240
238
|
// Supported in Chrome from 144+.
|
|
241
239
|
focusVisible: false
|
|
242
240
|
});
|
|
243
|
-
}
|
|
241
|
+
}
|
|
244
242
|
const handleTouchMove = useStableCallback(nativeEvent => {
|
|
245
243
|
const fingerCoords = getFingerCoords(nativeEvent, touchIdRef);
|
|
246
244
|
if (fingerCoords == null) {
|
|
@@ -135,10 +135,7 @@ export const SliderRoot = /*#__PURE__*/React.forwardRef(function SliderRoot(comp
|
|
|
135
135
|
setLastUsedThumbIndex(value);
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
|
-
useRegisterFieldControl(controlRef,
|
|
139
|
-
id,
|
|
140
|
-
value: valueUnwrapped
|
|
141
|
-
});
|
|
138
|
+
useRegisterFieldControl(controlRef, id, valueUnwrapped);
|
|
142
139
|
useValueChanged(valueUnwrapped, () => {
|
|
143
140
|
clearErrors(name);
|
|
144
141
|
if (shouldValidateOnChange()) {
|