@funstack/ui 0.1.0-alpha.10 → 0.1.0-alpha.12

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 (404) hide show
  1. package/dist/accordion/accordion-context.mjs.map +1 -1
  2. package/dist/accordion/accordion-item.d.mts +3 -4
  3. package/dist/accordion/accordion-item.d.mts.map +1 -1
  4. package/dist/accordion/accordion-item.mjs +10 -4
  5. package/dist/accordion/accordion-item.mjs.map +1 -1
  6. package/dist/accordion/accordion-panel.d.mts +3 -4
  7. package/dist/accordion/accordion-panel.d.mts.map +1 -1
  8. package/dist/accordion/accordion-panel.mjs +2 -1
  9. package/dist/accordion/accordion-panel.mjs.map +1 -1
  10. package/dist/accordion/accordion-root.d.mts +3 -3
  11. package/dist/accordion/accordion-root.d.mts.map +1 -1
  12. package/dist/accordion/accordion-root.mjs +8 -19
  13. package/dist/accordion/accordion-root.mjs.map +1 -1
  14. package/dist/accordion/accordion-trigger.d.mts +3 -4
  15. package/dist/accordion/accordion-trigger.d.mts.map +1 -1
  16. package/dist/accordion/accordion-trigger.mjs +5 -3
  17. package/dist/accordion/accordion-trigger.mjs.map +1 -1
  18. package/dist/button/button.d.mts +4 -2
  19. package/dist/button/button.d.mts.map +1 -1
  20. package/dist/button/button.mjs +3 -2
  21. package/dist/button/button.mjs.map +1 -1
  22. package/dist/checkbox/checkbox.d.mts +4 -5
  23. package/dist/checkbox/checkbox.d.mts.map +1 -1
  24. package/dist/checkbox/checkbox.mjs +16 -59
  25. package/dist/checkbox/checkbox.mjs.map +1 -1
  26. package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
  27. package/dist/checkbox-group/checkbox-group-item.d.mts +3 -4
  28. package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
  29. package/dist/checkbox-group/checkbox-group-item.mjs +21 -27
  30. package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
  31. package/dist/checkbox-group/checkbox-group-label.mjs +1 -6
  32. package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
  33. package/dist/checkbox-group/checkbox-group-parent.d.mts +3 -4
  34. package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
  35. package/dist/checkbox-group/checkbox-group-parent.mjs +12 -10
  36. package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
  37. package/dist/checkbox-group/checkbox-group-root.d.mts +1 -1
  38. package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
  39. package/dist/checkbox-group/checkbox-group-root.mjs +74 -101
  40. package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
  41. package/dist/combobox/combobox-clear.d.mts.map +1 -1
  42. package/dist/combobox/combobox-clear.mjs +5 -6
  43. package/dist/combobox/combobox-clear.mjs.map +1 -1
  44. package/dist/combobox/combobox-context.mjs.map +1 -1
  45. package/dist/combobox/combobox-group.d.mts.map +1 -1
  46. package/dist/combobox/combobox-group.mjs +2 -1
  47. package/dist/combobox/combobox-group.mjs.map +1 -1
  48. package/dist/combobox/combobox-input.d.mts.map +1 -1
  49. package/dist/combobox/combobox-input.mjs +14 -7
  50. package/dist/combobox/combobox-input.mjs.map +1 -1
  51. package/dist/combobox/combobox-list.d.mts.map +1 -1
  52. package/dist/combobox/combobox-list.mjs +6 -10
  53. package/dist/combobox/combobox-list.mjs.map +1 -1
  54. package/dist/combobox/combobox-option.d.mts.map +1 -1
  55. package/dist/combobox/combobox-option.mjs +2 -1
  56. package/dist/combobox/combobox-option.mjs.map +1 -1
  57. package/dist/combobox/combobox-popup.d.mts.map +1 -1
  58. package/dist/combobox/combobox-popup.mjs +9 -25
  59. package/dist/combobox/combobox-popup.mjs.map +1 -1
  60. package/dist/combobox/combobox-root.d.mts +11 -10
  61. package/dist/combobox/combobox-root.d.mts.map +1 -1
  62. package/dist/combobox/combobox-root.mjs +37 -109
  63. package/dist/combobox/combobox-root.mjs.map +1 -1
  64. package/dist/combobox/combobox-trigger.d.mts.map +1 -1
  65. package/dist/combobox/combobox-trigger.mjs +6 -25
  66. package/dist/combobox/combobox-trigger.mjs.map +1 -1
  67. package/dist/combobox/index.d.mts +2 -2
  68. package/dist/combobox/index.mjs +3 -3
  69. package/dist/combobox/index.mjs.map +1 -1
  70. package/dist/combobox/use-combobox-form.mjs +56 -0
  71. package/dist/combobox/use-combobox-form.mjs.map +1 -0
  72. package/dist/combobox/use-option-registry.mjs +62 -0
  73. package/dist/combobox/use-option-registry.mjs.map +1 -0
  74. package/dist/dialog/dialog-close.d.mts.map +1 -1
  75. package/dist/dialog/dialog-close.mjs +29 -62
  76. package/dist/dialog/dialog-close.mjs.map +1 -1
  77. package/dist/dialog/dialog-context.mjs.map +1 -1
  78. package/dist/dialog/dialog-form.d.mts.map +1 -1
  79. package/dist/dialog/dialog-form.mjs +5 -4
  80. package/dist/dialog/dialog-form.mjs.map +1 -1
  81. package/dist/dialog/dialog-popup.d.mts +3 -4
  82. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  83. package/dist/dialog/dialog-popup.mjs +37 -98
  84. package/dist/dialog/dialog-popup.mjs.map +1 -1
  85. package/dist/dialog/dialog-root.d.mts.map +1 -1
  86. package/dist/dialog/dialog-root.mjs +30 -118
  87. package/dist/dialog/dialog-root.mjs.map +1 -1
  88. package/dist/dialog/dialog-trigger.d.mts.map +1 -1
  89. package/dist/dialog/dialog-trigger.mjs +13 -16
  90. package/dist/dialog/dialog-trigger.mjs.map +1 -1
  91. package/dist/field/field-control.mjs +6 -13
  92. package/dist/field/field-control.mjs.map +1 -1
  93. package/dist/field/field-description.d.mts.map +1 -1
  94. package/dist/field/field-description.mjs +1 -2
  95. package/dist/field/field-description.mjs.map +1 -1
  96. package/dist/field/field-error.d.mts.map +1 -1
  97. package/dist/field/field-error.mjs +1 -2
  98. package/dist/field/field-error.mjs.map +1 -1
  99. package/dist/field/field-label.d.mts.map +1 -1
  100. package/dist/field/field-label.mjs +3 -11
  101. package/dist/field/field-label.mjs.map +1 -1
  102. package/dist/field/field-root.mjs +21 -41
  103. package/dist/field/field-root.mjs.map +1 -1
  104. package/dist/field/index.mjs +1 -1
  105. package/dist/field/use-server-error-visibility.mjs +44 -0
  106. package/dist/field/use-server-error-visibility.mjs.map +1 -0
  107. package/dist/form/form-root.d.mts.map +1 -1
  108. package/dist/form/form-root.mjs +6 -7
  109. package/dist/form/form-root.mjs.map +1 -1
  110. package/dist/form/form-submit.d.mts +1 -1
  111. package/dist/form/form-submit.mjs +4 -10
  112. package/dist/form/form-submit.mjs.map +1 -1
  113. package/dist/index.d.mts +4 -4
  114. package/dist/internal/anchor-position.mjs +1 -59
  115. package/dist/internal/anchor-position.mjs.map +1 -1
  116. package/dist/internal/announce.mjs.map +1 -1
  117. package/dist/internal/arrow-keys.mjs +21 -0
  118. package/dist/internal/arrow-keys.mjs.map +1 -0
  119. package/dist/internal/decimal.mjs +7 -1
  120. package/dist/internal/decimal.mjs.map +1 -1
  121. package/dist/internal/dom-order.mjs +17 -0
  122. package/dist/internal/dom-order.mjs.map +1 -0
  123. package/dist/internal/field-context.d.mts.map +1 -1
  124. package/dist/internal/field-context.mjs +11 -1
  125. package/dist/internal/field-context.mjs.map +1 -1
  126. package/dist/internal/focus-first-invalid.mjs +1 -1
  127. package/dist/internal/focus-first-invalid.mjs.map +1 -1
  128. package/dist/internal/group-member.mjs +37 -0
  129. package/dist/internal/group-member.mjs.map +1 -0
  130. package/dist/internal/overlay-popup.mjs +103 -0
  131. package/dist/internal/overlay-popup.mjs.map +1 -0
  132. package/dist/internal/popover-open.mjs +18 -0
  133. package/dist/internal/popover-open.mjs.map +1 -0
  134. package/dist/internal/render-element.d.mts +2 -0
  135. package/dist/internal/render-element.mjs +20 -2
  136. package/dist/internal/render-element.mjs.map +1 -1
  137. package/dist/internal/shipped-styles.mjs +14 -0
  138. package/dist/internal/shipped-styles.mjs.map +1 -0
  139. package/dist/internal/sync-presence.mjs +5 -1
  140. package/dist/internal/sync-presence.mjs.map +1 -1
  141. package/dist/internal/toolbar-context.mjs.map +1 -1
  142. package/dist/internal/tooltip-warm.mjs +1 -1
  143. package/dist/internal/tooltip-warm.mjs.map +1 -1
  144. package/dist/internal/transition-boundary.mjs +1 -1
  145. package/dist/internal/transition-boundary.mjs.map +1 -1
  146. package/dist/internal/types.d.mts +8 -6
  147. package/dist/internal/types.d.mts.map +1 -1
  148. package/dist/internal/use-action-trigger.mjs +5 -23
  149. package/dist/internal/use-action-trigger.mjs.map +1 -1
  150. package/dist/internal/use-checkable-input.mjs +79 -0
  151. package/dist/internal/use-checkable-input.mjs.map +1 -0
  152. package/dist/internal/use-controllable-action.mjs +16 -24
  153. package/dist/internal/use-controllable-action.mjs.map +1 -1
  154. package/dist/internal/use-dev-warning.mjs +8 -4
  155. package/dist/internal/use-dev-warning.mjs.map +1 -1
  156. package/dist/internal/use-element-check.mjs +39 -0
  157. package/dist/internal/use-element-check.mjs.map +1 -0
  158. package/dist/internal/use-exit-animation.mjs +1 -1
  159. package/dist/internal/use-exit-animation.mjs.map +1 -1
  160. package/dist/internal/use-field-control.mjs +28 -12
  161. package/dist/internal/use-field-control.mjs.map +1 -1
  162. package/dist/internal/use-fieldset-group.mjs +46 -0
  163. package/dist/internal/use-fieldset-group.mjs.map +1 -0
  164. package/dist/internal/use-form-reset.mjs +1 -5
  165. package/dist/internal/use-form-reset.mjs.map +1 -1
  166. package/dist/internal/use-item-order.mjs +42 -0
  167. package/dist/internal/use-item-order.mjs.map +1 -0
  168. package/dist/internal/use-latest.mjs +4 -8
  169. package/dist/internal/use-latest.mjs.map +1 -1
  170. package/dist/internal/use-merged-refs.mjs +19 -0
  171. package/dist/internal/use-merged-refs.mjs.map +1 -0
  172. package/dist/internal/use-name-warning.mjs +84 -0
  173. package/dist/internal/use-name-warning.mjs.map +1 -0
  174. package/dist/internal/use-native-checked.mjs +4 -6
  175. package/dist/internal/use-native-checked.mjs.map +1 -1
  176. package/dist/internal/use-native-focusgroup.mjs +19 -0
  177. package/dist/internal/use-native-focusgroup.mjs.map +1 -0
  178. package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
  179. package/dist/internal/use-overlay-close.mjs +63 -0
  180. package/dist/internal/use-overlay-close.mjs.map +1 -0
  181. package/dist/internal/{use-popover-root.mjs → use-overlay-root.mjs} +28 -39
  182. package/dist/internal/use-overlay-root.mjs.map +1 -0
  183. package/dist/internal/use-popover-popup.mjs +32 -78
  184. package/dist/internal/use-popover-popup.mjs.map +1 -1
  185. package/dist/internal/use-popover-trigger.d.mts +15 -0
  186. package/dist/internal/use-popover-trigger.d.mts.map +1 -0
  187. package/dist/internal/use-popover-trigger.mjs +13 -17
  188. package/dist/internal/use-popover-trigger.mjs.map +1 -1
  189. package/dist/internal/use-register-count.mjs +24 -0
  190. package/dist/internal/use-register-count.mjs.map +1 -0
  191. package/dist/internal/use-render.d.mts +2 -0
  192. package/dist/internal/use-render.mjs +2 -2
  193. package/dist/internal/use-render.mjs.map +1 -1
  194. package/dist/internal/use-resolved-placement.mjs +38 -22
  195. package/dist/internal/use-resolved-placement.mjs.map +1 -1
  196. package/dist/internal/use-roving-focus.mjs +5 -18
  197. package/dist/internal/use-roving-focus.mjs.map +1 -1
  198. package/dist/internal/use-superseded-rejection.mjs +47 -0
  199. package/dist/internal/use-superseded-rejection.mjs.map +1 -0
  200. package/dist/internal/validity.mjs +1 -13
  201. package/dist/internal/validity.mjs.map +1 -1
  202. package/dist/internal/value-set.mjs +41 -0
  203. package/dist/internal/value-set.mjs.map +1 -0
  204. package/dist/menu/index.d.mts +1 -1
  205. package/dist/menu/menu-checkbox-item.mjs.map +1 -1
  206. package/dist/menu/menu-context-trigger.d.mts +2 -7
  207. package/dist/menu/menu-context-trigger.d.mts.map +1 -1
  208. package/dist/menu/menu-context-trigger.mjs +10 -187
  209. package/dist/menu/menu-context-trigger.mjs.map +1 -1
  210. package/dist/menu/menu-context.d.mts +1 -1
  211. package/dist/menu/menu-context.mjs +1 -1
  212. package/dist/menu/menu-context.mjs.map +1 -1
  213. package/dist/menu/menu-dom.mjs +1 -2
  214. package/dist/menu/menu-dom.mjs.map +1 -1
  215. package/dist/menu/menu-gestures.mjs +167 -0
  216. package/dist/menu/menu-gestures.mjs.map +1 -0
  217. package/dist/menu/menu-group.d.mts.map +1 -1
  218. package/dist/menu/menu-group.mjs +2 -1
  219. package/dist/menu/menu-group.mjs.map +1 -1
  220. package/dist/menu/menu-hover.mjs +0 -1
  221. package/dist/menu/menu-hover.mjs.map +1 -1
  222. package/dist/menu/menu-item.mjs.map +1 -1
  223. package/dist/menu/menu-outside.mjs +101 -0
  224. package/dist/menu/menu-outside.mjs.map +1 -0
  225. package/dist/menu/menu-point.mjs +85 -0
  226. package/dist/menu/menu-point.mjs.map +1 -0
  227. package/dist/menu/menu-popup.d.mts +6 -7
  228. package/dist/menu/menu-popup.d.mts.map +1 -1
  229. package/dist/menu/menu-popup.mjs +37 -248
  230. package/dist/menu/menu-popup.mjs.map +1 -1
  231. package/dist/menu/menu-radio-group.mjs.map +1 -1
  232. package/dist/menu/menu-root.d.mts +10 -0
  233. package/dist/menu/menu-root.d.mts.map +1 -1
  234. package/dist/menu/menu-root.mjs +10 -8
  235. package/dist/menu/menu-root.mjs.map +1 -1
  236. package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
  237. package/dist/menu/menu-submenu-trigger.mjs +6 -6
  238. package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
  239. package/dist/menu/menu-trigger.d.mts +4 -9
  240. package/dist/menu/menu-trigger.d.mts.map +1 -1
  241. package/dist/menu/menu-trigger.mjs +8 -6
  242. package/dist/menu/menu-trigger.mjs.map +1 -1
  243. package/dist/menu/use-menu-item.mjs +14 -16
  244. package/dist/menu/use-menu-item.mjs.map +1 -1
  245. package/dist/menu/use-menu-keyboard.mjs +88 -0
  246. package/dist/menu/use-menu-keyboard.mjs.map +1 -0
  247. package/dist/meter/meter-root.mjs +1 -1
  248. package/dist/number-field/index.d.mts +2 -1
  249. package/dist/number-field/index.d.mts.map +1 -1
  250. package/dist/number-field/index.mjs +2 -2
  251. package/dist/number-field/index.mjs.map +1 -1
  252. package/dist/number-field/number-field-arithmetic.mjs +30 -11
  253. package/dist/number-field/number-field-arithmetic.mjs.map +1 -1
  254. package/dist/number-field/number-field-context.d.mts +6 -1
  255. package/dist/number-field/number-field-context.d.mts.map +1 -0
  256. package/dist/number-field/number-field-context.mjs.map +1 -1
  257. package/dist/number-field/number-field-decrement.d.mts +1 -1
  258. package/dist/number-field/number-field-decrement.mjs +1 -1
  259. package/dist/number-field/number-field-decrement.mjs.map +1 -1
  260. package/dist/number-field/number-field-increment.d.mts +2 -22
  261. package/dist/number-field/number-field-increment.d.mts.map +1 -1
  262. package/dist/number-field/number-field-increment.mjs +2 -53
  263. package/dist/number-field/number-field-increment.mjs.map +1 -1
  264. package/dist/number-field/number-field-input.d.mts.map +1 -1
  265. package/dist/number-field/number-field-input.mjs +18 -22
  266. package/dist/number-field/number-field-input.mjs.map +1 -1
  267. package/dist/number-field/number-field-label.d.mts.map +1 -1
  268. package/dist/number-field/number-field-label.mjs +3 -9
  269. package/dist/number-field/number-field-label.mjs.map +1 -1
  270. package/dist/number-field/number-field-root.d.mts +2 -1
  271. package/dist/number-field/number-field-root.d.mts.map +1 -1
  272. package/dist/number-field/number-field-root.mjs +81 -91
  273. package/dist/number-field/number-field-root.mjs.map +1 -1
  274. package/dist/number-field/use-number-field-dev-warnings.mjs +28 -0
  275. package/dist/number-field/use-number-field-dev-warnings.mjs.map +1 -0
  276. package/dist/number-field/use-step-button.d.mts +24 -0
  277. package/dist/number-field/use-step-button.d.mts.map +1 -0
  278. package/dist/number-field/use-step-button.mjs +57 -3
  279. package/dist/number-field/use-step-button.mjs.map +1 -1
  280. package/dist/popover/popover-close.d.mts.map +1 -1
  281. package/dist/popover/popover-close.mjs +28 -67
  282. package/dist/popover/popover-close.mjs.map +1 -1
  283. package/dist/popover/popover-context.mjs.map +1 -1
  284. package/dist/popover/popover-popup.d.mts +9 -6
  285. package/dist/popover/popover-popup.d.mts.map +1 -1
  286. package/dist/popover/popover-popup.mjs +13 -36
  287. package/dist/popover/popover-popup.mjs.map +1 -1
  288. package/dist/popover/popover-root.mjs +4 -3
  289. package/dist/popover/popover-root.mjs.map +1 -1
  290. package/dist/popover/popover-trigger.d.mts +4 -8
  291. package/dist/popover/popover-trigger.d.mts.map +1 -1
  292. package/dist/popover/popover-trigger.mjs +2 -1
  293. package/dist/popover/popover-trigger.mjs.map +1 -1
  294. package/dist/progress/progress-root.mjs +1 -1
  295. package/dist/radio-group/radio-group-context.mjs.map +1 -1
  296. package/dist/radio-group/radio-group-item.d.mts +3 -4
  297. package/dist/radio-group/radio-group-item.d.mts.map +1 -1
  298. package/dist/radio-group/radio-group-item.mjs +20 -25
  299. package/dist/radio-group/radio-group-item.mjs.map +1 -1
  300. package/dist/radio-group/radio-group-label.mjs +1 -6
  301. package/dist/radio-group/radio-group-label.mjs.map +1 -1
  302. package/dist/radio-group/radio-group-root.d.mts +1 -1
  303. package/dist/radio-group/radio-group-root.d.mts.map +1 -1
  304. package/dist/radio-group/radio-group-root.mjs +21 -40
  305. package/dist/radio-group/radio-group-root.mjs.map +1 -1
  306. package/dist/select/select-dom.mjs +9 -18
  307. package/dist/select/select-dom.mjs.map +1 -1
  308. package/dist/select/select-option.mjs +1 -1
  309. package/dist/select/select-root.mjs +3 -2
  310. package/dist/select/select-root.mjs.map +1 -1
  311. package/dist/slider/slider-arithmetic.mjs +74 -13
  312. package/dist/slider/slider-arithmetic.mjs.map +1 -1
  313. package/dist/slider/slider-context.mjs.map +1 -1
  314. package/dist/slider/slider-label.d.mts.map +1 -1
  315. package/dist/slider/slider-label.mjs +3 -9
  316. package/dist/slider/slider-label.mjs.map +1 -1
  317. package/dist/slider/slider-root.d.mts +2 -2
  318. package/dist/slider/slider-root.d.mts.map +1 -1
  319. package/dist/slider/slider-root.mjs +36 -116
  320. package/dist/slider/slider-root.mjs.map +1 -1
  321. package/dist/slider/slider-thumb.d.mts.map +1 -1
  322. package/dist/slider/slider-thumb.mjs +8 -6
  323. package/dist/slider/slider-thumb.mjs.map +1 -1
  324. package/dist/slider/slider-value.d.mts.map +1 -1
  325. package/dist/slider/slider-value.mjs +2 -1
  326. package/dist/slider/slider-value.mjs.map +1 -1
  327. package/dist/slider/use-slider-dev-warnings.mjs +29 -0
  328. package/dist/slider/use-slider-dev-warnings.mjs.map +1 -0
  329. package/dist/slider/use-thumb-registry.mjs +51 -0
  330. package/dist/slider/use-thumb-registry.mjs.map +1 -0
  331. package/dist/switch/switch.d.mts +4 -5
  332. package/dist/switch/switch.d.mts.map +1 -1
  333. package/dist/switch/switch.mjs +15 -55
  334. package/dist/switch/switch.mjs.map +1 -1
  335. package/dist/tabs/tabs-context.d.mts +2 -3
  336. package/dist/tabs/tabs-context.d.mts.map +1 -1
  337. package/dist/tabs/tabs-context.mjs.map +1 -1
  338. package/dist/tabs/tabs-list.d.mts.map +1 -1
  339. package/dist/tabs/tabs-list.mjs +9 -22
  340. package/dist/tabs/tabs-list.mjs.map +1 -1
  341. package/dist/tabs/tabs-panel.d.mts +3 -4
  342. package/dist/tabs/tabs-panel.d.mts.map +1 -1
  343. package/dist/tabs/tabs-panel.mjs.map +1 -1
  344. package/dist/tabs/tabs-root.d.mts +4 -3
  345. package/dist/tabs/tabs-root.d.mts.map +1 -1
  346. package/dist/tabs/tabs-root.mjs +2 -1
  347. package/dist/tabs/tabs-root.mjs.map +1 -1
  348. package/dist/tabs/tabs-tab.d.mts +3 -4
  349. package/dist/tabs/tabs-tab.d.mts.map +1 -1
  350. package/dist/tabs/tabs-tab.mjs.map +1 -1
  351. package/dist/toast/toast-action.mjs.map +1 -1
  352. package/dist/toast/toast-close.d.mts.map +1 -1
  353. package/dist/toast/toast-close.mjs +2 -8
  354. package/dist/toast/toast-close.mjs.map +1 -1
  355. package/dist/toast/toast-context.mjs.map +1 -1
  356. package/dist/toast/toast-hotkey.mjs +27 -0
  357. package/dist/toast/toast-hotkey.mjs.map +1 -0
  358. package/dist/toast/toast-queue.mjs +137 -0
  359. package/dist/toast/toast-queue.mjs.map +1 -0
  360. package/dist/toast/toast-timers.mjs +65 -0
  361. package/dist/toast/toast-timers.mjs.map +1 -0
  362. package/dist/toast/toast-viewport.d.mts.map +1 -1
  363. package/dist/toast/toast-viewport.mjs +30 -235
  364. package/dist/toast/toast-viewport.mjs.map +1 -1
  365. package/dist/toast/toast.mjs +1 -1
  366. package/dist/toast/toast.mjs.map +1 -1
  367. package/dist/toast/use-modal-portal-host.mjs +52 -0
  368. package/dist/toast/use-modal-portal-host.mjs.map +1 -0
  369. package/dist/toggle/toggle.d.mts +3 -4
  370. package/dist/toggle/toggle.d.mts.map +1 -1
  371. package/dist/toggle/toggle.mjs +7 -10
  372. package/dist/toggle/toggle.mjs.map +1 -1
  373. package/dist/toggle-group/toggle-group-context.d.mts +2 -1
  374. package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
  375. package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
  376. package/dist/toggle-group/toggle-group-item.d.mts +5 -3
  377. package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
  378. package/dist/toggle-group/toggle-group-item.mjs +5 -7
  379. package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
  380. package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
  381. package/dist/toggle-group/toggle-group-root.mjs +29 -64
  382. package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
  383. package/dist/toolbar/toolbar-root.d.mts +2 -2
  384. package/dist/toolbar/toolbar-root.d.mts.map +1 -1
  385. package/dist/toolbar/toolbar-root.mjs +3 -4
  386. package/dist/toolbar/toolbar-root.mjs.map +1 -1
  387. package/dist/tooltip/tooltip-context.d.mts +1 -1
  388. package/dist/tooltip/tooltip-context.mjs.map +1 -1
  389. package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
  390. package/dist/tooltip/tooltip-popup.mjs +6 -15
  391. package/dist/tooltip/tooltip-popup.mjs.map +1 -1
  392. package/dist/tooltip/tooltip-root.mjs +2 -2
  393. package/dist/tooltip/tooltip-root.mjs.map +1 -1
  394. package/dist/tooltip/tooltip-trigger.d.mts +2 -1
  395. package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
  396. package/dist/tooltip/tooltip-trigger.mjs +3 -2
  397. package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
  398. package/dist/tooltip/use-tooltip-interaction.mjs +4 -3
  399. package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
  400. package/package.json +3 -2
  401. package/dist/accordion/accordion-context.d.mts +0 -5
  402. package/dist/accordion/accordion-context.d.mts.map +0 -1
  403. package/dist/internal/use-popover-root.mjs.map +0 -1
  404. /package/dist/internal/{use-popover-root.d.mts → use-overlay-root.d.mts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"toggle-group-item.mjs","names":[],"sources":["../../src/toggle-group/toggle-group-item.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { isHostButton, rendersButton, useRender } from \"../internal/use-render.js\";\nimport { useToggleGroupContext } from \"./toggle-group-context.js\";\nimport type { ToggleGroupOrientation } from \"./toggle-group-context.js\";\n\nexport interface ToggleGroupItemState {\n /** Optimistic pressed state. */\n readonly pressed: boolean;\n /** The group's action is in flight and this Item's optimistic state differs from its committed one. */\n readonly pending: boolean;\n /** Own `disabled` or the Root's. */\n readonly disabled: boolean;\n readonly orientation: ToggleGroupOrientation;\n}\n\nexport interface ToggleGroupItemProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"type\" | \"value\" | \"tabIndex\" | \"aria-pressed\" | \"className\" | \"style\" | \"children\"\n> {\n /** The value this Item presses. Unique within the group. */\n value: string;\n /**\n * Never dispatches. Native `disabled` on a `<button>` (skipped by the arrow keys); with a link\n * or component `render`, `aria-disabled=\"true\"` instead: the element stays focusable and the\n * arrow keys reach it (the APG Toolbar behaviour).\n */\n disabled?: boolean;\n /**\n * Forwarded as `default` to the Item's `<ViewTransition>`. As on Toggle: animates the commit\n * that ends the group's action (and rollbacks), not the optimistic flip, which is a CSS\n * `transition` on `[data-pressed]`. Static; any value makes a mount inside a transition start a\n * document view transition (issue #35).\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, ToggleGroupItemState>;\n style?: StateValue<CSSProperties | undefined, ToggleGroupItemState>;\n /** Rendered from optimistic state; must not suspend. */\n children?: StateValue<ReactNode, ToggleGroupItemState>;\n /** Must be, or render, a `<button>` (a toggle is a button). */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, ToggleGroupItemState>;\n}\n\n/**\n * One toggle of a ToggleGroup: the `Toggle` element (`<button type=\"button\" aria-pressed>`) whose\n * pressed state is the Root's (design/components/toggle-group.md 16.3). Its `tabindex` is written\n * by the roving engine (the group's, or the enclosing Toolbar's).\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>` only), `aria-pressed`, `disabled`,\n * `aria-disabled` (link or component `render`), `data-pressed`, `data-pending`, `data-disabled`, `data-orientation`, `onClick`, and\n * `focusgroupstart` while the Root renders `focusgroup`.\n */\nexport function ToggleGroupItem({\n value,\n disabled: disabledProp = false,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: ToggleGroupItemProps) {\n const ctx = useToggleGroupContext(\"ToggleGroup.Item\");\n const pressed = ctx.optimistic.has(value);\n const pending = ctx.pending && pressed !== ctx.committed.has(value);\n const disabled = ctx.disabled || disabledProp;\n const { register } = ctx;\n const registerRef = useCallback((el: HTMLElement) => register(el, value), [register, value]);\n\n // Not a host <button> (a link, a component): `aria-disabled`, enforced by the click handler\n // (#83). The roving engine skips `:disabled` only, so such an Item is reached by the arrows.\n const focusable = !isHostButton(render);\n\n const state: ToggleGroupItemState = {\n pressed,\n pending,\n disabled,\n orientation: ctx.orientation,\n };\n\n const element = useRender<ComponentPropsWithRef<\"button\">, ToggleGroupItemState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n // Pass-through layer, as Toggle: a `render` element's own `type` wins.\n props: rendersButton(render) ? { ...rest, type: \"button\" } : rest,\n libraryProps: {\n disabled: focusable ? undefined : disabled,\n // Owned only in the focusable branch: a host button keeps a consumer's own.\n ...(focusable && { \"aria-disabled\": disabled ? true : undefined }),\n \"aria-pressed\": pressed,\n \"data-pressed\": dataAttr(pressed),\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n \"data-orientation\": ctx.orientation,\n ...(ctx.focusgroupStartValue !== null && {\n focusgroupstart: ctx.focusgroupStartValue === value ? \"\" : undefined,\n }),\n onClick: (event: MouseEvent<HTMLButtonElement>) => {\n // Native buttons do not fire `click` when disabled; the guard covers `render` elements\n // (a link must not navigate either).\n if (disabled) {\n event.preventDefault();\n return;\n }\n ctx.toggle(value, event.nativeEvent);\n },\n },\n ref: registerRef,\n });\n\n return useTransitionBoundary(\"ToggleGroup.Item\", transition, element);\n}\n\nToggleGroupItem.displayName = \"ToggleGroupItem\";\n"],"mappings":";;;;;;;;;;;;;;;;;AA8DA,SAAgB,gBAAgB,EAC9B,OACA,UAAU,eAAe,OACzB,YACA,WACA,OACA,UACA,QACA,GAAG,QACoB;CACvB,MAAM,MAAM,sBAAsB,kBAAkB;CACpD,MAAM,UAAU,IAAI,WAAW,IAAI,KAAK;CACxC,MAAM,UAAU,IAAI,WAAW,YAAY,IAAI,UAAU,IAAI,KAAK;CAClE,MAAM,WAAW,IAAI,YAAY;CACjC,MAAM,EAAE,aAAa;CACrB,MAAM,cAAc,aAAa,OAAoB,SAAS,IAAI,KAAK,GAAG,CAAC,UAAU,KAAK,CAAC;CAI3F,MAAM,YAAY,CAAC,aAAa,MAAM;CAEtC,MAAM,QAA8B;EAClC;EACA;EACA;EACA,aAAa,IAAI;CACnB;CAEA,MAAM,UAAU,UAAiE;EAC/E,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EAEA,OAAO,cAAc,MAAM,IAAI;GAAE,GAAG;GAAM,MAAM;EAAS,IAAI;EAC7D,cAAc;GACZ,UAAU,YAAY,KAAA,IAAY;GAElC,GAAI,aAAa,EAAE,iBAAiB,WAAW,OAAO,KAAA,EAAU;GAChE,gBAAgB;GAChB,gBAAgB,SAAS,OAAO;GAChC,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;GAClC,oBAAoB,IAAI;GACxB,GAAI,IAAI,yBAAyB,QAAQ,EACvC,iBAAiB,IAAI,yBAAyB,QAAQ,KAAK,KAAA,EAC7D;GACA,UAAU,UAAyC;IAGjD,IAAI,UAAU;KACZ,MAAM,eAAe;KACrB;IACF;IACA,IAAI,OAAO,OAAO,MAAM,WAAW;GACrC;EACF;EACA,KAAK;CACP,CAAC;CAED,OAAO,sBAAsB,oBAAoB,YAAY,OAAO;AACtE;AAEA,gBAAgB,cAAc"}
1
+ {"version":3,"file":"toggle-group-item.mjs","names":[],"sources":["../../src/toggle-group/toggle-group-item.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { disabledButton, rendersButton, useRender } from \"../internal/use-render.js\";\nimport { useToggleGroupContext } from \"./toggle-group-context.js\";\nimport type { ToggleGroupOrientation } from \"./toggle-group-context.js\";\n\nexport interface ToggleGroupItemState {\n /** Optimistic pressed state. */\n readonly pressed: boolean;\n /** The group's action is in flight and this Item's optimistic state differs from its committed one. */\n readonly pending: boolean;\n /** Own `disabled` or the Root's. */\n readonly disabled: boolean;\n readonly orientation: ToggleGroupOrientation;\n}\n\nexport interface ToggleGroupItemProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"type\" | \"value\" | \"tabIndex\" | \"aria-pressed\" | \"className\" | \"style\" | \"children\"\n> {\n /** The value this Item presses. Unique within the group. */\n value: string;\n /**\n * Never dispatches. Native `disabled` on a `<button>` (skipped by the arrow keys); with a link\n * or component `render`, `aria-disabled=\"true\"` instead: the element stays focusable and the\n * arrow keys reach it (the APG Toolbar behaviour).\n */\n disabled?: boolean;\n /**\n * Forwarded as `default` to the Item's `<ViewTransition>`. As on Toggle: animates the commit\n * that ends the group's action (and rollbacks), not the optimistic flip, which is a CSS\n * `transition` on `[data-pressed]`.\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, ToggleGroupItemState>;\n style?: StateValue<CSSProperties | undefined, ToggleGroupItemState>;\n /** Rendered from optimistic state; must not suspend. */\n children?: StateValue<ReactNode, ToggleGroupItemState>;\n /** Must be, or render, a `<button>` (a toggle is a button). */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, ToggleGroupItemState>;\n}\n\n/**\n * One toggle of a ToggleGroup: the `Toggle` element (`<button type=\"button\" aria-pressed>`) whose\n * pressed state is the Root's (design/components/toggle-group.md 16.3). Its `tabindex` is written\n * by the roving engine (the group's, or the enclosing Toolbar's).\n *\n * Owned keys (conventions 1.2): `aria-pressed`, `disabled`,\n * `aria-disabled` (link or component `render`), `data-pressed`, `data-pending`, `data-disabled`, `data-orientation`, `onClick`, and\n * `focusgroupstart` while the Root renders `focusgroup`.\n */\nexport function ToggleGroupItem({\n value,\n disabled: disabledProp = false,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: ToggleGroupItemProps) {\n const ctx = useToggleGroupContext(\"ToggleGroup.Item\");\n const pressed = ctx.optimistic.has(value);\n const pending = ctx.pending && pressed !== ctx.committed.has(value);\n const disabled = ctx.disabled || disabledProp;\n const { registerItem } = ctx;\n const registerRef = useCallback(\n (el: HTMLElement) => registerItem(el, value),\n [registerItem, value],\n );\n\n const state: ToggleGroupItemState = {\n pressed,\n pending,\n disabled,\n orientation: ctx.orientation,\n };\n\n const element = useRender<ComponentPropsWithRef<\"button\">, ToggleGroupItemState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n // Pass-through layer, as Toggle: a `render` element's own `type` wins.\n props: rendersButton(render) ? { ...rest, type: \"button\" } : rest,\n libraryProps: {\n ...disabledButton(render, disabled).props,\n \"aria-pressed\": pressed,\n \"data-pressed\": dataAttr(pressed),\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n \"data-orientation\": ctx.orientation,\n ...(ctx.focusgroupStartValue !== null && {\n focusgroupstart: ctx.focusgroupStartValue === value ? \"\" : undefined,\n }),\n onClick: (event: MouseEvent<HTMLButtonElement>) => {\n // Native buttons do not fire `click` when disabled; the guard covers `render` elements\n // (a link must not navigate either).\n if (disabled) {\n event.preventDefault();\n return;\n }\n ctx.toggle(value, event.nativeEvent);\n },\n },\n ref: registerRef,\n });\n\n return useTransitionBoundary(\"ToggleGroup.Item\", transition, element);\n}\n\nToggleGroupItem.displayName = \"ToggleGroupItem\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAgEA,SAAgB,gBAAgB,EAC9B,OACA,UAAU,eAAe,OACzB,YACA,WACA,OACA,UACA,QACA,GAAG,QACoB;CACvB,MAAM,MAAM,sBAAsB,kBAAkB;CACpD,MAAM,UAAU,IAAI,WAAW,IAAI,KAAK;CACxC,MAAM,UAAU,IAAI,WAAW,YAAY,IAAI,UAAU,IAAI,KAAK;CAClE,MAAM,WAAW,IAAI,YAAY;CACjC,MAAM,EAAE,iBAAiB;CACzB,MAAM,cAAc,aACjB,OAAoB,aAAa,IAAI,KAAK,GAC3C,CAAC,cAAc,KAAK,CACtB;CAEA,MAAM,QAA8B;EAClC;EACA;EACA;EACA,aAAa,IAAI;CACnB;CAEA,MAAM,UAAU,UAAiE;EAC/E,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EAEA,OAAO,cAAc,MAAM,IAAI;GAAE,GAAG;GAAM,MAAM;EAAS,IAAI;EAC7D,cAAc;GACZ,GAAG,eAAe,QAAQ,QAAQ,CAAC,CAAC;GACpC,gBAAgB;GAChB,gBAAgB,SAAS,OAAO;GAChC,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;GAClC,oBAAoB,IAAI;GACxB,GAAI,IAAI,yBAAyB,QAAQ,EACvC,iBAAiB,IAAI,yBAAyB,QAAQ,KAAK,KAAA,EAC7D;GACA,UAAU,UAAyC;IAGjD,IAAI,UAAU;KACZ,MAAM,eAAe;KACrB;IACF;IACA,IAAI,OAAO,OAAO,MAAM,WAAW;GACrC;EACF;EACA,KAAK;CACP,CAAC;CAED,OAAO,sBAAsB,oBAAoB,YAAY,OAAO;AACtE;AAEA,gBAAgB,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"toggle-group-root.d.mts","names":[],"sources":["../../src/toggle-group/toggle-group-root.tsx"],"mappings":";;;;;iBA6BiB,sCAAsC;;WAE5C;;WAEA;;iBAGM;;;;;;WAMN;;WAEA;WACA;;WAEA,aAAa;;UAGd,iCAAiC,KACzC;;EAYA,cAAc;;EAEd;;EAEA;;;;;;;EAOA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;iBAGnC,iCAAiC;EAChD;;EAEA;;EAEA;;;;;;;;;EASA,oBAAoB,uBAAuB;;EAE3C;;iBAGe,kCAAkC;;EAEjD;;EAEA;;EAEA;;;;;;EAMA;;EAEA,oBAAoB,4BAA4B;;;YAItC,uBAAuB,2BAA2B;;;;;;;;;;wBA6E9C,gBAAgB,OAAO,uCAAoB,IAAA;yBAA3C"}
1
+ {"version":3,"file":"toggle-group-root.d.mts","names":[],"sources":["../../src/toggle-group/toggle-group-root.tsx"],"mappings":";;;;;iBA2BiB,sCAAsC;;WAE5C;;WAEA;;iBAGM;;;;;;WAMN;;WAEA;WACA;;WAEA,aAAa;;UAGd,iCAAiC,KACzC;;EAYA,cAAc;;EAEd;;EAEA;;;;;;;EAOA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;iBAGnC,iCAAiC;EAChD;;EAEA;;EAEA;;;;;;;;;EASA,oBAAoB,uBAAuB;;EAE3C;;iBAGe,kCAAkC;;EAEjD;;EAEA;;EAEA;;;;;;EAMA;;EAEA,oBAAoB,4BAA4B;;;YAItC,uBAAuB,2BAA2B;;;;;;;;;;wBAkC9C,gBAAgB,OAAO,uCAAoB,IAAA;yBAA3C"}
@@ -8,44 +8,19 @@ import { transitionTypes } from "../internal/transition-types.mjs";
8
8
  import { useLatest } from "../internal/use-latest.mjs";
9
9
  import { useControllableAction } from "../internal/use-controllable-action.mjs";
10
10
  import { ToggleGroupContext } from "./toggle-group-context.mjs";
11
+ import { compareDocumentOrder } from "../internal/dom-order.mjs";
12
+ import { EMPTY_SET, applyPatch, arraysEqual, sortByOrder, toSet } from "../internal/value-set.mjs";
13
+ import { useItemOrder } from "../internal/use-item-order.mjs";
14
+ import { useNativeFocusgroup } from "../internal/use-native-focusgroup.mjs";
11
15
  import { useRovingFocus } from "../internal/use-roving-focus.mjs";
12
- import { useCallback, useEffectEvent, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
16
+ import { useCallback, useMemo, useRef, useState } from "react";
13
17
  import { jsx } from "react/jsx-runtime";
14
18
  //#region src/toggle-group/toggle-group-root.tsx
15
19
  const isDev = process.env.NODE_ENV !== "production";
16
- const EMPTY = /* @__PURE__ */ new Set();
17
- function toSet(value) {
18
- if (value === null) return EMPTY;
19
- return typeof value === "string" ? /* @__PURE__ */ new Set([value]) : new Set(value);
20
- }
21
- /** The optimistic reducer (design 5.2): apply a patch, so stacked dispatches re-base. */
22
- function reduce(set, patch) {
23
- const next = new Set(set);
24
- for (const v of patch.removed) next.delete(v);
25
- for (const v of patch.added) next.add(v);
26
- return next;
27
- }
28
- /** `values` sorted by `order`; values not in `order` keep their iteration order, last. */
29
- function sortByOrder(values, order) {
30
- const wanted = new Set(values);
31
- const sorted = [];
32
- for (const v of order) if (wanted.delete(v)) sorted.push(v);
33
- for (const v of wanted) sorted.push(v);
34
- return sorted;
35
- }
36
- function arraysEqual(a, b) {
37
- return a.length === b.length && a.every((v, i) => v === b[i]);
38
- }
39
- function byDocumentOrder(a, b) {
40
- if (a === b) return 0;
41
- return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
42
- }
43
20
  /** Standalone entry (design 6.2): the first pressed item, else the first item (radio-like). */
44
21
  function pressedFirst(items) {
45
22
  return items.find((el) => el.getAttribute("aria-pressed") === "true") ?? items[0];
46
23
  }
47
- /** Engine capabilities never change while the page lives. */
48
- const subscribeNever = () => () => {};
49
24
  const NO_LAYOUT = {
50
25
  order: [],
51
26
  disabled: []
@@ -63,39 +38,39 @@ function ToggleGroupRoot(props) {
63
38
  const { exclusive = false, value, defaultValue, valueChangeAction, deselectable = true, orientation: orientationProp, loop: loopProp, disabled = false, experimental_focusgroup: focusgroupProp, className, style, children, render, ...rest } = props;
64
39
  const toolbar = useToolbarContext();
65
40
  const inToolbar = toolbar !== null;
66
- useDevWarning(inToolbar && orientationProp !== void 0, "ToggleGroup.Root: `orientation` is ignored inside a Toolbar.Root; the group follows the Toolbar's orientation.");
67
- useDevWarning(inToolbar && loopProp !== void 0, "ToggleGroup.Root: `loop` is ignored inside a Toolbar.Root; the Toolbar's `loop` applies.");
68
- useDevWarning(inToolbar && focusgroupProp === true, "ToggleGroup.Root: `experimental_focusgroup` is ignored inside a Toolbar.Root. A nested focusgroup would split the Toolbar's single Tab stop; set the flag on the Toolbar.Root.");
41
+ useDevWarning(inToolbar && orientationProp !== void 0, isDev && "ToggleGroup.Root: `orientation` is ignored inside a Toolbar.Root; the group follows the Toolbar's orientation.");
42
+ useDevWarning(inToolbar && loopProp !== void 0, isDev && "ToggleGroup.Root: `loop` is ignored inside a Toolbar.Root; the Toolbar's `loop` applies.");
43
+ useDevWarning(inToolbar && focusgroupProp === true, isDev && "ToggleGroup.Root: `experimental_focusgroup` is ignored inside a Toolbar.Root. A nested focusgroup would split the Toolbar's single Tab stop; set the flag on the Toolbar.Root.");
69
44
  const orientation = toolbar?.orientation ?? orientationProp ?? "horizontal";
70
45
  const loop = loopProp ?? true;
71
46
  const flag = !inToolbar && focusgroupProp === true;
72
47
  const [mountExclusive] = useState(exclusive);
73
- useDevWarning(mountExclusive !== exclusive, "ToggleGroup.Root: `exclusive` changed after mount. Switching between exclusive and multiple mode is not supported; the group keeps the mode it mounted with.");
48
+ useDevWarning(mountExclusive !== exclusive, isDev && "ToggleGroup.Root: `exclusive` changed after mount. Switching between exclusive and multiple mode is not supported; the group keeps the mode it mounted with.");
74
49
  const controlledKey = value === void 0 ? void 0 : JSON.stringify(value);
75
50
  const controlledSet = useMemo(() => controlledKey === void 0 ? void 0 : toSet(JSON.parse(controlledKey)), [controlledKey]);
76
51
  const defaultKey = defaultValue === void 0 ? void 0 : JSON.stringify(defaultValue);
77
52
  const defaultSet = useMemo(() => defaultKey === void 0 ? void 0 : toSet(JSON.parse(defaultKey)), [defaultKey]);
78
53
  const registry = useRef(/* @__PURE__ */ new Map());
79
- const register = useCallback((element, itemValue) => {
54
+ const registerItem = useCallback((element, itemValue) => {
80
55
  registry.current.set(element, itemValue);
81
56
  return () => {
82
57
  registry.current.delete(element);
83
58
  };
84
59
  }, []);
85
- const sortedItems = () => [...registry.current].sort(([a], [b]) => byDocumentOrder(a, b));
60
+ const sortedItems = () => [...registry.current].sort(([a], [b]) => compareDocumentOrder(a, b));
86
61
  /** Sorts by the Items' current document order. Reads the DOM: handlers and effects only. */
87
62
  const sortByDocument = (values) => sortByOrder(values, sortedItems().map(([, v]) => v));
88
63
  const { optimistic, committed, pending, dispatch } = useControllableAction({
89
64
  controlled: controlledSet,
90
65
  defaultValue: defaultSet,
91
- initialValue: EMPTY,
66
+ initialValue: EMPTY_SET,
92
67
  action: valueChangeAction && ((next, details) => valueChangeAction(mountExclusive ? [...next][0] ?? null : sortByDocument(next), details)),
93
68
  transitionTypes: (_next, _prev, details) => [
94
69
  ...transitionTypes("toggle-group"),
95
70
  ...details.added.length > 0 ? ["fsui-toggle-group-press"] : [],
96
71
  ...details.removed.length > 0 ? ["fsui-toggle-group-release"] : []
97
72
  ],
98
- reducer: (prev, _next, details) => reduce(prev, details),
73
+ reducer: (prev, _next, details) => applyPatch(prev, details),
99
74
  warn: {
100
75
  component: "ToggleGroup.Root",
101
76
  prop: "value"
@@ -119,32 +94,22 @@ function ToggleGroupRoot(props) {
119
94
  added: [itemValue],
120
95
  removed: exclusive ? [...optimistic] : []
121
96
  };
122
- dispatch(reduce(optimistic, patch), createActionDetails(event, patch));
97
+ dispatch(applyPatch(optimistic, patch), createActionDetails(event, patch));
123
98
  }, [dispatch, latest]);
124
- const [layout, setLayout] = useState(NO_LAYOUT);
125
- const renderedValue = sortByOrder(optimistic, layout.order);
126
- const warnedDuplicate = useRef(false);
127
- const syncLayout = useEffectEvent(() => {
128
- const items = sortedItems();
129
- const order = items.map(([, v]) => v);
130
- const disabledValues = items.filter(([el]) => el.matches(":disabled")).map(([, v]) => v);
131
- const valueChanged = !arraysEqual(sortByOrder(optimistic, order), renderedValue);
132
- const startChanged = flag && (!arraysEqual(order, layout.order) || !arraysEqual(disabledValues, layout.disabled));
133
- if (valueChanged || startChanged) setLayout({
134
- order,
135
- disabled: disabledValues
136
- });
137
- if (!isDev || warnedDuplicate.current) return;
138
- const duplicate = order.find((v, i) => order.indexOf(v) !== i);
139
- if (duplicate !== void 0) {
140
- warnedDuplicate.current = true;
141
- console.error(`ToggleGroup.Item: two Items share the value "${duplicate}" in one ToggleGroup.Root. Item values must be unique; both follow the same pressed state.`);
142
- }
143
- });
144
- useLayoutEffect(() => {
145
- syncLayout();
99
+ const { layout, renderedValue } = useItemOrder({
100
+ optimistic,
101
+ initial: NO_LAYOUT,
102
+ read: () => {
103
+ const items = sortedItems();
104
+ return {
105
+ order: items.map(([, v]) => v),
106
+ disabled: items.filter(([el]) => el.matches(":disabled")).map(([, v]) => v)
107
+ };
108
+ },
109
+ changed: (prev, next) => flag && (!arraysEqual(next.order, prev.order) || !arraysEqual(next.disabled, prev.disabled)),
110
+ duplicateMessage: isDev && ((duplicate) => `ToggleGroup.Item: two Items share the value "${duplicate}" in one ToggleGroup.Root. Item values must be unique; both follow the same pressed state.`)
146
111
  });
147
- const native = useSyncExternalStore(subscribeNever, () => flag && "focusGroup" in HTMLElement.prototype, () => false);
112
+ const native = useNativeFocusgroup(flag);
148
113
  const focusgroupStartValue = flag && !disabled ? renderedValue.find((v) => (layout.order.length === 0 || layout.order.includes(v)) && !layout.disabled.includes(v)) ?? null : null;
149
114
  const rootRef = useRef(null);
150
115
  const roving = useRovingFocus(rootRef, {
@@ -163,7 +128,7 @@ function ToggleGroupRoot(props) {
163
128
  orientation,
164
129
  focusgroupStartValue,
165
130
  toggle,
166
- register
131
+ registerItem
167
132
  }), [
168
133
  optimistic,
169
134
  committed,
@@ -172,7 +137,7 @@ function ToggleGroupRoot(props) {
172
137
  orientation,
173
138
  focusgroupStartValue,
174
139
  toggle,
175
- register
140
+ registerItem
176
141
  ]);
177
142
  const state = {
178
143
  value: renderedValue,
@@ -1 +1 @@
1
- {"version":3,"file":"toggle-group-root.mjs","names":[],"sources":["../../src/toggle-group/toggle-group-root.tsx"],"sourcesContent":["\"use client\";\nimport {\n useCallback,\n useEffectEvent,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { useToolbarContext } from \"../internal/toolbar-context.js\";\nimport { transitionTypes } from \"../internal/transition-types.js\";\nimport type { ActionDetails, ChangeAction, RenderProp, StateValue } from \"../internal/types.js\";\nimport { useControllableAction } from \"../internal/use-controllable-action.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useRovingFocus } from \"../internal/use-roving-focus.js\";\nimport { ToggleGroupContext } from \"./toggle-group-context.js\";\nimport type { ToggleGroupContextValue, ToggleGroupOrientation } from \"./toggle-group-context.js\";\n\nexport type { ToggleGroupOrientation } from \"./toggle-group-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** Details passed as the second argument of `valueChangeAction`, in both modes. */\nexport interface ToggleGroupValueChangeDetails extends ActionDetails {\n /** Values this dispatch pressed (document order of their Items). Exclusive mode: `[next]` or `[]`. */\n readonly added: readonly string[];\n /** Values this dispatch released. Exclusive mode: `[previous]` or `[]`. */\n readonly removed: readonly string[];\n}\n\nexport interface ToggleGroupRootState {\n /**\n * Optimistic pressed values in document order of the Items (exclusive mode: `[value]` or `[]`,\n * so one state shape serves both modes). The server render and the first client render use the\n * value's own order. Content rendered from it must not suspend.\n */\n readonly value: readonly string[];\n /** An action dispatched through this group is in flight. */\n readonly pending: boolean;\n readonly disabled: boolean;\n /** The effective orientation: the Toolbar's when inside one. */\n readonly orientation: ToggleGroupOrientation;\n}\n\ninterface ToggleGroupRootBaseProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"role\"\n | \"onKeyDown\"\n | \"onFocus\"\n | \"onBlur\"\n | \"onPointerDown\"\n | \"defaultValue\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** Axis of the arrow keys and `data-orientation`. Default `\"horizontal\"`. Ignored inside a Toolbar (dev warning). */\n orientation?: ToggleGroupOrientation;\n /** Whether arrows wrap from the last Item to the first. Default `true`. Ignored inside a Toolbar (dev warning). */\n loop?: boolean;\n /** Disables every Item (native `disabled`). */\n disabled?: boolean;\n /**\n * Render `focusgroup=\"toolbar …\"` and, where the browser implements it, let the browser move\n * focus between the Items. Chromium 150+ only; elsewhere the JS path stays active. Ignored\n * inside a Toolbar (a nested focusgroup would split the Toolbar's sequence; dev warning).\n * Default `false`.\n */\n experimental_focusgroup?: boolean;\n className?: StateValue<string | undefined, ToggleGroupRootState>;\n style?: StateValue<CSSProperties | undefined, ToggleGroupRootState>;\n children?: StateValue<ReactNode, ToggleGroupRootState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ToggleGroupRootState>;\n}\n\nexport interface ToggleGroupMultipleProps extends ToggleGroupRootBaseProps {\n exclusive?: false;\n /** Controlled pressed values. `[]` presses nothing; `undefined` means uncontrolled. Order is not significant; duplicates ignored. */\n value?: string[];\n /** Initial pressed values in uncontrolled mode. Default `[]`. */\n defaultValue?: string[];\n /**\n * Runs inside the Root's transition whenever the set of pressed Items changes. Sync or async (a\n * Server Function may be passed directly); rejections reach the nearest Error Boundary and roll\n * the change back. `next` is the whole set as a fresh array in document order;\n * `details.added` / `details.removed` say what changed. A `setState` after your own `await` is\n * not a Transition update; wrap it in `startTransition`. Prefer a functional update keyed by\n * `added` / `removed` when controlled.\n */\n valueChangeAction?: ChangeAction<string[], ToggleGroupValueChangeDetails>;\n /** Exclusive mode only: a type error here (TypeScript's union excess-property check would let it through otherwise). */\n deselectable?: never;\n}\n\nexport interface ToggleGroupExclusiveProps extends ToggleGroupRootBaseProps {\n /** At most one Item is pressed; `value` is `string | null`. */\n exclusive: true;\n /** Controlled pressed value. `null` presses nothing; `undefined` means uncontrolled. */\n value?: string | null;\n /** Initial pressed value in uncontrolled mode. Default `null`. */\n defaultValue?: string | null;\n /**\n * Whether pressing the pressed Item releases it (`next === null`). Default `true`. With\n * `false` that press is a no-op and dispatches nothing; `value` stays `string | null` because\n * the group may start with nothing pressed, but the action is then never called with `null`.\n */\n deselectable?: boolean;\n /** See {@link ToggleGroupMultipleProps.valueChangeAction}; `next` is the pressed value or `null`. */\n valueChangeAction?: ChangeAction<string | null, ToggleGroupValueChangeDetails>;\n}\n\n/** Props of `ToggleGroup.Root`, discriminated on `exclusive`. */\nexport type ToggleGroupRootProps = ToggleGroupMultipleProps | ToggleGroupExclusiveProps;\n\ntype GroupValue = string[] | string | null;\ntype ValueSet = ReadonlySet<string>;\n\n/** Both variants as one shape, for the implementation. */\ninterface InternalProps extends ToggleGroupRootBaseProps {\n exclusive?: boolean;\n value?: GroupValue;\n defaultValue?: GroupValue;\n deselectable?: boolean;\n valueChangeAction?: ChangeAction<GroupValue, ToggleGroupValueChangeDetails>;\n}\n\nconst EMPTY: ValueSet = new Set();\n\nfunction toSet(value: GroupValue): ValueSet {\n if (value === null) return EMPTY;\n return typeof value === \"string\" ? new Set([value]) : new Set(value);\n}\n\ninterface Patch {\n readonly added: readonly string[];\n readonly removed: readonly string[];\n}\n\n/** The optimistic reducer (design 5.2): apply a patch, so stacked dispatches re-base. */\nfunction reduce(set: ValueSet, patch: Patch): ValueSet {\n const next = new Set(set);\n for (const v of patch.removed) next.delete(v);\n for (const v of patch.added) next.add(v);\n return next;\n}\n\n/** `values` sorted by `order`; values not in `order` keep their iteration order, last. */\nfunction sortByOrder(values: Iterable<string>, order: readonly string[]): string[] {\n const wanted = new Set(values);\n const sorted: string[] = [];\n for (const v of order) if (wanted.delete(v)) sorted.push(v);\n for (const v of wanted) sorted.push(v);\n return sorted;\n}\n\nfunction arraysEqual(a: readonly string[], b: readonly string[]): boolean {\n return a.length === b.length && a.every((v, i) => v === b[i]);\n}\n\nfunction byDocumentOrder(a: Node, b: Node): number {\n if (a === b) return 0;\n return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;\n}\n\n/** Standalone entry (design 6.2): the first pressed item, else the first item (radio-like). */\nfunction pressedFirst(items: readonly HTMLElement[]): HTMLElement | undefined {\n return items.find((el) => el.getAttribute(\"aria-pressed\") === \"true\") ?? items[0];\n}\n\n/** Engine capabilities never change while the page lives. */\nconst subscribeNever = () => () => {};\n\n/** The Items' document order and their disabled values, as of the Root's last commit. */\ninterface ItemLayout {\n readonly order: readonly string[];\n readonly disabled: readonly string[];\n}\n\nconst NO_LAYOUT: ItemLayout = { order: [], disabled: [] };\n\n/**\n * `<div role=\"group\">` that owns the pressed set, the transition and, when standalone, the roving\n * focus over its Items (design/components/toggle-group.md 16.2). Inside a `Toolbar.Root` it runs\n * no engine of its own: its Items are members of the Toolbar's sequence.\n *\n * Owned keys (conventions 1.2): `role`, `data-orientation`, `data-pending`, `data-disabled`;\n * standalone also `onKeyDown`, `onFocus`, `onBlur`, `onPointerDown` and, with the flag,\n * `focusgroup`.\n */\nexport function ToggleGroupRoot(props: ToggleGroupRootProps) {\n const {\n exclusive = false,\n value,\n defaultValue,\n valueChangeAction,\n deselectable = true,\n orientation: orientationProp,\n loop: loopProp,\n disabled = false,\n experimental_focusgroup: focusgroupProp,\n className,\n style,\n children,\n render,\n ...rest\n } = props as InternalProps;\n\n const toolbar = useToolbarContext();\n const inToolbar = toolbar !== null;\n useDevWarning(\n inToolbar && orientationProp !== undefined,\n \"ToggleGroup.Root: `orientation` is ignored inside a Toolbar.Root; the group follows the \" +\n \"Toolbar's orientation.\",\n );\n useDevWarning(\n inToolbar && loopProp !== undefined,\n \"ToggleGroup.Root: `loop` is ignored inside a Toolbar.Root; the Toolbar's `loop` applies.\",\n );\n useDevWarning(\n inToolbar && focusgroupProp === true,\n \"ToggleGroup.Root: `experimental_focusgroup` is ignored inside a Toolbar.Root. A nested \" +\n \"focusgroup would split the Toolbar's single Tab stop; set the flag on the Toolbar.Root.\",\n );\n const orientation: ToggleGroupOrientation =\n toolbar?.orientation ?? orientationProp ?? \"horizontal\";\n const loop = loopProp ?? true;\n const flag = !inToolbar && focusgroupProp === true;\n\n // The mode is fixed at mount (design 3.1).\n const [mountExclusive] = useState(exclusive);\n useDevWarning(\n mountExclusive !== exclusive,\n \"ToggleGroup.Root: `exclusive` changed after mount. Switching between exclusive and \" +\n \"multiple mode is not supported; the group keeps the mode it mounted with.\",\n );\n\n // Committed set keyed on the contents, so an inline `value={[\"a\"]}` does not re-base every render.\n const controlledKey = value === undefined ? undefined : JSON.stringify(value);\n const controlledSet = useMemo(\n () =>\n controlledKey === undefined ? undefined : toSet(JSON.parse(controlledKey) as GroupValue),\n [controlledKey],\n );\n const defaultKey = defaultValue === undefined ? undefined : JSON.stringify(defaultValue);\n const defaultSet = useMemo(\n () => (defaultKey === undefined ? undefined : toSet(JSON.parse(defaultKey) as GroupValue)),\n [defaultKey],\n );\n\n // Item registration (design 16.2): element → value, written from the Items' callback refs.\n const registry = useRef(new Map<HTMLElement, string>());\n const register = useCallback((element: HTMLElement, itemValue: string) => {\n registry.current.set(element, itemValue);\n return () => {\n registry.current.delete(element);\n };\n }, []);\n const sortedItems = (): [HTMLElement, string][] =>\n [...registry.current].sort(([a], [b]) => byDocumentOrder(a, b));\n /** Sorts by the Items' current document order. Reads the DOM: handlers and effects only. */\n const sortByDocument = (values: Iterable<string>): string[] =>\n sortByOrder(\n values,\n sortedItems().map(([, v]) => v),\n );\n\n const { optimistic, committed, pending, dispatch } = useControllableAction<\n ValueSet,\n ToggleGroupValueChangeDetails\n >({\n controlled: controlledSet,\n defaultValue: defaultSet,\n initialValue: EMPTY,\n action:\n valueChangeAction &&\n ((next, details) =>\n valueChangeAction(mountExclusive ? ([...next][0] ?? null) : sortByDocument(next), details)),\n transitionTypes: (_next, _prev, details) => [\n ...transitionTypes(\"toggle-group\"),\n ...(details.added.length > 0 ? [\"fsui-toggle-group-press\"] : []),\n ...(details.removed.length > 0 ? [\"fsui-toggle-group-release\"] : []),\n ],\n reducer: (prev, _next, details) => reduce(prev, details),\n warn: { component: \"ToggleGroup.Root\", prop: \"value\" },\n });\n\n // Read by the stable `toggle` (#48): a handler only runs against the committed UI.\n const latest = useLatest({ optimistic, exclusive: mountExclusive, deselectable });\n const toggle = useCallback(\n (itemValue: string, event: Event) => {\n const { optimistic, exclusive, deselectable } = latest.current;\n let patch: Patch;\n if (optimistic.has(itemValue)) {\n // Exclusive and not deselectable: pressing the pressed Item is a no-op (design 5.2).\n if (exclusive && !deselectable) return;\n patch = { added: [], removed: [itemValue] };\n } else {\n patch = { added: [itemValue], removed: exclusive ? [...optimistic] : [] };\n }\n dispatch(reduce(optimistic, patch), createActionDetails(event, patch));\n },\n [dispatch, latest],\n );\n\n // `state.value` is in document order. Render cannot read the DOM, so the Items' order (and,\n // for `focusgroupstart`, which values have a disabled Item) is kept in state, refreshed after a\n // commit of the Root only when what renders from it would change (CheckboxGroup's approach).\n const [layout, setLayout] = useState<ItemLayout>(NO_LAYOUT);\n const renderedValue = sortByOrder(optimistic, layout.order);\n const warnedDuplicate = useRef(false);\n const syncLayout = useEffectEvent(() => {\n const items = sortedItems();\n const order = items.map(([, v]) => v);\n const disabledValues = items.filter(([el]) => el.matches(\":disabled\")).map(([, v]) => v);\n const valueChanged = !arraysEqual(sortByOrder(optimistic, order), renderedValue);\n const startChanged =\n flag && (!arraysEqual(order, layout.order) || !arraysEqual(disabledValues, layout.disabled));\n // A DOM read (the Items' order) that render cannot do; the comparison ends the chain.\n if (valueChanged || startChanged) setLayout({ order, disabled: disabledValues });\n\n if (!isDev || warnedDuplicate.current) return;\n const duplicate = order.find((v, i) => order.indexOf(v) !== i);\n if (duplicate !== undefined) {\n warnedDuplicate.current = true;\n console.error(\n `ToggleGroup.Item: two Items share the value \"${duplicate}\" in one ToggleGroup.Root. ` +\n \"Item values must be unique; both follow the same pressed state.\",\n );\n }\n });\n useLayoutEffect(() => {\n // oxlint-disable-next-line react/set-state-in-effect -- a DOM read render cannot do (as CheckboxGroup.Root)\n syncLayout();\n });\n\n // Feature detection only when the flag is on, never during SSR or hydration (conventions 8).\n const native = useSyncExternalStore(\n subscribeNever,\n () => flag && \"focusGroup\" in HTMLElement.prototype,\n () => false,\n );\n\n const focusgroupStartValue =\n flag && !disabled\n ? (renderedValue.find(\n (v) =>\n (layout.order.length === 0 || layout.order.includes(v)) && !layout.disabled.includes(v),\n ) ?? null)\n : null;\n\n const rootRef = useRef<HTMLElement | null>(null);\n const roving = useRovingFocus(rootRef, {\n enabled: !inToolbar,\n orientation,\n loop,\n native,\n entry: pressedFirst,\n memory: false,\n });\n\n const context = useMemo<ToggleGroupContextValue>(\n () => ({\n optimistic,\n committed,\n pending,\n disabled,\n orientation,\n focusgroupStartValue,\n toggle,\n register,\n }),\n [optimistic, committed, pending, disabled, orientation, focusgroupStartValue, toggle, register],\n );\n\n const state: ToggleGroupRootState = { value: renderedValue, pending, disabled, orientation };\n\n const focusgroup = flag\n ? `toolbar ${orientation === \"vertical\" ? \"block\" : \"inline\"} ${loop ? \"wrap\" : \"nowrap\"} nomemory`\n : undefined;\n\n const element = useRender<ComponentPropsWithRef<\"div\">, ToggleGroupRootState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n role: \"group\",\n \"data-orientation\": orientation,\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n // Inside a Toolbar the group has no engine: the keys are not owned there.\n ...(!inToolbar && roving),\n ...(focusgroup !== undefined && { focusgroup }),\n },\n ref: rootRef,\n });\n\n return <ToggleGroupContext value={context}>{element}</ToggleGroupContext>;\n}\n\nToggleGroupRoot.displayName = \"ToggleGroupRoot\";\n"],"mappings":"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"}
1
+ {"version":3,"file":"toggle-group-root.mjs","names":[],"sources":["../../src/toggle-group/toggle-group-root.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { compareDocumentOrder } from \"../internal/dom-order.js\";\nimport { useToolbarContext } from \"../internal/toolbar-context.js\";\nimport { transitionTypes } from \"../internal/transition-types.js\";\nimport type { ActionDetails, ChangeAction, RenderProp, StateValue } from \"../internal/types.js\";\nimport { useControllableAction } from \"../internal/use-controllable-action.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useItemOrder } from \"../internal/use-item-order.js\";\nimport type { ItemLayout } from \"../internal/use-item-order.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useNativeFocusgroup } from \"../internal/use-native-focusgroup.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useRovingFocus } from \"../internal/use-roving-focus.js\";\nimport { applyPatch, EMPTY_SET, arraysEqual, sortByOrder, toSet } from \"../internal/value-set.js\";\nimport type { SetPatch, ValueSet } from \"../internal/value-set.js\";\nimport { ToggleGroupContext } from \"./toggle-group-context.js\";\nimport type { ToggleGroupContextValue, ToggleGroupOrientation } from \"./toggle-group-context.js\";\n\nexport type { ToggleGroupOrientation } from \"./toggle-group-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** Details passed as the second argument of `valueChangeAction`, in both modes. */\nexport interface ToggleGroupValueChangeDetails extends ActionDetails {\n /** Values this dispatch pressed (document order of their Items). Exclusive mode: `[next]` or `[]`. */\n readonly added: readonly string[];\n /** Values this dispatch released. Exclusive mode: `[previous]` or `[]`. */\n readonly removed: readonly string[];\n}\n\nexport interface ToggleGroupRootState {\n /**\n * Optimistic pressed values in document order of the Items (exclusive mode: `[value]` or `[]`,\n * so one state shape serves both modes). The server render and the first client render use the\n * value's own order. Content rendered from it must not suspend.\n */\n readonly value: readonly string[];\n /** An action dispatched through this group is in flight. */\n readonly pending: boolean;\n readonly disabled: boolean;\n /** The effective orientation: the Toolbar's when inside one. */\n readonly orientation: ToggleGroupOrientation;\n}\n\ninterface ToggleGroupRootBaseProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"role\"\n | \"onKeyDown\"\n | \"onFocus\"\n | \"onBlur\"\n | \"onPointerDown\"\n | \"defaultValue\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** Axis of the arrow keys and `data-orientation`. Default `\"horizontal\"`. Ignored inside a Toolbar (dev warning). */\n orientation?: ToggleGroupOrientation;\n /** Whether arrows wrap from the last Item to the first. Default `true`. Ignored inside a Toolbar (dev warning). */\n loop?: boolean;\n /** Disables every Item (native `disabled`). */\n disabled?: boolean;\n /**\n * Render `focusgroup=\"toolbar …\"` and, where the browser implements it, let the browser move\n * focus between the Items. Chromium 150+ only; elsewhere the JS path stays active. Ignored\n * inside a Toolbar (a nested focusgroup would split the Toolbar's sequence; dev warning).\n * Default `false`.\n */\n experimental_focusgroup?: boolean;\n className?: StateValue<string | undefined, ToggleGroupRootState>;\n style?: StateValue<CSSProperties | undefined, ToggleGroupRootState>;\n children?: StateValue<ReactNode, ToggleGroupRootState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ToggleGroupRootState>;\n}\n\nexport interface ToggleGroupMultipleProps extends ToggleGroupRootBaseProps {\n exclusive?: false;\n /** Controlled pressed values. `[]` presses nothing; `undefined` means uncontrolled. Order is not significant; duplicates ignored. */\n value?: string[];\n /** Initial pressed values in uncontrolled mode. Default `[]`. */\n defaultValue?: string[];\n /**\n * Runs inside the Root's transition whenever the set of pressed Items changes. Sync or async (a\n * Server Function may be passed directly); rejections reach the nearest Error Boundary and roll\n * the change back. `next` is the whole set as a fresh array in document order;\n * `details.added` / `details.removed` say what changed. A `setState` after your own `await` is\n * not a Transition update; wrap it in `startTransition`. Prefer a functional update keyed by\n * `added` / `removed` when controlled.\n */\n valueChangeAction?: ChangeAction<string[], ToggleGroupValueChangeDetails>;\n /** Exclusive mode only: a type error here (TypeScript's union excess-property check would let it through otherwise). */\n deselectable?: never;\n}\n\nexport interface ToggleGroupExclusiveProps extends ToggleGroupRootBaseProps {\n /** At most one Item is pressed; `value` is `string | null`. */\n exclusive: true;\n /** Controlled pressed value. `null` presses nothing; `undefined` means uncontrolled. */\n value?: string | null;\n /** Initial pressed value in uncontrolled mode. Default `null`. */\n defaultValue?: string | null;\n /**\n * Whether pressing the pressed Item releases it (`next === null`). Default `true`. With\n * `false` that press is a no-op and dispatches nothing; `value` stays `string | null` because\n * the group may start with nothing pressed, but the action is then never called with `null`.\n */\n deselectable?: boolean;\n /** See {@link ToggleGroupMultipleProps.valueChangeAction}; `next` is the pressed value or `null`. */\n valueChangeAction?: ChangeAction<string | null, ToggleGroupValueChangeDetails>;\n}\n\n/** Props of `ToggleGroup.Root`, discriminated on `exclusive`. */\nexport type ToggleGroupRootProps = ToggleGroupMultipleProps | ToggleGroupExclusiveProps;\n\ntype GroupValue = string[] | string | null;\n\n/** Both variants as one shape, for the implementation. */\ninterface InternalProps extends ToggleGroupRootBaseProps {\n exclusive?: boolean;\n value?: GroupValue;\n defaultValue?: GroupValue;\n deselectable?: boolean;\n valueChangeAction?: ChangeAction<GroupValue, ToggleGroupValueChangeDetails>;\n}\n\n/** Standalone entry (design 6.2): the first pressed item, else the first item (radio-like). */\nfunction pressedFirst(items: readonly HTMLElement[]): HTMLElement | undefined {\n return items.find((el) => el.getAttribute(\"aria-pressed\") === \"true\") ?? items[0];\n}\n\n/** The Items' document order and their disabled values, as of the Root's last commit. */\ninterface ToggleGroupLayout extends ItemLayout {\n readonly disabled: readonly string[];\n}\n\nconst NO_LAYOUT: ToggleGroupLayout = { order: [], disabled: [] };\n\n/**\n * `<div role=\"group\">` that owns the pressed set, the transition and, when standalone, the roving\n * focus over its Items (design/components/toggle-group.md 16.2). Inside a `Toolbar.Root` it runs\n * no engine of its own: its Items are members of the Toolbar's sequence.\n *\n * Owned keys (conventions 1.2): `role`, `data-orientation`, `data-pending`, `data-disabled`;\n * standalone also `onKeyDown`, `onFocus`, `onBlur`, `onPointerDown` and, with the flag,\n * `focusgroup`.\n */\nexport function ToggleGroupRoot(props: ToggleGroupRootProps) {\n const {\n exclusive = false,\n value,\n defaultValue,\n valueChangeAction,\n deselectable = true,\n orientation: orientationProp,\n loop: loopProp,\n disabled = false,\n experimental_focusgroup: focusgroupProp,\n className,\n style,\n children,\n render,\n ...rest\n } = props as InternalProps;\n\n const toolbar = useToolbarContext();\n const inToolbar = toolbar !== null;\n useDevWarning(\n inToolbar && orientationProp !== undefined,\n isDev &&\n \"ToggleGroup.Root: `orientation` is ignored inside a Toolbar.Root; the group follows the \" +\n \"Toolbar's orientation.\",\n );\n useDevWarning(\n inToolbar && loopProp !== undefined,\n isDev &&\n \"ToggleGroup.Root: `loop` is ignored inside a Toolbar.Root; the Toolbar's `loop` applies.\",\n );\n useDevWarning(\n inToolbar && focusgroupProp === true,\n isDev &&\n \"ToggleGroup.Root: `experimental_focusgroup` is ignored inside a Toolbar.Root. A nested \" +\n \"focusgroup would split the Toolbar's single Tab stop; set the flag on the Toolbar.Root.\",\n );\n const orientation: ToggleGroupOrientation =\n toolbar?.orientation ?? orientationProp ?? \"horizontal\";\n const loop = loopProp ?? true;\n const flag = !inToolbar && focusgroupProp === true;\n\n // The mode is fixed at mount (design 3.1).\n const [mountExclusive] = useState(exclusive);\n useDevWarning(\n mountExclusive !== exclusive,\n isDev &&\n \"ToggleGroup.Root: `exclusive` changed after mount. Switching between exclusive and \" +\n \"multiple mode is not supported; the group keeps the mode it mounted with.\",\n );\n\n // Committed set keyed on the contents, so an inline `value={[\"a\"]}` does not re-base every render.\n const controlledKey = value === undefined ? undefined : JSON.stringify(value);\n const controlledSet = useMemo(\n () =>\n controlledKey === undefined ? undefined : toSet(JSON.parse(controlledKey) as GroupValue),\n [controlledKey],\n );\n const defaultKey = defaultValue === undefined ? undefined : JSON.stringify(defaultValue);\n const defaultSet = useMemo(\n () => (defaultKey === undefined ? undefined : toSet(JSON.parse(defaultKey) as GroupValue)),\n [defaultKey],\n );\n\n // Item registration (design 16.2): element → value, written from the Items' callback refs.\n const registry = useRef(new Map<HTMLElement, string>());\n const registerItem = useCallback((element: HTMLElement, itemValue: string) => {\n registry.current.set(element, itemValue);\n return () => {\n registry.current.delete(element);\n };\n }, []);\n const sortedItems = (): [HTMLElement, string][] =>\n [...registry.current].sort(([a], [b]) => compareDocumentOrder(a, b));\n /** Sorts by the Items' current document order. Reads the DOM: handlers and effects only. */\n const sortByDocument = (values: Iterable<string>): string[] =>\n sortByOrder(\n values,\n sortedItems().map(([, v]) => v),\n );\n\n const { optimistic, committed, pending, dispatch } = useControllableAction<\n ValueSet,\n ToggleGroupValueChangeDetails\n >({\n controlled: controlledSet,\n defaultValue: defaultSet,\n initialValue: EMPTY_SET,\n action:\n valueChangeAction &&\n ((next, details) =>\n valueChangeAction(mountExclusive ? ([...next][0] ?? null) : sortByDocument(next), details)),\n transitionTypes: (_next, _prev, details) => [\n ...transitionTypes(\"toggle-group\"),\n ...(details.added.length > 0 ? [\"fsui-toggle-group-press\"] : []),\n ...(details.removed.length > 0 ? [\"fsui-toggle-group-release\"] : []),\n ],\n reducer: (prev, _next, details) => applyPatch(prev, details),\n warn: { component: \"ToggleGroup.Root\", prop: \"value\" },\n });\n\n // Read by the stable `toggle`: a handler only runs against the committed UI.\n const latest = useLatest({ optimistic, exclusive: mountExclusive, deselectable });\n const toggle = useCallback(\n (itemValue: string, event: Event) => {\n const { optimistic, exclusive, deselectable } = latest.current;\n let patch: SetPatch;\n if (optimistic.has(itemValue)) {\n // Exclusive and not deselectable: pressing the pressed Item is a no-op (design 5.2).\n if (exclusive && !deselectable) return;\n patch = { added: [], removed: [itemValue] };\n } else {\n patch = { added: [itemValue], removed: exclusive ? [...optimistic] : [] };\n }\n dispatch(applyPatch(optimistic, patch), createActionDetails(event, patch));\n },\n [dispatch, latest],\n );\n\n // `state.value` is in document order; `focusgroupstart` also renders from which values have a\n // disabled Item.\n const { layout, renderedValue } = useItemOrder<ToggleGroupLayout>({\n optimistic,\n initial: NO_LAYOUT,\n read: () => {\n const items = sortedItems();\n return {\n order: items.map(([, v]) => v),\n disabled: items.filter(([el]) => el.matches(\":disabled\")).map(([, v]) => v),\n };\n },\n changed: (prev, next) =>\n flag && (!arraysEqual(next.order, prev.order) || !arraysEqual(next.disabled, prev.disabled)),\n duplicateMessage:\n isDev &&\n ((duplicate) =>\n `ToggleGroup.Item: two Items share the value \"${duplicate}\" in one ToggleGroup.Root. ` +\n \"Item values must be unique; both follow the same pressed state.\"),\n });\n\n const native = useNativeFocusgroup(flag);\n\n const focusgroupStartValue =\n flag && !disabled\n ? (renderedValue.find(\n (v) =>\n (layout.order.length === 0 || layout.order.includes(v)) && !layout.disabled.includes(v),\n ) ?? null)\n : null;\n\n const rootRef = useRef<HTMLElement | null>(null);\n const roving = useRovingFocus(rootRef, {\n enabled: !inToolbar,\n orientation,\n loop,\n native,\n entry: pressedFirst,\n memory: false,\n });\n\n const context = useMemo<ToggleGroupContextValue>(\n () => ({\n optimistic,\n committed,\n pending,\n disabled,\n orientation,\n focusgroupStartValue,\n toggle,\n registerItem,\n }),\n [\n optimistic,\n committed,\n pending,\n disabled,\n orientation,\n focusgroupStartValue,\n toggle,\n registerItem,\n ],\n );\n\n const state: ToggleGroupRootState = { value: renderedValue, pending, disabled, orientation };\n\n const focusgroup = flag\n ? `toolbar ${orientation === \"vertical\" ? \"block\" : \"inline\"} ${loop ? \"wrap\" : \"nowrap\"} nomemory`\n : undefined;\n\n const element = useRender<ComponentPropsWithRef<\"div\">, ToggleGroupRootState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n role: \"group\",\n \"data-orientation\": orientation,\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n // Inside a Toolbar the group has no engine: the keys are not owned there.\n ...(!inToolbar && roving),\n ...(focusgroup !== undefined && { focusgroup }),\n },\n ref: rootRef,\n });\n\n return <ToggleGroupContext value={context}>{element}</ToggleGroupContext>;\n}\n\nToggleGroupRoot.displayName = \"ToggleGroupRoot\";\n"],"mappings":"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"}
@@ -1,7 +1,7 @@
1
- import { RenderProp, StateValue } from "../internal/types.mjs";
1
+ import { Orientation, RenderProp, StateValue } from "../internal/types.mjs";
2
2
  import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
3
3
  //#region src/toolbar/toolbar-root.d.ts
4
- export type ToolbarOrientation = "horizontal" | "vertical";
4
+ export type ToolbarOrientation = Orientation;
5
5
  export interface ToolbarRootState {
6
6
  readonly orientation: ToolbarOrientation;
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"toolbar-root.d.mts","names":[],"sources":["../../src/toolbar/toolbar-root.tsx"],"mappings":";;;YASY;iBAEK;WACN,aAAa;;iBAGP,yBAAyB,KACxC;;EAYA,cAAc;;EAEd;;;;;;EAMA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;wBAwBpC,cACd,aACA,MACA,yBACA,WACA,OACA,UACA,WACG,QACF,mCAAgB,IAAA;yBATH"}
1
+ {"version":3,"file":"toolbar-root.d.mts","names":[],"sources":["../../src/toolbar/toolbar-root.tsx"],"mappings":";;;YAUY,qBAAqB;iBAEhB;WACN,aAAa;;iBAGP,yBAAyB,KACxC;;EAYA,cAAc;;EAEd;;;;;;EAMA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;wBAqBpC,cACd,aACA,MACA,yBACA,WACA,OACA,UACA,WACG,QACF,mCAAgB,IAAA;yBATH"}
@@ -1,8 +1,9 @@
1
1
  "use client";
2
2
  import { ToolbarContext } from "../internal/toolbar-context.mjs";
3
3
  import { useRender } from "../internal/use-render.mjs";
4
+ import { useNativeFocusgroup } from "../internal/use-native-focusgroup.mjs";
4
5
  import { useRovingFocus } from "../internal/use-roving-focus.mjs";
5
- import { useMemo, useRef, useSyncExternalStore } from "react";
6
+ import { useMemo, useRef } from "react";
6
7
  import { jsx } from "react/jsx-runtime";
7
8
  //#region src/toolbar/toolbar-root.tsx
8
9
  /**
@@ -13,8 +14,6 @@ import { jsx } from "react/jsx-runtime";
13
14
  function firstItem(items) {
14
15
  return items[0];
15
16
  }
16
- /** Engine capabilities never change while the page lives. */
17
- const subscribeNever = () => () => {};
18
17
  /**
19
18
  * `<div role="toolbar" aria-orientation>` (WAI-ARIA APG Toolbar). Its items are its focusable
20
19
  * descendants, found in the DOM: one Tab stop (the last focused item), arrow keys, Home and End
@@ -25,7 +24,7 @@ const subscribeNever = () => () => {};
25
24
  * `onFocus`, `onBlur`, `onPointerDown`, and `focusgroup` while the flag is on.
26
25
  */
27
26
  function ToolbarRoot({ orientation = "horizontal", loop = true, experimental_focusgroup = false, className, style, children, render, ...rest }) {
28
- const native = useSyncExternalStore(subscribeNever, () => experimental_focusgroup && "focusGroup" in HTMLElement.prototype, () => false);
27
+ const native = useNativeFocusgroup(experimental_focusgroup);
29
28
  const rootRef = useRef(null);
30
29
  const roving = useRovingFocus(rootRef, {
31
30
  orientation,
@@ -1 +1 @@
1
- {"version":3,"file":"toolbar-root.mjs","names":[],"sources":["../../src/toolbar/toolbar-root.tsx"],"sourcesContent":["\"use client\";\nimport { useMemo, useRef, useSyncExternalStore } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { ToolbarContext } from \"../internal/toolbar-context.js\";\nimport type { ToolbarContextValue } from \"../internal/toolbar-context.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useRovingFocus } from \"../internal/use-roving-focus.js\";\n\nexport type ToolbarOrientation = \"horizontal\" | \"vertical\";\n\nexport interface ToolbarRootState {\n readonly orientation: ToolbarOrientation;\n}\n\nexport interface ToolbarRootProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"role\"\n | \"aria-orientation\"\n | \"onKeyDown\"\n | \"onFocus\"\n | \"onBlur\"\n | \"onPointerDown\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** Axis of the arrow keys; also `aria-orientation`. Default `\"horizontal\"`. */\n orientation?: ToolbarOrientation;\n /** Whether arrows wrap from the last item to the first. Default `true`. */\n loop?: boolean;\n /**\n * Render `focusgroup=\"toolbar …\"` and, where the browser implements it, let the browser handle\n * arrow keys, Home and End and the single Tab stop. Chromium 150+ only; elsewhere the JS path\n * stays active. Default `false`.\n */\n experimental_focusgroup?: boolean;\n className?: StateValue<string | undefined, ToolbarRootState>;\n style?: StateValue<CSSProperties | undefined, ToolbarRootState>;\n children?: StateValue<ReactNode, ToolbarRootState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ToolbarRootState>;\n}\n\n/**\n * First entry: the first item. Natively `disabled` controls are not items; `aria-disabled` ones\n * are, and are entered like any other, as Chromium's native `focusgroup` does (the APG allows\n * focusable disabled items in a toolbar).\n */\nfunction firstItem(items: readonly HTMLElement[]): HTMLElement | undefined {\n return items[0];\n}\n\n/** Engine capabilities never change while the page lives. */\nconst subscribeNever = () => () => {};\n\n/**\n * `<div role=\"toolbar\" aria-orientation>` (WAI-ARIA APG Toolbar). Its items are its focusable\n * descendants, found in the DOM: one Tab stop (the last focused item), arrow keys, Home and End\n * between them (design/components/toggle-group.md section 6). Name it with `aria-label` or\n * `aria-labelledby`.\n *\n * Owned keys (conventions 1.2): `role`, `aria-orientation`, `data-orientation`, `onKeyDown`,\n * `onFocus`, `onBlur`, `onPointerDown`, and `focusgroup` while the flag is on.\n */\nexport function ToolbarRoot({\n orientation = \"horizontal\",\n loop = true,\n experimental_focusgroup = false,\n className,\n style,\n children,\n render,\n ...rest\n}: ToolbarRootProps) {\n // Conventions 8: the server snapshot is `false`, so hydration markup matches the server.\n const native = useSyncExternalStore(\n subscribeNever,\n () => experimental_focusgroup && \"focusGroup\" in HTMLElement.prototype,\n () => false,\n );\n const rootRef = useRef<HTMLElement | null>(null);\n const roving = useRovingFocus(rootRef, {\n orientation,\n loop,\n native,\n entry: firstItem,\n memory: true,\n });\n\n const context = useMemo<ToolbarContextValue>(() => ({ orientation }), [orientation]);\n const state: ToolbarRootState = { orientation };\n\n const focusgroup = experimental_focusgroup\n ? `toolbar ${orientation === \"vertical\" ? \"block\" : \"inline\"} ${loop ? \"wrap\" : \"nowrap\"}`\n : undefined;\n\n const element = useRender<ComponentPropsWithRef<\"div\">, ToolbarRootState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n role: \"toolbar\",\n \"aria-orientation\": orientation,\n \"data-orientation\": orientation,\n ...roving,\n ...(focusgroup !== undefined && { focusgroup }),\n },\n ref: rootRef,\n });\n\n return <ToolbarContext value={context}>{element}</ToolbarContext>;\n}\n\nToolbarRoot.displayName = \"ToolbarRoot\";\n"],"mappings":";;;;;;;;;;;;AAgDA,SAAS,UAAU,OAAwD;CACzE,OAAO,MAAM;AACf;;AAGA,MAAM,6BAA6B,CAAC;;;;;;;;;;AAWpC,SAAgB,YAAY,EAC1B,cAAc,cACd,OAAO,MACP,0BAA0B,OAC1B,WACA,OACA,UACA,QACA,GAAG,QACgB;CAEnB,MAAM,SAAS,qBACb,sBACM,2BAA2B,gBAAgB,YAAY,iBACvD,KACR;CACA,MAAM,UAAU,OAA2B,IAAI;CAC/C,MAAM,SAAS,eAAe,SAAS;EACrC;EACA;EACA;EACA,OAAO;EACP,QAAQ;CACV,CAAC;CAED,MAAM,UAAU,eAAoC,EAAE,YAAY,IAAI,CAAC,WAAW,CAAC;CACnF,MAAM,QAA0B,EAAE,YAAY;CAE9C,MAAM,aAAa,0BACf,WAAW,gBAAgB,aAAa,UAAU,SAAS,GAAG,OAAO,SAAS,aAC9E,KAAA;CAEJ,MAAM,UAAU,UAA0D;EACxE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,MAAM;GACN,oBAAoB;GACpB,oBAAoB;GACpB,GAAG;GACH,GAAI,eAAe,KAAA,KAAa,EAAE,WAAW;EAC/C;EACA,KAAK;CACP,CAAC;CAED,OAAO,oBAAC,gBAAD;EAAgB,OAAO;EAAU,UAAA;CAAwB,CAAA;AAClE;AAEA,YAAY,cAAc"}
1
+ {"version":3,"file":"toolbar-root.mjs","names":[],"sources":["../../src/toolbar/toolbar-root.tsx"],"sourcesContent":["\"use client\";\nimport { useMemo, useRef } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { ToolbarContext } from \"../internal/toolbar-context.js\";\nimport type { ToolbarContextValue } from \"../internal/toolbar-context.js\";\nimport type { Orientation, RenderProp, StateValue } from \"../internal/types.js\";\nimport { useNativeFocusgroup } from \"../internal/use-native-focusgroup.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useRovingFocus } from \"../internal/use-roving-focus.js\";\n\nexport type ToolbarOrientation = Orientation;\n\nexport interface ToolbarRootState {\n readonly orientation: ToolbarOrientation;\n}\n\nexport interface ToolbarRootProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"role\"\n | \"aria-orientation\"\n | \"onKeyDown\"\n | \"onFocus\"\n | \"onBlur\"\n | \"onPointerDown\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** Axis of the arrow keys; also `aria-orientation`. Default `\"horizontal\"`. */\n orientation?: ToolbarOrientation;\n /** Whether arrows wrap from the last item to the first. Default `true`. */\n loop?: boolean;\n /**\n * Render `focusgroup=\"toolbar …\"` and, where the browser implements it, let the browser handle\n * arrow keys, Home and End and the single Tab stop. Chromium 150+ only; elsewhere the JS path\n * stays active. Default `false`.\n */\n experimental_focusgroup?: boolean;\n className?: StateValue<string | undefined, ToolbarRootState>;\n style?: StateValue<CSSProperties | undefined, ToolbarRootState>;\n children?: StateValue<ReactNode, ToolbarRootState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ToolbarRootState>;\n}\n\n/**\n * First entry: the first item. Natively `disabled` controls are not items; `aria-disabled` ones\n * are, and are entered like any other, as Chromium's native `focusgroup` does (the APG allows\n * focusable disabled items in a toolbar).\n */\nfunction firstItem(items: readonly HTMLElement[]): HTMLElement | undefined {\n return items[0];\n}\n\n/**\n * `<div role=\"toolbar\" aria-orientation>` (WAI-ARIA APG Toolbar). Its items are its focusable\n * descendants, found in the DOM: one Tab stop (the last focused item), arrow keys, Home and End\n * between them (design/components/toggle-group.md section 6). Name it with `aria-label` or\n * `aria-labelledby`.\n *\n * Owned keys (conventions 1.2): `role`, `aria-orientation`, `data-orientation`, `onKeyDown`,\n * `onFocus`, `onBlur`, `onPointerDown`, and `focusgroup` while the flag is on.\n */\nexport function ToolbarRoot({\n orientation = \"horizontal\",\n loop = true,\n experimental_focusgroup = false,\n className,\n style,\n children,\n render,\n ...rest\n}: ToolbarRootProps) {\n const native = useNativeFocusgroup(experimental_focusgroup);\n const rootRef = useRef<HTMLElement | null>(null);\n const roving = useRovingFocus(rootRef, {\n orientation,\n loop,\n native,\n entry: firstItem,\n memory: true,\n });\n\n const context = useMemo<ToolbarContextValue>(() => ({ orientation }), [orientation]);\n const state: ToolbarRootState = { orientation };\n\n const focusgroup = experimental_focusgroup\n ? `toolbar ${orientation === \"vertical\" ? \"block\" : \"inline\"} ${loop ? \"wrap\" : \"nowrap\"}`\n : undefined;\n\n const element = useRender<ComponentPropsWithRef<\"div\">, ToolbarRootState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n role: \"toolbar\",\n \"aria-orientation\": orientation,\n \"data-orientation\": orientation,\n ...roving,\n ...(focusgroup !== undefined && { focusgroup }),\n },\n ref: rootRef,\n });\n\n return <ToolbarContext value={context}>{element}</ToolbarContext>;\n}\n\nToolbarRoot.displayName = \"ToolbarRoot\";\n"],"mappings":";;;;;;;;;;;;;AAiDA,SAAS,UAAU,OAAwD;CACzE,OAAO,MAAM;AACf;;;;;;;;;;AAWA,SAAgB,YAAY,EAC1B,cAAc,cACd,OAAO,MACP,0BAA0B,OAC1B,WACA,OACA,UACA,QACA,GAAG,QACgB;CACnB,MAAM,SAAS,oBAAoB,uBAAuB;CAC1D,MAAM,UAAU,OAA2B,IAAI;CAC/C,MAAM,SAAS,eAAe,SAAS;EACrC;EACA;EACA;EACA,OAAO;EACP,QAAQ;CACV,CAAC;CAED,MAAM,UAAU,eAAoC,EAAE,YAAY,IAAI,CAAC,WAAW,CAAC;CACnF,MAAM,QAA0B,EAAE,YAAY;CAE9C,MAAM,aAAa,0BACf,WAAW,gBAAgB,aAAa,UAAU,SAAS,GAAG,OAAO,SAAS,aAC9E,KAAA;CAEJ,MAAM,UAAU,UAA0D;EACxE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,MAAM;GACN,oBAAoB;GACpB,oBAAoB;GACpB,GAAG;GACH,GAAI,eAAe,KAAA,KAAa,EAAE,WAAW;EAC/C;EACA,KAAK;CACP,CAAC;CAED,OAAO,oBAAC,gBAAD;EAAgB,OAAO;EAAU,UAAA;CAAwB,CAAA;AAClE;AAEA,YAAY,cAAc"}
@@ -1,7 +1,7 @@
1
1
  import { AnchorAlign, AnchorSide } from "../internal/anchor-position.mjs";
2
2
  //#region src/tooltip/tooltip-context.d.ts
3
3
  /**
4
- * `inline-start` / `inline-end` follow the popup's `direction` (wave 11; conventions 13.1). While
4
+ * `inline-start` / `inline-end` follow the popup's `direction` (conventions 13.1). While
5
5
  * shown, the state carries the resolved physical side.
6
6
  */
7
7
  export type TooltipSide = AnchorSide;
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-context.mjs","names":[],"sources":["../../src/tooltip/tooltip-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { AnchorAlign, AnchorSide } from \"../internal/anchor-position.js\";\n\n/**\n * `inline-start` / `inline-end` follow the popup's `direction` (wave 11; conventions 13.1). While\n * shown, the state carries the resolved physical side.\n */\nexport type TooltipSide = AnchorSide;\nexport type TooltipAlign = AnchorAlign;\n\n/** Which accessibility relation the tooltip provides for its trigger (design section 5.1). */\nexport type TooltipProvides = \"description\" | \"name\";\n\nexport interface TooltipContextValue {\n /** Id of the Popup; the Trigger references it through `aria-describedby` / `aria-labelledby`. */\n readonly popupId: string;\n readonly disabled: boolean;\n /** Written onto the Trigger as `interest-delay-start` / `-end` on the native path. */\n readonly delay: number;\n readonly closeDelay: number;\n readonly provides: TooltipProvides;\n /** Trigger and Popup register their elements through callback refs (design 12.2). */\n readonly setTriggerElement: (element: HTMLElement | null) => void;\n readonly setPopupElement: (element: HTMLElement | null) => void;\n /**\n * The Trigger reports whether it renders `interestfor`, so the Root's interaction effect re-runs\n * (and re-detects the native path) when `experimental_interestFor` changes after mount.\n */\n readonly setInterestForRequested: (requested: boolean) => void;\n}\n\nexport const TooltipContext = createContext<TooltipContextValue | null>(null);\n\n/** What `Tooltip.Popup` tells its `Tooltip.Arrow`: the placement it renders (design 12.2). */\nexport interface TooltipPopupContextValue {\n /** The resolved side while shown, else the requested one; `null` with `side={null}`. */\n readonly side: TooltipSide | null;\n readonly align: TooltipAlign;\n}\n\nexport const TooltipPopupContext = createContext<TooltipPopupContextValue | null>(null);\n\nexport function useTooltipContext(part: string): TooltipContextValue {\n const context = use(TooltipContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Tooltip.Root.`);\n }\n return context;\n}\n"],"mappings":";;;AAgCA,MAAa,iBAAiB,cAA0C,IAAI;AAS5E,MAAa,sBAAsB,cAA+C,IAAI;AAEtF,SAAgB,kBAAkB,MAAmC;CACnE,MAAM,UAAU,IAAI,cAAc;CAClC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,yCAAyC;CAEnE,OAAO;AACT"}
1
+ {"version":3,"file":"tooltip-context.mjs","names":[],"sources":["../../src/tooltip/tooltip-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { AnchorAlign, AnchorSide } from \"../internal/anchor-position.js\";\n\n/**\n * `inline-start` / `inline-end` follow the popup's `direction` (conventions 13.1). While\n * shown, the state carries the resolved physical side.\n */\nexport type TooltipSide = AnchorSide;\nexport type TooltipAlign = AnchorAlign;\n\n/** Which accessibility relation the tooltip provides for its trigger (design section 5.1). */\nexport type TooltipProvides = \"description\" | \"name\";\n\nexport interface TooltipContextValue {\n /** Id of the Popup; the Trigger references it through `aria-describedby` / `aria-labelledby`. */\n readonly popupId: string;\n readonly disabled: boolean;\n /** Written onto the Trigger as `interest-delay-start` / `-end` on the native path. */\n readonly delay: number;\n readonly closeDelay: number;\n readonly provides: TooltipProvides;\n /** Trigger and Popup register their elements through callback refs (design 12.2). */\n readonly setTriggerElement: (element: HTMLElement | null) => void;\n readonly setPopupElement: (element: HTMLElement | null) => void;\n /**\n * The Trigger reports whether it renders `interestfor`, so the Root's interaction effect re-runs\n * (and re-detects the native path) when `experimental_interestFor` changes after mount.\n */\n readonly setInterestForRequested: (requested: boolean) => void;\n}\n\nexport const TooltipContext = createContext<TooltipContextValue | null>(null);\n\n/** What `Tooltip.Popup` tells its `Tooltip.Arrow`: the placement it renders (design 12.2). */\nexport interface TooltipPopupContextValue {\n /** The resolved side while shown, else the requested one; `null` with `side={null}`. */\n readonly side: TooltipSide | null;\n readonly align: TooltipAlign;\n}\n\nexport const TooltipPopupContext = createContext<TooltipPopupContextValue | null>(null);\n\nexport function useTooltipContext(part: string): TooltipContextValue {\n const context = use(TooltipContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Tooltip.Root.`);\n }\n return context;\n}\n"],"mappings":";;;AAgCA,MAAa,iBAAiB,cAA0C,IAAI;AAS5E,MAAa,sBAAsB,cAA+C,IAAI;AAEtF,SAAgB,kBAAkB,MAAmC;CACnE,MAAM,UAAU,IAAI,cAAc;CAClC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,yCAAyC;CAEnE,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-popup.d.mts","names":[],"sources":["../../src/tooltip/tooltip-popup.tsx"],"mappings":";;;;iBAeiB;WACN;;;;;;WAMA,MAAM;;WAEN,OAAO;;iBAGD,0BAA0B,KACzC;;;;;;;EASA,OAAO;;;;;;EAMP,QAAQ;;;;;;;EAOR;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;;;;EAK9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;;;;;;;;;wBAqBpC,eACd,MAAM,UACN,OAAO,WACP,mBACA,WACA,OACA,UACA,WACG,QACF,oCAAiB,IAAA;yBATJ"}
1
+ {"version":3,"file":"tooltip-popup.d.mts","names":[],"sources":["../../src/tooltip/tooltip-popup.tsx"],"mappings":";;;;iBAciB;WACN;;;;;;WAMA,MAAM;;WAEN,OAAO;;iBAGD,0BAA0B,KACzC;;;;;;;EASA,OAAO;;;;;;EAMP,QAAQ;;;;;;;EAOR;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;;;;EAK9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;;;;;;;;;wBAqBpC,eACd,MAAM,UACN,OAAO,WACP,mBACA,WACA,OACA,UACA,WACG,QACF,oCAAiB,IAAA;yBATJ"}
@@ -1,11 +1,9 @@
1
1
  "use client";
2
2
  import { dataAttr } from "../internal/data-attr.mjs";
3
- import { mergeRefs } from "../internal/merge-props.mjs";
4
- import { resolveStateValue } from "../internal/render-element.mjs";
5
3
  import { useRender } from "../internal/use-render.mjs";
6
4
  import { TooltipPopupContext, useTooltipContext } from "./tooltip-context.mjs";
7
- import { POSITION_TRY_FALLBACKS, positionArea } from "../internal/anchor-position.mjs";
8
- import { useResolvedPlacement } from "../internal/use-resolved-placement.mjs";
5
+ import { useMergedRefs } from "../internal/use-merged-refs.mjs";
6
+ import { useAnchoredPlacement } from "../internal/use-resolved-placement.mjs";
9
7
  import { useMemo } from "react";
10
8
  import { jsx } from "react/jsx-runtime";
11
9
  //#region src/tooltip/tooltip-popup.tsx
@@ -29,7 +27,7 @@ import { jsx } from "react/jsx-runtime";
29
27
  */
30
28
  function TooltipPopup({ side: sideProp = "top", align: alignProp = "center", experimental_hint = false, className, style, children, render, ...rest }) {
31
29
  const ctx = useTooltipContext("Tooltip.Popup");
32
- const placement = useResolvedPlacement({
30
+ const placement = useAnchoredPlacement({
33
31
  side: sideProp,
34
32
  align: alignProp
35
33
  });
@@ -43,27 +41,20 @@ function TooltipPopup({ side: sideProp = "top", align: alignProp = "center", exp
43
41
  side,
44
42
  align
45
43
  }), [side, align]);
46
- const ref = useMemo(() => mergeRefs(ctx.setPopupElement, placement.ref), [ctx.setPopupElement, placement.ref]);
44
+ const ref = useMergedRefs(ctx.setPopupElement, placement.ref);
47
45
  const libraryProps = {
48
46
  id: ctx.popupId,
49
47
  popover: experimental_hint ? "hint" : "manual",
50
48
  role: "tooltip",
51
49
  "data-disabled": dataAttr(ctx.disabled),
52
- ...side !== null && {
53
- "data-side": side,
54
- "data-align": align
55
- }
50
+ ...placement.dataAttributes
56
51
  };
57
52
  const element = useRender({
58
53
  defaultElement: "div",
59
54
  render,
60
55
  state,
61
56
  className,
62
- style: sideProp === null ? style : (s) => ({
63
- positionArea: positionArea(sideProp, alignProp),
64
- positionTryFallbacks: POSITION_TRY_FALLBACKS,
65
- ...resolveStateValue(style, s)
66
- }),
57
+ style: placement.style(style),
67
58
  children,
68
59
  props: rest,
69
60
  libraryProps,
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-popup.mjs","names":[],"sources":["../../src/tooltip/tooltip-popup.tsx"],"sourcesContent":["\"use client\";\nimport { useMemo } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { POSITION_TRY_FALLBACKS, positionArea } from \"../internal/anchor-position.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { mergeRefs } from \"../internal/merge-props.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useResolvedPlacement } from \"../internal/use-resolved-placement.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { TooltipPopupContext, useTooltipContext } from \"./tooltip-context.js\";\nimport type { TooltipAlign, TooltipPopupContextValue, TooltipSide } from \"./tooltip-context.js\";\n\nexport type { TooltipAlign, TooltipSide } from \"./tooltip-context.js\";\n\nexport interface TooltipPopupState {\n readonly disabled: boolean;\n /**\n * While shown: the physical side the browser placed the popup on (`\"top\"` / `\"bottom\"` /\n * `\"left\"` / `\"right\"`, after any fallback flip). Otherwise the `side` prop. `null` with\n * `side={null}`.\n */\n readonly side: TooltipSide | null;\n /** While shown: the resolved alignment; otherwise the `align` prop. */\n readonly align: TooltipAlign;\n}\n\nexport interface TooltipPopupProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"id\" | \"popover\" | \"role\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Placement relative to the trigger through inline `position-area`, with\n * `position-try-fallbacks` flipping it when it does not fit. Default `\"top\"`. `\"inline-start\"` /\n * `\"inline-end\"` follow the popup's direction. `null` emits no inline positioning (and no\n * `data-side` / `data-align`), so a stylesheet owns placement.\n */\n side?: TooltipSide | null;\n /**\n * Alignment along the side. Default `\"center\"`. On a top / bottom side `start` / `end` are\n * inline-relative (mirrored under `direction: rtl`); on the other sides they are the top /\n * bottom edges. Ignored when `side` is `null`.\n */\n align?: TooltipAlign;\n /**\n * Experimental (Chrome 151+, Firefox 153+; Safari 27.0 treats it as `\"manual\"`). Renders\n * `popover=\"hint\"` instead of `popover=\"manual\"`: native light dismiss, and the tooltip can\n * open over an `auto` popover (a menu) without closing it. The JS Escape / pointerdown handling\n * stays in place for engines that do not know `hint`. Default `false`.\n */\n experimental_hint?: boolean;\n className?: StateValue<string | undefined, TooltipPopupState>;\n style?: StateValue<CSSProperties | undefined, TooltipPopupState>;\n /**\n * Rendered at mount (hidden by the popover's `display: none`), not at open time. Tooltip\n * content should be static; if it must suspend, put the `<Suspense>` boundary inside the Popup.\n */\n children?: StateValue<ReactNode, TooltipPopupState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, TooltipPopupState>;\n}\n\n/**\n * The tooltip content: a `div` with `popover` and `role=\"tooltip\"`, shown in the top layer and\n * anchored to the trigger implicitly (`interestfor` or `showPopover({ source })`). Open state is\n * browser-owned: style it with `:popover-open` and animate it with `@starting-style` in CSS.\n *\n * `data-side` / `data-align` are where the browser placed the popup while it is shown (the\n * `position-try-fallbacks` option it applied, read from the computed `position-area`;\n * conventions 13.2) and the requested values otherwise; `Tooltip.Arrow` echoes them.\n *\n * `data-instant` is present while the tooltip is shown by an open that began while another\n * `[role=\"tooltip\"]:popover-open` existed (a warm open, skip-delay), so\n * `[data-instant] { transition: none }` skips its entry animation. Not rendered by this part: the\n * Root's effect writes it on the element from the popup's `beforetoggle` (on both paths), before\n * the open's first style recalc, and removes it at the close's. No `state` counterpart.\n *\n * Owned keys (conventions 1.2): `id`, `popover`, `role`, `data-disabled`, and `data-side` /\n * `data-align` unless `side` is `null`.\n */\nexport function TooltipPopup({\n side: sideProp = \"top\",\n align: alignProp = \"center\",\n experimental_hint = false,\n className,\n style,\n children,\n render,\n ...rest\n}: TooltipPopupProps) {\n const ctx = useTooltipContext(\"Tooltip.Popup\");\n const placement = useResolvedPlacement({ side: sideProp, align: alignProp });\n const { side, align } = placement;\n const state: TooltipPopupState = { disabled: ctx.disabled, side, align };\n const arrow = useMemo<TooltipPopupContextValue>(() => ({ side, align }), [side, align]);\n const ref = useMemo(\n () => mergeRefs(ctx.setPopupElement, placement.ref),\n [ctx.setPopupElement, placement.ref],\n );\n\n const libraryProps: ComponentPropsWithRef<\"div\"> & DataAttributes = {\n id: ctx.popupId,\n popover: experimental_hint ? \"hint\" : \"manual\",\n role: \"tooltip\",\n \"data-disabled\": dataAttr(ctx.disabled),\n // Not owned with `side={null}`: the stylesheet (or a render element) may set them.\n ...(side !== null && { \"data-side\": side, \"data-align\": align }),\n };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, TooltipPopupState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n // The inline placement is the requested one (the browser keeps choosing from it) and sits\n // under the consumer's style: the consumer wins (design 3).\n style:\n sideProp === null\n ? style\n : (s) => ({\n positionArea: positionArea(sideProp, alignProp),\n positionTryFallbacks: POSITION_TRY_FALLBACKS,\n ...resolveStateValue(style, s),\n }),\n children,\n props: rest,\n libraryProps,\n ref,\n });\n\n return <TooltipPopupContext value={arrow}>{element}</TooltipPopupContext>;\n}\n\nTooltipPopup.displayName = \"TooltipPopup\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,SAAgB,aAAa,EAC3B,MAAM,WAAW,OACjB,OAAO,YAAY,UACnB,oBAAoB,OACpB,WACA,OACA,UACA,QACA,GAAG,QACiB;CACpB,MAAM,MAAM,kBAAkB,eAAe;CAC7C,MAAM,YAAY,qBAAqB;EAAE,MAAM;EAAU,OAAO;CAAU,CAAC;CAC3E,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,QAA2B;EAAE,UAAU,IAAI;EAAU;EAAM;CAAM;CACvE,MAAM,QAAQ,eAAyC;EAAE;EAAM;CAAM,IAAI,CAAC,MAAM,KAAK,CAAC;CACtF,MAAM,MAAM,cACJ,UAAU,IAAI,iBAAiB,UAAU,GAAG,GAClD,CAAC,IAAI,iBAAiB,UAAU,GAAG,CACrC;CAEA,MAAM,eAA8D;EAClE,IAAI,IAAI;EACR,SAAS,oBAAoB,SAAS;EACtC,MAAM;EACN,iBAAiB,SAAS,IAAI,QAAQ;EAEtC,GAAI,SAAS,QAAQ;GAAE,aAAa;GAAM,cAAc;EAAM;CAChE;CAEA,MAAM,UAAU,UAA2D;EACzE,gBAAgB;EAChB;EACA;EACA;EAGA,OACE,aAAa,OACT,SACC,OAAO;GACN,cAAc,aAAa,UAAU,SAAS;GAC9C,sBAAsB;GACtB,GAAG,kBAAkB,OAAO,CAAC;EAC/B;EACN;EACA,OAAO;EACP;EACA;CACF,CAAC;CAED,OAAO,oBAAC,qBAAD;EAAqB,OAAO;EAAQ,UAAA;CAA6B,CAAA;AAC1E;AAEA,aAAa,cAAc"}
1
+ {"version":3,"file":"tooltip-popup.mjs","names":[],"sources":["../../src/tooltip/tooltip-popup.tsx"],"sourcesContent":["\"use client\";\nimport { useMemo } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { useAnchoredPlacement } from \"../internal/use-resolved-placement.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { TooltipPopupContext, useTooltipContext } from \"./tooltip-context.js\";\nimport type { TooltipAlign, TooltipPopupContextValue, TooltipSide } from \"./tooltip-context.js\";\n\nexport type { TooltipAlign, TooltipSide } from \"./tooltip-context.js\";\n\nexport interface TooltipPopupState {\n readonly disabled: boolean;\n /**\n * While shown: the physical side the browser placed the popup on (`\"top\"` / `\"bottom\"` /\n * `\"left\"` / `\"right\"`, after any fallback flip). Otherwise the `side` prop. `null` with\n * `side={null}`.\n */\n readonly side: TooltipSide | null;\n /** While shown: the resolved alignment; otherwise the `align` prop. */\n readonly align: TooltipAlign;\n}\n\nexport interface TooltipPopupProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"id\" | \"popover\" | \"role\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Placement relative to the trigger through inline `position-area`, with\n * `position-try-fallbacks` flipping it when it does not fit. Default `\"top\"`. `\"inline-start\"` /\n * `\"inline-end\"` follow the popup's direction. `null` emits no inline positioning (and no\n * `data-side` / `data-align`), so a stylesheet owns placement.\n */\n side?: TooltipSide | null;\n /**\n * Alignment along the side. Default `\"center\"`. On a top / bottom side `start` / `end` are\n * inline-relative (mirrored under `direction: rtl`); on the other sides they are the top /\n * bottom edges. Ignored when `side` is `null`.\n */\n align?: TooltipAlign;\n /**\n * Experimental (Chrome 151+, Firefox 153+; Safari 27.0 treats it as `\"manual\"`). Renders\n * `popover=\"hint\"` instead of `popover=\"manual\"`: native light dismiss, and the tooltip can\n * open over an `auto` popover (a menu) without closing it. The JS Escape / pointerdown handling\n * stays in place for engines that do not know `hint`. Default `false`.\n */\n experimental_hint?: boolean;\n className?: StateValue<string | undefined, TooltipPopupState>;\n style?: StateValue<CSSProperties | undefined, TooltipPopupState>;\n /**\n * Rendered at mount (hidden by the popover's `display: none`), not at open time. Tooltip\n * content should be static; if it must suspend, put the `<Suspense>` boundary inside the Popup.\n */\n children?: StateValue<ReactNode, TooltipPopupState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, TooltipPopupState>;\n}\n\n/**\n * The tooltip content: a `div` with `popover` and `role=\"tooltip\"`, shown in the top layer and\n * anchored to the trigger implicitly (`interestfor` or `showPopover({ source })`). Open state is\n * browser-owned: style it with `:popover-open` and animate it with `@starting-style` in CSS.\n *\n * `data-side` / `data-align` are where the browser placed the popup while it is shown (the\n * `position-try-fallbacks` option it applied, read from the computed `position-area`;\n * conventions 13.2) and the requested values otherwise; `Tooltip.Arrow` echoes them.\n *\n * `data-instant` is present while the tooltip is shown by an open that began while another\n * `[role=\"tooltip\"]:popover-open` existed (a warm open, skip-delay), so\n * `[data-instant] { transition: none }` skips its entry animation. Not rendered by this part: the\n * Root's effect writes it on the element from the popup's `beforetoggle` (on both paths), before\n * the open's first style recalc, and removes it at the close's. No `state` counterpart.\n *\n * Owned keys (conventions 1.2): `id`, `popover`, `role`, `data-disabled`, and `data-side` /\n * `data-align` unless `side` is `null`.\n */\nexport function TooltipPopup({\n side: sideProp = \"top\",\n align: alignProp = \"center\",\n experimental_hint = false,\n className,\n style,\n children,\n render,\n ...rest\n}: TooltipPopupProps) {\n const ctx = useTooltipContext(\"Tooltip.Popup\");\n const placement = useAnchoredPlacement({ side: sideProp, align: alignProp });\n const { side, align } = placement;\n const state: TooltipPopupState = { disabled: ctx.disabled, side, align };\n const arrow = useMemo<TooltipPopupContextValue>(() => ({ side, align }), [side, align]);\n const ref = useMergedRefs(ctx.setPopupElement, placement.ref);\n\n const libraryProps: ComponentPropsWithRef<\"div\"> & DataAttributes = {\n id: ctx.popupId,\n popover: experimental_hint ? \"hint\" : \"manual\",\n role: \"tooltip\",\n \"data-disabled\": dataAttr(ctx.disabled),\n // Not owned with `side={null}`: the stylesheet (or a render element) may set them.\n ...placement.dataAttributes,\n };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, TooltipPopupState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n // The consumer's style wins over the inline placement (design 3).\n style: placement.style(style),\n children,\n props: rest,\n libraryProps,\n ref,\n });\n\n return <TooltipPopupContext value={arrow}>{element}</TooltipPopupContext>;\n}\n\nTooltipPopup.displayName = \"TooltipPopup\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,SAAgB,aAAa,EAC3B,MAAM,WAAW,OACjB,OAAO,YAAY,UACnB,oBAAoB,OACpB,WACA,OACA,UACA,QACA,GAAG,QACiB;CACpB,MAAM,MAAM,kBAAkB,eAAe;CAC7C,MAAM,YAAY,qBAAqB;EAAE,MAAM;EAAU,OAAO;CAAU,CAAC;CAC3E,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,QAA2B;EAAE,UAAU,IAAI;EAAU;EAAM;CAAM;CACvE,MAAM,QAAQ,eAAyC;EAAE;EAAM;CAAM,IAAI,CAAC,MAAM,KAAK,CAAC;CACtF,MAAM,MAAM,cAAc,IAAI,iBAAiB,UAAU,GAAG;CAE5D,MAAM,eAA8D;EAClE,IAAI,IAAI;EACR,SAAS,oBAAoB,SAAS;EACtC,MAAM;EACN,iBAAiB,SAAS,IAAI,QAAQ;EAEtC,GAAG,UAAU;CACf;CAEA,MAAM,UAAU,UAA2D;EACzE,gBAAgB;EAChB;EACA;EACA;EAEA,OAAO,UAAU,MAAM,KAAK;EAC5B;EACA,OAAO;EACP;EACA;CACF,CAAC;CAED,OAAO,oBAAC,qBAAD;EAAqB,OAAO;EAAQ,UAAA;CAA6B,CAAA;AAC1E;AAEA,aAAa,cAAc"}
@@ -54,13 +54,13 @@ TooltipRoot.displayName = "TooltipRoot";
54
54
  * The containers that move focus among their items with the arrow keys (roving tabindex, or a
55
55
  * native `focusgroup`): Menu, Tabs, Toolbar, a radio group, and the other APG composites, plus
56
56
  * `role="group"`, which a standalone `ToggleGroup.Root` renders while its roving engine writes
57
- * the Items' `tabindex` (#75, design/components/toggle-group.md 18).
57
+ * the Items' `tabindex` (design/components/toggle-group.md 18).
58
58
  */
59
59
  const COMPOSITE = "[role=\"menu\"],[role=\"menubar\"],[role=\"tablist\"],[role=\"toolbar\"],[role=\"group\"],[role=\"radiogroup\"],[role=\"listbox\"],[role=\"grid\"],[role=\"treegrid\"],[role=\"tree\"],[focusgroup]";
60
60
  /**
61
61
  * Whether keyboard users can focus the trigger: it is in the tab order, or it is a
62
62
  * roving-tabindex item (`tabindex="-1"` set explicitly, so script can focus it) inside a
63
- * composite widget that moves focus to it (#57).
63
+ * composite widget that moves focus to it.
64
64
  */
65
65
  function isKeyboardReachable(trigger) {
66
66
  if (trigger.tabIndex >= 0) return true;
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-root.mjs","names":[],"sources":["../../src/tooltip/tooltip-root.tsx"],"sourcesContent":["\"use client\";\nimport { useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport type { StateValue } from \"../internal/types.js\";\nimport { resolveStateValue } from \"../internal/use-render.js\";\nimport { TooltipContext } from \"./tooltip-context.js\";\nimport type { TooltipContextValue, TooltipProvides } from \"./tooltip-context.js\";\nimport { useTooltipInteraction } from \"./use-tooltip-interaction.js\";\n\nexport type { TooltipProvides } from \"./tooltip-context.js\";\n\nexport interface TooltipRootState {\n readonly disabled: boolean;\n}\n\nexport interface TooltipRootProps {\n /**\n * Milliseconds from hover or keyboard focus to open. Default 250 (Chromium's\n * `interest-delay-start`). The same delay applies to hover and focus.\n */\n delay?: number;\n /** Milliseconds from de-hover or blur to close. Default 150 (Chromium's `interest-delay-end`). */\n closeDelay?: number;\n /** When true the tooltip never opens. The ARIA relation stays in place. */\n disabled?: boolean;\n /**\n * Which accessibility relation the tooltip provides for the trigger.\n * `\"description\"` (default): `aria-describedby`, for triggers that have their own name.\n * `\"name\"`: `aria-labelledby`, for icon-only triggers; do not also set `aria-label`.\n */\n provides?: TooltipProvides;\n children?: StateValue<ReactNode, TooltipRootState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nconst FOCUSABLE =\n \"a[href],area[href],button,input,select,textarea,iframe,[tabindex],[contenteditable]\";\n\n/**\n * Owns the popup id, the options and the one interaction effect. Renders no DOM, so it has no\n * `ref`, `className` or `style`. The open state is browser-owned (the popover's top-layer state):\n * there is no `open` prop, no action, and no `data-open`; style with `:popover-open`.\n *\n * Render `Tooltip.Popup` immediately after `Tooltip.Trigger` in DOM order: the HTML spec\n * recommends that reading order for popovers, and some screen readers attach an adjacent tooltip\n * to the wrong control otherwise. This is documented, not enforced.\n */\nexport function TooltipRoot({\n delay = 250,\n closeDelay = 150,\n disabled = false,\n provides = \"description\",\n children,\n}: TooltipRootProps) {\n const popupId = useId();\n const [trigger, setTriggerElement] = useState<HTMLElement | null>(null);\n const [popup, setPopupElement] = useState<HTMLElement | null>(null);\n const [interestForRequested, setInterestForRequested] = useState(false);\n\n useTooltipInteraction(trigger, popup, { delay, closeDelay, disabled, interestForRequested });\n useTooltipDevWarnings(trigger, popup, provides);\n\n const context = useMemo<TooltipContextValue>(\n () => ({\n popupId,\n disabled,\n delay,\n closeDelay,\n provides,\n setTriggerElement,\n setPopupElement,\n setInterestForRequested,\n }),\n [popupId, disabled, delay, closeDelay, provides],\n );\n\n const state: TooltipRootState = { disabled };\n return <TooltipContext value={context}>{resolveStateValue(children, state)}</TooltipContext>;\n}\n\nTooltipRoot.displayName = \"TooltipRoot\";\n\n/**\n * The containers that move focus among their items with the arrow keys (roving tabindex, or a\n * native `focusgroup`): Menu, Tabs, Toolbar, a radio group, and the other APG composites, plus\n * `role=\"group\"`, which a standalone `ToggleGroup.Root` renders while its roving engine writes\n * the Items' `tabindex` (#75, design/components/toggle-group.md 18).\n */\nconst COMPOSITE =\n '[role=\"menu\"],[role=\"menubar\"],[role=\"tablist\"],[role=\"toolbar\"],[role=\"group\"],[role=\"radiogroup\"],[role=\"listbox\"],[role=\"grid\"],[role=\"treegrid\"],[role=\"tree\"],[focusgroup]';\n\n/**\n * Whether keyboard users can focus the trigger: it is in the tab order, or it is a\n * roving-tabindex item (`tabindex=\"-1\"` set explicitly, so script can focus it) inside a\n * composite widget that moves focus to it (#57).\n */\nfunction isKeyboardReachable(trigger: HTMLElement): boolean {\n if (trigger.tabIndex >= 0) return true;\n return trigger.hasAttribute(\"tabindex\") && trigger.parentElement?.closest(COMPOSITE) != null;\n}\n\n/** Development-only checks that need the mounted elements (design 12.5). Each fires once. */\nfunction useTooltipDevWarnings(\n trigger: HTMLElement | null,\n popup: HTMLElement | null,\n provides: TooltipProvides,\n): void {\n const warned = useRef({ label: false, focusable: false, interactive: false });\n useEffect(() => {\n if (!isDev) return;\n const w = warned.current;\n if (trigger !== null) {\n if (provides === \"name\" && trigger.hasAttribute(\"aria-label\") && !w.label) {\n w.label = true;\n console.error(\n '[Tooltip] provides=\"name\" together with aria-label on the trigger announces the name twice. Remove aria-label.',\n );\n }\n if (!isKeyboardReachable(trigger) && !w.focusable) {\n w.focusable = true;\n console.error(\n \"[Tooltip] The trigger is not focusable; keyboard users cannot open the tooltip. Render a <button> or a link, or set tabIndex={0}.\",\n );\n }\n }\n if (popup !== null && popup.querySelector(FOCUSABLE) !== null && !w.interactive) {\n w.interactive = true;\n console.error(\n \"[Tooltip] Tooltips must not contain interactive content. Use a non-modal dialog or a popover instead.\",\n );\n }\n }, [trigger, popup, provides]);\n}\n"],"mappings":";;;;;;;AAkCA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,MAAM,YACJ;;;;;;;;;;AAWF,SAAgB,YAAY,EAC1B,QAAQ,KACR,aAAa,KACb,WAAW,OACX,WAAW,eACX,YACmB;CACnB,MAAM,UAAU,MAAM;CACtB,MAAM,CAAC,SAAS,qBAAqB,SAA6B,IAAI;CACtE,MAAM,CAAC,OAAO,mBAAmB,SAA6B,IAAI;CAClE,MAAM,CAAC,sBAAsB,2BAA2B,SAAS,KAAK;CAEtE,sBAAsB,SAAS,OAAO;EAAE;EAAO;EAAY;EAAU;CAAqB,CAAC;CAC3F,sBAAsB,SAAS,OAAO,QAAQ;CAE9C,MAAM,UAAU,eACP;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EAAC;EAAS;EAAU;EAAO;EAAY;CAAQ,CACjD;CAGA,OAAO,oBAAC,gBAAD;EAAgB,OAAO;EAAU,UAAA,kBAAkB,UAAU,EADlC,SACsC,CAAC;CAAkB,CAAA;AAC7F;AAEA,YAAY,cAAc;;;;;;;AAQ1B,MAAM,YACJ;;;;;;AAOF,SAAS,oBAAoB,SAA+B;CAC1D,IAAI,QAAQ,YAAY,GAAG,OAAO;CAClC,OAAO,QAAQ,aAAa,UAAU,KAAK,QAAQ,eAAe,QAAQ,SAAS,KAAK;AAC1F;;AAGA,SAAS,sBACP,SACA,OACA,UACM;CACN,MAAM,SAAS,OAAO;EAAE,OAAO;EAAO,WAAW;EAAO,aAAa;CAAM,CAAC;CAC5E,gBAAgB;EACd,IAAI,CAAC,OAAO;EACZ,MAAM,IAAI,OAAO;EACjB,IAAI,YAAY,MAAM;GACpB,IAAI,aAAa,UAAU,QAAQ,aAAa,YAAY,KAAK,CAAC,EAAE,OAAO;IACzE,EAAE,QAAQ;IACV,QAAQ,MACN,kHACF;GACF;GACA,IAAI,CAAC,oBAAoB,OAAO,KAAK,CAAC,EAAE,WAAW;IACjD,EAAE,YAAY;IACd,QAAQ,MACN,mIACF;GACF;EACF;EACA,IAAI,UAAU,QAAQ,MAAM,cAAc,SAAS,MAAM,QAAQ,CAAC,EAAE,aAAa;GAC/E,EAAE,cAAc;GAChB,QAAQ,MACN,uGACF;EACF;CACF,GAAG;EAAC;EAAS;EAAO;CAAQ,CAAC;AAC/B"}
1
+ {"version":3,"file":"tooltip-root.mjs","names":[],"sources":["../../src/tooltip/tooltip-root.tsx"],"sourcesContent":["\"use client\";\nimport { useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport type { StateValue } from \"../internal/types.js\";\nimport { resolveStateValue } from \"../internal/use-render.js\";\nimport { TooltipContext } from \"./tooltip-context.js\";\nimport type { TooltipContextValue, TooltipProvides } from \"./tooltip-context.js\";\nimport { useTooltipInteraction } from \"./use-tooltip-interaction.js\";\n\nexport type { TooltipProvides } from \"./tooltip-context.js\";\n\nexport interface TooltipRootState {\n readonly disabled: boolean;\n}\n\nexport interface TooltipRootProps {\n /**\n * Milliseconds from hover or keyboard focus to open. Default 250 (Chromium's\n * `interest-delay-start`). The same delay applies to hover and focus.\n */\n delay?: number;\n /** Milliseconds from de-hover or blur to close. Default 150 (Chromium's `interest-delay-end`). */\n closeDelay?: number;\n /** When true the tooltip never opens. The ARIA relation stays in place. */\n disabled?: boolean;\n /**\n * Which accessibility relation the tooltip provides for the trigger.\n * `\"description\"` (default): `aria-describedby`, for triggers that have their own name.\n * `\"name\"`: `aria-labelledby`, for icon-only triggers; do not also set `aria-label`.\n */\n provides?: TooltipProvides;\n children?: StateValue<ReactNode, TooltipRootState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nconst FOCUSABLE =\n \"a[href],area[href],button,input,select,textarea,iframe,[tabindex],[contenteditable]\";\n\n/**\n * Owns the popup id, the options and the one interaction effect. Renders no DOM, so it has no\n * `ref`, `className` or `style`. The open state is browser-owned (the popover's top-layer state):\n * there is no `open` prop, no action, and no `data-open`; style with `:popover-open`.\n *\n * Render `Tooltip.Popup` immediately after `Tooltip.Trigger` in DOM order: the HTML spec\n * recommends that reading order for popovers, and some screen readers attach an adjacent tooltip\n * to the wrong control otherwise. This is documented, not enforced.\n */\nexport function TooltipRoot({\n delay = 250,\n closeDelay = 150,\n disabled = false,\n provides = \"description\",\n children,\n}: TooltipRootProps) {\n const popupId = useId();\n const [trigger, setTriggerElement] = useState<HTMLElement | null>(null);\n const [popup, setPopupElement] = useState<HTMLElement | null>(null);\n const [interestForRequested, setInterestForRequested] = useState(false);\n\n useTooltipInteraction(trigger, popup, { delay, closeDelay, disabled, interestForRequested });\n useTooltipDevWarnings(trigger, popup, provides);\n\n const context = useMemo<TooltipContextValue>(\n () => ({\n popupId,\n disabled,\n delay,\n closeDelay,\n provides,\n setTriggerElement,\n setPopupElement,\n setInterestForRequested,\n }),\n [popupId, disabled, delay, closeDelay, provides],\n );\n\n const state: TooltipRootState = { disabled };\n return <TooltipContext value={context}>{resolveStateValue(children, state)}</TooltipContext>;\n}\n\nTooltipRoot.displayName = \"TooltipRoot\";\n\n/**\n * The containers that move focus among their items with the arrow keys (roving tabindex, or a\n * native `focusgroup`): Menu, Tabs, Toolbar, a radio group, and the other APG composites, plus\n * `role=\"group\"`, which a standalone `ToggleGroup.Root` renders while its roving engine writes\n * the Items' `tabindex` (design/components/toggle-group.md 18).\n */\nconst COMPOSITE =\n '[role=\"menu\"],[role=\"menubar\"],[role=\"tablist\"],[role=\"toolbar\"],[role=\"group\"],[role=\"radiogroup\"],[role=\"listbox\"],[role=\"grid\"],[role=\"treegrid\"],[role=\"tree\"],[focusgroup]';\n\n/**\n * Whether keyboard users can focus the trigger: it is in the tab order, or it is a\n * roving-tabindex item (`tabindex=\"-1\"` set explicitly, so script can focus it) inside a\n * composite widget that moves focus to it.\n */\nfunction isKeyboardReachable(trigger: HTMLElement): boolean {\n if (trigger.tabIndex >= 0) return true;\n return trigger.hasAttribute(\"tabindex\") && trigger.parentElement?.closest(COMPOSITE) != null;\n}\n\n/** Development-only checks that need the mounted elements (design 12.5). Each fires once. */\nfunction useTooltipDevWarnings(\n trigger: HTMLElement | null,\n popup: HTMLElement | null,\n provides: TooltipProvides,\n): void {\n const warned = useRef({ label: false, focusable: false, interactive: false });\n useEffect(() => {\n if (!isDev) return;\n const w = warned.current;\n if (trigger !== null) {\n if (provides === \"name\" && trigger.hasAttribute(\"aria-label\") && !w.label) {\n w.label = true;\n console.error(\n '[Tooltip] provides=\"name\" together with aria-label on the trigger announces the name twice. Remove aria-label.',\n );\n }\n if (!isKeyboardReachable(trigger) && !w.focusable) {\n w.focusable = true;\n console.error(\n \"[Tooltip] The trigger is not focusable; keyboard users cannot open the tooltip. Render a <button> or a link, or set tabIndex={0}.\",\n );\n }\n }\n if (popup !== null && popup.querySelector(FOCUSABLE) !== null && !w.interactive) {\n w.interactive = true;\n console.error(\n \"[Tooltip] Tooltips must not contain interactive content. Use a non-modal dialog or a popover instead.\",\n );\n }\n }, [trigger, popup, provides]);\n}\n"],"mappings":";;;;;;;AAkCA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,MAAM,YACJ;;;;;;;;;;AAWF,SAAgB,YAAY,EAC1B,QAAQ,KACR,aAAa,KACb,WAAW,OACX,WAAW,eACX,YACmB;CACnB,MAAM,UAAU,MAAM;CACtB,MAAM,CAAC,SAAS,qBAAqB,SAA6B,IAAI;CACtE,MAAM,CAAC,OAAO,mBAAmB,SAA6B,IAAI;CAClE,MAAM,CAAC,sBAAsB,2BAA2B,SAAS,KAAK;CAEtE,sBAAsB,SAAS,OAAO;EAAE;EAAO;EAAY;EAAU;CAAqB,CAAC;CAC3F,sBAAsB,SAAS,OAAO,QAAQ;CAE9C,MAAM,UAAU,eACP;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EAAC;EAAS;EAAU;EAAO;EAAY;CAAQ,CACjD;CAGA,OAAO,oBAAC,gBAAD;EAAgB,OAAO;EAAU,UAAA,kBAAkB,UAAU,EADlC,SACsC,CAAC;CAAkB,CAAA;AAC7F;AAEA,YAAY,cAAc;;;;;;;AAQ1B,MAAM,YACJ;;;;;;AAOF,SAAS,oBAAoB,SAA+B;CAC1D,IAAI,QAAQ,YAAY,GAAG,OAAO;CAClC,OAAO,QAAQ,aAAa,UAAU,KAAK,QAAQ,eAAe,QAAQ,SAAS,KAAK;AAC1F;;AAGA,SAAS,sBACP,SACA,OACA,UACM;CACN,MAAM,SAAS,OAAO;EAAE,OAAO;EAAO,WAAW;EAAO,aAAa;CAAM,CAAC;CAC5E,gBAAgB;EACd,IAAI,CAAC,OAAO;EACZ,MAAM,IAAI,OAAO;EACjB,IAAI,YAAY,MAAM;GACpB,IAAI,aAAa,UAAU,QAAQ,aAAa,YAAY,KAAK,CAAC,EAAE,OAAO;IACzE,EAAE,QAAQ;IACV,QAAQ,MACN,kHACF;GACF;GACA,IAAI,CAAC,oBAAoB,OAAO,KAAK,CAAC,EAAE,WAAW;IACjD,EAAE,YAAY;IACd,QAAQ,MACN,mIACF;GACF;EACF;EACA,IAAI,UAAU,QAAQ,MAAM,cAAc,SAAS,MAAM,QAAQ,CAAC,EAAE,aAAa;GAC/E,EAAE,cAAc;GAChB,QAAQ,MACN,uGACF;EACF;CACF,GAAG;EAAC;EAAS;EAAO;CAAQ,CAAC;AAC/B"}
@@ -35,7 +35,8 @@ export interface TooltipTriggerProps extends Omit<ComponentPropsWithRef<"button"
35
35
  * Owned keys (conventions 1.2): `aria-describedby` (with `provides="description"`) or
36
36
  * `aria-labelledby` (with `provides="name"`), both token-merged with the consumer's ids;
37
37
  * `data-disabled`; and `interestfor` and `data-fsui-tooltip-trigger` when
38
- * `experimental_interestFor` is on.
38
+ * `experimental_interestFor` is on. `type="button"` is a default the consumer may override (the
39
+ * part installs no click handler), unlike the overlay Triggers, which own it.
39
40
  */
40
41
  export declare function TooltipTrigger({ experimental_interestFor, className, style, children, render, ...rest }: TooltipTriggerProps): import("react").JSX.Element;
41
42
  export declare namespace TooltipTrigger {
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-trigger.d.mts","names":[],"sources":["../../src/tooltip/tooltip-trigger.tsx"],"mappings":";;;iBAiBiB;WACN;;iBAGM,4BAA4B,KAC3C;;;;;;;;;;;;;;EAgBA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;;;;wBAgBvC,iBACd,0BACA,WACA,OACA,UACA,WACG,QACF,sCAAmB,IAAA;yBAPN"}
1
+ {"version":3,"file":"tooltip-trigger.d.mts","names":[],"sources":["../../src/tooltip/tooltip-trigger.tsx"],"mappings":";;;iBAiBiB;WACN;;iBAGM,4BAA4B,KAC3C;;;;;;;;;;;;;;EAgBA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;;;;;wBAiBvC,iBACd,0BACA,WACA,OACA,UACA,WACG,QACF,sCAAmB,IAAA;yBAPN"}
@@ -3,8 +3,8 @@ import { dataAttr } from "../internal/data-attr.mjs";
3
3
  import { rendersButton, resolveStateValue } from "../internal/render-element.mjs";
4
4
  import { useRender } from "../internal/use-render.mjs";
5
5
  import { useTooltipContext } from "./tooltip-context.mjs";
6
- import { FSUI_PRECEDENCE } from "../internal/anchor-position.mjs";
7
6
  import { CSPContext } from "../internal/csp-context.mjs";
7
+ import { FSUI_PRECEDENCE } from "../internal/shipped-styles.mjs";
8
8
  import { TOOLTIP_WARM_HREF, TOOLTIP_WARM_RULES, warmDelay } from "../internal/tooltip-warm.mjs";
9
9
  import { use, useLayoutEffect } from "react";
10
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -20,7 +20,8 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
20
20
  * Owned keys (conventions 1.2): `aria-describedby` (with `provides="description"`) or
21
21
  * `aria-labelledby` (with `provides="name"`), both token-merged with the consumer's ids;
22
22
  * `data-disabled`; and `interestfor` and `data-fsui-tooltip-trigger` when
23
- * `experimental_interestFor` is on.
23
+ * `experimental_interestFor` is on. `type="button"` is a default the consumer may override (the
24
+ * part installs no click handler), unlike the overlay Triggers, which own it.
24
25
  */
25
26
  function TooltipTrigger({ experimental_interestFor = false, className, style, children, render, ...rest }) {
26
27
  const ctx = useTooltipContext("Tooltip.Trigger");