@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
package/src/head.ts ADDED
@@ -0,0 +1,433 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @fileoverview Canonical `<head>` contract for Zazz pages.
5
+ * @description The single owner of everything a Zazz page loads before its own
6
+ * content: meta tags, the Geist fonts block, the one `index.css` stylesheet
7
+ * link, the feature polyfills, the third-party **import map**, the `index.js`
8
+ * module tag, and the theme-persistence script. The docs preview iframe, the
9
+ * kit's example pages (via `scripts/generate-heads.mjs`), and the docs page
10
+ * that teaches head structure all render from this module: there is no other
11
+ * copy to drift.
12
+ *
13
+ * This is a Node/server-side string builder (used at build/render time), not a
14
+ * browser runtime module; it attaches nothing to `window`.
15
+ *
16
+ * Third-party policy: one CDN provider (jsDelivr), exact pinned versions,
17
+ * static package files only (never dynamically generated `/+esm` bundles,
18
+ * as jsDelivr regenerates those when its bundler toolchain updates, which would
19
+ * silently invalidate SRI hashes), `sha384` integrity on every URL. ES modules
20
+ * resolve through the import map; classic polyfills load as plain script tags.
21
+ *
22
+ * @example
23
+ * import { buildHead } from "@zazz-ui/core/head";
24
+ * const head = buildHead({ base: "./zazz" });
25
+ */
26
+
27
+ import { PRIMITIVES, resolveClosure } from "./manifest.ts";
28
+
29
+ // --- Third-party dependency manifest ---
30
+
31
+ /** One pinned third-party file served from jsDelivr. */
32
+ interface CdnDependency {
33
+ /** npm package name: doubles as the import-map specifier for ESM deps. */
34
+ name: string;
35
+ /** Exact pinned version. Bump deliberately; then refresh `integrity`. */
36
+ version: string;
37
+ /** Static file within the package (never a generated `/+esm` bundle). */
38
+ file: string;
39
+ /**
40
+ * `sha384` SRI hash of the pinned file. Regenerate after a version bump:
41
+ * `curl -sL <url> | openssl dgst -sha384 -binary | openssl base64 -A`
42
+ */
43
+ integrity: string;
44
+ }
45
+
46
+ /** The one CDN provider for every third-party resource. */
47
+ const CDN = "https://cdn.jsdelivr.net/npm";
48
+
49
+ /** The kit's own published package name (CDN mode serves files out of it). */
50
+ const PACKAGE_NAME = "@zazz-ui/core";
51
+
52
+ /**
53
+ * Exact-version pin required in every kit CDN URL. SRI hashes are per-byte,
54
+ * so floating specs (`latest`, `0.3`) would break integrity on each release —
55
+ * and unpinned URLs defeat jsDelivr's permanent caching (ticket 06).
56
+ */
57
+ const EXACT_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
58
+
59
+ /**
60
+ * Base stylesheets in the exact order `src/index.css` loads them around the
61
+ * primitive imports: `PRE` before (layer declaration first), `POST` after
62
+ * (utilities and layout stay the final normal override layer). The granular
63
+ * CDN head mirrors this split; `head.test.ts` guards it against `index.css`.
64
+ */
65
+ const BASE_CSS_PRE = [
66
+ "base/_layers.css",
67
+ "base/_variables.css",
68
+ "base/_reset.css",
69
+ "base/_typography.css",
70
+ "base/_view-transitions.css",
71
+ ];
72
+ const BASE_CSS_POST = ["base/_utilities.css", "base/_layout.css"];
73
+
74
+ /**
75
+ * Core runtime modules reached by relative import from primitive scripts
76
+ * (never via their own script tag, except `dialog-lifecycle`, which is a
77
+ * side-effect module the granular head loads explicitly). Listed so the
78
+ * import map's `integrity` section can cover their transitive loads.
79
+ */
80
+ const CORE_RUNTIME_JS = [
81
+ "base/dialog-lifecycle.js",
82
+ "base/utils.js",
83
+ "base/signals.js",
84
+ "base/zazz-element.js",
85
+ ];
86
+
87
+ /**
88
+ * @description Builds the pinned jsDelivr URL for a dependency.
89
+ *
90
+ * @param dep - The dependency entry.
91
+ * @returns The versioned URL.
92
+ * @private
93
+ */
94
+ function cdnUrl(dep: CdnDependency): string {
95
+ return `${CDN}/${dep.name}@${dep.version}/${dep.file}`;
96
+ }
97
+
98
+ /**
99
+ * ES-module dependencies the kit's module graph imports by bare specifier.
100
+ * The import map points each specifier at its pinned static file; in tests and
101
+ * bundlers the same specifiers resolve from `node_modules` instead (the
102
+ * versions here must match the installed packages: `head.test.ts` pins that).
103
+ */
104
+ const ESM_DEPENDENCIES: readonly CdnDependency[] = [
105
+ {
106
+ name: "signal-polyfill",
107
+ version: "0.2.2",
108
+ file: "dist/index.js",
109
+ integrity: "sha384-0OqM7OXGT6Oz1z98u/geiFn/FUyz4iWexkXHCvbIGXRRDXl6bp6IKc0j78AQ6DEK",
110
+ },
111
+ {
112
+ name: "embla-carousel",
113
+ version: "8.6.0",
114
+ file: "esm/embla-carousel.esm.js",
115
+ integrity: "sha384-GXjfyU1fSHHeweoYd3rwo7OBKYtkq+JcsDoe8VDRc6znCty2ZTzyVvX1DwqCE+9t",
116
+ },
117
+ {
118
+ name: "embla-carousel-autoplay",
119
+ version: "8.6.0",
120
+ file: "esm/embla-carousel-autoplay.esm.js",
121
+ integrity: "sha384-AX49yBc7zd/CT8ZqNMRiiqqVSV9xfxb27VwEGziPioT3wL4k4C5BW2qwefdWuN4J",
122
+ },
123
+ {
124
+ name: "embla-carousel-auto-scroll",
125
+ version: "8.6.0",
126
+ file: "esm/embla-carousel-auto-scroll.esm.js",
127
+ integrity: "sha384-SPdnL1eic73WfM72zFEf0RJ5PdUC7TL3Yb5jOl1JC3/l4D7EsVxwO8wFnnezlMSu",
128
+ },
129
+ {
130
+ name: "embla-carousel-class-names",
131
+ version: "8.6.0",
132
+ file: "esm/embla-carousel-class-names.esm.js",
133
+ integrity: "sha384-ZWno/FqzYeWE5Ils19GIhep1AZ5bMl0mp9wmm6baTJE4+pjMjOdTnE55SjUQAdVh",
134
+ },
135
+ ];
136
+
137
+ /**
138
+ * Feature polyfills loaded as script tags ahead of the kit module: the Popover
139
+ * API (menus, tooltips, the toaster region) and Invoker Commands
140
+ * (`command`/`commandfor`). Native in current engines (2026); the polyfills
141
+ * keep older browsers consistent.
142
+ */
143
+ const POLYFILLS: readonly CdnDependency[] = [
144
+ {
145
+ name: "@oddbird/popover-polyfill",
146
+ version: "0.7.2",
147
+ file: "dist/popover.min.js",
148
+ integrity: "sha384-pOVHoXRgxuaWHCRM4KSyfyfRTmdxgjVo1Ux78ZKJ+GjUz4zIzXiTa8XXuDF1R1Sd",
149
+ },
150
+ {
151
+ name: "invokers",
152
+ version: "2.2.2",
153
+ file: "dist/esm/production/compatible.js",
154
+ integrity: "sha384-7vRXDaS2mcW7LheGSA/rxBwIQNEqmWj0OLEOta/+mvw+9Uf5w1vplA5qg8kLQ99u",
155
+ },
156
+ ];
157
+
158
+ // --- Head fragments ---
159
+
160
+ /**
161
+ * @description Renders the Geist fonts block (preconnect + preload + stylesheet).
162
+ *
163
+ * @param display - The `font-display` strategy for the Google Fonts request.
164
+ * @returns The fonts markup.
165
+ * @private
166
+ */
167
+ function fontsBlock(display: "swap" | "optional"): string {
168
+ return `<!-- Google Fonts: Geist + Geist Mono (preconnect so the CSS request starts early) -->
169
+ <link rel="preconnect" href="https://fonts.googleapis.com">
170
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
171
+ <link rel="preload" as="font" type="font/woff2" crossorigin href="https://fonts.gstatic.com/s/geist/v5/gyByhwUxId8gMEwcGFWNOITd.woff2">
172
+ <link href="https://fonts.googleapis.com/css2?family=Geist+Mono:ital,wght@0,100..900;1,100..900&family=Geist:ital,wght@0,100..900;1,100..900&display=${display}" rel="stylesheet">`;
173
+ }
174
+
175
+ /**
176
+ * @description Renders the import map that resolves the kit's bare specifiers
177
+ * (`signal-polyfill`, `embla-carousel`, …) to pinned jsDelivr URLs, with an
178
+ * `integrity` section covering every mapped file.
179
+ *
180
+ * @returns The import-map script tag.
181
+ * @private
182
+ */
183
+ function importMapBlock(extraIntegrity: Record<string, string> = {}): string {
184
+ const imports: Record<string, string> = {};
185
+ const integrity: Record<string, string> = { ...extraIntegrity };
186
+ for (const dep of ESM_DEPENDENCIES) {
187
+ const url = cdnUrl(dep);
188
+ imports[dep.name] = url;
189
+ integrity[url] = dep.integrity;
190
+ }
191
+ const json = JSON.stringify({ imports, integrity }, null, 2);
192
+ return `<!-- Import map: bare specifiers in Zazz scripts resolve to pinned, SRI-checked files -->
193
+ <script type="importmap">
194
+ ${json}
195
+ </script>`;
196
+ }
197
+
198
+ /**
199
+ * @description Renders the polyfill script tags. The popover polyfill is a
200
+ * classic script; the invokers compatibility build is a module. Both are
201
+ * deferred, so they execute in document order ahead of `index.js`.
202
+ *
203
+ * @returns The polyfill markup.
204
+ * @private
205
+ */
206
+ function polyfillsBlock(): string {
207
+ const [popover, invokers] = POLYFILLS;
208
+ return `<!-- Polyfills: Popover API + Invoker Commands (command/commandfor) -->
209
+ <script src="${cdnUrl(popover)}" integrity="${popover.integrity}" crossorigin="anonymous" defer></script>
210
+ <script type="module" src="${cdnUrl(invokers)}" integrity="${invokers.integrity}" crossorigin="anonymous" defer></script>`;
211
+ }
212
+
213
+ /**
214
+ * The theme-persistence script. Runs inline (no `defer`) while the parser is
215
+ * still in `<head>`, so `.dark` lands on `<html>` before first paint. The
216
+ * try/catch covers contexts where storage access throws (sandboxed iframes,
217
+ * blocked site data).
218
+ */
219
+ const THEME_SCRIPT = `<!-- Theme: apply the persisted (or preferred) scheme before first paint -->
220
+ <script>
221
+ (() => {
222
+ try {
223
+ const storedTheme = localStorage.getItem("theme");
224
+ const prefersDark = matchMedia("(prefers-color-scheme: dark)").matches;
225
+ const theme = storedTheme ?? (prefersDark ? "dark" : "light");
226
+ document.documentElement.classList.toggle("dark", theme === "dark");
227
+ } catch {
228
+ document.documentElement.classList.toggle(
229
+ "dark",
230
+ matchMedia("(prefers-color-scheme: dark)").matches,
231
+ );
232
+ }
233
+ })();
234
+ </script>`;
235
+
236
+ // --- Public API ---
237
+
238
+ /** CDN mode for `buildHead` — kit files served from jsDelivr (ticket 06). */
239
+ export interface CdnHeadOptions {
240
+ /** Exact published `@zazz-ui/core` version (`"0.1.0"`; never a dist-tag). */
241
+ version: string;
242
+ /**
243
+ * Granular grain: the primitives this page uses. Their dependency closure
244
+ * (via the kit manifest) decides which css/js files load. Omit for the
245
+ * bundle grain (`dist/zazz.css` + `dist/zazz.js`, whole kit, two requests).
246
+ */
247
+ primitives?: string[];
248
+ /**
249
+ * The version's `dist/sri.json` contents (package-relative path → sha384).
250
+ * When provided, every kit URL gets `integrity` + `crossorigin` (links and
251
+ * script tags directly; transitive module imports via the import map's
252
+ * `integrity` section). Omitted → plain pinned URLs.
253
+ */
254
+ sri?: Record<string, string>;
255
+ }
256
+
257
+ /** Options for `buildHead`. */
258
+ export interface HeadOptions {
259
+ /**
260
+ * URL prefix to the kit's `src/` contents, no trailing slash — where
261
+ * `index.css` and `index.js` live. Default `"./zazz"` (the documented copy
262
+ * location); the docs preview iframe passes `"/zazz/src"`.
263
+ */
264
+ base?: string;
265
+ /**
266
+ * Serve the kit from jsDelivr instead of a local copy: pinned, optionally
267
+ * SRI-checked URLs into the published package. Mutually exclusive with
268
+ * `base`.
269
+ */
270
+ cdn?: CdnHeadOptions;
271
+ /**
272
+ * Load component behavior: the import map, the polyfills, and the
273
+ * `index.js` module. `false` renders a style-only head. Default `true`.
274
+ */
275
+ scripts?: boolean;
276
+ /** Geist font loading; `false` skips the block entirely. Default `"swap"`. */
277
+ fontDisplay?: "swap" | "optional" | false;
278
+ /** Include the inline theme-persistence script (last in head). Default `true`. */
279
+ theme?: boolean;
280
+ }
281
+
282
+ /**
283
+ * @description Builds the canonical Zazz `<head>` contents: meta tags, fonts,
284
+ * the single stylesheet link, and (unless `scripts: false`) the import map,
285
+ * polyfills, and `index.js` module tag, ending with the theme script. Page
286
+ * specifics (`<title>`, prefetch hints, override stylesheets) belong after
287
+ * this block, outside the contract.
288
+ *
289
+ * @param options - See `HeadOptions`.
290
+ * @returns The head markup (no surrounding `<head>` tag).
291
+ * @example
292
+ * buildHead(); // full head for "./zazz"
293
+ * buildHead({ base: "/zazz/src", scripts: false, fontDisplay: "optional" });
294
+ */
295
+ export function buildHead(options: HeadOptions = {}): string {
296
+ const { base = "./zazz", cdn, scripts = true, fontDisplay = "swap", theme = true } = options;
297
+
298
+ const parts: string[] = [
299
+ `<meta charset="utf-8">`,
300
+ `<meta name="viewport" content="width=device-width, initial-scale=1">`,
301
+ `<!-- Paint the right theme (background, form controls, scrollbars) before CSS loads -->`,
302
+ `<meta name="color-scheme" content="light dark">`,
303
+ ];
304
+
305
+ if (fontDisplay !== false) parts.push(fontsBlock(fontDisplay));
306
+
307
+ if (cdn) {
308
+ parts.push(...cdnBlocks(cdn, scripts));
309
+ } else {
310
+ parts.push(
311
+ `<!-- Zazz styles: one bundle (index.css @imports every layer in cascade order) -->`,
312
+ `<link rel="stylesheet" href="${base}/index.css">`,
313
+ );
314
+
315
+ if (scripts) {
316
+ parts.push(
317
+ // The import map must precede EVERY module load — including the
318
+ // modulepreload hint — or the browser rejects it and bare specifiers fail.
319
+ importMapBlock(),
320
+ `<link rel="modulepreload" href="${base}/index.js">`,
321
+ polyfillsBlock(),
322
+ `<!-- Zazz behavior: one ES module imports every component script in dependency order -->`,
323
+ `<script type="module" src="${base}/index.js"></script>`,
324
+ );
325
+ }
326
+ }
327
+
328
+ if (theme) parts.push(THEME_SCRIPT);
329
+
330
+ return parts.join("\n");
331
+ }
332
+
333
+ // --- CDN mode ---
334
+
335
+ /**
336
+ * @description Renders the style/behavior blocks for CDN mode: the bundle
337
+ * grain (two `dist/` requests, whole kit) or, when `primitives` is given, the
338
+ * granular grain — base layers in cascade order, the dependency closure's
339
+ * stylesheets, and one module tag per closure script (relative imports between
340
+ * kit files resolve natively on jsDelivr; only bare specifiers need the map).
341
+ *
342
+ * @param cdn - The CDN options (exact version, optional primitives + sri).
343
+ * @param scripts - Whether behavior loads at all (`HeadOptions.scripts`).
344
+ * @returns The head fragments between the fonts block and the theme script.
345
+ * @private
346
+ */
347
+ function cdnBlocks(cdn: CdnHeadOptions, scripts: boolean): string[] {
348
+ const { version, primitives, sri } = cdn;
349
+ if (!EXACT_VERSION.test(version)) {
350
+ throw new Error(
351
+ `CDN URLs must pin an exact version (got "${version}"); ` +
352
+ `dist-tags and ranges break SRI and permanent caching`,
353
+ );
354
+ }
355
+ const url = (path: string): string => `${CDN}/${PACKAGE_NAME}@${version}/${path}`;
356
+ const attrs = (path: string): string => {
357
+ const hash = sri?.[path];
358
+ return hash ? ` integrity="${hash}" crossorigin="anonymous"` : "";
359
+ };
360
+ const parts: string[] = [];
361
+
362
+ if (!primitives) {
363
+ parts.push(
364
+ `<!-- Zazz styles: the whole kit, one request -->`,
365
+ `<link rel="stylesheet" href="${url("dist/zazz.css")}"${attrs("dist/zazz.css")}>`,
366
+ );
367
+ if (scripts) {
368
+ parts.push(
369
+ importMapBlock(),
370
+ `<link rel="modulepreload" href="${url("dist/zazz.js")}"${attrs("dist/zazz.js")}>`,
371
+ polyfillsBlock(),
372
+ `<!-- Zazz behavior: the whole kit, one module -->`,
373
+ `<script type="module" src="${url("dist/zazz.js")}"${attrs("dist/zazz.js")}></script>`,
374
+ );
375
+ }
376
+ return parts;
377
+ }
378
+
379
+ const closure = resolveClosure(primitives);
380
+
381
+ const css = [
382
+ ...BASE_CSS_PRE,
383
+ ...closure.flatMap((name) => PRIMITIVES[name]?.css ?? []),
384
+ ...BASE_CSS_POST,
385
+ ];
386
+ parts.push(
387
+ `<!-- Zazz styles: base layers, then ${closure.join(", ")} in cascade order -->`,
388
+ ...css.map(
389
+ (path) => `<link rel="stylesheet" href="${url(`src/${path}`)}"${attrs(`src/${path}`)}>`,
390
+ ),
391
+ );
392
+
393
+ if (scripts) {
394
+ // Side-effect modules need their own tag (nothing imports them); the rest
395
+ // of each primitive's chain loads through native relative imports. The
396
+ // core dialog-lifecycle module always leads: dialogs, menus, and popovers
397
+ // assume its lifecycle events. Polyfills stay in even for css-only
398
+ // closures — tooltip/dialog/menu styles ride on the Popover API and
399
+ // Invoker Commands.
400
+ const scriptFiles = [
401
+ ...new Set([
402
+ "base/dialog-lifecycle.js",
403
+ ...closure.flatMap((name) => {
404
+ const entry = PRIMITIVES[name];
405
+ return entry ? [...entry.base, ...entry.js] : [];
406
+ }),
407
+ ]),
408
+ ];
409
+ // Transitively imported core modules never get a tag, so their integrity
410
+ // rides in the import map's integrity section instead.
411
+ const transitive: Record<string, string> = {};
412
+ if (sri) {
413
+ for (const path of CORE_RUNTIME_JS) {
414
+ const hash = sri[`src/${path}`];
415
+ if (hash) transitive[url(`src/${path}`)] = hash;
416
+ }
417
+ }
418
+ parts.push(
419
+ importMapBlock(transitive),
420
+ polyfillsBlock(),
421
+ `<!-- Zazz behavior: side-effect modules by tag; the rest via module imports -->`,
422
+ ...scriptFiles.map(
423
+ (path) =>
424
+ `<script type="module" src="${url(`src/${path}`)}"${attrs(`src/${path}`)}></script>`,
425
+ ),
426
+ );
427
+ }
428
+
429
+ return parts;
430
+ }
431
+
432
+ export { ESM_DEPENDENCIES, POLYFILLS, cdnUrl };
433
+ export type { CdnDependency };
package/src/index.css ADDED
@@ -0,0 +1,71 @@
1
+ /**
2
+ * index.css — Plain-CSS entry point; @import bundle in cascade order.
3
+ *
4
+ * Bundles the base layers (layers → variables → reset) followed by every
5
+ * component, so a page only needs a single stylesheet link. Order matters:
6
+ * layers.css declares the cascade layers and must load first.
7
+ *
8
+ * Legacy support: import your legacy stylesheets into the legacy layer at the slot
9
+ * below (between the reset baseline and the components). Projects that prefer to
10
+ * compose the layers by hand can import the base files individually in the
11
+ * same order instead of using this bundle — see CONVENTIONS.md.
12
+ *
13
+ * @layer none
14
+ * @see CONVENTIONS.md — file anatomy & layer architecture
15
+ */
16
+
17
+ /* base — order matters; _layers.css declares the cascade layers first. */
18
+ @import "./base/_layers.css";
19
+ @import "./base/_variables.css";
20
+ @import "./base/_reset.css";
21
+ @import "./base/_typography.css";
22
+ @import "./base/_view-transitions.css";
23
+
24
+ /* Legacy layer — import legacy stylesheets here, into the legacy layer */
25
+ /* @import "./your-legacy.css" layer(legacy); */
26
+
27
+ /* Zazz primitives - UI omponents. */
28
+ @import "./primitives/separator/separator.css";
29
+ @import "./primitives/badge/badge.css";
30
+ @import "./primitives/kbd/kbd.css";
31
+ @import "./primitives/button/button.css";
32
+ @import "./primitives/button-group/button-group.css";
33
+ @import "./primitives/toggle/toggle.css";
34
+ @import "./primitives/toggle-group/toggle-group.css";
35
+ @import "./primitives/accordion/accordion.css";
36
+ @import "./primitives/table/table.css";
37
+ @import "./primitives/progress/progress.css";
38
+ @import "./primitives/meter/meter.css";
39
+ @import "./primitives/popover/popover.css";
40
+ @import "./primitives/tooltip/tooltip.css";
41
+ @import "./primitives/dialog/dialog.css";
42
+ @import "./primitives/alert-dialog/alert-dialog.css";
43
+ @import "./primitives/menu/menu.css";
44
+ @import "./primitives/navigation-menu/navigation-menu.css";
45
+ @import "./primitives/mobile-menu/mobile-menu.css";
46
+ @import "./primitives/fields/fields.css";
47
+ @import "./primitives/input/input.css";
48
+ @import "./primitives/textarea/textarea.css";
49
+ @import "./primitives/select/select.css";
50
+ @import "./primitives/autocomplete/autocomplete.css";
51
+ @import "./primitives/combobox/combobox.css";
52
+ @import "./primitives/command/command.css";
53
+ @import "./primitives/checkbox/checkbox.css";
54
+ @import "./primitives/slider/slider.css";
55
+ @import "./primitives/switch/switch.css";
56
+ @import "./primitives/input-group/input-group.css";
57
+ @import "./primitives/password-group/password-group.css";
58
+ @import "./primitives/otp/otp.css";
59
+ @import "./primitives/radio/radio.css";
60
+ @import "./primitives/tabs/tabs.css";
61
+ @import "./primitives/carousel/carousel.css";
62
+ @import "./primitives/lightbox/lightbox.css";
63
+ @import "./primitives/toaster/toaster.css";
64
+ @import "./primitives/reveal/reveal.css";
65
+
66
+ /* Utilities and layout remain the final normal Zazz override layer. */
67
+ @import "./base/_utilities.css";
68
+ @import "./base/_layout.css";
69
+
70
+ /* Migrations layer - for legacy css overrides */
71
+ /* @import "./migrations.css"; */
package/src/index.d.ts ADDED
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @fileoverview Zazz — single entry point for every component script.
3
+ * @description Imports all Zazz behavior modules so a page needs only one
4
+ * `<script type="module" src=".../index.js">` instead of ten separate tags.
5
+ * Each module runs for its side effects: global/utility setup, scroll-reveal
6
+ * and carousel auto-initialization, SPA navigation, and the custom-element
7
+ * registrations (`<ui-autocomplete>`, `<ui-carousel>`, `<ui-combobox>`,
8
+ * `<ui-command>`, `<ui-lightbox>`, `<ui-menu>`, `<ui-password>`, `<ui-tabs>`,
9
+ * `<ui-toaster>`).
10
+ *
11
+ * Internal dependencies are resolved by the module graph — utils loads
12
+ * before embla, embla before carousel, carousel before lightbox — so the
13
+ * import order below is for readability, not correctness.
14
+ *
15
+ * External dependencies (signal-polyfill, the Embla packages) are imported by
16
+ * bare specifier and resolved by the page's import map — generated by
17
+ * `head.ts` with pinned, SRI-checked jsDelivr URLs. No extra script tags.
18
+ */
19
+ import "./base/utils.ts";
20
+ import "./base/reveal.ts";
21
+ import "./base/dialog-lifecycle.ts";
22
+ import "./base/embla.ts";
23
+ import "./primitives/autocomplete/autocomplete.ts";
24
+ import "./primitives/checkbox/checkbox.ts";
25
+ import "./primitives/combobox/combobox.ts";
26
+ import "./primitives/command/command.ts";
27
+ import "./primitives/carousel/carousel.ts";
28
+ import "./primitives/lightbox/lightbox.ts";
29
+ import "./primitives/menu/menu.ts";
30
+ import "./primitives/otp/otp.ts";
31
+ import "./primitives/password-group/password-group.ts";
32
+ import "./primitives/select/multiselect.ts";
33
+ import "./primitives/tabs/tabs.ts";
34
+ import "./primitives/toaster/toaster.ts";
35
+ import "./base/navigation.ts";
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,iBAAiB,CAAC;AACzB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,4BAA4B,CAAC;AACpC,OAAO,iBAAiB,CAAC;AACzB,OAAO,2CAA2C,CAAC;AACnD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,mCAAmC,CAAC;AAC3C,OAAO,iCAAiC,CAAC;AACzC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,mCAAmC,CAAC;AAC3C,OAAO,2BAA2B,CAAC;AACnC,OAAO,yBAAyB,CAAC;AACjC,OAAO,+CAA+C,CAAC;AACvD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,2BAA2B,CAAC;AACnC,OAAO,iCAAiC,CAAC;AACzC,OAAO,sBAAsB,CAAC"}
package/src/index.js ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @fileoverview Zazz — single entry point for every component script.
3
+ * @description Imports all Zazz behavior modules so a page needs only one
4
+ * `<script type="module" src=".../index.js">` instead of ten separate tags.
5
+ * Each module runs for its side effects: global/utility setup, scroll-reveal
6
+ * and carousel auto-initialization, SPA navigation, and the custom-element
7
+ * registrations (`<ui-autocomplete>`, `<ui-carousel>`, `<ui-combobox>`,
8
+ * `<ui-command>`, `<ui-lightbox>`, `<ui-menu>`, `<ui-password>`, `<ui-tabs>`,
9
+ * `<ui-toaster>`).
10
+ *
11
+ * Internal dependencies are resolved by the module graph — utils loads
12
+ * before embla, embla before carousel, carousel before lightbox — so the
13
+ * import order below is for readability, not correctness.
14
+ *
15
+ * External dependencies (signal-polyfill, the Embla packages) are imported by
16
+ * bare specifier and resolved by the page's import map — generated by
17
+ * `head.ts` with pinned, SRI-checked jsDelivr URLs. No extra script tags.
18
+ */
19
+ import "./base/utils.js";
20
+ import "./base/reveal.js";
21
+ import "./base/dialog-lifecycle.js";
22
+ import "./base/embla.js";
23
+ import "./primitives/autocomplete/autocomplete.js";
24
+ import "./primitives/checkbox/checkbox.js";
25
+ import "./primitives/combobox/combobox.js";
26
+ import "./primitives/command/command.js";
27
+ import "./primitives/carousel/carousel.js";
28
+ import "./primitives/lightbox/lightbox.js";
29
+ import "./primitives/menu/menu.js";
30
+ import "./primitives/otp/otp.js";
31
+ import "./primitives/password-group/password-group.js";
32
+ import "./primitives/select/multiselect.js";
33
+ import "./primitives/tabs/tabs.js";
34
+ import "./primitives/toaster/toaster.js";
35
+ import "./base/navigation.js";
package/src/index.ts ADDED
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @fileoverview Zazz — single entry point for every component script.
3
+ * @description Imports all Zazz behavior modules so a page needs only one
4
+ * `<script type="module" src=".../index.js">` instead of ten separate tags.
5
+ * Each module runs for its side effects: global/utility setup, scroll-reveal
6
+ * and carousel auto-initialization, SPA navigation, and the custom-element
7
+ * registrations (`<ui-autocomplete>`, `<ui-carousel>`, `<ui-combobox>`,
8
+ * `<ui-command>`, `<ui-lightbox>`, `<ui-menu>`, `<ui-password>`, `<ui-tabs>`,
9
+ * `<ui-toaster>`).
10
+ *
11
+ * Internal dependencies are resolved by the module graph — utils loads
12
+ * before embla, embla before carousel, carousel before lightbox — so the
13
+ * import order below is for readability, not correctness.
14
+ *
15
+ * External dependencies (signal-polyfill, the Embla packages) are imported by
16
+ * bare specifier and resolved by the page's import map — generated by
17
+ * `head.ts` with pinned, SRI-checked jsDelivr URLs. No extra script tags.
18
+ */
19
+
20
+ import "./base/utils.ts";
21
+ import "./base/reveal.ts";
22
+ import "./base/dialog-lifecycle.ts";
23
+ import "./base/embla.ts";
24
+ import "./primitives/autocomplete/autocomplete.ts";
25
+ import "./primitives/checkbox/checkbox.ts";
26
+ import "./primitives/combobox/combobox.ts";
27
+ import "./primitives/command/command.ts";
28
+ import "./primitives/carousel/carousel.ts";
29
+ import "./primitives/lightbox/lightbox.ts";
30
+ import "./primitives/menu/menu.ts";
31
+ import "./primitives/otp/otp.ts";
32
+ import "./primitives/password-group/password-group.ts";
33
+ import "./primitives/select/multiselect.ts";
34
+ import "./primitives/tabs/tabs.ts";
35
+ import "./primitives/toaster/toaster.ts";
36
+ import "./base/navigation.ts";