@funstack/ui 0.1.0-alpha.14 → 0.1.0-alpha.16

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 (584) hide show
  1. package/README.md +22 -1
  2. package/dist/accordion/accordion-item.d.mts +19 -0
  3. package/dist/accordion/accordion-item.d.mts.map +1 -1
  4. package/dist/accordion/accordion-item.mjs +2 -0
  5. package/dist/accordion/accordion-item.mjs.map +1 -1
  6. package/dist/accordion/accordion-panel.d.mts +16 -0
  7. package/dist/accordion/accordion-panel.d.mts.map +1 -1
  8. package/dist/accordion/accordion-panel.mjs +2 -0
  9. package/dist/accordion/accordion-panel.mjs.map +1 -1
  10. package/dist/accordion/accordion-root.d.mts +36 -2
  11. package/dist/accordion/accordion-root.d.mts.map +1 -1
  12. package/dist/accordion/accordion-root.mjs +7 -4
  13. package/dist/accordion/accordion-root.mjs.map +1 -1
  14. package/dist/accordion/accordion-trigger.d.mts +9 -0
  15. package/dist/accordion/accordion-trigger.d.mts.map +1 -1
  16. package/dist/accordion/accordion-trigger.mjs +2 -0
  17. package/dist/accordion/accordion-trigger.mjs.map +1 -1
  18. package/dist/accordion/index.d.mts +2 -0
  19. package/dist/accordion/index.d.mts.map +1 -1
  20. package/dist/accordion/index.mjs +2 -0
  21. package/dist/accordion/index.mjs.map +1 -1
  22. package/dist/bin/skill-installer.d.mts +1 -0
  23. package/dist/bin/skill-installer.mjs +12 -0
  24. package/dist/bin/skill-installer.mjs.map +1 -0
  25. package/dist/button/button.d.mts +25 -7
  26. package/dist/button/button.d.mts.map +1 -1
  27. package/dist/button/button.mjs +2 -0
  28. package/dist/button/button.mjs.map +1 -1
  29. package/dist/checkbox/checkbox.d.mts +25 -3
  30. package/dist/checkbox/checkbox.d.mts.map +1 -1
  31. package/dist/checkbox/checkbox.mjs +2 -0
  32. package/dist/checkbox/checkbox.mjs.map +1 -1
  33. package/dist/checkbox-group/checkbox-group-item.d.mts +15 -0
  34. package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
  35. package/dist/checkbox-group/checkbox-group-item.mjs +2 -0
  36. package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
  37. package/dist/checkbox-group/checkbox-group-label.d.mts +10 -0
  38. package/dist/checkbox-group/checkbox-group-label.d.mts.map +1 -1
  39. package/dist/checkbox-group/checkbox-group-label.mjs +2 -0
  40. package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
  41. package/dist/checkbox-group/checkbox-group-parent.d.mts +19 -1
  42. package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
  43. package/dist/checkbox-group/checkbox-group-parent.mjs +2 -0
  44. package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
  45. package/dist/checkbox-group/checkbox-group-root.d.mts +31 -4
  46. package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
  47. package/dist/checkbox-group/checkbox-group-root.mjs +6 -5
  48. package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
  49. package/dist/checkbox-group/index.d.mts +2 -0
  50. package/dist/checkbox-group/index.d.mts.map +1 -1
  51. package/dist/checkbox-group/index.mjs +2 -0
  52. package/dist/checkbox-group/index.mjs.map +1 -1
  53. package/dist/combobox/combobox-clear.d.mts +18 -0
  54. package/dist/combobox/combobox-clear.d.mts.map +1 -1
  55. package/dist/combobox/combobox-clear.mjs +2 -0
  56. package/dist/combobox/combobox-clear.mjs.map +1 -1
  57. package/dist/combobox/combobox-context.mjs.map +1 -1
  58. package/dist/combobox/combobox-group.d.mts +49 -1
  59. package/dist/combobox/combobox-group.d.mts.map +1 -1
  60. package/dist/combobox/combobox-group.mjs +11 -1
  61. package/dist/combobox/combobox-group.mjs.map +1 -1
  62. package/dist/combobox/combobox-input.d.mts +18 -6
  63. package/dist/combobox/combobox-input.d.mts.map +1 -1
  64. package/dist/combobox/combobox-input.mjs +8 -5
  65. package/dist/combobox/combobox-input.mjs.map +1 -1
  66. package/dist/combobox/combobox-label.d.mts +18 -1
  67. package/dist/combobox/combobox-label.d.mts.map +1 -1
  68. package/dist/combobox/combobox-label.mjs +4 -1
  69. package/dist/combobox/combobox-label.mjs.map +1 -1
  70. package/dist/combobox/combobox-list.d.mts +14 -0
  71. package/dist/combobox/combobox-list.d.mts.map +1 -1
  72. package/dist/combobox/combobox-list.mjs +2 -0
  73. package/dist/combobox/combobox-list.mjs.map +1 -1
  74. package/dist/combobox/combobox-option.d.mts +25 -3
  75. package/dist/combobox/combobox-option.d.mts.map +1 -1
  76. package/dist/combobox/combobox-option.mjs +2 -0
  77. package/dist/combobox/combobox-option.mjs.map +1 -1
  78. package/dist/combobox/combobox-popup.d.mts +17 -1
  79. package/dist/combobox/combobox-popup.d.mts.map +1 -1
  80. package/dist/combobox/combobox-popup.mjs +5 -15
  81. package/dist/combobox/combobox-popup.mjs.map +1 -1
  82. package/dist/combobox/combobox-root.d.mts +49 -12
  83. package/dist/combobox/combobox-root.d.mts.map +1 -1
  84. package/dist/combobox/combobox-root.mjs +11 -80
  85. package/dist/combobox/combobox-root.mjs.map +1 -1
  86. package/dist/combobox/combobox-trigger.d.mts +26 -8
  87. package/dist/combobox/combobox-trigger.d.mts.map +1 -1
  88. package/dist/combobox/combobox-trigger.mjs +23 -17
  89. package/dist/combobox/combobox-trigger.mjs.map +1 -1
  90. package/dist/combobox/index.d.mts +4 -2
  91. package/dist/combobox/index.d.mts.map +1 -1
  92. package/dist/combobox/index.mjs +4 -2
  93. package/dist/combobox/index.mjs.map +1 -1
  94. package/dist/combobox/use-deferred-leave.mjs +105 -0
  95. package/dist/combobox/use-deferred-leave.mjs.map +1 -0
  96. package/dist/csp/csp-provider.d.mts +8 -0
  97. package/dist/csp/csp-provider.d.mts.map +1 -1
  98. package/dist/csp/csp-provider.mjs +2 -0
  99. package/dist/csp/csp-provider.mjs.map +1 -1
  100. package/dist/csp/style-hashes.d.mts +2 -0
  101. package/dist/csp/style-hashes.d.mts.map +1 -1
  102. package/dist/csp/style-hashes.mjs +2 -0
  103. package/dist/csp/style-hashes.mjs.map +1 -1
  104. package/dist/dialog/dialog-close.d.mts +18 -0
  105. package/dist/dialog/dialog-close.d.mts.map +1 -1
  106. package/dist/dialog/dialog-close.mjs +2 -0
  107. package/dist/dialog/dialog-close.mjs.map +1 -1
  108. package/dist/dialog/dialog-context.mjs.map +1 -1
  109. package/dist/dialog/dialog-description.d.mts +12 -0
  110. package/dist/dialog/dialog-description.d.mts.map +1 -1
  111. package/dist/dialog/dialog-description.mjs +2 -0
  112. package/dist/dialog/dialog-description.mjs.map +1 -1
  113. package/dist/dialog/dialog-form.d.mts +18 -1
  114. package/dist/dialog/dialog-form.d.mts.map +1 -1
  115. package/dist/dialog/dialog-form.mjs +2 -0
  116. package/dist/dialog/dialog-form.mjs.map +1 -1
  117. package/dist/dialog/dialog-popup.d.mts +25 -4
  118. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  119. package/dist/dialog/dialog-popup.mjs +4 -2
  120. package/dist/dialog/dialog-popup.mjs.map +1 -1
  121. package/dist/dialog/dialog-root.d.mts +15 -1
  122. package/dist/dialog/dialog-root.d.mts.map +1 -1
  123. package/dist/dialog/dialog-root.mjs +2 -0
  124. package/dist/dialog/dialog-root.mjs.map +1 -1
  125. package/dist/dialog/dialog-title.d.mts +11 -0
  126. package/dist/dialog/dialog-title.d.mts.map +1 -1
  127. package/dist/dialog/dialog-title.mjs +2 -0
  128. package/dist/dialog/dialog-title.mjs.map +1 -1
  129. package/dist/dialog/dialog-trigger.d.mts +16 -0
  130. package/dist/dialog/dialog-trigger.d.mts.map +1 -1
  131. package/dist/dialog/dialog-trigger.mjs +2 -0
  132. package/dist/dialog/dialog-trigger.mjs.map +1 -1
  133. package/dist/dialog/index.d.mts +2 -0
  134. package/dist/dialog/index.d.mts.map +1 -1
  135. package/dist/dialog/index.mjs +2 -0
  136. package/dist/dialog/index.mjs.map +1 -1
  137. package/dist/docs/components/accordion.md +426 -0
  138. package/dist/docs/components/button.md +464 -0
  139. package/dist/docs/components/checkbox-group.md +474 -0
  140. package/dist/docs/components/checkbox.md +373 -0
  141. package/dist/docs/components/combobox.md +635 -0
  142. package/dist/docs/components/context-menu.md +524 -0
  143. package/dist/docs/components/dialog.md +686 -0
  144. package/dist/docs/components/field.md +587 -0
  145. package/dist/docs/components/menu.md +589 -0
  146. package/dist/docs/components/meter.md +313 -0
  147. package/dist/docs/components/number-field.md +528 -0
  148. package/dist/docs/components/popover.md +591 -0
  149. package/dist/docs/components/progress.md +450 -0
  150. package/dist/docs/components/radio-group.md +457 -0
  151. package/dist/docs/components/select.md +662 -0
  152. package/dist/docs/components/slider.md +558 -0
  153. package/dist/docs/components/switch.md +311 -0
  154. package/dist/docs/components/tabs.md +473 -0
  155. package/dist/docs/components/toast.md +576 -0
  156. package/dist/docs/components/toggle-group.md +341 -0
  157. package/dist/docs/components/toggle.md +245 -0
  158. package/dist/docs/components/toolbar.md +389 -0
  159. package/dist/docs/components/tooltip.md +494 -0
  160. package/dist/docs/concepts/action-props.md +251 -0
  161. package/dist/docs/concepts/ai-agents.md +56 -0
  162. package/dist/docs/concepts/browser-owned-state.md +118 -0
  163. package/dist/docs/concepts/content-security-policy.md +69 -0
  164. package/dist/docs/concepts/experimental.md +36 -0
  165. package/dist/docs/concepts/pending-and-optimistic.md +250 -0
  166. package/dist/docs/concepts/server-components.md +118 -0
  167. package/dist/docs/concepts/suspense.md +124 -0
  168. package/dist/docs/concepts/transitions.md +118 -0
  169. package/dist/docs/getting-started.md +115 -0
  170. package/dist/docs/index.md +181 -0
  171. package/dist/docs/roadmap.md +74 -0
  172. package/dist/docs/why.md +100 -0
  173. package/dist/field/field-control.d.mts +26 -3
  174. package/dist/field/field-control.d.mts.map +1 -1
  175. package/dist/field/field-control.mjs +2 -0
  176. package/dist/field/field-control.mjs.map +1 -1
  177. package/dist/field/field-description.d.mts +11 -0
  178. package/dist/field/field-description.d.mts.map +1 -1
  179. package/dist/field/field-description.mjs +2 -0
  180. package/dist/field/field-description.mjs.map +1 -1
  181. package/dist/field/field-error.d.mts +14 -2
  182. package/dist/field/field-error.d.mts.map +1 -1
  183. package/dist/field/field-error.mjs +2 -0
  184. package/dist/field/field-error.mjs.map +1 -1
  185. package/dist/field/field-label.d.mts +10 -0
  186. package/dist/field/field-label.d.mts.map +1 -1
  187. package/dist/field/field-label.mjs +2 -0
  188. package/dist/field/field-label.mjs.map +1 -1
  189. package/dist/field/field-root.d.mts +21 -2
  190. package/dist/field/field-root.d.mts.map +1 -1
  191. package/dist/field/field-root.mjs +2 -0
  192. package/dist/field/field-root.mjs.map +1 -1
  193. package/dist/field/index.d.mts +9 -0
  194. package/dist/field/index.d.mts.map +1 -1
  195. package/dist/field/index.mjs +9 -0
  196. package/dist/field/index.mjs.map +1 -1
  197. package/dist/form/form-root.d.mts +17 -1
  198. package/dist/form/form-root.d.mts.map +1 -1
  199. package/dist/form/form-root.mjs +3 -1
  200. package/dist/form/form-root.mjs.map +1 -1
  201. package/dist/form/form-submit.d.mts +18 -0
  202. package/dist/form/form-submit.d.mts.map +1 -1
  203. package/dist/form/form-submit.mjs +2 -0
  204. package/dist/form/form-submit.mjs.map +1 -1
  205. package/dist/form/index.d.mts +7 -0
  206. package/dist/form/index.d.mts.map +1 -1
  207. package/dist/form/index.mjs +7 -0
  208. package/dist/form/index.mjs.map +1 -1
  209. package/dist/index.d.mts +2 -1
  210. package/dist/internal/announce.mjs +12 -7
  211. package/dist/internal/announce.mjs.map +1 -1
  212. package/dist/internal/focus-first-invalid.mjs +2 -11
  213. package/dist/internal/focus-first-invalid.mjs.map +1 -1
  214. package/dist/internal/focus-visible.mjs +26 -0
  215. package/dist/internal/focus-visible.mjs.map +1 -0
  216. package/dist/internal/{invoker-press.mjs → invokers.mjs} +22 -5
  217. package/dist/internal/invokers.mjs.map +1 -0
  218. package/dist/internal/platform-attributes.d.mts +1 -1
  219. package/dist/internal/pointer-capture.mjs +1 -1
  220. package/dist/internal/pointer-capture.mjs.map +1 -1
  221. package/dist/internal/trigger-ref.mjs +1 -1
  222. package/dist/internal/trigger-ref.mjs.map +1 -1
  223. package/dist/internal/types.d.mts +3 -0
  224. package/dist/internal/types.d.mts.map +1 -1
  225. package/dist/internal/use-interest-dismiss.mjs +84 -0
  226. package/dist/internal/use-interest-dismiss.mjs.map +1 -0
  227. package/dist/internal/use-overlay-root.mjs.map +1 -1
  228. package/dist/internal/use-popover-popup.mjs +43 -108
  229. package/dist/internal/use-popover-popup.mjs.map +1 -1
  230. package/dist/internal/use-popover-trigger.d.mts +1 -0
  231. package/dist/internal/use-popover-trigger.d.mts.map +1 -1
  232. package/dist/internal/use-popover-trigger.mjs +29 -10
  233. package/dist/internal/use-popover-trigger.mjs.map +1 -1
  234. package/dist/internal/use-value-set.mjs +20 -0
  235. package/dist/internal/use-value-set.mjs.map +1 -0
  236. package/dist/internal/validity.d.mts +11 -0
  237. package/dist/internal/validity.d.mts.map +1 -1
  238. package/dist/internal/validity.mjs.map +1 -1
  239. package/dist/menu/index.d.mts +2 -0
  240. package/dist/menu/index.d.mts.map +1 -1
  241. package/dist/menu/index.mjs +2 -0
  242. package/dist/menu/index.mjs.map +1 -1
  243. package/dist/menu/menu-checkbox-item.d.mts +26 -2
  244. package/dist/menu/menu-checkbox-item.d.mts.map +1 -1
  245. package/dist/menu/menu-checkbox-item.mjs +2 -0
  246. package/dist/menu/menu-checkbox-item.mjs.map +1 -1
  247. package/dist/menu/menu-context-trigger.d.mts +24 -2
  248. package/dist/menu/menu-context-trigger.d.mts.map +1 -1
  249. package/dist/menu/menu-context-trigger.mjs +2 -0
  250. package/dist/menu/menu-context-trigger.mjs.map +1 -1
  251. package/dist/menu/menu-group.d.mts +36 -1
  252. package/dist/menu/menu-group.d.mts.map +1 -1
  253. package/dist/menu/menu-group.mjs +9 -1
  254. package/dist/menu/menu-group.mjs.map +1 -1
  255. package/dist/menu/menu-item.d.mts +23 -1
  256. package/dist/menu/menu-item.d.mts.map +1 -1
  257. package/dist/menu/menu-item.mjs +2 -0
  258. package/dist/menu/menu-item.mjs.map +1 -1
  259. package/dist/menu/menu-popup.d.mts +34 -9
  260. package/dist/menu/menu-popup.d.mts.map +1 -1
  261. package/dist/menu/menu-popup.mjs +15 -27
  262. package/dist/menu/menu-popup.mjs.map +1 -1
  263. package/dist/menu/menu-radio-group.d.mts +20 -1
  264. package/dist/menu/menu-radio-group.d.mts.map +1 -1
  265. package/dist/menu/menu-radio-group.mjs +2 -0
  266. package/dist/menu/menu-radio-group.mjs.map +1 -1
  267. package/dist/menu/menu-radio-item.d.mts +16 -0
  268. package/dist/menu/menu-radio-item.d.mts.map +1 -1
  269. package/dist/menu/menu-radio-item.mjs +2 -0
  270. package/dist/menu/menu-radio-item.mjs.map +1 -1
  271. package/dist/menu/menu-root.d.mts +22 -3
  272. package/dist/menu/menu-root.d.mts.map +1 -1
  273. package/dist/menu/menu-root.mjs +2 -0
  274. package/dist/menu/menu-root.mjs.map +1 -1
  275. package/dist/menu/menu-submenu-trigger.d.mts +21 -8
  276. package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
  277. package/dist/menu/menu-submenu-trigger.mjs +11 -10
  278. package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
  279. package/dist/menu/menu-trigger.d.mts +23 -7
  280. package/dist/menu/menu-trigger.d.mts.map +1 -1
  281. package/dist/menu/menu-trigger.mjs +8 -12
  282. package/dist/menu/menu-trigger.mjs.map +1 -1
  283. package/dist/meter/index.d.mts +2 -0
  284. package/dist/meter/index.d.mts.map +1 -1
  285. package/dist/meter/index.mjs +2 -0
  286. package/dist/meter/index.mjs.map +1 -1
  287. package/dist/meter/meter-indicator.d.mts +11 -0
  288. package/dist/meter/meter-indicator.d.mts.map +1 -1
  289. package/dist/meter/meter-indicator.mjs +2 -0
  290. package/dist/meter/meter-indicator.mjs.map +1 -1
  291. package/dist/meter/meter-label.d.mts +11 -0
  292. package/dist/meter/meter-label.d.mts.map +1 -1
  293. package/dist/meter/meter-label.mjs +2 -0
  294. package/dist/meter/meter-label.mjs.map +1 -1
  295. package/dist/meter/meter-region.d.mts +5 -0
  296. package/dist/meter/meter-region.d.mts.map +1 -1
  297. package/dist/meter/meter-region.mjs.map +1 -1
  298. package/dist/meter/meter-root.d.mts +52 -10
  299. package/dist/meter/meter-root.d.mts.map +1 -1
  300. package/dist/meter/meter-root.mjs +2 -0
  301. package/dist/meter/meter-root.mjs.map +1 -1
  302. package/dist/meter/meter-track.d.mts +11 -0
  303. package/dist/meter/meter-track.d.mts.map +1 -1
  304. package/dist/meter/meter-track.mjs +2 -0
  305. package/dist/meter/meter-track.mjs.map +1 -1
  306. package/dist/meter/meter-value.d.mts +15 -1
  307. package/dist/meter/meter-value.d.mts.map +1 -1
  308. package/dist/meter/meter-value.mjs +2 -0
  309. package/dist/meter/meter-value.mjs.map +1 -1
  310. package/dist/number-field/index.d.mts +2 -0
  311. package/dist/number-field/index.d.mts.map +1 -1
  312. package/dist/number-field/index.mjs +2 -0
  313. package/dist/number-field/index.mjs.map +1 -1
  314. package/dist/number-field/number-field-decrement.d.mts +2 -0
  315. package/dist/number-field/number-field-decrement.d.mts.map +1 -1
  316. package/dist/number-field/number-field-decrement.mjs +2 -0
  317. package/dist/number-field/number-field-decrement.mjs.map +1 -1
  318. package/dist/number-field/number-field-increment.d.mts +2 -0
  319. package/dist/number-field/number-field-increment.d.mts.map +1 -1
  320. package/dist/number-field/number-field-increment.mjs +2 -0
  321. package/dist/number-field/number-field-increment.mjs.map +1 -1
  322. package/dist/number-field/number-field-input.d.mts +9 -0
  323. package/dist/number-field/number-field-input.d.mts.map +1 -1
  324. package/dist/number-field/number-field-input.mjs +2 -0
  325. package/dist/number-field/number-field-input.mjs.map +1 -1
  326. package/dist/number-field/number-field-label.d.mts +10 -0
  327. package/dist/number-field/number-field-label.d.mts.map +1 -1
  328. package/dist/number-field/number-field-label.mjs +2 -0
  329. package/dist/number-field/number-field-label.mjs.map +1 -1
  330. package/dist/number-field/number-field-root.d.mts +62 -14
  331. package/dist/number-field/number-field-root.d.mts.map +1 -1
  332. package/dist/number-field/number-field-root.mjs +3 -1
  333. package/dist/number-field/number-field-root.mjs.map +1 -1
  334. package/dist/number-field/use-step-button.d.mts +20 -0
  335. package/dist/number-field/use-step-button.d.mts.map +1 -1
  336. package/dist/number-field/use-step-button.mjs.map +1 -1
  337. package/dist/popover/index.d.mts +2 -0
  338. package/dist/popover/index.d.mts.map +1 -1
  339. package/dist/popover/index.mjs +2 -0
  340. package/dist/popover/index.mjs.map +1 -1
  341. package/dist/popover/popover-close.d.mts +21 -3
  342. package/dist/popover/popover-close.d.mts.map +1 -1
  343. package/dist/popover/popover-close.mjs +3 -1
  344. package/dist/popover/popover-close.mjs.map +1 -1
  345. package/dist/popover/popover-description.d.mts +12 -0
  346. package/dist/popover/popover-description.d.mts.map +1 -1
  347. package/dist/popover/popover-description.mjs +2 -0
  348. package/dist/popover/popover-description.mjs.map +1 -1
  349. package/dist/popover/popover-popup.d.mts +30 -4
  350. package/dist/popover/popover-popup.d.mts.map +1 -1
  351. package/dist/popover/popover-popup.mjs +2 -0
  352. package/dist/popover/popover-popup.mjs.map +1 -1
  353. package/dist/popover/popover-root.d.mts +9 -0
  354. package/dist/popover/popover-root.d.mts.map +1 -1
  355. package/dist/popover/popover-root.mjs +2 -0
  356. package/dist/popover/popover-root.mjs.map +1 -1
  357. package/dist/popover/popover-title.d.mts +11 -0
  358. package/dist/popover/popover-title.d.mts.map +1 -1
  359. package/dist/popover/popover-title.mjs +2 -0
  360. package/dist/popover/popover-title.mjs.map +1 -1
  361. package/dist/popover/popover-trigger.d.mts +24 -9
  362. package/dist/popover/popover-trigger.d.mts.map +1 -1
  363. package/dist/popover/popover-trigger.mjs +11 -9
  364. package/dist/popover/popover-trigger.mjs.map +1 -1
  365. package/dist/progress/index.d.mts +2 -0
  366. package/dist/progress/index.d.mts.map +1 -1
  367. package/dist/progress/index.mjs +2 -0
  368. package/dist/progress/index.mjs.map +1 -1
  369. package/dist/progress/progress-indicator.d.mts +11 -0
  370. package/dist/progress/progress-indicator.d.mts.map +1 -1
  371. package/dist/progress/progress-indicator.mjs +2 -0
  372. package/dist/progress/progress-indicator.mjs.map +1 -1
  373. package/dist/progress/progress-label.d.mts +11 -0
  374. package/dist/progress/progress-label.d.mts.map +1 -1
  375. package/dist/progress/progress-label.mjs +2 -0
  376. package/dist/progress/progress-label.mjs.map +1 -1
  377. package/dist/progress/progress-root.d.mts +36 -8
  378. package/dist/progress/progress-root.d.mts.map +1 -1
  379. package/dist/progress/progress-root.mjs +2 -0
  380. package/dist/progress/progress-root.mjs.map +1 -1
  381. package/dist/progress/progress-track.d.mts +11 -0
  382. package/dist/progress/progress-track.d.mts.map +1 -1
  383. package/dist/progress/progress-track.mjs +2 -0
  384. package/dist/progress/progress-track.mjs.map +1 -1
  385. package/dist/progress/progress-value.d.mts +15 -1
  386. package/dist/progress/progress-value.d.mts.map +1 -1
  387. package/dist/progress/progress-value.mjs +2 -0
  388. package/dist/progress/progress-value.mjs.map +1 -1
  389. package/dist/radio-group/index.d.mts +2 -0
  390. package/dist/radio-group/index.d.mts.map +1 -1
  391. package/dist/radio-group/index.mjs +2 -0
  392. package/dist/radio-group/index.mjs.map +1 -1
  393. package/dist/radio-group/radio-group-item.d.mts +18 -1
  394. package/dist/radio-group/radio-group-item.d.mts.map +1 -1
  395. package/dist/radio-group/radio-group-item.mjs +2 -0
  396. package/dist/radio-group/radio-group-item.mjs.map +1 -1
  397. package/dist/radio-group/radio-group-label.d.mts +10 -0
  398. package/dist/radio-group/radio-group-label.d.mts.map +1 -1
  399. package/dist/radio-group/radio-group-label.mjs +2 -0
  400. package/dist/radio-group/radio-group-label.mjs.map +1 -1
  401. package/dist/radio-group/radio-group-root.d.mts +29 -5
  402. package/dist/radio-group/radio-group-root.d.mts.map +1 -1
  403. package/dist/radio-group/radio-group-root.mjs +2 -0
  404. package/dist/radio-group/radio-group-root.mjs.map +1 -1
  405. package/dist/select/index.d.mts +2 -0
  406. package/dist/select/index.d.mts.map +1 -1
  407. package/dist/select/index.mjs +2 -0
  408. package/dist/select/index.mjs.map +1 -1
  409. package/dist/select/select-group-label.d.mts +10 -0
  410. package/dist/select/select-group-label.d.mts.map +1 -1
  411. package/dist/select/select-group-label.mjs +2 -0
  412. package/dist/select/select-group-label.mjs.map +1 -1
  413. package/dist/select/select-group.d.mts +15 -1
  414. package/dist/select/select-group.d.mts.map +1 -1
  415. package/dist/select/select-group.mjs +2 -0
  416. package/dist/select/select-group.mjs.map +1 -1
  417. package/dist/select/select-option.d.mts +19 -1
  418. package/dist/select/select-option.d.mts.map +1 -1
  419. package/dist/select/select-option.mjs +2 -0
  420. package/dist/select/select-option.mjs.map +1 -1
  421. package/dist/select/select-root.d.mts +24 -1
  422. package/dist/select/select-root.d.mts.map +1 -1
  423. package/dist/select/select-root.mjs +2 -0
  424. package/dist/select/select-root.mjs.map +1 -1
  425. package/dist/select/select-separator.d.mts +9 -0
  426. package/dist/select/select-separator.d.mts.map +1 -1
  427. package/dist/select/select-separator.mjs +2 -0
  428. package/dist/select/select-separator.mjs.map +1 -1
  429. package/dist/select/select-trigger.d.mts +9 -0
  430. package/dist/select/select-trigger.d.mts.map +1 -1
  431. package/dist/select/select-trigger.mjs +2 -0
  432. package/dist/select/select-trigger.mjs.map +1 -1
  433. package/dist/select/select-value.d.mts +9 -0
  434. package/dist/select/select-value.d.mts.map +1 -1
  435. package/dist/select/select-value.mjs +2 -0
  436. package/dist/select/select-value.mjs.map +1 -1
  437. package/dist/slider/index.d.mts +2 -0
  438. package/dist/slider/index.d.mts.map +1 -1
  439. package/dist/slider/index.mjs +2 -0
  440. package/dist/slider/index.mjs.map +1 -1
  441. package/dist/slider/slider-indicator.d.mts +12 -0
  442. package/dist/slider/slider-indicator.d.mts.map +1 -1
  443. package/dist/slider/slider-indicator.mjs +2 -0
  444. package/dist/slider/slider-indicator.mjs.map +1 -1
  445. package/dist/slider/slider-label.d.mts +11 -1
  446. package/dist/slider/slider-label.d.mts.map +1 -1
  447. package/dist/slider/slider-label.mjs +2 -0
  448. package/dist/slider/slider-label.mjs.map +1 -1
  449. package/dist/slider/slider-root.d.mts +53 -9
  450. package/dist/slider/slider-root.d.mts.map +1 -1
  451. package/dist/slider/slider-root.mjs +2 -0
  452. package/dist/slider/slider-root.mjs.map +1 -1
  453. package/dist/slider/slider-thumb.d.mts +32 -3
  454. package/dist/slider/slider-thumb.d.mts.map +1 -1
  455. package/dist/slider/slider-thumb.mjs +2 -0
  456. package/dist/slider/slider-thumb.mjs.map +1 -1
  457. package/dist/slider/slider-track.d.mts +17 -0
  458. package/dist/slider/slider-track.d.mts.map +1 -1
  459. package/dist/slider/slider-track.mjs +2 -0
  460. package/dist/slider/slider-track.mjs.map +1 -1
  461. package/dist/slider/slider-value.d.mts +11 -0
  462. package/dist/slider/slider-value.d.mts.map +1 -1
  463. package/dist/slider/slider-value.mjs +2 -0
  464. package/dist/slider/slider-value.mjs.map +1 -1
  465. package/dist/switch/switch.d.mts +23 -3
  466. package/dist/switch/switch.d.mts.map +1 -1
  467. package/dist/switch/switch.mjs +2 -0
  468. package/dist/switch/switch.mjs.map +1 -1
  469. package/dist/tabs/index.d.mts +2 -0
  470. package/dist/tabs/index.d.mts.map +1 -1
  471. package/dist/tabs/index.mjs +2 -0
  472. package/dist/tabs/index.mjs.map +1 -1
  473. package/dist/tabs/tabs-context.d.mts +5 -0
  474. package/dist/tabs/tabs-context.d.mts.map +1 -1
  475. package/dist/tabs/tabs-context.mjs.map +1 -1
  476. package/dist/tabs/tabs-indicator.d.mts +17 -0
  477. package/dist/tabs/tabs-indicator.d.mts.map +1 -1
  478. package/dist/tabs/tabs-indicator.mjs +2 -0
  479. package/dist/tabs/tabs-indicator.mjs.map +1 -1
  480. package/dist/tabs/tabs-list.d.mts +19 -1
  481. package/dist/tabs/tabs-list.d.mts.map +1 -1
  482. package/dist/tabs/tabs-list.mjs +2 -0
  483. package/dist/tabs/tabs-list.mjs.map +1 -1
  484. package/dist/tabs/tabs-panel.d.mts +19 -0
  485. package/dist/tabs/tabs-panel.d.mts.map +1 -1
  486. package/dist/tabs/tabs-panel.mjs +2 -0
  487. package/dist/tabs/tabs-panel.mjs.map +1 -1
  488. package/dist/tabs/tabs-root.d.mts +39 -5
  489. package/dist/tabs/tabs-root.d.mts.map +1 -1
  490. package/dist/tabs/tabs-root.mjs +2 -0
  491. package/dist/tabs/tabs-root.mjs.map +1 -1
  492. package/dist/tabs/tabs-tab.d.mts +22 -1
  493. package/dist/tabs/tabs-tab.d.mts.map +1 -1
  494. package/dist/tabs/tabs-tab.mjs +2 -0
  495. package/dist/tabs/tabs-tab.mjs.map +1 -1
  496. package/dist/toast/index.d.mts +2 -0
  497. package/dist/toast/index.d.mts.map +1 -1
  498. package/dist/toast/index.mjs +2 -0
  499. package/dist/toast/index.mjs.map +1 -1
  500. package/dist/toast/toast-action.d.mts +28 -3
  501. package/dist/toast/toast-action.d.mts.map +1 -1
  502. package/dist/toast/toast-action.mjs +2 -0
  503. package/dist/toast/toast-action.mjs.map +1 -1
  504. package/dist/toast/toast-close.d.mts +16 -0
  505. package/dist/toast/toast-close.d.mts.map +1 -1
  506. package/dist/toast/toast-close.mjs +2 -0
  507. package/dist/toast/toast-close.mjs.map +1 -1
  508. package/dist/toast/toast-description.d.mts +16 -1
  509. package/dist/toast/toast-description.d.mts.map +1 -1
  510. package/dist/toast/toast-description.mjs +2 -0
  511. package/dist/toast/toast-description.mjs.map +1 -1
  512. package/dist/toast/toast-root.d.mts +20 -0
  513. package/dist/toast/toast-root.d.mts.map +1 -1
  514. package/dist/toast/toast-root.mjs +2 -0
  515. package/dist/toast/toast-root.mjs.map +1 -1
  516. package/dist/toast/toast-title.d.mts +15 -1
  517. package/dist/toast/toast-title.d.mts.map +1 -1
  518. package/dist/toast/toast-title.mjs +2 -0
  519. package/dist/toast/toast-title.mjs.map +1 -1
  520. package/dist/toast/toast-viewport.d.mts +34 -5
  521. package/dist/toast/toast-viewport.d.mts.map +1 -1
  522. package/dist/toast/toast-viewport.mjs +6 -5
  523. package/dist/toast/toast-viewport.mjs.map +1 -1
  524. package/dist/toast/toast.d.mts +46 -6
  525. package/dist/toast/toast.d.mts.map +1 -1
  526. package/dist/toast/toast.mjs +4 -0
  527. package/dist/toast/toast.mjs.map +1 -1
  528. package/dist/toggle/toggle.d.mts +20 -2
  529. package/dist/toggle/toggle.d.mts.map +1 -1
  530. package/dist/toggle/toggle.mjs +2 -0
  531. package/dist/toggle/toggle.mjs.map +1 -1
  532. package/dist/toggle-group/index.d.mts +2 -0
  533. package/dist/toggle-group/index.d.mts.map +1 -1
  534. package/dist/toggle-group/index.mjs +2 -0
  535. package/dist/toggle-group/index.mjs.map +1 -1
  536. package/dist/toggle-group/toggle-group-context.d.mts +1 -0
  537. package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
  538. package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
  539. package/dist/toggle-group/toggle-group-item.d.mts +16 -0
  540. package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
  541. package/dist/toggle-group/toggle-group-item.mjs +2 -0
  542. package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
  543. package/dist/toggle-group/toggle-group-root.d.mts +73 -12
  544. package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
  545. package/dist/toggle-group/toggle-group-root.mjs +6 -5
  546. package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
  547. package/dist/toolbar/index.d.mts +2 -0
  548. package/dist/toolbar/index.d.mts.map +1 -1
  549. package/dist/toolbar/index.mjs +2 -0
  550. package/dist/toolbar/index.mjs.map +1 -1
  551. package/dist/toolbar/toolbar-root.d.mts +30 -3
  552. package/dist/toolbar/toolbar-root.d.mts.map +1 -1
  553. package/dist/toolbar/toolbar-root.mjs +2 -0
  554. package/dist/toolbar/toolbar-root.mjs.map +1 -1
  555. package/dist/toolbar/toolbar-separator.d.mts +13 -0
  556. package/dist/toolbar/toolbar-separator.d.mts.map +1 -1
  557. package/dist/toolbar/toolbar-separator.mjs +2 -0
  558. package/dist/toolbar/toolbar-separator.mjs.map +1 -1
  559. package/dist/tooltip/index.d.mts +2 -0
  560. package/dist/tooltip/index.d.mts.map +1 -1
  561. package/dist/tooltip/index.mjs +2 -0
  562. package/dist/tooltip/index.mjs.map +1 -1
  563. package/dist/tooltip/tooltip-arrow.d.mts +16 -0
  564. package/dist/tooltip/tooltip-arrow.d.mts.map +1 -1
  565. package/dist/tooltip/tooltip-arrow.mjs +2 -0
  566. package/dist/tooltip/tooltip-arrow.mjs.map +1 -1
  567. package/dist/tooltip/tooltip-context.d.mts +4 -0
  568. package/dist/tooltip/tooltip-context.d.mts.map +1 -1
  569. package/dist/tooltip/tooltip-context.mjs.map +1 -1
  570. package/dist/tooltip/tooltip-popup.d.mts +24 -3
  571. package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
  572. package/dist/tooltip/tooltip-popup.mjs +2 -0
  573. package/dist/tooltip/tooltip-popup.mjs.map +1 -1
  574. package/dist/tooltip/tooltip-root.d.mts +24 -2
  575. package/dist/tooltip/tooltip-root.d.mts.map +1 -1
  576. package/dist/tooltip/tooltip-root.mjs +2 -0
  577. package/dist/tooltip/tooltip-root.mjs.map +1 -1
  578. package/dist/tooltip/tooltip-trigger.d.mts +18 -1
  579. package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
  580. package/dist/tooltip/tooltip-trigger.mjs +2 -0
  581. package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
  582. package/package.json +9 -1
  583. package/skills/funstack-ui-knowledge/SKILL.md +75 -0
  584. package/dist/internal/invoker-press.mjs.map +0 -1
@@ -5,11 +5,9 @@ import { resolveStateValue } from "../internal/render-element.mjs";
5
5
  import { useRender } from "../internal/use-render.mjs";
6
6
  import { useElementCheck } from "../internal/use-element-check.mjs";
7
7
  import { useMergedRefs } from "../internal/use-merged-refs.mjs";
8
- import { isPopoverOpen } from "../internal/popover-open.mjs";
8
+ import { listenInvokerPresses } from "../internal/invokers.mjs";
9
9
  import { usePopoverPopup } from "../internal/use-popover-popup.mjs";
10
- import { listenInvokerPresses } from "../internal/invoker-press.mjs";
11
10
  import { ComboboxPopupContext, useComboboxContext } from "./combobox-context.mjs";
12
- import { useCallback, useEffect, useRef } from "react";
13
11
  import { jsx } from "react/jsx-runtime";
14
12
  //#region src/combobox/combobox-popup.tsx
15
13
  const isDev = process.env.NODE_ENV !== "production";
@@ -20,33 +18,25 @@ const preventDefault = (event) => event.preventDefault();
20
18
  * Anchor Positioning, at least as wide as the input. Focus never enters it: a press anywhere in
21
19
  * it is `preventDefault()`ed so the input keeps focus (design 7.1), and so is a press on a button
22
20
  * of the consumer's that names the popup (`popovertarget`, `commandfor`) while it is shown: its
23
- * click closes the listbox as `"activate"` with the text untouched (#126). Holds the `List` and,
21
+ * click closes the listbox as `"activate"` with the text untouched. Holds the `List` and,
24
22
  * outside it, `Empty` and `Status`. Style it with `:popover-open`; it emits `data-stale` but no
25
23
  * `data-open`.
26
24
  *
27
25
  * Owned keys (conventions 1.2): `id`, `popover`, `onPointerDown`, `onMouseDown`, `data-stale`.
28
26
  * Inline `position-area`, `position-try-fallbacks` and `min-width` sit under the consumer's
29
27
  * `style` (`style={{ positionTryFallbacks: "none" }}` removes the flip).
28
+ *
29
+ * @see https://ui.funstack.work/components/combobox
30
30
  */
31
31
  function ComboboxPopup({ keepMounted, transition, className, style, children, render, ...rest }) {
32
32
  const ctx = useComboboxContext("Combobox.Popup");
33
33
  const { popover } = ctx;
34
- const invokerPresses = useRef(null);
35
- const stopInvokerPresses = useCallback(() => {
36
- invokerPresses.current?.();
37
- invokerPresses.current = null;
38
- }, []);
39
- useEffect(() => stopInvokerPresses, [stopInvokerPresses]);
40
34
  const { setElement, renderContent } = usePopoverPopup(popover, {
41
35
  part: "Combobox.Popup",
42
36
  resolveInitialFocus: () => null,
43
37
  keepMounted,
44
38
  transition,
45
- onToggle: (event) => {
46
- const element = popover.popupRef.current;
47
- if (event.newState === "open" && element !== null && isPopoverOpen(element)) invokerPresses.current ??= listenInvokerPresses(element);
48
- else if (event.newState === "closed") stopInvokerPresses();
49
- }
39
+ whileShown: listenInvokerPresses
50
40
  });
51
41
  const devRef = useElementCheck(isDev && ((element) => element.tagName !== "DIV" ? `Combobox.Popup: rendered a <${element.tagName.toLowerCase()}>. Render a <div>: a <dialog popover> runs the dialog focusing steps and takes focus out of the input.` : null));
52
42
  const ref = useMergedRefs(setElement, devRef);
@@ -1 +1 @@
1
- {"version":3,"file":"combobox-popup.mjs","names":[],"sources":["../../src/combobox/combobox-popup.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { listenInvokerPresses } from \"../internal/invoker-press.js\";\nimport { isPopoverOpen } from \"../internal/popover-open.js\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { usePopoverPopup } from \"../internal/use-popover-popup.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { ComboboxPopupContext, useComboboxContext } from \"./combobox-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface ComboboxPopupState {\n /** Committed open state. Read `:popover-open` for the DOM truth. */\n readonly open: boolean;\n /** The results shown are for an older text. */\n readonly stale: boolean;\n /** The deferred text the results are for. */\n readonly query: string;\n}\n\nexport interface ComboboxPopupProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"id\"\n | \"popover\"\n | \"onToggle\"\n | \"onBeforeToggle\"\n | \"onPointerDown\"\n | \"onMouseDown\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * `false` (default): the children are not rendered while the listbox is closed. `true`: they\n * stay mounted inside `<Activity mode=\"hidden\">`.\n */\n keepMounted?: boolean;\n /**\n * Forwarded to the `<ViewTransition default>` around the popover element itself. Animates\n * library-driven opens and closes (typing, the Trigger, an accepted option) in every engine;\n * dismissals are the browser's (CSS only). **A deferred results render also activates the\n * boundary** (React: updates from `useDeferredValue` animate), so use a type map with\n * `default: \"none\"` unless every result change should cross-fade. Static.\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, ComboboxPopupState>;\n style?: StateValue<CSSProperties | undefined, ComboboxPopupState>;\n children?: StateValue<ReactNode, ComboboxPopupState>;\n /** Must render a `<div>`: a `<dialog>` would pull focus out of the input. */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxPopupState>;\n}\n\nconst preventDefault = (event: { preventDefault(): void }) => event.preventDefault();\n\n/**\n * The listbox's container: `<div popover=\"auto\">`, opened by the library with\n * `showPopover({ source: input })` and placed below (or, flipped, above) the input with CSS\n * Anchor Positioning, at least as wide as the input. Focus never enters it: a press anywhere in\n * it is `preventDefault()`ed so the input keeps focus (design 7.1), and so is a press on a button\n * of the consumer's that names the popup (`popovertarget`, `commandfor`) while it is shown: its\n * click closes the listbox as `\"activate\"` with the text untouched (#126). Holds the `List` and,\n * outside it, `Empty` and `Status`. Style it with `:popover-open`; it emits `data-stale` but no\n * `data-open`.\n *\n * Owned keys (conventions 1.2): `id`, `popover`, `onPointerDown`, `onMouseDown`, `data-stale`.\n * Inline `position-area`, `position-try-fallbacks` and `min-width` sit under the consumer's\n * `style` (`style={{ positionTryFallbacks: \"none\" }}` removes the flip).\n */\nexport function ComboboxPopup({\n keepMounted,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxPopupProps) {\n const ctx = useComboboxContext(\"Combobox.Popup\");\n const { popover } = ctx;\n\n // While shown, a press on a foreign invoker of the popup keeps focus in the input (design 5.4,\n // #126).\n const invokerPresses = useRef<(() => void) | null>(null);\n const stopInvokerPresses = useCallback(() => {\n invokerPresses.current?.();\n invokerPresses.current = null;\n }, []);\n useEffect(() => stopInvokerPresses, [stopInvokerPresses]);\n\n const { setElement, renderContent } = usePopoverPopup(popover, {\n part: \"Combobox.Popup\",\n // Focus stays in the input: nothing inside the popup is ever focused.\n resolveInitialFocus: () => null,\n keepMounted,\n transition,\n onToggle: (event) => {\n const element = popover.popupRef.current;\n if (event.newState === \"open\" && element !== null && isPopoverOpen(element)) {\n invokerPresses.current ??= listenInvokerPresses(element);\n } else if (event.newState === \"closed\") {\n stopInvokerPresses();\n }\n },\n });\n\n const devRef = useElementCheck(\n isDev &&\n ((element) =>\n element.tagName !== \"DIV\"\n ? `Combobox.Popup: rendered a <${element.tagName.toLowerCase()}>. Render a <div>: a ` +\n \"<dialog popover> runs the dialog focusing steps and takes focus out of the input.\"\n : null),\n );\n const ref = useMergedRefs(setElement, devRef);\n\n const state: ComboboxPopupState = {\n open: popover.committed,\n stale: ctx.stale,\n query: ctx.query,\n };\n\n const libraryProps: ComponentPropsWithRef<\"div\"> & DataAttributes = {\n id: popover.ids.popup,\n popover: \"auto\",\n onPointerDown: (event: PointerEvent<HTMLDivElement>) => preventDefault(event),\n onMouseDown: (event: MouseEvent<HTMLDivElement>) => preventDefault(event),\n \"data-stale\": dataAttr(ctx.stale),\n };\n\n const content = (s: ComboboxPopupState): ReactNode => (\n <ComboboxPopupContext value={true}>\n {renderContent(() => resolveStateValue(children, s))}\n </ComboboxPopupContext>\n );\n\n const element = useRender<ComponentPropsWithRef<\"div\">, ComboboxPopupState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n // `self-*` keywords resolve against the popup's own inherited direction, so a `dir=\"rtl\"`\n // page or container flips the listbox with no JS; plain logical keywords would follow the\n // root only (design 7.2, conventions 13.1). The consumer wins.\n style: (s) => ({\n positionArea: \"self-block-end span-self-inline-end\",\n positionTryFallbacks: \"flip-block\",\n minWidth: \"anchor-size(width)\",\n ...resolveStateValue(style, s),\n }),\n children: content,\n props: rest,\n libraryProps,\n ref,\n });\n\n return useTransitionBoundary(\"Combobox.Popup\", transition, element);\n}\n\nCom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U,UAA4D;EAC1E,gBAAgB;EAChB;EACA;EACA;EAIA,QAAQ,OAAO;GACb,cAAc;GACd,sBAAsB;GACtB,UAAU;GACV,GAAG,kBAAkB,OAAO,CAAC;EAC/B;EACA,UAAU;EACV,OAAO;EACP;EACA;CACF,CAAC;CAED,OAAO,sBAAsB,kBAAkB,YAAY,OAAO;AACpE;AAEA,cAAc,cAAc"}
1
+ {"version":3,"file":"combobox-popup.mjs","names":[],"sources":["../../src/combobox/combobox-popup.tsx"],"sourcesContent":["\"use client\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { listenInvokerPresses } from \"../internal/invokers.js\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { usePopoverPopup } from \"../internal/use-popover-popup.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { ComboboxPopupContext, useComboboxContext } from \"./combobox-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * State of `Combobox.Popup`, passed to the function forms of `className`, `style`, `children` and\n * `render`.\n */\nexport interface ComboboxPopupState {\n /** Committed open state. Read `:popover-open` for the DOM truth. */\n readonly open: boolean;\n /** The results shown are for an older text. */\n readonly stale: boolean;\n /** The deferred text the results are for. */\n readonly query: string;\n}\n\n/**\n * Props of `Combobox.Popup`.\n *\n * @see https://ui.funstack.work/components/combobox\n */\nexport interface ComboboxPopupProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"id\"\n | \"popover\"\n | \"onToggle\"\n | \"onBeforeToggle\"\n | \"onPointerDown\"\n | \"onMouseDown\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * `false` (default): the children are not rendered while the listbox is closed. `true`: they\n * stay mounted inside `<Activity mode=\"hidden\">`.\n *\n * @defaultValue `false`\n */\n keepMounted?: boolean;\n /**\n * Forwarded to the `<ViewTransition default>` around the popover element itself. Animates\n * library-driven opens and closes (typing, the Trigger, an accepted option) in every engine;\n * dismissals are the browser's (CSS only). **A deferred results render also activates the\n * boundary** (React: updates from `useDeferredValue` animate), so use a type map with\n * `default: \"none\"` unless every result change should cross-fade. Static.\n */\n transition?: ViewTransitionClass;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, ComboboxPopupState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, ComboboxPopupState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, ComboboxPopupState>;\n /** Must render a `<div>`: a `<dialog>` would pull focus out of the input. */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxPopupState>;\n}\n\nconst preventDefault = (event: { preventDefault(): void }) => event.preventDefault();\n\n/**\n * The listbox's container: `<div popover=\"auto\">`, opened by the library with\n * `showPopover({ source: input })` and placed below (or, flipped, above) the input with CSS\n * Anchor Positioning, at least as wide as the input. Focus never enters it: a press anywhere in\n * it is `preventDefault()`ed so the input keeps focus (design 7.1), and so is a press on a button\n * of the consumer's that names the popup (`popovertarget`, `commandfor`) while it is shown: its\n * click closes the listbox as `\"activate\"` with the text untouched. Holds the `List` and,\n * outside it, `Empty` and `Status`. Style it with `:popover-open`; it emits `data-stale` but no\n * `data-open`.\n *\n * Owned keys (conventions 1.2): `id`, `popover`, `onPointerDown`, `onMouseDown`, `data-stale`.\n * Inline `position-area`, `position-try-fallbacks` and `min-width` sit under the consumer's\n * `style` (`style={{ positionTryFallbacks: \"none\" }}` removes the flip).\n *\n * @see https://ui.funstack.work/components/combobox\n */\nexport function ComboboxPopup({\n keepMounted,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxPopupProps) {\n const ctx = useComboboxContext(\"Combobox.Popup\");\n const { popover } = ctx;\n\n const { setElement, renderContent } = usePopoverPopup(popover, {\n part: \"Combobox.Popup\",\n // Focus stays in the input: nothing inside the popup is ever focused.\n resolveInitialFocus: () => null,\n keepMounted,\n transition,\n // While shown, a press on a foreign invoker of the popup keeps focus in the input (design\n // 5.4).\n whileShown: listenInvokerPresses,\n });\n\n const devRef = useElementCheck(\n isDev &&\n ((element) =>\n element.tagName !== \"DIV\"\n ? `Combobox.Popup: rendered a <${element.tagName.toLowerCase()}>. Render a <div>: a ` +\n \"<dialog popover> runs the dialog focusing steps and takes focus out of the input.\"\n : null),\n );\n const ref = useMergedRefs(setElement, devRef);\n\n const state: ComboboxPopupState = {\n open: popover.committed,\n stale: ctx.stale,\n query: ctx.query,\n };\n\n const libraryProps: ComponentPropsWithRef<\"div\"> & DataAttributes = {\n id: popover.ids.popup,\n popover: \"auto\",\n onPointerDown: (event: PointerEvent<HTMLDivElement>) => preventDefault(event),\n onMouseDown: (event: MouseEvent<HTMLDivElement>) => preventDefault(event),\n \"data-stale\": dataAttr(ctx.stale),\n };\n\n const content = (s: ComboboxPopupState): ReactNode => (\n <ComboboxPopupContext value={true}>\n {renderContent(() => resolveStateValue(children, s))}\n </ComboboxPopupContext>\n );\n\n const element = useRender<ComponentPropsWithRef<\"div\">, ComboboxPopupState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n // `self-*` keywords resolve against the popup's own inherited direction, so a `dir=\"rtl\"`\n // page or container flips the listbox with no JS; plain logical keywords would follow the\n // root only (design 7.2, conventions 13.1). The consumer wins.\n style: (s) => ({\n positionArea: \"self-block-end span-self-inline-end\",\n positionTryFallbacks: \"flip-block\",\n minWidth: \"anchor-size(width)\",\n ...resolveStateValue(style, s),\n }),\n children: content,\n props: rest,\n libraryProps,\n ref,\n });\n\n return useTransitionBoundary(\"Combobox.Popup\", transition, element);\n}\n\nComboboxPopup.displayName = \"ComboboxPopup\";\n"],"mappings":";;;;;;;;;;;;AAoBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAyDvC,MAAM,kBAAkB,UAAsC,MAAM,eAAe;;;;;;;;;;;;;;;;;AAkBnF,SAAgB,cAAc,EAC5B,aACA,YACA,WACA,OACA,UACA,QACA,GAAG,QACkB;CACrB,MAAM,MAAM,mBAAmB,gBAAgB;CAC/C,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,YAAY,kBAAkB,gBAAgB,SAAS;EAC7D,MAAM;EAEN,2BAA2B;EAC3B;EACA;EAGA,YAAY;CACd,CAAC;CAED,MAAM,SAAS,gBACb,WACI,YACA,QAAQ,YAAY,QAChB,+BAA+B,QAAQ,QAAQ,YAAY,EAAE,0GAE7D,KACV;CACA,MAAM,MAAM,cAAc,YAAY,MAAM;CAE5C,MAAM,QAA4B;EAChC,MAAM,QAAQ;EACd,OAAO,IAAI;EACX,OAAO,IAAI;CACb;CAEA,MAAM,eAA8D;EAClE,IAAI,QAAQ,IAAI;EAChB,SAAS;EACT,gBAAgB,UAAwC,eAAe,KAAK;EAC5E,cAAc,UAAsC,eAAe,KAAK;EACxE,cAAc,SAAS,IAAI,KAAK;CAClC;CAEA,MAAM,WAAW,MACf,oBAAC,sBAAD;EAAsB,OAAO;EAC1B,UAAA,oBAAoB,kBAAkB,UAAU,CAAC,CAAC;CAC/B,CAAA;CAGxB,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA;EACA;EAIA,QAAQ,OAAO;GACb,cAAc;GACd,sBAAsB;GACtB,UAAU;GACV,GAAG,kBAAkB,OAAO,CAAC;EAC/B;EACA,UAAU;EACV,OAAO;EACP;EACA;CACF,CAAC;CAED,OAAO,sBAAsB,kBAAkB,YAAY,OAAO;AACpE;AAEA,cAAc,cAAc"}
@@ -33,6 +33,7 @@ export interface ComboboxOpenChangeDetails extends ActionDetails {
33
33
  */
34
34
  readonly reason: ChangeReason;
35
35
  }
36
+ /** State of `Combobox.Root`, passed to the function forms of `announce` and `children`. */
36
37
  export interface ComboboxRootState {
37
38
  /** Optimistic selection. Content rendered from it must not suspend. */
38
39
  readonly value: string | null;
@@ -48,12 +49,22 @@ export interface ComboboxRootState {
48
49
  readonly open: boolean;
49
50
  /** A `valueChangeAction` or `openChangeAction` dispatched through this Combobox is in flight. */
50
51
  readonly pending: boolean;
52
+ /** The `disabled` prop, or the enclosing Field's. */
51
53
  readonly disabled: boolean;
52
54
  }
55
+ /**
56
+ * Props of `Combobox.Root`.
57
+ *
58
+ * @see https://ui.funstack.work/components/combobox
59
+ */
53
60
  export interface ComboboxRootProps {
54
61
  /** Controlled selection. `null`: nothing selected. `undefined`: uncontrolled. */
55
62
  value?: string | null;
56
- /** Initial selection in uncontrolled mode. Default `null`. */
63
+ /**
64
+ * Initial selection in uncontrolled mode.
65
+ *
66
+ * @defaultValue `null`
67
+ */
57
68
  defaultValue?: string | null;
58
69
  /**
59
70
  * Runs inside the Root's transition when the user accepts an option, commits free text
@@ -66,8 +77,10 @@ export interface ComboboxRootProps {
66
77
  /** Controlled input text. `undefined`: uncontrolled. */
67
78
  inputValue?: string;
68
79
  /**
69
- * Initial input text. Default `""`. Pass the selected value's label when `defaultValue` is
80
+ * Initial input text. Pass the selected value's label when `defaultValue` is
70
81
  * set: the library never derives the text from the value.
82
+ *
83
+ * @defaultValue `""`
71
84
  */
72
85
  defaultInputValue?: string;
73
86
  /**
@@ -81,7 +94,11 @@ export interface ComboboxRootProps {
81
94
  onInputValueChange?: UrgentChangeHandler<string, ComboboxInputValueChangeDetails>;
82
95
  /** Controlled open state. `undefined`: uncontrolled. */
83
96
  open?: boolean;
84
- /** Initial open state when uncontrolled. Opens after hydration. */
97
+ /**
98
+ * Initial open state when uncontrolled. Opens after hydration.
99
+ *
100
+ * @defaultValue `false`
101
+ */
85
102
  defaultOpen?: boolean;
86
103
  /**
87
104
  * Awaited for opens and for the close after an accepted option (or the Trigger); a
@@ -91,32 +108,50 @@ export interface ComboboxRootProps {
91
108
  /**
92
109
  * Free text is a value: Enter with no active option, or focus leaving with text that is not
93
110
  * the selected option's label, dispatches the text with `details.custom: true` (empty text
94
- * dispatches `null`). Default `false`: unmatched text reverts to the selection's label when
95
- * focus leaves.
111
+ * dispatches `null`). When `false`, unmatched text reverts to the selection's label when focus
112
+ * leaves.
113
+ *
114
+ * @defaultValue `false`
96
115
  */
97
116
  allowCustomValue?: boolean;
98
117
  /**
99
118
  * Make the first enabled option active when the results for an open or an edit settle (APG
100
- * "automatic selection"). Stale results are never highlighted. Default `false`.
119
+ * "automatic selection"). Stale results are never highlighted.
120
+ *
121
+ * @defaultValue `false`
101
122
  */
102
123
  autoHighlight?: boolean;
103
- /** Open the listbox on a pointer click in the input (not on focus). Default `false`. */
124
+ /**
125
+ * Open the listbox on a pointer click in the input (not on focus).
126
+ *
127
+ * @defaultValue `false`
128
+ */
104
129
  openOnClick?: boolean;
105
- /** Wrap from the last option to the first and back with the arrow keys. Default `false`. */
130
+ /**
131
+ * Wrap from the last option to the first and back with the arrow keys.
132
+ *
133
+ * @defaultValue `false`
134
+ */
106
135
  loop?: boolean;
107
136
  /**
108
137
  * The message `ariaNotify()` announces on the List when the results settle, from the number
109
- * of mounted options. Default (English): `"No results"`, `"1 result"`, `"N results"`. Override
110
- * for localisation or a richer message; return `null` to announce nothing. Ignored where
111
- * `ariaNotify` is missing.
138
+ * of mounted options. Override for localisation or a richer message; return `null` to announce
139
+ * nothing. Ignored where `ariaNotify` is missing.
140
+ *
141
+ * @defaultValue English: `"No results"`, `"1 result"`, `"N results"`
112
142
  */
113
143
  announce?: (count: number, state: ComboboxRootState) => string | null;
114
144
  /** Form participation through a hidden input with this name (value `""` for `null`). */
115
145
  name?: string;
116
146
  /** The `form` attribute of the hidden input. */
117
147
  form?: string;
118
- /** Disables the Input, Trigger and Clear; nothing dispatches for user interaction. */
148
+ /**
149
+ * Disables the Input, Trigger and Clear; nothing dispatches for user interaction.
150
+ *
151
+ * @defaultValue `false`
152
+ */
119
153
  disabled?: boolean;
154
+ /** The parts, or a function of the Root's state. */
120
155
  children?: StateValue<ReactNode, ComboboxRootState>;
121
156
  }
122
157
  /**
@@ -127,6 +162,8 @@ export interface ComboboxRootProps {
127
162
  * urgent virtual focus (`aria-activedescendant`); the listbox is a `popover="auto"` opened by the
128
163
  * library with the input as `source`. Renders no DOM, except one `<input type="hidden">` when
129
164
  * `name` is given.
165
+ *
166
+ * @see https://ui.funstack.work/components/combobox
130
167
  */
131
168
  export declare function ComboboxRoot(props: ComboboxRootProps): import("react").JSX.Element;
132
169
  export declare namespace ComboboxRoot {
@@ -1 +1 @@
1
- {"version":3,"file":"combobox-root.d.mts","names":[],"sources":["../../src/combobox/combobox-root.tsx"],"mappings":";;;;iBAwCiB,mCAAmC;;;;;;;WAOzC,QAAQ;;WAER;;;iBAIM,wCAAwC;;;;;;;WAO9C,QAAQ;;;iBAIF,kCAAkC;;;;;;;WAOxC,QAAQ;;iBAGF;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;;iBAGM;;EAEf;;EAEA;;;;;;;;EAQA,oBAAoB,4BAA4B;;EAGhD;;;;;EAKA;;;;;;;;;EASA,qBAAqB,4BAA4B;;EAGjD;;EAEA;;;;;EAKA,mBAAmB,sBAAsB;;;;;;;EAQzC;;;;;EAKA;;EAEA;;EAEA;;;;;;;EAOA,YAAY,eAAe,OAAO;;EAGlC;;EAEA;;EAEA;EACA,WAAW,WAAW,WAAW;;;;;;;;;;;wBAkDnB,aAAa,OAAO,oCAAiB,IAAA;yBAArC"}
1
+ {"version":3,"file":"combobox-root.d.mts","names":[],"sources":["../../src/combobox/combobox-root.tsx"],"mappings":";;;;iBAyCiB,mCAAmC;;;;;;;WAOzC,QAAQ;;WAER;;;iBAIM,wCAAwC;;;;;;;WAO9C,QAAQ;;;iBAIF,kCAAkC;;;;;;;WAOxC,QAAQ;;;iBAIF;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;iBAQM;;EAEf;;;;;;EAMA;;;;;;;;EAQA,oBAAoB,4BAA4B;;EAGhD;;;;;;;EAOA;;;;;;;;;EASA,qBAAqB,4BAA4B;;EAGjD;;;;;;EAMA;;;;;EAKA,mBAAmB,sBAAsB;;;;;;;;;EAUzC;;;;;;;EAOA;;;;;;EAMA;;;;;;EAMA;;;;;;;;EAQA,YAAY,eAAe,OAAO;;EAGlC;;EAEA;;;;;;EAMA;;EAEA,WAAW,WAAW,WAAW;;;;;;;;;;;;;wBAoDnB,aAAa,OAAO,oCAAiB,IAAA;yBAArC"}
@@ -11,7 +11,9 @@ import { useFieldValueChange } from "../internal/use-field-control.mjs";
11
11
  import { popoverDetails, useOverlayRoot } from "../internal/use-overlay-root.mjs";
12
12
  import { capturePointer } from "../internal/pointer-capture.mjs";
13
13
  import { ComboboxContext } from "./combobox-context.mjs";
14
+ import { announce, canAnnounce } from "../internal/announce.mjs";
14
15
  import { useComboboxForm } from "./use-combobox-form.mjs";
16
+ import { useDeferredLeave } from "./use-deferred-leave.mjs";
15
17
  import { useOptionRegistry } from "./use-option-registry.mjs";
16
18
  import { use, useCallback, useDeferredValue, useEffect, useId, useInsertionEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
17
19
  import { flushSync } from "react-dom";
@@ -36,6 +38,8 @@ function isThenable(value) {
36
38
  * urgent virtual focus (`aria-activedescendant`); the listbox is a `popover="auto"` opened by the
37
39
  * library with the input as `source`. Renders no DOM, except one `<input type="hidden">` when
38
40
  * `name` is given.
41
+ *
42
+ * @see https://ui.funstack.work/components/combobox
39
43
  */
40
44
  function ComboboxRoot(props) {
41
45
  const { value, defaultValue, valueChangeAction, inputValue: inputValueProp, defaultInputValue, open, defaultOpen, openChangeAction, allowCustomValue = false, autoHighlight = false, openOnClick = false, loop = false, form, children } = props;
@@ -218,9 +222,9 @@ function ComboboxRoot(props) {
218
222
  if (lastAnnounced.current === key) return;
219
223
  lastAnnounced.current = key;
220
224
  const list = listRef.current;
221
- if (list === null || typeof list.ariaNotify !== "function") return;
225
+ if (list === null || !canAnnounce(list)) return;
222
226
  const message = (propsRef.current.announce ?? defaultComboboxAnnouncement)(count, state);
223
- if (message !== null) list.ariaNotify(message);
227
+ if (message !== null) announce(list, message);
224
228
  });
225
229
  useComboboxForm({
226
230
  value,
@@ -383,84 +387,11 @@ function ComboboxRoot(props) {
383
387
  const label = labelFor(selection.optimistic);
384
388
  if (textRef.current !== label) writeText(label, "dismiss", event);
385
389
  };
386
- const leaveRef = useLatest(leave);
387
- const presses = useRef(/* @__PURE__ */ new Set());
388
- const afterPress = useRef(null);
389
- const unwatchPresses = useRef(null);
390
- const unwatch = () => {
391
- unwatchPresses.current?.();
392
- unwatchPresses.current = null;
393
- presses.current.clear();
394
- afterPress.current = null;
395
- };
396
- const watchPresses = (input) => {
397
- presses.current.clear();
398
- if (unwatchPresses.current !== null) return;
399
- const doc = input.ownerDocument;
400
- const win = doc.defaultView;
401
- const released = () => {
402
- const check = afterPress.current;
403
- if (check === null || presses.current.size > 0) return;
404
- unwatch();
405
- setTimeout(check, 0);
406
- };
407
- const down = (event) => {
408
- presses.current.add(event.pointerId);
409
- };
410
- const up = (event) => {
411
- presses.current.delete(event.pointerId);
412
- released();
413
- };
414
- const blur = () => {
415
- presses.current.clear();
416
- released();
417
- };
418
- doc.addEventListener("pointerdown", down, true);
419
- doc.addEventListener("pointerup", up, true);
420
- doc.addEventListener("pointercancel", up, true);
421
- win?.addEventListener("blur", blur);
422
- unwatchPresses.current = () => {
423
- doc.removeEventListener("pointerdown", down, true);
424
- doc.removeEventListener("pointerup", up, true);
425
- doc.removeEventListener("pointercancel", up, true);
426
- win?.removeEventListener("blur", blur);
427
- };
428
- };
429
- useEffect(() => {
430
- const input = inputRef.current;
431
- if (input !== null && input.ownerDocument.activeElement === input) watchPresses(input);
432
- return unwatch;
433
- }, []);
434
- const focusIn = (event) => {
435
- watchPresses(event.currentTarget);
436
- };
437
- const focusOut = (event) => {
438
- const input = inputRef.current;
439
- const popup = popover.popupRef.current;
440
- const next = event.relatedTarget;
441
- if (next instanceof Node) {
442
- if (next === input || popup !== null && popup.contains(next)) return;
443
- unwatch();
444
- leave(event);
445
- return;
446
- }
447
- if (input === null) {
448
- unwatch();
449
- return;
450
- }
451
- const doc = input.ownerDocument;
452
- const check = () => {
453
- if (!doc.hasFocus()) return;
454
- const active = doc.activeElement;
455
- if (active === input || active !== null && popup !== null && popup.contains(active)) return;
456
- if (input.isConnected) leaveRef.current(event);
457
- };
458
- if (presses.current.size > 0) afterPress.current = check;
459
- else {
460
- unwatch();
461
- setTimeout(check, 0);
462
- }
463
- };
390
+ const { focusIn, focusOut } = useDeferredLeave({
391
+ inputRef,
392
+ popupRef: popover.popupRef,
393
+ leave
394
+ });
464
395
  const inputClick = (event) => {
465
396
  if (disabled || !openOnClick) return;
466
397
  popover.requestOpen(event, "activate");
@@ -1 +1 @@
1
- {"version":3,"file":"combobox-root.mjs","names":[],"sources":["../../src/combobox/combobox-root.tsx"],"sourcesContent":["\"use client\";\nimport {\n use,\n useCallback,\n useDeferredValue,\n useEffect,\n useId,\n useInsertionEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport type { AriaNotifyTarget } from \"../internal/announce.js\";\nimport { FieldContext } from \"../internal/field-context.js\";\nimport { isPopoverOpen } from \"../internal/popover-open.js\";\nimport { capturePointer } from \"../internal/pointer-capture.js\";\nimport { useFieldValueChange } from \"../internal/use-field-control.js\";\nimport type {\n ActionDetails,\n ChangeAction,\n ChangeReason,\n StateValue,\n UrgentChangeHandler,\n} from \"../internal/types.js\";\nimport { transitionTypes } from \"../internal/transition-types.js\";\nimport { useControllableAction } from \"../internal/use-controllable-action.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { popoverDetails, useOverlayRoot } from \"../internal/use-overlay-root.js\";\nimport { resolveStateValue } from \"../internal/use-render.js\";\nimport { ComboboxContext } from \"./combobox-context.js\";\nimport { useComboboxForm } from \"./use-combobox-form.js\";\nimport { useOptionRegistry } from \"./use-option-registry.js\";\nimport type { ComboboxContextValue } from \"./combobox-context.js\";\n\n/** Details passed as the second argument of `Combobox.Root`'s `valueChangeAction`. */\nexport interface ComboboxValueChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user accepted an option (Enter, click; `details.event` is the `keydown` or\n * `click`), committed free text with `allowCustomValue` (Enter: the `keydown`; focus leaving:\n * the `focusout`), or pressed Clear (`click`).\n * `\"platform\"`: a form reset (`details.event` is the `reset` event).\n */\n readonly reason: ChangeReason;\n /** `true` when `next` is free text committed under `allowCustomValue`, not an option's value. */\n readonly custom: boolean;\n}\n\n/** Details passed as the second argument of `Combobox.Root`'s `onInputValueChange`. */\nexport interface ComboboxInputValueChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: typing (the `input` event), an accepted option's label, Clear.\n * `\"dismiss\"`: a revert: focus left with unmatched text, or the selection rolled back.\n * `\"platform\"`: form reset (the `reset` event), or text found in the input at mount\n * (`undefined`).\n */\n readonly reason: ChangeReason;\n}\n\n/** Details passed as the second argument of `Combobox.Root`'s `openChangeAction`. */\nexport interface ComboboxOpenChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: typing, ArrowDown / ArrowUp / Alt+ArrowDown, the Trigger, a click on the input\n * with `openOnClick`, an accepted option (the close after it), a foreign `showPopover()`.\n * `\"dismiss\"`: Escape, light dismiss, focus leaving the combobox, another top-layer element.\n * `\"platform\"`: the popup was found open on mount (only script can cause it).\n */\n readonly reason: ChangeReason;\n}\n\nexport interface ComboboxRootState {\n /** Optimistic selection. Content rendered from it must not suspend. */\n readonly value: string | null;\n /** The text in the input (urgent). */\n readonly inputValue: string;\n /** The deferred text the mounted results are for. */\n readonly query: string;\n /** `inputValue !== query`: the results shown are for an older text. */\n readonly stale: boolean;\n /** The value of the option `aria-activedescendant` points at, or `null`. */\n readonly activeValue: string | null;\n /** Optimistic open state. */\n readonly open: boolean;\n /** A `valueChangeAction` or `openChangeAction` dispatched through this Combobox is in flight. */\n readonly pending: boolean;\n readonly disabled: boolean;\n}\n\nexport interface ComboboxRootProps {\n /** Controlled selection. `null`: nothing selected. `undefined`: uncontrolled. */\n value?: string | null;\n /** Initial selection in uncontrolled mode. Default `null`. */\n defaultValue?: string | null;\n /**\n * Runs inside the Root's transition when the user accepts an option, commits free text\n * (`allowCustomValue`), presses Clear, or the form resets. Awaited; the listbox closes in the\n * commit that ends it; a rejection rolls the input text and `data-selected` back and leaves\n * the listbox open. May be a Server Function. A `setState` after your own `await` needs\n * `startTransition`.\n */\n valueChangeAction?: ChangeAction<string | null, ComboboxValueChangeDetails>;\n\n /** Controlled input text. `undefined`: uncontrolled. */\n inputValue?: string;\n /**\n * Initial input text. Default `\"\"`. Pass the selected value's label when `defaultValue` is\n * set: the library never derives the text from the value.\n */\n defaultInputValue?: string;\n /**\n * The urgent lane, a handler and not an action: called synchronously, outside any Transition,\n * on every change of the text (typing, and the library's own writes: an accepted option's\n * label, a revert, Clear, a form reset, text typed before hydration). Not awaited; nothing is\n * pending for it. A controlled parent updates its state in the body (an urgent update, which is\n * what a controlled text input needs). A returned promise is ignored (development warns once: a\n * fetch belongs in a transition).\n */\n onInputValueChange?: UrgentChangeHandler<string, ComboboxInputValueChangeDetails>;\n\n /** Controlled open state. `undefined`: uncontrolled. */\n open?: boolean;\n /** Initial open state when uncontrolled. Opens after hydration. */\n defaultOpen?: boolean;\n /**\n * Awaited for opens and for the close after an accepted option (or the Trigger); a\n * notification for dismissals (Escape, a click outside, focus leaving).\n */\n openChangeAction?: ChangeAction<boolean, ComboboxOpenChangeDetails>;\n\n /**\n * Free text is a value: Enter with no active option, or focus leaving with text that is not\n * the selected option's label, dispatches the text with `details.custom: true` (empty text\n * dispatches `null`). Default `false`: unmatched text reverts to the selection's label when\n * focus leaves.\n */\n allowCustomValue?: boolean;\n /**\n * Make the first enabled option active when the results for an open or an edit settle (APG\n * \"automatic selection\"). Stale results are never highlighted. Default `false`.\n */\n autoHighlight?: boolean;\n /** Open the listbox on a pointer click in the input (not on focus). Default `false`. */\n openOnClick?: boolean;\n /** Wrap from the last option to the first and back with the arrow keys. Default `false`. */\n loop?: boolean;\n /**\n * The message `ariaNotify()` announces on the List when the results settle, from the number\n * of mounted options. Default (English): `\"No results\"`, `\"1 result\"`, `\"N results\"`. Override\n * for localisation or a richer message; return `null` to announce nothing. Ignored where\n * `ariaNotify` is missing.\n */\n announce?: (count: number, state: ComboboxRootState) => string | null;\n\n /** Form participation through a hidden input with this name (value `\"\"` for `null`). */\n name?: string;\n /** The `form` attribute of the hidden input. */\n form?: string;\n /** Disables the Input, Trigger and Clear; nothing dispatches for user interaction. */\n disabled?: boolean;\n children?: StateValue<ReactNode, ComboboxRootState>;\n}\n\n/** The default announcement (design 6.4; conventions 11: English, always overridable). */\nfunction defaultComboboxAnnouncement(count: number): string {\n if (count === 0) return \"No results\";\n if (count === 1) return \"1 result\";\n return `${count} results`;\n}\n\nconst VALUE_TRANSITION_TYPES = transitionTypes(\"combobox\", \"select\");\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nfunction isThenable(value: unknown): boolean {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { then?: unknown }).then === \"function\"\n );\n}\n\n/** What a value dispatch carries for the Root's own follow-up (by `details` identity). */\ninterface DispatchMeta {\n readonly id: number;\n /** The open this dispatch belongs to (Popover 3.4): a newer open drops the close. */\n readonly generation: number;\n /** Close the listbox once the action settled (an accepted option, Enter on free text). */\n readonly close: boolean;\n /** The text the library wrote with the dispatch: typing since then keeps the listbox open. */\n readonly text: string | undefined;\n}\n\n/** The text the library wrote for a user dispatch, reverted if the value does not land. */\ninterface TextRecord {\n readonly id: number;\n readonly value: string | null;\n readonly text: string;\n settled: boolean;\n}\n\n/**\n * Owns the two states of a combobox (design/components/combobox.md 2): the selection (`value`,\n * a transition with `useOptimistic`, like every other value) and the text (`inputValue`, the\n * library's **urgent** lane: the `onInputValueChange` handler is called synchronously, outside\n * any transition). The results render from `useDeferredValue(inputValue)`; the active option is\n * urgent virtual focus (`aria-activedescendant`); the listbox is a `popover=\"auto\"` opened by the\n * library with the input as `source`. Renders no DOM, except one `<input type=\"hidden\">` when\n * `name` is given.\n */\nexport function ComboboxRoot(props: ComboboxRootProps) {\n const {\n value,\n defaultValue,\n valueChangeAction,\n inputValue: inputValueProp,\n defaultInputValue,\n open,\n defaultOpen,\n openChangeAction,\n allowCustomValue = false,\n autoHighlight = false,\n openOnClick = false,\n loop = false,\n form,\n children,\n } = props;\n\n // Inside a Field.Root (design/components/field-form.md 7.2): the Input is the Field's control\n // (its id is the Field's, so `Field.Label` points at it), the hidden input's `name` and\n // `disabled` default from the Field, and the List is named by `Field.Label` when no\n // `Combobox.Label` is mounted.\n const field = use(FieldContext);\n const name = props.name ?? field?.name;\n const disabled = (props.disabled ?? false) || (field?.disabled ?? false);\n const fieldControlId = field?.ids.control;\n\n const id = useId();\n const ids = useMemo(\n () => ({\n input: fieldControlId ?? `${id}-input`,\n label: `${id}-label`,\n list: `${id}-list`,\n optionPrefix: `${id}-option-`,\n }),\n [id, fieldControlId],\n );\n\n const popover = useOverlayRoot<ComboboxOpenChangeDetails>({\n component: \"combobox\",\n part: \"Combobox.Root\",\n mode: \"library\",\n open,\n defaultOpen,\n openChangeAction,\n details: popoverDetails,\n });\n\n // --- Refs the handlers read after an `await` or from a timer ------------------------------\n\n const propsRef = useLatest(props);\n const popoverRef = useLatest(popover);\n\n const inputRef = useRef<HTMLInputElement | null>(null);\n const listRef = useRef<HTMLElement | null>(null);\n const hiddenRef = useRef<HTMLInputElement | null>(null);\n\n // --- Text: the urgent lane (design 4) ------------------------------------------------------\n\n const [internalText, setInternalText] = useState(() => defaultInputValue ?? inputValueProp ?? \"\");\n const text = inputValueProp ?? internalText;\n const query = useDeferredValue(text);\n const stale = text !== query;\n const textRef = useRef(text);\n useInsertionEffect(() => {\n textRef.current = text;\n });\n\n const warnedThenable = useRef(false);\n /** Writes the text (urgent) and calls `onInputValueChange` synchronously (design 2.2). */\n const writeText = useCallback(\n (next: string, reason: ChangeReason, event: Event | undefined): void => {\n const latest = propsRef.current;\n if (latest.inputValue === undefined) setInternalText(next);\n textRef.current = next;\n const handler = latest.onInputValueChange;\n if (handler === undefined) return;\n const result: unknown = handler(next, createActionDetails(event, { reason }));\n if (isDev && !warnedThenable.current && isThenable(result)) {\n warnedThenable.current = true;\n console.error(\n \"Combobox.Root: `onInputValueChange` returned a promise. It is the urgent lane: it is \" +\n \"not awaited. Fetch in a transition instead (`valueChangeAction`, or \" +\n \"`useDeferredValue` of `inputValue`).\",\n );\n }\n },\n [propsRef],\n );\n\n // --- Labels (design 2.3) -------------------------------------------------------------------\n\n const [labels] = useState(() => {\n const map = new Map<string, string>();\n const initialValue = value !== undefined ? value : (defaultValue ?? null);\n if (initialValue !== null) map.set(initialValue, defaultInputValue ?? inputValueProp ?? \"\");\n return map;\n });\n const labelFor = useCallback(\n (v: string | null): string => (v === null ? \"\" : (labels.get(v) ?? \"\")),\n [labels],\n );\n\n // --- Selection: a transition (design 3.1, 5.2) --------------------------------------------\n\n const dispatchSeq = useRef(0);\n const [dispatchMeta] = useState(() => new WeakMap<object, DispatchMeta>());\n const textRecord = useRef<TextRecord | null>(null);\n\n const runValueAction = async (\n next: string | null,\n details: ComboboxValueChangeDetails,\n ): Promise<void> => {\n const meta = dispatchMeta.get(details);\n try {\n await valueChangeAction?.(next, details);\n } catch (error) {\n // Walkthrough 4: the text rolls back with the optimistic value. A synchronous throw lands\n // here inside the Root's `startTransition` callback; yield once so the write (and the\n // consumer's `onInputValueChange`) is urgent, as every text write (conventions 2.6).\n await undefined;\n const record = textRecord.current;\n if (meta !== undefined && record !== null && record.id === meta.id) {\n textRecord.current = null;\n if (textRef.current === record.text) {\n writeText(labelFor(committedRef.current), \"dismiss\", undefined);\n }\n }\n throw error;\n }\n const record = textRecord.current;\n if (meta !== undefined && record !== null && record.id === meta.id) record.settled = true;\n // Menu decision 3: close in the commit that ends the action, unless a newer dispatch took\n // over, the user dismissed and re-opened meanwhile, or the user is typing a new search.\n const current = popoverRef.current;\n if (\n meta !== undefined &&\n meta.close &&\n meta.id === dispatchSeq.current &&\n current.openGeneration() === meta.generation &&\n (meta.text === undefined || textRef.current === meta.text)\n ) {\n current.requestClose(details.event, \"activate\");\n }\n };\n\n const selection = useControllableAction<string | null, ComboboxValueChangeDetails>({\n controlled: value,\n defaultValue,\n initialValue: null,\n action: runValueAction,\n transitionTypes: () => VALUE_TRANSITION_TYPES,\n warn: { component: \"Combobox.Root\", prop: \"value\" },\n });\n // Read by `runValueAction` above, which only runs after a commit.\n const committedRef = useLatest(selection.committed);\n\n /** The next change of the optimistic selection comes from the user (a dispatch). */\n const userEdit = useRef(false);\n const dispatchValue = (\n next: string | null,\n event: Event | undefined,\n fields: { reason: ChangeReason; custom: boolean },\n options: { close: boolean; text: string | undefined },\n ): void => {\n const details = createActionDetails(event, fields);\n const dispatchId = ++dispatchSeq.current;\n dispatchMeta.set(details, {\n id: dispatchId,\n generation: popover.openGeneration(),\n close: options.close,\n text: options.text,\n });\n textRecord.current =\n options.text === undefined\n ? null\n : { id: dispatchId, value: next, text: options.text, settled: false };\n if (next !== selection.optimistic) userEdit.current = true;\n selection.dispatch(next, details);\n };\n\n // Inside a Field: React writes the hidden input with no `input` / `change` event, so the Field\n // is told after the commit (its `validate` reads the hidden input; a user's pick dismisses a\n // shown server error like typing would).\n useFieldValueChange(selection.optimistic, () => {\n const edit = userEdit.current;\n userEdit.current = false;\n return edit;\n });\n\n // --- Option registry and the active option (design 2, 6.5) --------------------------------\n\n const {\n registry,\n optionCount,\n statusCount,\n statusCountRef,\n labelCount,\n registerOption,\n registerStatus,\n registerLabel,\n orderedOptions,\n } = useOptionRegistry(labels);\n\n const [activeValue, setActiveValue] = useState<string | null>(null);\n const activeRef = useRef<string | null>(null);\n const setActive = useCallback((next: string | null) => {\n activeRef.current = next;\n setActiveValue(next);\n }, []);\n // The edge to activate once the open has options (ArrowDown / ArrowUp while closed).\n const pendingEdge = useRef<\"first\" | \"last\" | null>(null);\n // `autoHighlight` (APG automatic selection) highlights once per open and once per edit, when\n // the results for it settle. Home / End / Left / Right clear the active option without\n // re-arming it, so the caret keys really return visual focus to the input.\n const autoArmed = useRef(true);\n\n // A Status inside the List is a Suspense fallback: the results are loading (design 6.3).\n const loading = statusCount > 0;\n const empty = optionCount === 0 && !stale && !loading;\n\n // Revalidation (design 6.5): urgent, in a layout effect after every commit; never dispatches.\n useLayoutEffect(() => {\n const current = activeRef.current;\n if (!popover.committed) {\n // Keep the edge of an open that is on its way (the optimistic commit comes first).\n if (!popover.intended()) pendingEdge.current = null;\n autoArmed.current = true;\n if (current !== null) setActive(null);\n return;\n }\n const enabled = orderedOptions().filter((option) => !option.disabled);\n let next = current;\n if (pendingEdge.current !== null && enabled.length > 0) {\n next = (pendingEdge.current === \"first\" ? enabled[0] : enabled.at(-1))!.value;\n pendingEdge.current = null;\n } else if (next !== null && !enabled.some((option) => option.value === next)) {\n next = null;\n }\n if (next !== null) {\n // Something is active (keys, hover): nothing to highlight for these results.\n autoArmed.current = false;\n } else if (autoHighlight && autoArmed.current && !stale && enabled.length > 0) {\n // Only settled results: a stale list's first option is never auto-highlighted, so a fast\n // Enter commits the typed text or does nothing (design 6.5).\n next = enabled[0]!.value;\n autoArmed.current = false;\n }\n if (next !== current) setActive(next);\n });\n\n // The selection did not land (a controlled parent refused it, or the caught-inside variant of\n // a controlled parent): the text goes back to the committed value's label (design 2.2).\n // Labels for values set from outside are learnt from the text the consumer passed with them.\n const prevCommitted = useRef(selection.committed);\n useLayoutEffect(() => {\n const record = textRecord.current;\n if (\n record !== null &&\n record.settled &&\n !selection.pending &&\n selection.latestInFlight() === null\n ) {\n textRecord.current = null;\n if (selection.committed !== record.value && textRef.current === record.text) {\n writeText(labelFor(selection.committed), \"dismiss\", undefined);\n }\n }\n if (prevCommitted.current !== selection.committed) {\n prevCommitted.current = selection.committed;\n const committed = selection.committed;\n if (committed !== null && textRecord.current === null && !labels.has(committed)) {\n labels.set(committed, textRef.current);\n }\n }\n });\n\n // --- Announcements (design 6.4) -----------------------------------------------------------\n\n const state: ComboboxRootState = {\n value: selection.optimistic,\n inputValue: text,\n query,\n stale,\n activeValue,\n open: popover.optimistic,\n pending: selection.pending || popover.pending,\n disabled,\n };\n\n const lastAnnounced = useRef<string | null>(null);\n useEffect(() => {\n if (!popover.committed) {\n lastAnnounced.current = null;\n return;\n }\n if (stale || statusCountRef.current > 0) return;\n // The registry, not `optionCount`: a commit's passive effects can run before the re-render\n // that the Options' registration scheduled.\n const count = registry.size;\n const key = `${count}\\u0000${query}`;\n if (lastAnnounced.current === key) return;\n lastAnnounced.current = key;\n const list = listRef.current as (HTMLElement & AriaNotifyTarget) | null;\n if (list === null || typeof list.ariaNotify !== \"function\") return;\n const announce = propsRef.current.announce ?? defaultComboboxAnnouncement;\n const message = announce(count, state);\n if (message !== null) list.ariaNotify(message);\n });\n\n // --- Form: hidden input, reset, mount reconciliation (design 11.1, walkthroughs 10 and 11) ---\n\n useComboboxForm({\n value,\n defaultValue,\n inputValue: inputValueProp,\n defaultInputValue,\n inputRef,\n hiddenRef,\n textRef,\n writeText,\n optimistic: selection.optimistic,\n resetValue: (next, event) =>\n dispatchValue(\n next,\n event,\n { reason: \"platform\", custom: false },\n { close: false, text: undefined },\n ),\n });\n\n const [missingText] = useState(\n () =>\n (value ?? defaultValue ?? null) !== null &&\n inputValueProp === undefined &&\n defaultInputValue === undefined,\n );\n useDevWarning(\n missingText,\n isDev &&\n \"Combobox.Root: `value` / `defaultValue` is set but neither `inputValue` nor \" +\n \"`defaultInputValue` is: the input will show no text for the selection. The library never \" +\n \"derives the text from the value; pass the selected option's label as well.\",\n );\n\n // --- Interaction (design 5, 8) -------------------------------------------------------------\n\n const accept = (optionValue: string, event: Event): void => {\n if (disabled) return;\n const entry = registry.get(optionValue);\n if (entry === undefined || entry.disabled) return;\n const label = entry.label ?? (entry.element.textContent ?? \"\").trim();\n labels.set(optionValue, label);\n pendingEdge.current = null;\n if (activeRef.current !== optionValue) setActive(optionValue);\n writeText(label, \"activate\", event);\n // Re-accepting the selected option dispatches nothing and closes (conventions 2.3 item 8).\n if (optionValue === selection.optimistic) {\n popover.requestClose(event, \"activate\");\n return;\n }\n dispatchValue(\n optionValue,\n event,\n { reason: \"activate\", custom: false },\n { close: true, text: label },\n );\n };\n\n /** Free text as the value (design 5.3). Returns whether it dispatched. */\n const commitText = (event: Event, close: boolean): boolean => {\n const current = selection.optimistic;\n const typed = textRef.current;\n if (typed === labelFor(current)) return false;\n const next = typed === \"\" ? null : typed;\n if (next === current) return false;\n if (next !== null) labels.set(next, typed);\n dispatchValue(\n next,\n event,\n { reason: \"activate\", custom: next !== null },\n { close, text: typed },\n );\n return true;\n };\n\n const clear = (event: Event): void => {\n if (disabled) return;\n if (textRef.current !== \"\") writeText(\"\", \"activate\", event);\n if (selection.optimistic !== null) {\n dispatchValue(null, event, { reason: \"activate\", custom: false }, { close: false, text: \"\" });\n }\n inputRef.current?.focus();\n };\n\n const typed = (next: string, event: Event): void => {\n if (disabled) return;\n writeText(next, \"activate\", event);\n pendingEdge.current = null;\n // APG: editing moves visual focus back to the input; `autoHighlight` picks the first option\n // again once the results for the new text settle.\n if (activeRef.current !== null) setActive(null);\n autoArmed.current = true;\n popover.requestOpen(event, \"activate\");\n };\n\n const move = (direction: 1 | -1): void => {\n const enabled = orderedOptions().filter((option) => !option.disabled);\n if (enabled.length === 0) return;\n const last = enabled.length - 1;\n const index = enabled.findIndex((option) => option.value === activeRef.current);\n let next: number;\n if (direction === 1) next = index < 0 ? 0 : index >= last ? (loop ? 0 : last) : index + 1;\n else next = index < 0 ? last : index <= 0 ? (loop ? last : 0) : index - 1;\n const target = enabled[next]!;\n setActive(target.value);\n if (typeof target.element.scrollIntoView === \"function\") {\n target.element.scrollIntoView({ block: \"nearest\" });\n }\n };\n\n const activeEnabled = (): string | null => {\n const current = activeRef.current;\n if (current === null) return null;\n const entry = registry.get(current);\n return entry !== undefined && !entry.disabled ? current : null;\n };\n\n const keyDown = (event: KeyboardEvent): boolean => {\n if (disabled || event.ctrlKey || event.metaKey) return false;\n // IME: the key belongs to the composition (Enter commits it, arrows pick a candidate).\n if (event.isComposing || event.keyCode === 229) return false;\n // What the user sees, not what is intended: right after Escape the platform has hidden the\n // popup but its `toggle` (and the library's notification) is still queued, and an open that\n // is still committing shows nothing yet. Enter must submit and arrows must open in both.\n const isOpen = isPopoverOpen(popover.popupRef.current);\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n if (event.altKey) {\n if (!isOpen) popover.requestOpen(event, \"activate\");\n } else if (!isOpen) {\n pendingEdge.current = \"first\";\n popover.requestOpen(event, \"activate\");\n } else {\n move(1);\n }\n return true;\n case \"ArrowUp\":\n event.preventDefault();\n if (event.altKey) {\n if (isOpen) {\n const active = activeEnabled();\n if (active !== null) accept(active, event);\n else popover.requestClose(event, \"activate\");\n }\n } else if (!isOpen) {\n pendingEdge.current = \"last\";\n popover.requestOpen(event, \"activate\");\n } else {\n move(-1);\n }\n return true;\n case \"Enter\": {\n if (isOpen) {\n // An open listbox means the user is choosing: never submit from here.\n event.preventDefault();\n const active = activeEnabled();\n if (active !== null) accept(active, event);\n else if (allowCustomValue && !commitText(event, true)) {\n popover.requestClose(event, \"activate\");\n }\n return true;\n }\n // Closed: not prevented, so a form still submits. The key's default action (implicit\n // submission) must see the optimistic hidden value: Firefox submits before React's\n // scheduled flush of the optimistic render, so it is flushed here (design 5.3).\n if (allowCustomValue) flushSync(() => commitText(event, false));\n return false;\n }\n case \"Home\":\n case \"End\":\n case \"ArrowLeft\":\n case \"ArrowRight\":\n // APG: the caret keys move visual focus to the input (not prevented: the caret moves).\n if (activeRef.current !== null) setActive(null);\n return false;\n default:\n return false;\n }\n };\n\n /** Focus has left the input and the popup (design 5.4). */\n const leave = (event: Event): void => {\n // `disabled`: nothing dispatches (disabling a focused input blurs it).\n if (disabled) return;\n const popup = popover.popupRef.current;\n if (popup !== null && isPopoverOpen(popup)) {\n popover.recordCloseIntent({ reason: \"dismiss\", event });\n popup.hidePopover();\n }\n pendingEdge.current = null;\n if (allowCustomValue) {\n commitText(event, false);\n return;\n }\n const label = labelFor(selection.optimistic);\n if (textRef.current !== label) writeText(label, \"dismiss\", event);\n };\n const leaveRef = useLatest(leave);\n\n // A press blurs the input at `mousedown`, but its outcome is known only at the `click`, which\n // runs in the `pointerup` task: a `<label for>` (Combobox.Label, Field.Label) refocuses the\n // input there (#111). While the input is focused (and until a leave deferred to a release has\n // been decided), the presses on its document are tracked; a leave check made while one is down\n // waits for the last release. A window blur forgets the presses (a release it swallowed would\n // otherwise hold the check back), and so does focus arriving in the input.\n const presses = useRef(new Set<number>());\n const afterPress = useRef<(() => void) | null>(null);\n const unwatchPresses = useRef<(() => void) | null>(null);\n const unwatch = (): void => {\n unwatchPresses.current?.();\n unwatchPresses.current = null;\n presses.current.clear();\n afterPress.current = null;\n };\n const watchPresses = (input: HTMLInputElement): void => {\n presses.current.clear();\n if (unwatchPresses.current !== null) return;\n const doc = input.ownerDocument;\n const win = doc.defaultView;\n const released = (): void => {\n const check = afterPress.current;\n if (check === null || presses.current.size > 0) return;\n unwatch();\n setTimeout(check, 0);\n };\n const down = (event: PointerEvent): void => {\n presses.current.add(event.pointerId);\n };\n const up = (event: PointerEvent): void => {\n presses.current.delete(event.pointerId);\n released();\n };\n const blur = (): void => {\n presses.current.clear();\n released();\n };\n doc.addEventListener(\"pointerdown\", down, true);\n doc.addEventListener(\"pointerup\", up, true);\n doc.addEventListener(\"pointercancel\", up, true);\n win?.addEventListener(\"blur\", blur);\n unwatchPresses.current = () => {\n doc.removeEventListener(\"pointerdown\", down, true);\n doc.removeEventListener(\"pointerup\", up, true);\n doc.removeEventListener(\"pointercancel\", up, true);\n win?.removeEventListener(\"blur\", blur);\n };\n };\n useEffect(() => {\n // Focused before the Root mounted (autofocus, typing before hydration): no `focus` follows.\n const input = inputRef.current;\n if (input !== null && input.ownerDocument.activeElement === input) watchPresses(input);\n return unwatch;\n }, []);\n\n const focusIn = (event: FocusEvent): void => {\n watchPresses(event.currentTarget as HTMLInputElement);\n };\n\n const focusOut = (event: FocusEvent): void => {\n const input = inputRef.current;\n const popup = popover.popupRef.current;\n const next = event.relatedTarget;\n if (next instanceof Node) {\n if (next === input || (popup !== null && popup.contains(next))) return;\n unwatch();\n leave(event);\n return;\n }\n // No related target: the window lost focus (nothing to do), or a press landed on something\n // that takes no focus (a label, the page itself: focus moved to <body>). Decide one task\n // after the press is released (its click has run then), or one task later without a press.\n if (input === null) {\n unwatch();\n return;\n }\n const doc = input.ownerDocument;\n const check = () => {\n if (!doc.hasFocus()) return;\n const active = doc.activeElement;\n if (active === input || (active !== null && popup !== null && popup.contains(active))) {\n return;\n }\n if (input.isConnected) leaveRef.current(event);\n };\n if (presses.current.size > 0) {\n afterPress.current = check;\n } else {\n unwatch();\n setTimeout(check, 0);\n }\n };\n\n const inputClick = (event: MouseEvent): void => {\n if (disabled || !openOnClick) return;\n popover.requestOpen(event, \"activate\");\n };\n\n // A press on the field while the listbox is shown: `source` is no light-dismiss exemption, so\n // the release goes to the Popup, whose topmost clicked popover is the listbox itself (design\n // 5.4, #123). Judged on `:popover-open`, not the intent: a press during a pending close must\n // not dismiss either. Primary button only (a right click keeps the field's own context menu).\n // The engine releases the capture after `pointerup`; the #111 press tracking above still sees\n // the release on the document.\n const inputPointerDown = (event: PointerEvent): void => {\n if (disabled || event.button !== 0) return;\n const popup = popover.popupRef.current;\n if (popup !== null && isPopoverOpen(popup)) capturePointer(popup, event.pointerId);\n };\n\n const context: ComboboxContextValue = {\n popover,\n ids,\n value: selection.optimistic,\n valuePending: selection.pending,\n pending: state.pending,\n inputValue: text,\n query,\n stale,\n activeValue,\n empty,\n loading,\n hasLabel: labelCount > 0,\n fieldLabelId: field?.ids.label,\n disabled,\n inputRef,\n listRef,\n registerOption,\n registerStatus,\n registerLabel,\n setActive,\n accept,\n clear,\n typed,\n keyDown,\n focusIn,\n focusOut,\n inputClick,\n inputPointerDown,\n };\n\n return (\n <ComboboxContext value={context}>\n {name !== undefined && (\n <input\n ref={hiddenRef}\n type=\"hidden\"\n name={name}\n form={form}\n value={selection.optimistic ?? \"\"}\n />\n )}\n {resolveStateValue(children, state)}\n </ComboboxContext>\n );\n}\n\nComboboxRoot.displayName = \"ComboboxRoot\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuKA,SAAS,4BAA4B,OAAuB;CAC1D,IAAI,UAAU,GAAG,OAAO;CACxB,IAAI,UAAU,GAAG,OAAO;CACxB,OAAO,GAAG,MAAM;AAClB;AAEA,MAAM,yBAAyB,gBAAgB,YAAY,QAAQ;AAEnE,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,SAAS,WAAW,OAAyB;CAC3C,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA6B,SAAS;AAElD;;;;;;;;;;AA8BA,SAAgB,aAAa,OAA0B;CACrD,MAAM,EACJ,OACA,cACA,mBACA,YAAY,gBACZ,mBACA,MACA,aACA,kBACA,mBAAmB,OACnB,gBAAgB,OAChB,cAAc,OACd,OAAO,OACP,MACA,aACE;CAMJ,MAAM,QAAQ,IAAI,YAAY;CAC9B,MAAM,OAAO,MAAM,QAAQ,OAAO;CAClC,MAAM,YAAY,MAAM,YAAY,WAAW,OAAO,YAAY;CAClE,MAAM,iBAAiB,OAAO,IAAI;CAElC,MAAM,KAAK,MAAM;CACjB,MAAM,MAAM,eACH;EACL,OAAO,kBAAkB,GAAG,GAAG;EAC/B,OAAO,GAAG,GAAG;EACb,MAAM,GAAG,GAAG;EACZ,cAAc,GAAG,GAAG;CACtB,IACA,CAAC,IAAI,cAAc,CACrB;CAEA,MAAM,UAAU,eAA0C;EACxD,WAAW;EACX,MAAM;EACN,MAAM;EACN;EACA;EACA;EACA,SAAS;CACX,CAAC;CAID,MAAM,WAAW,UAAU,KAAK;CAChC,MAAM,aAAa,UAAU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;;AAErB;AAEA,aAAa,cAAc"}
1
+ {"version":3,"file":"combobox-root.mjs","names":[],"sources":["../../src/combobox/combobox-root.tsx"],"sourcesContent":["\"use client\";\nimport {\n use,\n useCallback,\n useDeferredValue,\n useEffect,\n useId,\n useInsertionEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { announce, canAnnounce } from \"../internal/announce.js\";\nimport { FieldContext } from \"../internal/field-context.js\";\nimport { isPopoverOpen } from \"../internal/popover-open.js\";\nimport { capturePointer } from \"../internal/pointer-capture.js\";\nimport { useFieldValueChange } from \"../internal/use-field-control.js\";\nimport type {\n ActionDetails,\n ChangeAction,\n ChangeReason,\n StateValue,\n UrgentChangeHandler,\n} from \"../internal/types.js\";\nimport { transitionTypes } from \"../internal/transition-types.js\";\nimport { useControllableAction } from \"../internal/use-controllable-action.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { popoverDetails, useOverlayRoot } from \"../internal/use-overlay-root.js\";\nimport { resolveStateValue } from \"../internal/use-render.js\";\nimport { ComboboxContext } from \"./combobox-context.js\";\nimport { useComboboxForm } from \"./use-combobox-form.js\";\nimport { useDeferredLeave } from \"./use-deferred-leave.js\";\nimport { useOptionRegistry } from \"./use-option-registry.js\";\nimport type { ComboboxContextValue } from \"./combobox-context.js\";\n\n/** Details passed as the second argument of `Combobox.Root`'s `valueChangeAction`. */\nexport interface ComboboxValueChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user accepted an option (Enter, click; `details.event` is the `keydown` or\n * `click`), committed free text with `allowCustomValue` (Enter: the `keydown`; focus leaving:\n * the `focusout`), or pressed Clear (`click`).\n * `\"platform\"`: a form reset (`details.event` is the `reset` event).\n */\n readonly reason: ChangeReason;\n /** `true` when `next` is free text committed under `allowCustomValue`, not an option's value. */\n readonly custom: boolean;\n}\n\n/** Details passed as the second argument of `Combobox.Root`'s `onInputValueChange`. */\nexport interface ComboboxInputValueChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: typing (the `input` event), an accepted option's label, Clear.\n * `\"dismiss\"`: a revert: focus left with unmatched text, or the selection rolled back.\n * `\"platform\"`: form reset (the `reset` event), or text found in the input at mount\n * (`undefined`).\n */\n readonly reason: ChangeReason;\n}\n\n/** Details passed as the second argument of `Combobox.Root`'s `openChangeAction`. */\nexport interface ComboboxOpenChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: typing, ArrowDown / ArrowUp / Alt+ArrowDown, the Trigger, a click on the input\n * with `openOnClick`, an accepted option (the close after it), a foreign `showPopover()`.\n * `\"dismiss\"`: Escape, light dismiss, focus leaving the combobox, another top-layer element.\n * `\"platform\"`: the popup was found open on mount (only script can cause it).\n */\n readonly reason: ChangeReason;\n}\n\n/** State of `Combobox.Root`, passed to the function forms of `announce` and `children`. */\nexport interface ComboboxRootState {\n /** Optimistic selection. Content rendered from it must not suspend. */\n readonly value: string | null;\n /** The text in the input (urgent). */\n readonly inputValue: string;\n /** The deferred text the mounted results are for. */\n readonly query: string;\n /** `inputValue !== query`: the results shown are for an older text. */\n readonly stale: boolean;\n /** The value of the option `aria-activedescendant` points at, or `null`. */\n readonly activeValue: string | null;\n /** Optimistic open state. */\n readonly open: boolean;\n /** A `valueChangeAction` or `openChangeAction` dispatched through this Combobox is in flight. */\n readonly pending: boolean;\n /** The `disabled` prop, or the enclosing Field's. */\n readonly disabled: boolean;\n}\n\n/**\n * Props of `Combobox.Root`.\n *\n * @see https://ui.funstack.work/components/combobox\n */\nexport interface ComboboxRootProps {\n /** Controlled selection. `null`: nothing selected. `undefined`: uncontrolled. */\n value?: string | null;\n /**\n * Initial selection in uncontrolled mode.\n *\n * @defaultValue `null`\n */\n defaultValue?: string | null;\n /**\n * Runs inside the Root's transition when the user accepts an option, commits free text\n * (`allowCustomValue`), presses Clear, or the form resets. Awaited; the listbox closes in the\n * commit that ends it; a rejection rolls the input text and `data-selected` back and leaves\n * the listbox open. May be a Server Function. A `setState` after your own `await` needs\n * `startTransition`.\n */\n valueChangeAction?: ChangeAction<string | null, ComboboxValueChangeDetails>;\n\n /** Controlled input text. `undefined`: uncontrolled. */\n inputValue?: string;\n /**\n * Initial input text. Pass the selected value's label when `defaultValue` is\n * set: the library never derives the text from the value.\n *\n * @defaultValue `\"\"`\n */\n defaultInputValue?: string;\n /**\n * The urgent lane, a handler and not an action: called synchronously, outside any Transition,\n * on every change of the text (typing, and the library's own writes: an accepted option's\n * label, a revert, Clear, a form reset, text typed before hydration). Not awaited; nothing is\n * pending for it. A controlled parent updates its state in the body (an urgent update, which is\n * what a controlled text input needs). A returned promise is ignored (development warns once: a\n * fetch belongs in a transition).\n */\n onInputValueChange?: UrgentChangeHandler<string, ComboboxInputValueChangeDetails>;\n\n /** Controlled open state. `undefined`: uncontrolled. */\n open?: boolean;\n /**\n * Initial open state when uncontrolled. Opens after hydration.\n *\n * @defaultValue `false`\n */\n defaultOpen?: boolean;\n /**\n * Awaited for opens and for the close after an accepted option (or the Trigger); a\n * notification for dismissals (Escape, a click outside, focus leaving).\n */\n openChangeAction?: ChangeAction<boolean, ComboboxOpenChangeDetails>;\n\n /**\n * Free text is a value: Enter with no active option, or focus leaving with text that is not\n * the selected option's label, dispatches the text with `details.custom: true` (empty text\n * dispatches `null`). When `false`, unmatched text reverts to the selection's label when focus\n * leaves.\n *\n * @defaultValue `false`\n */\n allowCustomValue?: boolean;\n /**\n * Make the first enabled option active when the results for an open or an edit settle (APG\n * \"automatic selection\"). Stale results are never highlighted.\n *\n * @defaultValue `false`\n */\n autoHighlight?: boolean;\n /**\n * Open the listbox on a pointer click in the input (not on focus).\n *\n * @defaultValue `false`\n */\n openOnClick?: boolean;\n /**\n * Wrap from the last option to the first and back with the arrow keys.\n *\n * @defaultValue `false`\n */\n loop?: boolean;\n /**\n * The message `ariaNotify()` announces on the List when the results settle, from the number\n * of mounted options. Override for localisation or a richer message; return `null` to announce\n * nothing. Ignored where `ariaNotify` is missing.\n *\n * @defaultValue English: `\"No results\"`, `\"1 result\"`, `\"N results\"`\n */\n announce?: (count: number, state: ComboboxRootState) => string | null;\n\n /** Form participation through a hidden input with this name (value `\"\"` for `null`). */\n name?: string;\n /** The `form` attribute of the hidden input. */\n form?: string;\n /**\n * Disables the Input, Trigger and Clear; nothing dispatches for user interaction.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /** The parts, or a function of the Root's state. */\n children?: StateValue<ReactNode, ComboboxRootState>;\n}\n\n/** The default announcement (design 6.4; conventions 11: English, always overridable). */\nfunction defaultComboboxAnnouncement(count: number): string {\n if (count === 0) return \"No results\";\n if (count === 1) return \"1 result\";\n return `${count} results`;\n}\n\nconst VALUE_TRANSITION_TYPES = transitionTypes(\"combobox\", \"select\");\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nfunction isThenable(value: unknown): boolean {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { then?: unknown }).then === \"function\"\n );\n}\n\n/** What a value dispatch carries for the Root's own follow-up (by `details` identity). */\ninterface DispatchMeta {\n readonly id: number;\n /** The open this dispatch belongs to (Popover 3.4): a newer open drops the close. */\n readonly generation: number;\n /** Close the listbox once the action settled (an accepted option, Enter on free text). */\n readonly close: boolean;\n /** The text the library wrote with the dispatch: typing since then keeps the listbox open. */\n readonly text: string | undefined;\n}\n\n/** The text the library wrote for a user dispatch, reverted if the value does not land. */\ninterface TextRecord {\n readonly id: number;\n readonly value: string | null;\n readonly text: string;\n settled: boolean;\n}\n\n/**\n * Owns the two states of a combobox (design/components/combobox.md 2): the selection (`value`,\n * a transition with `useOptimistic`, like every other value) and the text (`inputValue`, the\n * library's **urgent** lane: the `onInputValueChange` handler is called synchronously, outside\n * any transition). The results render from `useDeferredValue(inputValue)`; the active option is\n * urgent virtual focus (`aria-activedescendant`); the listbox is a `popover=\"auto\"` opened by the\n * library with the input as `source`. Renders no DOM, except one `<input type=\"hidden\">` when\n * `name` is given.\n *\n * @see https://ui.funstack.work/components/combobox\n */\nexport function ComboboxRoot(props: ComboboxRootProps) {\n const {\n value,\n defaultValue,\n valueChangeAction,\n inputValue: inputValueProp,\n defaultInputValue,\n open,\n defaultOpen,\n openChangeAction,\n allowCustomValue = false,\n autoHighlight = false,\n openOnClick = false,\n loop = false,\n form,\n children,\n } = props;\n\n // Inside a Field.Root (design/components/field-form.md 7.2): the Input is the Field's control\n // (its id is the Field's, so `Field.Label` points at it), the hidden input's `name` and\n // `disabled` default from the Field, and the List is named by `Field.Label` when no\n // `Combobox.Label` is mounted.\n const field = use(FieldContext);\n const name = props.name ?? field?.name;\n const disabled = (props.disabled ?? false) || (field?.disabled ?? false);\n const fieldControlId = field?.ids.control;\n\n const id = useId();\n const ids = useMemo(\n () => ({\n input: fieldControlId ?? `${id}-input`,\n label: `${id}-label`,\n list: `${id}-list`,\n optionPrefix: `${id}-option-`,\n }),\n [id, fieldControlId],\n );\n\n const popover = useOverlayRoot<ComboboxOpenChangeDetails>({\n component: \"combobox\",\n part: \"Combobox.Root\",\n mode: \"library\",\n open,\n defaultOpen,\n openChangeAction,\n details: popoverDetails,\n });\n\n // --- Refs the handlers read after an `await` or from a timer ------------------------------\n\n const propsRef = useLatest(props);\n const popoverRef = useLatest(popover);\n\n const inputRef = useRef<HTMLInputElement | null>(null);\n const listRef = useRef<HTMLElement | null>(null);\n const hiddenRef = useRef<HTMLInputElement | null>(null);\n\n // --- Text: the urgent lane (design 4) ------------------------------------------------------\n\n const [internalText, setInternalText] = useState(() => defaultInputValue ?? inputValueProp ?? \"\");\n const text = inputValueProp ?? internalText;\n const query = useDeferredValue(text);\n const stale = text !== query;\n const textRef = useRef(text);\n useInsertionEffect(() => {\n textRef.current = text;\n });\n\n const warnedThenable = useRef(false);\n /** Writes the text (urgent) and calls `onInputValueChange` synchronously (design 2.2). */\n const writeText = useCallback(\n (next: string, reason: ChangeReason, event: Event | undefined): void => {\n const latest = propsRef.current;\n if (latest.inputValue === undefined) setInternalText(next);\n textRef.current = next;\n const handler = latest.onInputValueChange;\n if (handler === undefined) return;\n const result: unknown = handler(next, createActionDetails(event, { reason }));\n if (isDev && !warnedThenable.current && isThenable(result)) {\n warnedThenable.current = true;\n console.error(\n \"Combobox.Root: `onInputValueChange` returned a promise. It is the urgent lane: it is \" +\n \"not awaited. Fetch in a transition instead (`valueChangeAction`, or \" +\n \"`useDeferredValue` of `inputValue`).\",\n );\n }\n },\n [propsRef],\n );\n\n // --- Labels (design 2.3) -------------------------------------------------------------------\n\n const [labels] = useState(() => {\n const map = new Map<string, string>();\n const initialValue = value !== undefined ? value : (defaultValue ?? null);\n if (initialValue !== null) map.set(initialValue, defaultInputValue ?? inputValueProp ?? \"\");\n return map;\n });\n const labelFor = useCallback(\n (v: string | null): string => (v === null ? \"\" : (labels.get(v) ?? \"\")),\n [labels],\n );\n\n // --- Selection: a transition (design 3.1, 5.2) --------------------------------------------\n\n const dispatchSeq = useRef(0);\n const [dispatchMeta] = useState(() => new WeakMap<object, DispatchMeta>());\n const textRecord = useRef<TextRecord | null>(null);\n\n const runValueAction = async (\n next: string | null,\n details: ComboboxValueChangeDetails,\n ): Promise<void> => {\n const meta = dispatchMeta.get(details);\n try {\n await valueChangeAction?.(next, details);\n } catch (error) {\n // Walkthrough 4: the text rolls back with the optimistic value. A synchronous throw lands\n // here inside the Root's `startTransition` callback; yield once so the write (and the\n // consumer's `onInputValueChange`) is urgent, as every text write (conventions 2.6).\n await undefined;\n const record = textRecord.current;\n if (meta !== undefined && record !== null && record.id === meta.id) {\n textRecord.current = null;\n if (textRef.current === record.text) {\n writeText(labelFor(committedRef.current), \"dismiss\", undefined);\n }\n }\n throw error;\n }\n const record = textRecord.current;\n if (meta !== undefined && record !== null && record.id === meta.id) record.settled = true;\n // Menu decision 3: close in the commit that ends the action, unless a newer dispatch took\n // over, the user dismissed and re-opened meanwhile, or the user is typing a new search.\n const current = popoverRef.current;\n if (\n meta !== undefined &&\n meta.close &&\n meta.id === dispatchSeq.current &&\n current.openGeneration() === meta.generation &&\n (meta.text === undefined || textRef.current === meta.text)\n ) {\n current.requestClose(details.event, \"activate\");\n }\n };\n\n const selection = useControllableAction<string | null, ComboboxValueChangeDetails>({\n controlled: value,\n defaultValue,\n initialValue: null,\n action: runValueAction,\n transitionTypes: () => VALUE_TRANSITION_TYPES,\n warn: { component: \"Combobox.Root\", prop: \"value\" },\n });\n // Read by `runValueAction` above, which only runs after a commit.\n const committedRef = useLatest(selection.committed);\n\n /** The next change of the optimistic selection comes from the user (a dispatch). */\n const userEdit = useRef(false);\n const dispatchValue = (\n next: string | null,\n event: Event | undefined,\n fields: { reason: ChangeReason; custom: boolean },\n options: { close: boolean; text: string | undefined },\n ): void => {\n const details = createActionDetails(event, fields);\n const dispatchId = ++dispatchSeq.current;\n dispatchMeta.set(details, {\n id: dispatchId,\n generation: popover.openGeneration(),\n close: options.close,\n text: options.text,\n });\n textRecord.current =\n options.text === undefined\n ? null\n : { id: dispatchId, value: next, text: options.text, settled: false };\n if (next !== selection.optimistic) userEdit.current = true;\n selection.dispatch(next, details);\n };\n\n // Inside a Field: React writes the hidden input with no `input` / `change` event, so the Field\n // is told after the commit (its `validate` reads the hidden input; a user's pick dismisses a\n // shown server error like typing would).\n useFieldValueChange(selection.optimistic, () => {\n const edit = userEdit.current;\n userEdit.current = false;\n return edit;\n });\n\n // --- Option registry and the active option (design 2, 6.5) --------------------------------\n\n const {\n registry,\n optionCount,\n statusCount,\n statusCountRef,\n labelCount,\n registerOption,\n registerStatus,\n registerLabel,\n orderedOptions,\n } = useOptionRegistry(labels);\n\n const [activeValue, setActiveValue] = useState<string | null>(null);\n const activeRef = useRef<string | null>(null);\n const setActive = useCallback((next: string | null) => {\n activeRef.current = next;\n setActiveValue(next);\n }, []);\n // The edge to activate once the open has options (ArrowDown / ArrowUp while closed).\n const pendingEdge = useRef<\"first\" | \"last\" | null>(null);\n // `autoHighlight` (APG automatic selection) highlights once per open and once per edit, when\n // the results for it settle. Home / End / Left / Right clear the active option without\n // re-arming it, so the caret keys really return visual focus to the input.\n const autoArmed = useRef(true);\n\n // A Status inside the List is a Suspense fallback: the results are loading (design 6.3).\n const loading = statusCount > 0;\n const empty = optionCount === 0 && !stale && !loading;\n\n // Revalidation (design 6.5): urgent, in a layout effect after every commit; never dispatches.\n useLayoutEffect(() => {\n const current = activeRef.current;\n if (!popover.committed) {\n // Keep the edge of an open that is on its way (the optimistic commit comes first).\n if (!popover.intended()) pendingEdge.current = null;\n autoArmed.current = true;\n if (current !== null) setActive(null);\n return;\n }\n const enabled = orderedOptions().filter((option) => !option.disabled);\n let next = current;\n if (pendingEdge.current !== null && enabled.length > 0) {\n next = (pendingEdge.current === \"first\" ? enabled[0] : enabled.at(-1))!.value;\n pendingEdge.current = null;\n } else if (next !== null && !enabled.some((option) => option.value === next)) {\n next = null;\n }\n if (next !== null) {\n // Something is active (keys, hover): nothing to highlight for these results.\n autoArmed.current = false;\n } else if (autoHighlight && autoArmed.current && !stale && enabled.length > 0) {\n // Only settled results: a stale list's first option is never auto-highlighted, so a fast\n // Enter commits the typed text or does nothing (design 6.5).\n next = enabled[0]!.value;\n autoArmed.current = false;\n }\n if (next !== current) setActive(next);\n });\n\n // The selection did not land (a controlled parent refused it, or the caught-inside variant of\n // a controlled parent): the text goes back to the committed value's label (design 2.2).\n // Labels for values set from outside are learnt from the text the consumer passed with them.\n const prevCommitted = useRef(selection.committed);\n useLayoutEffect(() => {\n const record = textRecord.current;\n if (\n record !== null &&\n record.settled &&\n !selection.pending &&\n selection.latestInFlight() === null\n ) {\n textRecord.current = null;\n if (selection.committed !== record.value && textRef.current === record.text) {\n writeText(labelFor(selection.committed), \"dismiss\", undefined);\n }\n }\n if (prevCommitted.current !== selection.committed) {\n prevCommitted.current = selection.committed;\n const committed = selection.committed;\n if (committed !== null && textRecord.current === null && !labels.has(committed)) {\n labels.set(committed, textRef.current);\n }\n }\n });\n\n // --- Announcements (design 6.4) -----------------------------------------------------------\n\n const state: ComboboxRootState = {\n value: selection.optimistic,\n inputValue: text,\n query,\n stale,\n activeValue,\n open: popover.optimistic,\n pending: selection.pending || popover.pending,\n disabled,\n };\n\n const lastAnnounced = useRef<string | null>(null);\n useEffect(() => {\n if (!popover.committed) {\n lastAnnounced.current = null;\n return;\n }\n if (stale || statusCountRef.current > 0) return;\n // The registry, not `optionCount`: a commit's passive effects can run before the re-render\n // that the Options' registration scheduled.\n const count = registry.size;\n const key = `${count}\\u0000${query}`;\n if (lastAnnounced.current === key) return;\n lastAnnounced.current = key;\n const list = listRef.current;\n if (list === null || !canAnnounce(list)) return;\n const compose = propsRef.current.announce ?? defaultComboboxAnnouncement;\n const message = compose(count, state);\n if (message !== null) announce(list, message);\n });\n\n // --- Form: hidden input, reset, mount reconciliation (design 11.1, walkthroughs 10 and 11) ---\n\n useComboboxForm({\n value,\n defaultValue,\n inputValue: inputValueProp,\n defaultInputValue,\n inputRef,\n hiddenRef,\n textRef,\n writeText,\n optimistic: selection.optimistic,\n resetValue: (next, event) =>\n dispatchValue(\n next,\n event,\n { reason: \"platform\", custom: false },\n { close: false, text: undefined },\n ),\n });\n\n const [missingText] = useState(\n () =>\n (value ?? defaultValue ?? null) !== null &&\n inputValueProp === undefined &&\n defaultInputValue === undefined,\n );\n useDevWarning(\n missingText,\n isDev &&\n \"Combobox.Root: `value` / `defaultValue` is set but neither `inputValue` nor \" +\n \"`defaultInputValue` is: the input will show no text for the selection. The library never \" +\n \"derives the text from the value; pass the selected option's label as well.\",\n );\n\n // --- Interaction (design 5, 8) -------------------------------------------------------------\n\n const accept = (optionValue: string, event: Event): void => {\n if (disabled) return;\n const entry = registry.get(optionValue);\n if (entry === undefined || entry.disabled) return;\n const label = entry.label ?? (entry.element.textContent ?? \"\").trim();\n labels.set(optionValue, label);\n pendingEdge.current = null;\n if (activeRef.current !== optionValue) setActive(optionValue);\n writeText(label, \"activate\", event);\n // Re-accepting the selected option dispatches nothing and closes (conventions 2.3 item 8).\n if (optionValue === selection.optimistic) {\n popover.requestClose(event, \"activate\");\n return;\n }\n dispatchValue(\n optionValue,\n event,\n { reason: \"activate\", custom: false },\n { close: true, text: label },\n );\n };\n\n /** Free text as the value (design 5.3). Returns whether it dispatched. */\n const commitText = (event: Event, close: boolean): boolean => {\n const current = selection.optimistic;\n const typed = textRef.current;\n if (typed === labelFor(current)) return false;\n const next = typed === \"\" ? null : typed;\n if (next === current) return false;\n if (next !== null) labels.set(next, typed);\n dispatchValue(\n next,\n event,\n { reason: \"activate\", custom: next !== null },\n { close, text: typed },\n );\n return true;\n };\n\n const clear = (event: Event): void => {\n if (disabled) return;\n if (textRef.current !== \"\") writeText(\"\", \"activate\", event);\n if (selection.optimistic !== null) {\n dispatchValue(null, event, { reason: \"activate\", custom: false }, { close: false, text: \"\" });\n }\n inputRef.current?.focus();\n };\n\n const typed = (next: string, event: Event): void => {\n if (disabled) return;\n writeText(next, \"activate\", event);\n pendingEdge.current = null;\n // APG: editing moves visual focus back to the input; `autoHighlight` picks the first option\n // again once the results for the new text settle.\n if (activeRef.current !== null) setActive(null);\n autoArmed.current = true;\n popover.requestOpen(event, \"activate\");\n };\n\n const move = (direction: 1 | -1): void => {\n const enabled = orderedOptions().filter((option) => !option.disabled);\n if (enabled.length === 0) return;\n const last = enabled.length - 1;\n const index = enabled.findIndex((option) => option.value === activeRef.current);\n let next: number;\n if (direction === 1) next = index < 0 ? 0 : index >= last ? (loop ? 0 : last) : index + 1;\n else next = index < 0 ? last : index <= 0 ? (loop ? last : 0) : index - 1;\n const target = enabled[next]!;\n setActive(target.value);\n if (typeof target.element.scrollIntoView === \"function\") {\n target.element.scrollIntoView({ block: \"nearest\" });\n }\n };\n\n const activeEnabled = (): string | null => {\n const current = activeRef.current;\n if (current === null) return null;\n const entry = registry.get(current);\n return entry !== undefined && !entry.disabled ? current : null;\n };\n\n const keyDown = (event: KeyboardEvent): boolean => {\n if (disabled || event.ctrlKey || event.metaKey) return false;\n // IME: the key belongs to the composition (Enter commits it, arrows pick a candidate).\n if (event.isComposing || event.keyCode === 229) return false;\n // What the user sees, not what is intended: right after Escape the platform has hidden the\n // popup but its `toggle` (and the library's notification) is still queued, and an open that\n // is still committing shows nothing yet. Enter must submit and arrows must open in both.\n const isOpen = isPopoverOpen(popover.popupRef.current);\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n if (event.altKey) {\n if (!isOpen) popover.requestOpen(event, \"activate\");\n } else if (!isOpen) {\n pendingEdge.current = \"first\";\n popover.requestOpen(event, \"activate\");\n } else {\n move(1);\n }\n return true;\n case \"ArrowUp\":\n event.preventDefault();\n if (event.altKey) {\n if (isOpen) {\n const active = activeEnabled();\n if (active !== null) accept(active, event);\n else popover.requestClose(event, \"activate\");\n }\n } else if (!isOpen) {\n pendingEdge.current = \"last\";\n popover.requestOpen(event, \"activate\");\n } else {\n move(-1);\n }\n return true;\n case \"Enter\": {\n if (isOpen) {\n // An open listbox means the user is choosing: never submit from here.\n event.preventDefault();\n const active = activeEnabled();\n if (active !== null) accept(active, event);\n else if (allowCustomValue && !commitText(event, true)) {\n popover.requestClose(event, \"activate\");\n }\n return true;\n }\n // Closed: not prevented, so a form still submits. The key's default action (implicit\n // submission) must see the optimistic hidden value: Firefox submits before React's\n // scheduled flush of the optimistic render, so it is flushed here (design 5.3).\n if (allowCustomValue) flushSync(() => commitText(event, false));\n return false;\n }\n case \"Home\":\n case \"End\":\n case \"ArrowLeft\":\n case \"ArrowRight\":\n // APG: the caret keys move visual focus to the input (not prevented: the caret moves).\n if (activeRef.current !== null) setActive(null);\n return false;\n default:\n return false;\n }\n };\n\n /** Focus has left the input and the popup (design 5.4). */\n const leave = (event: Event): void => {\n // `disabled`: nothing dispatches (disabling a focused input blurs it).\n if (disabled) return;\n const popup = popover.popupRef.current;\n if (popup !== null && isPopoverOpen(popup)) {\n popover.recordCloseIntent({ reason: \"dismiss\", event });\n popup.hidePopover();\n }\n pendingEdge.current = null;\n if (allowCustomValue) {\n commitText(event, false);\n return;\n }\n const label = labelFor(selection.optimistic);\n if (textRef.current !== label) writeText(label, \"dismiss\", event);\n };\n const { focusIn, focusOut } = useDeferredLeave({\n inputRef,\n popupRef: popover.popupRef,\n leave,\n });\n\n const inputClick = (event: MouseEvent): void => {\n if (disabled || !openOnClick) return;\n popover.requestOpen(event, \"activate\");\n };\n\n // A press on the field while the listbox is shown: `source` is no light-dismiss exemption, so\n // the release goes to the Popup, whose topmost clicked popover is the listbox itself (design\n // 5.4). Judged on `:popover-open`, not the intent: a press during a pending close must\n // not dismiss either. Primary button only (a right click keeps the field's own context menu).\n // The engine releases the capture after `pointerup`; the press tracking above still sees\n // the release on the document.\n const inputPointerDown = (event: PointerEvent): void => {\n if (disabled || event.button !== 0) return;\n const popup = popover.popupRef.current;\n if (popup !== null && isPopoverOpen(popup)) capturePointer(popup, event.pointerId);\n };\n\n const context: ComboboxContextValue = {\n popover,\n ids,\n value: selection.optimistic,\n valuePending: selection.pending,\n pending: state.pending,\n inputValue: text,\n query,\n stale,\n activeValue,\n empty,\n loading,\n hasLabel: labelCount > 0,\n fieldLabelId: field?.ids.label,\n disabled,\n inputRef,\n listRef,\n registerOption,\n registerStatus,\n registerLabel,\n setActive,\n accept,\n clear,\n typed,\n keyDown,\n focusIn,\n focusOut,\n inputClick,\n inputPointerDown,\n };\n\n return (\n <ComboboxContext value={context}>\n {name !== undefined && (\n <input\n ref={hiddenRef}\n type=\"hidden\"\n name={name}\n form={form}\n value={selection.optimistic ?? \"\"}\n />\n )}\n {resolveStateValue(children, state)}\n </ComboboxContext>\n );\n}\n\nComboboxRoot.displayName = \"ComboboxRoot\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2MA,SAAS,4BAA4B,OAAuB;CAC1D,IAAI,UAAU,GAAG,OAAO;CACxB,IAAI,UAAU,GAAG,OAAO;CACxB,OAAO,GAAG,MAAM;AAClB;AAEA,MAAM,yBAAyB,gBAAgB,YAAY,QAAQ;AAEnE,MAAM,QAAQ,QAAQ,IAAI,aAAa;A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A,OACE,qBAAC,iBAAD;EAAiB,OAAO;EAAxB,UAAA,CACG,SAAS,KAAA,KACR,oBAAC,SAAD;GACE,KAAK;GACL,MAAK;GACC;GACA;GACN,OAAO,UAAU,cAAc;EAChC,CAAA,GAEF,kBAAkB,UAAU,KAAK,CACnB;;AAErB;AAEA,aAAa,cAAc"}
@@ -1,20 +1,34 @@
1
1
  import { RenderProp, StateValue } from "../internal/types.mjs";
2
2
  import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
3
3
  //#region src/combobox/combobox-trigger.d.ts
4
+ /**
5
+ * State of `Combobox.Trigger`, passed to the function forms of `className`, `style`, `children` and
6
+ * `render`.
7
+ */
4
8
  export interface ComboboxTriggerState {
5
9
  /** Optimistic open state. */
6
10
  readonly open: boolean;
7
11
  /** The open (or close) transition is in flight. */
8
12
  readonly pending: boolean;
13
+ /** Disabled by its own prop or by the Root. */
9
14
  readonly disabled: boolean;
10
15
  }
16
+ /**
17
+ * Props of `Combobox.Trigger`.
18
+ *
19
+ * @see https://ui.funstack.work/components/combobox
20
+ */
11
21
  export interface ComboboxTriggerProps extends Omit<ComponentPropsWithRef<"button">, "onClick" | "onPointerDown" | "onMouseDown" | "tabIndex" | "aria-expanded" | "aria-controls" | "commandfor" | "command" | "popoverTarget" | "popoverTargetAction" | "disabled" | "className" | "style" | "children"> {
12
22
  /**
13
23
  * Disables this button; the Root's `disabled` does too. Native `disabled` on a `<button>`; with
14
24
  * a link or component `render`, `aria-disabled="true"` instead.
25
+ *
26
+ * @defaultValue `false`
15
27
  */
16
28
  disabled?: boolean;
29
+ /** Class name, or a function of the part's state that returns one. */
17
30
  className?: StateValue<string | undefined, ComboboxTriggerState>;
31
+ /** Inline style, or a function of the part's state that returns one. */
18
32
  style?: StateValue<CSSProperties | undefined, ComboboxTriggerState>;
19
33
  /** Rendered from optimistic state; must not suspend. */
20
34
  children?: StateValue<ReactNode, ComboboxTriggerState>;
@@ -27,16 +41,20 @@ export interface ComboboxTriggerProps extends Omit<ComponentPropsWithRef<"button
27
41
  * does not take focus from the input, and a click focuses the input. After hydration a `<button>`
28
42
  * also names the Popup as its invoker (`popovertarget`, written through the ref, never
29
43
  * server-rendered), so a press while the listbox is open is not a light dismiss and the click's
30
- * close is the only one (design 3.3, #112, #121), and the browser exposes the listbox's state on
31
- * it: a `<button>` renders no `aria-expanded`, another element renders it from the shown listbox.
32
- * Every click is cancelled, so the toggle never runs: the listbox stays anchored to the input
33
- * (design 1).
44
+ * close is the only one (design 3.3), and the browser exposes the listbox's state on it: an
45
+ * invoker renders no `aria-expanded`. A Trigger that is disabled and still focusable
46
+ * (`aria-disabled` on a component `render`) is no invoker, like any other overlay Trigger: a press
47
+ * on it while the listbox is shown is a light dismiss. A non-invoker renders `aria-expanded` from
48
+ * the shown listbox. Every click is cancelled, so the toggle never runs: the listbox stays
49
+ * anchored to the input (design 1).
34
50
  *
35
51
  * Owned keys: `type` (on a `<button>`), `tabIndex`, `disabled`, `aria-disabled` (link or
36
- * component `render`), `aria-expanded`, `aria-controls` (token-merged), `popovertarget`,
37
- * `onClick`, `onPointerDown`, `onMouseDown`, `data-open`, `data-pending`, `data-disabled`;
38
- * `popoverTarget`, `popoverTargetAction`, `commandfor` and `command` (never written as props;
39
- * omitted from the props type).
52
+ * component `render`), `aria-expanded`, `aria-controls` (token-merged), `popovertarget` (while an
53
+ * invoker), `onClick`, `onPointerDown`, `onMouseDown`, `data-open`, `data-pending`,
54
+ * `data-disabled`; `popoverTarget`, `popoverTargetAction`, `commandfor` and `command` (never
55
+ * written as props; omitted from the props type).
56
+ *
57
+ * @see https://ui.funstack.work/components/combobox
40
58
  */
41
59
  export declare function ComboboxTrigger({ disabled: ownDisabled, className, style, children, render, ...rest }: ComboboxTriggerProps): ReactNode;
42
60
  export declare namespace ComboboxTrigger {