@perkyzz/emvb 1.3.0 → 1.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.
- package/README.md +2 -2
- package/package.json +2 -2
- package/src/admin/bulk-api.ts +5 -1
- package/src/admin/editor/A11yCopilot.tsx +3 -1
- package/src/admin/editor/Editor.tsx +22 -2
- package/src/admin/editor/Timeline.tsx +1 -8
- package/src/admin/editor/canvas/DeviceBar.tsx +7 -2
- package/src/admin/editor/canvas/EmptyCanvas.tsx +11 -2
- package/src/admin/editor/canvas/use-canvas-dnd.ts +1 -20
- package/src/admin/editor/canvas/vnode-react.tsx +2 -0
- package/src/admin/editor/co-design.ts +36 -1
- package/src/admin/editor/dnd/dragged-source.ts +22 -0
- package/src/admin/editor/dnd/layer-drop.ts +141 -0
- package/src/admin/editor/dnd/new-element.ts +16 -0
- package/src/admin/editor/editor-css.ts +9 -1
- package/src/admin/editor/element-chrome.ts +6 -0
- package/src/admin/editor/feature-css.ts +22 -0
- package/src/admin/editor/inert-links.ts +8 -0
- package/src/admin/editor/panels/ColorControl.tsx +2 -2
- package/src/admin/editor/panels/FontFaces.tsx +342 -0
- package/src/admin/editor/panels/LayersPanel.tsx +56 -6
- package/src/admin/editor/panels/LeftPanel.tsx +153 -29
- package/src/admin/editor/panels/SettingsPanel.tsx +1 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +5 -0
- package/src/admin/editor/panels/TemplatesPanel.tsx +205 -0
- package/src/admin/editor/panels/TokenScales.tsx +2 -0
- package/src/admin/editor/panels/TriggersEditor.tsx +203 -9
- package/src/admin/editor/panels/VariableSection.tsx +111 -7
- package/src/admin/editor/panels/color-space.ts +71 -6
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +3 -0
- package/src/admin/editor/panels/settings/FieldControl.tsx +18 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +9 -3
- package/src/admin/editor/panels/settings/StickyControl.tsx +97 -0
- package/src/admin/editor/panels/settings/StyleRow.tsx +14 -0
- package/src/admin/editor/panels/settings/style-sections.ts +19 -2
- package/src/admin/editor/panels/url-rules.ts +43 -0
- package/src/admin/editor/panels/use-layers-drop.ts +232 -0
- package/src/admin/editor/store.ts +4 -2
- package/src/admin/editor/useExtensions.ts +3 -1
- package/src/admin/editor/useNodeActions.ts +74 -1
- package/src/admin/editor/useSave.ts +116 -85
- package/src/admin/export-api.ts +25 -2
- package/src/admin/extension-outputs.ts +179 -0
- package/src/admin/font-files-api.ts +38 -0
- package/src/admin/pages/ImportButton.tsx +15 -4
- package/src/admin/pages/ImportElementorDialog.tsx +22 -188
- package/src/admin/pages/ImportHtmlDialog.tsx +209 -0
- package/src/admin/pages/ImportImageCopies.tsx +167 -0
- package/src/admin/pages/ImportReport.tsx +63 -0
- package/src/admin/pages/NewPageDialog.tsx +54 -32
- package/src/admin/pages/PageList.tsx +9 -0
- package/src/admin/pages/ThemePartList.tsx +9 -0
- package/src/astro/EmVBPage.astro +5 -2
- package/src/astro/extension-styles.ts +35 -0
- package/src/astro/forms/EmVBFormsClient.astro +3 -0
- package/src/astro/forms/enhance.ts +107 -0
- package/src/astro/popups/runtime.ts +47 -2
- package/src/astro/render.ts +19 -4
- package/src/astro/resolve-theme.ts +11 -4
- package/src/astro/widgets/EmVBStickyRuntime.astro +9 -0
- package/src/astro/widgets/EmVBThemeRuntime.astro +9 -0
- package/src/astro/widgets/EmVBWidgetRuntimes.astro +12 -0
- package/src/astro/widgets/alerts.ts +16 -2
- package/src/astro/widgets/carousel.ts +65 -24
- package/src/astro/widgets/countdown.ts +18 -7
- package/src/astro/widgets/extension-runtimes.ts +27 -0
- package/src/astro/widgets/headline.ts +14 -5
- package/src/astro/widgets/sticky.ts +87 -0
- package/src/astro/widgets/theme.ts +52 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +150 -2
- package/src/core/arrange.ts +19 -1
- package/src/core/css/font-face.ts +72 -0
- package/src/core/css/generate.ts +35 -1
- package/src/core/elements/form-elements.ts +119 -9
- package/src/core/elements/icon-svg.ts +14 -0
- package/src/core/elements/index.ts +24 -4
- package/src/core/elements/input-limits.ts +44 -0
- package/src/core/elements/menu.ts +109 -47
- package/src/core/elements/site.ts +108 -0
- package/src/core/elements/widgets.ts +13 -3
- package/src/core/export/runtimes.generated.ts +7 -5
- package/src/core/export/site.ts +50 -4
- package/src/core/extensions/classes.ts +114 -0
- package/src/core/extensions/index.ts +17 -2
- package/src/core/extensions/normalize.ts +13 -0
- package/src/core/extensions/registry.ts +134 -10
- package/src/core/extensions/render-ext.ts +66 -21
- package/src/core/extensions/safe-nodes.ts +67 -11
- package/src/core/extensions/types.ts +48 -1
- package/src/core/fonts/files.ts +74 -0
- package/src/core/fonts/google.ts +112 -0
- package/src/core/fonts/test-font.ts +9 -0
- package/src/core/import/elementor/context.ts +13 -4
- package/src/core/import/elementor/index.ts +32 -21
- package/src/core/import/elementor/widgets.ts +114 -12
- package/src/core/import/html/blocks.ts +602 -0
- package/src/core/import/html/index.ts +155 -0
- package/src/core/import/html/map.ts +958 -0
- package/src/core/import/html/parse.ts +430 -0
- package/src/core/index.ts +45 -0
- package/src/core/migrate/v18.ts +3 -0
- package/src/core/public-attributes.ts +17 -0
- package/src/core/render/extras.ts +31 -7
- package/src/core/render/form.ts +103 -10
- package/src/core/render/index.ts +151 -15
- package/src/core/render/section.ts +31 -1
- package/src/core/render/spacer-basis.ts +102 -0
- package/src/core/render/theme-boot.ts +16 -0
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +68 -3
- package/src/core/sanitize/motion.ts +12 -0
- package/src/core/schema/design.ts +40 -0
- package/src/core/schema/layout.ts +114 -5
- package/src/core/schema/style.ts +28 -0
- package/src/core/templates/index.ts +218 -0
- package/src/core/templates/pages.ts +29 -0
- package/src/core/templates/sections.ts +794 -0
- package/src/core/templates/types.ts +9 -0
- package/src/core/theme/dynamic.ts +9 -6
- package/src/core/theme/popup-markup.ts +21 -2
- package/src/core/theme/popup-rules.ts +36 -0
- package/src/core/theme/triggers.ts +64 -5
- package/src/core/translatable.ts +5 -2
- package/src/extension-build.ts +331 -0
- package/src/index.ts +25 -3
- package/src/mcp/brief.ts +191 -0
- package/src/mcp/prompts.ts +33 -0
- package/src/mcp/read.ts +29 -1
- package/src/mcp/tools.ts +40 -1
- package/src/mcp/write.ts +41 -1
- package/src/server/extension-routes.ts +73 -0
- package/src/server/font-routes.ts +301 -0
- package/src/server/plugin.ts +9 -0
package/src/core/sanitize/css.ts
CHANGED
|
@@ -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
|
-
|
|
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 = [
|
|
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
|
-
|
|
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
|
|
|
@@ -796,6 +848,9 @@ export const KNOWN_ELEMENT_TYPES = [
|
|
|
796
848
|
"share-link",
|
|
797
849
|
"hotspots",
|
|
798
850
|
"hotspot",
|
|
851
|
+
"search-form",
|
|
852
|
+
"theme-toggle",
|
|
853
|
+
"form-step",
|
|
799
854
|
] as const;
|
|
800
855
|
|
|
801
856
|
/** Headings on this page, as a list of links. No script (W-345). */
|
|
@@ -1388,6 +1443,33 @@ export const HotspotNode = leafNode(
|
|
|
1388
1443
|
}),
|
|
1389
1444
|
);
|
|
1390
1445
|
|
|
1446
|
+
/**
|
|
1447
|
+
* W-1073: a site search box: a plain GET form to `action` (unset "/search", the page EmDash's
|
|
1448
|
+
* own Search widget and site templates use) with the words in `q`. No script. `label` names the
|
|
1449
|
+
* field and the search landmark for screen readers (unset "Search"); `buttonText` unset "Search".
|
|
1450
|
+
*/
|
|
1451
|
+
export const SearchFormNode = leafNode(
|
|
1452
|
+
"search-form",
|
|
1453
|
+
z.strictObject({
|
|
1454
|
+
action: z.string().max(500).optional(),
|
|
1455
|
+
label: z.string().max(80).optional(),
|
|
1456
|
+
placeholder: z.string().max(120).optional(),
|
|
1457
|
+
buttonText: z.string().max(40).optional(),
|
|
1458
|
+
}),
|
|
1459
|
+
);
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* W-1067: a button that switches the site between light and dark (colour variables' dark
|
|
1463
|
+
* values), remembered on the visitor's browser. It needs the opt-in theme runtime, so without it
|
|
1464
|
+
* the button stays hidden. `label` is its text (unset "Dark mode"); it is a toggle (aria-pressed).
|
|
1465
|
+
*/
|
|
1466
|
+
export const ThemeToggleNode = leafNode(
|
|
1467
|
+
"theme-toggle",
|
|
1468
|
+
z.strictObject({
|
|
1469
|
+
label: z.string().max(40).optional(),
|
|
1470
|
+
}),
|
|
1471
|
+
);
|
|
1472
|
+
|
|
1391
1473
|
const knownTypeSet = new Set<string>(KNOWN_ELEMENT_TYPES);
|
|
1392
1474
|
|
|
1393
1475
|
/**
|
|
@@ -1441,6 +1523,8 @@ const KnownLayoutNode = z.discriminatedUnion("type", [
|
|
|
1441
1523
|
ShareLinkNode,
|
|
1442
1524
|
HotspotsNodeSchema,
|
|
1443
1525
|
HotspotNode,
|
|
1526
|
+
SearchFormNode,
|
|
1527
|
+
ThemeToggleNode,
|
|
1444
1528
|
CounterNode,
|
|
1445
1529
|
ProgressNode,
|
|
1446
1530
|
CountdownNode,
|
|
@@ -1457,6 +1541,7 @@ const KnownLayoutNode = z.discriminatedUnion("type", [
|
|
|
1457
1541
|
IconNode,
|
|
1458
1542
|
VideoNode,
|
|
1459
1543
|
FormNode,
|
|
1544
|
+
FormStepNode,
|
|
1460
1545
|
TextInputNode,
|
|
1461
1546
|
TextareaNode,
|
|
1462
1547
|
SelectNode,
|
|
@@ -1499,6 +1584,8 @@ export type FlipBoxNode = z.infer<typeof FlipBoxNode>;
|
|
|
1499
1584
|
export type HeadlineNode = z.infer<typeof HeadlineNode>;
|
|
1500
1585
|
export type ShareLinkNode = z.infer<typeof ShareLinkNode>;
|
|
1501
1586
|
export type HotspotNode = z.infer<typeof HotspotNode>;
|
|
1587
|
+
export type SearchFormNode = z.infer<typeof SearchFormNode>;
|
|
1588
|
+
export type ThemeToggleNode = z.infer<typeof ThemeToggleNode>;
|
|
1502
1589
|
export type IconBoxNode = z.infer<typeof IconBoxNode>;
|
|
1503
1590
|
export type ImageBoxNode = z.infer<typeof ImageBoxNode>;
|
|
1504
1591
|
export type TestimonialNode = z.infer<typeof TestimonialNode>;
|
|
@@ -1633,7 +1720,13 @@ export type TabsNode = NodeEnvelope & {
|
|
|
1633
1720
|
|
|
1634
1721
|
export type FormNode = NodeEnvelope & {
|
|
1635
1722
|
type: "form";
|
|
1636
|
-
props: { formId: string };
|
|
1723
|
+
props: { formId: string; nextLabel?: string; prevLabel?: string };
|
|
1724
|
+
children: LayoutNode[];
|
|
1725
|
+
};
|
|
1726
|
+
|
|
1727
|
+
export type FormStepNode = NodeEnvelope & {
|
|
1728
|
+
type: "form-step";
|
|
1729
|
+
props: { title?: string };
|
|
1637
1730
|
children: LayoutNode[];
|
|
1638
1731
|
};
|
|
1639
1732
|
|
|
@@ -1719,7 +1812,14 @@ export type MenuNode = NodeEnvelope & {
|
|
|
1719
1812
|
|
|
1720
1813
|
export type MenuItemNode = NodeEnvelope & {
|
|
1721
1814
|
type: "menu-item";
|
|
1722
|
-
props: {
|
|
1815
|
+
props: {
|
|
1816
|
+
text: string;
|
|
1817
|
+
href?: string;
|
|
1818
|
+
newTab?: boolean;
|
|
1819
|
+
wide?: boolean;
|
|
1820
|
+
panelPartId?: string;
|
|
1821
|
+
panelWidth?: z.infer<typeof Length>;
|
|
1822
|
+
};
|
|
1723
1823
|
children: LayoutNode[];
|
|
1724
1824
|
};
|
|
1725
1825
|
|
|
@@ -1739,6 +1839,7 @@ export type LayoutNode =
|
|
|
1739
1839
|
| TabsNode
|
|
1740
1840
|
| TabPanelNode
|
|
1741
1841
|
| FormNode
|
|
1842
|
+
| FormStepNode
|
|
1742
1843
|
| LoopNode
|
|
1743
1844
|
| LoopEmptyNode
|
|
1744
1845
|
| SectionNode
|
|
@@ -1770,6 +1871,8 @@ export type LayoutNode =
|
|
|
1770
1871
|
| ShareLinkNode
|
|
1771
1872
|
| HotspotsNode
|
|
1772
1873
|
| HotspotNode
|
|
1874
|
+
| SearchFormNode
|
|
1875
|
+
| ThemeToggleNode
|
|
1773
1876
|
| SpacerNode
|
|
1774
1877
|
| DividerNode
|
|
1775
1878
|
| TextNode
|
|
@@ -1910,6 +2013,8 @@ export const isContainerNode = (node: LayoutNode): node is ContainerNode =>
|
|
|
1910
2013
|
|
|
1911
2014
|
export const isFormNode = (node: LayoutNode): node is FormNode => node.type === "form";
|
|
1912
2015
|
|
|
2016
|
+
export const isFormStepNode = (node: LayoutNode): node is FormStepNode => node.type === "form-step";
|
|
2017
|
+
|
|
1913
2018
|
export const isLoopNode = (node: LayoutNode): node is LoopNode => node.type === "loop";
|
|
1914
2019
|
|
|
1915
2020
|
/**
|
|
@@ -1949,7 +2054,8 @@ export const isLayoutParentNode = (
|
|
|
1949
2054
|
| LoopEmptyNode
|
|
1950
2055
|
| AccordionItemNode
|
|
1951
2056
|
| MenuItemNode
|
|
1952
|
-
| CarouselSlideNode
|
|
2057
|
+
| CarouselSlideNode
|
|
2058
|
+
| FormStepNode =>
|
|
1953
2059
|
node.type === "container" ||
|
|
1954
2060
|
node.type === "div-block" ||
|
|
1955
2061
|
node.type === "layout-section" ||
|
|
@@ -1960,7 +2066,8 @@ export const isLayoutParentNode = (
|
|
|
1960
2066
|
node.type === "loop-empty" ||
|
|
1961
2067
|
node.type === "accordion-item" ||
|
|
1962
2068
|
node.type === "menu-item" ||
|
|
1963
|
-
node.type === "carousel-slide"
|
|
2069
|
+
node.type === "carousel-slide" ||
|
|
2070
|
+
node.type === "form-step";
|
|
1964
2071
|
|
|
1965
2072
|
/** Nodes that may hold children. */
|
|
1966
2073
|
export const isParentNode = (
|
|
@@ -1972,6 +2079,7 @@ export const isParentNode = (
|
|
|
1972
2079
|
| FlexboxNode
|
|
1973
2080
|
| GridNode
|
|
1974
2081
|
| FormNode
|
|
2082
|
+
| FormStepNode
|
|
1975
2083
|
| LoopNode
|
|
1976
2084
|
| LoopEmptyNode
|
|
1977
2085
|
| SectionNode
|
|
@@ -1994,6 +2102,7 @@ export const isParentNode = (
|
|
|
1994
2102
|
node.type === "flexbox" ||
|
|
1995
2103
|
node.type === "grid" ||
|
|
1996
2104
|
node.type === "form" ||
|
|
2105
|
+
node.type === "form-step" ||
|
|
1997
2106
|
node.type === "loop" ||
|
|
1998
2107
|
node.type === "loop-empty" ||
|
|
1999
2108
|
node.type === "part-ref" ||
|
package/src/core/schema/style.ts
CHANGED
|
@@ -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;
|