@perkyzz/emvb 0.8.0 → 1.0.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 +3 -3
- package/package.json +4 -4
- package/src/admin/agents-api.ts +45 -0
- package/src/admin/editor/A11yCopilot.tsx +1 -1
- package/src/admin/editor/Editor.tsx +325 -239
- package/src/admin/editor/FieldPreview.tsx +164 -0
- package/src/admin/editor/Timeline.tsx +2 -1
- package/src/admin/editor/TopBar.tsx +36 -3
- package/src/admin/editor/canvas/CanvasFrame.tsx +2 -2
- package/src/admin/editor/canvas/DeviceBar.tsx +17 -9
- package/src/admin/editor/canvas/canvas-scale.ts +2 -2
- package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
- package/src/admin/editor/co-design.ts +190 -0
- package/src/admin/editor/dnd/new-element.ts +26 -4
- package/src/admin/editor/editor-chrome.tsx +3 -3
- package/src/admin/editor/editor-commands.ts +8 -3
- package/src/admin/editor/editor-css.ts +3 -0
- package/src/admin/editor/element-chrome.ts +3 -1
- package/src/admin/editor/extension-manifests.ts +20 -0
- package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
- package/src/admin/editor/extensions-context.tsx +27 -0
- package/src/admin/editor/feature-css.ts +17 -0
- package/src/admin/editor/host.ts +6 -0
- package/src/admin/editor/palette-items.ts +2 -2
- package/src/admin/editor/panels/AddPanel.tsx +31 -1
- package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
- package/src/admin/editor/panels/ClassesSection.tsx +9 -6
- package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
- package/src/admin/editor/panels/ColorControl.tsx +2 -2
- package/src/admin/editor/panels/ElementPanel.tsx +53 -15
- package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
- package/src/admin/editor/panels/LayersPanel.tsx +10 -6
- package/src/admin/editor/panels/LeftPanel.tsx +33 -5
- package/src/admin/editor/panels/PageSettings.tsx +4 -0
- package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +76 -20
- package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
- package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
- package/src/admin/editor/panels/settings/EffectsControls.tsx +104 -9
- package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
- package/src/admin/editor/panels/settings/IconControls.tsx +14 -11
- package/src/admin/editor/panels/settings/LengthRow.tsx +27 -16
- package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +1 -1
- package/src/admin/editor/panels/settings/MediaPicker.tsx +5 -5
- package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
- package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
- package/src/admin/editor/panels/settings/StyleRow.tsx +113 -13
- package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
- package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
- package/src/admin/editor/panels/settings/background-mode.ts +14 -11
- package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
- package/src/admin/editor/panels/settings/box-sides.ts +22 -14
- package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
- package/src/admin/editor/panels/settings/length-units.ts +55 -2
- package/src/admin/editor/panels/settings/query-style.ts +3 -3
- package/src/admin/editor/panels/settings/style-sections.ts +51 -10
- package/src/admin/editor/panels/style-target.ts +9 -7
- package/src/admin/editor/presence.ts +60 -0
- package/src/admin/editor/store.ts +6 -2
- package/src/admin/editor/useCoDesign.ts +177 -0
- package/src/admin/editor/useEditorCommands.ts +4 -4
- package/src/admin/editor/useExtensions.ts +45 -0
- package/src/admin/editor/useNodeActions.ts +15 -6
- package/src/admin/editor/useProposals.ts +81 -0
- package/src/admin/index.tsx +5 -1
- package/src/admin/languages-api.ts +61 -0
- package/src/admin/media-api.ts +27 -0
- package/src/admin/pages/AgentSetup.tsx +148 -0
- package/src/admin/pages/AgentsPage.tsx +11 -28
- package/src/admin/pages/CollectionsPage.tsx +215 -0
- package/src/admin/pages/CreateDialog.tsx +15 -0
- package/src/admin/pages/ImportButton.tsx +18 -0
- package/src/admin/pages/ImportElementorDialog.tsx +669 -0
- package/src/admin/pages/ImportPageLinks.tsx +86 -0
- package/src/admin/pages/PageList.tsx +15 -1
- package/src/admin/pages/ThemePartList.tsx +15 -1
- package/src/admin/pages/section-head.tsx +27 -0
- package/src/admin/proposals-api.ts +91 -0
- package/src/admin/setup/host-collections.ts +100 -0
- package/src/admin/ui.ts +39 -2
- package/src/admin/widgets/CanvasField.tsx +202 -0
- package/src/admin/widgets/convert-body.ts +54 -0
- package/src/admin/widgets/field-fetcher.ts +79 -0
- package/src/astro/content-port.ts +14 -1
- package/src/astro/index.ts +2 -0
- package/src/astro/page-count.ts +77 -0
- package/src/astro/resolve-theme.ts +58 -3
- package/src/astro/resolve.ts +128 -5
- package/src/astro/responsive-images.ts +99 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +44 -14
- package/src/core/arrange.ts +5 -1
- package/src/core/bounded-array.ts +31 -0
- package/src/core/canvas-collections.ts +20 -0
- package/src/core/clipboard.ts +9 -0
- package/src/core/contract.ts +285 -0
- package/src/core/css/generate.ts +89 -20
- package/src/core/css/trace.ts +18 -9
- package/src/core/css-keywords.ts +51 -1
- package/src/core/design/cascade.ts +12 -9
- package/src/core/design/classes.ts +4 -5
- package/src/core/design/devices.ts +13 -13
- package/src/core/design/states.ts +5 -3
- package/src/core/design/transfer.ts +5 -0
- package/src/core/design/variables.ts +17 -4
- package/src/core/elements/dynamic-elements.ts +19 -4
- package/src/core/elements/index.ts +73 -9
- package/src/core/extensions/define.ts +13 -0
- package/src/core/extensions/index.ts +41 -0
- package/src/core/extensions/namespace.ts +82 -0
- package/src/core/extensions/normalize.ts +141 -0
- package/src/core/extensions/placeholder.ts +41 -0
- package/src/core/extensions/registry.ts +94 -0
- package/src/core/extensions/render-ext.ts +118 -0
- package/src/core/extensions/safe-nodes.ts +93 -0
- package/src/core/extensions/schema.ts +112 -0
- package/src/core/extensions/types.ts +159 -0
- package/src/core/forms/binding.ts +1 -1
- package/src/core/history/diff.ts +1 -1
- package/src/core/import/elementor/atomic.ts +1595 -0
- package/src/core/import/elementor/classes.ts +127 -0
- package/src/core/import/elementor/context.ts +429 -0
- package/src/core/import/elementor/counter-steps.ts +72 -0
- package/src/core/import/elementor/css.ts +445 -0
- package/src/core/import/elementor/html.ts +500 -0
- package/src/core/import/elementor/index.ts +949 -0
- package/src/core/import/elementor/inline-marks.ts +81 -0
- package/src/core/import/elementor/snapshots.ts +48 -0
- package/src/core/import/elementor/style.ts +409 -0
- package/src/core/import/elementor/values.ts +241 -0
- package/src/core/import/elementor/widgets.ts +1897 -0
- package/src/core/index.ts +84 -0
- package/src/core/json-schema.ts +107 -0
- package/src/core/limits.ts +19 -0
- package/src/core/migrate/index.ts +6 -1
- package/src/core/migrate/v18.ts +222 -0
- package/src/core/perf/meter.ts +5 -5
- package/src/core/portable-text.ts +127 -0
- package/src/core/proposals-safety.ts +102 -0
- package/src/core/proposals.ts +357 -0
- package/src/core/recipes/index.ts +2 -2
- package/src/core/render/extras.ts +3 -3
- package/src/core/render/index.ts +140 -20
- package/src/core/render/loop.ts +1 -1
- package/src/core/render/pagination.ts +20 -1
- package/src/core/render/section.ts +4 -4
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +125 -10
- package/src/core/sanitize/motion.ts +116 -0
- package/src/core/saved-sections.ts +6 -0
- package/src/core/schema/descriptors.ts +3 -1
- package/src/core/schema/design.ts +2 -1
- package/src/core/schema/layout.ts +87 -14
- package/src/core/schema/style.ts +251 -114
- package/src/core/text-marks.ts +227 -0
- package/src/core/theme/dynamic.ts +9 -4
- package/src/core/theme/float.ts +1 -0
- package/src/core/theme/pagination.ts +9 -0
- package/src/core/theme/popup-rules.ts +17 -1
- package/src/core/translatable.ts +34 -0
- package/src/core/validate.ts +13 -1
- package/src/index.ts +35 -1
- package/src/mcp/errors.ts +3 -1
- package/src/mcp/ports.ts +67 -0
- package/src/mcp/prompts.ts +1 -11
- package/src/mcp/proposals.ts +281 -0
- package/src/mcp/read.ts +10 -9
- package/src/mcp/tools.ts +71 -3
- package/src/mcp/write.ts +66 -11
- package/src/server/agent-settings.ts +21 -2
- package/src/server/hooks.ts +81 -0
- package/src/server/mcp-routes.ts +15 -0
- package/src/server/plugin.ts +53 -5
- package/src/server/presence.ts +78 -0
- package/src/server/proposals.ts +261 -0
- package/src/server/requests.ts +196 -0
- package/src/server/tools-served.ts +45 -0
|
@@ -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
|
+
}
|
|
@@ -103,10 +103,6 @@ export function MediaPicker({ node, fetcher, onChange, label = "Image", editable
|
|
|
103
103
|
}
|
|
104
104
|
}, [fetcher, setBusy]);
|
|
105
105
|
|
|
106
|
-
React.useEffect(() => {
|
|
107
|
-
if (open) void loadLibrary();
|
|
108
|
-
}, [open, loadLibrary]);
|
|
109
|
-
|
|
110
106
|
/** Focus Choose from library, or the URL field while the picker is busy (W-741). */
|
|
111
107
|
const focusOpener = () => {
|
|
112
108
|
const opener = libraryOpenerRef.current;
|
|
@@ -256,7 +252,11 @@ export function MediaPicker({ node, fetcher, onChange, label = "Image", editable
|
|
|
256
252
|
type="button"
|
|
257
253
|
className={BUTTON}
|
|
258
254
|
onClick={() => {
|
|
259
|
-
if (
|
|
255
|
+
if (busyRef.current) return;
|
|
256
|
+
// W-906: load in the same update that opens it; loading from an effect painted the
|
|
257
|
+
// last result ("No images yet.") first, and closing then raced the real load.
|
|
258
|
+
setOpen(true);
|
|
259
|
+
void loadLibrary();
|
|
260
260
|
}}
|
|
261
261
|
aria-disabled={busy}
|
|
262
262
|
ref={libraryOpenerRef}
|
|
@@ -5,24 +5,25 @@ import {
|
|
|
5
5
|
MOTION_EFFECTS,
|
|
6
6
|
MOTION_LIMITS,
|
|
7
7
|
type MotionEffect,
|
|
8
|
-
type
|
|
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<
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
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 = {
|
|
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("");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Input, Select } from "@cloudflare/kumo";
|
|
2
2
|
import { MotionControl } from "./MotionControl.tsx";
|
|
3
|
-
import {
|
|
3
|
+
import { LoopControl } from "./LoopControl.tsx";
|
|
4
|
+
import { isSafeFontStack, type DesignSystem, type FlatStyleProps } from "../../../../core/index.ts";
|
|
4
5
|
import type { Fetcher } from "../../../api.ts";
|
|
5
6
|
import { FIELD } from "../../../ui.ts";
|
|
6
7
|
import { ColorControl } from "../ColorControl.tsx";
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
EntranceControl,
|
|
13
14
|
FiltersControl,
|
|
14
15
|
ShadowControl,
|
|
16
|
+
TransformControl,
|
|
15
17
|
TransitionControl,
|
|
16
18
|
} from "./EffectsControls.tsx";
|
|
17
19
|
import {
|
|
@@ -33,6 +35,8 @@ const LENGTH_KEYS = new Set<StyleKey>([
|
|
|
33
35
|
"height",
|
|
34
36
|
"minHeight",
|
|
35
37
|
"maxHeight",
|
|
38
|
+
"flexBasis",
|
|
39
|
+
"markerSize",
|
|
36
40
|
"paddingTop",
|
|
37
41
|
"paddingRight",
|
|
38
42
|
"paddingBottom",
|
|
@@ -61,11 +65,14 @@ const LENGTH_KEYS = new Set<StyleKey>([
|
|
|
61
65
|
]);
|
|
62
66
|
|
|
63
67
|
const Z_INDEX: NumberSpec = { min: -9999, max: 9999, integer: true, example: "10" };
|
|
68
|
+
/** W-954: a flex child's share of free space (grow) or of the shortfall (shrink). */
|
|
69
|
+
const FLEX_FACTOR: NumberSpec = { min: 0, max: 100, example: "1" };
|
|
70
|
+
const ORDER: NumberSpec = { min: -99, max: 99, integer: true, example: "-1" };
|
|
64
71
|
const GRID_SPAN: NumberSpec = { min: 1, max: 12, integer: true, example: "2" };
|
|
65
72
|
const GRID_LINE: NumberSpec = { min: 1, max: 13, integer: true, example: "1" };
|
|
66
73
|
const OPACITY: NumberSpec = { min: 0, max: 100, scale: 100, example: "50", suffix: "%" };
|
|
67
74
|
|
|
68
|
-
const COLOR_KEYS = new Set<StyleKey>(["color", "backgroundColor", "borderColor"]);
|
|
75
|
+
const COLOR_KEYS = new Set<StyleKey>(["color", "backgroundColor", "borderColor", "markerColor"]);
|
|
69
76
|
|
|
70
77
|
const SELECT_OPTIONS: Partial<Record<StyleKey, { value: string; label: string }[]>> = {
|
|
71
78
|
textAlign: [
|
|
@@ -100,6 +107,39 @@ const SELECT_OPTIONS: Partial<Record<StyleKey, { value: string; label: string }[
|
|
|
100
107
|
{ value: "scroll", label: "Scroll" },
|
|
101
108
|
{ value: "auto", label: "Auto" },
|
|
102
109
|
],
|
|
110
|
+
alignSelf: [
|
|
111
|
+
{ value: "auto", label: "Follow the parent" },
|
|
112
|
+
{ value: "stretch", label: "Stretch" },
|
|
113
|
+
{ value: "flex-start", label: "Start" },
|
|
114
|
+
{ value: "center", label: "Center" },
|
|
115
|
+
{ value: "flex-end", label: "End" },
|
|
116
|
+
{ value: "baseline", label: "Baseline" },
|
|
117
|
+
],
|
|
118
|
+
overflowX: [
|
|
119
|
+
{ value: "visible", label: "Visible" },
|
|
120
|
+
{ value: "hidden", label: "Hidden" },
|
|
121
|
+
{ value: "clip", label: "Clip" },
|
|
122
|
+
{ value: "scroll", label: "Scroll" },
|
|
123
|
+
{ value: "auto", label: "Auto" },
|
|
124
|
+
],
|
|
125
|
+
overflowY: [
|
|
126
|
+
{ value: "visible", label: "Visible" },
|
|
127
|
+
{ value: "hidden", label: "Hidden" },
|
|
128
|
+
{ value: "clip", label: "Clip" },
|
|
129
|
+
{ value: "scroll", label: "Scroll" },
|
|
130
|
+
{ value: "auto", label: "Auto" },
|
|
131
|
+
],
|
|
132
|
+
objectPosition: [
|
|
133
|
+
{ value: "center", label: "Center" },
|
|
134
|
+
{ value: "top", label: "Top" },
|
|
135
|
+
{ value: "bottom", label: "Bottom" },
|
|
136
|
+
{ value: "left", label: "Left" },
|
|
137
|
+
{ value: "right", label: "Right" },
|
|
138
|
+
{ value: "top left", label: "Top left" },
|
|
139
|
+
{ value: "top right", label: "Top right" },
|
|
140
|
+
{ value: "bottom left", label: "Bottom left" },
|
|
141
|
+
{ value: "bottom right", label: "Bottom right" },
|
|
142
|
+
],
|
|
103
143
|
aspectRatio: [
|
|
104
144
|
{ value: "auto", label: "Auto" },
|
|
105
145
|
...["1/1", "4/3", "3/2", "16/9", "21/9", "3/4", "2/3", "9/16"].map((ratio) => ({
|
|
@@ -107,6 +147,21 @@ const SELECT_OPTIONS: Partial<Record<StyleKey, { value: string; label: string }[
|
|
|
107
147
|
label: ratio.replace("/", ":"),
|
|
108
148
|
})),
|
|
109
149
|
],
|
|
150
|
+
fontStyle: [
|
|
151
|
+
{ value: "normal", label: "Normal" },
|
|
152
|
+
{ value: "italic", label: "Italic" },
|
|
153
|
+
],
|
|
154
|
+
whiteSpace: [
|
|
155
|
+
{ value: "normal", label: "Wrap" },
|
|
156
|
+
{ value: "nowrap", label: "Don't wrap" },
|
|
157
|
+
{ value: "pre-line", label: "Keep line breaks" },
|
|
158
|
+
{ value: "pre-wrap", label: "Keep spaces and line breaks" },
|
|
159
|
+
],
|
|
160
|
+
overflowWrap: [
|
|
161
|
+
{ value: "normal", label: "Keep whole" },
|
|
162
|
+
{ value: "break-word", label: "Break if needed" },
|
|
163
|
+
{ value: "anywhere", label: "Break anywhere" },
|
|
164
|
+
],
|
|
110
165
|
objectFit: [
|
|
111
166
|
{ value: "fill", label: "Fill" },
|
|
112
167
|
{ value: "contain", label: "Contain" },
|
|
@@ -210,9 +265,9 @@ export function StyleRow({
|
|
|
210
265
|
onDesignChange,
|
|
211
266
|
}: {
|
|
212
267
|
styleKey: StyleKey;
|
|
213
|
-
style:
|
|
268
|
+
style: FlatStyleProps | undefined;
|
|
214
269
|
/** The Normal styles while a state is edited (W-089): shown as placeholders, never saved. */
|
|
215
|
-
inherited?:
|
|
270
|
+
inherited?: FlatStyleProps;
|
|
216
271
|
design: DesignSystem;
|
|
217
272
|
/** Present on an element, so a background image can use the media library. */
|
|
218
273
|
fetcher?: Fetcher;
|
|
@@ -220,7 +275,7 @@ export function StyleRow({
|
|
|
220
275
|
elementType?: string;
|
|
221
276
|
/** Which class and device the background fill memory belongs to (W-184). */
|
|
222
277
|
fillScope?: string;
|
|
223
|
-
onPatch: (patch: Partial<
|
|
278
|
+
onPatch: (patch: Partial<FlatStyleProps>) => void;
|
|
224
279
|
onDesignChange: (design: DesignSystem) => Promise<void>;
|
|
225
280
|
}) {
|
|
226
281
|
const value = style?.[styleKey];
|
|
@@ -287,7 +342,7 @@ export function StyleRow({
|
|
|
287
342
|
>
|
|
288
343
|
<ColorControl
|
|
289
344
|
label={label}
|
|
290
|
-
value={value as
|
|
345
|
+
value={value as FlatStyleProps["color"]}
|
|
291
346
|
placeholder={placeholder}
|
|
292
347
|
design={design}
|
|
293
348
|
onChange={(color) => onPatch({ [styleKey]: color })}
|
|
@@ -343,7 +398,7 @@ export function StyleRow({
|
|
|
343
398
|
const n = Number(next);
|
|
344
399
|
onPatch({
|
|
345
400
|
fontWeight: Number.isFinite(n)
|
|
346
|
-
? (n as NonNullable<
|
|
401
|
+
? (n as NonNullable<FlatStyleProps["fontWeight"]>)
|
|
347
402
|
: undefined,
|
|
348
403
|
});
|
|
349
404
|
return;
|
|
@@ -407,7 +462,7 @@ export function StyleRow({
|
|
|
407
462
|
kind="font"
|
|
408
463
|
design={design}
|
|
409
464
|
current={ref?.var ?? null}
|
|
410
|
-
onBind={(next) => onPatch({ fontFamily: next as
|
|
465
|
+
onBind={(next) => onPatch({ fontFamily: next as FlatStyleProps["fontFamily"] })}
|
|
411
466
|
/>
|
|
412
467
|
{reset}
|
|
413
468
|
</div>
|
|
@@ -416,6 +471,9 @@ export function StyleRow({
|
|
|
416
471
|
|
|
417
472
|
if (
|
|
418
473
|
styleKey === "zIndex" ||
|
|
474
|
+
styleKey === "flexGrow" ||
|
|
475
|
+
styleKey === "flexShrink" ||
|
|
476
|
+
styleKey === "order" ||
|
|
419
477
|
styleKey === "opacity" ||
|
|
420
478
|
styleKey === "gridColumnSpan" ||
|
|
421
479
|
styleKey === "gridRowSpan" ||
|
|
@@ -425,11 +483,15 @@ export function StyleRow({
|
|
|
425
483
|
const spec =
|
|
426
484
|
styleKey === "zIndex"
|
|
427
485
|
? Z_INDEX
|
|
428
|
-
: styleKey === "
|
|
429
|
-
?
|
|
430
|
-
: styleKey === "
|
|
431
|
-
?
|
|
432
|
-
:
|
|
486
|
+
: styleKey === "flexGrow" || styleKey === "flexShrink"
|
|
487
|
+
? FLEX_FACTOR
|
|
488
|
+
: styleKey === "order"
|
|
489
|
+
? ORDER
|
|
490
|
+
: styleKey === "opacity"
|
|
491
|
+
? OPACITY
|
|
492
|
+
: styleKey === "gridColumnStart" || styleKey === "gridRowStart"
|
|
493
|
+
? GRID_LINE
|
|
494
|
+
: GRID_SPAN;
|
|
433
495
|
return (
|
|
434
496
|
<NumberRow
|
|
435
497
|
rowKey={styleKey}
|
|
@@ -525,6 +587,16 @@ export function StyleRow({
|
|
|
525
587
|
);
|
|
526
588
|
}
|
|
527
589
|
|
|
590
|
+
if (styleKey === "loopMotion") {
|
|
591
|
+
return (
|
|
592
|
+
<LoopControl
|
|
593
|
+
value={style?.loopMotion}
|
|
594
|
+
onChange={(loopMotion) => onPatch({ loopMotion })}
|
|
595
|
+
reset={reset}
|
|
596
|
+
/>
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
|
|
528
600
|
if (styleKey === "transition") {
|
|
529
601
|
return (
|
|
530
602
|
<TransitionControl
|
|
@@ -545,6 +617,28 @@ export function StyleRow({
|
|
|
545
617
|
);
|
|
546
618
|
}
|
|
547
619
|
|
|
620
|
+
if (styleKey === "transform") {
|
|
621
|
+
return (
|
|
622
|
+
<TransformControl
|
|
623
|
+
value={style?.transform}
|
|
624
|
+
inherited={inherited?.transform}
|
|
625
|
+
onChange={(transform) => onPatch({ transform })}
|
|
626
|
+
/>
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
if (styleKey === "backdropFilter") {
|
|
631
|
+
return (
|
|
632
|
+
<FiltersControl
|
|
633
|
+
styleKey="backdropFilter"
|
|
634
|
+
label="Backdrop filters"
|
|
635
|
+
value={style?.backdropFilter}
|
|
636
|
+
inherited={inherited?.backdropFilter}
|
|
637
|
+
onChange={(backdropFilter) => onPatch({ backdropFilter })}
|
|
638
|
+
/>
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
|
|
548
642
|
if (LENGTH_KEYS.has(styleKey)) {
|
|
549
643
|
return (
|
|
550
644
|
<LengthRow
|
|
@@ -569,6 +663,9 @@ export const IMPLEMENTED_STYLE_KEYS: StyleKey[] = [
|
|
|
569
663
|
...COLOR_KEYS,
|
|
570
664
|
"fontFamily",
|
|
571
665
|
"zIndex",
|
|
666
|
+
"flexGrow",
|
|
667
|
+
"flexShrink",
|
|
668
|
+
"order",
|
|
572
669
|
"gridColumnSpan",
|
|
573
670
|
"gridColumnStart",
|
|
574
671
|
"gridRowSpan",
|
|
@@ -576,8 +673,11 @@ export const IMPLEMENTED_STYLE_KEYS: StyleKey[] = [
|
|
|
576
673
|
"opacity",
|
|
577
674
|
"boxShadow",
|
|
578
675
|
"filter",
|
|
676
|
+
"backdropFilter",
|
|
677
|
+
"transform",
|
|
579
678
|
"entrance",
|
|
580
679
|
"scrollMotion",
|
|
680
|
+
"loopMotion",
|
|
581
681
|
"transition",
|
|
582
682
|
"iconRotate",
|
|
583
683
|
"iconFlip",
|