@zazz-ui/core 0.6.1 → 0.6.3

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 (55) hide show
  1. package/AUTHORING.md +5 -3
  2. package/CHANGELOG.md +46 -0
  3. package/README.md +5 -5
  4. package/dist/csp-D72qtdXZ.js +1 -0
  5. package/dist/sri.json +18 -15
  6. package/dist/zazz.css +1 -1
  7. package/dist/zazz.js +1 -1
  8. package/editor/zazz.css-data.json +2028 -0
  9. package/editor/zazz.language-data.json +15 -3
  10. package/package.json +1 -1
  11. package/src/base/_reset.css +9 -17
  12. package/src/base/_utilities-color.css +3 -0
  13. package/src/base/_utilities-spacing.css +35 -0
  14. package/src/base/_variables.css +4 -0
  15. package/src/base/csp.d.ts +19 -0
  16. package/src/base/csp.d.ts.map +1 -0
  17. package/src/base/csp.js +131 -0
  18. package/src/base/csp.ts +137 -0
  19. package/src/base/declarations.d.ts +36 -0
  20. package/src/base/declarations.d.ts.map +1 -0
  21. package/src/base/declarations.js +70 -0
  22. package/src/base/declarations.ts +97 -0
  23. package/src/base/style-format.d.ts +3 -22
  24. package/src/base/style-format.d.ts.map +1 -1
  25. package/src/base/style-format.js +4 -62
  26. package/src/base/style-format.ts +4 -71
  27. package/src/base/utilities.d.ts.map +1 -1
  28. package/src/base/utilities.js +35 -17
  29. package/src/base/utilities.ts +42 -20
  30. package/src/head.d.ts +6 -0
  31. package/src/head.d.ts.map +1 -1
  32. package/src/head.js +21 -14
  33. package/src/head.ts +38 -11
  34. package/src/index.js +22 -0
  35. package/src/index.ts +19 -0
  36. package/src/manifest.d.ts +21 -1
  37. package/src/manifest.d.ts.map +1 -1
  38. package/src/manifest.js +10 -1
  39. package/src/manifest.ts +25 -1
  40. package/src/primitives/badge/badge.css +61 -111
  41. package/src/primitives/badge/badge.html +5 -0
  42. package/src/primitives/button/button.css +55 -53
  43. package/src/primitives/button/button.html +4 -0
  44. package/src/primitives/callout/callout.css +35 -10
  45. package/src/primitives/debug/audit-core.d.ts +1 -1
  46. package/src/primitives/debug/audit-core.d.ts.map +1 -1
  47. package/src/primitives/debug/audit-core.js +35 -5
  48. package/src/primitives/debug/audit-core.ts +42 -4
  49. package/src/primitives/prose/prose.html +3 -3
  50. package/src/primitives/table/table-size-sm.html +12 -12
  51. package/src/primitives/utilities/aspect-ratio.html +1 -0
  52. package/src/primitives/utilities/margin-auto.html +1 -1
  53. package/src/primitives/utilities/overflow.html +5 -6
  54. package/src/primitives/utilities/position.html +1 -1
  55. package/src/primitives/utilities/width.html +2 -1
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @fileoverview Splits a `style` attribute value into declarations.
5
+ * @description One parser for every reader of the attribute text: the
6
+ * formatter (`style-format.ts`), the language server, and the CSP fallback
7
+ * (`csp.ts`). Splits on top-level `;` only, so a `;` inside `url("…")`,
8
+ * `var(--x, …)`, or a quoted string stays in its value. No imports, so a
9
+ * runtime module can use it without pulling in the utility tables.
10
+ */
11
+
12
+ // --- Declarations ---
13
+
14
+ /** `[start, end)` offsets into a style value. */
15
+ export type Range = [number, number];
16
+
17
+ /** One declaration of a style value, with its parts' offsets (all trimmed). */
18
+ export interface ScannedDeclaration {
19
+ /** The whole declaration. */
20
+ span: Range;
21
+ /** The name; a declaration still being typed (`--p`) is all name. */
22
+ name: string;
23
+ nameSpan: Range;
24
+ /** Offset of the colon, or -1 when there is none yet. */
25
+ colon: number;
26
+ /** The value as written, `!important` included. */
27
+ value: string;
28
+ /** Empty (`[colon + 1, colon + 1]`) when nothing follows the colon. */
29
+ valueSpan: Range;
30
+ /** `"important"` when the value ends in `!important`, else `""` (what `setProperty` takes). */
31
+ priority: "" | "important";
32
+ }
33
+
34
+ /** Trims `[start, end)` of `text` to its non-whitespace extent. */
35
+ function trimRange(text: string, start: number, end: number): Range {
36
+ while (start < end && /\s/.test(text[start]!)) start++;
37
+ while (end > start && /\s/.test(text[end - 1]!)) end--;
38
+ return [start, end];
39
+ }
40
+
41
+ const IMPORTANT = /!\s*important$/i;
42
+
43
+ /**
44
+ * Scans a style value into declarations, splitting on top-level `;` (not inside
45
+ * parentheses or quotes). Empty segments are skipped.
46
+ */
47
+ export function scanDeclarations(value: string): ScannedDeclaration[] {
48
+ const found: ScannedDeclaration[] = [];
49
+ const push = (from: number, to: number) => {
50
+ const span = trimRange(value, from, to);
51
+ if (span[0] === span[1]) return;
52
+ const colon = value.indexOf(":", span[0]);
53
+ const hasColon = colon !== -1 && colon < span[1];
54
+ const nameSpan = hasColon ? trimRange(value, span[0], colon) : span;
55
+ const valueSpan = hasColon
56
+ ? trimRange(value, colon + 1, span[1])
57
+ : ([span[1], span[1]] as Range);
58
+ const text = value.slice(...valueSpan);
59
+ found.push({
60
+ span,
61
+ name: value.slice(...nameSpan),
62
+ nameSpan,
63
+ colon: hasColon ? colon : -1,
64
+ value: text,
65
+ valueSpan,
66
+ priority: IMPORTANT.test(text) ? "important" : "",
67
+ });
68
+ };
69
+ let depth = 0;
70
+ let quote: string | null = null;
71
+ let start = 0;
72
+ for (let i = 0; i < value.length; i++) {
73
+ const ch = value[i]!;
74
+ if (quote) {
75
+ if (ch === "\\") i++;
76
+ else if (ch === quote) quote = null;
77
+ } else if (ch === '"' || ch === "'") quote = ch;
78
+ else if (ch === "(") depth++;
79
+ else if (ch === ")") depth = Math.max(0, depth - 1);
80
+ else if (ch === ";" && depth === 0) {
81
+ push(start, i);
82
+ start = i + 1;
83
+ }
84
+ }
85
+ push(start, value.length);
86
+ return found;
87
+ }
88
+
89
+ /** Splits a style value on top-level `;`, ignoring ones inside parentheses or quotes. */
90
+ export function splitDeclarations(value: string): string[] {
91
+ return scanDeclarations(value).map(({ span }) => value.slice(...span));
92
+ }
93
+
94
+ /** A declaration's value without its `!important`, for `setProperty(name, value, priority)`. */
95
+ export function plainValue({ value }: ScannedDeclaration): string {
96
+ return value.replace(IMPORTANT, "").trimEnd();
97
+ }
@@ -1,25 +1,6 @@
1
- /** `[start, end)` offsets into a style value. */
2
- export type Range = [number, number];
3
- /** One declaration of a style value, with its parts' offsets (all trimmed). */
4
- export interface ScannedDeclaration {
5
- /** The whole declaration. */
6
- span: Range;
7
- /** The name; a declaration still being typed (`--p`) is all name. */
8
- name: string;
9
- nameSpan: Range;
10
- /** Offset of the colon, or -1 when there is none yet. */
11
- colon: number;
12
- value: string;
13
- /** Empty (`[colon + 1, colon + 1]`) when nothing follows the colon. */
14
- valueSpan: Range;
15
- }
16
- /**
17
- * Scans a style value into declarations, splitting on top-level `;` (not inside
18
- * parentheses or quotes). Empty segments are skipped.
19
- */
20
- export declare function scanDeclarations(value: string): ScannedDeclaration[];
21
- /** Splits a style value on top-level `;`, ignoring ones inside parentheses or quotes. */
22
- export declare function splitDeclarations(value: string): string[];
1
+ import { scanDeclarations, splitDeclarations } from "./declarations.ts";
2
+ export { scanDeclarations, splitDeclarations };
3
+ export type { Range, ScannedDeclaration } from "./declarations.ts";
23
4
  /** `--px :6` → `--px: 6`. A declaration without a colon is kept as written. */
24
5
  export declare function normalize(declaration: string): string;
25
6
  /** Declarations in cascade order (a stable sort). */
@@ -1 +1 @@
1
- {"version":3,"file":"style-format.d.ts","sourceRoot":"","sources":["style-format.ts"],"names":[],"mappings":"AAgCA,iDAAiD;AACjD,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAErC,+EAA+E;AAC/E,MAAM,WAAW,kBAAkB;IACjC,6BAA6B;IAC7B,IAAI,EAAE,KAAK,CAAC;IACZ,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC;IAChB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,SAAS,EAAE,KAAK,CAAC;CAClB;AASD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAsCpE;AAED,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzD;AAsBD,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAIrD;AA8BD,qDAAqD;AACrD,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAGlE;AAID;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAM1E"}
1
+ {"version":3,"file":"style-format.d.ts","sourceRoot":"","sources":["style-format.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC;AAC/C,YAAY,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAsBnE,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAIrD;AA8BD,qDAAqD;AACrD,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAGlE;AAID;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAM1E"}
@@ -18,68 +18,10 @@
18
18
  * keeps its winner and raw shorthands keep their place before longhands.
19
19
  */
20
20
  import { BREAKPOINTS, PSEUDO_ONLY, PSEUDO_SIDES, STATES, UTILITIES, parseUtilityName, } from "./utilities.js";
21
- /** Trims `[start, end)` of `text` to its non-whitespace extent. */
22
- function trimRange(text, start, end) {
23
- while (start < end && /\s/.test(text[start]))
24
- start++;
25
- while (end > start && /\s/.test(text[end - 1]))
26
- end--;
27
- return [start, end];
28
- }
29
- /**
30
- * Scans a style value into declarations, splitting on top-level `;` (not inside
31
- * parentheses or quotes). Empty segments are skipped.
32
- */
33
- export function scanDeclarations(value) {
34
- const found = [];
35
- const push = (from, to) => {
36
- const span = trimRange(value, from, to);
37
- if (span[0] === span[1])
38
- return;
39
- const colon = value.indexOf(":", span[0]);
40
- const hasColon = colon !== -1 && colon < span[1];
41
- const nameSpan = hasColon ? trimRange(value, span[0], colon) : span;
42
- const valueSpan = hasColon
43
- ? trimRange(value, colon + 1, span[1])
44
- : [span[1], span[1]];
45
- found.push({
46
- span,
47
- name: value.slice(...nameSpan),
48
- nameSpan,
49
- colon: hasColon ? colon : -1,
50
- value: value.slice(...valueSpan),
51
- valueSpan,
52
- });
53
- };
54
- let depth = 0;
55
- let quote = null;
56
- let start = 0;
57
- for (let i = 0; i < value.length; i++) {
58
- const ch = value[i];
59
- if (quote) {
60
- if (ch === "\\")
61
- i++;
62
- else if (ch === quote)
63
- quote = null;
64
- }
65
- else if (ch === '"' || ch === "'")
66
- quote = ch;
67
- else if (ch === "(")
68
- depth++;
69
- else if (ch === ")")
70
- depth = Math.max(0, depth - 1);
71
- else if (ch === ";" && depth === 0) {
72
- push(start, i);
73
- start = i + 1;
74
- }
75
- }
76
- push(start, value.length);
77
- return found;
78
- }
79
- /** Splits a style value on top-level `;`, ignoring ones inside parentheses or quotes. */
80
- export function splitDeclarations(value) {
81
- return scanDeclarations(value).map(({ span }) => value.slice(...span));
82
- }
21
+ // --- Declarations ---
22
+ // the parser lives in declarations.ts (no imports) so the CSP fallback can share it
23
+ import { scanDeclarations, splitDeclarations } from "./declarations.js";
24
+ export { scanDeclarations, splitDeclarations };
83
25
  /** Collapses whitespace runs to one space, outside quotes. */
84
26
  function collapse(text) {
85
27
  let out = "";
@@ -30,78 +30,11 @@ import {
30
30
 
31
31
  // --- Declarations ---
32
32
 
33
- /** `[start, end)` offsets into a style value. */
34
- export type Range = [number, number];
33
+ // the parser lives in declarations.ts (no imports) so the CSP fallback can share it
34
+ import { scanDeclarations, splitDeclarations } from "./declarations.ts";
35
35
 
36
- /** One declaration of a style value, with its parts' offsets (all trimmed). */
37
- export interface ScannedDeclaration {
38
- /** The whole declaration. */
39
- span: Range;
40
- /** The name; a declaration still being typed (`--p`) is all name. */
41
- name: string;
42
- nameSpan: Range;
43
- /** Offset of the colon, or -1 when there is none yet. */
44
- colon: number;
45
- value: string;
46
- /** Empty (`[colon + 1, colon + 1]`) when nothing follows the colon. */
47
- valueSpan: Range;
48
- }
49
-
50
- /** Trims `[start, end)` of `text` to its non-whitespace extent. */
51
- function trimRange(text: string, start: number, end: number): Range {
52
- while (start < end && /\s/.test(text[start]!)) start++;
53
- while (end > start && /\s/.test(text[end - 1]!)) end--;
54
- return [start, end];
55
- }
56
-
57
- /**
58
- * Scans a style value into declarations, splitting on top-level `;` (not inside
59
- * parentheses or quotes). Empty segments are skipped.
60
- */
61
- export function scanDeclarations(value: string): ScannedDeclaration[] {
62
- const found: ScannedDeclaration[] = [];
63
- const push = (from: number, to: number) => {
64
- const span = trimRange(value, from, to);
65
- if (span[0] === span[1]) return;
66
- const colon = value.indexOf(":", span[0]);
67
- const hasColon = colon !== -1 && colon < span[1];
68
- const nameSpan = hasColon ? trimRange(value, span[0], colon) : span;
69
- const valueSpan = hasColon
70
- ? trimRange(value, colon + 1, span[1])
71
- : ([span[1], span[1]] as Range);
72
- found.push({
73
- span,
74
- name: value.slice(...nameSpan),
75
- nameSpan,
76
- colon: hasColon ? colon : -1,
77
- value: value.slice(...valueSpan),
78
- valueSpan,
79
- });
80
- };
81
- let depth = 0;
82
- let quote: string | null = null;
83
- let start = 0;
84
- for (let i = 0; i < value.length; i++) {
85
- const ch = value[i]!;
86
- if (quote) {
87
- if (ch === "\\") i++;
88
- else if (ch === quote) quote = null;
89
- } else if (ch === '"' || ch === "'") quote = ch;
90
- else if (ch === "(") depth++;
91
- else if (ch === ")") depth = Math.max(0, depth - 1);
92
- else if (ch === ";" && depth === 0) {
93
- push(start, i);
94
- start = i + 1;
95
- }
96
- }
97
- push(start, value.length);
98
- return found;
99
- }
100
-
101
- /** Splits a style value on top-level `;`, ignoring ones inside parentheses or quotes. */
102
- export function splitDeclarations(value: string): string[] {
103
- return scanDeclarations(value).map(({ span }) => value.slice(...span));
104
- }
36
+ export { scanDeclarations, splitDeclarations };
37
+ export type { Range, ScannedDeclaration } from "./declarations.ts";
105
38
 
106
39
  /** Collapses whitespace runs to one space, outside quotes. */
107
40
  function collapse(text: string): string {
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["utilities.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,qDAAqD;AACrD,eAAO,MAAM,WAAW,YAAI,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAU,CAAC;AACpE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAMrD,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,MAAM,YACjB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,eAAe,EACf,cAAc,EACd,OAAO,EACP,SAAS,EACT,SAAS,EACT,MAAM,EACN,OAAO,CACC,CAAC;AACX,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5C;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,KAAK,EACL;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,IAAI,CAAA;CAAE,CAYlE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW;aACtB,QAAQ,EAAE,aAAa;aACvB,QAAQ,EAAE,gCAAgC;IAC1C,+FAA+F;aAC/F,QAAQ,EAAE,eAAe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oDAAoD;AACpD,eAAO,MAAM,WAAW,EAAE,SAAS,OAAO,EAEzC,CAAC;AAEF,eAAO,MAAM,YAAY,YAAI,QAAQ,EAAE,OAAO,CAAU,CAAC;AACzD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,6DAA6D;AAC7D,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAM3D;AAED,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,IAAI,CAAC;CACd;AAID,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAyBzD"}
@@ -179,6 +179,22 @@ export const SIZING_KEYWORDS = ["auto", "fit-content", "min-content", "max-conte
179
179
  export const MARGIN_KEYWORDS = ["auto"];
180
180
  /** A layout places its children; a tier-only column utility there keeps the band below the tier. */
181
181
  const LAYOUT_CHILDREN = ["ui-layout > *", '[data-ui~="layout"] > *'];
182
+ /**
183
+ * Elements the reset or the prose scope pads (a prose list's indent, a quote's
184
+ * inset, inline code, form controls): a tier-only padding utility there would
185
+ * zero that padding below the tier, so they keep the base requirement.
186
+ */
187
+ const BASE_PADDED = [
188
+ '[data-ui~="prose"] :is(ul, ol, dd, blockquote, cite)',
189
+ "code",
190
+ "button",
191
+ "input",
192
+ "select",
193
+ "textarea",
194
+ "optgroup",
195
+ ];
196
+ /** Elements the reset paints: a tier-only `--bg` there would clear the paint below the tier. */
197
+ const BASE_PAINTED = ["code", "hr"];
182
198
  /**
183
199
  * Track-list keywords `--grid-cols` / `--grid-rows` take besides a count. `none`
184
200
  * is not one: `--template-cols: none` says the same, and every keyword
@@ -350,26 +366,25 @@ export const UTILITIES = [
350
366
  family: "grid",
351
367
  emit: "grid-fit",
352
368
  },
353
- // spacing: dual mode; gap is on the no-base allowlist
354
- { name: "p", pseudo: true, properties: ["padding"], mode: "dual", family: "spacing" },
355
- { name: "px", pseudo: true, properties: ["padding-inline"], mode: "dual", family: "spacing" },
356
- { name: "py", pseudo: true, properties: ["padding-block"], mode: "dual", family: "spacing" },
357
- {
358
- name: "pt",
359
- pseudo: true,
360
- properties: ["padding-block-start"],
361
- mode: "dual",
362
- family: "spacing",
363
- },
364
- { name: "pb", pseudo: true, properties: ["padding-block-end"], mode: "dual", family: "spacing" },
365
- {
366
- name: "pl",
369
+ // spacing: dual mode; padding and gap are on the no-base allowlist (the reset
370
+ // zeroes padding, so `--px--md: 8` alone pads from md), except where the base pads
371
+ ...[
372
+ ["p", "padding"],
373
+ ["px", "padding-inline"],
374
+ ["py", "padding-block"],
375
+ ["pt", "padding-block-start"],
376
+ ["pb", "padding-block-end"],
377
+ ["pl", "padding-inline-start"],
378
+ ["pr", "padding-inline-end"],
379
+ ].map(([name, property]) => ({
380
+ name,
367
381
  pseudo: true,
368
- properties: ["padding-inline-start"],
382
+ properties: [property],
369
383
  mode: "dual",
370
384
  family: "spacing",
371
- },
372
- { name: "pr", pseudo: true, properties: ["padding-inline-end"], mode: "dual", family: "spacing" },
385
+ noBase: "0",
386
+ noBaseExclude: BASE_PADDED,
387
+ })),
373
388
  { name: "gap", properties: ["gap"], mode: "dual", family: "spacing", noBase: "0" },
374
389
  { name: "gap-x", properties: ["column-gap"], mode: "dual", family: "spacing", noBase: "0" },
375
390
  { name: "gap-y", properties: ["row-gap"], mode: "dual", family: "spacing", noBase: "0" },
@@ -556,6 +571,7 @@ export const UTILITIES = [
556
571
  { name: "whitespace", properties: ["white-space"], mode: "keyword", family: "typography" },
557
572
  // color: states; bg-alpha feeds the bg emission
558
573
  { name: "text", properties: ["color"], mode: "raw", family: "color", pseudo: true },
574
+ // on the no-base allowlist: a plain element is transparent, so `--bg--hover` alone paints on hover
559
575
  {
560
576
  name: "bg",
561
577
  properties: ["background-color"],
@@ -563,6 +579,8 @@ export const UTILITIES = [
563
579
  family: "color",
564
580
  emit: "bg",
565
581
  pseudo: true,
582
+ noBase: "transparent",
583
+ noBaseExclude: BASE_PAINTED,
566
584
  },
567
585
  { name: "bg-alpha", properties: [], mode: "raw", family: "color", emit: "none" },
568
586
  // gradients: the type utility carries the prelude (direction, shape, position,
@@ -286,6 +286,22 @@ export const SIZING_KEYWORDS = ["auto", "fit-content", "min-content", "max-conte
286
286
  export const MARGIN_KEYWORDS = ["auto"] as const;
287
287
  /** A layout places its children; a tier-only column utility there keeps the band below the tier. */
288
288
  const LAYOUT_CHILDREN = ["ui-layout > *", '[data-ui~="layout"] > *'] as const;
289
+ /**
290
+ * Elements the reset or the prose scope pads (a prose list's indent, a quote's
291
+ * inset, inline code, form controls): a tier-only padding utility there would
292
+ * zero that padding below the tier, so they keep the base requirement.
293
+ */
294
+ const BASE_PADDED = [
295
+ '[data-ui~="prose"] :is(ul, ol, dd, blockquote, cite)',
296
+ "code",
297
+ "button",
298
+ "input",
299
+ "select",
300
+ "textarea",
301
+ "optgroup",
302
+ ] as const;
303
+ /** Elements the reset paints: a tier-only `--bg` there would clear the paint below the tier. */
304
+ const BASE_PAINTED = ["code", "hr"] as const;
289
305
 
290
306
  /**
291
307
  * Track-list keywords `--grid-cols` / `--grid-rows` take besides a count. `none`
@@ -459,26 +475,29 @@ export const UTILITIES: readonly Utility[] = [
459
475
  family: "grid",
460
476
  emit: "grid-fit",
461
477
  },
462
- // spacing: dual mode; gap is on the no-base allowlist
463
- { name: "p", pseudo: true, properties: ["padding"], mode: "dual", family: "spacing" },
464
- { name: "px", pseudo: true, properties: ["padding-inline"], mode: "dual", family: "spacing" },
465
- { name: "py", pseudo: true, properties: ["padding-block"], mode: "dual", family: "spacing" },
466
- {
467
- name: "pt",
468
- pseudo: true,
469
- properties: ["padding-block-start"],
470
- mode: "dual",
471
- family: "spacing",
472
- },
473
- { name: "pb", pseudo: true, properties: ["padding-block-end"], mode: "dual", family: "spacing" },
474
- {
475
- name: "pl",
476
- pseudo: true,
477
- properties: ["padding-inline-start"],
478
- mode: "dual",
479
- family: "spacing",
480
- },
481
- { name: "pr", pseudo: true, properties: ["padding-inline-end"], mode: "dual", family: "spacing" },
478
+ // spacing: dual mode; padding and gap are on the no-base allowlist (the reset
479
+ // zeroes padding, so `--px--md: 8` alone pads from md), except where the base pads
480
+ ...(
481
+ [
482
+ ["p", "padding"],
483
+ ["px", "padding-inline"],
484
+ ["py", "padding-block"],
485
+ ["pt", "padding-block-start"],
486
+ ["pb", "padding-block-end"],
487
+ ["pl", "padding-inline-start"],
488
+ ["pr", "padding-inline-end"],
489
+ ] as const
490
+ ).map(
491
+ ([name, property]): Utility => ({
492
+ name,
493
+ pseudo: true,
494
+ properties: [property],
495
+ mode: "dual",
496
+ family: "spacing",
497
+ noBase: "0",
498
+ noBaseExclude: BASE_PADDED,
499
+ }),
500
+ ),
482
501
  { name: "gap", properties: ["gap"], mode: "dual", family: "spacing", noBase: "0" },
483
502
  { name: "gap-x", properties: ["column-gap"], mode: "dual", family: "spacing", noBase: "0" },
484
503
  { name: "gap-y", properties: ["row-gap"], mode: "dual", family: "spacing", noBase: "0" },
@@ -665,6 +684,7 @@ export const UTILITIES: readonly Utility[] = [
665
684
  { name: "whitespace", properties: ["white-space"], mode: "keyword", family: "typography" },
666
685
  // color: states; bg-alpha feeds the bg emission
667
686
  { name: "text", properties: ["color"], mode: "raw", family: "color", pseudo: true },
687
+ // on the no-base allowlist: a plain element is transparent, so `--bg--hover` alone paints on hover
668
688
  {
669
689
  name: "bg",
670
690
  properties: ["background-color"],
@@ -672,6 +692,8 @@ export const UTILITIES: readonly Utility[] = [
672
692
  family: "color",
673
693
  emit: "bg",
674
694
  pseudo: true,
695
+ noBase: "transparent",
696
+ noBaseExclude: BASE_PAINTED,
675
697
  },
676
698
  { name: "bg-alpha", properties: [], mode: "raw", family: "color", emit: "none" },
677
699
  // gradients: the type utility carries the prelude (direction, shape, position,
package/src/head.d.ts CHANGED
@@ -84,6 +84,12 @@ export interface HeadOptions {
84
84
  fontDisplay?: "swap" | "optional" | false;
85
85
  /** Include the inline theme-persistence script (last in head). Default `true`. */
86
86
  theme?: boolean;
87
+ /**
88
+ * A CSP nonce for the two inline scripts (the import map and the theme
89
+ * script), so a strict `script-src 'nonce-…'` allows them. The page's own
90
+ * value, generated per response; never a constant.
91
+ */
92
+ nonce?: string;
87
93
  /**
88
94
  * Local granular grain: the primitives this page uses, loaded file by file
89
95
  * from `base` (base layers, the closure's stylesheets in cascade order, one
package/src/head.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"head.d.ts","sourceRoot":"","sources":["head.ts"],"names":[],"mappings":"AA6BA,wDAAwD;AACxD,UAAU,aAAa;IACrB,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAqCD;;;;;;GAMG;AACH,iBAAS,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAE1C;AAED;;;;;GAKG;AACH,QAAA,MAAM,gBAAgB,EAAE,SAAS,aAAa,EA+B7C,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,SAAS,EAAE,SAAS,aAAa,EAOtC,CAAC;AAiFF,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,+BAA+B;AAC/B,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;O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;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,WAAgB,GAAG,MAAM,CAsD3D;AAgID,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AAC/C,YAAY,EAAE,aAAa,EAAE,CAAC;AAI9B;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,WAAW,CAAC;IACrB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;CAChB;AAKD,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,OAAO,GAAE,WAAgB,GAAG,MAAM,CAI5D;AAED,+FAA+F;AAC/F,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAgBjE;AAcD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,WAAW,GACpB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAa1D;AAED,0FAA0F;AAC1F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,CAG1F"}
package/src/head.js CHANGED
@@ -51,6 +51,9 @@ const CORE_RUNTIME_JS = [
51
51
  "base/zazz-element.js",
52
52
  // dynamically imported by index.js where container scroll-state queries are unsupported
53
53
  "base/scroll-state.js",
54
+ // dynamically imported by index.js where the page's CSP blocks inline style attributes
55
+ "base/csp.js",
56
+ "base/declarations.js",
54
57
  ];
55
58
  /**
56
59
  * @description Builds the pinned jsDelivr URL for a dependency.
@@ -146,7 +149,7 @@ function fontsBlock(display) {
146
149
  * @returns The import-map script tag.
147
150
  * @private
148
151
  */
149
- function importMapBlock(extraIntegrity = {}) {
152
+ function importMapBlock(extraIntegrity = {}, nonce) {
150
153
  const imports = {};
151
154
  const integrity = { ...extraIntegrity };
152
155
  for (const dep of ESM_DEPENDENCIES) {
@@ -156,7 +159,7 @@ function importMapBlock(extraIntegrity = {}) {
156
159
  }
157
160
  const json = JSON.stringify({ imports, integrity }, null, 2);
158
161
  return `<!-- Import map: bare specifiers in Zazz scripts resolve to pinned, SRI-checked files -->
159
- <script type="importmap">
162
+ <script type="importmap"${nonceAttr(nonce)}>
160
163
  ${json}
161
164
  </script>`;
162
165
  }
@@ -173,14 +176,18 @@ function polyfillsBlock() {
173
176
  return `<!-- Polyfill: Interest Invokers (interestfor) — native in Chromium only -->
174
177
  <script type="module" src="${cdnUrl(interest)}" integrity="${interest.integrity}" crossorigin="anonymous"></script>`;
175
178
  }
179
+ /** ` nonce="…"` for an inline script under a strict `script-src`, or nothing. */
180
+ function nonceAttr(nonce) {
181
+ return nonce ? ` nonce="${nonce.replace(/"/g, "&quot;")}"` : "";
182
+ }
176
183
  /**
177
184
  * The theme-persistence script. Runs inline (no `defer`) while the parser is
178
185
  * still in `<head>`, so the `theme-*` switch lands on `<html>` before first paint. The
179
186
  * try/catch covers contexts where storage access throws (sandboxed iframes,
180
187
  * blocked site data).
181
188
  */
182
- const THEME_SCRIPT = `<!-- Theme: apply the persisted (or preferred) scheme before first paint -->
183
- <script>
189
+ const themeScript = (nonce) => `<!-- Theme: apply the persisted (or preferred) scheme before first paint -->
190
+ <script${nonceAttr(nonce)}>
184
191
  (() => {
185
192
  try {
186
193
  // A stored choice pins the scheme with the theme-dark / theme-light
@@ -209,7 +216,7 @@ const THEME_SCRIPT = `<!-- Theme: apply the persisted (or preferred) scheme befo
209
216
  * buildHead({ base: "/zazz/src", scripts: false, fontDisplay: "optional" });
210
217
  */
211
218
  export function buildHead(options = {}) {
212
- const { base = "./zazz", cdn, scripts = true, fontDisplay = "swap", theme = true } = options;
219
+ const { base = "./zazz", cdn, scripts = true, fontDisplay = "swap", theme = true, nonce, } = options;
213
220
  const parts = [
214
221
  `<meta charset="utf-8">`,
215
222
  `<meta name="viewport" content="width=device-width, initial-scale=1">`,
@@ -219,10 +226,10 @@ export function buildHead(options = {}) {
219
226
  if (fontDisplay !== false)
220
227
  parts.push(fontsBlock(fontDisplay));
221
228
  if (cdn) {
222
- parts.push(...cdnBlocks(cdn, scripts));
229
+ parts.push(...cdnBlocks(cdn, scripts, nonce));
223
230
  }
224
231
  else if (options.primitives) {
225
- parts.push(...granularBlocks(options.primitives, (path) => `${base}/${path}`, () => "", scripts));
232
+ parts.push(...granularBlocks(options.primitives, (path) => `${base}/${path}`, () => "", scripts, {}, nonce));
226
233
  }
227
234
  else {
228
235
  parts.push(`<!-- Zazz styles: one bundle (index.css @imports every layer in cascade order) -->`, `<link rel="stylesheet" href="${base}/index.css">`);
@@ -230,11 +237,11 @@ export function buildHead(options = {}) {
230
237
  parts.push(
231
238
  // The import map must precede EVERY module load — including the
232
239
  // modulepreload hint — or the browser rejects it and bare specifiers fail.
233
- importMapBlock(), `<link rel="modulepreload" href="${base}/index.js">`, polyfillsBlock(), `<!-- Zazz behavior: one ES module imports every component script in dependency order -->`, `<script type="module" src="${base}/index.js"></script>`);
240
+ importMapBlock({}, nonce), `<link rel="modulepreload" href="${base}/index.js">`, polyfillsBlock(), `<!-- Zazz behavior: one ES module imports every component script in dependency order -->`, `<script type="module" src="${base}/index.js"></script>`);
234
241
  }
235
242
  }
236
243
  if (theme)
237
- parts.push(THEME_SCRIPT);
244
+ parts.push(themeScript(nonce));
238
245
  return parts.join("\n");
239
246
  }
240
247
  // --- CDN mode ---
@@ -250,7 +257,7 @@ export function buildHead(options = {}) {
250
257
  * @returns The head fragments between the fonts block and the theme script.
251
258
  * @private
252
259
  */
253
- function cdnBlocks(cdn, scripts) {
260
+ function cdnBlocks(cdn, scripts, nonce) {
254
261
  const { version, primitives, sri } = cdn;
255
262
  if (!EXACT_VERSION.test(version)) {
256
263
  throw new Error(`CDN URLs must pin an exact version (got "${version}"); ` +
@@ -265,7 +272,7 @@ function cdnBlocks(cdn, scripts) {
265
272
  if (!primitives) {
266
273
  parts.push(`<!-- Zazz styles: the whole kit, one request -->`, `<link rel="stylesheet" href="${url("dist/zazz.css")}"${attrs("dist/zazz.css")}>`);
267
274
  if (scripts) {
268
- parts.push(importMapBlock(), `<link rel="modulepreload" href="${url("dist/zazz.js")}"${attrs("dist/zazz.js")}>`, polyfillsBlock(), `<!-- Zazz behavior: the whole kit, one module -->`, `<script type="module" src="${url("dist/zazz.js")}"${attrs("dist/zazz.js")}></script>`);
275
+ parts.push(importMapBlock({}, nonce), `<link rel="modulepreload" href="${url("dist/zazz.js")}"${attrs("dist/zazz.js")}>`, polyfillsBlock(), `<!-- Zazz behavior: the whole kit, one module -->`, `<script type="module" src="${url("dist/zazz.js")}"${attrs("dist/zazz.js")}></script>`);
269
276
  }
270
277
  return parts;
271
278
  }
@@ -279,7 +286,7 @@ function cdnBlocks(cdn, scripts) {
279
286
  transitive[url(`src/${path}`)] = hash;
280
287
  }
281
288
  }
282
- return granularBlocks(primitives, (path) => url(`src/${path}`), (path) => attrs(`src/${path}`), scripts, transitive);
289
+ return granularBlocks(primitives, (path) => url(`src/${path}`), (path) => attrs(`src/${path}`), scripts, transitive, nonce);
283
290
  }
284
291
  /**
285
292
  * @description The granular grain, local or CDN: base layers in cascade order,
@@ -293,7 +300,7 @@ function cdnBlocks(cdn, scripts) {
293
300
  * @returns The head fragments between the fonts block and the theme script.
294
301
  * @private
295
302
  */
296
- function granularBlocks(primitives, url, attrs, scripts, transitive = {}) {
303
+ function granularBlocks(primitives, url, attrs, scripts, transitive = {}, nonce) {
297
304
  const parts = [];
298
305
  const closure = resolveClosure(primitives);
299
306
  const css = [
@@ -317,7 +324,7 @@ function granularBlocks(primitives, url, attrs, scripts, transitive = {}) {
317
324
  }),
318
325
  ]),
319
326
  ];
320
- parts.push(importMapBlock(transitive), polyfillsBlock(), `<!-- Zazz behavior: side-effect modules by tag; the rest via module imports -->`, ...scriptFiles.map((path) => `<script type="module" src="${url(path)}"${attrs(path)}></script>`));
327
+ parts.push(importMapBlock(transitive, nonce), polyfillsBlock(), `<!-- Zazz behavior: side-effect modules by tag; the rest via module imports -->`, ...scriptFiles.map((path) => `<script type="module" src="${url(path)}"${attrs(path)}></script>`));
321
328
  }
322
329
  return parts;
323
330
  }