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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. package/dist/accordion/accordion-context.mjs.map +1 -1
  2. package/dist/accordion/accordion-item.d.mts +3 -4
  3. package/dist/accordion/accordion-item.d.mts.map +1 -1
  4. package/dist/accordion/accordion-item.mjs +10 -4
  5. package/dist/accordion/accordion-item.mjs.map +1 -1
  6. package/dist/accordion/accordion-panel.d.mts +3 -4
  7. package/dist/accordion/accordion-panel.d.mts.map +1 -1
  8. package/dist/accordion/accordion-panel.mjs +2 -1
  9. package/dist/accordion/accordion-panel.mjs.map +1 -1
  10. package/dist/accordion/accordion-root.d.mts +3 -3
  11. package/dist/accordion/accordion-root.d.mts.map +1 -1
  12. package/dist/accordion/accordion-root.mjs +8 -19
  13. package/dist/accordion/accordion-root.mjs.map +1 -1
  14. package/dist/accordion/accordion-trigger.d.mts +3 -4
  15. package/dist/accordion/accordion-trigger.d.mts.map +1 -1
  16. package/dist/accordion/accordion-trigger.mjs +5 -3
  17. package/dist/accordion/accordion-trigger.mjs.map +1 -1
  18. package/dist/button/button.d.mts +4 -2
  19. package/dist/button/button.d.mts.map +1 -1
  20. package/dist/button/button.mjs +3 -2
  21. package/dist/button/button.mjs.map +1 -1
  22. package/dist/checkbox/checkbox.d.mts +4 -5
  23. package/dist/checkbox/checkbox.d.mts.map +1 -1
  24. package/dist/checkbox/checkbox.mjs +16 -59
  25. package/dist/checkbox/checkbox.mjs.map +1 -1
  26. package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
  27. package/dist/checkbox-group/checkbox-group-item.d.mts +3 -4
  28. package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
  29. package/dist/checkbox-group/checkbox-group-item.mjs +21 -27
  30. package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
  31. package/dist/checkbox-group/checkbox-group-label.mjs +1 -6
  32. package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
  33. package/dist/checkbox-group/checkbox-group-parent.d.mts +3 -4
  34. package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
  35. package/dist/checkbox-group/checkbox-group-parent.mjs +12 -10
  36. package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
  37. package/dist/checkbox-group/checkbox-group-root.d.mts +1 -1
  38. package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
  39. package/dist/checkbox-group/checkbox-group-root.mjs +74 -101
  40. package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
  41. package/dist/combobox/combobox-clear.d.mts.map +1 -1
  42. package/dist/combobox/combobox-clear.mjs +5 -6
  43. package/dist/combobox/combobox-clear.mjs.map +1 -1
  44. package/dist/combobox/combobox-context.mjs.map +1 -1
  45. package/dist/combobox/combobox-group.d.mts.map +1 -1
  46. package/dist/combobox/combobox-group.mjs +2 -1
  47. package/dist/combobox/combobox-group.mjs.map +1 -1
  48. package/dist/combobox/combobox-input.d.mts.map +1 -1
  49. package/dist/combobox/combobox-input.mjs +14 -7
  50. package/dist/combobox/combobox-input.mjs.map +1 -1
  51. package/dist/combobox/combobox-list.d.mts.map +1 -1
  52. package/dist/combobox/combobox-list.mjs +6 -10
  53. package/dist/combobox/combobox-list.mjs.map +1 -1
  54. package/dist/combobox/combobox-option.d.mts.map +1 -1
  55. package/dist/combobox/combobox-option.mjs +2 -1
  56. package/dist/combobox/combobox-option.mjs.map +1 -1
  57. package/dist/combobox/combobox-popup.d.mts.map +1 -1
  58. package/dist/combobox/combobox-popup.mjs +9 -25
  59. package/dist/combobox/combobox-popup.mjs.map +1 -1
  60. package/dist/combobox/combobox-root.d.mts +11 -10
  61. package/dist/combobox/combobox-root.d.mts.map +1 -1
  62. package/dist/combobox/combobox-root.mjs +37 -109
  63. package/dist/combobox/combobox-root.mjs.map +1 -1
  64. package/dist/combobox/combobox-trigger.d.mts.map +1 -1
  65. package/dist/combobox/combobox-trigger.mjs +6 -25
  66. package/dist/combobox/combobox-trigger.mjs.map +1 -1
  67. package/dist/combobox/index.d.mts +2 -2
  68. package/dist/combobox/index.mjs +3 -3
  69. package/dist/combobox/index.mjs.map +1 -1
  70. package/dist/combobox/use-combobox-form.mjs +56 -0
  71. package/dist/combobox/use-combobox-form.mjs.map +1 -0
  72. package/dist/combobox/use-option-registry.mjs +62 -0
  73. package/dist/combobox/use-option-registry.mjs.map +1 -0
  74. package/dist/dialog/dialog-close.d.mts.map +1 -1
  75. package/dist/dialog/dialog-close.mjs +29 -62
  76. package/dist/dialog/dialog-close.mjs.map +1 -1
  77. package/dist/dialog/dialog-context.mjs.map +1 -1
  78. package/dist/dialog/dialog-form.d.mts.map +1 -1
  79. package/dist/dialog/dialog-form.mjs +5 -4
  80. package/dist/dialog/dialog-form.mjs.map +1 -1
  81. package/dist/dialog/dialog-popup.d.mts +3 -4
  82. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  83. package/dist/dialog/dialog-popup.mjs +37 -98
  84. package/dist/dialog/dialog-popup.mjs.map +1 -1
  85. package/dist/dialog/dialog-root.d.mts.map +1 -1
  86. package/dist/dialog/dialog-root.mjs +30 -118
  87. package/dist/dialog/dialog-root.mjs.map +1 -1
  88. package/dist/dialog/dialog-trigger.d.mts.map +1 -1
  89. package/dist/dialog/dialog-trigger.mjs +13 -16
  90. package/dist/dialog/dialog-trigger.mjs.map +1 -1
  91. package/dist/field/field-control.mjs +6 -13
  92. package/dist/field/field-control.mjs.map +1 -1
  93. package/dist/field/field-description.d.mts.map +1 -1
  94. package/dist/field/field-description.mjs +1 -2
  95. package/dist/field/field-description.mjs.map +1 -1
  96. package/dist/field/field-error.d.mts.map +1 -1
  97. package/dist/field/field-error.mjs +1 -2
  98. package/dist/field/field-error.mjs.map +1 -1
  99. package/dist/field/field-label.d.mts.map +1 -1
  100. package/dist/field/field-label.mjs +3 -11
  101. package/dist/field/field-label.mjs.map +1 -1
  102. package/dist/field/field-root.mjs +21 -41
  103. package/dist/field/field-root.mjs.map +1 -1
  104. package/dist/field/index.mjs +1 -1
  105. package/dist/field/use-server-error-visibility.mjs +44 -0
  106. package/dist/field/use-server-error-visibility.mjs.map +1 -0
  107. package/dist/form/form-root.d.mts.map +1 -1
  108. package/dist/form/form-root.mjs +6 -7
  109. package/dist/form/form-root.mjs.map +1 -1
  110. package/dist/form/form-submit.d.mts +1 -1
  111. package/dist/form/form-submit.mjs +4 -10
  112. package/dist/form/form-submit.mjs.map +1 -1
  113. package/dist/index.d.mts +4 -4
  114. package/dist/internal/anchor-position.mjs +1 -59
  115. package/dist/internal/anchor-position.mjs.map +1 -1
  116. package/dist/internal/announce.mjs.map +1 -1
  117. package/dist/internal/arrow-keys.mjs +21 -0
  118. package/dist/internal/arrow-keys.mjs.map +1 -0
  119. package/dist/internal/decimal.mjs +7 -1
  120. package/dist/internal/decimal.mjs.map +1 -1
  121. package/dist/internal/dom-order.mjs +17 -0
  122. package/dist/internal/dom-order.mjs.map +1 -0
  123. package/dist/internal/field-context.d.mts.map +1 -1
  124. package/dist/internal/field-context.mjs +11 -1
  125. package/dist/internal/field-context.mjs.map +1 -1
  126. package/dist/internal/focus-first-invalid.mjs +1 -1
  127. package/dist/internal/focus-first-invalid.mjs.map +1 -1
  128. package/dist/internal/group-member.mjs +37 -0
  129. package/dist/internal/group-member.mjs.map +1 -0
  130. package/dist/internal/overlay-popup.mjs +103 -0
  131. package/dist/internal/overlay-popup.mjs.map +1 -0
  132. package/dist/internal/popover-open.mjs +18 -0
  133. package/dist/internal/popover-open.mjs.map +1 -0
  134. package/dist/internal/render-element.d.mts +2 -0
  135. package/dist/internal/render-element.mjs +20 -2
  136. package/dist/internal/render-element.mjs.map +1 -1
  137. package/dist/internal/shipped-styles.mjs +14 -0
  138. package/dist/internal/shipped-styles.mjs.map +1 -0
  139. package/dist/internal/sync-presence.mjs +5 -1
  140. package/dist/internal/sync-presence.mjs.map +1 -1
  141. package/dist/internal/toolbar-context.mjs.map +1 -1
  142. package/dist/internal/tooltip-warm.mjs +1 -1
  143. package/dist/internal/tooltip-warm.mjs.map +1 -1
  144. package/dist/internal/transition-boundary.mjs +1 -1
  145. package/dist/internal/transition-boundary.mjs.map +1 -1
  146. package/dist/internal/types.d.mts +8 -6
  147. package/dist/internal/types.d.mts.map +1 -1
  148. package/dist/internal/use-action-trigger.mjs +5 -23
  149. package/dist/internal/use-action-trigger.mjs.map +1 -1
  150. package/dist/internal/use-checkable-input.mjs +79 -0
  151. package/dist/internal/use-checkable-input.mjs.map +1 -0
  152. package/dist/internal/use-controllable-action.mjs +16 -24
  153. package/dist/internal/use-controllable-action.mjs.map +1 -1
  154. package/dist/internal/use-dev-warning.mjs +8 -4
  155. package/dist/internal/use-dev-warning.mjs.map +1 -1
  156. package/dist/internal/use-element-check.mjs +39 -0
  157. package/dist/internal/use-element-check.mjs.map +1 -0
  158. package/dist/internal/use-exit-animation.mjs +1 -1
  159. package/dist/internal/use-exit-animation.mjs.map +1 -1
  160. package/dist/internal/use-field-control.mjs +28 -12
  161. package/dist/internal/use-field-control.mjs.map +1 -1
  162. package/dist/internal/use-fieldset-group.mjs +46 -0
  163. package/dist/internal/use-fieldset-group.mjs.map +1 -0
  164. package/dist/internal/use-form-reset.mjs +1 -5
  165. package/dist/internal/use-form-reset.mjs.map +1 -1
  166. package/dist/internal/use-item-order.mjs +42 -0
  167. package/dist/internal/use-item-order.mjs.map +1 -0
  168. package/dist/internal/use-latest.mjs +4 -8
  169. package/dist/internal/use-latest.mjs.map +1 -1
  170. package/dist/internal/use-merged-refs.mjs +19 -0
  171. package/dist/internal/use-merged-refs.mjs.map +1 -0
  172. package/dist/internal/use-name-warning.mjs +84 -0
  173. package/dist/internal/use-name-warning.mjs.map +1 -0
  174. package/dist/internal/use-native-checked.mjs +4 -6
  175. package/dist/internal/use-native-checked.mjs.map +1 -1
  176. package/dist/internal/use-native-focusgroup.mjs +19 -0
  177. package/dist/internal/use-native-focusgroup.mjs.map +1 -0
  178. package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
  179. package/dist/internal/use-overlay-close.mjs +63 -0
  180. package/dist/internal/use-overlay-close.mjs.map +1 -0
  181. package/dist/internal/{use-popover-root.mjs → use-overlay-root.mjs} +28 -39
  182. package/dist/internal/use-overlay-root.mjs.map +1 -0
  183. package/dist/internal/use-popover-popup.mjs +32 -78
  184. package/dist/internal/use-popover-popup.mjs.map +1 -1
  185. package/dist/internal/use-popover-trigger.d.mts +15 -0
  186. package/dist/internal/use-popover-trigger.d.mts.map +1 -0
  187. package/dist/internal/use-popover-trigger.mjs +13 -17
  188. package/dist/internal/use-popover-trigger.mjs.map +1 -1
  189. package/dist/internal/use-register-count.mjs +24 -0
  190. package/dist/internal/use-register-count.mjs.map +1 -0
  191. package/dist/internal/use-render.d.mts +2 -0
  192. package/dist/internal/use-render.mjs +2 -2
  193. package/dist/internal/use-render.mjs.map +1 -1
  194. package/dist/internal/use-resolved-placement.mjs +38 -22
  195. package/dist/internal/use-resolved-placement.mjs.map +1 -1
  196. package/dist/internal/use-roving-focus.mjs +5 -18
  197. package/dist/internal/use-roving-focus.mjs.map +1 -1
  198. package/dist/internal/use-superseded-rejection.mjs +47 -0
  199. package/dist/internal/use-superseded-rejection.mjs.map +1 -0
  200. package/dist/internal/validity.mjs +1 -13
  201. package/dist/internal/validity.mjs.map +1 -1
  202. package/dist/internal/value-set.mjs +41 -0
  203. package/dist/internal/value-set.mjs.map +1 -0
  204. package/dist/menu/index.d.mts +1 -1
  205. package/dist/menu/menu-checkbox-item.mjs.map +1 -1
  206. package/dist/menu/menu-context-trigger.d.mts +2 -7
  207. package/dist/menu/menu-context-trigger.d.mts.map +1 -1
  208. package/dist/menu/menu-context-trigger.mjs +10 -187
  209. package/dist/menu/menu-context-trigger.mjs.map +1 -1
  210. package/dist/menu/menu-context.d.mts +1 -1
  211. package/dist/menu/menu-context.mjs +1 -1
  212. package/dist/menu/menu-context.mjs.map +1 -1
  213. package/dist/menu/menu-dom.mjs +1 -2
  214. package/dist/menu/menu-dom.mjs.map +1 -1
  215. package/dist/menu/menu-gestures.mjs +167 -0
  216. package/dist/menu/menu-gestures.mjs.map +1 -0
  217. package/dist/menu/menu-group.d.mts.map +1 -1
  218. package/dist/menu/menu-group.mjs +2 -1
  219. package/dist/menu/menu-group.mjs.map +1 -1
  220. package/dist/menu/menu-hover.mjs +0 -1
  221. package/dist/menu/menu-hover.mjs.map +1 -1
  222. package/dist/menu/menu-item.mjs.map +1 -1
  223. package/dist/menu/menu-outside.mjs +101 -0
  224. package/dist/menu/menu-outside.mjs.map +1 -0
  225. package/dist/menu/menu-point.mjs +85 -0
  226. package/dist/menu/menu-point.mjs.map +1 -0
  227. package/dist/menu/menu-popup.d.mts +6 -7
  228. package/dist/menu/menu-popup.d.mts.map +1 -1
  229. package/dist/menu/menu-popup.mjs +37 -248
  230. package/dist/menu/menu-popup.mjs.map +1 -1
  231. package/dist/menu/menu-radio-group.mjs.map +1 -1
  232. package/dist/menu/menu-root.d.mts +10 -0
  233. package/dist/menu/menu-root.d.mts.map +1 -1
  234. package/dist/menu/menu-root.mjs +10 -8
  235. package/dist/menu/menu-root.mjs.map +1 -1
  236. package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
  237. package/dist/menu/menu-submenu-trigger.mjs +6 -6
  238. package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
  239. package/dist/menu/menu-trigger.d.mts +4 -9
  240. package/dist/menu/menu-trigger.d.mts.map +1 -1
  241. package/dist/menu/menu-trigger.mjs +8 -6
  242. package/dist/menu/menu-trigger.mjs.map +1 -1
  243. package/dist/menu/use-menu-item.mjs +14 -16
  244. package/dist/menu/use-menu-item.mjs.map +1 -1
  245. package/dist/menu/use-menu-keyboard.mjs +88 -0
  246. package/dist/menu/use-menu-keyboard.mjs.map +1 -0
  247. package/dist/meter/meter-root.mjs +1 -1
  248. package/dist/number-field/index.d.mts +2 -1
  249. package/dist/number-field/index.d.mts.map +1 -1
  250. package/dist/number-field/index.mjs +2 -2
  251. package/dist/number-field/index.mjs.map +1 -1
  252. package/dist/number-field/number-field-arithmetic.mjs +30 -11
  253. package/dist/number-field/number-field-arithmetic.mjs.map +1 -1
  254. package/dist/number-field/number-field-context.d.mts +6 -1
  255. package/dist/number-field/number-field-context.d.mts.map +1 -0
  256. package/dist/number-field/number-field-context.mjs.map +1 -1
  257. package/dist/number-field/number-field-decrement.d.mts +1 -1
  258. package/dist/number-field/number-field-decrement.mjs +1 -1
  259. package/dist/number-field/number-field-decrement.mjs.map +1 -1
  260. package/dist/number-field/number-field-increment.d.mts +2 -22
  261. package/dist/number-field/number-field-increment.d.mts.map +1 -1
  262. package/dist/number-field/number-field-increment.mjs +2 -53
  263. package/dist/number-field/number-field-increment.mjs.map +1 -1
  264. package/dist/number-field/number-field-input.d.mts.map +1 -1
  265. package/dist/number-field/number-field-input.mjs +18 -22
  266. package/dist/number-field/number-field-input.mjs.map +1 -1
  267. package/dist/number-field/number-field-label.d.mts.map +1 -1
  268. package/dist/number-field/number-field-label.mjs +3 -9
  269. package/dist/number-field/number-field-label.mjs.map +1 -1
  270. package/dist/number-field/number-field-root.d.mts +2 -1
  271. package/dist/number-field/number-field-root.d.mts.map +1 -1
  272. package/dist/number-field/number-field-root.mjs +81 -91
  273. package/dist/number-field/number-field-root.mjs.map +1 -1
  274. package/dist/number-field/use-number-field-dev-warnings.mjs +28 -0
  275. package/dist/number-field/use-number-field-dev-warnings.mjs.map +1 -0
  276. package/dist/number-field/use-step-button.d.mts +24 -0
  277. package/dist/number-field/use-step-button.d.mts.map +1 -0
  278. package/dist/number-field/use-step-button.mjs +57 -3
  279. package/dist/number-field/use-step-button.mjs.map +1 -1
  280. package/dist/popover/popover-close.d.mts.map +1 -1
  281. package/dist/popover/popover-close.mjs +28 -67
  282. package/dist/popover/popover-close.mjs.map +1 -1
  283. package/dist/popover/popover-context.mjs.map +1 -1
  284. package/dist/popover/popover-popup.d.mts +9 -6
  285. package/dist/popover/popover-popup.d.mts.map +1 -1
  286. package/dist/popover/popover-popup.mjs +13 -36
  287. package/dist/popover/popover-popup.mjs.map +1 -1
  288. package/dist/popover/popover-root.mjs +4 -3
  289. package/dist/popover/popover-root.mjs.map +1 -1
  290. package/dist/popover/popover-trigger.d.mts +4 -8
  291. package/dist/popover/popover-trigger.d.mts.map +1 -1
  292. package/dist/popover/popover-trigger.mjs +2 -1
  293. package/dist/popover/popover-trigger.mjs.map +1 -1
  294. package/dist/progress/progress-root.mjs +1 -1
  295. package/dist/radio-group/radio-group-context.mjs.map +1 -1
  296. package/dist/radio-group/radio-group-item.d.mts +3 -4
  297. package/dist/radio-group/radio-group-item.d.mts.map +1 -1
  298. package/dist/radio-group/radio-group-item.mjs +20 -25
  299. package/dist/radio-group/radio-group-item.mjs.map +1 -1
  300. package/dist/radio-group/radio-group-label.mjs +1 -6
  301. package/dist/radio-group/radio-group-label.mjs.map +1 -1
  302. package/dist/radio-group/radio-group-root.d.mts +1 -1
  303. package/dist/radio-group/radio-group-root.d.mts.map +1 -1
  304. package/dist/radio-group/radio-group-root.mjs +21 -40
  305. package/dist/radio-group/radio-group-root.mjs.map +1 -1
  306. package/dist/select/select-dom.mjs +9 -18
  307. package/dist/select/select-dom.mjs.map +1 -1
  308. package/dist/select/select-option.mjs +1 -1
  309. package/dist/select/select-root.mjs +3 -2
  310. package/dist/select/select-root.mjs.map +1 -1
  311. package/dist/slider/slider-arithmetic.mjs +74 -13
  312. package/dist/slider/slider-arithmetic.mjs.map +1 -1
  313. package/dist/slider/slider-context.mjs.map +1 -1
  314. package/dist/slider/slider-label.d.mts.map +1 -1
  315. package/dist/slider/slider-label.mjs +3 -9
  316. package/dist/slider/slider-label.mjs.map +1 -1
  317. package/dist/slider/slider-root.d.mts +2 -2
  318. package/dist/slider/slider-root.d.mts.map +1 -1
  319. package/dist/slider/slider-root.mjs +36 -116
  320. package/dist/slider/slider-root.mjs.map +1 -1
  321. package/dist/slider/slider-thumb.d.mts.map +1 -1
  322. package/dist/slider/slider-thumb.mjs +8 -6
  323. package/dist/slider/slider-thumb.mjs.map +1 -1
  324. package/dist/slider/slider-value.d.mts.map +1 -1
  325. package/dist/slider/slider-value.mjs +2 -1
  326. package/dist/slider/slider-value.mjs.map +1 -1
  327. package/dist/slider/use-slider-dev-warnings.mjs +29 -0
  328. package/dist/slider/use-slider-dev-warnings.mjs.map +1 -0
  329. package/dist/slider/use-thumb-registry.mjs +51 -0
  330. package/dist/slider/use-thumb-registry.mjs.map +1 -0
  331. package/dist/switch/switch.d.mts +4 -5
  332. package/dist/switch/switch.d.mts.map +1 -1
  333. package/dist/switch/switch.mjs +15 -55
  334. package/dist/switch/switch.mjs.map +1 -1
  335. package/dist/tabs/tabs-context.d.mts +2 -3
  336. package/dist/tabs/tabs-context.d.mts.map +1 -1
  337. package/dist/tabs/tabs-context.mjs.map +1 -1
  338. package/dist/tabs/tabs-list.d.mts.map +1 -1
  339. package/dist/tabs/tabs-list.mjs +9 -22
  340. package/dist/tabs/tabs-list.mjs.map +1 -1
  341. package/dist/tabs/tabs-panel.d.mts +3 -4
  342. package/dist/tabs/tabs-panel.d.mts.map +1 -1
  343. package/dist/tabs/tabs-panel.mjs.map +1 -1
  344. package/dist/tabs/tabs-root.d.mts +4 -3
  345. package/dist/tabs/tabs-root.d.mts.map +1 -1
  346. package/dist/tabs/tabs-root.mjs +2 -1
  347. package/dist/tabs/tabs-root.mjs.map +1 -1
  348. package/dist/tabs/tabs-tab.d.mts +3 -4
  349. package/dist/tabs/tabs-tab.d.mts.map +1 -1
  350. package/dist/tabs/tabs-tab.mjs.map +1 -1
  351. package/dist/toast/toast-action.mjs.map +1 -1
  352. package/dist/toast/toast-close.d.mts.map +1 -1
  353. package/dist/toast/toast-close.mjs +2 -8
  354. package/dist/toast/toast-close.mjs.map +1 -1
  355. package/dist/toast/toast-context.mjs.map +1 -1
  356. package/dist/toast/toast-hotkey.mjs +27 -0
  357. package/dist/toast/toast-hotkey.mjs.map +1 -0
  358. package/dist/toast/toast-queue.mjs +137 -0
  359. package/dist/toast/toast-queue.mjs.map +1 -0
  360. package/dist/toast/toast-timers.mjs +65 -0
  361. package/dist/toast/toast-timers.mjs.map +1 -0
  362. package/dist/toast/toast-viewport.d.mts.map +1 -1
  363. package/dist/toast/toast-viewport.mjs +30 -235
  364. package/dist/toast/toast-viewport.mjs.map +1 -1
  365. package/dist/toast/toast.mjs +1 -1
  366. package/dist/toast/toast.mjs.map +1 -1
  367. package/dist/toast/use-modal-portal-host.mjs +52 -0
  368. package/dist/toast/use-modal-portal-host.mjs.map +1 -0
  369. package/dist/toggle/toggle.d.mts +3 -4
  370. package/dist/toggle/toggle.d.mts.map +1 -1
  371. package/dist/toggle/toggle.mjs +7 -10
  372. package/dist/toggle/toggle.mjs.map +1 -1
  373. package/dist/toggle-group/toggle-group-context.d.mts +2 -1
  374. package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
  375. package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
  376. package/dist/toggle-group/toggle-group-item.d.mts +5 -3
  377. package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
  378. package/dist/toggle-group/toggle-group-item.mjs +5 -7
  379. package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
  380. package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
  381. package/dist/toggle-group/toggle-group-root.mjs +29 -64
  382. package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
  383. package/dist/toolbar/toolbar-root.d.mts +2 -2
  384. package/dist/toolbar/toolbar-root.d.mts.map +1 -1
  385. package/dist/toolbar/toolbar-root.mjs +3 -4
  386. package/dist/toolbar/toolbar-root.mjs.map +1 -1
  387. package/dist/tooltip/tooltip-context.d.mts +1 -1
  388. package/dist/tooltip/tooltip-context.mjs.map +1 -1
  389. package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
  390. package/dist/tooltip/tooltip-popup.mjs +6 -15
  391. package/dist/tooltip/tooltip-popup.mjs.map +1 -1
  392. package/dist/tooltip/tooltip-root.mjs +2 -2
  393. package/dist/tooltip/tooltip-root.mjs.map +1 -1
  394. package/dist/tooltip/tooltip-trigger.d.mts +2 -1
  395. package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
  396. package/dist/tooltip/tooltip-trigger.mjs +3 -2
  397. package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
  398. package/dist/tooltip/use-tooltip-interaction.mjs +4 -3
  399. package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
  400. package/package.json +3 -2
  401. package/dist/accordion/accordion-context.d.mts +0 -5
  402. package/dist/accordion/accordion-context.d.mts.map +0 -1
  403. package/dist/internal/use-popover-root.mjs.map +0 -1
  404. /package/dist/internal/{use-popover-root.d.mts → use-overlay-root.d.mts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"accordion-context.mjs","names":[],"sources":["../../src/accordion/accordion-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext } from \"react\";\n\n/** Why a change was dispatched (design 2.2 / 2.3). */\nexport type AccordionChangeReason = \"activate\" | \"platform\";\n\n/**\n * \"static\": JS-free mode, the browser owns `open`. \"library\": `open` is driven by React\n * committed state inside the Root's transition (design section 2).\n */\nexport type AccordionMode = \"static\" | \"library\";\n\nexport interface AccordionRootContextValue {\n readonly mode: AccordionMode;\n readonly exclusive: boolean;\n /** `name` for every `<details>`; set only in static exclusive mode. */\n readonly name: string | undefined;\n readonly disabled: boolean;\n readonly pending: boolean;\n /** Committed open set (library mode). Empty in static mode. */\n readonly committed: ReadonlySet<string>;\n /** Optimistic open set (library mode). Empty in static mode. */\n readonly optimistic: ReadonlySet<string>;\n /** A Trigger was activated: compute `next` from the optimistic set and dispatch. */\n readonly dispatch: (item: string, open: boolean, event: Event | undefined) => void;\n /** The browser changed `details.open`: compute `next` from the DOM and dispatch (design 2.3). */\n readonly dispatchFromDom: (item: string, open: boolean, event: Event | undefined) => void;\n /** Items register their `<details>` so `dispatchFromDom` can read every item's DOM state. */\n readonly registerItem: (value: string, element: HTMLDetailsElement) => () => void;\n /** Triggers register their `<summary>` for arrow-key navigation (design section 5). */\n readonly registerTrigger: (element: HTMLElement) => () => void;\n}\n\nexport const AccordionRootContext = createContext<AccordionRootContextValue | null>(null);\n\nexport interface AccordionItemContextValue {\n readonly value: string;\n readonly disabled: boolean;\n /** `undefined` in static mode (browser-owned, unknown to React). */\n readonly committedOpen: boolean | undefined;\n /** `undefined` in static mode. */\n readonly optimisticOpen: boolean | undefined;\n readonly pending: boolean;\n /**\n * The Root's mode is `\"library\"`. The Root members the Trigger and Panel need are copied here\n * so they read only this context, which is memoised per item: opening another item re-renders\n * every Item (they read the Root's sets) but not their Triggers and Panels (#48).\n */\n readonly library: boolean;\n /** The Root's `dispatch` (stable); `undefined` outside a Root. */\n readonly dispatch: AccordionRootContextValue[\"dispatch\"] | undefined;\n /** The Root's `registerTrigger` (stable); `undefined` outside a Root. */\n readonly registerTrigger: AccordionRootContextValue[\"registerTrigger\"] | undefined;\n}\n\nexport const AccordionItemContext = createContext<AccordionItemContextValue | null>(null);\n"],"mappings":";;;AAiCA,MAAa,uBAAuB,cAAgD,IAAI;AAsBxF,MAAa,uBAAuB,cAAgD,IAAI"}
1
+ {"version":3,"file":"accordion-context.mjs","names":[],"sources":["../../src/accordion/accordion-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext } from \"react\";\n\n/**\n * \"static\": JS-free mode, the browser owns `open`. \"library\": `open` is driven by React\n * committed state inside the Root's transition (design section 2).\n */\nexport type AccordionMode = \"static\" | \"library\";\n\nexport interface AccordionRootContextValue {\n readonly mode: AccordionMode;\n readonly exclusive: boolean;\n /** `name` for every `<details>`; set only in static exclusive mode. */\n readonly name: string | undefined;\n readonly disabled: boolean;\n readonly pending: boolean;\n /** Committed open set (library mode). Empty in static mode. */\n readonly committed: ReadonlySet<string>;\n /** Optimistic open set (library mode). Empty in static mode. */\n readonly optimistic: ReadonlySet<string>;\n /** A Trigger was activated: compute `next` from the optimistic set and dispatch. */\n readonly dispatch: (item: string, open: boolean, event: Event | undefined) => void;\n /** The browser changed `details.open`: compute `next` from the DOM and dispatch (design 2.3). */\n readonly dispatchFromDom: (item: string, open: boolean, event: Event | undefined) => void;\n /** Items register their `<details>` so `dispatchFromDom` can read every item's DOM state. */\n readonly registerItem: (value: string, element: HTMLDetailsElement) => () => void;\n /** Triggers register their `<summary>` for arrow-key navigation (design section 5). */\n readonly registerTrigger: (element: HTMLElement) => () => void;\n}\n\nexport const AccordionRootContext = createContext<AccordionRootContextValue | null>(null);\n\nexport interface AccordionItemContextValue {\n readonly value: string;\n readonly disabled: boolean;\n /** `undefined` in static mode (browser-owned, unknown to React). */\n readonly committedOpen: boolean | undefined;\n /** `undefined` in static mode. */\n readonly optimisticOpen: boolean | undefined;\n readonly pending: boolean;\n /**\n * The Root's mode is `\"library\"`. The Root members the Trigger and Panel need are copied here\n * so they read only this context, which is memoised per item: opening another item re-renders\n * every Item (they read the Root's sets) but not their Triggers and Panels.\n */\n readonly library: boolean;\n /** The Root's `dispatch` (stable); `undefined` outside a Root. */\n readonly dispatch: AccordionRootContextValue[\"dispatch\"] | undefined;\n /** The Root's `registerTrigger` (stable); `undefined` outside a Root. */\n readonly registerTrigger: AccordionRootContextValue[\"registerTrigger\"] | undefined;\n}\n\nexport const AccordionItemContext = createContext<AccordionItemContextValue | null>(null);\n"],"mappings":";;;AA8BA,MAAa,uBAAuB,cAAgD,IAAI;AAsBxF,MAAa,uBAAuB,cAAgD,IAAI"}
@@ -28,10 +28,9 @@ export interface AccordionItemProps extends Omit<ComponentPropsWithRef<"details"
28
28
  * animates the commit that ends an action (the `open` attribute flip), not the optimistic
29
29
  * `data-open` flip. Ignored (dev warning) in JS-free mode.
30
30
  *
31
- * Static: without `transition` the part renders no `<ViewTransition>`; changing it between
32
- * `undefined` and a value remounts the element. Any value, `"none"` included, makes a mount or
33
- * `<Activity>` reveal of this part inside a transition start a document view transition: the
34
- * page cross-fades for about 250 ms and the next transition commit waits for it (issue #35).
31
+ * Static: setting or unsetting it remounts the element. Any value, `"none"` included, makes a
32
+ * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms
33
+ * page cross-fade that the next transition waits for).
35
34
  */
36
35
  transition?: ViewTransitionClass;
37
36
  className?: StateValue<string | undefined, AccordionItemState>;
@@ -1 +1 @@
1
- {"version":3,"file":"accordion-item.d.mts","names":[],"sources":["../../src/accordion/accordion-item.tsx"],"mappings":";;;iBAiBiB;WACN;;WAEA;;WAEA;;WAEA;;iBAGM,2BAA2B,KAC1C;;EAIA;;;;;EAKA;;;;;EAKA;;;;;;;;;;;EAWA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,kCAAkC;;;;;;;wBAUxC,gBACd,OACA,aACA,UAAU,cACV,YACA,WACA,OACA,UACA,WACG,QACF,qBAAkB;yBAVL"}
1
+ {"version":3,"file":"accordion-item.d.mts","names":[],"sources":["../../src/accordion/accordion-item.tsx"],"mappings":";;;iBAoBiB;WACN;;WAEA;;WAEA;;WAEA;;iBAGM,2BAA2B,KAC1C;;EAIA;;;;;EAKA;;;;;EAKA;;;;;;;;;;EAUA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,kCAAkC;;;;;;;wBAQxC,gBACd,OACA,aACA,UAAU,cACV,YACA,WACA,OACA,UACA,WACG,QACF,qBAAkB;yBAVL"}
@@ -3,6 +3,7 @@ import { dataAttr } from "../internal/data-attr.mjs";
3
3
  import { useTransitionBoundary } from "../internal/transition-boundary.mjs";
4
4
  import { useDevWarning } from "../internal/use-dev-warning.mjs";
5
5
  import { useRender } from "../internal/use-render.mjs";
6
+ import { useElementCheck } from "../internal/use-element-check.mjs";
6
7
  import { AccordionItemContext, AccordionRootContext } from "./accordion-context.mjs";
7
8
  import { use, useCallback, useMemo, useState } from "react";
8
9
  import { jsx } from "react/jsx-runtime";
@@ -22,16 +23,21 @@ function AccordionItem({ value, defaultOpen = false, disabled: disabledProp = fa
22
23
  const rootPending = root?.pending ?? false;
23
24
  const pending = isLibrary && rootPending && committedOpen !== optimisticOpen;
24
25
  const [staticOpen] = useState(defaultOpen);
25
- useDevWarning(isLibrary && defaultOpen, "Accordion.Item: `defaultOpen` is ignored in library mode. Use `defaultValue` or `value` on Accordion.Root instead.");
26
- useDevWarning(!isLibrary && transition !== void 0, "Accordion.Item: `transition` has no effect in JS-free mode; the browser toggles the item outside any React transition. Animate `::details-content` with CSS instead.");
26
+ useDevWarning(isLibrary && defaultOpen, isDev && "Accordion.Item: `defaultOpen` is ignored in library mode. Use `defaultValue` or `value` on Accordion.Root instead.");
27
+ useDevWarning(!isLibrary && transition !== void 0, isDev && "Accordion.Item: `transition` has no effect in JS-free mode; the browser toggles the item outside any React transition. Animate `::details-content` with CSS instead.");
27
28
  const registerItem = root?.registerItem;
29
+ const checkElement = useElementCheck(isDev && ((element) => element.tagName !== "DETAILS" ? `Accordion.Item: expected to render a <details> element but got <${element.tagName.toLowerCase()}>. The platform semantics (toggle, find-in-page, exclusive groups) need a real <details>.` : null));
28
30
  const libraryRef = useCallback((element) => {
29
- if (isDev && element.tagName !== "DETAILS") console.error(`Accordion.Item: expected to render a <details> element but got <${element.tagName.toLowerCase()}>. The platform semantics (toggle, find-in-page, exclusive groups) need a real <details>.`);
31
+ checkElement?.(element);
30
32
  const unregister = registerItem?.(value, element);
31
33
  return () => {
32
34
  unregister?.();
33
35
  };
34
- }, [registerItem, value]);
36
+ }, [
37
+ checkElement,
38
+ registerItem,
39
+ value
40
+ ]);
35
41
  const onToggle = isLibrary ? (event) => {
36
42
  const element = event.currentTarget;
37
43
  if (element.open === committedOpen) return;
@@ -1 +1 @@
1
- {"version":3,"file":"accordion-item.mjs","names":[],"sources":["../../src/accordion/accordion-item.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback, useMemo, useState } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n ReactNode,\n SyntheticEvent,\n ViewTransitionClass,\n} from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { AccordionItemContext, AccordionRootContext } from \"./accordion-context.js\";\nimport type { AccordionItemContextValue } from \"./accordion-context.js\";\n\nexport interface AccordionItemState {\n readonly value: string;\n /** Optimistic open state. `undefined` in JS-free mode (browser-owned, unknown to React). */\n readonly open: boolean | undefined;\n /** This item's open state is changing through an in-flight action. */\n readonly pending: boolean;\n /** Disabled by its own prop or by the Root. */\n readonly disabled: boolean;\n}\n\nexport interface AccordionItemProps extends Omit<\n ComponentPropsWithRef<\"details\">,\n \"open\" | \"name\" | \"onToggle\" | \"className\" | \"style\" | \"children\"\n> {\n /** Identifies the item in the Root's `value`. Required in both modes. */\n value: string;\n /**\n * JS-free mode only: renders the initial `open` attribute; the browser owns it from then on.\n * Ignored (dev warning) in library mode, where the Root's `defaultValue` / `value` decide.\n */\n defaultOpen?: boolean;\n /**\n * Disables this item: the Trigger renders `aria-disabled` and never toggles. Enforced by a\n * click handler, so in JS-free mode it does not hold before hydration or with JS off.\n */\n disabled?: boolean;\n /**\n * Library mode only. Forwarded as `default` to the `<ViewTransition>` around the `<details>`;\n * animates the commit that ends an action (the `open` attribute flip), not the optimistic\n * `data-open` flip. Ignored (dev warning) in JS-free mode.\n *\n * Static: without `transition` the part renders no `<ViewTransition>`; changing it between\n * `undefined` and a value remounts the element. Any value, `\"none\"` included, makes a mount or\n * `<Activity>` reveal of this part inside a transition start a document view transition: the\n * page cross-fades for about 250 ms and the next transition commit waits for it (issue #35).\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, AccordionItemState>;\n style?: StateValue<CSSProperties | undefined, AccordionItemState>;\n children?: StateValue<ReactNode, AccordionItemState>;\n /** Must render a `<details>` element. */\n render?: RenderProp<ComponentPropsWithRef<\"details\">, AccordionItemState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * One accordion entry: the `<details>` element. In library mode its `open` attribute follows\n * committed state and `data-open` / `data-pending` follow optimistic state; in JS-free mode (or\n * outside any Root, as a standalone disclosure) the browser owns `open`.\n */\nexport function AccordionItem({\n value,\n defaultOpen = false,\n disabled: disabledProp = false,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: AccordionItemProps) {\n const root = use(AccordionRootContext);\n const isLibrary = root?.mode === \"library\";\n const disabled = disabledProp || (root?.disabled ?? false);\n const committedOpen = isLibrary ? root.committed.has(value) : undefined;\n const optimisticOpen = isLibrary ? root.optimistic.has(value) : undefined;\n const rootPending = root?.pending ?? false;\n const pending = isLibrary && rootPending && committedOpen !== optimisticOpen;\n // JS-free mode: the prop React writes never changes after the first render, so React never\n // rewrites the attribute the browser now owns.\n const [staticOpen] = useState(defaultOpen);\n\n useDevWarning(\n isLibrary && defaultOpen,\n \"Accordion.Item: `defaultOpen` is ignored in library mode. Use `defaultValue` or `value` on \" +\n \"Accordion.Root instead.\",\n );\n useDevWarning(\n !isLibrary && transition !== undefined,\n \"Accordion.Item: `transition` has no effect in JS-free mode; the browser toggles the item \" +\n \"outside any React transition. Animate `::details-content` with CSS instead.\",\n );\n\n const registerItem = root?.registerItem;\n const libraryRef = useCallback(\n (element: HTMLDetailsElement) => {\n if (isDev && element.tagName !== \"DETAILS\") {\n console.error(\n `Accordion.Item: expected to render a <details> element but got <${element.tagName.toLowerCase()}>. ` +\n \"The platform semantics (toggle, find-in-page, exclusive groups) need a real <details>.\",\n );\n }\n const unregister = registerItem?.(value, element);\n return () => {\n unregister?.();\n };\n },\n [registerItem, value],\n );\n\n // Platform path (design 2.3): the Root reconciles pre-hydration clicks on mount and re-applies\n // committed state once nothing is in flight; this handler reports the browser's own flips.\n const onToggle = isLibrary\n ? (event: SyntheticEvent<HTMLDetailsElement>) => {\n const element = event.currentTarget;\n // Read `details.open`, never `ToggleEvent.newState`: `toggle` is coalesced.\n if (element.open === committedOpen) return; // our own commit echoing back\n if (disabled) {\n // A disabled item cannot be opened by the browser either; close it again now or, while\n // an action is in flight, when the Root re-applies committed state.\n if (!rootPending) element.open = committedOpen === true;\n return;\n }\n root.dispatchFromDom(value, element.open, event.nativeEvent);\n }\n : undefined;\n\n const state: AccordionItemState = { value, open: optimisticOpen, pending, disabled };\n const dispatch = root?.dispatch;\n const registerTrigger = root?.registerTrigger;\n // Memoised (#48): changes only with this item's own values, not with every Root change.\n const itemContext = useMemo<AccordionItemContextValue>(\n () => ({\n value,\n disabled,\n committedOpen,\n optimisticOpen,\n pending,\n library: isLibrary,\n dispatch,\n registerTrigger,\n }),\n [value, disabled, committedOpen, optimisticOpen, pending, isLibrary, dispatch, registerTrigger],\n );\n\n const element = useRender<ComponentPropsWithRef<\"details\">, AccordionItemState>({\n defaultElement: \"details\",\n render,\n state,\n className,\n style,\n children,\n ref: libraryRef,\n props: rest,\n // Library-controlled layer: `open`, `name` and `onToggle` are owned by the library in at\n // least one mode, so a `render` element cannot override them either (conventions 1.2).\n libraryProps: {\n open: isLibrary ? committedOpen : staticOpen,\n // A click before hydration changes `open` under React's feet in both modes; the mismatch is\n // expected and reconciled (library mode) or the browser's business (JS-free mode).\n suppressHydrationWarning: true,\n // Owned in both modes: in library mode there is one writer of `open`, so a render element's\n // `name` (a second, platform-level writer) is removed.\n name: !isLibrary ? root?.name : undefined,\n // Only installed in library mode; owning the key in static mode would strip a render\n // element's own `onToggle`.\n ...(isLibrary && { onToggle }),\n \"data-open\": dataAttr(optimisticOpen === true),\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n },\n });\n\n return useTransitionBoundary(\n \"Accordion.Item\",\n isLibrary ? transition : undefined,\n <AccordionItemContext value={itemContext}>{element}</AccordionItemContext>,\n );\n}\n\nAccordionItem.displayName = \"AccordionItem\";\n"],"mappings":";;;;;;;;;AA6DA,MAAM,QAAQ,QAAQ,I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EAAW;EAAU;CAAe,CAChG;CAEA,MAAM,UAAU,UAAgE;EAC9E,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,KAAK;EACL,OAAO;EAGP,cAAc;GACZ,MAAM,YAAY,gBAAgB;GAGlC,0BAA0B;GAG1B,MAAM,CAAC,YAAY,MAAM,OAAO,KAAA;GAGhC,GAAI,aAAa,EAAE,SAAS;GAC5B,aAAa,SAAS,mBAAmB,IAAI;GAC7C,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;EACpC;CACF,CAAC;CAED,OAAO,sBACL,kBACA,YAAY,aAAa,KAAA,GACzB,oBAAC,sBAAD;EAAsB,OAAO;EAAc,UAAA;CAA8B,CAAA,CAC3E;AACF;AAEA,cAAc,cAAc"}
1
+ {"version":3,"file":"accordion-item.mjs","names":[],"sources":["../../src/accordion/accordion-item.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback, useMemo, useState } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n ReactNode,\n SyntheticEvent,\n ViewTransitionClass,\n} from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { AccordionItemContext, AccordionRootContext } from \"./accordion-context.js\";\nimport type { AccordionItemContextValue } from \"./accordion-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface AccordionItemState {\n readonly value: string;\n /** Optimistic open state. `undefined` in JS-free mode (browser-owned, unknown to React). */\n readonly open: boolean | undefined;\n /** This item's open state is changing through an in-flight action. */\n readonly pending: boolean;\n /** Disabled by its own prop or by the Root. */\n readonly disabled: boolean;\n}\n\nexport interface AccordionItemProps extends Omit<\n ComponentPropsWithRef<\"details\">,\n \"open\" | \"name\" | \"onToggle\" | \"className\" | \"style\" | \"children\"\n> {\n /** Identifies the item in the Root's `value`. Required in both modes. */\n value: string;\n /**\n * JS-free mode only: renders the initial `open` attribute; the browser owns it from then on.\n * Ignored (dev warning) in library mode, where the Root's `defaultValue` / `value` decide.\n */\n defaultOpen?: boolean;\n /**\n * Disables this item: the Trigger renders `aria-disabled` and never toggles. Enforced by a\n * click handler, so in JS-free mode it does not hold before hydration or with JS off.\n */\n disabled?: boolean;\n /**\n * Library mode only. Forwarded as `default` to the `<ViewTransition>` around the `<details>`;\n * animates the commit that ends an action (the `open` attribute flip), not the optimistic\n * `data-open` flip. Ignored (dev warning) in JS-free mode.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, AccordionItemState>;\n style?: StateValue<CSSProperties | undefined, AccordionItemState>;\n children?: StateValue<ReactNode, AccordionItemState>;\n /** Must render a `<details>` element. */\n render?: RenderProp<ComponentPropsWithRef<\"details\">, AccordionItemState>;\n}\n\n/**\n * One accordion entry: the `<details>` element. In library mode its `open` attribute follows\n * committed state and `data-open` / `data-pending` follow optimistic state; in JS-free mode (or\n * outside any Root, as a standalone disclosure) the browser owns `open`.\n */\nexport function AccordionItem({\n value,\n defaultOpen = false,\n disabled: disabledProp = false,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: AccordionItemProps) {\n const root = use(AccordionRootContext);\n const isLibrary = root?.mode === \"library\";\n const disabled = disabledProp || (root?.disabled ?? false);\n const committedOpen = isLibrary ? root.committed.has(value) : undefined;\n const optimisticOpen = isLibrary ? root.optimistic.has(value) : undefined;\n const rootPending = root?.pending ?? false;\n const pending = isLibrary && rootPending && committedOpen !== optimisticOpen;\n // JS-free mode: the prop React writes never changes after the first render, so React never\n // rewrites the attribute the browser now owns.\n const [staticOpen] = useState(defaultOpen);\n\n useDevWarning(\n isLibrary && defaultOpen,\n isDev &&\n \"Accordion.Item: `defaultOpen` is ignored in library mode. Use `defaultValue` or `value` on \" +\n \"Accordion.Root instead.\",\n );\n useDevWarning(\n !isLibrary && transition !== undefined,\n isDev &&\n \"Accordion.Item: `transition` has no effect in JS-free mode; the browser toggles the item \" +\n \"outside any React transition. Animate `::details-content` with CSS instead.\",\n );\n\n const registerItem = root?.registerItem;\n const checkElement = useElementCheck<HTMLDetailsElement>(\n isDev &&\n ((element) =>\n element.tagName !== \"DETAILS\"\n ? `Accordion.Item: expected to render a <details> element but got <${element.tagName.toLowerCase()}>. ` +\n \"The platform semantics (toggle, find-in-page, exclusive groups) need a real <details>.\"\n : null),\n );\n const libraryRef = useCallback(\n (element: HTMLDetailsElement) => {\n checkElement?.(element);\n const unregister = registerItem?.(value, element);\n return () => {\n unregister?.();\n };\n },\n [checkElement, registerItem, value],\n );\n\n // Platform path (design 2.3): the Root reconciles pre-hydration clicks on mount and re-applies\n // committed state once nothing is in flight; this handler reports the browser's own flips.\n const onToggle = isLibrary\n ? (event: SyntheticEvent<HTMLDetailsElement>) => {\n const element = event.currentTarget;\n // Read `details.open`, never `ToggleEvent.newState`: `toggle` is coalesced.\n if (element.open === committedOpen) return; // our own commit echoing back\n if (disabled) {\n // A disabled item cannot be opened by the browser either; close it again now or, while\n // an action is in flight, when the Root re-applies committed state.\n if (!rootPending) element.open = committedOpen === true;\n return;\n }\n root.dispatchFromDom(value, element.open, event.nativeEvent);\n }\n : undefined;\n\n const state: AccordionItemState = { value, open: optimisticOpen, pending, disabled };\n const dispatch = root?.dispatch;\n const registerTrigger = root?.registerTrigger;\n // Memoised: changes only with this item's own values, not with every Root change.\n const itemContext = useMemo<AccordionItemContextValue>(\n () => ({\n value,\n disabled,\n committedOpen,\n optimisticOpen,\n pending,\n library: isLibrary,\n dispatch,\n registerTrigger,\n }),\n [value, disabled, committedOpen, optimisticOpen, pending, isLibrary, dispatch, registerTrigger],\n );\n\n const element = useRender<ComponentPropsWithRef<\"details\">, AccordionItemState>({\n defaultElement: \"details\",\n render,\n state,\n className,\n style,\n children,\n ref: libraryRef,\n props: rest,\n // Library-controlled layer: `open`, `name` and `onToggle` are owned by the library in at\n // least one mode, so a `render` element cannot override them either (conventions 1.2).\n libraryProps: {\n open: isLibrary ? committedOpen : staticOpen,\n // A click before hydration changes `open` under React's feet in both modes; the mismatch is\n // expected and reconciled (library mode) or the browser's business (JS-free mode).\n suppressHydrationWarning: true,\n // Owned in both modes: in library mode there is one writer of `open`, so a render element's\n // `name` (a second, platform-level writer) is removed.\n name: !isLibrary ? root?.name : undefined,\n // Only installed in library mode; owning the key in static mode would strip a render\n // element's own `onToggle`.\n ...(isLibrary && { onToggle }),\n \"data-open\": dataAttr(optimisticOpen === true),\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n },\n });\n\n return useTransitionBoundary(\n \"Accordion.Item\",\n isLibrary ? transition : undefined,\n <AccordionItemContext value={itemContext}>{element}</AccordionItemContext>,\n );\n}\n\nAccordionItem.displayName = \"AccordionItem\";\n"],"mappings":";;;;;;;;;;AAkBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;AAkDvC,SAAgB,cAAc,EAC5B,OACA,cAAc,OACd,UAAU,eAAe,OACzB,YACA,WACA,OACA,UACA,QACA,GAAG,QACkB;CACrB,MAAM,OAAO,IAAI,oBAAoB;CACrC,MAAM,YAAY,MAAM,SAAS;CACjC,MAAM,WAAW,iBAAiB,MAAM,YAAY;CACpD,MAAM,gBAAgB,YAAY,KAAK,UAAU,IAAI,KAAK,IAAI,KAAA;CAC9D,MAAM,iBAAiB,YAAY,KAAK,WAAW,IAAI,KAAK,IAAI,KAAA;CAChE,MAAM,cAAc,MAAM,WAAW;CACrC,MAAM,UAAU,aAAa,eAAe,kBAAkB;CAG9D,MAAM,CAAC,cAAc,SAAS,WAAW;CAEzC,cACE,aAAa,aACb,SACE,oHAEJ;CACA,cACE,CAAC,aAAa,eAAe,KAAA,GA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}
@@ -12,10 +12,9 @@ export interface AccordionPanelProps extends Omit<ComponentPropsWithRef<"div">,
12
12
  * Library mode only. Forwarded as `default` to the `<ViewTransition>` around the panel's
13
13
  * `div`; animates content that mounts or changes in the commit that ends an action.
14
14
  *
15
- * Static: without `transition` the part renders no `<ViewTransition>`; changing it between
16
- * `undefined` and a value remounts the element. Any value, `"none"` included, makes a mount or
17
- * `<Activity>` reveal of this part inside a transition start a document view transition: the
18
- * page cross-fades for about 250 ms and the next transition commit waits for it (issue #35).
15
+ * Static: setting or unsetting it remounts the element. Any value, `"none"` included, makes a
16
+ * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms
17
+ * page cross-fade that the next transition waits for).
19
18
  */
20
19
  transition?: ViewTransitionClass;
21
20
  className?: StateValue<string | undefined, AccordionPanelState>;
@@ -1 +1 @@
1
- {"version":3,"file":"accordion-panel.d.mts","names":[],"sources":["../../src/accordion/accordion-panel.tsx"],"mappings":";;;iBAUiB;WACN;;WAEA;WACA;;iBAGM,4BAA4B,KAC3C;;;;;;;;;;EAYA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;;;;;EAM9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;wBAOpC,iBACd,YACA,WACA,OACA,UACA,WACG,QACF,sBAAmB;yBAPN"}
1
+ {"version":3,"file":"accordion-panel.d.mts","names":[],"sources":["../../src/accordion/accordion-panel.tsx"],"mappings":";;;iBAYiB;WACN;;WAEA;WACA;;iBAGM,4BAA4B,KAC3C;;;;;;;;;EAWA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;;;;;EAM9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;wBAOpC,iBACd,YACA,WACA,OACA,UACA,WACG,QACF,sBAAmB;yBAPN"}
@@ -6,6 +6,7 @@ import { useRender } from "../internal/use-render.mjs";
6
6
  import { AccordionItemContext } from "./accordion-context.mjs";
7
7
  import { use } from "react";
8
8
  //#region src/accordion/accordion-panel.tsx
9
+ const isDev = process.env.NODE_ENV !== "production";
9
10
  /**
10
11
  * The item's content region: a `div` inside the `<details>`, after the Trigger. Its visibility
11
12
  * is the parent's `open` attribute (`details:open > .panel`); it renders committed state.
@@ -14,7 +15,7 @@ function AccordionPanel({ transition, className, style, children, render, ...res
14
15
  const item = use(AccordionItemContext);
15
16
  if (item === null) throw new Error("Accordion.Panel must be rendered inside an Accordion.Item.");
16
17
  const isLibrary = item.library;
17
- useDevWarning(!isLibrary && transition !== void 0, "Accordion.Panel: `transition` has no effect in JS-free mode; the browser toggles the item outside any React transition.");
18
+ useDevWarning(!isLibrary && transition !== void 0, isDev && "Accordion.Panel: `transition` has no effect in JS-free mode; the browser toggles the item outside any React transition.");
18
19
  const state = {
19
20
  value: item.value,
20
21
  open: item.committedOpen,
@@ -1 +1 @@
1
- {"version":3,"file":"accordion-panel.mjs","names":[],"sources":["../../src/accordion/accordion-panel.tsx"],"sourcesContent":["\"use client\";\nimport { use } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode, ViewTransitionClass } from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { AccordionItemContext } from \"./accordion-context.js\";\n\nexport interface AccordionPanelState {\n readonly value: string;\n /** Committed open state. `undefined` in JS-free mode. */\n readonly open: boolean | undefined;\n readonly disabled: boolean;\n}\n\nexport interface AccordionPanelProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"className\" | \"style\" | \"children\"\n> {\n /**\n * Library mode only. Forwarded as `default` to the `<ViewTransition>` around the panel's\n * `div`; animates content that mounts or changes in the commit that ends an action.\n *\n * Static: without `transition` the part renders no `<ViewTransition>`; changing it between\n * `undefined` and a value remounts the element. Any value, `\"none\"` included, makes a mount or\n * `<Activity>` reveal of this part inside a transition start a document view transition: the\n * page cross-fades for about 250 ms and the next transition commit waits for it (issue #35).\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, AccordionPanelState>;\n style?: StateValue<CSSProperties | undefined, AccordionPanelState>;\n /**\n * Always mounted (closed `<details>` content stays in the DOM, indexable and searchable). The\n * function form receives committed `open`, which is how content is mounted lazily and how\n * suspending content keeps the item closed until it is ready.\n */\n children?: StateValue<ReactNode, AccordionPanelState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, AccordionPanelState>;\n}\n\n/**\n * The item's content region: a `div` inside the `<details>`, after the Trigger. Its visibility\n * is the parent's `open` attribute (`details:open > .panel`); it renders committed state.\n */\nexport function AccordionPanel({\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: AccordionPanelProps) {\n // Only the Item's context (memoised per item, #48).\n const item = use(AccordionItemContext);\n if (item === null) {\n throw new Error(\"Accordion.Panel must be rendered inside an Accordion.Item.\");\n }\n const isLibrary = item.library;\n\n useDevWarning(\n !isLibrary && transition !== undefined,\n \"Accordion.Panel: `transition` has no effect in JS-free mode; the browser toggles the item \" +\n \"outside any React transition.\",\n );\n\n const state: AccordionPanelState = {\n value: item.value,\n open: item.committedOpen,\n disabled: item.disabled,\n };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, AccordionPanelState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n \"data-disabled\": dataAttr(item.disabled),\n },\n });\n\n return useTransitionBoundary(\"Accordion.Panel\", isLibrary ? transition : undefined, element);\n}\n\nAccordionPanel.displayName = \"AccordionPanel\";\n"],"mappings":";;;;;;;;;;;;AA8CA,SAAgB,eAAe,EAC7B,YACA,WACA,OACA,UACA,QACA,GAAG,QACmB;CAEtB,MAAM,OAAO,IAAI,oBAAoB;CACrC,IAAI,SAAS,MACX,MAAM,IAAI,MAAM,4DAA4D;CAE9E,MAAM,YAAY,KAAK;CAEvB,cACE,CAAC,aAAa,eAAe,KAAA,GAC7B,yHAEF;CAEA,MAAM,QAA6B;EACjC,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,UAAU,KAAK;CACjB;CAEA,MAAM,UAAU,UAA6D;EAC3E,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc,EACZ,iBAAiB,SAAS,KAAK,QAAQ,EACzC;CACF,CAAC;CAED,OAAO,sBAAsB,mBAAmB,YAAY,aAAa,KAAA,GAAW,OAAO;AAC7F;AAEA,eAAe,cAAc"}
1
+ {"version":3,"file":"accordion-panel.mjs","names":[],"sources":["../../src/accordion/accordion-panel.tsx"],"sourcesContent":["\"use client\";\nimport { use } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode, ViewTransitionClass } from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { AccordionItemContext } from \"./accordion-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface AccordionPanelState {\n readonly value: string;\n /** Committed open state. `undefined` in JS-free mode. */\n readonly open: boolean | undefined;\n readonly disabled: boolean;\n}\n\nexport interface AccordionPanelProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"className\" | \"style\" | \"children\"\n> {\n /**\n * Library mode only. Forwarded as `default` to the `<ViewTransition>` around the panel's\n * `div`; animates content that mounts or changes in the commit that ends an action.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, AccordionPanelState>;\n style?: StateValue<CSSProperties | undefined, AccordionPanelState>;\n /**\n * Always mounted (closed `<details>` content stays in the DOM, indexable and searchable). The\n * function form receives committed `open`, which is how content is mounted lazily and how\n * suspending content keeps the item closed until it is ready.\n */\n children?: StateValue<ReactNode, AccordionPanelState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, AccordionPanelState>;\n}\n\n/**\n * The item's content region: a `div` inside the `<details>`, after the Trigger. Its visibility\n * is the parent's `open` attribute (`details:open > .panel`); it renders committed state.\n */\nexport function AccordionPanel({\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: AccordionPanelProps) {\n // Only the Item's context (memoised per item).\n const item = use(AccordionItemContext);\n if (item === null) {\n throw new Error(\"Accordion.Panel must be rendered inside an Accordion.Item.\");\n }\n const isLibrary = item.library;\n\n useDevWarning(\n !isLibrary && transition !== undefined,\n isDev &&\n \"Accordion.Panel: `transition` has no effect in JS-free mode; the browser toggles the item \" +\n \"outside any React transition.\",\n );\n\n const state: AccordionPanelState = {\n value: item.value,\n open: item.committedOpen,\n disabled: item.disabled,\n };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, AccordionPanelState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n \"data-disabled\": dataAttr(item.disabled),\n },\n });\n\n return useTransitionBoundary(\"Accordion.Panel\", isLibrary ? transition : undefined, element);\n}\n\nAccordionPanel.displayName = \"AccordionPanel\";\n"],"mappings":";;;;;;;;AAUA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;AAqCvC,SAAgB,eAAe,EAC7B,YACA,WACA,OACA,UACA,QACA,GAAG,QACmB;CAEtB,MAAM,OAAO,IAAI,oBAAoB;CACrC,IAAI,SAAS,MACX,MAAM,IAAI,MAAM,4DAA4D;CAE9E,MAAM,YAAY,KAAK;CAEvB,cACE,CAAC,aAAa,eAAe,KAAA,GAC7B,SACE,yHAEJ;CAEA,MAAM,QAA6B;EACjC,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,UAAU,KAAK;CACjB;CAEA,MAAM,UAAU,UAA6D;EAC3E,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc,EACZ,iBAAiB,SAAS,KAAK,QAAQ,EACzC;CACF,CAAC;CAED,OAAO,sBAAsB,mBAAmB,YAAY,aAAa,KAAA,GAAW,OAAO;AAC7F;AAEA,eAAe,cAAc"}
@@ -1,5 +1,4 @@
1
- import { ActionDetails, ChangeAction, RenderProp, StateValue } from "../internal/types.mjs";
2
- import { AccordionChangeReason } from "./accordion-context.mjs";
1
+ import { ActionDetails, ChangeAction, ChangeReason, RenderProp, StateValue } from "../internal/types.mjs";
3
2
  import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
4
3
  //#region src/accordion/accordion-root.d.ts
5
4
  export interface AccordionRootState {
@@ -11,11 +10,12 @@ export interface AccordionRootState {
11
10
  /** Details passed as the second argument of `valueChangeAction`. */
12
11
  export interface AccordionValueChangeDetails extends ActionDetails {
13
12
  /**
13
+ * The shared vocabulary (conventions 2.2); Accordion dispatches two of its values.
14
14
  * `"activate"`: the user activated a Trigger. `"platform"`: the browser changed `open` itself
15
15
  * (find-in-page, a text fragment, a click before hydration); `event` is then the `toggle`
16
16
  * event, or `undefined` when the mismatch was found on mount.
17
17
  */
18
- readonly reason: AccordionChangeReason;
18
+ readonly reason: ChangeReason;
19
19
  /** The item whose open state changed. */
20
20
  readonly item: string;
21
21
  /** That item's new open state. */
@@ -1 +1 @@
1
- {"version":3,"file":"accordion-root.d.mts","names":[],"sources":["../../src/accordion/accordion-root.tsx"],"mappings":";;;;iBA0BiB;;WAEN;;WAEA;;;iBAIM,oCAAoC;;;;;;WAM1C,QAAQ;;WAER;;WAEA;;UAGD,+BAA+B,KACvC;;EAKA;;;;;;EAMA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;iBAGnC,mCAAmC;;EAElD;;EAEA;;EAEA;;;;;;;;;;;;EAYA,oBAAoB,uBAAuB;;iBAG5B,oCAAoC;;;;;EAKnD;;EAEA;;EAEA;;EAEA,oBAAoB,4BAA4B;;;;;;;;;;YAWtC,qBAAqB,6BAA6B;;;;;wBAqF9C,cAAc,OAAO,qCAAkB,IAAA;yBAAvC"}
1
+ {"version":3,"file":"accordion-root.d.mts","names":[],"sources":["../../src/accordion/accordion-root.tsx"],"mappings":";;;iBAiCiB;;WAEN;;WAEA;;;iBAIM,oCAAoC;;;;;;;WAO1C,QAAQ;;WAER;;WAEA;;UAGD,+BAA+B,KACvC;;EAKA;;;;;;EAMA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;iBAGnC,mCAAmC;;EAElD;;EAEA;;EAEA;;;;;;;;;;;;EAYA,oBAAoB,uBAAuB;;iBAG5B,oCAAoC;;;;;EAKnD;;EAEA;;EAEA;;EAEA,oBAAoB,4BAA4B;;;;;;;;;;YAWtC,qBAAqB,6BAA6B;;;;;wBAmE9C,cAAc,OAAO,qCAAkB,IAAA;yBAAvC"}
@@ -7,15 +7,13 @@ import { useRender } from "../internal/use-render.mjs";
7
7
  import { transitionTypes } from "../internal/transition-types.mjs";
8
8
  import { useLatest } from "../internal/use-latest.mjs";
9
9
  import { useControllableAction } from "../internal/use-controllable-action.mjs";
10
+ import { compareDocumentOrder } from "../internal/dom-order.mjs";
11
+ import { EMPTY_SET, setsEqual, toSet } from "../internal/value-set.mjs";
10
12
  import { AccordionRootContext } from "./accordion-context.mjs";
11
13
  import { useCallback, useEffectEvent, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
12
14
  import { jsx } from "react/jsx-runtime";
13
15
  //#region src/accordion/accordion-root.tsx
14
- const EMPTY = /* @__PURE__ */ new Set();
15
- function toSet(value) {
16
- if (value === null) return EMPTY;
17
- return typeof value === "string" ? /* @__PURE__ */ new Set([value]) : new Set(value);
18
- }
16
+ const isDev = process.env.NODE_ENV !== "production";
19
17
  /**
20
18
  * Converts the open set back to the public value. Multiple mode lists the items in registration
21
19
  * order (the order the Items mounted, which is document order for a list rendered top to bottom),
@@ -40,15 +38,6 @@ function reduce(set, item, open, exclusive) {
40
38
  if (exclusive) return /* @__PURE__ */ new Set([item]);
41
39
  return set.has(item) ? set : new Set(set).add(item);
42
40
  }
43
- function setsEqual(a, b) {
44
- if (a.size !== b.size) return false;
45
- for (const v of a) if (!b.has(v)) return false;
46
- return true;
47
- }
48
- function byDocumentOrder(a, b) {
49
- if (a === b) return 0;
50
- return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
51
- }
52
41
  const NAV_KEYS = /* @__PURE__ */ new Set([
53
42
  "ArrowDown",
54
43
  "ArrowUp",
@@ -84,7 +73,7 @@ function AccordionRoot(props) {
84
73
  const { exclusive = false, value, defaultValue, valueChangeAction, disabled = false, experimental_interpolateSize = false, className, style, children, render, ...rest } = props;
85
74
  const isLibraryNow = value !== void 0 || defaultValue !== void 0 || valueChangeAction !== void 0;
86
75
  const [mode] = useState(isLibraryNow ? "library" : "static");
87
- useDevWarning(mode === "library" !== isLibraryNow, "Accordion.Root: the mode changed after mount (`value`, `defaultValue` and `valueChangeAction` were all absent on one render and present on another). Switching between JS-free and library mode is not supported.");
76
+ useDevWarning(mode === "library" !== isLibraryNow, isDev && "Accordion.Root: the mode changed after mount (`value`, `defaultValue` and `valueChangeAction` were all absent on one render and present on another). Switching between JS-free and library mode is not supported.");
88
77
  const action = valueChangeAction;
89
78
  const controlledKey = value === void 0 ? void 0 : JSON.stringify(value);
90
79
  const controlledSet = useMemo(() => controlledKey === void 0 ? void 0 : toSet(JSON.parse(controlledKey)), [controlledKey]);
@@ -94,7 +83,7 @@ function AccordionRoot(props) {
94
83
  const { committed, optimistic, pending, dispatch, latestInFlight } = useControllableAction({
95
84
  controlled: controlledSet,
96
85
  defaultValue: defaultValue === void 0 ? void 0 : toSet(defaultValue),
97
- initialValue: EMPTY,
86
+ initialValue: EMPTY_SET,
98
87
  action: action && ((next, details) => action(fromSet(next, exclusive, registeredValues()), details)),
99
88
  transitionTypes: (_next, _prev, details) => transitionTypes("accordion", details.open ? "expand" : "collapse"),
100
89
  reducer: (prev, next, details) => details.reason === "platform" && details.event === void 0 ? next : reduce(prev, details.item, details.open, exclusive),
@@ -177,7 +166,7 @@ function AccordionRoot(props) {
177
166
  if (!NAV_KEYS.has(event.key)) return;
178
167
  const target = event.target;
179
168
  if (!(target instanceof HTMLElement) || !triggers.current.has(target)) return;
180
- const next = nextTrigger([...triggers.current].sort(byDocumentOrder), target, event.key);
169
+ const next = nextTrigger([...triggers.current].sort(compareDocumentOrder), target, event.key);
181
170
  if (next === void 0) return;
182
171
  event.preventDefault();
183
172
  event.stopPropagation();
@@ -190,8 +179,8 @@ function AccordionRoot(props) {
190
179
  pending: rootPending,
191
180
  disabled
192
181
  };
193
- const contextCommitted = isLibrary ? committed : EMPTY;
194
- const contextOptimistic = isLibrary ? optimistic : EMPTY;
182
+ const contextCommitted = isLibrary ? committed : EMPTY_SET;
183
+ const contextOptimistic = isLibrary ? optimistic : EMPTY_SET;
195
184
  const context = useMemo(() => ({
196
185
  mode,
197
186
  exclusive,
@@ -1 +1 @@
1
- {"version":3,"file":"accordion-root.mjs","names":[],"sources":["../../src/accordion/accordion-root.tsx"],"sourcesContent":["\"use client\";\nimport {\n useCallback,\n useEffectEvent,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, KeyboardEvent, ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { dataAttr } from \"../internal/data-attr.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 { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport { AccordionRootContext } from \"./accordion-context.js\";\nimport type {\n AccordionChangeReason,\n AccordionMode,\n AccordionRootContextValue,\n} from \"./accordion-context.js\";\n\nexport interface AccordionRootState {\n /** An action dispatched through this Accordion is in flight (library mode only). */\n readonly pending: boolean;\n /** The Root's `disabled` prop. */\n readonly disabled: boolean;\n}\n\n/** Details passed as the second argument of `valueChangeAction`. */\nexport interface AccordionValueChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user activated a Trigger. `\"platform\"`: the browser changed `open` itself\n * (find-in-page, a text fragment, a click before hydration); `event` is then the `toggle`\n * event, or `undefined` when the mismatch was found on mount.\n */\n readonly reason: AccordionChangeReason;\n /** The item whose open state changed. */\n readonly item: string;\n /** That item's new open state. */\n readonly open: boolean;\n}\n\ninterface AccordionRootBaseProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n // `defaultValue` is also a native HTMLAttributes member; the Accordion's own definition wins.\n \"onKeyDown\" | \"defaultValue\" | \"className\" | \"style\" | \"children\"\n> {\n /** Disables every item: triggers render `aria-disabled` and never dispatch. Default `false`. */\n disabled?: boolean;\n /**\n * Renders `interpolate-size: allow-keywords` on the root so `::details-content` can transition\n * `height` to `auto`. Chromium-only polish today; use the `grid-template-rows` form for a\n * cross-engine animation. Merged with `style`; the consumer's declaration wins.\n */\n experimental_interpolateSize?: boolean;\n className?: StateValue<string | undefined, AccordionRootState>;\n style?: StateValue<CSSProperties | undefined, AccordionRootState>;\n children?: StateValue<ReactNode, AccordionRootState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, AccordionRootState>;\n}\n\nexport interface AccordionRootMultipleProps extends AccordionRootBaseProps {\n /** Any number of items may be open. */\n exclusive?: false;\n /** Controlled open items. `undefined` means uncontrolled; `[]` means none open. */\n value?: string[];\n /** Initial open items in uncontrolled library mode. */\n defaultValue?: string[];\n /**\n * Called with the next open items on every change. Runs inside the Root's transition; may be\n * sync or async (also a Server Function). Rejections reach the nearest Error Boundary.\n *\n * May also be called with `details.reason === \"platform\"` when the browser opened an item\n * itself (find-in-page, a click before hydration); committed state is re-applied to the DOM\n * once the action settles.\n *\n * A `setState` placed after your own `await` is not a Transition update; wrap it in\n * `startTransition` (React limitation).\n */\n valueChangeAction?: ChangeAction<string[], AccordionValueChangeDetails>;\n}\n\nexport interface AccordionRootExclusiveProps extends AccordionRootBaseProps {\n /**\n * At most one item open. JS-free mode: renders the same `name` on every `<details>` (the\n * platform's exclusive group). Library mode: the value is a single item or `null`.\n */\n exclusive: true;\n /** Controlled open item. `undefined` means uncontrolled; `null` means none open. */\n value?: string | null;\n /** Initial open item in uncontrolled library mode. */\n defaultValue?: string | null;\n /** See {@link AccordionRootMultipleProps.valueChangeAction}. */\n valueChangeAction?: ChangeAction<string | null, AccordionValueChangeDetails>;\n}\n\n/**\n * Props of `Accordion.Root`, discriminated on `exclusive`.\n *\n * Without `value`, `defaultValue` and `valueChangeAction` the Accordion runs in **JS-free mode**:\n * the browser owns each `<details open>`, nothing runs on toggle, and `exclusive` renders `name`.\n * With any of them it runs in **library mode**: the summary click is intercepted, `open` is driven\n * by committed state inside a transition, and triggers show optimistic `data-open`.\n */\nexport type AccordionRootProps = AccordionRootMultipleProps | AccordionRootExclusiveProps;\n\ntype AccordionValue = string[] | string | null;\ntype OpenSet = ReadonlySet<string>;\n\nconst EMPTY: OpenSet = new Set();\n\nfunction toSet(value: AccordionValue): OpenSet {\n if (value === null) return EMPTY;\n return typeof value === \"string\" ? new Set([value]) : new Set(value);\n}\n\n/**\n * Converts the open set back to the public value. Multiple mode lists the items in registration\n * order (the order the Items mounted, which is document order for a list rendered top to bottom),\n * not in the order they were opened; unregistered values keep their insertion order at the end.\n */\nfunction fromSet(set: OpenSet, exclusive: boolean, order: readonly string[]): AccordionValue {\n if (exclusive) {\n const [first] = set;\n return first ?? null;\n }\n const index = new Map(order.map((v, i) => [v, i] as const));\n return [...set].sort((a, b) => (index.get(a) ?? Infinity) - (index.get(b) ?? Infinity));\n}\n\n/** The optimistic reducer of design 4.1: add/remove one item, or replace when exclusive. */\nfunction reduce(set: OpenSet, item: string, open: boolean, exclusive: boolean): OpenSet {\n if (!open) {\n if (!set.has(item)) return set;\n const next = new Set(set);\n next.delete(item);\n return next;\n }\n if (exclusive) return new Set([item]);\n return set.has(item) ? set : new Set(set).add(item);\n}\n\nfunction setsEqual(a: OpenSet, b: OpenSet): boolean {\n if (a.size !== b.size) return false;\n for (const v of a) if (!b.has(v)) return false;\n return true;\n}\n\nfunction byDocumentOrder<T extends Node>(a: T, b: T): number {\n if (a === b) return 0;\n return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;\n}\n\nconst NAV_KEYS = new Set([\"ArrowDown\", \"ArrowUp\", \"Home\", \"End\"]);\n\n/** Writes `open` to the DOM; it fires `toggle`, whose handler sees DOM === committed and returns. */\nfunction applyOpen(element: HTMLDetailsElement, open: boolean): void {\n if (element.open !== open) element.open = open;\n}\n\nfunction isEnabledTrigger(el: HTMLElement): boolean {\n return el.getAttribute(\"aria-disabled\") !== \"true\";\n}\n\n/**\n * Picks the trigger to focus for an arrow/Home/End key: `sorted` is every registered trigger in\n * document order; disabled ones are skipped; arrows wrap. Works when `current` is itself disabled\n * (disabled triggers stay focusable).\n */\nfunction nextTrigger(\n sorted: readonly HTMLElement[],\n current: HTMLElement,\n key: string,\n): HTMLElement | undefined {\n const enabled = sorted.filter(isEnabledTrigger);\n if (enabled.length === 0) return undefined;\n if (key === \"Home\") return enabled[0];\n if (key === \"End\") return enabled[enabled.length - 1];\n const position = sorted.indexOf(current);\n if (key === \"ArrowDown\") {\n return enabled.find((el) => sorted.indexOf(el) > position) ?? enabled[0];\n }\n return enabled.findLast((el) => sorted.indexOf(el) < position) ?? enabled[enabled.length - 1];\n}\n\n/**\n * The accordion container: a `div` that owns the open state, the transition, the context the\n * other parts read, and ArrowUp/ArrowDown/Home/End navigation between triggers.\n */\nexport function AccordionRoot(props: AccordionRootProps) {\n const {\n exclusive = false,\n value,\n defaultValue,\n valueChangeAction,\n disabled = false,\n experimental_interpolateSize = false,\n className,\n style,\n children,\n render,\n ...rest\n } = props;\n\n // Mode is decided once, from the first render's props (design 12).\n const isLibraryNow =\n value !== undefined || defaultValue !== undefined || valueChangeAction !== undefined;\n const [mode] = useState<AccordionMode>(isLibraryNow ? \"library\" : \"static\");\n useDevWarning(\n (mode === \"library\") !== isLibraryNow,\n \"Accordion.Root: the mode changed after mount (`value`, `defaultValue` and `valueChangeAction` \" +\n \"were all absent on one render and present on another). Switching between JS-free and \" +\n \"library mode is not supported.\",\n );\n\n // Both prop variants are narrowed by `exclusive` at the call site; internally one signature.\n const action = valueChangeAction as\n | ChangeAction<AccordionValue, AccordionValueChangeDetails>\n | undefined;\n\n // Keep the committed set's identity stable while the consumer's `value` has the same contents,\n // so `useOptimistic` only re-bases, and the context only changes, when the controlled value\n // really changed. Keyed on the contents, not the array: an inline `value={[\"a\"]}` is a new\n // array on every render. (Order-sensitive; a reordered array only costs one new set.)\n const controlledKey = value === undefined ? undefined : JSON.stringify(value);\n const controlledSet = useMemo(\n () =>\n controlledKey === undefined ? undefined : toSet(JSON.parse(controlledKey) as AccordionValue),\n [controlledKey],\n );\n\n const items = useRef(new Map<HTMLDetailsElement, string>());\n const triggers = useRef(new Set<HTMLElement>());\n const registeredValues = () => [...items.current.values()];\n\n const { committed, optimistic, pending, dispatch, latestInFlight } = useControllableAction<\n OpenSet,\n AccordionValueChangeDetails\n >({\n controlled: controlledSet,\n defaultValue: defaultValue === undefined ? undefined : toSet(defaultValue),\n initialValue: EMPTY,\n action:\n action && ((next, details) => action(fromSet(next, exclusive, registeredValues()), details)),\n transitionTypes: (_next, _prev, details) =>\n transitionTypes(\"accordion\", details.open ? \"expand\" : \"collapse\"),\n // One item per dispatch, re-based on the committed set, except the mount reconciliation\n // (reason \"platform\", no event), which folds every pre-hydration click into one `next`.\n reducer: (prev, next, details) =>\n details.reason === \"platform\" && details.event === undefined\n ? next\n : reduce(prev, details.item, details.open, exclusive),\n warn: { component: \"Accordion.Root\", prop: \"value\" },\n });\n\n const registerItem = useCallback((itemValue: string, element: HTMLDetailsElement) => {\n items.current.set(element, itemValue);\n return () => {\n items.current.delete(element);\n };\n }, []);\n\n const registerTrigger = useCallback((element: HTMLElement) => {\n triggers.current.add(element);\n return () => {\n triggers.current.delete(element);\n };\n }, []);\n\n const dispatchChange = useCallback(\n (\n next: OpenSet,\n item: string,\n open: boolean,\n reason: AccordionChangeReason,\n event: Event | undefined,\n ): void => {\n dispatch(next, createActionDetails(event, { reason, item, open }));\n },\n [dispatch],\n );\n\n // The two dispatchers below read the last committed optimistic set through `latest`, so they\n // keep one identity and the Items' contexts are reused across open-state changes (#48): a\n // handler only ever runs against the committed UI, so this is the set it closed over before.\n const latest = useLatest({ optimistic, exclusive });\n\n const dispatchFromTrigger = useCallback<AccordionRootContextValue[\"dispatch\"]>(\n (item, open, event) => {\n const { optimistic, exclusive } = latest.current;\n // `next` comes from the optimistic set: what the user sees and intends (design 2.2).\n dispatchChange(reduce(optimistic, item, open, exclusive), item, open, \"activate\", event);\n },\n [dispatchChange, latest],\n );\n\n const dispatchFromDom = useCallback<AccordionRootContextValue[\"dispatchFromDom\"]>(\n (item, open, event) => {\n const { optimistic, exclusive } = latest.current;\n // The browser flipped one item (design 2.3). `next` builds on what the user already\n // intends (the latest in-flight dispatch, else the optimistic set), never on the DOM: a\n // pending optimistic open would otherwise be lost to latest-wins. Exclusive mode therefore\n // lets the toggled item win when it opened (walkthrough 9.6).\n const base = latestInFlight()?.next ?? optimistic;\n const next = reduce(base, item, open, exclusive);\n if (setsEqual(next, base)) return;\n dispatchChange(next, item, open, \"platform\", event);\n },\n [dispatchChange, latestInFlight, latest],\n );\n\n const isLibrary = mode === \"library\";\n\n // Mount reconciliation (design 2.3): clicks before hydration left some `<details open>` out of\n // step with committed state. Every mismatch is folded into ONE dispatch with reason \"platform\"\n // and no event; disabled items are simply put back. Runs once per mount; the StrictMode re-run\n // is deduplicated against the dispatch just made.\n const reconcileOnMount = useEffectEvent(() => {\n const base = latestInFlight()?.next ?? optimistic;\n const mismatches: { item: string; open: boolean }[] = [];\n for (const [element, item] of items.current) {\n const want = committed.has(item);\n if (element.open === want) continue;\n if (element.hasAttribute(\"data-disabled\")) applyOpen(element, want);\n else mismatches.push({ item, open: element.open });\n }\n if (mismatches.length === 0) return;\n // Exclusive mode: the first opened item in registration order wins (the others are re-closed\n // by the re-apply effect); otherwise fold every flip onto the base.\n const opened = exclusive ? mismatches.find((m) => m.open) : undefined;\n const chosen = opened ?? mismatches[0]!;\n const next = opened\n ? new Set([opened.item])\n : mismatches.reduce((set, m) => reduce(set, m.item, m.open, exclusive), base);\n if (setsEqual(next, base)) return;\n dispatchChange(next, chosen.item, chosen.open, \"platform\", undefined);\n });\n useLayoutEffect(() => {\n if (isLibrary) reconcileOnMount();\n }, [isLibrary]);\n\n // Re-apply committed state to the DOM once nothing is in flight: closes what find-in-page\n // revealed and the parent refused, or what a rejected action left open. Writing `open` fires\n // `toggle`, whose handler sees DOM === committed and does nothing.\n useLayoutEffect(() => {\n if (!isLibrary || pending || latestInFlight() !== null) return;\n for (const [element, item] of items.current) applyOpen(element, committed.has(item));\n }, [isLibrary, pending, committed, latestInFlight]);\n\n function onKeyDown(event: KeyboardEvent<HTMLDivElement>): void {\n if (!NAV_KEYS.has(event.key)) return;\n const target = event.target;\n if (!(target instanceof HTMLElement) || !triggers.current.has(target)) return;\n const sorted = [...triggers.current].sort(byDocumentOrder);\n const next = nextTrigger(sorted, target, event.key);\n if (next === undefined) return;\n event.preventDefault();\n // A nested Root handles its own triggers; the outer one must not move focus again.\n event.stopPropagation();\n next.focus();\n }\n\n const id = useId();\n const name = !isLibrary && exclusive ? id : undefined;\n const rootPending = isLibrary && pending;\n const state: AccordionRootState = { pending: rootPending, disabled };\n const contextCommitted = isLibrary ? committed : EMPTY;\n const contextOptimistic = isLibrary ? optimistic : EMPTY;\n\n // Memoised (design 12, #48): the dispatchers are stable, so this changes only with the open\n // sets, pending and the props below.\n const context = useMemo<AccordionRootContextValue>(\n () => ({\n mode,\n exclusive,\n name,\n disabled,\n pending: rootPending,\n committed: contextCommitted,\n optimistic: contextOptimistic,\n dispatch: dispatchFromTrigger,\n dispatchFromDom,\n registerItem,\n registerTrigger,\n }),\n [\n mode,\n exclusive,\n name,\n disabled,\n rootPending,\n contextCommitted,\n contextOptimistic,\n dispatchFromTrigger,\n dispatchFromDom,\n registerItem,\n registerTrigger,\n ],\n );\n\n const resolvedStyle = resolveStateValue(style, state);\n const finalStyle: CSSProperties | undefined = experimental_interpolateSize\n ? { interpolateSize: \"allow-keywords\", ...resolvedStyle }\n : resolvedStyle;\n\n const element = useRender<ComponentPropsWithRef<\"div\">, AccordionRootState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style: finalStyle,\n children,\n props: rest,\n // Library-controlled layer: wins over a `render` element's props (conventions 1.2).\n libraryProps: {\n \"data-pending\": dataAttr(state.pending),\n \"data-disabled\": dataAttr(disabled),\n onKeyDown,\n },\n });\n\n return <AccordionRootContext value={context}>{element}</AccordionRootContext>;\n}\n\nAccordionRoot.displayName = \"AccordionRoot\";\n"],"mappings":";;;;;;;;;;;;;AAkHA,MAAM,wBAAiB,IAAI,IAAI;AAE/B,SAAS,MAAM,OAAgC;CAC7C,IAAI,UAAU,MAAM,OAAO;CAC3B,OAAO,OAAO,UAAU,2BAAW,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,KAAK;AACrE;;;;;;AAOA,SAAS,QAAQ,KAAc,WAAoB,OAA0C;CAC3F,IAAI,WAAW;EACb,MAAM,CAAC,SAAS;EAChB,OAAO,SAAS;CAClB;CACA,MAAM,QAAQ,IAAI,IAAI,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAU,CAAC;CAC1D,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,GAAG,OAAO,MAAM,IAAI,CAAC,KAAK,aAAa,MAAM,IAAI,CAA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CACnE,MAAM,mBAAmB,YAAY,YAAY;CACjD,MAAM,oBAAoB,YAAY,aAAa;CAInD,MAAM,UAAU,eACP;EACL;EACA;EACA;EACA;EACA,SAAS;EACT,WAAW;EACX,YAAY;EACZ,UAAU;EACV;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,gBAAgB,kBAAkB,OAAO,KAAK;CACpD,MAAM,aAAwC,+BAC1C;EAAE,iBAAiB;EAAkB,GAAG;CAAc,IACtD;CAEJ,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA;EACA;EACA,OAAO;EACP;EACA,OAAO;EAEP,cAAc;GACZ,gBAAgB,SAAS,MAAM,OAAO;GACtC,iBAAiB,SAAS,QAAQ;GAClC;EACF;CACF,CAAC;CAED,OAAO,oBAAC,sBAAD;EAAsB,OAAO;EAAU,UAAA;CAA8B,CAAA;AAC9E;AAEA,cAAc,cAAc"}
1
+ {"version":3,"file":"accordion-root.mjs","names":[],"sources":["../../src/accordion/accordion-root.tsx"],"sourcesContent":["\"use client\";\nimport {\n useCallback,\n useEffectEvent,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, KeyboardEvent, 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 { transitionTypes } from \"../internal/transition-types.js\";\nimport type {\n ActionDetails,\n ChangeAction,\n ChangeReason,\n RenderProp,\n StateValue,\n} 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 { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport { EMPTY_SET, setsEqual, toSet } from \"../internal/value-set.js\";\nimport type { ValueSet } from \"../internal/value-set.js\";\nimport { AccordionRootContext } from \"./accordion-context.js\";\nimport type { AccordionMode, AccordionRootContextValue } from \"./accordion-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface AccordionRootState {\n /** An action dispatched through this Accordion is in flight (library mode only). */\n readonly pending: boolean;\n /** The Root's `disabled` prop. */\n readonly disabled: boolean;\n}\n\n/** Details passed as the second argument of `valueChangeAction`. */\nexport interface AccordionValueChangeDetails extends ActionDetails {\n /**\n * The shared vocabulary (conventions 2.2); Accordion dispatches two of its values.\n * `\"activate\"`: the user activated a Trigger. `\"platform\"`: the browser changed `open` itself\n * (find-in-page, a text fragment, a click before hydration); `event` is then the `toggle`\n * event, or `undefined` when the mismatch was found on mount.\n */\n readonly reason: ChangeReason;\n /** The item whose open state changed. */\n readonly item: string;\n /** That item's new open state. */\n readonly open: boolean;\n}\n\ninterface AccordionRootBaseProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n // `defaultValue` is also a native HTMLAttributes member; the Accordion's own definition wins.\n \"onKeyDown\" | \"defaultValue\" | \"className\" | \"style\" | \"children\"\n> {\n /** Disables every item: triggers render `aria-disabled` and never dispatch. Default `false`. */\n disabled?: boolean;\n /**\n * Renders `interpolate-size: allow-keywords` on the root so `::details-content` can transition\n * `height` to `auto`. Chromium-only polish today; use the `grid-template-rows` form for a\n * cross-engine animation. Merged with `style`; the consumer's declaration wins.\n */\n experimental_interpolateSize?: boolean;\n className?: StateValue<string | undefined, AccordionRootState>;\n style?: StateValue<CSSProperties | undefined, AccordionRootState>;\n children?: StateValue<ReactNode, AccordionRootState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, AccordionRootState>;\n}\n\nexport interface AccordionRootMultipleProps extends AccordionRootBaseProps {\n /** Any number of items may be open. */\n exclusive?: false;\n /** Controlled open items. `undefined` means uncontrolled; `[]` means none open. */\n value?: string[];\n /** Initial open items in uncontrolled library mode. */\n defaultValue?: string[];\n /**\n * Called with the next open items on every change. Runs inside the Root's transition; may be\n * sync or async (also a Server Function). Rejections reach the nearest Error Boundary.\n *\n * May also be called with `details.reason === \"platform\"` when the browser opened an item\n * itself (find-in-page, a click before hydration); committed state is re-applied to the DOM\n * once the action settles.\n *\n * A `setState` placed after your own `await` is not a Transition update; wrap it in\n * `startTransition` (React limitation).\n */\n valueChangeAction?: ChangeAction<string[], AccordionValueChangeDetails>;\n}\n\nexport interface AccordionRootExclusiveProps extends AccordionRootBaseProps {\n /**\n * At most one item open. JS-free mode: renders the same `name` on every `<details>` (the\n * platform's exclusive group). Library mode: the value is a single item or `null`.\n */\n exclusive: true;\n /** Controlled open item. `undefined` means uncontrolled; `null` means none open. */\n value?: string | null;\n /** Initial open item in uncontrolled library mode. */\n defaultValue?: string | null;\n /** See {@link AccordionRootMultipleProps.valueChangeAction}. */\n valueChangeAction?: ChangeAction<string | null, AccordionValueChangeDetails>;\n}\n\n/**\n * Props of `Accordion.Root`, discriminated on `exclusive`.\n *\n * Without `value`, `defaultValue` and `valueChangeAction` the Accordion runs in **JS-free mode**:\n * the browser owns each `<details open>`, nothing runs on toggle, and `exclusive` renders `name`.\n * With any of them it runs in **library mode**: the summary click is intercepted, `open` is driven\n * by committed state inside a transition, and triggers show optimistic `data-open`.\n */\nexport type AccordionRootProps = AccordionRootMultipleProps | AccordionRootExclusiveProps;\n\ntype AccordionValue = string[] | string | null;\ntype OpenSet = ValueSet;\n\n/**\n * Converts the open set back to the public value. Multiple mode lists the items in registration\n * order (the order the Items mounted, which is document order for a list rendered top to bottom),\n * not in the order they were opened; unregistered values keep their insertion order at the end.\n */\nfunction fromSet(set: OpenSet, exclusive: boolean, order: readonly string[]): AccordionValue {\n if (exclusive) {\n const [first] = set;\n return first ?? null;\n }\n const index = new Map(order.map((v, i) => [v, i] as const));\n return [...set].sort((a, b) => (index.get(a) ?? Infinity) - (index.get(b) ?? Infinity));\n}\n\n/** The optimistic reducer of design 4.1: add/remove one item, or replace when exclusive. */\nfunction reduce(set: OpenSet, item: string, open: boolean, exclusive: boolean): OpenSet {\n if (!open) {\n if (!set.has(item)) return set;\n const next = new Set(set);\n next.delete(item);\n return next;\n }\n if (exclusive) return new Set([item]);\n return set.has(item) ? set : new Set(set).add(item);\n}\n\nconst NAV_KEYS = new Set([\"ArrowDown\", \"ArrowUp\", \"Home\", \"End\"]);\n\n/** Writes `open` to the DOM; it fires `toggle`, whose handler sees DOM === committed and returns. */\nfunction applyOpen(element: HTMLDetailsElement, open: boolean): void {\n if (element.open !== open) element.open = open;\n}\n\nfunction isEnabledTrigger(el: HTMLElement): boolean {\n return el.getAttribute(\"aria-disabled\") !== \"true\";\n}\n\n/**\n * Picks the trigger to focus for an arrow/Home/End key: `sorted` is every registered trigger in\n * document order; disabled ones are skipped; arrows wrap. Works when `current` is itself disabled\n * (disabled triggers stay focusable).\n */\nfunction nextTrigger(\n sorted: readonly HTMLElement[],\n current: HTMLElement,\n key: string,\n): HTMLElement | undefined {\n const enabled = sorted.filter(isEnabledTrigger);\n if (enabled.length === 0) return undefined;\n if (key === \"Home\") return enabled[0];\n if (key === \"End\") return enabled[enabled.length - 1];\n const position = sorted.indexOf(current);\n if (key === \"ArrowDown\") {\n return enabled.find((el) => sorted.indexOf(el) > position) ?? enabled[0];\n }\n return enabled.findLast((el) => sorted.indexOf(el) < position) ?? enabled[enabled.length - 1];\n}\n\n/**\n * The accordion container: a `div` that owns the open state, the transition, the context the\n * other parts read, and ArrowUp/ArrowDown/Home/End navigation between triggers.\n */\nexport function AccordionRoot(props: AccordionRootProps) {\n const {\n exclusive = false,\n value,\n defaultValue,\n valueChangeAction,\n disabled = false,\n experimental_interpolateSize = false,\n className,\n style,\n children,\n render,\n ...rest\n } = props;\n\n // Mode is decided once, from the first render's props (design 12).\n const isLibraryNow =\n value !== undefined || defaultValue !== undefined || valueChangeAction !== undefined;\n const [mode] = useState<AccordionMode>(isLibraryNow ? \"library\" : \"static\");\n useDevWarning(\n (mode === \"library\") !== isLibraryNow,\n isDev &&\n \"Accordion.Root: the mode changed after mount (`value`, `defaultValue` and `valueChangeAction` \" +\n \"were all absent on one render and present on another). Switching between JS-free and \" +\n \"library mode is not supported.\",\n );\n\n // Both prop variants are narrowed by `exclusive` at the call site; internally one signature.\n const action = valueChangeAction as\n | ChangeAction<AccordionValue, AccordionValueChangeDetails>\n | undefined;\n\n // Keep the committed set's identity stable while the consumer's `value` has the same contents,\n // so `useOptimistic` only re-bases, and the context only changes, when the controlled value\n // really changed. Keyed on the contents, not the array: an inline `value={[\"a\"]}` is a new\n // array on every render. (Order-sensitive; a reordered array only costs one new set.)\n const controlledKey = value === undefined ? undefined : JSON.stringify(value);\n const controlledSet = useMemo(\n () =>\n controlledKey === undefined ? undefined : toSet(JSON.parse(controlledKey) as AccordionValue),\n [controlledKey],\n );\n\n const items = useRef(new Map<HTMLDetailsElement, string>());\n const triggers = useRef(new Set<HTMLElement>());\n const registeredValues = () => [...items.current.values()];\n\n const { committed, optimistic, pending, dispatch, latestInFlight } = useControllableAction<\n OpenSet,\n AccordionValueChangeDetails\n >({\n controlled: controlledSet,\n defaultValue: defaultValue === undefined ? undefined : toSet(defaultValue),\n initialValue: EMPTY_SET,\n action:\n action && ((next, details) => action(fromSet(next, exclusive, registeredValues()), details)),\n transitionTypes: (_next, _prev, details) =>\n transitionTypes(\"accordion\", details.open ? \"expand\" : \"collapse\"),\n // One item per dispatch, re-based on the committed set, except the mount reconciliation\n // (reason \"platform\", no event), which folds every pre-hydration click into one `next`.\n reducer: (prev, next, details) =>\n details.reason === \"platform\" && details.event === undefined\n ? next\n : reduce(prev, details.item, details.open, exclusive),\n warn: { component: \"Accordion.Root\", prop: \"value\" },\n });\n\n const registerItem = useCallback((itemValue: string, element: HTMLDetailsElement) => {\n items.current.set(element, itemValue);\n return () => {\n items.current.delete(element);\n };\n }, []);\n\n const registerTrigger = useCallback((element: HTMLElement) => {\n triggers.current.add(element);\n return () => {\n triggers.current.delete(element);\n };\n }, []);\n\n const dispatchChange = useCallback(\n (\n next: OpenSet,\n item: string,\n open: boolean,\n reason: ChangeReason,\n event: Event | undefined,\n ): void => {\n dispatch(next, createActionDetails(event, { reason, item, open }));\n },\n [dispatch],\n );\n\n // The two dispatchers below read the last committed optimistic set through `latest`, so they\n // keep one identity and the Items' contexts are reused across open-state changes: a\n // handler only ever runs against the committed UI, so this is the set it closed over before.\n const latest = useLatest({ optimistic, exclusive });\n\n const dispatchFromTrigger = useCallback<AccordionRootContextValue[\"dispatch\"]>(\n (item, open, event) => {\n const { optimistic, exclusive } = latest.current;\n // `next` comes from the optimistic set: what the user sees and intends (design 2.2).\n dispatchChange(reduce(optimistic, item, open, exclusive), item, open, \"activate\", event);\n },\n [dispatchChange, latest],\n );\n\n const dispatchFromDom = useCallback<AccordionRootContextValue[\"dispatchFromDom\"]>(\n (item, open, event) => {\n const { optimistic, exclusive } = latest.current;\n // The browser flipped one item (design 2.3). `next` builds on what the user already\n // intends (the latest in-flight dispatch, else the optimistic set), never on the DOM: a\n // pending optimistic open would otherwise be lost to latest-wins. Exclusive mode therefore\n // lets the toggled item win when it opened (design walkthrough 9.6).\n const base = latestInFlight()?.next ?? optimistic;\n const next = reduce(base, item, open, exclusive);\n if (setsEqual(next, base)) return;\n dispatchChange(next, item, open, \"platform\", event);\n },\n [dispatchChange, latestInFlight, latest],\n );\n\n const isLibrary = mode === \"library\";\n\n // Mount reconciliation (design 2.3): clicks before hydration left some `<details open>` out of\n // step with committed state. Every mismatch is folded into ONE dispatch with reason \"platform\"\n // and no event; disabled items are simply put back. Runs once per mount; the StrictMode re-run\n // is deduplicated against the dispatch just made.\n const reconcileOnMount = useEffectEvent(() => {\n const base = latestInFlight()?.next ?? optimistic;\n const mismatches: { item: string; open: boolean }[] = [];\n for (const [element, item] of items.current) {\n const want = committed.has(item);\n if (element.open === want) continue;\n if (element.hasAttribute(\"data-disabled\")) applyOpen(element, want);\n else mismatches.push({ item, open: element.open });\n }\n if (mismatches.length === 0) return;\n // Exclusive mode: the first opened item in registration order wins (the others are re-closed\n // by the re-apply effect); otherwise fold every flip onto the base.\n const opened = exclusive ? mismatches.find((m) => m.open) : undefined;\n const chosen = opened ?? mismatches[0]!;\n const next = opened\n ? new Set([opened.item])\n : mismatches.reduce((set, m) => reduce(set, m.item, m.open, exclusive), base);\n if (setsEqual(next, base)) return;\n dispatchChange(next, chosen.item, chosen.open, \"platform\", undefined);\n });\n useLayoutEffect(() => {\n if (isLibrary) reconcileOnMount();\n }, [isLibrary]);\n\n // Re-apply committed state to the DOM once nothing is in flight: closes what find-in-page\n // revealed and the parent refused, or what a rejected action left open. Writing `open` fires\n // `toggle`, whose handler sees DOM === committed and does nothing.\n useLayoutEffect(() => {\n if (!isLibrary || pending || latestInFlight() !== null) return;\n for (const [element, item] of items.current) applyOpen(element, committed.has(item));\n }, [isLibrary, pending, committed, latestInFlight]);\n\n function onKeyDown(event: KeyboardEvent<HTMLDivElement>): void {\n if (!NAV_KEYS.has(event.key)) return;\n const target = event.target;\n if (!(target instanceof HTMLElement) || !triggers.current.has(target)) return;\n const sorted = [...triggers.current].sort(compareDocumentOrder);\n const next = nextTrigger(sorted, target, event.key);\n if (next === undefined) return;\n event.preventDefault();\n // A nested Root handles its own triggers; the outer one must not move focus again.\n event.stopPropagation();\n next.focus();\n }\n\n const id = useId();\n const name = !isLibrary && exclusive ? id : undefined;\n const rootPending = isLibrary && pending;\n const state: AccordionRootState = { pending: rootPending, disabled };\n const contextCommitted = isLibrary ? committed : EMPTY_SET;\n const contextOptimistic = isLibrary ? optimistic : EMPTY_SET;\n\n // Memoised (design 12): the dispatchers are stable, so this changes only with the open\n // sets, pending and the props below.\n const context = useMemo<AccordionRootContextValue>(\n () => ({\n mode,\n exclusive,\n name,\n disabled,\n pending: rootPending,\n committed: contextCommitted,\n optimistic: contextOptimistic,\n dispatch: dispatchFromTrigger,\n dispatchFromDom,\n registerItem,\n registerTrigger,\n }),\n [\n mode,\n exclusive,\n name,\n disabled,\n rootPending,\n contextCommitted,\n contextOptimistic,\n dispatchFromTrigger,\n dispatchFromDom,\n registerItem,\n registerTrigger,\n ],\n );\n\n const resolvedStyle = resolveStateValue(style, state);\n const finalStyle: CSSProperties | undefined = experimental_interpolateSize\n ? { interpolateSize: \"allow-keywords\", ...resolvedStyle }\n : resolvedStyle;\n\n const element = useRender<ComponentPropsWithRef<\"div\">, AccordionRootState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style: finalStyle,\n children,\n props: rest,\n // Library-controlled layer: wins over a `render` element's props (conventions 1.2).\n libraryProps: {\n \"data-pending\": dataAttr(state.pending),\n \"data-disabled\": dataAttr(disabled),\n onKeyDown,\n },\n });\n\n return <AccordionRootContext value={context}>{element}</AccordionRootContext>;\n}\n\nAccordionRoot.displayName = \"AccordionRoot\";\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;AAgGvC,SAAS,QAAQ,KAAc,WAAoB,OAA0C;CAC3F,IAAI,WAAW;EACb,MAAM,CAAC,SAAS;EAChB,OAAO,SAAS;CAClB;CACA,MAAM,QAAQ,IAAI,IAAI,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAU,CAAC;CAC1D,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,GAAG,OAAO,MAAM,IAAI,CAAC,KAAK,aAAa,MAAM,IAAI,CAAC,KAAK,SAAS;AACxF;;AAGA,SAAS,OAAO,KAAc,MAAc,MAAe,WAA6B;CACtF,IAAI,CAAC,MAAM;EACT,IAAI,CAAC,IAAI,IAAI,IAAI,GAAG,OAAO;EAC3B,MAAM,OAAO,IAAI,IAAI,GAAG;EACxB,KAAK,OAAO,IAAI;EAChB,OAAO;CACT;CACA,IAAI,WAAW,uBAAO,IAAI,IAAI,CAAC,IAAI,CAAC;CACpC,OAAO,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI;AACpD;AAEA,MAAM,2BAAW,IAAI,IAAI;CAAC;CAAa;CAAW;CAA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C;EAAW;EAAS;EAAW;CAAc,CAAC;CAElD,SAAS,UAAU,OAA4C;EAC7D,IAAI,CAAC,SAAS,IAAI,MAAM,GAAG,GAAG;EAC9B,MAAM,SAAS,MAAM;EACrB,IAAI,EAAE,kBAAkB,gBAAgB,CAAC,SAAS,QAAQ,IAAI,MAAM,GAAG;EAEvE,MAAM,OAAO,YADE,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC,KAAK,oBACZ,GAAG,QAAQ,MAAM,GAAG;EAClD,IAAI,SAAS,KAAA,GAAW;EACxB,MAAM,eAAe;EAErB,MAAM,gBAAgB;EACtB,KAAK,MAAM;CACb;CAEA,MAAM,KAAK,MAAM;CACjB,MAAM,OAAO,CAAC,aAAa,YAAY,KAAK,KAAA;CAC5C,MAAM,cAAc,aAAa;CACjC,MAAM,QAA4B;EAAE,SAAS;EAAa;CAAS;CACnE,MAAM,mBAAmB,YAAY,YAAY;CACjD,MAAM,oBAAoB,YAAY,aAAa;CAInD,MAAM,UAAU,eACP;EACL;EACA;EACA;EACA;EACA,SAAS;EACT,WAAW;EACX,YAAY;EACZ,UAAU;EACV;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,gBAAgB,kBAAkB,OAAO,KAAK;CACpD,MAAM,aAAwC,+BAC1C;EAAE,iBAAiB;EAAkB,GAAG;CAAc,IACtD;CAEJ,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA;EACA;EACA,OAAO;EACP;EACA,OAAO;EAEP,cAAc;GACZ,gBAAgB,SAAS,MAAM,OAAO;GACtC,iBAAiB,SAAS,QAAQ;GAClC;EACF;CACF,CAAC;CAED,OAAO,oBAAC,sBAAD;EAAsB,OAAO;EAAU,UAAA;CAA8B,CAAA;AAC9E;AAEA,cAAc,cAAc"}
@@ -10,10 +10,9 @@ export interface AccordionTriggerProps extends Omit<ComponentPropsWithRef<"summa
10
10
  * Animates only the commit that ends an action (for example a spinner rendered from `pending`
11
11
  * disappearing); the optimistic `data-open` flip is a CSS job.
12
12
  *
13
- * Static: without `transition` the part renders no `<ViewTransition>`; changing it between
14
- * `undefined` and a value remounts the element. Any value, `"none"` included, makes a mount or
15
- * `<Activity>` reveal of this part inside a transition start a document view transition: the
16
- * page cross-fades for about 250 ms and the next transition commit waits for it (issue #35).
13
+ * Static: setting or unsetting it remounts the element. Any value, `"none"` included, makes a
14
+ * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms
15
+ * page cross-fade that the next transition waits for).
17
16
  */
18
17
  transition?: ViewTransitionClass;
19
18
  className?: StateValue<string | undefined, AccordionTriggerState>;
@@ -1 +1 @@
1
- {"version":3,"file":"accordion-trigger.d.mts","names":[],"sources":["../../src/accordion/accordion-trigger.tsx"],"mappings":";;;;;YAkBY,wBAAwB;iBAEnB,8BAA8B,KAC7C;;;;;;;;;;;EAaA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,kCAAkC;;;;;;;;wBA+BxC,mBACd,YACA,WACA,OACA,UACA,WACG,QACF,wBAAqB;yBAPR"}
1
+ {"version":3,"file":"accordion-trigger.d.mts","names":[],"sources":["../../src/accordion/accordion-trigger.tsx"],"mappings":";;;;;YAqBY,wBAAwB;iBAEnB,8BAA8B,KAC7C;;;;;;;;;;EAYA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,kCAAkC;;;;;;;;wBA6BxC,mBACd,YACA,WACA,OACA,UACA,WACG,QACF,wBAAqB;yBAPR"}
@@ -3,6 +3,7 @@ import { dataAttr } from "../internal/data-attr.mjs";
3
3
  import { useTransitionBoundary } from "../internal/transition-boundary.mjs";
4
4
  import { useDevWarning } from "../internal/use-dev-warning.mjs";
5
5
  import { useRender } from "../internal/use-render.mjs";
6
+ import { useElementCheck } from "../internal/use-element-check.mjs";
6
7
  import { AccordionItemContext } from "./accordion-context.mjs";
7
8
  import { use, useCallback } from "react";
8
9
  //#region src/accordion/accordion-trigger.tsx
@@ -29,15 +30,16 @@ function AccordionTrigger({ transition, className, style, children, render, ...r
29
30
  const item = use(AccordionItemContext);
30
31
  if (item === null) throw new Error("Accordion.Trigger must be rendered inside an Accordion.Item.");
31
32
  const isLibrary = item.library;
32
- useDevWarning(!isLibrary && transition !== void 0, "Accordion.Trigger: `transition` has no effect in JS-free mode; the browser toggles the item outside any React transition.");
33
+ useDevWarning(!isLibrary && transition !== void 0, isDev && "Accordion.Trigger: `transition` has no effect in JS-free mode; the browser toggles the item outside any React transition.");
33
34
  const registerTrigger = item.registerTrigger;
35
+ const checkElement = useElementCheck(isDev && ((element) => element.tagName !== "SUMMARY" ? `Accordion.Trigger: expected to render a <summary> element but got <${element.tagName.toLowerCase()}>. Only a <summary> toggles its parent <details>.` : null));
34
36
  const libraryRef = useCallback((element) => {
35
- if (isDev && element.tagName !== "SUMMARY") console.error(`Accordion.Trigger: expected to render a <summary> element but got <${element.tagName.toLowerCase()}>. Only a <summary> toggles its parent <details>.`);
37
+ checkElement?.(element);
36
38
  const unregister = registerTrigger?.(element);
37
39
  return () => {
38
40
  unregister?.();
39
41
  };
40
- }, [registerTrigger]);
42
+ }, [checkElement, registerTrigger]);
41
43
  const state = {
42
44
  value: item.value,
43
45
  open: item.optimisticOpen,
@@ -1 +1 @@
1
- {"version":3,"file":"accordion-trigger.mjs","names":[],"sources":["../../src/accordion/accordion-trigger.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { AccordionItemContext } from \"./accordion-context.js\";\nimport type { AccordionItemState } from \"./accordion-item.js\";\n\n/** The trigger is the item's control; it renders the item's state object. */\nexport type AccordionTriggerState = AccordionItemState;\n\nexport interface AccordionTriggerProps extends Omit<\n ComponentPropsWithRef<\"summary\">,\n \"onClick\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Library mode only. Forwarded as `default` to the `<ViewTransition>` around the `<summary>`.\n * Animates only the commit that ends an action (for example a spinner rendered from `pending`\n * disappearing); the optimistic `data-open` flip is a CSS job.\n *\n * Static: without `transition` the part renders no `<ViewTransition>`; changing it between\n * `undefined` and a value remounts the element. Any value, `\"none\"` included, makes a mount or\n * `<Activity>` reveal of this part inside a transition start a document view transition: the\n * page cross-fades for about 250 ms and the next transition commit waits for it (issue #35).\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, AccordionTriggerState>;\n style?: StateValue<CSSProperties | undefined, AccordionTriggerState>;\n /** Rendered from optimistic state; must not suspend. A heading inside is recommended. */\n children?: StateValue<ReactNode, AccordionTriggerState>;\n /** Must render a `<summary>` element. */\n render?: RenderProp<ComponentPropsWithRef<\"summary\">, AccordionTriggerState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nconst NESTED_INTERACTIVE =\n \"a[href], button, label, input, select, textarea, [contenteditable]:not([contenteditable='false'])\";\n\n/**\n * Nested controls with an activation behaviour of their own. The browser runs theirs instead of\n * the summary's (no toggle), so their click must keep its default: navigation, check, submit.\n */\nconst SELF_ACTIVATING =\n \"a[href], button, label, input:is([type='button'], [type='submit'], [type='reset'], \" +\n \"[type='image'], [type='checkbox'], [type='radio'], [type='file'], [type='color'])\";\n\n/** The interactive descendant of the summary that was clicked (a link in the heading), if any. */\nfunction nestedInteractive(target: EventTarget | null, summary: HTMLElement): Element | null {\n if (!(target instanceof Element) || target === summary) return null;\n const interactive = target.closest(NESTED_INTERACTIVE);\n return interactive !== null && interactive !== summary && summary.contains(interactive)\n ? interactive\n : null;\n}\n\n/**\n * The item's disclosure control: the `<summary>`, which must be the first child of the Item. In\n * library mode the click is intercepted and dispatched through the Root's transition; the\n * element shows optimistic `data-open` and `data-pending`. The platform forbids `aria-expanded`\n * on a summary, so assistive technology hears the committed state (from `<details open>`).\n */\nexport function AccordionTrigger({\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: AccordionTriggerProps) {\n // Only the Item's context (memoised per item, #48), which carries what is needed of the Root's.\n const item = use(AccordionItemContext);\n if (item === null) {\n throw new Error(\"Accordion.Trigger must be rendered inside an Accordion.Item.\");\n }\n const isLibrary = item.library;\n\n useDevWarning(\n !isLibrary && transition !== undefined,\n \"Accordion.Trigger: `transition` has no effect in JS-free mode; the browser toggles the item \" +\n \"outside any React transition.\",\n );\n\n const registerTrigger = item.registerTrigger;\n const libraryRef = useCallback(\n (element: HTMLElement) => {\n if (isDev && element.tagName !== \"SUMMARY\") {\n console.error(\n `Accordion.Trigger: expected to render a <summary> element but got <${element.tagName.toLowerCase()}>. ` +\n \"Only a <summary> toggles its parent <details>.\",\n );\n }\n const unregister = registerTrigger?.(element);\n // Always return a cleanup so the merged ref never calls back with `null`.\n return () => {\n unregister?.();\n };\n },\n [registerTrigger],\n );\n\n const state: AccordionTriggerState = {\n value: item.value,\n open: item.optimisticOpen,\n pending: item.pending,\n disabled: item.disabled,\n };\n\n // JS-free mode attaches no click handler unless the item is disabled (design 2.1 / section 6).\n const onClick =\n isLibrary || item.disabled\n ? (event: MouseEvent<HTMLElement>) => {\n const nested = nestedInteractive(event.target, event.currentTarget);\n if (nested !== null) {\n // A nested control never toggles. Controls without their own activation behaviour\n // (text input, select, textarea, contenteditable) would let the click fall through to\n // the summary's toggle, so cancel it; focus and pickers happen on mousedown and are\n // unaffected. Self-activating controls already pre-empt the summary's behaviour.\n if (!nested.matches(SELF_ACTIVATING)) event.preventDefault();\n return;\n }\n // Cancelling the click is what keeps the browser from touching `open`.\n event.preventDefault();\n if (item.disabled || !isLibrary) return;\n item.dispatch?.(item.value, !item.optimisticOpen, event.nativeEvent);\n }\n : undefined;\n\n const element = useRender<ComponentPropsWithRef<\"summary\">, AccordionTriggerState>({\n defaultElement: \"summary\",\n render,\n state,\n className,\n style,\n children,\n ref: libraryRef,\n props: rest,\n // Library-controlled layer: wins over a `render` element's props (conventions 1.2).\n libraryProps: {\n \"aria-disabled\": item.disabled ? true : undefined,\n \"data-open\": dataAttr(item.optimisticOpen === true),\n \"data-pending\": dataAttr(item.pending),\n \"data-disabled\": dataAttr(item.disabled),\n // Only owned when installed, so a render element keeps its own `onClick` in JS-free mode.\n ...(onClick && { onClick }),\n },\n });\n\n return useTransitionBoundary(\"Accordion.Trigger\", isLibrary ? transition : undefined, element);\n}\n\nAccordionTrigger.displayName = \"AccordionTrigger\";\n"],"mappings":";;;;;;;;AA2CA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,MAAM,qBACJ;;;;;AAMF,MAAM,kBACJ;;AAIF,SAAS,kBAAkB,QAA4B,SAAsC;CAC3F,IAAI,EAAE,kBAAkB,YAAY,WAAW,SAAS,OAAO;CAC/D,MAAM,cAAc,OAAO,QAAQ,kBAAkB;CACrD,OAAO,gBAAgB,QAAQ,gBAAgB,WAAW,QAAQ,SAAS,WAAW,IAClF,cACA;AACN;;;;;;;AAQA,SAAgB,iBAAiB,EAC/B,YACA,WACA,OACA,UACA,QACA,GAAG,QACqB;CAExB,MAAM,OAAO,IAAI,oBAAoB;CACrC,IAAI,SAAS,MACX,MAAM,IAAI,MAAM,8DAA8D;CAEhF,MAAM,YAAY,KAAK;CAEvB,cACE,CAAC,aAAa,eAAe,KAAA,GAC7B,2HAEF;CAEA,MAAM,kBAAkB,KAAK;CAC7B,MAAM,aAAa,aAChB,YAAyB;EACxB,IAAI,SAAS,QAAQ,YAAY,WAC/B,QAAQ,MACN,sEAAsE,QAAQ,QAAQ,YAAY,EAAE,kDAEtG;EAEF,MAAM,aAAa,kBAAkB,OAAO;EAE5C,aAAa;GACX,aAAa;EACf;CACF,GACA,CAAC,eAAe,CAClB;CAEA,MAAM,QAA+B;EACnC,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,SAAS,KAAK;EACd,UAAU,KAAK;CACjB;CAGA,MAAM,UACJ,aAAa,KAAK,YACb,UAAmC;EAClC,MAAM,SAAS,kBAAkB,MAAM,QAAQ,MAAM,aAAa;EAClE,IAAI,WAAW,MAAM;GAKnB,IAAI,CAAC,OAAO,QAAQ,eAAe,GAAG,MAAM,eAAe;GAC3D;EACF;EAEA,MAAM,eAAe;EACrB,IAAI,KAAK,YAAY,CAAC,WAAW;EACjC,KAAK,WAAW,KAAK,OAAO,CAAC,KAAK,gBAAgB,MAAM,WAAW;CACrE,IACA,KAAA;CAEN,MAAM,UAAU,UAAmE;EACjF,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,KAAK;EACL,OAAO;EAEP,cAAc;GACZ,iBAAiB,KAAK,WAAW,OAAO,KAAA;GACxC,aAAa,SAAS,KAAK,mBAAmB,IAAI;GAClD,gBAAgB,SAAS,KAAK,OAAO;GACrC,iBAAiB,SAAS,KAAK,QAAQ;GAEvC,GAAI,WAAW,EAAE,QAAQ;EAC3B;CACF,CAAC;CAED,OAAO,sBAAsB,qBAAqB,YAAY,aAAa,KAAA,GAAW,OAAO;AAC/F;AAEA,iBAAiB,cAAc"}
1
+ {"version":3,"file":"accordion-trigger.mjs","names":[],"sources":["../../src/accordion/accordion-trigger.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { AccordionItemContext } from \"./accordion-context.js\";\nimport type { AccordionItemState } from \"./accordion-item.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** The trigger is the item's control; it renders the item's state object. */\nexport type AccordionTriggerState = AccordionItemState;\n\nexport interface AccordionTriggerProps extends Omit<\n ComponentPropsWithRef<\"summary\">,\n \"onClick\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Library mode only. Forwarded as `default` to the `<ViewTransition>` around the `<summary>`.\n * Animates only the commit that ends an action (for example a spinner rendered from `pending`\n * disappearing); the optimistic `data-open` flip is a CSS job.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, AccordionTriggerState>;\n style?: StateValue<CSSProperties | undefined, AccordionTriggerState>;\n /** Rendered from optimistic state; must not suspend. A heading inside is recommended. */\n children?: StateValue<ReactNode, AccordionTriggerState>;\n /** Must render a `<summary>` element. */\n render?: RenderProp<ComponentPropsWithRef<\"summary\">, AccordionTriggerState>;\n}\n\nconst NESTED_INTERACTIVE =\n \"a[href], button, label, input, select, textarea, [contenteditable]:not([contenteditable='false'])\";\n\n/**\n * Nested controls with an activation behaviour of their own. The browser runs theirs instead of\n * the summary's (no toggle), so their click must keep its default: navigation, check, submit.\n */\nconst SELF_ACTIVATING =\n \"a[href], button, label, input:is([type='button'], [type='submit'], [type='reset'], \" +\n \"[type='image'], [type='checkbox'], [type='radio'], [type='file'], [type='color'])\";\n\n/** The interactive descendant of the summary that was clicked (a link in the heading), if any. */\nfunction nestedInteractive(target: EventTarget | null, summary: HTMLElement): Element | null {\n if (!(target instanceof Element) || target === summary) return null;\n const interactive = target.closest(NESTED_INTERACTIVE);\n return interactive !== null && interactive !== summary && summary.contains(interactive)\n ? interactive\n : null;\n}\n\n/**\n * The item's disclosure control: the `<summary>`, which must be the first child of the Item. In\n * library mode the click is intercepted and dispatched through the Root's transition; the\n * element shows optimistic `data-open` and `data-pending`. The platform forbids `aria-expanded`\n * on a summary, so assistive technology hears the committed state (from `<details open>`).\n */\nexport function AccordionTrigger({\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: AccordionTriggerProps) {\n // Only the Item's context (memoised per item), which carries what is needed of the Root's.\n const item = use(AccordionItemContext);\n if (item === null) {\n throw new Error(\"Accordion.Trigger must be rendered inside an Accordion.Item.\");\n }\n const isLibrary = item.library;\n\n useDevWarning(\n !isLibrary && transition !== undefined,\n isDev &&\n \"Accordion.Trigger: `transition` has no effect in JS-free mode; the browser toggles the item \" +\n \"outside any React transition.\",\n );\n\n const registerTrigger = item.registerTrigger;\n const checkElement = useElementCheck(\n isDev &&\n ((element) =>\n element.tagName !== \"SUMMARY\"\n ? `Accordion.Trigger: expected to render a <summary> element but got <${element.tagName.toLowerCase()}>. ` +\n \"Only a <summary> toggles its parent <details>.\"\n : null),\n );\n const libraryRef = useCallback(\n (element: HTMLElement) => {\n checkElement?.(element);\n const unregister = registerTrigger?.(element);\n // Always return a cleanup so the merged ref never calls back with `null`.\n return () => {\n unregister?.();\n };\n },\n [checkElement, registerTrigger],\n );\n\n const state: AccordionTriggerState = {\n value: item.value,\n open: item.optimisticOpen,\n pending: item.pending,\n disabled: item.disabled,\n };\n\n // JS-free mode attaches no click handler unless the item is disabled (design 2.1 / section 6).\n const onClick =\n isLibrary || item.disabled\n ? (event: MouseEvent<HTMLElement>) => {\n const nested = nestedInteractive(event.target, event.currentTarget);\n if (nested !== null) {\n // A nested control never toggles. Controls without their own activation behaviour\n // (text input, select, textarea, contenteditable) would let the click fall through to\n // the summary's toggle, so cancel it; focus and pickers happen on mousedown and are\n // unaffected. Self-activating controls already pre-empt the summary's behaviour.\n if (!nested.matches(SELF_ACTIVATING)) event.preventDefault();\n return;\n }\n // Cancelling the click is what keeps the browser from touching `open`.\n event.preventDefault();\n if (item.disabled || !isLibrary) return;\n item.dispatch?.(item.value, !item.optimisticOpen, event.nativeEvent);\n }\n : undefined;\n\n const element = useRender<ComponentPropsWithRef<\"summary\">, AccordionTriggerState>({\n defaultElement: \"summary\",\n render,\n state,\n className,\n style,\n children,\n ref: libraryRef,\n props: rest,\n // Library-controlled layer: wins over a `render` element's props (conventions 1.2).\n libraryProps: {\n \"aria-disabled\": item.disabled ? true : undefined,\n \"data-open\": dataAttr(item.optimisticOpen === true),\n \"data-pending\": dataAttr(item.pending),\n \"data-disabled\": dataAttr(item.disabled),\n // Only owned when installed, so a render element keeps its own `onClick` in JS-free mode.\n ...(onClick && { onClick }),\n },\n });\n\n return useTransitionBoundary(\"Accordion.Trigger\", isLibrary ? transition : undefined, element);\n}\n\nAccordionTrigger.displayName = \"AccordionTrigger\";\n"],"mappings":";;;;;;;;;AAkBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AA2BvC,MAAM,qBACJ;;;;;AAMF,MAAM,kBACJ;;AAIF,SAAS,kBAAkB,QAA4B,SAAsC;CAC3F,IAAI,EAAE,kBAAkB,YAAY,WAAW,SAAS,OAAO;CAC/D,MAAM,cAAc,OAAO,QAAQ,kBAAkB;CACrD,OAAO,gBAAgB,QAAQ,gBAAgB,WAAW,QAAQ,SAAS,WAAW,IAClF,cACA;AACN;;;;;;;AAQA,SAAgB,iBAAiB,EAC/B,YACA,WACA,OACA,UACA,QACA,GAAG,QACqB;CAExB,MAAM,OAAO,IAAI,oBAAoB;CACrC,IAAI,SAAS,MACX,MAAM,IAAI,MAAM,8DAA8D;CAEhF,MAAM,YAAY,KAAK;CAEvB,cACE,CAAC,aAAa,eAAe,KAAA,GAC7B,SACE,2HAEJ;CAEA,MAAM,kBAAkB,KAAK;CAC7B,MAAM,eAAe,gBACnB,WACI,YACA,QAAQ,YAAY,YAChB,sEAAsE,QAAQ,QAAQ,YAAY,EAAE,qDAEpG,KACV;CACA,MAAM,aAAa,aAChB,YAAyB;EACxB,eAAe,OAAO;EACtB,MAAM,aAAa,kBAAkB,OAAO;EAE5C,aAAa;GACX,aAAa;EACf;CACF,GACA,CAAC,cAAc,eAAe,CAChC;CAEA,MAAM,QAA+B;EACnC,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,SAAS,KAAK;EACd,UAAU,KAAK;CACjB;CAGA,MAAM,UACJ,aAAa,KAAK,YACb,UAAmC;EAClC,MAAM,SAAS,kBAAkB,MAAM,QAAQ,MAAM,aAAa;EAClE,IAAI,WAAW,MAAM;GAKnB,IAAI,CAAC,OAAO,QAAQ,eAAe,GAAG,MAAM,eAAe;GAC3D;EACF;EAEA,MAAM,eAAe;EACrB,IAAI,KAAK,YAAY,CAAC,WAAW;EACjC,KAAK,WAAW,KAAK,OAAO,CAAC,KAAK,gBAAgB,MAAM,WAAW;CACrE,IACA,KAAA;CAEN,MAAM,UAAU,UAAmE;EACjF,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,KAAK;EACL,OAAO;EAEP,cAAc;GACZ,iBAAiB,KAAK,WAAW,OAAO,KAAA;GACxC,aAAa,SAAS,KAAK,mBAAmB,IAAI;GAClD,gBAAgB,SAAS,KAAK,OAAO;GACrC,iBAAiB,SAAS,KAAK,QAAQ;GAEvC,GAAI,WAAW,EAAE,QAAQ;EAC3B;CACF,CAAC;CAED,OAAO,sBAAsB,qBAAqB,YAAY,aAAa,KAAA,GAAW,OAAO;AAC/F;AAEA,iBAAiB,cAAc"}
@@ -51,8 +51,10 @@ export interface ButtonProps extends Omit<ComponentPropsWithRef<"button">, "onCl
51
51
  focusableWhenDisabled?: boolean;
52
52
  /**
53
53
  * Forwarded as `default` to the Button's `<ViewTransition>`: animates the commit that ends the
54
- * action (content keyed on `pending`), not a click. Static; any value makes a mount inside a
55
- * transition start a document view transition (issue #35).
54
+ * action (content keyed on `pending`), not a click.
55
+ * Static: setting or unsetting it remounts the element. Any value, `"none"` included, makes a
56
+ * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms
57
+ * page cross-fade that the next transition waits for).
56
58
  */
57
59
  transition?: ViewTransitionClass;
58
60
  className?: StateValue<string | undefined, ButtonState>;
@@ -1 +1 @@
1
- {"version":3,"file":"button.d.mts","names":[],"sources":["../../src/button/button.tsx"],"mappings":";;;;iBAoBiB,4BAA4B;iBAE5B;;;;;WAKN;;WAEA;;iBAGM,oBAAoB,KACnC;;;;;;;EASA,SAAS,QAAQ,SAAS;;;;;;;;EAQ1B,aAAa;;;;;;;EAOb;;;;;;;EAOA;;;;;;;EAOA;;;;;;EAMA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;wBAavC,SACd,QACA,YACA,MACA,UACA,uBACA,YACA,WACA,OACA,UACA,WACG,QACF,cAAW;yBAZE"}
1
+ {"version":3,"file":"button.d.mts","names":[],"sources":["../../src/button/button.tsx"],"mappings":";;;;iBAsBiB,4BAA4B;iBAE5B;;;;;WAKN;;WAEA;;iBAGM,oBAAoB,KACnC;;;;;;;EASA,SAAS,QAAQ,SAAS;;;;;;;;EAQ1B,aAAa;;;;;;;EAOb;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;EAQA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;wBAavC,SACd,QACA,YACA,MACA,UACA,uBACA,YACA,WACA,OACA,UACA,WACG,QACF,cAAW;yBAZE"}
@@ -10,6 +10,7 @@ import { useRender } from "../internal/use-render.mjs";
10
10
  import { useRef } from "react";
11
11
  import { useFormStatus } from "react-dom";
12
12
  //#region src/button/button.tsx
13
+ const isDev = process.env.NODE_ENV !== "production";
13
14
  /**
14
15
  * A button whose click is a transition (design/components/button.md): `<button type="button">`
15
16
  * that runs `action` in its own transition, with `data-pending` and `aria-disabled="true"` while
@@ -28,8 +29,8 @@ function Button({ action, formAction, type, disabled = false, focusableWhenDisab
28
29
  const submittedWith = useRef(void 0);
29
30
  const formPending = status.pending && typeof formAction === "function" && (status.action === formAction || status.action === submittedWith.current);
30
31
  const pending = ownPending || formPending;
31
- useDevWarning(action !== void 0 && formAction !== void 0, "Button: `action` and `formAction` were both given. One click would run two actions; the Button runs `action` and leaves `formAction` to the form submission. Pass one of them.");
32
- useDevWarning(action !== void 0 && (type === "submit" || type === "reset"), `Button: \`action\` together with type="${type}". One click would run \`action\` in a transition and ${type === "reset" ? "reset" : "submit"} the form. Use \`formAction\` for a submitter, or drop \`type\`.`);
32
+ useDevWarning(action !== void 0 && formAction !== void 0, isDev && "Button: `action` and `formAction` were both given. One click would run two actions; the Button runs `action` and leaves `formAction` to the form submission. Pass one of them.");
33
+ useDevWarning(action !== void 0 && (type === "submit" || type === "reset"), isDev && `Button: \`action\` together with type="${type}". One click would run \`action\` in a transition and ${type === "reset" ? "reset" : "submit"} the form. Use \`formAction\` for a submitter, or drop \`type\`.`);
33
34
  const element = useRender({
34
35
  defaultElement: "button",
35
36
  render,