@funstack/ui 0.1.0-alpha.11 → 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 (401) 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.map +1 -1
  61. package/dist/combobox/combobox-root.mjs +30 -102
  62. package/dist/combobox/combobox-root.mjs.map +1 -1
  63. package/dist/combobox/combobox-trigger.d.mts.map +1 -1
  64. package/dist/combobox/combobox-trigger.mjs +6 -25
  65. package/dist/combobox/combobox-trigger.mjs.map +1 -1
  66. package/dist/combobox/index.mjs +1 -1
  67. package/dist/combobox/use-combobox-form.mjs +56 -0
  68. package/dist/combobox/use-combobox-form.mjs.map +1 -0
  69. package/dist/combobox/use-option-registry.mjs +62 -0
  70. package/dist/combobox/use-option-registry.mjs.map +1 -0
  71. package/dist/dialog/dialog-close.d.mts.map +1 -1
  72. package/dist/dialog/dialog-close.mjs +29 -62
  73. package/dist/dialog/dialog-close.mjs.map +1 -1
  74. package/dist/dialog/dialog-context.mjs.map +1 -1
  75. package/dist/dialog/dialog-form.d.mts.map +1 -1
  76. package/dist/dialog/dialog-form.mjs +5 -4
  77. package/dist/dialog/dialog-form.mjs.map +1 -1
  78. package/dist/dialog/dialog-popup.d.mts +3 -4
  79. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  80. package/dist/dialog/dialog-popup.mjs +37 -98
  81. package/dist/dialog/dialog-popup.mjs.map +1 -1
  82. package/dist/dialog/dialog-root.d.mts.map +1 -1
  83. package/dist/dialog/dialog-root.mjs +30 -118
  84. package/dist/dialog/dialog-root.mjs.map +1 -1
  85. package/dist/dialog/dialog-trigger.d.mts.map +1 -1
  86. package/dist/dialog/dialog-trigger.mjs +13 -16
  87. package/dist/dialog/dialog-trigger.mjs.map +1 -1
  88. package/dist/field/field-control.mjs +6 -13
  89. package/dist/field/field-control.mjs.map +1 -1
  90. package/dist/field/field-description.d.mts.map +1 -1
  91. package/dist/field/field-description.mjs +1 -2
  92. package/dist/field/field-description.mjs.map +1 -1
  93. package/dist/field/field-error.d.mts.map +1 -1
  94. package/dist/field/field-error.mjs +1 -2
  95. package/dist/field/field-error.mjs.map +1 -1
  96. package/dist/field/field-label.d.mts.map +1 -1
  97. package/dist/field/field-label.mjs +3 -11
  98. package/dist/field/field-label.mjs.map +1 -1
  99. package/dist/field/field-root.mjs +21 -41
  100. package/dist/field/field-root.mjs.map +1 -1
  101. package/dist/field/index.mjs +1 -1
  102. package/dist/field/use-server-error-visibility.mjs +44 -0
  103. package/dist/field/use-server-error-visibility.mjs.map +1 -0
  104. package/dist/form/form-root.d.mts.map +1 -1
  105. package/dist/form/form-root.mjs +6 -7
  106. package/dist/form/form-root.mjs.map +1 -1
  107. package/dist/form/form-submit.d.mts +1 -1
  108. package/dist/form/form-submit.mjs +4 -10
  109. package/dist/form/form-submit.mjs.map +1 -1
  110. package/dist/index.d.mts +2 -2
  111. package/dist/internal/anchor-position.mjs +1 -59
  112. package/dist/internal/anchor-position.mjs.map +1 -1
  113. package/dist/internal/announce.mjs.map +1 -1
  114. package/dist/internal/arrow-keys.mjs +21 -0
  115. package/dist/internal/arrow-keys.mjs.map +1 -0
  116. package/dist/internal/decimal.mjs +7 -1
  117. package/dist/internal/decimal.mjs.map +1 -1
  118. package/dist/internal/dom-order.mjs +17 -0
  119. package/dist/internal/dom-order.mjs.map +1 -0
  120. package/dist/internal/field-context.d.mts.map +1 -1
  121. package/dist/internal/field-context.mjs +11 -1
  122. package/dist/internal/field-context.mjs.map +1 -1
  123. package/dist/internal/focus-first-invalid.mjs +1 -1
  124. package/dist/internal/focus-first-invalid.mjs.map +1 -1
  125. package/dist/internal/group-member.mjs +37 -0
  126. package/dist/internal/group-member.mjs.map +1 -0
  127. package/dist/internal/overlay-popup.mjs +103 -0
  128. package/dist/internal/overlay-popup.mjs.map +1 -0
  129. package/dist/internal/popover-open.mjs +18 -0
  130. package/dist/internal/popover-open.mjs.map +1 -0
  131. package/dist/internal/render-element.d.mts +2 -0
  132. package/dist/internal/render-element.mjs +20 -2
  133. package/dist/internal/render-element.mjs.map +1 -1
  134. package/dist/internal/shipped-styles.mjs +14 -0
  135. package/dist/internal/shipped-styles.mjs.map +1 -0
  136. package/dist/internal/sync-presence.mjs +5 -1
  137. package/dist/internal/sync-presence.mjs.map +1 -1
  138. package/dist/internal/toolbar-context.mjs.map +1 -1
  139. package/dist/internal/tooltip-warm.mjs +1 -1
  140. package/dist/internal/tooltip-warm.mjs.map +1 -1
  141. package/dist/internal/transition-boundary.mjs +1 -1
  142. package/dist/internal/transition-boundary.mjs.map +1 -1
  143. package/dist/internal/types.d.mts +2 -0
  144. package/dist/internal/types.d.mts.map +1 -1
  145. package/dist/internal/use-action-trigger.mjs +5 -23
  146. package/dist/internal/use-action-trigger.mjs.map +1 -1
  147. package/dist/internal/use-checkable-input.mjs +79 -0
  148. package/dist/internal/use-checkable-input.mjs.map +1 -0
  149. package/dist/internal/use-controllable-action.mjs +16 -24
  150. package/dist/internal/use-controllable-action.mjs.map +1 -1
  151. package/dist/internal/use-dev-warning.mjs +8 -4
  152. package/dist/internal/use-dev-warning.mjs.map +1 -1
  153. package/dist/internal/use-element-check.mjs +39 -0
  154. package/dist/internal/use-element-check.mjs.map +1 -0
  155. package/dist/internal/use-exit-animation.mjs +1 -1
  156. package/dist/internal/use-exit-animation.mjs.map +1 -1
  157. package/dist/internal/use-field-control.mjs +28 -12
  158. package/dist/internal/use-field-control.mjs.map +1 -1
  159. package/dist/internal/use-fieldset-group.mjs +46 -0
  160. package/dist/internal/use-fieldset-group.mjs.map +1 -0
  161. package/dist/internal/use-form-reset.mjs +1 -5
  162. package/dist/internal/use-form-reset.mjs.map +1 -1
  163. package/dist/internal/use-item-order.mjs +42 -0
  164. package/dist/internal/use-item-order.mjs.map +1 -0
  165. package/dist/internal/use-latest.mjs +4 -8
  166. package/dist/internal/use-latest.mjs.map +1 -1
  167. package/dist/internal/use-merged-refs.mjs +19 -0
  168. package/dist/internal/use-merged-refs.mjs.map +1 -0
  169. package/dist/internal/use-name-warning.mjs +84 -0
  170. package/dist/internal/use-name-warning.mjs.map +1 -0
  171. package/dist/internal/use-native-checked.mjs +4 -6
  172. package/dist/internal/use-native-checked.mjs.map +1 -1
  173. package/dist/internal/use-native-focusgroup.mjs +19 -0
  174. package/dist/internal/use-native-focusgroup.mjs.map +1 -0
  175. package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
  176. package/dist/internal/use-overlay-close.mjs +63 -0
  177. package/dist/internal/use-overlay-close.mjs.map +1 -0
  178. package/dist/internal/{use-popover-root.mjs → use-overlay-root.mjs} +28 -39
  179. package/dist/internal/use-overlay-root.mjs.map +1 -0
  180. package/dist/internal/use-popover-popup.mjs +32 -78
  181. package/dist/internal/use-popover-popup.mjs.map +1 -1
  182. package/dist/internal/use-popover-trigger.d.mts +15 -0
  183. package/dist/internal/use-popover-trigger.d.mts.map +1 -0
  184. package/dist/internal/use-popover-trigger.mjs +13 -17
  185. package/dist/internal/use-popover-trigger.mjs.map +1 -1
  186. package/dist/internal/use-register-count.mjs +24 -0
  187. package/dist/internal/use-register-count.mjs.map +1 -0
  188. package/dist/internal/use-render.d.mts +2 -0
  189. package/dist/internal/use-render.mjs +2 -2
  190. package/dist/internal/use-render.mjs.map +1 -1
  191. package/dist/internal/use-resolved-placement.mjs +38 -22
  192. package/dist/internal/use-resolved-placement.mjs.map +1 -1
  193. package/dist/internal/use-roving-focus.mjs +5 -18
  194. package/dist/internal/use-roving-focus.mjs.map +1 -1
  195. package/dist/internal/use-superseded-rejection.mjs +47 -0
  196. package/dist/internal/use-superseded-rejection.mjs.map +1 -0
  197. package/dist/internal/validity.mjs +1 -13
  198. package/dist/internal/validity.mjs.map +1 -1
  199. package/dist/internal/value-set.mjs +41 -0
  200. package/dist/internal/value-set.mjs.map +1 -0
  201. package/dist/menu/index.d.mts +1 -1
  202. package/dist/menu/menu-checkbox-item.mjs.map +1 -1
  203. package/dist/menu/menu-context-trigger.d.mts +2 -7
  204. package/dist/menu/menu-context-trigger.d.mts.map +1 -1
  205. package/dist/menu/menu-context-trigger.mjs +10 -187
  206. package/dist/menu/menu-context-trigger.mjs.map +1 -1
  207. package/dist/menu/menu-context.d.mts +1 -1
  208. package/dist/menu/menu-context.mjs +1 -1
  209. package/dist/menu/menu-context.mjs.map +1 -1
  210. package/dist/menu/menu-dom.mjs +1 -2
  211. package/dist/menu/menu-dom.mjs.map +1 -1
  212. package/dist/menu/menu-gestures.mjs +167 -0
  213. package/dist/menu/menu-gestures.mjs.map +1 -0
  214. package/dist/menu/menu-group.d.mts.map +1 -1
  215. package/dist/menu/menu-group.mjs +2 -1
  216. package/dist/menu/menu-group.mjs.map +1 -1
  217. package/dist/menu/menu-hover.mjs +0 -1
  218. package/dist/menu/menu-hover.mjs.map +1 -1
  219. package/dist/menu/menu-item.mjs.map +1 -1
  220. package/dist/menu/menu-outside.mjs +101 -0
  221. package/dist/menu/menu-outside.mjs.map +1 -0
  222. package/dist/menu/menu-point.mjs +85 -0
  223. package/dist/menu/menu-point.mjs.map +1 -0
  224. package/dist/menu/menu-popup.d.mts +6 -7
  225. package/dist/menu/menu-popup.d.mts.map +1 -1
  226. package/dist/menu/menu-popup.mjs +37 -248
  227. package/dist/menu/menu-popup.mjs.map +1 -1
  228. package/dist/menu/menu-radio-group.mjs.map +1 -1
  229. package/dist/menu/menu-root.d.mts +10 -0
  230. package/dist/menu/menu-root.d.mts.map +1 -1
  231. package/dist/menu/menu-root.mjs +10 -8
  232. package/dist/menu/menu-root.mjs.map +1 -1
  233. package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
  234. package/dist/menu/menu-submenu-trigger.mjs +6 -6
  235. package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
  236. package/dist/menu/menu-trigger.d.mts +4 -9
  237. package/dist/menu/menu-trigger.d.mts.map +1 -1
  238. package/dist/menu/menu-trigger.mjs +8 -6
  239. package/dist/menu/menu-trigger.mjs.map +1 -1
  240. package/dist/menu/use-menu-item.mjs +14 -16
  241. package/dist/menu/use-menu-item.mjs.map +1 -1
  242. package/dist/menu/use-menu-keyboard.mjs +88 -0
  243. package/dist/menu/use-menu-keyboard.mjs.map +1 -0
  244. package/dist/meter/meter-root.mjs +1 -1
  245. package/dist/number-field/index.d.mts +2 -1
  246. package/dist/number-field/index.d.mts.map +1 -1
  247. package/dist/number-field/index.mjs +2 -2
  248. package/dist/number-field/index.mjs.map +1 -1
  249. package/dist/number-field/number-field-arithmetic.mjs +30 -11
  250. package/dist/number-field/number-field-arithmetic.mjs.map +1 -1
  251. package/dist/number-field/number-field-context.d.mts +6 -1
  252. package/dist/number-field/number-field-context.d.mts.map +1 -0
  253. package/dist/number-field/number-field-context.mjs.map +1 -1
  254. package/dist/number-field/number-field-decrement.d.mts +1 -1
  255. package/dist/number-field/number-field-decrement.mjs +1 -1
  256. package/dist/number-field/number-field-decrement.mjs.map +1 -1
  257. package/dist/number-field/number-field-increment.d.mts +2 -22
  258. package/dist/number-field/number-field-increment.d.mts.map +1 -1
  259. package/dist/number-field/number-field-increment.mjs +2 -53
  260. package/dist/number-field/number-field-increment.mjs.map +1 -1
  261. package/dist/number-field/number-field-input.d.mts.map +1 -1
  262. package/dist/number-field/number-field-input.mjs +18 -22
  263. package/dist/number-field/number-field-input.mjs.map +1 -1
  264. package/dist/number-field/number-field-label.d.mts.map +1 -1
  265. package/dist/number-field/number-field-label.mjs +3 -9
  266. package/dist/number-field/number-field-label.mjs.map +1 -1
  267. package/dist/number-field/number-field-root.d.mts +2 -1
  268. package/dist/number-field/number-field-root.d.mts.map +1 -1
  269. package/dist/number-field/number-field-root.mjs +81 -91
  270. package/dist/number-field/number-field-root.mjs.map +1 -1
  271. package/dist/number-field/use-number-field-dev-warnings.mjs +28 -0
  272. package/dist/number-field/use-number-field-dev-warnings.mjs.map +1 -0
  273. package/dist/number-field/use-step-button.d.mts +24 -0
  274. package/dist/number-field/use-step-button.d.mts.map +1 -0
  275. package/dist/number-field/use-step-button.mjs +57 -3
  276. package/dist/number-field/use-step-button.mjs.map +1 -1
  277. package/dist/popover/popover-close.d.mts.map +1 -1
  278. package/dist/popover/popover-close.mjs +28 -67
  279. package/dist/popover/popover-close.mjs.map +1 -1
  280. package/dist/popover/popover-context.mjs.map +1 -1
  281. package/dist/popover/popover-popup.d.mts +9 -6
  282. package/dist/popover/popover-popup.d.mts.map +1 -1
  283. package/dist/popover/popover-popup.mjs +13 -36
  284. package/dist/popover/popover-popup.mjs.map +1 -1
  285. package/dist/popover/popover-root.mjs +4 -3
  286. package/dist/popover/popover-root.mjs.map +1 -1
  287. package/dist/popover/popover-trigger.d.mts +4 -8
  288. package/dist/popover/popover-trigger.d.mts.map +1 -1
  289. package/dist/popover/popover-trigger.mjs +2 -1
  290. package/dist/popover/popover-trigger.mjs.map +1 -1
  291. package/dist/progress/progress-root.mjs +1 -1
  292. package/dist/radio-group/radio-group-context.mjs.map +1 -1
  293. package/dist/radio-group/radio-group-item.d.mts +3 -4
  294. package/dist/radio-group/radio-group-item.d.mts.map +1 -1
  295. package/dist/radio-group/radio-group-item.mjs +20 -25
  296. package/dist/radio-group/radio-group-item.mjs.map +1 -1
  297. package/dist/radio-group/radio-group-label.mjs +1 -6
  298. package/dist/radio-group/radio-group-label.mjs.map +1 -1
  299. package/dist/radio-group/radio-group-root.d.mts +1 -1
  300. package/dist/radio-group/radio-group-root.d.mts.map +1 -1
  301. package/dist/radio-group/radio-group-root.mjs +21 -40
  302. package/dist/radio-group/radio-group-root.mjs.map +1 -1
  303. package/dist/select/select-dom.mjs +9 -18
  304. package/dist/select/select-dom.mjs.map +1 -1
  305. package/dist/select/select-option.mjs +1 -1
  306. package/dist/select/select-root.mjs +3 -2
  307. package/dist/select/select-root.mjs.map +1 -1
  308. package/dist/slider/slider-arithmetic.mjs +74 -13
  309. package/dist/slider/slider-arithmetic.mjs.map +1 -1
  310. package/dist/slider/slider-context.mjs.map +1 -1
  311. package/dist/slider/slider-label.d.mts.map +1 -1
  312. package/dist/slider/slider-label.mjs +3 -9
  313. package/dist/slider/slider-label.mjs.map +1 -1
  314. package/dist/slider/slider-root.d.mts +2 -2
  315. package/dist/slider/slider-root.d.mts.map +1 -1
  316. package/dist/slider/slider-root.mjs +36 -116
  317. package/dist/slider/slider-root.mjs.map +1 -1
  318. package/dist/slider/slider-thumb.d.mts.map +1 -1
  319. package/dist/slider/slider-thumb.mjs +8 -6
  320. package/dist/slider/slider-thumb.mjs.map +1 -1
  321. package/dist/slider/slider-value.d.mts.map +1 -1
  322. package/dist/slider/slider-value.mjs +2 -1
  323. package/dist/slider/slider-value.mjs.map +1 -1
  324. package/dist/slider/use-slider-dev-warnings.mjs +29 -0
  325. package/dist/slider/use-slider-dev-warnings.mjs.map +1 -0
  326. package/dist/slider/use-thumb-registry.mjs +51 -0
  327. package/dist/slider/use-thumb-registry.mjs.map +1 -0
  328. package/dist/switch/switch.d.mts +4 -5
  329. package/dist/switch/switch.d.mts.map +1 -1
  330. package/dist/switch/switch.mjs +15 -55
  331. package/dist/switch/switch.mjs.map +1 -1
  332. package/dist/tabs/tabs-context.d.mts +2 -3
  333. package/dist/tabs/tabs-context.d.mts.map +1 -1
  334. package/dist/tabs/tabs-context.mjs.map +1 -1
  335. package/dist/tabs/tabs-list.d.mts.map +1 -1
  336. package/dist/tabs/tabs-list.mjs +9 -22
  337. package/dist/tabs/tabs-list.mjs.map +1 -1
  338. package/dist/tabs/tabs-panel.d.mts +3 -4
  339. package/dist/tabs/tabs-panel.d.mts.map +1 -1
  340. package/dist/tabs/tabs-panel.mjs.map +1 -1
  341. package/dist/tabs/tabs-root.d.mts +4 -3
  342. package/dist/tabs/tabs-root.d.mts.map +1 -1
  343. package/dist/tabs/tabs-root.mjs +2 -1
  344. package/dist/tabs/tabs-root.mjs.map +1 -1
  345. package/dist/tabs/tabs-tab.d.mts +3 -4
  346. package/dist/tabs/tabs-tab.d.mts.map +1 -1
  347. package/dist/tabs/tabs-tab.mjs.map +1 -1
  348. package/dist/toast/toast-action.mjs.map +1 -1
  349. package/dist/toast/toast-close.d.mts.map +1 -1
  350. package/dist/toast/toast-close.mjs +2 -8
  351. package/dist/toast/toast-close.mjs.map +1 -1
  352. package/dist/toast/toast-context.mjs.map +1 -1
  353. package/dist/toast/toast-hotkey.mjs +27 -0
  354. package/dist/toast/toast-hotkey.mjs.map +1 -0
  355. package/dist/toast/toast-queue.mjs +137 -0
  356. package/dist/toast/toast-queue.mjs.map +1 -0
  357. package/dist/toast/toast-timers.mjs +65 -0
  358. package/dist/toast/toast-timers.mjs.map +1 -0
  359. package/dist/toast/toast-viewport.d.mts.map +1 -1
  360. package/dist/toast/toast-viewport.mjs +30 -235
  361. package/dist/toast/toast-viewport.mjs.map +1 -1
  362. package/dist/toast/toast.mjs +1 -1
  363. package/dist/toast/toast.mjs.map +1 -1
  364. package/dist/toast/use-modal-portal-host.mjs +52 -0
  365. package/dist/toast/use-modal-portal-host.mjs.map +1 -0
  366. package/dist/toggle/toggle.d.mts +3 -4
  367. package/dist/toggle/toggle.d.mts.map +1 -1
  368. package/dist/toggle/toggle.mjs +7 -10
  369. package/dist/toggle/toggle.mjs.map +1 -1
  370. package/dist/toggle-group/toggle-group-context.d.mts +2 -1
  371. package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
  372. package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
  373. package/dist/toggle-group/toggle-group-item.d.mts +5 -3
  374. package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
  375. package/dist/toggle-group/toggle-group-item.mjs +5 -7
  376. package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
  377. package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
  378. package/dist/toggle-group/toggle-group-root.mjs +29 -64
  379. package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
  380. package/dist/toolbar/toolbar-root.d.mts +2 -2
  381. package/dist/toolbar/toolbar-root.d.mts.map +1 -1
  382. package/dist/toolbar/toolbar-root.mjs +3 -4
  383. package/dist/toolbar/toolbar-root.mjs.map +1 -1
  384. package/dist/tooltip/tooltip-context.d.mts +1 -1
  385. package/dist/tooltip/tooltip-context.mjs.map +1 -1
  386. package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
  387. package/dist/tooltip/tooltip-popup.mjs +6 -15
  388. package/dist/tooltip/tooltip-popup.mjs.map +1 -1
  389. package/dist/tooltip/tooltip-root.mjs +2 -2
  390. package/dist/tooltip/tooltip-root.mjs.map +1 -1
  391. package/dist/tooltip/tooltip-trigger.d.mts +2 -1
  392. package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
  393. package/dist/tooltip/tooltip-trigger.mjs +3 -2
  394. package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
  395. package/dist/tooltip/use-tooltip-interaction.mjs +4 -3
  396. package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
  397. package/package.json +3 -2
  398. package/dist/accordion/accordion-context.d.mts +0 -5
  399. package/dist/accordion/accordion-context.d.mts.map +0 -1
  400. package/dist/internal/use-popover-root.mjs.map +0 -1
  401. /package/dist/internal/{use-popover-root.d.mts → use-overlay-root.d.mts} +0 -0
@@ -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":";;;;;;;;;;;;;;AA0BA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AA0GvC,MAAM,wBAAkB,IAAI,IAAI;AAEhC,SAAS,MAAM,OAA6B;CAC1C,IAAI,UAAU,MAAM,OAAO;CAC3B,OAAO,OAAO,UAAU,2BAAW,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,KAAK;AACrE;;AAQA,SAAS,OAAO,KAAe,OAAwB;CACrD,MAAM,OAAO,IAAI,IAAI,GAAG;CACxB,KAAK,MAAM,KAAK,MAAM,SAAS,KAAK,OAAO,CAAC;CAC5C,KAAK,MAAM,KAAK,MAAM,OAAO,KAAK,IAAI,CAAC;CACvC,OAAO;AACT;;AAGA,SAAS,YAAY,QAA0B,OAAoC;CACjF,MAAM,SAAS,IAAI,IAAI,MAAM;CAC7B,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,KAAK,OAAO,IAAI,OAAO,OAAO,CAAC,GAAG,OAAO,KAAK,CAAC;CAC1D,KAAK,MAAM,KAAK,QAAQ,OAAO,KAAK,CAAC;CACrC,OAAO;AACT;AAEA,SAAS,YAAY,GAAsB,GAA+B;CACxE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,MAAM,EAAE,EAAE;AAC9D;AAEA,SAAS,gBAAgB,GAAS,GAAiB;CACjD,IAAI,MAAM,GAAG,OAAO;CACpB,OAAO,EAAE,wBAAwB,CAAC,IAAI,KAAK,8BAA8B,KAAK;AAChF;;AAGA,SAAS,aAAa,OAAwD;CAC5E,OAAO,MAAM,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G;CAEA,MAAM,QAA8B;EAAE,OAAO;EAAe;EAAS;EAAU;CAAY;CAE3F,MAAM,aAAa,OACf,WAAW,gBAAgB,aAAa,UAAU,SAAS,GAAG,OAAO,SAAS,SAAS,aACvF,KAAA;CAEJ,MAAM,UAAU,UAA8D;EAC5E,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,MAAM;GACN,oBAAoB;GACpB,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;GAElC,GAAI,CAAC,aAAa;GAClB,GAAI,eAAe,KAAA,KAAa,EAAE,WAAW;EAC/C;EACA,KAAK;CACP,CAAC;CAED,OAAO,oBAAC,oBAAD;EAAoB,OAAO;EAAU,UAAA;CAA4B,CAAA;AAC1E;AAEA,gBAAgB,cAAc"}
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":";;;;;;;;;;;;;;;;;;AAwBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;AA0GvC,SAAS,aAAa,OAAwD;CAC5E,OAAO,MAAM,MAAM,OAAO,GAAG,aAAa,cAAc,MAAM,MAAM,KAAK,MAAM;AACjF;AAOA,MAAM,YAA+B;CAAE,OAAO,CAAC;CAAG,UAAU,CAAC;AAAE;;;;;;;;;;AAW/D,SAAgB,gBAAgB,OAA6B;CAC3D,MAAM,EACJ,YAAY,OACZ,OACA,cACA,mBACA,eAAe,MACf,aAAa,iBACb,MAAM,UACN,WAAW,OACX,yBAAyB,gBACzB,WACA,OACA,UACA,QACA,GAAG,SACD;CAEJ,MAAM,UAAU,kBAAkB;CAClC,MAAM,YAAY,YAAY;CAC9B,cACE,aAAa,oBAAoB,KAAA,GACjC,SACE,gHAEJ;CACA,cACE,aAAa,aAAa,KAAA,GAC1B,SACE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AO,MAAM,WAAW,KAAK,OAAO,MAAM,SAAS,CAAC,MAAM,CAAC,OAAO,SAAS,SAAS,CAAC,CAC1F,KAAK,OACL;CAEN,MAAM,UAAU,OAA2B,IAAI;CAC/C,MAAM,SAAS,eAAe,SAAS;EACrC,SAAS,CAAC;EACV;EACA;EACA;EACA,OAAO;EACP,QAAQ;CACV,CAAC;CAED,MAAM,UAAU,eACP;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,QAA8B;EAAE,OAAO;EAAe;EAAS;EAAU;CAAY;CAE3F,MAAM,aAAa,OACf,WAAW,gBAAgB,aAAa,UAAU,SAAS,GAAG,OAAO,SAAS,SAAS,aACvF,KAAA;CAEJ,MAAM,UAAU,UAA8D;EAC5E,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,MAAM;GACN,oBAAoB;GACpB,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;GAElC,GAAI,CAAC,aAAa;GAClB,GAAI,eAAe,KAAA,KAAa,EAAE,WAAW;EAC/C;EACA,KAAK;CACP,CAAC;CAED,OAAO,oBAAC,oBAAD;EAAoB,OAAO;EAAU,UAAA;CAA4B,CAAA;AAC1E;AAEA,gBAAgB,cAAc"}
@@ -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");
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-trigger.mjs","names":[],"sources":["../../src/tooltip/tooltip-trigger.tsx"],"sourcesContent":["\"use client\";\nimport { use, useLayoutEffect } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { CSPContext } from \"../internal/csp-context.js\";\nimport { FSUI_PRECEDENCE } from \"../internal/anchor-position.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport {\n TOOLTIP_TRIGGER_MARKER,\n TOOLTIP_WARM_HREF,\n TOOLTIP_WARM_RULES,\n warmDelay,\n} from \"../internal/tooltip-warm.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { rendersButton, resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { useTooltipContext } from \"./tooltip-context.js\";\n\nexport interface TooltipTriggerState {\n readonly disabled: boolean;\n}\n\nexport interface TooltipTriggerProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"className\" | \"style\" | \"children\"\n> {\n /**\n * Experimental (Chromium 142+). Renders `interestfor` and `interest-delay-start/end` so the\n * browser owns hover, focus, Escape and long-press; the library's JS trigger path is skipped\n * where the rendered element implements `interestForElement`. No effect in other engines (the\n * attribute is ignored and the JS path runs). Pair with `Tooltip.Popup experimental_hint`.\n * Skip-delay on this path comes from a shipped rule: the Trigger renders the\n * `data-fsui-tooltip-trigger` marker, an `interest-delay-start` of\n * `calc(<delay>ms * (1 - var(--fsui-tooltip-warm, 0)))` and a hoisted\n * `<style href=\"@funstack/ui/tooltip-warm\">` (nonce from `<CSPProvider>`), rendered beside the\n * element so a `render` element with its own children keeps it. When that stylesheet is\n * missing (a CSP blocks it), the tooltip opens after its `delay` and only skip-delay is lost.\n * Default `false`.\n */\n experimental_interestFor?: boolean;\n className?: StateValue<string | undefined, TooltipTriggerState>;\n style?: StateValue<CSSProperties | undefined, TooltipTriggerState>;\n children?: StateValue<ReactNode, TooltipTriggerState>;\n render?: RenderProp<ComponentPropsWithRef<\"button\">, TooltipTriggerState>;\n}\n\n/**\n * The element the user hovers or focuses: a `<button type=\"button\">` by default. `render` may\n * substitute a link or a custom button; the element must be focusable (a dev warning fires when\n * it is not). A natively `disabled` button never opens a tooltip; use `aria-disabled` instead.\n *\n * The library attaches its hover / focus listeners with `addEventListener` from `Tooltip.Root`,\n * so every `on*` prop passes through untouched.\n *\n * Owned keys (conventions 1.2): `aria-describedby` (with `provides=\"description\"`) or\n * `aria-labelledby` (with `provides=\"name\"`), both token-merged with the consumer's ids;\n * `data-disabled`; and `interestfor` and `data-fsui-tooltip-trigger` when\n * `experimental_interestFor` is on.\n */\nexport function TooltipTrigger({\n experimental_interestFor = false,\n className,\n style,\n children,\n render,\n ...rest\n}: TooltipTriggerProps) {\n const ctx = useTooltipContext(\"Tooltip.Trigger\");\n const { disabled, popupId, provides, setInterestForRequested } = ctx;\n const native = experimental_interestFor && !disabled;\n const csp = use(CSPContext);\n\n useLayoutEffect(() => {\n setInterestForRequested(native);\n }, [native, setInterestForRequested]);\n\n const state: TooltipTriggerState = { disabled };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n // Only the relation in use is owned; the other one passes through untouched.\n ...(provides === \"name\" ? { \"aria-labelledby\": popupId } : { \"aria-describedby\": popupId }),\n \"data-disabled\": dataAttr(disabled),\n // Owned while the flag is on: a disabled tooltip removes the attribute, so the browser\n // cannot open it either. Unflagged, the key is omitted (conventions 1.2).\n ...(experimental_interestFor && {\n interestfor: native ? popupId : undefined,\n // What the shipped skip-delay rule matches (design 6); nothing else carries it.\n [TOOLTIP_TRIGGER_MARKER]: native ? \"\" : undefined,\n }),\n };\n\n // Skip-delay on the native path (design 6, conventions 12): the browser reads the delay from\n // the computed style when the hover starts, and only a rule can see that another tooltip is\n // showing. Hoisted into <head> by React (during SSR too) and deduplicated; nothing lands in\n // place. Rendered beside the element, not in its children: a `render` element with its own\n // children (`render={<a href>Text</a>}`) wins over `children` and would drop it.\n const warmRules = native ? (\n <style href={TOOLTIP_WARM_HREF} precedence={FSUI_PRECEDENCE} nonce={csp?.nonce}>\n {TOOLTIP_WARM_RULES}\n </style>\n ) : null;\n\n const element = useRender<ComponentPropsWithRef<\"button\">, TooltipTriggerState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n // The native delays sit under the consumer's style: the consumer wins. The open delay is 0\n // while another tooltip is showing (`--fsui-tooltip-warm`, design 6).\n style: native\n ? (s) => ({\n interestDelayStart: warmDelay(ctx.delay),\n interestDelayEnd: `${ctx.closeDelay}ms`,\n ...resolveStateValue(style, s),\n })\n : style,\n children,\n // `type=\"button\"` only on a real button (the consumer may override it); a link or a\n // component element does not get it.\n props: rendersButton(render) ? { type: \"button\", ...rest } : rest,\n libraryProps,\n ref: ctx.setTriggerElement,\n });\n return (\n <>\n {warmRules}\n {element}\n </>\n );\n}\n\nTooltipTrigger.displayName = \"TooltipTrigger\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,eAAe,EAC7B,2BAA2B,OAC3B,WACA,OACA,UACA,QACA,GAAG,QACmB;CACtB,MAAM,MAAM,kBAAkB,iBAAiB;CAC/C,MAAM,EAAE,UAAU,SAAS,UAAU,4BAA4B;CACjE,MAAM,SAAS,4BAA4B,CAAC;CAC5C,MAAM,MAAM,IAAI,UAAU;CAE1B,sBAAsB;EACpB,wBAAwB,MAAM;CAChC,GAAG,CAAC,QAAQ,uBAAuB,CAAC;CAEpC,MAAM,QAA6B,EAAE,SAAS;CAE9C,MAAM,eAAiE;EAErE,GAAI,aAAa,SAAS,EAAE,mBAAmB,QAAQ,IAAI,EAAE,oBAAoB,QAAQ;EACzF,iBAAiB,SAAS,QAAQ;EAGlC,GAAI,4BAA4B;GAC9B,aAAa,SAAS,UAAU,KAAA;IAEN,8BAAA,SAAS,KAAK,KAAA;EAC1C;CACF;CAOA,MAAM,YAAY,SAChB,oBAAC,SAAD;EAAO,MAAM;EAAmB,YAAY;EAAiB,OAAO,KAAK;EACtE,UAAA;CACI,CAAA,IACL;CAEJ,MAAM,UAAU,UAAgE;EAC9E,gBAAgB;EAChB;EACA;EACA;EAGA,OAAO,UACF,OAAO;GACN,oBAAoB,UAAU,IAAI,KAAK;GACvC,kBAAkB,GAAG,IAAI,WAAW;GACpC,GAAG,kBAAkB,OAAO,CAAC;EAC/B,KACA;EACJ;EAGA,OAAO,cAAc,MAAM,IAAI;GAAE,MAAM;GAAU,GAAG;EAAK,IAAI;EAC7D;EACA,KAAK,IAAI;CACX,CAAC;CACD,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,WACA,OACD,EAAA,CAAA;AAEN;AAEA,eAAe,cAAc"}
1
+ {"version":3,"file":"tooltip-trigger.mjs","names":[],"sources":["../../src/tooltip/tooltip-trigger.tsx"],"sourcesContent":["\"use client\";\nimport { use, useLayoutEffect } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { CSPContext } from \"../internal/csp-context.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { FSUI_PRECEDENCE } from \"../internal/shipped-styles.js\";\nimport {\n TOOLTIP_TRIGGER_MARKER,\n TOOLTIP_WARM_HREF,\n TOOLTIP_WARM_RULES,\n warmDelay,\n} from \"../internal/tooltip-warm.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { rendersButton, resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { useTooltipContext } from \"./tooltip-context.js\";\n\nexport interface TooltipTriggerState {\n readonly disabled: boolean;\n}\n\nexport interface TooltipTriggerProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"className\" | \"style\" | \"children\"\n> {\n /**\n * Experimental (Chromium 142+). Renders `interestfor` and `interest-delay-start/end` so the\n * browser owns hover, focus, Escape and long-press; the library's JS trigger path is skipped\n * where the rendered element implements `interestForElement`. No effect in other engines (the\n * attribute is ignored and the JS path runs). Pair with `Tooltip.Popup experimental_hint`.\n * Skip-delay on this path comes from a shipped rule: the Trigger renders the\n * `data-fsui-tooltip-trigger` marker, an `interest-delay-start` of\n * `calc(<delay>ms * (1 - var(--fsui-tooltip-warm, 0)))` and a hoisted\n * `<style href=\"@funstack/ui/tooltip-warm\">` (nonce from `<CSPProvider>`), rendered beside the\n * element so a `render` element with its own children keeps it. When that stylesheet is\n * missing (a CSP blocks it), the tooltip opens after its `delay` and only skip-delay is lost.\n * Default `false`.\n */\n experimental_interestFor?: boolean;\n className?: StateValue<string | undefined, TooltipTriggerState>;\n style?: StateValue<CSSProperties | undefined, TooltipTriggerState>;\n children?: StateValue<ReactNode, TooltipTriggerState>;\n render?: RenderProp<ComponentPropsWithRef<\"button\">, TooltipTriggerState>;\n}\n\n/**\n * The element the user hovers or focuses: a `<button type=\"button\">` by default. `render` may\n * substitute a link or a custom button; the element must be focusable (a dev warning fires when\n * it is not). A natively `disabled` button never opens a tooltip; use `aria-disabled` instead.\n *\n * The library attaches its hover / focus listeners with `addEventListener` from `Tooltip.Root`,\n * so every `on*` prop passes through untouched.\n *\n * Owned keys (conventions 1.2): `aria-describedby` (with `provides=\"description\"`) or\n * `aria-labelledby` (with `provides=\"name\"`), both token-merged with the consumer's ids;\n * `data-disabled`; and `interestfor` and `data-fsui-tooltip-trigger` when\n * `experimental_interestFor` is on. `type=\"button\"` is a default the consumer may override (the\n * part installs no click handler), unlike the overlay Triggers, which own it.\n */\nexport function TooltipTrigger({\n experimental_interestFor = false,\n className,\n style,\n children,\n render,\n ...rest\n}: TooltipTriggerProps) {\n const ctx = useTooltipContext(\"Tooltip.Trigger\");\n const { disabled, popupId, provides, setInterestForRequested } = ctx;\n const native = experimental_interestFor && !disabled;\n const csp = use(CSPContext);\n\n useLayoutEffect(() => {\n setInterestForRequested(native);\n }, [native, setInterestForRequested]);\n\n const state: TooltipTriggerState = { disabled };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n // Only the relation in use is owned; the other one passes through untouched.\n ...(provides === \"name\" ? { \"aria-labelledby\": popupId } : { \"aria-describedby\": popupId }),\n \"data-disabled\": dataAttr(disabled),\n // Owned while the flag is on: a disabled tooltip removes the attribute, so the browser\n // cannot open it either. Unflagged, the key is omitted (conventions 1.2).\n ...(experimental_interestFor && {\n interestfor: native ? popupId : undefined,\n // What the shipped skip-delay rule matches (design 6); nothing else carries it.\n [TOOLTIP_TRIGGER_MARKER]: native ? \"\" : undefined,\n }),\n };\n\n // Skip-delay on the native path (design 6, conventions 12): the browser reads the delay from\n // the computed style when the hover starts, and only a rule can see that another tooltip is\n // showing. Hoisted into <head> by React (during SSR too) and deduplicated; nothing lands in\n // place. Rendered beside the element, not in its children: a `render` element with its own\n // children (`render={<a href>Text</a>}`) wins over `children` and would drop it.\n const warmRules = native ? (\n <style href={TOOLTIP_WARM_HREF} precedence={FSUI_PRECEDENCE} nonce={csp?.nonce}>\n {TOOLTIP_WARM_RULES}\n </style>\n ) : null;\n\n const element = useRender<ComponentPropsWithRef<\"button\">, TooltipTriggerState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n // The native delays sit under the consumer's style: the consumer wins. The open delay is 0\n // while another tooltip is showing (`--fsui-tooltip-warm`, design 6).\n style: native\n ? (s) => ({\n interestDelayStart: warmDelay(ctx.delay),\n interestDelayEnd: `${ctx.closeDelay}ms`,\n ...resolveStateValue(style, s),\n })\n : style,\n children,\n // `type=\"button\"` only on a real button (the consumer may override it); a link or a\n // component element does not get it.\n props: rendersButton(render) ? { type: \"button\", ...rest } : rest,\n libraryProps,\n ref: ctx.setTriggerElement,\n });\n return (\n <>\n {warmRules}\n {element}\n </>\n );\n}\n\nTooltipTrigger.displayName = \"TooltipTrigger\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,SAAgB,eAAe,EAC7B,2BAA2B,OAC3B,WACA,OACA,UACA,QACA,GAAG,QACmB;CACtB,MAAM,MAAM,kBAAkB,iBAAiB;CAC/C,MAAM,EAAE,UAAU,SAAS,UAAU,4BAA4B;CACjE,MAAM,SAAS,4BAA4B,CAAC;CAC5C,MAAM,MAAM,IAAI,UAAU;CAE1B,sBAAsB;EACpB,wBAAwB,MAAM;CAChC,GAAG,CAAC,QAAQ,uBAAuB,CAAC;CAEpC,MAAM,QAA6B,EAAE,SAAS;CAE9C,MAAM,eAAiE;EAErE,GAAI,aAAa,SAAS,EAAE,mBAAmB,QAAQ,IAAI,EAAE,oBAAoB,QAAQ;EACzF,iBAAiB,SAAS,QAAQ;EAGlC,GAAI,4BAA4B;GAC9B,aAAa,SAAS,UAAU,KAAA;IAEN,8BAAA,SAAS,KAAK,KAAA;EAC1C;CACF;CAOA,MAAM,YAAY,SAChB,oBAAC,SAAD;EAAO,MAAM;EAAmB,YAAY;EAAiB,OAAO,KAAK;EACtE,UAAA;CACI,CAAA,IACL;CAEJ,MAAM,UAAU,UAAgE;EAC9E,gBAAgB;EAChB;EACA;EACA;EAGA,OAAO,UACF,OAAO;GACN,oBAAoB,UAAU,IAAI,KAAK;GACvC,kBAAkB,GAAG,IAAI,WAAW;GACpC,GAAG,kBAAkB,OAAO,CAAC;EAC/B,KACA;EACJ;EAGA,OAAO,cAAc,MAAM,IAAI;GAAE,MAAM;GAAU,GAAG;EAAK,IAAI;EAC7D;EACA,KAAK,IAAI;CACX,CAAC;CACD,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,WACA,OACD,EAAA,CAAA;AAEN;AAEA,eAAe,cAAc"}
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { isPopoverOpen } from "../internal/popover-open.mjs";
2
3
  import { syncPresence } from "../internal/sync-presence.mjs";
3
4
  import { createDelayedPair } from "../internal/use-delayed-pair.mjs";
4
5
  import { useEffect, useEffectEvent } from "react";
@@ -16,11 +17,11 @@ import { useEffect, useEffectEvent } from "react";
16
17
  * in which an Escape or pointerdown does nothing) and detached when `toggle` reports a close,
17
18
  * including closes the library did not perform (native light dismiss of `popover="hint"`).
18
19
  *
19
- * Skip-delay (design 6, wave 11): while another tooltip is showing anywhere in the document
20
+ * Skip-delay (design 6): while another tooltip is showing anywhere in the document
20
21
  * (`[role="tooltip"]:popover-open`, FUNSTACK's or not), a hover or keyboard focus hides it and
21
22
  * opens this one at once. Stateless: the DOM is read at the start of each hover or focus.
22
23
  *
23
- * Warm opens (design amendment for #93, wave 12): on **both** paths one `beforetoggle` listener on
24
+ * Warm opens (design, "Amendment: warm opens"): on **both** paths one `beforetoggle` listener on
24
25
  * the popup writes `data-instant` by presence: on an open, iff another tooltip is showing at that
25
26
  * moment (the skip-delay condition); on a close, never. `beforetoggle` is synchronous and precedes
26
27
  * the top-layer insertion, so the open's first style recalc already sees the attribute and
@@ -161,7 +162,7 @@ function otherOpenTooltip(doc, popup) {
161
162
  }
162
163
  /** The popover's top-layer state, read from the DOM. A removed popover is never open. */
163
164
  function isOpen(popup) {
164
- return popup.isConnected && popup.matches(":popover-open");
165
+ return popup.isConnected && isPopoverOpen(popup);
165
166
  }
166
167
  //#endregion
167
168
  export { useTooltipInteraction };
@@ -1 +1 @@
1
- {"version":3,"file":"use-tooltip-interaction.mjs","names":[],"sources":["../../src/tooltip/use-tooltip-interaction.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useEffectEvent } from \"react\";\nimport { syncPresence } from \"../internal/sync-presence.js\";\nimport { createDelayedPair } from \"../internal/use-delayed-pair.js\";\n\nexport interface TooltipInteractionOptions {\n readonly delay: number;\n readonly closeDelay: number;\n readonly disabled: boolean;\n /** The Trigger renders `interestfor` (flag on and not disabled). Re-runs the detection. */\n readonly interestForRequested: boolean;\n}\n\n/**\n * The cross-engine JS path of design section 2.2: hover / keyboard focus with delays,\n * `showPopover({ source })`, Escape and pointerdown-anywhere. Listeners go through\n * `addEventListener` (conventions 7.4) so they can be feature-detected away: where the trigger\n * renders `interestfor` and the element implements `interestForElement`, the browser owns the\n * whole interaction and nothing is attached.\n *\n * Open state is browser-owned (conventions 3.5): every decision reads\n * `popup.matches(\":popover-open\")`, never a copy. The document listeners are attached right after\n * `showPopover()` (the `toggle` event is queued as a task, so waiting for it would leave a window\n * in which an Escape or pointerdown does nothing) and detached when `toggle` reports a close,\n * including closes the library did not perform (native light dismiss of `popover=\"hint\"`).\n *\n * Skip-delay (design 6, wave 11): while another tooltip is showing anywhere in the document\n * (`[role=\"tooltip\"]:popover-open`, FUNSTACK's or not), a hover or keyboard focus hides it and\n * opens this one at once. Stateless: the DOM is read at the start of each hover or focus.\n *\n * Warm opens (design amendment for #93, wave 12): on **both** paths one `beforetoggle` listener on\n * the popup writes `data-instant` by presence: on an open, iff another tooltip is showing at that\n * moment (the skip-delay condition); on a close, never. `beforetoggle` is synchronous and precedes\n * the top-layer insertion, so the open's first style recalc already sees the attribute and\n * `.tip[data-instant] { transition: none }` creates no transition (a later write would start and\n * cancel one). A DOM write, never React state (conventions 7.4). This hook's only listener on the\n * native path (the popup also has `useResolvedPlacement`'s `toggle`); it handles and cancels\n * nothing.\n */\nexport function useTooltipInteraction(\n trigger: HTMLElement | null,\n popup: HTMLElement | null,\n options: TooltipInteractionOptions,\n): void {\n const getDelays = useEffectEvent(() => ({\n delay: options.delay,\n closeDelay: options.closeDelay,\n }));\n const { disabled, interestForRequested } = options;\n\n useEffect(() => {\n if (popup === null) return;\n // Attached before the `disabled` and native-path branches and removed last, so every open and\n // close (the library's below, the browser's, a consumer's through the ref) passes through it.\n const onBeforeToggle = (event: Event) => {\n const opening = (event as ToggleEvent).newState === \"open\";\n syncPresence(\n popup,\n \"data-instant\",\n opening && otherOpenTooltip(popup.ownerDocument, popup) !== null,\n );\n };\n popup.addEventListener(\"beforetoggle\", onBeforeToggle);\n // The effect event is called (from the timers this effect sets up), never passed itself.\n const detach = attachInteraction(trigger, popup, disabled, interestForRequested, () =>\n getDelays(),\n );\n return () => {\n detach?.();\n popup.removeEventListener(\"beforetoggle\", onBeforeToggle);\n };\n }, [trigger, popup, disabled, interestForRequested]);\n}\n\n/**\n * The rest of the effect: the JS path's interaction listeners, or nothing (disabled, no trigger,\n * the native path). Returns their cleanup, which hides an open popup first.\n */\nfunction attachInteraction(\n trigger: HTMLElement | null,\n popup: HTMLElement,\n disabled: boolean,\n interestForRequested: boolean,\n getDelays: () => { delay: number; closeDelay: number },\n): (() => void) | undefined {\n // Disabling while open hides the popup on both paths (design section 13, Disabled row). On the\n // JS path the previous run's cleanup already did; on the native path nothing else would, and\n // removing `interestfor` does not close an open popover.\n if (disabled) {\n if (isOpen(popup)) popup.hidePopover();\n return;\n }\n if (trigger === null) return;\n // Native path (conventions 8): only when the flag put `interestfor` on the element, and per\n // element, so a `render`ed `<span>` (no `interestForElement`) keeps the JS path. No\n // interaction listener is attached here (only the caller's `beforetoggle`), Escape included:\n // the browser's interest handling and the `hint` close watcher decide, so in Chromium an Escape that closes the tooltip may also close an enclosing modal\n // `<dialog>` (the library cannot `preventDefault()` a keydown it never sees).\n if (\n interestForRequested &&\n trigger.hasAttribute(\"interestfor\") &&\n \"interestForElement\" in trigger\n ) {\n return;\n }\n\n const doc = trigger.ownerDocument;\n // One pending open or close at a time (the timer helper shared with Menu's hover intent).\n const timers = createDelayedPair();\n const clear = timers.cancel;\n const show = () => {\n if (isOpen(popup) || !popup.isConnected || !trigger.isConnected) return;\n popup.showPopover({ source: trigger });\n listenDocument(true);\n };\n const hide = () => {\n // A removed popover is already hidden (`isOpen` is false), so this never throws.\n if (!isOpen(popup)) return;\n popup.hidePopover();\n listenDocument(false);\n };\n const showLater = () => {\n timers.open(getDelays().delay, show);\n };\n const hideLater = () => {\n timers.close(getDelays().closeDelay, hide);\n };\n const hideNow = () => {\n clear();\n hide();\n };\n // Another tooltip is showing: open now and hide it, else wait `delay` (design 6). Show first,\n // so this popup's `beforetoggle` still sees the other one open (`data-instant`): the DOM of\n // the native path, where `hint` stacking hides it inside `showPopover` after `beforetoggle`.\n // With `hint` here too that already happened and the guard skips the call. The other Root\n // sees its `toggle` and detaches; its pending close timer finds it closed.\n const showSoon = () => {\n const other = isOpen(popup) ? null : otherOpenTooltip(doc, popup);\n if (other === null) {\n showLater();\n return;\n }\n clear();\n show();\n if (isOpen(other)) other.hidePopover();\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\") return;\n clear();\n // Escape while closed passes through untouched.\n if (!isOpen(popup)) return;\n hide();\n // This Escape was the tooltip's: an enclosing modal `<dialog>` or `popover=\"auto\"` menu\n // stays open (the close request sees a canceled keydown). A second Escape reaches them.\n event.preventDefault();\n };\n function listenDocument(listen: boolean) {\n if (listen) {\n doc.addEventListener(\"keydown\", onKeyDown);\n doc.addEventListener(\"pointerdown\", hideNow, true);\n } else {\n doc.removeEventListener(\"keydown\", onKeyDown);\n doc.removeEventListener(\"pointerdown\", hideNow, true);\n }\n }\n // Follows opens and closes the library did not perform; reads the DOM, not `newState`, so a\n // toggle task that is stale by the time it runs cannot detach the listeners of an open popup.\n const onToggle = () => {\n listenDocument(isOpen(popup));\n };\n const onTriggerEnter = (event: PointerEvent) => {\n // No hover on touch; the ARIA relation still works for screen-reader focus (design 5.3).\n if (event.pointerType !== \"touch\") showSoon();\n };\n const onTriggerFocus = () => {\n // Pointer focus (a click) does not open; keyboard focus does (design 5.2).\n if (trigger.matches(\":focus-visible\")) showSoon();\n };\n // The document listeners exist only while the popup is open, so before that the trigger\n // itself cancels a pending open: a click or Escape before `delay` elapses must not open the\n // tooltip afterwards. Once open, the document listeners do the hiding.\n const onTriggerKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") clear();\n };\n\n trigger.addEventListener(\"pointerenter\", onTriggerEnter);\n trigger.addEventListener(\"pointerleave\", hideLater);\n trigger.addEventListener(\"pointerdown\", clear);\n trigger.addEventListener(\"keydown\", onTriggerKeyDown);\n trigger.addEventListener(\"focus\", onTriggerFocus);\n trigger.addEventListener(\"blur\", hideLater);\n popup.addEventListener(\"pointerenter\", clear);\n popup.addEventListener(\"pointerleave\", hideLater);\n popup.addEventListener(\"toggle\", onToggle);\n\n return () => {\n hideNow();\n listenDocument(false);\n trigger.removeEventListener(\"pointerenter\", onTriggerEnter);\n trigger.removeEventListener(\"pointerleave\", hideLater);\n trigger.removeEventListener(\"pointerdown\", clear);\n trigger.removeEventListener(\"keydown\", onTriggerKeyDown);\n trigger.removeEventListener(\"focus\", onTriggerFocus);\n trigger.removeEventListener(\"blur\", hideLater);\n popup.removeEventListener(\"pointerenter\", clear);\n popup.removeEventListener(\"pointerleave\", hideLater);\n popup.removeEventListener(\"toggle\", onToggle);\n };\n}\n\n/**\n * A tooltip popover other than `popup` that is showing in the document, or `null` (the warm\n * condition of design 6, the same one the native path's `:root:has()` rule reads). Walks the\n * tooltip popovers and asks each for `:popover-open` rather than one `querySelector`, which the\n * jsdom shim could not answer.\n */\nfunction otherOpenTooltip(doc: Document, popup: HTMLElement): HTMLElement | null {\n for (const element of doc.querySelectorAll<HTMLElement>('[role=\"tooltip\"][popover]')) {\n if (element !== popup && isOpen(element)) return element;\n }\n return null;\n}\n\n/** The popover's top-layer state, read from the DOM. A removed popover is never open. */\nfunction isOpen(popup: HTMLElement): boolean {\n return popup.isConnected && popup.matches(\":popover-open\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,sBACd,SACA,OACA,SACM;CACN,MAAM,YAAY,sBAAsB;EACtC,OAAO,QAAQ;EACf,YAAY,QAAQ;CACtB,EAAE;CACF,MAAM,EAAE,UAAU,yBAAyB;CAE3C,gBAAgB;EACd,IAAI,UAAU,MAAM;EAGpB,MAAM,kBAAkB,UAAiB;GACvC,MAAM,UAAW,MAAsB,aAAa;GACpD,aACE,OACA,gBACA,WAAW,iBAAiB,MAAM,eAAe,KAAK,MAAM,IAC9D;EACF;EACA,MAAM,iBAAiB,gBAAgB,cAAc;EAErD,MAAM,SAAS,kBAAkB,SAAS,OAAO,UAAU,4BACzD,UAAU,CACZ;EACA,aAAa;GACX,SAAS;GACT,MAAM,oBAAoB,gBAAgB,cAAc;EAC1D;CACF,GAAG;EAAC;EAAS;EAAO;EAAU;CAAoB,CAAC;AACrD;;;;;AAMA,SAAS,kBACP,SACA,OACA,UACA,sBACA,WAC0B;CAI1B,IAAI,UAAU;EACZ,IAAI,OAAO,KAAK,GAAG,MAAM,YAAY;EACrC;CACF;CACA,IAAI,YAAY,MAAM;CAMtB,IACE,wBACA,QAAQ,aAAa,aAAa,KAClC,wBAAwB,SAExB;CA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,QAAQ,QAAQ,gBAAgB,GAAG,SAAS;CAClD;CAIA,MAAM,oBAAoB,UAAyB;EACjD,IAAI,MAAM,QAAQ,UAAU,MAAM;CACpC;CAEA,QAAQ,iBAAiB,gBAAgB,cAAc;CACvD,QAAQ,iBAAiB,gBAAgB,SAAS;CAClD,QAAQ,iBAAiB,eAAe,KAAK;CAC7C,QAAQ,iBAAiB,WAAW,gBAAgB;CACpD,QAAQ,iBAAiB,SAAS,cAAc;CAChD,QAAQ,iBAAiB,QAAQ,SAAS;CAC1C,MAAM,iBAAiB,gBAAgB,KAAK;CAC5C,MAAM,iBAAiB,gBAAgB,SAAS;CAChD,MAAM,iBAAiB,UAAU,QAAQ;CAEzC,aAAa;EACX,QAAQ;EACR,eAAe,KAAK;EACpB,QAAQ,oBAAoB,gBAAgB,cAAc;EAC1D,QAAQ,oBAAoB,gBAAgB,SAAS;EACrD,QAAQ,oBAAoB,eAAe,KAAK;EAChD,QAAQ,oBAAoB,WAAW,gBAAgB;EACvD,QAAQ,oBAAoB,SAAS,cAAc;EACnD,QAAQ,oBAAoB,QAAQ,SAAS;EAC7C,MAAM,oBAAoB,gBAAgB,KAAK;EAC/C,MAAM,oBAAoB,gBAAgB,SAAS;EACnD,MAAM,oBAAoB,UAAU,QAAQ;CAC9C;AACF;;;;;;;AAQA,SAAS,iBAAiB,KAAe,OAAwC;CAC/E,KAAK,MAAM,WAAW,IAAI,iBAA8B,6BAA2B,GACjF,IAAI,YAAY,SAAS,OAAO,OAAO,GAAG,OAAO;CAEnD,OAAO;AACT;;AAGA,SAAS,OAAO,OAA6B;CAC3C,OAAO,MAAM,eAAe,MAAM,QAAQ,eAAe;AAC3D"}
1
+ {"version":3,"file":"use-tooltip-interaction.mjs","names":[],"sources":["../../src/tooltip/use-tooltip-interaction.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useEffectEvent } from \"react\";\nimport { isPopoverOpen } from \"../internal/popover-open.js\";\nimport { syncPresence } from \"../internal/sync-presence.js\";\nimport { createDelayedPair } from \"../internal/use-delayed-pair.js\";\n\nexport interface TooltipInteractionOptions {\n readonly delay: number;\n readonly closeDelay: number;\n readonly disabled: boolean;\n /** The Trigger renders `interestfor` (flag on and not disabled). Re-runs the detection. */\n readonly interestForRequested: boolean;\n}\n\n/**\n * The cross-engine JS path of design section 2.2: hover / keyboard focus with delays,\n * `showPopover({ source })`, Escape and pointerdown-anywhere. Listeners go through\n * `addEventListener` (conventions 7.4) so they can be feature-detected away: where the trigger\n * renders `interestfor` and the element implements `interestForElement`, the browser owns the\n * whole interaction and nothing is attached.\n *\n * Open state is browser-owned (conventions 3.5): every decision reads\n * `popup.matches(\":popover-open\")`, never a copy. The document listeners are attached right after\n * `showPopover()` (the `toggle` event is queued as a task, so waiting for it would leave a window\n * in which an Escape or pointerdown does nothing) and detached when `toggle` reports a close,\n * including closes the library did not perform (native light dismiss of `popover=\"hint\"`).\n *\n * Skip-delay (design 6): while another tooltip is showing anywhere in the document\n * (`[role=\"tooltip\"]:popover-open`, FUNSTACK's or not), a hover or keyboard focus hides it and\n * opens this one at once. Stateless: the DOM is read at the start of each hover or focus.\n *\n * Warm opens (design, \"Amendment: warm opens\"): on **both** paths one `beforetoggle` listener on\n * the popup writes `data-instant` by presence: on an open, iff another tooltip is showing at that\n * moment (the skip-delay condition); on a close, never. `beforetoggle` is synchronous and precedes\n * the top-layer insertion, so the open's first style recalc already sees the attribute and\n * `.tip[data-instant] { transition: none }` creates no transition (a later write would start and\n * cancel one). A DOM write, never React state (conventions 7.4). This hook's only listener on the\n * native path (the popup also has `useResolvedPlacement`'s `toggle`); it handles and cancels\n * nothing.\n */\nexport function useTooltipInteraction(\n trigger: HTMLElement | null,\n popup: HTMLElement | null,\n options: TooltipInteractionOptions,\n): void {\n const getDelays = useEffectEvent(() => ({\n delay: options.delay,\n closeDelay: options.closeDelay,\n }));\n const { disabled, interestForRequested } = options;\n\n useEffect(() => {\n if (popup === null) return;\n // Attached before the `disabled` and native-path branches and removed last, so every open and\n // close (the library's below, the browser's, a consumer's through the ref) passes through it.\n const onBeforeToggle = (event: Event) => {\n const opening = (event as ToggleEvent).newState === \"open\";\n syncPresence(\n popup,\n \"data-instant\",\n opening && otherOpenTooltip(popup.ownerDocument, popup) !== null,\n );\n };\n popup.addEventListener(\"beforetoggle\", onBeforeToggle);\n // The effect event is called (from the timers this effect sets up), never passed itself.\n const detach = attachInteraction(trigger, popup, disabled, interestForRequested, () =>\n getDelays(),\n );\n return () => {\n detach?.();\n popup.removeEventListener(\"beforetoggle\", onBeforeToggle);\n };\n }, [trigger, popup, disabled, interestForRequested]);\n}\n\n/**\n * The rest of the effect: the JS path's interaction listeners, or nothing (disabled, no trigger,\n * the native path). Returns their cleanup, which hides an open popup first.\n */\nfunction attachInteraction(\n trigger: HTMLElement | null,\n popup: HTMLElement,\n disabled: boolean,\n interestForRequested: boolean,\n getDelays: () => { delay: number; closeDelay: number },\n): (() => void) | undefined {\n // Disabling while open hides the popup on both paths (design section 13, Disabled row). On the\n // JS path the previous run's cleanup already did; on the native path nothing else would, and\n // removing `interestfor` does not close an open popover.\n if (disabled) {\n if (isOpen(popup)) popup.hidePopover();\n return;\n }\n if (trigger === null) return;\n // Native path (conventions 8): only when the flag put `interestfor` on the element, and per\n // element, so a `render`ed `<span>` (no `interestForElement`) keeps the JS path. No\n // interaction listener is attached here (only the caller's `beforetoggle`), Escape included:\n // the browser's interest handling and the `hint` close watcher decide, so in Chromium an Escape\n // that closes the tooltip may also close an enclosing modal `<dialog>` (the library cannot\n // `preventDefault()` a keydown it never sees).\n if (\n interestForRequested &&\n trigger.hasAttribute(\"interestfor\") &&\n \"interestForElement\" in trigger\n ) {\n return;\n }\n\n const doc = trigger.ownerDocument;\n // One pending open or close at a time (the timer helper shared with Menu's hover intent).\n const timers = createDelayedPair();\n const clear = timers.cancel;\n const show = () => {\n if (isOpen(popup) || !popup.isConnected || !trigger.isConnected) return;\n popup.showPopover({ source: trigger });\n listenDocument(true);\n };\n const hide = () => {\n // A removed popover is already hidden (`isOpen` is false), so this never throws.\n if (!isOpen(popup)) return;\n popup.hidePopover();\n listenDocument(false);\n };\n const showLater = () => {\n timers.open(getDelays().delay, show);\n };\n const hideLater = () => {\n timers.close(getDelays().closeDelay, hide);\n };\n const hideNow = () => {\n clear();\n hide();\n };\n // Another tooltip is showing: open now and hide it, else wait `delay` (design 6). Show first,\n // so this popup's `beforetoggle` still sees the other one open (`data-instant`): the DOM of\n // the native path, where `hint` stacking hides it inside `showPopover` after `beforetoggle`.\n // With `hint` here too that already happened and the guard skips the call. The other Root\n // sees its `toggle` and detaches; its pending close timer finds it closed.\n const showSoon = () => {\n const other = isOpen(popup) ? null : otherOpenTooltip(doc, popup);\n if (other === null) {\n showLater();\n return;\n }\n clear();\n show();\n if (isOpen(other)) other.hidePopover();\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\") return;\n clear();\n // Escape while closed passes through untouched.\n if (!isOpen(popup)) return;\n hide();\n // This Escape was the tooltip's: an enclosing modal `<dialog>` or `popover=\"auto\"` menu\n // stays open (the close request sees a canceled keydown). A second Escape reaches them.\n event.preventDefault();\n };\n function listenDocument(listen: boolean) {\n if (listen) {\n doc.addEventListener(\"keydown\", onKeyDown);\n doc.addEventListener(\"pointerdown\", hideNow, true);\n } else {\n doc.removeEventListener(\"keydown\", onKeyDown);\n doc.removeEventListener(\"pointerdown\", hideNow, true);\n }\n }\n // Follows opens and closes the library did not perform; reads the DOM, not `newState`, so a\n // toggle task that is stale by the time it runs cannot detach the listeners of an open popup.\n const onToggle = () => {\n listenDocument(isOpen(popup));\n };\n const onTriggerEnter = (event: PointerEvent) => {\n // No hover on touch; the ARIA relation still works for screen-reader focus (design 5.3).\n if (event.pointerType !== \"touch\") showSoon();\n };\n const onTriggerFocus = () => {\n // Pointer focus (a click) does not open; keyboard focus does (design 5.2).\n if (trigger.matches(\":focus-visible\")) showSoon();\n };\n // The document listeners exist only while the popup is open, so before that the trigger\n // itself cancels a pending open: a click or Escape before `delay` elapses must not open the\n // tooltip afterwards. Once open, the document listeners do the hiding.\n const onTriggerKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") clear();\n };\n\n trigger.addEventListener(\"pointerenter\", onTriggerEnter);\n trigger.addEventListener(\"pointerleave\", hideLater);\n trigger.addEventListener(\"pointerdown\", clear);\n trigger.addEventListener(\"keydown\", onTriggerKeyDown);\n trigger.addEventListener(\"focus\", onTriggerFocus);\n trigger.addEventListener(\"blur\", hideLater);\n popup.addEventListener(\"pointerenter\", clear);\n popup.addEventListener(\"pointerleave\", hideLater);\n popup.addEventListener(\"toggle\", onToggle);\n\n return () => {\n hideNow();\n listenDocument(false);\n trigger.removeEventListener(\"pointerenter\", onTriggerEnter);\n trigger.removeEventListener(\"pointerleave\", hideLater);\n trigger.removeEventListener(\"pointerdown\", clear);\n trigger.removeEventListener(\"keydown\", onTriggerKeyDown);\n trigger.removeEventListener(\"focus\", onTriggerFocus);\n trigger.removeEventListener(\"blur\", hideLater);\n popup.removeEventListener(\"pointerenter\", clear);\n popup.removeEventListener(\"pointerleave\", hideLater);\n popup.removeEventListener(\"toggle\", onToggle);\n };\n}\n\n/**\n * A tooltip popover other than `popup` that is showing in the document, or `null` (the warm\n * condition of design 6, the same one the native path's `:root:has()` rule reads). Walks the\n * tooltip popovers and asks each for `:popover-open` rather than one `querySelector`, which the\n * jsdom shim could not answer.\n */\nfunction otherOpenTooltip(doc: Document, popup: HTMLElement): HTMLElement | null {\n for (const element of doc.querySelectorAll<HTMLElement>('[role=\"tooltip\"][popover]')) {\n if (element !== popup && isOpen(element)) return element;\n }\n return null;\n}\n\n/** The popover's top-layer state, read from the DOM. A removed popover is never open. */\nfunction isOpen(popup: HTMLElement): boolean {\n return popup.isConnected && isPopoverOpen(popup);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,sBACd,SACA,OACA,SACM;CACN,MAAM,YAAY,sBAAsB;EACtC,OAAO,QAAQ;EACf,Y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QAAQ,oBAAoB,WAAW,gBAAgB;EACvD,QAAQ,oBAAoB,SAAS,cAAc;EACnD,QAAQ,oBAAoB,QAAQ,SAAS;EAC7C,MAAM,oBAAoB,gBAAgB,KAAK;EAC/C,MAAM,oBAAoB,gBAAgB,SAAS;EACnD,MAAM,oBAAoB,UAAU,QAAQ;CAC9C;AACF;;;;;;;AAQA,SAAS,iBAAiB,KAAe,OAAwC;CAC/E,KAAK,MAAM,WAAW,IAAI,iBAA8B,6BAA2B,GACjF,IAAI,YAAY,SAAS,OAAO,OAAO,GAAG,OAAO;CAEnD,OAAO;AACT;;AAGA,SAAS,OAAO,OAA6B;CAC3C,OAAO,MAAM,eAAe,cAAc,KAAK;AACjD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funstack/ui",
3
- "version": "0.1.0-alpha.11",
3
+ "version": "0.1.0-alpha.12",
4
4
  "description": "Headless UI library for React — the first Async React-native UI library",
5
5
  "keywords": [
6
6
  "components",
@@ -68,6 +68,7 @@
68
68
  "playwright": "^1.64.1",
69
69
  "react": "^19.3.1",
70
70
  "react-dom": "^19.3.1",
71
+ "rolldown": "1.2.14",
71
72
  "tsdown": "^0.23.1",
72
73
  "typescript": "^7.0.2",
73
74
  "vitest": "^5.0.5"
@@ -81,7 +82,7 @@
81
82
  "dev": "tsdown --watch",
82
83
  "test": "vitest",
83
84
  "test:run": "vitest run",
84
- "test:jsdom": "vitest run --project jsdom",
85
+ "test:jsdom": "vitest run --project jsdom --project jsdom-isolated",
85
86
  "test:browser": "vitest run --project browser",
86
87
  "test:browser:dev": "vitest --project browser --browser.headless=false",
87
88
  "typecheck": "tsc --noEmit"
@@ -1,5 +0,0 @@
1
- //#region src/accordion/accordion-context.d.ts
2
- /** Why a change was dispatched (design 2.2 / 2.3). */
3
- export type AccordionChangeReason = "activate" | "platform";
4
- //#endregion
5
- //# sourceMappingURL=accordion-context.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"accordion-context.d.mts","names":[],"sources":["../../src/accordion/accordion-context.ts"],"mappings":";;YAIY"}