@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
@@ -3,60 +3,35 @@ import { createActionDetails } from "../internal/action-details.mjs";
3
3
  import { dataAttr } from "../internal/data-attr.mjs";
4
4
  import { useRender } from "../internal/use-render.mjs";
5
5
  import { transitionTypes } from "../internal/transition-types.mjs";
6
- import { useControllableAction } from "../internal/use-controllable-action.mjs";
7
- import { useFieldControl, useFieldValueChange, useMergedRef } from "../internal/use-field-control.mjs";
6
+ import { useLatest } from "../internal/use-latest.mjs";
7
+ import { intendedValue, useControllableAction } from "../internal/use-controllable-action.mjs";
8
+ import { EMPTY_SET, applyPatch, setsEqual, sortByOrder, toSet } from "../internal/value-set.mjs";
9
+ import { useItemOrder } from "../internal/use-item-order.mjs";
10
+ import { useFieldValueChange } from "../internal/use-field-control.mjs";
11
+ import { useFieldsetGroup } from "../internal/use-fieldset-group.mjs";
8
12
  import { useNativeGroupReconciliation } from "../internal/use-native-group-reconciliation.mjs";
9
13
  import { CheckboxGroupContext, enabledValues } from "./checkbox-group-context.mjs";
10
- import { useCallback, useEffectEvent, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
14
+ import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
11
15
  import { jsx } from "react/jsx-runtime";
12
16
  //#region src/checkbox-group/checkbox-group-root.tsx
13
17
  const isDev = process.env.NODE_ENV !== "production";
14
- const EMPTY = /* @__PURE__ */ new Set();
15
- function toSet(value) {
16
- return new Set(value);
17
- }
18
- function setsEqual(a, b) {
19
- if (a.size !== b.size) return false;
20
- for (const v of a) if (!b.has(v)) return false;
21
- return true;
22
- }
23
- /** The optimistic reducer (design 5.2): apply a patch, so stacked dispatches re-base. */
24
- function reduce(set, patch) {
25
- const next = new Set(set);
26
- for (const v of patch.removed) next.delete(v);
27
- for (const v of patch.added) next.add(v);
28
- return next;
29
- }
30
- /**
31
- * `values` sorted by `order` (the Items' values in document order); values not in `order` keep
32
- * their iteration order, after the others.
33
- */
34
- function sortByOrder(values, order) {
35
- const wanted = new Set(values);
36
- const sorted = [];
37
- for (const v of order) if (wanted.delete(v)) sorted.push(v);
38
- for (const v of wanted) sorted.push(v);
39
- return sorted;
40
- }
41
18
  function summarize(registry) {
42
19
  const items = /* @__PURE__ */ new Map();
43
20
  for (const { value, disabled } of registry.values()) items.set(value, (items.get(value) ?? false) || !disabled);
44
21
  return items;
45
22
  }
46
23
  function disabledOf(items) {
47
- if (items === null) return EMPTY;
24
+ if (items === null) return EMPTY_SET;
48
25
  const disabled = /* @__PURE__ */ new Set();
49
26
  for (const [value, enabled] of items) if (!enabled) disabled.add(value);
50
- return disabled.size === 0 ? EMPTY : disabled;
27
+ return disabled.size === 0 ? EMPTY_SET : disabled;
51
28
  }
52
29
  function mapsEqual(a, b) {
53
30
  if (a.size !== b.size) return false;
54
31
  for (const [k, v] of a) if (b.get(k) !== v) return false;
55
32
  return true;
56
33
  }
57
- function arraysEqual(a, b) {
58
- return a.length === b.length && a.every((v, i) => v === b[i]);
59
- }
34
+ const NO_ORDER = { order: [] };
60
35
  /** The group's Items: checkboxes of this `name` in the fieldset (Parents have none). */
61
36
  function readItems(fieldset, name) {
62
37
  if (fieldset === null) return [];
@@ -77,20 +52,12 @@ function readItems(fieldset, name) {
77
52
  * click before an Item hydrated is reconciled when it does.
78
53
  */
79
54
  function CheckboxGroupRoot({ value, defaultValue, valueChangeAction, name: nameProp, form, required: requiredProp, disabled: disabledProp, className, style, children, render, ...rest }) {
80
- const field = useFieldControl({
81
- labelable: false,
55
+ const { field, name, required, disabled, fieldsetRef, rootRef } = useFieldsetGroup({
56
+ component: "CheckboxGroup.Root",
82
57
  name: nameProp,
83
58
  disabled: disabledProp,
84
- required: requiredProp,
85
- component: "CheckboxGroup.Root"
59
+ required: requiredProp
86
60
  });
87
- const required = field.required;
88
- const disabled = field.disabled;
89
- const fallbackName = useId();
90
- const name = field.name ?? fallbackName;
91
- const fieldsetRef = useRef(null);
92
- const warnedElement = useRef(false);
93
- const warnedDuplicate = useRef(false);
94
61
  /** Parent reports waiting for the next mount read (design 8.1). */
95
62
  const parentReports = useRef([]);
96
63
  const itemRegistry = useRef(/* @__PURE__ */ new Map());
@@ -112,31 +79,29 @@ function CheckboxGroupRoot({ value, defaultValue, valueChangeAction, name: nameP
112
79
  };
113
80
  }, []);
114
81
  const disabledItems = useMemo(() => disabledOf(items), [items]);
115
- const controlledSet = useMemo(() => value === void 0 ? void 0 : toSet(value), [value]);
116
- const defaultSet = useMemo(() => defaultValue === void 0 ? void 0 : toSet(defaultValue), [defaultValue]);
82
+ const controlledKey = value === void 0 ? void 0 : JSON.stringify(value);
83
+ const controlledSet = useMemo(() => controlledKey === void 0 ? void 0 : toSet(JSON.parse(controlledKey)), [controlledKey]);
84
+ const defaultKey = defaultValue === void 0 ? void 0 : JSON.stringify(defaultValue);
85
+ const defaultSet = useMemo(() => defaultKey === void 0 ? void 0 : toSet(JSON.parse(defaultKey)), [defaultKey]);
117
86
  /** Sorts by the Items' current document order. Reads the DOM: handlers and effects only. */
118
87
  const sortByDocument = (values) => sortByOrder(values, readItems(fieldsetRef.current, name).map((item) => item.value));
119
88
  const { optimistic, committed, pending, dispatch, latestInFlight } = useControllableAction({
120
89
  controlled: controlledSet,
121
90
  defaultValue: defaultSet,
122
- initialValue: EMPTY,
91
+ initialValue: EMPTY_SET,
123
92
  action: valueChangeAction && ((next, details) => valueChangeAction(sortByDocument(next), details)),
124
93
  transitionTypes: (_next, _prev, details) => [
125
94
  ...transitionTypes("checkbox-group"),
126
95
  ...details.added.length > 0 ? ["fsui-checkbox-group-check"] : [],
127
96
  ...details.removed.length > 0 ? ["fsui-checkbox-group-uncheck"] : []
128
97
  ],
129
- reducer: (prev, _next, details) => reduce(prev, details),
98
+ reducer: (prev, _next, details) => applyPatch(prev, details),
130
99
  warn: {
131
100
  component: "CheckboxGroup.Root",
132
101
  prop: "value"
133
102
  }
134
103
  });
135
- /** What the user intends: the latest in-flight dispatch, else optimistic (conventions 3.8 rule 1). */
136
- const base = () => {
137
- const inFlight = latestInFlight();
138
- return inFlight === null ? optimistic : inFlight.next;
139
- };
104
+ const base = () => intendedValue(latestInFlight, optimistic);
140
105
  /** Dispatches `patch` on top of `from`, with the details of design 3.1. */
141
106
  const dispatchPatch = (from, patch, reason, event) => {
142
107
  const details = createActionDetails(event, {
@@ -144,7 +109,7 @@ function CheckboxGroupRoot({ value, defaultValue, valueChangeAction, name: nameP
144
109
  added: sortByDocument(patch.added),
145
110
  removed: sortByDocument(patch.removed)
146
111
  });
147
- dispatch(reduce(from, details), details);
112
+ dispatch(applyPatch(from, details), details);
148
113
  };
149
114
  /**
150
115
  * The group as the DOM shows it (`checked`) or as a form reset leaves it (`defaultChecked`),
@@ -180,7 +145,7 @@ function CheckboxGroupRoot({ value, defaultValue, valueChangeAction, name: nameP
180
145
  parentReports.current = [];
181
146
  return next;
182
147
  },
183
- readDefault: () => readGroup("defaultChecked", value === void 0 ? defaultSet ?? EMPTY : base()),
148
+ readDefault: () => readGroup("defaultChecked", value === void 0 ? defaultSet ?? EMPTY_SET : base()),
184
149
  base,
185
150
  equals: setsEqual,
186
151
  onPlatformChange: (next, event) => {
@@ -207,57 +172,42 @@ function CheckboxGroupRoot({ value, defaultValue, valueChangeAction, name: nameP
207
172
  lateSnapshot.current = null;
208
173
  });
209
174
  };
210
- const [itemOrder, setItemOrder] = useState([]);
211
- const renderedValue = sortByOrder(optimistic, itemOrder);
212
- const syncItemOrder = useEffectEvent(() => {
213
- const order = readItems(fieldsetRef.current, name).map((item) => item.value);
214
- if (!arraysEqual(sortByOrder(optimistic, order), renderedValue)) setItemOrder(order);
215
- if (!isDev || warnedDuplicate.current) return;
216
- const duplicate = order.find((v, i) => order.indexOf(v) !== i);
217
- if (duplicate !== void 0) {
218
- warnedDuplicate.current = true;
219
- console.error(`CheckboxGroup.Item: two Items share the value "${duplicate}" in one CheckboxGroup.Root. Item values must be unique; both boxes follow the same value.`);
220
- }
221
- });
222
- useLayoutEffect(() => {
223
- syncItemOrder();
175
+ const { renderedValue } = useItemOrder({
176
+ optimistic,
177
+ initial: NO_ORDER,
178
+ read: () => ({ order: readItems(fieldsetRef.current, name).map((item) => item.value) }),
179
+ duplicateMessage: isDev && ((duplicate) => `CheckboxGroup.Item: two Items share the value "${duplicate}" in one CheckboxGroup.Root. Item values must be unique; both boxes follow the same value.`)
224
180
  });
225
- const libraryRef = useCallback((el) => {
226
- fieldsetRef.current = el;
227
- if (isDev && !warnedElement.current && el.tagName !== "FIELDSET") {
228
- warnedElement.current = true;
229
- console.error(`CheckboxGroup.Root: expected to render a <fieldset> element but got <${el.tagName.toLowerCase()}>. The platform semantics (legend naming, disabled inheritance, form reset) need a real <fieldset>.`);
230
- }
231
- return () => {
232
- fieldsetRef.current = null;
233
- };
234
- }, []);
235
- const rootRef = useMergedRef(libraryRef, field.ref);
236
181
  const itemsRequired = required && (items === null ? optimistic.size === 0 : ![...optimistic].some((v) => items.get(v) === true));
237
182
  useFieldValueChange(`${[...optimistic].sort().join("\0")}|${String(itemsRequired)}`);
238
183
  const { "aria-invalid": fieldInvalid, ...groupAttributes } = field.attributes;
239
- const context = {
240
- name,
241
- form,
242
- fieldInvalid,
243
- required: itemsRequired,
244
- disabledItems,
245
- registerItem,
246
- optimistic,
247
- committed,
184
+ const renderedKey = JSON.stringify(renderedValue);
185
+ const state = useMemo(() => ({
186
+ value: JSON.parse(renderedKey),
187
+ pending,
188
+ disabled
189
+ }), [
190
+ renderedKey,
248
191
  pending,
249
- disabled,
250
- defaultValue: value === void 0 ? defaultSet ?? EMPTY : void 0,
192
+ disabled
193
+ ]);
194
+ const latest = useLatest({
195
+ optimistic,
251
196
  onItemMounted,
197
+ sortByDocument,
198
+ dispatchPatch
199
+ });
200
+ const callbacks = useMemo(() => ({
201
+ onItemMounted: (el) => latest.current.onItemMounted(el),
252
202
  reportParent: (values, checked) => {
253
203
  parentReports.current.push({
254
204
  values,
255
205
  checked
256
206
  });
257
207
  },
258
- value: renderedValue,
259
- sortByDocument,
208
+ sortByDocument: (values) => latest.current.sortByDocument(values),
260
209
  toggle: (item, checked, event) => {
210
+ const { optimistic, dispatchPatch } = latest.current;
261
211
  if (optimistic.has(item) === checked) return;
262
212
  dispatchPatch(optimistic, checked ? {
263
213
  added: [item],
@@ -268,6 +218,7 @@ function CheckboxGroupRoot({ value, defaultValue, valueChangeAction, name: nameP
268
218
  }, "activate", event);
269
219
  },
270
220
  apply: (patch, event) => {
221
+ const { optimistic, dispatchPatch } = latest.current;
271
222
  const added = patch.added.filter((v) => !optimistic.has(v));
272
223
  const removed = patch.removed.filter((v) => optimistic.has(v));
273
224
  if (added.length === 0 && removed.length === 0) return;
@@ -276,15 +227,37 @@ function CheckboxGroupRoot({ value, defaultValue, valueChangeAction, name: nameP
276
227
  removed
277
228
  }, "activate", event);
278
229
  }
279
- };
230
+ }), [latest]);
231
+ const contextDefault = value === void 0 ? defaultSet ?? EMPTY_SET : void 0;
232
+ const context = useMemo(() => ({
233
+ name,
234
+ form,
235
+ fieldInvalid,
236
+ required: itemsRequired,
237
+ disabledItems,
238
+ registerItem,
239
+ optimistic,
240
+ committed,
241
+ state,
242
+ defaultValue: contextDefault,
243
+ ...callbacks
244
+ }), [
245
+ name,
246
+ form,
247
+ fieldInvalid,
248
+ itemsRequired,
249
+ disabledItems,
250
+ registerItem,
251
+ optimistic,
252
+ committed,
253
+ state,
254
+ contextDefault,
255
+ callbacks
256
+ ]);
280
257
  const element = useRender({
281
258
  defaultElement: "fieldset",
282
259
  render,
283
- state: {
284
- value: renderedValue,
285
- pending,
286
- disabled
287
- },
260
+ state,
288
261
  className,
289
262
  style,
290
263
  children,
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox-group-root.mjs","names":[],"sources":["../../src/checkbox-group/checkbox-group-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, 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 {\n ActionDetails,\n ChangeAction,\n ChangeReason,\n RenderProp,\n StateValue,\n} from \"../internal/types.js\";\nimport { useControllableAction } from \"../internal/use-controllable-action.js\";\nimport { useNativeGroupReconciliation } from \"../internal/use-native-group-reconciliation.js\";\nimport {\n useFieldControl,\n useFieldValueChange,\n useMergedRef,\n} from \"../internal/use-field-control.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { CheckboxGroupContext, enabledValues } from \"./checkbox-group-context.js\";\nimport type { CheckboxGroupContextValue, CheckboxGroupPatch } from \"./checkbox-group-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** Details passed as the second argument of `valueChangeAction`. */\nexport interface CheckboxGroupValueChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user toggled an Item or a Parent (click, Space, label click; `event` is the\n * native `click`). `\"platform\"`: the browser changed the checked boxes itself: a form reset\n * (`event` is the `reset` event), or clicks before hydration / Firefox form-state restoration\n * found at mount (`event` is `undefined`).\n */\n readonly reason: ChangeReason;\n /** Values this dispatch checked, in document order of their Items (values with no Item last). */\n readonly added: readonly string[];\n /** Values this dispatch unchecked, same order. */\n readonly removed: readonly string[];\n}\n\nexport interface CheckboxGroupRootState {\n /**\n * Optimistic checked values, in document order of the Items as of the Root's last render\n * (values with no Item last). Items reordered by a component that re-renders without the Root\n * keep the previous order here until the Root renders again; `next` and `details` of\n * `valueChangeAction` always read the current DOM order. The server render and the first client\n * render use the value's own order. Content rendered from it must not suspend.\n */\n readonly value: readonly string[];\n /** An action dispatched through this group is in flight. */\n readonly pending: boolean;\n /** The `disabled` prop. */\n readonly disabled: boolean;\n}\n\nexport interface CheckboxGroupRootProps extends Omit<\n ComponentPropsWithRef<\"fieldset\">,\n | \"className\"\n | \"style\"\n | \"children\"\n | \"defaultValue\"\n | \"defaultChecked\"\n | \"name\"\n | \"disabled\"\n | \"form\"\n> {\n /**\n * Controlled checked values. `[]` checks nothing; `undefined` means uncontrolled. Order is not\n * significant and duplicates are ignored: the value is a set.\n *\n * A form reset returns each box to the `checked` it had when *that box* mounted (React sets\n * `defaultChecked` once, from the initial `checked`). The reset is offered to\n * `valueChangeAction` as a `\"platform\"` change; for a stable target use `defaultValue`.\n */\n value?: string[];\n /**\n * Initial values in uncontrolled mode. Defaults to `[]`. Also the values a form reset returns\n * to: the latest prop value is mirrored into the boxes' `defaultChecked`.\n */\n defaultValue?: string[];\n /**\n * Runs inside the Root's transition whenever the set of checked values changes. May be sync\n * or async (also a Server Function); rejections reach the nearest Error Boundary and roll the\n * change back.\n *\n * `next` is the whole set as a fresh array in document order of the Items; treat it as a set.\n * `details.added` / `details.removed` say what changed. When controlled and updating after\n * your own `await`, prefer a functional update keyed by `added` / `removed` over\n * `setValue(next)`: two overlapping actions completing out of order would otherwise land the\n * older whole set last. A `setState` placed after your own `await` is not a Transition update;\n * wrap it in `startTransition` (React limitation). `details.event.preventDefault()` is not a\n * veto; use controlled mode to veto a change.\n */\n valueChangeAction?: ChangeAction<string[], CheckboxGroupValueChangeDetails>;\n /**\n * The `name` shared by every Item (form data key: `formData.getAll(name)`). Defaults to a\n * `useId()` value; pass a real name when the group is inside a `<form>` you submit.\n */\n name?: string;\n /** The `form` attribute, applied to the fieldset and to every Item. */\n form?: string;\n /**\n * \"At least one Item must be checked.\" Rendered as native `required` on every Item while no\n * enabled Item is checked, and on none once one is: values with no Item and checked disabled\n * Items (neither is submitted) do not satisfy it. Until the Items have mounted (server HTML,\n * before hydration) any checked value satisfies it. Not exposed on the fieldset (ARIA does not\n * allow `aria-required` on role `group`): say it in the `Label` or through `aria-describedby`.\n */\n required?: boolean;\n /** Renders `<fieldset disabled>`: every Item and Parent is disabled and unfocusable. */\n disabled?: boolean;\n className?: StateValue<string | undefined, CheckboxGroupRootState>;\n style?: StateValue<CSSProperties | undefined, CheckboxGroupRootState>;\n children?: StateValue<ReactNode, CheckboxGroupRootState>;\n /** Replace the rendered element. Must keep a `<fieldset>`. */\n render?: RenderProp<ComponentPropsWithRef<\"fieldset\">, CheckboxGroupRootState>;\n}\n\ntype ValueSet = ReadonlySet<string>;\n\nconst EMPTY: ValueSet = new Set();\n\nfunction toSet(value: readonly string[]): ValueSet {\n return new Set(value);\n}\n\nfunction setsEqual(a: ValueSet, b: ValueSet): 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\n/** The optimistic reducer (design 5.2): apply a patch, so stacked dispatches re-base. */\nfunction reduce(set: ValueSet, patch: CheckboxGroupPatch): ValueSet {\n const next = new Set(set);\n for (const v of patch.removed) next.delete(v);\n for (const v of patch.added) next.add(v);\n return next;\n}\n\n/**\n * `values` sorted by `order` (the Items' values in document order); values not in `order` keep\n * their iteration order, after the others.\n */\nfunction sortByOrder(values: Iterable<string>, order: readonly string[]): string[] {\n const wanted = new Set(values);\n const sorted: string[] = [];\n for (const v of order) if (wanted.delete(v)) sorted.push(v);\n for (const v of wanted) sorted.push(v);\n return sorted;\n}\n\n/** Value → \"has an Item without its own `disabled`\", over the registered Items. */\ntype ItemRegistry = Map<object, { readonly value: string; readonly disabled: boolean }>;\n\nfunction summarize(registry: ItemRegistry): Map<string, boolean> {\n const items = new Map<string, boolean>();\n for (const { value, disabled } of registry.values()) {\n items.set(value, (items.get(value) ?? false) || !disabled);\n }\n return items;\n}\n\nfunction disabledOf(items: ReadonlyMap<string, boolean> | null): ValueSet {\n if (items === null) return EMPTY;\n const disabled = new Set<string>();\n for (const [value, enabled] of items) if (!enabled) disabled.add(value);\n return disabled.size === 0 ? EMPTY : disabled;\n}\n\nfunction mapsEqual(a: ReadonlyMap<string, boolean>, b: ReadonlyMap<string, boolean>): boolean {\n if (a.size !== b.size) return false;\n for (const [k, v] of a) if (b.get(k) !== v) return false;\n return true;\n}\n\nfunction arraysEqual(a: readonly string[], b: readonly string[]): boolean {\n return a.length === b.length && a.every((v, i) => v === b[i]);\n}\n\n/** The group's Items: checkboxes of this `name` in the fieldset (Parents have none). */\nfunction readItems(fieldset: HTMLFieldSetElement | null, name: string): HTMLInputElement[] {\n if (fieldset === null) return [];\n return [...fieldset.querySelectorAll<HTMLInputElement>('input[type=\"checkbox\"]')].filter(\n (box) => box.name === name,\n );\n}\n\n/**\n * `<fieldset>` that owns the group's state (a set of values), the transition, the shared `name`,\n * the form-reset listener, the mount reconciliation and the group-level `required`\n * (design/components/checkbox-group.md 14.3). Carries `data-pending` while `valueChangeAction`\n * is in flight. Its implicit role is `group`; no `role` is written.\n *\n * Owned keys (conventions 1.2): `disabled`, `form`, `data-pending`, `data-disabled`; inside a\n * `Field.Root` also `aria-labelledby` (→ `Field.Label`, token-merged), `aria-describedby`\n * (token-merged), `aria-invalid` and `data-invalid`, and `name` / `required` / `disabled` default\n * from the Field.\n *\n * Unlike RadioGroup, Items may hydrate after their Root (a Suspense boundary between them): a\n * click before an Item hydrated is reconciled when it does.\n */\nexport function CheckboxGroupRoot({\n value,\n defaultValue,\n valueChangeAction,\n name: nameProp,\n form,\n required: requiredProp,\n disabled: disabledProp,\n className,\n style,\n children,\n render,\n ...rest\n}: CheckboxGroupRootProps) {\n // Inside a Field.Root (design/components/field-form.md 7.2) the fieldset is the Field's group\n // control: `aria-labelledby` → `Field.Label`, the ARIA wiring, and `name` / `required` (\"at\n // least one\") / `disabled` defaulting from the Field.\n const field = useFieldControl({\n labelable: false,\n name: nameProp,\n disabled: disabledProp,\n required: requiredProp,\n component: \"CheckboxGroup.Root\",\n });\n const required = field.required;\n const disabled = field.disabled;\n const fallbackName = useId();\n const name = field.name ?? fallbackName;\n const fieldsetRef = useRef<HTMLFieldSetElement | null>(null);\n const warnedElement = useRef(false);\n const warnedDuplicate = useRef(false);\n /** Parent reports waiting for the next mount read (design 8.1). */\n const parentReports = useRef<{ values: readonly string[]; checked: boolean }[]>([]);\n\n // Item registration (design 6.2, 7): each Item reports its value and own `disabled` from a\n // layout effect. The ref is current for the residual-path reads; the state, set only when the\n // summary changes, is what render uses. `null` until an Item registered, so the server render\n // and the hydration render (which cannot know) agree.\n const itemRegistry = useRef<ItemRegistry>(new Map());\n const [items, setItems] = useState<ReadonlyMap<string, boolean> | null>(null);\n const registerItem = useCallback((value: string, disabled: boolean) => {\n const publish = () => {\n const next = summarize(itemRegistry.current);\n setItems((prev) => (prev !== null && mapsEqual(prev, next) ? prev : next));\n };\n const token = {};\n itemRegistry.current.set(token, { value, disabled });\n publish();\n return () => {\n itemRegistry.current.delete(token);\n publish();\n };\n }, []);\n const disabledItems = useMemo(() => disabledOf(items), [items]);\n\n const controlledSet = useMemo(() => (value === undefined ? undefined : toSet(value)), [value]);\n const defaultSet = useMemo(\n () => (defaultValue === undefined ? undefined : toSet(defaultValue)),\n [defaultValue],\n );\n\n /** Sorts by the Items' current document order. Reads the DOM: handlers and effects only. */\n const sortByDocument = (values: Iterable<string>): string[] =>\n sortByOrder(\n values,\n readItems(fieldsetRef.current, name).map((item) => item.value),\n );\n\n const { optimistic, committed, pending, dispatch, latestInFlight } = useControllableAction<\n ValueSet,\n CheckboxGroupValueChangeDetails\n >({\n controlled: controlledSet,\n defaultValue: defaultSet,\n initialValue: EMPTY,\n action:\n valueChangeAction && ((next, details) => valueChangeAction(sortByDocument(next), details)),\n transitionTypes: (_next, _prev, details) => [\n ...transitionTypes(\"checkbox-group\"),\n ...(details.added.length > 0 ? [\"fsui-checkbox-group-check\"] : []),\n ...(details.removed.length > 0 ? [\"fsui-checkbox-group-uncheck\"] : []),\n ],\n reducer: (prev, _next, details) => reduce(prev, details),\n warn: { component: \"CheckboxGroup.Root\", prop: \"value\" },\n });\n // Deliberately no warning when neither `value` nor `defaultValue` is given: an empty group is\n // the HTML default (design 3.1).\n\n /** What the user intends: the latest in-flight dispatch, else optimistic (conventions 3.8 rule 1). */\n const base = (): ValueSet => {\n const inFlight = latestInFlight();\n return inFlight === null ? optimistic : inFlight.next;\n };\n\n /** Dispatches `patch` on top of `from`, with the details of design 3.1. */\n const dispatchPatch = (\n from: ValueSet,\n patch: CheckboxGroupPatch,\n reason: ChangeReason,\n event: Event | undefined,\n ): void => {\n const details = createActionDetails(event, {\n reason,\n added: sortByDocument(patch.added),\n removed: sortByDocument(patch.removed),\n });\n dispatch(reduce(from, details), details);\n };\n\n /**\n * The group as the DOM shows it (`checked`) or as a form reset leaves it (`defaultChecked`),\n * laid over `base()` so that values with no Item are kept (they have no DOM to read).\n */\n const readDom = (prop: \"checked\" | \"defaultChecked\"): Map<string, boolean> =>\n new Map(readItems(fieldsetRef.current, name).map((item) => [item.value, item[prop]]));\n const readGroup = (\n prop: \"checked\" | \"defaultChecked\",\n from: ValueSet,\n dom: ReadonlyMap<string, boolean> = readDom(prop),\n ): Set<string> => {\n const next = new Set(from);\n for (const [v, isChecked] of dom) {\n if (isChecked) next.add(v);\n else next.delete(v);\n }\n return next;\n };\n\n /**\n * The Root's own mount reconciliation ran: later member mounts are \"late\" (8.3). Set after the\n * adapter's mount effect; reset by the cleanup (StrictMode included).\n */\n const rootMounted = useRef(false);\n /**\n * Late mounts: the members' `checked` read in the first late member's mount layout effect. The\n * adapter reads the group in a microtask, but the Items' registration re-renders the group\n * right after the layout effects, and that re-render re-applies each Item's `checked`, erasing a\n * click made before the Item hydrated. Every member of the commit is in the DOM by then.\n */\n const lateSnapshot = useRef<Map<string, boolean> | null>(null);\n\n // The residual browser paths (design section 8): one dispatch per group, from here. Items and\n // Parents that mount after the Root report through `onItemMounted`.\n const { onItemMounted: onMemberMounted } = useNativeGroupReconciliation<ValueSet>({\n element: fieldsetRef,\n readCurrent: () => {\n const next = readGroup(\"checked\", base(), lateSnapshot.current ?? undefined);\n lateSnapshot.current = null;\n // A Parent clicked before hydration means what its click means: check / uncheck all of its\n // values whose Items are enabled (8.1, 6.2). Read from the registry ref: the Items of this\n // commit registered before this runs, and render has not caught up yet.\n const disabledNow = disabledOf(summarize(itemRegistry.current));\n for (const report of parentReports.current) {\n for (const v of enabledValues(report.values, disabledNow)) {\n if (report.checked) next.add(v);\n else next.delete(v);\n }\n }\n parentReports.current = [];\n return next;\n },\n // Uncontrolled: start from `defaultValue`, so values with no Item return to it too (they have\n // no `defaultChecked` to read). Controlled: from `base()`, as for the mount read; the parent\n // decides.\n readDefault: () =>\n readGroup(\"defaultChecked\", value === undefined ? (defaultSet ?? EMPTY) : base()),\n base,\n equals: setsEqual,\n onPlatformChange: (next, event) => {\n const from = base();\n const added = [...next].filter((v) => !from.has(v));\n const removed = [...from].filter((v) => !next.has(v));\n dispatchPatch(from, { added, removed }, \"platform\", event);\n },\n });\n\n useLayoutEffect(() => {\n rootMounted.current = true;\n return () => {\n rootMounted.current = false;\n };\n }, []);\n const onItemMounted = (el: HTMLInputElement | null) => {\n const late = rootMounted.current;\n if (late && lateSnapshot.current === null) lateSnapshot.current = readDom(\"checked\");\n onMemberMounted(el);\n // A snapshot the adapter did not consume (it queues one read per commit, before this).\n if (late) {\n queueMicrotask(() => {\n lateSnapshot.current = null;\n });\n }\n };\n\n // The state's `value` is in document order. Render cannot read the DOM, so the Items' order is\n // kept in state, refreshed after a commit only when the rendered `value` would change (a value\n // given out of document order, Items reordered or added). The first render, and the server,\n // use the value's own order.\n const [itemOrder, setItemOrder] = useState<readonly string[]>([]);\n const renderedValue = sortByOrder(optimistic, itemOrder);\n // After every commit of the Root (a deps-less layout effect runs only when the Root itself\n // committed: Items moved by a child that re-renders alone are picked up at the Root's next\n // render). The comparison ends the chain: the re-render it causes renders exactly the value\n // just compared against.\n const syncItemOrder = useEffectEvent(() => {\n const order = readItems(fieldsetRef.current, name).map((item) => item.value);\n if (!arraysEqual(sortByOrder(optimistic, order), renderedValue)) setItemOrder(order);\n\n // Dev only: Item values must be unique within the Root (design 14.6).\n if (!isDev || warnedDuplicate.current) return;\n const duplicate = order.find((v, i) => order.indexOf(v) !== i);\n if (duplicate !== undefined) {\n warnedDuplicate.current = true;\n console.error(\n `CheckboxGroup.Item: two Items share the value \"${duplicate}\" in one ` +\n `CheckboxGroup.Root. Item values must be unique; both boxes follow the same value.`,\n );\n }\n });\n useLayoutEffect(() => {\n syncItemOrder();\n });\n\n const libraryRef = useCallback((el: HTMLFieldSetElement) => {\n fieldsetRef.current = el;\n if (isDev && !warnedElement.current && el.tagName !== \"FIELDSET\") {\n warnedElement.current = true;\n console.error(\n `CheckboxGroup.Root: expected to render a <fieldset> element but got ` +\n `<${el.tagName.toLowerCase()}>. The platform semantics (legend naming, disabled ` +\n `inheritance, form reset) need a real <fieldset>.`,\n );\n }\n return () => {\n fieldsetRef.current = null;\n };\n }, []);\n const rootRef = useMergedRef<HTMLFieldSetElement>(libraryRef, field.ref);\n\n const itemsRequired =\n required &&\n (items === null ? optimistic.size === 0 : ![...optimistic].some((v) => items.get(v) === true));\n // Inside a Field: the Items' `checked` and derived `required` are written by React after the\n // click's `change` (a Parent checks Items with no event of their own), so the Field re-reads\n // validity and `validate` after the commit (design/components/field-form.md 7.2).\n useFieldValueChange(`${[...optimistic].sort().join(\"\\u0000\")}|${String(itemsRequired)}`);\n\n // `aria-invalid` is not supported on role `group` (ARIA 1.2 made it widget-specific): inside a\n // Field it goes on every Item (a `checkbox`) instead; the fieldset keeps `data-invalid` and\n // `aria-describedby`, read when focus enters the group.\n const { \"aria-invalid\": fieldInvalid, ...groupAttributes } = field.attributes;\n\n const context: CheckboxGroupContextValue = {\n name,\n form,\n fieldInvalid,\n required: itemsRequired,\n disabledItems,\n registerItem,\n optimistic,\n committed,\n pending,\n disabled,\n defaultValue: value === undefined ? (defaultSet ?? EMPTY) : undefined,\n onItemMounted,\n reportParent: (values, checked) => {\n parentReports.current.push({ values, checked });\n },\n value: renderedValue,\n sortByDocument,\n toggle: (item, checked, event) => {\n // No-op rule against the optimistic set (conventions 2.3 item 8).\n if (optimistic.has(item) === checked) return;\n const patch = checked ? { added: [item], removed: [] } : { added: [], removed: [item] };\n dispatchPatch(optimistic, patch, \"activate\", event);\n },\n apply: (patch, event) => {\n const added = patch.added.filter((v) => !optimistic.has(v));\n const removed = patch.removed.filter((v) => optimistic.has(v));\n if (added.length === 0 && removed.length === 0) return;\n dispatchPatch(optimistic, { added, removed }, \"activate\", event);\n },\n };\n\n const state: CheckboxGroupRootState = {\n value: renderedValue,\n pending,\n disabled,\n };\n\n const element = useRender<ComponentPropsWithRef<\"fieldset\">, CheckboxGroupRootState>({\n defaultElement: \"fieldset\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n ...groupAttributes,\n disabled,\n form,\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n },\n ref: rootRef,\n });\n\n return <CheckboxGroupContext value={context}>{element}</CheckboxGroupContext>;\n}\n\nCheckboxGroupRoot.displayName = \"CheckboxGroupRoot\";\n"],"mappings":";;;;;;;;;;;;AAgCA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAiGvC,MAAM,wBAAkB,IAAI,IAAI;AAEhC,SAAS,MAAM,OAAoC;CACjD,OAAO,IAAI,IAAI,KAAK;AACtB;AAEA,SAAS,UAAU,GAAa,GAAsB;CACpD,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO;CAC9B,KAAK,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,OAAO;CACzC,OAAO;AACT;;AAGA,SAAS,OAAO,KAAe,OAAqC;CAClE,MAAM,OAAO,IAAI,IAAI,GAAG;C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IAAE,OAAO,CAAC,IAAI;IAAG,SAAS,CAAC;GAAE,IAAI;IAAE,OAAO,CAAC;IAAG,SAAS,CAAC,IAAI;GAAE,GACrD,YAAY,KAAK;EACpD;EACA,QAAQ,OAAO,UAAU;GACvB,MAAM,QAAQ,MAAM,MAAM,QAAQ,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC;GAC1D,MAAM,UAAU,MAAM,QAAQ,QAAQ,MAAM,WAAW,IAAI,CAAC,CAAC;GAC7D,IAAI,MAAM,WAAW,KAAK,QAAQ,WAAW,GAAG;GAChD,cAAc,YAAY;IAAE;IAAO;GAAQ,GAAG,YAAY,KAAK;EACjE;CACF;CAQA,MAAM,UAAU,UAAqE;EACnF,gBAAgB;EAChB;EACA,OAAA;GARA,OAAO;GACP;GACA;EAMI;EACJ;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,GAAG;GACH;GACA;GACA,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;EACpC;EACA,KAAK;CACP,CAAC;CAED,OAAO,oBAAC,sBAAD;EAAsB,OAAO;EAAU,UAAA;CAA8B,CAAA;AAC9E;AAEA,kBAAkB,cAAc"}
1
+ {"version":3,"file":"checkbox-group-root.mjs","names":[],"sources":["../../src/checkbox-group/checkbox-group-root.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { transitionTypes } from \"../internal/transition-types.js\";\nimport type {\n ActionDetails,\n ChangeAction,\n ChangeReason,\n RenderProp,\n StateValue,\n} from \"../internal/types.js\";\nimport { intendedValue, useControllableAction } from \"../internal/use-controllable-action.js\";\nimport { useFieldValueChange } from \"../internal/use-field-control.js\";\nimport { useFieldsetGroup } from \"../internal/use-fieldset-group.js\";\nimport { useItemOrder } from \"../internal/use-item-order.js\";\nimport type { ItemLayout } from \"../internal/use-item-order.js\";\nimport { useNativeGroupReconciliation } from \"../internal/use-native-group-reconciliation.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { applyPatch, EMPTY_SET, setsEqual, sortByOrder, toSet } from \"../internal/value-set.js\";\nimport type { ValueSet } from \"../internal/value-set.js\";\nimport { CheckboxGroupContext, enabledValues } from \"./checkbox-group-context.js\";\nimport type { CheckboxGroupContextValue, CheckboxGroupPatch } from \"./checkbox-group-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** Details passed as the second argument of `valueChangeAction`. */\nexport interface CheckboxGroupValueChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user toggled an Item or a Parent (click, Space, label click; `event` is the\n * native `click`). `\"platform\"`: the browser changed the checked boxes itself: a form reset\n * (`event` is the `reset` event), or clicks before hydration / Firefox form-state restoration\n * found at mount (`event` is `undefined`).\n */\n readonly reason: ChangeReason;\n /** Values this dispatch checked, in document order of their Items (values with no Item last). */\n readonly added: readonly string[];\n /** Values this dispatch unchecked, same order. */\n readonly removed: readonly string[];\n}\n\nexport interface CheckboxGroupRootState {\n /**\n * Optimistic checked values, in document order of the Items as of the Root's last render\n * (values with no Item last). Items reordered by a component that re-renders without the Root\n * keep the previous order here until the Root renders again; `next` and `details` of\n * `valueChangeAction` always read the current DOM order. The server render and the first client\n * render use the value's own order. Content rendered from it must not suspend.\n */\n readonly value: readonly string[];\n /** An action dispatched through this group is in flight. */\n readonly pending: boolean;\n /** The `disabled` prop (or the enclosing `Field.Root`'s). */\n readonly disabled: boolean;\n}\n\nexport interface CheckboxGroupRootProps extends Omit<\n ComponentPropsWithRef<\"fieldset\">,\n | \"className\"\n | \"style\"\n | \"children\"\n | \"defaultValue\"\n | \"defaultChecked\"\n | \"name\"\n | \"disabled\"\n | \"form\"\n> {\n /**\n * Controlled checked values. `[]` checks nothing; `undefined` means uncontrolled. Order is not\n * significant and duplicates are ignored: the value is a set.\n *\n * A form reset returns each box to the `checked` it had when *that box* mounted (React sets\n * `defaultChecked` once, from the initial `checked`). The reset is offered to\n * `valueChangeAction` as a `\"platform\"` change; for a stable target use `defaultValue`.\n */\n value?: string[];\n /**\n * Initial values in uncontrolled mode. Defaults to `[]`. Also the values a form reset returns\n * to: the latest prop value is mirrored into the boxes' `defaultChecked`.\n */\n defaultValue?: string[];\n /**\n * Runs inside the Root's transition whenever the set of checked values changes. May be sync\n * or async (also a Server Function); rejections reach the nearest Error Boundary and roll the\n * change back.\n *\n * `next` is the whole set as a fresh array in document order of the Items; treat it as a set.\n * `details.added` / `details.removed` say what changed. When controlled and updating after\n * your own `await`, prefer a functional update keyed by `added` / `removed` over\n * `setValue(next)`: two overlapping actions completing out of order would otherwise land the\n * older whole set last. A `setState` placed after your own `await` is not a Transition update;\n * wrap it in `startTransition` (React limitation). `details.event.preventDefault()` is not a\n * veto; use controlled mode to veto a change.\n */\n valueChangeAction?: ChangeAction<string[], CheckboxGroupValueChangeDetails>;\n /**\n * The `name` shared by every Item (form data key: `formData.getAll(name)`). Defaults to a\n * `useId()` value; pass a real name when the group is inside a `<form>` you submit.\n */\n name?: string;\n /** The `form` attribute, applied to the fieldset and to every Item. */\n form?: string;\n /**\n * \"At least one Item must be checked.\" Rendered as native `required` on every Item while no\n * enabled Item is checked, and on none once one is: values with no Item and checked disabled\n * Items (neither is submitted) do not satisfy it. Until the Items have mounted (server HTML,\n * before hydration) any checked value satisfies it. Not exposed on the fieldset (ARIA does not\n * allow `aria-required` on role `group`): say it in the `Label` or through `aria-describedby`.\n */\n required?: boolean;\n /** Renders `<fieldset disabled>`: every Item and Parent is disabled and unfocusable. */\n disabled?: boolean;\n className?: StateValue<string | undefined, CheckboxGroupRootState>;\n style?: StateValue<CSSProperties | undefined, CheckboxGroupRootState>;\n children?: StateValue<ReactNode, CheckboxGroupRootState>;\n /** Replace the rendered element. Must keep a `<fieldset>`. */\n render?: RenderProp<ComponentPropsWithRef<\"fieldset\">, CheckboxGroupRootState>;\n}\n\n/** Value → \"has an Item without its own `disabled`\", over the registered Items. */\ntype ItemRegistry = Map<object, { readonly value: string; readonly disabled: boolean }>;\n\nfunction summarize(registry: ItemRegistry): Map<string, boolean> {\n const items = new Map<string, boolean>();\n for (const { value, disabled } of registry.values()) {\n items.set(value, (items.get(value) ?? false) || !disabled);\n }\n return items;\n}\n\nfunction disabledOf(items: ReadonlyMap<string, boolean> | null): ValueSet {\n if (items === null) return EMPTY_SET;\n const disabled = new Set<string>();\n for (const [value, enabled] of items) if (!enabled) disabled.add(value);\n return disabled.size === 0 ? EMPTY_SET : disabled;\n}\n\nfunction mapsEqual(a: ReadonlyMap<string, boolean>, b: ReadonlyMap<string, boolean>): boolean {\n if (a.size !== b.size) return false;\n for (const [k, v] of a) if (b.get(k) !== v) return false;\n return true;\n}\n\nconst NO_ORDER: ItemLayout = { order: [] };\n\n/** The group's Items: checkboxes of this `name` in the fieldset (Parents have none). */\nfunction readItems(fieldset: HTMLFieldSetElement | null, name: string): HTMLInputElement[] {\n if (fieldset === null) return [];\n return [...fieldset.querySelectorAll<HTMLInputElement>('input[type=\"checkbox\"]')].filter(\n (box) => box.name === name,\n );\n}\n\n/**\n * `<fieldset>` that owns the group's state (a set of values), the transition, the shared `name`,\n * the form-reset listener, the mount reconciliation and the group-level `required`\n * (design/components/checkbox-group.md 14.3). Carries `data-pending` while `valueChangeAction`\n * is in flight. Its implicit role is `group`; no `role` is written.\n *\n * Owned keys (conventions 1.2): `disabled`, `form`, `data-pending`, `data-disabled`; inside a\n * `Field.Root` also `aria-labelledby` (→ `Field.Label`, token-merged), `aria-describedby`\n * (token-merged), `aria-invalid` and `data-invalid`, and `name` / `required` / `disabled` default\n * from the Field.\n *\n * Unlike RadioGroup, Items may hydrate after their Root (a Suspense boundary between them): a\n * click before an Item hydrated is reconciled when it does.\n */\nexport function CheckboxGroupRoot({\n value,\n defaultValue,\n valueChangeAction,\n name: nameProp,\n form,\n required: requiredProp,\n disabled: disabledProp,\n className,\n style,\n children,\n render,\n ...rest\n}: CheckboxGroupRootProps) {\n // `required` is \"at least one\" (design section 7).\n const { field, name, required, disabled, fieldsetRef, rootRef } = useFieldsetGroup({\n component: \"CheckboxGroup.Root\",\n name: nameProp,\n disabled: disabledProp,\n required: requiredProp,\n });\n /** Parent reports waiting for the next mount read (design 8.1). */\n const parentReports = useRef<{ values: readonly string[]; checked: boolean }[]>([]);\n\n // Item registration (design 6.2, 7): each Item reports its value and own `disabled` from a\n // layout effect. The ref is current for the residual-path reads; the state, set only when the\n // summary changes, is what render uses. `null` until an Item registered, so the server render\n // and the hydration render (which cannot know) agree.\n const itemRegistry = useRef<ItemRegistry>(new Map());\n const [items, setItems] = useState<ReadonlyMap<string, boolean> | null>(null);\n const registerItem = useCallback((value: string, disabled: boolean) => {\n const publish = () => {\n const next = summarize(itemRegistry.current);\n setItems((prev) => (prev !== null && mapsEqual(prev, next) ? prev : next));\n };\n const token = {};\n itemRegistry.current.set(token, { value, disabled });\n publish();\n return () => {\n itemRegistry.current.delete(token);\n publish();\n };\n }, []);\n const disabledItems = useMemo(() => disabledOf(items), [items]);\n\n // Keyed on the contents, so an inline `value={[\"a\"]}` does not re-base every render.\n const controlledKey = value === undefined ? undefined : JSON.stringify(value);\n const controlledSet = useMemo(\n () => (controlledKey === undefined ? undefined : toSet(JSON.parse(controlledKey) as string[])),\n [controlledKey],\n );\n const defaultKey = defaultValue === undefined ? undefined : JSON.stringify(defaultValue);\n const defaultSet = useMemo(\n () => (defaultKey === undefined ? undefined : toSet(JSON.parse(defaultKey) as string[])),\n [defaultKey],\n );\n\n /** Sorts by the Items' current document order. Reads the DOM: handlers and effects only. */\n const sortByDocument = (values: Iterable<string>): string[] =>\n sortByOrder(\n values,\n readItems(fieldsetRef.current, name).map((item) => item.value),\n );\n\n const { optimistic, committed, pending, dispatch, latestInFlight } = useControllableAction<\n ValueSet,\n CheckboxGroupValueChangeDetails\n >({\n controlled: controlledSet,\n defaultValue: defaultSet,\n initialValue: EMPTY_SET,\n action:\n valueChangeAction && ((next, details) => valueChangeAction(sortByDocument(next), details)),\n transitionTypes: (_next, _prev, details) => [\n ...transitionTypes(\"checkbox-group\"),\n ...(details.added.length > 0 ? [\"fsui-checkbox-group-check\"] : []),\n ...(details.removed.length > 0 ? [\"fsui-checkbox-group-uncheck\"] : []),\n ],\n reducer: (prev, _next, details) => applyPatch(prev, details),\n warn: { component: \"CheckboxGroup.Root\", prop: \"value\" },\n });\n // Deliberately no warning when neither `value` nor `defaultValue` is given: an empty group is\n // the HTML default (design 3.1).\n\n const base = (): ValueSet => intendedValue(latestInFlight, optimistic);\n\n /** Dispatches `patch` on top of `from`, with the details of design 3.1. */\n const dispatchPatch = (\n from: ValueSet,\n patch: CheckboxGroupPatch,\n reason: ChangeReason,\n event: Event | undefined,\n ): void => {\n const details = createActionDetails(event, {\n reason,\n added: sortByDocument(patch.added),\n removed: sortByDocument(patch.removed),\n });\n dispatch(applyPatch(from, details), details);\n };\n\n /**\n * The group as the DOM shows it (`checked`) or as a form reset leaves it (`defaultChecked`),\n * laid over `base()` so that values with no Item are kept (they have no DOM to read).\n */\n const readDom = (prop: \"checked\" | \"defaultChecked\"): Map<string, boolean> =>\n new Map(readItems(fieldsetRef.current, name).map((item) => [item.value, item[prop]]));\n const readGroup = (\n prop: \"checked\" | \"defaultChecked\",\n from: ValueSet,\n dom: ReadonlyMap<string, boolean> = readDom(prop),\n ): Set<string> => {\n const next = new Set(from);\n for (const [v, isChecked] of dom) {\n if (isChecked) next.add(v);\n else next.delete(v);\n }\n return next;\n };\n\n /**\n * The Root's own mount reconciliation ran: later member mounts are \"late\" (8.3). Set after the\n * adapter's mount effect; reset by the cleanup (StrictMode included).\n */\n const rootMounted = useRef(false);\n /**\n * Late mounts: the members' `checked` read in the first late member's mount layout effect. The\n * adapter reads the group in a microtask, but the Items' registration re-renders the group\n * right after the layout effects, and that re-render re-applies each Item's `checked`, erasing a\n * click made before the Item hydrated. Every member of the commit is in the DOM by then.\n */\n const lateSnapshot = useRef<Map<string, boolean> | null>(null);\n\n // The residual browser paths (design section 8): one dispatch per group, from here. Items and\n // Parents that mount after the Root report through `onItemMounted`.\n const { onItemMounted: onMemberMounted } = useNativeGroupReconciliation<ValueSet>({\n element: fieldsetRef,\n readCurrent: () => {\n const next = readGroup(\"checked\", base(), lateSnapshot.current ?? undefined);\n lateSnapshot.current = null;\n // A Parent clicked before hydration means what its click means: check / uncheck all of its\n // values whose Items are enabled (8.1, 6.2). Read from the registry ref: the Items of this\n // commit registered before this runs, and render has not caught up yet.\n const disabledNow = disabledOf(summarize(itemRegistry.current));\n for (const report of parentReports.current) {\n for (const v of enabledValues(report.values, disabledNow)) {\n if (report.checked) next.add(v);\n else next.delete(v);\n }\n }\n parentReports.current = [];\n return next;\n },\n // Uncontrolled: start from `defaultValue`, so values with no Item return to it too (they have\n // no `defaultChecked` to read). Controlled: from `base()`, as for the mount read; the parent\n // decides.\n readDefault: () =>\n readGroup(\"defaultChecked\", value === undefined ? (defaultSet ?? EMPTY_SET) : base()),\n base,\n equals: setsEqual,\n onPlatformChange: (next, event) => {\n const from = base();\n const added = [...next].filter((v) => !from.has(v));\n const removed = [...from].filter((v) => !next.has(v));\n dispatchPatch(from, { added, removed }, \"platform\", event);\n },\n });\n\n useLayoutEffect(() => {\n rootMounted.current = true;\n return () => {\n rootMounted.current = false;\n };\n }, []);\n const onItemMounted = (el: HTMLInputElement | null) => {\n const late = rootMounted.current;\n if (late && lateSnapshot.current === null) lateSnapshot.current = readDom(\"checked\");\n onMemberMounted(el);\n // A snapshot the adapter did not consume (it queues one read per commit, before this).\n if (late) {\n queueMicrotask(() => {\n lateSnapshot.current = null;\n });\n }\n };\n\n // The state's `value` is in document order (design 14.6: Item values are unique).\n const { renderedValue } = useItemOrder({\n optimistic,\n initial: NO_ORDER,\n read: () => ({ order: readItems(fieldsetRef.current, name).map((item) => item.value) }),\n duplicateMessage:\n isDev &&\n ((duplicate) =>\n `CheckboxGroup.Item: two Items share the value \"${duplicate}\" in one ` +\n `CheckboxGroup.Root. Item values must be unique; both boxes follow the same value.`),\n });\n\n const itemsRequired =\n required &&\n (items === null ? optimistic.size === 0 : ![...optimistic].some((v) => items.get(v) === true));\n // Inside a Field: the Items' `checked` and derived `required` are written by React after the\n // click's `change` (a Parent checks Items with no event of their own), so the Field re-reads\n // validity and `validate` after the commit (design/components/field-form.md 7.2).\n useFieldValueChange(`${[...optimistic].sort().join(\"\\u0000\")}|${String(itemsRequired)}`);\n\n // `aria-invalid` is not supported on role `group` (ARIA 1.2 made it widget-specific): inside a\n // Field it goes on every Item (a `checkbox`) instead; the fieldset keeps `data-invalid` and\n // `aria-describedby`, read when focus enters the group.\n const { \"aria-invalid\": fieldInvalid, ...groupAttributes } = field.attributes;\n\n // `renderedValue` is a fresh array on every render: keyed on its contents.\n const renderedKey = JSON.stringify(renderedValue);\n const state = useMemo<CheckboxGroupRootState>(\n () => ({ value: JSON.parse(renderedKey) as string[], pending, disabled }),\n [renderedKey, pending, disabled],\n );\n\n // The context's callbacks are stable (handlers and member effects only: they read the last\n // committed render), so the context changes only with the values below.\n const latest = useLatest({ optimistic, onItemMounted, sortByDocument, dispatchPatch });\n const callbacks = useMemo(\n () => ({\n onItemMounted: (el: HTMLInputElement | null) => latest.current.onItemMounted(el),\n reportParent: (values: readonly string[], checked: boolean) => {\n parentReports.current.push({ values, checked });\n },\n sortByDocument: (values: Iterable<string>) => latest.current.sortByDocument(values),\n toggle: (item: string, checked: boolean, event: Event) => {\n const { optimistic, dispatchPatch } = latest.current;\n // No-op rule against the optimistic set (conventions 2.3 item 8).\n if (optimistic.has(item) === checked) return;\n const patch = checked ? { added: [item], removed: [] } : { added: [], removed: [item] };\n dispatchPatch(optimistic, patch, \"activate\", event);\n },\n apply: (patch: CheckboxGroupPatch, event: Event) => {\n const { optimistic, dispatchPatch } = latest.current;\n const added = patch.added.filter((v) => !optimistic.has(v));\n const removed = patch.removed.filter((v) => optimistic.has(v));\n if (added.length === 0 && removed.length === 0) return;\n dispatchPatch(optimistic, { added, removed }, \"activate\", event);\n },\n }),\n [latest],\n );\n const contextDefault = value === undefined ? (defaultSet ?? EMPTY_SET) : undefined;\n const context = useMemo<CheckboxGroupContextValue>(\n () => ({\n name,\n form,\n fieldInvalid,\n required: itemsRequired,\n disabledItems,\n registerItem,\n optimistic,\n committed,\n state,\n defaultValue: contextDefault,\n ...callbacks,\n }),\n [\n name,\n form,\n fieldInvalid,\n itemsRequired,\n disabledItems,\n registerItem,\n optimistic,\n committed,\n state,\n contextDefault,\n callbacks,\n ],\n );\n\n const element = useRender<ComponentPropsWithRef<\"fieldset\">, CheckboxGroupRootState>({\n defaultElement: \"fieldset\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n ...groupAttributes,\n disabled,\n form,\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n },\n ref: rootRef,\n });\n\n return <CheckboxGroupContext value={context}>{element}</CheckboxGroupContext>;\n}\n\nCheckboxGroupRoot.displayName = \"CheckboxGroupRoot\";\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAkGvC,SAAS,UAAU,UAA8C;CAC/D,MAAM,wBAAQ,IAAI,IAAqB;CACvC,KAAK,MAAM,EAAE,OAAO,cAAc,SAAS,OAAO,GAChD,MAAM,IAAI,QAAQ,MAAM,IAAI,KAAK,KAAK,UAAU,CAAC,QAAQ;CAE3D,OAAO;AACT;AAEA,SAAS,WAAW,OAAsD;CACxE,IAAI,UAAU,MAAM,OAAO;CAC3B,MAAM,2BAAW,IAAI,IAAY;CACjC,KAAK,MAAM,CAAC,OAAO,YAAY,OAAO,IAAI,CAAC,SAAS,SAAS,IAAI,KAAK;CACtE,OAAO,SAAS,SAAS,IAAI,YAAY;AAC3C;AAEA,SAAS,UAAU,GAAiC,GAA0C;CAC5F,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO;CAC9B,KAAK,MAAM,CA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BAAkB,OAAO;GAC7C,MAAM,QAAQ,MAAM,MAAM,QAAQ,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC;GAC1D,MAAM,UAAU,MAAM,QAAQ,QAAQ,MAAM,WAAW,IAAI,CAAC,CAAC;GAC7D,IAAI,MAAM,WAAW,KAAK,QAAQ,WAAW,GAAG;GAChD,cAAc,YAAY;IAAE;IAAO;GAAQ,GAAG,YAAY,KAAK;EACjE;CACF,IACA,CAAC,MAAM,CACT;CACA,MAAM,iBAAiB,UAAU,KAAA,IAAa,cAAc,YAAa,KAAA;CACzE,MAAM,UAAU,eACP;EACL;EACA;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;EACA;EACA,cAAc;EACd,GAAG;CACL,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,UAAU,UAAqE;EACnF,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,GAAG;GACH;GACA;GACA,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;EACpC;EACA,KAAK;CACP,CAAC;CAED,OAAO,oBAAC,sBAAD;EAAsB,OAAO;EAAU,UAAA;CAA8B,CAAA;AAC9E;AAEA,kBAAkB,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"combobox-clear.d.mts","names":[],"sources":["../../src/combobox/combobox-clear.tsx"],"mappings":";;;iBAeiB;;WAEN;WACA;WACA;;iBAGM,2BAA2B,KAC1C;;;;;EAcA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;wBAavC,gBACd,UAAU,aACV,WACA,OACA,UACA,WACG,QACF,qBAAkB;yBAPL"}
1
+ {"version":3,"file":"combobox-clear.d.mts","names":[],"sources":["../../src/combobox/combobox-clear.tsx"],"mappings":";;;iBAiBiB;;WAEN;WACA;WACA;;iBAGM,2BAA2B,KAC1C;;;;;EAcA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;wBAavC,gBACd,UAAU,aACV,WACA,OACA,UACA,WACG,QACF,qBAAkB;yBAPL"}
@@ -1,10 +1,11 @@
1
1
  "use client";
2
2
  import { dataAttr } from "../internal/data-attr.mjs";
3
- import { isHostButton, rendersButton } from "../internal/render-element.mjs";
3
+ import { disabledButton, rendersButton } from "../internal/render-element.mjs";
4
4
  import { useRender } from "../internal/use-render.mjs";
5
+ import { BUTTON_NAME, useNameWarning } from "../internal/use-name-warning.mjs";
5
6
  import { useComboboxContext } from "./combobox-context.mjs";
6
- import { useNameWarning } from "./combobox-trigger.mjs";
7
7
  //#region src/combobox/combobox-clear.tsx
8
+ const isDev = process.env.NODE_ENV !== "production";
8
9
  /**
9
10
  * The optional button that clears the combobox: `<button type="button" tabindex="-1">`. A click
10
11
  * empties the text (urgent) and dispatches `valueChangeAction(null)` unless nothing is selected;
@@ -18,8 +19,7 @@ import { useNameWarning } from "./combobox-trigger.mjs";
18
19
  function ComboboxClear({ disabled: ownDisabled = false, className, style, children, render, ...rest }) {
19
20
  const ctx = useComboboxContext("Combobox.Clear");
20
21
  const disabled = ownDisabled || ctx.disabled;
21
- const ref = useNameWarning("Combobox.Clear");
22
- const focusable = !isHostButton(render);
22
+ const ref = useNameWarning(isDev && "Combobox.Clear: the button has no accessible name. Give it an `aria-label`.", BUTTON_NAME);
23
23
  const state = {
24
24
  value: ctx.value,
25
25
  inputValue: ctx.inputValue,
@@ -28,8 +28,7 @@ function ComboboxClear({ disabled: ownDisabled = false, className, style, childr
28
28
  const libraryProps = {
29
29
  ...rendersButton(render) && { type: "button" },
30
30
  tabIndex: -1,
31
- disabled: focusable ? void 0 : disabled,
32
- ...focusable && { "aria-disabled": disabled ? true : void 0 },
31
+ ...disabledButton(render, disabled).props,
33
32
  onPointerDown: (event) => {
34
33
  event.preventDefault();
35
34
  },
@@ -1 +1 @@
1
- {"version":3,"file":"combobox-clear.mjs","names":[],"sources":["../../src/combobox/combobox-clear.tsx"],"sourcesContent":["\"use client\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n ReactNode,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { isHostButton, rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { useComboboxContext } from \"./combobox-context.js\";\nimport { useNameWarning } from \"./combobox-trigger.js\";\n\nexport interface ComboboxClearState {\n /** Optimistic selection. */\n readonly value: string | null;\n readonly inputValue: string;\n readonly disabled: boolean;\n}\n\nexport interface ComboboxClearProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n | \"onClick\"\n | \"onPointerDown\"\n | \"onMouseDown\"\n | \"tabIndex\"\n | \"disabled\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * Disables this button; the Root's `disabled` does too. Native `disabled` on a `<button>`; with\n * a link or component `render`, `aria-disabled=\"true\"` instead.\n */\n disabled?: boolean;\n className?: StateValue<string | undefined, ComboboxClearState>;\n style?: StateValue<CSSProperties | undefined, ComboboxClearState>;\n children?: StateValue<ReactNode, ComboboxClearState>;\n /** Should render a `<button>`. */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, ComboboxClearState>;\n}\n\n/**\n * The optional button that clears the combobox: `<button type=\"button\" tabindex=\"-1\">`. A click\n * empties the text (urgent) and dispatches `valueChangeAction(null)` unless nothing is selected;\n * the input keeps focus. Always rendered: hide it with CSS (`:placeholder-shown`) or `state`.\n * A click while the listbox is open closes it (the platform's light dismiss: the button is\n * outside the popup).\n *\n * Owned keys: `type` (on a `<button>`), `tabIndex`, `disabled`, `aria-disabled` (link or component\n * `render`), `onClick`, `onPointerDown`, `onMouseDown`, `data-disabled`.\n */\nexport function ComboboxClear({\n disabled: ownDisabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxClearProps) {\n const ctx = useComboboxContext(\"Combobox.Clear\");\n const disabled = ownDisabled || ctx.disabled;\n const ref = useNameWarning(\"Combobox.Clear\");\n // A link or component render: native `disabled` would mean nothing on a link; the click\n // handler refuses, so `aria-disabled` (#83).\n const focusable = !isHostButton(render);\n const state: ComboboxClearState = { value: ctx.value, inputValue: ctx.inputValue, disabled };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n tabIndex: -1,\n disabled: focusable ? undefined : disabled,\n ...(focusable && { \"aria-disabled\": disabled ? true : undefined }),\n onPointerDown: (event: PointerEvent<HTMLButtonElement>) => {\n event.preventDefault();\n },\n onMouseDown: (event: MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n },\n onClick: (event: MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n // A disabled link must not navigate either.\n event.preventDefault();\n return;\n }\n ctx.clear(event.nativeEvent);\n },\n \"data-disabled\": dataAttr(disabled),\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, ComboboxClearState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps,\n ref,\n });\n}\n\nComboboxClear.displayName = \"ComboboxClear\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAuDA,SAAgB,cAAc,EAC5B,UAAU,cAAc,OACxB,WACA,OACA,UACA,QACA,GAAG,QACkB;CACrB,MAAM,MAAM,mBAAmB,gBAAgB;CAC/C,MAAM,WAAW,eAAe,IAAI;CACpC,MAAM,MAAM,eAAe,gBAAgB;CAG3C,MAAM,YAAY,CAAC,aAAa,MAAM;CACtC,MAAM,QAA4B;EAAE,OAAO,IAAI;EAAO,YAAY,IAAI;EAAY;CAAS;CAE3F,MAAM,eAAiE;EACrE,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;EACvD,UAAU;EACV,UAAU,YAAY,KAAA,IAAY;EAClC,GAAI,aAAa,EAAE,iBAAiB,WAAW,OAAO,KAAA,EAAU;EAChE,gBAAgB,UAA2C;GACzD,MAAM,eAAe;EACvB;EACA,cAAc,UAAyC;GACrD,MAAM,eAAe;EACvB;EACA,UAAU,UAAyC;GACjD,IAAI,UAAU;IAEZ,MAAM,eAAe;IACrB;GACF;GACA,IAAI,MAAM,MAAM,WAAW;EAC7B;EACA,iBAAiB,SAAS,QAAQ;CACpC;CAEA,OAAO,UAA+D;EACpE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA;CACF,CAAC;AACH;AAEA,cAAc,cAAc"}
1
+ {"version":3,"file":"combobox-clear.mjs","names":[],"sources":["../../src/combobox/combobox-clear.tsx"],"sourcesContent":["\"use client\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n ReactNode,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { BUTTON_NAME, useNameWarning } from \"../internal/use-name-warning.js\";\nimport { disabledButton, rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { useComboboxContext } from \"./combobox-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface ComboboxClearState {\n /** Optimistic selection. */\n readonly value: string | null;\n readonly inputValue: string;\n readonly disabled: boolean;\n}\n\nexport interface ComboboxClearProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n | \"onClick\"\n | \"onPointerDown\"\n | \"onMouseDown\"\n | \"tabIndex\"\n | \"disabled\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * Disables this button; the Root's `disabled` does too. Native `disabled` on a `<button>`; with\n * a link or component `render`, `aria-disabled=\"true\"` instead.\n */\n disabled?: boolean;\n className?: StateValue<string | undefined, ComboboxClearState>;\n style?: StateValue<CSSProperties | undefined, ComboboxClearState>;\n children?: StateValue<ReactNode, ComboboxClearState>;\n /** Should render a `<button>`. */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, ComboboxClearState>;\n}\n\n/**\n * The optional button that clears the combobox: `<button type=\"button\" tabindex=\"-1\">`. A click\n * empties the text (urgent) and dispatches `valueChangeAction(null)` unless nothing is selected;\n * the input keeps focus. Always rendered: hide it with CSS (`:placeholder-shown`) or `state`.\n * A click while the listbox is open closes it (the platform's light dismiss: the button is\n * outside the popup).\n *\n * Owned keys: `type` (on a `<button>`), `tabIndex`, `disabled`, `aria-disabled` (link or component\n * `render`), `onClick`, `onPointerDown`, `onMouseDown`, `data-disabled`.\n */\nexport function ComboboxClear({\n disabled: ownDisabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxClearProps) {\n const ctx = useComboboxContext(\"Combobox.Clear\");\n const disabled = ownDisabled || ctx.disabled;\n const ref = useNameWarning(\n isDev && \"Combobox.Clear: the button has no accessible name. Give it an `aria-label`.\",\n BUTTON_NAME,\n );\n const state: ComboboxClearState = { value: ctx.value, inputValue: ctx.inputValue, disabled };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n tabIndex: -1,\n ...disabledButton(render, disabled).props,\n onPointerDown: (event: PointerEvent<HTMLButtonElement>) => {\n event.preventDefault();\n },\n onMouseDown: (event: MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n },\n onClick: (event: MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n // A disabled link must not navigate either.\n event.preventDefault();\n return;\n }\n ctx.clear(event.nativeEvent);\n },\n \"data-disabled\": dataAttr(disabled),\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, ComboboxClearState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps,\n ref,\n });\n}\n\nComboboxClear.displayName = \"ComboboxClear\";\n"],"mappings":";;;;;;;AAeA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;AA0CvC,SAAgB,cAAc,EAC5B,UAAU,cAAc,OACxB,WACA,OACA,UACA,QACA,GAAG,QACkB;CACrB,MAAM,MAAM,mBAAmB,gBAAgB;CAC/C,MAAM,WAAW,eAAe,IAAI;CACpC,MAAM,MAAM,eACV,SAAS,+EACT,WACF;CACA,MAAM,QAA4B;EAAE,OAAO,IAAI;EAAO,YAAY,IAAI;EAAY;CAAS;CAE3F,MAAM,eAAiE;EACrE,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;EACvD,UAAU;EACV,GAAG,eAAe,QAAQ,QAAQ,CAAC,CAAC;EACpC,gBAAgB,UAA2C;GACzD,MAAM,eAAe;EACvB;EACA,cAAc,UAAyC;GACrD,MAAM,eAAe;EACvB;EACA,UAAU,UAAyC;GACjD,IAAI,UAAU;IAEZ,MAAM,eAAe;IACrB;GACF;GACA,IAAI,MAAM,MAAM,WAAW;EAC7B;EACA,iBAAiB,SAAS,QAAQ;CACpC;CAEA,OAAO,UAA+D;EACpE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA;CACF,CAAC;AACH;AAEA,cAAc,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"combobox-context.mjs","names":[],"sources":["../../src/combobox/combobox-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { PopoverRootValue } from \"../internal/use-popover-root.js\";\n\n/** What a mounted `Combobox.Option` tells its Root (design 2, \"mounted options, labels\"). */\nexport interface ComboboxOptionEntry {\n readonly element: HTMLElement;\n /** The `label` prop; `undefined`: the element's trimmed `textContent` at the moment of use. */\n readonly label: string | undefined;\n readonly disabled: boolean;\n}\n\n/** One Combobox: what its Root provides to every part (design 14, `combobox-context.ts`). */\nexport interface ComboboxContextValue {\n /** The shared popover machinery (`usePopoverRoot`, library mode). */\n readonly popover: PopoverRootValue;\n readonly ids: {\n readonly input: string;\n readonly label: string;\n readonly list: string;\n /** `${root}-option-`: an Option's id is this plus `encodeURIComponent(value)`. */\n readonly optionPrefix: string;\n };\n /** Optimistic selection. */\n readonly value: string | null;\n /** The `valueChangeAction` transition is in flight. */\n readonly valuePending: boolean;\n /** `valuePending` or the open transition is in flight (the Root's `pending`). */\n readonly pending: boolean;\n /** The urgent text. */\n readonly inputValue: string;\n /** `useDeferredValue(inputValue)`: what the mounted results are for. */\n readonly query: string;\n readonly stale: boolean;\n /** The option `aria-activedescendant` points at (urgent virtual focus), or `null`. */\n readonly activeValue: string | null;\n /** No option is mounted and the results are settled (`Empty`, `data-empty`). */\n readonly empty: boolean;\n /** A `Combobox.Status` is mounted inside the List (a Suspense fallback): results are loading. */\n readonly loading: boolean;\n /** A `Combobox.Label` is mounted (the List's `aria-labelledby` names it only then). */\n readonly hasLabel: boolean;\n /** The enclosing `Field.Label`'s id: names the List when no `Combobox.Label` is mounted. */\n readonly fieldLabelId: string | undefined;\n readonly disabled: boolean;\n readonly inputRef: RefObject<HTMLInputElement | null>;\n readonly listRef: RefObject<HTMLElement | null>;\n /** Registers a mounted Option; returns the unregistration. */\n readonly registerOption: (value: string, entry: ComboboxOptionEntry) => () => void;\n /** Registers a mounted `Combobox.Status`; while one is mounted the results count as loading. */\n readonly registerStatus: () => () => void;\n /** Registers a mounted `Combobox.Label`; returns the unregistration. */\n readonly registerLabel: () => () => void;\n /** Make `value` the active option (urgent; never dispatches). */\n readonly setActive: (value: string | null) => void;\n /** Accept an option (design 5.2): urgent text write, dispatch, close when it settles. */\n readonly accept: (value: string, event: Event) => void;\n /** `Combobox.Clear` (design 3.3). */\n readonly clear: (event: Event) => void;\n /** The `change` of the Input: urgent text write and an open request (design 2.2, 5.1). */\n readonly typed: (text: string, event: Event) => void;\n /** Keyboard model of design section 8, run by the Input's `onKeyDown`. */\n readonly keyDown: (event: KeyboardEvent) => boolean;\n /** Focus left the Input (design 5.4): close at once, then revert or commit free text. */\n readonly focusOut: (event: FocusEvent) => void;\n /** A pointer click in the Input (`openOnClick`). */\n readonly inputClick: (event: MouseEvent) => void;\n}\n\nexport const ComboboxContext = createContext<ComboboxContextValue | null>(null);\n\nexport function useComboboxContext(part: string): ComboboxContextValue {\n const context = use(ComboboxContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Combobox.Root.`);\n }\n return context;\n}\n\n/** Provided by `Combobox.Popup` (a List outside a Popup warns). */\nexport const ComboboxPopupContext = createContext<boolean>(false);\n\n/** Provided by `Combobox.List` (an Option outside a List warns). */\nexport const ComboboxListContext = createContext<boolean>(false);\n\n/** `Combobox.Group`: the id its `Combobox.GroupLabel` renders. */\nexport const ComboboxGroupContext = createContext<string | null>(null);\n\n/** The id fragment of an option value: stable across result sets, no whitespace (design 3.5). */\nexport function optionId(prefix: string, value: string): string {\n return `${prefix}${encodeURIComponent(value)}`;\n}\n"],"mappings":";;;AAsEA,MAAa,kBAAkB,cAA2C,IAAI;AAE9E,SAAgB,mBAAmB,MAAoC;CACrE,MAAM,UAAU,IAAI,eAAe;CACnC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,0CAA0C;CAEpE,OAAO;AACT;;AAGA,MAAa,uBAAuB,cAAuB,KAAK;;AAGhE,MAAa,sBAAsB,cAAuB,KAAK;;AAG/D,MAAa,uBAAuB,cAA6B,IAAI;;AAGrE,SAAgB,SAAS,QAAgB,OAAuB;CAC9D,OAAO,GAAG,SAAS,mBAAmB,KAAK;AAC7C"}
1
+ {"version":3,"file":"combobox-context.mjs","names":[],"sources":["../../src/combobox/combobox-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { PopoverRootValue } from \"../internal/use-overlay-root.js\";\n\n/** What a mounted `Combobox.Option` tells its Root (design 2, \"mounted options, labels\"). */\nexport interface ComboboxOptionEntry {\n readonly element: HTMLElement;\n /** The `label` prop; `undefined`: the element's trimmed `textContent` at the moment of use. */\n readonly label: string | undefined;\n readonly disabled: boolean;\n}\n\n/** One Combobox: what its Root provides to every part (design 14, `combobox-context.ts`). */\nexport interface ComboboxContextValue {\n /** The shared popover machinery (`useOverlayRoot`, library mode). */\n readonly popover: PopoverRootValue;\n readonly ids: {\n readonly input: string;\n readonly label: string;\n readonly list: string;\n /** `${root}-option-`: an Option's id is this plus `encodeURIComponent(value)`. */\n readonly optionPrefix: string;\n };\n /** Optimistic selection. */\n readonly value: string | null;\n /** The `valueChangeAction` transition is in flight. */\n readonly valuePending: boolean;\n /** `valuePending` or the open transition is in flight (the Root's `pending`). */\n readonly pending: boolean;\n /** The urgent text. */\n readonly inputValue: string;\n /** `useDeferredValue(inputValue)`: what the mounted results are for. */\n readonly query: string;\n readonly stale: boolean;\n /** The option `aria-activedescendant` points at (urgent virtual focus), or `null`. */\n readonly activeValue: string | null;\n /** No option is mounted and the results are settled (`Empty`, `data-empty`). */\n readonly empty: boolean;\n /** A `Combobox.Status` is mounted inside the List (a Suspense fallback): results are loading. */\n readonly loading: boolean;\n /** A `Combobox.Label` is mounted (the List's `aria-labelledby` names it only then). */\n readonly hasLabel: boolean;\n /** The enclosing `Field.Label`'s id: names the List when no `Combobox.Label` is mounted. */\n readonly fieldLabelId: string | undefined;\n readonly disabled: boolean;\n readonly inputRef: RefObject<HTMLInputElement | null>;\n readonly listRef: RefObject<HTMLElement | null>;\n /** Registers a mounted Option; returns the unregistration. */\n readonly registerOption: (value: string, entry: ComboboxOptionEntry) => () => void;\n /** Registers a mounted `Combobox.Status`; while one is mounted the results count as loading. */\n readonly registerStatus: () => () => void;\n /** Registers a mounted `Combobox.Label`; returns the unregistration. */\n readonly registerLabel: () => () => void;\n /** Make `value` the active option (urgent; never dispatches). */\n readonly setActive: (value: string | null) => void;\n /** Accept an option (design 5.2): urgent text write, dispatch, close when it settles. */\n readonly accept: (value: string, event: Event) => void;\n /** `Combobox.Clear` (design 3.3). */\n readonly clear: (event: Event) => void;\n /** The `change` of the Input: urgent text write and an open request (design 2.2, 5.1). */\n readonly typed: (text: string, event: Event) => void;\n /** Keyboard model of design section 8, run by the Input's `onKeyDown`. */\n readonly keyDown: (event: KeyboardEvent) => boolean;\n /** Focus left the Input (design 5.4): close at once, then revert or commit free text. */\n readonly focusOut: (event: FocusEvent) => void;\n /** A pointer click in the Input (`openOnClick`). */\n readonly inputClick: (event: MouseEvent) => void;\n}\n\nexport const ComboboxContext = createContext<ComboboxContextValue | null>(null);\n\nexport function useComboboxContext(part: string): ComboboxContextValue {\n const context = use(ComboboxContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Combobox.Root.`);\n }\n return context;\n}\n\n/** Provided by `Combobox.Popup` (a List outside a Popup warns). */\nexport const ComboboxPopupContext = createContext<boolean>(false);\n\n/** Provided by `Combobox.List` (an Option outside a List warns). */\nexport const ComboboxListContext = createContext<boolean>(false);\n\n/** `Combobox.Group`: the id its `Combobox.GroupLabel` renders. */\nexport const ComboboxGroupContext = createContext<string | null>(null);\n\n/** The id fragment of an option value: stable across result sets, no whitespace (design 3.5). */\nexport function optionId(prefix: string, value: string): string {\n return `${prefix}${encodeURIComponent(value)}`;\n}\n"],"mappings":";;;AAsEA,MAAa,kBAAkB,cAA2C,IAAI;AAE9E,SAAgB,mBAAmB,MAAoC;CACrE,MAAM,UAAU,IAAI,eAAe;CACnC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,0CAA0C;CAEpE,OAAO;AACT;;AAGA,MAAa,uBAAuB,cAAuB,KAAK;;AAGhE,MAAa,sBAAsB,cAAuB,KAAK;;AAG/D,MAAa,uBAAuB,cAA6B,IAAI;;AAGrE,SAAgB,SAAS,QAAgB,OAAuB;CAC9D,OAAO,GAAG,SAAS,mBAAmB,KAAK;AAC7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"combobox-group.d.mts","names":[],"sources":["../../src/combobox/combobox-group.tsx"],"mappings":";;;;;YAcY,qBAAqB;YACrB,0BAA0B;YAC1B,sBAAsB;;YAEtB,qBAAqB;iBAIhB,2BAA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B;;;wBAIpC,qBACd,WACA,OACA,UACA,WACG,QACF,0BAAuB;yBANV;;;iBA0BC,2BAA2B,KAC1C;EAGA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;wBASpC,gBAAgB,WAAW,OAAO,UAAU,WAAW,QAAQ,qBAAkB;yBAAjF;;;iBAiBC,4BAA4B,KAC3C;EAGA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;wBAYpC,iBACd,WACA,OACA,UACA,WACG,QACF,sBAAmB;yBANN"}
@@ -5,6 +5,7 @@ import { ComboboxGroupContext, ComboboxListContext, useComboboxContext } from ".
5
5
  import { use, useId, useLayoutEffect } from "react";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  //#region src/combobox/combobox-group.tsx
8
+ const isDev = process.env.NODE_ENV !== "production";
8
9
  const EMPTY = {};
9
10
  /**
10
11
  * A labelled set of options: `<div role="group" aria-labelledby>` named by the
@@ -35,7 +36,7 @@ ComboboxGroup.displayName = "ComboboxGroup";
35
36
  /** The name of the enclosing `Combobox.Group`: a `<div>` with the referenced id. Owned key: `id`. */
36
37
  function ComboboxGroupLabel({ className, style, children, render, ...rest }) {
37
38
  const labelId = use(ComboboxGroupContext);
38
- useDevWarning(labelId === null, "Combobox.GroupLabel: rendered outside a Combobox.Group; it names nothing.");
39
+ useDevWarning(labelId === null, isDev && "Combobox.GroupLabel: rendered outside a Combobox.Group; it names nothing.");
39
40
  return useRender({
40
41
  defaultElement: "div",
41
42
  render,
@@ -1 +1 @@
1
- {"version":3,"file":"combobox-group.mjs","names":[],"sources":["../../src/combobox/combobox-group.tsx"],"sourcesContent":["\"use client\";\nimport { use, useId, useLayoutEffect } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport {\n ComboboxGroupContext,\n ComboboxListContext,\n useComboboxContext,\n} from \"./combobox-context.js\";\nimport type { ComboboxListState } from \"./combobox-list.js\";\n\n/** `Combobox.Group`, `Combobox.GroupLabel` and `Combobox.Status` have no state of their own. */\nexport type ComboboxGroupState = Record<string, never>;\nexport type ComboboxGroupLabelState = Record<string, never>;\nexport type ComboboxStatusState = Record<string, never>;\n/** `Combobox.Empty` renders from the List's state. */\nexport type ComboboxEmptyState = ComboboxListState;\n\nconst EMPTY: Record<string, never> = {};\n\nexport interface ComboboxGroupProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"role\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxGroupState>;\n style?: StateValue<CSSProperties | undefined, ComboboxGroupState>;\n children?: StateValue<ReactNode, ComboboxGroupState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxGroupState>;\n}\n\n/**\n * A labelled set of options: `<div role=\"group\" aria-labelledby>` named by the\n * `Combobox.GroupLabel` inside it. Owned keys: `role`, `aria-labelledby` (token-merged).\n */\nexport function ComboboxGroup({ className, style, children, render, ...rest }: ComboboxGroupProps) {\n useComboboxContext(\"Combobox.Group\");\n const labelId = `${useId()}-label`;\n const element = useRender<ComponentPropsWithRef<\"div\">, ComboboxGroupState>({\n defaultElement: \"div\",\n render,\n state: EMPTY,\n className,\n style,\n children,\n props: rest,\n libraryProps: { role: \"group\", \"aria-labelledby\": labelId },\n });\n return <ComboboxGroupContext value={labelId}>{element}</ComboboxGroupContext>;\n}\n\nComboboxGroup.displayName = \"ComboboxGroup\";\n\nexport interface ComboboxGroupLabelProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"id\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxGroupLabelState>;\n style?: StateValue<CSSProperties | undefined, ComboboxGroupLabelState>;\n children?: StateValue<ReactNode, ComboboxGroupLabelState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxGroupLabelState>;\n}\n\n/** The name of the enclosing `Combobox.Group`: a `<div>` with the referenced id. Owned key: `id`. */\nexport function ComboboxGroupLabel({\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxGroupLabelProps) {\n const labelId = use(ComboboxGroupContext);\n useDevWarning(\n labelId === null,\n \"Combobox.GroupLabel: rendered outside a Combobox.Group; it names nothing.\",\n );\n return useRender<ComponentPropsWithRef<\"div\">, ComboboxGroupLabelState>({\n defaultElement: \"div\",\n render,\n state: EMPTY,\n className,\n style,\n children,\n props: rest,\n libraryProps: labelId === null ? {} : { id: labelId },\n });\n}\n\nComboboxGroupLabel.displayName = \"ComboboxGroupLabel\";\n\nexport interface ComboboxEmptyProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxEmptyState>;\n style?: StateValue<CSSProperties | undefined, ComboboxEmptyState>;\n children?: StateValue<ReactNode, ComboboxEmptyState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxEmptyState>;\n}\n\n/**\n * \"No results\": renders a `<div>` with its children only when the List has **no mounted\n * options, the results are not stale and none are loading** (no `Combobox.Status` mounted inside\n * the List, i.e. no Suspense fallback showing); nothing otherwise (design 6.3). Place it in the\n * Popup, outside the List (a listbox holds only options). Owns no keys.\n */\nexport function ComboboxEmpty({ className, style, children, render, ...rest }: ComboboxEmptyProps) {\n const ctx = useComboboxContext(\"Combobox.Empty\");\n const state: ComboboxEmptyState = { query: ctx.query, stale: ctx.stale, empty: ctx.empty };\n const element = useRender<ComponentPropsWithRef<\"div\">, ComboboxEmptyState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n });\n return ctx.empty ? element : null;\n}\n\nComboboxEmpty.displayName = \"ComboboxEmpty\";\n\nexport interface ComboboxStatusProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"role\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxStatusState>;\n style?: StateValue<CSSProperties | undefined, ComboboxStatusState>;\n children?: StateValue<ReactNode, ComboboxStatusState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxStatusState>;\n}\n\n/**\n * A loading row or a hint. Rendered **inside the List** (the usual Suspense fallback,\n * `<Suspense fallback={<Combobox.Status>Searching…</Combobox.Status>}>`), it marks the results\n * as loading: `<div role=\"none\">` (a listbox owns only options and groups, and a live region\n * there would talk over the count; the List is `aria-busy` instead), `Empty` stays hidden and\n * nothing is announced while it is mounted. Rendered in the Popup outside the List it is a plain\n * hint, `<div role=\"status\">`. No live-region work of its own either way (the result count is\n * announced with `ariaNotify`). Owned key: `role`.\n */\nexport function ComboboxStatus({\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxStatusProps) {\n const { registerStatus } = useComboboxContext(\"Combobox.Status\");\n const inList = use(ComboboxListContext);\n useLayoutEffect(() => (inList ? registerStatus() : undefined), [inList, registerStatus]);\n return useRender<ComponentPropsWithRef<\"div\">, ComboboxStatusState>({\n defaultElement: \"div\",\n render,\n state: EMPTY,\n className,\n style,\n children,\n props: rest,\n libraryProps: { role: inList ? \"none\" : \"status\" },\n });\n}\n\nComboboxStatus.displayName = \"ComboboxStatus\";\n"],"mappings":";;;;;;;AAoBA,MAAM,QAA+B,CAAC;;;;;AAgBtC,SAAgB,cAAc,EAAE,WAAW,OAAO,UAAU,QAAQ,GAAG,QAA4B;CACjG,mBAAmB,gBAAgB;CACnC,MAAM,UAAU,GAAG,MAAM,EAAE;CAC3B,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA;EACA,OAAO;EACP,cAAc;GAAE,MAAM;GAAS,mBAAmB;EAAQ;CAC5D,CAAC;CACD,OAAO,oBAAC,sBAAD;EAAsB,OAAO;EAAU,UAAA;CAA8B,CAAA;AAC9E;AAEA,cAAc,cAAc;;AAa5B,SAAgB,mBAAmB,EACjC,WACA,OACA,UACA,QACA,GAAG,QACuB;CAC1B,MAAM,UAAU,IAAI,oBAAoB;CACxC,cACE,YAAY,MACZ,2EACF;CACA,OAAO,UAAiE;EACtE,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA;EACA,OAAO;EACP,cAAc,YAAY,OAAO,CAAC,IAAI,EAAE,IAAI,QAAQ;CACtD,CAAC;AACH;AAEA,mBAAmB,cAAc;;;;;;;AAkBjC,SAAgB,cAAc,EAAE,WAAW,OAAO,UAAU,QAAQ,GAAG,QAA4B;CACjG,MAAM,MAAM,mBAAmB,gBAAgB;CAC/C,MAAM,QAA4B;EAAE,OAAO,IAAI;EAAO,OAAO,IAAI;EAAO,OAAO,IAAI;CAAM;CACzF,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;CACT,CAAC;CACD,OAAO,IAAI,QAAQ,UAAU;AAC/B;AAEA,cAAc,cAAc;;;;;;;;;;AAqB5B,SAAgB,eAAe,EAC7B,WACA,OACA,UACA,QACA,GAAG,QACmB;CACtB,MAAM,EAAE,mBAAmB,mBAAmB,iBAAiB;CAC/D,MAAM,SAAS,IAAI,mBAAmB;CACtC,sBAAuB,SAAS,eAAe,IAAI,KAAA,GAAY,CAAC,QAAQ,cAAc,CAAC;CACvF,OAAO,UAA6D;EAClE,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA;EACA,OAAO;EACP,cAAc,EAAE,MAAM,SAAS,SAAS,SAAS;CACnD,CAAC;AACH;AAEA,eAAe,cAAc"}
1
+ {"version":3,"file":"combobox-group.mjs","names":[],"sources":["../../src/combobox/combobox-group.tsx"],"sourcesContent":["\"use client\";\nimport { use, useId, useLayoutEffect } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport {\n ComboboxGroupContext,\n ComboboxListContext,\n useComboboxContext,\n} from \"./combobox-context.js\";\nimport type { ComboboxListState } from \"./combobox-list.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** `Combobox.Group`, `Combobox.GroupLabel` and `Combobox.Status` have no state of their own. */\nexport type ComboboxGroupState = Record<string, never>;\nexport type ComboboxGroupLabelState = Record<string, never>;\nexport type ComboboxStatusState = Record<string, never>;\n/** `Combobox.Empty` renders from the List's state. */\nexport type ComboboxEmptyState = ComboboxListState;\n\nconst EMPTY: Record<string, never> = {};\n\nexport interface ComboboxGroupProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"role\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxGroupState>;\n style?: StateValue<CSSProperties | undefined, ComboboxGroupState>;\n children?: StateValue<ReactNode, ComboboxGroupState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxGroupState>;\n}\n\n/**\n * A labelled set of options: `<div role=\"group\" aria-labelledby>` named by the\n * `Combobox.GroupLabel` inside it. Owned keys: `role`, `aria-labelledby` (token-merged).\n */\nexport function ComboboxGroup({ className, style, children, render, ...rest }: ComboboxGroupProps) {\n useComboboxContext(\"Combobox.Group\");\n const labelId = `${useId()}-label`;\n const element = useRender<ComponentPropsWithRef<\"div\">, ComboboxGroupState>({\n defaultElement: \"div\",\n render,\n state: EMPTY,\n className,\n style,\n children,\n props: rest,\n libraryProps: { role: \"group\", \"aria-labelledby\": labelId },\n });\n return <ComboboxGroupContext value={labelId}>{element}</ComboboxGroupContext>;\n}\n\nComboboxGroup.displayName = \"ComboboxGroup\";\n\nexport interface ComboboxGroupLabelProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"id\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxGroupLabelState>;\n style?: StateValue<CSSProperties | undefined, ComboboxGroupLabelState>;\n children?: StateValue<ReactNode, ComboboxGroupLabelState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxGroupLabelState>;\n}\n\n/** The name of the enclosing `Combobox.Group`: a `<div>` with the referenced id. Owned key: `id`. */\nexport function ComboboxGroupLabel({\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxGroupLabelProps) {\n const labelId = use(ComboboxGroupContext);\n useDevWarning(\n labelId === null,\n isDev && \"Combobox.GroupLabel: rendered outside a Combobox.Group; it names nothing.\",\n );\n return useRender<ComponentPropsWithRef<\"div\">, ComboboxGroupLabelState>({\n defaultElement: \"div\",\n render,\n state: EMPTY,\n className,\n style,\n children,\n props: rest,\n libraryProps: labelId === null ? {} : { id: labelId },\n });\n}\n\nComboboxGroupLabel.displayName = \"ComboboxGroupLabel\";\n\nexport interface ComboboxEmptyProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxEmptyState>;\n style?: StateValue<CSSProperties | undefined, ComboboxEmptyState>;\n children?: StateValue<ReactNode, ComboboxEmptyState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxEmptyState>;\n}\n\n/**\n * \"No results\": renders a `<div>` with its children only when the List has **no mounted\n * options, the results are not stale and none are loading** (no `Combobox.Status` mounted inside\n * the List, i.e. no Suspense fallback showing); nothing otherwise (design 6.3). Place it in the\n * Popup, outside the List (a listbox holds only options). Owns no keys.\n */\nexport function ComboboxEmpty({ className, style, children, render, ...rest }: ComboboxEmptyProps) {\n const ctx = useComboboxContext(\"Combobox.Empty\");\n const state: ComboboxEmptyState = { query: ctx.query, stale: ctx.stale, empty: ctx.empty };\n const element = useRender<ComponentPropsWithRef<\"div\">, ComboboxEmptyState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n });\n return ctx.empty ? element : null;\n}\n\nComboboxEmpty.displayName = \"ComboboxEmpty\";\n\nexport interface ComboboxStatusProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"role\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxStatusState>;\n style?: StateValue<CSSProperties | undefined, ComboboxStatusState>;\n children?: StateValue<ReactNode, ComboboxStatusState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxStatusState>;\n}\n\n/**\n * A loading row or a hint. Rendered **inside the List** (the usual Suspense fallback,\n * `<Suspense fallback={<Combobox.Status>Searching…</Combobox.Status>}>`), it marks the results\n * as loading: `<div role=\"none\">` (a listbox owns only options and groups, and a live region\n * there would talk over the count; the List is `aria-busy` instead), `Empty` stays hidden and\n * nothing is announced while it is mounted. Rendered in the Popup outside the List it is a plain\n * hint, `<div role=\"status\">`. No live-region work of its own either way (the result count is\n * announced with `ariaNotify`). Owned key: `role`.\n */\nexport function ComboboxStatus({\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxStatusProps) {\n const { registerStatus } = useComboboxContext(\"Combobox.Status\");\n const inList = use(ComboboxListContext);\n useLayoutEffect(() => (inList ? registerStatus() : undefined), [inList, registerStatus]);\n return useRender<ComponentPropsWithRef<\"div\">, ComboboxStatusState>({\n defaultElement: \"div\",\n render,\n state: EMPTY,\n className,\n style,\n children,\n props: rest,\n libraryProps: { role: inList ? \"none\" : \"status\" },\n });\n}\n\nComboboxStatus.displayName = \"ComboboxStatus\";\n"],"mappings":";;;;;;;AAaA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AASvC,MAAM,QAA+B,CAAC;;;;;AAgBtC,SAAgB,cAAc,EAAE,WAAW,OAAO,UAAU,QAAQ,GAAG,QAA4B;CACjG,mBAAmB,gBAAgB;CACnC,MAAM,UAAU,GAAG,MAAM,EAAE;CAC3B,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA;EACA,OAAO;EACP,cAAc;GAAE,MAAM;GAAS,mBAAmB;EAAQ;CAC5D,CAAC;CACD,OAAO,oBAAC,sBAAD;EAAsB,OAAO;EAAU,UAAA;CAA8B,CAAA;AAC9E;AAEA,cAAc,cAAc;;AAa5B,SAAgB,mBAAmB,EACjC,WACA,OACA,UACA,QACA,GAAG,QACuB;CAC1B,MAAM,UAAU,IAAI,oBAAoB;CACxC,cACE,YAAY,MACZ,SAAS,2EACX;CACA,OAAO,UAAiE;EACtE,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA;EACA,OAAO;EACP,cAAc,YAAY,OAAO,CAAC,IAAI,EAAE,IAAI,QAAQ;CACtD,CAAC;AACH;AAEA,mBAAmB,cAAc;;;;;;;AAkBjC,SAAgB,cAAc,EAAE,WAAW,OAAO,UAAU,QAAQ,GAAG,QAA4B;CACjG,MAAM,MAAM,mBAAmB,gBAAgB;CAC/C,MAAM,QAA4B;EAAE,OAAO,IAAI;EAAO,OAAO,IAAI;EAAO,OAAO,IAAI;CAAM;CACzF,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;CACT,CAAC;CACD,OAAO,IAAI,QAAQ,UAAU;AAC/B;AAEA,cAAc,cAAc;;;;;;;;;;AAqB5B,SAAgB,eAAe,EAC7B,WACA,OACA,UACA,QACA,GAAG,QACmB;CACtB,MAAM,EAAE,mBAAmB,mBAAmB,iBAAiB;CAC/D,MAAM,SAAS,IAAI,mBAAmB;CACtC,sBAAuB,SAAS,eAAe,IAAI,KAAA,GAAY,CAAC,QAAQ,cAAc,CAAC;CACvF,OAAO,UAA6D;EAClE,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA;EACA,OAAO;EACP,cAAc,EAAE,MAAM,SAAS,SAAS,SAAS;CACnD,CAAC;AACH;AAEA,eAAe,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"combobox-input.d.mts","names":[],"sources":["../../src/combobox/combobox-input.tsx"],"mappings":";;;iBAiBiB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;WACA;;iBAGM,2BAA2B,KAC1C;;EAoBA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,gCAAgC;;;;;;;;;;;;;;wBAiBtC,gBAAgB,WAAW,OAAO,WAAW,QAAQ,qCAAkB;yBAAvE"}
1
+ {"version":3,"file":"combobox-input.d.mts","names":[],"sources":["../../src/combobox/combobox-input.tsx"],"mappings":";;;iBAqBiB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;WACA;;iBAGM,2BAA2B,KAC1C;;EAoBA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,gCAAgC;;;;;;;;;;;;;;wBAetC,gBAAgB,WAAW,OAAO,WAAW,QAAQ,qCAAkB;yBAAvE"}