@zazz-ui/core 0.4.1 → 0.5.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 (331) hide show
  1. package/AUTHORING.md +158 -0
  2. package/CHANGELOG.md +345 -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 +43 -39
  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 +61 -31
  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 +145 -122
  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 +88 -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 +297 -186
  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 +76 -26
  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
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @fileoverview How a `style=""` of utilities is written: normalized, in
5
+ * cascade order, one declaration per line.
6
+ * @description The `zazz/style-format` lint rule (`@zazz-ui/eslint-plugin`)
7
+ * writes `style` with it: fixed on save, by the commit hook, and by
8
+ * `vp run fmt:html`. Development tooling only; no runtime entry imports it.
9
+ *
10
+ * Order: utilities follow the `UTILITIES` table (family, then emission order,
11
+ * shorthands first), each led by its `--*--starting` tier (the value it
12
+ * transitions from reads before the value it lands on; CSS order does not
13
+ * matter, the generated setter sits in `@starting-style`) and followed by its
14
+ * tiers (breakpoints small to large, then states in `STATES` order) and its
15
+ * `--group-*` forms; then the
16
+ * `--before-*` forms, then `--after-*`; then other custom properties (`--ui-*`
17
+ * hooks) and raw CSS, each kept in source order. Custom properties do not
18
+ * depend on declaration order, and the sort is stable, so a repeated name
19
+ * keeps its winner and raw shorthands keep their place before longhands.
20
+ */
21
+
22
+ import {
23
+ BREAKPOINTS,
24
+ PSEUDO_ONLY,
25
+ PSEUDO_SIDES,
26
+ STATES,
27
+ UTILITIES,
28
+ parseUtilityName,
29
+ } from "./utilities.ts";
30
+
31
+ // --- Declarations ---
32
+
33
+ /** `[start, end)` offsets into a style value. */
34
+ export type Range = [number, number];
35
+
36
+ /** One declaration of a style value, with its parts' offsets (all trimmed). */
37
+ export interface ScannedDeclaration {
38
+ /** The whole declaration. */
39
+ span: Range;
40
+ /** The name; a declaration still being typed (`--p`) is all name. */
41
+ name: string;
42
+ nameSpan: Range;
43
+ /** Offset of the colon, or -1 when there is none yet. */
44
+ colon: number;
45
+ value: string;
46
+ /** Empty (`[colon + 1, colon + 1]`) when nothing follows the colon. */
47
+ valueSpan: Range;
48
+ }
49
+
50
+ /** Trims `[start, end)` of `text` to its non-whitespace extent. */
51
+ function trimRange(text: string, start: number, end: number): Range {
52
+ while (start < end && /\s/.test(text[start]!)) start++;
53
+ while (end > start && /\s/.test(text[end - 1]!)) end--;
54
+ return [start, end];
55
+ }
56
+
57
+ /**
58
+ * Scans a style value into declarations, splitting on top-level `;` (not inside
59
+ * parentheses or quotes). Empty segments are skipped.
60
+ */
61
+ export function scanDeclarations(value: string): ScannedDeclaration[] {
62
+ const found: ScannedDeclaration[] = [];
63
+ const push = (from: number, to: number) => {
64
+ const span = trimRange(value, from, to);
65
+ if (span[0] === span[1]) return;
66
+ const colon = value.indexOf(":", span[0]);
67
+ const hasColon = colon !== -1 && colon < span[1];
68
+ const nameSpan = hasColon ? trimRange(value, span[0], colon) : span;
69
+ const valueSpan = hasColon
70
+ ? trimRange(value, colon + 1, span[1])
71
+ : ([span[1], span[1]] as Range);
72
+ found.push({
73
+ span,
74
+ name: value.slice(...nameSpan),
75
+ nameSpan,
76
+ colon: hasColon ? colon : -1,
77
+ value: value.slice(...valueSpan),
78
+ valueSpan,
79
+ });
80
+ };
81
+ let depth = 0;
82
+ let quote: string | null = null;
83
+ let start = 0;
84
+ for (let i = 0; i < value.length; i++) {
85
+ const ch = value[i]!;
86
+ if (quote) {
87
+ if (ch === "\\") i++;
88
+ else if (ch === quote) quote = null;
89
+ } else if (ch === '"' || ch === "'") quote = ch;
90
+ else if (ch === "(") depth++;
91
+ else if (ch === ")") depth = Math.max(0, depth - 1);
92
+ else if (ch === ";" && depth === 0) {
93
+ push(start, i);
94
+ start = i + 1;
95
+ }
96
+ }
97
+ push(start, value.length);
98
+ return found;
99
+ }
100
+
101
+ /** Splits a style value on top-level `;`, ignoring ones inside parentheses or quotes. */
102
+ export function splitDeclarations(value: string): string[] {
103
+ return scanDeclarations(value).map(({ span }) => value.slice(...span));
104
+ }
105
+
106
+ /** Collapses whitespace runs to one space, outside quotes. */
107
+ function collapse(text: string): string {
108
+ let out = "";
109
+ let quote: string | null = null;
110
+ for (let i = 0; i < text.length; i++) {
111
+ const ch = text[i]!;
112
+ if (quote) {
113
+ out += ch;
114
+ if (ch === "\\" && i + 1 < text.length) out += text[++i];
115
+ else if (ch === quote) quote = null;
116
+ } else if (ch === '"' || ch === "'") {
117
+ quote = ch;
118
+ out += ch;
119
+ } else if (/\s/.test(ch)) {
120
+ if (!out.endsWith(" ")) out += " ";
121
+ } else out += ch;
122
+ }
123
+ return out.trim();
124
+ }
125
+
126
+ /** `--px :6` → `--px: 6`. A declaration without a colon is kept as written. */
127
+ export function normalize(declaration: string): string {
128
+ const colon = declaration.indexOf(":");
129
+ if (colon === -1) return collapse(declaration);
130
+ return `${declaration.slice(0, colon).trim()}: ${collapse(declaration.slice(colon + 1))}`;
131
+ }
132
+
133
+ // --- Order ---
134
+
135
+ const UTILITY_RANK = new Map([...UTILITIES, ...PSEUDO_ONLY].map((utility, i) => [utility.name, i]));
136
+ // the starting tier leads its utility, ahead of the base (rank 0)
137
+ const TIER_RANK = new Map<string, number>(
138
+ [...BREAKPOINTS, ...STATES].map((tier, i) => [tier, tier === "starting" ? -1 : i + 1]),
139
+ );
140
+
141
+ /** Sort key: utilities by side, table order, own-before-group, tier; everything else after. */
142
+ function rank(declaration: string): number[] {
143
+ const colon = declaration.indexOf(":");
144
+ const name = colon === -1 ? "" : declaration.slice(0, colon).trim();
145
+ if (!name.startsWith("--")) return [2];
146
+ const parsed = parseUtilityName(name);
147
+ const utility = UTILITY_RANK.get(parsed.name);
148
+ if (utility === undefined || name.startsWith("--ui-")) return [1];
149
+ const side = parsed.side ? PSEUDO_SIDES.indexOf(parsed.side as "before") + 1 : 0;
150
+ return [0, side, utility, parsed.group ? 1 : 0, parsed.tier ? TIER_RANK.get(parsed.tier)! : 0];
151
+ }
152
+
153
+ function compare(a: number[], b: number[]): number {
154
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
155
+ const delta = (a[i] ?? -1) - (b[i] ?? -1);
156
+ if (delta) return delta;
157
+ }
158
+ return 0;
159
+ }
160
+
161
+ /** Declarations in cascade order (a stable sort). */
162
+ export function orderDeclarations(declarations: string[]): string[] {
163
+ const ranks = new Map(declarations.map((d) => [d, rank(d)]));
164
+ return [...declarations].sort((a, b) => compare(ranks.get(a)!, ranks.get(b)!));
165
+ }
166
+
167
+ // --- Layout ---
168
+
169
+ /**
170
+ * The formatted `style` value: normalized declarations in cascade order, one
171
+ * per line under `attrIndent` (the attribute's own indent) when there are two
172
+ * or more, a bare declaration when there is one.
173
+ */
174
+ export function formatStyleValue(value: string, attrIndent: string): string {
175
+ const declarations = orderDeclarations(splitDeclarations(value).map(normalize));
176
+ if (declarations.length === 0) return value;
177
+ if (declarations.length === 1) return declarations[0]!;
178
+ const inner = `${attrIndent} `;
179
+ return `\n${declarations.map((d) => `${inner}${d};`).join("\n")}\n${attrIndent}`;
180
+ }
@@ -1,9 +1,9 @@
1
1
  import { ZazzElement } from "./zazz-element.ts";
2
2
  /** What the ranker needs to know about one item. */
3
3
  interface ItemFacts {
4
- /** The text scored and committed: `data-value` ?? trimmed text content. */
4
+ /** The text scored and committed: `data-<prefix>-value` ?? trimmed text content. */
5
5
  value: string;
6
- /** Extra match targets from `data-keywords`. */
6
+ /** Extra match targets from `data-<prefix>-keywords`. */
7
7
  keywords: string[];
8
8
  }
9
9
  /** The ranker's verdict for one item, in input order. */
@@ -43,6 +43,10 @@ declare abstract class TypeaheadElement extends ZazzElement {
43
43
  #private;
44
44
  /** Slot prefix: `"autocomplete"` finds `autocomplete-panel`, `-list`, `-item`. */
45
45
  protected abstract readonly slotPrefix: string;
46
+ /** @description Selector for a part: `data-<prefix>-slot~="<name>"`. */
47
+ protected partSelector(name: string): string;
48
+ /** @description A root config attribute: `data-<prefix>-<key>`. */
49
+ protected config(key: string): string | null;
46
50
  /** Whether this element opens/closes its own `popover="manual"` panel. */
47
51
  protected readonly managesPanel: boolean;
48
52
  /**
@@ -55,6 +59,15 @@ declare abstract class TypeaheadElement extends ZazzElement {
55
59
  protected get sortByScore(): boolean;
56
60
  /** Whether filtering auto-highlights the best item (command palettes do). */
57
61
  protected readonly autoHighlight: boolean;
62
+ /**
63
+ * @description Whether the engine filters and scores the items itself.
64
+ * `data-<prefix>-filter="none"` opts out for a list another source already
65
+ * filtered (a search index, a server): every item stays visible in document
66
+ * order, and keyboard navigation, highlight, and ARIA still run.
67
+ */
68
+ protected get filtersItems(): boolean;
69
+ /** @description Whether visible items are re-ordered by score (never for an unfiltered list). */
70
+ protected get ordersByScore(): boolean;
58
71
  /**
59
72
  * Applies a committed item: fill the input, sync a value, activate.
60
73
  * `source` indicates how the commit happened: a pointer commit has already run
@@ -67,6 +80,8 @@ declare abstract class TypeaheadElement extends ZazzElement {
67
80
  protected readonly query: import("signal-polyfill").Signal.State<string>;
68
81
  protected readonly open: import("signal-polyfill").Signal.State<boolean>;
69
82
  protected readonly activeIndex: import("signal-polyfill").Signal.State<number>;
83
+ /** Bumped when items are added or removed, so the ranking effect re-runs. */
84
+ protected readonly itemsVersion: import("signal-polyfill").Signal.State<number>;
70
85
  protected setup(signal: AbortSignal): void;
71
86
  /**
72
87
  * @description The panel's items, in DOM order.
@@ -76,7 +91,7 @@ declare abstract class TypeaheadElement extends ZazzElement {
76
91
  protected items(): HTMLElement[];
77
92
  /**
78
93
  * @description The visible items in visual order: score order when
79
- * `data-sort="score"`, DOM order otherwise, so arrow keys always follow
94
+ * `data-<prefix>-sort="score"`, DOM order otherwise, so arrow keys always follow
80
95
  * what the user sees.
81
96
  *
82
97
  * @param items - All items, DOM order.
@@ -90,7 +105,7 @@ declare abstract class TypeaheadElement extends ZazzElement {
90
105
  * value ("Go to docs ⇧⌘D" matches and announces as "Go to docs").
91
106
  *
92
107
  * @param item - The item element.
93
- * @returns `data-value` when present, trimmed hint-free text otherwise.
108
+ * @returns `data-<prefix>-value` when present, trimmed hint-free text otherwise.
94
109
  */
95
110
  protected itemValue(item: HTMLElement): string;
96
111
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"typeahead.d.ts","sourceRoot":"","sources":["typeahead.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKhD,oDAAoD;AACpD,UAAU,SAAS;IACjB,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,yDAAyD;AACzD,UAAU,UAAU;IAClB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,iBAAS,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,UAAU,EAAE,CAM3E;AAED;;;;;;;;GAQG;AACH,iBAAS,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAc5E;AAMD;;;;GAIG;AACH,uBAAe,gBAAiB,SAAQ,WAAW;;IACjD,kFAAkF;IAClF,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC/C,0EAA0E;IAC1E,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAQ;IAChD;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAQ;IAC/C,kEAAkE;IAClE,SAAS,KAAK,WAAW,IAAI,OAAO,CAEnC;IACD,6EAA6E;IAC7E,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAS;IAElD;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC;IAEnF,SAAS,CAAC,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IACtD,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAQ;IAE3C,SAAS,CAAC,QAAQ,CAAC,KAAK,iDAAa;IACrC,SAAS,CAAC,QAAQ,CAAC,IAAI,kDAAgB;IACvC,SAAS,CAAC,QAAQ,CAAC,WAAW,iDAAa;IAE3C,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CA2MzC;IAED;;;;OAIG;IACH,SAAS,CAAC,KAAK,IAAI,WAAW,EAAE,CAM/B;IAED;;;;;;;;OAQG;IACH,SAAS,CAAC,YAAY,CACpB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,MAAM,EAAE,SAAS,UAAU,EAAE,GAC5B,WAAW,EAAE,CAIf;IA6BD;;;;;;;OAOG;IACH,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAO7C;IAED;;;;OAIG;IACH,SAAS,CAAC,UAAU,IAAI,IAAI,CAK3B;CA6EF;AAED,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AACxD,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"typeahead.d.ts","sourceRoot":"","sources":["typeahead.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKhD,oDAAoD;AACpD,UAAU,SAAS;IACjB,oFAAoF;IACpF,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,yDAAyD;AACzD,UAAU,UAAU;IAClB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,iBAAS,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,UAAU,EAAE,CAM3E;AAED;;;;;;;;GAQG;AACH,iBAAS,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAc5E;AAMD;;;;GAIG;AACH,uBAAe,gBAAiB,SAAQ,WAAW;;IACjD,kFAAkF;IAClF,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE/C,wEAAwE;IACxE,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3C;IAED,mEAAmE;IACnE,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE3C;IACD,0EAA0E;IAC1E,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAQ;IAChD;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAQ;IAC/C,kEAAkE;IAClE,SAAS,KAAK,WAAW,IAAI,OAAO,CAEnC;IACD,6EAA6E;IAC7E,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAS;IAClD;;;;;OAKG;IACH,SAAS,KAAK,YAAY,IAAI,OAAO,CAEpC;IAED,iGAAiG;IACjG,SAAS,KAAK,aAAa,IAAI,OAAO,CAErC;IAED;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC;IAEnF,SAAS,CAAC,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IACtD,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAQ;IAE3C,SAAS,CAAC,QAAQ,CAAC,KAAK,iDAAa;IACrC,SAAS,CAAC,QAAQ,CAAC,IAAI,kDAAgB;IACvC,SAAS,CAAC,QAAQ,CAAC,WAAW,iDAAa;IAC3C,6EAA6E;IAC7E,SAAS,CAAC,QAAQ,CAAC,YAAY,iDAAY;IAE3C,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CA6NzC;IAED;;;;OAIG;IACH,SAAS,CAAC,KAAK,IAAI,WAAW,EAAE,CAM/B;IAED;;;;;;;;OAQG;IACH,SAAS,CAAC,YAAY,CACpB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,MAAM,EAAE,SAAS,UAAU,EAAE,GAC5B,WAAW,EAAE,CAIf;IAgCD;;;;;;;OAOG;IACH,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAO7C;IAED;;;;OAIG;IACH,SAAS,CAAC,UAAU,IAAI,IAAI,CAK3B;CA6EF;AAED,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AACxD,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC"}
@@ -14,9 +14,12 @@
14
14
  * restructured, so forms, focus, and progressive enhancement stay untouched.
15
15
  * Groups and empty states hide with CSS `:has()`, not code.
16
16
  *
17
- * Item facts come from the markup: the match/commit text is `data-value`
18
- * (falling back to text content) and `data-keywords` adds extra match
19
- * targets. `data-sort="score"` on the root re-ranks visually via `order`.
17
+ * Item facts come from the markup: the match/commit text is `data-<prefix>-value`
18
+ * (falling back to text content) and `data-<prefix>-keywords` adds extra match
19
+ * targets. `data-<prefix>-sort="score"` on the root re-ranks visually via `order`;
20
+ * `data-<prefix>-filter="none"` leaves filtering to another source (a search
21
+ * index) and only navigates, highlights, and announces. Items added to or
22
+ * removed from the list after the query are ranked like typed input.
20
23
  */
21
24
  import { commandScore } from "./command-score.js";
22
25
  import { ZazzElement } from "./zazz-element.js";
@@ -69,6 +72,14 @@ let typeaheadIdCounter = 0;
69
72
  * navigation, ARIA wiring, and (when `managesPanel`) the manual popover.
70
73
  */
71
74
  class TypeaheadElement extends ZazzElement {
75
+ /** @description Selector for a part: `data-<prefix>-slot~="<name>"`. */
76
+ partSelector(name) {
77
+ return `[data-${this.slotPrefix}-slot~="${name}"]`;
78
+ }
79
+ /** @description A root config attribute: `data-<prefix>-<key>`. */
80
+ config(key) {
81
+ return this.getAttribute(`data-${this.slotPrefix}-${key}`);
82
+ }
72
83
  /** Whether this element opens/closes its own `popover="manual"` panel. */
73
84
  managesPanel = true;
74
85
  /**
@@ -79,29 +90,62 @@ class TypeaheadElement extends ZazzElement {
79
90
  openOnFocus = true;
80
91
  /** Whether ranking also re-orders visually via inline `order`. */
81
92
  get sortByScore() {
82
- return this.getAttribute("data-sort") === "score";
93
+ return this.config("sort") === "score";
83
94
  }
84
95
  /** Whether filtering auto-highlights the best item (command palettes do). */
85
96
  autoHighlight = false;
97
+ /**
98
+ * @description Whether the engine filters and scores the items itself.
99
+ * `data-<prefix>-filter="none"` opts out for a list another source already
100
+ * filtered (a search index, a server): every item stays visible in document
101
+ * order, and keyboard navigation, highlight, and ARIA still run.
102
+ */
103
+ get filtersItems() {
104
+ return this.config("filter") !== "none";
105
+ }
106
+ /** @description Whether visible items are re-ordered by score (never for an unfiltered list). */
107
+ get ordersByScore() {
108
+ return this.sortByScore && this.filtersItems;
109
+ }
86
110
  searchInput = null;
87
111
  panel = null;
88
112
  query = state("");
89
113
  open = state(false);
90
114
  activeIndex = state(-1);
115
+ /** Bumped when items are added or removed, so the ranking effect re-runs. */
116
+ itemsVersion = state(0);
91
117
  setup(signal) {
92
118
  const prefix = this.slotPrefix;
93
- const panel = this.querySelector(`[data-slot~="${prefix}-panel"]`);
119
+ const panel = this.querySelector(this.partSelector("panel"));
94
120
  const input = this.querySelector('input[role="combobox"]') ??
95
- this.querySelector(`[data-slot~="${prefix}-input"]`);
121
+ this.querySelector(this.partSelector("input"));
96
122
  if (!(panel instanceof HTMLElement) || !(input instanceof HTMLInputElement))
97
123
  return;
98
124
  this.panel = panel;
99
125
  this.searchInput = input;
100
- const list = panel.querySelector(`[data-slot~="${prefix}-list"]`);
126
+ const list = panel.querySelector(this.partSelector("list"));
101
127
  if (list instanceof HTMLElement) {
102
128
  list.id ||= `ui-${prefix}-list-${++typeaheadIdCounter}`;
103
129
  input.setAttribute("aria-controls", list.id);
104
130
  }
131
+ // Items that arrive or leave after the query (an async result source) are
132
+ // ranked like typed input: re-run the output effect and, for a palette,
133
+ // highlight the new best match. Only an added or removed *item* counts: a
134
+ // text swap inside an item or a result counter next to the list must not
135
+ // reset the highlight. The effect's own writes are attributes, so it never
136
+ // observes itself.
137
+ const itemSelector = this.partSelector("item");
138
+ const touchesItem = (node) => node instanceof Element &&
139
+ (node.matches(itemSelector) || node.querySelector(itemSelector) !== null);
140
+ const itemsObserver = new MutationObserver((records) => {
141
+ if (!records.some((r) => [...r.addedNodes, ...r.removedNodes].some(touchesItem)))
142
+ return;
143
+ this.itemsVersion.set(this.itemsVersion.get() + 1);
144
+ if (this.autoHighlight)
145
+ this.activeIndex.set(0);
146
+ });
147
+ itemsObserver.observe(list ?? panel, { childList: true, subtree: true });
148
+ signal.addEventListener("abort", () => itemsObserver.disconnect(), { once: true });
105
149
  // Input adapters: DOM events only write signals
106
150
  input.addEventListener("input", () => {
107
151
  this.query.set(input.value);
@@ -176,7 +220,7 @@ class TypeaheadElement extends ZazzElement {
176
220
  return;
177
221
  if (event.target.closest("input, textarea, select, [contenteditable]"))
178
222
  return;
179
- if (!event.target.closest(`[data-slot~="${prefix}-list"]`))
223
+ if (!event.target.closest(this.partSelector("list")))
180
224
  return;
181
225
  event.preventDefault();
182
226
  }, { signal });
@@ -185,7 +229,7 @@ class TypeaheadElement extends ZazzElement {
185
229
  panel.addEventListener("click", (event) => {
186
230
  if (!(event.target instanceof Element))
187
231
  return;
188
- const item = event.target.closest(`[data-slot~="${prefix}-item"]`);
232
+ const item = event.target.closest(this.partSelector("item"));
189
233
  if (item && !item.hidden)
190
234
  this.commit(item, "pointer");
191
235
  }, { signal });
@@ -232,7 +276,7 @@ class TypeaheadElement extends ZazzElement {
232
276
  return;
233
277
  }
234
278
  const { items, ranked, visible } = this.#rank(query);
235
- const sort = this.sortByScore;
279
+ const sort = this.ordersByScore;
236
280
  for (const verdict of ranked) {
237
281
  const item = items[verdict.index];
238
282
  item.hidden = verdict.hidden;
@@ -244,9 +288,9 @@ class TypeaheadElement extends ZazzElement {
244
288
  visible.forEach((item, index) => {
245
289
  item.id ||= `ui-${prefix}-item-${++typeaheadIdCounter}`;
246
290
  if (index === active)
247
- item.setAttribute("data-highlighted", "");
291
+ item.setAttribute(`data-${this.slotPrefix}-state`, "highlighted");
248
292
  else
249
- item.removeAttribute("data-highlighted");
293
+ item.removeAttribute(`data-${this.slotPrefix}-state`);
250
294
  });
251
295
  const highlighted = active >= 0 ? visible[active] : undefined;
252
296
  if (highlighted) {
@@ -267,11 +311,11 @@ class TypeaheadElement extends ZazzElement {
267
311
  const panel = this.panel;
268
312
  if (!panel)
269
313
  return [];
270
- return Array.from(panel.querySelectorAll(`[data-slot~="${this.slotPrefix}-item"]`)).filter((node) => node instanceof HTMLElement);
314
+ return Array.from(panel.querySelectorAll(this.partSelector("item"))).filter((node) => node instanceof HTMLElement);
271
315
  }
272
316
  /**
273
317
  * @description The visible items in visual order: score order when
274
- * `data-sort="score"`, DOM order otherwise, so arrow keys always follow
318
+ * `data-<prefix>-sort="score"`, DOM order otherwise, so arrow keys always follow
275
319
  * what the user sees.
276
320
  *
277
321
  * @param items - All items, DOM order.
@@ -280,7 +324,7 @@ class TypeaheadElement extends ZazzElement {
280
324
  */
281
325
  visibleItems(items, ranked) {
282
326
  const visible = ranked.filter((verdict) => !verdict.hidden);
283
- if (this.sortByScore)
327
+ if (this.ordersByScore)
284
328
  visible.sort((a, b) => b.score - a.score || a.index - b.index);
285
329
  return visible.map((verdict) => items[verdict.index]);
286
330
  }
@@ -296,10 +340,13 @@ class TypeaheadElement extends ZazzElement {
296
340
  * @private
297
341
  */
298
342
  #rank(query) {
343
+ this.itemsVersion.get();
299
344
  const items = this.items();
300
- const ranked = rankItems(query, items.map((item) => ({
345
+ const ranked = rankItems(this.filtersItems ? query : "", items.map((item) => ({
301
346
  value: this.itemValue(item),
302
- keywords: (item.getAttribute("data-keywords") ?? "").split(/\s+/).filter(Boolean),
347
+ keywords: (item.getAttribute(`data-${this.slotPrefix}-keywords`) ?? "")
348
+ .split(/\s+/)
349
+ .filter(Boolean),
303
350
  })));
304
351
  return { items, ranked, visible: this.visibleItems(items, ranked) };
305
352
  }
@@ -309,10 +356,10 @@ class TypeaheadElement extends ZazzElement {
309
356
  * value ("Go to docs ⇧⌘D" matches and announces as "Go to docs").
310
357
  *
311
358
  * @param item - The item element.
312
- * @returns `data-value` when present, trimmed hint-free text otherwise.
359
+ * @returns `data-<prefix>-value` when present, trimmed hint-free text otherwise.
313
360
  */
314
361
  itemValue(item) {
315
- const explicit = item.getAttribute("data-value");
362
+ const explicit = item.getAttribute(`data-${this.slotPrefix}-value`);
316
363
  if (explicit !== null)
317
364
  return explicit;
318
365
  if (!item.querySelector("kbd, ui-kbd-group"))
@@ -335,13 +382,13 @@ class TypeaheadElement extends ZazzElement {
335
382
  this.query.set("");
336
383
  }
337
384
  /**
338
- * @description Minimum query length before the panel opens (`data-min-length`).
385
+ * @description Minimum query length before the panel opens (`data-<prefix>-min-length`).
339
386
  *
340
387
  * @returns The threshold, 0 by default.
341
388
  * @private
342
389
  */
343
390
  #minLength() {
344
- const raw = Number(this.getAttribute("data-min-length"));
391
+ const raw = Number(this.config("min-length"));
345
392
  return Number.isFinite(raw) && raw > 0 ? raw : 0;
346
393
  }
347
394
  /**