@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.
Files changed (579) hide show
  1. package/CHANGELOG.md +125 -8
  2. package/README.md +1 -1
  3. package/accordion/item/AccordionItem.d.ts +4 -0
  4. package/accordion/item/AccordionItem.js +5 -4
  5. package/accordion/panel/AccordionPanel.js +29 -51
  6. package/accordion/root/AccordionRoot.js +5 -6
  7. package/accordion/trigger/AccordionTrigger.js +3 -4
  8. package/alert-dialog/handle.d.ts +14 -1
  9. package/alert-dialog/handle.js +22 -5
  10. package/alert-dialog/index.d.ts +1 -1
  11. package/alert-dialog/index.parts.d.ts +2 -3
  12. package/alert-dialog/index.parts.js +4 -5
  13. package/alert-dialog/root/AlertDialogRoot.d.ts +7 -7
  14. package/alert-dialog/root/AlertDialogRoot.js +2 -56
  15. package/alert-dialog/trigger/AlertDialogTrigger.d.ts +25 -0
  16. package/alert-dialog/trigger/AlertDialogTrigger.js +15 -0
  17. package/alert-dialog/trigger/AlertDialogTriggerDataAttributes.d.ts +10 -0
  18. package/alert-dialog/trigger/AlertDialogTriggerDataAttributes.js +18 -0
  19. package/autocomplete/root/AutocompleteRoot.js +9 -10
  20. package/avatar/image/AvatarImage.js +4 -4
  21. package/checkbox/indicator/CheckboxIndicator.js +2 -2
  22. package/checkbox/root/CheckboxRoot.js +49 -11
  23. package/checkbox-group/CheckboxGroup.js +1 -5
  24. package/collapsible/panel/CollapsiblePanel.js +29 -51
  25. package/collapsible/panel/useCollapsiblePanel.d.ts +9 -23
  26. package/collapsible/panel/useCollapsiblePanel.js +308 -268
  27. package/collapsible/root/CollapsibleRoot.d.ts +1 -1
  28. package/collapsible/root/CollapsibleRootContext.d.ts +0 -2
  29. package/collapsible/root/useCollapsibleRoot.d.ts +0 -27
  30. package/collapsible/root/useCollapsibleRoot.js +2 -64
  31. package/collapsible/trigger/CollapsibleTrigger.js +5 -6
  32. package/combobox/arrow/ComboboxArrow.js +1 -1
  33. package/combobox/backdrop/ComboboxBackdrop.js +1 -1
  34. package/combobox/chip/ComboboxChip.js +7 -2
  35. package/combobox/clear/ComboboxClear.d.ts +4 -0
  36. package/combobox/clear/ComboboxClear.js +1 -0
  37. package/combobox/clear/ComboboxClearDataAttributes.d.ts +4 -0
  38. package/combobox/clear/ComboboxClearDataAttributes.js +4 -0
  39. package/combobox/icon/ComboboxIcon.js +1 -1
  40. package/combobox/input/ComboboxInput.js +15 -6
  41. package/combobox/item/ComboboxItem.js +8 -14
  42. package/combobox/item-indicator/ComboboxItemIndicator.js +1 -2
  43. package/combobox/root/AriaCombobox.js +61 -28
  44. package/combobox/store.d.ts +4 -8
  45. package/combobox/store.js +2 -1
  46. package/combobox/utils/ComboboxInternalDismissButton.js +2 -3
  47. package/csp-provider/CSPProvider.js +1 -1
  48. package/dialog/close/DialogClose.js +6 -6
  49. package/dialog/popup/DialogPopup.js +9 -4
  50. package/dialog/root/DialogRoot.d.ts +1 -2
  51. package/dialog/root/DialogRoot.js +3 -73
  52. package/dialog/root/DialogRootContext.d.ts +1 -0
  53. package/dialog/root/DialogRootContext.js +3 -1
  54. package/dialog/root/useDialogRoot.d.ts +12 -4
  55. package/dialog/root/useDialogRoot.js +27 -25
  56. package/dialog/root/useRenderDialogRoot.d.ts +4 -0
  57. package/dialog/root/useRenderDialogRoot.js +96 -0
  58. package/dialog/store/DialogHandle.d.ts +1 -1
  59. package/dialog/store/DialogHandle.js +2 -2
  60. package/dialog/store/DialogStore.d.ts +88 -1
  61. package/dialog/store/DialogStore.js +12 -17
  62. package/dialog/trigger/DialogTrigger.d.ts +1 -1
  63. package/dialog/trigger/DialogTrigger.js +11 -4
  64. package/dialog/viewport/DialogViewport.js +4 -3
  65. package/drawer/popup/DrawerPopup.js +13 -9
  66. package/drawer/root/DrawerRoot.js +11 -11
  67. package/drawer/root/DrawerRootContext.d.ts +1 -1
  68. package/drawer/swipe-area/DrawerSwipeArea.js +6 -5
  69. package/drawer/viewport/DrawerViewport.js +13 -14
  70. package/esm/accordion/item/AccordionItem.d.ts +4 -0
  71. package/esm/accordion/item/AccordionItem.js +5 -4
  72. package/esm/accordion/panel/AccordionPanel.js +29 -51
  73. package/esm/accordion/root/AccordionRoot.js +5 -6
  74. package/esm/accordion/trigger/AccordionTrigger.js +4 -5
  75. package/esm/alert-dialog/handle.d.ts +14 -1
  76. package/esm/alert-dialog/handle.js +20 -5
  77. package/esm/alert-dialog/index.d.ts +1 -1
  78. package/esm/alert-dialog/index.parts.d.ts +2 -3
  79. package/esm/alert-dialog/index.parts.js +2 -3
  80. package/esm/alert-dialog/root/AlertDialogRoot.d.ts +7 -7
  81. package/esm/alert-dialog/root/AlertDialogRoot.js +2 -55
  82. package/esm/alert-dialog/trigger/AlertDialogTrigger.d.ts +25 -0
  83. package/esm/alert-dialog/trigger/AlertDialogTrigger.js +10 -0
  84. package/esm/alert-dialog/trigger/AlertDialogTriggerDataAttributes.d.ts +10 -0
  85. package/esm/alert-dialog/trigger/AlertDialogTriggerDataAttributes.js +12 -0
  86. package/esm/autocomplete/root/AutocompleteRoot.js +9 -10
  87. package/esm/avatar/image/AvatarImage.js +4 -4
  88. package/esm/checkbox/indicator/CheckboxIndicator.js +2 -2
  89. package/esm/checkbox/root/CheckboxRoot.js +49 -11
  90. package/esm/checkbox-group/CheckboxGroup.js +1 -5
  91. package/esm/collapsible/panel/CollapsiblePanel.js +29 -51
  92. package/esm/collapsible/panel/useCollapsiblePanel.d.ts +9 -23
  93. package/esm/collapsible/panel/useCollapsiblePanel.js +309 -269
  94. package/esm/collapsible/root/CollapsibleRoot.d.ts +1 -1
  95. package/esm/collapsible/root/CollapsibleRootContext.d.ts +0 -2
  96. package/esm/collapsible/root/useCollapsibleRoot.d.ts +0 -27
  97. package/esm/collapsible/root/useCollapsibleRoot.js +2 -64
  98. package/esm/collapsible/trigger/CollapsibleTrigger.js +5 -6
  99. package/esm/combobox/arrow/ComboboxArrow.js +1 -1
  100. package/esm/combobox/backdrop/ComboboxBackdrop.js +1 -1
  101. package/esm/combobox/chip/ComboboxChip.js +7 -2
  102. package/esm/combobox/clear/ComboboxClear.d.ts +4 -0
  103. package/esm/combobox/clear/ComboboxClear.js +1 -0
  104. package/esm/combobox/clear/ComboboxClearDataAttributes.d.ts +4 -0
  105. package/esm/combobox/clear/ComboboxClearDataAttributes.js +4 -0
  106. package/esm/combobox/icon/ComboboxIcon.js +1 -1
  107. package/esm/combobox/input/ComboboxInput.js +16 -7
  108. package/esm/combobox/item/ComboboxItem.js +8 -14
  109. package/esm/combobox/item-indicator/ComboboxItemIndicator.js +1 -2
  110. package/esm/combobox/root/AriaCombobox.js +62 -29
  111. package/esm/combobox/store.d.ts +4 -8
  112. package/esm/combobox/store.js +2 -1
  113. package/esm/combobox/utils/ComboboxInternalDismissButton.js +2 -3
  114. package/esm/csp-provider/CSPProvider.js +1 -1
  115. package/esm/dialog/close/DialogClose.js +6 -6
  116. package/esm/dialog/popup/DialogPopup.js +9 -4
  117. package/esm/dialog/root/DialogRoot.d.ts +1 -2
  118. package/esm/dialog/root/DialogRoot.js +4 -72
  119. package/esm/dialog/root/DialogRootContext.d.ts +1 -0
  120. package/esm/dialog/root/DialogRootContext.js +2 -0
  121. package/esm/dialog/root/useDialogRoot.d.ts +12 -4
  122. package/esm/dialog/root/useDialogRoot.js +28 -27
  123. package/esm/dialog/root/useRenderDialogRoot.d.ts +4 -0
  124. package/esm/dialog/root/useRenderDialogRoot.js +90 -0
  125. package/esm/dialog/store/DialogHandle.d.ts +1 -1
  126. package/esm/dialog/store/DialogHandle.js +2 -2
  127. package/esm/dialog/store/DialogStore.d.ts +88 -1
  128. package/esm/dialog/store/DialogStore.js +13 -18
  129. package/esm/dialog/trigger/DialogTrigger.d.ts +1 -1
  130. package/esm/dialog/trigger/DialogTrigger.js +12 -5
  131. package/esm/dialog/viewport/DialogViewport.js +4 -3
  132. package/esm/drawer/popup/DrawerPopup.js +14 -9
  133. package/esm/drawer/root/DrawerRoot.js +11 -11
  134. package/esm/drawer/root/DrawerRootContext.d.ts +1 -1
  135. package/esm/drawer/swipe-area/DrawerSwipeArea.js +6 -5
  136. package/esm/drawer/viewport/DrawerViewport.js +13 -14
  137. package/esm/field/control/FieldControl.js +2 -6
  138. package/esm/field/item/FieldItem.js +1 -4
  139. package/esm/field/root/FieldRoot.js +11 -3
  140. package/esm/field/root/useFieldValidation.d.ts +1 -0
  141. package/esm/field/root/useFieldValidation.js +23 -20
  142. package/esm/field/utils/getCombinedFieldValidityData.d.ts +1 -1
  143. package/esm/field/validity/FieldValidity.d.ts +1 -1
  144. package/esm/floating-ui-react/components/FloatingDelayGroup.js +3 -3
  145. package/esm/floating-ui-react/components/FloatingFocusManager.d.ts +1 -1
  146. package/esm/floating-ui-react/components/FloatingFocusManager.js +20 -8
  147. package/esm/floating-ui-react/components/FloatingPortal.js +3 -3
  148. package/esm/floating-ui-react/hooks/useClick.js +83 -74
  149. package/esm/floating-ui-react/hooks/useClientPoint.js +29 -20
  150. package/esm/floating-ui-react/hooks/useDismiss.d.ts +1 -1
  151. package/esm/floating-ui-react/hooks/useDismiss.js +82 -93
  152. package/esm/floating-ui-react/hooks/useFloating.js +37 -32
  153. package/esm/floating-ui-react/hooks/useFloatingRootContext.d.ts +1 -1
  154. package/esm/floating-ui-react/hooks/useFloatingRootContext.js +2 -2
  155. package/esm/floating-ui-react/hooks/useFocus.js +84 -81
  156. package/esm/floating-ui-react/hooks/useHover.js +72 -76
  157. package/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js +49 -44
  158. package/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js +1 -1
  159. package/esm/floating-ui-react/hooks/useHoverReferenceInteraction.d.ts +7 -2
  160. package/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js +44 -39
  161. package/esm/floating-ui-react/hooks/useHoverShared.d.ts +2 -1
  162. package/esm/floating-ui-react/hooks/useHoverShared.js +4 -0
  163. package/esm/floating-ui-react/hooks/useListNavigation.d.ts +1 -3
  164. package/esm/floating-ui-react/hooks/useListNavigation.js +83 -74
  165. package/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.d.ts +9 -6
  166. package/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js +25 -20
  167. package/esm/floating-ui-react/hooks/useTypeahead.d.ts +2 -2
  168. package/esm/floating-ui-react/hooks/useTypeahead.js +33 -52
  169. package/esm/floating-ui-react/index.d.ts +0 -2
  170. package/esm/floating-ui-react/index.js +0 -2
  171. package/esm/floating-ui-react/types.d.ts +2 -7
  172. package/esm/floating-ui-react/utils/composite.js +2 -0
  173. package/esm/floating-ui-react/utils/enqueueFocus.d.ts +1 -1
  174. package/esm/floating-ui-react/utils/enqueueFocus.js +10 -7
  175. package/esm/floating-ui-react/utils/getEmptyRootContext.js +1 -1
  176. package/esm/form/Form.js +2 -2
  177. package/esm/index.js +1 -1
  178. package/esm/internals/composite/composite.d.ts +0 -1
  179. package/esm/internals/composite/composite.js +1 -2
  180. package/esm/internals/composite/root/useCompositeRoot.js +2 -2
  181. package/esm/internals/createBaseUIEventDetails.d.ts +2 -0
  182. package/esm/internals/csp-context/index.d.ts +2 -0
  183. package/esm/internals/csp-context/index.js +1 -0
  184. package/esm/internals/field-register-control/index.d.ts +0 -1
  185. package/esm/internals/field-register-control/useFieldControlRegistration.d.ts +2 -1
  186. package/esm/internals/field-register-control/useFieldControlRegistration.js +11 -14
  187. package/esm/internals/field-register-control/useRegisterFieldControl.d.ts +1 -4
  188. package/esm/internals/field-register-control/useRegisterFieldControl.js +6 -11
  189. package/esm/internals/field-root-context/FieldRootContext.d.ts +1 -0
  190. package/esm/internals/field-root-context/FieldRootContext.js +3 -2
  191. package/esm/internals/form-context/FormContext.d.ts +5 -1
  192. package/esm/internals/reason-parts.d.ts +2 -0
  193. package/esm/internals/reason-parts.js +2 -0
  194. package/esm/internals/types.d.ts +1 -0
  195. package/esm/internals/use-button/useButton.js +4 -4
  196. package/esm/internals/usePressAndHold.js +2 -2
  197. package/esm/internals/useRenderElement.js +2 -0
  198. package/esm/menu/arrow/MenuArrow.js +1 -1
  199. package/esm/menu/backdrop/MenuBackdrop.js +1 -1
  200. package/esm/menu/checkbox-item/MenuCheckboxItem.js +5 -7
  201. package/esm/menu/group/MenuGroup.js +1 -4
  202. package/esm/menu/group/MenuGroupContext.d.ts +1 -3
  203. package/esm/menu/group/MenuGroupContext.js +1 -1
  204. package/esm/menu/group-label/MenuGroupLabel.js +4 -6
  205. package/esm/menu/link-item/MenuLinkItem.js +2 -2
  206. package/esm/menu/popup/MenuPopup.js +5 -5
  207. package/esm/menu/radio-group/MenuRadioGroup.js +11 -5
  208. package/esm/menu/radio-item/MenuRadioItem.js +5 -7
  209. package/esm/menu/root/MenuRoot.js +63 -68
  210. package/esm/menu/store/MenuHandle.js +1 -1
  211. package/esm/menu/store/MenuStore.d.ts +87 -0
  212. package/esm/menu/submenu-trigger/MenuSubmenuTrigger.js +8 -5
  213. package/esm/menu/trigger/MenuTrigger.js +13 -10
  214. package/esm/menu/viewport/MenuViewport.d.ts +2 -2
  215. package/esm/menu/viewport/MenuViewport.js +2 -2
  216. package/esm/navigation-menu/arrow/NavigationMenuArrow.js +1 -1
  217. package/esm/navigation-menu/backdrop/NavigationMenuBackdrop.js +1 -1
  218. package/esm/navigation-menu/content/NavigationMenuContent.js +8 -5
  219. package/esm/navigation-menu/icon/NavigationMenuIcon.js +1 -1
  220. package/esm/navigation-menu/item/NavigationMenuItem.js +2 -2
  221. package/esm/navigation-menu/list/NavigationMenuList.js +1 -1
  222. package/esm/navigation-menu/popup/NavigationMenuPopup.js +2 -2
  223. package/esm/navigation-menu/root/NavigationMenuRoot.js +1 -3
  224. package/esm/navigation-menu/trigger/NavigationMenuTrigger.js +24 -17
  225. package/esm/navigation-menu/utils/isOutsideMenuEvent.d.ts +0 -1
  226. package/esm/navigation-menu/utils/isOutsideMenuEvent.js +1 -5
  227. package/esm/navigation-menu/viewport/NavigationMenuViewport.js +2 -3
  228. package/esm/number-field/input/NumberFieldInput.js +3 -5
  229. package/esm/number-field/root/NumberFieldRoot.js +5 -2
  230. package/esm/number-field/scrub-area/NumberFieldScrubArea.js +7 -3
  231. package/esm/otp-field/input/OTPFieldInput.js +43 -29
  232. package/esm/otp-field/root/OTPFieldRoot.d.ts +17 -8
  233. package/esm/otp-field/root/OTPFieldRoot.js +33 -33
  234. package/esm/otp-field/root/OTPFieldRootContext.d.ts +1 -1
  235. package/esm/otp-field/utils/otp.d.ts +5 -4
  236. package/esm/otp-field/utils/otp.js +23 -12
  237. package/esm/popover/arrow/PopoverArrow.js +1 -1
  238. package/esm/popover/backdrop/PopoverBackdrop.js +1 -1
  239. package/esm/popover/close/PopoverClose.js +2 -2
  240. package/esm/popover/description/PopoverDescription.js +1 -7
  241. package/esm/popover/popup/PopoverPopup.d.ts +1 -1
  242. package/esm/popover/popup/PopoverPopup.js +16 -10
  243. package/esm/popover/popup/PopoverPopupDataAttributes.d.ts +1 -1
  244. package/esm/popover/popup/PopoverPopupDataAttributes.js +1 -1
  245. package/esm/popover/positioner/PopoverPositioner.js +5 -5
  246. package/esm/popover/root/PopoverRoot.d.ts +1 -1
  247. package/esm/popover/root/PopoverRoot.js +42 -47
  248. package/esm/popover/store/PopoverHandle.js +1 -1
  249. package/esm/popover/store/PopoverStore.d.ts +91 -4
  250. package/esm/popover/store/PopoverStore.js +17 -18
  251. package/esm/popover/title/PopoverTitle.js +1 -7
  252. package/esm/popover/trigger/PopoverTrigger.js +24 -17
  253. package/esm/popover/viewport/PopoverViewport.d.ts +3 -3
  254. package/esm/popover/viewport/PopoverViewport.js +2 -2
  255. package/esm/popover/viewport/PopoverViewportDataAttributes.d.ts +1 -1
  256. package/esm/popover/viewport/PopoverViewportDataAttributes.js +1 -1
  257. package/esm/preview-card/positioner/PreviewCardPositioner.js +11 -1
  258. package/esm/preview-card/root/PreviewCardRoot.d.ts +1 -1
  259. package/esm/preview-card/root/PreviewCardRoot.js +32 -22
  260. package/esm/preview-card/store/PreviewCardHandle.js +1 -1
  261. package/esm/preview-card/store/PreviewCardStore.d.ts +90 -2
  262. package/esm/preview-card/store/PreviewCardStore.js +19 -31
  263. package/esm/preview-card/trigger/PreviewCardTrigger.js +6 -3
  264. package/esm/preview-card/viewport/PreviewCardViewport.d.ts +2 -2
  265. package/esm/preview-card/viewport/PreviewCardViewport.js +2 -2
  266. package/esm/preview-card/viewport/PreviewCardViewportDataAttributes.d.ts +2 -2
  267. package/esm/preview-card/viewport/PreviewCardViewportDataAttributes.js +2 -2
  268. package/esm/progress/indicator/ProgressIndicator.js +6 -11
  269. package/esm/progress/root/ProgressRoot.d.ts +1 -1
  270. package/esm/radio/root/RadioRoot.js +7 -3
  271. package/esm/radio-group/RadioGroup.js +4 -11
  272. package/esm/radio-group/RadioGroupContext.d.ts +0 -1
  273. package/esm/scroll-area/content/ScrollAreaContent.js +4 -4
  274. package/esm/scroll-area/root/ScrollAreaRoot.js +1 -1
  275. package/esm/scroll-area/scrollbar/ScrollAreaScrollbar.js +16 -20
  276. package/esm/scroll-area/viewport/ScrollAreaViewport.js +6 -10
  277. package/esm/select/arrow/SelectArrow.js +1 -1
  278. package/esm/select/backdrop/SelectBackdrop.js +1 -1
  279. package/esm/select/group/SelectGroup.js +1 -1
  280. package/esm/select/group-label/SelectGroupLabel.js +2 -2
  281. package/esm/select/icon/SelectIcon.js +1 -1
  282. package/esm/select/item/SelectItem.js +46 -32
  283. package/esm/select/item/SelectItemContext.d.ts +1 -1
  284. package/esm/select/item-indicator/SelectItemIndicator.js +1 -2
  285. package/esm/select/item-text/SelectItemText.js +9 -6
  286. package/esm/select/list/SelectList.js +1 -1
  287. package/esm/select/popup/SelectPopup.js +8 -3
  288. package/esm/select/positioner/SelectPositioner.js +3 -0
  289. package/esm/select/root/SelectRoot.js +46 -40
  290. package/esm/select/root/SelectRootContext.d.ts +4 -5
  291. package/esm/select/store.d.ts +3 -0
  292. package/esm/select/store.js +1 -0
  293. package/esm/select/trigger/SelectTrigger.d.ts +5 -0
  294. package/esm/select/trigger/SelectTrigger.js +19 -33
  295. package/esm/select/trigger/SelectTriggerDataAttributes.d.ts +5 -0
  296. package/esm/select/trigger/SelectTriggerDataAttributes.js +5 -0
  297. package/esm/slider/control/SliderControl.js +10 -12
  298. package/esm/slider/root/SliderRoot.js +1 -4
  299. package/esm/slider/thumb/SliderThumb.js +32 -30
  300. package/esm/slider/value/SliderValue.js +7 -15
  301. package/esm/switch/root/SwitchRoot.js +10 -10
  302. package/esm/switch/thumb/SwitchThumb.js +1 -9
  303. package/esm/tabs/indicator/TabsIndicator.js +14 -19
  304. package/esm/tabs/list/TabsList.js +4 -10
  305. package/esm/tabs/list/TabsListContext.d.ts +2 -1
  306. package/esm/tabs/panel/TabsPanel.js +1 -1
  307. package/esm/tabs/root/TabsRoot.d.ts +16 -1
  308. package/esm/tabs/root/TabsRoot.js +73 -25
  309. package/esm/tabs/root/TabsRootContext.d.ts +0 -2
  310. package/esm/toast/provider/ToastProvider.js +1 -1
  311. package/esm/toast/root/ToastRoot.d.ts +1 -1
  312. package/esm/toast/root/ToastRoot.js +108 -131
  313. package/esm/toast/root/ToastRootDataAttributes.d.ts +1 -1
  314. package/esm/toast/root/ToastRootDataAttributes.js +1 -1
  315. package/esm/toast/store.d.ts +9 -1
  316. package/esm/toast/store.js +19 -13
  317. package/esm/toast/useToastManager.d.ts +1 -1
  318. package/esm/toast/viewport/ToastViewport.js +1 -1
  319. package/esm/toggle/Toggle.js +5 -9
  320. package/esm/toggle-group/ToggleGroup.d.ts +2 -2
  321. package/esm/toggle-group/ToggleGroup.js +6 -13
  322. package/esm/toolbar/link/ToolbarLink.d.ts +1 -1
  323. package/esm/toolbar/link/ToolbarLink.js +1 -2
  324. package/esm/tooltip/arrow/TooltipArrow.js +3 -3
  325. package/esm/tooltip/popup/TooltipPopup.js +5 -4
  326. package/esm/tooltip/root/TooltipRoot.js +35 -26
  327. package/esm/tooltip/store/TooltipHandle.js +1 -1
  328. package/esm/tooltip/store/TooltipStore.d.ts +90 -2
  329. package/esm/tooltip/store/TooltipStore.js +18 -31
  330. package/esm/tooltip/trigger/TooltipTrigger.js +151 -20
  331. package/esm/tooltip/viewport/TooltipViewport.d.ts +2 -2
  332. package/esm/tooltip/viewport/TooltipViewport.js +2 -2
  333. package/esm/tooltip/viewport/TooltipViewportDataAttributes.d.ts +1 -1
  334. package/esm/tooltip/viewport/TooltipViewportDataAttributes.js +1 -1
  335. package/esm/unstable-use-media-query/index.js +1 -1
  336. package/esm/utils/popups/index.d.ts +1 -0
  337. package/esm/utils/popups/index.js +1 -0
  338. package/esm/utils/popups/inlineRect.d.ts +15 -0
  339. package/esm/utils/popups/inlineRect.js +191 -0
  340. package/esm/utils/popups/popupStoreUtils.d.ts +28 -10
  341. package/esm/utils/popups/popupStoreUtils.js +105 -20
  342. package/esm/utils/popups/popupTriggerMap.js +2 -0
  343. package/esm/utils/popups/store.d.ts +15 -2
  344. package/esm/utils/popups/store.js +38 -2
  345. package/esm/utils/popups/useTriggerFocusGuards.js +4 -5
  346. package/esm/utils/useAnchorPositioning.d.ts +5 -0
  347. package/esm/utils/useAnchorPositioning.js +12 -9
  348. package/esm/utils/useOpenInteractionType.d.ts +4 -0
  349. package/esm/utils/useOpenInteractionType.js +23 -18
  350. package/field/control/FieldControl.js +2 -6
  351. package/field/item/FieldItem.js +1 -4
  352. package/field/root/FieldRoot.js +11 -3
  353. package/field/root/useFieldValidation.d.ts +1 -0
  354. package/field/root/useFieldValidation.js +23 -20
  355. package/field/utils/getCombinedFieldValidityData.d.ts +1 -1
  356. package/field/validity/FieldValidity.d.ts +1 -1
  357. package/floating-ui-react/components/FloatingDelayGroup.js +3 -3
  358. package/floating-ui-react/components/FloatingFocusManager.d.ts +1 -1
  359. package/floating-ui-react/components/FloatingFocusManager.js +20 -8
  360. package/floating-ui-react/components/FloatingPortal.js +3 -3
  361. package/floating-ui-react/hooks/useClick.js +82 -73
  362. package/floating-ui-react/hooks/useClientPoint.js +29 -20
  363. package/floating-ui-react/hooks/useDismiss.d.ts +1 -1
  364. package/floating-ui-react/hooks/useDismiss.js +82 -92
  365. package/floating-ui-react/hooks/useFloating.js +36 -32
  366. package/floating-ui-react/hooks/useFloatingRootContext.d.ts +1 -1
  367. package/floating-ui-react/hooks/useFloatingRootContext.js +2 -2
  368. package/floating-ui-react/hooks/useFocus.js +84 -81
  369. package/floating-ui-react/hooks/useHover.js +74 -78
  370. package/floating-ui-react/hooks/useHoverFloatingInteraction.js +48 -43
  371. package/floating-ui-react/hooks/useHoverInteractionSharedState.js +1 -1
  372. package/floating-ui-react/hooks/useHoverReferenceInteraction.d.ts +7 -2
  373. package/floating-ui-react/hooks/useHoverReferenceInteraction.js +43 -38
  374. package/floating-ui-react/hooks/useHoverShared.d.ts +2 -1
  375. package/floating-ui-react/hooks/useHoverShared.js +11 -0
  376. package/floating-ui-react/hooks/useListNavigation.d.ts +1 -3
  377. package/floating-ui-react/hooks/useListNavigation.js +83 -74
  378. package/floating-ui-react/hooks/useSyncedFloatingRootContext.d.ts +9 -6
  379. package/floating-ui-react/hooks/useSyncedFloatingRootContext.js +26 -20
  380. package/floating-ui-react/hooks/useTypeahead.d.ts +2 -2
  381. package/floating-ui-react/hooks/useTypeahead.js +33 -52
  382. package/floating-ui-react/index.d.ts +0 -2
  383. package/floating-ui-react/index.js +0 -14
  384. package/floating-ui-react/types.d.ts +2 -7
  385. package/floating-ui-react/utils/composite.js +2 -0
  386. package/floating-ui-react/utils/enqueueFocus.d.ts +1 -1
  387. package/floating-ui-react/utils/enqueueFocus.js +10 -7
  388. package/floating-ui-react/utils/getEmptyRootContext.js +1 -1
  389. package/form/Form.js +2 -2
  390. package/index.js +1 -1
  391. package/internals/composite/composite.d.ts +0 -1
  392. package/internals/composite/composite.js +2 -3
  393. package/internals/composite/root/useCompositeRoot.js +1 -1
  394. package/internals/createBaseUIEventDetails.d.ts +2 -0
  395. package/internals/csp-context/index.d.ts +2 -0
  396. package/internals/csp-context/index.js +18 -0
  397. package/internals/field-register-control/index.d.ts +0 -1
  398. package/internals/field-register-control/useFieldControlRegistration.d.ts +2 -1
  399. package/internals/field-register-control/useFieldControlRegistration.js +11 -14
  400. package/internals/field-register-control/useRegisterFieldControl.d.ts +1 -4
  401. package/internals/field-register-control/useRegisterFieldControl.js +6 -11
  402. package/internals/field-root-context/FieldRootContext.d.ts +1 -0
  403. package/internals/field-root-context/FieldRootContext.js +4 -3
  404. package/internals/form-context/FormContext.d.ts +5 -1
  405. package/internals/reason-parts.d.ts +2 -0
  406. package/internals/reason-parts.js +3 -1
  407. package/internals/types.d.ts +1 -0
  408. package/internals/use-button/useButton.js +4 -4
  409. package/internals/usePressAndHold.js +2 -2
  410. package/internals/useRenderElement.js +2 -0
  411. package/menu/arrow/MenuArrow.js +1 -1
  412. package/menu/backdrop/MenuBackdrop.js +1 -1
  413. package/menu/checkbox-item/MenuCheckboxItem.js +5 -7
  414. package/menu/group/MenuGroup.js +1 -4
  415. package/menu/group/MenuGroupContext.d.ts +1 -3
  416. package/menu/group/MenuGroupContext.js +1 -1
  417. package/menu/group-label/MenuGroupLabel.js +4 -6
  418. package/menu/link-item/MenuLinkItem.js +2 -2
  419. package/menu/popup/MenuPopup.js +5 -5
  420. package/menu/radio-group/MenuRadioGroup.js +11 -5
  421. package/menu/radio-item/MenuRadioItem.js +5 -7
  422. package/menu/root/MenuRoot.js +60 -65
  423. package/menu/store/MenuHandle.js +1 -1
  424. package/menu/store/MenuStore.d.ts +87 -0
  425. package/menu/submenu-trigger/MenuSubmenuTrigger.js +7 -4
  426. package/menu/trigger/MenuTrigger.js +12 -9
  427. package/menu/viewport/MenuViewport.d.ts +2 -2
  428. package/menu/viewport/MenuViewport.js +2 -2
  429. package/navigation-menu/arrow/NavigationMenuArrow.js +1 -1
  430. package/navigation-menu/backdrop/NavigationMenuBackdrop.js +1 -1
  431. package/navigation-menu/content/NavigationMenuContent.js +8 -5
  432. package/navigation-menu/icon/NavigationMenuIcon.js +1 -1
  433. package/navigation-menu/item/NavigationMenuItem.js +2 -2
  434. package/navigation-menu/list/NavigationMenuList.js +1 -1
  435. package/navigation-menu/popup/NavigationMenuPopup.js +2 -2
  436. package/navigation-menu/root/NavigationMenuRoot.js +1 -3
  437. package/navigation-menu/trigger/NavigationMenuTrigger.js +23 -16
  438. package/navigation-menu/utils/isOutsideMenuEvent.d.ts +0 -1
  439. package/navigation-menu/utils/isOutsideMenuEvent.js +1 -5
  440. package/navigation-menu/viewport/NavigationMenuViewport.js +2 -3
  441. package/number-field/input/NumberFieldInput.js +3 -5
  442. package/number-field/root/NumberFieldRoot.js +5 -2
  443. package/number-field/scrub-area/NumberFieldScrubArea.js +7 -3
  444. package/otp-field/input/OTPFieldInput.js +42 -28
  445. package/otp-field/root/OTPFieldRoot.d.ts +17 -8
  446. package/otp-field/root/OTPFieldRoot.js +32 -32
  447. package/otp-field/root/OTPFieldRootContext.d.ts +1 -1
  448. package/otp-field/utils/otp.d.ts +5 -4
  449. package/otp-field/utils/otp.js +24 -12
  450. package/package.json +331 -317
  451. package/popover/arrow/PopoverArrow.js +1 -1
  452. package/popover/backdrop/PopoverBackdrop.js +1 -1
  453. package/popover/close/PopoverClose.js +2 -2
  454. package/popover/description/PopoverDescription.js +1 -7
  455. package/popover/popup/PopoverPopup.d.ts +1 -1
  456. package/popover/popup/PopoverPopup.js +16 -10
  457. package/popover/popup/PopoverPopupDataAttributes.d.ts +1 -1
  458. package/popover/popup/PopoverPopupDataAttributes.js +1 -1
  459. package/popover/positioner/PopoverPositioner.js +5 -5
  460. package/popover/root/PopoverRoot.d.ts +1 -1
  461. package/popover/root/PopoverRoot.js +39 -44
  462. package/popover/store/PopoverHandle.js +1 -1
  463. package/popover/store/PopoverStore.d.ts +91 -4
  464. package/popover/store/PopoverStore.js +16 -19
  465. package/popover/title/PopoverTitle.js +1 -7
  466. package/popover/trigger/PopoverTrigger.js +23 -16
  467. package/popover/viewport/PopoverViewport.d.ts +3 -3
  468. package/popover/viewport/PopoverViewport.js +2 -2
  469. package/popover/viewport/PopoverViewportDataAttributes.d.ts +1 -1
  470. package/popover/viewport/PopoverViewportDataAttributes.js +1 -1
  471. package/preview-card/positioner/PreviewCardPositioner.js +11 -1
  472. package/preview-card/root/PreviewCardRoot.d.ts +1 -1
  473. package/preview-card/root/PreviewCardRoot.js +30 -20
  474. package/preview-card/store/PreviewCardHandle.js +1 -1
  475. package/preview-card/store/PreviewCardStore.d.ts +90 -2
  476. package/preview-card/store/PreviewCardStore.js +18 -30
  477. package/preview-card/trigger/PreviewCardTrigger.js +5 -2
  478. package/preview-card/viewport/PreviewCardViewport.d.ts +2 -2
  479. package/preview-card/viewport/PreviewCardViewport.js +2 -2
  480. package/preview-card/viewport/PreviewCardViewportDataAttributes.d.ts +2 -2
  481. package/preview-card/viewport/PreviewCardViewportDataAttributes.js +2 -2
  482. package/progress/indicator/ProgressIndicator.js +6 -11
  483. package/progress/root/ProgressRoot.d.ts +1 -1
  484. package/radio/root/RadioRoot.js +7 -3
  485. package/radio-group/RadioGroup.js +4 -11
  486. package/radio-group/RadioGroupContext.d.ts +0 -1
  487. package/scroll-area/content/ScrollAreaContent.js +4 -4
  488. package/scroll-area/root/ScrollAreaRoot.js +1 -1
  489. package/scroll-area/scrollbar/ScrollAreaScrollbar.js +16 -20
  490. package/scroll-area/viewport/ScrollAreaViewport.js +6 -10
  491. package/select/arrow/SelectArrow.js +1 -1
  492. package/select/backdrop/SelectBackdrop.js +1 -1
  493. package/select/group/SelectGroup.js +1 -1
  494. package/select/group-label/SelectGroupLabel.js +2 -2
  495. package/select/icon/SelectIcon.js +1 -1
  496. package/select/item/SelectItem.js +46 -32
  497. package/select/item/SelectItemContext.d.ts +1 -1
  498. package/select/item-indicator/SelectItemIndicator.js +1 -2
  499. package/select/item-text/SelectItemText.js +9 -6
  500. package/select/list/SelectList.js +1 -1
  501. package/select/popup/SelectPopup.js +8 -3
  502. package/select/positioner/SelectPositioner.js +3 -0
  503. package/select/root/SelectRoot.js +45 -39
  504. package/select/root/SelectRootContext.d.ts +4 -5
  505. package/select/store.d.ts +3 -0
  506. package/select/store.js +1 -0
  507. package/select/trigger/SelectTrigger.d.ts +5 -0
  508. package/select/trigger/SelectTrigger.js +19 -33
  509. package/select/trigger/SelectTriggerDataAttributes.d.ts +5 -0
  510. package/select/trigger/SelectTriggerDataAttributes.js +5 -0
  511. package/slider/control/SliderControl.js +9 -11
  512. package/slider/root/SliderRoot.js +1 -4
  513. package/slider/thumb/SliderThumb.js +32 -30
  514. package/slider/value/SliderValue.js +7 -15
  515. package/switch/root/SwitchRoot.js +10 -10
  516. package/switch/thumb/SwitchThumb.js +1 -9
  517. package/tabs/indicator/TabsIndicator.js +14 -19
  518. package/tabs/list/TabsList.js +4 -10
  519. package/tabs/list/TabsListContext.d.ts +2 -1
  520. package/tabs/panel/TabsPanel.js +1 -1
  521. package/tabs/root/TabsRoot.d.ts +16 -1
  522. package/tabs/root/TabsRoot.js +71 -24
  523. package/tabs/root/TabsRootContext.d.ts +0 -2
  524. package/toast/provider/ToastProvider.js +1 -1
  525. package/toast/root/ToastRoot.d.ts +1 -1
  526. package/toast/root/ToastRoot.js +110 -133
  527. package/toast/root/ToastRootDataAttributes.d.ts +1 -1
  528. package/toast/root/ToastRootDataAttributes.js +1 -1
  529. package/toast/store.d.ts +9 -1
  530. package/toast/store.js +18 -12
  531. package/toast/useToastManager.d.ts +1 -1
  532. package/toast/viewport/ToastViewport.js +1 -1
  533. package/toggle/Toggle.js +5 -9
  534. package/toggle-group/ToggleGroup.d.ts +2 -2
  535. package/toggle-group/ToggleGroup.js +6 -13
  536. package/toolbar/link/ToolbarLink.d.ts +1 -1
  537. package/toolbar/link/ToolbarLink.js +1 -2
  538. package/tooltip/arrow/TooltipArrow.js +3 -3
  539. package/tooltip/popup/TooltipPopup.js +5 -4
  540. package/tooltip/root/TooltipRoot.js +32 -23
  541. package/tooltip/store/TooltipHandle.js +1 -1
  542. package/tooltip/store/TooltipStore.d.ts +90 -2
  543. package/tooltip/store/TooltipStore.js +17 -30
  544. package/tooltip/trigger/TooltipTrigger.js +152 -20
  545. package/tooltip/viewport/TooltipViewport.d.ts +2 -2
  546. package/tooltip/viewport/TooltipViewport.js +2 -2
  547. package/tooltip/viewport/TooltipViewportDataAttributes.d.ts +1 -1
  548. package/tooltip/viewport/TooltipViewportDataAttributes.js +1 -1
  549. package/unstable-use-media-query/index.js +1 -1
  550. package/utils/popups/index.d.ts +1 -0
  551. package/utils/popups/index.js +11 -0
  552. package/utils/popups/inlineRect.d.ts +15 -0
  553. package/utils/popups/inlineRect.js +198 -0
  554. package/utils/popups/popupStoreUtils.d.ts +28 -10
  555. package/utils/popups/popupStoreUtils.js +110 -20
  556. package/utils/popups/popupTriggerMap.js +2 -0
  557. package/utils/popups/store.d.ts +15 -2
  558. package/utils/popups/store.js +39 -2
  559. package/utils/popups/useTriggerFocusGuards.js +4 -5
  560. package/utils/useAnchorPositioning.d.ts +5 -0
  561. package/utils/useAnchorPositioning.js +12 -9
  562. package/utils/useOpenInteractionType.d.ts +4 -0
  563. package/utils/useOpenInteractionType.js +24 -17
  564. package/checkbox-group/index.parts.d.ts +0 -1
  565. package/checkbox-group/index.parts.js +0 -12
  566. package/esm/checkbox-group/index.parts.d.ts +0 -1
  567. package/esm/checkbox-group/index.parts.js +0 -1
  568. package/esm/floating-ui-react/hooks/useInteractions.d.ts +0 -20
  569. package/esm/floating-ui-react/hooks/useInteractions.js +0 -88
  570. package/esm/floating-ui-react/hooks/useRole.d.ts +0 -17
  571. package/esm/floating-ui-react/hooks/useRole.js +0 -113
  572. package/floating-ui-react/hooks/useInteractions.d.ts +0 -20
  573. package/floating-ui-react/hooks/useInteractions.js +0 -95
  574. package/floating-ui-react/hooks/useRole.d.ts +0 -17
  575. package/floating-ui-react/hooks/useRole.js +0 -120
  576. /package/{csp-provider → esm/internals/csp-context}/CSPContext.d.ts +0 -0
  577. /package/esm/{csp-provider → internals/csp-context}/CSPContext.js +0 -0
  578. /package/{esm/csp-provider → internals/csp-context}/CSPContext.d.ts +0 -0
  579. /package/{csp-provider → internals/csp-context}/CSPContext.js +0 -0
@@ -5,6 +5,7 @@ import { useStableCallback } from '@base-ui/utils/useStableCallback';
5
5
  import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
6
6
  import { useMergedRefs } from '@base-ui/utils/useMergedRefs';
7
7
  import { visuallyHidden } from '@base-ui/utils/visuallyHidden';
8
+ import { ownerWindow } from '@base-ui/utils/owner';
8
9
  import { clamp } from "../../internals/clamp.js";
9
10
  import { formatNumber } from "../../utils/formatNumber.js";
10
11
  import { mergeProps } from "../../merge-props/index.js";
@@ -15,7 +16,7 @@ import { valueToPercent } from "../../utils/valueToPercent.js";
15
16
  import { ARROW_DOWN, ARROW_UP, ARROW_RIGHT, ARROW_LEFT, HOME, END, COMPOSITE_KEYS, PAGE_UP, PAGE_DOWN } from "../../internals/composite/composite.js";
16
17
  import { useCompositeListItem } from "../../internals/composite/list/useCompositeListItem.js";
17
18
  import { useDirection } from "../../internals/direction-context/DirectionContext.js";
18
- import { useCSPContext } from "../../csp-provider/CSPContext.js";
19
+ import { useCSPContext } from "../../internals/csp-context/CSPContext.js";
19
20
  import { useFieldRootContext } from "../../internals/field-root-context/FieldRootContext.js";
20
21
  import { matchesFocusVisible } from "../../floating-ui-react/utils/element.js";
21
22
  import { useLabelableId } from "../../internals/labelable-provider/useLabelableId.js";
@@ -27,7 +28,7 @@ import { sliderStateAttributesMapping } from "../root/stateAttributesMapping.js"
27
28
  import { SliderThumbDataAttributes } from "./SliderThumbDataAttributes.js";
28
29
  import { script as prehydrationScript } from "./prehydrationScript.min.js";
29
30
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
30
- const ALL_KEYS = new Set([ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, HOME, END, PAGE_UP, PAGE_DOWN]);
31
+ const ALL_KEYS = new Set([...COMPOSITE_KEYS, PAGE_UP, PAGE_DOWN]);
31
32
  function getDefaultAriaValueText(values, index, format, locale) {
32
33
  if (index < 0) {
33
34
  return undefined;
@@ -170,7 +171,7 @@ export const SliderThumb = /*#__PURE__*/React.forwardRef(function SliderThumb(co
170
171
  }
171
172
  }, [getInsetPosition, inset, thumbValuePercent]);
172
173
  useIsoLayoutEffect(() => {
173
- if (!inset || typeof ResizeObserver !== 'function') {
174
+ if (!inset) {
174
175
  return undefined;
175
176
  }
176
177
  const control = controlRef.current;
@@ -178,39 +179,32 @@ export const SliderThumb = /*#__PURE__*/React.forwardRef(function SliderThumb(co
178
179
  if (!control || !thumb) {
179
180
  return undefined;
180
181
  }
181
- const resizeObserver = new ResizeObserver(getInsetPosition);
182
+ const ResizeObserverCtor = ownerWindow(control).ResizeObserver;
183
+ if (typeof ResizeObserverCtor !== 'function') {
184
+ return undefined;
185
+ }
186
+ const resizeObserver = new ResizeObserverCtor(getInsetPosition);
182
187
  resizeObserver.observe(control);
183
188
  resizeObserver.observe(thumb);
184
189
  return () => {
185
190
  resizeObserver.disconnect();
186
191
  };
187
192
  }, [controlRef, getInsetPosition, inset]);
188
- const getThumbStyle = React.useCallback(() => {
189
- const startEdge = vertical ? 'bottom' : 'insetInlineStart';
190
- const crossOffsetProperty = vertical ? 'left' : 'top';
191
- let zIndex;
192
- if (range) {
193
- if (activeIndex === index) {
194
- zIndex = 2;
195
- } else if (safeLastUsedThumbIndex === index) {
196
- zIndex = 1;
197
- }
198
- } else if (activeIndex === index) {
193
+ const startEdge = vertical ? 'bottom' : 'insetInlineStart';
194
+ const crossOffsetProperty = vertical ? 'left' : 'top';
195
+ let zIndex;
196
+ if (range) {
197
+ if (activeIndex === index) {
198
+ zIndex = 2;
199
+ } else if (safeLastUsedThumbIndex === index) {
199
200
  zIndex = 1;
200
201
  }
201
- if (!inset) {
202
- if (!Number.isFinite(thumbValuePercent)) {
203
- return visuallyHidden;
204
- }
205
- return {
206
- position: 'absolute',
207
- [startEdge]: `${thumbValuePercent}%`,
208
- [crossOffsetProperty]: '50%',
209
- translate: `${(vertical || !rtl ? -1 : 1) * 50}% ${(vertical ? 1 : -1) * 50}%`,
210
- zIndex
211
- };
212
- }
213
- return {
202
+ } else if (activeIndex === index) {
203
+ zIndex = 1;
204
+ }
205
+ let thumbStyle;
206
+ if (inset) {
207
+ thumbStyle = {
214
208
  ['--position']: `${positionPercent ?? 0}%`,
215
209
  visibility: renderBeforeHydration && isHydrating || positionPercent === undefined ? 'hidden' : undefined,
216
210
  position: 'absolute',
@@ -219,7 +213,15 @@ export const SliderThumb = /*#__PURE__*/React.forwardRef(function SliderThumb(co
219
213
  translate: `${(vertical || !rtl ? -1 : 1) * 50}% ${(vertical ? 1 : -1) * 50}%`,
220
214
  zIndex
221
215
  };
222
- }, [activeIndex, index, inset, isHydrating, positionPercent, range, renderBeforeHydration, rtl, safeLastUsedThumbIndex, thumbValuePercent, vertical]);
216
+ } else {
217
+ thumbStyle = !Number.isFinite(thumbValuePercent) ? visuallyHidden : {
218
+ position: 'absolute',
219
+ [startEdge]: `${thumbValuePercent}%`,
220
+ [crossOffsetProperty]: '50%',
221
+ translate: `${(vertical || !rtl ? -1 : 1) * 50}% ${(vertical ? 1 : -1) * 50}%`,
222
+ zIndex
223
+ };
224
+ }
223
225
  let cssWritingMode;
224
226
  if (orientation === 'vertical') {
225
227
  cssWritingMode = rtl ? 'vertical-rl' : 'vertical-lr';
@@ -375,7 +377,7 @@ export const SliderThumb = /*#__PURE__*/React.forwardRef(function SliderThumb(co
375
377
  pressedInputRef.current = inputRef.current;
376
378
  }
377
379
  },
378
- style: getThumbStyle(),
380
+ style: thumbStyle,
379
381
  suppressHydrationWarning: renderBeforeHydration || undefined
380
382
  }, elementProps],
381
383
  stateAttributesMapping: sliderStateAttributesMapping
@@ -27,15 +27,13 @@ export const SliderValue = /*#__PURE__*/React.forwardRef(function SliderValue(co
27
27
  formatOptionsRef,
28
28
  locale
29
29
  } = useSliderRootContext();
30
- const outputFor = React.useMemo(() => {
31
- let htmlFor = '';
32
- for (const thumbMetadata of thumbMap.values()) {
33
- if (thumbMetadata?.inputId) {
34
- htmlFor += `${thumbMetadata.inputId} `;
35
- }
30
+ let htmlFor = '';
31
+ for (const thumbMetadata of thumbMap.values()) {
32
+ if (thumbMetadata?.inputId) {
33
+ htmlFor += `${thumbMetadata.inputId} `;
36
34
  }
37
- return htmlFor.trim() === '' ? undefined : htmlFor.trim();
38
- }, [thumbMap]);
35
+ }
36
+ const outputFor = htmlFor.trim() === '' ? undefined : htmlFor.trim();
39
37
  const formattedValues = React.useMemo(() => {
40
38
  const arr = [];
41
39
  for (let i = 0; i < values.length; i += 1) {
@@ -43,13 +41,7 @@ export const SliderValue = /*#__PURE__*/React.forwardRef(function SliderValue(co
43
41
  }
44
42
  return arr;
45
43
  }, [formatOptionsRef, locale, values]);
46
- const defaultDisplayValue = React.useMemo(() => {
47
- const arr = [];
48
- for (let i = 0; i < values.length; i += 1) {
49
- arr.push(formattedValues[i] || values[i]);
50
- }
51
- return arr.join(' – ');
52
- }, [values, formattedValues]);
44
+ const defaultDisplayValue = values.map((v, i) => formattedValues[i] || v).join(' – ');
53
45
  const element = useRenderElement('output', componentProps, {
54
46
  state,
55
47
  ref: forwardedRef,
@@ -2,11 +2,11 @@
2
2
 
3
3
  import * as React from 'react';
4
4
  import { useControlled } from '@base-ui/utils/useControlled';
5
- import { useStableCallback } from '@base-ui/utils/useStableCallback';
6
5
  import { useMergedRefs } from '@base-ui/utils/useMergedRefs';
7
6
  import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
8
7
  import { visuallyHidden, visuallyHiddenInput } from '@base-ui/utils/visuallyHidden';
9
8
  import { EMPTY_OBJECT } from '@base-ui/utils/empty';
9
+ import { ownerWindow } from '@base-ui/utils/owner';
10
10
  import { useRenderElement } from "../../internals/useRenderElement.js";
11
11
  import { mergeProps } from "../../merge-props/index.js";
12
12
  import { useBaseUiId } from "../../internals/useBaseUiId.js";
@@ -41,7 +41,7 @@ export const SwitchRoot = /*#__PURE__*/React.forwardRef(function SwitchRoot(comp
41
41
  inputRef: externalInputRef,
42
42
  name: nameProp,
43
43
  nativeButton = false,
44
- onCheckedChange: onCheckedChangeProp,
44
+ onCheckedChange,
45
45
  readOnly = false,
46
46
  required = false,
47
47
  disabled: disabledProp = false,
@@ -72,7 +72,6 @@ export const SwitchRoot = /*#__PURE__*/React.forwardRef(function SwitchRoot(comp
72
72
  } = useLabelableContext();
73
73
  const disabled = fieldDisabled || disabledProp;
74
74
  const name = fieldName ?? nameProp;
75
- const onCheckedChange = useStableCallback(onCheckedChangeProp);
76
75
  const inputRef = React.useRef(null);
77
76
  const handleInputRef = useMergedRefs(inputRef, externalInputRef, validation.inputRef);
78
77
  const switchRef = React.useRef(null);
@@ -89,10 +88,7 @@ export const SwitchRoot = /*#__PURE__*/React.forwardRef(function SwitchRoot(comp
89
88
  name: 'Switch',
90
89
  state: 'checked'
91
90
  });
92
- useRegisterFieldControl(switchRef, {
93
- id,
94
- value: checked
95
- });
91
+ useRegisterFieldControl(switchRef, id, checked);
96
92
  useIsoLayoutEffect(() => {
97
93
  if (inputRef.current) {
98
94
  setFilled(inputRef.current.checked);
@@ -144,7 +140,11 @@ export const SwitchRoot = /*#__PURE__*/React.forwardRef(function SwitchRoot(comp
144
140
  return;
145
141
  }
146
142
  event.preventDefault();
147
- inputRef.current?.dispatchEvent(new PointerEvent('click', {
143
+ const input = inputRef.current;
144
+ if (!input) {
145
+ return;
146
+ }
147
+ input.dispatchEvent(new (ownerWindow(input).PointerEvent)('click', {
148
148
  bubbles: true,
149
149
  shiftKey: event.shiftKey,
150
150
  ctrlKey: event.ctrlKey,
@@ -153,7 +153,7 @@ export const SwitchRoot = /*#__PURE__*/React.forwardRef(function SwitchRoot(comp
153
153
  }));
154
154
  }
155
155
  };
156
- const inputProps = React.useMemo(() => mergeProps({
156
+ const inputProps = mergeProps({
157
157
  checked,
158
158
  disabled,
159
159
  form,
@@ -190,7 +190,7 @@ export const SwitchRoot = /*#__PURE__*/React.forwardRef(function SwitchRoot(comp
190
190
  // To avoid this, we only set the value if it's defined
191
191
  value !== undefined ? {
192
192
  value
193
- } : EMPTY_OBJECT), [checked, disabled, form, handleInputRef, hiddenInputId, name, onCheckedChange, readOnly, required, setCheckedState, validation, value]);
193
+ } : EMPTY_OBJECT);
194
194
  const state = React.useMemo(() => ({
195
195
  ...fieldState,
196
196
  checked,
@@ -3,7 +3,6 @@
3
3
  import * as React from 'react';
4
4
  import { useSwitchRootContext } from "../root/SwitchRootContext.js";
5
5
  import { useRenderElement } from "../../internals/useRenderElement.js";
6
- import { useFieldRootContext } from "../../internals/field-root-context/FieldRootContext.js";
7
6
  import { stateAttributesMapping } from "../stateAttributesMapping.js";
8
7
 
9
8
  /**
@@ -19,16 +18,9 @@ export const SwitchThumb = /*#__PURE__*/React.forwardRef(function SwitchThumb(co
19
18
  style,
20
19
  ...elementProps
21
20
  } = componentProps;
22
- const {
23
- state: fieldState
24
- } = useFieldRootContext();
25
21
  const state = useSwitchRootContext();
26
- const extendedState = {
27
- ...fieldState,
28
- ...state
29
- };
30
22
  return useRenderElement('span', componentProps, {
31
- state: extendedState,
23
+ state,
32
24
  ref: forwardedRef,
33
25
  stateAttributesMapping,
34
26
  props: elementProps
@@ -10,7 +10,7 @@ import { tabsStateAttributesMapping } from "../root/stateAttributesMapping.js";
10
10
  import { useTabsListContext } from "../list/TabsListContext.js";
11
11
  import { script as prehydrationScript } from "./prehydrationScript.min.js";
12
12
  import { TabsIndicatorCssVars } from "./TabsIndicatorCssVars.js";
13
- import { useCSPContext } from "../../csp-provider/CSPContext.js";
13
+ import { useCSPContext } from "../../internals/csp-context/CSPContext.js";
14
14
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
15
  const stateAttributesMapping = {
16
16
  ...tabsStateAttributesMapping,
@@ -24,7 +24,7 @@ const stateAttributesMapping = {
24
24
  *
25
25
  * Documentation: [Base UI Tabs](https://base-ui.com/react/components/tabs)
26
26
  */
27
- export const TabsIndicator = /*#__PURE__*/React.forwardRef(function TabIndicator(componentProps, forwardedRef) {
27
+ export const TabsIndicator = /*#__PURE__*/React.forwardRef(function TabsIndicator(componentProps, forwardedRef) {
28
28
  const {
29
29
  className,
30
30
  render,
@@ -89,29 +89,24 @@ export const TabsIndicator = /*#__PURE__*/React.forwardRef(function TabIndicator
89
89
  bottom = tabsListElement.scrollHeight - top - height;
90
90
  }
91
91
  }
92
- const activeTabPosition = React.useMemo(() => isTabSelected ? {
92
+ const activeTabPosition = isTabSelected ? {
93
93
  left,
94
94
  right,
95
95
  top,
96
96
  bottom
97
- } : null, [left, right, top, bottom, isTabSelected]);
98
- const activeTabSize = React.useMemo(() => isTabSelected ? {
97
+ } : null;
98
+ const activeTabSize = isTabSelected ? {
99
99
  width,
100
100
  height
101
- } : null, [width, height, isTabSelected]);
102
- const style = React.useMemo(() => {
103
- if (!isTabSelected) {
104
- return undefined;
105
- }
106
- return {
107
- [TabsIndicatorCssVars.activeTabLeft]: `${left}px`,
108
- [TabsIndicatorCssVars.activeTabRight]: `${right}px`,
109
- [TabsIndicatorCssVars.activeTabTop]: `${top}px`,
110
- [TabsIndicatorCssVars.activeTabBottom]: `${bottom}px`,
111
- [TabsIndicatorCssVars.activeTabWidth]: `${width}px`,
112
- [TabsIndicatorCssVars.activeTabHeight]: `${height}px`
113
- };
114
- }, [left, right, top, bottom, width, height, isTabSelected]);
101
+ } : null;
102
+ const style = isTabSelected ? {
103
+ [TabsIndicatorCssVars.activeTabLeft]: `${left}px`,
104
+ [TabsIndicatorCssVars.activeTabRight]: `${right}px`,
105
+ [TabsIndicatorCssVars.activeTabTop]: `${top}px`,
106
+ [TabsIndicatorCssVars.activeTabBottom]: `${bottom}px`,
107
+ [TabsIndicatorCssVars.activeTabWidth]: `${width}px`,
108
+ [TabsIndicatorCssVars.activeTabHeight]: `${height}px`
109
+ } : undefined;
115
110
  const displayIndicator = isTabSelected && width > 0 && height > 0;
116
111
  const state = {
117
112
  orientation,
@@ -36,20 +36,14 @@ export const TabsList = /*#__PURE__*/React.forwardRef(function TabsList(componen
36
36
  const indicatorUpdateListenersRef = React.useRef(new Set());
37
37
  const tabResizeObserverElementsRef = React.useRef(new Set());
38
38
  const resizeObserverRef = React.useRef(null);
39
- const notifyIndicatorUpdateListeners = useStableCallback(() => {
40
- indicatorUpdateListenersRef.current.forEach(listener => {
41
- listener();
42
- });
43
- });
44
39
  React.useEffect(() => {
45
40
  if (typeof ResizeObserver === 'undefined') {
46
41
  return undefined;
47
42
  }
48
43
  const resizeObserver = new ResizeObserver(() => {
49
- if (!indicatorUpdateListenersRef.current.size) {
50
- return;
51
- }
52
- notifyIndicatorUpdateListeners();
44
+ indicatorUpdateListenersRef.current.forEach(listener => {
45
+ listener();
46
+ });
53
47
  });
54
48
  resizeObserverRef.current = resizeObserver;
55
49
  if (tabsListElement) {
@@ -62,7 +56,7 @@ export const TabsList = /*#__PURE__*/React.forwardRef(function TabsList(componen
62
56
  resizeObserver.disconnect();
63
57
  resizeObserverRef.current = null;
64
58
  };
65
- }, [tabsListElement, notifyIndicatorUpdateListeners]);
59
+ }, [tabsListElement]);
66
60
  const registerIndicatorUpdateListener = useStableCallback(listener => {
67
61
  indicatorUpdateListenersRef.current.add(listener);
68
62
  return () => {
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import type { TabsRoot } from "../root/TabsRoot.js";
3
+ import type { TabsTab } from "../tab/TabsTab.js";
3
4
  export interface TabsListContext {
4
5
  activateOnFocus: boolean;
5
6
  highlightedTabIndex: number;
6
7
  registerIndicatorUpdateListener: (listener: () => void) => () => void;
7
8
  registerTabResizeObserverElement: (element: HTMLElement) => () => void;
8
- onTabActivation: (newValue: any, eventDetails: TabsRoot.ChangeEventDetails) => void;
9
+ onTabActivation: (newValue: TabsTab.Value, eventDetails: TabsRoot.ChangeEventDetails) => void;
9
10
  setHighlightedTabIndex: (index: number) => void;
10
11
  tabsListElement: HTMLElement | null;
11
12
  }
@@ -23,7 +23,7 @@ const stateAttributesMapping = {
23
23
  *
24
24
  * Documentation: [Base UI Tabs](https://base-ui.com/react/components/tabs)
25
25
  */
26
- export const TabsPanel = /*#__PURE__*/React.forwardRef(function TabPanel(componentProps, forwardedRef) {
26
+ export const TabsPanel = /*#__PURE__*/React.forwardRef(function TabsPanel(componentProps, forwardedRef) {
27
27
  const {
28
28
  className,
29
29
  value,
@@ -40,10 +40,25 @@ export interface TabsRootProps extends BaseUIComponentProps<'div', TabsRootState
40
40
  orientation?: TabsRoot.Orientation | undefined;
41
41
  /**
42
42
  * Callback invoked when new value is being set.
43
+ *
44
+ * The event `reason` is `'none'` for user-initiated changes, such as a click
45
+ * or keyboard navigation; `'initial'` for the first automatic selection or
46
+ * fallback in uncontrolled roots when `defaultValue` is omitted or
47
+ * `undefined`, including when the implicit initial value is disabled or
48
+ * missing; `'disabled'` for automatic fallback when the selected tab becomes
49
+ * disabled in uncontrolled roots; or `'missing'` for automatic fallback when
50
+ * the selected tab is removed, or when an explicit `defaultValue` never
51
+ * matches a mounted tab in uncontrolled roots.
52
+ *
53
+ * For automatic changes, the selected value can be `null` when no enabled Tab
54
+ * is available as a fallback.
55
+ *
56
+ * Automatic changes cannot be canceled; calling `eventDetails.cancel()` for
57
+ * `'initial'`, `'disabled'`, or `'missing'` has no effect.
43
58
  */
44
59
  onValueChange?: ((value: TabsTab.Value, eventDetails: TabsRoot.ChangeEventDetails) => void) | undefined;
45
60
  }
46
- export type TabsRootChangeEventReason = typeof REASONS.none;
61
+ export type TabsRootChangeEventReason = typeof REASONS.none | typeof REASONS.disabled | typeof REASONS.missing | typeof REASONS.initial;
47
62
  export type TabsRootChangeEventDetails = BaseUIChangeEventDetails<TabsRoot.ChangeEventReason, {
48
63
  activationDirection: TabsTab.ActivationDirection;
49
64
  }>;
@@ -8,13 +8,16 @@ import { useRenderElement } from "../../internals/useRenderElement.js";
8
8
  import { CompositeList } from "../../internals/composite/list/CompositeList.js";
9
9
  import { TabsRootContext } from "./TabsRootContext.js";
10
10
  import { tabsStateAttributesMapping } from "./stateAttributesMapping.js";
11
- import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { createChangeEventDetails } from "../../internals/createBaseUIEventDetails.js";
12
+ import { REASONS } from "../../internals/reasons.js";
13
+
12
14
  /**
13
15
  * Groups the tabs and the corresponding panels.
14
16
  * Renders a `<div>` element.
15
17
  *
16
18
  * Documentation: [Base UI Tabs](https://base-ui.com/react/components/tabs)
17
19
  */
20
+ import { jsx as _jsx } from "react/jsx-runtime";
18
21
  export const TabsRoot = /*#__PURE__*/React.forwardRef(function TabsRoot(componentProps, forwardedRef) {
19
22
  const {
20
23
  className,
@@ -27,9 +30,9 @@ export const TabsRoot = /*#__PURE__*/React.forwardRef(function TabsRoot(componen
27
30
  ...elementProps
28
31
  } = componentProps;
29
32
 
30
- // Track whether the user explicitly provided a `defaultValue` prop.
33
+ // Track whether the user explicitly provided a defined `defaultValue` prop.
31
34
  // Used to determine if we should honor a disabled tab selection.
32
- const hasExplicitDefaultValueProp = Object.hasOwn(componentProps, 'defaultValue');
35
+ const hasExplicitDefaultValueProp = componentProps.defaultValue !== undefined;
33
36
  const tabPanelRefs = React.useRef([]);
34
37
  const [mountedTabPanels, setMountedTabPanels] = React.useState(() => new Map());
35
38
  const [value, setValue] = useControlled({
@@ -97,6 +100,11 @@ export const TabsRoot = /*#__PURE__*/React.forwardRef(function TabsRoot(componen
97
100
  }
98
101
  setValue(newValue);
99
102
  });
103
+ const notifyAutomaticValueChange = useStableCallback((nextValue, reason) => {
104
+ onValueChangeProp?.(nextValue, createChangeEventDetails(reason, undefined, undefined, {
105
+ activationDirection: 'none'
106
+ }));
107
+ });
100
108
  const registerMountedTabPanel = useStableCallback((panelValue, panelId) => {
101
109
  setMountedTabPanels(prev => {
102
110
  if (prev.get(panelValue) === panelId) {
@@ -164,38 +172,78 @@ export const TabsRoot = /*#__PURE__*/React.forwardRef(function TabsRoot(componen
164
172
  return undefined;
165
173
  }, [tabMap]);
166
174
 
167
- // Automatically switch to the first enabled tab when:
168
- // - The current selection is disabled (and wasn't explicitly set via defaultValue)
169
- // - The current selection is missing (tab was removed from DOM)
170
- // Falls back to null if all tabs are disabled.
175
+ // Implicit uncontrolled selections are still automatic changes, so notify
176
+ // once when the tabs first register. Explicit defaults are treated as user-owned.
177
+ const shouldNotifyInitialValueChangeRef = React.useRef(!hasExplicitDefaultValueProp);
178
+ // An explicit defaultValue can intentionally point at a disabled tab on mount.
179
+ // Once that selection becomes valid, later disabled states should fall back.
180
+ const shouldHonorDisabledDefaultValueRef = React.useRef(hasExplicitDefaultValueProp);
181
+ const didRegisterTabsRef = React.useRef(false);
182
+
183
+ // Uncontrolled roots own automatic fallback. Controlled roots keep the exact
184
+ // value supplied by the parent, even when that tab is disabled or missing.
171
185
  useIsoLayoutEffect(() => {
172
- if (isControlled || tabMap.size === 0) {
186
+ if (isControlled) {
187
+ return;
188
+ }
189
+ function commitAutomaticValueChange(fallbackValue, fallbackReason) {
190
+ setValue(fallbackValue);
191
+ // Automatic fallbacks are not directional transitions; reset the direction
192
+ // alongside the value so the batched commit keeps both in sync.
193
+ setActivationDirectionState(prev => {
194
+ if (prev.previousValue === fallbackValue && prev.tabActivationDirection === 'none') {
195
+ return prev;
196
+ }
197
+ return {
198
+ previousValue: fallbackValue,
199
+ tabActivationDirection: 'none'
200
+ };
201
+ });
202
+ notifyAutomaticValueChange(fallbackValue, fallbackReason);
203
+ // Mark the initial notification as delivered only after the consumer
204
+ // callback returns. The fallback value is queued first so automatic
205
+ // consistency updates are not cancelable through a throwing handler.
206
+ shouldNotifyInitialValueChangeRef.current = false;
207
+ }
208
+ if (tabMap.size === 0) {
209
+ if (!didRegisterTabsRef.current || value === null) {
210
+ return;
211
+ }
212
+ commitAutomaticValueChange(null, REASONS.missing);
173
213
  return;
174
214
  }
215
+ didRegisterTabsRef.current = true;
175
216
  const selectionIsDisabled = selectedTabMetadata?.disabled;
176
217
  const selectionIsMissing = selectedTabMetadata == null && value !== null;
177
- const shouldHonorExplicitDefaultSelection = hasExplicitDefaultValueProp && selectionIsDisabled && value === defaultValueProp;
178
- if (shouldHonorExplicitDefaultSelection) {
179
- return;
218
+ if (!selectionIsDisabled && value === defaultValueProp) {
219
+ shouldHonorDisabledDefaultValueRef.current = false;
180
220
  }
181
- if (!selectionIsDisabled && !selectionIsMissing) {
221
+ if (shouldHonorDisabledDefaultValueRef.current && selectionIsDisabled && value === defaultValueProp) {
182
222
  return;
183
223
  }
184
- const fallbackValue = firstEnabledTabValue ?? null;
185
- if (value === fallbackValue) {
224
+ const shouldNotifyInitialValueChange = shouldNotifyInitialValueChangeRef.current;
225
+ if (selectionIsDisabled || selectionIsMissing) {
226
+ const fallbackValue = firstEnabledTabValue ?? null;
227
+ if (value === fallbackValue) {
228
+ // Already at the fallback value; no commit or notification needed,
229
+ // but record that the implicit-initial transition has resolved.
230
+ shouldNotifyInitialValueChangeRef.current = false;
231
+ return;
232
+ }
233
+ let fallbackReason = REASONS.missing;
234
+ if (shouldNotifyInitialValueChange) {
235
+ fallbackReason = REASONS.initial;
236
+ } else if (selectionIsDisabled) {
237
+ fallbackReason = REASONS.disabled;
238
+ }
239
+ commitAutomaticValueChange(fallbackValue, fallbackReason);
186
240
  return;
187
241
  }
188
- setValue(fallbackValue);
189
- setActivationDirectionState(prev => {
190
- if (prev.tabActivationDirection === 'none') {
191
- return prev;
192
- }
193
- return {
194
- ...prev,
195
- tabActivationDirection: 'none'
196
- };
197
- });
198
- }, [defaultValueProp, firstEnabledTabValue, hasExplicitDefaultValueProp, isControlled, selectedTabMetadata, setValue, tabMap, value]);
242
+ if (shouldNotifyInitialValueChange && selectedTabMetadata != null) {
243
+ notifyAutomaticValueChange(value, REASONS.initial);
244
+ shouldNotifyInitialValueChangeRef.current = false;
245
+ }
246
+ }, [defaultValueProp, firstEnabledTabValue, isControlled, notifyAutomaticValueChange, selectedTabMetadata, setValue, tabMap, value]);
199
247
  const state = {
200
248
  orientation,
201
249
  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;
@@ -50,7 +50,7 @@ export const ToastProvider = function ToastProvider(props) {
50
50
  }
51
51
  });
52
52
  return unsubscribe;
53
- }, [store, timeout, toastManager]);
53
+ }, [store, toastManager]);
54
54
  store.useSyncedValues({
55
55
  timeout,
56
56
  limit
@@ -20,7 +20,7 @@ export interface ToastRootState {
20
20
  */
21
21
  expanded: boolean;
22
22
  /**
23
- * Whether the toast was removed due to exceeding the limit.
23
+ * Whether the toast was limited because the toast limit was exceeded.
24
24
  */
25
25
  limited: boolean;
26
26
  /**