@funstack/ui 0.1.0-alpha.15 → 0.1.0-alpha.17

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 (588) 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 +3 -1
  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 +46 -15
  26. package/dist/button/button.d.mts.map +1 -1
  27. package/dist/button/button.mjs +10 -6
  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 +7 -1
  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-group.d.mts +49 -1
  58. package/dist/combobox/combobox-group.d.mts.map +1 -1
  59. package/dist/combobox/combobox-group.mjs +11 -1
  60. package/dist/combobox/combobox-group.mjs.map +1 -1
  61. package/dist/combobox/combobox-input.d.mts +11 -0
  62. package/dist/combobox/combobox-input.d.mts.map +1 -1
  63. package/dist/combobox/combobox-input.mjs +2 -0
  64. package/dist/combobox/combobox-input.mjs.map +1 -1
  65. package/dist/combobox/combobox-label.d.mts +16 -0
  66. package/dist/combobox/combobox-label.d.mts.map +1 -1
  67. package/dist/combobox/combobox-label.mjs +2 -0
  68. package/dist/combobox/combobox-label.mjs.map +1 -1
  69. package/dist/combobox/combobox-list.d.mts +14 -0
  70. package/dist/combobox/combobox-list.d.mts.map +1 -1
  71. package/dist/combobox/combobox-list.mjs +2 -0
  72. package/dist/combobox/combobox-list.mjs.map +1 -1
  73. package/dist/combobox/combobox-option.d.mts +25 -3
  74. package/dist/combobox/combobox-option.d.mts.map +1 -1
  75. package/dist/combobox/combobox-option.mjs +2 -0
  76. package/dist/combobox/combobox-option.mjs.map +1 -1
  77. package/dist/combobox/combobox-popup.d.mts +20 -1
  78. package/dist/combobox/combobox-popup.d.mts.map +1 -1
  79. package/dist/combobox/combobox-popup.mjs +2 -0
  80. package/dist/combobox/combobox-popup.mjs.map +1 -1
  81. package/dist/combobox/combobox-root.d.mts +64 -17
  82. package/dist/combobox/combobox-root.d.mts.map +1 -1
  83. package/dist/combobox/combobox-root.mjs +11 -11
  84. package/dist/combobox/combobox-root.mjs.map +1 -1
  85. package/dist/combobox/combobox-trigger.d.mts +16 -0
  86. package/dist/combobox/combobox-trigger.d.mts.map +1 -1
  87. package/dist/combobox/combobox-trigger.mjs +9 -2
  88. package/dist/combobox/combobox-trigger.mjs.map +1 -1
  89. package/dist/combobox/index.d.mts +2 -0
  90. package/dist/combobox/index.d.mts.map +1 -1
  91. package/dist/combobox/index.mjs +2 -0
  92. package/dist/combobox/index.mjs.map +1 -1
  93. package/dist/csp/csp-provider.d.mts +8 -0
  94. package/dist/csp/csp-provider.d.mts.map +1 -1
  95. package/dist/csp/csp-provider.mjs +2 -0
  96. package/dist/csp/csp-provider.mjs.map +1 -1
  97. package/dist/csp/style-hashes.d.mts +2 -0
  98. package/dist/csp/style-hashes.d.mts.map +1 -1
  99. package/dist/csp/style-hashes.mjs +2 -0
  100. package/dist/csp/style-hashes.mjs.map +1 -1
  101. package/dist/dialog/dialog-close.d.mts +31 -3
  102. package/dist/dialog/dialog-close.d.mts.map +1 -1
  103. package/dist/dialog/dialog-close.mjs +5 -2
  104. package/dist/dialog/dialog-close.mjs.map +1 -1
  105. package/dist/dialog/dialog-context.mjs.map +1 -1
  106. package/dist/dialog/dialog-description.d.mts +12 -0
  107. package/dist/dialog/dialog-description.d.mts.map +1 -1
  108. package/dist/dialog/dialog-description.mjs +2 -0
  109. package/dist/dialog/dialog-description.mjs.map +1 -1
  110. package/dist/dialog/dialog-form.d.mts +20 -2
  111. package/dist/dialog/dialog-form.d.mts.map +1 -1
  112. package/dist/dialog/dialog-form.mjs +2 -0
  113. package/dist/dialog/dialog-form.mjs.map +1 -1
  114. package/dist/dialog/dialog-popup.d.mts +34 -8
  115. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  116. package/dist/dialog/dialog-popup.mjs +14 -20
  117. package/dist/dialog/dialog-popup.mjs.map +1 -1
  118. package/dist/dialog/dialog-root.d.mts +53 -25
  119. package/dist/dialog/dialog-root.d.mts.map +1 -1
  120. package/dist/dialog/dialog-root.mjs +12 -8
  121. package/dist/dialog/dialog-root.mjs.map +1 -1
  122. package/dist/dialog/dialog-title.d.mts +11 -0
  123. package/dist/dialog/dialog-title.d.mts.map +1 -1
  124. package/dist/dialog/dialog-title.mjs +2 -0
  125. package/dist/dialog/dialog-title.mjs.map +1 -1
  126. package/dist/dialog/dialog-trigger.d.mts +19 -3
  127. package/dist/dialog/dialog-trigger.d.mts.map +1 -1
  128. package/dist/dialog/dialog-trigger.mjs +2 -0
  129. package/dist/dialog/dialog-trigger.mjs.map +1 -1
  130. package/dist/dialog/index.d.mts +7 -5
  131. package/dist/dialog/index.d.mts.map +1 -1
  132. package/dist/dialog/index.mjs +7 -5
  133. package/dist/dialog/index.mjs.map +1 -1
  134. package/dist/docs/components/accordion.md +426 -0
  135. package/dist/docs/components/button.md +508 -0
  136. package/dist/docs/components/checkbox-group.md +483 -0
  137. package/dist/docs/components/checkbox.md +373 -0
  138. package/dist/docs/components/combobox.md +698 -0
  139. package/dist/docs/components/context-menu.md +524 -0
  140. package/dist/docs/components/dialog.md +692 -0
  141. package/dist/docs/components/field.md +587 -0
  142. package/dist/docs/components/menu.md +670 -0
  143. package/dist/docs/components/meter.md +313 -0
  144. package/dist/docs/components/number-field.md +528 -0
  145. package/dist/docs/components/popover.md +656 -0
  146. package/dist/docs/components/progress.md +450 -0
  147. package/dist/docs/components/radio-group.md +457 -0
  148. package/dist/docs/components/select.md +662 -0
  149. package/dist/docs/components/slider.md +558 -0
  150. package/dist/docs/components/switch.md +311 -0
  151. package/dist/docs/components/tabs.md +473 -0
  152. package/dist/docs/components/toast.md +599 -0
  153. package/dist/docs/components/toggle-group.md +341 -0
  154. package/dist/docs/components/toggle.md +245 -0
  155. package/dist/docs/components/toolbar.md +390 -0
  156. package/dist/docs/components/tooltip.md +494 -0
  157. package/dist/docs/concepts/action-props.md +281 -0
  158. package/dist/docs/concepts/ai-agents.md +56 -0
  159. package/dist/docs/concepts/browser-owned-state.md +133 -0
  160. package/dist/docs/concepts/content-security-policy.md +69 -0
  161. package/dist/docs/concepts/experimental.md +36 -0
  162. package/dist/docs/concepts/pending-and-optimistic.md +263 -0
  163. package/dist/docs/concepts/render.md +23 -0
  164. package/dist/docs/concepts/server-components.md +132 -0
  165. package/dist/docs/concepts/suspense.md +129 -0
  166. package/dist/docs/concepts/transitions.md +112 -0
  167. package/dist/docs/getting-started.md +102 -0
  168. package/dist/docs/index.md +182 -0
  169. package/dist/docs/roadmap.md +128 -0
  170. package/dist/docs/why.md +104 -0
  171. package/dist/field/field-control.d.mts +26 -3
  172. package/dist/field/field-control.d.mts.map +1 -1
  173. package/dist/field/field-control.mjs +2 -0
  174. package/dist/field/field-control.mjs.map +1 -1
  175. package/dist/field/field-description.d.mts +11 -0
  176. package/dist/field/field-description.d.mts.map +1 -1
  177. package/dist/field/field-description.mjs +2 -0
  178. package/dist/field/field-description.mjs.map +1 -1
  179. package/dist/field/field-error.d.mts +14 -2
  180. package/dist/field/field-error.d.mts.map +1 -1
  181. package/dist/field/field-error.mjs +2 -0
  182. package/dist/field/field-error.mjs.map +1 -1
  183. package/dist/field/field-label.d.mts +10 -0
  184. package/dist/field/field-label.d.mts.map +1 -1
  185. package/dist/field/field-label.mjs +2 -0
  186. package/dist/field/field-label.mjs.map +1 -1
  187. package/dist/field/field-root.d.mts +21 -2
  188. package/dist/field/field-root.d.mts.map +1 -1
  189. package/dist/field/field-root.mjs +2 -0
  190. package/dist/field/field-root.mjs.map +1 -1
  191. package/dist/field/index.d.mts +9 -0
  192. package/dist/field/index.d.mts.map +1 -1
  193. package/dist/field/index.mjs +9 -0
  194. package/dist/field/index.mjs.map +1 -1
  195. package/dist/form/form-root.d.mts +17 -1
  196. package/dist/form/form-root.d.mts.map +1 -1
  197. package/dist/form/form-root.mjs +2 -0
  198. package/dist/form/form-root.mjs.map +1 -1
  199. package/dist/form/form-submit.d.mts +18 -0
  200. package/dist/form/form-submit.d.mts.map +1 -1
  201. package/dist/form/form-submit.mjs +2 -0
  202. package/dist/form/form-submit.mjs.map +1 -1
  203. package/dist/form/index.d.mts +7 -0
  204. package/dist/form/index.d.mts.map +1 -1
  205. package/dist/form/index.mjs +7 -0
  206. package/dist/form/index.mjs.map +1 -1
  207. package/dist/index.d.mts +3 -2
  208. package/dist/internal/call-urgent-handler.mjs +37 -0
  209. package/dist/internal/call-urgent-handler.mjs.map +1 -0
  210. package/dist/internal/css-transition-cut.mjs +66 -0
  211. package/dist/internal/css-transition-cut.mjs.map +1 -0
  212. package/dist/internal/overlay-popup.mjs.map +1 -1
  213. package/dist/internal/report-dropped.mjs +45 -0
  214. package/dist/internal/report-dropped.mjs.map +1 -0
  215. package/dist/internal/types.d.mts +36 -7
  216. package/dist/internal/types.d.mts.map +1 -1
  217. package/dist/internal/use-action-trigger.mjs +32 -17
  218. package/dist/internal/use-action-trigger.mjs.map +1 -1
  219. package/dist/internal/use-controllable-action.mjs +52 -16
  220. package/dist/internal/use-controllable-action.mjs.map +1 -1
  221. package/dist/internal/use-exit-animation.mjs +1 -1
  222. package/dist/internal/use-exit-animation.mjs.map +1 -1
  223. package/dist/internal/use-native-group-reconciliation.mjs +4 -2
  224. package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
  225. package/dist/internal/use-overlay-close.mjs +10 -4
  226. package/dist/internal/use-overlay-close.mjs.map +1 -1
  227. package/dist/internal/use-overlay-root.mjs +40 -7
  228. package/dist/internal/use-overlay-root.mjs.map +1 -1
  229. package/dist/internal/use-popover-popup.mjs +22 -7
  230. package/dist/internal/use-popover-popup.mjs.map +1 -1
  231. package/dist/internal/use-popover-trigger.d.mts +2 -1
  232. package/dist/internal/use-popover-trigger.d.mts.map +1 -1
  233. package/dist/internal/use-popover-trigger.mjs +11 -3
  234. package/dist/internal/use-popover-trigger.mjs.map +1 -1
  235. package/dist/internal/validity.d.mts +11 -0
  236. package/dist/internal/validity.d.mts.map +1 -1
  237. package/dist/internal/validity.mjs.map +1 -1
  238. package/dist/menu/index.d.mts +2 -0
  239. package/dist/menu/index.d.mts.map +1 -1
  240. package/dist/menu/index.mjs +2 -0
  241. package/dist/menu/index.mjs.map +1 -1
  242. package/dist/menu/menu-checkbox-item.d.mts +27 -3
  243. package/dist/menu/menu-checkbox-item.d.mts.map +1 -1
  244. package/dist/menu/menu-checkbox-item.mjs +2 -0
  245. package/dist/menu/menu-checkbox-item.mjs.map +1 -1
  246. package/dist/menu/menu-context-trigger.d.mts +24 -2
  247. package/dist/menu/menu-context-trigger.d.mts.map +1 -1
  248. package/dist/menu/menu-context-trigger.mjs +2 -0
  249. package/dist/menu/menu-context-trigger.mjs.map +1 -1
  250. package/dist/menu/menu-group.d.mts +36 -1
  251. package/dist/menu/menu-group.d.mts.map +1 -1
  252. package/dist/menu/menu-group.mjs +9 -1
  253. package/dist/menu/menu-group.mjs.map +1 -1
  254. package/dist/menu/menu-item.d.mts +38 -5
  255. package/dist/menu/menu-item.d.mts.map +1 -1
  256. package/dist/menu/menu-item.mjs +12 -5
  257. package/dist/menu/menu-item.mjs.map +1 -1
  258. package/dist/menu/menu-outside.mjs +2 -2
  259. package/dist/menu/menu-outside.mjs.map +1 -1
  260. package/dist/menu/menu-popup.d.mts +36 -8
  261. package/dist/menu/menu-popup.d.mts.map +1 -1
  262. package/dist/menu/menu-popup.mjs +2 -0
  263. package/dist/menu/menu-popup.mjs.map +1 -1
  264. package/dist/menu/menu-radio-group.d.mts +20 -1
  265. package/dist/menu/menu-radio-group.d.mts.map +1 -1
  266. package/dist/menu/menu-radio-group.mjs +2 -0
  267. package/dist/menu/menu-radio-group.mjs.map +1 -1
  268. package/dist/menu/menu-radio-item.d.mts +16 -0
  269. package/dist/menu/menu-radio-item.d.mts.map +1 -1
  270. package/dist/menu/menu-radio-item.mjs +2 -0
  271. package/dist/menu/menu-radio-item.mjs.map +1 -1
  272. package/dist/menu/menu-root.d.mts +49 -15
  273. package/dist/menu/menu-root.d.mts.map +1 -1
  274. package/dist/menu/menu-root.mjs +7 -4
  275. package/dist/menu/menu-root.mjs.map +1 -1
  276. package/dist/menu/menu-submenu-trigger.d.mts +13 -0
  277. package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
  278. package/dist/menu/menu-submenu-trigger.mjs +2 -0
  279. package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
  280. package/dist/menu/menu-trigger.d.mts +15 -0
  281. package/dist/menu/menu-trigger.d.mts.map +1 -1
  282. package/dist/menu/menu-trigger.mjs +2 -0
  283. package/dist/menu/menu-trigger.mjs.map +1 -1
  284. package/dist/meter/index.d.mts +2 -0
  285. package/dist/meter/index.d.mts.map +1 -1
  286. package/dist/meter/index.mjs +2 -0
  287. package/dist/meter/index.mjs.map +1 -1
  288. package/dist/meter/meter-indicator.d.mts +11 -0
  289. package/dist/meter/meter-indicator.d.mts.map +1 -1
  290. package/dist/meter/meter-indicator.mjs +2 -0
  291. package/dist/meter/meter-indicator.mjs.map +1 -1
  292. package/dist/meter/meter-label.d.mts +11 -0
  293. package/dist/meter/meter-label.d.mts.map +1 -1
  294. package/dist/meter/meter-label.mjs +2 -0
  295. package/dist/meter/meter-label.mjs.map +1 -1
  296. package/dist/meter/meter-region.d.mts +5 -0
  297. package/dist/meter/meter-region.d.mts.map +1 -1
  298. package/dist/meter/meter-region.mjs.map +1 -1
  299. package/dist/meter/meter-root.d.mts +52 -10
  300. package/dist/meter/meter-root.d.mts.map +1 -1
  301. package/dist/meter/meter-root.mjs +2 -0
  302. package/dist/meter/meter-root.mjs.map +1 -1
  303. package/dist/meter/meter-track.d.mts +11 -0
  304. package/dist/meter/meter-track.d.mts.map +1 -1
  305. package/dist/meter/meter-track.mjs +2 -0
  306. package/dist/meter/meter-track.mjs.map +1 -1
  307. package/dist/meter/meter-value.d.mts +15 -1
  308. package/dist/meter/meter-value.d.mts.map +1 -1
  309. package/dist/meter/meter-value.mjs +2 -0
  310. package/dist/meter/meter-value.mjs.map +1 -1
  311. package/dist/number-field/index.d.mts +2 -0
  312. package/dist/number-field/index.d.mts.map +1 -1
  313. package/dist/number-field/index.mjs +2 -0
  314. package/dist/number-field/index.mjs.map +1 -1
  315. package/dist/number-field/number-field-decrement.d.mts +2 -0
  316. package/dist/number-field/number-field-decrement.d.mts.map +1 -1
  317. package/dist/number-field/number-field-decrement.mjs +2 -0
  318. package/dist/number-field/number-field-decrement.mjs.map +1 -1
  319. package/dist/number-field/number-field-increment.d.mts +2 -0
  320. package/dist/number-field/number-field-increment.d.mts.map +1 -1
  321. package/dist/number-field/number-field-increment.mjs +2 -0
  322. package/dist/number-field/number-field-increment.mjs.map +1 -1
  323. package/dist/number-field/number-field-input.d.mts +9 -0
  324. package/dist/number-field/number-field-input.d.mts.map +1 -1
  325. package/dist/number-field/number-field-input.mjs +2 -0
  326. package/dist/number-field/number-field-input.mjs.map +1 -1
  327. package/dist/number-field/number-field-label.d.mts +10 -0
  328. package/dist/number-field/number-field-label.d.mts.map +1 -1
  329. package/dist/number-field/number-field-label.mjs +2 -0
  330. package/dist/number-field/number-field-label.mjs.map +1 -1
  331. package/dist/number-field/number-field-root.d.mts +62 -14
  332. package/dist/number-field/number-field-root.d.mts.map +1 -1
  333. package/dist/number-field/number-field-root.mjs +4 -8
  334. package/dist/number-field/number-field-root.mjs.map +1 -1
  335. package/dist/number-field/use-step-button.d.mts +20 -0
  336. package/dist/number-field/use-step-button.d.mts.map +1 -1
  337. package/dist/number-field/use-step-button.mjs.map +1 -1
  338. package/dist/popover/index.d.mts +5 -3
  339. package/dist/popover/index.d.mts.map +1 -1
  340. package/dist/popover/index.mjs +5 -3
  341. package/dist/popover/index.mjs.map +1 -1
  342. package/dist/popover/popover-close.d.mts +32 -3
  343. package/dist/popover/popover-close.d.mts.map +1 -1
  344. package/dist/popover/popover-close.mjs +6 -2
  345. package/dist/popover/popover-close.mjs.map +1 -1
  346. package/dist/popover/popover-description.d.mts +12 -0
  347. package/dist/popover/popover-description.d.mts.map +1 -1
  348. package/dist/popover/popover-description.mjs +2 -0
  349. package/dist/popover/popover-description.mjs.map +1 -1
  350. package/dist/popover/popover-popup.d.mts +36 -7
  351. package/dist/popover/popover-popup.d.mts.map +1 -1
  352. package/dist/popover/popover-popup.mjs +5 -2
  353. package/dist/popover/popover-popup.mjs.map +1 -1
  354. package/dist/popover/popover-root.d.mts +40 -18
  355. package/dist/popover/popover-root.d.mts.map +1 -1
  356. package/dist/popover/popover-root.mjs +11 -7
  357. package/dist/popover/popover-root.mjs.map +1 -1
  358. package/dist/popover/popover-title.d.mts +11 -0
  359. package/dist/popover/popover-title.d.mts.map +1 -1
  360. package/dist/popover/popover-title.mjs +2 -0
  361. package/dist/popover/popover-title.mjs.map +1 -1
  362. package/dist/popover/popover-trigger.d.mts +15 -0
  363. package/dist/popover/popover-trigger.d.mts.map +1 -1
  364. package/dist/popover/popover-trigger.mjs +2 -0
  365. package/dist/popover/popover-trigger.mjs.map +1 -1
  366. package/dist/progress/index.d.mts +2 -0
  367. package/dist/progress/index.d.mts.map +1 -1
  368. package/dist/progress/index.mjs +2 -0
  369. package/dist/progress/index.mjs.map +1 -1
  370. package/dist/progress/progress-indicator.d.mts +11 -0
  371. package/dist/progress/progress-indicator.d.mts.map +1 -1
  372. package/dist/progress/progress-indicator.mjs +2 -0
  373. package/dist/progress/progress-indicator.mjs.map +1 -1
  374. package/dist/progress/progress-label.d.mts +11 -0
  375. package/dist/progress/progress-label.d.mts.map +1 -1
  376. package/dist/progress/progress-label.mjs +2 -0
  377. package/dist/progress/progress-label.mjs.map +1 -1
  378. package/dist/progress/progress-root.d.mts +36 -8
  379. package/dist/progress/progress-root.d.mts.map +1 -1
  380. package/dist/progress/progress-root.mjs +2 -0
  381. package/dist/progress/progress-root.mjs.map +1 -1
  382. package/dist/progress/progress-track.d.mts +11 -0
  383. package/dist/progress/progress-track.d.mts.map +1 -1
  384. package/dist/progress/progress-track.mjs +2 -0
  385. package/dist/progress/progress-track.mjs.map +1 -1
  386. package/dist/progress/progress-value.d.mts +15 -1
  387. package/dist/progress/progress-value.d.mts.map +1 -1
  388. package/dist/progress/progress-value.mjs +2 -0
  389. package/dist/progress/progress-value.mjs.map +1 -1
  390. package/dist/radio-group/index.d.mts +2 -0
  391. package/dist/radio-group/index.d.mts.map +1 -1
  392. package/dist/radio-group/index.mjs +2 -0
  393. package/dist/radio-group/index.mjs.map +1 -1
  394. package/dist/radio-group/radio-group-item.d.mts +18 -1
  395. package/dist/radio-group/radio-group-item.d.mts.map +1 -1
  396. package/dist/radio-group/radio-group-item.mjs +2 -0
  397. package/dist/radio-group/radio-group-item.mjs.map +1 -1
  398. package/dist/radio-group/radio-group-label.d.mts +10 -0
  399. package/dist/radio-group/radio-group-label.d.mts.map +1 -1
  400. package/dist/radio-group/radio-group-label.mjs +2 -0
  401. package/dist/radio-group/radio-group-label.mjs.map +1 -1
  402. package/dist/radio-group/radio-group-root.d.mts +29 -5
  403. package/dist/radio-group/radio-group-root.d.mts.map +1 -1
  404. package/dist/radio-group/radio-group-root.mjs +2 -0
  405. package/dist/radio-group/radio-group-root.mjs.map +1 -1
  406. package/dist/select/index.d.mts +2 -0
  407. package/dist/select/index.d.mts.map +1 -1
  408. package/dist/select/index.mjs +2 -0
  409. package/dist/select/index.mjs.map +1 -1
  410. package/dist/select/select-group-label.d.mts +10 -0
  411. package/dist/select/select-group-label.d.mts.map +1 -1
  412. package/dist/select/select-group-label.mjs +2 -0
  413. package/dist/select/select-group-label.mjs.map +1 -1
  414. package/dist/select/select-group.d.mts +15 -1
  415. package/dist/select/select-group.d.mts.map +1 -1
  416. package/dist/select/select-group.mjs +2 -0
  417. package/dist/select/select-group.mjs.map +1 -1
  418. package/dist/select/select-option.d.mts +19 -1
  419. package/dist/select/select-option.d.mts.map +1 -1
  420. package/dist/select/select-option.mjs +2 -0
  421. package/dist/select/select-option.mjs.map +1 -1
  422. package/dist/select/select-root.d.mts +24 -1
  423. package/dist/select/select-root.d.mts.map +1 -1
  424. package/dist/select/select-root.mjs +2 -0
  425. package/dist/select/select-root.mjs.map +1 -1
  426. package/dist/select/select-separator.d.mts +9 -0
  427. package/dist/select/select-separator.d.mts.map +1 -1
  428. package/dist/select/select-separator.mjs +2 -0
  429. package/dist/select/select-separator.mjs.map +1 -1
  430. package/dist/select/select-trigger.d.mts +9 -0
  431. package/dist/select/select-trigger.d.mts.map +1 -1
  432. package/dist/select/select-trigger.mjs +2 -0
  433. package/dist/select/select-trigger.mjs.map +1 -1
  434. package/dist/select/select-value.d.mts +9 -0
  435. package/dist/select/select-value.d.mts.map +1 -1
  436. package/dist/select/select-value.mjs +2 -0
  437. package/dist/select/select-value.mjs.map +1 -1
  438. package/dist/slider/index.d.mts +2 -0
  439. package/dist/slider/index.d.mts.map +1 -1
  440. package/dist/slider/index.mjs +2 -0
  441. package/dist/slider/index.mjs.map +1 -1
  442. package/dist/slider/slider-indicator.d.mts +12 -0
  443. package/dist/slider/slider-indicator.d.mts.map +1 -1
  444. package/dist/slider/slider-indicator.mjs +2 -0
  445. package/dist/slider/slider-indicator.mjs.map +1 -1
  446. package/dist/slider/slider-label.d.mts +11 -1
  447. package/dist/slider/slider-label.d.mts.map +1 -1
  448. package/dist/slider/slider-label.mjs +2 -0
  449. package/dist/slider/slider-label.mjs.map +1 -1
  450. package/dist/slider/slider-root.d.mts +53 -9
  451. package/dist/slider/slider-root.d.mts.map +1 -1
  452. package/dist/slider/slider-root.mjs +4 -8
  453. package/dist/slider/slider-root.mjs.map +1 -1
  454. package/dist/slider/slider-thumb.d.mts +32 -3
  455. package/dist/slider/slider-thumb.d.mts.map +1 -1
  456. package/dist/slider/slider-thumb.mjs +2 -0
  457. package/dist/slider/slider-thumb.mjs.map +1 -1
  458. package/dist/slider/slider-track.d.mts +17 -0
  459. package/dist/slider/slider-track.d.mts.map +1 -1
  460. package/dist/slider/slider-track.mjs +2 -0
  461. package/dist/slider/slider-track.mjs.map +1 -1
  462. package/dist/slider/slider-value.d.mts +11 -0
  463. package/dist/slider/slider-value.d.mts.map +1 -1
  464. package/dist/slider/slider-value.mjs +2 -0
  465. package/dist/slider/slider-value.mjs.map +1 -1
  466. package/dist/switch/switch.d.mts +23 -3
  467. package/dist/switch/switch.d.mts.map +1 -1
  468. package/dist/switch/switch.mjs +2 -0
  469. package/dist/switch/switch.mjs.map +1 -1
  470. package/dist/tabs/index.d.mts +2 -0
  471. package/dist/tabs/index.d.mts.map +1 -1
  472. package/dist/tabs/index.mjs +2 -0
  473. package/dist/tabs/index.mjs.map +1 -1
  474. package/dist/tabs/tabs-context.d.mts +5 -0
  475. package/dist/tabs/tabs-context.d.mts.map +1 -1
  476. package/dist/tabs/tabs-context.mjs.map +1 -1
  477. package/dist/tabs/tabs-indicator.d.mts +17 -0
  478. package/dist/tabs/tabs-indicator.d.mts.map +1 -1
  479. package/dist/tabs/tabs-indicator.mjs +2 -0
  480. package/dist/tabs/tabs-indicator.mjs.map +1 -1
  481. package/dist/tabs/tabs-list.d.mts +19 -1
  482. package/dist/tabs/tabs-list.d.mts.map +1 -1
  483. package/dist/tabs/tabs-list.mjs +2 -0
  484. package/dist/tabs/tabs-list.mjs.map +1 -1
  485. package/dist/tabs/tabs-panel.d.mts +19 -0
  486. package/dist/tabs/tabs-panel.d.mts.map +1 -1
  487. package/dist/tabs/tabs-panel.mjs +2 -0
  488. package/dist/tabs/tabs-panel.mjs.map +1 -1
  489. package/dist/tabs/tabs-root.d.mts +39 -5
  490. package/dist/tabs/tabs-root.d.mts.map +1 -1
  491. package/dist/tabs/tabs-root.mjs +2 -0
  492. package/dist/tabs/tabs-root.mjs.map +1 -1
  493. package/dist/tabs/tabs-tab.d.mts +22 -1
  494. package/dist/tabs/tabs-tab.d.mts.map +1 -1
  495. package/dist/tabs/tabs-tab.mjs +2 -0
  496. package/dist/tabs/tabs-tab.mjs.map +1 -1
  497. package/dist/toast/index.d.mts +2 -0
  498. package/dist/toast/index.d.mts.map +1 -1
  499. package/dist/toast/index.mjs +2 -0
  500. package/dist/toast/index.mjs.map +1 -1
  501. package/dist/toast/toast-action.d.mts +42 -6
  502. package/dist/toast/toast-action.d.mts.map +1 -1
  503. package/dist/toast/toast-action.mjs +8 -4
  504. package/dist/toast/toast-action.mjs.map +1 -1
  505. package/dist/toast/toast-close.d.mts +16 -0
  506. package/dist/toast/toast-close.d.mts.map +1 -1
  507. package/dist/toast/toast-close.mjs +2 -0
  508. package/dist/toast/toast-close.mjs.map +1 -1
  509. package/dist/toast/toast-context.mjs.map +1 -1
  510. package/dist/toast/toast-description.d.mts +16 -1
  511. package/dist/toast/toast-description.d.mts.map +1 -1
  512. package/dist/toast/toast-description.mjs +2 -0
  513. package/dist/toast/toast-description.mjs.map +1 -1
  514. package/dist/toast/toast-queue.mjs.map +1 -1
  515. package/dist/toast/toast-root.d.mts +20 -0
  516. package/dist/toast/toast-root.d.mts.map +1 -1
  517. package/dist/toast/toast-root.mjs +2 -0
  518. package/dist/toast/toast-root.mjs.map +1 -1
  519. package/dist/toast/toast-title.d.mts +15 -1
  520. package/dist/toast/toast-title.d.mts.map +1 -1
  521. package/dist/toast/toast-title.mjs +2 -0
  522. package/dist/toast/toast-title.mjs.map +1 -1
  523. package/dist/toast/toast-viewport.d.mts +34 -5
  524. package/dist/toast/toast-viewport.d.mts.map +1 -1
  525. package/dist/toast/toast-viewport.mjs +17 -15
  526. package/dist/toast/toast-viewport.mjs.map +1 -1
  527. package/dist/toast/toast.d.mts +56 -13
  528. package/dist/toast/toast.d.mts.map +1 -1
  529. package/dist/toast/toast.mjs +4 -0
  530. package/dist/toast/toast.mjs.map +1 -1
  531. package/dist/toggle/toggle.d.mts +20 -2
  532. package/dist/toggle/toggle.d.mts.map +1 -1
  533. package/dist/toggle/toggle.mjs +2 -0
  534. package/dist/toggle/toggle.mjs.map +1 -1
  535. package/dist/toggle-group/index.d.mts +2 -0
  536. package/dist/toggle-group/index.d.mts.map +1 -1
  537. package/dist/toggle-group/index.mjs +2 -0
  538. package/dist/toggle-group/index.mjs.map +1 -1
  539. package/dist/toggle-group/toggle-group-context.d.mts +1 -0
  540. package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
  541. package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
  542. package/dist/toggle-group/toggle-group-item.d.mts +16 -0
  543. package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
  544. package/dist/toggle-group/toggle-group-item.mjs +2 -0
  545. package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
  546. package/dist/toggle-group/toggle-group-root.d.mts +73 -12
  547. package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
  548. package/dist/toggle-group/toggle-group-root.mjs +3 -1
  549. package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
  550. package/dist/toolbar/index.d.mts +2 -0
  551. package/dist/toolbar/index.d.mts.map +1 -1
  552. package/dist/toolbar/index.mjs +2 -0
  553. package/dist/toolbar/index.mjs.map +1 -1
  554. package/dist/toolbar/toolbar-root.d.mts +30 -3
  555. package/dist/toolbar/toolbar-root.d.mts.map +1 -1
  556. package/dist/toolbar/toolbar-root.mjs +2 -0
  557. package/dist/toolbar/toolbar-root.mjs.map +1 -1
  558. package/dist/toolbar/toolbar-separator.d.mts +13 -0
  559. package/dist/toolbar/toolbar-separator.d.mts.map +1 -1
  560. package/dist/toolbar/toolbar-separator.mjs +2 -0
  561. package/dist/toolbar/toolbar-separator.mjs.map +1 -1
  562. package/dist/tooltip/index.d.mts +2 -0
  563. package/dist/tooltip/index.d.mts.map +1 -1
  564. package/dist/tooltip/index.mjs +2 -0
  565. package/dist/tooltip/index.mjs.map +1 -1
  566. package/dist/tooltip/tooltip-arrow.d.mts +16 -0
  567. package/dist/tooltip/tooltip-arrow.d.mts.map +1 -1
  568. package/dist/tooltip/tooltip-arrow.mjs +2 -0
  569. package/dist/tooltip/tooltip-arrow.mjs.map +1 -1
  570. package/dist/tooltip/tooltip-context.d.mts +4 -0
  571. package/dist/tooltip/tooltip-context.d.mts.map +1 -1
  572. package/dist/tooltip/tooltip-context.mjs.map +1 -1
  573. package/dist/tooltip/tooltip-popup.d.mts +24 -3
  574. package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
  575. package/dist/tooltip/tooltip-popup.mjs +2 -0
  576. package/dist/tooltip/tooltip-popup.mjs.map +1 -1
  577. package/dist/tooltip/tooltip-root.d.mts +24 -2
  578. package/dist/tooltip/tooltip-root.d.mts.map +1 -1
  579. package/dist/tooltip/tooltip-root.mjs +2 -0
  580. package/dist/tooltip/tooltip-root.mjs.map +1 -1
  581. package/dist/tooltip/tooltip-trigger.d.mts +18 -1
  582. package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
  583. package/dist/tooltip/tooltip-trigger.mjs +2 -0
  584. package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
  585. package/package.json +9 -1
  586. package/skills/funstack-ui-knowledge/SKILL.md +75 -0
  587. package/dist/internal/use-superseded-rejection.mjs +0 -47
  588. package/dist/internal/use-superseded-rejection.mjs.map +0 -1
@@ -0,0 +1,656 @@
1
+ # Popover
2
+
3
+ Built on `popover="auto"`, a `<dialog>` element, a `popovertarget` Trigger and an Invoker Command Close. The platform supplies the top layer, light dismiss, Escape, one-at-a-time stacking with nesting, placement next to the trigger, a declarative trigger that works before hydration, and focus return. The library adds the asynchronous half: opening a popover whose content loads is a transition, so the trigger shows `data-pending` and the popover opens once its content is ready; and the closes the user asks a part for run through the library too, so `<ViewTransition>` can animate the exit, in Firefox as well.
4
+
5
+ ```tsx title="PopoverShare.tsx"
6
+ // No "use client": this file is a Server Component. The Popover.Root has no `open`, `defaultOpen`
7
+ // or `openChangeAction`, so it runs in JS-free mode: the Trigger is a native `popovertarget`
8
+ // invoker and Done is a `command="hide-popover"` button. The browser opens the popup in the top
9
+ // layer below the button, focuses the input (the first focusable element, through the dialog
10
+ // focusing steps), and closes it on Escape, a click outside or Done, before hydration and with
11
+ // JavaScript off. No `autoFocus`: React writes it only into
12
+ // server-rendered HTML, not after a client navigation; `initialFocus` covers both.
13
+ import { Popover } from "@funstack/ui/popover";
14
+
15
+ export function PopoverShare() {
16
+ return (
17
+ <Popover.Root>
18
+ <Popover.Trigger className="demo-button">Share</Popover.Trigger>
19
+ <Popover.Popup className="demo-popover" align="start">
20
+ <Popover.Title>Share this page</Popover.Title>
21
+ <input
22
+ className="demo-popover-input"
23
+ readOnly
24
+ value="https://ui.funstack.work/components/popover"
25
+ />
26
+ <div className="demo-popover-actions">
27
+ <Popover.Close className="demo-button">Done</Popover.Close>
28
+ </div>
29
+ </Popover.Popup>
30
+ </Popover.Root>
31
+ );
32
+ }
33
+ ```
34
+
35
+ ```css title="popover.css"
36
+ /* Popover: the Popup is the <dialog popover> itself. Open state is `:popover-open` on it (exact
37
+ in both modes); the Trigger carries `data-open` in both modes and `data-pending` in library
38
+ mode only. A <button> Trigger has no `aria-expanded` (the browser exposes its state). */
39
+
40
+ .demo-popover {
41
+ /* The popover UA stylesheet sets `inset: 0; margin: auto`: reset both for anchored placement. */
42
+ margin: 0;
43
+ inset: auto;
44
+ min-inline-size: 14rem;
45
+ padding: 16px;
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.25);
51
+ }
52
+
53
+ /* The gap. `data-side` is where the browser placed the popup (absent with `side={null}`); a
54
+ flip swaps the popup's margins, so the gap goes on both sides of the axis. */
55
+ .demo-popover[data-side="bottom"],
56
+ .demo-popover[data-side="top"] {
57
+ margin-block: 6px;
58
+ }
59
+
60
+ .demo-popover h2 {
61
+ margin: 0 0 8px;
62
+ padding: 0;
63
+ border: 0;
64
+ font-size: 1rem;
65
+ }
66
+
67
+ /* Enter and exit with CSS, both modes. Enter works everywhere; the exit animates in Chromium
68
+ (with `overlay`) and Safari and is instant in Firefox. On iOS, `position-try-fallbacks`
69
+ together with `@starting-style` can hang (WebKit bug 317926). */
70
+ .demo-popover {
71
+ opacity: 0;
72
+ translate: 0 -4px;
73
+ transition:
74
+ opacity 120ms,
75
+ translate 120ms,
76
+ display 120ms allow-discrete,
77
+ overlay 120ms allow-discrete;
78
+ }
79
+
80
+ .demo-popover:popover-open {
81
+ opacity: 1;
82
+ translate: 0 0;
83
+ }
84
+
85
+ @starting-style {
86
+ .demo-popover:popover-open {
87
+ opacity: 0;
88
+ translate: 0 -4px;
89
+ }
90
+ }
91
+
92
+ /* With `transition`, the view transition animates library-driven opens and closes (Firefox
93
+ included); dismissals keep the CSS exit above.
94
+ The library keeps the two apart; no extra rule is needed. */
95
+
96
+ ::view-transition-new(.pop) {
97
+ animation: 160ms ease-out both demo-pop-in;
98
+ }
99
+
100
+ ::view-transition-old(.pop) {
101
+ animation: 120ms ease-in both demo-pop-out;
102
+ }
103
+
104
+ @keyframes demo-pop-in {
105
+ from {
106
+ opacity: 0;
107
+ scale: 0.96;
108
+ }
109
+ }
110
+
111
+ @keyframes demo-pop-out {
112
+ to {
113
+ opacity: 0;
114
+ scale: 0.96;
115
+ }
116
+ }
117
+
118
+ @media (prefers-reduced-motion: reduce) {
119
+ .demo-popover {
120
+ transition: none;
121
+ }
122
+ ::view-transition-group(*),
123
+ ::view-transition-old(*),
124
+ ::view-transition-new(*) {
125
+ animation: none !important;
126
+ }
127
+ }
128
+
129
+ /* Dim the popup while a Close action runs (the Close button carries data-pending). */
130
+ .demo-popover:popover-open:has([data-pending]) {
131
+ opacity: 0.8;
132
+ }
133
+
134
+ .demo-popover-actions {
135
+ display: flex;
136
+ justify-content: flex-end;
137
+ gap: 8px;
138
+ margin-top: 12px;
139
+ }
140
+
141
+ .demo-popover-input {
142
+ box-sizing: border-box;
143
+ inline-size: 100%;
144
+ padding: 0.35em 0.6em;
145
+ border: 1px solid var(--color-border);
146
+ border-radius: 6px;
147
+ background: var(--color-bg);
148
+ color: var(--color-text);
149
+ font: inherit;
150
+ }
151
+
152
+ /* The Trigger: `data-open` flips at the click in library mode and follows the shown popup in
153
+ JS-free mode. A page that never hydrates can use `.demo-button:has(+ :popover-open)`. */
154
+ .demo-button[data-open] {
155
+ border-color: var(--color-primary);
156
+ color: var(--color-primary);
157
+ }
158
+
159
+ .demo-button[data-pending] {
160
+ cursor: progress;
161
+ }
162
+
163
+ ul.demo-list {
164
+ margin: 0 0 12px;
165
+ padding: 0;
166
+ list-style: none;
167
+ }
168
+
169
+ ul.demo-list .demo-row {
170
+ justify-content: space-between;
171
+ max-inline-size: 20rem;
172
+ padding-block: 4px;
173
+ }
174
+
175
+ ul.demo-list .demo-row[data-archived] > span {
176
+ color: var(--color-text-secondary);
177
+ text-decoration: line-through;
178
+ }
179
+ ```
180
+
181
+ This share popover is a Server Component in JS-free mode. The Trigger and Done are native invokers, so it works before hydration and with JavaScript disabled; the platform's dialog focusing steps put focus on the input, the first focusable element.
182
+
183
+ ## Anatomy
184
+
185
+ ```tsx
186
+ import { Popover } from "@funstack/ui/popover";
187
+
188
+ <Popover.Root> {/* no DOM: ids, mode, state */}
189
+ <Popover.Trigger>Filters</Popover.Trigger> {/* button[popovertarget] */}
190
+ <Popover.Popup side="bottom" align="start"> {/* dialog[popover=auto][aria-modal=false] */}
191
+ <Popover.Title>Filters</Popover.Title> {/* h2, wired to aria-labelledby */}
192
+ <Popover.Description>…</Popover.Description> {/* p, wired to aria-describedby */}
193
+ <FilterForm />
194
+ <Popover.Close>Done</Popover.Close> {/* button[commandfor][command=hide-popover] */}
195
+ </Popover.Popup>
196
+ </Popover.Root>
197
+ ```
198
+
199
+ - **Root renders no DOM.** Trigger and Popup are linked by id through `popovertarget`. Render the Popup **right after the Trigger** where the layout allows: Safari 27.0 does not put a far-away popover next in the Tab order after its trigger. A `<button popovertarget>` or `<button commandfor command>` of your own that targets the popover is a [foreign invoker](../concepts/browser-owned-state.md#foreign-invoker) (see [Other ways to open and close](#other-openers)).
200
+ - **Popup is the `<dialog popover>` itself.** There is no Portal, Positioner, Arrow or Backdrop part: the top layer and CSS Anchor Positioning make them unnecessary, and a portalled popover would be inert inside a modal Dialog. A Popover nested inside a Popup is a nested popover; a Dialog opened from a Popup keeps it open.
201
+ - No `Form` part: a popover-shown `<dialog>` ignores `<form method="dialog">`. "Submit, then close" is a `<form action>` plus a controlled `open` (recipe below), or a `Popover.Close action`.
202
+ - `render`: Popup renders a `<dialog>` (default) or a `<div>`; Trigger and Close render a `<button>` for the native invoker path, and another element works only through the library's click handler (library mode, or a Close with `action`). Wrong elements are development warnings.
203
+
204
+ ## How it works
205
+
206
+ ### Two modes
207
+
208
+ | | JS-free mode | Library mode |
209
+ | - | - | - |
210
+ | Selected when | Root has none of `open`, `defaultOpen`, `openChangeAction`, `onOpenChange` | Root has any of them |
211
+ | Open | the browser toggles it (the Trigger's `popovertarget`) | the click is intercepted and dispatched in the Root's transition; `showPopover({ source: trigger })` runs in the commit that mounts the content. Any other open (a foreign invoker, a script) is cancelled at `beforetoggle` and routed the same way |
212
+ | Close by a part (Trigger, Close) | the browser | the library: `openChangeAction(false)` is awaited, then `hidePopover()` runs in the commit |
213
+ | Close by a dismissal (Escape, click outside, another popover) | the browser | the browser; a fact: `onOpenChange(false)` is called synchronously, nothing is pending, no view transition |
214
+ | Popup content | always mounted (in the server HTML) | rendered from committed `open`; unmounted while closed unless `keepMounted` |
215
+ | Trigger `data-open` | kept current on the element from the popup's `toggle` event | optimistic, rendered |
216
+ | Trigger `data-pending` | not emitted | emitted |
217
+ | Before hydration | everything works | the native open happens; the content arrives on hydration |
218
+ | `transition` on Popup | no effect (development warning) | animates opens, content swaps and every library-driven close |
219
+
220
+ 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, a click outside, another popover opening) is the browser's: a fact, reported to `onOpenChange` ([Requests and facts](../concepts/browser-owned-state.md#requests-and-facts)). The mode is decided on the first render; switching later is not supported (development warning).
221
+
222
+ ### <a id="other-openers"></a>Other ways to open and close
223
+
224
+ - **[Foreign invokers](../concepts/browser-owned-state.md#foreign-invoker) and scripts:** in library mode any open that the library did not start (a `<button commandfor command="show-popover">`, a `<button popovertarget>`, a script `showPopover()`) is cancelled at `beforetoggle` and dispatched with that `ToggleEvent`. A foreign close happens natively, so it is a fact: `onOpenChange(false)` with `"activate"` and a `hide-popover` or `toggle-popover` command's `CommandEvent`, or a `<button popovertarget>`'s `beforetoggle` `ToggleEvent`, whose `source` is the button. Escape, a click outside and a script `hidePopover()` are `"dismiss"` facts.
225
+ - **Hover card (Chromium):** a `<button interestfor>` naming the Popup (your own button, or the Trigger with `interestfor` added) opens it on interest (hover or keyboard focus) through the library, and in library mode the Popup hides again on lost interest: a `"dismiss"` fact, `onOpenChange(false)`, whose `details.event` is the `loseinterest` event (its `source` is the button). Lost interest while the open is still pending cancels it (a request, `openChangeAction(false, { reason: "dismiss" })`, superseding the open), so the card never appears under a pointer that has left. A Trigger-click open stays open on lost interest, as in the platform. As with the platform's own lost-interest hide, focus is not returned to the Trigger. Firefox and Safari ignore `interestfor`, so give the button a click path (make it the Trigger) when the card must open everywhere. For a name or description (`role="tooltip"` content), use [Tooltip](tooltip.md).
226
+
227
+ ## Props
228
+
229
+ ### `Popover.Root`
230
+
231
+ | Prop | Type | Default | Description |
232
+ | - | - | - | - |
233
+ | `open` | `boolean` | – | Controlled open state. undefined means uncontrolled. Selects library mode. Pass `onOpenChange` too: the browser closes the popover without asking (development warns). |
234
+ | `defaultOpen` | `boolean` | – | Initial open state in uncontrolled library mode. A popover that starts open is shown after hydration (there is no attribute for an open popover in HTML); its content and the Trigger's `data-open` are already in the server HTML, while the Trigger is exposed collapsed until the popup is shown. `defaultOpen={false}` is the usual way to select library mode without an action. |
235
+ | `openChangeAction` | `ChangeAction<boolean, PopoverOpenChangeDetails>` | – | Requests only. Awaited for `true` (the popover opens when it resolves and the content has rendered) and for a `false` the user asked a part for (Trigger, Close: the popover hides when it resolves). Never called for a dismissal (`onOpenChange`). Runs in the Root's transition; may be a Server Function; rejections reach the nearest Error Boundary above the Root. `details.reason`: `"activate"` (Trigger, Close, a foreign open), `"dismiss"` (lost interest while an `interestfor` open is still pending) or `"platform"` (found open on hydration; `event` is `undefined`). Selects library mode. |
236
+ | `onOpenChange` | `UrgentChangeHandler<boolean, PopoverOpenChangeDetails>` | – | Facts only: the popover was closed without the library closing it. Always `false`. `details.reason`: `"dismiss"` (Escape, a click outside, another popover or modal dialog, a parent popover closing, script `hidePopover()`, lost interest on an `interestfor` button) or `"activate"` (a foreign invoker; a non-button Trigger pressed while open). Called synchronously in the browser's `toggle` event, outside any transition, and not awaited: nothing is pending and no view transition runs. In controlled mode set state directly here (`onOpenChange={setOpen}`), never in `startTransition` or after an `await`; a parent that keeps `open` gets the popover shown again at once. May return a promise (a Server Function); a rejection or a throw goes to `reportError`. Selects library mode. |
237
+ | `children` | `ReactNode \| ((state: PopoverRootState) => ReactNode)` | – | The parts. The function form receives the optimistic state and must not suspend. |
238
+
239
+ - **State**: `PopoverRootState` is `{ open, pending }`; `open` is optimistic, and both are `false` in JS-free mode.
240
+ - **Owned**: nothing rendered: the Root has no element (no `ref`, `className` or `style`), and no `disabled` (the Trigger has it).
241
+
242
+ ### `Popover.Trigger`
243
+
244
+ A `<button popovertarget>`: see [Triggers of a popup](../concepts/browser-owned-state.md#popup-triggers) for what that gives it, and for a Trigger rendered as another element. One per Root: it is the popover's anchor and focus-return target, and a press on a second Trigger while open counts as outside.
245
+
246
+ | Prop | Type | Default | Description |
247
+ | - | - | - | - |
248
+ | `disabled` | `boolean` | `false` | Native `disabled`: a disabled button is not an invoker and never dispatches. Owned, so a `render` element cannot re-enable it. In library mode with a link or component `render`, `aria-disabled="true"` instead (the element stays focusable). |
249
+ | `className` | `string \| ((state: PopoverTriggerState) => string \| undefined)` | – | A class name, or a function of the part's state. |
250
+ | `style` | `CSSProperties \| ((state: PopoverTriggerState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
251
+ | `children` | `ReactNode \| ((state: PopoverTriggerState) => ReactNode)` | – | Rendered from optimistic state; must not suspend. |
252
+ | `render` | `ReactElement \| ((props, state: PopoverTriggerState) => ReactNode)` | – | Replace the default \<button> (element form) or take over rendering (function form). |
253
+
254
+ - **State**: `PopoverTriggerState` is `{ open, pending, disabled }`; `pending` is true while the Root is pending: an open or a part's close, never a dismissal (a request still running when a dismissal superseded it keeps `pending` until that request settles).
255
+ - **Owned**: `type` (only on a `<button>`), `disabled`, `aria-disabled` (library mode, link or component `render`), `popoverTarget` (only on an invoker), `aria-expanded` (only on a Trigger that is no invoker), `onClick` (library mode), `data-open`, `data-pending`, `data-disabled`. Owned and never written: `popoverTargetAction`, `commandfor`, `command`. Not in the props type: these three, `popoverTarget` and `aria-expanded`.
256
+
257
+ A click on a `<button>` Trigger while open is a part's close; a second click during a pending open cancels it (the latest intent wins). A Trigger rendered as another element (library mode only) is light-dismissed before its click; that close is a fact, `onOpenChange(false)` with `"activate"` and the click. `aria-haspopup` and `aria-controls` pass through.
258
+
259
+ ### `Popover.Popup`
260
+
261
+ | Prop | Type | Default | Description |
262
+ | - | - | - | - |
263
+ | `side` | `"top" \| "bottom" \| "left" \| "right" \| "inline-start" \| "inline-end" \| null` | `"bottom"` | Placement relative to the Trigger through inline `position-area`, with `position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline` flipping it when it does not fit. `inline-start` / `inline-end` follow the popup's direction (`inline-end` is the right in LTR, the left in RTL); the other four are physical. `null` emits no inline placement and no `data-side` / `data-align`: your stylesheet owns placement. |
264
+ | `align` | `"start" \| "center" \| "end"` | `"center"` | Alignment along the side. On a top / bottom side `start` / `end` are inline-relative (`start` lines up the inline-start edges: the left in LTR, the right in RTL); on the other sides the top / bottom edges. Ignored when `side` is `null`. |
265
+ | `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). Unmounting waits for the popover's CSS exit animation, or happens in the close commit when `transition` is set. Ignored in JS-free mode (always mounted). An action of a part inside that rejects while it is hidden goes to `reportError`, not to an Error Boundary (see [Action props](../concepts/action-props.md)). |
266
+ | `initialFocus` | `RefObject<HTMLElement \| null> \| string` | – | The element to focus on open: a ref, or a selector resolved inside the popup. The library writes `autofocus` on it right before `showPopover()` and lets the platform focus it. Default: the platform's choice for a `<dialog>` (the first focusable element, else the popup); with `render={<div />}` focus stays on the Trigger. 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). |
267
+ | `transition` | `ViewTransitionClass` | – | Library mode only. Forwarded to a `<ViewTransition>` around the popover element itself: animates the opening commit, content swaps, and every library-driven close (Trigger, Close, a controlled `open={false}`) in all engines. Dismissals are the browser's and animate with CSS. Default: no boundary. Keep it static; any value makes a Root inserted by a transition run the page cross-fade. |
268
+ | `className` | `string \| ((state: PopoverPopupState) => string \| undefined)` | – | A class name, or a function of the part's state. |
269
+ | `style` | `CSSProperties \| ((state: PopoverPopupState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
270
+ | `children` | `ReactNode \| ((state: PopoverPopupState) => ReactNode)` | – | Content, or a function of the part's state. |
271
+ | `render` | `ReactElement \| ((props, state: PopoverPopupState) => ReactNode)` | – | Replace the default \<dialog> (element form) or take over rendering (function form). |
272
+
273
+ - **State**: `PopoverPopupState` is `{ open, side, align }`; `open` is committed (`false` in JS-free mode; `:popover-open` is the DOM truth); `side` / `align` are where the browser placed the popup while it is shown (a physical side, after any fallback flip, in both modes), your props otherwise.
274
+ - **Owned**: `id`, `popover` (`"auto"`), `open` (never rendered), `aria-modal` (`"false"`: Chromium exposes a `<dialog popover>` as modal otherwise), `data-side` / `data-align` (unless `side` is `null`); `aria-labelledby` and `aria-describedby` are merged with yours.
275
+
276
+ `role="dialog"` is a default you can override (`"region"` or `"group"` for a non-interactive card). `onToggle` and `onBeforeToggle` are not accepted; use a `ref` for the platform events. Your `style` wins over the inline placement.
277
+
278
+ ### `Popover.Close`
279
+
280
+ | Prop | Type | Default | Description |
281
+ | - | - | - | - |
282
+ | `action` | `Action<[details: ActionDetails]>` | – | Runs in this button's own transition (`data-pending` on it), then closes the popover: in library mode through the Root (`openChangeAction(false)` awaited, view transition if set), in JS-free mode with `hidePopover()`. A rejection reaches the nearest Error Boundary above the button and leaves the popover open. A second click while it is pending is ignored, and the button is `aria-disabled="true"` meanwhile, unless `whilePending` is `"run"`. Without `action` in JS-free mode the button is a native `command="hide-popover"` invoker. |
283
+ | `whilePending` | `"run" \| "ignore"` | `"ignore"` | What a click, Enter or Space does while this part's `action` is pending. `"ignore"`: nothing (the click is cancelled, `aria-disabled="true"` meanwhile). `"run"`: the action runs again (`data-pending` until every run has settled, no `aria-disabled`); the popover closes once the last run has settled, and only if the latest run resolved: a rejection leaves it open in both modes. No effect without `action`. See [A second click while pending](../concepts/pending-and-optimistic.md#second-click). |
284
+ | `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). |
285
+ | `className` | `string \| ((state: PopoverCloseState) => string \| undefined)` | – | A class name, or a function of the part's state. |
286
+ | `style` | `CSSProperties \| ((state: PopoverCloseState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
287
+ | `children` | `ReactNode \| ((state: PopoverCloseState) => ReactNode)` | – | Content, or a function of the part's state. |
288
+ | `render` | `ReactElement \| ((props, state: PopoverCloseState) => ReactNode)` | – | Replace the default \<button> (element form) or take over rendering (function form). |
289
+
290
+ - **State**: `PopoverCloseState` is `{ pending, disabled }`.
291
+ - **Owned**: `type` (on a `<button>` only), `disabled`, `aria-disabled`, `commandfor`, `command` (not on a link or other non-button host element), `onClick` (library mode, or with `action`), `data-pending`, `data-disabled`; a `render` element cannot re-enable a disabled Close.
292
+
293
+ In library mode the click is always intercepted, so every Close goes through the Root. By default (`whilePending="ignore"`) a second click while the action is pending is ignored (and cancelled), and the button is `aria-disabled="true"` for as long as it shows `data-pending` (the action and the hide); never natively disabled, so it keeps focus. To hide at once and finish the work in the background, do not return the promise: `action={() => { void apply(); }}`. If the user dismisses the popover and opens it again while the action runs, the action's close is dropped: it belonged to the earlier open. Popovers have no return value.
294
+
295
+ ### `Popover.Title`, `Popover.Description`
296
+
297
+ | Prop | Type | Default | Description |
298
+ | - | - | - | - |
299
+ | `className` | `string \| ((state: PopoverTitleState) => string \| undefined)` | – | A class name, or a function of the part's state. |
300
+ | `style` | `CSSProperties \| ((state: PopoverTitleState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
301
+ | `children` | `ReactNode \| ((state: PopoverTitleState) => ReactNode)` | – | Content, or a function of the part's state. |
302
+ | `render` | `ReactElement \| ((props, state: PopoverTitleState) => ReactNode)` | – | Replace the default \<h2> (Title) or \<p> (Description). `render={<h3 />}` changes the heading level. |
303
+
304
+ - **State**: the Popup's (`PopoverTitleState` and `PopoverDescriptionState` are `PopoverPopupState`).
305
+ - **Owned**: `id`.
306
+
307
+ A dialog-role Popup with neither a Title nor an `aria-label` is a development warning once shown.
308
+
309
+ ## Data attributes
310
+
311
+ | Hook | On | Meaning |
312
+ | - | - | - |
313
+ | `:popover-open` | Popup | The popover is shown (DOM truth, both modes). |
314
+ | `data-side`, `data-align` | Popup | While shown: where the browser placed the popup (`top` / `bottom` / `left` / `right`, after any flip; read from the computed `position-area`). Otherwise the requested placement. Absent with `side={null}`. |
315
+ | `aria-expanded` | Trigger, only when it is no [invoker](../concepts/browser-owned-state.md#popup-triggers): a link or other non-button element, or a disabled component `render` | Whether the popup is shown (library mode). A `<button>` Trigger has none: the browser exposes the state. |
316
+ | `data-open` | Trigger | Library mode: optimistic open state. JS-free mode: whether the popup is shown, written from its `toggle` event. |
317
+ | `data-pending` | Trigger | An open or a part-initiated close is in flight (library mode only). A dismissal never pends, but a request still running when a dismissal superseded it keeps it until that request settles. |
318
+ | `data-pending` | Close | Its `action` is in flight. |
319
+ | `aria-disabled` | Close | `"true"` while `data-pending` with `whilePending="ignore"` (the default): a second click is ignored meanwhile. |
320
+ | `data-disabled` | Trigger, Close | The `disabled` prop (both modes). |
321
+
322
+ ## Keyboard and ARIA
323
+
324
+ | Key | Behaviour | Who |
325
+ | - | - | - |
326
+ | Enter / Space on the Trigger | Toggles | the browser (JS-free) or the Trigger |
327
+ | Tab / Shift+Tab | Moves through the popup; the popup follows the Trigger in focus order. Tab past the end leaves, and the popover stays open | the browser |
328
+ | Escape | Closes the innermost open popover; focus returns to its Trigger; `onOpenChange(false, { reason: "dismiss" })` | the browser (and the library for a nested popover) |
329
+ | Escape in a modal Dialog opened from the popup | Closes the Dialog only; a second Escape closes the popover | the browser |
330
+
331
+ - **Initial focus.** With the default `<dialog>`, opening runs the dialog focusing steps: the `initialFocus` target, else the first focusable element, else the popup itself (the APG non-modal dialog), in every engine. For a disclosure-style card that keeps focus on the Trigger, render a `<div>`: `render={<div />}` with `role="region"` and an `aria-label`.
332
+ - **Focus return.** The platform returns focus to the Trigger for the first popover in a stack. For a **nested** popover it returns nothing, so the library focuses the inner Trigger when focus was inside the popup and was left on the body. A click outside leaves focus where the click put it.
333
+ - **ARIA.** The Popup has `role="dialog"` and `aria-modal="false"` explicitly (WebKit implements no minimum role for popovers; Chromium would expose a `<dialog popover>` as modal). The browser exposes the Trigger's expanded state ([Triggers of a popup](../concepts/browser-owned-state.md#popup-triggers)). No `aria-haspopup` (the APG disclosure shape); add `aria-haspopup="dialog"` or `aria-controls` yourself if you want them.
334
+ - No focus trap and no `lightDismiss` or `modal` prop: light dismiss and Escape are what `popover="auto"` is. A panel that must survive stray clicks is a [Dialog](dialog.md).
335
+
336
+ ## Transition types
337
+
338
+ Concept: [Transitions & ViewTransition](../concepts/transitions.md#transition-types)
339
+
340
+ Library mode: `fsui-popover` plus `fsui-popover-open` or `fsui-popover-close`; a controlled close carries none, and a dismissal starts no transition at all. JS-free mode starts no transitions.
341
+
342
+ ### ViewTransition: an exit in every engine
343
+
344
+ With `transition`, the Popup renders `<ViewTransition>` around the popover element itself. A library-driven open shows the popover in the layout effect of its commit and a library-driven close hides it in the layout effect of its commit, so the view transition captures the popup's box as `::view-transition-new` on open and `::view-transition-old` (with its content) on close. That is the only way a popover's exit can animate in Firefox.
345
+
346
+ ```tsx
347
+ <Popover.Popup transition={{ "fsui-popover-open": "pop-in", "fsui-popover-close": "pop-out", default: "none" }}>
348
+ ```
349
+
350
+ ```css
351
+ ::view-transition-new(.pop-in) { animation: 160ms ease-out both pop-in; }
352
+ ::view-transition-old(.pop-out) { animation: 120ms ease-in both pop-out; }
353
+ @media (prefers-reduced-motion: reduce) {
354
+ ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
355
+ }
356
+ ```
357
+
358
+ - Transition types: `fsui-popover` plus `fsui-popover-open` or `fsui-popover-close`. A controlled close carries none.
359
+ - Dismissals (Escape, a click outside) are facts: their commit is urgent, so they start no view transition and animate with the CSS exit only. Keep it next to `transition`: the library turns the popup's CSS transitions off for the moment of its own show and hide while a view transition runs, so you need no extra rule ([A popup with a CSS exit and a view transition](../concepts/transitions.md#css-exit)).
360
+ - A plain open starts no document view transition: the content mounts under the already-mounted popover element. A Popup with `transition` that itself mounts inside a transition (a Root inserted by one, a nested Popup mounting with the outer content) runs the page cross-fade ([the transition prop](../concepts/transitions.md#transition-prop), issue [#35](https://github.com/uhyo/funstack-ui/issues/35)). The page receives no pointer events while a view transition runs: keep them short.
361
+
362
+ ## Optimistic and pending
363
+
364
+ Concept: [Pending & optimistic state](../concepts/pending-and-optimistic.md)
365
+
366
+ Library mode: the Trigger shows the optimistic open state (`data-open`) and `data-pending` while an open or a part's close is in flight. A dismissal is a fact: the popup, `data-open`, the committed `open` and the expanded state assistive technology hears all change at once, and nothing is pending. 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).
367
+
368
+ ### Walkthrough (library mode)
369
+
370
+ ```tsx title="PopoverActions.tsx"
371
+ "use client";
372
+ import { startTransition, use, useState } from "react";
373
+ import { Popover } from "@funstack/ui/popover";
374
+ import type { PopoverOpenChangeDetails } from "@funstack/ui/popover";
375
+ import { sleep } from "./fake-api.js";
376
+
377
+ // Cache the promises so `use()` sees the same one on every render.
378
+ const cache = new Map<string, Promise<readonly string[]>>();
379
+ function loadPermissions(id: string): Promise<readonly string[]> {
380
+ let promise = cache.get(id);
381
+ if (promise === undefined) {
382
+ promise = sleep(1000).then(() => (id === "notes" ? ["Rename"] : ["Rename", "Archive"]));
383
+ cache.set(id, promise);
384
+ }
385
+ return promise;
386
+ }
387
+
388
+ function RowActions({ id, archive }: { id: string; archive: () => Promise<void> }) {
389
+ const permissions = use(loadPermissions(id));
390
+ return (
391
+ <div className="demo-popover-actions">
392
+ <Popover.Close className="demo-button" action={() => sleep(400)}>
393
+ {({ pending }) => (pending ? "Renaming…" : "Rename")}
394
+ </Popover.Close>
395
+ {permissions.includes("Archive") && (
396
+ <Popover.Close className="demo-button demo-danger" action={archive}>
397
+ {({ pending }) => (pending ? "Archiving…" : "Archive")}
398
+ </Popover.Close>
399
+ )}
400
+ </div>
401
+ );
402
+ }
403
+
404
+ // Library mode: `defaultOpen={false}` (or any action prop) hands the open to the library. The
405
+ // Popup's children render from committed state, so <RowActions> mounts inside the opening
406
+ // transition and suspends: the popup stays hidden and the Trigger carries data-pending until the
407
+ // permissions are loaded, then it opens once, complete. A Close with an `action` runs it with its
408
+ // own pending state, then closes through the Root: the commit hides the popup, and
409
+ // `transition="pop"` animates that exit with a view transition, Firefox included. Escape and
410
+ // clicks outside are the browser's, facts reported to `onOpenChange` (reason "dismiss"), and use
411
+ // the CSS fade.
412
+ export function PopoverActions() {
413
+ const [archived, setArchived] = useState<readonly string[]>([]);
414
+ const [last, setLast] = useState("(none yet)");
415
+ const record = (open: boolean, { reason }: PopoverOpenChangeDetails) => {
416
+ // The synchronous part of an action: this setState is a transition update.
417
+ setLast(`openChangeAction(${open}, "${reason}")`);
418
+ };
419
+ const recordFact = (open: boolean, { reason }: PopoverOpenChangeDetails) => {
420
+ // A fact handler: this setState is urgent.
421
+ setLast(`onOpenChange(${open}, "${reason}")`);
422
+ };
423
+ const rows = [
424
+ { id: "report", name: "Quarterly report" },
425
+ { id: "notes", name: "Offsite notes" },
426
+ ];
427
+ return (
428
+ <>
429
+ <ul className="demo-list">
430
+ {rows.map(({ id, name }) => (
431
+ <li key={id} className="demo-row" data-archived={archived.includes(id) ? "" : undefined}>
432
+ <span>{name}</span>
433
+ <Popover.Root defaultOpen={false} openChangeAction={record} onOpenChange={recordFact}>
434
+ <Popover.Trigger className="demo-button" aria-label={`Actions for ${name}`}>
435
+ {({ pending }) => (pending ? <span className="demo-spinner" aria-hidden /> : "⋯")}
436
+ </Popover.Trigger>
437
+ <Popover.Popup className="demo-popover" align="end" transition="pop">
438
+ <Popover.Title>{name}</Popover.Title>
439
+ <RowActions
440
+ id={id}
441
+ archive={async () => {
442
+ await sleep(800);
443
+ // After an await: wrap the update in startTransition (React limitation).
444
+ startTransition(() => setArchived((ids) => [...ids, id]));
445
+ }}
446
+ />
447
+ </Popover.Popup>
448
+ </Popover.Root>
449
+ </li>
450
+ ))}
451
+ </ul>
452
+ <div className="demo-row">
453
+ <button type="button" className="demo-button" onClick={() => cache.clear()}>
454
+ Clear the cache
455
+ </button>
456
+ </div>
457
+ <output className="demo-readout">
458
+ last call: <code>{last}</code>
459
+ </output>
460
+ </>
461
+ );
462
+ }
463
+ ```
464
+
465
+ `popover.css`: the same file as above.
466
+
467
+ 1. Click ⋯: the click is cancelled (so the native toggle does not run), the Trigger gets `data-open` and `data-pending` (it is exposed collapsed until the popup is shown), and `openChangeAction(true, { reason: "activate" })` runs.
468
+ 2. The commit that sets committed `open` renders the Popup's children; `RowActions` suspends, so React holds the commit. The popup stays hidden; the Trigger keeps spinning.
469
+ 3. The data arrives: the content commits and `showPopover({ source: trigger })` runs in the same commit, so the popup is anchored below the Trigger and the platform focuses fully rendered content. With `transition="pop"` it animates in.
470
+ 4. Click Archive: the button shows its own pending label while its action runs; then the Close dispatches `openChangeAction(false, { reason: "activate" })` and the commit that ends it hides the popup inside a view transition: the exit animates in every engine.
471
+ 5. Press Escape or click outside instead: the browser hides the popover at once (CSS fade), and the Root calls `onOpenChange(false, { reason: "dismiss" })` in the same event. Nothing is pending, and `openChangeAction` is not called.
472
+
473
+ > **Refusing a close**
474
+ >
475
+ > A controlled parent that keeps `open` after a **part-initiated** close vetoes it: nothing was hidden, the Trigger's `data-open` snaps back. After a **dismissal** the popover is already hidden; a parent that keeps `open` gets it re-opened at once, which the user sees as a blink; the default `<dialog>` popup gets focus again from the browser's dialog focusing steps (after a click outside it takes focus back from the element clicked; [#156](https://github.com/uhyo/funstack-ui/issues/156)), a `<div>` popup keeps focus where the dismissal put it. Adopt `false` in `onOpenChange`, directly (`onOpenChange={setOpen}`), not in `startTransition` and not after an `await`.
476
+
477
+ ### A slow `openChangeAction`
478
+
479
+ Here every `openChangeAction` call takes 2 seconds, like a server call, and `onOpenChange` logs the dismissals. The Trigger is exposed as expanded exactly while the popup is shown:
480
+
481
+ ```tsx title="PopoverSlowOpen.tsx"
482
+ "use client";
483
+ import { startTransition, useState } from "react";
484
+ import { Popover } from "@funstack/ui/popover";
485
+ import type { PopoverOpenChangeDetails } from "@funstack/ui/popover";
486
+ import { sleep } from "./fake-api.js";
487
+
488
+ // A slow `openChangeAction`: a pretend server call of 2 seconds for every request (an open, or a
489
+ // close with the Trigger or the Close). Opening: the Trigger gets data-open and data-pending at
490
+ // once, the popup is shown when the action settles. Closing with the Trigger or the Close: the
491
+ // popup stays shown until the action settles. Escape and a click outside are the browser's, a
492
+ // fact: the popup hides at once, nothing is pending and the action is not called; `onOpenChange`
493
+ // reports it, synchronously. The browser exposes the Trigger as expanded exactly while the popup
494
+ // is shown. The readout is plain text, not a live region.
495
+ export function PopoverSlowOpen() {
496
+ const [log, setLog] = useState("(none yet)");
497
+ const slow = async (open: boolean, { reason }: PopoverOpenChangeDetails) => {
498
+ const call = `openChangeAction(${open}, "${reason}")`;
499
+ setLog(`${call}: running…`);
500
+ await sleep(2000);
501
+ // After an await: wrap the update in startTransition (React limitation).
502
+ startTransition(() => setLog(`${call}: settled`));
503
+ };
504
+ // A fact: called in the browser's event, not awaited. A plain setState here is urgent.
505
+ const dismissed = (open: boolean, { reason }: PopoverOpenChangeDetails) => {
506
+ setLog(`onOpenChange(${open}, "${reason}")`);
507
+ };
508
+ return (
509
+ <div className="demo-stack">
510
+ <Popover.Root openChangeAction={slow} onOpenChange={dismissed}>
511
+ <Popover.Trigger className="demo-button">
512
+ {({ open, pending }) => (
513
+ <>
514
+ Filters{pending && <span className="demo-spinner" aria-hidden />}
515
+ <span aria-hidden>{open ? " ▴" : " ▾"}</span>
516
+ </>
517
+ )}
518
+ </Popover.Trigger>
519
+ <Popover.Popup className="demo-popover">
520
+ <Popover.Title>Filters</Popover.Title>
521
+ <p>Saved filters for this list.</p>
522
+ <Popover.Close className="demo-button">Close</Popover.Close>
523
+ </Popover.Popup>
524
+ </Popover.Root>
525
+ <p className="demo-readout">
526
+ Last: <code>{log}</code>
527
+ </p>
528
+ </div>
529
+ );
530
+ }
531
+ ```
532
+
533
+ `popover.css`: the same file as above.
534
+
535
+ - Open: the Trigger gets `data-open` and `data-pending` at once (here a spinner and ▴) and stays collapsed; the popup is shown, and the Trigger expanded, when the action settles.
536
+ - Close with the Trigger or Close: `data-open` goes at once, the popup stays shown and the Trigger expanded until the action settles.
537
+ - Escape or a click outside: a fact. The popup hides, `data-open` goes and the Trigger is collapsed at once; nothing is pending and the slow action is not called; `onOpenChange` is.
538
+
539
+ The readout under the example is plain text, not a live region, so it does not interrupt a screen reader.
540
+
541
+ ## Suspense
542
+
543
+ Concept: [Suspense](../concepts/suspense.md)
544
+
545
+ Content that suspends holds the open: the popup stays hidden with the Trigger pending, then shows 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 the Trigger's `popovertarget` and the Close's Invoker Command. Library mode: opening and a close asked for by a part are requests (`openChangeAction`); a dismissal (Escape, a click outside, another popover opening) is the browser's, a fact: the popover closes at once and `onOpenChange(false)` is called with `reason: "dismiss"`. 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, including `autoFocus` in server-rendered markup. Library mode: the Trigger opens the popover natively, but the content is not in the HTML yet; on hydration the Popup finds it open, dispatches `openChangeAction(true)` with `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. 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 `popovertarget`, so a click opens the popover natively, but the content is not in the HTML yet (with `defaultOpen` it is, and the Trigger already has `data-open`; only the showing waits for hydration). On hydration the Popup finds it open and dispatches `openChangeAction(true, { reason: "platform" })` with no event; the content mounts into the open popover. If the action rejects or a controlled parent refuses, the popover closes again.
563
+
564
+ ## Styling
565
+
566
+ The Trigger's styling hook is `data-open` in both modes (optimistic in library mode, written from the popup's `toggle` event in JS-free mode); a `<button>` Trigger has no `aria-expanded` to select on ([Triggers of a popup](../concepts/browser-owned-state.md#popup-triggers)). On a page that never hydrates, style the Trigger from the popup that follows it:
567
+
568
+ ```css
569
+ .trigger[data-open] { color: var(--accent); }
570
+ /* Without JavaScript: the Popup right after the Trigger. */
571
+ .trigger:has(+ :popover-open) { color: var(--accent); }
572
+ ```
573
+
574
+ The Popup emits no `data-open`: `:popover-open` is exact. Enter and exit animate in CSS, in both modes:
575
+
576
+ ```css
577
+ .popover {
578
+ margin: 0;
579
+ inset: auto; /* the popover UA stylesheet sets inset: 0 */
580
+ opacity: 0;
581
+ translate: 0 -4px;
582
+ transition: opacity 120ms, translate 120ms, display 120ms allow-discrete, overlay 120ms allow-discrete;
583
+ }
584
+ .popover:popover-open { opacity: 1; translate: 0 0; }
585
+ @starting-style { .popover:popover-open { opacity: 0; translate: 0 -4px; } }
586
+ /* The gap, static on the requested edge (side="bottom"): a flip swaps the popup's margins, so
587
+ it moves to the other edge by itself. */
588
+ .popover { margin-block-start: 6px; }
589
+ /* A class that serves any side: both sides of the axis, keyed on data-side, the closed logical
590
+ values included so the first layout has the gap. A one-sided margin keyed on the resolved
591
+ data-side is the wrong form: after a flip it lands on the far edge. */
592
+ .popover-any[data-side="top"], .popover-any[data-side="bottom"] { margin-block: 6px; }
593
+ .popover-any[data-side="left"], .popover-any[data-side="right"],
594
+ .popover-any[data-side="inline-start"], .popover-any[data-side="inline-end"] { margin-inline: 6px; }
595
+ @media (prefers-reduced-motion: reduce) { .popover { transition: none; } }
596
+ ```
597
+
598
+ `data-side` is where the popup **is**, read from the computed `position-area` while it is shown; the [Tooltip page](tooltip.md#data-attributes) explains the mechanism, its render cost and the margin and animation caveats, which apply here as they are. Popover has no Arrow part; an arrow drawn with a pseudo-element on `[data-side]` follows a flip (see the [Tooltip arrow](tooltip.md#arrow)).
599
+
600
+ ## Recipes
601
+
602
+ ### Submit, then close (controlled)
603
+
604
+ ```tsx
605
+ const [open, setOpen] = useState(false);
606
+
607
+ <Popover.Root open={open} openChangeAction={setOpen} onOpenChange={setOpen}>
608
+ <Popover.Trigger>Rename</Popover.Trigger>
609
+ <Popover.Popup initialFocus="[name=title]">
610
+ <Popover.Title>Rename</Popover.Title>
611
+ <form
612
+ action={async (formData) => {
613
+ await rename(formData);
614
+ startTransition(() => setOpen(false)); // a library-driven close: view transition if set
615
+ }}
616
+ >
617
+ <input name="title" defaultValue={title} />
618
+ <SubmitButton>Save</SubmitButton>
619
+ <Popover.Close>Cancel</Popover.Close>
620
+ </form>
621
+ </Popover.Popup>
622
+ </Popover.Root>
623
+ ```
624
+
625
+ ### Controlled, opened without a Trigger
626
+
627
+ ```tsx
628
+ <Popover.Root open={open} openChangeAction={setOpen} onOpenChange={setOpen}>
629
+ <Popover.Popup side={null} className="popover centered">…</Popover.Popup>
630
+ </Popover.Root>
631
+ ```
632
+
633
+ Without a Trigger there is no anchor: the popover is centred by the UA stylesheet unless you position it, so use `side={null}`.
634
+
635
+ ### Nested popovers
636
+
637
+ ```tsx
638
+ <Popover.Root defaultOpen={false}>
639
+ <Popover.Trigger>Share</Popover.Trigger>
640
+ <Popover.Popup>
641
+ <Popover.Title>Share</Popover.Title>
642
+ <Popover.Root defaultOpen={false}> {/* nested auto popover */}
643
+ <Popover.Trigger>Permissions</Popover.Trigger>
644
+ <Popover.Popup side="right" align="start">…</Popover.Popup>
645
+ </Popover.Root>
646
+ </Popover.Popup>
647
+ </Popover.Root>
648
+ ```
649
+
650
+ Opening the inner keeps the outer open; Escape closes the inner and focus returns to "Permissions"; a click outside closes both. Outer parts must sit outside the inner Root. Leave `transition` off an inner Popup unless you want the animation (it pays the page cross-fade when it mounts with the outer content). In Safari, a nested popover with `position-try-fallbacks` can hang (WebKit bug 302008): give the inner Popup `side={null}` and place it in CSS if you hit it.
651
+
652
+ ## Browser notes
653
+
654
+ - **Right-to-left:** `side="inline-start"` / `"inline-end"` and `align` on a top or bottom side use the `self-*` keywords, which follow the popup's inherited direction: an RTL page and an RTL container both mirror them, with no JavaScript. Firefox misplaces a popover inside a direction island ([#89](https://github.com/uhyo/funstack-ui/issues/89); see [Tooltip](tooltip.md#browser-notes)).
655
+ - The CSS exit animates in Chromium and Safari; Firefox hides a popover instantly. The library keeps the content mounted until the exit animation ends, so a fading popover is never empty.
656
+ - On iOS, `position-try-fallbacks` together with `@starting-style` can hang (WebKit bug 317926).