@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
package/tabs/root/TabsRoot.js
CHANGED
|
@@ -14,6 +14,8 @@ var _useRenderElement = require("../../internals/useRenderElement");
|
|
|
14
14
|
var _CompositeList = require("../../internals/composite/list/CompositeList");
|
|
15
15
|
var _TabsRootContext = require("./TabsRootContext");
|
|
16
16
|
var _stateAttributesMapping = require("./stateAttributesMapping");
|
|
17
|
+
var _createBaseUIEventDetails = require("../../internals/createBaseUIEventDetails");
|
|
18
|
+
var _reasons = require("../../internals/reasons");
|
|
17
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
20
|
/**
|
|
19
21
|
* Groups the tabs and the corresponding panels.
|
|
@@ -33,9 +35,9 @@ const TabsRoot = exports.TabsRoot = /*#__PURE__*/React.forwardRef(function TabsR
|
|
|
33
35
|
...elementProps
|
|
34
36
|
} = componentProps;
|
|
35
37
|
|
|
36
|
-
// Track whether the user explicitly provided a `defaultValue` prop.
|
|
38
|
+
// Track whether the user explicitly provided a defined `defaultValue` prop.
|
|
37
39
|
// Used to determine if we should honor a disabled tab selection.
|
|
38
|
-
const hasExplicitDefaultValueProp =
|
|
40
|
+
const hasExplicitDefaultValueProp = componentProps.defaultValue !== undefined;
|
|
39
41
|
const tabPanelRefs = React.useRef([]);
|
|
40
42
|
const [mountedTabPanels, setMountedTabPanels] = React.useState(() => new Map());
|
|
41
43
|
const [value, setValue] = (0, _useControlled.useControlled)({
|
|
@@ -103,6 +105,11 @@ const TabsRoot = exports.TabsRoot = /*#__PURE__*/React.forwardRef(function TabsR
|
|
|
103
105
|
}
|
|
104
106
|
setValue(newValue);
|
|
105
107
|
});
|
|
108
|
+
const notifyAutomaticValueChange = (0, _useStableCallback.useStableCallback)((nextValue, reason) => {
|
|
109
|
+
onValueChangeProp?.(nextValue, (0, _createBaseUIEventDetails.createChangeEventDetails)(reason, undefined, undefined, {
|
|
110
|
+
activationDirection: 'none'
|
|
111
|
+
}));
|
|
112
|
+
});
|
|
106
113
|
const registerMountedTabPanel = (0, _useStableCallback.useStableCallback)((panelValue, panelId) => {
|
|
107
114
|
setMountedTabPanels(prev => {
|
|
108
115
|
if (prev.get(panelValue) === panelId) {
|
|
@@ -170,38 +177,78 @@ const TabsRoot = exports.TabsRoot = /*#__PURE__*/React.forwardRef(function TabsR
|
|
|
170
177
|
return undefined;
|
|
171
178
|
}, [tabMap]);
|
|
172
179
|
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
//
|
|
180
|
+
// Implicit uncontrolled selections are still automatic changes, so notify
|
|
181
|
+
// once when the tabs first register. Explicit defaults are treated as user-owned.
|
|
182
|
+
const shouldNotifyInitialValueChangeRef = React.useRef(!hasExplicitDefaultValueProp);
|
|
183
|
+
// An explicit defaultValue can intentionally point at a disabled tab on mount.
|
|
184
|
+
// Once that selection becomes valid, later disabled states should fall back.
|
|
185
|
+
const shouldHonorDisabledDefaultValueRef = React.useRef(hasExplicitDefaultValueProp);
|
|
186
|
+
const didRegisterTabsRef = React.useRef(false);
|
|
187
|
+
|
|
188
|
+
// Uncontrolled roots own automatic fallback. Controlled roots keep the exact
|
|
189
|
+
// value supplied by the parent, even when that tab is disabled or missing.
|
|
177
190
|
(0, _useIsoLayoutEffect.useIsoLayoutEffect)(() => {
|
|
178
|
-
if (isControlled
|
|
191
|
+
if (isControlled) {
|
|
179
192
|
return;
|
|
180
193
|
}
|
|
194
|
+
function commitAutomaticValueChange(fallbackValue, fallbackReason) {
|
|
195
|
+
setValue(fallbackValue);
|
|
196
|
+
// Automatic fallbacks are not directional transitions; reset the direction
|
|
197
|
+
// alongside the value so the batched commit keeps both in sync.
|
|
198
|
+
setActivationDirectionState(prev => {
|
|
199
|
+
if (prev.previousValue === fallbackValue && prev.tabActivationDirection === 'none') {
|
|
200
|
+
return prev;
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
previousValue: fallbackValue,
|
|
204
|
+
tabActivationDirection: 'none'
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
notifyAutomaticValueChange(fallbackValue, fallbackReason);
|
|
208
|
+
// Mark the initial notification as delivered only after the consumer
|
|
209
|
+
// callback returns. The fallback value is queued first so automatic
|
|
210
|
+
// consistency updates are not cancelable through a throwing handler.
|
|
211
|
+
shouldNotifyInitialValueChangeRef.current = false;
|
|
212
|
+
}
|
|
213
|
+
if (tabMap.size === 0) {
|
|
214
|
+
if (!didRegisterTabsRef.current || value === null) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
commitAutomaticValueChange(null, _reasons.REASONS.missing);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
didRegisterTabsRef.current = true;
|
|
181
221
|
const selectionIsDisabled = selectedTabMetadata?.disabled;
|
|
182
222
|
const selectionIsMissing = selectedTabMetadata == null && value !== null;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return;
|
|
223
|
+
if (!selectionIsDisabled && value === defaultValueProp) {
|
|
224
|
+
shouldHonorDisabledDefaultValueRef.current = false;
|
|
186
225
|
}
|
|
187
|
-
if (
|
|
226
|
+
if (shouldHonorDisabledDefaultValueRef.current && selectionIsDisabled && value === defaultValueProp) {
|
|
188
227
|
return;
|
|
189
228
|
}
|
|
190
|
-
const
|
|
191
|
-
if (
|
|
229
|
+
const shouldNotifyInitialValueChange = shouldNotifyInitialValueChangeRef.current;
|
|
230
|
+
if (selectionIsDisabled || selectionIsMissing) {
|
|
231
|
+
const fallbackValue = firstEnabledTabValue ?? null;
|
|
232
|
+
if (value === fallbackValue) {
|
|
233
|
+
// Already at the fallback value; no commit or notification needed,
|
|
234
|
+
// but record that the implicit-initial transition has resolved.
|
|
235
|
+
shouldNotifyInitialValueChangeRef.current = false;
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
let fallbackReason = _reasons.REASONS.missing;
|
|
239
|
+
if (shouldNotifyInitialValueChange) {
|
|
240
|
+
fallbackReason = _reasons.REASONS.initial;
|
|
241
|
+
} else if (selectionIsDisabled) {
|
|
242
|
+
fallbackReason = _reasons.REASONS.disabled;
|
|
243
|
+
}
|
|
244
|
+
commitAutomaticValueChange(fallbackValue, fallbackReason);
|
|
192
245
|
return;
|
|
193
246
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
...prev,
|
|
201
|
-
tabActivationDirection: 'none'
|
|
202
|
-
};
|
|
203
|
-
});
|
|
204
|
-
}, [defaultValueProp, firstEnabledTabValue, hasExplicitDefaultValueProp, isControlled, selectedTabMetadata, setValue, tabMap, value]);
|
|
247
|
+
if (shouldNotifyInitialValueChange && selectedTabMetadata != null) {
|
|
248
|
+
notifyAutomaticValueChange(value, _reasons.REASONS.initial);
|
|
249
|
+
shouldNotifyInitialValueChangeRef.current = false;
|
|
250
|
+
}
|
|
251
|
+
}, [defaultValueProp, firstEnabledTabValue, isControlled, notifyAutomaticValueChange, selectedTabMetadata, setValue, tabMap, value]);
|
|
205
252
|
const state = {
|
|
206
253
|
orientation,
|
|
207
254
|
tabActivationDirection
|
|
@@ -20,12 +20,10 @@ export interface TabsRootContext {
|
|
|
20
20
|
getTabElementBySelectedValue: (selectedValue: TabsTab.Value | undefined) => HTMLElement | null;
|
|
21
21
|
/**
|
|
22
22
|
* Gets the `id` attribute of the Tab that corresponds to the given TabPanel value.
|
|
23
|
-
* @param (any) panelValue Value to find the Tab for.
|
|
24
23
|
*/
|
|
25
24
|
getTabIdByPanelValue: (panelValue: TabsTab.Value) => string | undefined;
|
|
26
25
|
/**
|
|
27
26
|
* Gets the `id` attribute of the TabPanel that corresponds to the given Tab value.
|
|
28
|
-
* @param (any) tabValue Value to find the TabPanel for.
|
|
29
27
|
*/
|
|
30
28
|
getTabPanelIdByValue: (tabValue: TabsTab.Value) => string | undefined;
|
|
31
29
|
registerMountedTabPanel: (panelValue: TabsTab.Value | number, panelId: string) => void;
|
package/toast/root/ToastRoot.js
CHANGED
|
@@ -21,6 +21,7 @@ var _useRenderElement = require("../../internals/useRenderElement");
|
|
|
21
21
|
var _useOpenChangeComplete = require("../../internals/useOpenChangeComplete");
|
|
22
22
|
var _ToastRootCssVars = require("./ToastRootCssVars");
|
|
23
23
|
var _constants = require("../../internals/constants");
|
|
24
|
+
var _useSwipeDismiss = require("../../utils/useSwipeDismiss");
|
|
24
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
26
|
const stateAttributesMapping = {
|
|
26
27
|
..._stateAttributesMapping.transitionStatusMapping,
|
|
@@ -35,47 +36,6 @@ const REVERSE_CANCEL_THRESHOLD = 10;
|
|
|
35
36
|
const OPPOSITE_DIRECTION_DAMPING_FACTOR = 0.5;
|
|
36
37
|
const MIN_DRAG_THRESHOLD = 1;
|
|
37
38
|
const TOAST_SWIPE_IGNORE_SELECTOR = `${_constants.BASE_UI_SWIPE_IGNORE_SELECTOR},${_constants.LEGACY_SWIPE_IGNORE_SELECTOR}`;
|
|
38
|
-
function getDisplacement(direction, deltaX, deltaY) {
|
|
39
|
-
switch (direction) {
|
|
40
|
-
case 'up':
|
|
41
|
-
return -deltaY;
|
|
42
|
-
case 'down':
|
|
43
|
-
return deltaY;
|
|
44
|
-
case 'left':
|
|
45
|
-
return -deltaX;
|
|
46
|
-
case 'right':
|
|
47
|
-
return deltaX;
|
|
48
|
-
default:
|
|
49
|
-
return 0;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function getElementTransform(element) {
|
|
53
|
-
const computedStyle = (0, _owner.ownerWindow)(element).getComputedStyle(element);
|
|
54
|
-
const transform = computedStyle.transform;
|
|
55
|
-
let translateX = 0;
|
|
56
|
-
let translateY = 0;
|
|
57
|
-
let scale = 1;
|
|
58
|
-
if (transform && transform !== 'none') {
|
|
59
|
-
const matrix = transform.match(/matrix(?:3d)?\(([^)]+)\)/);
|
|
60
|
-
if (matrix) {
|
|
61
|
-
const values = matrix[1].split(', ').map(parseFloat);
|
|
62
|
-
if (values.length === 6) {
|
|
63
|
-
translateX = values[4];
|
|
64
|
-
translateY = values[5];
|
|
65
|
-
scale = Math.sqrt(values[0] * values[0] + values[1] * values[1]);
|
|
66
|
-
} else if (values.length === 16) {
|
|
67
|
-
translateX = values[12];
|
|
68
|
-
translateY = values[13];
|
|
69
|
-
scale = values[0];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
x: translateX,
|
|
75
|
-
y: translateY,
|
|
76
|
-
scale
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
39
|
|
|
80
40
|
/**
|
|
81
41
|
* Groups all parts of an individual toast.
|
|
@@ -133,6 +93,12 @@ const ToastRoot = exports.ToastRoot = /*#__PURE__*/React.forwardRef(function Toa
|
|
|
133
93
|
y: 0
|
|
134
94
|
});
|
|
135
95
|
const isFirstPointerMoveRef = React.useRef(false);
|
|
96
|
+
const dragOffsetRef = React.useRef({
|
|
97
|
+
x: 0,
|
|
98
|
+
y: 0
|
|
99
|
+
});
|
|
100
|
+
const activePointerIdRef = React.useRef(null);
|
|
101
|
+
const dragAbortControllerRef = React.useRef(null);
|
|
136
102
|
const domIndex = store.useState('toastIndex', toast.id);
|
|
137
103
|
const visibleIndex = store.useState('toastVisibleIndex', toast.id);
|
|
138
104
|
const offsetY = store.useState('toastOffsetY', toast.id);
|
|
@@ -148,11 +114,8 @@ const ToastRoot = exports.ToastRoot = /*#__PURE__*/React.forwardRef(function Toa
|
|
|
148
114
|
}
|
|
149
115
|
});
|
|
150
116
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
* @param flushSync Whether to flush the update synchronously. Use in observer
|
|
154
|
-
* callbacks to avoid visual flickers.
|
|
155
|
-
*/
|
|
117
|
+
// Recalculates the natural height of the toast and updates it in the toast manager.
|
|
118
|
+
// `flushSync` avoids visual flickers when called from observer callbacks.
|
|
156
119
|
const recalculateHeight = (0, _useStableCallback.useStableCallback)((flushSync = false) => {
|
|
157
120
|
const element = rootRef.current;
|
|
158
121
|
if (!element) {
|
|
@@ -178,6 +141,15 @@ const ToastRoot = exports.ToastRoot = /*#__PURE__*/React.forwardRef(function Toa
|
|
|
178
141
|
}
|
|
179
142
|
});
|
|
180
143
|
(0, _useIsoLayoutEffect.useIsoLayoutEffect)(recalculateHeight, [recalculateHeight]);
|
|
144
|
+
function setResolvedDragOffset(nextDragOffset) {
|
|
145
|
+
dragOffsetRef.current = nextDragOffset;
|
|
146
|
+
setDragOffset(nextDragOffset);
|
|
147
|
+
}
|
|
148
|
+
(0, _useIsoLayoutEffect.useIsoLayoutEffect)(() => {
|
|
149
|
+
return () => {
|
|
150
|
+
dragAbortControllerRef.current?.abort();
|
|
151
|
+
};
|
|
152
|
+
}, []);
|
|
181
153
|
function applyDirectionalDamping(deltaX, deltaY) {
|
|
182
154
|
let newDeltaX = deltaX;
|
|
183
155
|
let newDeltaY = deltaY;
|
|
@@ -206,6 +178,75 @@ const ToastRoot = exports.ToastRoot = /*#__PURE__*/React.forwardRef(function Toa
|
|
|
206
178
|
y: newDeltaY
|
|
207
179
|
};
|
|
208
180
|
}
|
|
181
|
+
const handleSwipeEnd = (0, _useStableCallback.useStableCallback)(event => {
|
|
182
|
+
if (event.pointerId !== activePointerIdRef.current) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
activePointerIdRef.current = null;
|
|
186
|
+
dragAbortControllerRef.current?.abort();
|
|
187
|
+
dragAbortControllerRef.current = null;
|
|
188
|
+
setIsSwiping(false);
|
|
189
|
+
setIsRealSwipe(false);
|
|
190
|
+
setLockedDirection(null);
|
|
191
|
+
const resolvedInitialTransform = initialTransformRef.current;
|
|
192
|
+
if (event.type === 'pointercancel' || cancelledSwipeRef.current) {
|
|
193
|
+
setResolvedDragOffset({
|
|
194
|
+
x: resolvedInitialTransform.x,
|
|
195
|
+
y: resolvedInitialTransform.y
|
|
196
|
+
});
|
|
197
|
+
setCurrentSwipeDirection(undefined);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
let shouldClose = false;
|
|
201
|
+
const resolvedDragOffset = dragOffsetRef.current;
|
|
202
|
+
const deltaX = resolvedDragOffset.x - resolvedInitialTransform.x;
|
|
203
|
+
const deltaY = resolvedDragOffset.y - resolvedInitialTransform.y;
|
|
204
|
+
let dismissDirection;
|
|
205
|
+
for (const direction of swipeDirections) {
|
|
206
|
+
switch (direction) {
|
|
207
|
+
case 'right':
|
|
208
|
+
if (deltaX > SWIPE_THRESHOLD) {
|
|
209
|
+
shouldClose = true;
|
|
210
|
+
dismissDirection = 'right';
|
|
211
|
+
}
|
|
212
|
+
break;
|
|
213
|
+
case 'left':
|
|
214
|
+
if (deltaX < -SWIPE_THRESHOLD) {
|
|
215
|
+
shouldClose = true;
|
|
216
|
+
dismissDirection = 'left';
|
|
217
|
+
}
|
|
218
|
+
break;
|
|
219
|
+
case 'down':
|
|
220
|
+
if (deltaY > SWIPE_THRESHOLD) {
|
|
221
|
+
shouldClose = true;
|
|
222
|
+
dismissDirection = 'down';
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
case 'up':
|
|
226
|
+
if (deltaY < -SWIPE_THRESHOLD) {
|
|
227
|
+
shouldClose = true;
|
|
228
|
+
dismissDirection = 'up';
|
|
229
|
+
}
|
|
230
|
+
break;
|
|
231
|
+
default:
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
if (shouldClose) {
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (shouldClose) {
|
|
239
|
+
setCurrentSwipeDirection(dismissDirection);
|
|
240
|
+
setDragDismissed(true);
|
|
241
|
+
store.closeToast(toast.id);
|
|
242
|
+
} else {
|
|
243
|
+
setResolvedDragOffset({
|
|
244
|
+
x: resolvedInitialTransform.x,
|
|
245
|
+
y: resolvedInitialTransform.y
|
|
246
|
+
});
|
|
247
|
+
setCurrentSwipeDirection(undefined);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
209
250
|
function handlePointerDown(event) {
|
|
210
251
|
if (event.button !== 0) {
|
|
211
252
|
return;
|
|
@@ -221,16 +262,17 @@ const ToastRoot = exports.ToastRoot = /*#__PURE__*/React.forwardRef(function Toa
|
|
|
221
262
|
cancelledSwipeRef.current = false;
|
|
222
263
|
intendedSwipeDirectionRef.current = undefined;
|
|
223
264
|
maxSwipeDisplacementRef.current = 0;
|
|
265
|
+
activePointerIdRef.current = event.pointerId;
|
|
224
266
|
dragStartPosRef.current = {
|
|
225
267
|
x: event.clientX,
|
|
226
268
|
y: event.clientY
|
|
227
269
|
};
|
|
228
270
|
swipeCancelBaselineRef.current = dragStartPosRef.current;
|
|
229
271
|
if (rootRef.current) {
|
|
230
|
-
const transform = getElementTransform(rootRef.current);
|
|
272
|
+
const transform = (0, _useSwipeDismiss.getElementTransform)(rootRef.current);
|
|
231
273
|
initialTransformRef.current = transform;
|
|
232
274
|
setInitialTransform(transform);
|
|
233
|
-
|
|
275
|
+
setResolvedDragOffset({
|
|
234
276
|
x: transform.x,
|
|
235
277
|
y: transform.y
|
|
236
278
|
});
|
|
@@ -240,10 +282,23 @@ const ToastRoot = exports.ToastRoot = /*#__PURE__*/React.forwardRef(function Toa
|
|
|
240
282
|
setIsRealSwipe(false);
|
|
241
283
|
setLockedDirection(null);
|
|
242
284
|
isFirstPointerMoveRef.current = true;
|
|
243
|
-
rootRef.current
|
|
285
|
+
const element = rootRef.current;
|
|
286
|
+
if (element) {
|
|
287
|
+
dragAbortControllerRef.current?.abort();
|
|
288
|
+
const dragAbortController = new AbortController();
|
|
289
|
+
dragAbortControllerRef.current = dragAbortController;
|
|
290
|
+
const doc = (0, _owner.ownerDocument)(element);
|
|
291
|
+
doc.addEventListener('pointerup', handleSwipeEnd, {
|
|
292
|
+
signal: dragAbortController.signal
|
|
293
|
+
});
|
|
294
|
+
doc.addEventListener('pointercancel', handleSwipeEnd, {
|
|
295
|
+
signal: dragAbortController.signal
|
|
296
|
+
});
|
|
297
|
+
element.setPointerCapture?.(event.pointerId);
|
|
298
|
+
}
|
|
244
299
|
}
|
|
245
300
|
function handlePointerMove(event) {
|
|
246
|
-
if (
|
|
301
|
+
if (event.pointerId !== activePointerIdRef.current) {
|
|
247
302
|
return;
|
|
248
303
|
}
|
|
249
304
|
|
|
@@ -316,12 +371,12 @@ const ToastRoot = exports.ToastRoot = /*#__PURE__*/React.forwardRef(function Toa
|
|
|
316
371
|
}
|
|
317
372
|
if (candidate && swipeDirections.includes(candidate)) {
|
|
318
373
|
intendedSwipeDirectionRef.current = candidate;
|
|
319
|
-
maxSwipeDisplacementRef.current = getDisplacement(candidate, deltaX, deltaY);
|
|
374
|
+
maxSwipeDisplacementRef.current = (0, _useSwipeDismiss.getDisplacement)(candidate, deltaX, deltaY);
|
|
320
375
|
setCurrentSwipeDirection(candidate);
|
|
321
376
|
}
|
|
322
377
|
} else {
|
|
323
378
|
const direction = intendedSwipeDirectionRef.current;
|
|
324
|
-
const currentDisplacement = getDisplacement(direction, cancelDeltaX, cancelDeltaY);
|
|
379
|
+
const currentDisplacement = (0, _useSwipeDismiss.getDisplacement)(direction, cancelDeltaX, cancelDeltaY);
|
|
325
380
|
if (currentDisplacement > SWIPE_THRESHOLD) {
|
|
326
381
|
cancelledSwipeRef.current = false;
|
|
327
382
|
setCurrentSwipeDirection(direction);
|
|
@@ -349,89 +404,11 @@ const ToastRoot = exports.ToastRoot = /*#__PURE__*/React.forwardRef(function Toa
|
|
|
349
404
|
newOffsetY += dampedDelta.y;
|
|
350
405
|
}
|
|
351
406
|
}
|
|
352
|
-
|
|
407
|
+
setResolvedDragOffset({
|
|
353
408
|
x: newOffsetX,
|
|
354
409
|
y: newOffsetY
|
|
355
410
|
});
|
|
356
411
|
}
|
|
357
|
-
function handlePointerUp(event) {
|
|
358
|
-
if (!isSwiping) {
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
setIsSwiping(false);
|
|
362
|
-
setIsRealSwipe(false);
|
|
363
|
-
setLockedDirection(null);
|
|
364
|
-
rootRef.current?.releasePointerCapture(event.pointerId);
|
|
365
|
-
if (cancelledSwipeRef.current) {
|
|
366
|
-
setDragOffset({
|
|
367
|
-
x: initialTransform.x,
|
|
368
|
-
y: initialTransform.y
|
|
369
|
-
});
|
|
370
|
-
setCurrentSwipeDirection(undefined);
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
let shouldClose = false;
|
|
374
|
-
const deltaX = dragOffset.x - initialTransform.x;
|
|
375
|
-
const deltaY = dragOffset.y - initialTransform.y;
|
|
376
|
-
let dismissDirection;
|
|
377
|
-
for (const direction of swipeDirections) {
|
|
378
|
-
switch (direction) {
|
|
379
|
-
case 'right':
|
|
380
|
-
if (deltaX > SWIPE_THRESHOLD) {
|
|
381
|
-
shouldClose = true;
|
|
382
|
-
dismissDirection = 'right';
|
|
383
|
-
}
|
|
384
|
-
break;
|
|
385
|
-
case 'left':
|
|
386
|
-
if (deltaX < -SWIPE_THRESHOLD) {
|
|
387
|
-
shouldClose = true;
|
|
388
|
-
dismissDirection = 'left';
|
|
389
|
-
}
|
|
390
|
-
break;
|
|
391
|
-
case 'down':
|
|
392
|
-
if (deltaY > SWIPE_THRESHOLD) {
|
|
393
|
-
shouldClose = true;
|
|
394
|
-
dismissDirection = 'down';
|
|
395
|
-
}
|
|
396
|
-
break;
|
|
397
|
-
case 'up':
|
|
398
|
-
if (deltaY < -SWIPE_THRESHOLD) {
|
|
399
|
-
shouldClose = true;
|
|
400
|
-
dismissDirection = 'up';
|
|
401
|
-
}
|
|
402
|
-
break;
|
|
403
|
-
default:
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
406
|
-
if (shouldClose) {
|
|
407
|
-
break;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
if (shouldClose) {
|
|
411
|
-
setCurrentSwipeDirection(dismissDirection);
|
|
412
|
-
setDragDismissed(true);
|
|
413
|
-
store.closeToast(toast.id);
|
|
414
|
-
} else {
|
|
415
|
-
setDragOffset({
|
|
416
|
-
x: initialTransform.x,
|
|
417
|
-
y: initialTransform.y
|
|
418
|
-
});
|
|
419
|
-
setCurrentSwipeDirection(undefined);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
function handlePointerCancel() {
|
|
423
|
-
if (!isSwiping) {
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
setIsSwiping(false);
|
|
427
|
-
setIsRealSwipe(false);
|
|
428
|
-
setLockedDirection(null);
|
|
429
|
-
setDragOffset({
|
|
430
|
-
x: initialTransform.x,
|
|
431
|
-
y: initialTransform.y
|
|
432
|
-
});
|
|
433
|
-
setCurrentSwipeDirection(undefined);
|
|
434
|
-
}
|
|
435
412
|
function handleKeyDown(event) {
|
|
436
413
|
if (event.key === 'Escape') {
|
|
437
414
|
if (!rootRef.current || !(0, _utils.contains)(rootRef.current, (0, _utils.activeElement)((0, _owner.ownerDocument)(rootRef.current)))) {
|
|
@@ -485,8 +462,8 @@ const ToastRoot = exports.ToastRoot = /*#__PURE__*/React.forwardRef(function Toa
|
|
|
485
462
|
'aria-hidden': isHighPriority && !focused ? true : undefined,
|
|
486
463
|
onPointerDown: swipeEnabled ? handlePointerDown : undefined,
|
|
487
464
|
onPointerMove: swipeEnabled ? handlePointerMove : undefined,
|
|
488
|
-
onPointerUp: swipeEnabled ?
|
|
489
|
-
onPointerCancel: swipeEnabled ?
|
|
465
|
+
onPointerUp: swipeEnabled ? handleSwipeEnd : undefined,
|
|
466
|
+
onPointerCancel: swipeEnabled ? handleSwipeEnd : undefined,
|
|
490
467
|
onKeyDown: handleKeyDown,
|
|
491
468
|
inert: (0, _inertValue.inertValue)(toast.limited),
|
|
492
469
|
style: {
|
|
@@ -5,7 +5,7 @@ export declare enum ToastRootDataAttributes {
|
|
|
5
5
|
*/
|
|
6
6
|
expanded = "data-expanded",
|
|
7
7
|
/**
|
|
8
|
-
* Present when the toast was
|
|
8
|
+
* Present when the toast was limited because the toast limit was exceeded.
|
|
9
9
|
* @type {boolean}
|
|
10
10
|
*/
|
|
11
11
|
limited = "data-limited",
|
|
@@ -12,7 +12,7 @@ let ToastRootDataAttributes = exports.ToastRootDataAttributes = function (ToastR
|
|
|
12
12
|
*/
|
|
13
13
|
ToastRootDataAttributes["expanded"] = "data-expanded";
|
|
14
14
|
/**
|
|
15
|
-
* Present when the toast was
|
|
15
|
+
* Present when the toast was limited because the toast limit was exceeded.
|
|
16
16
|
* @type {boolean}
|
|
17
17
|
*/
|
|
18
18
|
ToastRootDataAttributes["limited"] = "data-limited";
|
package/toast/store.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ type RemoveToastBehavior = {
|
|
|
10
10
|
};
|
|
11
11
|
export type State = {
|
|
12
12
|
toasts: ToastObject<any>[];
|
|
13
|
+
toastMetadata: Map<string, ToastMetadata>;
|
|
13
14
|
hovering: boolean;
|
|
14
15
|
focused: boolean;
|
|
15
16
|
timeout: number;
|
|
@@ -18,6 +19,13 @@ export type State = {
|
|
|
18
19
|
viewport: HTMLElement | null;
|
|
19
20
|
prevFocusElement: HTMLElement | null;
|
|
20
21
|
};
|
|
22
|
+
type ToastMetadata = {
|
|
23
|
+
value: ToastObject<any>;
|
|
24
|
+
domIndex: number;
|
|
25
|
+
visibleIndex: number;
|
|
26
|
+
offsetY: number;
|
|
27
|
+
};
|
|
28
|
+
type InitialState = Omit<State, 'toastMetadata'>;
|
|
21
29
|
export declare const selectors: {
|
|
22
30
|
toasts: (state: State) => ToastObject<any>[];
|
|
23
31
|
isEmpty: (state: State) => boolean;
|
|
@@ -34,7 +42,7 @@ export declare const selectors: {
|
|
|
34
42
|
export declare class ToastStore extends ReactStore<State, {}, typeof selectors> {
|
|
35
43
|
private timers;
|
|
36
44
|
private areTimersPaused;
|
|
37
|
-
constructor(initialState:
|
|
45
|
+
constructor(initialState: InitialState);
|
|
38
46
|
setFocused(focused: boolean): void;
|
|
39
47
|
setHovering(hovering: boolean): void;
|
|
40
48
|
setIsWindowFocused(isWindowFocused: boolean): void;
|
package/toast/store.js
CHANGED
|
@@ -11,13 +11,13 @@ var _useTimeout = require("@base-ui/utils/useTimeout");
|
|
|
11
11
|
var _resolvePromiseOptions = require("./utils/resolvePromiseOptions");
|
|
12
12
|
var _utils = require("../floating-ui-react/utils");
|
|
13
13
|
var _focusVisible = require("./utils/focusVisible");
|
|
14
|
-
|
|
15
|
-
const
|
|
14
|
+
function createToastMetadata(toasts) {
|
|
15
|
+
const metadata = new Map();
|
|
16
16
|
let visibleIndex = 0;
|
|
17
17
|
let offsetY = 0;
|
|
18
18
|
toasts.forEach((toast, toastIndex) => {
|
|
19
19
|
const isEnding = toast.transitionStatus === 'ending';
|
|
20
|
-
|
|
20
|
+
metadata.set(toast.id, {
|
|
21
21
|
value: toast,
|
|
22
22
|
domIndex: toastIndex,
|
|
23
23
|
visibleIndex: isEnding ? -1 : visibleIndex,
|
|
@@ -28,15 +28,16 @@ const toastMapSelector = (0, _store.createSelectorMemoized)(state => state.toast
|
|
|
28
28
|
visibleIndex += 1;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
return
|
|
32
|
-
}
|
|
31
|
+
return metadata;
|
|
32
|
+
}
|
|
33
|
+
const toastMetadataSelector = state => state.toastMetadata;
|
|
33
34
|
const selectors = exports.selectors = {
|
|
34
35
|
toasts: (0, _store.createSelector)(state => state.toasts),
|
|
35
36
|
isEmpty: (0, _store.createSelector)(state => state.toasts.length === 0),
|
|
36
|
-
toast: (0, _store.createSelector)(
|
|
37
|
-
toastIndex: (0, _store.createSelector)(
|
|
38
|
-
toastOffsetY: (0, _store.createSelector)(
|
|
39
|
-
toastVisibleIndex: (0, _store.createSelector)(
|
|
37
|
+
toast: (0, _store.createSelector)(toastMetadataSelector, (toastMetadata, id) => toastMetadata.get(id)?.value),
|
|
38
|
+
toastIndex: (0, _store.createSelector)(toastMetadataSelector, (toastMetadata, id) => toastMetadata.get(id)?.domIndex ?? -1),
|
|
39
|
+
toastOffsetY: (0, _store.createSelector)(toastMetadataSelector, (toastMetadata, id) => toastMetadata.get(id)?.offsetY ?? 0),
|
|
40
|
+
toastVisibleIndex: (0, _store.createSelector)(toastMetadataSelector, (toastMetadata, id) => toastMetadata.get(id)?.visibleIndex ?? -1),
|
|
40
41
|
hovering: (0, _store.createSelector)(state => state.hovering),
|
|
41
42
|
focused: (0, _store.createSelector)(state => state.focused),
|
|
42
43
|
expanded: (0, _store.createSelector)(state => state.hovering || state.focused),
|
|
@@ -47,7 +48,10 @@ class ToastStore extends _store.ReactStore {
|
|
|
47
48
|
timers = new Map();
|
|
48
49
|
areTimersPaused = false;
|
|
49
50
|
constructor(initialState) {
|
|
50
|
-
super(
|
|
51
|
+
super({
|
|
52
|
+
...initialState,
|
|
53
|
+
toastMetadata: createToastMetadata(initialState.toasts)
|
|
54
|
+
}, {}, selectors);
|
|
51
55
|
}
|
|
52
56
|
setFocused(focused) {
|
|
53
57
|
this.set('focused', focused);
|
|
@@ -252,7 +256,8 @@ class ToastStore extends _store.ReactStore {
|
|
|
252
256
|
} : item;
|
|
253
257
|
});
|
|
254
258
|
const updates = {
|
|
255
|
-
toasts: newToasts
|
|
259
|
+
toasts: newToasts,
|
|
260
|
+
toastMetadata: createToastMetadata(newToasts)
|
|
256
261
|
};
|
|
257
262
|
if (closeAll || toasts.length === 1) {
|
|
258
263
|
updates.hovering = false;
|
|
@@ -364,7 +369,8 @@ class ToastStore extends _store.ReactStore {
|
|
|
364
369
|
}
|
|
365
370
|
setToasts(newToasts) {
|
|
366
371
|
const updates = {
|
|
367
|
-
toasts: newToasts
|
|
372
|
+
toasts: newToasts,
|
|
373
|
+
toastMetadata: createToastMetadata(newToasts)
|
|
368
374
|
};
|
|
369
375
|
if (newToasts.length === 0) {
|
|
370
376
|
updates.hovering = false;
|
|
@@ -48,7 +48,7 @@ export interface ToastObject<Data extends object> {
|
|
|
48
48
|
*/
|
|
49
49
|
updateKey?: number | undefined;
|
|
50
50
|
/**
|
|
51
|
-
* Determines if the toast was
|
|
51
|
+
* Determines if the toast was limited because the toast limit was exceeded.
|
|
52
52
|
*/
|
|
53
53
|
limited?: boolean | undefined;
|
|
54
54
|
/**
|
|
@@ -45,6 +45,7 @@ const ToastViewport = exports.ToastViewport = /*#__PURE__*/React.forwardRef(func
|
|
|
45
45
|
const prevFocusElement = store.useState('prevFocusElement');
|
|
46
46
|
const frontmostHeight = toasts[0]?.height ?? 0;
|
|
47
47
|
const hasTransitioningToasts = React.useMemo(() => toasts.some(toast => toast.transitionStatus === 'ending'), [toasts]);
|
|
48
|
+
const highPriorityToasts = React.useMemo(() => toasts.filter(toast => toast.priority === 'high'), [toasts]);
|
|
48
49
|
|
|
49
50
|
// Listen globally for F6 so we can force-focus the viewport.
|
|
50
51
|
React.useEffect(() => {
|
|
@@ -234,7 +235,6 @@ const ToastViewport = exports.ToastViewport = /*#__PURE__*/React.forwardRef(func
|
|
|
234
235
|
})
|
|
235
236
|
}]
|
|
236
237
|
});
|
|
237
|
-
const highPriorityToasts = React.useMemo(() => toasts.filter(toast => toast.priority === 'high'), [toasts]);
|
|
238
238
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
239
239
|
children: [!isEmpty && prevFocusElement && /*#__PURE__*/(0, _jsxRuntime.jsx)(_FocusGuard.FocusGuard, {
|
|
240
240
|
onFocus: handleFocusGuard
|