@perkyzz/emvb 1.3.0 → 1.4.1

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 (161) hide show
  1. package/README.md +2 -2
  2. package/package.json +2 -2
  3. package/src/admin/bulk-api.ts +5 -1
  4. package/src/admin/content-item.ts +3 -0
  5. package/src/admin/copy-rich-text.ts +99 -9
  6. package/src/admin/editor/A11yCopilot.tsx +3 -1
  7. package/src/admin/editor/Editor.tsx +28 -3
  8. package/src/admin/editor/Timeline.tsx +1 -8
  9. package/src/admin/editor/canvas/DeviceBar.tsx +7 -2
  10. package/src/admin/editor/canvas/EmptyCanvas.tsx +11 -2
  11. package/src/admin/editor/canvas/use-canvas-dnd.ts +1 -20
  12. package/src/admin/editor/canvas/vnode-react.tsx +2 -0
  13. package/src/admin/editor/co-design.ts +36 -1
  14. package/src/admin/editor/collection-previews.ts +7 -8
  15. package/src/admin/editor/dnd/dragged-source.ts +22 -0
  16. package/src/admin/editor/dnd/layer-drop.ts +141 -0
  17. package/src/admin/editor/dnd/new-element.ts +16 -0
  18. package/src/admin/editor/editor-css.ts +9 -1
  19. package/src/admin/editor/element-chrome.ts +6 -0
  20. package/src/admin/editor/extensions/ExtensionPanels.tsx +33 -1
  21. package/src/admin/editor/extensions-context.tsx +16 -1
  22. package/src/admin/editor/feature-css.ts +27 -0
  23. package/src/admin/editor/inert-links.ts +8 -0
  24. package/src/admin/editor/panels/ColorControl.tsx +2 -2
  25. package/src/admin/editor/panels/ConditionsEditor.tsx +18 -0
  26. package/src/admin/editor/panels/ElementPanel.tsx +2 -2
  27. package/src/admin/editor/panels/FontFaces.tsx +342 -0
  28. package/src/admin/editor/panels/LayersPanel.tsx +56 -6
  29. package/src/admin/editor/panels/LeftPanel.tsx +153 -29
  30. package/src/admin/editor/panels/SettingsPanel.tsx +1 -0
  31. package/src/admin/editor/panels/SiteStylesDrawer.tsx +5 -0
  32. package/src/admin/editor/panels/TemplatesPanel.tsx +205 -0
  33. package/src/admin/editor/panels/TokenScales.tsx +2 -0
  34. package/src/admin/editor/panels/TriggersEditor.tsx +203 -9
  35. package/src/admin/editor/panels/VariableSection.tsx +111 -7
  36. package/src/admin/editor/panels/color-space.ts +71 -6
  37. package/src/admin/editor/panels/settings/AudienceEditor.tsx +3 -0
  38. package/src/admin/editor/panels/settings/FieldControl.tsx +33 -0
  39. package/src/admin/editor/panels/settings/FormBindControl.tsx +27 -31
  40. package/src/admin/editor/panels/settings/ImageFieldControl.tsx +106 -0
  41. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +9 -3
  42. package/src/admin/editor/panels/settings/StickyControl.tsx +97 -0
  43. package/src/admin/editor/panels/settings/StyleRow.tsx +14 -0
  44. package/src/admin/editor/panels/settings/loop-context.ts +34 -3
  45. package/src/admin/editor/panels/settings/style-sections.ts +19 -2
  46. package/src/admin/editor/panels/url-rules.ts +43 -0
  47. package/src/admin/editor/panels/use-layers-drop.ts +232 -0
  48. package/src/admin/editor/store.ts +4 -2
  49. package/src/admin/editor/useExtensions.ts +3 -1
  50. package/src/admin/editor/useNodeActions.ts +74 -1
  51. package/src/admin/editor/useSave.ts +116 -85
  52. package/src/admin/export-api.ts +27 -2
  53. package/src/admin/extension-outputs.ts +236 -0
  54. package/src/admin/font-files-api.ts +38 -0
  55. package/src/admin/import-forms.ts +133 -0
  56. package/src/admin/pages/ImportButton.tsx +15 -4
  57. package/src/admin/pages/ImportElementorDialog.tsx +53 -187
  58. package/src/admin/pages/ImportForms.tsx +71 -0
  59. package/src/admin/pages/ImportHtmlDialog.tsx +209 -0
  60. package/src/admin/pages/ImportImageCopies.tsx +167 -0
  61. package/src/admin/pages/ImportReport.tsx +63 -0
  62. package/src/admin/pages/NewPageDialog.tsx +54 -32
  63. package/src/admin/pages/PageList.tsx +9 -0
  64. package/src/admin/pages/ThemePartList.tsx +9 -0
  65. package/src/admin/setup/plan.ts +2 -0
  66. package/src/admin/ui.ts +7 -0
  67. package/src/admin/widgets/ConvertToRichText.tsx +3 -2
  68. package/src/astro/EmVBPage.astro +5 -2
  69. package/src/astro/extension-styles.ts +35 -0
  70. package/src/astro/forms/EmVBFormsClient.astro +3 -0
  71. package/src/astro/forms/enhance.ts +107 -0
  72. package/src/astro/popups/runtime.ts +47 -2
  73. package/src/astro/render.ts +25 -4
  74. package/src/astro/resolve-theme.ts +11 -4
  75. package/src/astro/resolve.ts +2 -0
  76. package/src/astro/theme-posts.ts +17 -23
  77. package/src/astro/visitor.ts +14 -5
  78. package/src/astro/widgets/EmVBStickyRuntime.astro +9 -0
  79. package/src/astro/widgets/EmVBThemeRuntime.astro +9 -0
  80. package/src/astro/widgets/EmVBWidgetRuntimes.astro +12 -0
  81. package/src/astro/widgets/alerts.ts +16 -2
  82. package/src/astro/widgets/carousel.ts +65 -24
  83. package/src/astro/widgets/countdown.ts +18 -7
  84. package/src/astro/widgets/extension-runtimes.ts +27 -0
  85. package/src/astro/widgets/headline.ts +14 -5
  86. package/src/astro/widgets/sticky.ts +87 -0
  87. package/src/astro/widgets/theme.ts +52 -0
  88. package/src/constants.ts +1 -1
  89. package/src/core/a11y/audit.ts +150 -2
  90. package/src/core/arrange.ts +19 -1
  91. package/src/core/css/font-face.ts +72 -0
  92. package/src/core/css/generate.ts +41 -2
  93. package/src/core/css/trace.ts +8 -0
  94. package/src/core/data/bindings.ts +7 -4
  95. package/src/core/elements/dynamic-elements.ts +1 -1
  96. package/src/core/elements/element-nouns.ts +48 -0
  97. package/src/core/elements/form-elements.ts +119 -9
  98. package/src/core/elements/icon-svg.ts +14 -0
  99. package/src/core/elements/index.ts +24 -4
  100. package/src/core/elements/input-limits.ts +44 -0
  101. package/src/core/elements/menu.ts +109 -47
  102. package/src/core/elements/site.ts +108 -0
  103. package/src/core/elements/widgets.ts +13 -3
  104. package/src/core/export/runtimes.generated.ts +7 -5
  105. package/src/core/export/site.ts +53 -4
  106. package/src/core/extensions/classes.ts +114 -0
  107. package/src/core/extensions/index.ts +19 -2
  108. package/src/core/extensions/normalize.ts +13 -0
  109. package/src/core/extensions/placeholder.ts +7 -2
  110. package/src/core/extensions/registry.ts +134 -10
  111. package/src/core/extensions/render-ext.ts +115 -36
  112. package/src/core/extensions/safe-nodes.ts +67 -11
  113. package/src/core/extensions/types.ts +48 -1
  114. package/src/core/fonts/files.ts +74 -0
  115. package/src/core/fonts/google.ts +112 -0
  116. package/src/core/fonts/test-font.ts +9 -0
  117. package/src/core/import/elementor/context.ts +42 -4
  118. package/src/core/import/elementor/index.ts +55 -23
  119. package/src/core/import/elementor/widgets.ts +242 -20
  120. package/src/core/import/html/blocks.ts +602 -0
  121. package/src/core/import/html/index.ts +155 -0
  122. package/src/core/import/html/map.ts +958 -0
  123. package/src/core/import/html/parse.ts +430 -0
  124. package/src/core/index.ts +54 -0
  125. package/src/core/migrate/v18.ts +3 -0
  126. package/src/core/public-attributes.ts +17 -0
  127. package/src/core/render/extras.ts +31 -7
  128. package/src/core/render/form.ts +103 -10
  129. package/src/core/render/index.ts +165 -16
  130. package/src/core/render/section.ts +31 -1
  131. package/src/core/render/spacer-basis.ts +102 -0
  132. package/src/core/render/theme-boot.ts +16 -0
  133. package/src/core/render/vnode.ts +1 -1
  134. package/src/core/sanitize/css.ts +68 -3
  135. package/src/core/sanitize/motion.ts +12 -0
  136. package/src/core/schema/design.ts +40 -0
  137. package/src/core/schema/layout.ts +118 -6
  138. package/src/core/schema/style.ts +28 -0
  139. package/src/core/templates/index.ts +218 -0
  140. package/src/core/templates/pages.ts +29 -0
  141. package/src/core/templates/sections.ts +794 -0
  142. package/src/core/templates/types.ts +9 -0
  143. package/src/core/theme/dynamic.ts +9 -6
  144. package/src/core/theme/media-value.ts +88 -0
  145. package/src/core/theme/popup-markup.ts +21 -2
  146. package/src/core/theme/popup-rules.ts +36 -0
  147. package/src/core/theme/triggers.ts +64 -5
  148. package/src/core/translatable.ts +5 -2
  149. package/src/core/visitor-cookie.ts +91 -0
  150. package/src/extension-build.ts +331 -0
  151. package/src/index.ts +53 -4
  152. package/src/mcp/agent-defaults.ts +40 -0
  153. package/src/mcp/brief.ts +191 -0
  154. package/src/mcp/extensions.ts +138 -0
  155. package/src/mcp/prompts.ts +33 -0
  156. package/src/mcp/read.ts +84 -20
  157. package/src/mcp/tools.ts +42 -3
  158. package/src/mcp/write.ts +124 -9
  159. package/src/server/extension-routes.ts +110 -0
  160. package/src/server/font-routes.ts +301 -0
  161. package/src/server/plugin.ts +15 -0
@@ -78,7 +78,7 @@ const TAGS = new Set([
78
78
  const VOID = new Set(["hr", "img", "input", "br"]);
79
79
  // iframe/video are not void — they need closing tags.
80
80
  const ATTR_NAME =
81
- /^(?:class|id|href|src|srcset|sizes|alt|width|height|loading|decoding|fetchpriority|dir|lang|hreflang|role|type|checked|target|rel|aria-[a-z][a-z0-9-]*|title|allow|referrerpolicy|preload|controls|allowfullscreen|sandbox|xmlns|viewBox|fill|stroke|stroke-width|stroke-linecap|stroke-linejoin|stroke-dasharray|stroke-opacity|fill-opacity|opacity|transform|focusable|d|cx|cy|r|x|y|x1|y1|x2|y2|points|rx|ry|xlink:href|preserveAspectRatio|gradientUnits|gradientTransform|offset|stop-color|stop-opacity|clipPathUnits|maskUnits|maskContentUnits|patternUnits|patternContentUnits|patternTransform|markerUnits|markerWidth|markerHeight|refX|refY|orient|font-size|font-family|font-weight|text-anchor|dominant-baseline|dx|dy|clip-path|mask|method|action|name|value|placeholder|for|tabindex|autocomplete|open|popover|popovertarget|popovertargetaction|datetime|muted|loop|playsinline|autoplay|required|novalidate|minlength|maxlength|min|max|pattern|step|start|data-[a-z][a-z0-9-]*)$/;
81
+ /^(?:class|id|href|src|srcset|sizes|alt|width|height|loading|decoding|fetchpriority|dir|lang|hreflang|role|type|checked|target|rel|aria-[a-z][a-z0-9-]*|title|allow|referrerpolicy|preload|controls|allowfullscreen|sandbox|xmlns|viewBox|fill|stroke|stroke-width|stroke-linecap|stroke-linejoin|stroke-dasharray|stroke-opacity|fill-opacity|opacity|transform|focusable|d|cx|cy|r|x|y|x1|y1|x2|y2|points|rx|ry|xlink:href|preserveAspectRatio|gradientUnits|gradientTransform|offset|stop-color|stop-opacity|clipPathUnits|maskUnits|maskContentUnits|patternUnits|patternContentUnits|patternTransform|markerUnits|markerWidth|markerHeight|refX|refY|orient|font-size|font-family|font-weight|text-anchor|dominant-baseline|dx|dy|clip-path|mask|method|action|name|value|placeholder|for|tabindex|autocomplete|open|popover|popovertarget|popovertargetaction|datetime|muted|loop|playsinline|autoplay|required|novalidate|hidden|minlength|maxlength|min|max|pattern|step|start|data-[a-z][a-z0-9-]*)$/;
82
82
 
83
83
  export const isAllowedTag = (tag: string) => TAGS.has(tag);
84
84
  export const isAllowedAttr = (name: string) => ATTR_NAME.test(name);
@@ -733,6 +733,8 @@ const PROPERTY_MAP: {
733
733
  scrollMotion: { css: "animation", toValue: () => undefined },
734
734
  // W-938: written by `loopDeclarations` in `styleDeclarations`; this entry only names it.
735
735
  loopMotion: { css: "animation", toValue: () => undefined },
736
+ // W-1070: written by `stickyDeclarations` in `styleDeclarations`; this entry only names it.
737
+ stickyMotion: { css: "animation", toValue: () => undefined },
736
738
  iconRotate: { css: "--emvb-icon-rotate", toValue: cssIconRotate },
737
739
  iconFlip: { css: "--emvb-icon-flip", toValue: cssIconFlip },
738
740
  iconScale: { css: "scale", toValue: cssIconScale },
@@ -811,6 +813,46 @@ function withViewportUnits(declarations: Declaration[], units: unknown): void {
811
813
  }
812
814
  }
813
815
 
816
+ /**
817
+ * Declarations for a `stickyMotion` value (W-1070): one page-scroll animation per effect over
818
+ * 0 to `distance` px, and the values the keyframes read. Undefined for a bad value; `{ type:
819
+ * "none" }` is `animation: none`. `hide` writes no CSS here: the element gets an attribute.
820
+ */
821
+ function stickyDeclarations(value: unknown): Declaration[] | undefined {
822
+ if (typeof value !== "object" || value === null) return undefined;
823
+ const record = value as Record<string, unknown>;
824
+ if (record["type"] === "none" && Object.keys(record).length === 1) {
825
+ return [{ property: "animation", value: "none" }];
826
+ }
827
+ const allowed = new Set(["distance", "background", "shadow", "padding", "hide"]);
828
+ if (Object.keys(record).some((key) => !allowed.has(key))) return undefined;
829
+ const { distance, background, shadow, padding, hide } = record;
830
+ if (
831
+ distance !== undefined &&
832
+ (!Number.isInteger(distance) || (distance as number) < 10 || (distance as number) > 2000)
833
+ )
834
+ return undefined;
835
+ if (shadow !== undefined && typeof shadow !== "boolean") return undefined;
836
+ if (hide !== undefined && typeof hide !== "boolean") return undefined;
837
+ const color = background === undefined ? undefined : cssColor(background);
838
+ const pad = padding === undefined ? undefined : cssLength(padding);
839
+ if ((background !== undefined && !color) || (padding !== undefined && !pad)) return undefined;
840
+ const names = [
841
+ ...(color ? ["emvb-sticky-bg"] : []),
842
+ ...(shadow ? ["emvb-sticky-shadow"] : []),
843
+ ...(pad ? ["emvb-sticky-pad"] : []),
844
+ ];
845
+ if (names.length === 0) return hide ? [] : undefined;
846
+ const range = `0px ${(distance as number | undefined) ?? 120}px`;
847
+ return [
848
+ { property: "animation", value: names.map((n) => `${n} linear both`).join(", ") },
849
+ { property: "animation-timeline", value: names.map(() => "scroll(root)").join(", ") },
850
+ { property: "animation-range", value: names.map(() => range).join(", ") },
851
+ ...(color ? [{ property: "--emvb-sticky-bg", value: color }] : []),
852
+ ...(pad ? [{ property: "--emvb-sticky-pad", value: pad }] : []),
853
+ ];
854
+ }
855
+
814
856
  export function styleDeclarations(style: unknown): {
815
857
  declarations: Declaration[];
816
858
  rejected: string[];
@@ -821,6 +863,7 @@ export function styleDeclarations(style: unknown): {
821
863
  const record = style as Record<string, unknown>;
822
864
  let motion: Declaration[] = [];
823
865
  let loop: Declaration[] = [];
866
+ let sticky: Declaration[] = [];
824
867
  for (const [key, raw] of shorthandsFirst(record)) {
825
868
  if (BACKGROUND_KEYS.has(key)) continue;
826
869
  if (
@@ -838,6 +881,19 @@ export function styleDeclarations(style: unknown): {
838
881
  else rejected.push(key);
839
882
  continue;
840
883
  }
884
+ if (key === "stickyMotion") {
885
+ const found = stickyDeclarations(raw);
886
+ if (found && found.every((d) => isSafeCssValue(d.value))) {
887
+ sticky = found;
888
+ // W-1070: whether "Hide while scrolling down" is on at this width, for the sticky script.
889
+ // Unset keeps a wider device's choice; `{ type: "none" }` turns it off.
890
+ const { hide, type } = raw as { hide?: unknown; type?: unknown };
891
+ if (typeof hide === "boolean" || type === "none") {
892
+ declarations.push({ property: "--emvb-sticky-hide", value: hide === true ? "1" : "0" });
893
+ }
894
+ } else rejected.push(key);
895
+ continue;
896
+ }
841
897
  if (key === "transform") {
842
898
  const found = transformDeclarations(raw);
843
899
  if (found) declarations.push(...found);
@@ -888,11 +944,19 @@ export function styleDeclarations(style: unknown): {
888
944
  if (column.badSpan) rejected.push("gridColumnSpan");
889
945
  if (row.badStart) rejected.push("gridRowStart");
890
946
  if (row.badSpan) rejected.push("gridRowSpan");
891
- return { declarations: withLoop(withMotion(declarations, motion), loop), rejected };
947
+ // W-1070: sticky effects join the same animation list, last (withLoop appends any animation).
948
+ const animated = withLoop(withLoop(withMotion(declarations, motion), loop), sticky);
949
+ return { declarations: animated, rejected };
892
950
  }
893
951
 
894
952
  /** Normal only (W-089, W-237): a state's `transition` and `iconAnimation` are dropped and reported. */
895
- const NORMAL_ONLY = ["transition", "iconAnimation", "scrollMotion", "loopMotion"] as const;
953
+ const NORMAL_ONLY = [
954
+ "transition",
955
+ "iconAnimation",
956
+ "scrollMotion",
957
+ "loopMotion",
958
+ "stickyMotion",
959
+ ] as const;
896
960
  const withoutTransition = (style: unknown): unknown => {
897
961
  if (typeof style !== "object" || style === null) return style;
898
962
  if (!NORMAL_ONLY.some((key) => key in style)) return style;
@@ -901,6 +965,7 @@ const withoutTransition = (style: unknown): unknown => {
901
965
  iconAnimation: _loop,
902
966
  scrollMotion: _scroll,
903
967
  loopMotion: _loopMotion,
968
+ stickyMotion: _sticky,
904
969
  ...rest
905
970
  } = style as Record<string, unknown>;
906
971
  return rest;
@@ -951,7 +1016,7 @@ const BACKGROUND_LAYER_KEYS = [
951
1016
  * gradient) are filled in from `inherited` here. Otherwise they vanish on that device.
952
1017
  */
953
1018
  /** Both write `animation` (W-319), so one set alone would drop the other it inherits. */
954
- const ANIMATION_KEYS = ["entrance", "scrollMotion", "loopMotion"] as const;
1019
+ const ANIMATION_KEYS = ["entrance", "scrollMotion", "loopMotion", "stickyMotion"] as const;
955
1020
 
956
1021
  /**
957
1022
  * A style that sets an entrance or scroll motion keeps the other one it inherits from a wider
@@ -243,3 +243,15 @@ export function withLoop(declarations: Declaration[], loop: Declaration[]): Decl
243
243
  ...vars,
244
244
  ];
245
245
  }
246
+
247
+ /**
248
+ * W-1070: keyframes for a sticky element's look once the page has scrolled: they exist only
249
+ * where scroll-driven animations do; padding also waits for no reduced-motion preference.
250
+ */
251
+ export const STICKY_KEYFRAMES =
252
+ "@supports (animation-timeline: scroll()){@keyframes emvb-sticky-bg{to{background-color:var(--emvb-sticky-bg)}}@keyframes emvb-sticky-shadow{to{box-shadow:0 2px 12px rgb(0 0 0 / 15%)}}}" +
253
+ "@media (prefers-reduced-motion: no-preference){@supports (animation-timeline: scroll()){@keyframes emvb-sticky-pad{to{padding-top:var(--emvb-sticky-pad);padding-bottom:var(--emvb-sticky-pad)}}}}";
254
+
255
+ /** W-1070: whether declarations play a sticky effect, so the page sends STICKY_KEYFRAMES. */
256
+ export const usesSticky = (declarations: readonly Declaration[]) =>
257
+ declarations.some((d) => d.property === "animation" && d.value.includes("emvb-sticky-"));
@@ -25,6 +25,37 @@ export const ColorVariable = z.strictObject({
25
25
  id: VariableId,
26
26
  name: z.string().min(1).max(60),
27
27
  value: z.string().regex(HEX_COLOR, "Use a hex color such as #1a2b3c"),
28
+ /**
29
+ * W-1067: the colour in dark mode: when the visitor's system prefers dark, unless a Theme
30
+ * toggle chose light; and whenever it chose dark. Unset keeps `value`.
31
+ */
32
+ dark: z.string().regex(HEX_COLOR, "Use a hex color such as #1a2b3c").optional(),
33
+ });
34
+
35
+ /**
36
+ * W-1072: a family name a custom font is declared under. The same characters as a quoted name in
37
+ * a font stack (letters, digits, spaces, `_`, `.`, `-`), so it can never close a CSS string.
38
+ */
39
+ export const FONT_FAMILY_NAME = /^[\p{L}\p{N}](?:[\p{L}\p{N} _.-]{0,58}[\p{L}\p{N}_.-])?$/u;
40
+
41
+ /** W-1072: one `unicode-range` list, such as `U+0000-00FF, U+0131`. */
42
+ export const UNICODE_RANGE =
43
+ /^U\+[0-9A-Fa-f?]{1,6}(?:-[0-9A-Fa-f]{1,6})?(?:, ?U\+[0-9A-Fa-f?]{1,6}(?:-[0-9A-Fa-f]{1,6})?)*$/;
44
+
45
+ /**
46
+ * W-1072: one file of a custom font (a WOFF2), emitted as an `@font-face` rule when a page uses
47
+ * the variable. `src` is a path on the site (EmVB's font route for uploads and Google fonts), so a
48
+ * page never asks another host for a font.
49
+ */
50
+ const FontFace = z.strictObject({
51
+ weight: z.number().int().min(1).max(1000),
52
+ style: z.enum(["normal", "italic"]),
53
+ src: z
54
+ .string()
55
+ .min(1)
56
+ .max(500)
57
+ .regex(/^\/(?!\/)/, "Use a font file on this site (a path starting with /)"),
58
+ unicodeRange: z.string().max(1000).regex(UNICODE_RANGE, "Use a unicode-range list").optional(),
28
59
  });
29
60
 
30
61
  /** Font stack string — commas and quoted family names allowed; `generateCss` drops an unsafe one. */
@@ -32,6 +63,14 @@ export const FontVariable = z.strictObject({
32
63
  id: VariableId,
33
64
  name: z.string().min(1).max(60),
34
65
  value: z.string().min(1).max(200),
66
+ /**
67
+ * W-1072: the family the custom `faces` are declared under; `value` names it first. Both or
68
+ * neither: faces without a family are not emitted.
69
+ */
70
+ family: z.string().regex(FONT_FAMILY_NAME, "Use letters, digits, spaces, _ . or -").optional(),
71
+ faces: boundedArray(FontFace, 60).optional(),
72
+ /** W-1072: where the faces came from, for the editor. Unset: uploaded files. */
73
+ source: z.enum(["upload", "google"]).optional(),
35
74
  });
36
75
 
37
76
  /**
@@ -106,6 +145,7 @@ export const DesignSystem = z.strictObject({
106
145
 
107
146
  export type ColorVariable = z.infer<typeof ColorVariable>;
108
147
  export type FontVariable = z.infer<typeof FontVariable>;
148
+ export type FontFace = z.infer<typeof FontFace>;
109
149
  export type LengthVariable = z.infer<typeof LengthVariable>;
110
150
  export type DesignSystem = z.infer<typeof DesignSystem>;
111
151
 
@@ -492,6 +492,14 @@ export const MenuItemNode = parentNode(
492
492
  newTab: z.boolean().optional(),
493
493
  /** The panel stretches across the menu instead of sitting under the item. */
494
494
  wide: z.boolean().optional(),
495
+ /**
496
+ * W-1069: a mega menu. The published Section theme part whose layout fills this item's
497
+ * dropdown panel, in place of its children. A missing part leaves the item's own children
498
+ * (none: a plain link).
499
+ */
500
+ panelPartId: z.string().max(128).optional(),
501
+ /** W-1069: the mega panel's width (the most it takes when `wide`). Unset: its content's. */
502
+ panelWidth: Length.optional(),
495
503
  }),
496
504
  );
497
505
 
@@ -529,6 +537,21 @@ export const FormNode = parentNode(
529
537
  z.strictObject({
530
538
  /** Empty until the editor binds a forms-plugin form (W-036). */
531
539
  formId: z.string().max(64),
540
+ /** W-1065: the Next and Previous buttons of a form with steps. Unset: "Next", "Previous". */
541
+ nextLabel: z.string().max(80).optional(),
542
+ prevLabel: z.string().max(80).optional(),
543
+ }),
544
+ );
545
+
546
+ /**
547
+ * W-1065: one step of a form, placed directly inside it. With the forms script the visitor sees
548
+ * one step at a time; without it every step shows, as one long form. All steps send together.
549
+ */
550
+ export const FormStepNode = parentNode(
551
+ "form-step",
552
+ z.strictObject({
553
+ /** The step's legend, read out when it opens. Unset: "Step 2". */
554
+ title: z.string().max(200).optional(),
532
555
  }),
533
556
  );
534
557
 
@@ -538,7 +561,36 @@ const InputFieldProps = z.strictObject({
538
561
  placeholder: z.string().max(200).optional(),
539
562
  });
540
563
 
541
- export const TextInputNode = leafNode("text-input", InputFieldProps);
564
+ /** W-1065: the most a number input's limits and step may be, either way. */
565
+ export const MAX_INPUT_NUMBER = 1e12;
566
+ const InputNumber = z.number().min(-MAX_INPUT_NUMBER).max(MAX_INPUT_NUMBER);
567
+ /** A calendar date as date inputs take it: YYYY-MM-DD, a real day of years 1000 to 9999. */
568
+ const InputDate = z
569
+ .string()
570
+ .regex(/^[1-9]\d{3}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/, "Dates are YYYY-MM-DD")
571
+ .refine((value) => {
572
+ const [y, m, d] = value.split("-").map(Number) as [number, number, number];
573
+ const day = new Date(Date.UTC(y, m - 1, d));
574
+ return day.getUTCMonth() === m - 1 && day.getUTCDate() === d;
575
+ }, "That day doesn't exist");
576
+
577
+ /** W-1065: input kinds a Text input may ask for when its form field is plain text. */
578
+ export const TEXT_INPUT_TYPES = ["number", "date"] as const;
579
+
580
+ export const TextInputNode = leafNode(
581
+ "text-input",
582
+ InputFieldProps.extend({
583
+ /** W-1065: a number or date box; the form field's own type (email, number, date) wins. */
584
+ inputType: z.enum(TEXT_INPUT_TYPES).optional(),
585
+ /** Lowest and highest number, and the step between allowed numbers (unset: any). */
586
+ min: InputNumber.optional(),
587
+ max: InputNumber.optional(),
588
+ step: z.number().positive().max(MAX_INPUT_NUMBER).optional(),
589
+ /** Earliest and latest date (YYYY-MM-DD). */
590
+ minDate: InputDate.optional(),
591
+ maxDate: InputDate.optional(),
592
+ }),
593
+ );
542
594
 
543
595
  export const TextareaNode = leafNode("textarea", InputFieldProps);
544
596
 
@@ -659,7 +711,10 @@ export const LoopNode = parentNode(
659
711
  .max(200)
660
712
  .regex(LOOP_PERMALINK, "A site path with {slug} or {id}, such as /team/{slug}")
661
713
  .optional(),
662
- /** The entry field holding the image Post Image shows (W-330). Unset = featured_image. */
714
+ /**
715
+ * The entry field holding the image Post Image shows (W-330). Unset = featured_image, else the
716
+ * entry's first image field (W-1090).
717
+ */
663
718
  imageField: z.string().regex(FIELD_SLUG, FIELD_SLUG_HINT).optional(),
664
719
  /** The entry field Post Excerpt shows (W-330). Unset = excerpt. */
665
720
  excerptField: z.string().regex(FIELD_SLUG, FIELD_SLUG_HINT).optional(),
@@ -796,6 +851,9 @@ export const KNOWN_ELEMENT_TYPES = [
796
851
  "share-link",
797
852
  "hotspots",
798
853
  "hotspot",
854
+ "search-form",
855
+ "theme-toggle",
856
+ "form-step",
799
857
  ] as const;
800
858
 
801
859
  /** Headings on this page, as a list of links. No script (W-345). */
@@ -1388,6 +1446,33 @@ export const HotspotNode = leafNode(
1388
1446
  }),
1389
1447
  );
1390
1448
 
1449
+ /**
1450
+ * W-1073: a site search box: a plain GET form to `action` (unset "/search", the page EmDash's
1451
+ * own Search widget and site templates use) with the words in `q`. No script. `label` names the
1452
+ * field and the search landmark for screen readers (unset "Search"); `buttonText` unset "Search".
1453
+ */
1454
+ export const SearchFormNode = leafNode(
1455
+ "search-form",
1456
+ z.strictObject({
1457
+ action: z.string().max(500).optional(),
1458
+ label: z.string().max(80).optional(),
1459
+ placeholder: z.string().max(120).optional(),
1460
+ buttonText: z.string().max(40).optional(),
1461
+ }),
1462
+ );
1463
+
1464
+ /**
1465
+ * W-1067: a button that switches the site between light and dark (colour variables' dark
1466
+ * values), remembered on the visitor's browser. It needs the opt-in theme runtime, so without it
1467
+ * the button stays hidden. `label` is its text (unset "Dark mode"); it is a toggle (aria-pressed).
1468
+ */
1469
+ export const ThemeToggleNode = leafNode(
1470
+ "theme-toggle",
1471
+ z.strictObject({
1472
+ label: z.string().max(40).optional(),
1473
+ }),
1474
+ );
1475
+
1391
1476
  const knownTypeSet = new Set<string>(KNOWN_ELEMENT_TYPES);
1392
1477
 
1393
1478
  /**
@@ -1441,6 +1526,8 @@ const KnownLayoutNode = z.discriminatedUnion("type", [
1441
1526
  ShareLinkNode,
1442
1527
  HotspotsNodeSchema,
1443
1528
  HotspotNode,
1529
+ SearchFormNode,
1530
+ ThemeToggleNode,
1444
1531
  CounterNode,
1445
1532
  ProgressNode,
1446
1533
  CountdownNode,
@@ -1457,6 +1544,7 @@ const KnownLayoutNode = z.discriminatedUnion("type", [
1457
1544
  IconNode,
1458
1545
  VideoNode,
1459
1546
  FormNode,
1547
+ FormStepNode,
1460
1548
  TextInputNode,
1461
1549
  TextareaNode,
1462
1550
  SelectNode,
@@ -1499,6 +1587,8 @@ export type FlipBoxNode = z.infer<typeof FlipBoxNode>;
1499
1587
  export type HeadlineNode = z.infer<typeof HeadlineNode>;
1500
1588
  export type ShareLinkNode = z.infer<typeof ShareLinkNode>;
1501
1589
  export type HotspotNode = z.infer<typeof HotspotNode>;
1590
+ export type SearchFormNode = z.infer<typeof SearchFormNode>;
1591
+ export type ThemeToggleNode = z.infer<typeof ThemeToggleNode>;
1502
1592
  export type IconBoxNode = z.infer<typeof IconBoxNode>;
1503
1593
  export type ImageBoxNode = z.infer<typeof ImageBoxNode>;
1504
1594
  export type TestimonialNode = z.infer<typeof TestimonialNode>;
@@ -1633,7 +1723,13 @@ export type TabsNode = NodeEnvelope & {
1633
1723
 
1634
1724
  export type FormNode = NodeEnvelope & {
1635
1725
  type: "form";
1636
- props: { formId: string };
1726
+ props: { formId: string; nextLabel?: string; prevLabel?: string };
1727
+ children: LayoutNode[];
1728
+ };
1729
+
1730
+ export type FormStepNode = NodeEnvelope & {
1731
+ type: "form-step";
1732
+ props: { title?: string };
1637
1733
  children: LayoutNode[];
1638
1734
  };
1639
1735
 
@@ -1719,7 +1815,14 @@ export type MenuNode = NodeEnvelope & {
1719
1815
 
1720
1816
  export type MenuItemNode = NodeEnvelope & {
1721
1817
  type: "menu-item";
1722
- props: { text: string; href?: string; newTab?: boolean; wide?: boolean };
1818
+ props: {
1819
+ text: string;
1820
+ href?: string;
1821
+ newTab?: boolean;
1822
+ wide?: boolean;
1823
+ panelPartId?: string;
1824
+ panelWidth?: z.infer<typeof Length>;
1825
+ };
1723
1826
  children: LayoutNode[];
1724
1827
  };
1725
1828
 
@@ -1739,6 +1842,7 @@ export type LayoutNode =
1739
1842
  | TabsNode
1740
1843
  | TabPanelNode
1741
1844
  | FormNode
1845
+ | FormStepNode
1742
1846
  | LoopNode
1743
1847
  | LoopEmptyNode
1744
1848
  | SectionNode
@@ -1770,6 +1874,8 @@ export type LayoutNode =
1770
1874
  | ShareLinkNode
1771
1875
  | HotspotsNode
1772
1876
  | HotspotNode
1877
+ | SearchFormNode
1878
+ | ThemeToggleNode
1773
1879
  | SpacerNode
1774
1880
  | DividerNode
1775
1881
  | TextNode
@@ -1910,6 +2016,8 @@ export const isContainerNode = (node: LayoutNode): node is ContainerNode =>
1910
2016
 
1911
2017
  export const isFormNode = (node: LayoutNode): node is FormNode => node.type === "form";
1912
2018
 
2019
+ export const isFormStepNode = (node: LayoutNode): node is FormStepNode => node.type === "form-step";
2020
+
1913
2021
  export const isLoopNode = (node: LayoutNode): node is LoopNode => node.type === "loop";
1914
2022
 
1915
2023
  /**
@@ -1949,7 +2057,8 @@ export const isLayoutParentNode = (
1949
2057
  | LoopEmptyNode
1950
2058
  | AccordionItemNode
1951
2059
  | MenuItemNode
1952
- | CarouselSlideNode =>
2060
+ | CarouselSlideNode
2061
+ | FormStepNode =>
1953
2062
  node.type === "container" ||
1954
2063
  node.type === "div-block" ||
1955
2064
  node.type === "layout-section" ||
@@ -1960,7 +2069,8 @@ export const isLayoutParentNode = (
1960
2069
  node.type === "loop-empty" ||
1961
2070
  node.type === "accordion-item" ||
1962
2071
  node.type === "menu-item" ||
1963
- node.type === "carousel-slide";
2072
+ node.type === "carousel-slide" ||
2073
+ node.type === "form-step";
1964
2074
 
1965
2075
  /** Nodes that may hold children. */
1966
2076
  export const isParentNode = (
@@ -1972,6 +2082,7 @@ export const isParentNode = (
1972
2082
  | FlexboxNode
1973
2083
  | GridNode
1974
2084
  | FormNode
2085
+ | FormStepNode
1975
2086
  | LoopNode
1976
2087
  | LoopEmptyNode
1977
2088
  | SectionNode
@@ -1994,6 +2105,7 @@ export const isParentNode = (
1994
2105
  node.type === "flexbox" ||
1995
2106
  node.type === "grid" ||
1996
2107
  node.type === "form" ||
2108
+ node.type === "form-step" ||
1997
2109
  node.type === "loop" ||
1998
2110
  node.type === "loop-empty" ||
1999
2111
  node.type === "part-ref" ||
@@ -209,6 +209,30 @@ const LoopMotion = z.union([
209
209
  z.strictObject({ type: z.literal("none") }),
210
210
  ]);
211
211
 
212
+ /**
213
+ * W-1070: what a sticky (or fixed) element does as the page scrolls, over its first `distance`
214
+ * px (unset 120): it takes `background`, a `shadow` and `padding` (top and bottom), with CSS
215
+ * scroll-driven animations; browsers without them keep it as it is, and padding doesn't change
216
+ * for visitors who prefer reduced motion. `hide` slides it away while the visitor scrolls down
217
+ * and back on scrolling up, with the opt-in sticky script; never while focus is inside it.
218
+ * `{ type: "none" }` stops what a wider device sets.
219
+ */
220
+ const StickyMotion = z.union([
221
+ z
222
+ .strictObject({
223
+ distance: z.number().int().min(10).max(2000).optional(),
224
+ background: ColorValue.optional(),
225
+ shadow: z.boolean().optional(),
226
+ padding: LengthValue.optional(),
227
+ hide: z.boolean().optional(),
228
+ })
229
+ .refine(
230
+ (s) => s.background !== undefined || s.shadow || s.padding !== undefined || s.hide,
231
+ "Choose at least one effect.",
232
+ ),
233
+ z.strictObject({ type: z.literal("none") }),
234
+ ]);
235
+
212
236
  /**
213
237
  * Plays once (W-101, W-107). `delay` waits before it starts. `view` starts as the element
214
238
  * scrolls into view, using CSS scroll-driven animations, and falls back to playing on load.
@@ -233,6 +257,7 @@ export const Motion = z.strictObject({
233
257
  transition: Transition.optional(),
234
258
  icon: IconAnimation.optional(),
235
259
  loop: LoopMotion.optional(),
260
+ sticky: StickyMotion.optional(),
236
261
  });
237
262
 
238
263
  export type Motion = z.infer<typeof Motion>;
@@ -505,6 +530,7 @@ const FlatStyleShape = StyleProps.omit({ motion: true }).extend({
505
530
  scrollMotion: ScrollMotion.optional(),
506
531
  entrance: Entrance.optional(),
507
532
  loopMotion: LoopMotion.optional(),
533
+ stickyMotion: StickyMotion.optional(),
508
534
  });
509
535
  const flatShape: Record<string, z.ZodType> = {};
510
536
  for (const [key, schema] of Object.entries(StyleProps.omit({ motion: true }).shape)) {
@@ -516,6 +542,8 @@ for (const [key, schema] of Object.entries(StyleProps.omit({ motion: true }).sha
516
542
  flatShape["entrance"] = Entrance.optional();
517
543
  // W-938: added in 1.0, so after every 0.x key (0.x pages keep their CSS order).
518
544
  flatShape["loopMotion"] = LoopMotion.optional();
545
+ // W-1070: added in 1.4, last for the same reason.
546
+ flatShape["stickyMotion"] = StickyMotion.optional();
519
547
  }
520
548
  }
521
549
  export const FlatStyleProps = z.strictObject(flatShape) as unknown as typeof FlatStyleShape;