@zazz-ui/core 0.15.1 → 0.16.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 (247) hide show
  1. package/AUTHORING.md +29 -14
  2. package/CHANGELOG.md +156 -0
  3. package/README.md +6 -5
  4. package/dist/{csp-LRx1fynI.js → csp-C1f62vyT.js} +1 -1
  5. package/dist/sri.json +70 -65
  6. package/dist/zazz.css +1 -1
  7. package/dist/zazz.js +1 -1
  8. package/editor/zazz.css-data.json +74 -2
  9. package/editor/zazz.html-data.json +119 -79
  10. package/editor/zazz.language-data.json +401 -313
  11. package/editor/zazz.lint-data.json +1752 -1731
  12. package/package.json +2 -1
  13. package/src/base/_defaults.css +11 -11
  14. package/src/base/_reset.css +2 -10
  15. package/src/base/_typography.css +17 -568
  16. package/src/base/_utilities-box.css +17 -17
  17. package/src/base/_utilities-pseudo.css +2 -2
  18. package/src/base/_variables.css +142 -97
  19. package/src/base/carousel-scroll.d.ts +1 -1
  20. package/src/base/carousel-scroll.js +6 -6
  21. package/src/base/carousel-scroll.ts +6 -6
  22. package/src/base/carousel.d.ts.map +1 -1
  23. package/src/base/carousel.js +6 -2
  24. package/src/base/carousel.ts +6 -2
  25. package/src/base/csp.js +2 -2
  26. package/src/base/csp.ts +2 -2
  27. package/src/base/kit-styling.d.ts.map +1 -1
  28. package/src/base/kit-styling.js +186 -183
  29. package/src/base/kit-styling.ts +186 -183
  30. package/src/base/navigation.d.ts +2 -2
  31. package/src/base/navigation.d.ts.map +1 -1
  32. package/src/base/navigation.js +25 -21
  33. package/src/base/navigation.ts +27 -21
  34. package/src/base/utilities.d.ts +1 -1
  35. package/src/base/utilities.d.ts.map +1 -1
  36. package/src/base/utilities.js +20 -4
  37. package/src/base/utilities.ts +21 -5
  38. package/src/base/zazz-element.d.ts +1 -1
  39. package/src/base/zazz-element.js +1 -1
  40. package/src/base/zazz-element.ts +1 -1
  41. package/src/{base → behaviors}/gesture.d.ts +4 -3
  42. package/src/behaviors/gesture.d.ts.map +1 -0
  43. package/src/{base → behaviors}/gesture.js +1 -1
  44. package/src/{base → behaviors}/gesture.ts +5 -4
  45. package/src/{base → behaviors}/hotkeys.d.ts +2 -1
  46. package/src/behaviors/hotkeys.d.ts.map +1 -0
  47. package/src/{base → behaviors}/hotkeys.ts +2 -1
  48. package/src/behaviors/list-navigation.d.ts +64 -0
  49. package/src/behaviors/list-navigation.d.ts.map +1 -0
  50. package/src/behaviors/list-navigation.js +66 -0
  51. package/src/behaviors/list-navigation.ts +107 -0
  52. package/src/{base → behaviors}/typeahead.d.ts +3 -1
  53. package/src/behaviors/typeahead.d.ts.map +1 -0
  54. package/src/{base → behaviors}/typeahead.js +12 -17
  55. package/src/{base → behaviors}/typeahead.ts +12 -17
  56. package/src/css-properties.json +704 -0
  57. package/src/index.css +7 -0
  58. package/src/manifest.d.ts +20 -9
  59. package/src/manifest.d.ts.map +1 -1
  60. package/src/manifest.js +125 -37
  61. package/src/manifest.ts +132 -38
  62. package/src/primitives/accordion/accordion.json +49 -0
  63. package/src/primitives/alert-dialog/alert-dialog.json +35 -0
  64. package/src/primitives/autocomplete/autocomplete.d.ts +2 -2
  65. package/src/primitives/autocomplete/autocomplete.d.ts.map +1 -1
  66. package/src/primitives/autocomplete/autocomplete.js +2 -2
  67. package/src/primitives/autocomplete/autocomplete.json +65 -0
  68. package/src/primitives/autocomplete/autocomplete.ts +2 -2
  69. package/src/primitives/avatar/avatar.css +108 -0
  70. package/src/primitives/avatar/avatar.html +20 -74
  71. package/src/primitives/avatar/avatar.json +48 -0
  72. package/src/primitives/badge/badge.css +45 -10
  73. package/src/primitives/badge/badge.html +4 -0
  74. package/src/primitives/badge/badge.json +83 -0
  75. package/src/primitives/breadcrumbs/breadcrumbs.json +20 -0
  76. package/src/primitives/button/button.css +50 -66
  77. package/src/primitives/button/button.html +4 -0
  78. package/src/primitives/button/button.json +85 -0
  79. package/src/primitives/button-group/button-group.css +4 -15
  80. package/src/primitives/button-group/button-group.json +40 -0
  81. package/src/primitives/callout/callout.css +1 -1
  82. package/src/primitives/callout/callout.html +12 -12
  83. package/src/primitives/callout/callout.json +54 -0
  84. package/src/primitives/card/card-article.html +13 -37
  85. package/src/primitives/card/card-horizontal.html +11 -14
  86. package/src/primitives/card/card-login.html +4 -4
  87. package/src/primitives/card/card-product.html +3 -3
  88. package/src/primitives/card/card-subgrid.html +4 -4
  89. package/src/primitives/card/card.css +1 -1
  90. package/src/primitives/card/card.html +8 -8
  91. package/src/primitives/card/card.json +73 -0
  92. package/src/primitives/carousel/carousel.css +1 -1
  93. package/src/primitives/carousel/carousel.json +89 -0
  94. package/src/primitives/checkbox/checkbox.css +1 -2
  95. package/src/primitives/checkbox/checkbox.json +51 -0
  96. package/src/primitives/combobox/combobox.css +3 -2
  97. package/src/primitives/combobox/combobox.d.ts +2 -2
  98. package/src/primitives/combobox/combobox.d.ts.map +1 -1
  99. package/src/primitives/combobox/combobox.js +2 -2
  100. package/src/primitives/combobox/combobox.json +113 -0
  101. package/src/primitives/combobox/combobox.ts +2 -2
  102. package/src/primitives/command/command-actions.html +1 -1
  103. package/src/primitives/command/command.d.ts +4 -3
  104. package/src/primitives/command/command.d.ts.map +1 -1
  105. package/src/primitives/command/command.js +7 -6
  106. package/src/primitives/command/command.json +86 -0
  107. package/src/primitives/command/command.ts +7 -6
  108. package/src/primitives/debug/audit-core.d.ts +19 -12
  109. package/src/primitives/debug/audit-core.d.ts.map +1 -1
  110. package/src/primitives/debug/audit-core.js +78 -16
  111. package/src/primitives/debug/audit-core.ts +94 -22
  112. package/src/primitives/debug/debug.d.ts +6 -4
  113. package/src/primitives/debug/debug.d.ts.map +1 -1
  114. package/src/primitives/debug/debug.js +50 -21
  115. package/src/primitives/debug/debug.json +29 -0
  116. package/src/primitives/debug/debug.ts +57 -35
  117. package/src/primitives/dialog/dialog.css +1 -4
  118. package/src/primitives/dialog/dialog.json +78 -0
  119. package/src/primitives/drawer/drawer.css +4 -2
  120. package/src/primitives/drawer/drawer.d.ts.map +1 -1
  121. package/src/primitives/drawer/drawer.js +76 -4
  122. package/src/primitives/drawer/drawer.json +98 -0
  123. package/src/primitives/drawer/drawer.ts +78 -5
  124. package/src/primitives/fields/fields.css +11 -4
  125. package/src/primitives/fields/fields.json +92 -0
  126. package/src/primitives/font/font.css +188 -0
  127. package/src/primitives/font/font.html +14 -0
  128. package/src/primitives/font/font.json +39 -0
  129. package/src/primitives/group/group.json +25 -0
  130. package/src/primitives/input/input.css +1 -2
  131. package/src/primitives/input/input.json +56 -0
  132. package/src/primitives/input-group/input-group-password-group.html +1 -1
  133. package/src/primitives/input-group/input-group.css +32 -3
  134. package/src/primitives/input-group/input-group.html +5 -8
  135. package/src/primitives/input-group/input-group.json +69 -0
  136. package/src/primitives/kbd/kbd.css +1 -1
  137. package/src/primitives/kbd/kbd.json +52 -0
  138. package/src/primitives/layout/layout.json +45 -0
  139. package/src/primitives/lightbox/lightbox.css +4 -3
  140. package/src/primitives/lightbox/lightbox.html +2 -2
  141. package/src/primitives/lightbox/lightbox.js +1 -1
  142. package/src/primitives/lightbox/lightbox.json +87 -0
  143. package/src/primitives/lightbox/lightbox.ts +1 -1
  144. package/src/primitives/link/link.css +28 -0
  145. package/src/primitives/link/link.html +5 -0
  146. package/src/primitives/link/link.json +23 -0
  147. package/src/primitives/menu/menu.d.ts +3 -0
  148. package/src/primitives/menu/menu.d.ts.map +1 -1
  149. package/src/primitives/menu/menu.js +10 -25
  150. package/src/primitives/menu/menu.json +51 -0
  151. package/src/primitives/menu/menu.ts +10 -27
  152. package/src/primitives/menubar/menubar.json +23 -0
  153. package/src/primitives/meter/meter.css +24 -3
  154. package/src/primitives/meter/meter.json +41 -0
  155. package/src/primitives/mobile-menu/mobile-menu.html +1 -1
  156. package/src/primitives/mobile-menu/mobile-menu.json +64 -0
  157. package/src/primitives/navigation-menu/navigation-menu-featured.html +58 -58
  158. package/src/primitives/navigation-menu/navigation-menu-megamenu.html +6 -113
  159. package/src/primitives/navigation-menu/navigation-menu.css +11 -5
  160. package/src/primitives/navigation-menu/navigation-menu.html +1 -1
  161. package/src/primitives/navigation-menu/navigation-menu.json +82 -0
  162. package/src/primitives/otp/otp.css +1 -1
  163. package/src/primitives/otp/otp.d.ts +3 -3
  164. package/src/primitives/otp/otp.js +5 -5
  165. package/src/primitives/otp/otp.json +75 -0
  166. package/src/primitives/otp/otp.ts +5 -5
  167. package/src/primitives/password-group/password-group.css +32 -2
  168. package/src/primitives/password-group/password-group.html +1 -1
  169. package/src/primitives/password-group/password-group.json +74 -0
  170. package/src/primitives/popover/popover.css +1 -1
  171. package/src/primitives/popover/popover.json +64 -0
  172. package/src/primitives/progress/progress.css +25 -3
  173. package/src/primitives/progress/progress.json +41 -0
  174. package/src/primitives/prose/prose.css +341 -0
  175. package/src/primitives/prose/prose.html +11 -11
  176. package/src/primitives/prose/prose.json +47 -0
  177. package/src/primitives/radio/radio.css +1 -1
  178. package/src/primitives/radio/radio.json +48 -0
  179. package/src/primitives/reveal/reveal.json +72 -0
  180. package/src/primitives/scroll-fade/scroll-fade.css +0 -3
  181. package/src/primitives/scroll-fade/scroll-fade.json +34 -0
  182. package/src/primitives/select/select.css +2 -2
  183. package/src/primitives/select/select.json +119 -0
  184. package/src/primitives/separator/separator.json +34 -0
  185. package/src/primitives/slider/slider.css +87 -13
  186. package/src/primitives/slider/slider.json +49 -0
  187. package/src/primitives/style-guard/style-guard.js +1 -1
  188. package/src/primitives/style-guard/style-guard.json +22 -0
  189. package/src/primitives/style-guard/style-guard.ts +2 -2
  190. package/src/primitives/switch/switch.css +107 -18
  191. package/src/primitives/switch/switch.json +71 -0
  192. package/src/primitives/table/table.json +74 -0
  193. package/src/primitives/tabs/tabs.css +24 -12
  194. package/src/primitives/tabs/tabs.d.ts +4 -2
  195. package/src/primitives/tabs/tabs.d.ts.map +1 -1
  196. package/src/primitives/tabs/tabs.js +14 -24
  197. package/src/primitives/tabs/tabs.json +94 -0
  198. package/src/primitives/tabs/tabs.ts +14 -26
  199. package/src/primitives/textarea/textarea.css +1 -1
  200. package/src/primitives/textarea/textarea.json +48 -0
  201. package/src/primitives/toaster/toaster.d.ts.map +1 -1
  202. package/src/primitives/toaster/toaster.js +4 -4
  203. package/src/primitives/toaster/toaster.json +101 -0
  204. package/src/primitives/toaster/toaster.ts +5 -5
  205. package/src/primitives/toggle/toggle.css +2 -52
  206. package/src/primitives/toggle/toggle.json +84 -0
  207. package/src/primitives/toggle-group/toggle-group.css +1 -1
  208. package/src/primitives/toggle-group/toggle-group.json +41 -0
  209. package/src/primitives/toolbar/toolbar.json +26 -0
  210. package/src/primitives/tooltip/tooltip.css +1 -1
  211. package/src/primitives/tooltip/tooltip.json +85 -0
  212. package/src/primitives/utilities/aspect-ratio.html +3 -3
  213. package/src/primitives/utilities/basis.html +5 -5
  214. package/src/primitives/utilities/col-span.html +5 -5
  215. package/src/primitives/utilities/compose.html +3 -3
  216. package/src/primitives/utilities/flex-align.html +3 -3
  217. package/src/primitives/utilities/flex-direction.html +8 -8
  218. package/src/primitives/utilities/flex-grow.html +3 -3
  219. package/src/primitives/utilities/flex-reverse.html +8 -8
  220. package/src/primitives/utilities/gallery.html +19 -19
  221. package/src/primitives/utilities/gap.html +12 -12
  222. package/src/primitives/utilities/grid-cols.html +6 -6
  223. package/src/primitives/utilities/grid-responsive.html +9 -9
  224. package/src/primitives/utilities/inline-flex.html +2 -2
  225. package/src/primitives/utilities/margin-auto.html +1 -1
  226. package/src/primitives/utilities/object-fit.html +3 -3
  227. package/src/primitives/utilities/order.html +3 -3
  228. package/src/primitives/utilities/overflow.html +14 -14
  229. package/src/primitives/utilities/padding-compose.html +3 -3
  230. package/src/primitives/utilities/padding.html +4 -4
  231. package/src/primitives/utilities/position.html +1 -1
  232. package/src/primitives/utilities/responsive-flex.html +4 -4
  233. package/src/primitives/utilities/responsive-grid.html +9 -9
  234. package/src/primitives/utilities/size.html +5 -5
  235. package/src/primitives/utilities/subgrid-col.html +7 -7
  236. package/src/primitives/utilities/subgrid-row.html +9 -9
  237. package/src/primitives/utilities/subgrid.html +9 -9
  238. package/src/primitives/utilities/utilities.json +48 -0
  239. package/src/primitives/utilities/width.html +5 -5
  240. package/src/base/gesture.d.ts.map +0 -1
  241. package/src/base/hotkeys.d.ts.map +0 -1
  242. package/src/base/typeahead.d.ts.map +0 -1
  243. /package/src/{base → behaviors}/command-score.d.ts +0 -0
  244. /package/src/{base → behaviors}/command-score.d.ts.map +0 -0
  245. /package/src/{base → behaviors}/command-score.js +0 -0
  246. /package/src/{base → behaviors}/command-score.ts +0 -0
  247. /package/src/{base → behaviors}/hotkeys.js +0 -0
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ // --- Keys ---
3
+ /**
4
+ * @description Maps a key to a step through a list. The arrows across the
5
+ * list's orientation are not steps, so a vertical list leaves ArrowLeft and
6
+ * ArrowRight to the page.
7
+ *
8
+ * @param key - The `KeyboardEvent.key` pressed.
9
+ * @param layout - The list's orientation and writing direction.
10
+ * @returns The step, or null when the key does not move through the list.
11
+ */
12
+ function listStep(key, layout = {}) {
13
+ if (key === "Home")
14
+ return "first";
15
+ if (key === "End")
16
+ return "last";
17
+ if (layout.orientation === "horizontal") {
18
+ const [previous, next] = layout.rtl ? ["ArrowRight", "ArrowLeft"] : ["ArrowLeft", "ArrowRight"];
19
+ if (key === next)
20
+ return "next";
21
+ if (key === previous)
22
+ return "previous";
23
+ return null;
24
+ }
25
+ if (key === "ArrowDown")
26
+ return "next";
27
+ if (key === "ArrowUp")
28
+ return "previous";
29
+ return null;
30
+ }
31
+ // --- Index ---
32
+ /**
33
+ * @description Reducer for a step through a wrapping list. From no current
34
+ * item, `next` enters at the first item and `previous` at the last.
35
+ *
36
+ * @param current - The current index, -1 for none.
37
+ * @param step - The step to take.
38
+ * @param count - How many items the list has.
39
+ * @returns The index the step lands on, -1 when the list is empty.
40
+ */
41
+ function stepIndex(current, step, count) {
42
+ if (count === 0)
43
+ return -1;
44
+ switch (step) {
45
+ case "next":
46
+ return current < 0 ? 0 : (current + 1) % count;
47
+ case "previous":
48
+ return current < 0 ? count - 1 : (current - 1 + count) % count;
49
+ case "first":
50
+ return 0;
51
+ case "last":
52
+ return count - 1;
53
+ }
54
+ }
55
+ // --- Items ---
56
+ /**
57
+ * @description Whether the keys skip an item: a disabled form control, or any
58
+ * element marked `aria-disabled="true"` (a link has no `disabled`).
59
+ *
60
+ * @param item - The list item.
61
+ * @returns True when the item is disabled.
62
+ */
63
+ function isDisabledItem(item) {
64
+ return item.matches(":disabled") || item.getAttribute("aria-disabled") === "true";
65
+ }
66
+ export { listStep, stepIndex, isDisabledItem };
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @fileoverview List navigation: the keys that move through a list of items.
5
+ * @description The decision half of arrow-key navigation, shared by the
6
+ * tabs, the menu, and the typeahead engine (autocomplete, combobox, command).
7
+ *
8
+ * A key press is two questions, and each has one function:
9
+ *
10
+ * - `listStep()`: which step is this key? The arrows along the list's
11
+ * orientation are `next` and `previous`, mirrored in RTL for a horizontal
12
+ * list; Home and End are `first` and `last`. Any other key is `null`, so the
13
+ * caller returns before it calls `preventDefault()`.
14
+ * - `stepIndex()`: where does that step land? Lists wrap at both ends.
15
+ *
16
+ * The primitive owns everything else: which elements are items, and what
17
+ * moving means there (focus a link, check a radio, set
18
+ * `aria-activedescendant`). `isDisabledItem()` is the one test for an item the
19
+ * keys skip.
20
+ *
21
+ * @example
22
+ * const step = listStep(event.key, { orientation: "horizontal", rtl });
23
+ * if (!step) return;
24
+ * event.preventDefault();
25
+ * items[stepIndex(items.indexOf(target), step, items.length)]?.focus();
26
+ */
27
+
28
+ // --- Types ---
29
+
30
+ /** A move through a list. */
31
+ type ListStep = "next" | "previous" | "first" | "last";
32
+
33
+ /** How a list is laid out, which decides the arrow keys that move through it. */
34
+ interface ListLayout {
35
+ /** The axis the items run along. Defaults to `vertical`. */
36
+ orientation?: "vertical" | "horizontal";
37
+ /** Whether the list's writing direction is right to left. Only a horizontal list reads it. */
38
+ rtl?: boolean;
39
+ }
40
+
41
+ // --- Keys ---
42
+
43
+ /**
44
+ * @description Maps a key to a step through a list. The arrows across the
45
+ * list's orientation are not steps, so a vertical list leaves ArrowLeft and
46
+ * ArrowRight to the page.
47
+ *
48
+ * @param key - The `KeyboardEvent.key` pressed.
49
+ * @param layout - The list's orientation and writing direction.
50
+ * @returns The step, or null when the key does not move through the list.
51
+ */
52
+ function listStep(key: string, layout: ListLayout = {}): ListStep | null {
53
+ if (key === "Home") return "first";
54
+ if (key === "End") return "last";
55
+
56
+ if (layout.orientation === "horizontal") {
57
+ const [previous, next] = layout.rtl ? ["ArrowRight", "ArrowLeft"] : ["ArrowLeft", "ArrowRight"];
58
+ if (key === next) return "next";
59
+ if (key === previous) return "previous";
60
+ return null;
61
+ }
62
+
63
+ if (key === "ArrowDown") return "next";
64
+ if (key === "ArrowUp") return "previous";
65
+ return null;
66
+ }
67
+
68
+ // --- Index ---
69
+
70
+ /**
71
+ * @description Reducer for a step through a wrapping list. From no current
72
+ * item, `next` enters at the first item and `previous` at the last.
73
+ *
74
+ * @param current - The current index, -1 for none.
75
+ * @param step - The step to take.
76
+ * @param count - How many items the list has.
77
+ * @returns The index the step lands on, -1 when the list is empty.
78
+ */
79
+ function stepIndex(current: number, step: ListStep, count: number): number {
80
+ if (count === 0) return -1;
81
+ switch (step) {
82
+ case "next":
83
+ return current < 0 ? 0 : (current + 1) % count;
84
+ case "previous":
85
+ return current < 0 ? count - 1 : (current - 1 + count) % count;
86
+ case "first":
87
+ return 0;
88
+ case "last":
89
+ return count - 1;
90
+ }
91
+ }
92
+
93
+ // --- Items ---
94
+
95
+ /**
96
+ * @description Whether the keys skip an item: a disabled form control, or any
97
+ * element marked `aria-disabled="true"` (a link has no `disabled`).
98
+ *
99
+ * @param item - The list item.
100
+ * @returns True when the item is disabled.
101
+ */
102
+ function isDisabledItem(item: Element): boolean {
103
+ return item.matches(":disabled") || item.getAttribute("aria-disabled") === "true";
104
+ }
105
+
106
+ export { listStep, stepIndex, isDisabledItem };
107
+ export type { ListLayout, ListStep };
@@ -1,4 +1,4 @@
1
- import { ZazzElement } from "./zazz-element.ts";
1
+ import { ZazzElement } from "../base/zazz-element.ts";
2
2
  /** What the ranker needs to know about one item. */
3
3
  interface ItemFacts {
4
4
  /** The text scored and committed: `data-<prefix>-value` ?? trimmed text content. */
@@ -27,6 +27,8 @@ declare function rankItems(query: string, items: readonly ItemFacts[]): RankedIt
27
27
  /**
28
28
  * @description Reducer for active-item keyboard navigation. ArrowDown from
29
29
  * nothing highlights the first item, ArrowUp from nothing the last; both wrap.
30
+ * The steps are the shared list navigation behavior's
31
+ * (`behaviors/list-navigation.ts`); a key that is not a step keeps the index.
30
32
  *
31
33
  * @param current - The currently active index, -1 for none.
32
34
  * @param key - The `KeyboardEvent.key` pressed.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeahead.d.ts","sourceRoot":"","sources":["typeahead.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAMtD,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;;;;;;;;;;GAUG;AACH,iBAAS,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI5E;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;CA8EF;AAED,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AACxD,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC"}
@@ -4,7 +4,8 @@
4
4
  * @description The common runtime behind the filter-as-you-type family: a
5
5
  * query signal fed by the input, score-based ranking of real DOM items
6
6
  * (`commandScore`), active-item keyboard navigation with
7
- * `aria-activedescendant` (focus never leaves the input), and, for form
7
+ * `aria-activedescendant` (focus never leaves the input; the steps are the
8
+ * list navigation behavior's, `behaviors/list-navigation.ts`), and, for form
8
9
  * controls whose panel sits outside the input, ownership of a
9
10
  * `popover="manual"` panel with outside-pointerdown and Escape close paths.
10
11
  *
@@ -22,8 +23,9 @@
22
23
  * removed from the list after the query are ranked like typed input.
23
24
  */
24
25
  import { commandScore } from "./command-score.js";
25
- import { ZazzElement } from "./zazz-element.js";
26
- import { effect, state } from "./signals.js";
26
+ import { ZazzElement } from "../base/zazz-element.js";
27
+ import { effect, state } from "../base/signals.js";
28
+ import { listStep, stepIndex } from "./list-navigation.js";
27
29
  /**
28
30
  * @description Scores every item against the query. An empty query leaves all
29
31
  * items visible with a neutral score.
@@ -42,6 +44,8 @@ function rankItems(query, items) {
42
44
  /**
43
45
  * @description Reducer for active-item keyboard navigation. ArrowDown from
44
46
  * nothing highlights the first item, ArrowUp from nothing the last; both wrap.
47
+ * The steps are the shared list navigation behavior's
48
+ * (`behaviors/list-navigation.ts`); a key that is not a step keeps the index.
45
49
  *
46
50
  * @param current - The currently active index, -1 for none.
47
51
  * @param key - The `KeyboardEvent.key` pressed.
@@ -51,18 +55,8 @@ function rankItems(query, items) {
51
55
  function nextActiveIndex(current, key, count) {
52
56
  if (count === 0)
53
57
  return -1;
54
- switch (key) {
55
- case "ArrowDown":
56
- return current < 0 ? 0 : (current + 1) % count;
57
- case "ArrowUp":
58
- return current < 0 ? count - 1 : (current - 1 + count) % count;
59
- case "Home":
60
- return 0;
61
- case "End":
62
- return count - 1;
63
- default:
64
- return current;
65
- }
58
+ const step = listStep(key);
59
+ return step ? stepIndex(current, step, count) : current;
66
60
  }
67
61
  // --- Element base ---
68
62
  let typeaheadIdCounter = 0;
@@ -434,9 +428,10 @@ class TypeaheadElement extends ZazzElement {
434
428
  }
435
429
  return;
436
430
  }
437
- if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
431
+ const step = listStep(event.key);
432
+ if (step) {
438
433
  // Home/End belong to the text caret unless an item is already active
439
- if ((event.key === "Home" || event.key === "End") && this.activeIndex.get() < 0)
434
+ if ((step === "first" || step === "last") && this.activeIndex.get() < 0)
440
435
  return;
441
436
  event.preventDefault();
442
437
  if (this.managesPanel && !this.open.get())
@@ -5,7 +5,8 @@
5
5
  * @description The common runtime behind the filter-as-you-type family: a
6
6
  * query signal fed by the input, score-based ranking of real DOM items
7
7
  * (`commandScore`), active-item keyboard navigation with
8
- * `aria-activedescendant` (focus never leaves the input), and, for form
8
+ * `aria-activedescendant` (focus never leaves the input; the steps are the
9
+ * list navigation behavior's, `behaviors/list-navigation.ts`), and, for form
9
10
  * controls whose panel sits outside the input, ownership of a
10
11
  * `popover="manual"` panel with outside-pointerdown and Escape close paths.
11
12
  *
@@ -24,8 +25,9 @@
24
25
  */
25
26
 
26
27
  import { commandScore } from "./command-score.ts";
27
- import { ZazzElement } from "./zazz-element.ts";
28
- import { effect, state } from "./signals.ts";
28
+ import { ZazzElement } from "../base/zazz-element.ts";
29
+ import { effect, state } from "../base/signals.ts";
30
+ import { listStep, stepIndex } from "./list-navigation.ts";
29
31
 
30
32
  // --- Pure ranking and navigation ---
31
33
 
@@ -66,6 +68,8 @@ function rankItems(query: string, items: readonly ItemFacts[]): RankedItem[] {
66
68
  /**
67
69
  * @description Reducer for active-item keyboard navigation. ArrowDown from
68
70
  * nothing highlights the first item, ArrowUp from nothing the last; both wrap.
71
+ * The steps are the shared list navigation behavior's
72
+ * (`behaviors/list-navigation.ts`); a key that is not a step keeps the index.
69
73
  *
70
74
  * @param current - The currently active index, -1 for none.
71
75
  * @param key - The `KeyboardEvent.key` pressed.
@@ -74,18 +78,8 @@ function rankItems(query: string, items: readonly ItemFacts[]): RankedItem[] {
74
78
  */
75
79
  function nextActiveIndex(current: number, key: string, count: number): number {
76
80
  if (count === 0) return -1;
77
- switch (key) {
78
- case "ArrowDown":
79
- return current < 0 ? 0 : (current + 1) % count;
80
- case "ArrowUp":
81
- return current < 0 ? count - 1 : (current - 1 + count) % count;
82
- case "Home":
83
- return 0;
84
- case "End":
85
- return count - 1;
86
- default:
87
- return current;
88
- }
81
+ const step = listStep(key);
82
+ return step ? stepIndex(current, step, count) : current;
89
83
  }
90
84
 
91
85
  // --- Element base ---
@@ -525,9 +519,10 @@ abstract class TypeaheadElement extends ZazzElement {
525
519
  return;
526
520
  }
527
521
 
528
- if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
522
+ const step = listStep(event.key);
523
+ if (step) {
529
524
  // Home/End belong to the text caret unless an item is already active
530
- if ((event.key === "Home" || event.key === "End") && this.activeIndex.get() < 0) return;
525
+ if ((step === "first" || step === "last") && this.activeIndex.get() < 0) return;
531
526
  event.preventDefault();
532
527
  if (this.managesPanel && !this.open.get()) this.open.set(true);
533
528
  const count = this.#rank(this.query.get()).visible.length;