@perkyzz/emvb 0.9.0 → 1.1.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 (187) hide show
  1. package/README.md +10 -1
  2. package/package.json +2 -2
  3. package/src/admin/agents-api.ts +45 -0
  4. package/src/admin/bulk-api.ts +67 -0
  5. package/src/admin/content-api.ts +10 -6
  6. package/src/admin/copy-rich-text.ts +119 -0
  7. package/src/admin/dialog-tab-wrap.ts +78 -0
  8. package/src/admin/editor/A11yCopilot.tsx +3 -1
  9. package/src/admin/editor/Editor.tsx +311 -250
  10. package/src/admin/editor/Timeline.tsx +8 -3
  11. package/src/admin/editor/TopBar.tsx +29 -7
  12. package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
  13. package/src/admin/editor/canvas/DeviceBar.tsx +31 -10
  14. package/src/admin/editor/canvas/canvas-scale.ts +3 -3
  15. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  16. package/src/admin/editor/co-design.ts +190 -0
  17. package/src/admin/editor/dnd/new-element.ts +48 -4
  18. package/src/admin/editor/editor-chrome.tsx +8 -6
  19. package/src/admin/editor/editor-commands.ts +15 -4
  20. package/src/admin/editor/editor-css.ts +2 -1
  21. package/src/admin/editor/element-chrome.ts +3 -1
  22. package/src/admin/editor/extension-manifests.ts +20 -0
  23. package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
  24. package/src/admin/editor/extensions-context.tsx +27 -0
  25. package/src/admin/editor/feature-css.ts +17 -0
  26. package/src/admin/editor/palette-items.ts +2 -2
  27. package/src/admin/editor/panels/AddPanel.tsx +31 -1
  28. package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
  29. package/src/admin/editor/panels/ClassesSection.tsx +9 -6
  30. package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
  31. package/src/admin/editor/panels/ColorControl.tsx +2 -2
  32. package/src/admin/editor/panels/ElementPanel.tsx +68 -20
  33. package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
  34. package/src/admin/editor/panels/LayersPanel.tsx +10 -6
  35. package/src/admin/editor/panels/LeftPanel.tsx +33 -5
  36. package/src/admin/editor/panels/PageSettings.tsx +4 -0
  37. package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
  38. package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
  39. package/src/admin/editor/panels/settings/BackgroundControls.tsx +72 -15
  40. package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
  41. package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
  42. package/src/admin/editor/panels/settings/EffectsControls.tsx +183 -10
  43. package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
  44. package/src/admin/editor/panels/settings/IconControls.tsx +25 -11
  45. package/src/admin/editor/panels/settings/LengthRow.tsx +63 -19
  46. package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
  47. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +19 -1
  48. package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
  49. package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
  50. package/src/admin/editor/panels/settings/StyleRow.tsx +120 -13
  51. package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
  52. package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
  53. package/src/admin/editor/panels/settings/background-mode.ts +14 -11
  54. package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
  55. package/src/admin/editor/panels/settings/box-sides.ts +22 -14
  56. package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
  57. package/src/admin/editor/panels/settings/length-units.ts +68 -4
  58. package/src/admin/editor/panels/settings/query-style.ts +3 -3
  59. package/src/admin/editor/panels/settings/style-sections.ts +52 -10
  60. package/src/admin/editor/panels/style-target.ts +22 -7
  61. package/src/admin/editor/presence.ts +60 -0
  62. package/src/admin/editor/section-templates.ts +26 -4
  63. package/src/admin/editor/store.ts +14 -4
  64. package/src/admin/editor/useCoDesign.ts +177 -0
  65. package/src/admin/editor/useEditorCommands.ts +7 -5
  66. package/src/admin/editor/useExtensions.ts +45 -0
  67. package/src/admin/editor/useNodeActions.ts +18 -7
  68. package/src/admin/editor/useProposals.ts +81 -0
  69. package/src/admin/export-api.ts +221 -0
  70. package/src/admin/index.tsx +6 -1
  71. package/src/admin/languages-api.ts +61 -0
  72. package/src/admin/pages/AgentSetup.tsx +148 -0
  73. package/src/admin/pages/AgentsPage.tsx +9 -26
  74. package/src/admin/pages/CreateDialog.tsx +15 -0
  75. package/src/admin/pages/ExportDialog.tsx +395 -0
  76. package/src/admin/pages/ImportButton.tsx +18 -0
  77. package/src/admin/pages/ImportElementorDialog.tsx +669 -0
  78. package/src/admin/pages/ImportPageLinks.tsx +86 -0
  79. package/src/admin/pages/PageList.tsx +82 -3
  80. package/src/admin/pages/ThemePartList.tsx +52 -2
  81. package/src/admin/pages/bulk.tsx +303 -0
  82. package/src/admin/pages/section-head.tsx +27 -0
  83. package/src/admin/proposals-api.ts +91 -0
  84. package/src/admin/search.ts +20 -0
  85. package/src/admin/theme-api.ts +4 -0
  86. package/src/admin/ui.ts +50 -4
  87. package/src/admin/widgets/CanvasField.tsx +8 -0
  88. package/src/admin/widgets/ConvertToRichText.tsx +136 -0
  89. package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
  90. package/src/admin/widgets/convert-body.ts +73 -2
  91. package/src/astro/content-port.ts +14 -1
  92. package/src/astro/render.ts +6 -6
  93. package/src/astro/resolve-theme.ts +25 -8
  94. package/src/astro/resolve.ts +89 -2
  95. package/src/astro/tabs/runtime.ts +16 -6
  96. package/src/constants.ts +1 -1
  97. package/src/core/a11y/audit.ts +45 -14
  98. package/src/core/arrange.ts +5 -1
  99. package/src/core/bounded-array.ts +31 -0
  100. package/src/core/clipboard.ts +9 -0
  101. package/src/core/contract.ts +305 -0
  102. package/src/core/css/generate.ts +151 -20
  103. package/src/core/css/scope.ts +10 -2
  104. package/src/core/css/trace.ts +47 -13
  105. package/src/core/css-keywords.ts +51 -1
  106. package/src/core/design/cascade.ts +12 -9
  107. package/src/core/design/classes.ts +28 -9
  108. package/src/core/design/devices.ts +89 -13
  109. package/src/core/design/states.ts +5 -3
  110. package/src/core/design/transfer.ts +5 -0
  111. package/src/core/design/variables.ts +31 -5
  112. package/src/core/elements/dynamic-elements.ts +3 -3
  113. package/src/core/elements/index.ts +73 -9
  114. package/src/core/export/runtimes.generated.ts +9 -0
  115. package/src/core/export/site.ts +562 -0
  116. package/src/core/export/zip.ts +95 -0
  117. package/src/core/extensions/define.ts +13 -0
  118. package/src/core/extensions/index.ts +41 -0
  119. package/src/core/extensions/namespace.ts +82 -0
  120. package/src/core/extensions/normalize.ts +141 -0
  121. package/src/core/extensions/placeholder.ts +41 -0
  122. package/src/core/extensions/registry.ts +94 -0
  123. package/src/core/extensions/render-ext.ts +118 -0
  124. package/src/core/extensions/safe-nodes.ts +93 -0
  125. package/src/core/extensions/schema.ts +112 -0
  126. package/src/core/extensions/types.ts +159 -0
  127. package/src/core/forms/binding.ts +1 -1
  128. package/src/core/history/diff.ts +26 -1
  129. package/src/core/import/elementor/atomic.ts +1608 -0
  130. package/src/core/import/elementor/classes.ts +127 -0
  131. package/src/core/import/elementor/context.ts +429 -0
  132. package/src/core/import/elementor/counter-steps.ts +72 -0
  133. package/src/core/import/elementor/css.ts +445 -0
  134. package/src/core/import/elementor/html.ts +500 -0
  135. package/src/core/import/elementor/index.ts +967 -0
  136. package/src/core/import/elementor/inline-marks.ts +81 -0
  137. package/src/core/import/elementor/snapshots.ts +48 -0
  138. package/src/core/import/elementor/style.ts +429 -0
  139. package/src/core/import/elementor/values.ts +241 -0
  140. package/src/core/import/elementor/widgets.ts +1897 -0
  141. package/src/core/index.ts +96 -0
  142. package/src/core/json-schema.ts +114 -0
  143. package/src/core/limits.ts +19 -0
  144. package/src/core/migrate/index.ts +6 -1
  145. package/src/core/migrate/v18.ts +222 -0
  146. package/src/core/perf/meter.ts +42 -24
  147. package/src/core/portable-text-export.ts +243 -0
  148. package/src/core/proposals-safety.ts +102 -0
  149. package/src/core/proposals.ts +357 -0
  150. package/src/core/public-attributes.ts +30 -0
  151. package/src/core/recipes/index.ts +2 -2
  152. package/src/core/render/extras.ts +3 -3
  153. package/src/core/render/index.ts +222 -23
  154. package/src/core/render/loop.ts +1 -1
  155. package/src/core/render/section.ts +4 -4
  156. package/src/core/render/tabs.ts +18 -11
  157. package/src/core/render/vnode.ts +1 -1
  158. package/src/core/sanitize/css.ts +151 -10
  159. package/src/core/sanitize/motion.ts +116 -0
  160. package/src/core/saved-sections.ts +6 -0
  161. package/src/core/schema/descriptors.ts +3 -1
  162. package/src/core/schema/design.ts +4 -3
  163. package/src/core/schema/layout.ts +92 -16
  164. package/src/core/schema/style.ts +296 -112
  165. package/src/core/search-text.ts +70 -0
  166. package/src/core/text-marks.ts +227 -0
  167. package/src/core/theme/dynamic.ts +9 -4
  168. package/src/core/theme/float.ts +2 -0
  169. package/src/core/theme/popup-rules.ts +33 -1
  170. package/src/core/translatable.ts +34 -0
  171. package/src/core/validate.ts +13 -1
  172. package/src/index.ts +24 -0
  173. package/src/mcp/errors.ts +3 -1
  174. package/src/mcp/ports.ts +67 -0
  175. package/src/mcp/prompts.ts +1 -11
  176. package/src/mcp/proposals.ts +281 -0
  177. package/src/mcp/read.ts +10 -10
  178. package/src/mcp/tools.ts +71 -3
  179. package/src/mcp/write.ts +66 -11
  180. package/src/server/agent-settings.ts +5 -1
  181. package/src/server/icon-routes.ts +52 -12
  182. package/src/server/mcp-routes.ts +15 -0
  183. package/src/server/plugin.ts +35 -2
  184. package/src/server/presence.ts +78 -0
  185. package/src/server/proposals.ts +261 -0
  186. package/src/server/requests.ts +196 -0
  187. package/src/server/tools-served.ts +45 -0
@@ -1,14 +1,19 @@
1
1
  import { DropdownMenu, InputGroup } from "@cloudflare/kumo";
2
2
  import { CaretDownIcon } from "@phosphor-icons/react";
3
3
  import * as React from "react";
4
- import type { DesignSystem, StyleProps } from "../../../../core/index.ts";
4
+ import type { DesignSystem, FlatStyleProps } from "../../../../core/index.ts";
5
5
  import { FIELD } from "../../../ui.ts";
6
6
  import {
7
+ fluidDraft,
8
+ isFluid,
7
9
  parseLengthDraft,
10
+ takesFluid,
8
11
  unitsFor,
12
+ type FluidLiteral,
9
13
  type LengthLiteral,
10
14
  type LengthUnit,
11
15
  type UnitChoice,
16
+ isViewportUnit,
12
17
  } from "./length-units.ts";
13
18
  import type { StyleKey } from "./style-sections.ts";
14
19
  import { bindKind, boundRef, lengthRef, VariableButton, VariableChip } from "./VariableBinding.tsx";
@@ -21,7 +26,9 @@ const isLiteral = (value: unknown): value is LengthLiteral =>
21
26
  typeof (value as { unit?: unknown }).unit === "string";
22
27
 
23
28
  const same = (a: unknown, b: unknown) =>
24
- a === b || (isLiteral(a) && isLiteral(b) && a.value === b.value && a.unit === b.unit);
29
+ a === b ||
30
+ (isLiteral(a) && isLiteral(b) && a.value === b.value && a.unit === b.unit) ||
31
+ (isFluid(a) && isFluid(b) && a.fluid.min === b.fluid.min && a.fluid.max === b.fluid.max);
25
32
 
26
33
  type NumericUnit = LengthUnit | "x";
27
34
 
@@ -39,6 +46,7 @@ export function LengthRow({
39
46
  slider = false,
40
47
  onPatch,
41
48
  reset,
49
+ viewportUnits,
42
50
  }: {
43
51
  styleKey: StyleKey;
44
52
  label: string;
@@ -49,31 +57,65 @@ export function LengthRow({
49
57
  placeholder?: string;
50
58
  /** Gap: a slider for the common range. The number field still accepts the full length. */
51
59
  slider?: boolean;
52
- onPatch: (patch: Partial<StyleProps>) => void;
60
+ onPatch: (patch: Partial<FlatStyleProps>) => void;
53
61
  reset: React.ReactNode;
62
+ /** W-974: the record's dvh/svh marks; a marked `vh` length shows as that unit. */
63
+ viewportUnits?: FlatStyleProps["viewportUnits"];
54
64
  }) {
55
65
  const units = unitsFor(styleKey);
56
66
  // W-213: a plain number is a unitless line height, shown with the `x` unit.
57
67
  // W-603: memoized, so a plain number doesn't make a new object each render; the effect below
58
68
  // would reset the draft on every keystroke and nothing typed over a unitless value would stick.
69
+ const marked = viewportUnits?.[styleKey as keyof NonNullable<typeof viewportUnits>];
59
70
  const literal = React.useMemo<{ value: number; unit: NumericUnit } | undefined>(
60
- () => (isLiteral(value) ? value : typeof value === "number" ? { value, unit: "x" } : undefined),
61
- [value],
71
+ () =>
72
+ isLiteral(value)
73
+ ? value.unit === "vh" && marked
74
+ ? { value: value.value, unit: marked }
75
+ : value
76
+ : typeof value === "number"
77
+ ? { value, unit: "x" }
78
+ : undefined,
79
+ [value, marked],
62
80
  );
63
- const numericUnit = literal?.unit ?? firstNumeric(units);
64
- const [draft, setDraft] = React.useState(literal ? String(literal.value) : "");
81
+ // W-955: a fluid size shows as "32–56" in px.
82
+ const fluid = isFluid(value) ? value : undefined;
83
+ const textOf = (): string => (fluid ? fluidDraft(fluid) : literal ? String(literal.value) : "");
84
+ const numericUnit = literal?.unit ?? (fluid ? "px" : firstNumeric(units));
85
+ const [draft, setDraft] = React.useState(textOf);
65
86
  const [unit, setUnit] = React.useState<UnitChoice>(value === "auto" ? "auto" : numericUnit);
66
87
  const lastNumeric = React.useRef<NumericUnit>(numericUnit);
67
88
  const [error, setError] = React.useState<string | null>(null);
68
89
  React.useEffect(() => {
69
- setDraft(literal ? String(literal.value) : "");
70
- setUnit(value === "auto" ? "auto" : (literal?.unit ?? lastNumeric.current));
90
+ setDraft(textOf());
91
+ setUnit(value === "auto" ? "auto" : (literal?.unit ?? (fluid ? "px" : lastNumeric.current)));
71
92
  if (literal) lastNumeric.current = literal.unit;
72
93
  setError(null);
73
94
  }, [value, literal]);
74
95
 
75
- const send = (next: LengthLiteral | "auto" | number | undefined) => {
76
- if (!same(next, value)) onPatch({ [styleKey]: next });
96
+ const send = (next: LengthLiteral | FluidLiteral | "auto" | number | undefined) => {
97
+ // W-974: dvh and svh are stored as vh plus the record's mark, so 1.0 still draws vh.
98
+ const nextUnit = isLiteral(next) ? next.unit : undefined;
99
+ const stored =
100
+ isLiteral(next) && isViewportUnit(nextUnit)
101
+ ? { value: next.value, unit: "vh" as const }
102
+ : next;
103
+ const marks = { ...viewportUnits } as Record<string, string>;
104
+ if (isViewportUnit(nextUnit)) marks[styleKey] = nextUnit;
105
+ else delete marks[styleKey];
106
+ const marksChanged = (marks[styleKey] ?? null) !== (marked ?? null);
107
+ if (same(stored, value) && !marksChanged) return;
108
+ onPatch({
109
+ [styleKey]: stored,
110
+ ...(marksChanged
111
+ ? {
112
+ viewportUnits:
113
+ Object.keys(marks).length > 0
114
+ ? (marks as FlatStyleProps["viewportUnits"])
115
+ : undefined,
116
+ }
117
+ : {}),
118
+ });
77
119
  };
78
120
 
79
121
  const commit = () => {
@@ -97,13 +139,15 @@ export function LengthRow({
97
139
  }
98
140
  lastNumeric.current = next;
99
141
  const parsed = parseLengthDraft(draft, styleKey, next);
100
- if (parsed.ok && parsed.value !== undefined && parsed.value !== "auto") {
101
- const n = typeof parsed.value === "number" ? parsed.value : parsed.value.value;
102
- if (next === "x") {
103
- if (n <= 100) send(n);
104
- else setError("Line height without a unit can be from 0 to 100.");
105
- } else send({ value: n, unit: next });
106
- }
142
+ if (!parsed.ok) return;
143
+ const typed = parsed.value;
144
+ // A fluid range is always px; the unit menu leaves it as it is.
145
+ if (typed === undefined || typed === "auto" || isFluid(typed)) return;
146
+ const n = typeof typed === "number" ? typed : typed.value;
147
+ if (next === "x") {
148
+ if (n <= 100) send(n);
149
+ else setError("Line height without a unit can be from 0 to 100.");
150
+ } else send({ value: n, unit: next });
107
151
  };
108
152
 
109
153
  const kind = bindKind(styleKey);
@@ -140,7 +184,7 @@ export function LengthRow({
140
184
  placeholder={unit === "auto" ? "auto" : placeholder}
141
185
  title={`A number in ${unit === "auto" ? lastNumeric.current : unit}, or with its own unit (2rem, 50%)${
142
186
  units.includes("auto") ? ", or auto" : ""
143
- }`}
187
+ }${takesFluid(styleKey) ? ". A range such as 32–56 grows from phones to large screens (px)" : ""}`}
144
188
  aria-invalid={error ? true : undefined}
145
189
  onChange={(event) => {
146
190
  if (unit === "auto") setUnit(lastNumeric.current);
@@ -0,0 +1,269 @@
1
+ import { Button, DropdownMenu } from "@cloudflare/kumo";
2
+ import { PlusIcon, XIcon } from "@phosphor-icons/react";
3
+ import type * as React from "react";
4
+ import { MOTION_EFFECTS, type FlatStyleProps } from "../../../../core/index.ts";
5
+ import { BUTTON } from "../../../ui.ts";
6
+ import { TransitionSelect } from "./EffectsControls.tsx";
7
+ import { HintedSwitch } from "./HintedSwitch.tsx";
8
+ import { EFFECT_LABELS, specFor } from "./MotionControl.tsx";
9
+ import { NumberField, type NumberSpec } from "./NumberRow.tsx";
10
+
11
+ type Loop = NonNullable<FlatStyleProps["loopMotion"]>;
12
+ type Playing = Extract<Loop, { effects: unknown }>;
13
+ type Effect = Playing["effects"][number];
14
+ type Easing = NonNullable<Playing["easing"]>;
15
+
16
+ const DURATION: NumberSpec = {
17
+ min: 200,
18
+ max: 20_000,
19
+ integer: true,
20
+ example: "1600",
21
+ suffix: "ms",
22
+ };
23
+
24
+ const EASINGS: { value: Easing; label: string }[] = [
25
+ { value: "ease-in-out", label: "Smooth" },
26
+ { value: "ease", label: "Ease" },
27
+ { value: "ease-in", label: "Speed up" },
28
+ { value: "ease-out", label: "Slow down" },
29
+ { value: "linear", label: "Steady" },
30
+ ];
31
+
32
+ /**
33
+ * Ready-made loops (W-939). Each is a plain value: pick one, then tune it. They play back and
34
+ * forth, except Spin, which turns all the way round.
35
+ */
36
+ export const LOOP_PRESETS: { id: string; label: string; value: Playing }[] = [
37
+ {
38
+ id: "float",
39
+ label: "Float",
40
+ value: { duration: 1600, effects: [{ type: "move-y", from: 0, to: -8 }] },
41
+ },
42
+ {
43
+ id: "pulse",
44
+ label: "Pulse",
45
+ value: { duration: 900, effects: [{ type: "scale", from: 100, to: 106 }] },
46
+ },
47
+ {
48
+ id: "breathe",
49
+ label: "Breathe",
50
+ value: { duration: 1800, effects: [{ type: "fade", from: 100, to: 60 }] },
51
+ },
52
+ {
53
+ id: "wiggle",
54
+ label: "Wiggle",
55
+ value: { duration: 300, effects: [{ type: "rotate", from: -3, to: 3 }] },
56
+ },
57
+ {
58
+ id: "drift",
59
+ label: "Drift sideways",
60
+ value: { duration: 2400, effects: [{ type: "move-x", from: -6, to: 6 }] },
61
+ },
62
+ {
63
+ id: "spin",
64
+ label: "Spin",
65
+ value: {
66
+ duration: 2000,
67
+ easing: "linear",
68
+ alternate: false,
69
+ effects: [{ type: "rotate", from: 0, to: 360 }],
70
+ },
71
+ },
72
+ ];
73
+
74
+ const presetOf = (value: Playing): string => {
75
+ const { loop: _loop, ...rest } = value;
76
+ const key = JSON.stringify(rest);
77
+ return LOOP_PRESETS.find((p) => JSON.stringify(p.value) === key)?.id ?? "custom";
78
+ };
79
+
80
+ /**
81
+ * A looping animation (W-938, W-939, Normal only): a preset, its speed and each effect's two ends.
82
+ * Plays back and forth unless turned off; stops after about 5 seconds unless it loops forever
83
+ * (D-057, D-059); never for visitors who prefer reduced motion. Plays live on the canvas.
84
+ */
85
+ export function LoopControl({
86
+ value,
87
+ onChange,
88
+ reset,
89
+ }: {
90
+ value: Loop | undefined;
91
+ onChange: (next: Loop | undefined) => void;
92
+ reset: React.ReactNode;
93
+ }) {
94
+ const playing = value && "effects" in value ? value : undefined;
95
+ const update = (patch: Partial<Playing>) => playing && onChange({ ...playing, ...patch });
96
+ const setEffects = (effects: Effect[]) => {
97
+ if (!playing) return;
98
+ onChange(effects.length > 0 ? { ...playing, effects } : undefined);
99
+ };
100
+ const unused = MOTION_EFFECTS.filter((t) => !playing?.effects.some((e) => e.type === t));
101
+ const presetOptions = [
102
+ ...LOOP_PRESETS.map((p) => ({ value: p.id, label: p.label })),
103
+ ...(playing && presetOf(playing) === "custom" ? [{ value: "custom", label: "Custom" }] : []),
104
+ ];
105
+ return (
106
+ <div
107
+ className="emvb-style-row"
108
+ data-emvb-style="loopMotion"
109
+ data-set={value ? "true" : undefined}
110
+ >
111
+ <div className="emvb-field-group emvb-transition emvb-motion">
112
+ <span className="emvb-var-field-label">Loop</span>
113
+ {value && !playing && (
114
+ <p className="emvb-helper" data-emvb-loop-off="">
115
+ Off on this screen.
116
+ </p>
117
+ )}
118
+ {playing && (
119
+ <>
120
+ <TransitionSelect
121
+ label="Motion"
122
+ value={presetOf(playing)}
123
+ options={presetOptions}
124
+ onChange={(id) => {
125
+ const preset = LOOP_PRESETS.find((p) => p.id === id);
126
+ if (preset)
127
+ onChange({
128
+ ...structuredClone(preset.value),
129
+ ...(playing.loop ? { loop: true as const } : {}),
130
+ });
131
+ }}
132
+ />
133
+ <NumberField
134
+ fieldKey="loopMotion.duration"
135
+ label="Duration"
136
+ value={playing.duration}
137
+ spec={DURATION}
138
+ onCommit={(n) => update({ duration: n ?? 1600 })}
139
+ />
140
+ <TransitionSelect
141
+ label="Easing"
142
+ value={playing.easing ?? "ease-in-out"}
143
+ options={EASINGS}
144
+ onChange={(easing) => update({ easing })}
145
+ />
146
+ <HintedSwitch
147
+ label="Back and forth"
148
+ checked={playing.alternate !== false}
149
+ onCheckedChange={(on) => {
150
+ const { alternate: _a, ...rest } = playing;
151
+ onChange(on ? rest : { ...rest, alternate: false });
152
+ }}
153
+ data={{ "data-emvb-loop-alternate": "" }}
154
+ hint="Off: it jumps back to the start each time, as a spin does."
155
+ />
156
+ {playing.effects.map((effect, index) => (
157
+ <div className="emvb-motion-effect" key={effect.type} data-emvb-loop={effect.type}>
158
+ <span className="emvb-motion-name">{EFFECT_LABELS[effect.type].label}</span>
159
+ <NumberField
160
+ fieldKey={`loopMotion.${effect.type}.from`}
161
+ label="From"
162
+ value={effect.from}
163
+ spec={specFor(effect.type)}
164
+ onCommit={(n) =>
165
+ setEffects(
166
+ playing.effects.with(index, {
167
+ ...effect,
168
+ from: n ?? EFFECT_LABELS[effect.type].neutral,
169
+ }),
170
+ )
171
+ }
172
+ />
173
+ <NumberField
174
+ fieldKey={`loopMotion.${effect.type}.to`}
175
+ label="To"
176
+ value={effect.to}
177
+ spec={specFor(effect.type)}
178
+ onCommit={(n) =>
179
+ setEffects(
180
+ playing.effects.with(index, {
181
+ ...effect,
182
+ to: n ?? EFFECT_LABELS[effect.type].neutral,
183
+ }),
184
+ )
185
+ }
186
+ />
187
+ <Button
188
+ type="button"
189
+ variant="ghost"
190
+ shape="square"
191
+ className={BUTTON}
192
+ aria-label={`Remove ${EFFECT_LABELS[effect.type].label}`}
193
+ icon={<XIcon aria-hidden="true" />}
194
+ onClick={() => setEffects(playing.effects.filter((_, i) => i !== index))}
195
+ />
196
+ </div>
197
+ ))}
198
+ {unused.length > 0 && (
199
+ <DropdownMenu>
200
+ <DropdownMenu.Trigger>
201
+ <Button
202
+ type="button"
203
+ variant="secondary"
204
+ className={`${BUTTON} emvb-add-effect`}
205
+ icon={<PlusIcon aria-hidden="true" />}
206
+ >
207
+ Add effect
208
+ </Button>
209
+ </DropdownMenu.Trigger>
210
+ <DropdownMenu.Content data-emvb-add-loop-effect="">
211
+ {unused.map((type) => (
212
+ <DropdownMenu.Item
213
+ key={type}
214
+ onClick={() => {
215
+ const n = EFFECT_LABELS[type].neutral;
216
+ setEffects([...playing.effects, { type, from: n, to: n }]);
217
+ }}
218
+ >
219
+ {EFFECT_LABELS[type].label}
220
+ </DropdownMenu.Item>
221
+ ))}
222
+ </DropdownMenu.Content>
223
+ </DropdownMenu>
224
+ )}
225
+ <HintedSwitch
226
+ label="Loop forever"
227
+ checked={playing.loop === true}
228
+ onCheckedChange={(loop) => {
229
+ const { loop: _old, ...rest } = playing;
230
+ onChange(loop ? { ...rest, loop: true } : rest);
231
+ }}
232
+ data={{ "data-emvb-loop-forever": "" }}
233
+ hint={
234
+ playing.loop
235
+ ? "Keeps going. Moving content that never stops can distract; the accessibility check flags it. Off for visitors who prefer reduced motion."
236
+ : "Stops on its own after about 5 seconds. Off for visitors who prefer reduced motion."
237
+ }
238
+ />
239
+ </>
240
+ )}
241
+ {!value && (
242
+ <Button
243
+ type="button"
244
+ variant="secondary"
245
+ className={`${BUTTON} emvb-add-shadow`}
246
+ icon={<PlusIcon aria-hidden="true" />}
247
+ data-emvb-add-loop=""
248
+ onClick={() =>
249
+ onChange(structuredClone((LOOP_PRESETS[0] as (typeof LOOP_PRESETS)[number]).value))
250
+ }
251
+ >
252
+ Add loop
253
+ </Button>
254
+ )}
255
+ {playing && (
256
+ <Button
257
+ type="button"
258
+ variant="ghost"
259
+ className={BUTTON}
260
+ onClick={() => onChange({ type: "none" })}
261
+ >
262
+ Turn off loop
263
+ </Button>
264
+ )}
265
+ </div>
266
+ {reset}
267
+ </div>
268
+ );
269
+ }
@@ -24,7 +24,7 @@ export function LoopItemBindControl({
24
24
  }: {
25
25
  value: string;
26
26
  fetcher: Fetcher;
27
- onChange: (itemPartId: string) => void;
27
+ onChange: (partId: string) => void;
28
28
  partType?: ThemePartType;
29
29
  label?: string;
30
30
  emptyLabel?: string;
@@ -56,6 +56,7 @@ export function LoopItemBindControl({
56
56
 
57
57
  if (parts && parts.length > 0) {
58
58
  const known = parts.some((part) => part.id === value);
59
+ const chosen = parts.find((part) => part.id === value);
59
60
  const selectValue = value === "" ? NONE : known ? value : MANUAL;
60
61
  return (
61
62
  <div {...{ [`data-emvb-${marker}-bind`]: "list" }}>
@@ -98,6 +99,11 @@ export function LoopItemBindControl({
98
99
  Optional published {label} theme part. Leave blank to use nested elements.
99
100
  {adminLinks && <a href="/_emdash/admin/plugins/emvb/theme"> Open Theme Builder</a>}
100
101
  </p>
102
+ {chosen && chosen.status !== "published" && (
103
+ <p className="emvb-helper" role="note" data-emvb-part-draft={chosen.status}>
104
+ {draftNote(chosen.status)}
105
+ </p>
106
+ )}
101
107
  </div>
102
108
  );
103
109
  }
@@ -128,3 +134,15 @@ function labelFor(part: ThemePartSummary): string {
128
134
  const status = part.status === "published" ? "" : ` (${part.status})`;
129
135
  return `${part.title}${status}`;
130
136
  }
137
+
138
+ /**
139
+ * W-970: the canvas draws a part's latest saved version, but visitors only see what is published.
140
+ * Say so when the chosen part has unpublished changes, or was never published.
141
+ */
142
+ function draftNote(status: string): string {
143
+ if (status === "changed")
144
+ return "The canvas shows this part's unpublished changes. Visitors see the published version until you publish it in Theme Builder.";
145
+ if (status === "scheduled")
146
+ return "The canvas shows this part as scheduled. Visitors see it once it goes live.";
147
+ return "This part isn't published yet. The canvas shows its draft, but visitors see nothing here until you publish it in Theme Builder.";
148
+ }
@@ -5,24 +5,25 @@ import {
5
5
  MOTION_EFFECTS,
6
6
  MOTION_LIMITS,
7
7
  type MotionEffect,
8
- type StyleProps,
8
+ type FlatStyleProps,
9
9
  } from "../../../../core/index.ts";
10
10
  import { BUTTON } from "../../../ui.ts";
11
11
  import { TransitionSelect } from "./EffectsControls.tsx";
12
12
  import { NumberField, type NumberSpec } from "./NumberRow.tsx";
13
13
 
14
- type Motion = NonNullable<StyleProps["scrollMotion"]>;
14
+ type Motion = NonNullable<FlatStyleProps["scrollMotion"]>;
15
15
  type Playing = Extract<Motion, { effects: unknown }>;
16
16
  type Effect = Playing["effects"][number];
17
17
 
18
- const EFFECT_LABELS: Record<MotionEffect, { label: string; unit: string; neutral: number }> = {
19
- fade: { label: "Opacity", unit: "%", neutral: 100 },
20
- "move-x": { label: "Move sideways", unit: "px", neutral: 0 },
21
- "move-y": { label: "Move up/down", unit: "px", neutral: 0 },
22
- scale: { label: "Scale", unit: "%", neutral: 100 },
23
- rotate: { label: "Rotate", unit: "°", neutral: 0 },
24
- blur: { label: "Blur", unit: "px", neutral: 0 },
25
- };
18
+ export const EFFECT_LABELS: Record<MotionEffect, { label: string; unit: string; neutral: number }> =
19
+ {
20
+ fade: { label: "Opacity", unit: "%", neutral: 100 },
21
+ "move-x": { label: "Move sideways", unit: "px", neutral: 0 },
22
+ "move-y": { label: "Move up/down", unit: "px", neutral: 0 },
23
+ scale: { label: "Scale", unit: "%", neutral: 100 },
24
+ rotate: { label: "Rotate", unit: "°", neutral: 0 },
25
+ blur: { label: "Blur", unit: "px", neutral: 0 },
26
+ };
26
27
 
27
28
  const RANGES: { value: Playing["range"]; label: string }[] = [
28
29
  { value: "enter", label: "As it comes into view" },
@@ -87,7 +88,7 @@ export const MOTION_PRESETS: { id: string; label: string; value: Playing }[] = [
87
88
  },
88
89
  ];
89
90
 
90
- const specFor = (type: MotionEffect): NumberSpec => {
91
+ export const specFor = (type: MotionEffect): NumberSpec => {
91
92
  const [min, max] = MOTION_LIMITS[type];
92
93
  return {
93
94
  min,
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { LayoutNode } from "../../../../core/index.ts";
2
+ import { flattenMotion, nestMotion, type LayoutNode } from "../../../../core/index.ts";
3
3
  import { FIELD } from "../../../ui.ts";
4
4
  import { savableNode } from "./DraftTextField.tsx";
5
5
  import { formatStyleValue, parseStyleValue, QUERY_STYLE_KEYS } from "./query-style.ts";
@@ -15,7 +15,10 @@ type QueryStyle = NonNullable<LayoutNode["query"]>["style"];
15
15
  function withQueryStyle(node: LayoutNode, style: Record<string, unknown>): LayoutNode | string {
16
16
  const query = node.query;
17
17
  if (!query) return "Set a container width first.";
18
- const next = { ...node, query: { ...query, style: style as QueryStyle } } as LayoutNode;
18
+ const next = {
19
+ ...node,
20
+ query: { ...query, style: nestMotion(style) as QueryStyle },
21
+ } as LayoutNode;
19
22
  return savableNode(next) || !savableNode(node) ? next : "That value can't be saved here.";
20
23
  }
21
24
 
@@ -32,7 +35,7 @@ function QueryStyleRow({
32
35
  styleKey: string;
33
36
  onChange: (node: LayoutNode) => void;
34
37
  }) {
35
- const style = (node.query?.style ?? {}) as Record<string, unknown>;
38
+ const style = flattenMotion(node.query?.style ?? {}) as Record<string, unknown>;
36
39
  const stored = formatStyleValue(style[styleKey]);
37
40
  const [draft, setDraft] = React.useState(stored);
38
41
  const [error, setError] = React.useState<string | null>(null);
@@ -105,7 +108,7 @@ export function QueryStyleRows({
105
108
  node: LayoutNode;
106
109
  onChange: (node: LayoutNode) => void;
107
110
  }) {
108
- const style = (node.query?.style ?? {}) as Record<string, unknown>;
111
+ const style = flattenMotion(node.query?.style ?? {}) as Record<string, unknown>;
109
112
  const keys = Object.keys(style).filter((key) => style[key] !== undefined);
110
113
  const free = QUERY_STYLE_KEYS.filter((key) => !keys.includes(key));
111
114
  const [newKey, setNewKey] = React.useState("");