@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,57 @@
1
+ # Parts and Composition
2
+
3
+ Put a component's parts together and choose the elements they bind.
4
+
5
+ A component is a set of custom elements. A Popover has a root to hold its state, a trigger to open it, and content to show.
6
+
7
+ ## Put Parts Together
8
+
9
+ Import the component, then nest its parts as shown in its Composition:
10
+
11
+ ```ts
12
+ import "@ui-sdk/web/popover"
13
+ ```
14
+
15
+ ```html
16
+ <ui-popover id="details">
17
+ <ui-popover-trigger><button>Details</button></ui-popover-trigger>
18
+ <ui-popover-content>
19
+ <ui-popover-title>Project Details</ui-popover-title>
20
+ <p>Last updated today.</p>
21
+ <ui-popover-close><button>Done</button></ui-popover-close>
22
+ </ui-popover-content>
23
+ </ui-popover>
24
+ ```
25
+
26
+ Triggers and Close parts wrap your own `<button>`. These wrappers use `display: contents`, so the button participates in layout directly.
27
+
28
+ Parts find their root by looking up the DOM. You can put your own layout elements between them. An external part can name its root with `for="id"`; [Controllers](./controllers.md) shows an example.
29
+
30
+ ## Choose the Element
31
+
32
+ Use `as-child` when the part should bind to its first child. For example, render a menu item as a link:
33
+
34
+ ```ts
35
+ import "@ui-sdk/web/menu"
36
+ ```
37
+
38
+ ```html
39
+ <ui-menu>
40
+ <ui-menu-trigger><button>Account</button></ui-menu-trigger>
41
+ <ui-menu-content>
42
+ <ui-menu-item as-child><a href="/settings">Settings</a></ui-menu-item>
43
+ </ui-menu-content>
44
+ </ui-menu>
45
+ ```
46
+
47
+ The link receives the part's role, attributes, and keyboard behavior. Triggers and Close parts already use their first button or link, so they don't need `as-child`.
48
+
49
+ ## Name the Control
50
+
51
+ Use a label or title part, such as `<ui-field-label>` or `<ui-dialog-title>`. For an icon button, put `aria-label` on the native button inside its wrapper.
52
+
53
+ Parts write the attributes they manage, including roles, IDs, and ARIA state. Other attributes and your own listeners remain. So does a name or typing hint you write on the element: `aria-label`, `aria-labelledby`, `aria-description`, `title`, `autocomplete`, `autocapitalize`, `autocorrect`, `inputmode` and `spellcheck`. Keep those managed attributes intact when changing the markup.
54
+
55
+ ## Respond to State
56
+
57
+ Use data attributes for styling and DOM events for changes to content. [State and Events](./state-and-events.md) shows how to listen and cancel a change.
package/docs/popups.md ADDED
@@ -0,0 +1,92 @@
1
+ # Popups
2
+
3
+ Place popup content, control dismissal, and choose its container.
4
+
5
+ Popovers, menus, selects, and dialogs use the browser's top layer. They render in place, above the page, so you don't need a portal or Positioner part. Their events bubble through the elements around them like any other child's, so a click handler or a link wrapped around a popup also gets the clicks inside it. Keep popups outside clickable cards and links.
6
+
7
+ ## Place the Content
8
+
9
+ ```ts
10
+ import "@ui-sdk/web/popover"
11
+ ```
12
+
13
+ ```html
14
+ <ui-popover id="details">
15
+ <ui-popover-trigger><button>Details</button></ui-popover-trigger>
16
+ <ui-popover-content side="bottom" align="start" side-offset="8">
17
+ <ui-popover-title>Project Details</ui-popover-title>
18
+ <p>Last updated today.</p>
19
+ <ui-popover-close><button>Done</button></ui-popover-close>
20
+ </ui-popover-content>
21
+ </ui-popover>
22
+ ```
23
+
24
+ The popup flips or shifts when there isn't enough room.
25
+
26
+ | Attribute | What It Does |
27
+ | ------------------- | ---------------------------------------------------------------------------------------------------- |
28
+ | `side` | Chooses `top`, `bottom`, `left`, `right`, `start`, or `end`. Start and end follow reading direction. |
29
+ | `align` | Aligns to the start, center, or end of that side. |
30
+ | `side-offset` | Sets the gap from the anchor, in pixels. |
31
+ | `align-offset` | Shifts it along its side. |
32
+ | `collision-padding` | Leaves space from the window's edges. |
33
+
34
+ `anchor` accepts a selector for another element. For a point or rectangle, pass an anchor to the controller's `open()` method.
35
+
36
+ ## Control Dismissal
37
+
38
+ Set `dismissible="false"` on the root to stop Escape, outside presses, focus leaving, Back, and sheet swipes from closing it. The trigger, Close part, and controller can still close it.
39
+
40
+ The `dismissattempt` event reports refused dismissals through `event.detail.reason`. [State and Events](./state-and-events.md) shows how to cancel just one reason.
41
+
42
+ ## Modals and Sheets
43
+
44
+ `modal="true"` makes the rest of the page inert and locks scrolling. Each component documents its default.
45
+
46
+ Menu, Select, Combobox, Autocomplete, Popover, and Dialog support `presentation="auto"` to become a sheet on small touch screens. Use `presentation="sheet"` to always show a sheet.
47
+
48
+ ## Focus
49
+
50
+ Dialogs, alert dialogs, drawers, and popovers move focus into their content when they open. Where it lands depends on how they opened:
51
+
52
+ | Opened With | Focus Goes To |
53
+ | -------------------------------------------- | ------------------------------------------------------------ |
54
+ | Keyboard, screen reader, mouse, pen, or code | The element `initial-focus` picks. |
55
+ | Touch | The content itself, so no on-screen keyboard appears. |
56
+ | Hover | Nowhere. Focus stays where it is. |
57
+ | Rendered open | Nowhere, except in a dialog, which takes focus as it mounts. |
58
+
59
+ `initial-focus` defaults to `auto`: the first focusable element, or the content when it has none. A dialog tries an element with `autofocus` first, and an alert dialog tries its first Close part. Set it to `content` to focus the content itself, `none` to leave focus alone, or a CSS selector.
60
+
61
+ `modal` decides whether Tab can leave. With `modal="true"` or `modal="trap-focus"`, Tab and Shift+Tab wrap inside the content. With `modal="false"`, Tab moves from the trigger into a popover and on to the page after it, and focus leaving closes the popover. A non-modal dialog stays open.
62
+
63
+ When a popup closes while focus is inside it, focus returns to the trigger. If the trigger is gone or can't take focus, focus goes to the element focused before the popup opened, then where the popup it was opened from would return focus, then to the nearest focusable element after where the trigger was. A popup a controller opened returns to the element focused before it first. Set `final-focus` to `none` to leave focus alone, or to a selector to send it somewhere else. Closing because focus moved away never moves it back, and neither does pressing something focusable outside a non-modal popup.
64
+
65
+ Menus, selects, and comboboxes handle focus within their own lists, and tooltips never move it. Each component's page covers its own.
66
+
67
+ ## Hidden Content and Containers
68
+
69
+ Closed content stays in your markup, hidden. The `openchangecomplete` event fires after opening or closing finishes, including animations. `keep-mounted` is available for animation libraries that need the closed element rendered.
70
+
71
+ `container` takes a selector for the element to render into, looked up in the popup's own tree, so a popup in a shadow root finds it in that shadow root. Inside an iframe, a popup handles focus, Escape, and scroll locking in the iframe's own document. Keep a dialog containing a form outside a surrounding form, or move its content with `container`, to avoid nested forms.
72
+
73
+ [Styling and Animation](./styling-and-animation.md) covers transitions.
74
+
75
+ ## Toasts and Confirms
76
+
77
+ Place `<ui-overlay-host>` near your app's root, then call `toast()` from an event handler:
78
+
79
+ ```html
80
+ <ui-overlay-host></ui-overlay-host> <button id="save">Save</button>
81
+ ```
82
+
83
+ ```ts
84
+ import "@ui-sdk/web/overlays"
85
+ import { toast } from "@ui-sdk/web"
86
+
87
+ document
88
+ .querySelector("#save")!
89
+ .addEventListener("click", () => toast.success("Saved"))
90
+ ```
91
+
92
+ See [Toast](./components/toast.md) and [Alert Dialog](./components/alert-dialog.md) for complete examples.
@@ -0,0 +1,71 @@
1
+ # Rendering Primitives
2
+
3
+ Turn a Core primitive into custom elements with createParts.
4
+
5
+ This page renders the rating from [Compose Behaviors](./core.md#compose-behaviors). Start with that guide's [complete `rating.ts`](./core.md#complete-primitive): it already handles selection, arrow keys, and focus. Here we'll connect its `root` and `star` slots to custom elements.
6
+
7
+ ## Define the Elements
8
+
9
+ `createParts` registers one custom element for each slot you map. Save this beside `rating.ts`:
10
+
11
+ ```ts title="rating-web.ts"
12
+ import { createParts, wrappedButton } from "@ui-sdk/web"
13
+ import { rating } from "./rating"
14
+
15
+ createParts(rating, {
16
+ root: "my-rating",
17
+ star: { tag: "my-rating-star", target: wrappedButton, display: "contents" },
18
+ })
19
+ ```
20
+
21
+ The root creates the primitive instance. Each star finds that instance through the root above it. `wrappedButton` puts the star's behavior and attributes on a native button inside the custom element.
22
+
23
+ `createParts` also returns the element classes, named like the parts in other frameworks: `Root` and `Star`. Keep them with `const parts = createParts(rating, { ... })` to check an element, like `element instanceof parts.Star`. On the server nothing is registered, so they're `undefined`.
24
+
25
+ ## Render the Rating
26
+
27
+ Load `rating-web.ts` from your app's module entry, then use the registered tags:
28
+
29
+ ```html
30
+ <my-rating default-value="4" aria-label="Rating">
31
+ <my-rating-star value="1"
32
+ ><button aria-label="1 star">★</button></my-rating-star
33
+ >
34
+ <my-rating-star value="2"
35
+ ><button aria-label="2 stars">★</button></my-rating-star
36
+ >
37
+ <my-rating-star value="3"
38
+ ><button aria-label="3 stars">★</button></my-rating-star
39
+ >
40
+ <my-rating-star value="4"
41
+ ><button aria-label="4 stars">★</button></my-rating-star
42
+ >
43
+ <my-rating-star value="5"
44
+ ><button aria-label="5 stars">★</button></my-rating-star
45
+ >
46
+ </my-rating>
47
+ ```
48
+
49
+ The primitive's schema parses `default-value` as a number and each star's `value` as a string. Put the star's accessible label and styles on its button. The button receives `data-filled` when it contributes to the rating.
50
+
51
+ [Styling and Animation](./styling-and-animation.md) covers styling those attributes. The native buttons remain in the HTML before the elements upgrade; their rating behavior starts when the module loads.
52
+
53
+ ## Listen to Changes
54
+
55
+ The primitive's `onValueChange` callback becomes a `valuechange` event on the root:
56
+
57
+ ```ts
58
+ import "./rating-web"
59
+
60
+ const element = document.querySelector("my-rating")!
61
+ element.addEventListener("valuechange", (event) => {
62
+ const { value } = (event as CustomEvent<{ value: number }>).detail
63
+ console.log(`Rating: ${value}`)
64
+ })
65
+ ```
66
+
67
+ Call `event.preventDefault()` to cancel a change. These events don't bubble, so listen on the root itself. [State and Events](./state-and-events.md) explains the details and controlled values.
68
+
69
+ ## Add Logic to a Part
70
+
71
+ [Custom Parts](./custom-parts.md) builds on these same elements: choose a part's binding target, and expose API methods or live properties.
@@ -0,0 +1,118 @@
1
+ # Server Rendering
2
+
3
+ Send HTML from the server and upgrade custom elements in the browser.
4
+
5
+ Write custom elements in your server-rendered HTML. Import their modules in the browser to upgrade them and connect their behavior.
6
+
7
+ ## Send the Markup
8
+
9
+ ```html
10
+ <ui-toggle default-pressed>
11
+ <button type="button" aria-pressed="true">Bold</button>
12
+ </ui-toggle>
13
+ <script type="module" src="/src/components.ts"></script>
14
+ ```
15
+
16
+ ```ts title="components.ts"
17
+ import "@ui-sdk/web/toggle"
18
+ ```
19
+
20
+ Your bundler resolves the package import. The browser upgrades `<ui-toggle>` when that module runs. Plain server-rendered HTML does not calculate the primitive’s ARIA state. Here, `aria-pressed="true"` describes the initial button before upgrade and matches `default-pressed`. After upgrade, ui-sdk keeps it in sync as the button toggles.
21
+
22
+ ## Before Upgrade
23
+
24
+ The Bold button is visible before the script loads, but it cannot toggle yet. Native behavior still works: a submit button can submit a form, and a native input can accept text. Keyboard navigation and state changes managed by ui-sdk need the component’s script.
25
+
26
+ Design the initial HTML accordingly. For a control that must submit before upgrade, include a native input or select using the fallback markup shown on its component page.
27
+
28
+ ## Wait for an Element
29
+
30
+ Run code that uses component properties after the markup exists and the element is defined:
31
+
32
+ ```ts
33
+ import "@ui-sdk/web/toggle"
34
+
35
+ await customElements.whenDefined("ui-toggle")
36
+ const toggle = document.querySelector("ui-toggle")!
37
+ console.log(toggle.pressed)
38
+ ```
39
+
40
+ Run this after the markup exists. `whenDefined` waits for the tag's registration; it doesn't wait for an element to be inserted into the document.
41
+
42
+ ## Saved Preferences and Storage
43
+
44
+ Preferences like a color scheme or an emoji skin tone are saved in the browser, so your server can't render them. [Preferences](./core.md#preferences) covers the preferences themselves; this is how they fit server-rendered HTML.
45
+
46
+ ### Show Them Before the Scripts Load
47
+
48
+ Write `preferencesScript([...])` from `@ui-sdk/core` into your HTML as `<ui-preferences>`'s first child. It runs as the browser parses the page, before any module, and puts every saved value on its `data-*` attribute, so CSS that selects those attributes is right from the first paint. Give the element its preferences once its module loads:
49
+
50
+ ```ts title="server.ts"
51
+ import { preferencesScript } from "@ui-sdk/core"
52
+ import { colorScheme, skinTone } from "./preferences"
53
+
54
+ const page = `<body>
55
+ <ui-preferences>
56
+ <script>${preferencesScript([colorScheme, skinTone])}</script>
57
+ …
58
+ </ui-preferences>
59
+ <script type="module" src="/src/page.ts"></script>
60
+ </body>`
61
+ ```
62
+
63
+ ```ts title="page.ts"
64
+ import "@ui-sdk/web/preferences"
65
+ import { colorScheme, skinTone } from "./preferences"
66
+
67
+ document.querySelector("ui-preferences")!.preferences = [colorScheme, skinTone]
68
+ ```
69
+
70
+ The script writes preferences made with `global: true` on `<html>`, and the others on `<ui-preferences>`. Once the element has its preferences, it keeps the attributes in step with every change. Add a `nonce` attribute to the script if your Content Security Policy needs one.
71
+
72
+ ### Read a Cookie on the Server
73
+
74
+ A preference kept in a cookie can render on your server too, content included. Pass the request's `Cookie` header to `createCookieStorage` while rendering that request, and read the value to write it into the HTML:
75
+
76
+ ```ts
77
+ const skinTone = createPreference({
78
+ values: ["default", "light", "medium", "dark"],
79
+ defaultValue: "default",
80
+ attribute: "data-skin-tone",
81
+ storage: createCookieStorage("skin-tone", {
82
+ cookie: request.headers.get("cookie"),
83
+ }),
84
+ })
85
+
86
+ const page = `<ui-preferences data-skin-tone="${skinTone.get().value}">…</ui-preferences>`
87
+ ```
88
+
89
+ In the browser the same storage reads `document.cookie`.
90
+
91
+ ### Render the Storage Script Yourself
92
+
93
+ For one element that keeps its own value, like a toolbar's density, a storage's `script` returns the same kind of inline script for a single element. Write it right after the element, since it sets the element right before it:
94
+
95
+ ```ts title="server.ts"
96
+ import { createLocalStorage } from "@ui-sdk/core"
97
+
98
+ const density = createLocalStorage("density")
99
+ const script = density.script({
100
+ attribute: "data-density",
101
+ values: ["comfortable", "compact"],
102
+ })
103
+
104
+ const toolbar = `<div class="toolbar" data-density="comfortable">…</div>
105
+ <script>${script}</script>`
106
+ ```
107
+
108
+ - **Shared by ID.** Every script with the same storage kind and ID reads the storage once, however many elements it follows, and the scripts are identical, so compression shrinks the repeats.
109
+ - **Only safe values.** Any script on your site can write the saved value, so `script` only sets attributes that start with `data-`, and only to one of `values`.
110
+ - **Not for cookies.** A cookie storage's `script` returns undefined, since your server reads the cookie and can write the value itself.
111
+
112
+ To run before the page's content at all, write `preferencesScript([...])` into `<head>`. Only global preferences make sense there, since the others go on the script's parent element.
113
+
114
+ ## Importing on the Server
115
+
116
+ Component modules skip registration when `customElements` is unavailable. Importing one on the server doesn't upgrade markup. Load it again in the browser.
117
+
118
+ Popups render in place, so your server template doesn't need a portal root. [Popups](./popups.md) covers placement, and [Forms](./forms.md) covers submission.
@@ -0,0 +1,134 @@
1
+ # State and Events
2
+
3
+ Set initial state, change properties, and respond to DOM events.
4
+
5
+ Set the starting state in HTML. Read and change it through the element's properties once it has upgraded.
6
+
7
+ ## Set the Starting Value
8
+
9
+ ```ts
10
+ import "@ui-sdk/web/toggle"
11
+ ```
12
+
13
+ ```html
14
+ <ui-toggle default-pressed><button type="button">Bold</button></ui-toggle>
15
+ ```
16
+
17
+ The attribute depends on the component: `default-pressed`, `default-checked`, `default-open`, or `default-value`. Leave a boolean attribute out to turn its option off. An option that's on by default, like `loop`, turns off with `"false"`. `disabled` and `required` work like they do on native controls: written at all, even as `"false"`, they're on.
18
+
19
+ ## Change a Value from Script
20
+
21
+ On a page with the toggle above, read or set its live `pressed` property:
22
+
23
+ ```ts
24
+ import "@ui-sdk/web/toggle"
25
+
26
+ await customElements.whenDefined("ui-toggle")
27
+ const toggle = document.querySelector("ui-toggle")!
28
+ toggle.pressed = true
29
+ console.log(toggle.pressed)
30
+ ```
31
+
32
+ Other elements expose `open`, `checked`, or `value`. These are live properties, not React-style controlled props. Changing an attribute such as `pressed` also updates state.
33
+
34
+ Setting a property or attribute fires no event, like setting a native input's `value`. So a page that renders the state back into the element never hears its own write. Changes from the person using it, from the element's `api`, or from an agent fire events.
35
+
36
+ ## Change an Option from Script
37
+
38
+ Options have properties too. On the same toggle, changing `disabled` also updates its attribute:
39
+
40
+ ```ts
41
+ import "@ui-sdk/web/toggle"
42
+
43
+ const toggle = document.querySelector("ui-toggle")!
44
+ toggle.disabled = true
45
+ ```
46
+
47
+ The button is now disabled, and `<ui-toggle>` has a `disabled` attribute. Set the property to `false` to remove it.
48
+
49
+ Other option types follow the same pattern:
50
+
51
+ | Option Type | Property and Attribute |
52
+ | ----------------------- | -------------------------------------------------------- |
53
+ | Boolean, off by default | `disabled = true` adds `disabled`; `false` removes it. |
54
+ | Boolean, on by default | `loop = false` writes `loop="false"`. |
55
+ | Text or number | Reads back as the same type, or `undefined` when absent. |
56
+ | List | Reads as an array; the attribute is comma-separated. |
57
+
58
+ Options an attribute cannot hold, such as a data menu’s `items`, are properties only.
59
+
60
+ ## Respond to a Change
61
+
62
+ Callbacks become lowercase DOM events, such as `pressedchange` and `openchange`. Each one fires on the element whose state changed and doesn't bubble, like `toggle` on `<details>`. Its `detail` holds the requested value and the change details:
63
+
64
+ | Detail | What It Tells You |
65
+ | -------- | --------------------------------------------------------------------------- |
66
+ | `value` | The requested value. |
67
+ | `reason` | What requested the change, such as `press` or `outside-press`. |
68
+ | `event` | The DOM event behind the change, when there is one. |
69
+ | `source` | `keyboard`, `mouse`, `touch`, `pen`, `virtual`, `programmatic`, or `agent`. |
70
+
71
+ Call `event.preventDefault()` to cancel the change. This example keeps the popover open when someone clicks outside:
72
+
73
+ ```html
74
+ <ui-popover id="details">
75
+ <ui-popover-trigger><button>Details</button></ui-popover-trigger>
76
+ <ui-popover-content>
77
+ <ui-popover-title>Project Details</ui-popover-title>
78
+ <p>Last updated today.</p>
79
+ <ui-popover-close><button>Done</button></ui-popover-close>
80
+ </ui-popover-content>
81
+ </ui-popover>
82
+ ```
83
+
84
+ ```ts
85
+ import "@ui-sdk/web/popover"
86
+
87
+ const popover = document.querySelector("ui-popover")!
88
+ popover.addEventListener("openchange", (event) => {
89
+ if (!event.detail.value && event.detail.reason === "outside-press") {
90
+ event.preventDefault()
91
+ }
92
+ })
93
+ ```
94
+
95
+ The Done button still closes it.
96
+
97
+ ### Listen to Many Elements at Once
98
+
99
+ Since events don't bubble, a dialog only hears its own `openchange`, never the one from an alert dialog inside it. To hear every element inside a container with one listener, listen in the capture phase. `event.target` is the element that changed:
100
+
101
+ ```html
102
+ <div id="formatting">
103
+ <ui-toggle><button type="button">Bold</button></ui-toggle>
104
+ <ui-toggle><button type="button">Italic</button></ui-toggle>
105
+ </div>
106
+ <output id="last-change"></output>
107
+ ```
108
+
109
+ ```ts
110
+ import "@ui-sdk/web/toggle"
111
+
112
+ const toolbar = document.querySelector("#formatting")!
113
+ const output = document.querySelector("#last-change")!
114
+
115
+ toolbar.addEventListener(
116
+ "pressedchange",
117
+ (event) => {
118
+ if (event instanceof CustomEvent && event.target instanceof HTMLElement) {
119
+ output.textContent = `${event.target.textContent}: ${event.detail.value}`
120
+ }
121
+ },
122
+ { capture: true }
123
+ )
124
+ ```
125
+
126
+ ## Empty and Multiple Values
127
+
128
+ Select, Tabs, and Radio Group report `null` when nothing is selected. A multiple Select or Combobox uses an array. Accordion and Toggle Group always use arrays. In attributes, lists are comma-separated, such as `default-value="bold,italic"`.
129
+
130
+ Add `debug` to a root to log changes while you work. [Controllers](./controllers.md) covers changing state from elsewhere.
131
+
132
+ ## Move an Element
133
+
134
+ An element keeps its state when you move it, like a native `<details>` keeps `open`. Take it off the page and put it back later, like a view your router keeps, and it picks up where it was: the same tab selected, the same value.
@@ -0,0 +1,104 @@
1
+ # Styling and Animation
2
+
3
+ Style the rendered elements and add entry and exit transitions.
4
+
5
+ Parts render without styles. The component demos use plain CSS, and the same state attributes and CSS variables work with Tailwind CSS or any other stylesheet.
6
+
7
+ ## Style a Part
8
+
9
+ Style the element that receives the behavior. For a toggle, that is the button inside its wrapper. Import `@ui-sdk/web/toggle` on this page:
10
+
11
+ ```html
12
+ <ui-toggle>
13
+ <button
14
+ class="rounded-md border border-neutral-300 px-2.5 py-1.5 text-sm data-pressed:bg-neutral-100 data-disabled:opacity-50"
15
+ >
16
+ Bold
17
+ </button>
18
+ </ui-toggle>
19
+ ```
20
+
21
+ State attributes such as `data-pressed` and `data-disabled` are present or absent. Others have values, such as `data-side="top"`. Each component's Styling section lists its attributes and CSS variables.
22
+
23
+ ## CSS Modules
24
+
25
+ CSS Modules need a bundler that imports a class-name map. With plain CSS, use an ordinary class name and load the stylesheet instead. Import the module and pass its class to the button:
26
+
27
+ ```html
28
+ <ui-toggle id="bold"><button>Bold</button></ui-toggle>
29
+ ```
30
+
31
+ ```ts
32
+ import "@ui-sdk/web/toggle"
33
+ import styles from "./toggle.module.css"
34
+
35
+ const button = document.querySelector("#bold button")!
36
+ button.classList.add(styles.toggle)
37
+ ```
38
+
39
+ ```css title="toggle.module.css"
40
+ .toggle {
41
+ cursor: default;
42
+ border: 1px solid var(--input, #e5e5e5);
43
+ border-radius: 1.125rem;
44
+ background: transparent;
45
+ padding: 0.375rem 0.625rem;
46
+ color: inherit;
47
+ font: inherit;
48
+ font-size: 0.875rem;
49
+ }
50
+
51
+ .toggle[data-pressed] {
52
+ background: var(--muted, #f5f5f5);
53
+ }
54
+
55
+ .toggle[data-disabled] {
56
+ opacity: 0.5;
57
+ }
58
+
59
+ .toggle:focus-visible {
60
+ outline: 2px solid var(--ring, #a3a3a3);
61
+ outline-offset: 2px;
62
+ }
63
+ ```
64
+
65
+ ## Animate Opening and Closing
66
+
67
+ Import `@ui-sdk/web/popover`, then style `data-starting-style` for entry and `data-ending-style` for exit:
68
+
69
+ ```html
70
+ <ui-popover id="details">
71
+ <ui-popover-trigger><button>Details</button></ui-popover-trigger>
72
+ <ui-popover-content
73
+ class="origin-(--transform-origin) transition-[opacity,scale] duration-150 data-starting-style:scale-96 data-starting-style:opacity-0 data-ending-style:scale-96 data-ending-style:opacity-0 motion-reduce:transition-none"
74
+ >
75
+ <ui-popover-title>Project Details</ui-popover-title>
76
+ <p>Last updated today.</p>
77
+ <ui-popover-close><button>Done</button></ui-popover-close>
78
+ </ui-popover-content>
79
+ </ui-popover>
80
+ ```
81
+
82
+ The popup stays shown until its exit transition or animation finishes, then becomes hidden. Put exit styles on `data-ending-style`; `data-closed` describes state but doesn't wait for an exit.
83
+
84
+ Popups provide `--anchor-width` and `--available-height` for sizing. Use those and `data-slot` rather than generated IDs. [Popups](./popups.md) covers placement and containers.
85
+
86
+ ## The ui-sdk Layer
87
+
88
+ A few behaviors need a little CSS, like keeping a closed popup hidden or giving each element a default `display`, so ui-sdk adds it to the page in a cascade layer named `ui-sdk`. Declare that layer at the top of the stylesheet your page links, so your own styles win over it wherever the page puts them. With Tailwind, put it above `@import "tailwindcss"`:
89
+
90
+ ```css
91
+ @layer ui-sdk;
92
+ ```
93
+
94
+ ## Content Security Policy
95
+
96
+ A Content Security Policy without `'unsafe-inline'` in `style-src` blocks the CSS ui-sdk adds to the page. Give ui-sdk your policy's nonce with a meta tag in the page's `<head>`, next to where your server writes the policy:
97
+
98
+ ```html
99
+ <meta property="csp-nonce" nonce="your-nonce" />
100
+ ```
101
+
102
+ With Vite, set `html.cspNonce` in your Vite config to a placeholder, and Vite writes this tag for you. Your server replaces the placeholder with a new nonce on each request. Shadow roots need nothing: ui-sdk adopts constructed style sheets there, which no policy blocks.
103
+
104
+ If your policy has no nonce for styles, add the tag without the `nonce` attribute, and ui-sdk adopts constructed style sheets on the page too. If your code replaces `document.adoptedStyleSheets`, ui-sdk adds its sheets back as elements update or are added.