@zazz-ui/core 0.1.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 (260) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +21 -0
  3. package/README.md +61 -0
  4. package/dist/sri.json +75 -0
  5. package/dist/zazz.css +1 -0
  6. package/dist/zazz.js +1 -0
  7. package/examples/about.html +590 -0
  8. package/examples/components.html +1040 -0
  9. package/examples/forms.html +511 -0
  10. package/examples/index.html +268 -0
  11. package/examples/layout.html +320 -0
  12. package/examples/products.html +846 -0
  13. package/examples/responsive.html +339 -0
  14. package/package.json +85 -0
  15. package/src/base/_layers.css +12 -0
  16. package/src/base/_layout.css +568 -0
  17. package/src/base/_reset.css +515 -0
  18. package/src/base/_typography.css +495 -0
  19. package/src/base/_utilities.css +6628 -0
  20. package/src/base/_variables.css +682 -0
  21. package/src/base/_view-transitions.css +103 -0
  22. package/src/base/command-score.d.ts +12 -0
  23. package/src/base/command-score.d.ts.map +1 -0
  24. package/src/base/command-score.js +151 -0
  25. package/src/base/command-score.ts +192 -0
  26. package/src/base/dialog-lifecycle.d.ts +11 -0
  27. package/src/base/dialog-lifecycle.d.ts.map +1 -0
  28. package/src/base/dialog-lifecycle.js +65 -0
  29. package/src/base/dialog-lifecycle.ts +80 -0
  30. package/src/base/embla.d.ts +90 -0
  31. package/src/base/embla.d.ts.map +1 -0
  32. package/src/base/embla.js +643 -0
  33. package/src/base/embla.ts +791 -0
  34. package/src/base/hotkeys.d.ts +82 -0
  35. package/src/base/hotkeys.d.ts.map +1 -0
  36. package/src/base/hotkeys.js +141 -0
  37. package/src/base/hotkeys.ts +195 -0
  38. package/src/base/navigation.d.ts +2 -0
  39. package/src/base/navigation.d.ts.map +1 -0
  40. package/src/base/navigation.js +136 -0
  41. package/src/base/navigation.ts +151 -0
  42. package/src/base/reveal.d.ts +80 -0
  43. package/src/base/reveal.d.ts.map +1 -0
  44. package/src/base/reveal.js +305 -0
  45. package/src/base/reveal.ts +379 -0
  46. package/src/base/signals.d.ts +89 -0
  47. package/src/base/signals.d.ts.map +1 -0
  48. package/src/base/signals.js +134 -0
  49. package/src/base/signals.ts +164 -0
  50. package/src/base/typeahead.d.ts +105 -0
  51. package/src/base/typeahead.d.ts.map +1 -0
  52. package/src/base/typeahead.js +411 -0
  53. package/src/base/typeahead.ts +500 -0
  54. package/src/base/utils.d.ts +56 -0
  55. package/src/base/utils.d.ts.map +1 -0
  56. package/src/base/utils.js +88 -0
  57. package/src/base/utils.ts +98 -0
  58. package/src/base/zazz-element.d.ts +44 -0
  59. package/src/base/zazz-element.d.ts.map +1 -0
  60. package/src/base/zazz-element.js +59 -0
  61. package/src/base/zazz-element.ts +73 -0
  62. package/src/globals.d.ts +148 -0
  63. package/src/head.d.ts +95 -0
  64. package/src/head.d.ts.map +1 -0
  65. package/src/head.js +311 -0
  66. package/src/head.ts +433 -0
  67. package/src/index.css +71 -0
  68. package/src/index.d.ts +36 -0
  69. package/src/index.d.ts.map +1 -0
  70. package/src/index.js +35 -0
  71. package/src/index.ts +36 -0
  72. package/src/manifest.d.ts +90 -0
  73. package/src/manifest.d.ts.map +1 -0
  74. package/src/manifest.js +614 -0
  75. package/src/manifest.ts +667 -0
  76. package/src/primitives/accordion/accordion.css +104 -0
  77. package/src/primitives/accordion/accordion.html +69 -0
  78. package/src/primitives/alert-dialog/alert-dialog.css +38 -0
  79. package/src/primitives/alert-dialog/alert-dialog.html +53 -0
  80. package/src/primitives/autocomplete/autocomplete-groups.html +77 -0
  81. package/src/primitives/autocomplete/autocomplete.css +114 -0
  82. package/src/primitives/autocomplete/autocomplete.d.ts +30 -0
  83. package/src/primitives/autocomplete/autocomplete.d.ts.map +1 -0
  84. package/src/primitives/autocomplete/autocomplete.html +66 -0
  85. package/src/primitives/autocomplete/autocomplete.js +41 -0
  86. package/src/primitives/autocomplete/autocomplete.ts +46 -0
  87. package/src/primitives/avatar/avatar.html +44 -0
  88. package/src/primitives/badge/badge-icon.html +36 -0
  89. package/src/primitives/badge/badge.css +251 -0
  90. package/src/primitives/badge/badge.html +7 -0
  91. package/src/primitives/breadcrumbs/breadcrumbs.html +9 -0
  92. package/src/primitives/button/button-icon-only.html +84 -0
  93. package/src/primitives/button/button-icon.html +82 -0
  94. package/src/primitives/button/button.css +319 -0
  95. package/src/primitives/button/button.html +8 -0
  96. package/src/primitives/button-group/button-group-vertical.html +6 -0
  97. package/src/primitives/button-group/button-group.css +94 -0
  98. package/src/primitives/button-group/button-group.html +64 -0
  99. package/src/primitives/card/card-subgrid.html +118 -0
  100. package/src/primitives/card/card.html +53 -0
  101. package/src/primitives/carousel/carousel.css +61 -0
  102. package/src/primitives/carousel/carousel.d.ts +16 -0
  103. package/src/primitives/carousel/carousel.d.ts.map +1 -0
  104. package/src/primitives/carousel/carousel.html +315 -0
  105. package/src/primitives/carousel/carousel.js +73 -0
  106. package/src/primitives/carousel/carousel.ts +84 -0
  107. package/src/primitives/checkbox/checkbox-tasklist.html +71 -0
  108. package/src/primitives/checkbox/checkbox.css +82 -0
  109. package/src/primitives/checkbox/checkbox.d.ts +21 -0
  110. package/src/primitives/checkbox/checkbox.d.ts.map +1 -0
  111. package/src/primitives/checkbox/checkbox.html +17 -0
  112. package/src/primitives/checkbox/checkbox.js +190 -0
  113. package/src/primitives/checkbox/checkbox.ts +219 -0
  114. package/src/primitives/combobox/combobox-multiselect.html +91 -0
  115. package/src/primitives/combobox/combobox.css +307 -0
  116. package/src/primitives/combobox/combobox.d.ts +100 -0
  117. package/src/primitives/combobox/combobox.d.ts.map +1 -0
  118. package/src/primitives/combobox/combobox.html +73 -0
  119. package/src/primitives/combobox/combobox.js +503 -0
  120. package/src/primitives/combobox/combobox.ts +559 -0
  121. package/src/primitives/command/command-actions.d.ts +31 -0
  122. package/src/primitives/command/command-actions.d.ts.map +1 -0
  123. package/src/primitives/command/command-actions.html +89 -0
  124. package/src/primitives/command/command-actions.js +70 -0
  125. package/src/primitives/command/command-actions.ts +77 -0
  126. package/src/primitives/command/command-dialog.html +77 -0
  127. package/src/primitives/command/command.css +151 -0
  128. package/src/primitives/command/command.d.ts +52 -0
  129. package/src/primitives/command/command.d.ts.map +1 -0
  130. package/src/primitives/command/command.html +119 -0
  131. package/src/primitives/command/command.js +146 -0
  132. package/src/primitives/command/command.ts +157 -0
  133. package/src/primitives/dialog/dialog-with-form.html +200 -0
  134. package/src/primitives/dialog/dialog.css +229 -0
  135. package/src/primitives/dialog/dialog.html +90 -0
  136. package/src/primitives/fields/fields.css +278 -0
  137. package/src/primitives/input/input-icon-leading.html +19 -0
  138. package/src/primitives/input/input-icon-trailing.html +18 -0
  139. package/src/primitives/input/input.css +114 -0
  140. package/src/primitives/input/input.html +61 -0
  141. package/src/primitives/input-group/input-group-password-group.html +108 -0
  142. package/src/primitives/input-group/input-group.css +215 -0
  143. package/src/primitives/input-group/input-group.html +132 -0
  144. package/src/primitives/kbd/kbd-group.html +18 -0
  145. package/src/primitives/kbd/kbd.css +87 -0
  146. package/src/primitives/kbd/kbd.html +7 -0
  147. package/src/primitives/lightbox/lightbox.css +459 -0
  148. package/src/primitives/lightbox/lightbox.d.ts +7 -0
  149. package/src/primitives/lightbox/lightbox.d.ts.map +1 -0
  150. package/src/primitives/lightbox/lightbox.html +665 -0
  151. package/src/primitives/lightbox/lightbox.js +96 -0
  152. package/src/primitives/lightbox/lightbox.ts +113 -0
  153. package/src/primitives/menu/menu-interest.html +52 -0
  154. package/src/primitives/menu/menu.css +55 -0
  155. package/src/primitives/menu/menu.d.ts +38 -0
  156. package/src/primitives/menu/menu.d.ts.map +1 -0
  157. package/src/primitives/menu/menu.html +70 -0
  158. package/src/primitives/menu/menu.js +117 -0
  159. package/src/primitives/menu/menu.ts +131 -0
  160. package/src/primitives/menubar/menubar-help-search.html +103 -0
  161. package/src/primitives/menubar/menubar.html +166 -0
  162. package/src/primitives/meter/meter.css +178 -0
  163. package/src/primitives/meter/meter.html +38 -0
  164. package/src/primitives/mobile-menu/mobile-menu.css +145 -0
  165. package/src/primitives/mobile-menu/mobile-menu.html +614 -0
  166. package/src/primitives/navigation-menu/navigation-menu-featured.html +76 -0
  167. package/src/primitives/navigation-menu/navigation-menu-icon-grid.html +158 -0
  168. package/src/primitives/navigation-menu/navigation-menu-interest.html +103 -0
  169. package/src/primitives/navigation-menu/navigation-menu-megamenu.html +141 -0
  170. package/src/primitives/navigation-menu/navigation-menu-simple.html +96 -0
  171. package/src/primitives/navigation-menu/navigation-menu.css +295 -0
  172. package/src/primitives/navigation-menu/navigation-menu.html +576 -0
  173. package/src/primitives/otp/otp.css +126 -0
  174. package/src/primitives/otp/otp.d.ts +89 -0
  175. package/src/primitives/otp/otp.d.ts.map +1 -0
  176. package/src/primitives/otp/otp.html +22 -0
  177. package/src/primitives/otp/otp.js +226 -0
  178. package/src/primitives/otp/otp.ts +279 -0
  179. package/src/primitives/password-group/password-group.css +238 -0
  180. package/src/primitives/password-group/password-group.d.ts +25 -0
  181. package/src/primitives/password-group/password-group.d.ts.map +1 -0
  182. package/src/primitives/password-group/password-group.html +109 -0
  183. package/src/primitives/password-group/password-group.js +76 -0
  184. package/src/primitives/password-group/password-group.ts +95 -0
  185. package/src/primitives/popover/popover.css +233 -0
  186. package/src/primitives/progress/progress-indeterminate.html +1 -0
  187. package/src/primitives/progress/progress.css +105 -0
  188. package/src/primitives/progress/progress.html +7 -0
  189. package/src/primitives/prose/prose.html +65 -0
  190. package/src/primitives/radio/radio.css +84 -0
  191. package/src/primitives/radio/radio.html +17 -0
  192. package/src/primitives/reveal/reveal.css +167 -0
  193. package/src/primitives/select/multiselect.d.ts +43 -0
  194. package/src/primitives/select/multiselect.d.ts.map +1 -0
  195. package/src/primitives/select/multiselect.js +147 -0
  196. package/src/primitives/select/multiselect.ts +188 -0
  197. package/src/primitives/select/select-align.html +49 -0
  198. package/src/primitives/select/select-multiple.html +12 -0
  199. package/src/primitives/select/select-sides.html +65 -0
  200. package/src/primitives/select/select.css +481 -0
  201. package/src/primitives/select/select.html +16 -0
  202. package/src/primitives/separator/separator.css +49 -0
  203. package/src/primitives/separator/separator.html +16 -0
  204. package/src/primitives/slider/slider.css +122 -0
  205. package/src/primitives/slider/slider.html +1 -0
  206. package/src/primitives/switch/switch.css +126 -0
  207. package/src/primitives/switch/switch.html +13 -0
  208. package/src/primitives/table/table-alternating.html +36 -0
  209. package/src/primitives/table/table-grid.html +30 -0
  210. package/src/primitives/table/table-size-sm.html +26 -0
  211. package/src/primitives/table/table.css +158 -0
  212. package/src/primitives/table/table.html +45 -0
  213. package/src/primitives/tabs/tabs.css +328 -0
  214. package/src/primitives/tabs/tabs.d.ts +35 -0
  215. package/src/primitives/tabs/tabs.d.ts.map +1 -0
  216. package/src/primitives/tabs/tabs.html +75 -0
  217. package/src/primitives/tabs/tabs.js +84 -0
  218. package/src/primitives/tabs/tabs.ts +93 -0
  219. package/src/primitives/textarea/textarea.css +78 -0
  220. package/src/primitives/textarea/textarea.html +10 -0
  221. package/src/primitives/toaster/toaster.css +309 -0
  222. package/src/primitives/toaster/toaster.d.ts +138 -0
  223. package/src/primitives/toaster/toaster.d.ts.map +1 -0
  224. package/src/primitives/toaster/toaster.html +77 -0
  225. package/src/primitives/toaster/toaster.js +736 -0
  226. package/src/primitives/toaster/toaster.ts +823 -0
  227. package/src/primitives/toggle/toggle.css +295 -0
  228. package/src/primitives/toggle/toggle.html +68 -0
  229. package/src/primitives/toggle-group/toggle-group-multiple.html +14 -0
  230. package/src/primitives/toggle-group/toggle-group-vertical.html +14 -0
  231. package/src/primitives/toggle-group/toggle-group.css +73 -0
  232. package/src/primitives/toggle-group/toggle-group.html +53 -0
  233. package/src/primitives/toolbar/toolbar.html +45 -0
  234. package/src/primitives/tooltip/tooltip-disabled.html +19 -0
  235. package/src/primitives/tooltip/tooltip-sides.html +57 -0
  236. package/src/primitives/tooltip/tooltip-with-kbd.html +31 -0
  237. package/src/primitives/tooltip/tooltip.css +235 -0
  238. package/src/primitives/tooltip/tooltip.html +12 -0
  239. package/src/primitives/utilities/aspect-ratio.html +17 -0
  240. package/src/primitives/utilities/basis.html +27 -0
  241. package/src/primitives/utilities/col-span.html +23 -0
  242. package/src/primitives/utilities/compose.html +19 -0
  243. package/src/primitives/utilities/flex-align.html +26 -0
  244. package/src/primitives/utilities/flex-direction.html +36 -0
  245. package/src/primitives/utilities/flex-grow.html +17 -0
  246. package/src/primitives/utilities/gap.html +62 -0
  247. package/src/primitives/utilities/grid-cols.html +20 -0
  248. package/src/primitives/utilities/grid-pile.html +5 -0
  249. package/src/primitives/utilities/grid-responsive.html +31 -0
  250. package/src/primitives/utilities/margin-auto.html +13 -0
  251. package/src/primitives/utilities/object-fit.html +41 -0
  252. package/src/primitives/utilities/order.html +17 -0
  253. package/src/primitives/utilities/overflow.html +26 -0
  254. package/src/primitives/utilities/padding-compose.html +23 -0
  255. package/src/primitives/utilities/padding.html +30 -0
  256. package/src/primitives/utilities/position.html +13 -0
  257. package/src/primitives/utilities/responsive-flex.html +22 -0
  258. package/src/primitives/utilities/responsive-grid.html +31 -0
  259. package/src/primitives/utilities/size.html +22 -0
  260. package/src/primitives/utilities/width.html +22 -0
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview `<ui-lightbox>` — HTML web component for lightbox galleries.
4
+ * @description Light-DOM custom element that coordinates the two carousels in
5
+ * a lightbox: the inline gallery and the fullscreen `<dialog>` slideshow.
6
+ *
7
+ * Responsibilities (subscribing to `zazz:dialog-open` / `zazz:dialog-close`
8
+ * from base/dialog-lifecycle.ts — ADR-0003):
9
+ * - On dialog open: initializes the dialog's `<ui-carousel>` (deferred
10
+ * while the dialog was closed), jumps it to the gallery's current slide,
11
+ * and focuses the viewport so keyboard navigation works immediately.
12
+ * - On dialog close: scrolls the inline gallery to the last viewed slide.
13
+ *
14
+ * Opening and closing the dialog itself needs no JavaScript — slides carry
15
+ * `command="show-modal"` / `command="close"` (Invoker Commands). Drag-aware
16
+ * click suppression on the stage and thumbs is wired by `initRoot` in
17
+ * embla.js (keyed generically on command-bearing `carousel-slide` slots).
18
+ *
19
+ * Load order: the module graph resolves it — `index.js` imports embla.js and
20
+ * carousel.js before this file; Embla itself resolves via the page's import map.
21
+ *
22
+ * @example
23
+ * <ui-lightbox>
24
+ * <div data-slot="lightbox-gallery">
25
+ * <ui-carousel data-slot="lightbox-stage" data-carousel-loop="true">…</ui-carousel>
26
+ * </div>
27
+ * <dialog class="dialog" data-slot="lightbox-dialog" closedby="any">
28
+ * <ui-carousel data-carousel-loop="true">…</ui-carousel>
29
+ * </dialog>
30
+ * </ui-lightbox>
31
+ */
32
+ import { UiCarouselElement } from "../carousel/carousel.js";
33
+ import { ZazzElement, defineZazzElement } from "../../base/zazz-element.js";
34
+ class UiLightbox extends ZazzElement {
35
+ setup(signal) {
36
+ const dialog = this.querySelector("dialog");
37
+ if (!(dialog instanceof HTMLDialogElement))
38
+ return;
39
+ // The dialog is a descendant, so its lifecycle events (ADR-0003) bubble
40
+ // through this element — subscribe here instead of observing attributes.
41
+ this.addEventListener("zazz:dialog-open", (e) => {
42
+ if (e.target === dialog)
43
+ this.#onDialogOpen(dialog);
44
+ }, { signal });
45
+ this.addEventListener("zazz:dialog-close", (e) => {
46
+ if (e.target === dialog)
47
+ this.#syncGalleryToDialog(dialog);
48
+ }, { signal });
49
+ }
50
+ /**
51
+ * @returns The inline gallery's carousel root.
52
+ */
53
+ #galleryRoot() {
54
+ return this.querySelector('[data-slot~="lightbox-gallery"] :is(ui-carousel, .ui-carousel)');
55
+ }
56
+ /**
57
+ * @description Initializes the dialog carousel, opens it at the gallery's
58
+ * current slide, and moves focus to the slideshow viewport.
59
+ *
60
+ * @param dialog - The lightbox dialog.
61
+ */
62
+ #onDialogOpen(dialog) {
63
+ const dialogRoot = dialog.querySelector(":is(ui-carousel, .ui-carousel)");
64
+ if (!dialogRoot)
65
+ return;
66
+ // <ui-carousel> defers init while its dialog is closed. Its own
67
+ // zazz:dialog-open listener (on the dialog) fires before this one (on the
68
+ // ancestor) by DOM dispatch order, but init here too — idempotent — so the
69
+ // jump below never races a class-form root.
70
+ if (dialogRoot instanceof UiCarouselElement) {
71
+ dialogRoot.init();
72
+ }
73
+ const galleryApi = this.#galleryRoot()?._emblaApi;
74
+ if (dialogRoot._emblaApi && galleryApi) {
75
+ dialogRoot._emblaApi.scrollTo(galleryApi.selectedScrollSnap(), true);
76
+ }
77
+ const viewport = dialogRoot.querySelector('[data-slot~="carousel-viewport"]');
78
+ if (viewport instanceof HTMLElement) {
79
+ viewport.focus({ preventScroll: true });
80
+ }
81
+ }
82
+ /**
83
+ * @description Scrolls the inline gallery to the slide last viewed in the dialog.
84
+ *
85
+ * @param dialog - The lightbox dialog.
86
+ */
87
+ #syncGalleryToDialog(dialog) {
88
+ const dialogApi = dialog.querySelector(":is(ui-carousel, .ui-carousel)")?._emblaApi;
89
+ const galleryApi = this.#galleryRoot()?._emblaApi;
90
+ if (dialogApi && galleryApi) {
91
+ galleryApi.scrollTo(dialogApi.selectedScrollSnap());
92
+ }
93
+ }
94
+ }
95
+ defineZazzElement("ui-lightbox", UiLightbox);
96
+ export { UiLightbox };
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @fileoverview `<ui-lightbox>` — HTML web component for lightbox galleries.
5
+ * @description Light-DOM custom element that coordinates the two carousels in
6
+ * a lightbox: the inline gallery and the fullscreen `<dialog>` slideshow.
7
+ *
8
+ * Responsibilities (subscribing to `zazz:dialog-open` / `zazz:dialog-close`
9
+ * from base/dialog-lifecycle.ts — ADR-0003):
10
+ * - On dialog open: initializes the dialog's `<ui-carousel>` (deferred
11
+ * while the dialog was closed), jumps it to the gallery's current slide,
12
+ * and focuses the viewport so keyboard navigation works immediately.
13
+ * - On dialog close: scrolls the inline gallery to the last viewed slide.
14
+ *
15
+ * Opening and closing the dialog itself needs no JavaScript — slides carry
16
+ * `command="show-modal"` / `command="close"` (Invoker Commands). Drag-aware
17
+ * click suppression on the stage and thumbs is wired by `initRoot` in
18
+ * embla.js (keyed generically on command-bearing `carousel-slide` slots).
19
+ *
20
+ * Load order: the module graph resolves it — `index.js` imports embla.js and
21
+ * carousel.js before this file; Embla itself resolves via the page's import map.
22
+ *
23
+ * @example
24
+ * <ui-lightbox>
25
+ * <div data-slot="lightbox-gallery">
26
+ * <ui-carousel data-slot="lightbox-stage" data-carousel-loop="true">…</ui-carousel>
27
+ * </div>
28
+ * <dialog class="dialog" data-slot="lightbox-dialog" closedby="any">
29
+ * <ui-carousel data-carousel-loop="true">…</ui-carousel>
30
+ * </dialog>
31
+ * </ui-lightbox>
32
+ */
33
+
34
+ import { UiCarouselElement } from "../carousel/carousel.ts";
35
+ import { ZazzElement, defineZazzElement } from "../../base/zazz-element.ts";
36
+
37
+ class UiLightbox extends ZazzElement {
38
+ protected setup(signal: AbortSignal): void {
39
+ const dialog = this.querySelector("dialog");
40
+ if (!(dialog instanceof HTMLDialogElement)) return;
41
+
42
+ // The dialog is a descendant, so its lifecycle events (ADR-0003) bubble
43
+ // through this element — subscribe here instead of observing attributes.
44
+ this.addEventListener(
45
+ "zazz:dialog-open",
46
+ (e) => {
47
+ if (e.target === dialog) this.#onDialogOpen(dialog);
48
+ },
49
+ { signal },
50
+ );
51
+
52
+ this.addEventListener(
53
+ "zazz:dialog-close",
54
+ (e) => {
55
+ if (e.target === dialog) this.#syncGalleryToDialog(dialog);
56
+ },
57
+ { signal },
58
+ );
59
+ }
60
+
61
+ /**
62
+ * @returns The inline gallery's carousel root.
63
+ */
64
+ #galleryRoot(): Element | null {
65
+ return this.querySelector('[data-slot~="lightbox-gallery"] :is(ui-carousel, .ui-carousel)');
66
+ }
67
+
68
+ /**
69
+ * @description Initializes the dialog carousel, opens it at the gallery's
70
+ * current slide, and moves focus to the slideshow viewport.
71
+ *
72
+ * @param dialog - The lightbox dialog.
73
+ */
74
+ #onDialogOpen(dialog: HTMLDialogElement): void {
75
+ const dialogRoot = dialog.querySelector(":is(ui-carousel, .ui-carousel)");
76
+ if (!dialogRoot) return;
77
+
78
+ // <ui-carousel> defers init while its dialog is closed. Its own
79
+ // zazz:dialog-open listener (on the dialog) fires before this one (on the
80
+ // ancestor) by DOM dispatch order, but init here too — idempotent — so the
81
+ // jump below never races a class-form root.
82
+ if (dialogRoot instanceof UiCarouselElement) {
83
+ dialogRoot.init();
84
+ }
85
+
86
+ const galleryApi = this.#galleryRoot()?._emblaApi;
87
+ if (dialogRoot._emblaApi && galleryApi) {
88
+ dialogRoot._emblaApi.scrollTo(galleryApi.selectedScrollSnap(), true);
89
+ }
90
+
91
+ const viewport = dialogRoot.querySelector('[data-slot~="carousel-viewport"]');
92
+ if (viewport instanceof HTMLElement) {
93
+ viewport.focus({ preventScroll: true });
94
+ }
95
+ }
96
+
97
+ /**
98
+ * @description Scrolls the inline gallery to the slide last viewed in the dialog.
99
+ *
100
+ * @param dialog - The lightbox dialog.
101
+ */
102
+ #syncGalleryToDialog(dialog: HTMLDialogElement): void {
103
+ const dialogApi = dialog.querySelector(":is(ui-carousel, .ui-carousel)")?._emblaApi;
104
+ const galleryApi = this.#galleryRoot()?._emblaApi;
105
+ if (dialogApi && galleryApi) {
106
+ galleryApi.scrollTo(dialogApi.selectedScrollSnap());
107
+ }
108
+ }
109
+ }
110
+
111
+ defineZazzElement("ui-lightbox", UiLightbox);
112
+
113
+ export { UiLightbox };
@@ -0,0 +1,52 @@
1
+ <div class="flex gap-sm">
2
+ <ui-menu>
3
+ <button
4
+ class="ui-button"
5
+ type="button"
6
+ popovertarget="menu-interest-example-1"
7
+ interestfor="menu-interest-example-1"
8
+ >
9
+ Hover or click
10
+ </button>
11
+ <div
12
+ id="menu-interest-example-1"
13
+ data-slot="menu-popover"
14
+ data-side="bottom"
15
+ data-align="start"
16
+ popover="auto"
17
+ >
18
+ <menu>
19
+ <li class="font-strong text-eyebrow text-muted-foreground p-xs">Account</li>
20
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Profile</a></li>
21
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Settings</a></li>
22
+ <hr class="ui-separator my-xs" />
23
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Sign out</a></li>
24
+ </menu>
25
+ </div>
26
+ </ui-menu>
27
+
28
+ <ui-menu>
29
+ <button
30
+ class="ui-button"
31
+ type="button"
32
+ data-variant="outline"
33
+ popovertarget="menu-interest-example-2"
34
+ interestfor="menu-interest-example-2"
35
+ >
36
+ Resources
37
+ </button>
38
+ <div
39
+ id="menu-interest-example-2"
40
+ data-slot="menu-popover"
41
+ data-side="bottom"
42
+ data-align="start"
43
+ popover="auto"
44
+ >
45
+ <menu>
46
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Documentation</a></li>
47
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Changelog</a></li>
48
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Support</a></li>
49
+ </menu>
50
+ </div>
51
+ </ui-menu>
52
+ </div>
@@ -0,0 +1,55 @@
1
+ /**
2
+ * menu.css: Menu (ui-menu | .ui-menu, [data-slot~="menu-popover"])
3
+ *
4
+ * @layer variables, components
5
+ * @requires layers.css, _variables.css, popover.css, button.css
6
+ * @uses popovertarget + [popover]: inherits Popover API from popover.css
7
+ * @uses interestfor: optional hover/focus open on the same trigger
8
+ * (Interest Invokers, Chromium 142+; polyfill via invokers)
9
+ * @uses anchor-name, anchor-scope, position-anchor: tether panel to trigger
10
+ * @uses data-side / data-align: maps to --ui-popover-position-* in popover.css
11
+ * @tokens --ui-menu-* (@layer variables)
12
+ * @consumedby select.css (--ui-menu-button-radius)
13
+ * @see menu.ts: optional arrow-key navigation; the class form stays no-JS
14
+ */
15
+
16
+ @layer variables {
17
+ :root {
18
+ --ui-menu-button-radius: var(--radius-sm);
19
+ --ui-menu-min-inline-size: var(--step-52);
20
+ --ui-menu-option-gap: var(--ui-field-option-gap);
21
+ --ui-menu-shadow: var(--shadow-sm);
22
+ }
23
+ }
24
+
25
+ @layer zazz.components {
26
+ /* ===========================================================================
27
+ MENU: trigger + anchored popover of actions/links
28
+ - Inherits --ui-popover-* tokens and [popover] surface/positioning from popover.css.
29
+ - Only menu-specific wiring lives here: anchor scope/name and nested buttons.
30
+ - The native <menu> element stays inside the panel as the list; the root names
31
+ the trigger + panel assembly.
32
+ - Explicit anchor-name covers both popovertarget (click) and interestfor
33
+ (hover/focus) triggers; implicit interest anchors are not polyfilled.
34
+ =========================================================================== */
35
+
36
+ :where(ui-menu, .ui-menu) {
37
+ anchor-scope: --ui-menu-trigger;
38
+ display: grid;
39
+ gap: var(--ui-menu-option-gap);
40
+ }
41
+
42
+ :where(ui-menu, .ui-menu) > :where([popovertarget], [interestfor]) {
43
+ anchor-name: --ui-menu-trigger;
44
+ }
45
+
46
+ [data-slot~="menu-popover"] {
47
+ position-anchor: --ui-menu-trigger;
48
+ min-inline-size: var(--ui-menu-min-inline-size);
49
+ box-shadow: var(--ui-menu-shadow);
50
+ }
51
+
52
+ [data-slot~="menu-popover"] .ui-button {
53
+ --ui-button-radius: var(--ui-menu-button-radius);
54
+ }
55
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @fileoverview `<ui-menu>`: HTML web component for keyboard-enhanced menus.
3
+ * @description Light-DOM custom element that augments the CSS-only menu
4
+ * pattern (trigger + anchored `[data-slot~="menu-popover"]` panel) with
5
+ * arrow-key navigation. The class form `.ui-menu` stays fully functional
6
+ * without JavaScript: the Popover API provides open/close, light dismiss,
7
+ * and focus return on its own.
8
+ *
9
+ * Keyboard behavior:
10
+ * - ArrowDown / ArrowUp on the closed trigger open the panel and focus the
11
+ * first / last item.
12
+ * - ArrowDown / ArrowUp inside the open panel move focus between items,
13
+ * wrapping around and skipping disabled items.
14
+ * - Home / End jump to the first / last item.
15
+ * - Escape and light dismiss are native Popover API behavior (no code here).
16
+ *
17
+ * The menu keeps the honest disclosure posture: items are plain links and
18
+ * buttons, and no `role="menu"` is claimed. Add the full ARIA menu contract
19
+ * yourself only if every item is an action and you implement the rest of the
20
+ * pattern (typeahead, close-on-activate).
21
+ *
22
+ * @example
23
+ * <ui-menu>
24
+ * <button class="ui-button" type="button" popovertarget="m1">Open</button>
25
+ * <div id="m1" data-slot="menu-popover" popover="auto">
26
+ * <menu>
27
+ * <li><a href="/docs" class="ui-button justify-start" data-variant="ghost">Docs</a></li>
28
+ * </menu>
29
+ * </div>
30
+ * </ui-menu>
31
+ */
32
+ import { ZazzElement } from "../../base/zazz-element.ts";
33
+ declare class UiMenu extends ZazzElement {
34
+ #private;
35
+ protected setup(signal: AbortSignal): void;
36
+ }
37
+ export { UiMenu };
38
+ //# sourceMappingURL=menu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["menu.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,WAAW,EAAqB,MAAM,4BAA4B,CAAC;AAE5E,cAAM,MAAO,SAAQ,WAAW;;IAC9B,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAEzC;CAuFF;AAID,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,70 @@
1
+ <div class="flex gap-sm">
2
+ <ui-menu>
3
+ <button class="ui-button" type="button" popovertarget="menu-example-1">Bottom / start</button>
4
+ <div
5
+ id="menu-example-1"
6
+ data-slot="menu-popover"
7
+ data-side="bottom"
8
+ data-align="start"
9
+ popover="auto"
10
+ >
11
+ <menu>
12
+ <li class="font-strong text-eyebrow text-muted-foreground p-xs">Group 1</li>
13
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 1</a></li>
14
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 2</a></li>
15
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 3</a></li>
16
+ <hr class="ui-separator my-xs" />
17
+ <li class="font-strong text-eyebrow text-muted-foreground p-xs">Group 2</li>
18
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 4</a></li>
19
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 5</a></li>
20
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 6</a></li>
21
+ </menu>
22
+ </div>
23
+ </ui-menu>
24
+
25
+ <ui-menu>
26
+ <button class="ui-button" type="button" popovertarget="menu-example-2">Bottom / center</button>
27
+ <div
28
+ id="menu-example-2"
29
+ data-slot="menu-popover"
30
+ data-side="bottom"
31
+ data-align="center"
32
+ popover="auto"
33
+ >
34
+ <menu>
35
+ <li class="font-strong text-eyebrow text-muted-foreground p-xs">Group 1</li>
36
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 1</a></li>
37
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 2</a></li>
38
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 3</a></li>
39
+ <hr class="ui-separator my-xs" />
40
+ <li class="font-strong text-eyebrow text-muted-foreground p-xs">Group 2</li>
41
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 4</a></li>
42
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 5</a></li>
43
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 6</a></li>
44
+ </menu>
45
+ </div>
46
+ </ui-menu>
47
+
48
+ <ui-menu>
49
+ <button class="ui-button" type="button" popovertarget="menu-example-3">Bottom / end</button>
50
+ <div
51
+ id="menu-example-3"
52
+ data-slot="menu-popover"
53
+ data-side="bottom"
54
+ data-align="end"
55
+ popover="auto"
56
+ >
57
+ <menu>
58
+ <li class="font-strong text-eyebrow text-muted-foreground p-xs">Group 1</li>
59
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 1</a></li>
60
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 2</a></li>
61
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 3</a></li>
62
+ <hr class="ui-separator my-xs" />
63
+ <li class="font-strong text-eyebrow text-muted-foreground p-xs">Group 2</li>
64
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 4</a></li>
65
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 5</a></li>
66
+ <li><a href="#" class="ui-button justify-start" data-variant="ghost">Link 6</a></li>
67
+ </menu>
68
+ </div>
69
+ </ui-menu>
70
+ </div>
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview `<ui-menu>`: HTML web component for keyboard-enhanced menus.
4
+ * @description Light-DOM custom element that augments the CSS-only menu
5
+ * pattern (trigger + anchored `[data-slot~="menu-popover"]` panel) with
6
+ * arrow-key navigation. The class form `.ui-menu` stays fully functional
7
+ * without JavaScript: the Popover API provides open/close, light dismiss,
8
+ * and focus return on its own.
9
+ *
10
+ * Keyboard behavior:
11
+ * - ArrowDown / ArrowUp on the closed trigger open the panel and focus the
12
+ * first / last item.
13
+ * - ArrowDown / ArrowUp inside the open panel move focus between items,
14
+ * wrapping around and skipping disabled items.
15
+ * - Home / End jump to the first / last item.
16
+ * - Escape and light dismiss are native Popover API behavior (no code here).
17
+ *
18
+ * The menu keeps the honest disclosure posture: items are plain links and
19
+ * buttons, and no `role="menu"` is claimed. Add the full ARIA menu contract
20
+ * yourself only if every item is an action and you implement the rest of the
21
+ * pattern (typeahead, close-on-activate).
22
+ *
23
+ * @example
24
+ * <ui-menu>
25
+ * <button class="ui-button" type="button" popovertarget="m1">Open</button>
26
+ * <div id="m1" data-slot="menu-popover" popover="auto">
27
+ * <menu>
28
+ * <li><a href="/docs" class="ui-button justify-start" data-variant="ghost">Docs</a></li>
29
+ * </menu>
30
+ * </div>
31
+ * </ui-menu>
32
+ */
33
+ import { ZazzElement, defineZazzElement } from "../../base/zazz-element.js";
34
+ class UiMenu extends ZazzElement {
35
+ setup(signal) {
36
+ this.addEventListener("keydown", (event) => this.#onKeydown(event), { signal });
37
+ }
38
+ /**
39
+ * @description The menu's own panel: a direct child so nested menus keep
40
+ * their panels to themselves.
41
+ *
42
+ * @returns The panel element, or null when the markup is incomplete.
43
+ */
44
+ #panel() {
45
+ const panel = this.querySelector(':scope > [data-slot~="menu-popover"]');
46
+ return panel instanceof HTMLElement ? panel : null;
47
+ }
48
+ /**
49
+ * @description Focusable items inside the panel, in DOM order.
50
+ *
51
+ * @param panel - The menu panel.
52
+ * @returns Enabled links and buttons the arrow keys move between.
53
+ */
54
+ #items(panel) {
55
+ return Array.from(panel.querySelectorAll("a[href], button"))
56
+ .filter((node) => node instanceof HTMLElement)
57
+ .filter((item) => !item.hasAttribute("disabled") &&
58
+ item.getAttribute("aria-disabled") !== "true" &&
59
+ item.closest("ui-menu, .ui-menu") === this);
60
+ }
61
+ /**
62
+ * @description Routes arrow-key, Home, and End presses: opens the panel from
63
+ * the trigger, or moves focus between items inside the open panel.
64
+ *
65
+ * @param event - The keydown event.
66
+ */
67
+ #onKeydown(event) {
68
+ if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key))
69
+ return;
70
+ const target = event.target;
71
+ if (!(target instanceof HTMLElement))
72
+ return;
73
+ // Ignore keys that belong to a nested ui-menu
74
+ if (target.closest("ui-menu") !== this)
75
+ return;
76
+ const panel = this.#panel();
77
+ if (!panel)
78
+ return;
79
+ const isTrigger = target.parentElement === this &&
80
+ (target.hasAttribute("popovertarget") || target.hasAttribute("interestfor"));
81
+ const open = panel.matches(":popover-open, .\\:popover-open");
82
+ if (isTrigger && !open && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
83
+ event.preventDefault();
84
+ panel.showPopover();
85
+ const items = this.#items(panel);
86
+ items[event.key === "ArrowDown" ? 0 : items.length - 1]?.focus();
87
+ return;
88
+ }
89
+ if (!open || !panel.contains(target))
90
+ return;
91
+ const items = this.#items(panel);
92
+ if (items.length === 0)
93
+ return;
94
+ const index = items.indexOf(target);
95
+ let nextIndex;
96
+ switch (event.key) {
97
+ case "ArrowDown":
98
+ nextIndex = index === -1 ? 0 : (index + 1) % items.length;
99
+ break;
100
+ case "ArrowUp":
101
+ nextIndex = index === -1 ? items.length - 1 : (index - 1 + items.length) % items.length;
102
+ break;
103
+ case "Home":
104
+ nextIndex = 0;
105
+ break;
106
+ case "End":
107
+ nextIndex = items.length - 1;
108
+ break;
109
+ default:
110
+ return;
111
+ }
112
+ event.preventDefault();
113
+ items[nextIndex].focus();
114
+ }
115
+ }
116
+ defineZazzElement("ui-menu", UiMenu);
117
+ export { UiMenu };
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @fileoverview `<ui-menu>`: HTML web component for keyboard-enhanced menus.
5
+ * @description Light-DOM custom element that augments the CSS-only menu
6
+ * pattern (trigger + anchored `[data-slot~="menu-popover"]` panel) with
7
+ * arrow-key navigation. The class form `.ui-menu` stays fully functional
8
+ * without JavaScript: the Popover API provides open/close, light dismiss,
9
+ * and focus return on its own.
10
+ *
11
+ * Keyboard behavior:
12
+ * - ArrowDown / ArrowUp on the closed trigger open the panel and focus the
13
+ * first / last item.
14
+ * - ArrowDown / ArrowUp inside the open panel move focus between items,
15
+ * wrapping around and skipping disabled items.
16
+ * - Home / End jump to the first / last item.
17
+ * - Escape and light dismiss are native Popover API behavior (no code here).
18
+ *
19
+ * The menu keeps the honest disclosure posture: items are plain links and
20
+ * buttons, and no `role="menu"` is claimed. Add the full ARIA menu contract
21
+ * yourself only if every item is an action and you implement the rest of the
22
+ * pattern (typeahead, close-on-activate).
23
+ *
24
+ * @example
25
+ * <ui-menu>
26
+ * <button class="ui-button" type="button" popovertarget="m1">Open</button>
27
+ * <div id="m1" data-slot="menu-popover" popover="auto">
28
+ * <menu>
29
+ * <li><a href="/docs" class="ui-button justify-start" data-variant="ghost">Docs</a></li>
30
+ * </menu>
31
+ * </div>
32
+ * </ui-menu>
33
+ */
34
+
35
+ import { ZazzElement, defineZazzElement } from "../../base/zazz-element.ts";
36
+
37
+ class UiMenu extends ZazzElement {
38
+ protected setup(signal: AbortSignal): void {
39
+ this.addEventListener("keydown", (event) => this.#onKeydown(event), { signal });
40
+ }
41
+
42
+ /**
43
+ * @description The menu's own panel: a direct child so nested menus keep
44
+ * their panels to themselves.
45
+ *
46
+ * @returns The panel element, or null when the markup is incomplete.
47
+ */
48
+ #panel(): HTMLElement | null {
49
+ const panel = this.querySelector(':scope > [data-slot~="menu-popover"]');
50
+ return panel instanceof HTMLElement ? panel : null;
51
+ }
52
+
53
+ /**
54
+ * @description Focusable items inside the panel, in DOM order.
55
+ *
56
+ * @param panel - The menu panel.
57
+ * @returns Enabled links and buttons the arrow keys move between.
58
+ */
59
+ #items(panel: HTMLElement): HTMLElement[] {
60
+ return Array.from(panel.querySelectorAll("a[href], button"))
61
+ .filter((node): node is HTMLElement => node instanceof HTMLElement)
62
+ .filter(
63
+ (item) =>
64
+ !item.hasAttribute("disabled") &&
65
+ item.getAttribute("aria-disabled") !== "true" &&
66
+ item.closest("ui-menu, .ui-menu") === this,
67
+ );
68
+ }
69
+
70
+ /**
71
+ * @description Routes arrow-key, Home, and End presses: opens the panel from
72
+ * the trigger, or moves focus between items inside the open panel.
73
+ *
74
+ * @param event - The keydown event.
75
+ */
76
+ #onKeydown(event: KeyboardEvent): void {
77
+ if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
78
+
79
+ const target = event.target;
80
+ if (!(target instanceof HTMLElement)) return;
81
+ // Ignore keys that belong to a nested ui-menu
82
+ if (target.closest("ui-menu") !== this) return;
83
+
84
+ const panel = this.#panel();
85
+ if (!panel) return;
86
+
87
+ const isTrigger =
88
+ target.parentElement === this &&
89
+ (target.hasAttribute("popovertarget") || target.hasAttribute("interestfor"));
90
+ const open = panel.matches(":popover-open, .\\:popover-open");
91
+
92
+ if (isTrigger && !open && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
93
+ event.preventDefault();
94
+ panel.showPopover();
95
+ const items = this.#items(panel);
96
+ items[event.key === "ArrowDown" ? 0 : items.length - 1]?.focus();
97
+ return;
98
+ }
99
+
100
+ if (!open || !panel.contains(target)) return;
101
+
102
+ const items = this.#items(panel);
103
+ if (items.length === 0) return;
104
+
105
+ const index = items.indexOf(target);
106
+ let nextIndex: number;
107
+ switch (event.key) {
108
+ case "ArrowDown":
109
+ nextIndex = index === -1 ? 0 : (index + 1) % items.length;
110
+ break;
111
+ case "ArrowUp":
112
+ nextIndex = index === -1 ? items.length - 1 : (index - 1 + items.length) % items.length;
113
+ break;
114
+ case "Home":
115
+ nextIndex = 0;
116
+ break;
117
+ case "End":
118
+ nextIndex = items.length - 1;
119
+ break;
120
+ default:
121
+ return;
122
+ }
123
+
124
+ event.preventDefault();
125
+ items[nextIndex].focus();
126
+ }
127
+ }
128
+
129
+ defineZazzElement("ui-menu", UiMenu);
130
+
131
+ export { UiMenu };