@zazz-ui/core 0.4.0 → 0.5.0

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 (331) hide show
  1. package/AUTHORING.md +158 -0
  2. package/CHANGELOG.md +341 -0
  3. package/README.md +55 -23
  4. package/dist/scroll-state-C8mA5gq6.js +1 -0
  5. package/dist/sri.json +124 -72
  6. package/dist/zazz.css +1 -1
  7. package/dist/zazz.js +1 -1
  8. package/editor/zazz.css-data.json +116794 -0
  9. package/editor/zazz.html-data.json +1683 -0
  10. package/editor/zazz.language-data.json +5001 -0
  11. package/editor/zazz.lint-data.json +152 -0
  12. package/package.json +12 -5
  13. package/src/base/_breakpoints.css +12 -0
  14. package/src/base/_layers.css +8 -9
  15. package/src/base/_properties-2xl.css +171 -0
  16. package/src/base/_properties-active.css +107 -0
  17. package/src/base/_properties-checked.css +107 -0
  18. package/src/base/_properties-current.css +107 -0
  19. package/src/base/_properties-disabled.css +107 -0
  20. package/src/base/_properties-focus-visible.css +107 -0
  21. package/src/base/_properties-focus-within.css +107 -0
  22. package/src/base/_properties-hover.css +107 -0
  23. package/src/base/_properties-lg.css +171 -0
  24. package/src/base/_properties-md.css +171 -0
  25. package/src/base/_properties-open.css +107 -0
  26. package/src/base/_properties-sm.css +171 -0
  27. package/src/base/_properties-starting.css +55 -0
  28. package/src/base/_properties-stuck.css +55 -0
  29. package/src/base/_properties-xl.css +171 -0
  30. package/src/base/_properties.css +555 -0
  31. package/src/base/_reset.css +67 -75
  32. package/src/base/_switches.css +145 -0
  33. package/src/base/_typography.css +437 -370
  34. package/src/base/_utilities-box.css +142 -0
  35. package/src/base/_utilities-color.css +290 -0
  36. package/src/base/_utilities-effects.css +235 -0
  37. package/src/base/_utilities-flow.css +312 -0
  38. package/src/base/_utilities-grid.css +143 -0
  39. package/src/base/_utilities-margin.css +376 -0
  40. package/src/base/_utilities-pseudo.css +426 -0
  41. package/src/base/_utilities-sizing.css +259 -0
  42. package/src/base/_utilities-spacing.css +190 -0
  43. package/src/base/_utilities-tier-2xl.css +93 -0
  44. package/src/base/_utilities-tier-active.css +61 -0
  45. package/src/base/_utilities-tier-checked.css +61 -0
  46. package/src/base/_utilities-tier-current.css +61 -0
  47. package/src/base/_utilities-tier-disabled.css +61 -0
  48. package/src/base/_utilities-tier-focus-visible.css +61 -0
  49. package/src/base/_utilities-tier-focus-within.css +61 -0
  50. package/src/base/_utilities-tier-hover.css +63 -0
  51. package/src/base/_utilities-tier-lg.css +93 -0
  52. package/src/base/_utilities-tier-md.css +93 -0
  53. package/src/base/_utilities-tier-open.css +61 -0
  54. package/src/base/_utilities-tier-sm.css +93 -0
  55. package/src/base/_utilities-tier-starting.css +35 -0
  56. package/src/base/_utilities-tier-stuck.css +114 -0
  57. package/src/base/_utilities-tier-xl.css +93 -0
  58. package/src/base/_utilities-typography.css +141 -0
  59. package/src/base/_variables.css +323 -372
  60. package/src/base/_view-transitions.css +10 -12
  61. package/src/base/command-score.d.ts.map +1 -1
  62. package/src/base/command-score.js +1 -2
  63. package/src/base/command-score.ts +1 -2
  64. package/src/base/dialog-lifecycle.js +1 -1
  65. package/src/base/dialog-lifecycle.ts +1 -1
  66. package/src/base/embla.d.ts +6 -7
  67. package/src/base/embla.d.ts.map +1 -1
  68. package/src/base/embla.js +89 -55
  69. package/src/base/embla.ts +89 -55
  70. package/src/base/hotkeys.d.ts +0 -5
  71. package/src/base/hotkeys.d.ts.map +1 -1
  72. package/src/base/hotkeys.ts +0 -5
  73. package/src/base/navigation.d.ts +12 -1
  74. package/src/base/navigation.d.ts.map +1 -1
  75. package/src/base/navigation.js +229 -86
  76. package/src/base/navigation.ts +224 -92
  77. package/src/base/reveal.js +14 -14
  78. package/src/base/reveal.ts +14 -14
  79. package/src/base/scroll-state.d.ts +21 -0
  80. package/src/base/scroll-state.d.ts.map +1 -0
  81. package/src/base/scroll-state.js +177 -0
  82. package/src/base/scroll-state.ts +188 -0
  83. package/src/base/signals.d.ts +1 -2
  84. package/src/base/signals.d.ts.map +1 -1
  85. package/src/base/signals.js +4 -6
  86. package/src/base/signals.ts +4 -6
  87. package/src/base/style-format.d.ts +33 -0
  88. package/src/base/style-format.d.ts.map +1 -0
  89. package/src/base/style-format.js +160 -0
  90. package/src/base/style-format.ts +180 -0
  91. package/src/base/typeahead.d.ts +19 -4
  92. package/src/base/typeahead.d.ts.map +1 -1
  93. package/src/base/typeahead.js +68 -21
  94. package/src/base/typeahead.ts +73 -23
  95. package/src/base/utilities.d.ts +188 -0
  96. package/src/base/utilities.d.ts.map +1 -0
  97. package/src/base/utilities.js +750 -0
  98. package/src/base/utilities.ts +865 -0
  99. package/src/base/utils.d.ts +3 -7
  100. package/src/base/utils.d.ts.map +1 -1
  101. package/src/base/utils.js +4 -8
  102. package/src/base/utils.ts +4 -8
  103. package/src/base/zazz-element.d.ts +14 -8
  104. package/src/base/zazz-element.d.ts.map +1 -1
  105. package/src/base/zazz-element.js +14 -8
  106. package/src/base/zazz-element.ts +15 -8
  107. package/src/globals.d.ts +1 -1
  108. package/src/head.d.ts +50 -4
  109. package/src/head.d.ts.map +1 -1
  110. package/src/head.js +119 -38
  111. package/src/head.ts +172 -41
  112. package/src/index.css +57 -14
  113. package/src/index.js +5 -0
  114. package/src/index.ts +6 -0
  115. package/src/manifest.d.ts +36 -5
  116. package/src/manifest.d.ts.map +1 -1
  117. package/src/manifest.js +150 -6
  118. package/src/manifest.ts +167 -9
  119. package/src/primitives/accordion/accordion.css +18 -17
  120. package/src/primitives/accordion/accordion.html +42 -9
  121. package/src/primitives/alert-dialog/alert-dialog.css +13 -13
  122. package/src/primitives/alert-dialog/alert-dialog.html +26 -12
  123. package/src/primitives/autocomplete/autocomplete-groups.html +64 -33
  124. package/src/primitives/autocomplete/autocomplete.css +45 -43
  125. package/src/primitives/autocomplete/autocomplete.d.ts +6 -5
  126. package/src/primitives/autocomplete/autocomplete.d.ts.map +1 -1
  127. package/src/primitives/autocomplete/autocomplete.html +38 -26
  128. package/src/primitives/autocomplete/autocomplete.js +6 -5
  129. package/src/primitives/autocomplete/autocomplete.ts +6 -5
  130. package/src/primitives/avatar/avatar.html +110 -15
  131. package/src/primitives/badge/badge-icon.html +22 -8
  132. package/src/primitives/badge/badge.css +401 -128
  133. package/src/primitives/badge/badge.html +12 -6
  134. package/src/primitives/breadcrumbs/breadcrumbs.html +25 -5
  135. package/src/primitives/button/button-icon-only.html +17 -11
  136. package/src/primitives/button/button-icon.html +9 -3
  137. package/src/primitives/button/button.css +408 -164
  138. package/src/primitives/button/button.html +14 -7
  139. package/src/primitives/button-group/button-group-vertical.html +5 -5
  140. package/src/primitives/button-group/button-group.css +53 -25
  141. package/src/primitives/button-group/button-group.html +18 -12
  142. package/src/primitives/callout/callout.css +114 -0
  143. package/src/primitives/callout/callout.html +188 -0
  144. package/src/primitives/card/card-subgrid.html +249 -34
  145. package/src/primitives/card/card.css +125 -0
  146. package/src/primitives/card/card.html +141 -20
  147. package/src/primitives/carousel/carousel.css +30 -20
  148. package/src/primitives/carousel/carousel.d.ts +7 -10
  149. package/src/primitives/carousel/carousel.d.ts.map +1 -1
  150. package/src/primitives/carousel/carousel.html +420 -84
  151. package/src/primitives/carousel/carousel.js +1 -1
  152. package/src/primitives/carousel/carousel.ts +8 -11
  153. package/src/primitives/checkbox/checkbox-tasklist.html +6 -6
  154. package/src/primitives/checkbox/checkbox.css +98 -40
  155. package/src/primitives/checkbox/checkbox.d.ts.map +1 -1
  156. package/src/primitives/checkbox/checkbox.html +13 -8
  157. package/src/primitives/checkbox/checkbox.js +7 -9
  158. package/src/primitives/checkbox/checkbox.ts +7 -15
  159. package/src/primitives/combobox/combobox-multiselect.html +53 -33
  160. package/src/primitives/combobox/combobox.css +147 -126
  161. package/src/primitives/combobox/combobox.d.ts +12 -11
  162. package/src/primitives/combobox/combobox.d.ts.map +1 -1
  163. package/src/primitives/combobox/combobox.html +48 -28
  164. package/src/primitives/combobox/combobox.js +46 -51
  165. package/src/primitives/combobox/combobox.ts +48 -55
  166. package/src/primitives/command/command-actions.d.ts +2 -3
  167. package/src/primitives/command/command-actions.d.ts.map +1 -1
  168. package/src/primitives/command/command-actions.html +48 -33
  169. package/src/primitives/command/command-actions.js +12 -10
  170. package/src/primitives/command/command-actions.ts +12 -13
  171. package/src/primitives/command/command-dialog.html +49 -25
  172. package/src/primitives/command/command.css +52 -42
  173. package/src/primitives/command/command.d.ts +10 -7
  174. package/src/primitives/command/command.d.ts.map +1 -1
  175. package/src/primitives/command/command.html +95 -46
  176. package/src/primitives/command/command.js +30 -13
  177. package/src/primitives/command/command.ts +30 -12
  178. package/src/primitives/debug/audit-core.d.ts +64 -0
  179. package/src/primitives/debug/audit-core.d.ts.map +1 -0
  180. package/src/primitives/debug/audit-core.js +356 -0
  181. package/src/primitives/debug/audit-core.ts +535 -0
  182. package/src/primitives/debug/debug.d.ts +50 -0
  183. package/src/primitives/debug/debug.d.ts.map +1 -0
  184. package/src/primitives/debug/debug.js +168 -0
  185. package/src/primitives/debug/debug.ts +211 -0
  186. package/src/primitives/dialog/dialog-with-form.html +67 -45
  187. package/src/primitives/dialog/dialog.css +87 -61
  188. package/src/primitives/dialog/dialog.html +25 -17
  189. package/src/primitives/fields/fields.css +108 -134
  190. package/src/primitives/fields/fields.html +39 -0
  191. package/src/primitives/input/input-icon-leading.html +3 -3
  192. package/src/primitives/input/input-icon-trailing.html +3 -3
  193. package/src/primitives/input/input.css +87 -49
  194. package/src/primitives/input/input.html +15 -15
  195. package/src/primitives/input-group/input-group-password-group.html +15 -15
  196. package/src/primitives/input-group/input-group.css +118 -75
  197. package/src/primitives/input-group/input-group.html +42 -30
  198. package/src/primitives/kbd/kbd-group.html +15 -2
  199. package/src/primitives/kbd/kbd.css +44 -31
  200. package/src/primitives/kbd/kbd.html +7 -1
  201. package/src/primitives/layout/layout.css +159 -0
  202. package/src/primitives/layout/layout.html +35 -0
  203. package/src/primitives/lightbox/lightbox.css +178 -105
  204. package/src/primitives/lightbox/lightbox.d.ts.map +1 -1
  205. package/src/primitives/lightbox/lightbox.html +138 -166
  206. package/src/primitives/lightbox/lightbox.js +10 -13
  207. package/src/primitives/lightbox/lightbox.ts +12 -13
  208. package/src/primitives/menu/menu-interest.html +60 -18
  209. package/src/primitives/menu/menu.css +22 -17
  210. package/src/primitives/menu/menu.d.ts +5 -5
  211. package/src/primitives/menu/menu.html +195 -40
  212. package/src/primitives/menu/menu.js +8 -8
  213. package/src/primitives/menu/menu.ts +8 -8
  214. package/src/primitives/menubar/menubar-help-search.html +78 -32
  215. package/src/primitives/menubar/menubar.html +166 -38
  216. package/src/primitives/meter/meter.css +41 -38
  217. package/src/primitives/meter/meter.html +44 -9
  218. package/src/primitives/mobile-menu/mobile-menu.css +47 -40
  219. package/src/primitives/mobile-menu/mobile-menu.html +1460 -179
  220. package/src/primitives/navigation-menu/navigation-menu-featured.html +155 -33
  221. package/src/primitives/navigation-menu/navigation-menu-icon-grid.html +222 -47
  222. package/src/primitives/navigation-menu/navigation-menu-interest.html +130 -38
  223. package/src/primitives/navigation-menu/navigation-menu-megamenu.html +402 -72
  224. package/src/primitives/navigation-menu/navigation-menu-simple.html +90 -40
  225. package/src/primitives/navigation-menu/navigation-menu.css +104 -106
  226. package/src/primitives/navigation-menu/navigation-menu.html +554 -158
  227. package/src/primitives/otp/otp.css +43 -44
  228. package/src/primitives/otp/otp.d.ts +4 -5
  229. package/src/primitives/otp/otp.d.ts.map +1 -1
  230. package/src/primitives/otp/otp.html +7 -6
  231. package/src/primitives/otp/otp.js +13 -18
  232. package/src/primitives/otp/otp.ts +12 -19
  233. package/src/primitives/password-group/password-group.css +132 -107
  234. package/src/primitives/password-group/password-group.d.ts.map +1 -1
  235. package/src/primitives/password-group/password-group.html +23 -16
  236. package/src/primitives/password-group/password-group.js +11 -12
  237. package/src/primitives/password-group/password-group.ts +11 -12
  238. package/src/primitives/popover/popover.css +89 -95
  239. package/src/primitives/popover/popover.html +18 -0
  240. package/src/primitives/progress/progress-indeterminate.html +1 -1
  241. package/src/primitives/progress/progress.css +34 -35
  242. package/src/primitives/progress/progress.html +18 -4
  243. package/src/primitives/prose/prose.html +19 -12
  244. package/src/primitives/radio/radio.css +83 -46
  245. package/src/primitives/radio/radio.html +16 -11
  246. package/src/primitives/reveal/reveal.css +37 -46
  247. package/src/primitives/reveal/reveal.html +15 -0
  248. package/src/primitives/scroll-fade/scroll-fade.css +115 -0
  249. package/src/primitives/scroll-fade/scroll-fade.html +69 -0
  250. package/src/primitives/select/multiselect.d.ts +8 -10
  251. package/src/primitives/select/multiselect.d.ts.map +1 -1
  252. package/src/primitives/select/multiselect.js +23 -27
  253. package/src/primitives/select/multiselect.ts +23 -29
  254. package/src/primitives/select/select-align.html +79 -16
  255. package/src/primitives/select/select-multiple.html +8 -4
  256. package/src/primitives/select/select-sides.html +104 -21
  257. package/src/primitives/select/select.css +299 -191
  258. package/src/primitives/select/select.html +24 -5
  259. package/src/primitives/separator/separator.css +15 -18
  260. package/src/primitives/separator/separator.html +37 -10
  261. package/src/primitives/slider/slider.css +48 -38
  262. package/src/primitives/slider/slider.html +9 -1
  263. package/src/primitives/style-guard/style-guard.d.ts +19 -0
  264. package/src/primitives/style-guard/style-guard.d.ts.map +1 -0
  265. package/src/primitives/style-guard/style-guard.js +125 -0
  266. package/src/primitives/style-guard/style-guard.ts +153 -0
  267. package/src/primitives/switch/switch.css +42 -33
  268. package/src/primitives/switch/switch.html +11 -6
  269. package/src/primitives/table/table-alternating.html +1 -1
  270. package/src/primitives/table/table-grid.html +5 -5
  271. package/src/primitives/table/table-size-sm.html +1 -1
  272. package/src/primitives/table/table.css +64 -61
  273. package/src/primitives/table/table.html +7 -7
  274. package/src/primitives/tabs/tabs.css +167 -166
  275. package/src/primitives/tabs/tabs.d.ts +10 -11
  276. package/src/primitives/tabs/tabs.d.ts.map +1 -1
  277. package/src/primitives/tabs/tabs.html +192 -36
  278. package/src/primitives/tabs/tabs.js +14 -15
  279. package/src/primitives/tabs/tabs.ts +14 -15
  280. package/src/primitives/textarea/textarea.css +69 -44
  281. package/src/primitives/textarea/textarea.html +3 -3
  282. package/src/primitives/toaster/toaster.css +90 -92
  283. package/src/primitives/toaster/toaster.d.ts +0 -6
  284. package/src/primitives/toaster/toaster.d.ts.map +1 -1
  285. package/src/primitives/toaster/toaster.html +22 -18
  286. package/src/primitives/toaster/toaster.js +64 -72
  287. package/src/primitives/toaster/toaster.ts +71 -87
  288. package/src/primitives/toggle/toggle.css +368 -153
  289. package/src/primitives/toggle/toggle.html +27 -9
  290. package/src/primitives/toggle-group/toggle-group-multiple.html +3 -3
  291. package/src/primitives/toggle-group/toggle-group-vertical.html +4 -4
  292. package/src/primitives/toggle-group/toggle-group.css +71 -23
  293. package/src/primitives/toggle-group/toggle-group.html +3 -3
  294. package/src/primitives/toolbar/toolbar.html +35 -13
  295. package/src/primitives/tooltip/tooltip-disabled.html +3 -3
  296. package/src/primitives/tooltip/tooltip-sides.html +36 -14
  297. package/src/primitives/tooltip/tooltip-with-kbd.html +5 -5
  298. package/src/primitives/tooltip/tooltip.css +111 -80
  299. package/src/primitives/tooltip/tooltip.html +3 -3
  300. package/src/primitives/utilities/aspect-ratio.html +51 -7
  301. package/src/primitives/utilities/basis.html +64 -11
  302. package/src/primitives/utilities/col-span.html +65 -9
  303. package/src/primitives/utilities/compose.html +48 -10
  304. package/src/primitives/utilities/flex-align.html +89 -19
  305. package/src/primitives/utilities/flex-direction.html +111 -13
  306. package/src/primitives/utilities/flex-grow.html +41 -7
  307. package/src/primitives/utilities/gap.html +158 -19
  308. package/src/primitives/utilities/grid-cols.html +75 -7
  309. package/src/primitives/utilities/grid-responsive.html +111 -12
  310. package/src/primitives/utilities/margin-auto.html +38 -7
  311. package/src/primitives/utilities/object-fit.html +75 -13
  312. package/src/primitives/utilities/order.html +40 -4
  313. package/src/primitives/utilities/overflow.html +74 -20
  314. package/src/primitives/utilities/padding-compose.html +67 -10
  315. package/src/primitives/utilities/padding.html +84 -13
  316. package/src/primitives/utilities/pile.html +29 -0
  317. package/src/primitives/utilities/position.html +65 -8
  318. package/src/primitives/utilities/responsive-flex.html +54 -7
  319. package/src/primitives/utilities/responsive-grid.html +115 -12
  320. package/src/primitives/utilities/size.html +120 -16
  321. package/src/primitives/utilities/width.html +123 -16
  322. package/examples/about.html +0 -583
  323. package/examples/components.html +0 -1028
  324. package/examples/forms.html +0 -504
  325. package/examples/index.html +0 -261
  326. package/examples/layout.html +0 -313
  327. package/examples/products.html +0 -839
  328. package/examples/responsive.html +0 -332
  329. package/src/base/_layout.css +0 -571
  330. package/src/base/_utilities.css +0 -6758
  331. package/src/primitives/utilities/grid-pile.html +0 -5
@@ -5,34 +5,35 @@
5
5
  * @description Light-DOM custom element on the shared typeahead engine
6
6
  * (`base/typeahead.ts`). A relative of select: the panel filters as you type,
7
7
  * but free text can never submit. The form value lives in an authored hidden
8
- * input (`data-slot="combobox-value"`), synced whenever the selection changes.
8
+ * input (`data-combobox-slot="value"`), synced whenever the selection changes.
9
9
  *
10
10
  * The visible input carries a **display value, not the filter**. Committing
11
11
  * writes the option label into it and clears the query, so reopening shows
12
- * the full list with the committed row checked, matching `.ui-select`.
12
+ * the full list with the committed row checked, matching `[data-ui~="select"]`.
13
13
  * Opening selects that label so the first keystroke replaces it, and focus
14
14
  * alone never opens the panel (a click, the chevron, an arrow key or typing
15
15
  * does). On blur, stray text reverts to the committed label and cleared text
16
16
  * clears the selection.
17
17
  *
18
- * `data-variant="multiselect"` selects a set instead: committing toggles a row
18
+ * `data-combobox-variant="multiselect"` selects a set instead: committing toggles a row
19
19
  * and keeps the panel open, and every selected value renders as a removable
20
20
  * tag stamped inside the control. The tag markup is HTML, not script: author
21
- * a `<template data-slot="combobox-tag-template">` to control its classes and
21
+ * a `<template data-combobox-slot="tag-template">` to control its classes and
22
22
  * structure, and this file fills in the label, the value, and the remove
23
- * button accessible name. Without one, the ui-badge default below applies.
23
+ * button accessible name. Without one, the badge default below applies.
24
24
  * Backspace on an empty input drops the last tag. Options carrying
25
25
  * `aria-selected="true"` are the single source of truth: the tags and the
26
26
  * hidden inputs are both derived from them in DOM order so nothing can drift.
27
27
  * The form submits repeated `name` pairs like `<select multiple>`: the authored
28
28
  * hidden input carries the first value, and stamped siblings carry the rest.
29
29
  *
30
- * Where a no-JS fallback matters, prefer `.ui-select` / `<ui-multiselect>`:
30
+ * Where a no-JS fallback matters, prefer `[data-ui~="select"]` / `<ui-multiselect>`:
31
31
  * this control is inert without its script (the hidden input still submits a
32
32
  * server-set value, but no tags render).
33
33
  *
34
- * Attributes on the root: `data-variant="multiselect"`, `data-sort="score"`,
35
- * `data-min-length="<n>"`, `data-label-remove="Remove {label}"`.
34
+ * Attributes on the root: `data-combobox-variant="multiselect"`, `data-combobox-sort="score"`,
35
+ * `data-combobox-filter="none"` (another source filters; the engine only navigates),
36
+ * `data-combobox-min-length="<n>"`, `data-combobox-label-remove="Remove {label}"`.
36
37
  * Parts: `combobox-value` (hidden input), `combobox-control` (select-look
37
38
  * shell), `combobox-tag-template` (authored `<template>`), `combobox-tag` /
38
39
  * `combobox-tag-label` / `combobox-tag-remove` (cloned from it),
@@ -43,19 +44,11 @@
43
44
  import { TypeaheadElement } from "../../base/typeahead.ts";
44
45
  import { defineZazzElement } from "../../base/zazz-element.ts";
45
46
 
46
- // --- Tag blueprint ---
47
-
48
- /**
49
- * The default tag markup, cloned once per selected value. Authors override it
50
- * wholesale with a `<template data-slot="combobox-tag-template">`, so restyling
51
- * a tag (other classes, an extra icon, a different component entirely) never
52
- * means editing this script. Kept as markup rather than createElement calls so
53
- * the default reads the same way the override is written.
54
- */
47
+ /** Default tag markup, cloned per selected value; a `tag-template` overrides it. */
55
48
  const TAG_MARKUP =
56
- '<span class="ui-badge" data-slot="combobox-tag">' +
57
- '<span data-slot="combobox-tag-label"></span>' +
58
- '<button type="button" tabindex="-1" data-slot="combobox-tag-remove"></button>' +
49
+ '<span data-ui="badge" data-combobox-slot="tag">' +
50
+ '<span data-combobox-slot="tag-label"></span>' +
51
+ '<button type="button" tabindex="-1" data-combobox-slot="tag-remove"></button>' +
59
52
  "</span>";
60
53
 
61
54
  let defaultTagTemplate: HTMLTemplateElement | null = null;
@@ -74,8 +67,6 @@ function defaultTagBlueprint(): HTMLTemplateElement {
74
67
  return defaultTagTemplate;
75
68
  }
76
69
 
77
- // --- Pure derivations ---
78
-
79
70
  /** What a blur does to the input's text and to the committed selection. */
80
71
  interface BlurOutcome {
81
72
  /** The text the input shows once focus has left. */
@@ -102,7 +93,7 @@ function resolveBlur(typed: string, committedLabel: string, multiselect: boolean
102
93
  }
103
94
 
104
95
  /**
105
- * @description Fills the remove-button label template (`data-label-remove`).
96
+ * @description Fills the remove-button label template (`data-combobox-label-remove`).
106
97
  *
107
98
  * @param template - Template with a `{label}` placeholder.
108
99
  * @param label - The tag's visible label.
@@ -112,8 +103,6 @@ function resolveRemoveLabel(template: string, label: string): string {
112
103
  return template.replace("{label}", label);
113
104
  }
114
105
 
115
- // --- Element ---
116
-
117
106
  class UiCombobox extends TypeaheadElement {
118
107
  protected readonly slotPrefix = "combobox";
119
108
  /** The input holds a committed label, so focus alone must not open the list. */
@@ -132,7 +121,7 @@ class UiCombobox extends TypeaheadElement {
132
121
  this.#placeholder = input.getAttribute("placeholder") ?? "";
133
122
 
134
123
  if (multiselect) {
135
- this.querySelector('[data-slot~="combobox-list"]')?.setAttribute(
124
+ this.querySelector('[data-combobox-slot~="list"]')?.setAttribute(
136
125
  "aria-multiselectable",
137
126
  "true",
138
127
  );
@@ -163,7 +152,7 @@ class UiCombobox extends TypeaheadElement {
163
152
  input.value = this.#committedLabel;
164
153
  this.#syncSelection(false);
165
154
 
166
- const control = input.closest<HTMLElement>('[data-slot~="combobox-control"]');
155
+ const control = input.closest<HTMLElement>('[data-combobox-slot~="control"]');
167
156
 
168
157
  // A select-look control is one big hit target
169
158
  input.addEventListener("click", () => this.#openPanel(), { signal });
@@ -176,7 +165,7 @@ class UiCombobox extends TypeaheadElement {
176
165
  // the tag remove buttons would otherwise blur it and close the panel
177
166
  event.preventDefault();
178
167
  input.focus();
179
- if (!event.target.closest('[data-slot~="combobox-trigger"], [data-slot~="combobox-tag"]')) {
168
+ if (!event.target.closest('[data-combobox-slot~="trigger"], [data-combobox-slot~="tag"]')) {
180
169
  this.#openPanel();
181
170
  }
182
171
  },
@@ -188,11 +177,13 @@ class UiCombobox extends TypeaheadElement {
188
177
  "click",
189
178
  (event) => {
190
179
  if (!(event.target instanceof Element)) return;
191
- const remove = event.target.closest('[data-slot~="combobox-tag-remove"]');
180
+ const remove = event.target.closest('[data-combobox-slot~="tag-remove"]');
192
181
  if (!remove) return;
193
182
  // A template that forgets type="button" would otherwise submit the form
194
183
  event.preventDefault();
195
- const value = remove.closest('[data-slot~="combobox-tag"]')?.getAttribute("data-value");
184
+ const value = remove
185
+ .closest('[data-combobox-slot~="tag"]')
186
+ ?.getAttribute("data-combobox-value");
196
187
  this.#deselect(this.items().find((item) => this.#itemFormValue(item) === value));
197
188
  input.focus();
198
189
  },
@@ -200,7 +191,7 @@ class UiCombobox extends TypeaheadElement {
200
191
  );
201
192
 
202
193
  // Chevron toggles the full, unfiltered list
203
- const trigger = this.querySelector('[data-slot~="combobox-trigger"]');
194
+ const trigger = this.querySelector('[data-combobox-slot~="trigger"]');
204
195
  if (trigger instanceof HTMLElement) {
205
196
  trigger.addEventListener(
206
197
  "click",
@@ -254,7 +245,7 @@ class UiCombobox extends TypeaheadElement {
254
245
 
255
246
  protected teardown(): void {
256
247
  for (const node of this.querySelectorAll(
257
- '[data-slot~="combobox-tag"], [data-combobox-stamped]',
248
+ '[data-combobox-slot~="tag"], [data-combobox-state~="stamped"]',
258
249
  )) {
259
250
  node.remove();
260
251
  }
@@ -263,7 +254,7 @@ class UiCombobox extends TypeaheadElement {
263
254
 
264
255
  /**
265
256
  * @description Combobox items match against what the user sees (the label)
266
- * not the machine `data-value`.
257
+ * not the machine `data-combobox-value`.
267
258
  *
268
259
  * @param item - The item element.
269
260
  * @returns The trimmed visible label.
@@ -285,7 +276,7 @@ class UiCombobox extends TypeaheadElement {
285
276
  }
286
277
 
287
278
  /**
288
- * @description Committing shows the item's label, stores its `data-value` in
279
+ * @description Committing shows the item's label, stores its `data-combobox-value` in
289
280
  * the hidden input, and moves `aria-selected`. The multiselect variant
290
281
  * toggles the row instead and keeps the panel open so picking can continue.
291
282
  *
@@ -327,11 +318,11 @@ class UiCombobox extends TypeaheadElement {
327
318
  /**
328
319
  * @description Whether the multiselect variant is active.
329
320
  *
330
- * @returns True for `data-variant="multiselect"`.
321
+ * @returns True for `data-combobox-variant="multiselect"`.
331
322
  * @private
332
323
  */
333
324
  #multiselect(): boolean {
334
- return this.getAttribute("data-variant") === "multiselect";
325
+ return this.config("variant") === "multiselect";
335
326
  }
336
327
 
337
328
  /**
@@ -384,11 +375,11 @@ class UiCombobox extends TypeaheadElement {
384
375
  * @description An item's machine value.
385
376
  *
386
377
  * @param item - The item element.
387
- * @returns `data-value` when present, the visible label otherwise.
378
+ * @returns `data-combobox-value` when present, the visible label otherwise.
388
379
  * @private
389
380
  */
390
381
  #itemFormValue(item: HTMLElement): string {
391
- return item.getAttribute("data-value") ?? this.itemValue(item);
382
+ return item.getAttribute("data-combobox-value") ?? this.itemValue(item);
392
383
  }
393
384
 
394
385
  /**
@@ -411,7 +402,9 @@ class UiCombobox extends TypeaheadElement {
411
402
  * @private
412
403
  */
413
404
  #valueInput(): HTMLInputElement | null {
414
- const hidden = this.querySelector('[data-slot~="combobox-value"]:not([data-combobox-stamped])');
405
+ const hidden = this.querySelector(
406
+ '[data-combobox-slot~="value"]:not([data-combobox-state~="stamped"])',
407
+ );
415
408
  return hidden instanceof HTMLInputElement ? hidden : null;
416
409
  }
417
410
 
@@ -438,13 +431,13 @@ class UiCombobox extends TypeaheadElement {
438
431
  const hidden = this.#valueInput();
439
432
  if (!hidden) return;
440
433
  hidden.value = values[0] ?? "";
441
- for (const stale of this.querySelectorAll("[data-combobox-stamped]")) stale.remove();
434
+ for (const stale of this.querySelectorAll('[data-combobox-state~="stamped"]')) stale.remove();
442
435
  let anchor: Element = hidden;
443
436
  for (const value of values.slice(1)) {
444
437
  const extra = document.createElement("input");
445
438
  extra.type = "hidden";
446
- extra.setAttribute("data-slot", "combobox-value");
447
- extra.setAttribute("data-combobox-stamped", "");
439
+ extra.setAttribute("data-combobox-slot", "value");
440
+ extra.setAttribute("data-combobox-state", "stamped");
448
441
  if (hidden.name) extra.name = hidden.name;
449
442
  extra.value = value;
450
443
  anchor.after(extra);
@@ -455,16 +448,16 @@ class UiCombobox extends TypeaheadElement {
455
448
 
456
449
  /**
457
450
  * @description The element cloned per selected value: the first child of an
458
- * authored `<template data-slot="combobox-tag-template">` when present, the
459
- * default ui-badge otherwise. A template's content lives in a separate
460
- * fragment, so a blueprint carrying `data-slot="combobox-tag"` is invisible to
451
+ * authored `<template data-combobox-slot="tag-template">` when present, the
452
+ * default badge otherwise. A template's content lives in a separate
453
+ * fragment, so a blueprint carrying `data-combobox-slot="tag"` is invisible to
461
454
  * the stale-tag sweep and can never be mistaken for a rendered tag.
462
455
  *
463
456
  * @returns The blueprint element, or null when an authored template is empty.
464
457
  * @private
465
458
  */
466
459
  #tagBlueprint(): HTMLElement | null {
467
- const authored = this.querySelector('[data-slot~="combobox-tag-template"]');
460
+ const authored = this.querySelector('[data-combobox-slot~="tag-template"]');
468
461
  const template = authored instanceof HTMLTemplateElement ? authored : defaultTagBlueprint();
469
462
  const root = template.content.firstElementChild;
470
463
  return root instanceof HTMLElement ? root : null;
@@ -479,35 +472,35 @@ class UiCombobox extends TypeaheadElement {
479
472
  * @private
480
473
  */
481
474
  #renderTags(input: HTMLInputElement): void {
482
- const control = input.closest('[data-slot~="combobox-control"]');
475
+ const control = input.closest('[data-combobox-slot~="control"]');
483
476
  if (!control) return;
484
- for (const stale of control.querySelectorAll('[data-slot~="combobox-tag"]')) stale.remove();
477
+ for (const stale of control.querySelectorAll('[data-combobox-slot~="tag"]')) stale.remove();
485
478
 
486
479
  const blueprint = this.#tagBlueprint();
487
480
  if (!blueprint) return;
488
481
 
489
- const removeLabel = this.getAttribute("data-label-remove") ?? "Remove {label}";
482
+ const removeLabel = this.config("label-remove") ?? "Remove {label}";
490
483
  const tags = this.#selectedItems().map((item) => {
491
484
  const label = this.itemValue(item);
492
485
  const tag = blueprint.cloneNode(true) as HTMLElement;
493
- tag.setAttribute("data-value", this.#itemFormValue(item));
486
+ tag.setAttribute("data-combobox-value", this.#itemFormValue(item));
494
487
 
495
488
  // The slot is the contract every other moving part keys off (the CSS, the
496
489
  // stale sweep above, and tag removal), so add the token if the template
497
490
  // left it out rather than stamping an orphan
498
- if (!tag.matches('[data-slot~="combobox-tag"]')) {
499
- const slots = tag.getAttribute("data-slot");
500
- tag.setAttribute("data-slot", slots ? `${slots} combobox-tag` : "combobox-tag");
491
+ if (!tag.matches('[data-combobox-slot~="tag"]')) {
492
+ const slots = tag.getAttribute("data-combobox-slot");
493
+ tag.setAttribute("data-combobox-slot", slots ? `${slots} tag` : "tag");
501
494
  }
502
495
 
503
496
  // The label wants its own box: text-overflow ignores a flex container's
504
497
  // own text, but a template without one still gets its text
505
- const text = tag.querySelector('[data-slot~="combobox-tag-label"]');
498
+ const text = tag.querySelector('[data-combobox-slot~="tag-label"]');
506
499
  if (text) text.textContent = label;
507
500
  else tag.prepend(document.createTextNode(label));
508
501
 
509
502
  tag
510
- .querySelector('[data-slot~="combobox-tag-remove"]')
503
+ .querySelector('[data-combobox-slot~="tag-remove"]')
511
504
  ?.setAttribute("aria-label", resolveRemoveLabel(removeLabel, label));
512
505
 
513
506
  return tag;
@@ -17,9 +17,8 @@
17
17
  * palette-wide concerns like analytics.
18
18
  */
19
19
  /**
20
- * @description Binds this page's custom `--command` handlers. Handlers attach
21
- * to the command *target* (the `commandfor` element), per the Invoker
22
- * Commands contract.
20
+ * @description Binds this page's custom `--command` handlers on the command
21
+ * *target* (the `commandfor` element).
23
22
  */
24
23
  declare function initCommandActions(): void;
25
24
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"command-actions.d.ts","sourceRoot":"","sources":["command-actions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAIH;;;;GAIG;AACH,iBAAS,kBAAkB,IAAI,IAAI,CAsBlC;AAID;;;GAGG;AACH,iBAAS,wBAAwB,IAAI,IAAI,CAKxC;AAaD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,CAAC"}
1
+ {"version":3,"file":"command-actions.d.ts","sourceRoot":"","sources":["command-actions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;GAGG;AACH,iBAAS,kBAAkB,IAAI,IAAI,CA4BlC;AAED;;;GAGG;AACH,iBAAS,wBAAwB,IAAI,IAAI,CAKxC;AAWD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,CAAC"}
@@ -1,28 +1,38 @@
1
- <!-- command-actions.js (loaded with this example) shows how to register
2
- custom actions: listen for your `--command` on its `commandfor` target,
3
- or for `zazz:command-select` on the root. Copy it into your project as a
4
- starting point. -->
5
- <ui-command data-command-hotkey="mod+j" id="command-actions-target" class="w-full max-w-xl">
1
+ <!-- command-actions.js shows how to register custom actions: listen for your
2
+ `--command` on its `commandfor` target, or for `zazz:command-select` on
3
+ the root. -->
4
+ <ui-command
5
+ data-command-hotkey="mod+j"
6
+ id="command-actions-target"
7
+ style="
8
+ --w: 100%;
9
+ --max-w: 96;
10
+ "
11
+ >
6
12
  <button
7
- class="ui-button w-full justify-between"
13
+ data-ui="button"
8
14
  type="button"
9
- data-variant="outline"
15
+ data-button-variant="outline"
10
16
  popovertarget="command-example-actions-1"
11
- data-slot="command-open"
17
+ data-command-slot="open"
18
+ style="
19
+ --justify: space-between;
20
+ --w: 100%;
21
+ "
12
22
  >
13
- <span class="text-muted-foreground">Quick actions...</span>
23
+ <span style="--text: var(--color-muted-foreground)">Quick actions...</span>
14
24
  <ui-kbd-group><kbd>⌘</kbd><kbd>J</kbd></ui-kbd-group>
15
25
  </button>
16
26
  <div
17
27
  id="command-example-actions-1"
18
- data-slot="command-panel"
19
- data-side="bottom"
20
- data-align="start"
28
+ data-command-slot="panel"
29
+ data-popover-side="bottom"
30
+ data-popover-align="start"
21
31
  popover="auto"
22
32
  >
23
- <header data-slot="command-header">
33
+ <header data-command-slot="header">
24
34
  <input
25
- data-slot="command-input"
35
+ data-command-slot="input"
26
36
  type="text"
27
37
  placeholder="Type a command..."
28
38
  role="combobox"
@@ -32,52 +42,57 @@
32
42
  aria-label="Search commands"
33
43
  />
34
44
  </header>
35
- <div role="listbox" data-slot="command-list" aria-label="Commands">
45
+ <div role="listbox" data-command-slot="list" aria-label="Commands">
36
46
  <button
37
47
  role="option"
38
- data-slot="command-item"
39
- class="ui-button justify-start"
40
- data-variant="ghost"
48
+ data-command-slot="item"
49
+ data-ui="button"
50
+ data-button-variant="ghost"
41
51
  type="button"
42
52
  command="--theme-toggle"
43
53
  commandfor="command-actions-target"
44
54
  tabindex="-1"
45
- data-keywords="dark light mode appearance"
46
- data-stay-open
55
+ data-command-keywords="dark light mode appearance"
56
+ data-command-stay-open
57
+ style="--justify: start"
47
58
  >
48
59
  Toggle theme
49
60
  </button>
50
61
  <button
51
62
  role="option"
52
- data-slot="command-item"
53
- class="ui-button justify-start"
54
- data-variant="ghost"
63
+ data-command-slot="item"
64
+ data-ui="button"
65
+ data-button-variant="ghost"
55
66
  type="button"
56
67
  command="--copy-link"
57
68
  commandfor="command-actions-target"
58
69
  tabindex="-1"
59
- data-keywords="share url clipboard"
70
+ data-command-keywords="share url clipboard"
71
+ style="--justify: start"
60
72
  >
61
73
  Copy link
62
74
  </button>
63
75
  <button
64
76
  role="option"
65
- data-slot="command-item"
66
- class="ui-button justify-start"
67
- data-variant="ghost"
77
+ data-command-slot="item"
78
+ data-ui="button"
79
+ data-button-variant="ghost"
68
80
  type="button"
69
81
  command="--toast-success"
70
82
  commandfor="command-actions-toaster"
71
- data-title="Saved"
72
- data-description="Your changes are safe."
83
+ data-toaster-title="Saved"
84
+ data-toaster-description="Your changes are safe."
73
85
  tabindex="-1"
74
- data-keywords="notify notification"
86
+ data-command-keywords="notify notification"
87
+ style="--justify: start"
75
88
  >
76
89
  Show a toast
77
90
  </button>
78
91
  </div>
79
- <p data-slot="command-empty" class="text-muted-foreground">No commands found.</p>
80
- <footer data-slot="command-footer">
92
+ <p data-command-slot="empty" style="--text: var(--color-muted-foreground)">
93
+ No commands found.
94
+ </p>
95
+ <footer data-command-slot="footer">
81
96
  <span
82
97
  ><ui-kbd-group><kbd>↑</kbd><kbd>↓</kbd></ui-kbd-group> navigate</span
83
98
  >
@@ -86,4 +101,4 @@
86
101
  </div>
87
102
  </ui-command>
88
103
 
89
- <ui-toaster id="command-actions-toaster" data-position="bottom-end"></ui-toaster>
104
+ <ui-toaster id="command-actions-toaster" data-toaster-position="bottom-end"></ui-toaster>
@@ -17,18 +17,16 @@
17
17
  * from the `<ui-command>` root (`detail: { item, value }`); use it for
18
18
  * palette-wide concerns like analytics.
19
19
  */
20
- // --- Custom invoker commands ---
21
20
  /**
22
- * @description Binds this page's custom `--command` handlers. Handlers attach
23
- * to the command *target* (the `commandfor` element), per the Invoker
24
- * Commands contract.
21
+ * @description Binds this page's custom `--command` handlers on the command
22
+ * *target* (the `commandfor` element).
25
23
  */
26
24
  function initCommandActions() {
27
25
  const themeTarget = document.getElementById("command-actions-target");
28
26
  if (!themeTarget)
29
27
  return;
30
- // The invokers polyfill can deliver the same command twice in one task even
31
- // with native support: de-dupe like the toaster does.
28
+ // The invokers polyfill can deliver the same command twice in one task, even
29
+ // with native support.
32
30
  let lastEvent = null;
33
31
  themeTarget.addEventListener("command", (event) => {
34
32
  if (event === lastEvent)
@@ -36,16 +34,21 @@ function initCommandActions() {
36
34
  lastEvent = event;
37
35
  const command = event.command;
38
36
  switch (command) {
39
- case "--theme-toggle":
40
- document.documentElement.classList.toggle("dark");
37
+ case "--theme-toggle": {
38
+ // data-ui-theme pins the scheme; unset follows the system
39
+ const root = document.documentElement;
40
+ const dark = root.dataset.uiTheme
41
+ ? root.dataset.uiTheme === "dark"
42
+ : matchMedia("(prefers-color-scheme: dark)").matches;
43
+ root.dataset.uiTheme = dark ? "light" : "dark";
41
44
  break;
45
+ }
42
46
  case "--copy-link":
43
47
  void navigator.clipboard?.writeText(window.location.href);
44
48
  break;
45
49
  }
46
50
  });
47
51
  }
48
- // --- Palette-wide hook ---
49
52
  /**
50
53
  * @description Logs every command activation: swap for analytics, recents
51
54
  * tracking, or any cross-cutting concern.
@@ -56,7 +59,6 @@ function initCommandSelectLogging() {
56
59
  console.info("[command] selected:", detail.value);
57
60
  });
58
61
  }
59
- // --- Auto-initialization ---
60
62
  if (typeof window !== "undefined" && typeof document !== "undefined") {
61
63
  const init = () => {
62
64
  initCommandActions();
@@ -19,19 +19,16 @@
19
19
  * palette-wide concerns like analytics.
20
20
  */
21
21
 
22
- // --- Custom invoker commands ---
23
-
24
22
  /**
25
- * @description Binds this page's custom `--command` handlers. Handlers attach
26
- * to the command *target* (the `commandfor` element), per the Invoker
27
- * Commands contract.
23
+ * @description Binds this page's custom `--command` handlers on the command
24
+ * *target* (the `commandfor` element).
28
25
  */
29
26
  function initCommandActions(): void {
30
27
  const themeTarget = document.getElementById("command-actions-target");
31
28
  if (!themeTarget) return;
32
29
 
33
- // The invokers polyfill can deliver the same command twice in one task even
34
- // with native support: de-dupe like the toaster does.
30
+ // The invokers polyfill can deliver the same command twice in one task, even
31
+ // with native support.
35
32
  let lastEvent: Event | null = null;
36
33
 
37
34
  themeTarget.addEventListener("command", (event) => {
@@ -40,9 +37,15 @@ function initCommandActions(): void {
40
37
 
41
38
  const command = (event as CommandEvent).command;
42
39
  switch (command) {
43
- case "--theme-toggle":
44
- document.documentElement.classList.toggle("dark");
40
+ case "--theme-toggle": {
41
+ // data-ui-theme pins the scheme; unset follows the system
42
+ const root = document.documentElement;
43
+ const dark = root.dataset.uiTheme
44
+ ? root.dataset.uiTheme === "dark"
45
+ : matchMedia("(prefers-color-scheme: dark)").matches;
46
+ root.dataset.uiTheme = dark ? "light" : "dark";
45
47
  break;
48
+ }
46
49
  case "--copy-link":
47
50
  void navigator.clipboard?.writeText(window.location.href);
48
51
  break;
@@ -50,8 +53,6 @@ function initCommandActions(): void {
50
53
  });
51
54
  }
52
55
 
53
- // --- Palette-wide hook ---
54
-
55
56
  /**
56
57
  * @description Logs every command activation: swap for analytics, recents
57
58
  * tracking, or any cross-cutting concern.
@@ -63,8 +64,6 @@ function initCommandSelectLogging(): void {
63
64
  });
64
65
  }
65
66
 
66
- // --- Auto-initialization ---
67
-
68
67
  if (typeof window !== "undefined" && typeof document !== "undefined") {
69
68
  const init = (): void => {
70
69
  initCommandActions();