@perkyzz/emvb 0.1.0 → 0.2.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 (153) hide show
  1. package/README.md +4 -2
  2. package/THIRD_PARTY_NOTICES.md +32 -0
  3. package/licenses/fontawesome-free.LICENSE +165 -0
  4. package/licenses/lucide-static.LICENSE +43 -0
  5. package/licenses/remixicon.LICENSE +201 -0
  6. package/licenses/tabler-icons.LICENSE +21 -0
  7. package/package.json +8 -4
  8. package/src/admin/api.ts +27 -0
  9. package/src/admin/content-api.ts +72 -9
  10. package/src/admin/editor/Editor.tsx +89 -14
  11. package/src/admin/editor/EditorOverlay.tsx +12 -0
  12. package/src/admin/editor/SmallScreenNotice.tsx +4 -3
  13. package/src/admin/editor/TopBar.tsx +76 -12
  14. package/src/admin/editor/canvas/CanvasFrame.tsx +224 -43
  15. package/src/admin/editor/canvas/DeviceBar.tsx +43 -2
  16. package/src/admin/editor/canvas/SelectionOverlay.tsx +60 -6
  17. package/src/admin/editor/canvas/canvas-events.ts +20 -7
  18. package/src/admin/editor/canvas/tab-reveal.ts +66 -0
  19. package/src/admin/editor/canvas/vnode-react.tsx +21 -1
  20. package/src/admin/editor/dialogs.tsx +39 -0
  21. package/src/admin/editor/dnd/drop-target.ts +63 -16
  22. package/src/admin/editor/dnd/new-element.ts +76 -1
  23. package/src/admin/editor/editor-css.ts +101 -15
  24. package/src/admin/editor/host.ts +30 -0
  25. package/src/admin/editor/icons/IconLibraryDialog.tsx +850 -0
  26. package/src/admin/editor/icons/library.ts +243 -0
  27. package/src/admin/editor/icons/set-format.ts +29 -0
  28. package/src/admin/editor/icons/sets/fontawesome.json +1 -0
  29. package/src/admin/editor/icons/sets/lucide.json +1 -0
  30. package/src/admin/editor/icons/sets/remix.json +1 -0
  31. package/src/admin/editor/icons/sets/tabler.json +1 -0
  32. package/src/admin/editor/panels/AddPanel.tsx +7 -3
  33. package/src/admin/editor/panels/ClassesSection.tsx +44 -6
  34. package/src/admin/editor/panels/ColorControl.tsx +268 -21
  35. package/src/admin/editor/panels/ElementPanel.tsx +237 -93
  36. package/src/admin/editor/panels/LayersPanel.tsx +303 -66
  37. package/src/admin/editor/panels/LeftPanel.tsx +4 -0
  38. package/src/admin/editor/panels/PageSettings.tsx +134 -5
  39. package/src/admin/editor/panels/SettingsPanel.tsx +12 -0
  40. package/src/admin/editor/panels/SiteStylesDrawer.tsx +158 -2
  41. package/src/admin/editor/panels/TriggersEditor.tsx +19 -2
  42. package/src/admin/editor/panels/VariableSection.tsx +47 -9
  43. package/src/admin/editor/panels/color-space.ts +195 -0
  44. package/src/admin/editor/panels/settings/AdvancedFields.tsx +119 -0
  45. package/src/admin/editor/panels/settings/BackgroundControls.tsx +153 -55
  46. package/src/admin/editor/panels/settings/BackgroundFill.tsx +221 -0
  47. package/src/admin/editor/panels/settings/BoxControl.tsx +271 -0
  48. package/src/admin/editor/panels/settings/ChoiceGroup.tsx +138 -0
  49. package/src/admin/editor/panels/settings/ClassChipInput.tsx +104 -2
  50. package/src/admin/editor/panels/settings/DraftTextField.tsx +44 -3
  51. package/src/admin/editor/panels/settings/EffectsControls.tsx +23 -16
  52. package/src/admin/editor/panels/settings/FieldBindControl.tsx +53 -17
  53. package/src/admin/editor/panels/settings/FieldControl.tsx +129 -9
  54. package/src/admin/editor/panels/settings/FormBindControl.tsx +14 -5
  55. package/src/admin/editor/panels/settings/IconControls.tsx +438 -0
  56. package/src/admin/editor/panels/settings/IconPicker.tsx +133 -72
  57. package/src/admin/editor/panels/settings/ItemList.tsx +199 -0
  58. package/src/admin/editor/panels/settings/LengthRow.tsx +97 -61
  59. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +10 -4
  60. package/src/admin/editor/panels/settings/MediaPicker.tsx +4 -2
  61. package/src/admin/editor/panels/settings/StateSwitcher.tsx +1 -1
  62. package/src/admin/editor/panels/settings/StyleRow.tsx +158 -75
  63. package/src/admin/editor/panels/settings/VariableBinding.tsx +5 -1
  64. package/src/admin/editor/panels/settings/advanced-rules.ts +63 -0
  65. package/src/admin/editor/panels/settings/background-mode.ts +112 -0
  66. package/src/admin/editor/panels/settings/box-link-name.ts +38 -0
  67. package/src/admin/editor/panels/settings/box-sides.ts +153 -0
  68. package/src/admin/editor/panels/settings/button-url.ts +27 -0
  69. package/src/admin/editor/panels/settings/class-suggest.ts +5 -3
  70. package/src/admin/editor/panels/settings/form-names.ts +38 -0
  71. package/src/admin/editor/panels/settings/heading-warning.ts +25 -0
  72. package/src/admin/editor/panels/settings/image-alt.ts +25 -0
  73. package/src/admin/editor/panels/settings/length-units.ts +40 -7
  74. package/src/admin/editor/panels/settings/loop-context.ts +26 -0
  75. package/src/admin/editor/panels/settings/style-sections.ts +114 -11
  76. package/src/admin/editor/panels/settings/svg-images.ts +14 -0
  77. package/src/admin/editor/panels/site-list.tsx +3 -0
  78. package/src/admin/editor/restore-deleted.ts +80 -0
  79. package/src/admin/editor/shortcuts.ts +1 -1
  80. package/src/admin/editor/store.ts +35 -7
  81. package/src/admin/editor/useEditorCommands.ts +66 -5
  82. package/src/admin/editor/useEditorData.ts +29 -3
  83. package/src/admin/editor/useEditorShortcuts.ts +34 -2
  84. package/src/admin/editor/useNodeActions.ts +68 -6
  85. package/src/admin/editor/useSave.ts +60 -3
  86. package/src/admin/entry-status.ts +19 -0
  87. package/src/admin/icon-uploads-api.ts +44 -0
  88. package/src/admin/pages/PageList.tsx +22 -2
  89. package/src/admin/pages/ThemePartList.tsx +23 -4
  90. package/src/admin/pages/list-kit.tsx +52 -2
  91. package/src/admin/setup/spec.ts +7 -0
  92. package/src/admin/theme-api.ts +61 -14
  93. package/src/admin/ui.ts +17 -4
  94. package/src/astro/EmVBPage.astro +28 -2
  95. package/src/astro/floats/EmVBFloatsRuntime.astro +9 -0
  96. package/src/astro/floats/index.ts +1 -0
  97. package/src/astro/floats/runtime.ts +78 -0
  98. package/src/astro/forms-definitions.ts +22 -0
  99. package/src/astro/index.ts +1 -0
  100. package/src/astro/menu/EmVBMenuRuntime.astro +9 -0
  101. package/src/astro/menu/index.ts +1 -0
  102. package/src/astro/menu/runtime.ts +37 -0
  103. package/src/astro/popups/runtime.ts +54 -4
  104. package/src/astro/render.ts +47 -13
  105. package/src/astro/resolve-theme.ts +164 -20
  106. package/src/astro/tabs/runtime.ts +6 -1
  107. package/src/astro/theme-context.ts +11 -3
  108. package/src/constants.ts +1 -1
  109. package/src/core/arrange.ts +98 -10
  110. package/src/core/clipboard.ts +91 -9
  111. package/src/core/css/generate.ts +21 -4
  112. package/src/core/design/classes.ts +95 -9
  113. package/src/core/design/transfer.ts +101 -2
  114. package/src/core/design/variables.ts +51 -11
  115. package/src/core/elements/dynamic-elements.ts +57 -5
  116. package/src/core/elements/field-id.ts +6 -0
  117. package/src/core/elements/form-elements.ts +23 -8
  118. package/src/core/elements/index.ts +267 -49
  119. package/src/core/elements/menu.ts +190 -0
  120. package/src/core/forms/definition.ts +11 -0
  121. package/src/core/index.ts +67 -3
  122. package/src/core/limits.ts +2 -0
  123. package/src/core/migrate/index.ts +51 -1
  124. package/src/core/nesting.ts +51 -0
  125. package/src/core/render/context.ts +7 -0
  126. package/src/core/render/dynamic-post.ts +39 -11
  127. package/src/core/render/extras.ts +22 -3
  128. package/src/core/render/form.ts +134 -36
  129. package/src/core/render/index.ts +123 -25
  130. package/src/core/render/loop.ts +10 -3
  131. package/src/core/render/pagination.ts +76 -0
  132. package/src/core/render/section.ts +5 -1
  133. package/src/core/render/tabs.ts +8 -4
  134. package/src/core/render/vnode.ts +1 -1
  135. package/src/core/sanitize/css.ts +197 -17
  136. package/src/core/sanitize/embed-url.ts +64 -7
  137. package/src/core/sanitize/svg-upload.ts +203 -0
  138. package/src/core/sanitize/svg.ts +102 -21
  139. package/src/core/schema/descriptors.ts +4 -0
  140. package/src/core/schema/design.ts +7 -2
  141. package/src/core/schema/layout.ts +210 -19
  142. package/src/core/schema/style.ts +87 -8
  143. package/src/core/tabs/presence.ts +9 -0
  144. package/src/core/theme/conditions.ts +4 -1
  145. package/src/core/theme/dynamic.ts +10 -0
  146. package/src/core/theme/float.ts +113 -0
  147. package/src/core/theme/pagination.ts +97 -0
  148. package/src/core/theme/part-types.ts +2 -0
  149. package/src/core/theme/popup-markup.ts +3 -1
  150. package/src/core/theme/popup-rules.ts +4 -3
  151. package/src/server/hooks.ts +20 -0
  152. package/src/server/icon-routes.ts +79 -0
  153. package/src/server/plugin.ts +5 -1
@@ -2,8 +2,12 @@ import { z } from "zod";
2
2
  import { MAX_TEXT_LENGTH } from "../limits.ts";
3
3
  import { DeviceStyles, HiddenOn, Length, StyleProps, StyleStates } from "./style.ts";
4
4
 
5
- /** 9 since W-103 (D-042). v8 → v9 changes nothing, so an older EmVB shows "saved by a newer EmVB". */
6
- export const LAYOUT_SCHEMA_VERSION = 9;
5
+ /**
6
+ * 12 since W-160: gradient type, stop locations, and up to 10 stops. v11 gradients
7
+ * (`{ angle, from, to }`) become a linear gradient on read.
8
+ * 11 since W-156 and W-157 (D-045): the layout Section element and an editor-only node label.
9
+ */
10
+ export const LAYOUT_SCHEMA_VERSION = 12;
7
11
 
8
12
  export const NodeId = z
9
13
  .string()
@@ -29,6 +33,9 @@ export const CONTAINER_TAGS = [
29
33
  ] as const;
30
34
  export const TEXT_TAGS = ["p", "div"] as const;
31
35
 
36
+ /** The editor-only name of a node in Layers (W-157, D-045). Never rendered on the page. */
37
+ const NodeLabel = z.string().trim().min(1).max(80);
38
+
32
39
  /** `data-*` and `aria-*` only. Names stay unique on the element (W-105 / R-032). */
33
40
  const HtmlAttribute = z.strictObject({
34
41
  name: z
@@ -60,6 +67,7 @@ const nodeFields = <T extends string, P extends z.ZodType>(type: T, props: P) =>
60
67
  classes: ClassIds.optional(),
61
68
  htmlId: HtmlId.optional(),
62
69
  attributes: HtmlAttributes.optional(),
70
+ label: NodeLabel.optional(),
63
71
  });
64
72
 
65
73
  const leafNode = <T extends string, P extends z.ZodType>(type: T, props: P) =>
@@ -78,6 +86,9 @@ export const HeadingNode = leafNode(
78
86
  z.strictObject({
79
87
  text: z.string().max(MAX_TEXT_LENGTH),
80
88
  level: z.number().int().min(1).max(6),
89
+ /** Optional link around the text (W-141), like Elementor's Heading link. */
90
+ href: z.string().max(2000).optional(),
91
+ newTab: z.boolean().optional(),
81
92
  }),
82
93
  );
83
94
 
@@ -141,19 +152,39 @@ export const VideoNode = leafNode(
141
152
  }),
142
153
  );
143
154
 
144
- /** Bundled Lucide icon by id (W-025 / A-04). Unknown ids stay on save; renderer shows a placeholder. */
155
+ /**
156
+ * An icon (W-025 / A-04). `iconId` names it: a bundled Lucide id ("star") or, from the Icon library
157
+ * (W-234), `<set prefix>:<name>` ("fa-solid:rocket"), so the picker can reopen on it. `iconSvg` is
158
+ * that icon's SVG, stored with the page so public pages load no icon library; it's sanitized on
159
+ * every render. Unknown ids without SVG stay on save; the renderer shows a placeholder.
160
+ * W-239: an uploaded SVG is `upload:<id>` (EmVB's icon uploads); the cap rose from 16 KB to
161
+ * 32 KB for uploaded logos and illustrations: the SVG sanitizer's own limit (and the SVG
162
+ * element's), so a stored icon always renders.
163
+ */
164
+ export const ICON_SVG_MAX = 32_768;
145
165
  export const IconNode = leafNode(
146
166
  "icon",
147
167
  z.strictObject({
148
168
  iconId: z.string().min(1).max(64),
169
+ iconSvg: z.string().max(ICON_SVG_MAX).optional(),
170
+ /** W-238: paint a multi-colour SVG in the icon's colour (fills and strokes → currentColor). */
171
+ singleColor: z.boolean().optional(),
149
172
  size: z.number().int().positive().max(512).optional(),
150
173
  decorative: z.boolean().optional(),
151
174
  title: z.string().max(200).optional(),
175
+ /** Optional link around the icon (W-141); the title names the link. */
176
+ href: z.string().max(2000).optional(),
177
+ newTab: z.boolean().optional(),
152
178
  }),
153
- ).refine((node) => node.props.decorative === true || (node.props.title?.length ?? 0) > 0, {
154
- message: "Title is required unless the icon is marked decorative.",
155
- path: ["props", "title"],
156
- });
179
+ )
180
+ .refine((node) => node.props.decorative === true || (node.props.title?.length ?? 0) > 0, {
181
+ message: "Title is required unless the icon is marked decorative.",
182
+ path: ["props", "title"],
183
+ })
184
+ .refine((node) => !node.props.href?.trim() || (node.props.title?.trim().length ?? 0) > 0, {
185
+ message: "A linked icon needs a title: it names the link.",
186
+ path: ["props", "title"],
187
+ });
157
188
 
158
189
  /** Image from the media library or a URL (W-024 / R-007). Alt required unless decorative. */
159
190
  export const ImageNode = leafNode(
@@ -165,6 +196,8 @@ export const ImageNode = leafNode(
165
196
  width: z.number().int().positive().max(10000).optional(),
166
197
  height: z.number().int().positive().max(10000).optional(),
167
198
  mediaId: z.string().min(1).max(128).optional(),
199
+ /** Load right away (eager, high fetch priority) for the hero/LCP image (W-226). */
200
+ priority: z.boolean().optional(),
168
201
  }),
169
202
  ).refine((node) => node.props.decorative === true || node.props.alt.length > 0, {
170
203
  message: "Alt text is required unless the image is marked decorative.",
@@ -180,21 +213,42 @@ export const ContainerNode = parentNode(
180
213
  );
181
214
 
182
215
  /** Field name on a forms-plugin form (D-015). */
216
+ /** Form field names (W-202 checks them as you type with the same rule). */
217
+ export const FIELD_NAME_PATTERN = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
218
+ export const MAX_FIELD_NAME = 80;
183
219
  const FieldName = z
184
220
  .string()
185
221
  .min(1)
186
- .max(80)
187
- .regex(/^[a-zA-Z][a-zA-Z0-9_-]*$/, "Field names start with a letter");
222
+ .max(MAX_FIELD_NAME)
223
+ .regex(FIELD_NAME_PATTERN, "Field names start with a letter");
188
224
 
189
225
  export const DivBlockNode = parentNode("div-block", z.strictObject({ ...BoxLink }));
190
226
 
227
+ /**
228
+ * A layout Section (W-156, D-045): a full-width band whose contents sit in a centred inner box,
229
+ * `contentWidth` wide at most (1140 px when unset), or the full width with `fullWidth`.
230
+ */
231
+ export const LayoutSectionNode = parentNode(
232
+ "layout-section",
233
+ z.strictObject({
234
+ tag: z.enum(CONTAINER_TAGS).optional(),
235
+ contentWidth: Length.optional(),
236
+ fullWidth: z.boolean().optional(),
237
+ }),
238
+ );
239
+
191
240
  export const FlexboxNode = parentNode("flexbox", z.strictObject({ ...BoxLink }));
192
241
 
193
- /** Equal columns. Children span with `gridColumnSpan` and `gridRowSpan` on their style. */
242
+ /**
243
+ * Equal columns. Children span with `gridColumnSpan` and `gridRowSpan` on their style. Tablet
244
+ * and mobile may have their own count (W-139); unset follows the next wider device.
245
+ */
194
246
  export const GridNode = parentNode(
195
247
  "grid",
196
248
  z.strictObject({
197
249
  columns: z.number().int().min(1).max(12),
250
+ columnsTablet: z.number().int().min(1).max(12).optional(),
251
+ columnsMobile: z.number().int().min(1).max(12).optional(),
198
252
  ...BoxLink,
199
253
  }),
200
254
  );
@@ -210,6 +264,28 @@ export const AccordionItemNode = parentNode(
210
264
  }),
211
265
  );
212
266
 
267
+ /** A row or column of menu items. Dropdowns and wide panels are the items' children (W-162). */
268
+ export const MenuNode = parentNode(
269
+ "menu",
270
+ z.strictObject({
271
+ direction: z.enum(["row", "column"]),
272
+ /** Names the navigation landmark. Omitted uses "Menu". */
273
+ label: z.string().max(80).optional(),
274
+ }),
275
+ );
276
+
277
+ /** A link, and, when it has children, the dropdown or wide panel under it. */
278
+ export const MenuItemNode = parentNode(
279
+ "menu-item",
280
+ z.strictObject({
281
+ text: z.string().min(1).max(MAX_TEXT_LENGTH),
282
+ href: z.string().max(2000).optional(),
283
+ newTab: z.boolean().optional(),
284
+ /** The panel stretches across the menu instead of sitting under the item. */
285
+ wide: z.boolean().optional(),
286
+ }),
287
+ );
288
+
213
289
  export const SvgNode = leafNode(
214
290
  "svg",
215
291
  z.strictObject({
@@ -284,8 +360,11 @@ export const PostTitleNode = leafNode(
284
360
  }),
285
361
  );
286
362
 
287
- /** Dynamic post excerpt (escaped text). */
288
- export const PostExcerptNode = leafNode("post-excerpt", z.strictObject({}));
363
+ /** Dynamic post excerpt (escaped text). `maxWords` cuts it to that many words, with "…" (W-177). */
364
+ export const PostExcerptNode = leafNode(
365
+ "post-excerpt",
366
+ z.strictObject({ maxWords: z.number().int().positive().max(10_000).optional() }),
367
+ );
289
368
 
290
369
  /** Dynamic post body from Portable Text / string (sanitized via VNode serialize). */
291
370
  export const PostContentNode = leafNode("post-content", z.strictObject({}));
@@ -298,8 +377,14 @@ export const PostImageNode = leafNode(
298
377
  }),
299
378
  );
300
379
 
380
+ /** How a Post Date reads (W-177). Unset is `medium`. `numeric` is YYYY-MM-DD. */
381
+ export const POST_DATE_FORMATS = ["medium", "short", "long", "full", "numeric"] as const;
382
+
301
383
  /** Published date from the post, shown as a `<time>` element (W-108). */
302
- export const PostDateNode = leafNode("post-date", z.strictObject({}));
384
+ export const PostDateNode = leafNode(
385
+ "post-date",
386
+ z.strictObject({ format: z.enum(POST_DATE_FORMATS).optional() }),
387
+ );
303
388
 
304
389
  /** Author name from the post (W-108). */
305
390
  export const PostAuthorNode = leafNode("post-author", z.strictObject({}));
@@ -322,6 +407,20 @@ export const LoopNode = parentNode(
322
407
  "loop",
323
408
  z.strictObject({
324
409
  itemPartId: z.string().max(128).optional(),
410
+ /** Posts per archive page, 1–50 (W-221). Unset = 20. */
411
+ perPage: z.number().int().min(1).max(50).optional(),
412
+ }),
413
+ );
414
+
415
+ /**
416
+ * Previous / page numbers / Next links for an archive (W-222). Renders only on an archive with
417
+ * more than one page; the host supplies `ThemeDynamicData.pagination`.
418
+ */
419
+ export const PaginationNode = leafNode(
420
+ "pagination",
421
+ z.strictObject({
422
+ prevText: z.string().max(40).optional(),
423
+ nextText: z.string().max(40).optional(),
325
424
  }),
326
425
  );
327
426
 
@@ -365,6 +464,7 @@ export const KNOWN_ELEMENT_TYPES = [
365
464
  "post-date",
366
465
  "post-author",
367
466
  "loop",
467
+ "pagination",
368
468
  "section",
369
469
  "div-block",
370
470
  "flexbox",
@@ -374,6 +474,9 @@ export const KNOWN_ELEMENT_TYPES = [
374
474
  "tab-panel",
375
475
  "accordion",
376
476
  "accordion-item",
477
+ "menu",
478
+ "menu-item",
479
+ "layout-section",
377
480
  ] as const;
378
481
 
379
482
  const knownTypeSet = new Set<string>(KNOWN_ELEMENT_TYPES);
@@ -395,6 +498,7 @@ const UnknownNodeSchema = z.strictObject({
395
498
  classes: ClassIds.optional(),
396
499
  htmlId: HtmlId.optional(),
397
500
  attributes: HtmlAttributes.optional(),
501
+ label: NodeLabel.optional(),
398
502
  get children(): z.ZodType<LayoutNode[] | undefined> {
399
503
  return z.array(LayoutNode).optional();
400
504
  },
@@ -403,6 +507,7 @@ const UnknownNodeSchema = z.strictObject({
403
507
  const KnownLayoutNode = z.discriminatedUnion("type", [
404
508
  ContainerNode,
405
509
  DivBlockNode,
510
+ LayoutSectionNode,
406
511
  FlexboxNode,
407
512
  GridNode,
408
513
  SvgNode,
@@ -434,9 +539,12 @@ const KnownLayoutNode = z.discriminatedUnion("type", [
434
539
  PostDateNode,
435
540
  PostAuthorNode,
436
541
  LoopNode,
542
+ PaginationNode,
437
543
  SectionNode,
438
544
  AccordionNode,
439
545
  AccordionItemNode,
546
+ MenuNode,
547
+ MenuItemNode,
440
548
  ]);
441
549
 
442
550
  export type HeadingNode = z.infer<typeof HeadingNode>;
@@ -461,6 +569,7 @@ export type PostExcerptNode = z.infer<typeof PostExcerptNode>;
461
569
  export type PostContentNode = z.infer<typeof PostContentNode>;
462
570
  export type PostImageNode = z.infer<typeof PostImageNode>;
463
571
  export type PostLinkNode = z.infer<typeof PostLinkNode>;
572
+ export type PaginationNode = z.infer<typeof PaginationNode>;
464
573
  export type PostDateNode = z.infer<typeof PostDateNode>;
465
574
  export type PostAuthorNode = z.infer<typeof PostAuthorNode>;
466
575
 
@@ -485,6 +594,7 @@ export type UnknownNode = {
485
594
  classes?: ClassesOf;
486
595
  htmlId?: HtmlIdOf;
487
596
  attributes?: HtmlAttributeOf[];
597
+ label?: string;
488
598
  children?: LayoutNode[];
489
599
  };
490
600
 
@@ -499,6 +609,7 @@ export type ContainerNode = {
499
609
  classes?: ClassesOf;
500
610
  htmlId?: HtmlIdOf;
501
611
  attributes?: HtmlAttributeOf[];
612
+ label?: string;
502
613
  children: LayoutNode[];
503
614
  };
504
615
 
@@ -513,13 +624,39 @@ export type DivBlockNode = {
513
624
  classes?: ClassesOf;
514
625
  htmlId?: HtmlIdOf;
515
626
  attributes?: HtmlAttributeOf[];
627
+ label?: string;
628
+ children: LayoutNode[];
629
+ };
630
+
631
+ export type LayoutSectionNode = {
632
+ id: IdOf;
633
+ type: "layout-section";
634
+ props: {
635
+ tag?: (typeof CONTAINER_TAGS)[number];
636
+ contentWidth?: z.infer<typeof Length>;
637
+ fullWidth?: boolean;
638
+ };
639
+ style?: StyleOf;
640
+ states?: StatesOf;
641
+ devices?: DevicesOf;
642
+ hiddenOn?: HiddenOnOf;
643
+ classes?: ClassesOf;
644
+ htmlId?: HtmlIdOf;
645
+ attributes?: HtmlAttributeOf[];
646
+ label?: string;
516
647
  children: LayoutNode[];
517
648
  };
518
649
 
519
650
  export type GridNode = {
520
651
  id: IdOf;
521
652
  type: "grid";
522
- props: { columns: number; href?: string; newTab?: boolean };
653
+ props: {
654
+ columns: number;
655
+ columnsTablet?: number;
656
+ columnsMobile?: number;
657
+ href?: string;
658
+ newTab?: boolean;
659
+ };
523
660
  style?: StyleOf;
524
661
  states?: StatesOf;
525
662
  devices?: DevicesOf;
@@ -527,6 +664,7 @@ export type GridNode = {
527
664
  classes?: ClassesOf;
528
665
  htmlId?: HtmlIdOf;
529
666
  attributes?: HtmlAttributeOf[];
667
+ label?: string;
530
668
  children: LayoutNode[];
531
669
  };
532
670
 
@@ -541,6 +679,7 @@ export type FlexboxNode = {
541
679
  classes?: ClassesOf;
542
680
  htmlId?: HtmlIdOf;
543
681
  attributes?: HtmlAttributeOf[];
682
+ label?: string;
544
683
  children: LayoutNode[];
545
684
  };
546
685
 
@@ -560,6 +699,7 @@ export type SvgNode = {
560
699
  classes?: ClassesOf;
561
700
  htmlId?: HtmlIdOf;
562
701
  attributes?: HtmlAttributeOf[];
702
+ label?: string;
563
703
  };
564
704
 
565
705
  export type TabPanelNode = {
@@ -573,6 +713,7 @@ export type TabPanelNode = {
573
713
  classes?: ClassesOf;
574
714
  htmlId?: HtmlIdOf;
575
715
  attributes?: HtmlAttributeOf[];
716
+ label?: string;
576
717
  children: LayoutNode[];
577
718
  };
578
719
 
@@ -587,6 +728,7 @@ export type TabsNode = {
587
728
  classes?: ClassesOf;
588
729
  htmlId?: HtmlIdOf;
589
730
  attributes?: HtmlAttributeOf[];
731
+ label?: string;
590
732
  children: LayoutNode[];
591
733
  };
592
734
 
@@ -601,13 +743,14 @@ export type FormNode = {
601
743
  classes?: ClassesOf;
602
744
  htmlId?: HtmlIdOf;
603
745
  attributes?: HtmlAttributeOf[];
746
+ label?: string;
604
747
  children: LayoutNode[];
605
748
  };
606
749
 
607
750
  export type LoopNode = {
608
751
  id: IdOf;
609
752
  type: "loop";
610
- props: { itemPartId?: string };
753
+ props: { itemPartId?: string; perPage?: number };
611
754
  style?: StyleOf;
612
755
  states?: StatesOf;
613
756
  devices?: DevicesOf;
@@ -615,6 +758,7 @@ export type LoopNode = {
615
758
  classes?: ClassesOf;
616
759
  htmlId?: HtmlIdOf;
617
760
  attributes?: HtmlAttributeOf[];
761
+ label?: string;
618
762
  children: LayoutNode[];
619
763
  };
620
764
 
@@ -629,6 +773,7 @@ export type SectionNode = {
629
773
  classes?: ClassesOf;
630
774
  htmlId?: HtmlIdOf;
631
775
  attributes?: HtmlAttributeOf[];
776
+ label?: string;
632
777
  children: LayoutNode[];
633
778
  };
634
779
 
@@ -643,6 +788,37 @@ export type AccordionNode = {
643
788
  classes?: ClassesOf;
644
789
  htmlId?: HtmlIdOf;
645
790
  attributes?: HtmlAttributeOf[];
791
+ label?: string;
792
+ children: LayoutNode[];
793
+ };
794
+
795
+ export type MenuNode = {
796
+ id: IdOf;
797
+ type: "menu";
798
+ props: { direction: "row" | "column"; label?: string };
799
+ style?: StyleOf;
800
+ states?: StatesOf;
801
+ devices?: DevicesOf;
802
+ hiddenOn?: HiddenOnOf;
803
+ classes?: ClassesOf;
804
+ htmlId?: HtmlIdOf;
805
+ attributes?: HtmlAttributeOf[];
806
+ label?: string;
807
+ children: LayoutNode[];
808
+ };
809
+
810
+ export type MenuItemNode = {
811
+ id: IdOf;
812
+ type: "menu-item";
813
+ props: { text: string; href?: string; newTab?: boolean; wide?: boolean };
814
+ style?: StyleOf;
815
+ states?: StatesOf;
816
+ devices?: DevicesOf;
817
+ hiddenOn?: HiddenOnOf;
818
+ classes?: ClassesOf;
819
+ htmlId?: HtmlIdOf;
820
+ attributes?: HtmlAttributeOf[];
821
+ label?: string;
646
822
  children: LayoutNode[];
647
823
  };
648
824
 
@@ -657,12 +833,14 @@ export type AccordionItemNode = {
657
833
  classes?: ClassesOf;
658
834
  htmlId?: HtmlIdOf;
659
835
  attributes?: HtmlAttributeOf[];
836
+ label?: string;
660
837
  children: LayoutNode[];
661
838
  };
662
839
 
663
840
  export type LayoutNode =
664
841
  | ContainerNode
665
842
  | DivBlockNode
843
+ | LayoutSectionNode
666
844
  | FlexboxNode
667
845
  | GridNode
668
846
  | SvgNode
@@ -695,8 +873,11 @@ export type LayoutNode =
695
873
  | PostLinkNode
696
874
  | PostDateNode
697
875
  | PostAuthorNode
876
+ | PaginationNode
698
877
  | AccordionNode
699
878
  | AccordionItemNode
879
+ | MenuNode
880
+ | MenuItemNode
700
881
  | UnknownNode;
701
882
 
702
883
  /**
@@ -768,18 +949,22 @@ export const isLayoutParentNode = (
768
949
  ): node is
769
950
  | ContainerNode
770
951
  | DivBlockNode
952
+ | LayoutSectionNode
771
953
  | FlexboxNode
772
954
  | GridNode
773
955
  | TabPanelNode
774
956
  | SectionNode
775
- | AccordionItemNode =>
957
+ | AccordionItemNode
958
+ | MenuItemNode =>
776
959
  node.type === "container" ||
777
960
  node.type === "div-block" ||
961
+ node.type === "layout-section" ||
778
962
  node.type === "flexbox" ||
779
963
  node.type === "grid" ||
780
964
  node.type === "tab-panel" ||
781
965
  node.type === "section" ||
782
- node.type === "accordion-item";
966
+ node.type === "accordion-item" ||
967
+ node.type === "menu-item";
783
968
 
784
969
  /** Nodes that may hold children. */
785
970
  export const isParentNode = (
@@ -787,6 +972,7 @@ export const isParentNode = (
787
972
  ): node is
788
973
  | ContainerNode
789
974
  | DivBlockNode
975
+ | LayoutSectionNode
790
976
  | FlexboxNode
791
977
  | GridNode
792
978
  | FormNode
@@ -795,9 +981,12 @@ export const isParentNode = (
795
981
  | TabsNode
796
982
  | TabPanelNode
797
983
  | AccordionNode
798
- | AccordionItemNode =>
984
+ | AccordionItemNode
985
+ | MenuNode
986
+ | MenuItemNode =>
799
987
  node.type === "container" ||
800
988
  node.type === "div-block" ||
989
+ node.type === "layout-section" ||
801
990
  node.type === "flexbox" ||
802
991
  node.type === "grid" ||
803
992
  node.type === "form" ||
@@ -806,7 +995,9 @@ export const isParentNode = (
806
995
  node.type === "tabs" ||
807
996
  node.type === "tab-panel" ||
808
997
  node.type === "accordion" ||
809
- node.type === "accordion-item";
998
+ node.type === "accordion-item" ||
999
+ node.type === "menu" ||
1000
+ node.type === "menu-item";
810
1001
 
811
1002
  export const isFormFieldType = (type: string): boolean =>
812
1003
  (FORM_FIELD_TYPES as readonly string[]).includes(type);
@@ -121,17 +121,30 @@ export const StyleProps = z.strictObject({
121
121
  ])
122
122
  .optional(),
123
123
  fontSize: LengthValue.optional(),
124
+ /** W-213: any weight 100–900 in steps of 100 (the font must ship it to look different). */
124
125
  fontWeight: z
125
126
  .union([
127
+ z.literal(100),
128
+ z.literal(200),
129
+ z.literal(300),
126
130
  z.literal(400),
127
131
  z.literal(500),
128
132
  z.literal(600),
129
133
  z.literal(700),
134
+ z.literal(800),
135
+ z.literal(900),
130
136
  z.enum(["normal", "bold"]),
131
137
  ])
132
138
  .optional(),
133
- lineHeight: LengthValue.optional(),
134
- letterSpacing: LengthValue.optional(),
139
+ /** W-213: also a plain number (unitless, 0–100), which scales with each child's font size. */
140
+ lineHeight: z.union([Length, VariableRef, z.number().finite().min(0).max(100)]).optional(),
141
+ /** W-213: may be negative, for tight display headings. */
142
+ letterSpacing: z
143
+ .union([
144
+ z.strictObject({ value: z.number().finite().min(-10_000).max(10_000), unit: LengthUnit }),
145
+ VariableRef,
146
+ ])
147
+ .optional(),
135
148
  textAlign: z.enum(["left", "center", "right", "justify"]).optional(),
136
149
  textTransform: z.enum(["none", "uppercase", "lowercase", "capitalize"]).optional(),
137
150
  /** W-113. A button sets `none` in its base CSS, so it is not underlined unless a style says so. */
@@ -173,12 +186,36 @@ export const StyleProps = z.strictObject({
173
186
  "Use an http(s) URL or a site path, with no spaces or parentheses",
174
187
  )
175
188
  .optional(),
176
- /** Two-stop linear gradient. Stops are colours, so a variable binding is a colour use (W-094). */
189
+ /**
190
+ * Background gradient (W-160). Up to 10 stops. `angle` is the linear direction and the conic
191
+ * start; `position` is the radial centre. A stop colour variable is a colour use.
192
+ */
177
193
  gradient: z
178
194
  .strictObject({
179
- angle: z.number().int().min(0).max(360),
180
- from: ColorValue,
181
- to: ColorValue,
195
+ type: z.enum(["linear", "radial", "conic"]),
196
+ angle: z.number().int().min(0).max(360).optional(),
197
+ position: z
198
+ .enum([
199
+ "center",
200
+ "top",
201
+ "bottom",
202
+ "left",
203
+ "right",
204
+ "top left",
205
+ "top right",
206
+ "bottom left",
207
+ "bottom right",
208
+ ])
209
+ .optional(),
210
+ stops: z
211
+ .array(
212
+ z.strictObject({
213
+ color: ColorValue,
214
+ at: z.number().int().min(0).max(100),
215
+ }),
216
+ )
217
+ .min(2)
218
+ .max(10),
182
219
  })
183
220
  .optional(),
184
221
  /** A colour laid over the image and gradient. `opacity` is 0–1 (W-094). */
@@ -189,9 +226,19 @@ export const StyleProps = z.strictObject({
189
226
  })
190
227
  .optional(),
191
228
  borderWidth: LengthValue.optional(),
229
+ /** Per-side widths (W-138, D-044), after `borderWidth`, so a side beats the all-sides value. */
230
+ borderTopWidth: LengthValue.optional(),
231
+ borderRightWidth: LengthValue.optional(),
232
+ borderBottomWidth: LengthValue.optional(),
233
+ borderLeftWidth: LengthValue.optional(),
192
234
  borderStyle: z.enum(["none", "solid", "dashed", "dotted"]).optional(),
193
235
  borderColor: ColorValue.optional(),
194
236
  borderRadius: LengthValue.optional(),
237
+ /** Per-corner radii (W-138, D-044), after `borderRadius`. */
238
+ borderTopLeftRadius: LengthValue.optional(),
239
+ borderTopRightRadius: LengthValue.optional(),
240
+ borderBottomRightRadius: LengthValue.optional(),
241
+ borderBottomLeftRadius: LengthValue.optional(),
195
242
  opacity: z.number().finite().min(0).max(1).optional(),
196
243
  boxShadow: BoxShadow.optional(),
197
244
  filter: Filter.optional(),
@@ -209,6 +256,37 @@ export const StyleProps = z.strictObject({
209
256
  ])
210
257
  .optional(),
211
258
  transition: Transition.optional(),
259
+ /**
260
+ * Icon element glyph styling (W-237). Emitted as custom properties on the icon's wrapper, so
261
+ * they work in states, devices and classes; the Icon's base CSS applies them to its `<svg>`.
262
+ * Elsewhere they do nothing. `iconScale` scales the whole icon (with its background shape).
263
+ */
264
+ iconRotate: z.number().int().min(-360).max(360).optional(),
265
+ iconFlip: z.enum(["none", "horizontal", "vertical", "both"]).optional(),
266
+ iconScale: num(0.1, 4).optional(),
267
+ iconStrokeWidth: num(0.25, 6).optional(),
268
+ /** A drop shadow that follows the glyph's shape (CSS `drop-shadow`), in px. */
269
+ iconShadow: z
270
+ .strictObject({
271
+ x: num(-100, 100),
272
+ y: num(-100, 100),
273
+ blur: num(0, 100),
274
+ color: ColorValue.optional(),
275
+ })
276
+ .optional(),
277
+ /**
278
+ * A looping spin or pulse; off for visitors who prefer reduced motion. `{ type: "none" }`
279
+ * (W-248) stops an animation a device would otherwise inherit from a wider one.
280
+ */
281
+ iconAnimation: z
282
+ .union([
283
+ z.strictObject({
284
+ type: z.enum(["spin", "pulse"]),
285
+ duration: z.number().int().min(200).max(10_000),
286
+ }),
287
+ z.strictObject({ type: z.literal("none") }),
288
+ ])
289
+ .optional(),
212
290
  /**
213
291
  * Plays once (W-101, W-107). `delay` waits before it starts. `view` starts as the element
214
292
  * scrolls into view, using CSS scroll-driven animations, and falls back to playing on load.
@@ -228,9 +306,10 @@ export type StyleProps = z.infer<typeof StyleProps>;
228
306
 
229
307
  /**
230
308
  * `states` on a node or class (D-032, W-089): hover, focus (`:focus-visible`) and active, each with
231
- * the same keys and limits as `style` except `transition` and `entrance`. Unknown states are refused.
309
+ * the same keys and limits as `style` except `transition`, `entrance` and `iconAnimation`. Unknown
310
+ * states are refused.
232
311
  */
233
- const StateStyle = StyleProps.omit({ transition: true, entrance: true });
312
+ const StateStyle = StyleProps.omit({ transition: true, entrance: true, iconAnimation: true });
234
313
 
235
314
  export const StyleStates = z.strictObject({
236
315
  hover: StateStyle.optional(),
@@ -14,3 +14,12 @@ export function layoutHasTabs(layout: Layout): boolean {
14
14
  });
15
15
  return found;
16
16
  }
17
+
18
+ /** A Menu with a dropdown, so hosts load the Escape-to-close menu script (W-197). */
19
+ export function layoutHasMenuDropdown(layout: Layout): boolean {
20
+ let found = false;
21
+ walk(layout.root, (node) => {
22
+ if (node.type === "menu-item" && nodeChildren(node).length > 0) found = true;
23
+ });
24
+ return found;
25
+ }
@@ -32,6 +32,8 @@ export type ThemeRequestContext = {
32
32
  collection?: string;
33
33
  entryId?: string;
34
34
  taxonomy?: { type: "category" | "tag"; slug: string };
35
+ /** Archive page from `/page/N` (W-221); `path` stays the archive's own path. Absent = 1. */
36
+ page?: number;
35
37
  };
36
38
 
37
39
  /** Entire Site include with a stable default id — used when creating a theme part. */
@@ -190,7 +192,8 @@ export function themePartLocationApplies(
190
192
  case "header":
191
193
  case "footer":
192
194
  case "popup":
193
- // Overlays compete on every route; conditions decide (S7b).
195
+ case "float":
196
+ // Overlays and floats compete on every route; conditions decide.
194
197
  return true;
195
198
  case "error_404":
196
199
  return ctx.is404;