@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
@@ -0,0 +1,686 @@
1
+ # Dialog
2
+
3
+ Built on `<dialog>`, `showModal()` and Invoker Commands. The platform supplies the top layer, the backdrop, the inert page, Escape, initial focus and focus return. The library adds the asynchronous half: opening a dialog whose content loads is a transition, so the trigger shows `data-pending` and the dialog opens once its content is ready, and closing it with one of its parts waits for your action and can animate with a view transition.
4
+
5
+ ```tsx title="DialogConfirm.tsx"
6
+ // No "use client": this file is a Server Component. The Dialog.Root has no `open`, `defaultOpen`
7
+ // or `openChangeAction`, so it runs in JS-free mode: the Trigger is a native
8
+ // `command="show-modal"` invoker, Cancel is a `command="request-close"` button and Delete submits
9
+ // a `<form method="dialog">`. The browser opens, focuses, closes on Escape and returns focus,
10
+ // before hydration and with JavaScript off.
11
+ import { Dialog } from "@funstack/ui/dialog";
12
+
13
+ export function DialogConfirm() {
14
+ return (
15
+ <Dialog.Root>
16
+ <Dialog.Trigger className="demo-button">Delete draft…</Dialog.Trigger>
17
+ <Dialog.Popup className="demo-dialog" role="alertdialog">
18
+ <Dialog.Title>Delete this draft?</Dialog.Title>
19
+ <Dialog.Description>This cannot be undone.</Dialog.Description>
20
+ <Dialog.Form className="demo-dialog-actions">
21
+ <Dialog.Close className="demo-button" value="cancel">
22
+ Cancel
23
+ </Dialog.Close>
24
+ <button type="submit" className="demo-button demo-danger" value="delete">
25
+ Delete
26
+ </button>
27
+ </Dialog.Form>
28
+ </Dialog.Popup>
29
+ </Dialog.Root>
30
+ );
31
+ }
32
+ ```
33
+
34
+ ```css title="dialog.css"
35
+ /* Dialog: the Popup is the <dialog> itself. Open state is `:open` / `:modal` on it (exact in
36
+ both modes); the Trigger carries `data-open` / `data-pending` in library mode only. */
37
+
38
+ /* CSS-only scroll lock, keyed on :modal: covers dialogs opened before hydration and nested ones. */
39
+ html:has(.demo-dialog:modal) {
40
+ overflow: hidden;
41
+ }
42
+
43
+ .demo-dialog {
44
+ inline-size: min(28rem, calc(100vw - 32px));
45
+ padding: 20px 24px;
46
+ border: 1px solid var(--color-border);
47
+ border-radius: 10px;
48
+ background: var(--color-bg);
49
+ color: var(--color-text);
50
+ box-shadow: 0 12px 40px rgb(0 0 0 / 0.3);
51
+ overscroll-behavior: contain;
52
+ }
53
+
54
+ .demo-dialog::backdrop {
55
+ background: rgb(0 0 0 / 0.45);
56
+ }
57
+
58
+ .demo-dialog h2 {
59
+ margin: 0 0 8px;
60
+ padding: 0;
61
+ border: 0;
62
+ font-size: 1.2rem;
63
+ }
64
+
65
+ .demo-dialog p {
66
+ margin: 0 0 12px;
67
+ color: var(--color-text-secondary);
68
+ }
69
+
70
+ /* Enter and exit with CSS, both modes. Enter works everywhere; the exit animates in Chromium
71
+ (with `overlay`) and Safari and is instant in Firefox. */
72
+ .demo-dialog,
73
+ .demo-dialog::backdrop {
74
+ opacity: 0;
75
+ transition:
76
+ opacity 150ms,
77
+ translate 150ms,
78
+ display 150ms allow-discrete,
79
+ overlay 150ms allow-discrete;
80
+ }
81
+
82
+ .demo-dialog {
83
+ translate: 0 8px;
84
+ }
85
+
86
+ .demo-dialog:open,
87
+ .demo-dialog:open::backdrop {
88
+ opacity: 1;
89
+ translate: 0 0;
90
+ }
91
+
92
+ @starting-style {
93
+ .demo-dialog:open,
94
+ .demo-dialog:open::backdrop {
95
+ opacity: 0;
96
+ }
97
+ .demo-dialog:open {
98
+ translate: 0 8px;
99
+ }
100
+ }
101
+
102
+ /* With `transition`, a view transition animates the library-driven opens and closes (a Close
103
+ part, a Form, a controlled close), Firefox included; dismissals (Escape, a click on the
104
+ backdrop) are the browser's and keep the CSS exit above. While a view transition runs the CSS
105
+ transition is cut: otherwise a closing dialog stays rendered through its fade, and Chromium
106
+ captures it in the close's new snapshot as well (a double image). */
107
+ html:active-view-transition .demo-dialog-vt {
108
+ transition: none;
109
+ }
110
+
111
+ ::view-transition-new(.demo-dialog-pop) {
112
+ animation: 180ms ease-out both demo-dialog-pop-in;
113
+ }
114
+
115
+ ::view-transition-old(.demo-dialog-pop) {
116
+ animation: 140ms ease-in both demo-dialog-pop-out;
117
+ }
118
+
119
+ @keyframes demo-dialog-pop-in {
120
+ from {
121
+ opacity: 0;
122
+ scale: 0.96;
123
+ }
124
+ }
125
+
126
+ @keyframes demo-dialog-pop-out {
127
+ to {
128
+ opacity: 0;
129
+ scale: 0.96;
130
+ }
131
+ }
132
+
133
+ @media (prefers-reduced-motion: reduce) {
134
+ .demo-dialog,
135
+ .demo-dialog::backdrop {
136
+ transition: none;
137
+ }
138
+ ::view-transition-group(*),
139
+ ::view-transition-old(*),
140
+ ::view-transition-new(*) {
141
+ animation: none !important;
142
+ }
143
+ }
144
+
145
+ .demo-dialog-actions {
146
+ display: flex;
147
+ justify-content: flex-end;
148
+ gap: 8px;
149
+ margin-top: 16px;
150
+ }
151
+
152
+ .demo-dialog-form label {
153
+ display: grid;
154
+ gap: 4px;
155
+ }
156
+
157
+ .demo-dialog-form input {
158
+ padding: 0.35em 0.6em;
159
+ border: 1px solid var(--color-border);
160
+ border-radius: 6px;
161
+ background: var(--color-bg);
162
+ color: var(--color-text);
163
+ font: inherit;
164
+ }
165
+
166
+ .demo-dialog-details {
167
+ display: grid;
168
+ grid-template-columns: auto 1fr;
169
+ gap: 4px 16px;
170
+ margin: 0;
171
+ }
172
+
173
+ .demo-dialog-details dd {
174
+ margin: 0;
175
+ }
176
+
177
+ /* The Trigger in library mode: optimistic open and pending. */
178
+ .demo-button[data-open] {
179
+ border-color: var(--color-primary);
180
+ color: var(--color-primary);
181
+ }
182
+
183
+ .demo-button[data-pending] {
184
+ cursor: progress;
185
+ }
186
+
187
+ ul.demo-list {
188
+ margin: 0 0 12px;
189
+ padding: 0;
190
+ list-style: none;
191
+ }
192
+
193
+ ul.demo-list .demo-row {
194
+ justify-content: space-between;
195
+ max-inline-size: 20rem;
196
+ padding-block: 4px;
197
+ }
198
+ ```
199
+
200
+ This confirmation is a Server Component in JS-free mode. Every button is a native invoker or a `method="dialog"` submit, so it works before hydration and with JavaScript disabled.
201
+
202
+ ## Anatomy
203
+
204
+ ```tsx
205
+ import { Dialog } from "@funstack/ui/dialog";
206
+
207
+ <Dialog.Root> {/* no DOM: ids, mode, state */}
208
+ <Dialog.Trigger>Edit profile</Dialog.Trigger> {/* button[commandfor][command=show-modal] */}
209
+ <Dialog.Popup> {/* dialog */}
210
+ <Dialog.Title>Edit profile</Dialog.Title> {/* h2, wired to aria-labelledby */}
211
+ <Dialog.Description>…</Dialog.Description> {/* p, wired to aria-describedby */}
212
+ <Dialog.Form action={saveProfile}> {/* form: closes after the action settles */}
213
+ <input name="name" />
214
+ <Dialog.Close>Cancel</Dialog.Close> {/* button[commandfor][command=request-close] */}
215
+ <button type="submit">Save</button>
216
+ </Dialog.Form>
217
+ </Dialog.Popup>
218
+ </Dialog.Root>
219
+ ```
220
+
221
+ - **Root renders no DOM.** Trigger and Popup need not be siblings: `commandfor` links them by id. A Popup without a Trigger is fine (controlled `open`); a Trigger without a Popup is a development warning. A `<button commandfor command>` of your own that targets the dialog is a [foreign invoker](../concepts/browser-owned-state.md#foreign-invoker); in library mode it goes through the library too.
222
+ - **Popup is the `<dialog>` itself**, so it carries `::backdrop`. There is no Portal, Backdrop or Positioner part: the top layer makes them unnecessary. Nothing inside the dialog portals out of it.
223
+ - `render`: Popup must render a `<dialog>`, Form a `<form>`. Trigger and Close must render a `<button>` for the command path; another element works only through a click handler (Trigger in library mode, Close with `action`). Wrong elements are development warnings.
224
+
225
+ ## How it works
226
+
227
+ ### Two modes
228
+
229
+ | | JS-free mode | Library mode |
230
+ | - | - | - |
231
+ | Selected when | Root has none of `open`, `defaultOpen`, `openChangeAction` | Root has any of them |
232
+ | Open | the browser runs `command="show-modal"` | the click is intercepted and dispatched in the Root's transition; `showModal()` runs in the commit that mounts the content |
233
+ | Close by a part (Close, Form, a foreign close command, controlled `open={false}`) | the browser | the click, submit or command is cancelled and dispatched in the Root's transition; `close(returnValue)` runs in the commit that ends it |
234
+ | Dismissal (Escape, Android back, a click outside) | the browser | the browser, at once; `openChangeAction(false)` is a notification |
235
+ | Popup content | always mounted (in the server HTML) | rendered from committed `open`; unmounted while closed unless `keepMounted` |
236
+ | Trigger `data-open`, `data-pending` | not emitted; style `:open` on the dialog | emitted (optimistic) |
237
+ | Before hydration | everything works | the native open happens; the content arrives on hydration (see below) |
238
+ | `transition` on Popup | no effect (development warning) | animates opens, content swaps and every library-driven close |
239
+
240
+ In library mode, opening and [a part's close](../concepts/browser-owned-state.md#parts-close) are the library's; a [dismissal](../concepts/browser-owned-state.md#dismissal) (Escape, Android back, a click outside) is the browser's, and the Root is notified afterwards ([Parts vs dismissals](../concepts/browser-owned-state.md#parts-vs-dismissals)). The mode is decided on the first render; switching later is not supported (development warning).
241
+
242
+ ## Props
243
+
244
+ ### `Dialog.Root`
245
+
246
+ | Prop | Type | Default | Description |
247
+ | - | - | - | - |
248
+ | `open` | `boolean` | – | Controlled open state. undefined means uncontrolled. Selects library mode. |
249
+ | `defaultOpen` | `boolean` | – | Initial open state in uncontrolled library mode. A dialog that starts open is shown after hydration, never by the server HTML; its content and the Trigger's open state are already in that HTML. `defaultOpen={false}` is the usual way to select library mode without an action. |
250
+ | `openChangeAction` | `ChangeAction<boolean, DialogOpenChangeDetails>` | – | Awaited for `true`: the dialog opens when it resolves and the content has rendered. Awaited for a `false` the user asked a part for (a `Dialog.Close`, a `Dialog.Form` submit or settled action, a foreign close command): the dialog closes with `details.returnValue` when it resolves, with a view transition if the Popup has `transition`; a controlled parent that keeps `open` vetoes it. A notification for a dismissal (Escape, a click outside): the dialog is already closed when it runs. Runs in the Root's transition; may be a Server Function; rejections reach the nearest Error Boundary above the Root. `details`: `reason` (`"activate"`, `"dismiss"` or `"platform"`) and `returnValue` (the closing button's or submitter's `value`, `""` for a dismiss, `undefined` on open). Selects library mode. |
251
+ | `modal` | `boolean` | `true` | `showModal()` (top layer, backdrop, inert page, Escape) or `show()`. A non-modal dialog has no command to open it, so its Trigger always uses a click handler: in JS-free mode too, it needs JavaScript to open. |
252
+ | `children` | `ReactNode \| ((state: DialogRootState) => ReactNode)` | – | The parts. The function form receives the optimistic state and must not suspend. |
253
+
254
+ - **State**: `DialogRootState` is `{ open, pending, modal }`; `open` is optimistic, and `open` and `pending` are `false` in JS-free mode.
255
+ - **Owned**: nothing rendered: the Root has no element (no `ref`, `className` or `style`).
256
+
257
+ ### `Dialog.Trigger`
258
+
259
+ One per Root: focus returns to the Trigger that mounted last, and a non-modal dialog treats a press on any other one as outside. A second `Dialog.Trigger` in the same Root is not supported (development warns); use a Root per trigger.
260
+
261
+ | Prop | Type | Default | Description |
262
+ | - | - | - | - |
263
+ | `disabled` | `boolean` | `false` | Native `disabled`: a disabled button is not an invoker and never opens. With a link or component `render` where the Trigger handles the click (library mode, or a non-modal dialog), `aria-disabled="true"` instead (the element stays focusable). |
264
+ | `className` | `string \| ((state: DialogTriggerState) => string \| undefined)` | – | A class name, or a function of the part's state. |
265
+ | `style` | `CSSProperties \| ((state: DialogTriggerState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
266
+ | `children` | `ReactNode \| ((state: DialogTriggerState) => ReactNode)` | – | Rendered from optimistic state; must not suspend. |
267
+ | `render` | `ReactElement \| ((props, state: DialogTriggerState) => ReactNode)` | – | Replace the default \<button> (element form) or take over rendering (function form). |
268
+
269
+ - **State**: `DialogTriggerState` is `{ open, pending, disabled }`; `pending` is true while the Root is pending: an open in flight, a part's close waiting for `openChangeAction(false)`, a close notification in flight, or a re-open requested while a close notification is still settling.
270
+ - **Owned**: `type` (on a `<button>` only), `disabled`, `aria-disabled` (a link or component `render` with the click handler installed), `commandfor`, `command` (not on a link or other non-button host element), `onClick` (when it installs one), `onPointerDown` (non-modal JS-free mode), `data-open`, `data-pending`, `data-disabled`.
271
+
272
+ ### `Dialog.Popup`
273
+
274
+ | Prop | Type | Default | Description |
275
+ | - | - | - | - |
276
+ | `keepMounted` | `boolean` | `false` | Library mode. `false`: children are not rendered while closed, so content that suspends holds the open until it is ready. `true`: children stay in `<Activity mode="hidden">` (state kept, effects stopped, pre-rendered at low priority; not in the server HTML). Either way, unmounting waits for the dialog's CSS exit animation, or happens inside the close's view transition when `transition` is set. Ignored in JS-free mode (always mounted). |
277
+ | `initialFocus` | `RefObject<HTMLElement \| null> \| string` | – | The element to focus on open: a ref, or a selector resolved inside the dialog. The library writes `autofocus` on it right before `showModal()` and lets the platform focus it; it never calls `.focus()`. Default: the platform's choice (the first focusable element). In JS-free mode the attribute is written after mount; prefer it to `autoFocus`, which React writes only into server-rendered HTML (not when the Popup renders on the client, for example after a client navigation to a Server Component page). |
278
+ | `lightDismiss` | `boolean` | `false` | Close on a click outside the dialog (the `::backdrop` for a modal). JS `pointerdown` and `click` listeners: both the press and the click must land outside, so a drag that starts inside (selecting text) never closes. With `experimental_closedBy`, native `closedby="any"`, which behaves the same. A click on the Trigger of an open non-modal dialog counts as outside, as native `closedby="any"` treats it: the dialog ends closed and the click does not re-open it, in JS-free and library mode. |
279
+ | `experimental_closedBy` | `boolean` | `false` | Renders `closedby` (`"any"` with `lightDismiss`, else `"closerequest"`) and skips the JS dismiss listeners where the browser implements it (Chromium, Firefox). Elsewhere the JS stays. See [Experimental features](../concepts/experimental.md). |
280
+ | `transition` | `ViewTransitionClass` | – | Library mode only. Forwarded to the `<ViewTransition>` around the dialog; without it no boundary is rendered. Animates the opening commit, content swaps while open, and every library-driven close (a Close part, a Form submit or settled action, a foreign close command, a controlled `open={false}`) in all engines. Dismissals (Escape, a click outside) are the browser's and animate with CSS only. Keep it static; any value makes a Root inserted by a transition run the page cross-fade. |
281
+ | `className` | `string \| ((state: DialogPopupState) => string \| undefined)` | – | A class name, or a function of the part's state. |
282
+ | `style` | `CSSProperties \| ((state: DialogPopupState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
283
+ | `children` | `ReactNode \| ((state: DialogPopupState) => ReactNode)` | – | Content, or a function of the part's state. |
284
+ | `render` | `ReactElement \| ((props, state: DialogPopupState) => ReactNode)` | – | Replace the default \<dialog> (element form) or take over rendering (function form). |
285
+
286
+ - **State**: `DialogPopupState` is `{ open, modal }`; `open` is committed (`false` in JS-free mode; `:open` is the DOM truth).
287
+ - **Owned**: `id`, `open` (never rendered: opening goes through `showModal()` only), `closedby`, `data-modal`, `suppressHydrationWarning`; `aria-labelledby` and `aria-describedby` are merged with yours. `onToggle` and `onBeforeToggle` are not accepted: use a `ref` for the platform events.
288
+
289
+ Other props, such as `role="alertdialog"` or `onCancel`, pass through.
290
+
291
+ ### `Dialog.Close`
292
+
293
+ | Prop | Type | Default | Description |
294
+ | - | - | - | - |
295
+ | `action` | `Action<[details: DialogCloseDetails]>` | – | Runs in this button's own transition (`data-pending` on it), then closes the dialog with `value` as `returnValue`: in library mode through the Root (`openChangeAction(false)` awaited, view transition if set; the button stays pending until the dialog closes), in JS-free mode with `close(value)`. A rejection reaches the nearest Error Boundary above the button and leaves the dialog open. If the dialog was closed and opened again while the action ran, the close is dropped: it belonged to the previous opening. A second click while it is pending is ignored, and the button is `aria-disabled="true"` meanwhile. Without `action` the button is a native `command="request-close"` invoker in JS-free mode and goes straight through the Root in library mode. `details.returnValue` is the `value`. |
296
+ | `value` | `string` | – | Becomes `dialog.returnValue`, and `details.returnValue` of `openChangeAction(false)`. |
297
+ | `disabled` | `boolean` | `false` | Native `disabled`; owned, so a `render` element cannot re-enable it. With a link or component `render` where the Close handles the click (library mode, or with `action`), `aria-disabled="true"` instead (the element stays focusable). |
298
+ | `className` | `string \| ((state: DialogCloseState) => string \| undefined)` | – | A class name, or a function of the part's state. |
299
+ | `style` | `CSSProperties \| ((state: DialogCloseState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
300
+ | `children` | `ReactNode \| ((state: DialogCloseState) => ReactNode)` | – | Content, or a function of the part's state. |
301
+ | `render` | `ReactElement \| ((props, state: DialogCloseState) => ReactNode)` | – | Replace the default \<button> (element form) or take over rendering (function form). |
302
+
303
+ - **State**: `DialogCloseState` is `{ pending, disabled }`.
304
+ - **Owned**: `type` (on a `<button>` only), `disabled`, `aria-disabled`, `commandfor`, `command` (not on a link or other non-button host element), `value`, `onClick` (library mode, or with `action`), `data-pending`, `data-disabled`; a `render` element cannot re-enable a disabled Close.
305
+
306
+ A second click, Enter or Space while the action is pending is ignored (and cancelled), and the button is `aria-disabled="true"` for as long as it shows `data-pending`, which spans the action and the close; it is never natively disabled, so it keeps focus. To close at once and finish the work in the background, do not return the promise: `action={() => { void save(); }}`.
307
+
308
+ ### `Dialog.Form`
309
+
310
+ | Prop | Type | Default | Description |
311
+ | - | - | - | - |
312
+ | `action` | `string \| ((formData: FormData) => unknown)` | – | Without `action` the form renders `method="dialog"`: a submit closes the dialog with the submitter's `value`, natively in JS-free mode and through the Root in library mode (`openChangeAction(false)` awaited, view transition if set). A `preventDefault()` in your `onSubmit` keeps it open in both modes. A function (may be a Server Function) is React's form action, passed through unwrapped; the dialog closes, in the same way, once the action's transition has settled, including any Suspense wait it causes (see `closeOnSettle`). A rejection leaves the dialog open. A string is a plain navigating form. |
313
+ | `closeOnSettle` | `boolean` | `true` | With a function `action`: close the dialog once the action settles without throwing and, when the form is rendered as a `Form.Root` (`render={<Form.Root errors={state.errors} />}`), with no field error: a settle whose `errors` has a non-empty entry (hidden stale ones included, the `autoReset` rule) keeps the dialog open and the Form focuses the first errored field. Without a `Form.Root` the library never sees a result, so any settle that does not throw counts, including a `useActionState` result that reports errors: render the form as a `Form.Root` to route them, throw to keep the dialog open, or set `false` and close it yourself (a `Dialog.Close`, a submit button in a separate `method="dialog"` form, or a controlled `open`; a `formMethod="dialog"` submitter inside this form runs the action again instead). The dialog is never closed when it was closed while the action ran, even if the user re-opened it meanwhile. |
314
+ | `method` | `string` | – | Only with a string `action` (for example `"post"`). Otherwise owned: `"dialog"` without `action`, React's own with a function. |
315
+ | `className` | `string \| ((state: DialogFormState) => string \| undefined)` | – | A class name, or a function of the part's state. |
316
+ | `style` | `CSSProperties \| ((state: DialogFormState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
317
+ | `children` | `ReactNode \| ((state: DialogFormState) => ReactNode)` | – | Content, or a function of the part's state. |
318
+ | `render` | `ReactElement \| ((props, state: DialogFormState) => ReactNode)` | – | Replace the default \<form> (element form) or take over rendering (function form). |
319
+
320
+ - **State**: `DialogFormState` is `{ pending }`, this form's `useFormStatus().pending`; it is not emitted as `data-pending` and not folded into any other part's state.
321
+ - **Owned**: `action`, and `method` unless `action` is a string.
322
+
323
+ With field errors from `useActionState`, render it as a `Form.Root`: `<Dialog.Form action={dispatch} render={<Form.Root errors={state.errors} />}>`. The Form then runs the action, routes the errors to its fields and resets the form only on success (React's own path resets it after every successful action), and the dialog closes only on a result with no field error: errors keep it open with the first errored field focused. The composition needs a function `action` (without one the form would navigate; a development warning says so). The reset runs before the close, so pass `autoReset={false}` on the `Form.Root` element if your exit animation is visible. See [Field and Form: in a Dialog](field.md#dialog-form).
324
+
325
+ ### `Dialog.Title`, `Dialog.Description`
326
+
327
+ | Prop | Type | Default | Description |
328
+ | - | - | - | - |
329
+ | `className` | `string \| ((state: DialogTitleState) => string \| undefined)` | – | A class name, or a function of the part's state. |
330
+ | `style` | `CSSProperties \| ((state: DialogTitleState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
331
+ | `children` | `ReactNode \| ((state: DialogTitleState) => ReactNode)` | – | Content, or a function of the part's state. |
332
+ | `render` | `ReactElement \| ((props, state: DialogTitleState) => ReactNode)` | – | Replace the default \<h2> (Title) or \<p> (Description). `render={<h3 />}` changes the heading level. |
333
+
334
+ - **State**: the Popup's (`DialogTitleState` and `DialogDescriptionState` are `DialogPopupState`).
335
+ - **Owned**: `id`.
336
+
337
+ ## Data attributes
338
+
339
+ | Hook | On | Meaning |
340
+ | - | - | - |
341
+ | `:open` | Popup | The dialog is open (DOM truth, both modes). |
342
+ | `:modal` | Popup | Opened with `showModal()`. |
343
+ | `::backdrop` | Popup | The modal backdrop. |
344
+ | `data-modal` | Popup | The `modal` prop (also before the dialog opens). |
345
+ | `data-open` | Trigger | Optimistic open state (library mode only). |
346
+ | `data-pending` | Trigger | An open, a part's close, or a close notification is in flight (library mode only). |
347
+ | `data-pending` | Close | Its `action` is in flight. |
348
+ | `aria-disabled` | Close | `"true"` while `data-pending`: a second click is ignored meanwhile. |
349
+ | `data-disabled` | Trigger, Close | The `disabled` prop (both modes). |
350
+
351
+ The `<dialog>` emits no `data-open`: `:open` and `:modal` are exact. Enter and exit animate in CSS, in both modes:
352
+
353
+ ```css
354
+ .dialog, .dialog::backdrop {
355
+ opacity: 0;
356
+ transition: opacity 150ms, display 150ms allow-discrete, overlay 150ms allow-discrete;
357
+ }
358
+ .dialog:open, .dialog:open::backdrop { opacity: 1; }
359
+ @starting-style { .dialog:open, .dialog:open::backdrop { opacity: 0; } }
360
+
361
+ /* Scroll lock, CSS only: keyed on :modal, so it covers pre-hydration opens and nested dialogs. */
362
+ html { scrollbar-gutter: stable; }
363
+ html:has(dialog:modal) { overflow: hidden; }
364
+ ```
365
+
366
+ The CSS exit animates in Chromium and Safari; Firefox closes a dialog instantly. The library keeps the content mounted until the exit animation ends, so a fading dialog is never empty, and a controlled close keeps it through the fade as well.
367
+
368
+ ## Keyboard and ARIA
369
+
370
+ | Key | Behaviour | Who |
371
+ | - | - | - |
372
+ | Enter / Space on the Trigger | Opens | the browser (JS-free) or the Trigger |
373
+ | Tab / Shift+Tab in a modal | Cycles through the dialog and the browser UI; the page is inert | the browser |
374
+ | Escape (modal) | Closes and returns focus; `openChangeAction(false, { reason: "dismiss" })` | the browser |
375
+ | Escape (non-modal) | Closes with `requestClose()` | the Popup (or `closedby` with the flag) |
376
+ | Escape in a nested dialog | Closes the innermost one only | the browser |
377
+ | Enter in a form field | Submits the Form: closes (through the Root in library mode), or runs the action and then closes | the browser / Form |
378
+
379
+ - The Popup's role is the native `dialog`; `aria-modal` is exposed by the browser after `showModal()`, never set by hand. `role="alertdialog"` passes through. `aria-labelledby` and `aria-describedby` point at Title and Description. A Popup with neither a Title nor an `aria-label` is a development warning.
380
+ - There is no focus trap: `showModal()` makes the rest of the page inert. Focus return is the platform's; the library only steps in when the opener has been removed (focus goes to the Trigger if it is still there, else to the body), and when a library-driven close of a non-modal dialog unmounted the focused button before the dialog closed (focus goes to the Trigger).
381
+ - For long or destructive dialogs, focus a static element so the title is heard first: `initialFocus` pointing at a `<Dialog.Title tabIndex={-1}>`.
382
+ - The Trigger is a plain button: no `aria-expanded`, no `aria-haspopup`. Give an icon-only Close an `aria-label`.
383
+
384
+ > **Escape cannot be turned off**
385
+ >
386
+ > Browsers honour `cancel.preventDefault()` only once per user activation, so a `closeOnEscape={false}` prop could not keep its promise. Build "unsaved changes" confirmation inside the dialog: a "Discard…" button that is the Trigger of a nested confirm Dialog, whose own `Dialog.Close action` does the work and then closes the outer dialog. Never write an action that awaits the user's answer in another dialog: React holds every transition started while an async action is pending, so the confirm would never open.
387
+
388
+ ## Transition types
389
+
390
+ Concept: [Transitions & ViewTransition](../concepts/transitions.md#transition-types)
391
+
392
+ Library mode: `fsui-dialog` plus `fsui-dialog-open` or `fsui-dialog-close`; a controlled close carries none. JS-free mode starts no transitions.
393
+
394
+ ### ViewTransition: an exit in every engine
395
+
396
+ With `transition`, the Popup renders `<ViewTransition>` around the `<dialog>`. A library-driven open calls `showModal()` in the layout effect of its commit and a library-driven close calls `close(returnValue)` in the layout effect of its commit, so the view transition captures the dialog's box as `::view-transition-new` on open and `::view-transition-old` (with its content) on close. That is the only way a dialog's exit can animate in Firefox. The order example below uses it.
397
+
398
+ ```tsx
399
+ <Dialog.Popup transition={{ "fsui-dialog-open": "pop", "fsui-dialog-close": "pop", default: "none" }}>
400
+ ```
401
+
402
+ ```css
403
+ ::view-transition-new(.pop) { animation: 180ms ease-out both pop-in; }
404
+ ::view-transition-old(.pop) { animation: 140ms ease-in both pop-out; }
405
+ /* Keep the CSS exit above for dismissals, but not while a view transition runs. */
406
+ html:active-view-transition .dialog { transition: none; }
407
+ @media (prefers-reduced-motion: reduce) {
408
+ ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
409
+ }
410
+ ```
411
+
412
+ - Library-driven closes: a `Dialog.Close`, a `Dialog.Form` submit or settled action, a foreign `request-close` / `close` command, a controlled `open={false}`. Transition types: `fsui-dialog` plus `fsui-dialog-open` or `fsui-dialog-close`; a controlled close carries none.
413
+ - Dismissals (Escape, a click outside) animate with the CSS exit only: keep it, and cut it while a view transition runs, as above ([A popup with a CSS exit and a view transition](../concepts/transitions.md#css-exit)).
414
+ - The `::backdrop` is not captured on its own: it is part of the page snapshot and leaves with the root cross-fade. A backdrop that should animate with the dialog is an element rendered as the Popup's first child (`position: fixed; inset: 0`; clicks on it are not light dismiss).
415
+ - A plain open with `transition="none"` starts no document view transition (the content mounts under the already-mounted `<dialog>`). A Root inserted by a transition with `transition` on its Popup, or a nested Popup with `transition` that mounts with the outer content, runs the page cross-fade ([issue #35](https://github.com/uhyo/funstack-ui/issues/35)).
416
+
417
+ ## Optimistic and pending
418
+
419
+ Concept: [Pending & optimistic state](../concepts/pending-and-optimistic.md)
420
+
421
+ Library mode: the Trigger shows the optimistic open state (`data-open`) and `data-pending` while an open, a part's close or a close notification is in flight. The Popup's content renders from the committed `open`. A Close with an `action` is a [pure trigger](../concepts/pending-and-optimistic.md#pure-trigger) (`data-pending`, `aria-disabled`).
422
+
423
+ ### Walkthrough (library mode)
424
+
425
+ ```tsx title="DialogOrders.tsx"
426
+ "use client";
427
+ import { use, useState } from "react";
428
+ import { Dialog } from "@funstack/ui/dialog";
429
+ import type { DialogOpenChangeDetails } from "@funstack/ui/dialog";
430
+ import { sleep } from "./fake-api.js";
431
+
432
+ interface Order {
433
+ readonly items: string;
434
+ readonly total: string;
435
+ }
436
+
437
+ // Cache the promises so `use()` sees the same one on every render.
438
+ const cache = new Map<string, Promise<Order>>();
439
+ function loadOrder(id: string): Promise<Order> {
440
+ let promise = cache.get(id);
441
+ if (promise === undefined) {
442
+ promise = sleep(1200).then(() => ({
443
+ items: id === "1042" ? "Keyboard, USB-C cable" : "Notebook",
444
+ total: id === "1042" ? "$129.00" : "$18.50",
445
+ }));
446
+ cache.set(id, promise);
447
+ }
448
+ return promise;
449
+ }
450
+
451
+ function OrderDetails({ id }: { id: string }) {
452
+ const order = use(loadOrder(id));
453
+ return (
454
+ <dl className="demo-dialog-details">
455
+ <dt>Items</dt>
456
+ <dd>{order.items}</dd>
457
+ <dt>Total</dt>
458
+ <dd>{order.total}</dd>
459
+ </dl>
460
+ );
461
+ }
462
+
463
+ // Library mode: `defaultOpen={false}` (or any action prop) hands the open to the library. The
464
+ // Popup's children render from committed state, so <OrderDetails> mounts inside the opening
465
+ // transition and suspends: the dialog stays closed and the Trigger carries data-pending until the
466
+ // data is ready, then the dialog opens once, complete. The Close button's close is library-owned
467
+ // too: openChangeAction(false) runs first, then the dialog closes in a view transition
468
+ // (`transition`), so the exit animates in every engine, Firefox included. Escape and a click on
469
+ // the backdrop are dismissals: the browser closes the dialog (with the CSS exit) and the Root is
470
+ // told afterwards. The readout shows what the Root received.
471
+ export function DialogOrders() {
472
+ const [last, setLast] = useState("(none yet)");
473
+ const record = (open: boolean, { reason, returnValue }: DialogOpenChangeDetails) => {
474
+ // The synchronous part of an action: this setState is a transition update.
475
+ setLast(`open=${open} reason="${reason}" returnValue=${JSON.stringify(returnValue)}`);
476
+ };
477
+ return (
478
+ <>
479
+ <ul className="demo-list">
480
+ {["1042", "1043"].map((id) => (
481
+ <li key={id} className="demo-row">
482
+ Order #{id}
483
+ <Dialog.Root defaultOpen={false} openChangeAction={record}>
484
+ <Dialog.Trigger className="demo-button">
485
+ {({ pending }) => (
486
+ <>
487
+ Details
488
+ {pending && <span className="demo-spinner" aria-hidden />}
489
+ </>
490
+ )}
491
+ </Dialog.Trigger>
492
+ <Dialog.Popup
493
+ className="demo-dialog demo-dialog-vt"
494
+ lightDismiss
495
+ initialFocus="[data-autofocus]"
496
+ transition={{
497
+ "fsui-dialog-open": "demo-dialog-pop",
498
+ "fsui-dialog-close": "demo-dialog-pop",
499
+ default: "none",
500
+ }}
501
+ >
502
+ <Dialog.Title>Order #{id}</Dialog.Title>
503
+ <OrderDetails id={id} />
504
+ <div className="demo-dialog-actions">
505
+ <Dialog.Close className="demo-button" value="done" data-autofocus="">
506
+ Close
507
+ </Dialog.Close>
508
+ </div>
509
+ </Dialog.Popup>
510
+ </Dialog.Root>
511
+ </li>
512
+ ))}
513
+ </ul>
514
+ <div className="demo-row">
515
+ <button type="button" className="demo-button" onClick={() => cache.clear()}>
516
+ Clear the cache
517
+ </button>
518
+ </div>
519
+ <output className="demo-readout">
520
+ last openChangeAction: <code>{last}</code>
521
+ </output>
522
+ </>
523
+ );
524
+ }
525
+ ```
526
+
527
+ `dialog.css`: the same file as above.
528
+
529
+ 1. Click Details: the click is cancelled (so the native command does not run), the Trigger gets `data-open` and `data-pending`, and `openChangeAction(true, { reason: "activate", returnValue: undefined })` runs.
530
+ 2. The commit that sets committed `open` renders the Popup's children; `OrderDetails` suspends, so React holds the commit. The dialog stays closed; the Trigger keeps spinning.
531
+ 3. The data arrives: the content commits and `showModal()` runs in the same commit's layout effect, so the platform focuses fully rendered content (here the Close button, through `initialFocus`).
532
+ 4. Close it with the Close button: the click is cancelled, the Trigger shows `data-pending` while `openChangeAction(false, { reason: "activate", returnValue: "done" })` runs, then the dialog closes in a view transition (the `transition` prop), in Firefox too. Escape or a click on the backdrop (`lightDismiss`) are dismissals: the browser closes the dialog at once and the Root then receives `reason: "dismiss"`. The second open is instant (the data is cached).
533
+ 5. If the opening action rejects, the error reaches the Error Boundary above the Root and the dialog never opens.
534
+
535
+ To open now and show a skeleton instead, put a `<Suspense>` boundary inside the Popup: a newly mounted boundary shows its fallback immediately.
536
+
537
+ > **A part's close is yours to refuse; a dismissal's is not**
538
+ >
539
+ > A close a part asks for waits for `openChangeAction(false)`: a controlled parent that keeps `open` gets a plain snap-back, and the dialog never blinks (for example "the save failed, keep editing", checked through `details.returnValue`). A dismissal is already done when the action runs: a parent that does not adopt `false` gets the dialog re-opened once the action settles, and the user sees it close and come back. Adopt a dismissal's `false` unconditionally. If the user dismisses the dialog while a part's close is still running and you then veto that close, the dialog stays closed and you receive the dismissal (`reason: "dismiss"`) right after. Neither is a way to ask the user first: an action must never await input, so build confirmation inside the dialog (see the callout above).
540
+
541
+ ## Suspense
542
+
543
+ Concept: [Suspense](../concepts/suspense.md)
544
+
545
+ Content that suspends holds the open: the dialog stays closed with the Trigger pending, then opens once, complete. A `<Suspense>` inside the Popup opens at once with a skeleton instead.
546
+
547
+ ## Browser-owned state
548
+
549
+ Concept: [Browser-owned state](../concepts/browser-owned-state.md)
550
+
551
+ JS-free mode: the browser owns everything through Invoker Commands. Library mode: opening and a close asked for by a part are library-owned; a dismissal (Escape, Android back, a click outside) is the browser's: the dialog closes at once, `openChangeAction(false)` is a notification with `reason: "dismiss"`, and a controlled parent that keeps `open` gets it re-opened once the action settles. Dismissals animate with CSS only.
552
+
553
+ ## Before hydration
554
+
555
+ Concept: [Server Components](../concepts/server-components.md#before-hydration)
556
+
557
+ JS-free mode: everything for a modal dialog: open (`command="show-modal"`), Escape, Close buttons (`command="request-close"`), `<form method="dialog">`, focus and focus return, `autoFocus` in server-rendered markup, CSS animation; a `Dialog.Form` with a Server Function action submits with React's progressive enhancement. Hydration adds `initialFocus`, `lightDismiss` and closing after a form action. A non-modal dialog needs JavaScript to open. Library mode: the Trigger opens the dialog natively, but its content is not in the HTML; on hydration it is reconciled with one `openChangeAction(true)` call (`reason: "platform"`) and the content mounts.
558
+
559
+ ### The [platform paths](../concepts/browser-owned-state.md#platform-path)
560
+
561
+ - **Before hydration, JS-free mode:** everything works, including `autoFocus` in server-rendered markup and `Dialog.Form` with a Server Function action (React's progressive enhancement). After hydration, and for content React renders on the client, use `initialFocus`: React does not write `autofocus` on client-rendered elements.
562
+ - **Before hydration, library mode:** the Trigger already carries the command, so a click opens the dialog natively, but the content is not in the HTML yet. On hydration the Popup finds the dialog open and dispatches `openChangeAction(true, { reason: "platform" })` with no event; the content mounts into the open dialog. If the action rejects or a controlled parent refuses, the dialog closes again. A dialog whose pre-hydration experience matters belongs in JS-free mode.
563
+ - **Foreign invokers:** in library mode, any `<button commandfor command="show-modal">` (or `"request-close"` / `"close"`) pointing at the dialog goes through the library too, as the Trigger and Close parts do; a close command's `value` becomes the `returnValue`.
564
+
565
+ ## Forms
566
+
567
+ ```tsx title="DialogProfile.tsx"
568
+ "use client";
569
+ import { startTransition, useState } from "react";
570
+ import { useFormStatus } from "react-dom";
571
+ import { Dialog } from "@funstack/ui/dialog";
572
+ import { DemoErrorBoundary } from "./DemoErrorBoundary.js";
573
+ import { sleep } from "./fake-api.js";
574
+
575
+ function SaveButton() {
576
+ // React's form channel. The Form part only observes it; nothing in the library reports it as
577
+ // its own pending state.
578
+ const { pending } = useFormStatus();
579
+ return (
580
+ <button type="submit" className="demo-button demo-primary" value="save">
581
+ {pending && <span className="demo-spinner" aria-hidden />}
582
+ Save
583
+ </button>
584
+ );
585
+ }
586
+
587
+ // Dialog.Form with a function `action` renders <form action> (React's form action, passed
588
+ // through unwrapped, so a Server Function keeps progressive enhancement) and closes the dialog
589
+ // once the action's transition has settled, with the submitter's value as returnValue. A name
590
+ // containing "fail" makes the save reject: the Error Boundary inside the dialog shows the error
591
+ // and the dialog stays open.
592
+ export function DialogProfile() {
593
+ const [name, setName] = useState("Ada Lovelace");
594
+ return (
595
+ <>
596
+ <Dialog.Root defaultOpen={false}>
597
+ <Dialog.Trigger className="demo-button">Edit profile</Dialog.Trigger>
598
+ <Dialog.Popup className="demo-dialog" initialFocus="[name=name]">
599
+ <Dialog.Title>Edit profile</Dialog.Title>
600
+ <Dialog.Description>
601
+ Type a name containing &quot;fail&quot; to see a rejected save.
602
+ </Dialog.Description>
603
+ <DemoErrorBoundary>
604
+ <Dialog.Form
605
+ className="demo-dialog-form"
606
+ action={async (formData) => {
607
+ const next = String(formData.get("name") ?? "");
608
+ await sleep(900);
609
+ if (next.toLowerCase().includes("fail")) {
610
+ throw new Error(`The server rejected the name "${next}".`);
611
+ }
612
+ // After an await: wrap the update yourself (React limitation).
613
+ startTransition(() => setName(next));
614
+ }}
615
+ >
616
+ <label>
617
+ Name <input name="name" defaultValue={name} />
618
+ </label>
619
+ <div className="demo-dialog-actions">
620
+ <Dialog.Close className="demo-button" value="cancel">
621
+ Cancel
622
+ </Dialog.Close>
623
+ <SaveButton />
624
+ </div>
625
+ </Dialog.Form>
626
+ </DemoErrorBoundary>
627
+ </Dialog.Popup>
628
+ </Dialog.Root>
629
+ <output className="demo-readout">
630
+ saved name: <strong>{name}</strong>
631
+ </output>
632
+ </>
633
+ );
634
+ }
635
+ ```
636
+
637
+ `dialog.css`: the same file as above.
638
+
639
+ 1. Submit: React runs the form action; `useFormStatus().pending` is true in the Save button. The dialog stays open.
640
+ 2. The action resolves and the name updates in a transition. When the form's pending state ends, the Form asks the Root to close the dialog with the submitter's `value` (`"save"`): `openChangeAction(false)` runs with `reason: "activate"`, then the dialog closes.
641
+ 3. A name containing "fail" rejects: the Error Boundary inside the Popup shows the error and the dialog stays open. A boundary above the Root would unmount the dialog instead.
642
+
643
+ For a single "run this, then close" button without a form, such as Delete, use `Dialog.Close action`: it shows `data-pending` on the button and closes when the action resolves.
644
+
645
+ In library mode a `method="dialog"` submit is a library-owned close too, with the submitter's `value`, after your own `onSubmit` ran. To leave such a form to the browser, call `event.stopPropagation()` in its `onSubmit`: the dialog then closes natively and the Root is notified with `reason: "dismiss"`.
646
+
647
+ ### Server Functions
648
+
649
+ The dialog's action and the [form channel](../concepts/action-props.md#form-channel) are independent, and both usable from a Server Component:
650
+
651
+ ```tsx
652
+ // Persist "seen" when the user dismisses an announcement.
653
+ <Dialog.Root defaultOpen={!user.seenAnnouncement} openChangeAction={markAnnouncementSeen}>
654
+ ...
655
+ </Dialog.Root>
656
+
657
+ // A form inside the dialog: progressive enhancement before hydration, close after success.
658
+ <Dialog.Form action={saveProfile}>...</Dialog.Form>
659
+ ```
660
+
661
+ `openChangeAction` is a per-dialog action with the Trigger's pending state; `Dialog.Form action` is React's form action with React's `useFormStatus`. The Form only observes the form channel to close the dialog afterwards; it never wraps your function and never reports form pending as the dialog's.
662
+
663
+ ## Recipes
664
+
665
+ ### Controlled, opened without a Trigger
666
+
667
+ ```tsx
668
+ const [open, setOpen] = useState(false);
669
+
670
+ <Dialog.Root open={open} openChangeAction={(next) => { setOpen(next); }}>
671
+ <Dialog.Popup>...</Dialog.Popup>
672
+ </Dialog.Root>
673
+ ```
674
+
675
+ ### Branch on how it closed
676
+
677
+ ```tsx
678
+ <Dialog.Root
679
+ defaultOpen={false}
680
+ openChangeAction={(open, { reason, returnValue }) => {
681
+ if (!open && reason === "activate" && returnValue === "delete") deleteDraft();
682
+ }}
683
+ >
684
+ ```
685
+
686
+ A `<ViewTransition>` that mounts inside a transition runs the page cross-fade ([the transition prop](../concepts/transitions.md#transition-prop), issue [#35](https://github.com/uhyo/funstack-ui/issues/35)). In a library-mode dialog that happens when the content mounts parts that render one, such as a nested Dialog or a control with `transition` set.