@ui-sdk/web 0.0.0-stage → 0.1.0-beta.1

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 (467) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +10 -2
  3. package/browser/web/accordion.js +1 -0
  4. package/browser/web/alert-dialog.js +1 -0
  5. package/browser/web/autocomplete.js +1 -0
  6. package/browser/web/avatar.js +1 -0
  7. package/browser/web/button.js +1 -0
  8. package/browser/web/calendar.js +1 -0
  9. package/browser/web/carousel.js +1 -0
  10. package/browser/web/checkbox.js +1 -0
  11. package/browser/web/chunks/0eRGibL6.js +1 -0
  12. package/browser/web/chunks/2bIEUO6_.js +1 -0
  13. package/browser/web/chunks/5A9w2ULz.js +1 -0
  14. package/browser/web/chunks/5RSyydjV.js +1 -0
  15. package/browser/web/chunks/9pWTy2wl.js +1 -0
  16. package/browser/web/chunks/B0f2j6zz.js +1 -0
  17. package/browser/web/chunks/B1rux6br.js +1 -0
  18. package/browser/web/chunks/B3-APaNf.js +1 -0
  19. package/browser/web/chunks/B7EgSgjQ.js +1 -0
  20. package/browser/web/chunks/B8QcOzJU.js +1 -0
  21. package/browser/web/chunks/BFueEkwm.js +3 -0
  22. package/browser/web/chunks/BJj3oS29.js +1 -0
  23. package/browser/web/chunks/BNSvTCpr.js +1 -0
  24. package/browser/web/chunks/BPD0kAZB.js +1 -0
  25. package/browser/web/chunks/BQeduZqT.js +1 -0
  26. package/browser/web/chunks/B_CVFyiz.js +1 -0
  27. package/browser/web/chunks/B_ns1YHO.js +1 -0
  28. package/browser/web/chunks/BcwkVTsR.js +1 -0
  29. package/browser/web/chunks/BeaQ6TYM.js +1 -0
  30. package/browser/web/chunks/BgBB013u.js +1 -0
  31. package/browser/web/chunks/BgsKhHDm.js +1 -0
  32. package/browser/web/chunks/BjMcbuhi.js +9 -0
  33. package/browser/web/chunks/Bjiy_F2N.js +1 -0
  34. package/browser/web/chunks/BqScCLwv.js +1 -0
  35. package/browser/web/chunks/BqX3Utqx.js +1 -0
  36. package/browser/web/chunks/BtVkQf3z.js +1 -0
  37. package/browser/web/chunks/By30h-7B.js +1 -0
  38. package/browser/web/chunks/C1zqYpy2.js +1 -0
  39. package/browser/web/chunks/C436juFf.js +1 -0
  40. package/browser/web/chunks/C4_bULs1.js +1 -0
  41. package/browser/web/chunks/C4omqJEz.js +1 -0
  42. package/browser/web/chunks/C7tt0T3n.js +1 -0
  43. package/browser/web/chunks/C8w7s5dg.js +1 -0
  44. package/browser/web/chunks/CElY4erO.js +1 -0
  45. package/browser/web/chunks/CFODo-m2.js +1 -0
  46. package/browser/web/chunks/CL4wjam9.js +1 -0
  47. package/browser/web/chunks/CMg-8UVf.js +1 -0
  48. package/browser/web/chunks/COWKfakj.js +1 -0
  49. package/browser/web/chunks/CQBU0qZ4.js +1 -0
  50. package/browser/web/chunks/CV6uABgc.js +1 -0
  51. package/browser/web/chunks/C_SWFpWQ.js +1 -0
  52. package/browser/web/chunks/C_Uanbrl.js +1 -0
  53. package/browser/web/chunks/Ce_CSanC.js +1 -0
  54. package/browser/web/chunks/Cg-ZmRhS.js +1 -0
  55. package/browser/web/chunks/Cgf2wPI_.js +1 -0
  56. package/browser/web/chunks/Cuep_3Vf.js +1 -0
  57. package/browser/web/chunks/D02PaHn6.js +1 -0
  58. package/browser/web/chunks/D5LiaI5R.js +1 -0
  59. package/browser/web/chunks/D9UgVYvF.js +1 -0
  60. package/browser/web/chunks/DC08tnkE.js +2 -0
  61. package/browser/web/chunks/DG8YGSvu.js +1 -0
  62. package/browser/web/chunks/DIQd0FYD.js +1 -0
  63. package/browser/web/chunks/DMLqacE8.js +1 -0
  64. package/browser/web/chunks/DSUI3yI-.js +1 -0
  65. package/browser/web/chunks/DT3Hb76X.js +1 -0
  66. package/browser/web/chunks/DY75g3-W.js +1 -0
  67. package/browser/web/chunks/DZpNQKZ9.js +1 -0
  68. package/browser/web/chunks/Db-W1wrC.js +1 -0
  69. package/browser/web/chunks/Dc1xK3Ii.js +1 -0
  70. package/browser/web/chunks/DdF6awFs.js +1 -0
  71. package/browser/web/chunks/DdaCLml8.js +1 -0
  72. package/browser/web/chunks/Dh8MLjQO.js +1 -0
  73. package/browser/web/chunks/DiuslJRy.js +1 -0
  74. package/browser/web/chunks/DjRcw3Y0.js +1 -0
  75. package/browser/web/chunks/Djdv-16J.js +1 -0
  76. package/browser/web/chunks/DnFXe_lF.js +1 -0
  77. package/browser/web/chunks/DneGv1oC.js +1 -0
  78. package/browser/web/chunks/DsVxP-p-.js +1 -0
  79. package/browser/web/chunks/DwDilCo2.js +1 -0
  80. package/browser/web/chunks/DwV48AXv.js +1 -0
  81. package/browser/web/chunks/F37aF4-L.js +1 -0
  82. package/browser/web/chunks/LyB6XIbN.js +1 -0
  83. package/browser/web/chunks/NKnbYGjC.js +1 -0
  84. package/browser/web/chunks/Vk-rVi16.js +1 -0
  85. package/browser/web/chunks/XsM0J1Ex.js +1 -0
  86. package/browser/web/chunks/asSN9iEp.js +1 -0
  87. package/browser/web/chunks/c-AjHfdF.js +1 -0
  88. package/browser/web/chunks/dR-12TPY.js +1 -0
  89. package/browser/web/chunks/hR4xM0EC.js +1 -0
  90. package/browser/web/chunks/hqOaBxAg.js +1 -0
  91. package/browser/web/chunks/kMKqqeG4.js +1 -0
  92. package/browser/web/chunks/kXboBcfi.js +1 -0
  93. package/browser/web/chunks/l4aQIg22.js +1 -0
  94. package/browser/web/chunks/tJC0JSU4.js +1 -0
  95. package/browser/web/chunks/wHdS_QYM.js +1 -0
  96. package/browser/web/chunks/yv8dTvNI.js +1 -0
  97. package/browser/web/chunks/yw9M3nfi.js +1 -0
  98. package/browser/web/collapsible.js +1 -0
  99. package/browser/web/color-picker.js +1 -0
  100. package/browser/web/combobox.js +2 -0
  101. package/browser/web/command.js +1 -0
  102. package/browser/web/core.js +5 -0
  103. package/browser/web/date-input.js +1 -0
  104. package/browser/web/date-picker.js +1 -0
  105. package/browser/web/dialog.js +1 -0
  106. package/browser/web/drawer.js +1 -0
  107. package/browser/web/field.js +1 -0
  108. package/browser/web/file-input.js +1 -0
  109. package/browser/web/hover-card.js +1 -0
  110. package/browser/web/image-cropper.js +1 -0
  111. package/browser/web/input.js +1 -0
  112. package/browser/web/label.js +1 -0
  113. package/browser/web/listbox.js +1 -0
  114. package/browser/web/menu.js +1 -0
  115. package/browser/web/menubar.js +1 -0
  116. package/browser/web/meter.js +1 -0
  117. package/browser/web/navigation-menu.js +1 -0
  118. package/browser/web/number-input.js +1 -0
  119. package/browser/web/otp-input.js +2 -0
  120. package/browser/web/overlays.js +1 -0
  121. package/browser/web/pagination.js +1 -0
  122. package/browser/web/password-input.js +1 -0
  123. package/browser/web/popover.js +1 -0
  124. package/browser/web/preferences.js +1 -0
  125. package/browser/web/progress.js +1 -0
  126. package/browser/web/radio.js +1 -0
  127. package/browser/web/rating.js +1 -0
  128. package/browser/web/resizable.js +1 -0
  129. package/browser/web/scroll-area.js +1 -0
  130. package/browser/web/segmented-control.js +1 -0
  131. package/browser/web/select.js +1 -0
  132. package/browser/web/separator.js +1 -0
  133. package/browser/web/slider.js +1 -0
  134. package/browser/web/switch.js +1 -0
  135. package/browser/web/tabs.js +1 -0
  136. package/browser/web/textarea.js +1 -0
  137. package/browser/web/time-input.js +1 -0
  138. package/browser/web/timeline.js +1 -0
  139. package/browser/web/toast.js +1 -0
  140. package/browser/web/toggle.js +1 -0
  141. package/browser/web/token-input.js +8 -0
  142. package/browser/web/toolbar.js +1 -0
  143. package/browser/web/tooltip.js +1 -0
  144. package/browser/web/tree.js +1 -0
  145. package/browser/web/trigger-menu.js +4 -0
  146. package/browser/web/waterfall.js +1 -0
  147. package/browser/web.css +3378 -0
  148. package/browser/web.js +3 -0
  149. package/custom-elements.json +32315 -0
  150. package/dist/accordion.d.ts +2 -0
  151. package/dist/accordion.js +57 -0
  152. package/dist/action.d.ts +16 -0
  153. package/dist/action.js +39 -0
  154. package/dist/agent.d.ts +2 -0
  155. package/dist/agent.js +7 -0
  156. package/dist/autocomplete.d.ts +2 -0
  157. package/dist/autocomplete.js +120 -0
  158. package/dist/autoload.d.ts +18 -0
  159. package/dist/autoload.js +63 -0
  160. package/dist/avatar.d.ts +2 -0
  161. package/dist/avatar.js +27 -0
  162. package/dist/browser-core.d.ts +2 -0
  163. package/dist/browser-core.js +8 -0
  164. package/dist/button.d.ts +2 -0
  165. package/dist/button.js +35 -0
  166. package/dist/calendar.d.ts +23 -0
  167. package/dist/calendar.js +429 -0
  168. package/dist/carousel.d.ts +2 -0
  169. package/dist/carousel.js +54 -0
  170. package/dist/checkbox.d.ts +4 -0
  171. package/dist/checkbox.js +75 -0
  172. package/dist/collapsible.d.ts +2 -0
  173. package/dist/collapsible.js +28 -0
  174. package/dist/color-picker.d.ts +2 -0
  175. package/dist/color-picker.js +64 -0
  176. package/dist/combobox.d.ts +2 -0
  177. package/dist/combobox.js +334 -0
  178. package/dist/command.d.ts +2 -0
  179. package/dist/command.js +122 -0
  180. package/dist/date-input.d.ts +3 -0
  181. package/dist/date-input.js +87 -0
  182. package/dist/date-picker.d.ts +2 -0
  183. package/dist/date-picker.js +174 -0
  184. package/dist/default-text.d.ts +3 -0
  185. package/dist/default-text.js +24 -0
  186. package/dist/define-element.d.ts +404 -0
  187. package/dist/define-element.js +1489 -0
  188. package/dist/dialog.d.ts +3 -0
  189. package/dist/dialog.js +94 -0
  190. package/dist/drawer.d.ts +2 -0
  191. package/dist/drawer.js +96 -0
  192. package/dist/entries/accordion.d.ts +3 -0
  193. package/dist/entries/accordion.js +7 -0
  194. package/dist/entries/alert-dialog.d.ts +3 -0
  195. package/dist/entries/alert-dialog.js +13 -0
  196. package/dist/entries/autocomplete.d.ts +3 -0
  197. package/dist/entries/autocomplete.js +7 -0
  198. package/dist/entries/avatar.d.ts +2 -0
  199. package/dist/entries/avatar.js +3 -0
  200. package/dist/entries/button.d.ts +2 -0
  201. package/dist/entries/button.js +3 -0
  202. package/dist/entries/calendar.d.ts +3 -0
  203. package/dist/entries/calendar.js +7 -0
  204. package/dist/entries/carousel.d.ts +3 -0
  205. package/dist/entries/carousel.js +7 -0
  206. package/dist/entries/checkbox.d.ts +3 -0
  207. package/dist/entries/checkbox.js +15 -0
  208. package/dist/entries/collapsible.d.ts +3 -0
  209. package/dist/entries/collapsible.js +7 -0
  210. package/dist/entries/color-picker.d.ts +3 -0
  211. package/dist/entries/color-picker.js +7 -0
  212. package/dist/entries/combobox.d.ts +3 -0
  213. package/dist/entries/combobox.js +7 -0
  214. package/dist/entries/command.d.ts +3 -0
  215. package/dist/entries/command.js +7 -0
  216. package/dist/entries/date-input.d.ts +3 -0
  217. package/dist/entries/date-input.js +7 -0
  218. package/dist/entries/date-picker.d.ts +3 -0
  219. package/dist/entries/date-picker.js +7 -0
  220. package/dist/entries/dialog.d.ts +3 -0
  221. package/dist/entries/dialog.js +7 -0
  222. package/dist/entries/drawer.d.ts +3 -0
  223. package/dist/entries/drawer.js +8 -0
  224. package/dist/entries/field.d.ts +2 -0
  225. package/dist/entries/field.js +3 -0
  226. package/dist/entries/file-input.d.ts +3 -0
  227. package/dist/entries/file-input.js +13 -0
  228. package/dist/entries/hover-card.d.ts +3 -0
  229. package/dist/entries/hover-card.js +7 -0
  230. package/dist/entries/image-cropper.d.ts +3 -0
  231. package/dist/entries/image-cropper.js +7 -0
  232. package/dist/entries/input.d.ts +3 -0
  233. package/dist/entries/input.js +8 -0
  234. package/dist/entries/label.d.ts +2 -0
  235. package/dist/entries/label.js +3 -0
  236. package/dist/entries/listbox.d.ts +3 -0
  237. package/dist/entries/listbox.js +7 -0
  238. package/dist/entries/menu.d.ts +3 -0
  239. package/dist/entries/menu.js +7 -0
  240. package/dist/entries/menubar.d.ts +3 -0
  241. package/dist/entries/menubar.js +7 -0
  242. package/dist/entries/meter.d.ts +2 -0
  243. package/dist/entries/meter.js +3 -0
  244. package/dist/entries/navigation-menu.d.ts +3 -0
  245. package/dist/entries/navigation-menu.js +7 -0
  246. package/dist/entries/number-input.d.ts +3 -0
  247. package/dist/entries/number-input.js +7 -0
  248. package/dist/entries/otp-input.d.ts +3 -0
  249. package/dist/entries/otp-input.js +7 -0
  250. package/dist/entries/overlays.d.ts +2 -0
  251. package/dist/entries/overlays.js +3 -0
  252. package/dist/entries/pagination.d.ts +3 -0
  253. package/dist/entries/pagination.js +11 -0
  254. package/dist/entries/password-input.d.ts +3 -0
  255. package/dist/entries/password-input.js +7 -0
  256. package/dist/entries/popover.d.ts +3 -0
  257. package/dist/entries/popover.js +7 -0
  258. package/dist/entries/preferences.d.ts +3 -0
  259. package/dist/entries/preferences.js +13 -0
  260. package/dist/entries/progress.d.ts +2 -0
  261. package/dist/entries/progress.js +3 -0
  262. package/dist/entries/radio.d.ts +3 -0
  263. package/dist/entries/radio.js +7 -0
  264. package/dist/entries/rating.d.ts +3 -0
  265. package/dist/entries/rating.js +8 -0
  266. package/dist/entries/resizable.d.ts +3 -0
  267. package/dist/entries/resizable.js +11 -0
  268. package/dist/entries/scroll-area.d.ts +3 -0
  269. package/dist/entries/scroll-area.js +7 -0
  270. package/dist/entries/segmented-control.d.ts +3 -0
  271. package/dist/entries/segmented-control.js +7 -0
  272. package/dist/entries/select.d.ts +3 -0
  273. package/dist/entries/select.js +7 -0
  274. package/dist/entries/separator.d.ts +2 -0
  275. package/dist/entries/separator.js +3 -0
  276. package/dist/entries/slider.d.ts +3 -0
  277. package/dist/entries/slider.js +7 -0
  278. package/dist/entries/switch.d.ts +3 -0
  279. package/dist/entries/switch.js +7 -0
  280. package/dist/entries/tabs.d.ts +3 -0
  281. package/dist/entries/tabs.js +7 -0
  282. package/dist/entries/textarea.d.ts +3 -0
  283. package/dist/entries/textarea.js +7 -0
  284. package/dist/entries/time-input.d.ts +3 -0
  285. package/dist/entries/time-input.js +7 -0
  286. package/dist/entries/timeline.d.ts +3 -0
  287. package/dist/entries/timeline.js +7 -0
  288. package/dist/entries/toast.d.ts +2 -0
  289. package/dist/entries/toast.js +3 -0
  290. package/dist/entries/toggle.d.ts +3 -0
  291. package/dist/entries/toggle.js +12 -0
  292. package/dist/entries/token-input.d.ts +3 -0
  293. package/dist/entries/token-input.js +17 -0
  294. package/dist/entries/toolbar.d.ts +3 -0
  295. package/dist/entries/toolbar.js +7 -0
  296. package/dist/entries/tooltip.d.ts +3 -0
  297. package/dist/entries/tooltip.js +7 -0
  298. package/dist/entries/tree.d.ts +3 -0
  299. package/dist/entries/tree.js +17 -0
  300. package/dist/entries/trigger-menu.d.ts +3 -0
  301. package/dist/entries/trigger-menu.js +11 -0
  302. package/dist/entries/waterfall.d.ts +3 -0
  303. package/dist/entries/waterfall.js +11 -0
  304. package/dist/events.d.ts +1658 -0
  305. package/dist/events.js +0 -0
  306. package/dist/field.d.ts +2 -0
  307. package/dist/field.js +101 -0
  308. package/dist/file-input.d.ts +2 -0
  309. package/dist/file-input.js +140 -0
  310. package/dist/forward-attributes.d.ts +2 -0
  311. package/dist/forward-attributes.js +22 -0
  312. package/dist/history.d.ts +2 -0
  313. package/dist/history.js +11 -0
  314. package/dist/hover-card.d.ts +2 -0
  315. package/dist/hover-card.js +31 -0
  316. package/dist/image-cropper.d.ts +2 -0
  317. package/dist/image-cropper.js +66 -0
  318. package/dist/index.d.ts +66 -0
  319. package/dist/index.js +269 -0
  320. package/dist/input.d.ts +3 -0
  321. package/dist/input.js +69 -0
  322. package/dist/label.d.ts +2 -0
  323. package/dist/label.js +11 -0
  324. package/dist/list.d.ts +40 -0
  325. package/dist/list.js +192 -0
  326. package/dist/listbox.d.ts +2 -0
  327. package/dist/listbox.js +84 -0
  328. package/dist/menu.d.ts +4 -0
  329. package/dist/menu.js +295 -0
  330. package/dist/menubar.d.ts +4 -0
  331. package/dist/menubar.js +30 -0
  332. package/dist/meter.d.ts +2 -0
  333. package/dist/meter.js +22 -0
  334. package/dist/navigation-menu.d.ts +2 -0
  335. package/dist/navigation-menu.js +114 -0
  336. package/dist/number-input.d.ts +2 -0
  337. package/dist/number-input.js +73 -0
  338. package/dist/observe.d.ts +2 -0
  339. package/dist/observe.js +7 -0
  340. package/dist/otp-input.d.ts +2 -0
  341. package/dist/otp-input.js +72 -0
  342. package/dist/overlays.d.ts +13 -0
  343. package/dist/overlays.js +156 -0
  344. package/dist/pagination.d.ts +2 -0
  345. package/dist/pagination.js +127 -0
  346. package/dist/password-input.d.ts +2 -0
  347. package/dist/password-input.js +57 -0
  348. package/dist/popover.d.ts +2 -0
  349. package/dist/popover.js +64 -0
  350. package/dist/popup.d.ts +40 -0
  351. package/dist/popup.js +112 -0
  352. package/dist/preferences.d.ts +2 -0
  353. package/dist/preferences.js +56 -0
  354. package/dist/progress.d.ts +2 -0
  355. package/dist/progress.js +22 -0
  356. package/dist/radio.d.ts +2 -0
  357. package/dist/radio.js +33 -0
  358. package/dist/rating.d.ts +2 -0
  359. package/dist/rating.js +64 -0
  360. package/dist/resizable.d.ts +2 -0
  361. package/dist/resizable.js +42 -0
  362. package/dist/scroll-area.d.ts +2 -0
  363. package/dist/scroll-area.js +45 -0
  364. package/dist/segmented-control.d.ts +2 -0
  365. package/dist/segmented-control.js +28 -0
  366. package/dist/select.d.ts +2 -0
  367. package/dist/select.js +239 -0
  368. package/dist/separator.d.ts +2 -0
  369. package/dist/separator.js +11 -0
  370. package/dist/slider.d.ts +2 -0
  371. package/dist/slider.js +77 -0
  372. package/dist/tabs.d.ts +2 -0
  373. package/dist/tabs.js +37 -0
  374. package/dist/timeline.d.ts +2 -0
  375. package/dist/timeline.js +27 -0
  376. package/dist/toast.d.ts +20 -0
  377. package/dist/toast.js +177 -0
  378. package/dist/toggle.d.ts +3 -0
  379. package/dist/toggle.js +64 -0
  380. package/dist/token-input.d.ts +2 -0
  381. package/dist/token-input.js +103 -0
  382. package/dist/toolbar.d.ts +2 -0
  383. package/dist/toolbar.js +36 -0
  384. package/dist/tooltip.d.ts +2 -0
  385. package/dist/tooltip.js +35 -0
  386. package/dist/tree.d.ts +2 -0
  387. package/dist/tree.js +147 -0
  388. package/dist/trigger-menu.d.ts +2 -0
  389. package/dist/trigger-menu.js +133 -0
  390. package/dist/waterfall.d.ts +2 -0
  391. package/dist/waterfall.js +140 -0
  392. package/docs/README.md +89 -0
  393. package/docs/agents.md +1523 -0
  394. package/docs/components/accordion.md +1401 -0
  395. package/docs/components/alert-dialog.md +788 -0
  396. package/docs/components/autocomplete.md +1692 -0
  397. package/docs/components/avatar.md +261 -0
  398. package/docs/components/button.md +441 -0
  399. package/docs/components/calendar.md +1536 -0
  400. package/docs/components/carousel.md +1055 -0
  401. package/docs/components/checkbox.md +1045 -0
  402. package/docs/components/collapsible.md +535 -0
  403. package/docs/components/color-picker.md +651 -0
  404. package/docs/components/combobox.md +3274 -0
  405. package/docs/components/command.md +1431 -0
  406. package/docs/components/date-input.md +563 -0
  407. package/docs/components/date-picker.md +1136 -0
  408. package/docs/components/dialog.md +1360 -0
  409. package/docs/components/drawer.md +1201 -0
  410. package/docs/components/field.md +519 -0
  411. package/docs/components/file-input.md +617 -0
  412. package/docs/components/hover-card.md +486 -0
  413. package/docs/components/image-cropper.md +489 -0
  414. package/docs/components/input.md +327 -0
  415. package/docs/components/label.md +208 -0
  416. package/docs/components/listbox.md +1015 -0
  417. package/docs/components/menu.md +1212 -0
  418. package/docs/components/menubar.md +460 -0
  419. package/docs/components/meter.md +298 -0
  420. package/docs/components/navigation-menu.md +1573 -0
  421. package/docs/components/number-input.md +1087 -0
  422. package/docs/components/otp-input.md +558 -0
  423. package/docs/components/pagination.md +639 -0
  424. package/docs/components/password-input.md +649 -0
  425. package/docs/components/popover.md +1433 -0
  426. package/docs/components/preferences.md +243 -0
  427. package/docs/components/progress.md +406 -0
  428. package/docs/components/radio.md +855 -0
  429. package/docs/components/rating.md +431 -0
  430. package/docs/components/resizable.md +866 -0
  431. package/docs/components/scroll-area.md +898 -0
  432. package/docs/components/segmented-control.md +421 -0
  433. package/docs/components/select.md +1957 -0
  434. package/docs/components/separator.md +238 -0
  435. package/docs/components/slider.md +1018 -0
  436. package/docs/components/switch.md +583 -0
  437. package/docs/components/tabs.md +948 -0
  438. package/docs/components/textarea.md +331 -0
  439. package/docs/components/time-input.md +235 -0
  440. package/docs/components/timeline.md +622 -0
  441. package/docs/components/toast.md +1223 -0
  442. package/docs/components/toggle.md +522 -0
  443. package/docs/components/token-input.md +854 -0
  444. package/docs/components/toolbar.md +815 -0
  445. package/docs/components/tooltip.md +860 -0
  446. package/docs/components/tree.md +1243 -0
  447. package/docs/components/trigger-menu.md +1110 -0
  448. package/docs/components/waterfall.md +709 -0
  449. package/docs/controllers.md +66 -0
  450. package/docs/core.md +8027 -0
  451. package/docs/custom-parts.md +91 -0
  452. package/docs/first-component.md +88 -0
  453. package/docs/forms.md +125 -0
  454. package/docs/installation.md +141 -0
  455. package/docs/introduction.md +32 -0
  456. package/docs/lists-and-menus.md +166 -0
  457. package/docs/llms.txt +1566 -0
  458. package/docs/parts-and-composition.md +57 -0
  459. package/docs/popups.md +92 -0
  460. package/docs/rendering.md +71 -0
  461. package/docs/server-rendering.md +118 -0
  462. package/docs/state-and-events.md +134 -0
  463. package/docs/styling-and-animation.md +104 -0
  464. package/docs/utilities/async-options.md +332 -0
  465. package/docs/utilities/shortcuts.md +184 -0
  466. package/html-custom-data.json +14792 -0
  467. package/package.json +302 -3
@@ -0,0 +1,788 @@
1
+ # Alert Dialog
2
+
3
+ Ask someone to confirm an action before you continue.
4
+
5
+ Use an alert dialog when someone needs to answer a question before an action continues, such as deleting a project.
6
+
7
+ ```ts title="basic.ts"
8
+ import "@ui-sdk/web/alert-dialog"
9
+
10
+ function mount(root: HTMLElement) {
11
+ root.innerHTML = `
12
+ <ui-alert-dialog>
13
+ <ui-alert-dialog-trigger>
14
+ <button>Delete Project</button>
15
+ </ui-alert-dialog-trigger>
16
+ <ui-alert-dialog-backdrop hidden></ui-alert-dialog-backdrop>
17
+ <ui-alert-dialog-content hidden>
18
+ <div data-slot="stack">
19
+ <ui-alert-dialog-title>Delete this project?</ui-alert-dialog-title>
20
+ <ui-alert-dialog-description>
21
+ This permanently deletes the project, its files and its deployment history for everyone on your team.
22
+ </ui-alert-dialog-description>
23
+ </div>
24
+ <div data-slot="row">
25
+ <ui-alert-dialog-close>
26
+ <button>Cancel</button>
27
+ </ui-alert-dialog-close>
28
+ <ui-alert-dialog-close value="confirm">
29
+ <button data-variant="solid">Delete</button>
30
+ </ui-alert-dialog-close>
31
+ </div>
32
+ </ui-alert-dialog-content>
33
+ </ui-alert-dialog>
34
+ `
35
+ }
36
+
37
+ export { mount }
38
+ ```
39
+
40
+ Open the dialog with Enter to start on Cancel. Tab stays inside, clicking outside leaves it open, and Escape closes it and returns focus to the trigger.
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ npm install @ui-sdk/web @ui-sdk/core
46
+ ```
47
+
48
+ Import the component to register its elements. The import is safe on the server.
49
+
50
+ ```ts
51
+ import "@ui-sdk/web/alert-dialog"
52
+ ```
53
+
54
+ ## Composition
55
+
56
+ Use the following composition to build a `ui-alert-dialog`:
57
+
58
+ ```text
59
+ ui-alert-dialog
60
+ ├── ui-alert-dialog-trigger
61
+ │ └── button
62
+ ├── ui-alert-dialog-backdrop
63
+ └── ui-alert-dialog-content
64
+ ├── ui-alert-dialog-title
65
+ ├── ui-alert-dialog-description
66
+ ├── ui-alert-dialog-close
67
+ │ └── button
68
+ └── ui-alert-dialog-close
69
+ └── button
70
+ ```
71
+
72
+ Put the question in `ui-alert-dialog-title`, explain what happens in `ui-alert-dialog-description`, and wrap each answer's native button in `ui-alert-dialog-close`. Add `ui-alert-dialog-backdrop` to dim the page. Give the content and backdrop `hidden` to keep them hidden before the elements upgrade.
73
+
74
+ A Close part reports its `value` when it closes. `value="confirm"` is the agreeing answer that the [confirm helper](#confirm) recognizes.
75
+
76
+ ## Usage
77
+
78
+ Import the parts and put them together:
79
+
80
+ ```html
81
+ <script type="module">
82
+ import "@ui-sdk/web/alert-dialog"
83
+ </script>
84
+
85
+ <ui-alert-dialog>
86
+ <ui-alert-dialog-trigger
87
+ ><button>Delete Project</button></ui-alert-dialog-trigger
88
+ >
89
+ <ui-alert-dialog-content hidden>
90
+ <ui-alert-dialog-title>Delete this project?</ui-alert-dialog-title>
91
+ <ui-alert-dialog-description
92
+ >The project and its files will be deleted for
93
+ everyone.</ui-alert-dialog-description
94
+ >
95
+ <ui-alert-dialog-close><button>Cancel</button></ui-alert-dialog-close>
96
+ <ui-alert-dialog-close value="confirm"
97
+ ><button>Delete</button></ui-alert-dialog-close
98
+ >
99
+ </ui-alert-dialog-content>
100
+ </ui-alert-dialog>
101
+ ```
102
+
103
+ ## Build Your Own
104
+
105
+ `@ui-sdk/web/alert-dialog` comes with ready-made `ui-alert-dialog` elements. If you'd like to build your own, with your own element names, start from the `alertDialog` primitive in `@ui-sdk/core`:
106
+
107
+ ```ts title="confirm-elements.ts"
108
+ import { alertDialog } from "@ui-sdk/core/alert-dialog"
109
+ import { createParts, wrappedButton } from "@ui-sdk/web"
110
+
111
+ createParts(alertDialog, {
112
+ root: "confirm-dialog",
113
+ trigger: {
114
+ tag: "confirm-trigger",
115
+ target: wrappedButton,
116
+ display: "contents",
117
+ },
118
+ backdrop: "confirm-backdrop",
119
+ content: "confirm-content",
120
+ title: "confirm-title",
121
+ description: "confirm-description",
122
+ close: { tag: "confirm-close", target: wrappedButton, display: "contents" },
123
+ })
124
+ ```
125
+
126
+ ```html
127
+ <confirm-dialog>
128
+ <confirm-trigger><button>Delete Project</button></confirm-trigger>
129
+ <confirm-backdrop hidden></confirm-backdrop>
130
+ <confirm-content hidden>
131
+ <confirm-title>Delete this project?</confirm-title>
132
+ <confirm-description
133
+ >This permanently deletes the project.</confirm-description
134
+ >
135
+ <confirm-close><button>Cancel</button></confirm-close>
136
+ <confirm-close value="confirm"><button>Delete</button></confirm-close>
137
+ </confirm-content>
138
+ </confirm-dialog>
139
+ ```
140
+
141
+ Each element keeps the behavior, state and data attributes of its ready-made counterpart: the content opens in the top layer, traps focus and makes the page inert. See [Rendering](../rendering.md) and [Custom Parts](../custom-parts.md) for more.
142
+
143
+ ## Controlled
144
+
145
+ Set the element's `open` property to open or close it from your app. Listen for `openchange` to follow changes made by its parts. [State and Events](../state-and-events.md) explains controlled state and canceling a change.
146
+
147
+ ```ts title="controlled.ts"
148
+ import "@ui-sdk/web/alert-dialog"
149
+
150
+ function mount(root: HTMLElement) {
151
+ root.innerHTML = `
152
+ <div data-slot="stack">
153
+ <button type="button" aria-haspopup="dialog">Review Changes</button>
154
+ <ui-alert-dialog>
155
+ <ui-alert-dialog-backdrop hidden></ui-alert-dialog-backdrop>
156
+ <ui-alert-dialog-content hidden>
157
+ <div data-slot="stack">
158
+ <ui-alert-dialog-title>Discard unsaved changes?</ui-alert-dialog-title>
159
+ <ui-alert-dialog-description>
160
+ Your edits will be lost if you leave without saving.
161
+ </ui-alert-dialog-description>
162
+ </div>
163
+ <div data-slot="row">
164
+ <ui-alert-dialog-close>
165
+ <button>Keep Editing</button>
166
+ </ui-alert-dialog-close>
167
+ <ui-alert-dialog-close value="confirm">
168
+ <button data-variant="solid">Discard</button>
169
+ </ui-alert-dialog-close>
170
+ </div>
171
+ </ui-alert-dialog-content>
172
+ </ui-alert-dialog>
173
+ </div>
174
+ `
175
+ const dialog = root.querySelector("ui-alert-dialog")!
176
+ root.querySelector("button")!.addEventListener("click", () => {
177
+ dialog.open = true
178
+ })
179
+ }
180
+
181
+ export { mount }
182
+ ```
183
+
184
+ Choose Review Changes, then Keep Editing or Discard.
185
+
186
+ ## Shortcut
187
+
188
+ Give the trigger a `shortcut` to open the dialog from the keyboard, and put `ui-alert-dialog-shortcut` inside its button to show the keys. [Dialog](./dialog.md#keyboard-shortcut) covers the shortcut syntax.
189
+
190
+ ```ts title="shortcut.ts"
191
+ import "@ui-sdk/web/alert-dialog"
192
+
193
+ function mount(root: HTMLElement) {
194
+ root.innerHTML = `
195
+ <ui-alert-dialog>
196
+ <ui-alert-dialog-trigger shortcut="mod+shift+h">
197
+ <button>
198
+ Clear History
199
+ <ui-alert-dialog-shortcut></ui-alert-dialog-shortcut>
200
+ </button>
201
+ </ui-alert-dialog-trigger>
202
+ <ui-alert-dialog-backdrop hidden></ui-alert-dialog-backdrop>
203
+ <ui-alert-dialog-content hidden>
204
+ <div data-slot="stack">
205
+ <ui-alert-dialog-title>Clear your history?</ui-alert-dialog-title>
206
+ <ui-alert-dialog-description>
207
+ Recent searches and visited pages are removed from this device.
208
+ </ui-alert-dialog-description>
209
+ </div>
210
+ <div data-slot="row">
211
+ <ui-alert-dialog-close>
212
+ <button>Cancel</button>
213
+ </ui-alert-dialog-close>
214
+ <ui-alert-dialog-close value="confirm">
215
+ <button data-variant="solid">Clear</button>
216
+ </ui-alert-dialog-close>
217
+ </div>
218
+ </ui-alert-dialog-content>
219
+ </ui-alert-dialog>
220
+ `
221
+ }
222
+
223
+ export { mount }
224
+ ```
225
+
226
+ Press Cmd+Shift+H (Ctrl+Shift+H on Windows and Linux) to open the dialog without clicking.
227
+
228
+ ## Animation
229
+
230
+ The content has `data-starting-style` while it opens and `data-ending-style` while it closes. Transition from those states, and the dialog stays mounted until the exit finishes:
231
+
232
+ ```css
233
+ [data-slot="alert-dialog-content"] {
234
+ transition:
235
+ opacity 0.2s,
236
+ translate 0.25s cubic-bezier(0.22, 1, 0.36, 1),
237
+ scale 0.25s cubic-bezier(0.22, 1, 0.36, 1);
238
+
239
+ &:is([data-starting-style], [data-ending-style]) {
240
+ opacity: 0;
241
+ translate: 0 16px;
242
+ scale: 0.96;
243
+ }
244
+
245
+ &[data-ending-style] {
246
+ transition-duration: 0.15s;
247
+ }
248
+ }
249
+ ```
250
+
251
+ ```ts title="animation.ts"
252
+ import "@ui-sdk/web/alert-dialog"
253
+
254
+ function mount(root: HTMLElement) {
255
+ root.innerHTML = `
256
+ <ui-alert-dialog>
257
+ <ui-alert-dialog-trigger>
258
+ <button>Leave Workspace</button>
259
+ </ui-alert-dialog-trigger>
260
+ <ui-alert-dialog-backdrop hidden></ui-alert-dialog-backdrop>
261
+ <ui-alert-dialog-content hidden>
262
+ <div data-slot="stack">
263
+ <ui-alert-dialog-title>Leave this workspace?</ui-alert-dialog-title>
264
+ <ui-alert-dialog-description>
265
+ You'll lose access to its projects until someone invites you again.
266
+ </ui-alert-dialog-description>
267
+ </div>
268
+ <div data-slot="row">
269
+ <ui-alert-dialog-close>
270
+ <button>Cancel</button>
271
+ </ui-alert-dialog-close>
272
+ <ui-alert-dialog-close value="confirm">
273
+ <button data-variant="solid">Leave</button>
274
+ </ui-alert-dialog-close>
275
+ </div>
276
+ </ui-alert-dialog-content>
277
+ </ui-alert-dialog>
278
+ `
279
+ }
280
+
281
+ export { mount }
282
+ ```
283
+
284
+ Open and close the dialog. It slides up and fades in, and slides down and fades out before it unmounts.
285
+
286
+ ## Nested
287
+
288
+ An alert dialog opened inside another joins its stack, such as a second confirmation before something can't be undone. Escape closes the topmost one and returns focus to its trigger. The dialog underneath gets `data-nested-open`, so you can show which layer is active. To close both once the last question is answered, listen for the inner dialog's `openchange` and set the outer one's `open` to `false` when `event.detail.returnValue` is `"confirm"`.
289
+
290
+ ```ts title="nested.ts"
291
+ import "@ui-sdk/web/alert-dialog"
292
+
293
+ function mount(root: HTMLElement) {
294
+ root.innerHTML = `
295
+ <ui-alert-dialog>
296
+ <ui-alert-dialog-trigger>
297
+ <button>Delete Workspace</button>
298
+ </ui-alert-dialog-trigger>
299
+ <ui-alert-dialog-backdrop hidden></ui-alert-dialog-backdrop>
300
+ <ui-alert-dialog-content hidden>
301
+ <div data-slot="stack">
302
+ <ui-alert-dialog-title>Delete this workspace?</ui-alert-dialog-title>
303
+ <ui-alert-dialog-description>
304
+ All 12 projects and their deployments will be deleted for everyone on your team.
305
+ </ui-alert-dialog-description>
306
+ </div>
307
+ <div data-slot="row">
308
+ <ui-alert-dialog-close>
309
+ <button>Cancel</button>
310
+ </ui-alert-dialog-close>
311
+ <ui-alert-dialog>
312
+ <ui-alert-dialog-trigger>
313
+ <button data-variant="solid">Delete</button>
314
+ </ui-alert-dialog-trigger>
315
+ <ui-alert-dialog-backdrop hidden></ui-alert-dialog-backdrop>
316
+ <ui-alert-dialog-content hidden>
317
+ <div data-slot="stack">
318
+ <ui-alert-dialog-title>Are you absolutely sure?</ui-alert-dialog-title>
319
+ <ui-alert-dialog-description>There's no way to get the workspace back.</ui-alert-dialog-description>
320
+ </div>
321
+ <div data-slot="row">
322
+ <ui-alert-dialog-close>
323
+ <button>Go Back</button>
324
+ </ui-alert-dialog-close>
325
+ <ui-alert-dialog-close value="confirm">
326
+ <button data-variant="solid">Delete Workspace</button>
327
+ </ui-alert-dialog-close>
328
+ </div>
329
+ </ui-alert-dialog-content>
330
+ </ui-alert-dialog>
331
+ </div>
332
+ </ui-alert-dialog-content>
333
+ </ui-alert-dialog>
334
+ `
335
+ const [outer, inner] = root.querySelectorAll("ui-alert-dialog")
336
+ inner.addEventListener("openchange", (event) => {
337
+ if (!event.detail.value && event.detail.returnValue === "confirm") {
338
+ outer.open = false
339
+ }
340
+ })
341
+ }
342
+
343
+ export { mount }
344
+ ```
345
+
346
+ Choose Delete Workspace, then Delete. Press Escape to step back to the first question, or choose Delete Workspace to close both.
347
+
348
+ ## Async Action
349
+
350
+ Add `action` to a Close part and listen for its `action` event. Pass a Promise to `event.detail.waitUntil()` during that event to keep the dialog open until the work finishes. A resolved Promise closes it with the reason `action`; a rejection keeps it open and puts the error in that part's state.
351
+
352
+ ```ts title="async-action.ts"
353
+ import "@ui-sdk/web/alert-dialog"
354
+
355
+ function mount(root: HTMLElement) {
356
+ root.innerHTML = `
357
+ <div data-slot="stack">
358
+ <ui-alert-dialog pending-announcement="Deleting project">
359
+ <ui-alert-dialog-trigger>
360
+ <button>Delete Project</button>
361
+ </ui-alert-dialog-trigger>
362
+ <ui-alert-dialog-backdrop hidden></ui-alert-dialog-backdrop>
363
+ <ui-alert-dialog-content hidden>
364
+ <div data-slot="stack">
365
+ <ui-alert-dialog-title>Delete project?</ui-alert-dialog-title>
366
+ <ui-alert-dialog-description>
367
+ This permanently deletes the project, its files and its deployment history for everyone on your team.
368
+ </ui-alert-dialog-description>
369
+ </div>
370
+ <div data-slot="stack">
371
+ <p data-slot="hint" role="alert"></p>
372
+ <div data-slot="row">
373
+ <ui-alert-dialog-close>
374
+ <button>Cancel</button>
375
+ </ui-alert-dialog-close>
376
+ <ui-alert-dialog-close action value="confirm">
377
+ <button data-variant="solid">Delete</button>
378
+ </ui-alert-dialog-close>
379
+ </div>
380
+ </div>
381
+ </ui-alert-dialog-content>
382
+ </ui-alert-dialog>
383
+ </div>
384
+ `
385
+ let attempts = 0
386
+ const dialog = root.querySelector("ui-alert-dialog")!
387
+ const close = root.querySelector("ui-alert-dialog-close[action]")!
388
+ const button = close.querySelector("button")!
389
+ const message = root.querySelector("p")!
390
+
391
+ async function deleteProject() {
392
+ await new Promise((resolve) => setTimeout(resolve, 1200))
393
+ if (attempts++ === 0) {
394
+ throw new Error("Couldn't delete the project.")
395
+ }
396
+ }
397
+
398
+ close.addEventListener("action", (event) => {
399
+ const { waitUntil } = (
400
+ event as CustomEvent<{ waitUntil: (promise: Promise<unknown>) => void }>
401
+ ).detail
402
+ button.textContent = "Deleting…"
403
+ message.textContent = ""
404
+ const deleting = deleteProject()
405
+ waitUntil(deleting)
406
+ deleting.then(
407
+ () => {
408
+ button.textContent = "Delete"
409
+ },
410
+ (error: Error) => {
411
+ button.textContent = "Try Again"
412
+ message.textContent = error.message
413
+ }
414
+ )
415
+ })
416
+ dialog.addEventListener("openchange", (event) => {
417
+ if (!event.detail.value) {
418
+ return
419
+ }
420
+ button.textContent = "Delete"
421
+ message.textContent = ""
422
+ })
423
+ }
424
+
425
+ export { mount }
426
+ ```
427
+
428
+ Choose Delete Project, then Delete. The first attempt fails so you can try again. While Deleting… is shown, Cancel and Escape leave the dialog open. A successful retry closes it.
429
+
430
+ While the action runs, its button stays focusable and gets `data-pending`, `aria-busy`, and `aria-disabled`. Other Close parts and dismissals cannot close the dialog until it settles. `dismissattempt` reports refused dismissals; a controller can still close it.
431
+
432
+ The root's `pending-announcement` attribute sets what screen readers hear after a second of waiting. The error clears on the next attempt or when the dialog opens again. The action event's `detail.source` describes the input that started it; [Changes After an Await](./button.md#changes-after-an-await) explains when to use it.
433
+
434
+ ## Confirm From Anywhere
435
+
436
+ The shared `confirm()` asks a question without any dialog markup. Import `@ui-sdk/web/overlays` and put one `ui-overlay-host` near the end of your page, and it shows each question as an alert dialog. `confirm()` resolves `true` when someone agrees. [Confirm Options](#confirm-options) lists what you can pass.
437
+
438
+ ```ts title="confirm-anywhere.ts"
439
+ import { confirm } from "@ui-sdk/web/alert-dialog"
440
+ import "@ui-sdk/web/overlays"
441
+ import { log } from "./log"
442
+
443
+ function mount(root: HTMLElement) {
444
+ root.innerHTML = `
445
+ <button type="button">Archive Project</button>
446
+ <ui-overlay-host></ui-overlay-host>
447
+ `
448
+ root.querySelector("button")!.addEventListener("click", async () => {
449
+ const yes = await confirm({
450
+ title: "Archive this project?",
451
+ description: "It moves to Archived, and you can restore it anytime.",
452
+ confirmLabel: "Archive",
453
+ })
454
+ log(root, yes ? "Archived the project" : "Kept the project")
455
+ })
456
+ }
457
+
458
+ export { mount }
459
+ ```
460
+
461
+ Choose Archive Project, then Archive or Cancel. The console shows the answer.
462
+
463
+ ## Confirm
464
+
465
+ Use `createConfirm<Payload>()` to ask a question from an event handler and await the answer. Import it from `@ui-sdk/web/alert-dialog`, create it once, then assign its `controller` to the root element's `controller` property. The `payloadchange` event provides the current question in `event.detail.value`.
466
+
467
+ `await confirm({ name })` resolves `true` when the Close part with `value="confirm"` closes the dialog. Cancel, Escape, and other answers resolve `false`. This lets several rows share one dialog:
468
+
469
+ ```ts title="confirm.ts"
470
+ import {
471
+ createConfirm,
472
+ type UiAlertDialogElement,
473
+ } from "@ui-sdk/web/alert-dialog"
474
+
475
+ const names = ["Acme", "Globex", "Initech"]
476
+
477
+ function mount(root: HTMLElement) {
478
+ root.innerHTML = `
479
+ <div data-slot="stack">
480
+ <div data-slot="controls">
481
+ <button type="button">Reset Projects</button>
482
+ </div>
483
+ <ul data-slot="list" aria-label="Projects"></ul>
484
+ <ui-alert-dialog>
485
+ <ui-alert-dialog-backdrop hidden></ui-alert-dialog-backdrop>
486
+ <ui-alert-dialog-content hidden>
487
+ <div data-slot="stack">
488
+ <ui-alert-dialog-title></ui-alert-dialog-title>
489
+ <ui-alert-dialog-description>
490
+ The project and its files will be deleted for everyone on your team.
491
+ </ui-alert-dialog-description>
492
+ </div>
493
+ <div data-slot="row">
494
+ <ui-alert-dialog-close>
495
+ <button>Cancel</button>
496
+ </ui-alert-dialog-close>
497
+ <ui-alert-dialog-close value="confirm">
498
+ <button data-variant="solid">Delete</button>
499
+ </ui-alert-dialog-close>
500
+ </div>
501
+ </ui-alert-dialog-content>
502
+ </ui-alert-dialog>
503
+ </div>
504
+ `
505
+ const confirm = createConfirm<{ name: string }>()
506
+ const dialog =
507
+ root.querySelector<UiAlertDialogElement<{ name: string }>>(
508
+ "ui-alert-dialog"
509
+ )!
510
+ const title = root.querySelector("ui-alert-dialog-title")!
511
+ const list = root.querySelector("ul")!
512
+ const reset = root.querySelector("button")!
513
+ dialog.controller = confirm.controller
514
+ dialog.addEventListener("payloadchange", (event) => {
515
+ title.textContent = `Delete ${event.detail.value?.name}?`
516
+ })
517
+
518
+ function resetProjects() {
519
+ list.innerHTML = names
520
+ .map(
521
+ (name) =>
522
+ `<li data-slot="row">${name}<button type="button" data-size="sm" aria-label="Delete ${name}">Delete</button></li>`
523
+ )
524
+ .join("")
525
+ for (const [index, row] of list.querySelectorAll("li").entries()) {
526
+ const name = names[index]
527
+ row.querySelector("button")!.addEventListener("click", async () => {
528
+ if (!(await confirm({ name }))) {
529
+ return
530
+ }
531
+ const next = (
532
+ row.nextElementSibling ?? row.previousElementSibling
533
+ )?.querySelector("button")
534
+ const target = next ?? reset
535
+ target.focus()
536
+ row.remove()
537
+ if (!list.children.length) {
538
+ list.innerHTML = `<li data-slot="row">All projects deleted.</li>`
539
+ }
540
+ })
541
+ }
542
+ }
543
+ reset.addEventListener("click", resetProjects)
544
+ resetProjects()
545
+ }
546
+
547
+ export { mount }
548
+ ```
549
+
550
+ Delete a project. Cancel or Escape keeps it; Delete removes it and focuses a neighboring row's button. Reset Projects brings the list back.
551
+
552
+ When the action removes the button that opened the dialog, choose a useful place for focus to go. This example focuses a neighboring row, or Reset Projects when the list is empty.
553
+
554
+ ## Queued Questions
555
+
556
+ Calls to the same confirm function wait their turn. You can ask two questions at once; the second appears only after the first has an answer.
557
+
558
+ ```ts title="queue.ts"
559
+ import {
560
+ createConfirm,
561
+ type UiAlertDialogElement,
562
+ } from "@ui-sdk/web/alert-dialog"
563
+ import { log } from "./log"
564
+
565
+ function mount(root: HTMLElement) {
566
+ root.innerHTML = `
567
+ <div data-slot="stack">
568
+ <button type="button">Review Two Projects</button>
569
+ <ui-alert-dialog>
570
+ <ui-alert-dialog-backdrop hidden></ui-alert-dialog-backdrop>
571
+ <ui-alert-dialog-content hidden>
572
+ <div data-slot="stack">
573
+ <ui-alert-dialog-title></ui-alert-dialog-title>
574
+ <ui-alert-dialog-description>
575
+ Archived projects leave the active list. You can restore them later.
576
+ </ui-alert-dialog-description>
577
+ </div>
578
+ <div data-slot="row">
579
+ <ui-alert-dialog-close>
580
+ <button>Cancel</button>
581
+ </ui-alert-dialog-close>
582
+ <ui-alert-dialog-close value="confirm">
583
+ <button data-variant="solid">Archive</button>
584
+ </ui-alert-dialog-close>
585
+ </div>
586
+ </ui-alert-dialog-content>
587
+ </ui-alert-dialog>
588
+ </div>
589
+ `
590
+ const confirm = createConfirm<{ name: string }>()
591
+ const dialog =
592
+ root.querySelector<UiAlertDialogElement<{ name: string }>>(
593
+ "ui-alert-dialog"
594
+ )!
595
+ const title = root.querySelector("ui-alert-dialog-title")!
596
+ dialog.controller = confirm.controller
597
+ dialog.addEventListener("payloadchange", (event) => {
598
+ title.textContent = `Archive ${event.detail.value?.name}?`
599
+ })
600
+ root.querySelector("button")!.addEventListener("click", async () => {
601
+ const acme = confirm({ name: "Acme" })
602
+ const globex = confirm({ name: "Globex" })
603
+ const [first, second] = await Promise.all([acme, globex])
604
+ log(root, `Acme: ${first ? "confirmed" : "canceled"}`)
605
+ log(root, `Globex: ${second ? "confirmed" : "canceled"}`)
606
+ })
607
+ }
608
+
609
+ export { mount }
610
+ ```
611
+
612
+ Choose Review Two Projects. Answer the Acme question, then the Globex question. The console shows both answers once the second one is in.
613
+
614
+ ## Styling
615
+
616
+ Each element has a `data-slot`, such as `alert-dialog-content`, and shows its state through the attributes listed under [Data Attributes](#data-attributes). [Styling and Animation](../styling-and-animation.md) covers state attributes and entry and exit transitions.
617
+
618
+ ### `<ui-alert-dialog-content>`
619
+ - `--dialog-stack`: How many dialogs are open above this one, nested inside it. 0 for the topmost.
620
+ - `--keyboard-inset`: How many pixels of the page the on-screen keyboard covers, 0 without one.
621
+ - `--visual-viewport-width`: The width of the part of the page you can see.
622
+ - `--visual-viewport-height`: The height of the part of the page you can see, above the keyboard.
623
+ - `--visual-viewport-top`: How far the part of the page you can see is scrolled from the top of the layout, as when the keyboard pushes it up.
624
+
625
+ ## Data Attributes
626
+
627
+ ### `<ui-alert-dialog-trigger>`
628
+ `[data-slot="alert-dialog-trigger"]`
629
+
630
+ - `data-closed`: Present while the dialog is closed, including while it animates out.
631
+ - `data-disabled`: Present when the trigger is disabled.
632
+ - `data-open`: Present while the dialog is open. On a trigger, while it's open from that trigger.
633
+
634
+ ### `<ui-alert-dialog-backdrop>`
635
+ `[data-slot="alert-dialog-backdrop"]`
636
+
637
+ - `data-closed`: Present while the dialog is closed, including while it animates out.
638
+ - `data-open`: Present while the dialog is open. On a trigger, while it's open from that trigger.
639
+ - `data-starting-style`: Present for the first frame. Style the state you animate from.
640
+ - `data-ending-style`: Present while the dialog animates out. Style the state you animate to.
641
+
642
+ ### `<ui-alert-dialog-content>`
643
+ `[data-slot="alert-dialog-content"]`
644
+
645
+ - `data-closed`: Present while the dialog is closed, including while it animates out.
646
+ - `data-open`: Present while the dialog is open. On a trigger, while it's open from that trigger.
647
+ - `data-starting-style`: Present for the first frame. Style the state you animate from.
648
+ - `data-ending-style`: Present while the dialog animates out. Style the state you animate to.
649
+ - `data-keyboard`: Present while the on-screen keyboard covers part of the page.
650
+
651
+ ### `<ui-alert-dialog-close>`
652
+ `[data-slot="alert-dialog-close"]`
653
+
654
+ - `data-pending`: Present on a Close part while its action runs.
655
+
656
+ ## API Reference
657
+
658
+ Alert Dialog shares [Dialog's](./dialog.md) options, except `modal`, `closeOnOutsidePress`, and `presentation`. It is always modal, never closes on an outside press, and does not present as a sheet.
659
+
660
+ ### AlertDialog
661
+
662
+ - `container?` (`DocumentFragment | Element | null`): Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent.
663
+ - `open?` (`boolean`): Whether the dialog is open. Pass it to control the dialog.
664
+ - `defaultOpen?` (`boolean`): Whether the dialog starts open, when uncontrolled. Focus moves into it once it's on the page.
665
+ - `openchangecomplete event`: Runs once the dialog has finished opening or closing, after any animation.
666
+ - `dismissible?` (`boolean`): Whether Escape, an outside press and Android's back gesture can close the dialog. Close parts, triggers and the controller always can. Pass `false` while a form has unsaved changes, and ask in `dismissattempt`.
667
+ - `dismissattempt event`: Runs when a dismissal was refused, because `dismissible` is false, an outside press doesn't close it, or a Close part's action is running. Ask "Discard changes?" here.
668
+ - `persistentElements?` (`(string | Element)[] | (() => Element[])`): Elements that stay usable while the dialog makes the page inert, like a chat launcher or a password manager's button. Elements, CSS selectors, or a function that returns elements, read when the dialog opens. Presses on them never close it.
669
+ - `pendingAnnouncement?` (`string`): What screen readers hear once a Close part's action has been running for a second, so a slow action doesn't pass in silence. Set it in the page's language. An empty string says nothing.
670
+ - `debug?` (`boolean`): Logs every state change with its reason to the console, in development builds.
671
+ - `openchange event`: Runs when the alert dialog wants to open or close. `details.reason` says why, `details.cancel()` stops it, and `details.returnValue` is the `value` of the Close part that closed it.
672
+ - `payloadchange event`: Runs when a trigger or a controller with another payload opens the alert dialog, before `openchange`, or a controller's `open({ payload })` gives the open one another payload. `details.cancel()` keeps the previous payload.
673
+ - `controller?` (`PopupController<any, AlertDialogOpenChangeReason, {}, any, DialogPayloadChangeReason>`): Opens, closes and inspects the alert dialog from anywhere. Create one with `createAlertDialogController()` or `createConfirm()`.
674
+
675
+ ### AlertDialogTrigger
676
+
677
+ - `disabled?` (`boolean`): Stops the trigger from opening the dialog. A native button can't be focused or pressed, unless `focusableWhenDisabled` is set.
678
+ - `focusableWhenDisabled?` (`boolean`): Keeps a disabled trigger in the tab order with `aria-disabled` instead of the native attribute, so it can host a tooltip that says why. Presses still do nothing.
679
+ - `payload?` (`unknown`): Data for the content to render when this trigger opens the dialog, like the row it belongs to.
680
+ - `shortcut?` (`string`): A keyboard shortcut that presses the trigger, like `"mod+k"`. `mod` is Command on Apple platforms and Control elsewhere. Sets `aria-keyshortcuts`, and a Shortcut part inside shows it. A modal dialog pauses the page's shortcuts while it's open.
681
+ - `controller?` (`PopupController<any, AlertDialogOpenChangeReason, {}, any, DialogPayloadChangeReason>`): Connects a trigger outside the alert dialog to the alert dialog with this controller.
682
+
683
+ ### AlertDialogBackdrop
684
+
685
+ Dims the page behind the dialog. `<ui-alert-dialog-backdrop>` takes no attributes of its own.
686
+
687
+ ### AlertDialogContent
688
+
689
+ - `container?` (`DocumentFragment | Element | null`): Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent.
690
+ - `initialFocus?` (`DialogInitialFocus`): Where focus goes when the dialog opens. Opening with touch focuses the dialog itself, so no on-screen keyboard appears.
691
+ - `finalFocus?` (`PopupFocusTarget`): Where focus goes when the dialog closes while focus is inside it.
692
+ - `keepMounted?` (`boolean`): Whether the dialog stays in the page, hidden, while closed. For animation libraries that drive the exit from state.
693
+
694
+ ### AlertDialogTitle
695
+
696
+ The question. `<ui-alert-dialog-title>` renders a level 2 heading, and the content uses it as its accessible name.
697
+
698
+ ### AlertDialogDescription
699
+
700
+ What happens if you agree. `<ui-alert-dialog-description>` is a paragraph, and the content uses it as its accessible description.
701
+
702
+ ### AlertDialogClose
703
+
704
+ - `value?` (`string`): Reported as `returnValue` in `openchange` and by the controller's `open()`. `createConfirm()` resolves `true` for `"confirm"`.
705
+ - `action?` (`((event: Event | undefined, details: ActionDetails) => unknown)`): Runs when the part is pressed, before the dialog closes. A returned Promise keeps the dialog open while it runs: the part gets `data-pending`, `aria-busy` and `aria-disabled`, screen readers hear the dialog's `pendingAnnouncement` after a second, and nothing but the controller closes the dialog. It closes with reason `"action"` once the Promise resolves. A rejection keeps it open and puts the reason in the part's `error` state until the next press, or until the dialog opens again. `details.source` says how the part was pressed, for changes made after an `await`.
706
+
707
+ ### AlertDialogShortcut
708
+
709
+ - `shortcut?` (`string`): The keys to show. Inside a trigger, its `shortcut`.
710
+
711
+ ### Confirm Options
712
+
713
+ The shared `confirm()` function uses these options when a `ui-overlay-host` renders the question. See [Toasts and Confirms](../popups.md#toasts-and-confirms) for the host setup. With your own dialog, `createConfirm<Payload>()` accepts the payload you choose instead.
714
+
715
+ - `title` (`string`): The question, like "Delete this project?".
716
+ - `description?` (`string`): What agreeing does.
717
+ - `confirmLabel?` (`string`): The agreeing button's text.
718
+ - `cancelLabel?` (`string`): The other button's text.
719
+
720
+ ### State
721
+
722
+ `AlertDialogContent`:
723
+
724
+ - `open` (`boolean`): Whether the dialog is open. False while it animates out.
725
+ - `modal` (`boolean | "trap-focus"`): The `modal` setting. Always true for an alert dialog.
726
+ - `nested` (`boolean`): Whether the dialog was opened from inside another dialog.
727
+ - `nestedOpen` (`boolean`): Whether a dialog opened from inside this one is open.
728
+ - `stack` (`number`): How many dialogs are open above this one, nested inside it.
729
+ - `payload` (`Payload | undefined`): The payload of the last open, from the trigger that opened it or a controller, typed as the controller's `Payload`.
730
+ - `pending` (`boolean`): Whether a Close part's action is running.
731
+ - `presentation` (`"dialog"`): Always `"dialog"`: an alert dialog never presents as a sheet.
732
+
733
+ `AlertDialogClose`:
734
+
735
+ - `pending` (`boolean`): Whether this part's action is running.
736
+ - `error` (`unknown`): Why this part's last action failed, until it's pressed again or the dialog opens again.
737
+
738
+ `AlertDialogShortcut`:
739
+
740
+ - `text` (`string`): The shortcut formatted for this platform: `⌘K` on Apple platforms and `Ctrl+K` elsewhere. Empty without one.
741
+
742
+ ### Reasons
743
+
744
+ - `trigger-press` (`MouseEvent | KeyboardEvent | TouchEvent`): Click, tap, Enter or Space on the part that opens, closes or toggles. Arrow keys that open a menu or submenu count too. A tap on a combobox's input that opens a sheet reports its `touchend`.
745
+ - `close-press` (`MouseEvent | KeyboardEvent | SubmitEvent`): A Close part was pressed, or a form with `method="dialog"` was submitted.
746
+ - `escape-key` (`KeyboardEvent`): Escape, or a submenu's close key (ArrowLeft in left-to-right layouts).
747
+ - `parent-close` (`none`): The parent layer closed.
748
+ - `back` (`Event`): Going back: the Android back button or gesture, or Backspace in an empty command input, which returns to the previous page.
749
+ - `action` (`MouseEvent | KeyboardEvent`): A Close part's `action` finished.
750
+ - `shortcut` (`KeyboardEvent`): A keyboard shortcut, like a trigger's `shortcut`.
751
+ - `imperative` (`none`): A controller or `api` call, or a property set on a web component.
752
+
753
+ `payloadchange` fires before `openchange` when the dialog opens with another payload. Calling `controller.open({ payload })` on an open dialog updates the payload with the reason `imperative`.
754
+
755
+ - `trigger-press` (`MouseEvent | KeyboardEvent | TouchEvent`): Click, tap, Enter or Space on the part that opens, closes or toggles. Arrow keys that open a menu or submenu count too. A tap on a combobox's input that opens a sheet reports its `touchend`.
756
+ - `shortcut` (`KeyboardEvent`): A keyboard shortcut, like a trigger's `shortcut`.
757
+ - `imperative` (`none`): A controller or `api` call, or a property set on a web component.
758
+
759
+ ### Controller
760
+
761
+ Use `createAlertDialogController<Payload, Result>()` from `@ui-sdk/web/alert-dialog` for direct control. The root element's `api` property has the same methods. `createConfirm<Payload>()` returns a confirm function with its own `controller`.
762
+
763
+ - `isOpen()` (`() => boolean`): Whether it's open. False as soon as it starts closing, while it still animates out.
764
+ - `setOpen(open, options?)` (`(open: boolean, options?: PopupChangeOptions<AlertDialogOpenChangeReason> | undefined) => boolean`): Opens or closes it. Returns false when the change was canceled or it was already open or closed.
765
+ - `open(options?)` (`(options?: (PopupChangeOptions<DialogPayloadChangeReason> & { payload?: Payload | undefined; anchor?: Anchor | undefined; signal?: AbortSignal | undefined; }) | undefined) => Promise<...>`): Opens it, and resolves once it closes, with why, how and any return value. Resolves exactly once and never rejects: on the next close from any source, when `signal` aborts, or with reason `"unmount"` when the component leaves the page.
766
+ - `close(options?)` (`(options?: (PopupChangeOptions<AlertDialogOpenChangeReason> & { returnValue?: Result | undefined; }) | undefined) => boolean`): Closes it. `returnValue` is passed to the promise `open()` returned. Returns false when the close was canceled or it was already closed.
767
+ - `toggle(options?)` (`(options?: PopupChangeOptions<AlertDialogOpenChangeReason> | undefined) => boolean`): Opens it when it's closed, and closes it when it's open. Returns false when the change was canceled.
768
+ - `getPayload()` (`() => Payload | undefined`): The payload of the last open, from a controller or the trigger that opened it.
769
+ - `focus()` (`() => void`): Moves focus to the trigger that opened it last, or the first trigger.
770
+
771
+ ## Accessibility
772
+
773
+ Give the dialog a title and a description, and put the least destructive answer first. It follows the [WAI-ARIA alert dialog pattern](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/).
774
+
775
+ The dialog uses the `alertdialog` role and keeps the rest of the page inert while it's open. Screen readers announce its title and description. Opening it focuses the first Close part, so put Cancel first. A touch open focuses the content instead, so no on-screen keyboard appears. Escape closes the dialog, but pressing outside never does. [Dialog](./dialog.md#focus) covers other initial and final focus targets.
776
+
777
+ These behaviors are covered by automated tests:
778
+
779
+ **Alert dialog**
780
+
781
+ - Opens with focus on the least destructive action.
782
+ - Is described by its message.
783
+ - An outside press keeps it open.
784
+ - Escape closes it and returns focus to the trigger.
785
+ - Tab cycles between its actions.
786
+ - The action reports and closes.
787
+
788
+ Runs in React, Vue and web components.