@perkyzz/emvb 0.3.0 → 0.4.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 (121) hide show
  1. package/README.md +4 -2
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/package.json +3 -1
  4. package/src/admin/access/role.ts +9 -3
  5. package/src/admin/api.ts +17 -7
  6. package/src/admin/content-api.ts +7 -51
  7. package/src/admin/content-item.ts +22 -0
  8. package/src/admin/design-api.ts +30 -0
  9. package/src/admin/editor/A11yCopilot.tsx +1 -1
  10. package/src/admin/editor/Editor.tsx +106 -332
  11. package/src/admin/editor/EditorOverlay.tsx +3 -1
  12. package/src/admin/editor/PerfMeter.tsx +1 -1
  13. package/src/admin/editor/ShortcutsDialog.tsx +4 -1
  14. package/src/admin/editor/Timeline.tsx +16 -3
  15. package/src/admin/editor/canvas/CanvasFrame.tsx +51 -368
  16. package/src/admin/editor/canvas/DeviceBar.tsx +4 -1
  17. package/src/admin/editor/canvas/SelectionOverlay.tsx +86 -46
  18. package/src/admin/editor/canvas/canvas-scale.ts +20 -0
  19. package/src/admin/editor/canvas/drop-line.ts +24 -0
  20. package/src/admin/editor/canvas/use-canvas-dnd.ts +207 -0
  21. package/src/admin/editor/canvas/use-canvas-session.ts +216 -0
  22. package/src/admin/editor/collection-previews.ts +28 -5
  23. package/src/admin/editor/editor-chrome.tsx +346 -0
  24. package/src/admin/editor/editor-commands.ts +360 -0
  25. package/src/admin/editor/element-chrome.ts +89 -0
  26. package/src/admin/editor/feature-css.ts +15 -15
  27. package/src/admin/editor/host.ts +33 -0
  28. package/src/admin/editor/icons/IconLibraryDialog.tsx +64 -218
  29. package/src/admin/editor/icons/library.ts +29 -19
  30. package/src/admin/editor/icons/use-icon-library.ts +315 -0
  31. package/src/admin/editor/palette-items.ts +36 -5
  32. package/src/admin/editor/palette.ts +3 -2
  33. package/src/admin/editor/panels/AddPanel.tsx +2 -67
  34. package/src/admin/editor/panels/ColorControl.tsx +2 -10
  35. package/src/admin/editor/panels/ElementPanel.tsx +40 -99
  36. package/src/admin/editor/panels/LayersPanel.tsx +34 -62
  37. package/src/admin/editor/panels/SettingsPanel.tsx +1 -0
  38. package/src/admin/editor/panels/SiteStylesDrawer.tsx +16 -10
  39. package/src/admin/editor/panels/VariableSection.tsx +1 -10
  40. package/src/admin/editor/panels/inline-error.tsx +11 -0
  41. package/src/admin/editor/panels/settings/AdvancedFields.tsx +87 -1
  42. package/src/admin/editor/panels/settings/AudienceEditor.tsx +73 -3
  43. package/src/admin/editor/panels/settings/DraftTextField.tsx +4 -0
  44. package/src/admin/editor/panels/settings/FormBindControl.tsx +8 -4
  45. package/src/admin/editor/panels/settings/ItemList.tsx +34 -1
  46. package/src/admin/editor/panels/settings/StyleRow.tsx +14 -2
  47. package/src/admin/editor/panels/settings/form-names.ts +7 -11
  48. package/src/admin/editor/panels/settings/length-units.ts +15 -4
  49. package/src/admin/editor/panels/settings/style-sections.ts +5 -1
  50. package/src/admin/editor/panels/style-target.ts +105 -0
  51. package/src/admin/editor/section-templates.ts +43 -21
  52. package/src/admin/editor/shortcuts.ts +4 -0
  53. package/src/admin/editor/store.ts +10 -1
  54. package/src/admin/editor/useClipboardActions.ts +1 -1
  55. package/src/admin/editor/useEditorCommands.ts +61 -13
  56. package/src/admin/editor/useEditorData.ts +7 -1
  57. package/src/admin/editor/useEditorShortcuts.ts +23 -15
  58. package/src/admin/editor/useNodeActions.ts +6 -1
  59. package/src/admin/forms-api.ts +17 -6
  60. package/src/admin/icon-uploads-api.ts +18 -0
  61. package/src/admin/theme-api.ts +5 -18
  62. package/src/astro/content-port.ts +24 -0
  63. package/src/astro/forms/EmVBFormsClient.astro +11 -0
  64. package/src/astro/forms/EmVBFormsRuntime.astro +6 -7
  65. package/src/astro/forms/client.ts +1 -0
  66. package/src/astro/forms-definitions.ts +24 -11
  67. package/src/astro/index.ts +1 -0
  68. package/src/astro/render-session.ts +85 -0
  69. package/src/astro/request-data.ts +20 -8
  70. package/src/astro/resolve-theme.ts +166 -76
  71. package/src/astro/resolve.ts +57 -16
  72. package/src/astro/theme-posts.ts +16 -5
  73. package/src/astro/visitor.ts +67 -5
  74. package/src/constants.ts +1 -1
  75. package/src/core/arrange.ts +63 -38
  76. package/src/core/audience/rules.ts +22 -2
  77. package/src/core/canvas-styles.ts +24 -0
  78. package/src/core/clipboard.ts +11 -32
  79. package/src/core/css/generate.ts +9 -0
  80. package/src/core/css/print.ts +12 -0
  81. package/src/core/css/scope.ts +3 -3
  82. package/src/core/css-keywords.ts +83 -0
  83. package/src/core/data/bindings.ts +4 -6
  84. package/src/core/design/classes.ts +13 -15
  85. package/src/core/design/diff.ts +55 -0
  86. package/src/core/design/merge.ts +127 -0
  87. package/src/core/design/variables.ts +25 -21
  88. package/src/core/elements/dynamic-elements.ts +30 -0
  89. package/src/core/elements/form-elements.ts +1 -0
  90. package/src/core/elements/index.ts +183 -7
  91. package/src/core/forms/binding.ts +4 -13
  92. package/src/core/index.ts +10 -0
  93. package/src/core/local-style.ts +27 -0
  94. package/src/core/migrate/index.ts +9 -4
  95. package/src/core/nesting.ts +4 -23
  96. package/src/core/perf/scripts.ts +9 -6
  97. package/src/core/record.ts +3 -0
  98. package/src/core/render/context.ts +2 -0
  99. package/src/core/render/dynamic-post.ts +1 -2
  100. package/src/core/render/form.ts +133 -10
  101. package/src/core/render/index.ts +155 -13
  102. package/src/core/render/vnode.ts +12 -2
  103. package/src/core/sanitize/css.ts +90 -77
  104. package/src/core/sanitize/svg.ts +8 -3
  105. package/src/core/sanitize/url.ts +10 -1
  106. package/src/core/schema/design.ts +5 -7
  107. package/src/core/schema/layout.ts +153 -181
  108. package/src/core/schema/style.ts +53 -63
  109. package/src/core/share/link.ts +68 -28
  110. package/src/core/tabs/presence.ts +7 -17
  111. package/src/core/theme/dynamic.ts +200 -39
  112. package/src/core/theme/float.ts +1 -1
  113. package/src/core/tree-ops.ts +57 -0
  114. package/src/index.ts +14 -2
  115. package/src/server/design-routes.ts +4 -1
  116. package/src/server/icon-routes.ts +68 -16
  117. package/src/server/plugin.ts +8 -2
  118. package/src/admin/editor/icons/sets/fontawesome.json +0 -1
  119. package/src/admin/editor/icons/sets/lucide.json +0 -1
  120. package/src/admin/editor/icons/sets/remix.json +0 -1
  121. package/src/admin/editor/icons/sets/tabler.json +0 -1
@@ -1,53 +1,46 @@
1
+ import {
2
+ ALIGN_ITEMS,
3
+ BACKGROUND_POSITIONS,
4
+ BACKGROUND_REPEATS,
5
+ BACKGROUND_SIZES,
6
+ BORDER_STYLES,
7
+ CURSORS,
8
+ FLEX_DIRECTIONS as FLEX_DIRECTION_VALUES,
9
+ FLEX_WRAPS as FLEX_WRAP_VALUES,
10
+ FONT_WEIGHTS,
11
+ HEX_COLOR,
12
+ JUSTIFY_CONTENT,
13
+ LENGTH_UNITS,
14
+ OBJECT_FITS,
15
+ OVERFLOWS,
16
+ POSITIONS,
17
+ TEXT_ALIGNS,
18
+ TEXT_DECORATIONS,
19
+ TEXT_TRANSFORMS,
20
+ TRANSITION_EASINGS as TRANSITION_EASING_VALUES,
21
+ } from "../css-keywords.ts";
1
22
  import { STYLE_STATES, type StyleStateName } from "../schema/state-names.ts";
2
23
  import type { StyleProps } from "../schema/style.ts";
3
24
  import { sanitizeMediaUrl } from "./media-url.ts";
4
25
  import { motionDeclarations, withMotion } from "./motion.ts";
26
+ import { isRecord } from "../record.ts";
5
27
 
6
- const HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
28
+ const setOf = (values: readonly string[]) => new Set<string>(values);
7
29
  const VAR_ID = /^[a-z0-9-]{1,40}$/;
8
- const UNITS = new Set(["px", "rem", "em", "%", "vw", "vh"]);
9
- const FLEX_DIRECTIONS = new Set(["row", "column", "row-reverse", "column-reverse"]);
10
- const FLEX_WRAPS = new Set(["nowrap", "wrap", "wrap-reverse"]);
11
- const JUSTIFY = new Set([
12
- "flex-start",
13
- "flex-end",
14
- "center",
15
- "space-between",
16
- "space-around",
17
- "space-evenly",
18
- ]);
19
- const ALIGN = new Set(["stretch", "flex-start", "flex-end", "center", "baseline"]);
20
- const TEXT_TRANSFORM = new Set(["none", "uppercase", "lowercase", "capitalize"]);
21
- const TEXT_DECORATION = new Set(["none", "underline", "overline", "line-through"]);
22
- const BORDER_STYLE = new Set(["none", "solid", "dashed", "dotted"]);
23
- const OVERFLOW = new Set(["visible", "hidden", "clip", "scroll", "auto"]);
24
- const OBJECT_FIT = new Set(["fill", "contain", "cover", "none", "scale-down"]);
25
- const POSITION = new Set(["static", "relative", "absolute", "fixed", "sticky"]);
26
- const CURSOR = new Set([
27
- "default",
28
- "pointer",
29
- "text",
30
- "move",
31
- "grab",
32
- "not-allowed",
33
- "help",
34
- "crosshair",
35
- "zoom-in",
36
- ]);
30
+ const UNITS = setOf(LENGTH_UNITS);
31
+ const FLEX_DIRECTIONS = setOf(FLEX_DIRECTION_VALUES);
32
+ const FLEX_WRAPS = setOf(FLEX_WRAP_VALUES);
33
+ const JUSTIFY = setOf(JUSTIFY_CONTENT);
34
+ const ALIGN = setOf(ALIGN_ITEMS);
35
+ const TEXT_TRANSFORM = setOf(TEXT_TRANSFORMS);
36
+ const TEXT_DECORATION = setOf(TEXT_DECORATIONS);
37
+ const BORDER_STYLE = setOf(BORDER_STYLES);
38
+ const OVERFLOW = setOf(OVERFLOWS);
39
+ const OBJECT_FIT = setOf(OBJECT_FITS);
40
+ const POSITION = setOf(POSITIONS);
41
+ const CURSOR = setOf(CURSORS);
37
42
  const ASPECT_RATIO = /^([1-9]\d{0,3})\/([1-9]\d{0,3})$/;
38
- const FONT_WEIGHT = new Set([
39
- "normal",
40
- "bold",
41
- "100",
42
- "200",
43
- "300",
44
- "400",
45
- "500",
46
- "600",
47
- "700",
48
- "800",
49
- "900",
50
- ]);
43
+ const FONT_WEIGHT = setOf(FONT_WEIGHTS);
51
44
  const FORBIDDEN = /[{};<>\\"'`]|\/\*|url\(|expression\(|@import|javascript:/i;
52
45
 
53
46
  /** Last line of defence on every emitted value, even ones built by the typed validators below. */
@@ -192,11 +185,13 @@ function cssEntrance(value: unknown): string | undefined {
192
185
  return `emvb-${type} ${duration}ms ease-out${wait} both`;
193
186
  }
194
187
 
188
+ const TEXT_ALIGN = setOf(TEXT_ALIGNS);
189
+
195
190
  function cssTextAlign(value: unknown): string | undefined {
191
+ if (typeof value !== "string" || !TEXT_ALIGN.has(value)) return undefined;
196
192
  if (value === "left") return "start";
197
193
  if (value === "right") return "end";
198
- if (value === "center" || value === "justify") return value;
199
- return undefined;
194
+ return value;
200
195
  }
201
196
 
202
197
  const cssGridSpan = (value: unknown): string | undefined =>
@@ -204,6 +199,28 @@ const cssGridSpan = (value: unknown): string | undefined =>
204
199
  ? `span ${value}`
205
200
  : undefined;
206
201
 
202
+ const cssGridStart = (value: unknown): number | undefined =>
203
+ Number.isInteger(value) && (value as number) >= 1 && (value as number) <= 13
204
+ ? (value as number)
205
+ : undefined;
206
+
207
+ /** `span N`, a line number, or `start / span N` when both are set. */
208
+ function gridPlacement(
209
+ start: unknown,
210
+ span: unknown,
211
+ ): { value?: string; badStart: boolean; badSpan: boolean } {
212
+ const badStart = start !== undefined && cssGridStart(start) === undefined;
213
+ const badSpan = span !== undefined && cssGridSpan(span) === undefined;
214
+ const line = cssGridStart(start);
215
+ const across = cssGridSpan(span);
216
+ if (line !== undefined && across !== undefined) {
217
+ return { value: `${line} / ${across}`, badStart, badSpan };
218
+ }
219
+ if (line !== undefined) return { value: String(line), badStart, badSpan };
220
+ if (across !== undefined) return { value: across, badStart, badSpan };
221
+ return { badStart, badSpan };
222
+ }
223
+
207
224
  const inRange = (value: unknown, min: number, max: number): value is number =>
208
225
  typeof value === "number" && Number.isFinite(value) && value >= min && value <= max;
209
226
 
@@ -283,7 +300,7 @@ function cssFontWeight(value: unknown): string | undefined {
283
300
  return undefined;
284
301
  }
285
302
 
286
- const TRANSITION_EASINGS = new Set(["ease", "ease-in", "ease-out", "ease-in-out", "linear"]);
303
+ const TRANSITION_EASINGS = setOf(TRANSITION_EASING_VALUES);
287
304
  const TRANSITION_PROPERTIES: Readonly<Record<string, readonly string[]>> = {
288
305
  all: ["all"],
289
306
  colors: ["color", "background-color", "border-color"],
@@ -371,19 +388,9 @@ function cssIconAnimation(value: unknown): string | undefined {
371
388
 
372
389
  export type Declaration = { property: string; value: string };
373
390
 
374
- const BACKGROUND_SIZE = new Set(["auto", "cover", "contain"]);
375
- const BACKGROUND_POSITION = new Set([
376
- "center",
377
- "top",
378
- "bottom",
379
- "left",
380
- "right",
381
- "top left",
382
- "top right",
383
- "bottom left",
384
- "bottom right",
385
- ]);
386
- const BACKGROUND_REPEAT = new Set(["no-repeat", "repeat", "repeat-x", "repeat-y"]);
391
+ const BACKGROUND_SIZE = setOf(BACKGROUND_SIZES);
392
+ const BACKGROUND_POSITION = setOf(BACKGROUND_POSITIONS);
393
+ const BACKGROUND_REPEAT = setOf(BACKGROUND_REPEATS);
387
394
  const BACKGROUND_KEYS = new Set([
388
395
  "backgroundImage",
389
396
  "backgroundSize",
@@ -399,9 +406,6 @@ function isSafeBackground(value: string): boolean {
399
406
  return value.length > 0 && value.length <= 4096 && !/[{};<>\\`]|\/\*|\n|\r/.test(value);
400
407
  }
401
408
 
402
- const isRecord = (value: unknown): value is Record<string, unknown> =>
403
- typeof value === "object" && value !== null && !Array.isArray(value);
404
-
405
409
  /** A media URL wrapped for CSS. The schema already refuses quotes, spaces and parentheses. */
406
410
  function cssBackgroundImage(value: unknown): string | undefined {
407
411
  if (typeof value !== "string") return undefined;
@@ -410,17 +414,7 @@ function cssBackgroundImage(value: unknown): string | undefined {
410
414
  return isSafeBackground(css) ? css : undefined;
411
415
  }
412
416
 
413
- const GRADIENT_POSITION = new Set([
414
- "center",
415
- "top",
416
- "bottom",
417
- "left",
418
- "right",
419
- "top left",
420
- "top right",
421
- "bottom left",
422
- "bottom right",
423
- ]);
417
+ const GRADIENT_POSITION = setOf(BACKGROUND_POSITIONS);
424
418
 
425
419
  function cssAngle(value: unknown, fallback: number): number | undefined {
426
420
  const angle = value === undefined ? fallback : value;
@@ -588,6 +582,9 @@ const PROPERTY_MAP: {
588
582
  gap: { css: "gap", toValue: cssLength },
589
583
  gridColumnSpan: { css: "grid-column", toValue: cssGridSpan },
590
584
  gridRowSpan: { css: "grid-row", toValue: cssGridSpan },
585
+ // Composed with the span in `styleDeclarations` (`start / span n`).
586
+ gridColumnStart: { css: "grid-column", toValue: () => undefined },
587
+ gridRowStart: { css: "grid-row", toValue: () => undefined },
591
588
  width: { css: "width", toValue: cssLengthOrAuto },
592
589
  minWidth: { css: "min-width", toValue: cssLength },
593
590
  maxWidth: { css: "max-width", toValue: cssLength },
@@ -601,10 +598,10 @@ const PROPERTY_MAP: {
601
598
  paddingRight: { css: "padding-inline-end", toValue: cssLength },
602
599
  paddingBottom: { css: "padding-bottom", toValue: cssLength },
603
600
  paddingLeft: { css: "padding-inline-start", toValue: cssLength },
604
- marginTop: { css: "margin-top", toValue: cssLengthOrAuto },
605
- marginRight: { css: "margin-inline-end", toValue: cssLengthOrAuto },
606
- marginBottom: { css: "margin-bottom", toValue: cssLengthOrAuto },
607
- marginLeft: { css: "margin-inline-start", toValue: cssLengthOrAuto },
601
+ marginTop: { css: "margin-top", toValue: cssOffset },
602
+ marginRight: { css: "margin-inline-end", toValue: cssOffset },
603
+ marginBottom: { css: "margin-bottom", toValue: cssOffset },
604
+ marginLeft: { css: "margin-inline-start", toValue: cssOffset },
608
605
  position: { css: "position", toValue: keyword(POSITION) },
609
606
  top: { css: "top", toValue: cssOffset },
610
607
  right: { css: "inset-inline-end", toValue: cssOffset },
@@ -683,6 +680,14 @@ export function styleDeclarations(style: unknown): {
683
680
  let motion: Declaration[] = [];
684
681
  for (const [key, raw] of shorthandsFirst(record)) {
685
682
  if (BACKGROUND_KEYS.has(key)) continue;
683
+ if (
684
+ key === "gridColumnSpan" ||
685
+ key === "gridRowSpan" ||
686
+ key === "gridColumnStart" ||
687
+ key === "gridRowStart"
688
+ ) {
689
+ continue;
690
+ }
686
691
  if (key === "scrollMotion") {
687
692
  const found = motionDeclarations(raw);
688
693
  if (found && found.every((d) => isSafeCssValue(d.value))) motion = found;
@@ -714,6 +719,14 @@ export function styleDeclarations(style: unknown): {
714
719
  const background = composeBackground(record);
715
720
  declarations.push(...background.declarations);
716
721
  rejected.push(...background.rejected);
722
+ const column = gridPlacement(record["gridColumnStart"], record["gridColumnSpan"]);
723
+ const row = gridPlacement(record["gridRowStart"], record["gridRowSpan"]);
724
+ if (column.value) declarations.push({ property: "grid-column", value: column.value });
725
+ if (row.value) declarations.push({ property: "grid-row", value: row.value });
726
+ if (column.badStart) rejected.push("gridColumnStart");
727
+ if (column.badSpan) rejected.push("gridColumnSpan");
728
+ if (row.badStart) rejected.push("gridRowStart");
729
+ if (row.badSpan) rejected.push("gridRowSpan");
717
730
  return { declarations: withMotion(declarations, motion), rejected };
718
731
  }
719
732
 
@@ -198,9 +198,14 @@ function isSafeHref(tag: string, name: string, value: string): boolean {
198
198
  const isHrefName = (name: string) => name === "href" || name === "xlink:href";
199
199
 
200
200
  function isSafeUrlRefAttr(name: string, value: string): boolean {
201
- if (name !== "clip-path" && name !== "mask") return true;
202
- if (value === "none") return true;
203
- return URL_HASH_REF.test(value);
201
+ if (name === "clip-path" || name === "mask") {
202
+ if (value === "none") return true;
203
+ return URL_HASH_REF.test(value);
204
+ }
205
+ // fill, stroke and the rest: `url(https://…)` is a request from the visitor's browser.
206
+ // A fragment (`url(#id)`) stays inside this SVG.
207
+ if (/url\s*\(/i.test(value)) return URL_HASH_REF.test(value);
208
+ return true;
204
209
  }
205
210
 
206
211
  type ParsedAttrs = { attrs: Record<string, string>; external: boolean };
@@ -16,16 +16,25 @@ export function sanitizeUrl(value: string, schemes: ReadonlySet<string>): string
16
16
  if (!hasScheme) {
17
17
  // Browsers resolve `//host` and `/\host` to another site; EmDash 1.0 refuses them for `url` fields too.
18
18
  if (/^\/[/\\]/.test(trimmed)) return undefined;
19
+ // A normal space can sit in a relative path. Any other whitespace, or a backslash, is how a
20
+ // second address hides in the same string.
21
+ if (/[^\S ]|\\/.test(trimmed)) return undefined;
19
22
  // Relative: /path, ./path, ../path, ?query, #hash, or bare path segment
20
23
  if (/^(?:[/?#.]|[A-Za-z0-9._~-])/.test(trimmed)) return trimmed;
21
24
  return undefined;
22
25
  }
23
26
 
27
+ // Parse the string we will return. Stripping whitespace first, then returning the original,
28
+ // accepted `https://site/a.png 1w, https://evil/x` because only the stripped copy was checked.
29
+ if (/[\s\\]/.test(trimmed)) return undefined;
30
+
24
31
  let parsed: URL;
25
32
  try {
26
- parsed = new URL(trimmed.replace(/\s+/g, ""));
33
+ parsed = new URL(trimmed);
27
34
  } catch {
28
35
  return undefined;
29
36
  }
37
+ // `user:pass@host` would publish the password in the page.
38
+ if (parsed.username || parsed.password) return undefined;
30
39
  return schemes.has(parsed.protocol.toLowerCase()) ? trimmed : undefined;
31
40
  }
@@ -1,11 +1,14 @@
1
1
  import { z } from "zod";
2
+ import { HEX_COLOR } from "../css-keywords.ts";
2
3
  import { DeviceStyles, HiddenOn, StyleProps, StyleStates } from "./style.ts";
3
4
 
4
5
  /**
6
+ * 15 since W-341, in step with layouts (optional fields only; the design document itself is unchanged).
7
+ * 14 since W-329, in step with layouts (optional fields only: `ch` lengths, negative margins).
5
8
  * 13 since W-307, in step with layouts (the W-307 batch only adds optional fields).
6
9
  * 12 since W-160: class gradients use the same stops as layouts. v11 `{ angle, from, to }` upgrades on read.
7
10
  */
8
- export const DESIGN_SCHEMA_VERSION = 13;
11
+ export const DESIGN_SCHEMA_VERSION = 15;
9
12
 
10
13
  /** Tags a site can give a starting style. Classes and local styles still win. */
11
14
  export const DEFAULT_STYLE_TAGS = ["h1", "h2", "h3", "h4", "h5", "h6", "p", "a", "button"] as const;
@@ -19,12 +22,7 @@ const VariableId = z
19
22
  export const ColorVariable = z.strictObject({
20
23
  id: VariableId,
21
24
  name: z.string().min(1).max(60),
22
- value: z
23
- .string()
24
- .regex(
25
- /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,
26
- "Use a hex color such as #1a2b3c",
27
- ),
25
+ value: z.string().regex(HEX_COLOR, "Use a hex color such as #1a2b3c"),
28
26
  });
29
27
 
30
28
  /** Font stack string — commas and quoted family names allowed; `generateCss` drops an unsafe one. */