@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
package/src/core/schema/style.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import {
|
|
3
3
|
ALIGN_ITEMS,
|
|
4
|
+
ALIGN_SELF,
|
|
4
5
|
BACKGROUND_POSITIONS,
|
|
5
6
|
BACKGROUND_REPEATS,
|
|
6
7
|
BACKGROUND_SIZES,
|
|
@@ -8,10 +9,12 @@ import {
|
|
|
8
9
|
CURSORS,
|
|
9
10
|
FLEX_DIRECTIONS,
|
|
10
11
|
FLEX_WRAPS,
|
|
12
|
+
FONT_STYLES,
|
|
11
13
|
HEX_COLOR,
|
|
12
14
|
JUSTIFY_CONTENT,
|
|
13
15
|
LENGTH_UNITS,
|
|
14
16
|
OBJECT_FITS,
|
|
17
|
+
OVERFLOW_WRAPS,
|
|
15
18
|
OVERFLOWS,
|
|
16
19
|
POSITIONS,
|
|
17
20
|
TEXT_ALIGNS,
|
|
@@ -19,10 +22,11 @@ import {
|
|
|
19
22
|
TEXT_TRANSFORMS,
|
|
20
23
|
TRANSITION_EASINGS,
|
|
21
24
|
TRANSITION_PROPERTIES,
|
|
25
|
+
WHITE_SPACES,
|
|
22
26
|
} from "../css-keywords.ts";
|
|
23
27
|
import { isSafeFontStack } from "../sanitize/css.ts";
|
|
24
28
|
import { sanitizeMediaUrl } from "../sanitize/media-url.ts";
|
|
25
|
-
import {
|
|
29
|
+
import { DEVICES } from "../theme/popup-rules.ts";
|
|
26
30
|
import { MOTION_EFFECTS, MOTION_LIMITS } from "./motion.ts";
|
|
27
31
|
|
|
28
32
|
/** Colour refs omit `from` (legacy). Length/font refs set `from` (W-028). */
|
|
@@ -50,6 +54,19 @@ export const LengthValue = z.union([Length, VariableRef]);
|
|
|
50
54
|
/** Width, height and margins may also be `auto` (W-088). */
|
|
51
55
|
const SizeValue = z.union([Length, VariableRef, z.literal("auto")]);
|
|
52
56
|
|
|
57
|
+
/**
|
|
58
|
+
* W-955: a fluid size, `min` px on small screens growing to `max` px on large ones, emitted as
|
|
59
|
+
* `clamp()` between 360 and 1280 px wide screens (the design's fluid sizes use the same formula).
|
|
60
|
+
*/
|
|
61
|
+
const FluidLength = z.strictObject({
|
|
62
|
+
fluid: z.strictObject({
|
|
63
|
+
min: z.number().finite().min(0).max(10_000),
|
|
64
|
+
max: z.number().finite().min(0).max(10_000),
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
const FluidLengthValue = z.union([Length, VariableRef, FluidLength]);
|
|
68
|
+
const FluidSizeValue = z.union([Length, VariableRef, FluidLength, z.literal("auto")]);
|
|
69
|
+
|
|
53
70
|
/**
|
|
54
71
|
* Top, right, bottom and left may be negative, `auto` or a spacing variable (W-088); so may
|
|
55
72
|
* margins since W-331, to pull an element over its neighbour.
|
|
@@ -58,6 +75,7 @@ const OffsetValue = z.union([
|
|
|
58
75
|
z.strictObject({ value: z.number().finite().min(-10_000).max(10_000), unit: LengthUnit }),
|
|
59
76
|
VariableRef,
|
|
60
77
|
z.literal("auto"),
|
|
78
|
+
FluidLength,
|
|
61
79
|
]);
|
|
62
80
|
|
|
63
81
|
/** `w/h` with whole numbers 1–9999, emitted as `w / h` (W-088). */
|
|
@@ -76,6 +94,22 @@ const BoxShadow = z.strictObject({
|
|
|
76
94
|
});
|
|
77
95
|
|
|
78
96
|
/** Filter functions, emitted in a fixed order; at least one is set (W-088). */
|
|
97
|
+
/**
|
|
98
|
+
* W-953: move, scale and rotate, written as CSS's own `translate`, `scale` and `rotate` so an
|
|
99
|
+
* entrance (which animates `transform`) never cancels it. In a hover state it is a lift.
|
|
100
|
+
*/
|
|
101
|
+
const Transform = z
|
|
102
|
+
.strictObject({
|
|
103
|
+
/** Pixels, right and down. */
|
|
104
|
+
x: z.number().int().min(-2000).max(2000).optional(),
|
|
105
|
+
y: z.number().int().min(-2000).max(2000).optional(),
|
|
106
|
+
/** Percent, 100 = unchanged. */
|
|
107
|
+
scale: z.number().int().min(10).max(400).optional(),
|
|
108
|
+
/** Degrees, clockwise. */
|
|
109
|
+
rotate: z.number().int().min(-360).max(360).optional(),
|
|
110
|
+
})
|
|
111
|
+
.refine((t) => Object.values(t).some((v) => v !== undefined), "Set at least one transform");
|
|
112
|
+
|
|
79
113
|
const Filter = z
|
|
80
114
|
.strictObject({
|
|
81
115
|
blur: num(0, 100).optional(),
|
|
@@ -101,13 +135,145 @@ const Transition = z.strictObject({
|
|
|
101
135
|
property: z.enum(TRANSITION_PROPERTIES),
|
|
102
136
|
});
|
|
103
137
|
|
|
104
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* A spin or pulse; off for visitors who prefer reduced motion. It stops after about 5 s
|
|
140
|
+
* (W-848) unless `loop` is true (W-853, D-059). `{ type: "none" }` (W-248) stops an animation a
|
|
141
|
+
* device would otherwise inherit from a wider one.
|
|
142
|
+
*/
|
|
143
|
+
const IconAnimation = z.union([
|
|
144
|
+
z.strictObject({
|
|
145
|
+
type: z.enum(["spin", "pulse"]),
|
|
146
|
+
duration: z.number().int().min(200).max(10_000),
|
|
147
|
+
loop: z.literal(true).optional(),
|
|
148
|
+
}),
|
|
149
|
+
z.strictObject({ type: z.literal("none") }),
|
|
150
|
+
]);
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Scroll motion (W-319): effects tied to the element's trip through the screen (or the page's
|
|
154
|
+
* scroll), with CSS scroll-driven animations. Browsers without them, and visitors who prefer
|
|
155
|
+
* reduced motion, see the element still. `{ type: "none" }` stops motion a wider device sets.
|
|
156
|
+
*/
|
|
157
|
+
/** From/to values per effect, each effect once, within MOTION_LIMITS (W-319; loops W-938). */
|
|
158
|
+
const MotionEffects = z
|
|
159
|
+
.array(
|
|
160
|
+
z.strictObject({
|
|
161
|
+
type: z.enum(MOTION_EFFECTS),
|
|
162
|
+
from: z.number().min(-1000).max(1000),
|
|
163
|
+
to: z.number().min(-1000).max(1000),
|
|
164
|
+
}),
|
|
165
|
+
)
|
|
166
|
+
.min(1)
|
|
167
|
+
.max(MOTION_EFFECTS.length)
|
|
168
|
+
.superRefine((effects, ctx) => {
|
|
169
|
+
const seen = new Set<string>();
|
|
170
|
+
for (const effect of effects) {
|
|
171
|
+
const [min, max] = MOTION_LIMITS[effect.type];
|
|
172
|
+
if ([effect.from, effect.to].some((n) => n < min || n > max)) {
|
|
173
|
+
ctx.addIssue({
|
|
174
|
+
code: "custom",
|
|
175
|
+
message: `${effect.type} goes from ${min} to ${max}`,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (seen.has(effect.type)) {
|
|
179
|
+
ctx.addIssue({ code: "custom", message: `${effect.type} is set twice` });
|
|
180
|
+
}
|
|
181
|
+
seen.add(effect.type);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const ScrollMotion = z.union([
|
|
186
|
+
z.strictObject({
|
|
187
|
+
effects: MotionEffects,
|
|
188
|
+
range: z.enum(["enter", "cross", "exit", "page"]),
|
|
189
|
+
}),
|
|
190
|
+
z.strictObject({ type: z.literal("none") }),
|
|
191
|
+
]);
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* A looping animation (W-938): the effects play from their `from` to their `to` values over
|
|
195
|
+
* `duration`, and back when `alternate` (the default). Like an Icon's spin (D-057, D-059) it stops
|
|
196
|
+
* after about 5 seconds unless `loop` is true, and it is off for visitors who prefer reduced
|
|
197
|
+
* motion. Presets in the editor (float, pulse, wiggle…) are just effect sets. `{ type: "none" }`
|
|
198
|
+
* stops a loop a wider device sets.
|
|
199
|
+
*/
|
|
200
|
+
const LoopMotion = z.union([
|
|
201
|
+
z.strictObject({
|
|
202
|
+
effects: MotionEffects,
|
|
203
|
+
duration: z.number().int().min(200).max(20_000),
|
|
204
|
+
easing: z.enum(TRANSITION_EASINGS).optional(),
|
|
205
|
+
alternate: z.boolean().optional(),
|
|
206
|
+
loop: z.literal(true).optional(),
|
|
207
|
+
}),
|
|
208
|
+
z.strictObject({ type: z.literal("none") }),
|
|
209
|
+
]);
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Plays once (W-101, W-107). `delay` waits before it starts. `view` starts as the element
|
|
213
|
+
* scrolls into view, using CSS scroll-driven animations, and falls back to playing on load.
|
|
214
|
+
* Not a state style.
|
|
215
|
+
*/
|
|
216
|
+
const Entrance = z.strictObject({
|
|
217
|
+
type: z.enum(["fade", "fade-up", "fade-down", "slide-up", "slide-down", "scale"]),
|
|
218
|
+
duration: z.number().int().min(0).max(2000),
|
|
219
|
+
delay: z.number().int().min(0).max(2000).optional(),
|
|
220
|
+
trigger: z.enum(["load", "view"]).optional(),
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Every motion setting of a style, under one key (W-925, layout 18 / design 17): `entrance`,
|
|
225
|
+
* `scroll` (scroll motion), `transition` and `icon` (an Icon's spin or pulse). Before 1.0 these
|
|
226
|
+
* were the flat style keys `entrance`, `scrollMotion`, `transition` and `iconAnimation`; stored
|
|
227
|
+
* documents are moved here on read. Each part keeps its own rules and its own device cascade.
|
|
228
|
+
*/
|
|
229
|
+
export const Motion = z.strictObject({
|
|
230
|
+
entrance: Entrance.optional(),
|
|
231
|
+
scroll: ScrollMotion.optional(),
|
|
232
|
+
transition: Transition.optional(),
|
|
233
|
+
icon: IconAnimation.optional(),
|
|
234
|
+
loop: LoopMotion.optional(),
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
export type Motion = z.infer<typeof Motion>;
|
|
238
|
+
|
|
239
|
+
/** A gradient: up to 10 stops (W-160). Also the paint of a gradient overlay (W-949). */
|
|
240
|
+
const Gradient = z.strictObject({
|
|
241
|
+
type: z.enum(["linear", "radial", "conic"]),
|
|
242
|
+
angle: z.number().int().min(0).max(360).optional(),
|
|
243
|
+
position: z.enum(BACKGROUND_POSITIONS).optional(),
|
|
244
|
+
stops: z
|
|
245
|
+
.array(
|
|
246
|
+
z.strictObject({
|
|
247
|
+
color: ColorValue,
|
|
248
|
+
at: z.number().int().min(0).max(100),
|
|
249
|
+
}),
|
|
250
|
+
)
|
|
251
|
+
.min(2)
|
|
252
|
+
.max(10),
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
/** A colour or gradient laid over a background (W-094, W-949). */
|
|
256
|
+
const Overlay = z.union([
|
|
257
|
+
z.strictObject({
|
|
258
|
+
color: ColorValue,
|
|
259
|
+
opacity: z.number().finite().min(0).max(1),
|
|
260
|
+
}),
|
|
261
|
+
z.strictObject({
|
|
262
|
+
gradient: Gradient,
|
|
263
|
+
opacity: z.number().finite().min(0).max(1).optional(),
|
|
264
|
+
}),
|
|
265
|
+
]);
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Style properties for layout and text elements (W-017 / R-012). Unknown keys are refused here;
|
|
269
|
+
* `validateLayout` and `validateDesign` keep a newer 1.x key aside and puts it back untouched (D-065, W-925).
|
|
270
|
+
*/
|
|
105
271
|
export const StyleProps = z.strictObject({
|
|
106
272
|
flexDirection: z.enum(FLEX_DIRECTIONS).optional(),
|
|
107
273
|
flexWrap: z.enum(FLEX_WRAPS).optional(),
|
|
108
274
|
justifyContent: z.enum(JUSTIFY_CONTENT).optional(),
|
|
109
275
|
alignItems: z.enum(ALIGN_ITEMS).optional(),
|
|
110
|
-
gap:
|
|
276
|
+
gap: FluidLengthValue.optional(),
|
|
111
277
|
/** How many grid columns this element spans (1–12). */
|
|
112
278
|
gridColumnSpan: z.number().int().min(1).max(12).optional(),
|
|
113
279
|
/** How many grid rows this element spans (1–12). */
|
|
@@ -116,21 +282,36 @@ export const StyleProps = z.strictObject({
|
|
|
116
282
|
gridColumnStart: z.number().int().min(1).max(13).optional(),
|
|
117
283
|
/** First row line (1–13). With a span, emits `start / span n`. */
|
|
118
284
|
gridRowStart: z.number().int().min(1).max(13).optional(),
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
285
|
+
/**
|
|
286
|
+
* W-954: how a child of a Flexbox or Container shares the row or column: how much it grows into
|
|
287
|
+
* free space, how much it gives up when space is short, its starting size, its own alignment
|
|
288
|
+
* and its place in the order.
|
|
289
|
+
*/
|
|
290
|
+
flexGrow: z.number().finite().min(0).max(100).optional(),
|
|
291
|
+
flexShrink: z.number().finite().min(0).max(100).optional(),
|
|
292
|
+
flexBasis: SizeValue.optional(),
|
|
293
|
+
alignSelf: z.enum(ALIGN_SELF).optional(),
|
|
294
|
+
order: z.number().int().min(-99).max(99).optional(),
|
|
295
|
+
width: FluidSizeValue.optional(),
|
|
296
|
+
minWidth: FluidLengthValue.optional(),
|
|
297
|
+
maxWidth: FluidLengthValue.optional(),
|
|
298
|
+
height: FluidSizeValue.optional(),
|
|
299
|
+
minHeight: FluidLengthValue.optional(),
|
|
300
|
+
maxHeight: FluidLengthValue.optional(),
|
|
125
301
|
overflow: z.enum(OVERFLOWS).optional(),
|
|
302
|
+
/** W-957: one axis only, after `overflow` so it wins (a table that scrolls sideways). */
|
|
303
|
+
overflowX: z.enum(OVERFLOWS).optional(),
|
|
304
|
+
overflowY: z.enum(OVERFLOWS).optional(),
|
|
126
305
|
aspectRatio: z
|
|
127
306
|
.union([z.literal("auto"), z.string().regex(ASPECT_RATIO, "Use a ratio such as 16/9")])
|
|
128
307
|
.optional(),
|
|
129
308
|
objectFit: z.enum(OBJECT_FITS).optional(),
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
309
|
+
/** W-957: which part of an image or video stays in view when it is cropped. */
|
|
310
|
+
objectPosition: z.enum(BACKGROUND_POSITIONS).optional(),
|
|
311
|
+
paddingTop: FluidLengthValue.optional(),
|
|
312
|
+
paddingRight: FluidLengthValue.optional(),
|
|
313
|
+
paddingBottom: FluidLengthValue.optional(),
|
|
314
|
+
paddingLeft: FluidLengthValue.optional(),
|
|
134
315
|
marginTop: OffsetValue.optional(),
|
|
135
316
|
marginRight: OffsetValue.optional(),
|
|
136
317
|
marginBottom: OffsetValue.optional(),
|
|
@@ -147,7 +328,7 @@ export const StyleProps = z.strictObject({
|
|
|
147
328
|
VariableRef,
|
|
148
329
|
])
|
|
149
330
|
.optional(),
|
|
150
|
-
fontSize:
|
|
331
|
+
fontSize: FluidLengthValue.optional(),
|
|
151
332
|
/** W-213: any weight 100–900 in steps of 100 (the font must ship it to look different). */
|
|
152
333
|
fontWeight: z
|
|
153
334
|
.union([
|
|
@@ -176,6 +357,13 @@ export const StyleProps = z.strictObject({
|
|
|
176
357
|
textTransform: z.enum(TEXT_TRANSFORMS).optional(),
|
|
177
358
|
/** W-113. A button sets `none` in its base CSS, so it is not underlined unless a style says so. */
|
|
178
359
|
textDecoration: z.enum(TEXT_DECORATIONS).optional(),
|
|
360
|
+
/** W-952: a List's markers (bullets, numbers, step circles): their colour and size. */
|
|
361
|
+
markerColor: ColorValue.optional(),
|
|
362
|
+
markerSize: LengthValue.optional(),
|
|
363
|
+
/** W-957. */
|
|
364
|
+
fontStyle: z.enum(FONT_STYLES).optional(),
|
|
365
|
+
whiteSpace: z.enum(WHITE_SPACES).optional(),
|
|
366
|
+
overflowWrap: z.enum(OVERFLOW_WRAPS).optional(),
|
|
179
367
|
color: ColorValue.optional(),
|
|
180
368
|
backgroundColor: ColorValue.optional(),
|
|
181
369
|
/** http(s) or a site path. Spaces, quotes and parentheses are refused so the URL can sit inside `url("")`. */
|
|
@@ -205,29 +393,12 @@ export const StyleProps = z.strictObject({
|
|
|
205
393
|
* Background gradient (W-160). Up to 10 stops. `angle` is the linear direction and the conic
|
|
206
394
|
* start; `position` is the radial centre. A stop colour variable is a colour use.
|
|
207
395
|
*/
|
|
208
|
-
gradient:
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
.array(
|
|
215
|
-
z.strictObject({
|
|
216
|
-
color: ColorValue,
|
|
217
|
-
at: z.number().int().min(0).max(100),
|
|
218
|
-
}),
|
|
219
|
-
)
|
|
220
|
-
.min(2)
|
|
221
|
-
.max(10),
|
|
222
|
-
})
|
|
223
|
-
.optional(),
|
|
224
|
-
/** A colour laid over the image and gradient. `opacity` is 0–1 (W-094). */
|
|
225
|
-
overlay: z
|
|
226
|
-
.strictObject({
|
|
227
|
-
color: ColorValue,
|
|
228
|
-
opacity: z.number().finite().min(0).max(1),
|
|
229
|
-
})
|
|
230
|
-
.optional(),
|
|
396
|
+
gradient: Gradient.optional(),
|
|
397
|
+
/**
|
|
398
|
+
* Laid over the image and gradient (W-094): a colour, or since W-949 a gradient (a scrim that
|
|
399
|
+
* fades from dark behind the text to clear). `opacity` 0–1 fades the whole overlay.
|
|
400
|
+
*/
|
|
401
|
+
overlay: Overlay.optional(),
|
|
231
402
|
borderWidth: LengthValue.optional(),
|
|
232
403
|
/** Per-side widths (W-138, D-044), after `borderWidth`, so a side beats the all-sides value. */
|
|
233
404
|
borderTopWidth: LengthValue.optional(),
|
|
@@ -245,8 +416,10 @@ export const StyleProps = z.strictObject({
|
|
|
245
416
|
opacity: z.number().finite().min(0).max(1).optional(),
|
|
246
417
|
boxShadow: BoxShadow.optional(),
|
|
247
418
|
filter: Filter.optional(),
|
|
419
|
+
transform: Transform.optional(),
|
|
420
|
+
/** W-957: the same filters applied to what is behind the element (frosted glass). */
|
|
421
|
+
backdropFilter: Filter.optional(),
|
|
248
422
|
cursor: z.enum(CURSORS).optional(),
|
|
249
|
-
transition: Transition.optional(),
|
|
250
423
|
/**
|
|
251
424
|
* Icon element glyph styling (W-237). Emitted as custom properties on the icon's wrapper, so
|
|
252
425
|
* they work in states, devices and classes; the Icon's base CSS applies them to its `<svg>`.
|
|
@@ -265,88 +438,50 @@ export const StyleProps = z.strictObject({
|
|
|
265
438
|
color: ColorValue.optional(),
|
|
266
439
|
})
|
|
267
440
|
.optional(),
|
|
268
|
-
|
|
269
|
-
* A spin or pulse; off for visitors who prefer reduced motion. It stops after about 5 s
|
|
270
|
-
* (W-848) unless `loop` is true (W-853, D-059). `{ type: "none" }` (W-248) stops an animation a
|
|
271
|
-
* device would otherwise inherit from a wider one.
|
|
272
|
-
*/
|
|
273
|
-
iconAnimation: z
|
|
274
|
-
.union([
|
|
275
|
-
z.strictObject({
|
|
276
|
-
type: z.enum(["spin", "pulse"]),
|
|
277
|
-
duration: z.number().int().min(200).max(10_000),
|
|
278
|
-
loop: z.literal(true).optional(),
|
|
279
|
-
}),
|
|
280
|
-
z.strictObject({ type: z.literal("none") }),
|
|
281
|
-
])
|
|
282
|
-
.optional(),
|
|
283
|
-
/**
|
|
284
|
-
* Scroll motion (W-319): effects tied to the element's trip through the screen (or the page's
|
|
285
|
-
* scroll), with CSS scroll-driven animations. Browsers without them, and visitors who prefer
|
|
286
|
-
* reduced motion, see the element still. `{ type: "none" }` stops motion a wider device sets.
|
|
287
|
-
*/
|
|
288
|
-
scrollMotion: z
|
|
289
|
-
.union([
|
|
290
|
-
z.strictObject({
|
|
291
|
-
effects: z
|
|
292
|
-
.array(
|
|
293
|
-
z.strictObject({
|
|
294
|
-
type: z.enum(MOTION_EFFECTS),
|
|
295
|
-
from: z.number().min(-1000).max(1000),
|
|
296
|
-
to: z.number().min(-1000).max(1000),
|
|
297
|
-
}),
|
|
298
|
-
)
|
|
299
|
-
.min(1)
|
|
300
|
-
.max(MOTION_EFFECTS.length)
|
|
301
|
-
.superRefine((effects, ctx) => {
|
|
302
|
-
const seen = new Set<string>();
|
|
303
|
-
for (const effect of effects) {
|
|
304
|
-
const [min, max] = MOTION_LIMITS[effect.type];
|
|
305
|
-
if ([effect.from, effect.to].some((n) => n < min || n > max)) {
|
|
306
|
-
ctx.addIssue({
|
|
307
|
-
code: "custom",
|
|
308
|
-
message: `${effect.type} goes from ${min} to ${max}`,
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
if (seen.has(effect.type)) {
|
|
312
|
-
ctx.addIssue({ code: "custom", message: `${effect.type} is set twice` });
|
|
313
|
-
}
|
|
314
|
-
seen.add(effect.type);
|
|
315
|
-
}
|
|
316
|
-
}),
|
|
317
|
-
range: z.enum(["enter", "cross", "exit", "page"]),
|
|
318
|
-
}),
|
|
319
|
-
z.strictObject({ type: z.literal("none") }),
|
|
320
|
-
])
|
|
321
|
-
.optional(),
|
|
322
|
-
/**
|
|
323
|
-
* Plays once (W-101, W-107). `delay` waits before it starts. `view` starts as the element
|
|
324
|
-
* scrolls into view, using CSS scroll-driven animations, and falls back to playing on load.
|
|
325
|
-
* Not a state style.
|
|
326
|
-
*/
|
|
327
|
-
entrance: z
|
|
328
|
-
.strictObject({
|
|
329
|
-
type: z.enum(["fade", "fade-up", "fade-down", "slide-up", "slide-down", "scale"]),
|
|
330
|
-
duration: z.number().int().min(0).max(2000),
|
|
331
|
-
delay: z.number().int().min(0).max(2000).optional(),
|
|
332
|
-
trigger: z.enum(["load", "view"]).optional(),
|
|
333
|
-
})
|
|
334
|
-
.optional(),
|
|
441
|
+
motion: Motion.optional(),
|
|
335
442
|
});
|
|
336
443
|
|
|
337
444
|
export type StyleProps = z.infer<typeof StyleProps>;
|
|
338
445
|
|
|
339
446
|
/**
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
* `
|
|
447
|
+
* The pre-1.0 flat style shape: `motion`'s parts as the top-level keys `entrance`, `scrollMotion`,
|
|
448
|
+
* `transition` and `iconAnimation` (W-925). The editor's style rows and the CSS sanitizer work on
|
|
449
|
+
* this shape; `flattenMotion` and `nestMotion` convert. It is never stored.
|
|
450
|
+
* Its keys are in the 0.x schema order (`transition` after `cursor`, `iconAnimation` after the
|
|
451
|
+
* other icon keys, then `scrollMotion` and `entrance`): a parsed style's CSS is written in that
|
|
452
|
+
* order, so keeping it keeps 0.x pages byte for byte.
|
|
343
453
|
*/
|
|
344
|
-
const
|
|
345
|
-
transition:
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
454
|
+
const FlatStyleShape = StyleProps.omit({ motion: true }).extend({
|
|
455
|
+
transition: Transition.optional(),
|
|
456
|
+
iconAnimation: IconAnimation.optional(),
|
|
457
|
+
scrollMotion: ScrollMotion.optional(),
|
|
458
|
+
entrance: Entrance.optional(),
|
|
459
|
+
loopMotion: LoopMotion.optional(),
|
|
349
460
|
});
|
|
461
|
+
const flatShape: Record<string, z.ZodType> = {};
|
|
462
|
+
for (const [key, schema] of Object.entries(StyleProps.omit({ motion: true }).shape)) {
|
|
463
|
+
flatShape[key] = schema;
|
|
464
|
+
if (key === "cursor") flatShape["transition"] = Transition.optional();
|
|
465
|
+
if (key === "iconShadow") {
|
|
466
|
+
flatShape["iconAnimation"] = IconAnimation.optional();
|
|
467
|
+
flatShape["scrollMotion"] = ScrollMotion.optional();
|
|
468
|
+
flatShape["entrance"] = Entrance.optional();
|
|
469
|
+
// W-938: added in 1.0, so after every 0.x key (0.x pages keep their CSS order).
|
|
470
|
+
flatShape["loopMotion"] = LoopMotion.optional();
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
export const FlatStyleProps = z.strictObject(flatShape) as unknown as typeof FlatStyleShape;
|
|
474
|
+
|
|
475
|
+
export type FlatStyleProps = z.infer<typeof FlatStyleProps>;
|
|
476
|
+
|
|
477
|
+
/** A style edit: flat motion keys (`undefined` clears), or a whole `motion` record. */
|
|
478
|
+
export type StylePatch = Partial<FlatStyleProps> & { motion?: Motion | undefined };
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* `states` on a node or class (D-032, W-089): hover, focus (`:focus-visible`) and active, each with
|
|
482
|
+
* the same keys and limits as `style` except `motion`. Unknown states are refused.
|
|
483
|
+
*/
|
|
484
|
+
const StateStyle = StyleProps.omit({ motion: true });
|
|
350
485
|
|
|
351
486
|
export const StyleStates = z.strictObject({
|
|
352
487
|
hover: StateStyle.optional(),
|
|
@@ -361,6 +496,8 @@ export type StyleStates = z.infer<typeof StyleStates>;
|
|
|
361
496
|
* are stored. A phone matches both media queries, so mobile wins over tablet for the same key.
|
|
362
497
|
*/
|
|
363
498
|
export const DeviceStyles = z.strictObject({
|
|
499
|
+
/** W-956: up to 1366 px; Tablet and Mobile win over it. */
|
|
500
|
+
laptop: StyleProps.optional(),
|
|
364
501
|
tablet: StyleProps.optional(),
|
|
365
502
|
mobile: StyleProps.optional(),
|
|
366
503
|
});
|
|
@@ -368,6 +505,6 @@ export const DeviceStyles = z.strictObject({
|
|
|
368
505
|
export type DeviceStyles = z.infer<typeof DeviceStyles>;
|
|
369
506
|
|
|
370
507
|
/** Devices on which the element is `display: none`. Empty means shown everywhere. */
|
|
371
|
-
export const HiddenOn = z.array(z.enum(
|
|
508
|
+
export const HiddenOn = z.array(z.enum(DEVICES)).max(4);
|
|
372
509
|
|
|
373
510
|
export type HiddenOn = z.infer<typeof HiddenOn>;
|