@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,1431 @@
1
+ # Command
2
+
3
+ Search commands, run actions, and open pages of more choices.
4
+
5
+ Command puts a search field over a list of actions. The list stays open while someone searches. You can use it on its own, or put it in a dialog to build a command palette.
6
+
7
+ ```ts title="demo.ts"
8
+ import "@ui-sdk/web/command"
9
+ import {
10
+ Calculator,
11
+ Calendar,
12
+ createElement,
13
+ CreditCard,
14
+ Search,
15
+ Settings,
16
+ Smile,
17
+ User,
18
+ } from "lucide"
19
+
20
+ const suggestions = [
21
+ { value: "calendar", label: "Calendar", icon: Calendar },
22
+ { value: "emoji", label: "Search Emoji", icon: Smile },
23
+ {
24
+ value: "calculator",
25
+ label: "Calculator",
26
+ icon: Calculator,
27
+ disabled: true,
28
+ },
29
+ ]
30
+
31
+ const settings = [
32
+ { value: "profile", label: "Profile", icon: User, shortcut: "mod+p" },
33
+ { value: "billing", label: "Billing", icon: CreditCard, shortcut: "mod+b" },
34
+ { value: "settings", label: "Settings", icon: Settings, shortcut: "mod+s" },
35
+ ]
36
+
37
+ function mount(root: HTMLElement) {
38
+ root.innerHTML = `
39
+ <ui-command>
40
+ <div data-slot="row">
41
+ ${createElement(Search, { "aria-hidden": "true" }).outerHTML}
42
+ <ui-command-input>
43
+ <input aria-label="Search commands" placeholder="Type a command or search…" />
44
+ </ui-command-input>
45
+ </div>
46
+ <ui-command-empty>No results found.</ui-command-empty>
47
+ <ui-command-list>
48
+ <ui-command-group>
49
+ <ui-command-group-label>Suggestions</ui-command-group-label>
50
+ ${suggestions
51
+ .map(
52
+ (item) => `
53
+ <ui-command-item value="${item.value}" ${item.disabled ? "disabled" : ""}>
54
+ <ui-command-item-icon>${createElement(item.icon, { "aria-hidden": "true" }).outerHTML}</ui-command-item-icon>
55
+ <span>${item.label}</span>
56
+ </ui-command-item>
57
+ `
58
+ )
59
+ .join("")}
60
+ </ui-command-group>
61
+ <ui-command-separator></ui-command-separator>
62
+ <ui-command-group>
63
+ <ui-command-group-label>Settings</ui-command-group-label>
64
+ ${settings
65
+ .map(
66
+ (item) => `
67
+ <ui-command-item value="${item.value}" shortcut="${item.shortcut}">
68
+ <ui-command-item-icon>${createElement(item.icon, { "aria-hidden": "true" }).outerHTML}</ui-command-item-icon>
69
+ <span>${item.label}</span>
70
+ <ui-command-shortcut></ui-command-shortcut>
71
+ </ui-command-item>
72
+ `
73
+ )
74
+ .join("")}
75
+ </ui-command-group>
76
+ </ui-command-list>
77
+ </ui-command>
78
+ `
79
+ }
80
+
81
+ export { mount }
82
+ ```
83
+
84
+ Type “bil” to find Billing. Arrow keys move the highlight; Escape clears the search.
85
+
86
+ ## Installation
87
+
88
+ ```bash
89
+ npm install @ui-sdk/web @ui-sdk/core
90
+ ```
91
+
92
+ Import the element definitions once in your application:
93
+
94
+ ```ts
95
+ import "@ui-sdk/web/command"
96
+ ```
97
+
98
+ ## Composition
99
+
100
+ Use the following composition to build a `ui-command`:
101
+
102
+ ```text
103
+ ui-command
104
+ ├── ui-command-input
105
+ │ └── input
106
+ ├── ui-command-empty
107
+ └── ui-command-list
108
+ ├── ui-command-item
109
+ └── ui-command-item
110
+ ```
111
+
112
+ Give the input an accessible name and each command a unique value. `ui-command-input` wraps a native input. Keep empty and status messages outside the list, which holds commands and groups. The `action` event reports the value of the command that ran in `event.detail.value`; use it to perform the action.
113
+
114
+ Use `ui-command-group` and `ui-command-group-label` to name related commands, with a `ui-command-separator` between groups. Groups and separators disappear when filtering leaves them empty.
115
+
116
+ ## Usage
117
+
118
+ Import the parts and put them together:
119
+
120
+ ```html
121
+ <script type="module">
122
+ import "@ui-sdk/web/command"
123
+ </script>
124
+
125
+ <ui-command>
126
+ <ui-command-input><input aria-label="Search commands" /></ui-command-input>
127
+ <ui-command-empty>No commands found.</ui-command-empty>
128
+ <ui-command-list>
129
+ <ui-command-item value="new-file">New file</ui-command-item>
130
+ <ui-command-item value="new-folder">New folder</ui-command-item>
131
+ </ui-command-list>
132
+ </ui-command>
133
+ ```
134
+
135
+ ## Build Your Own
136
+
137
+ `@ui-sdk/web/command` comes with ready-made `ui-command` elements. If you'd like to build your own, with your own element names, start from the `command` primitive in `@ui-sdk/core`:
138
+
139
+ ```ts title="palette-elements.ts"
140
+ import { command } from "@ui-sdk/core/command"
141
+ import { createParts, wrappedChild } from "@ui-sdk/web"
142
+
143
+ createParts(command, {
144
+ root: "command-palette",
145
+ input: {
146
+ tag: "palette-search",
147
+ target: wrappedChild("input"),
148
+ display: "contents",
149
+ },
150
+ empty: "palette-empty",
151
+ list: "palette-list",
152
+ item: "palette-action",
153
+ })
154
+ ```
155
+
156
+ ```html
157
+ <command-palette>
158
+ <palette-search><input aria-label="Search actions" /></palette-search>
159
+ <palette-empty>No actions found.</palette-empty>
160
+ <palette-list>
161
+ <palette-action value="new-file">New file</palette-action>
162
+ <palette-action value="new-folder">New folder</palette-action>
163
+ </palette-list>
164
+ </command-palette>
165
+ ```
166
+
167
+ Each element keeps the behavior, state and data attributes of its ready-made counterpart: typing filters the commands, arrow keys move the highlight and Enter runs it. See [Rendering](../rendering.md) and [Custom Parts](../custom-parts.md) for more.
168
+
169
+ ## Dialog
170
+
171
+ Put Command inside a [Dialog](./dialog.md) for a command palette. Give the dialog a title, put `shortcut="mod+k"` on its trigger, and close it when a command runs. The dialog handles dismissal and returns focus to the trigger.
172
+
173
+ ```ts title="dialog.ts"
174
+ import "@ui-sdk/web/command"
175
+ import "@ui-sdk/web/dialog"
176
+ import {
177
+ Calculator,
178
+ Calendar,
179
+ createElement,
180
+ CreditCard,
181
+ Search,
182
+ Settings,
183
+ Smile,
184
+ User,
185
+ } from "lucide"
186
+ import { log } from "./log"
187
+
188
+ const commands = [
189
+ { value: "calendar", label: "Calendar", icon: Calendar },
190
+ { value: "emoji", label: "Search Emoji", icon: Smile },
191
+ {
192
+ value: "calculator",
193
+ label: "Calculator",
194
+ icon: Calculator,
195
+ disabled: true,
196
+ },
197
+ { value: "profile", label: "Profile", icon: User },
198
+ { value: "billing", label: "Billing", icon: CreditCard },
199
+ { value: "settings", label: "Settings", icon: Settings },
200
+ ]
201
+
202
+ function mount(root: HTMLElement) {
203
+ root.innerHTML = `
204
+ <div data-slot="stack">
205
+ <ui-dialog>
206
+ <ui-dialog-trigger shortcut="mod+k">
207
+ <button>
208
+ Search…
209
+ <ui-dialog-shortcut></ui-dialog-shortcut>
210
+ </button>
211
+ </ui-dialog-trigger>
212
+ <ui-dialog-backdrop hidden></ui-dialog-backdrop>
213
+ <ui-dialog-content hidden>
214
+ <ui-dialog-title>Command palette</ui-dialog-title>
215
+ <ui-command>
216
+ <div data-slot="row">
217
+ ${createElement(Search, { "aria-hidden": "true" }).outerHTML}
218
+ <ui-command-input>
219
+ <input aria-label="Search commands" placeholder="Type a command or search…" />
220
+ </ui-command-input>
221
+ </div>
222
+ <ui-command-empty>No results found.</ui-command-empty>
223
+ <ui-command-list>
224
+ <ui-command-group>
225
+ <ui-command-group-label>Suggestions</ui-command-group-label>
226
+ ${commands
227
+ .map(
228
+ (item) => `
229
+ <ui-command-item value="${item.value}" ${item.disabled ? "disabled" : ""}>
230
+ <ui-command-item-icon>${createElement(item.icon, { "aria-hidden": "true" }).outerHTML}</ui-command-item-icon>
231
+ ${item.label}
232
+ </ui-command-item>
233
+ `
234
+ )
235
+ .join("")}
236
+ </ui-command-group>
237
+ </ui-command-list>
238
+ </ui-command>
239
+ </ui-dialog-content>
240
+ </ui-dialog>
241
+ </div>
242
+ `
243
+ const dialog = root.querySelector("ui-dialog")!
244
+ root.querySelector("ui-command")!.addEventListener("action", (event) => {
245
+ log(root, `Ran ${event.detail.value}`)
246
+ dialog.open = false
247
+ })
248
+ }
249
+
250
+ export { mount }
251
+ ```
252
+
253
+ Press Search or use Cmd+K / Ctrl+K. Choose a command to run it and close the palette; the console logs what ran.
254
+
255
+ ## Shortcuts
256
+
257
+ An item’s `shortcut` can run it while the command list is mounted, even when the search or current page hides it. `ui-command-shortcut` displays the keys for the current platform, and the item gets `aria-keyshortcuts`. Shortcuts inside a dialog run while it is open.
258
+
259
+ ```ts title="shortcuts.ts"
260
+ import "@ui-sdk/web/command"
261
+ import { createElement, CreditCard, Settings, User } from "lucide"
262
+ import { log } from "./log"
263
+
264
+ const settings = [
265
+ { value: "profile", label: "Profile", icon: User, shortcut: "mod+p" },
266
+ { value: "billing", label: "Billing", icon: CreditCard, shortcut: "mod+b" },
267
+ { value: "settings", label: "Settings", icon: Settings, shortcut: "mod+s" },
268
+ ]
269
+
270
+ function mount(root: HTMLElement) {
271
+ root.innerHTML = `
272
+ <div data-slot="stack">
273
+ <ui-command>
274
+ <ui-command-input>
275
+ <input aria-label="Search settings" placeholder="Search settings…" />
276
+ </ui-command-input>
277
+ <ui-command-list>
278
+ <ui-command-group>
279
+ <ui-command-group-label>Settings</ui-command-group-label>
280
+ ${settings
281
+ .map(
282
+ (item) => `
283
+ <ui-command-item value="${item.value}" shortcut="${item.shortcut}">
284
+ <ui-command-item-icon>${createElement(item.icon, { "aria-hidden": "true" }).outerHTML}</ui-command-item-icon>
285
+ <span>${item.label}</span>
286
+ <ui-command-shortcut></ui-command-shortcut>
287
+ </ui-command-item>
288
+ `
289
+ )
290
+ .join("")}
291
+ </ui-command-group>
292
+ </ui-command-list>
293
+ </ui-command>
294
+ </div>
295
+ `
296
+ root
297
+ .querySelector("ui-command")!
298
+ .addEventListener("action", (event) =>
299
+ log(root, `Ran ${event.detail.value}`)
300
+ )
301
+ }
302
+
303
+ export { mount }
304
+ ```
305
+
306
+ Press Cmd+P / Ctrl+P to run Profile, even when the search hides it. The console logs each command that runs.
307
+
308
+ ## Highlight Matches
309
+
310
+ `ui-command-item-text` marks the matched text. The default fuzzy filter can match letters that are apart, so one command may have several marked segments.
311
+
312
+ ```ts title="highlight.ts"
313
+ import "@ui-sdk/web/command"
314
+ import {
315
+ Calculator,
316
+ Calendar,
317
+ createElement,
318
+ CreditCard,
319
+ Search,
320
+ Settings,
321
+ Smile,
322
+ User,
323
+ } from "lucide"
324
+
325
+ const commands = [
326
+ { value: "calendar", label: "Calendar", icon: Calendar },
327
+ { value: "emoji", label: "Search Emoji", icon: Smile },
328
+ {
329
+ value: "calculator",
330
+ label: "Calculator",
331
+ icon: Calculator,
332
+ disabled: true,
333
+ },
334
+ { value: "profile", label: "Profile", icon: User },
335
+ { value: "billing", label: "Billing", icon: CreditCard },
336
+ { value: "settings", label: "Settings", icon: Settings },
337
+ ]
338
+
339
+ function mount(root: HTMLElement) {
340
+ root.innerHTML = `
341
+ <ui-command>
342
+ <div data-slot="row">
343
+ ${createElement(Search, { "aria-hidden": "true" }).outerHTML}
344
+ <ui-command-input>
345
+ <input aria-label="Search commands" placeholder="Try “prf” or “emo”…" />
346
+ </ui-command-input>
347
+ </div>
348
+ <ui-command-empty>No results found.</ui-command-empty>
349
+ <ui-command-list>
350
+ ${commands
351
+ .map(
352
+ (item) => `
353
+ <ui-command-item value="${item.value}" ${item.disabled ? "disabled" : ""}>
354
+ <ui-command-item-icon>${createElement(item.icon, { "aria-hidden": "true" }).outerHTML}</ui-command-item-icon>
355
+ <ui-command-item-text>${item.label}</ui-command-item-text>
356
+ </ui-command-item>
357
+ `
358
+ )
359
+ .join("")}
360
+ </ui-command-list>
361
+ </ui-command>
362
+ `
363
+ }
364
+
365
+ export { mount }
366
+ ```
367
+
368
+ Type “prf” to find Profile. Matching letters are marked even when they are not next to each other.
369
+
370
+ ## Filter and Keywords
371
+
372
+ `"fuzzy"` is the default: `nf` matches New file. `"contains"` and `"startsWith"` match the text itself. A custom function returns a boolean or a score; zero hides a command and higher scores rank first. Assign a function to the `filter` property.
373
+
374
+ Data commands are sorted by score. Commands written directly in markup keep their order, even though the best match can be highlighted.
375
+
376
+ `keywords` adds search terms without changing the command's label. Use it for synonyms or names someone might type instead.
377
+
378
+ ```ts title="filter.ts"
379
+ import "@ui-sdk/web/command"
380
+ import "@ui-sdk/web/select"
381
+ import { Check, ChevronDown, createElement } from "lucide"
382
+
383
+ const commands = [
384
+ { label: "Home" },
385
+ { label: "Inbox", keywords: ["mail", "messages"] },
386
+ { label: "Documents" },
387
+ { label: "Downloads" },
388
+ { label: "New file" },
389
+ { label: "New folder" },
390
+ { label: "Copy" },
391
+ { label: "Paste" },
392
+ { label: "Delete", keywords: ["remove", "trash"] },
393
+ { label: "Zoom in" },
394
+ { label: "Zoom out" },
395
+ { label: "Search emoji", keywords: ["smiley", "face"] },
396
+ { label: "Keyboard shortcuts", keywords: ["hotkeys"] },
397
+ { label: "Settings", keywords: ["preferences"] },
398
+ ]
399
+
400
+ const modes = [
401
+ { value: "fuzzy", label: "Fuzzy" },
402
+ { value: "contains", label: "Contains" },
403
+ { value: "startsWith", label: "Starts with" },
404
+ { value: "words", label: "Words" },
405
+ ]
406
+ type Mode = "fuzzy" | "contains" | "startsWith" | "words"
407
+
408
+ function words(item: { label: string }, query: string) {
409
+ return query
410
+ .toLowerCase()
411
+ .split(/\s+/)
412
+ .every((word) =>
413
+ item.label
414
+ .toLowerCase()
415
+ .split(" ")
416
+ .some((part) => part.startsWith(word))
417
+ )
418
+ }
419
+
420
+ function mount(root: HTMLElement) {
421
+ root.innerHTML = `
422
+ <div data-slot="stack">
423
+ <div data-slot="controls">
424
+ <ui-select default-value="fuzzy">
425
+ <ui-select-label>Filter</ui-select-label>
426
+ <ui-select-trigger>
427
+ <button>
428
+ <ui-select-value></ui-select-value>
429
+ ${createElement(ChevronDown, { "aria-hidden": "true" }).outerHTML}
430
+ </button>
431
+ </ui-select-trigger>
432
+ <ui-select-content hidden>
433
+ ${modes
434
+ .map(
435
+ (option) => `
436
+ <ui-select-item value="${option.value}">
437
+ ${option.label}
438
+ <ui-select-item-indicator>${createElement(Check, { "aria-hidden": "true" }).outerHTML}</ui-select-item-indicator>
439
+ </ui-select-item>
440
+ `
441
+ )
442
+ .join("")}
443
+ </ui-select-content>
444
+ </ui-select>
445
+ </div>
446
+ <ui-command>
447
+ <ui-command-input>
448
+ <input aria-label="Search commands" placeholder="Try “nf”, “zo in” or “smiley”" />
449
+ </ui-command-input>
450
+ <ui-command-empty>No results found.</ui-command-empty>
451
+ <ui-command-list>
452
+ ${commands
453
+ .map(
454
+ (command) =>
455
+ `<ui-command-item value="${command.label}"${command.keywords ? ` keywords="${command.keywords.join(",")}"` : ""}>${command.label}</ui-command-item>`
456
+ )
457
+ .join("")}
458
+ </ui-command-list>
459
+ </ui-command>
460
+ </div>
461
+ `
462
+ const command = root.querySelector("ui-command")!
463
+ root.querySelector("ui-select")!.addEventListener("valuechange", (event) => {
464
+ const mode = event.detail.value as Mode | null
465
+ if (mode) {
466
+ command.filter = mode === "words" ? words : mode
467
+ }
468
+ })
469
+ }
470
+
471
+ export { mount }
472
+ ```
473
+
474
+ Type “nf” with Fuzzy to find New file. Choose Words and type “zo in” for Zoom in, or type “smiley” to find Search emoji through a keyword.
475
+
476
+ ## Pages
477
+
478
+ Set an item’s `page` to the value of a `ui-command-page` to open it. An unnamed page holds the first set of commands. The `pages` property records the stack of pages that have been opened.
479
+
480
+ Backspace in an empty search goes back and restores the previous page’s query. Escape clears the query first, then goes back. A Go back command can call `pop()` on the element’s `api`.
481
+
482
+ ```ts title="pages.ts"
483
+ import "@ui-sdk/web/command"
484
+ import { ArrowLeft, createElement, Moon, Users } from "lucide"
485
+
486
+ const themes = [
487
+ { value: "light", label: "Light" },
488
+ { value: "dark", label: "Dark" },
489
+ { value: "system", label: "System" },
490
+ ]
491
+
492
+ const teams = [
493
+ { value: "design", label: "Design" },
494
+ { value: "engineering", label: "Engineering" },
495
+ { value: "marketing", label: "Marketing" },
496
+ ]
497
+
498
+ function mount(root: HTMLElement) {
499
+ root.innerHTML = `
500
+ <ui-command>
501
+ <div data-slot="row"></div>
502
+ <ui-command-input>
503
+ <input aria-label="Search commands" placeholder="What do you need?" />
504
+ </ui-command-input>
505
+ <ui-command-empty>No results found.</ui-command-empty>
506
+ <ui-command-list>
507
+ <ui-command-page>
508
+ <ui-command-group>
509
+ <ui-command-group-label>Workspace</ui-command-group-label>
510
+ <ui-command-item value="theme" page="theme">
511
+ <ui-command-item-icon>${createElement(Moon, { "aria-hidden": "true" }).outerHTML}</ui-command-item-icon>
512
+ Change theme…
513
+ </ui-command-item>
514
+ <ui-command-item value="teams" page="teams">
515
+ <ui-command-item-icon>${createElement(Users, { "aria-hidden": "true" }).outerHTML}</ui-command-item-icon>
516
+ Switch team…
517
+ </ui-command-item>
518
+ </ui-command-group>
519
+ </ui-command-page>
520
+ <ui-command-page value="theme">
521
+ ${themes
522
+ .map(
523
+ (theme) =>
524
+ `<ui-command-item value="${theme.value}">${theme.label}</ui-command-item>`
525
+ )
526
+ .join("")}
527
+ </ui-command-page>
528
+ <ui-command-page value="teams">
529
+ ${teams
530
+ .map(
531
+ (team) =>
532
+ `<ui-command-item value="${team.value}">${team.label}</ui-command-item>`
533
+ )
534
+ .join("")}
535
+ </ui-command-page>
536
+ </ui-command-list>
537
+ </ui-command>
538
+ `
539
+ const command = root.querySelector("ui-command") as HTMLElement & {
540
+ api: { pop: () => void }
541
+ }
542
+ const breadcrumb = command.querySelector("div")!
543
+ const input = command.querySelector("input")!
544
+ const list = command.querySelector("ui-command-list")!
545
+ const back = document.createElement("ui-command-item")
546
+ back.setAttribute("value", "back")
547
+ back.innerHTML = `<ui-command-item-icon mirror>${createElement(ArrowLeft, { "aria-hidden": "true" }).outerHTML}</ui-command-item-icon>Go back`
548
+ command.addEventListener("action", (event) => {
549
+ if ((event as CustomEvent<{ value: string }>).detail.value === "back") {
550
+ command.api.pop()
551
+ }
552
+ })
553
+ command.addEventListener("pageschange", (event) => {
554
+ const pages = (event as CustomEvent<{ value: string[] }>).detail.value
555
+ breadcrumb.innerHTML = pages
556
+ .map((page) => `<span data-slot="badge">${page}</span>`)
557
+ .join("")
558
+ input.placeholder = pages.length
559
+ ? "Search… (Backspace to go back)"
560
+ : "What do you need?"
561
+ if (!pages.length) {
562
+ back.remove()
563
+ } else if (!back.isConnected) {
564
+ list.append(back)
565
+ }
566
+ })
567
+ }
568
+
569
+ export { mount }
570
+ ```
571
+
572
+ Choose Change theme or Switch team. Use Go back, or press Backspace in an empty search field, to return.
573
+
574
+ ## Items as Data
575
+
576
+ Assign `items` as a property to provide commands, groups, separators, and pages as `CommandData`. A data command with its own `items` opens a page. Its shortcut still works when another page or filter hides it.
577
+
578
+ The element renders bare parts for you, following the current page and ranked results. For styled commands, a `<template>` inside it supplies the markup for the generated parts. The example handles groups and separators as well as commands. [Lists and Menus](../lists-and-menus.md) covers the shared data format.
579
+
580
+ Assign `emptyItems` alongside `items` to show suggested or recent commands while the first page's search is empty. Once someone types, the full collection is searched.
581
+
582
+ ```ts
583
+ const command = document.querySelector("ui-command")!
584
+ command.items = commands
585
+ command.emptyItems = [{ type: "group", label: "Suggested", items: recent }]
586
+ ```
587
+
588
+ ```ts title="data.ts"
589
+ import type { CommandData } from "@ui-sdk/core/command"
590
+ import "@ui-sdk/web/command"
591
+ import { log } from "./log"
592
+
593
+ const commands: CommandData = [
594
+ {
595
+ type: "group",
596
+ label: "Navigation",
597
+ items: [
598
+ { value: "home", label: "Go home", keywords: ["start"] },
599
+ { value: "inbox", label: "Open inbox", shortcut: "mod+i" },
600
+ ],
601
+ },
602
+ { type: "separator" },
603
+ {
604
+ type: "group",
605
+ label: "Preferences",
606
+ items: [
607
+ {
608
+ value: "theme",
609
+ label: "Change theme…",
610
+ items: [
611
+ { value: "light", label: "Light" },
612
+ { value: "dark", label: "Dark" },
613
+ { value: "system", label: "System" },
614
+ ],
615
+ },
616
+ {
617
+ value: "language",
618
+ label: "Change language…",
619
+ items: ["English", "Français", "Deutsch", "日本語"],
620
+ },
621
+ { value: "sign-out", label: "Sign out", shortcut: "mod+shift+q" },
622
+ ],
623
+ },
624
+ ]
625
+
626
+ function mount(root: HTMLElement) {
627
+ root.innerHTML = `
628
+ <div data-slot="stack">
629
+ <ui-command>
630
+ <ui-command-input>
631
+ <input aria-label="Search commands" placeholder="Type a command…" />
632
+ </ui-command-input>
633
+ <ui-command-empty>No results found.</ui-command-empty>
634
+ <template>
635
+ <ui-command-list>
636
+ <ui-command-group>
637
+ <ui-command-group-label></ui-command-group-label>
638
+ <ui-command-item>
639
+ <ui-command-shortcut></ui-command-shortcut>
640
+ </ui-command-item>
641
+ </ui-command-group>
642
+ <ui-command-separator></ui-command-separator>
643
+ </ui-command-list>
644
+ </template>
645
+ </ui-command>
646
+ </div>
647
+ `
648
+ const command = root.querySelector("ui-command")!
649
+ command.items = commands
650
+ command.addEventListener("action", (event) =>
651
+ log(root, `Ran ${event.detail.value}`)
652
+ )
653
+ }
654
+
655
+ export { mount }
656
+ ```
657
+
658
+ Choose Change theme to open its commands. Press Cmd+I / Ctrl+I to run Open inbox from any page; the console logs what ran.
659
+
660
+ ## Async Results
661
+
662
+ Use [async options](../utilities/async-options.md) to wait for typing to pause and discard stale results. Send query changes to `setQuery()`, assign the returned items to `items`, and set the `status` attribute. Set `filter="false"` to keep the server’s order.
663
+
664
+ `ui-command-status` describes loading and failures, and the list gets `aria-busy` while loading. The `loadmore` event can request another page when scrolling or highlighting reaches the last command. Without a status part, `announcement` controls the result-count message after typing pauses.
665
+
666
+ ```ts title="async.ts"
667
+ import { createAsyncOptions } from "@ui-sdk/core/async-options"
668
+ import "@ui-sdk/web/command"
669
+
670
+ function searchIssues(query: string, { signal }: { signal: AbortSignal }) {
671
+ const issues = [
672
+ "Fix login redirect",
673
+ "Dark mode flicker",
674
+ "Add billing page",
675
+ "Search is slow",
676
+ "Update dependencies",
677
+ "Crash on upload",
678
+ "Export to CSV",
679
+ "Keyboard shortcuts help",
680
+ ]
681
+ return new Promise<{ value: string; label: string }[]>((resolve, reject) => {
682
+ const timer = setTimeout(() => {
683
+ const needle = query.trim().toLowerCase()
684
+ resolve(
685
+ issues
686
+ .filter((issue) => issue.toLowerCase().includes(needle))
687
+ .map((issue) => ({
688
+ value: issue.toLowerCase().replaceAll(" ", "-"),
689
+ label: issue,
690
+ }))
691
+ )
692
+ }, 400)
693
+ signal.addEventListener("abort", () => {
694
+ clearTimeout(timer)
695
+ reject(new DOMException("Aborted", "AbortError"))
696
+ })
697
+ })
698
+ }
699
+
700
+ function mount(root: HTMLElement) {
701
+ root.innerHTML = `
702
+ <ui-command filter="false">
703
+ <ui-command-input>
704
+ <input aria-label="Search issues" placeholder="Search issues…" />
705
+ </ui-command-input>
706
+ <ui-command-status></ui-command-status>
707
+ <ui-command-empty>No issues match “<span></span>”.</ui-command-empty>
708
+ <ui-command-list></ui-command-list>
709
+ <template>
710
+ <ui-command-item>
711
+ </ui-command-item>
712
+ </template>
713
+ </ui-command>
714
+ `
715
+ const command = root.querySelector("ui-command")!
716
+ const status = root.querySelector("ui-command-status")!
717
+ const query = root.querySelector("ui-command-empty span")!
718
+ const issues = createAsyncOptions(searchIssues, {
719
+ debounce: 250,
720
+ immediate: true,
721
+ })
722
+ const update = () => {
723
+ const { items, status: loading } = issues.getState()
724
+ command.items = items
725
+ command.setAttribute("status", loading)
726
+ status.textContent =
727
+ loading === "loading"
728
+ ? "Searching…"
729
+ : `${items.length} ${items.length === 1 ? "issue" : "issues"}`
730
+ }
731
+ issues.subscribe(update)
732
+ update()
733
+ command.addEventListener("querychange", (event) => {
734
+ query.textContent = event.detail.value
735
+ issues.setQuery(event.detail.value)
736
+ })
737
+ command.addEventListener("loadmore", () => issues.loadMore())
738
+ }
739
+
740
+ export { mount }
741
+ ```
742
+
743
+ Type “login” and wait for matching issues. Replace the text to start a new search; only the latest results appear.
744
+
745
+ ## Pending Actions
746
+
747
+ Pass a promise to `event.detail.waitUntil()` in an `action` listener. The command gets `data-pending`, `aria-busy` and `aria-disabled` until it settles; further presses do not start another run. A rejection becomes the command’s `error` state, which clears when it runs again.
748
+
749
+ An item’s `select` event fires before `action`. Call `preventDefault()` on it to stop the action.
750
+
751
+ ```ts title="pending.ts"
752
+ import "@ui-sdk/web/command"
753
+ import { createElement, LoaderCircle } from "lucide"
754
+ import { log } from "./log"
755
+
756
+ const wait = (ms: number) =>
757
+ new Promise<void>((resolve) => setTimeout(resolve, ms))
758
+
759
+ function mount(root: HTMLElement) {
760
+ const spinner = createElement(LoaderCircle, {
761
+ "data-slot": "spinner",
762
+ "aria-hidden": "true",
763
+ }).outerHTML
764
+ root.innerHTML = `
765
+ <div data-slot="stack">
766
+ <ui-command>
767
+ <ui-command-input>
768
+ <input aria-label="Search actions" placeholder="Search actions…" />
769
+ </ui-command-input>
770
+ <ui-command-list>
771
+ <ui-command-item value="deploy" label="Deploy to production">
772
+ Deploy to production
773
+ ${spinner}
774
+ </ui-command-item>
775
+ <ui-command-item value="sync" label="Sync with server">
776
+ Sync with server
777
+ ${spinner}
778
+ <span data-slot="hint" data-error hidden>Failed, try again</span>
779
+ </ui-command-item>
780
+ </ui-command-list>
781
+ </ui-command>
782
+ </div>
783
+ `
784
+ const error = root.querySelector<HTMLElement>("[data-error]")!
785
+ root.querySelector("ui-command")!.addEventListener("action", (event) => {
786
+ const { value, waitUntil } = event.detail
787
+ if (value === "deploy") {
788
+ waitUntil(wait(1200).then(() => log(root, "Deployed to production")))
789
+ }
790
+ if (value === "sync") {
791
+ error.hidden = true
792
+ const sync = wait(600).then(() => {
793
+ log(root, "Couldn't sync: offline")
794
+ throw new Error("Offline")
795
+ })
796
+ waitUntil(sync)
797
+ sync.catch(() => (error.hidden = false))
798
+ }
799
+ })
800
+ }
801
+
802
+ export { mount }
803
+ ```
804
+
805
+ Run Deploy to production and try it again while it's pending. Sync with server fails and can be retried; the console logs each outcome.
806
+
807
+ ## Virtualized
808
+
809
+ Assign the full `items` collection so filtering and keyboard navigation include commands that are not mounted. Render only visible rows, giving each its `index` in the current results. The `valuechange` event includes that index so you can scroll a newly highlighted row into view.
810
+
811
+ ```ts title="virtualized.ts"
812
+ import { fuzzyScore } from "@ui-sdk/core/text-match"
813
+ import "@ui-sdk/web/command"
814
+
815
+ const commands = Array.from({ length: 10_000 }, (_, index) => ({
816
+ value: `command-${index + 1}`,
817
+ label: `Command ${index + 1}`,
818
+ }))
819
+
820
+ const row = 32
821
+
822
+ function rank(query: string) {
823
+ if (!query.trim()) {
824
+ return commands
825
+ }
826
+ return commands
827
+ .map((item) => ({ item, score: fuzzyScore(item.label, query) }))
828
+ .filter((entry) => entry.score > 0)
829
+ .sort((a, b) => b.score - a.score)
830
+ .map((entry) => entry.item)
831
+ }
832
+
833
+ function mount(root: HTMLElement) {
834
+ root.innerHTML = `
835
+ <ui-command>
836
+ <ui-command-input>
837
+ <input aria-label="Search 10,000 commands" placeholder="Search 10,000 commands…" />
838
+ </ui-command-input>
839
+ <ui-command-list>
840
+ <div aria-hidden="true"></div>
841
+ </ui-command-list>
842
+ </ui-command>
843
+ `
844
+ const command = root.querySelector("ui-command") as HTMLElement & {
845
+ items: typeof commands
846
+ }
847
+ const list = root.querySelector<HTMLElement>("ui-command-list")!
848
+ const spacer = list.querySelector<HTMLElement>("div")!
849
+
850
+ let matches = commands
851
+
852
+ const rendered = new Map<string, HTMLElement>()
853
+ const render = () => {
854
+ spacer.style.height = `${matches.length * row}px`
855
+ const start = Math.max(0, Math.floor(list.scrollTop / row) - 4)
856
+ const end = Math.min(
857
+ matches.length,
858
+ Math.ceil((list.scrollTop + list.clientHeight) / row) + 4
859
+ )
860
+ const visible = new Map(
861
+ matches
862
+ .slice(start, end)
863
+ .map((item, offset) => [item.value, start + offset])
864
+ )
865
+ for (const [value, el] of rendered) {
866
+ if (visible.has(value)) {
867
+ continue
868
+ }
869
+ el.remove()
870
+ rendered.delete(value)
871
+ }
872
+ for (const [value, index] of visible) {
873
+ const existing = rendered.get(value)
874
+ if (existing) {
875
+ existing.setAttribute("index", String(index))
876
+ existing.style.top = `${index * row}px`
877
+ continue
878
+ }
879
+ const item = matches[index]
880
+ list.insertAdjacentHTML(
881
+ "beforeend",
882
+ `<ui-command-item value="${item.value}" label="${item.label}" index="${index}" style="top: ${index * row}px">${item.label}</ui-command-item>`
883
+ )
884
+ rendered.set(value, list.lastElementChild as HTMLElement)
885
+ }
886
+ }
887
+ render()
888
+ command.items = commands
889
+ list.addEventListener("scroll", render)
890
+ command.addEventListener("querychange", (event) => {
891
+ matches = rank((event as CustomEvent<{ value: string }>).detail.value)
892
+ render()
893
+ })
894
+ command.addEventListener("valuechange", (event) => {
895
+ const { index } = (
896
+ event as CustomEvent<{ value: string | null; index: number }>
897
+ ).detail
898
+ if (index < 0) {
899
+ return
900
+ }
901
+ const top = index * row
902
+ if (top < list.scrollTop) {
903
+ list.scrollTop = top
904
+ } else if (top + row > list.scrollTop + list.clientHeight) {
905
+ list.scrollTop = top + row - list.clientHeight
906
+ }
907
+ render()
908
+ })
909
+ }
910
+
911
+ export { mount }
912
+ ```
913
+
914
+ Search 10,000 commands or move through them with the arrow keys. Only the rows near the viewport render.
915
+
916
+ ## Controlled
917
+
918
+ The highlighted command, search text, and page stack are separate:
919
+
920
+ | Value | Shape | Change Notification |
921
+ | ------- | ----------------------------------- | ------------------- |
922
+ | `value` | A command’s string value or `null`. | `valuechange` |
923
+ | `query` | The search text. | `querychange` |
924
+ | `pages` | An array of page values. | `pageschange` |
925
+
926
+ Read or write these properties on the element, and use `default-value`, `default-query`, and `default-pages` for starting state. Change events carry the new value in `event.detail.value` and the reason beside it; call `event.preventDefault()` to reject a change. `value` is the highlighted command, not a chosen one, and it changes as the highlight moves. `action` reports activation, so moving the highlight alone does not run a command. [State and Events](../state-and-events.md) covers the shared binding pattern.
927
+
928
+ ```ts title="controlled.ts"
929
+ import "@ui-sdk/web/command"
930
+ import { log } from "./log"
931
+
932
+ const themes = [
933
+ { value: "light", label: "Light" },
934
+ { value: "dark", label: "Dark" },
935
+ { value: "system", label: "System" },
936
+ ]
937
+
938
+ function mount(root: HTMLElement) {
939
+ root.innerHTML = `
940
+ <ui-command default-value="dark" default-pages="theme">
941
+ <ui-command-input>
942
+ <input aria-label="Search themes" placeholder="Search themes…" />
943
+ </ui-command-input>
944
+ <ui-command-list>
945
+ <ui-command-page>
946
+ <ui-command-item value="theme" page="theme">Change theme…</ui-command-item>
947
+ </ui-command-page>
948
+ <ui-command-page value="theme">
949
+ ${themes
950
+ .map(
951
+ (theme) =>
952
+ `<ui-command-item value="${theme.value}">${theme.label}</ui-command-item>`
953
+ )
954
+ .join("")}
955
+ </ui-command-page>
956
+ </ui-command-list>
957
+ </ui-command>
958
+ `
959
+ const command = root.querySelector("ui-command")!
960
+ command.addEventListener("valuechange", (event) =>
961
+ log(
962
+ root,
963
+ `Highlighted ${event.detail.value ?? "nothing"} (${event.detail.reason})`
964
+ )
965
+ )
966
+ command.addEventListener("querychange", (event) =>
967
+ log(root, `Query “${event.detail.value}” (${event.detail.reason})`)
968
+ )
969
+ command.addEventListener("pageschange", (event) =>
970
+ log(
971
+ root,
972
+ `Pages [${event.detail.value.join(", ")}] (${event.detail.reason})`
973
+ )
974
+ )
975
+ command.addEventListener("action", (event) =>
976
+ log(root, `Ran ${event.detail.value}`)
977
+ )
978
+ }
979
+
980
+ export { mount }
981
+ ```
982
+
983
+ Open Change theme, search and move the highlight. The console logs each highlight, query and page change with its reason.
984
+
985
+ ## Controller
986
+
987
+ Use the element’s `api` property. It can read and set the highlight, query, and page stack. Use `push()` and `pop()` to navigate pages, `run()` to run the highlighted command or a named one, and `focus()` to focus the search. See [Controllers](../controllers.md) for setup and lifecycle.
988
+
989
+ ```ts title="controller.ts"
990
+ import "@ui-sdk/web/command"
991
+ import { log } from "./log"
992
+
993
+ const themes = [
994
+ { value: "light", label: "Light" },
995
+ { value: "dark", label: "Dark" },
996
+ { value: "system", label: "System" },
997
+ ]
998
+
999
+ function mount(root: HTMLElement) {
1000
+ root.innerHTML = `
1001
+ <div data-slot="stack">
1002
+ <div data-slot="controls">
1003
+ <button type="button" data-action="push">Open Themes</button>
1004
+ <button type="button" data-action="pop">Back</button>
1005
+ <button type="button" data-action="highlight">Highlight Dark</button>
1006
+ <button type="button" data-action="search">Search “li”</button>
1007
+ <button type="button" data-action="run">Run Highlighted</button>
1008
+ <button type="button" data-action="focus">Focus</button>
1009
+ </div>
1010
+ <ui-command>
1011
+ <ui-command-input>
1012
+ <input aria-label="Search commands" />
1013
+ </ui-command-input>
1014
+ <ui-command-list>
1015
+ <ui-command-page>
1016
+ <ui-command-item value="theme" page="theme">Change theme…</ui-command-item>
1017
+ </ui-command-page>
1018
+ <ui-command-page value="theme">
1019
+ ${themes
1020
+ .map(
1021
+ (theme) =>
1022
+ `<ui-command-item value="${theme.value}">${theme.label}</ui-command-item>`
1023
+ )
1024
+ .join("")}
1025
+ </ui-command-page>
1026
+ </ui-command-list>
1027
+ </ui-command>
1028
+ </div>
1029
+ `
1030
+ const command = root.querySelector("ui-command")!
1031
+ const palette = command.api
1032
+ const actions: Record<string, () => void> = {
1033
+ push: () => palette.push("theme"),
1034
+ pop: () => palette.pop(),
1035
+ highlight: () => palette.setValue("dark"),
1036
+ search: () => palette.setQuery("li"),
1037
+ run: () => palette.run(),
1038
+ focus: () => palette.focus(),
1039
+ }
1040
+ for (const button of root.querySelectorAll<HTMLElement>("[data-action]")) {
1041
+ button.addEventListener("click", () => actions[button.dataset.action!]())
1042
+ }
1043
+ command.addEventListener("action", (event) =>
1044
+ log(root, `Ran ${event.detail.value}`)
1045
+ )
1046
+ }
1047
+
1048
+ export { mount }
1049
+ ```
1050
+
1051
+ Use the buttons to open pages, search, move the highlight and run it from outside. The console logs each command that runs.
1052
+
1053
+ ## Custom Rendering
1054
+
1055
+ Put an anchor inside a command and add `as-child` when it should navigate: the command binds the anchor. Enter follows the highlighted link; modified clicks keep their usual browser behavior.
1056
+
1057
+ ```ts title="custom-rendering.ts"
1058
+ import "@ui-sdk/web/command"
1059
+ import { CornerDownLeft, createElement } from "lucide"
1060
+
1061
+ const pages = ["Composition", "Installation", "Styling"]
1062
+
1063
+ function mount(root: HTMLElement) {
1064
+ root.innerHTML = `
1065
+ <ui-command>
1066
+ <ui-command-input>
1067
+ <input aria-label="Search docs" placeholder="Search docs…" />
1068
+ </ui-command-input>
1069
+ <ui-command-list>
1070
+ ${pages
1071
+ .map(
1072
+ (page) => `
1073
+ <ui-command-item value="${page}" label="${page}" as-child>
1074
+ <a href="#${page.toLowerCase()}">
1075
+ <ui-command-item-text>${page}</ui-command-item-text>
1076
+ ${createElement(CornerDownLeft, { "aria-hidden": "true" }).outerHTML}
1077
+ </a>
1078
+ </ui-command-item>
1079
+ `
1080
+ )
1081
+ .join("")}
1082
+ </ui-command-list>
1083
+ </ui-command>
1084
+ `
1085
+ }
1086
+
1087
+ export { mount }
1088
+ ```
1089
+
1090
+ Search for Installation and press Enter. The command follows the link to that section on this page.
1091
+
1092
+ ## Styling
1093
+
1094
+ Each element has a `data-slot`, such as `command-item`, and shows its state through the attributes listed under [Data Attributes](#data-attributes).
1095
+
1096
+ Use `data-highlighted` for the active command and `data-pending` for an action in progress. Give the list a height limit and `overflow-y: auto` for long lists; keyboard navigation scrolls the highlighted command into view. When mixing commands with and without icons, `data-has-icons` on the list and `data-has-icon` on each item let you reserve matching space with logical padding.
1097
+
1098
+ ## Data Attributes
1099
+
1100
+ ### `<ui-command>`
1101
+ `[data-slot="command"]`
1102
+
1103
+ - `data-loading`: Present while results load, with `status="loading"`.
1104
+
1105
+ ### `<ui-command-input>`
1106
+ ### `<ui-command-list>`
1107
+ `[data-slot="command-list"]`
1108
+
1109
+ - `data-has-icons`: Present while any command inside holds an icon part, so items without one can line up.
1110
+
1111
+ ### `<ui-command-item>`
1112
+ `[data-slot="command-item"]`
1113
+
1114
+ - `data-disabled`: Present when the command can't run. Arrow keys skip it.
1115
+ - `data-highlighted`: Present on the highlighted command, which Enter runs. Focus stays in the field.
1116
+ - `data-pending`: Present while the Promise the command's `onSelect` or `onAction` returned is running.
1117
+ - `data-has-icon`: Present on a command while it holds an icon part.
1118
+
1119
+ ### `<ui-command-item-text>`
1120
+ `[data-slot="command-item-text"]`
1121
+
1122
+ - `data-matched`: Present on a command's text while the search matched part of it, which is marked.
1123
+
1124
+ ### `<ui-command-item-icon>`
1125
+ `[data-slot="command-item-icon"]`
1126
+
1127
+ - `data-mirror`: Present on an icon that flips in right-to-left text, with `mirror`.
1128
+
1129
+ ### `<ui-command-empty>`
1130
+ `[data-slot="command-empty"]`
1131
+
1132
+ - `data-loading`: Present while results load, with `status="loading"`.
1133
+ - `data-empty`: Present while no command matches.
1134
+
1135
+ ### `<ui-command-status>`
1136
+ `[data-slot="command-status"]`
1137
+
1138
+ - `data-loading`: Present while results load, with `status="loading"`.
1139
+
1140
+ ## API Reference
1141
+
1142
+ Props are attributes in kebab case, like `default-pages` and `auto-highlight`: `"false"` is false. `filter` takes `fuzzy`, `contains`, `startsWith` or `false`. `items`, `emptyItems`, `announcement` and a `filter` function are properties. Callbacks are DOM events.
1143
+
1144
+ ### Command
1145
+
1146
+ - `value?` (`string | null`): The highlighted command's value. Pass it to control the highlight. `null` highlights nothing.
1147
+ - `defaultValue?` (`string | null`): The command highlighted at first, when uncontrolled. Without it, the first command is, with `autoHighlight`.
1148
+ - `valuechange event`: Runs when the highlight moves: arrow keys, the pointer, typing, a page change or a controller. `details.index` says where the command is, for virtualized lists.
1149
+ - `query?` (`string`): The search text, which filters the commands. Pass it to control it.
1150
+ - `defaultQuery?` (`string`): The search text at first, when uncontrolled.
1151
+ - `querychange event`: Runs when the search text wants to change: typing, opening a page, going back, or a controller.
1152
+ - `pages?` (`string[]`): The stack of open pages, from the first page opened to the current one. Pass it to control it.
1153
+ - `defaultPages?` (`string[]`): The pages open at first, when uncontrolled.
1154
+ - `pageschange event`: Runs when a page opens or Backspace or Escape goes back.
1155
+ - `action event`: Runs when a command runs, with its value: Enter, a click, or its shortcut. Return a Promise to mark the command pending until it settles: it gets `data-pending`, `aria-busy` and `aria-disabled`, and running it again waits. A rejection puts the reason in its `error` state until the next run.
1156
+ - `pendingAnnouncement?` (`string`): What screen readers hear once a command has been pending for a second, so a slow action doesn't pass in silence. Set it in the page's language. An empty string says nothing.
1157
+ - `items?` (`CommandData`): The commands as data. Renders them for you, ranked as the user types, with pages for commands that have `items`.
1158
+ - `emptyItems?` (`CommandData`): Commands shown instead of `items` on the first page while the search is empty, like recent or suggested ones. Groups work, like `{ type: "group", label: "Suggestions", items }`. Needs `items`.
1159
+ - `filter?` (`SearchFilter<string>`): How typing narrows the list: `"fuzzy"` keeps commands with the text's letters in order, best matches first; `"contains"` and `"startsWith"` match the text itself. A function returns a score (0 hides) or a boolean. `false` keeps every command, for results a server already filtered. Composed commands keep their order, and data commands are ranked by score.
1160
+ - `autoHighlight?` (`boolean`): Whether the first command is highlighted while nothing else is, and the best match as the user types, so Enter runs it.
1161
+ - `loop?` (`boolean`): Whether arrow keys wrap from the last command to the first.
1162
+ - `status?` (`AsyncOptionsStatus`): Whether results are loading or failed, for the empty and status parts. Sets `aria-busy` on the list while loading.
1163
+ - `loadmore event`: Runs when the highlight or scrolling reaches the last command, so the next page can load, like `createAsyncOptions`'s `loadMore`. Not again for the same commands, unless the last load failed.
1164
+ - `announcement?` (`((change: ListAnnouncement) => string | null | undefined)`): What screen readers hear after typing pauses, when no `CommandStatus` is rendered. Return null for nothing.
1165
+ - `controller?` (`object`): Reads and drives the list from anywhere. Create one with `createCommandController()`.
1166
+ - `debug?` (`boolean`): Logs every state change with its reason to the console, in development builds.
1167
+
1168
+ ### CommandInput
1169
+
1170
+ The search field. `<ui-command-input>` wraps a native `input`, which gets the combobox role.
1171
+
1172
+ ### CommandStatus
1173
+
1174
+ Describes loading and failures. `<ui-command-status>` has the status role.
1175
+
1176
+ ### CommandEmpty
1177
+
1178
+ Shows while no command matches. `<ui-command-empty>` stays hidden while there are matches.
1179
+
1180
+ ### CommandList
1181
+
1182
+ Holds the commands. `<ui-command-list>` has the listbox role and is always shown.
1183
+
1184
+ ### CommandPage
1185
+
1186
+ - `value?` (`string`): The page's name, which a command's `page` opens. Leave it out for the first page.
1187
+
1188
+ ### CommandGroup
1189
+
1190
+ Groups commands under a label. `<ui-command-group>` has the group role.
1191
+
1192
+ ### CommandGroupLabel
1193
+
1194
+ Names its group. `<ui-command-group-label>` labels the group.
1195
+
1196
+ ### CommandItem
1197
+
1198
+ - `value?` (`string`): Passed to `action` and `valuechange`, and identifies the command. Without it, one is generated.
1199
+ - `label?` (`string`): The text the search matches, when the content isn't plain text. Not the accessible name: use `aria-label` for that.
1200
+ - `keywords?` (`string[]`): More words the search matches.
1201
+ - `disabled?` (`boolean`): Keeps the command from running. Arrow keys and the pointer skip it. Sets `data-disabled` and `aria-disabled`.
1202
+ - `shortcut?` (`string`): A keyboard shortcut that runs the command while it's in the page, like `"mod+p"`. Sets `aria-keyshortcuts`, and a `CommandShortcut` inside shows it.
1203
+ - `page?` (`string`): The page choosing this command opens, by the `value` of a `CommandPage`.
1204
+ - `index?` (`number`): The command's position among all visible commands, for virtualized lists that render only some. Sets `aria-posinset` and `aria-setsize`.
1205
+ - `select event`: Runs when the command runs, before `action`, with the click or key press that ran it, or a new `select` Event for a shortcut or a controller's `run()`. Call `event.preventDefault()` to skip `action` and the page. Return a Promise to mark the command pending until it settles, like `action`.
1206
+
1207
+ ### CommandItemIcon
1208
+
1209
+ - `mirror?` (`boolean`): Flips the icon horizontally in right-to-left text, for icons that point a way, like arrows and chevrons. Icons that picture a thing, like a clock or a check, stay as they are.
1210
+
1211
+ ### CommandItemText
1212
+
1213
+ Shows its command's label, and marks what matched the search in `<mark>`. `<ui-command-item-text>` holds text only.
1214
+
1215
+ ### CommandShortcut
1216
+
1217
+ - `shortcut?` (`string`): The keys to show, like `"mod+p"`. Inside a command, its `shortcut`.
1218
+
1219
+ ### CommandSeparator
1220
+
1221
+ Separates commands or groups. `<ui-command-separator>` has the separator role.
1222
+
1223
+ ### Items as Data
1224
+
1225
+ Each command in `items`. Groups are `{ type: "group", label, items }` and separators `{ type: "separator" }`.
1226
+
1227
+ - `value` (`string`): Identifies the item, and is what choosing it reports. A string, or any value with `itemToValue`.
1228
+ - `label` (`string`): The text shown and matched by typeahead and filtering. A select's trigger shows it once chosen.
1229
+ - `keywords?` (`string[]`): More words filtering matches, like `["team"]` for a plan called Pro.
1230
+ - `disabled?` (`boolean`): Keeps the item from being chosen. The keyboard skips it, like in a native select.
1231
+ - `shortcut?` (`string`): A keyboard shortcut that runs the command, like `"mod+p"`, while the list is in the page, whatever page it's on. Shows `⌘P` on Apple platforms and `Ctrl+P` elsewhere.
1232
+ - `items?` (`CommandData`): Commands on a page of their own. Choosing this command opens the page, and Backspace in the empty field goes back.
1233
+
1234
+ ### State
1235
+
1236
+ The same state shows as data attributes on each element.
1237
+
1238
+ `Command`:
1239
+
1240
+ - `page` (`string | null`): The current page, or `null` on the first page.
1241
+ - `loading` (`boolean`): Whether results are loading.
1242
+
1243
+ `CommandInput`:
1244
+
1245
+ - `page` (`string | null`): The current page, or `null` on the first page.
1246
+
1247
+ `CommandList`:
1248
+
1249
+ - `status` (`AsyncOptionsStatus`): Whether results are loading or failed.
1250
+ - `items` (`CommandData`): The visible data commands, ranked, for rendering a virtualized list yourself.
1251
+
1252
+ `CommandItem`:
1253
+
1254
+ - `highlighted` (`boolean`): Whether the command is highlighted, by the keyboard, the pointer or typing.
1255
+ - `disabled` (`boolean`): Whether the command can't run.
1256
+ - `pending` (`boolean`): Whether its action's Promise is running.
1257
+ - `error` (`unknown`): Why its last action failed, until it runs again.
1258
+
1259
+ `CommandEmpty`:
1260
+
1261
+ - `loading` (`boolean`): Whether results are loading.
1262
+ - `empty` (`boolean`): Whether no item matches.
1263
+ - `query` (`string`): The text the list is filtered by.
1264
+
1265
+ `CommandStatus`:
1266
+
1267
+ - `status` (`"idle" | "loading" | "error"`): Whether results are loading or failed.
1268
+ - `loading` (`boolean`): Whether results are loading.
1269
+ - `count` (`number`): How many items are visible.
1270
+
1271
+ `CommandShortcut`:
1272
+
1273
+ - `text` (`string`): The shortcut formatted for this platform: `⌘P` on Apple platforms and `Ctrl+P` elsewhere. Empty without one.
1274
+
1275
+ `CommandItemText`, which takes no props of its own:
1276
+
1277
+ - `segments` (`MatchSegment[]`): The text in pieces, each marked when it matched. Joined, they're the whole text.
1278
+ - `matched` (`boolean`): Whether any piece matched.
1279
+
1280
+ `CommandItemIcon`:
1281
+
1282
+ - `mirror` (`boolean`): Whether it flips in right-to-left text.
1283
+
1284
+ ### Reasons
1285
+
1286
+ `event.detail.reason` says why the highlighted command changed:
1287
+
1288
+ - `list-navigation` (`KeyboardEvent`): Arrow, Home or End keys moved the selection, typing picked an item, or Ctrl or ⌘ with A selected every item of a listbox.
1289
+ - `item-hover` (`PointerEvent`): The pointer moved onto an item, which highlighted it, like in a command list.
1290
+ - `input-change` (`Event`): Typing, pasting or dropping changed a text field's value; in a combobox it can also open or close it, or Enter keeps the typed text as the value.
1291
+ - `item-press` (`MouseEvent | KeyboardEvent`): A member of a collection was chosen: a menu item, a tab, a radio or a checkbox item.
1292
+ - `shortcut` (`KeyboardEvent`): A keyboard shortcut, like a trigger's `shortcut`.
1293
+ - `back` (`Event`): Going back: the Android back button or gesture, or Backspace in an empty command input, which returns to the previous page.
1294
+ - `escape-key` (`KeyboardEvent`): Escape, or a submenu's close key (ArrowLeft in left-to-right layouts).
1295
+ - `item-removed` (`none`): The selected item left the page, and another was picked.
1296
+ - `imperative` (`none`): A controller or `api` call, or a property set on a web component.
1297
+
1298
+ Why the search text changed:
1299
+
1300
+ - `input-change` (`Event`): Typing, pasting or dropping changed a text field's value; in a combobox it can also open or close it, or Enter keeps the typed text as the value.
1301
+ - `item-press` (`MouseEvent | KeyboardEvent`): A member of a collection was chosen: a menu item, a tab, a radio or a checkbox item.
1302
+ - `shortcut` (`KeyboardEvent`): A keyboard shortcut, like a trigger's `shortcut`.
1303
+ - `back` (`Event`): Going back: the Android back button or gesture, or Backspace in an empty command input, which returns to the previous page.
1304
+ - `escape-key` (`KeyboardEvent`): Escape, or a submenu's close key (ArrowLeft in left-to-right layouts).
1305
+ - `imperative` (`none`): A controller or `api` call, or a property set on a web component.
1306
+
1307
+ And why the stack of pages changed:
1308
+
1309
+ - `item-press` (`MouseEvent | KeyboardEvent`): A member of a collection was chosen: a menu item, a tab, a radio or a checkbox item.
1310
+ - `shortcut` (`KeyboardEvent`): A keyboard shortcut, like a trigger's `shortcut`.
1311
+ - `back` (`Event`): Going back: the Android back button or gesture, or Backspace in an empty command input, which returns to the previous page.
1312
+ - `escape-key` (`KeyboardEvent`): Escape, or a submenu's close key (ArrowLeft in left-to-right layouts).
1313
+ - `imperative` (`none`): A controller or `api` call, or a property set on a web component.
1314
+
1315
+ ### Controller
1316
+
1317
+ The element's `api` property has the same methods.
1318
+
1319
+ - `getValue()` (`() => string | null`): The highlighted command's value, or `null`.
1320
+ - `setValue(value, options?)` (`(value: string | null, options?: CommandChangeOptions<CommandValueChangeReason> | undefined) => boolean`): Highlights a command, and scrolls it into view. Returns false when the change was canceled or nothing changed.
1321
+ - `getQuery()` (`() => string`): The search text.
1322
+ - `setQuery(query, options?)` (`(query: string, options?: CommandChangeOptions<CommandQueryChangeReason> | undefined) => boolean`): Changes the search text, which filters the commands. Returns false when the change was canceled or nothing changed.
1323
+ - `getPages()` (`() => string[]`): The stack of open pages, from the first page opened to the current one. Empty on the first page.
1324
+ - `setPages(pages, options?)` (`(pages: string[], options?: CommandChangeOptions<CommandPagesChangeReason> | undefined) => boolean`): Replaces the stack of pages. Returns false when the change was canceled or nothing changed.
1325
+ - `push(page, options?)` (`(page: string, options?: CommandChangeOptions<CommandPagesChangeReason> | undefined) => boolean`): Opens a page on top of the current one, by the `value` of a `CommandPage` or a data command. Returns false when the change was canceled or nothing changed.
1326
+ - `pop(options?)` (`(options?: CommandChangeOptions<CommandPagesChangeReason> | undefined) => boolean`): Goes back to the previous page, and puts back the search text typed there. Returns false when the change was canceled or nothing changed.
1327
+ - `run(value?)` (`(value?: string | undefined) => void`): Runs a command, as Enter would: the highlighted one, or the one with this value.
1328
+ - `focus()` (`() => void`): Moves focus to the search field.
1329
+
1330
+ ### Events
1331
+
1332
+ Events fire on their own element and don't bubble, with the new state in `event.detail.value` and the `reason` and `event` beside it. Calling `preventDefault()` on a change event cancels it.
1333
+
1334
+ | Member | On | Description |
1335
+ | ------------------- | ----------------- | --------------------------------------------------------------------- |
1336
+ | `value` property | `ui-command` | The highlighted command. Setting it highlights, as a controller would |
1337
+ | `query` property | `ui-command` | The search text |
1338
+ | `pages` property | `ui-command` | The stack of pages |
1339
+ | `api` property | `ui-command` | The [controller](#controller-1) |
1340
+ | `valuechange` event | `ui-command` | `detail: { value, reason, event, source, index }` |
1341
+ | `querychange` event | `ui-command` | `detail: { value: query, reason, event, source }` |
1342
+ | `pageschange` event | `ui-command` | `detail: { value: pages, reason, event, source }` |
1343
+ | `action` event | `ui-command` | `detail: { value, waitUntil(promise) }`, when a command runs |
1344
+ | `loadmore` event | `ui-command` | When the last command is reached |
1345
+ | `select` event | `ui-command-item` | Before `action`. `preventDefault()` skips the `action` event |
1346
+
1347
+ ## Accessibility
1348
+
1349
+ The command list follows the [WAI-ARIA combobox pattern](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/) with a listbox that's always shown. Focus stays in the input, which points to the highlighted command with `aria-activedescendant`. Every line below is an automated test.
1350
+
1351
+ ### Keyboard
1352
+
1353
+ | Key | Does |
1354
+ | ------------------ | --------------------------------------------------------------------- |
1355
+ | Typing | Filters the commands and highlights the best match |
1356
+ | ArrowDown, ArrowUp | Moves the highlight. Wraps unless `loop="false"` |
1357
+ | Enter | Runs the highlighted command, or follows it when it renders as a link |
1358
+ | Escape | Clears the search, then goes back a page |
1359
+ | Backspace | In an empty search, goes back a page and restores its query |
1360
+ | An item's shortcut | Runs it while the list is mounted, even when hidden by the search |
1361
+
1362
+ The first available command is highlighted by default. Set `auto-highlight="false"` to wait for an arrow key or pointer movement.
1363
+
1364
+ ### Tested Behavior
1365
+
1366
+ **Field**
1367
+
1368
+ - Is a combobox that controls an always-expanded listbox.
1369
+ - The first command is highlighted from the start.
1370
+
1371
+ **Filtering**
1372
+
1373
+ - Typing keeps the commands that match, ignoring case and accents.
1374
+ - Groups without a match hide, and the rest keep their labels.
1375
+ - The first match is highlighted as the text changes, so Enter runs it.
1376
+ - Deleting text brings back the commands the shorter text matches.
1377
+ - Commands without a value that mount while the field has text show when they match.
1378
+ - Going back a page reports the new highlight as back, not as a removal.
1379
+ - Nothing matching shows the empty message.
1380
+
1381
+ **Keyboard**
1382
+
1383
+ - Arrow keys move the highlight while focus stays in the field.
1384
+ - Home and End stay in the field for the caret.
1385
+ - The highlighted option has the id aria-activedescendant names.
1386
+ - Enter runs the highlighted command.
1387
+
1388
+ **Pointer**
1389
+
1390
+ - Clicking a command runs it.
1391
+ - A disabled command doesn't run.
1392
+
1393
+ **AutoHighlight**
1394
+
1395
+ - Without autoHighlight, nothing is highlighted until an arrow key.
1396
+
1397
+ Runs in React, Vue and web components.
1398
+
1399
+ Long lists stay fast and announce their size:
1400
+
1401
+ **Virtualized**
1402
+
1403
+ - Renders only the rows in view, each with its place in the whole list.
1404
+ - Arrow keys reach commands that weren't rendered, and the active descendant follows.
1405
+ - Typing ranks every command, rendered or not, best match first.
1406
+
1407
+ Runs in React.
1408
+
1409
+ Also tested:
1410
+
1411
+ **Enhancements**
1412
+
1413
+ - The highlighted command is the selected option, as the APG's list autocomplete marks it.
1414
+ - Keywords match as well as labels.
1415
+ - Fuzzy matching finds the letters in order, across words.
1416
+ - Arrow keys skip disabled commands.
1417
+ - A command's shortcut runs it and sets aria-keyshortcuts.
1418
+ - A shortcut runs its command while the search hides it.
1419
+ - A command is pending while its action's Promise runs, and runs only once.
1420
+ - A command opens its page, and Backspace in the empty field goes back with the text.
1421
+ - Escape clears the text, then goes back a page.
1422
+ - Results that still hold the highlighted command keep the highlight.
1423
+ - The list is busy while results load.
1424
+
1425
+ Runs in React, Vue and web components.
1426
+
1427
+ Screen readers hear the same thing in each tested framework, recorded by a virtual screen reader:
1428
+
1429
+ - Announcements while searching with a keyboard.
1430
+
1431
+ Runs in React, Vue and web components.