@funstack/ui 0.1.0-alpha.11 → 0.1.0-alpha.13

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 (416) hide show
  1. package/dist/accordion/accordion-context.mjs.map +1 -1
  2. package/dist/accordion/accordion-item.d.mts +3 -4
  3. package/dist/accordion/accordion-item.d.mts.map +1 -1
  4. package/dist/accordion/accordion-item.mjs +10 -4
  5. package/dist/accordion/accordion-item.mjs.map +1 -1
  6. package/dist/accordion/accordion-panel.d.mts +3 -4
  7. package/dist/accordion/accordion-panel.d.mts.map +1 -1
  8. package/dist/accordion/accordion-panel.mjs +2 -1
  9. package/dist/accordion/accordion-panel.mjs.map +1 -1
  10. package/dist/accordion/accordion-root.d.mts +3 -3
  11. package/dist/accordion/accordion-root.d.mts.map +1 -1
  12. package/dist/accordion/accordion-root.mjs +8 -19
  13. package/dist/accordion/accordion-root.mjs.map +1 -1
  14. package/dist/accordion/accordion-trigger.d.mts +3 -4
  15. package/dist/accordion/accordion-trigger.d.mts.map +1 -1
  16. package/dist/accordion/accordion-trigger.mjs +5 -3
  17. package/dist/accordion/accordion-trigger.mjs.map +1 -1
  18. package/dist/button/button.d.mts +4 -2
  19. package/dist/button/button.d.mts.map +1 -1
  20. package/dist/button/button.mjs +3 -2
  21. package/dist/button/button.mjs.map +1 -1
  22. package/dist/checkbox/checkbox.d.mts +4 -5
  23. package/dist/checkbox/checkbox.d.mts.map +1 -1
  24. package/dist/checkbox/checkbox.mjs +16 -59
  25. package/dist/checkbox/checkbox.mjs.map +1 -1
  26. package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
  27. package/dist/checkbox-group/checkbox-group-item.d.mts +3 -4
  28. package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
  29. package/dist/checkbox-group/checkbox-group-item.mjs +21 -27
  30. package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
  31. package/dist/checkbox-group/checkbox-group-label.mjs +1 -6
  32. package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
  33. package/dist/checkbox-group/checkbox-group-parent.d.mts +3 -4
  34. package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
  35. package/dist/checkbox-group/checkbox-group-parent.mjs +12 -10
  36. package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
  37. package/dist/checkbox-group/checkbox-group-root.d.mts +1 -1
  38. package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
  39. package/dist/checkbox-group/checkbox-group-root.mjs +74 -101
  40. package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
  41. package/dist/combobox/combobox-clear.d.mts.map +1 -1
  42. package/dist/combobox/combobox-clear.mjs +5 -6
  43. package/dist/combobox/combobox-clear.mjs.map +1 -1
  44. package/dist/combobox/combobox-context.mjs.map +1 -1
  45. package/dist/combobox/combobox-group.d.mts.map +1 -1
  46. package/dist/combobox/combobox-group.mjs +2 -1
  47. package/dist/combobox/combobox-group.mjs.map +1 -1
  48. package/dist/combobox/combobox-input.d.mts +6 -5
  49. package/dist/combobox/combobox-input.d.mts.map +1 -1
  50. package/dist/combobox/combobox-input.mjs +29 -14
  51. package/dist/combobox/combobox-input.mjs.map +1 -1
  52. package/dist/combobox/combobox-list.d.mts.map +1 -1
  53. package/dist/combobox/combobox-list.mjs +6 -10
  54. package/dist/combobox/combobox-list.mjs.map +1 -1
  55. package/dist/combobox/combobox-option.d.mts.map +1 -1
  56. package/dist/combobox/combobox-option.mjs +2 -1
  57. package/dist/combobox/combobox-option.mjs.map +1 -1
  58. package/dist/combobox/combobox-popup.d.mts.map +1 -1
  59. package/dist/combobox/combobox-popup.mjs +9 -25
  60. package/dist/combobox/combobox-popup.mjs.map +1 -1
  61. package/dist/combobox/combobox-root.d.mts.map +1 -1
  62. package/dist/combobox/combobox-root.mjs +101 -106
  63. package/dist/combobox/combobox-root.mjs.map +1 -1
  64. package/dist/combobox/combobox-trigger.d.mts +9 -6
  65. package/dist/combobox/combobox-trigger.d.mts.map +1 -1
  66. package/dist/combobox/combobox-trigger.mjs +36 -43
  67. package/dist/combobox/combobox-trigger.mjs.map +1 -1
  68. package/dist/combobox/index.mjs +1 -1
  69. package/dist/combobox/use-combobox-form.mjs +56 -0
  70. package/dist/combobox/use-combobox-form.mjs.map +1 -0
  71. package/dist/combobox/use-option-registry.mjs +62 -0
  72. package/dist/combobox/use-option-registry.mjs.map +1 -0
  73. package/dist/dialog/dialog-close.d.mts.map +1 -1
  74. package/dist/dialog/dialog-close.mjs +29 -62
  75. package/dist/dialog/dialog-close.mjs.map +1 -1
  76. package/dist/dialog/dialog-context.mjs.map +1 -1
  77. package/dist/dialog/dialog-form.d.mts.map +1 -1
  78. package/dist/dialog/dialog-form.mjs +5 -4
  79. package/dist/dialog/dialog-form.mjs.map +1 -1
  80. package/dist/dialog/dialog-popup.d.mts +5 -5
  81. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  82. package/dist/dialog/dialog-popup.mjs +39 -103
  83. package/dist/dialog/dialog-popup.mjs.map +1 -1
  84. package/dist/dialog/dialog-root.d.mts.map +1 -1
  85. package/dist/dialog/dialog-root.mjs +30 -118
  86. package/dist/dialog/dialog-root.mjs.map +1 -1
  87. package/dist/dialog/dialog-trigger.d.mts +2 -1
  88. package/dist/dialog/dialog-trigger.d.mts.map +1 -1
  89. package/dist/dialog/dialog-trigger.mjs +27 -23
  90. package/dist/dialog/dialog-trigger.mjs.map +1 -1
  91. package/dist/field/field-control.mjs +6 -13
  92. package/dist/field/field-control.mjs.map +1 -1
  93. package/dist/field/field-description.d.mts.map +1 -1
  94. package/dist/field/field-description.mjs +1 -2
  95. package/dist/field/field-description.mjs.map +1 -1
  96. package/dist/field/field-error.d.mts.map +1 -1
  97. package/dist/field/field-error.mjs +1 -2
  98. package/dist/field/field-error.mjs.map +1 -1
  99. package/dist/field/field-label.d.mts.map +1 -1
  100. package/dist/field/field-label.mjs +3 -11
  101. package/dist/field/field-label.mjs.map +1 -1
  102. package/dist/field/field-root.mjs +22 -42
  103. package/dist/field/field-root.mjs.map +1 -1
  104. package/dist/field/index.mjs +1 -1
  105. package/dist/field/use-server-error-visibility.mjs +44 -0
  106. package/dist/field/use-server-error-visibility.mjs.map +1 -0
  107. package/dist/form/form-root.d.mts.map +1 -1
  108. package/dist/form/form-root.mjs +6 -7
  109. package/dist/form/form-root.mjs.map +1 -1
  110. package/dist/form/form-submit.d.mts +1 -1
  111. package/dist/form/form-submit.mjs +4 -10
  112. package/dist/form/form-submit.mjs.map +1 -1
  113. package/dist/index.d.mts +2 -2
  114. package/dist/internal/anchor-position.mjs +1 -59
  115. package/dist/internal/anchor-position.mjs.map +1 -1
  116. package/dist/internal/announce.mjs +4 -42
  117. package/dist/internal/announce.mjs.map +1 -1
  118. package/dist/internal/arrow-keys.mjs +21 -0
  119. package/dist/internal/arrow-keys.mjs.map +1 -0
  120. package/dist/internal/decimal.mjs +7 -1
  121. package/dist/internal/decimal.mjs.map +1 -1
  122. package/dist/internal/dom-order.mjs +17 -0
  123. package/dist/internal/dom-order.mjs.map +1 -0
  124. package/dist/internal/field-context.d.mts.map +1 -1
  125. package/dist/internal/field-context.mjs +11 -1
  126. package/dist/internal/field-context.mjs.map +1 -1
  127. package/dist/internal/focus-first-invalid.mjs +16 -7
  128. package/dist/internal/focus-first-invalid.mjs.map +1 -1
  129. package/dist/internal/group-member.mjs +37 -0
  130. package/dist/internal/group-member.mjs.map +1 -0
  131. package/dist/internal/overlay-popup.mjs +103 -0
  132. package/dist/internal/overlay-popup.mjs.map +1 -0
  133. package/dist/internal/pointer-capture.mjs +20 -0
  134. package/dist/internal/pointer-capture.mjs.map +1 -0
  135. package/dist/internal/popover-open.mjs +18 -0
  136. package/dist/internal/popover-open.mjs.map +1 -0
  137. package/dist/internal/render-element.d.mts +2 -0
  138. package/dist/internal/render-element.mjs +20 -2
  139. package/dist/internal/render-element.mjs.map +1 -1
  140. package/dist/internal/shipped-styles.mjs +14 -0
  141. package/dist/internal/shipped-styles.mjs.map +1 -0
  142. package/dist/internal/sync-presence.mjs +5 -1
  143. package/dist/internal/sync-presence.mjs.map +1 -1
  144. package/dist/internal/toolbar-context.mjs.map +1 -1
  145. package/dist/internal/tooltip-warm.mjs +1 -1
  146. package/dist/internal/tooltip-warm.mjs.map +1 -1
  147. package/dist/internal/transition-boundary.mjs +1 -1
  148. package/dist/internal/transition-boundary.mjs.map +1 -1
  149. package/dist/internal/trigger-ref.mjs +26 -0
  150. package/dist/internal/trigger-ref.mjs.map +1 -0
  151. package/dist/internal/types.d.mts +2 -0
  152. package/dist/internal/types.d.mts.map +1 -1
  153. package/dist/internal/use-action-trigger.mjs +5 -23
  154. package/dist/internal/use-action-trigger.mjs.map +1 -1
  155. package/dist/internal/use-checkable-input.mjs +79 -0
  156. package/dist/internal/use-checkable-input.mjs.map +1 -0
  157. package/dist/internal/use-controllable-action.mjs +16 -24
  158. package/dist/internal/use-controllable-action.mjs.map +1 -1
  159. package/dist/internal/use-dev-warning.mjs +8 -4
  160. package/dist/internal/use-dev-warning.mjs.map +1 -1
  161. package/dist/internal/use-element-check.mjs +39 -0
  162. package/dist/internal/use-element-check.mjs.map +1 -0
  163. package/dist/internal/use-exit-animation.mjs +1 -1
  164. package/dist/internal/use-exit-animation.mjs.map +1 -1
  165. package/dist/internal/use-field-control.mjs +28 -12
  166. package/dist/internal/use-field-control.mjs.map +1 -1
  167. package/dist/internal/use-fieldset-group.mjs +46 -0
  168. package/dist/internal/use-fieldset-group.mjs.map +1 -0
  169. package/dist/internal/use-form-reset.mjs +1 -5
  170. package/dist/internal/use-form-reset.mjs.map +1 -1
  171. package/dist/internal/use-item-order.mjs +42 -0
  172. package/dist/internal/use-item-order.mjs.map +1 -0
  173. package/dist/internal/use-latest.mjs +4 -8
  174. package/dist/internal/use-latest.mjs.map +1 -1
  175. package/dist/internal/use-merged-refs.mjs +19 -0
  176. package/dist/internal/use-merged-refs.mjs.map +1 -0
  177. package/dist/internal/use-name-warning.mjs +84 -0
  178. package/dist/internal/use-name-warning.mjs.map +1 -0
  179. package/dist/internal/use-native-checked.mjs +4 -6
  180. package/dist/internal/use-native-checked.mjs.map +1 -1
  181. package/dist/internal/use-native-focusgroup.mjs +19 -0
  182. package/dist/internal/use-native-focusgroup.mjs.map +1 -0
  183. package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
  184. package/dist/internal/use-overlay-close.mjs +63 -0
  185. package/dist/internal/use-overlay-close.mjs.map +1 -0
  186. package/dist/internal/{use-popover-root.mjs → use-overlay-root.mjs} +32 -39
  187. package/dist/internal/use-overlay-root.mjs.map +1 -0
  188. package/dist/internal/use-popover-popup.mjs +38 -80
  189. package/dist/internal/use-popover-popup.mjs.map +1 -1
  190. package/dist/internal/use-popover-trigger.d.mts +15 -0
  191. package/dist/internal/use-popover-trigger.d.mts.map +1 -0
  192. package/dist/internal/use-popover-trigger.mjs +28 -24
  193. package/dist/internal/use-popover-trigger.mjs.map +1 -1
  194. package/dist/internal/use-register-count.mjs +24 -0
  195. package/dist/internal/use-register-count.mjs.map +1 -0
  196. package/dist/internal/use-render.d.mts +2 -0
  197. package/dist/internal/use-render.mjs +2 -2
  198. package/dist/internal/use-render.mjs.map +1 -1
  199. package/dist/internal/use-resolved-placement.mjs +38 -22
  200. package/dist/internal/use-resolved-placement.mjs.map +1 -1
  201. package/dist/internal/use-roving-focus.mjs +5 -18
  202. package/dist/internal/use-roving-focus.mjs.map +1 -1
  203. package/dist/internal/use-superseded-rejection.mjs +47 -0
  204. package/dist/internal/use-superseded-rejection.mjs.map +1 -0
  205. package/dist/internal/validity.mjs +1 -13
  206. package/dist/internal/validity.mjs.map +1 -1
  207. package/dist/internal/value-set.mjs +41 -0
  208. package/dist/internal/value-set.mjs.map +1 -0
  209. package/dist/menu/index.d.mts +1 -1
  210. package/dist/menu/menu-checkbox-item.mjs.map +1 -1
  211. package/dist/menu/menu-context-trigger.d.mts +2 -7
  212. package/dist/menu/menu-context-trigger.d.mts.map +1 -1
  213. package/dist/menu/menu-context-trigger.mjs +11 -187
  214. package/dist/menu/menu-context-trigger.mjs.map +1 -1
  215. package/dist/menu/menu-context.d.mts +1 -1
  216. package/dist/menu/menu-context.mjs +1 -1
  217. package/dist/menu/menu-context.mjs.map +1 -1
  218. package/dist/menu/menu-dom.mjs +2 -17
  219. package/dist/menu/menu-dom.mjs.map +1 -1
  220. package/dist/menu/menu-gestures.mjs +166 -0
  221. package/dist/menu/menu-gestures.mjs.map +1 -0
  222. package/dist/menu/menu-group.d.mts.map +1 -1
  223. package/dist/menu/menu-group.mjs +2 -1
  224. package/dist/menu/menu-group.mjs.map +1 -1
  225. package/dist/menu/menu-hover.mjs +0 -1
  226. package/dist/menu/menu-hover.mjs.map +1 -1
  227. package/dist/menu/menu-item.mjs.map +1 -1
  228. package/dist/menu/menu-outside.mjs +101 -0
  229. package/dist/menu/menu-outside.mjs.map +1 -0
  230. package/dist/menu/menu-point.mjs +85 -0
  231. package/dist/menu/menu-point.mjs.map +1 -0
  232. package/dist/menu/menu-popup.d.mts +6 -7
  233. package/dist/menu/menu-popup.d.mts.map +1 -1
  234. package/dist/menu/menu-popup.mjs +38 -248
  235. package/dist/menu/menu-popup.mjs.map +1 -1
  236. package/dist/menu/menu-radio-group.mjs.map +1 -1
  237. package/dist/menu/menu-radio-item.d.mts +2 -0
  238. package/dist/menu/menu-radio-item.d.mts.map +1 -1
  239. package/dist/menu/menu-radio-item.mjs +1 -0
  240. package/dist/menu/menu-radio-item.mjs.map +1 -1
  241. package/dist/menu/menu-root.d.mts +10 -0
  242. package/dist/menu/menu-root.d.mts.map +1 -1
  243. package/dist/menu/menu-root.mjs +10 -8
  244. package/dist/menu/menu-root.mjs.map +1 -1
  245. package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
  246. package/dist/menu/menu-submenu-trigger.mjs +12 -9
  247. package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
  248. package/dist/menu/menu-trigger.d.mts +10 -11
  249. package/dist/menu/menu-trigger.d.mts.map +1 -1
  250. package/dist/menu/menu-trigger.mjs +14 -7
  251. package/dist/menu/menu-trigger.mjs.map +1 -1
  252. package/dist/menu/use-menu-item.mjs +14 -16
  253. package/dist/menu/use-menu-item.mjs.map +1 -1
  254. package/dist/menu/use-menu-keyboard.mjs +88 -0
  255. package/dist/menu/use-menu-keyboard.mjs.map +1 -0
  256. package/dist/meter/meter-root.mjs +1 -1
  257. package/dist/number-field/index.d.mts +2 -1
  258. package/dist/number-field/index.d.mts.map +1 -1
  259. package/dist/number-field/index.mjs +2 -2
  260. package/dist/number-field/index.mjs.map +1 -1
  261. package/dist/number-field/number-field-arithmetic.mjs +30 -11
  262. package/dist/number-field/number-field-arithmetic.mjs.map +1 -1
  263. package/dist/number-field/number-field-context.d.mts +6 -1
  264. package/dist/number-field/number-field-context.d.mts.map +1 -0
  265. package/dist/number-field/number-field-context.mjs.map +1 -1
  266. package/dist/number-field/number-field-decrement.d.mts +1 -1
  267. package/dist/number-field/number-field-decrement.mjs +1 -1
  268. package/dist/number-field/number-field-decrement.mjs.map +1 -1
  269. package/dist/number-field/number-field-increment.d.mts +2 -22
  270. package/dist/number-field/number-field-increment.d.mts.map +1 -1
  271. package/dist/number-field/number-field-increment.mjs +2 -53
  272. package/dist/number-field/number-field-increment.mjs.map +1 -1
  273. package/dist/number-field/number-field-input.d.mts.map +1 -1
  274. package/dist/number-field/number-field-input.mjs +18 -22
  275. package/dist/number-field/number-field-input.mjs.map +1 -1
  276. package/dist/number-field/number-field-label.d.mts.map +1 -1
  277. package/dist/number-field/number-field-label.mjs +3 -9
  278. package/dist/number-field/number-field-label.mjs.map +1 -1
  279. package/dist/number-field/number-field-root.d.mts +3 -2
  280. package/dist/number-field/number-field-root.d.mts.map +1 -1
  281. package/dist/number-field/number-field-root.mjs +81 -91
  282. package/dist/number-field/number-field-root.mjs.map +1 -1
  283. package/dist/number-field/use-number-field-dev-warnings.mjs +28 -0
  284. package/dist/number-field/use-number-field-dev-warnings.mjs.map +1 -0
  285. package/dist/number-field/use-step-button.d.mts +24 -0
  286. package/dist/number-field/use-step-button.d.mts.map +1 -0
  287. package/dist/number-field/use-step-button.mjs +57 -3
  288. package/dist/number-field/use-step-button.mjs.map +1 -1
  289. package/dist/popover/popover-close.d.mts.map +1 -1
  290. package/dist/popover/popover-close.mjs +28 -67
  291. package/dist/popover/popover-close.mjs.map +1 -1
  292. package/dist/popover/popover-context.mjs.map +1 -1
  293. package/dist/popover/popover-popup.d.mts +9 -6
  294. package/dist/popover/popover-popup.d.mts.map +1 -1
  295. package/dist/popover/popover-popup.mjs +13 -36
  296. package/dist/popover/popover-popup.mjs.map +1 -1
  297. package/dist/popover/popover-root.mjs +4 -3
  298. package/dist/popover/popover-root.mjs.map +1 -1
  299. package/dist/popover/popover-trigger.d.mts +10 -10
  300. package/dist/popover/popover-trigger.d.mts.map +1 -1
  301. package/dist/popover/popover-trigger.mjs +4 -2
  302. package/dist/popover/popover-trigger.mjs.map +1 -1
  303. package/dist/progress/progress-root.mjs +1 -1
  304. package/dist/radio-group/radio-group-context.mjs.map +1 -1
  305. package/dist/radio-group/radio-group-item.d.mts +3 -4
  306. package/dist/radio-group/radio-group-item.d.mts.map +1 -1
  307. package/dist/radio-group/radio-group-item.mjs +20 -25
  308. package/dist/radio-group/radio-group-item.mjs.map +1 -1
  309. package/dist/radio-group/radio-group-label.mjs +1 -6
  310. package/dist/radio-group/radio-group-label.mjs.map +1 -1
  311. package/dist/radio-group/radio-group-root.d.mts +1 -1
  312. package/dist/radio-group/radio-group-root.d.mts.map +1 -1
  313. package/dist/radio-group/radio-group-root.mjs +21 -40
  314. package/dist/radio-group/radio-group-root.mjs.map +1 -1
  315. package/dist/select/select-dom.mjs +9 -18
  316. package/dist/select/select-dom.mjs.map +1 -1
  317. package/dist/select/select-option.mjs +1 -1
  318. package/dist/select/select-root.mjs +3 -2
  319. package/dist/select/select-root.mjs.map +1 -1
  320. package/dist/slider/slider-arithmetic.mjs +74 -13
  321. package/dist/slider/slider-arithmetic.mjs.map +1 -1
  322. package/dist/slider/slider-context.mjs.map +1 -1
  323. package/dist/slider/slider-label.d.mts.map +1 -1
  324. package/dist/slider/slider-label.mjs +3 -9
  325. package/dist/slider/slider-label.mjs.map +1 -1
  326. package/dist/slider/slider-root.d.mts +2 -2
  327. package/dist/slider/slider-root.d.mts.map +1 -1
  328. package/dist/slider/slider-root.mjs +36 -116
  329. package/dist/slider/slider-root.mjs.map +1 -1
  330. package/dist/slider/slider-thumb.d.mts.map +1 -1
  331. package/dist/slider/slider-thumb.mjs +8 -6
  332. package/dist/slider/slider-thumb.mjs.map +1 -1
  333. package/dist/slider/slider-value.d.mts.map +1 -1
  334. package/dist/slider/slider-value.mjs +2 -1
  335. package/dist/slider/slider-value.mjs.map +1 -1
  336. package/dist/slider/use-slider-dev-warnings.mjs +29 -0
  337. package/dist/slider/use-slider-dev-warnings.mjs.map +1 -0
  338. package/dist/slider/use-thumb-registry.mjs +51 -0
  339. package/dist/slider/use-thumb-registry.mjs.map +1 -0
  340. package/dist/switch/switch.d.mts +4 -5
  341. package/dist/switch/switch.d.mts.map +1 -1
  342. package/dist/switch/switch.mjs +15 -55
  343. package/dist/switch/switch.mjs.map +1 -1
  344. package/dist/tabs/tabs-context.d.mts +2 -3
  345. package/dist/tabs/tabs-context.d.mts.map +1 -1
  346. package/dist/tabs/tabs-context.mjs.map +1 -1
  347. package/dist/tabs/tabs-list.d.mts.map +1 -1
  348. package/dist/tabs/tabs-list.mjs +9 -22
  349. package/dist/tabs/tabs-list.mjs.map +1 -1
  350. package/dist/tabs/tabs-panel.d.mts +3 -4
  351. package/dist/tabs/tabs-panel.d.mts.map +1 -1
  352. package/dist/tabs/tabs-panel.mjs.map +1 -1
  353. package/dist/tabs/tabs-root.d.mts +4 -3
  354. package/dist/tabs/tabs-root.d.mts.map +1 -1
  355. package/dist/tabs/tabs-root.mjs +2 -1
  356. package/dist/tabs/tabs-root.mjs.map +1 -1
  357. package/dist/tabs/tabs-tab.d.mts +3 -4
  358. package/dist/tabs/tabs-tab.d.mts.map +1 -1
  359. package/dist/tabs/tabs-tab.mjs.map +1 -1
  360. package/dist/toast/toast-action.mjs.map +1 -1
  361. package/dist/toast/toast-close.d.mts.map +1 -1
  362. package/dist/toast/toast-close.mjs +2 -8
  363. package/dist/toast/toast-close.mjs.map +1 -1
  364. package/dist/toast/toast-context.mjs.map +1 -1
  365. package/dist/toast/toast-hotkey.mjs +27 -0
  366. package/dist/toast/toast-hotkey.mjs.map +1 -0
  367. package/dist/toast/toast-queue.mjs +137 -0
  368. package/dist/toast/toast-queue.mjs.map +1 -0
  369. package/dist/toast/toast-root.d.mts.map +1 -1
  370. package/dist/toast/toast-root.mjs +2 -0
  371. package/dist/toast/toast-root.mjs.map +1 -1
  372. package/dist/toast/toast-timers.mjs +65 -0
  373. package/dist/toast/toast-timers.mjs.map +1 -0
  374. package/dist/toast/toast-viewport.d.mts.map +1 -1
  375. package/dist/toast/toast-viewport.mjs +30 -235
  376. package/dist/toast/toast-viewport.mjs.map +1 -1
  377. package/dist/toast/toast.mjs +1 -1
  378. package/dist/toast/toast.mjs.map +1 -1
  379. package/dist/toast/use-modal-portal-host.mjs +52 -0
  380. package/dist/toast/use-modal-portal-host.mjs.map +1 -0
  381. package/dist/toggle/toggle.d.mts +3 -4
  382. package/dist/toggle/toggle.d.mts.map +1 -1
  383. package/dist/toggle/toggle.mjs +7 -10
  384. package/dist/toggle/toggle.mjs.map +1 -1
  385. package/dist/toggle-group/toggle-group-context.d.mts +2 -1
  386. package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
  387. package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
  388. package/dist/toggle-group/toggle-group-item.d.mts +7 -3
  389. package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
  390. package/dist/toggle-group/toggle-group-item.mjs +6 -7
  391. package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
  392. package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
  393. package/dist/toggle-group/toggle-group-root.mjs +29 -64
  394. package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
  395. package/dist/toolbar/toolbar-root.d.mts +2 -2
  396. package/dist/toolbar/toolbar-root.d.mts.map +1 -1
  397. package/dist/toolbar/toolbar-root.mjs +3 -4
  398. package/dist/toolbar/toolbar-root.mjs.map +1 -1
  399. package/dist/tooltip/tooltip-context.d.mts +1 -1
  400. package/dist/tooltip/tooltip-context.mjs.map +1 -1
  401. package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
  402. package/dist/tooltip/tooltip-popup.mjs +6 -15
  403. package/dist/tooltip/tooltip-popup.mjs.map +1 -1
  404. package/dist/tooltip/tooltip-root.mjs +2 -2
  405. package/dist/tooltip/tooltip-root.mjs.map +1 -1
  406. package/dist/tooltip/tooltip-trigger.d.mts +2 -1
  407. package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
  408. package/dist/tooltip/tooltip-trigger.mjs +3 -2
  409. package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
  410. package/dist/tooltip/use-tooltip-interaction.mjs +4 -3
  411. package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
  412. package/package.json +3 -2
  413. package/dist/accordion/accordion-context.d.mts +0 -5
  414. package/dist/accordion/accordion-context.d.mts.map +0 -1
  415. package/dist/internal/use-popover-root.mjs.map +0 -1
  416. /package/dist/internal/{use-popover-root.d.mts → use-overlay-root.d.mts} +0 -0
@@ -1,47 +1,49 @@
1
1
  "use client";
2
2
  import { dataAttr } from "../internal/data-attr.mjs";
3
- import { isHostButton, rendersButton } from "../internal/render-element.mjs";
3
+ import { disabledButton, rendersButton } from "../internal/render-element.mjs";
4
4
  import { useRender } from "../internal/use-render.mjs";
5
+ import { useElementCheck } from "../internal/use-element-check.mjs";
6
+ import { BUTTON_NAME, useNameWarning } from "../internal/use-name-warning.mjs";
5
7
  import { useComboboxContext } from "./combobox-context.mjs";
6
- import { useCallback, useRef } from "react";
8
+ import { useCallback } from "react";
7
9
  //#region src/combobox/combobox-trigger.tsx
8
10
  const isDev = process.env.NODE_ENV !== "production";
9
11
  /**
10
- * Development check (design 9): an icon-only Trigger needs a name from the consumer. Checked a
11
- * microtask after the element attaches, once per instance.
12
- */
13
- function useNameWarning(part) {
14
- const warned = useRef(false);
15
- return useCallback((element) => {
16
- if (!isDev || warned.current) return () => {};
17
- queueMicrotask(() => {
18
- if (warned.current || !element.isConnected) return;
19
- if (element.hasAttribute("aria-label") || element.hasAttribute("aria-labelledby")) return;
20
- if ((element.textContent ?? "").trim() !== "" || element.hasAttribute("title")) return;
21
- warned.current = true;
22
- console.error(`${part}: the button has no accessible name. Give it an \`aria-label\`.`);
23
- });
24
- return () => {};
25
- }, [part]);
26
- }
27
- /**
28
12
  * The optional button that toggles the listbox: `<button type="button" tabindex="-1"
29
13
  * aria-expanded aria-controls>` (the APG keeps it out of the Tab sequence; the input is the one
30
- * stop). A press does not take focus from the input, and a click focuses the input. No
31
- * `commandfor`: the listbox is anchored to the input, never to this button (design 1).
14
+ * stop). A press does not take focus from the input, and a click focuses the input. After
15
+ * hydration a `<button>` also names the Popup as its invoker (`commandfor`,
16
+ * `command="toggle-popover"`, written through the ref, never server-rendered), so a press while
17
+ * the listbox is open is not a light dismiss and the click's close is the only one (design 3.3,
18
+ * #112). Every click is cancelled, so the command never runs: the listbox stays anchored to the
19
+ * input (design 1).
32
20
  *
33
21
  * Owned keys: `type` (on a `<button>`), `tabIndex`, `disabled`, `aria-disabled` (link or
34
- * component `render`), `aria-expanded`,
35
- * `aria-controls` (token-merged), `onClick`, `onPointerDown`, `onPointerCancel`, `onMouseDown`,
36
- * `data-open`, `data-pending`, `data-disabled`.
22
+ * component `render`), `aria-expanded`, `aria-controls` (token-merged), `commandfor`, `command`,
23
+ * `onClick`, `onPointerDown`, `onMouseDown`, `data-open`, `data-pending`, `data-disabled`.
37
24
  */
38
25
  function ComboboxTrigger({ disabled: ownDisabled = false, className, style, children, render, ...rest }) {
39
26
  const ctx = useComboboxContext("Combobox.Trigger");
40
27
  const { popover } = ctx;
41
28
  const disabled = ownDisabled || ctx.disabled;
42
- const openAtPress = useRef(null);
43
- const ref = useNameWarning("Combobox.Trigger");
44
- const focusable = !isHostButton(render);
29
+ const checkName = useNameWarning(isDev && "Combobox.Trigger: the button has no accessible name. Give it an `aria-label`.", BUTTON_NAME);
30
+ const checkElement = useElementCheck(isDev && ((element) => element.tagName === "BUTTON" ? null : `Combobox.Trigger: rendered a <${element.tagName.toLowerCase()}>. Only a <button> is the listbox's invoker: a press on this element while the listbox is open closes it through light dismiss before the click, so the close is not awaited, openChangeAction(false) cannot veto it and there is no exit transition. Render a <button>.`));
31
+ const popupId = popover.ids.popup;
32
+ const ref = useCallback((element) => {
33
+ checkName?.(element);
34
+ checkElement?.(element);
35
+ if (element.tagName !== "BUTTON") return () => {};
36
+ element.setAttribute("commandfor", popupId);
37
+ element.setAttribute("command", "toggle-popover");
38
+ return () => {
39
+ element.removeAttribute("commandfor");
40
+ element.removeAttribute("command");
41
+ };
42
+ }, [
43
+ checkName,
44
+ checkElement,
45
+ popupId
46
+ ]);
45
47
  const state = {
46
48
  open: popover.optimistic,
47
49
  pending: popover.pending,
@@ -50,29 +52,20 @@ function ComboboxTrigger({ disabled: ownDisabled = false, className, style, chil
50
52
  const libraryProps = {
51
53
  ...rendersButton(render) && { type: "button" },
52
54
  tabIndex: -1,
53
- disabled: focusable ? void 0 : disabled,
54
- ...focusable && { "aria-disabled": disabled ? true : void 0 },
55
- "aria-expanded": popover.optimistic,
55
+ ...disabledButton(render, disabled).props,
56
+ "aria-expanded": popover.shown,
56
57
  "aria-controls": ctx.ids.list,
57
58
  onPointerDown: (event) => {
58
- openAtPress.current = popover.intended();
59
59
  event.preventDefault();
60
60
  },
61
- onPointerCancel: () => {
62
- openAtPress.current = null;
63
- },
64
61
  onMouseDown: (event) => {
65
62
  event.preventDefault();
66
63
  },
67
64
  onClick: (event) => {
68
- const wasOpen = (event.detail === 0 ? null : openAtPress.current) ?? popover.intended();
69
- openAtPress.current = null;
70
- if (disabled) {
71
- event.preventDefault();
72
- return;
73
- }
65
+ event.preventDefault();
66
+ if (disabled) return;
74
67
  const native = event.nativeEvent;
75
- if (wasOpen) popover.requestClose(native, "activate");
68
+ if (popover.intended()) popover.requestClose(native, "activate");
76
69
  else popover.requestOpen(native, "activate");
77
70
  ctx.inputRef.current?.focus();
78
71
  },
@@ -94,6 +87,6 @@ function ComboboxTrigger({ disabled: ownDisabled = false, className, style, chil
94
87
  }
95
88
  ComboboxTrigger.displayName = "ComboboxTrigger";
96
89
  //#endregion
97
- export { ComboboxTrigger, useNameWarning };
90
+ export { ComboboxTrigger };
98
91
 
99
92
  //# sourceMappingURL=combobox-trigger.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"combobox-trigger.mjs","names":[],"sources":["../../src/combobox/combobox-trigger.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback, useRef } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n ReactNode,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { isHostButton, rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { useComboboxContext } from \"./combobox-context.js\";\n\nexport interface ComboboxTriggerState {\n /** Optimistic open state. */\n readonly open: boolean;\n /** The open (or close) transition is in flight. */\n readonly pending: boolean;\n readonly disabled: boolean;\n}\n\nexport interface ComboboxTriggerProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n | \"onClick\"\n | \"onPointerDown\"\n | \"onMouseDown\"\n | \"onPointerCancel\"\n | \"tabIndex\"\n | \"aria-expanded\"\n | \"aria-controls\"\n | \"disabled\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * Disables this button; the Root's `disabled` does too. Native `disabled` on a `<button>`; with\n * a link or component `render`, `aria-disabled=\"true\"` instead.\n */\n disabled?: boolean;\n className?: StateValue<string | undefined, ComboboxTriggerState>;\n style?: StateValue<CSSProperties | undefined, ComboboxTriggerState>;\n /** Rendered from optimistic state; must not suspend. */\n children?: StateValue<ReactNode, ComboboxTriggerState>;\n /** Should render a `<button>`. */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, ComboboxTriggerState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * Development check (design 9): an icon-only Trigger needs a name from the consumer. Checked a\n * microtask after the element attaches, once per instance.\n */\nexport function useNameWarning(part: string): (element: HTMLElement) => () => void {\n const warned = useRef(false);\n return useCallback(\n (element: HTMLElement) => {\n if (!isDev || warned.current) return () => {};\n queueMicrotask(() => {\n if (warned.current || !element.isConnected) return;\n if (element.hasAttribute(\"aria-label\") || element.hasAttribute(\"aria-labelledby\")) return;\n if ((element.textContent ?? \"\").trim() !== \"\" || element.hasAttribute(\"title\")) return;\n warned.current = true;\n console.error(`${part}: the button has no accessible name. Give it an \\`aria-label\\`.`);\n });\n return () => {};\n },\n [part],\n );\n}\n\n/**\n * The optional button that toggles the listbox: `<button type=\"button\" tabindex=\"-1\"\n * aria-expanded aria-controls>` (the APG keeps it out of the Tab sequence; the input is the one\n * stop). A press does not take focus from the input, and a click focuses the input. No\n * `commandfor`: the listbox is anchored to the input, never to this button (design 1).\n *\n * Owned keys: `type` (on a `<button>`), `tabIndex`, `disabled`, `aria-disabled` (link or\n * component `render`), `aria-expanded`,\n * `aria-controls` (token-merged), `onClick`, `onPointerDown`, `onPointerCancel`, `onMouseDown`,\n * `data-open`, `data-pending`, `data-disabled`.\n */\nexport function ComboboxTrigger({\n disabled: ownDisabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxTriggerProps) {\n const ctx = useComboboxContext(\"Combobox.Trigger\");\n const { popover } = ctx;\n const disabled = ownDisabled || ctx.disabled;\n // What the user saw at the press: a press outside the popup light-dismisses it before the\n // click arrives, so the toggle is decided against the state at `pointerdown`.\n const openAtPress = useRef<boolean | null>(null);\n const ref = useNameWarning(\"Combobox.Trigger\");\n\n // A link or component render: native `disabled` would mean nothing on a link; the click\n // handler refuses, so `aria-disabled` (#83).\n const focusable = !isHostButton(render);\n\n const state: ComboboxTriggerState = {\n open: popover.optimistic,\n pending: popover.pending,\n disabled,\n };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n tabIndex: -1,\n disabled: focusable ? undefined : disabled,\n ...(focusable && { \"aria-disabled\": disabled ? true : undefined }),\n \"aria-expanded\": popover.optimistic,\n \"aria-controls\": ctx.ids.list,\n onPointerDown: (event: PointerEvent<HTMLButtonElement>) => {\n openAtPress.current = popover.intended();\n event.preventDefault();\n },\n onPointerCancel: () => {\n // The press never becomes a click.\n openAtPress.current = null;\n },\n onMouseDown: (event: MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n },\n onClick: (event: MouseEvent<HTMLButtonElement>) => {\n // `detail === 0`: a click without a press (assistive technology, `element.click()`); a\n // snapshot left by a press that never clicked (dragged off) does not belong to it.\n const pressed = event.detail === 0 ? null : openAtPress.current;\n const wasOpen = pressed ?? popover.intended();\n openAtPress.current = null;\n if (disabled) {\n // A disabled link must not navigate either.\n event.preventDefault();\n return;\n }\n const native = event.nativeEvent;\n if (wasOpen) popover.requestClose(native, \"activate\");\n else popover.requestOpen(native, \"activate\");\n ctx.inputRef.current?.focus();\n },\n \"data-open\": dataAttr(popover.optimistic),\n \"data-pending\": dataAttr(popover.pending),\n \"data-disabled\": dataAttr(disabled),\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, ComboboxTriggerState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps,\n ref,\n });\n}\n\nComboboxTrigger.displayName = \"ComboboxTrigger\";\n"],"mappings":";;;;;;;AAkDA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;AAMvC,SAAgB,eAAe,MAAoD;CACjF,MAAM,SAAS,OAAO,KAAK;CAC3B,OAAO,aACJ,YAAyB;EACxB,IAAI,CAAC,SAAS,OAAO,SAAS,aAAa,CAAC;EAC5C,qBAAqB;GACnB,IAAI,OAAO,WAAW,CAAC,QAAQ,aAAa;GAC5C,IAAI,QAAQ,aAAa,YAAY,KAAK,QAAQ,aAAa,iBAAiB,GAAG;GACnF,KAAK,QAAQ,eAAe,GAAA,CAAI,KAAK,MAAM,MAAM,QAAQ,aAAa,OAAO,GAAG;GAChF,OAAO,UAAU;GACjB,QAAQ,MAAM,GAAG,KAAK,gEAAgE;EACxF,CAAC;EACD,aAAa,CAAC;CAChB,GACA,CAAC,IAAI,CACP;AACF;;;;;;;;;;;;AAaA,SAAgB,gBAAgB,EAC9B,UAAU,cAAc,OACxB,WACA,OACA,UACA,QACA,GAAG,QACoB;CACvB,MAAM,MAAM,mBAAmB,kBAAkB;CACjD,MAAM,EAAE,YAAY;CACpB,MAAM,WAAW,eAAe,IAAI;CAGpC,MAAM,cAAc,OAAuB,IAAI;CAC/C,MAAM,MAAM,eAAe,kBAAkB;CAI7C,MAAM,YAAY,CAAC,aAAa,MAAM;CAEtC,MAAM,QAA8B;EAClC,MAAM,QAAQ;EACd,SAAS,QAAQ;EACjB;CACF;CAEA,MAAM,eAAiE;EACrE,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;EACvD,UAAU;EACV,UAAU,YAAY,KAAA,IAAY;EAClC,GAAI,aAAa,EAAE,iBAAiB,WAAW,OAAO,KAAA,EAAU;EAChE,iBAAiB,QAAQ;EACzB,iBAAiB,IAAI,IAAI;EACzB,gBAAgB,UAA2C;GACzD,YAAY,UAAU,QAAQ,SAAS;GACvC,MAAM,eAAe;EACvB;EACA,uBAAuB;GAErB,YAAY,UAAU;EACxB;EACA,cAAc,UAAyC;GACrD,MAAM,eAAe;EACvB;EACA,UAAU,UAAyC;GAIjD,MAAM,WADU,MAAM,WAAW,IAAI,OAAO,YAAY,YAC7B,QAAQ,SAAS;GAC5C,YAAY,UAAU;GACtB,IAAI,UAAU;IAEZ,MAAM,eAAe;IACrB;GACF;GACA,MAAM,SAAS,MAAM;GACrB,IAAI,SAAS,QAAQ,aAAa,QAAQ,UAAU;QAC/C,QAAQ,YAAY,QAAQ,UAAU;GAC3C,IAAI,SAAS,SAAS,MAAM;EAC9B;EACA,aAAa,SAAS,QAAQ,UAAU;EACxC,gBAAgB,SAAS,QAAQ,OAAO;EACxC,iBAAiB,SAAS,QAAQ;CACpC;CAEA,OAAO,UAAiE;EACtE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA;CACF,CAAC;AACH;AAEA,gBAAgB,cAAc"}
1
+ {"version":3,"file":"combobox-trigger.mjs","names":[],"sources":["../../src/combobox/combobox-trigger.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n ReactNode,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { BUTTON_NAME, useNameWarning } from \"../internal/use-name-warning.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { disabledButton, rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { useComboboxContext } from \"./combobox-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface ComboboxTriggerState {\n /** Optimistic open state. */\n readonly open: boolean;\n /** The open (or close) transition is in flight. */\n readonly pending: boolean;\n readonly disabled: boolean;\n}\n\nexport interface ComboboxTriggerProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n | \"onClick\"\n | \"onPointerDown\"\n | \"onMouseDown\"\n | \"tabIndex\"\n | \"aria-expanded\"\n | \"aria-controls\"\n | \"commandfor\"\n | \"command\"\n | \"disabled\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * Disables this button; the Root's `disabled` does too. Native `disabled` on a `<button>`; with\n * a link or component `render`, `aria-disabled=\"true\"` instead.\n */\n disabled?: boolean;\n className?: StateValue<string | undefined, ComboboxTriggerState>;\n style?: StateValue<CSSProperties | undefined, ComboboxTriggerState>;\n /** Rendered from optimistic state; must not suspend. */\n children?: StateValue<ReactNode, ComboboxTriggerState>;\n /** Should render a `<button>`. */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, ComboboxTriggerState>;\n}\n\n/**\n * The optional button that toggles the listbox: `<button type=\"button\" tabindex=\"-1\"\n * aria-expanded aria-controls>` (the APG keeps it out of the Tab sequence; the input is the one\n * stop). A press does not take focus from the input, and a click focuses the input. After\n * hydration a `<button>` also names the Popup as its invoker (`commandfor`,\n * `command=\"toggle-popover\"`, written through the ref, never server-rendered), so a press while\n * the listbox is open is not a light dismiss and the click's close is the only one (design 3.3,\n * #112). Every click is cancelled, so the command never runs: the listbox stays anchored to the\n * input (design 1).\n *\n * Owned keys: `type` (on a `<button>`), `tabIndex`, `disabled`, `aria-disabled` (link or\n * component `render`), `aria-expanded`, `aria-controls` (token-merged), `commandfor`, `command`,\n * `onClick`, `onPointerDown`, `onMouseDown`, `data-open`, `data-pending`, `data-disabled`.\n */\nexport function ComboboxTrigger({\n disabled: ownDisabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxTriggerProps) {\n const ctx = useComboboxContext(\"Combobox.Trigger\");\n const { popover } = ctx;\n const disabled = ownDisabled || ctx.disabled;\n // Development check (design 9): an icon-only Trigger needs a name from the consumer.\n const checkName = useNameWarning(\n isDev && \"Combobox.Trigger: the button has no accessible name. Give it an `aria-label`.\",\n BUTTON_NAME,\n );\n const checkElement = useElementCheck(\n isDev &&\n ((element) =>\n element.tagName === \"BUTTON\"\n ? null\n : `Combobox.Trigger: rendered a <${element.tagName.toLowerCase()}>. Only a <button> ` +\n \"is the listbox's invoker: a press on this element while the listbox is open closes \" +\n \"it through light dismiss before the click, so the close is not awaited, \" +\n \"openChangeAction(false) cannot veto it and there is no exit transition. Render a \" +\n \"<button>.\"),\n );\n const popupId = popover.ids.popup;\n // After hydration a `<button>` becomes the popup's invoker (design 3.3, #112): the platform's\n // light dismiss exempts a press on an invoker of the open popover. Written here, not rendered,\n // so the server HTML has no `commandfor` and a click before hydration opens nothing.\n const ref = useCallback(\n (element: HTMLElement) => {\n checkName?.(element);\n checkElement?.(element);\n if (element.tagName !== \"BUTTON\") return () => {};\n element.setAttribute(\"commandfor\", popupId);\n element.setAttribute(\"command\", \"toggle-popover\");\n return () => {\n element.removeAttribute(\"commandfor\");\n element.removeAttribute(\"command\");\n };\n },\n [checkName, checkElement, popupId],\n );\n\n const state: ComboboxTriggerState = {\n open: popover.optimistic,\n pending: popover.pending,\n disabled,\n };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n tabIndex: -1,\n ...disabledButton(render, disabled).props,\n // Shown (the listbox is in the top layer); `data-open` is the optimistic one (#118).\n \"aria-expanded\": popover.shown,\n \"aria-controls\": ctx.ids.list,\n onPointerDown: (event: PointerEvent<HTMLButtonElement>) => {\n event.preventDefault();\n },\n onMouseDown: (event: MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n },\n onClick: (event: MouseEvent<HTMLButtonElement>) => {\n // Cancelled first, whatever follows: the command must never run (the library opens the\n // listbox anchored to the input), and a disabled link must not navigate either.\n event.preventDefault();\n if (disabled) return;\n const native = event.nativeEvent;\n if (popover.intended()) popover.requestClose(native, \"activate\");\n else popover.requestOpen(native, \"activate\");\n ctx.inputRef.current?.focus();\n },\n \"data-open\": dataAttr(popover.optimistic),\n \"data-pending\": dataAttr(popover.pending),\n \"data-disabled\": dataAttr(disabled),\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, ComboboxTriggerState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps,\n ref,\n });\n}\n\nComboboxTrigger.displayName = \"ComboboxTrigger\";\n"],"mappings":";;;;;;;;;AAiBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;;;;AAoDvC,SAAgB,gBAAgB,EAC9B,UAAU,cAAc,OACxB,WACA,OACA,UACA,QACA,GAAG,QACoB;CACvB,MAAM,MAAM,mBAAmB,kBAAkB;CACjD,MAAM,EAAE,YAAY;CACpB,MAAM,WAAW,eAAe,IAAI;CAEpC,MAAM,YAAY,eAChB,SAAS,iFACT,WACF;CACA,MAAM,eAAe,gBACnB,WACI,YACA,QAAQ,YAAY,WAChB,OACA,iCAAiC,QAAQ,QAAQ,YAAY,EAAE,0QAKzE;CACA,MAAM,UAAU,QAAQ,IAAI;CAI5B,MAAM,MAAM,aACT,YAAyB;EACxB,YAAY,OAAO;EACnB,eAAe,OAAO;EACtB,IAAI,QAAQ,YAAY,UAAU,aAAa,CAAC;EAChD,QAAQ,aAAa,cAAc,OAAO;EAC1C,QAAQ,aAAa,WAAW,gBAAgB;EAChD,aAAa;GACX,QAAQ,gBAAgB,YAAY;GACpC,QAAQ,gBAAgB,SAAS;EACnC;CACF,GACA;EAAC;EAAW;EAAc;CAAO,CACnC;CAEA,MAAM,QAA8B;EAClC,MAAM,QAAQ;EACd,SAAS,QAAQ;EACjB;CACF;CAEA,MAAM,eAAiE;EACrE,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;EACvD,UAAU;EACV,GAAG,eAAe,QAAQ,QAAQ,CAAC,CAAC;EAEpC,iBAAiB,QAAQ;EACzB,iBAAiB,IAAI,IAAI;EACzB,gBAAgB,UAA2C;GACzD,MAAM,eAAe;EACvB;EACA,cAAc,UAAyC;GACrD,MAAM,eAAe;EACvB;EACA,UAAU,UAAyC;GAGjD,MAAM,eAAe;GACrB,IAAI,UAAU;GACd,MAAM,SAAS,MAAM;GACrB,IAAI,QAAQ,SAAS,GAAG,QAAQ,aAAa,QAAQ,UAAU;QAC1D,QAAQ,YAAY,QAAQ,UAAU;GAC3C,IAAI,SAAS,SAAS,MAAM;EAC9B;EACA,aAAa,SAAS,QAAQ,UAAU;EACxC,gBAAgB,SAAS,QAAQ,OAAO;EACxC,iBAAiB,SAAS,QAAQ;CACpC;CAEA,OAAO,UAAiE;EACtE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA;CACF,CAAC;AACH;AAEA,gBAAgB,cAAc"}
@@ -1,4 +1,3 @@
1
- import { ComboboxTrigger } from "./combobox-trigger.mjs";
2
1
  import { ComboboxClear } from "./combobox-clear.mjs";
3
2
  import { ComboboxEmpty, ComboboxGroup, ComboboxGroupLabel, ComboboxStatus } from "./combobox-group.mjs";
4
3
  import { ComboboxInput } from "./combobox-input.mjs";
@@ -7,6 +6,7 @@ import { ComboboxList } from "./combobox-list.mjs";
7
6
  import { ComboboxOption } from "./combobox-option.mjs";
8
7
  import { ComboboxPopup } from "./combobox-popup.mjs";
9
8
  import { ComboboxRoot } from "./combobox-root.mjs";
9
+ import { ComboboxTrigger } from "./combobox-trigger.mjs";
10
10
  //#region src/combobox/index.ts
11
11
  /**
12
12
  * Editable combobox with list autocomplete (WAI-ARIA APG) on `popover="auto"`: `Root` (no DOM,
@@ -0,0 +1,56 @@
1
+ "use client";
2
+ import { useFormReset } from "../internal/use-form-reset.mjs";
3
+ import { useLayoutEffect, useMemo, useRef, useState } from "react";
4
+ //#region src/combobox/use-combobox-form.ts
5
+ /**
6
+ * The Combobox's form behaviour (design/components/combobox.md 11.1, walkthroughs 10 and 11):
7
+ * form reset of the text and the value, the DOM re-sync for a controlled parent that keeps its
8
+ * text, and the mount reconciliation of a text typed before hydration.
9
+ */
10
+ function useComboboxForm(options) {
11
+ const { value, defaultValue, inputValue, defaultInputValue, inputRef, hiddenRef, textRef } = options;
12
+ const { writeText } = options;
13
+ const [mountValue] = useState(value);
14
+ const [mountText] = useState(inputValue);
15
+ const valueResetTarget = value !== void 0 ? mountValue ?? null : defaultValue ?? null;
16
+ const inputDefaultValue = inputValue !== void 0 ? mountText ?? "" : defaultInputValue ?? "";
17
+ const [resync, setResync] = useState(0);
18
+ useLayoutEffect(() => {
19
+ const input = inputRef.current;
20
+ if (resync > 0 && input !== null && input.value !== textRef.current) input.value = textRef.current;
21
+ }, [
22
+ resync,
23
+ inputRef,
24
+ textRef
25
+ ]);
26
+ const formElement = useMemo(() => ({
27
+ get current() {
28
+ return hiddenRef.current ?? inputRef.current;
29
+ },
30
+ set current(_ignored) {}
31
+ }), [hiddenRef, inputRef]);
32
+ useFormReset(formElement, (event) => {
33
+ const domText = inputRef.current?.value ?? inputDefaultValue;
34
+ if (domText !== textRef.current) writeText(domText, "platform", event);
35
+ setResync((n) => n + 1);
36
+ if (valueResetTarget !== options.optimistic) options.resetValue(valueResetTarget, event);
37
+ }, () => {
38
+ const input = inputRef.current;
39
+ if (input !== null && input.defaultValue !== inputDefaultValue) input.defaultValue = inputDefaultValue;
40
+ });
41
+ const reconciled = useRef(false);
42
+ useLayoutEffect(() => {
43
+ if (reconciled.current) return;
44
+ reconciled.current = true;
45
+ const input = inputRef.current;
46
+ if (input !== null && input.value !== textRef.current) writeText(input.value, "platform", void 0);
47
+ }, [
48
+ writeText,
49
+ inputRef,
50
+ textRef
51
+ ]);
52
+ }
53
+ //#endregion
54
+ export { useComboboxForm };
55
+
56
+ //# sourceMappingURL=use-combobox-form.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-combobox-form.mjs","names":[],"sources":["../../src/combobox/use-combobox-form.ts"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { ChangeReason } from \"../internal/types.js\";\nimport type { FormAssociatedElement } from \"../internal/use-form-owner-event.js\";\nimport { useFormReset } from \"../internal/use-form-reset.js\";\n\nexport interface ComboboxFormOptions {\n /** The Root's props, for the reset targets. */\n readonly value: string | null | undefined;\n readonly defaultValue: string | null | undefined;\n readonly inputValue: string | undefined;\n readonly defaultInputValue: string | undefined;\n readonly inputRef: RefObject<HTMLInputElement | null>;\n readonly hiddenRef: RefObject<HTMLInputElement | null>;\n /** The latest text (the urgent lane). */\n readonly textRef: RefObject<string>;\n readonly writeText: (next: string, reason: ChangeReason, event: Event | undefined) => void;\n /** The optimistic selection. */\n readonly optimistic: string | null;\n /** Dispatches the reset target as the value (`\"platform\"`). */\n readonly resetValue: (next: string | null, event: Event) => void;\n}\n\n/**\n * The Combobox's form behaviour (design/components/combobox.md 11.1, walkthroughs 10 and 11):\n * form reset of the text and the value, the DOM re-sync for a controlled parent that keeps its\n * text, and the mount reconciliation of a text typed before hydration.\n */\nexport function useComboboxForm(options: ComboboxFormOptions): void {\n const { value, defaultValue, inputValue, defaultInputValue, inputRef, hiddenRef, textRef } =\n options;\n const { writeText } = options;\n\n const [mountValue] = useState(value);\n const [mountText] = useState(inputValue);\n // Reset targets (conventions 3.8 rule 6): uncontrolled, the latest default props; controlled,\n // the mount-time values.\n const valueResetTarget = value !== undefined ? (mountValue ?? null) : (defaultValue ?? null);\n const inputDefaultValue =\n inputValue !== undefined ? (mountText ?? \"\") : (defaultInputValue ?? \"\");\n // After a form reset a controlled parent may not adopt the text: put React's value back into\n // the DOM (react-dom only does that after its own input events).\n const [resync, setResync] = useState(0);\n useLayoutEffect(() => {\n const input = inputRef.current;\n if (resync > 0 && input !== null && input.value !== textRef.current) {\n input.value = textRef.current;\n }\n }, [resync, inputRef, textRef]);\n\n const formElement = useMemo<RefObject<FormAssociatedElement | null>>(\n () => ({\n get current() {\n return hiddenRef.current ?? inputRef.current;\n },\n set current(_ignored) {},\n }),\n [hiddenRef, inputRef],\n );\n useFormReset(\n formElement,\n (event) => {\n const input = inputRef.current;\n const domText = input?.value ?? inputDefaultValue;\n if (domText !== textRef.current) writeText(domText, \"platform\", event);\n // A controlled parent that does not adopt the text gets the DOM re-synced.\n setResync((n) => n + 1);\n if (valueResetTarget !== options.optimistic) options.resetValue(valueResetTarget, event);\n },\n () => {\n // react-dom writes `defaultValue = value` after every update of a controlled input, so the\n // reset target is written here, right before the browser's reset algorithm reads it.\n const input = inputRef.current;\n if (input !== null && input.defaultValue !== inputDefaultValue) {\n input.defaultValue = inputDefaultValue;\n }\n },\n );\n\n // Walkthrough 11: react-dom keeps a hydrated text input's DOM value and fires no `onChange`.\n const reconciled = useRef(false);\n useLayoutEffect(() => {\n if (reconciled.current) return;\n reconciled.current = true;\n const input = inputRef.current;\n if (input !== null && input.value !== textRef.current) {\n writeText(input.value, \"platform\", undefined);\n }\n }, [writeText, inputRef, textRef]);\n}\n"],"mappings":";;;;;;;;;AA6BA,SAAgB,gBAAgB,SAAoC;CAClE,MAAM,EAAE,OAAO,cAAc,YAAY,mBAAmB,UAAU,WAAW,YAC/E;CACF,MAAM,EAAE,cAAc;CAEtB,MAAM,CAAC,cAAc,SAAS,KAAK;CACnC,MAAM,CAAC,aAAa,SAAS,UAAU;CAGvC,MAAM,mBAAmB,UAAU,KAAA,IAAa,cAAc,OAAS,gBAAgB;CACvF,MAAM,oBACJ,eAAe,KAAA,IAAa,aAAa,KAAO,qBAAqB;CAGvE,MAAM,CAAC,QAAQ,aAAa,SAAS,CAAC;CACtC,sBAAsB;EACpB,MAAM,QAAQ,SAAS;EACvB,IAAI,SAAS,KAAK,UAAU,QAAQ,MAAM,UAAU,QAAQ,SAC1D,MAAM,QAAQ,QAAQ;CAE1B,GAAG;EAAC;EAAQ;EAAU;CAAO,CAAC;CAE9B,MAAM,cAAc,eACX;EACL,IAAI,UAAU;GACZ,OAAO,UAAU,WAAW,SAAS;EACvC;EACA,IAAI,QAAQ,UAAU,CAAC;CACzB,IACA,CAAC,WAAW,QAAQ,CACtB;CACA,aACE,cACC,UAAU;EAET,MAAM,UADQ,SAAS,SACA,SAAS;EAChC,IAAI,YAAY,QAAQ,SAAS,UAAU,SAAS,YAAY,KAAK;EAErE,WAAW,MAAM,IAAI,CAAC;EACtB,IAAI,qBAAqB,QAAQ,YAAY,QAAQ,WAAW,kBAAkB,KAAK;CACzF,SACM;EAGJ,MAAM,QAAQ,SAAS;EACvB,IAAI,UAAU,QAAQ,MAAM,iBAAiB,mBAC3C,MAAM,eAAe;CAEzB,CACF;CAGA,MAAM,aAAa,OAAO,KAAK;CAC/B,sBAAsB;EACpB,IAAI,WAAW,SAAS;EACxB,WAAW,UAAU;EACrB,MAAM,QAAQ,SAAS;EACvB,IAAI,UAAU,QAAQ,MAAM,UAAU,QAAQ,SAC5C,UAAU,MAAM,OAAO,YAAY,KAAA,CAAS;CAEhD,GAAG;EAAC;EAAW;EAAU;CAAO,CAAC;AACnC"}
@@ -0,0 +1,62 @@
1
+ "use client";
2
+ import { useCallback, useRef, useState } from "react";
3
+ //#region src/combobox/use-option-registry.ts
4
+ const isDev = process.env.NODE_ENV !== "production";
5
+ /**
6
+ * The Options, Statuses and Labels mounted in a Combobox (design/components/combobox.md 2, 6.5).
7
+ * An Option's label is learnt into `labels` (design 2.3) as it registers.
8
+ */
9
+ function useOptionRegistry(labels) {
10
+ const [registry] = useState(() => /* @__PURE__ */ new Map());
11
+ const [optionCount, setOptionCount] = useState(0);
12
+ const [statusCount, setStatusCount] = useState(0);
13
+ const statusCountRef = useRef(0);
14
+ const [labelCount, setLabelCount] = useState(0);
15
+ const warnedDuplicate = useRef(false);
16
+ return {
17
+ registry,
18
+ optionCount,
19
+ statusCount,
20
+ statusCountRef,
21
+ labelCount,
22
+ registerOption: useCallback((optionValue, entry) => {
23
+ const existing = registry.get(optionValue);
24
+ if (isDev && !warnedDuplicate.current && existing !== void 0 && existing.element !== entry.element && existing.element.isConnected) {
25
+ warnedDuplicate.current = true;
26
+ console.error(`Combobox.Option: two options have the value ${JSON.stringify(optionValue)}. Option ids are derived from the value, so they must be unique within one Combobox.`);
27
+ }
28
+ registry.set(optionValue, entry);
29
+ labels.set(optionValue, entry.label ?? (entry.element.textContent ?? "").trim());
30
+ setOptionCount(registry.size);
31
+ return () => {
32
+ if (registry.get(optionValue) === entry) registry.delete(optionValue);
33
+ setOptionCount(registry.size);
34
+ };
35
+ }, [registry, labels]),
36
+ registerStatus: useCallback(() => {
37
+ statusCountRef.current += 1;
38
+ setStatusCount((count) => count + 1);
39
+ return () => {
40
+ statusCountRef.current -= 1;
41
+ setStatusCount((count) => count - 1);
42
+ };
43
+ }, []),
44
+ registerLabel: useCallback(() => {
45
+ setLabelCount((count) => count + 1);
46
+ return () => setLabelCount((count) => count - 1);
47
+ }, []),
48
+ orderedOptions: useCallback(() => {
49
+ const options = [];
50
+ for (const [optionValue, entry] of registry) options.push({
51
+ value: optionValue,
52
+ ...entry
53
+ });
54
+ options.sort((a, b) => a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
55
+ return options;
56
+ }, [registry])
57
+ };
58
+ }
59
+ //#endregion
60
+ export { useOptionRegistry };
61
+
62
+ //# sourceMappingURL=use-option-registry.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-option-registry.mjs","names":[],"sources":["../../src/combobox/use-option-registry.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { ComboboxOptionEntry } from \"./combobox-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface OrderedOption extends ComboboxOptionEntry {\n readonly value: string;\n}\n\nexport interface OptionRegistry {\n /** The mounted Options by value. */\n readonly registry: ReadonlyMap<string, ComboboxOptionEntry>;\n readonly optionCount: number;\n readonly statusCount: number;\n /**\n * The same count for the announcement effect: the open commit's passive effects can run before\n * the re-render the Status's registration scheduled (the race `registry` avoids for options).\n */\n readonly statusCountRef: RefObject<number>;\n readonly labelCount: number;\n readonly registerOption: (value: string, entry: ComboboxOptionEntry) => () => void;\n readonly registerStatus: () => () => void;\n readonly registerLabel: () => () => void;\n /** The registered Options in document order. */\n readonly orderedOptions: () => OrderedOption[];\n}\n\n/**\n * The Options, Statuses and Labels mounted in a Combobox (design/components/combobox.md 2, 6.5).\n * An Option's label is learnt into `labels` (design 2.3) as it registers.\n */\nexport function useOptionRegistry(labels: Map<string, string>): OptionRegistry {\n const [registry] = useState(() => new Map<string, ComboboxOptionEntry>());\n const [optionCount, setOptionCount] = useState(0);\n const [statusCount, setStatusCount] = useState(0);\n const statusCountRef = useRef(0);\n const [labelCount, setLabelCount] = useState(0);\n const warnedDuplicate = useRef(false);\n\n const registerOption = useCallback(\n (optionValue: string, entry: ComboboxOptionEntry) => {\n const existing = registry.get(optionValue);\n if (\n isDev &&\n !warnedDuplicate.current &&\n existing !== undefined &&\n existing.element !== entry.element &&\n existing.element.isConnected\n ) {\n warnedDuplicate.current = true;\n console.error(\n `Combobox.Option: two options have the value ${JSON.stringify(optionValue)}. ` +\n \"Option ids are derived from the value, so they must be unique within one Combobox.\",\n );\n }\n registry.set(optionValue, entry);\n labels.set(optionValue, entry.label ?? (entry.element.textContent ?? \"\").trim());\n setOptionCount(registry.size);\n return () => {\n if (registry.get(optionValue) === entry) registry.delete(optionValue);\n setOptionCount(registry.size);\n };\n },\n [registry, labels],\n );\n\n const registerStatus = useCallback(() => {\n statusCountRef.current += 1;\n setStatusCount((count) => count + 1);\n return () => {\n statusCountRef.current -= 1;\n setStatusCount((count) => count - 1);\n };\n }, []);\n\n const registerLabel = useCallback(() => {\n setLabelCount((count) => count + 1);\n return () => setLabelCount((count) => count - 1);\n }, []);\n\n const orderedOptions = useCallback((): OrderedOption[] => {\n const options: OrderedOption[] = [];\n for (const [optionValue, entry] of registry) options.push({ value: optionValue, ...entry });\n options.sort((a, b) =>\n a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1,\n );\n return options;\n }, [registry]);\n\n return {\n registry,\n optionCount,\n statusCount,\n statusCountRef,\n labelCount,\n registerOption,\n registerStatus,\n registerLabel,\n orderedOptions,\n };\n}\n"],"mappings":";;;AAKA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;AA4BvC,SAAgB,kBAAkB,QAA6C;CAC7E,MAAM,CAAC,YAAY,+BAAe,IAAI,IAAiC,CAAC;CACxE,MAAM,CAAC,aAAa,kBAAkB,SAAS,CAAC;CAChD,MAAM,CAAC,aAAa,kBAAkB,SAAS,CAAC;CAChD,MAAM,iBAAiB,OAAO,CAAC;CAC/B,MAAM,CAAC,YAAY,iBAAiB,SAAS,CAAC;CAC9C,MAAM,kBAAkB,OAAO,KAAK;CAoDpC,OAAO;EACL;EACA;EACA;EACA;EACA;EACA,gBAxDqB,aACpB,aAAqB,UAA+B;GACnD,MAAM,WAAW,SAAS,IAAI,WAAW;GACzC,IACE,SACA,CAAC,gBAAgB,WACjB,aAAa,KAAA,KACb,SAAS,YAAY,MAAM,WAC3B,SAAS,QAAQ,aACjB;IACA,gBAAgB,UAAU;IAC1B,QAAQ,MACN,+CAA+C,KAAK,UAAU,WAAW,EAAE,qFAE7E;GACF;GACA,SAAS,IAAI,aAAa,KAAK;GAC/B,OAAO,IAAI,aAAa,MAAM,UAAU,MAAM,QAAQ,eAAe,GAAA,CAAI,KAAK,CAAC;GAC/E,eAAe,SAAS,IAAI;GAC5B,aAAa;IACX,IAAI,SAAS,IAAI,WAAW,MAAM,OAAO,SAAS,OAAO,WAAW;IACpE,eAAe,SAAS,IAAI;GAC9B;EACF,GACA,CAAC,UAAU,MAAM,CAgCJ;EACb,gBA9BqB,kBAAkB;GACvC,eAAe,WAAW;GAC1B,gBAAgB,UAAU,QAAQ,CAAC;GACnC,aAAa;IACX,eAAe,WAAW;IAC1B,gBAAgB,UAAU,QAAQ,CAAC;GACrC;EACF,GAAG,CAAC,CAuBW;EACb,eAtBoB,kBAAkB;GACtC,eAAe,UAAU,QAAQ,CAAC;GAClC,aAAa,eAAe,UAAU,QAAQ,CAAC;EACjD,GAAG,CAAC,CAmBU;EACZ,gBAlBqB,kBAAmC;GACxD,MAAM,UAA2B,CAAC;GAClC,KAAK,MAAM,CAAC,aAAa,UAAU,UAAU,QAAQ,KAAK;IAAE,OAAO;IAAa,GAAG;GAAM,CAAC;GAC1F,QAAQ,MAAM,GAAG,MACf,EAAE,QAAQ,wBAAwB,EAAE,OAAO,IAAI,KAAK,8BAA8B,KAAK,CACzF;GACA,OAAO;EACT,GAAG,CAAC,QAAQ,CAWG;CACf;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"dialog-close.d.mts","names":[],"sources":["../../src/dialog/dialog-close.tsx"],"mappings":";;;iBAWiB;;WAEN;WACA;;;iBAIM,2BAA2B;;WAEjC;;iBAGM,yBAAyB,KACxC;;;;;;;;;;EAYA,SAAS,QAAQ,SAAS;;EAE1B;;;;;;EAMA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;;;;wBAkBvC,cACd,QACA,OACA,UACA,WACA,OACA,UACA,WACG,QACF,mBAAgB;yBATH"}
1
+ {"version":3,"file":"dialog-close.d.mts","names":[],"sources":["../../src/dialog/dialog-close.tsx"],"mappings":";;;iBAOiB;;WAEN;WACA;;;iBAIM,2BAA2B;;WAEjC;;iBAGM,yBAAyB,KACxC;;;;;;;;;;EAYA,SAAS,QAAQ,SAAS;;EAE1B;;;;;;EAMA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;;;;wBAgBvC,cACd,QACA,OACA,UACA,WACA,OACA,UACA,WACG,QACF,mBAAgB;yBATH"}
@@ -1,13 +1,8 @@
1
1
  "use client";
2
2
  import { createActionDetails } from "../internal/action-details.mjs";
3
- import { dataAttr } from "../internal/data-attr.mjs";
4
- import { useActionTrigger } from "../internal/use-action-trigger.mjs";
5
- import { isHostButton, rendersButton } from "../internal/render-element.mjs";
6
- import { useRender } from "../internal/use-render.mjs";
3
+ import { useOverlayClose } from "../internal/use-overlay-close.mjs";
7
4
  import { useDialogContext } from "./dialog-context.mjs";
8
- import { useCallback } from "react";
9
5
  //#region src/dialog/dialog-close.tsx
10
- const isDev = process.env.NODE_ENV !== "production";
11
6
  /**
12
7
  * A close button: `<button type="button" commandfor command="request-close">`. In JS-free mode
13
8
  * without `action` the browser closes the dialog (a close request: `cancel`, then `close`), with
@@ -23,66 +18,38 @@ const isDev = process.env.NODE_ENV !== "production";
23
18
  */
24
19
  function DialogClose({ action, value, disabled = false, className, style, children, render, ...rest }) {
25
20
  const ctx = useDialogContext("Dialog.Close");
26
- const { pending, run } = useActionTrigger({ openGeneration: ctx.openGeneration });
27
- const { ids, dialogRef, recordCloseIntent } = ctx;
21
+ const { popupRef, recordCloseIntent } = ctx;
28
22
  const isLibrary = ctx.mode === "library";
29
- const installClick = isLibrary || action !== void 0;
30
- const focusable = installClick && !isHostButton(render);
31
- const noInvoker = focusable && disabled;
32
- const state = {
33
- pending,
34
- disabled
35
- };
36
- const devRef = useCallback((element) => {
37
- if (isDev && !installClick && element.tagName !== "BUTTON") console.error(`Dialog.Close: rendered a <${element.tagName.toLowerCase()}> in JS-free mode without \`action\`. Only a <button> runs \`command="request-close"\`; this element will not close the dialog.`);
38
- return () => {};
39
- }, [installClick]);
40
- const close = (event, returnValue) => {
41
- if (isLibrary) {
42
- ctx.requestClose(event, "activate", returnValue);
43
- return;
44
- }
45
- const dialog = dialogRef.current;
46
- if (dialog === null || !dialog.open) return;
47
- recordCloseIntent({
48
- reason: "activate",
49
- event
50
- });
51
- dialog.close(returnValue);
52
- };
53
- const onClick = (event) => {
54
- event.preventDefault();
55
- if (disabled) return;
56
- const native = event.nativeEvent;
57
- const returnValue = value ?? "";
58
- if (action === void 0) {
59
- close(native, returnValue);
60
- return;
61
- }
62
- const details = createActionDetails(native, { returnValue });
63
- run(() => action(details), () => close(native, returnValue));
64
- };
65
- const libraryProps = {
66
- ...rendersButton(render) && { type: "button" },
67
- disabled: focusable ? void 0 : disabled,
68
- commandfor: noInvoker ? void 0 : ids.dialog,
69
- command: noInvoker ? void 0 : "request-close",
70
- value,
71
- ...installClick && { onClick },
72
- "aria-disabled": pending || focusable && disabled ? true : void 0,
73
- "data-pending": dataAttr(pending),
74
- "data-disabled": dataAttr(disabled)
75
- };
76
- return useRender({
77
- defaultElement: "button",
78
- render,
79
- state,
23
+ return useOverlayClose({
24
+ part: "Dialog.Close",
25
+ noun: "dialog",
26
+ isLibrary,
27
+ popupId: ctx.ids.popup,
28
+ command: "request-close",
29
+ openGeneration: ctx.openGeneration,
30
+ action,
31
+ details: (event) => createActionDetails(event, { returnValue: value ?? "" }),
32
+ close: (event) => {
33
+ const returnValue = value ?? "";
34
+ if (isLibrary) {
35
+ ctx.requestClose(event, "activate", returnValue);
36
+ return;
37
+ }
38
+ const dialog = popupRef.current;
39
+ if (dialog === null || !dialog.open) return;
40
+ recordCloseIntent({
41
+ reason: "activate",
42
+ event
43
+ });
44
+ dialog.close(returnValue);
45
+ },
46
+ ownProps: { value },
47
+ disabled,
80
48
  className,
81
49
  style,
82
50
  children,
83
- props: rest,
84
- libraryProps,
85
- ref: devRef
51
+ render,
52
+ rest
86
53
  });
87
54
  }
88
55
  DialogClose.displayName = "DialogClose";
@@ -1 +1 @@
1
- {"version":3,"file":"dialog-close.mjs","names":[],"sources":["../../src/dialog/dialog-close.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, MouseEvent, ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { Action, ActionDetails, RenderProp, StateValue } from \"../internal/types.js\";\nimport { useActionTrigger } from \"../internal/use-action-trigger.js\";\nimport { isHostButton, rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { useDialogContext } from \"./dialog-context.js\";\n\nexport interface DialogCloseState {\n /** The `action` is in flight. */\n readonly pending: boolean;\n readonly disabled: boolean;\n}\n\n/** Details passed to `Dialog.Close`'s `action`. */\nexport interface DialogCloseDetails extends ActionDetails {\n /** The `value` the dialog closes with (`dialog.returnValue`); `\"\"` without `value`. */\n readonly returnValue: string;\n}\n\nexport interface DialogCloseProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"value\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Runs inside this part's own transition (`data-pending` on the button), then closes the\n * dialog with `value` as `returnValue`: in library mode through the Root\n * (`openChangeAction(false)` awaited, view transition if set), in JS-free mode with\n * `close(value)`. A rejection reaches the nearest Error Boundary above the Close part and\n * leaves the dialog open. If the dialog was dismissed and opened again while the action ran,\n * the close is dropped: it belonged to the earlier open. Without `action` in JS-free mode the\n * button is a native `command=\"request-close\"` invoker.\n */\n action?: Action<[details: DialogCloseDetails]>;\n /** Becomes `dialog.returnValue` (and `details.returnValue` of `openChangeAction(false)`). */\n value?: string;\n /**\n * Never closes. Native `disabled` on a `<button>`; owned, so a `render` element cannot\n * re-enable it. With a link or component `render` whose click this part handles (library mode,\n * or with `action`), `aria-disabled=\"true\"` instead: the element stays focusable.\n */\n disabled?: boolean;\n className?: StateValue<string | undefined, DialogCloseState>;\n style?: StateValue<CSSProperties | undefined, DialogCloseState>;\n children?: StateValue<ReactNode, DialogCloseState>;\n render?: RenderProp<ComponentPropsWithRef<\"button\">, DialogCloseState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * A close button: `<button type=\"button\" commandfor command=\"request-close\">`. In JS-free mode\n * without `action` the browser closes the dialog (a close request: `cancel`, then `close`), with\n * `value` as the `returnValue`. In library mode the click is always cancelled and the close goes\n * through the Root (`openChangeAction(false)` awaited, then `close(value)` in the commit, inside\n * the view transition if the Popup's `transition` is set). With `action` the action runs first in\n * this part's own transition (`data-pending` and `aria-disabled` on the button; a second click\n * meanwhile is ignored); a rejection leaves the dialog open.\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>` only), `disabled`, `commandfor`,\n * `command`, `value`, `onClick` (library mode, or with `action`), `aria-disabled`, `data-pending`,\n * `data-disabled`.\n */\nexport function DialogClose({\n action,\n value,\n disabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: DialogCloseProps) {\n const ctx = useDialogContext(\"Dialog.Close\");\n // The open-generation guard: a close from a previous opening must not close a new one.\n const { pending, run } = useActionTrigger({ openGeneration: ctx.openGeneration });\n const { ids, dialogRef, recordCloseIntent } = ctx;\n const isLibrary = ctx.mode === \"library\";\n const hasAction = action !== undefined;\n const installClick = isLibrary || hasAction;\n // A link or component render whose click this part handles: `aria-disabled`, enforced by the\n // handler (#83). JS-free mode without `action` is the browser's `request-close` command,\n // which only native `disabled` stops.\n const focusable = installClick && !isHostButton(render);\n // Disabled in the `aria-disabled` branch: no `commandfor` / `command` either. Without native\n // `disabled` the element would still be a live invoker before hydration (a component render\n // spreading onto a real <button>), and the command would run (wave 9 review M1).\n const noInvoker = focusable && disabled;\n\n const state: DialogCloseState = { pending, disabled };\n\n const devRef = useCallback(\n (element: HTMLElement) => {\n if (isDev && !installClick && element.tagName !== \"BUTTON\") {\n console.error(\n `Dialog.Close: rendered a <${element.tagName.toLowerCase()}> in JS-free mode without ` +\n '`action`. Only a <button> runs `command=\"request-close\"`; this element will not ' +\n \"close the dialog.\",\n );\n }\n // A cleanup, so the merged ref never calls back with `null`.\n return () => {};\n },\n [installClick],\n );\n\n const close = (event: Event, returnValue: string): void => {\n if (isLibrary) {\n // A library-owned close (design 2.3): awaited, then `close(returnValue)` in the commit. A\n // no-op when `false` is already intended (a repeated click, or a dismissal meanwhile).\n ctx.requestClose(event, \"activate\", returnValue);\n return;\n }\n // JS-free mode with `action`: a browser-owned close; there is no Root state to go through.\n const dialog = dialogRef.current;\n if (dialog === null || !dialog.open) return;\n recordCloseIntent({ reason: \"activate\", event });\n dialog.close(returnValue);\n };\n\n const onClick = (event: MouseEvent<HTMLElement>) => {\n // Cancelling the click cancels the command.\n event.preventDefault();\n if (disabled) return;\n const native = event.nativeEvent;\n const returnValue = value ?? \"\";\n if (action === undefined) {\n close(native, returnValue);\n return;\n }\n const details = createActionDetails(native, { returnValue });\n // A second activation while this Close's own run is in flight starts nothing (the hook's\n // guard; the click is already cancelled above, #81). A close whose open was superseded by a\n // newer one (dismissed and re-opened meanwhile) is dropped by the hook.\n run(\n () => action(details),\n () => close(native, returnValue),\n );\n };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n // Owned: a render element must not re-enable a disabled Close. Absent in the focusable branch.\n disabled: focusable ? undefined : disabled,\n commandfor: noInvoker ? undefined : ids.dialog,\n command: noInvoker ? undefined : \"request-close\",\n value,\n ...(installClick && { onClick }),\n // Exactly while `data-pending` (#81): a Close that will not act is unavailable to AT. Owned,\n // so an idle Close removes a render element's own `aria-disabled`.\n \"aria-disabled\": pending || (focusable && disabled) ? true : undefined,\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, DialogCloseState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps,\n ref: devRef,\n });\n}\n\nDialogClose.displayName = \"DialogClose\";\n"],"mappings":";;;;;;;;;AAmDA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;;;AAevC,SAAgB,YAAY,EAC1B,QACA,OACA,WAAW,OACX,WACA,OACA,UACA,QACA,GAAG,QACgB;CACnB,MAAM,MAAM,iBAAiB,cAAc;CAE3C,MAAM,EAAE,SAAS,QAAQ,iBAAiB,EAAE,gBAAgB,IAAI,eAAe,CAAC;CAChF,MAAM,EAAE,KAAK,WAAW,sBAAsB;CAC9C,MAAM,YAAY,IAAI,SAAS;CAE/B,MAAM,eAAe,aADH,WAAW,KAAA;CAK7B,MAAM,YAAY,gBAAgB,CAAC,aAAa,MAAM;CAItD,MAAM,YAAY,aAAa;CAE/B,MAAM,QAA0B;EAAE;EAAS;CAAS;CAEpD,MAAM,SAAS,aACZ,YAAyB;EACxB,IAAI,SAAS,CAAC,gBAAgB,QAAQ,YAAY,UAChD,QAAQ,MACN,6BAA6B,QAAQ,QAAQ,YAAY,EAAE,gIAG7D;EAGF,aAAa,CAAC;CAChB,GACA,CAAC,YAAY,CACf;CAEA,MAAM,SAAS,OAAc,gBAA8B;EACzD,IAAI,WAAW;GAGb,IAAI,aAAa,OAAO,YAAY,WAAW;GAC/C;EACF;EAEA,MAAM,SAAS,UAAU;EACzB,IAAI,WAAW,QAAQ,CAAC,OAAO,MAAM;EACrC,kBAAkB;GAAE,QAAQ;GAAY;EAAM,CAAC;EAC/C,OAAO,MAAM,WAAW;CAC1B;CAEA,MAAM,WAAW,UAAmC;EAElD,MAAM,eAAe;EACrB,IAAI,UAAU;EACd,MAAM,SAAS,MAAM;EACrB,MAAM,cAAc,SAAS;EAC7B,IAAI,WAAW,KAAA,GAAW;GACxB,MAAM,QAAQ,WAAW;GACzB;EACF;EACA,MAAM,UAAU,oBAAoB,QAAQ,EAAE,YAAY,CAAC;EAI3D,UACQ,OAAO,OAAO,SACd,MAAM,QAAQ,WAAW,CACjC;CACF;CAEA,MAAM,eAAiE;EACrE,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;EAEvD,UAAU,YAAY,KAAA,IAAY;EAClC,YAAY,YAAY,KAAA,IAAY,IAAI;EACxC,SAAS,YAAY,KAAA,IAAY;EACjC;EACA,GAAI,gBAAgB,EAAE,QAAQ;EAG9B,iBAAiB,WAAY,aAAa,WAAY,OAAO,KAAA;EAC7D,gBAAgB,SAAS,OAAO;EAChC,iBAAiB,SAAS,QAAQ;CACpC;CAEA,OAAO,UAA6D;EAClE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA,KAAK;CACP,CAAC;AACH;AAEA,YAAY,cAAc"}
1
+ {"version":3,"file":"dialog-close.mjs","names":[],"sources":["../../src/dialog/dialog-close.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport type { Action, ActionDetails, RenderProp, StateValue } from \"../internal/types.js\";\nimport { useOverlayClose } from \"../internal/use-overlay-close.js\";\nimport { useDialogContext } from \"./dialog-context.js\";\n\nexport interface DialogCloseState {\n /** The `action` is in flight. */\n readonly pending: boolean;\n readonly disabled: boolean;\n}\n\n/** Details passed to `Dialog.Close`'s `action`. */\nexport interface DialogCloseDetails extends ActionDetails {\n /** The `value` the dialog closes with (`dialog.returnValue`); `\"\"` without `value`. */\n readonly returnValue: string;\n}\n\nexport interface DialogCloseProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"value\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Runs inside this part's own transition (`data-pending` on the button), then closes the\n * dialog with `value` as `returnValue`: in library mode through the Root\n * (`openChangeAction(false)` awaited, view transition if set), in JS-free mode with\n * `close(value)`. A rejection reaches the nearest Error Boundary above the Close part and\n * leaves the dialog open. If the dialog was dismissed and opened again while the action ran,\n * the close is dropped: it belonged to the earlier open. Without `action` in JS-free mode the\n * button is a native `command=\"request-close\"` invoker.\n */\n action?: Action<[details: DialogCloseDetails]>;\n /** Becomes `dialog.returnValue` (and `details.returnValue` of `openChangeAction(false)`). */\n value?: string;\n /**\n * Never closes. Native `disabled` on a `<button>`; owned, so a `render` element cannot\n * re-enable it. With a link or component `render` whose click this part handles (library mode,\n * or with `action`), `aria-disabled=\"true\"` instead: the element stays focusable.\n */\n disabled?: boolean;\n className?: StateValue<string | undefined, DialogCloseState>;\n style?: StateValue<CSSProperties | undefined, DialogCloseState>;\n children?: StateValue<ReactNode, DialogCloseState>;\n render?: RenderProp<ComponentPropsWithRef<\"button\">, DialogCloseState>;\n}\n\n/**\n * A close button: `<button type=\"button\" commandfor command=\"request-close\">`. In JS-free mode\n * without `action` the browser closes the dialog (a close request: `cancel`, then `close`), with\n * `value` as the `returnValue`. In library mode the click is always cancelled and the close goes\n * through the Root (`openChangeAction(false)` awaited, then `close(value)` in the commit, inside\n * the view transition if the Popup's `transition` is set). With `action` the action runs first in\n * this part's own transition (`data-pending` and `aria-disabled` on the button; a second click\n * meanwhile is ignored); a rejection leaves the dialog open.\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>` only), `disabled`, `commandfor`,\n * `command`, `value`, `onClick` (library mode, or with `action`), `aria-disabled`, `data-pending`,\n * `data-disabled`.\n */\nexport function DialogClose({\n action,\n value,\n disabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: DialogCloseProps) {\n const ctx = useDialogContext(\"Dialog.Close\");\n const { popupRef, recordCloseIntent } = ctx;\n const isLibrary = ctx.mode === \"library\";\n return useOverlayClose({\n part: \"Dialog.Close\",\n noun: \"dialog\",\n isLibrary,\n popupId: ctx.ids.popup,\n command: \"request-close\",\n openGeneration: ctx.openGeneration,\n action,\n details: (event) => createActionDetails(event, { returnValue: value ?? \"\" }),\n close: (event) => {\n const returnValue = value ?? \"\";\n if (isLibrary) {\n // A library-owned close (design 2.3): awaited, then `close(returnValue)` in the commit. A\n // no-op when `false` is already intended (a repeated click, or a dismissal meanwhile).\n ctx.requestClose(event, \"activate\", returnValue);\n return;\n }\n // JS-free mode with `action`: a browser-owned close; there is no Root state to go through.\n const dialog = popupRef.current;\n if (dialog === null || !dialog.open) return;\n recordCloseIntent({ reason: \"activate\", event });\n dialog.close(returnValue);\n },\n ownProps: { value },\n disabled,\n className,\n style,\n children,\n render,\n rest,\n });\n}\n\nDialogClose.displayName = \"DialogClose\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4DA,SAAgB,YAAY,EAC1B,QACA,OACA,WAAW,OACX,WACA,OACA,UACA,QACA,GAAG,QACgB;CACnB,MAAM,MAAM,iBAAiB,cAAc;CAC3C,MAAM,EAAE,UAAU,sBAAsB;CACxC,MAAM,YAAY,IAAI,SAAS;CAC/B,OAAO,gBAAgB;EACrB,MAAM;EACN,MAAM;EACN;EACA,SAAS,IAAI,IAAI;EACjB,SAAS;EACT,gBAAgB,IAAI;EACpB;EACA,UAAU,UAAU,oBAAoB,OAAO,EAAE,aAAa,SAAS,GAAG,CAAC;EAC3E,QAAQ,UAAU;GAChB,MAAM,cAAc,SAAS;GAC7B,IAAI,WAAW;IAGb,IAAI,aAAa,OAAO,YAAY,WAAW;IAC/C;GACF;GAEA,MAAM,SAAS,SAAS;GACxB,IAAI,WAAW,QAAQ,CAAC,OAAO,MAAM;GACrC,kBAAkB;IAAE,QAAQ;IAAY;GAAM,CAAC;GAC/C,OAAO,MAAM,WAAW;EAC1B;EACA,UAAU,EAAE,MAAM;EAClB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH;AAEA,YAAY,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"dialog-context.mjs","names":[],"sources":["../../src/dialog/dialog-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { ChangeReason } from \"../internal/types.js\";\n\n/**\n * \"static\": JS-free mode, the browser owns open and close through Invoker Commands. \"library\":\n * opening and the closes a part asks for are library-owned (transitions keyed on committed\n * state); dismissals are browser-owned and notified (design section 2).\n */\nexport type DialogMode = \"static\" | \"library\";\n\n/**\n * What caused the next `close` event, recorded just before the close happens (design 2.3). The\n * `close` event carries no source; without an intent the close is a `\"dismiss\"`.\n */\nexport interface DialogCloseIntent {\n readonly reason: ChangeReason;\n readonly event: Event | undefined;\n}\n\nexport interface DialogContextValue {\n readonly mode: DialogMode;\n /** `useId`-based ids: the `<dialog>`, its Title and its Description. */\n readonly ids: { readonly dialog: string; readonly title: string; readonly description: string };\n readonly modal: boolean;\n /** Committed open state (library mode); `false` in static mode. */\n readonly committed: boolean;\n /** Optimistic open state (library mode); `false` in static mode. */\n readonly optimistic: boolean;\n /** The Root's transition is pending (library mode). */\n readonly pending: boolean;\n /**\n * Open the dialog through the Root's transition (library mode): a Trigger click, a foreign\n * `show-modal` command, or mount reconciliation. A no-op when the user already intends `true`.\n */\n readonly requestOpen: (event: Event | undefined, reason: ChangeReason) => void;\n /**\n * The dialog closed natively (a dismissal, not the library's own `close()`): dispatch the\n * `false` notification unless the user already intends `false`.\n */\n readonly notifyClosed: (event: Event, reason: ChangeReason, returnValue: string) => void;\n /**\n * What the user already intends: the latest in-flight dispatch's `next`, else the optimistic\n * value of the last commit. Safe to call from handlers and effects (layout effects included,\n * also in the commit that changed it), and after an `await`. Not during render.\n */\n readonly intended: () => boolean;\n /**\n * A library-owned close (library mode, design 2.3): a Close part, a `method=\"dialog\"` submit,\n * a Form's settle close, a foreign close command. Records `returnValue` for the apply effect's\n * `close()` and dispatches `false` (`openChangeAction(false)` awaited). A no-op when `false` is\n * already intended.\n */\n readonly requestClose: (\n event: Event | undefined,\n reason: ChangeReason,\n returnValue: string,\n ) => void;\n /**\n * Read and clear the `returnValue` of the pending part-initiated close, for the apply effect's\n * `close()`; `\"\"` when there is none (a controlled close).\n */\n readonly takeCloseReturnValue: () => string;\n /** From `useControllableAction`: the latest in-flight intent, or `null`. */\n readonly latestInFlight: () => { readonly next: boolean } | null;\n /** The registered Trigger element, for the focus-return fallback (design 6.2). */\n readonly triggerRef: RefObject<HTMLElement | null>;\n /** The `<dialog>`, set by the Popup's ref; how Close and Form reach `close(value)`. */\n readonly dialogRef: RefObject<HTMLDialogElement | null>;\n /** Record what causes the next close. Cleared after a task if the dialog did not close. */\n readonly recordCloseIntent: (intent: DialogCloseIntent | undefined) => void;\n /** Read and clear the recorded intent (the Popup's `close` listener). */\n readonly takeCloseIntent: () => DialogCloseIntent | undefined;\n /**\n * Counts the opens of this dialog. A Close action reads it when it starts and skips its close\n * if a newer open started meanwhile (the dialog was dismissed and opened again).\n */\n readonly openGeneration: () => number;\n /** Advance `openGeneration` (an open dispatch, the `<dialog>`'s native `beforetoggle` to open). */\n readonly nextOpenGeneration: () => void;\n}\n\nexport const DialogContext = createContext<DialogContextValue | null>(null);\n\nexport function useDialogContext(part: string): DialogContextValue {\n const context = use(DialogContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Dialog.Root.`);\n }\n return context;\n}\n"],"mappings":";;;AAmFA,MAAa,gBAAgB,cAAyC,IAAI;AAE1E,SAAgB,iBAAiB,MAAkC;CACjE,MAAM,UAAU,IAAI,aAAa;CACjC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,wCAAwC;CAElE,OAAO;AACT"}
1
+ {"version":3,"file":"dialog-context.mjs","names":[],"sources":["../../src/dialog/dialog-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { ChangeReason } from \"../internal/types.js\";\nimport type { OverlayRootValue } from \"../internal/use-overlay-root.js\";\n\n/**\n * The Root's machinery (`useOverlayRoot`, as Popover's) with the `<dialog>` as the popup element\n * and a close's `returnValue`. `mode` \"static\" is JS-free mode, where the browser owns open and\n * close through Invoker Commands; in \"library\" mode opening and the closes a part asks for are\n * library-owned, dismissals browser-owned and notified (design section 2).\n */\nexport interface DialogContextValue extends OverlayRootValue<\n HTMLDialogElement,\n [returnValue: string]\n> {\n readonly modal: boolean;\n /**\n * A library-owned close (library mode, design 2.3): a Close part, a `method=\"dialog\"` submit,\n * a Form's settle close, a foreign close command. Records `returnValue` for the apply effect's\n * `close()` and dispatches `false` (`openChangeAction(false)` awaited). A no-op when `false` is\n * already intended. `notifyClosed` (a native close) records nothing.\n */\n readonly requestClose: (\n event: Event | undefined,\n reason: ChangeReason,\n returnValue: string,\n ) => void;\n /**\n * Read and clear the `returnValue` of the pending part-initiated close, for the apply effect's\n * `close()`; `\"\"` when there is none (a controlled close).\n */\n readonly takeCloseReturnValue: () => string;\n}\n\nexport const DialogContext = createContext<DialogContextValue | null>(null);\n\nexport function useDialogContext(part: string): DialogContextValue {\n const context = use(DialogContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Dialog.Root.`);\n }\n return context;\n}\n"],"mappings":";;;AAkCA,MAAa,gBAAgB,cAAyC,IAAI;AAE1E,SAAgB,iBAAiB,MAAkC;CACjE,MAAM,UAAU,IAAI,aAAa;CACjC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,wCAAwC;CAElE,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"dialog-form.d.mts","names":[],"sources":["../../src/dialog/dialog-form.tsx"],"mappings":";;;iBAWiB;;WAEN;;iBAGM,wBAAwB,KACvC;;;;;;;;;;;;EAcA,oBAAoB,UAAU;;;;;;;;;;;;;;;;;;;EAmB9B;;;;;EAKA,SAAS;EACT,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,+BAA+B;;;;;;;;;;;;;;;;;;wBAmBrC,aACd,QACA,eACA,QACA,WACA,OACA,UACA,WACG,QACF,kBAAe;yBATF"}
1
+ {"version":3,"file":"dialog-form.d.mts","names":[],"sources":["../../src/dialog/dialog-form.tsx"],"mappings":";;;iBAaiB;;WAEN;;iBAGM,wBAAwB,KACvC;;;;;;;;;;;;EAcA,oBAAoB,UAAU;;;;;;;;;;;;;;;;;;;EAmB9B;;;;;EAKA,SAAS;EACT,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,+BAA+B;;;;;;;;;;;;;;;;;;wBAmBrC,aACd,QACA,eACA,QACA,WACA,OACA,UACA,WACG,QACF,kBAAe;yBATF"}
@@ -9,6 +9,7 @@ import { hasAnyError } from "../internal/validity.mjs";
9
9
  import { use, useCallback, useRef, useState } from "react";
10
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
11
  //#region src/dialog/dialog-form.tsx
12
+ const isDev = process.env.NODE_ENV !== "production";
12
13
  /**
13
14
  * A form that completes the dialog. Without `action`: `<form method="dialog">`, so a submit
14
15
  * closes the dialog with the submitter's `value` as `returnValue` (natively in JS-free mode;
@@ -27,7 +28,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
27
28
  */
28
29
  function DialogForm({ action, closeOnSettle = true, method, className, style, children, render, ...rest }) {
29
30
  const ctx = useDialogContext("Dialog.Form");
30
- const { dialogRef, recordCloseIntent, requestClose } = ctx;
31
+ const { popupRef, recordCloseIntent, requestClose } = ctx;
31
32
  const isLibrary = ctx.mode === "library";
32
33
  const [pending, setPending] = useState(false);
33
34
  const submission = useRef(null);
@@ -55,7 +56,7 @@ function DialogForm({ action, closeOnSettle = true, method, className, style, ch
55
56
  };
56
57
  }, []);
57
58
  const onSettled = useCallback((clean) => {
58
- const dialog = dialogRef.current;
59
+ const dialog = popupRef.current;
59
60
  const submitted = submission.current;
60
61
  submission.current = null;
61
62
  if (!closeOnSettle || closedSinceSubmit.current) return;
@@ -73,7 +74,7 @@ function DialogForm({ action, closeOnSettle = true, method, className, style, ch
73
74
  dialog.close(returnValue);
74
75
  }, [
75
76
  closeOnSettle,
76
- dialogRef,
77
+ popupRef,
77
78
  isLibrary,
78
79
  recordCloseIntent,
79
80
  requestClose
@@ -107,7 +108,7 @@ DialogForm.displayName = "DialogForm";
107
108
  */
108
109
  function DialogFormSettle({ watches, missingAction, onPendingChange, onSettled }) {
109
110
  const form = use(FormContext);
110
- useDevWarning(form !== null && missingAction, "`Dialog.Form` rendered as a `Form.Root` needs a function `action`; without one the form navigates instead of closing the dialog. Render a plain `<Dialog.Form>` for a `method=\"dialog\"` form.");
111
+ useDevWarning(form !== null && missingAction, isDev && "`Dialog.Form` rendered as a `Form.Root` needs a function `action`; without one the form navigates instead of closing the dialog. Render a plain `<Dialog.Form>` for a `method=\"dialog\"` form.");
111
112
  const isForm = form !== null;
112
113
  const errors = form?.errors;
113
114
  const settled = useCallback(() => onSettled(!isForm || !hasAnyError(errors)), [