@perkyzz/emvb 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/package.json +7 -7
- package/src/admin/access/RequireEditor.tsx +7 -7
- package/src/admin/access/role.ts +5 -2
- package/src/admin/content-api.ts +10 -3
- package/src/admin/content-item.ts +1 -1
- package/src/admin/editor/A11yCopilot.tsx +104 -56
- package/src/admin/editor/CommandPalette.tsx +29 -13
- package/src/admin/editor/DialogCloseButton.tsx +16 -0
- package/src/admin/editor/Editor.tsx +115 -20
- package/src/admin/editor/EditorToasts.tsx +26 -0
- package/src/admin/editor/PerfMeter.tsx +92 -73
- package/src/admin/editor/SavedSectionDialogs.tsx +169 -0
- package/src/admin/editor/ShareLink.tsx +102 -72
- package/src/admin/editor/ShortcutsDialog.tsx +37 -18
- package/src/admin/editor/Timeline.tsx +250 -160
- package/src/admin/editor/TopBar.tsx +71 -14
- package/src/admin/editor/canvas/CanvasFrame.tsx +10 -1
- package/src/admin/editor/canvas/CanvasTextEdit.tsx +8 -2
- package/src/admin/editor/canvas/drop-line.ts +11 -3
- package/src/admin/editor/canvas/frame-focus-ring.ts +37 -0
- package/src/admin/editor/canvas/use-canvas-dnd.ts +32 -3
- package/src/admin/editor/canvas/vnode-react.tsx +7 -0
- package/src/admin/editor/collection-previews.ts +10 -0
- package/src/admin/editor/dialogs.tsx +41 -28
- package/src/admin/editor/dnd/drop-target.ts +26 -1
- package/src/admin/editor/edited-noun.ts +15 -0
- package/src/admin/editor/editor-chrome.tsx +43 -7
- package/src/admin/editor/editor-commands.ts +17 -2
- package/src/admin/editor/editor-css.ts +75 -24
- package/src/admin/editor/element-chrome.ts +21 -11
- package/src/admin/editor/feature-css.ts +56 -14
- package/src/admin/editor/focus-when-lost.ts +23 -0
- package/src/admin/editor/icons/IconLibraryDialog.tsx +54 -18
- package/src/admin/editor/icons/library.ts +1 -1
- package/src/admin/editor/icons/use-icon-library.ts +5 -2
- package/src/admin/editor/ime.ts +29 -0
- package/src/admin/editor/palette-items.ts +27 -3
- package/src/admin/editor/panels/AddPanel.tsx +44 -11
- package/src/admin/editor/panels/ClassesSection.tsx +18 -7
- package/src/admin/editor/panels/ColorControl.tsx +130 -23
- package/src/admin/editor/panels/ConditionsEditor.tsx +52 -26
- package/src/admin/editor/panels/ElementPanel.tsx +134 -24
- package/src/admin/editor/panels/LayersPanel.tsx +61 -20
- package/src/admin/editor/panels/LeftPanel.tsx +9 -1
- package/src/admin/editor/panels/PageSettings.tsx +66 -35
- package/src/admin/editor/panels/SavedSectionsGroup.tsx +246 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +224 -42
- package/src/admin/editor/panels/TokenScales.tsx +88 -48
- package/src/admin/editor/panels/TriggerSettings.tsx +50 -12
- package/src/admin/editor/panels/TriggersEditor.tsx +3 -2
- package/src/admin/editor/panels/VariableSection.tsx +48 -18
- package/src/admin/editor/panels/color-space.ts +23 -29
- package/src/admin/editor/panels/settings/AdvancedFields.tsx +12 -2
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +87 -74
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +55 -11
- package/src/admin/editor/panels/settings/BackgroundFill.tsx +3 -2
- package/src/admin/editor/panels/settings/BindingsEditor.tsx +15 -18
- package/src/admin/editor/panels/settings/BoxControl.tsx +2 -1
- package/src/admin/editor/panels/settings/ClassChip.tsx +21 -9
- package/src/admin/editor/panels/settings/ClassChipInput.tsx +24 -16
- package/src/admin/editor/panels/settings/DraftTextField.tsx +41 -3
- package/src/admin/editor/panels/settings/EffectsControls.tsx +38 -14
- package/src/admin/editor/panels/settings/FieldBindControl.tsx +46 -28
- package/src/admin/editor/panels/settings/FieldControl.tsx +20 -8
- package/src/admin/editor/panels/settings/FormBindControl.tsx +2 -2
- package/src/admin/editor/panels/settings/HintedSwitch.tsx +33 -0
- package/src/admin/editor/panels/settings/IconControls.tsx +33 -13
- package/src/admin/editor/panels/settings/IconPicker.tsx +2 -0
- package/src/admin/editor/panels/settings/ImageSourcesField.tsx +3 -1
- package/src/admin/editor/panels/settings/ItemList.tsx +15 -2
- package/src/admin/editor/panels/settings/LengthRow.tsx +8 -6
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +1 -1
- package/src/admin/editor/panels/settings/MediaPicker.tsx +127 -23
- package/src/admin/editor/panels/settings/MotionControl.tsx +28 -15
- package/src/admin/editor/panels/settings/NumberRow.tsx +9 -3
- package/src/admin/editor/panels/settings/PanelSelect.tsx +50 -0
- package/src/admin/editor/panels/settings/QueryStyleRows.tsx +25 -18
- package/src/admin/editor/panels/settings/RequiredFieldsNotice.tsx +66 -1
- package/src/admin/editor/panels/settings/StyleRow.tsx +10 -3
- package/src/admin/editor/panels/settings/StyleSources.tsx +4 -1
- package/src/admin/editor/panels/settings/VariantEditor.tsx +10 -1
- package/src/admin/editor/panels/settings/box-link-name.ts +6 -2
- package/src/admin/editor/panels/settings/class-suggest.ts +7 -7
- package/src/admin/editor/panels/settings/query-style.ts +38 -9
- package/src/admin/editor/panels/settings/svg-images.ts +13 -0
- package/src/admin/editor/panels/site-list.tsx +20 -6
- package/src/admin/editor/panels/variable-values.ts +11 -4
- package/src/admin/editor/restore-deleted.ts +21 -2
- package/src/admin/editor/section-templates.ts +81 -12
- package/src/admin/editor/shortcuts.ts +31 -2
- package/src/admin/editor/store.ts +7 -0
- package/src/admin/editor/useEditorCommands.ts +61 -15
- package/src/admin/editor/useEditorData.ts +4 -2
- package/src/admin/editor/useEditorShortcuts.ts +17 -7
- package/src/admin/editor/useNodeActions.ts +61 -6
- package/src/admin/editor/useSave.ts +22 -7
- package/src/admin/editor/useSavedSections.ts +197 -0
- package/src/admin/forms-api.ts +2 -0
- package/src/admin/image-editor/Canvas.tsx +61 -17
- package/src/admin/image-editor/CurvesPanel.tsx +2 -1
- package/src/admin/image-editor/ExportDialog.tsx +48 -18
- package/src/admin/image-editor/ImageEditorDialog.tsx +179 -8
- package/src/admin/image-editor/MetadataPanel.tsx +15 -4
- package/src/admin/image-editor/crop-geometry.ts +3 -2
- package/src/admin/image-editor/image-editor-css.ts +15 -10
- package/src/admin/image-editor/load.ts +9 -2
- package/src/admin/image-editor/parts.tsx +69 -19
- package/src/admin/image-editor/save.ts +54 -8
- package/src/admin/media-api.ts +2 -1
- package/src/admin/pages/AgentsPage.tsx +138 -27
- package/src/admin/pages/CreateDialog.tsx +97 -30
- package/src/admin/pages/NewPageDialog.tsx +21 -3
- package/src/admin/pages/NewThemePartDialog.tsx +11 -3
- package/src/admin/pages/PageList.tsx +14 -6
- package/src/admin/pages/SetupShell.tsx +28 -12
- package/src/admin/pages/ThemePartList.tsx +59 -11
- package/src/admin/pages/list-kit.tsx +106 -24
- package/src/admin/saved-sections-api.ts +51 -0
- package/src/admin/search.ts +15 -0
- package/src/admin/setup/useSetupStatus.ts +1 -1
- package/src/admin/theme-api.ts +16 -5
- package/src/admin/ui.ts +82 -22
- package/src/astro/floats/runtime.ts +21 -0
- package/src/astro/menu/runtime.ts +34 -1
- package/src/astro/popups/runtime.ts +41 -9
- package/src/astro/render.ts +3 -0
- package/src/astro/resolve-theme.ts +53 -11
- package/src/astro/resolve.ts +9 -1
- package/src/astro/tabs/runtime.ts +12 -0
- package/src/astro/theme-posts.ts +2 -2
- package/src/astro/visitor.ts +2 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +196 -24
- package/src/core/arrange.ts +48 -12
- package/src/core/audience/rules.ts +5 -1
- package/src/core/audience/variants.ts +29 -3
- package/src/core/clipboard.ts +7 -0
- package/src/core/css/generate.ts +31 -6
- package/src/core/css/print.ts +5 -0
- package/src/core/data/bindings.ts +8 -1
- package/src/core/design/classes.ts +39 -16
- package/src/core/design/devices.ts +7 -13
- package/src/core/design/diff.ts +6 -0
- package/src/core/design/merge.ts +90 -2
- package/src/core/design/states.ts +7 -13
- package/src/core/design/tokens.ts +16 -2
- package/src/core/design/transfer.ts +33 -6
- package/src/core/design/variables.ts +30 -9
- package/src/core/elements/dynamic-elements.ts +53 -14
- package/src/core/elements/form-elements.ts +55 -16
- package/src/core/elements/index.ts +84 -39
- package/src/core/elements/menu.ts +40 -19
- package/src/core/elements/select-prompt.ts +3 -0
- package/src/core/elements/svg-ids.ts +39 -0
- package/src/core/forms/binding.ts +57 -16
- package/src/core/forms/definition.ts +72 -0
- package/src/core/history/diff.ts +18 -1
- package/src/core/icons/animation-runs.ts +11 -0
- package/src/core/icons/catalog.ts +3 -2
- package/src/core/image-edit/schema.ts +11 -1
- package/src/core/image-edit/summary.ts +6 -3
- package/src/core/index.ts +35 -1
- package/src/core/limits.ts +12 -1
- package/src/core/migrate/index.ts +3 -0
- package/src/core/perf/meter.ts +42 -7
- package/src/core/recipes/index.ts +5 -4
- package/src/core/render/context.ts +8 -0
- package/src/core/render/dynamic-post.ts +69 -12
- package/src/core/render/extras.ts +77 -4
- package/src/core/render/form.ts +140 -6
- package/src/core/render/index.ts +156 -20
- package/src/core/render/loop.ts +44 -8
- package/src/core/render/pagination.ts +18 -4
- package/src/core/render/section.ts +27 -0
- package/src/core/render/tabs.ts +12 -3
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +29 -8
- package/src/core/sanitize/embed-url.ts +42 -5
- package/src/core/sanitize/url.ts +2 -1
- package/src/core/saved-sections.ts +318 -0
- package/src/core/schema/design.ts +1 -1
- package/src/core/schema/layout.ts +16 -7
- package/src/core/schema/style.ts +4 -2
- package/src/core/stats.ts +2 -1
- package/src/core/theme/conditions.ts +3 -1
- package/src/core/theme/dynamic.ts +36 -5
- package/src/core/theme/float.ts +12 -2
- package/src/core/theme/pagination.ts +50 -29
- package/src/core/theme/part-types.ts +4 -4
- package/src/core/theme/popup-markup.ts +23 -5
- package/src/core/theme/popup-rules.ts +1 -0
- package/src/core/theme/triggers.ts +3 -2
- package/src/core/tree-ops.ts +27 -0
- package/src/mcp/ports.ts +22 -1
- package/src/mcp/rate-limit.ts +2 -1
- package/src/mcp/read.ts +15 -3
- package/src/mcp/refs.ts +18 -0
- package/src/mcp/sections.ts +183 -0
- package/src/mcp/tools.ts +44 -0
- package/src/mcp/write.ts +178 -14
- package/src/server/agent-settings.ts +1 -1
- package/src/server/hooks.ts +5 -3
- package/src/server/icon-routes.ts +30 -9
- package/src/server/mcp-routes.ts +8 -1
- package/src/server/plugin.ts +14 -0
- package/src/server/saved-sections.ts +163 -0
|
@@ -17,7 +17,7 @@ export function fieldNameError(name: string): string | null {
|
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
/** The Field name box
|
|
20
|
+
/** The Field name box shares its draft with the definition picker (W-720). */
|
|
21
21
|
function FieldNameInput({
|
|
22
22
|
value,
|
|
23
23
|
onChange,
|
|
@@ -27,24 +27,16 @@ function FieldNameInput({
|
|
|
27
27
|
onChange: (name: string) => void;
|
|
28
28
|
manual?: boolean;
|
|
29
29
|
}) {
|
|
30
|
-
const
|
|
31
|
-
React.useEffect(() => {
|
|
32
|
-
setDraft((current) => (fieldNameError(current.trim()) === null ? value : current));
|
|
33
|
-
}, [value]);
|
|
34
|
-
const error = fieldNameError(draft.trim());
|
|
30
|
+
const error = fieldNameError(value.trim());
|
|
35
31
|
return (
|
|
36
32
|
<>
|
|
37
33
|
<Input
|
|
38
34
|
label="Field name"
|
|
39
35
|
className={`${FIELD} emvb-mono`}
|
|
40
|
-
value={
|
|
36
|
+
value={value}
|
|
41
37
|
aria-invalid={error ? true : undefined}
|
|
42
38
|
{...(manual ? { "data-emvb-field-bind": "manual" } : {})}
|
|
43
|
-
onChange={(event) =>
|
|
44
|
-
const next = event.target.value;
|
|
45
|
-
setDraft(next);
|
|
46
|
-
if (fieldNameError(next.trim()) === null) onChange(next.trim());
|
|
47
|
-
}}
|
|
39
|
+
onChange={(event) => onChange(event.target.value)}
|
|
48
40
|
/>
|
|
49
41
|
{error && (
|
|
50
42
|
<p className="emvb-inline-error" data-emvb-field-name-error>
|
|
@@ -70,32 +62,57 @@ export function FieldBindControl({
|
|
|
70
62
|
onChange: (field: string, label?: string) => void;
|
|
71
63
|
}) {
|
|
72
64
|
const [fields, setFields] = React.useState<DefinitionField[] | null>(null);
|
|
65
|
+
const [loading, setLoading] = React.useState(Boolean(formId));
|
|
66
|
+
const [draft, setDraft] = React.useState(value);
|
|
67
|
+
|
|
68
|
+
React.useEffect(() => {
|
|
69
|
+
setDraft(value);
|
|
70
|
+
}, [value]);
|
|
71
|
+
|
|
72
|
+
const changeName = (next: string) => {
|
|
73
|
+
setDraft(next);
|
|
74
|
+
if (fieldNameError(next.trim()) === null) onChange(next.trim());
|
|
75
|
+
};
|
|
73
76
|
|
|
74
77
|
React.useEffect(() => {
|
|
75
78
|
let cancelled = false;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
79
|
+
setLoading(Boolean(formId));
|
|
80
|
+
setFields(null);
|
|
81
|
+
if (!formId) return;
|
|
80
82
|
void loadFormFields(fetcher, formId).then((next) => {
|
|
81
|
-
if (!cancelled)
|
|
83
|
+
if (!cancelled) {
|
|
84
|
+
setFields(next);
|
|
85
|
+
setLoading(false);
|
|
86
|
+
}
|
|
82
87
|
});
|
|
83
88
|
return () => {
|
|
84
89
|
cancelled = true;
|
|
85
90
|
};
|
|
86
91
|
}, [fetcher, formId]);
|
|
87
92
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
const hasFields = fields !== null && fields.length > 0;
|
|
94
|
+
const name = draft.trim();
|
|
95
|
+
const known = fields?.some((field) => field.name === name);
|
|
96
|
+
let feedback = "";
|
|
97
|
+
if (!formId)
|
|
98
|
+
feedback =
|
|
99
|
+
"Choose a form on the parent Form element to list its fields, or enter a field name manually.";
|
|
100
|
+
else if (loading) feedback = "Loading form fields… You can enter a field name.";
|
|
101
|
+
else if (fields === null) feedback = "Could not load form fields. Enter a field name manually.";
|
|
102
|
+
else if (fields.length === 0)
|
|
103
|
+
feedback = "This form has no fields yet. Enter a field name manually.";
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<div className="emvb-field-group" data-emvb-field-bind={hasFields ? "list" : undefined}>
|
|
107
|
+
{hasFields && (
|
|
92
108
|
<Select
|
|
93
109
|
label="Field"
|
|
94
110
|
className={FIELD}
|
|
95
|
-
value={known ?
|
|
111
|
+
value={known ? name : MANUAL}
|
|
96
112
|
onValueChange={(next) => {
|
|
97
113
|
if (!next || next === MANUAL) return;
|
|
98
114
|
const picked = fields.find((each) => each.name === next);
|
|
115
|
+
setDraft(next);
|
|
99
116
|
onChange(next, picked?.label);
|
|
100
117
|
}}
|
|
101
118
|
renderValue={(current: unknown) => {
|
|
@@ -110,10 +127,11 @@ export function FieldBindControl({
|
|
|
110
127
|
</Select.Option>
|
|
111
128
|
))}
|
|
112
129
|
</Select>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
130
|
+
)}
|
|
131
|
+
<FieldNameInput value={draft} onChange={changeName} manual={!hasFields} />
|
|
132
|
+
<p className="emvb-helper" role="status" aria-label="Form fields status" aria-live="polite">
|
|
133
|
+
{feedback}
|
|
134
|
+
</p>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
119
137
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { Select
|
|
2
|
+
import { Select } from "@cloudflare/kumo";
|
|
3
3
|
import type { FieldDescriptor, LayoutNode } from "../../../../core/index.ts";
|
|
4
4
|
import type { Fetcher } from "../../../api.ts";
|
|
5
5
|
import { FIELD } from "../../../ui.ts";
|
|
6
6
|
import { DraftTextField } from "./DraftTextField.tsx";
|
|
7
7
|
import { FieldBindControl } from "./FieldBindControl.tsx";
|
|
8
8
|
import { FormBindControl } from "./FormBindControl.tsx";
|
|
9
|
+
import { HintedSwitch } from "./HintedSwitch.tsx";
|
|
9
10
|
import { RequiredFieldsNotice } from "./RequiredFieldsNotice.tsx";
|
|
10
11
|
import { LoopItemBindControl } from "./LoopItemBindControl.tsx";
|
|
11
12
|
import { IconPicker } from "./IconPicker.tsx";
|
|
@@ -129,13 +130,14 @@ export function FieldControl({
|
|
|
129
130
|
|
|
130
131
|
if (field.kind === "boolean") {
|
|
131
132
|
return (
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
<HintedSwitch
|
|
134
|
+
label={field.label}
|
|
135
|
+
checked={Boolean(raw)}
|
|
136
|
+
onCheckedChange={(checked) => onChange(withProp(node, field.key, checked || undefined))}
|
|
137
|
+
hint={SWITCH_HINTS[`${node.type}.${field.key}`]}
|
|
138
|
+
data={{ "data-emvb-field": field.key }}
|
|
139
|
+
hintData={{ "data-emvb-field-hint": "" }}
|
|
140
|
+
/>
|
|
139
141
|
);
|
|
140
142
|
}
|
|
141
143
|
|
|
@@ -181,6 +183,16 @@ export function FieldControl({
|
|
|
181
183
|
return <DraftTextField field={field} node={node} onChange={onChange} />;
|
|
182
184
|
}
|
|
183
185
|
|
|
186
|
+
/** UX-042, UX-043: switches whose label alone doesn't say when to turn them on. */
|
|
187
|
+
const SWITCH_HINTS: Readonly<Record<string, string>> = {
|
|
188
|
+
"image.decorative": "For images that add nothing to the text. Screen readers skip them.",
|
|
189
|
+
"image.priority": "For the first large image on the page. Others load as they scroll into view.",
|
|
190
|
+
"post-image.decorative": "For images that add nothing to the text. Screen readers skip them.",
|
|
191
|
+
"icon.decorative": "For icons that repeat nearby text. Screen readers skip them.",
|
|
192
|
+
"svg.decorative": "For graphics that add nothing to the text. Screen readers skip them.",
|
|
193
|
+
"menu-item.wide": "The dropdown spans the width of the menu.",
|
|
194
|
+
};
|
|
195
|
+
|
|
184
196
|
const DEVICE_NAMES = { tablet: "tablet", mobile: "mobile" } as const;
|
|
185
197
|
|
|
186
198
|
/**
|
|
@@ -52,7 +52,7 @@ export function FormBindControl({
|
|
|
52
52
|
const known = capability.forms.some((form) => form.id === value);
|
|
53
53
|
const placeholder = !known && value ? "Current id (not in list)" : "Choose a form…";
|
|
54
54
|
return (
|
|
55
|
-
<div data-emvb-form-bind="list">
|
|
55
|
+
<div className="emvb-field-group" data-emvb-form-bind="list">
|
|
56
56
|
<Select
|
|
57
57
|
label="Form"
|
|
58
58
|
className={FIELD}
|
|
@@ -89,7 +89,7 @@ export function FormBindControl({
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
return (
|
|
92
|
-
<div data-emvb-form-bind="manual">
|
|
92
|
+
<div className="emvb-field-group" data-emvb-form-bind="manual">
|
|
93
93
|
<Input
|
|
94
94
|
label="Form id"
|
|
95
95
|
className={`${FIELD} emvb-mono`}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Switch } from "@cloudflare/kumo";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
label: string;
|
|
6
|
+
checked: boolean;
|
|
7
|
+
onCheckedChange: (checked: boolean) => void;
|
|
8
|
+
/** One line on when to turn it on; it describes the switch and lines up with its label. */
|
|
9
|
+
hint?: React.ReactNode;
|
|
10
|
+
/** Data attributes for the wrapper and the hint, so tests and styles can find them. */
|
|
11
|
+
data?: Record<`data-${string}`, string>;
|
|
12
|
+
hintData?: Record<`data-${string}`, string>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** A panel switch with its explanation under the label (UX-042, UX-046). */
|
|
16
|
+
export function HintedSwitch({ label, checked, onCheckedChange, hint, data, hintData }: Props) {
|
|
17
|
+
const hintId = React.useId();
|
|
18
|
+
return (
|
|
19
|
+
<div className="emvb-field-group" {...data}>
|
|
20
|
+
<Switch
|
|
21
|
+
label={label}
|
|
22
|
+
checked={checked}
|
|
23
|
+
aria-describedby={hint ? hintId : undefined}
|
|
24
|
+
onCheckedChange={(next) => onCheckedChange(next === true)}
|
|
25
|
+
/>
|
|
26
|
+
{hint && (
|
|
27
|
+
<p className="emvb-helper emvb-switch-hint" id={hintId} {...hintData}>
|
|
28
|
+
{hint}
|
|
29
|
+
</p>
|
|
30
|
+
)}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, Select
|
|
1
|
+
import { Button, Select } from "@cloudflare/kumo";
|
|
2
2
|
import {
|
|
3
3
|
FlipHorizontalIcon,
|
|
4
4
|
FlipVerticalIcon,
|
|
@@ -11,6 +11,7 @@ import { BUTTON, FIELD } from "../../../ui.ts";
|
|
|
11
11
|
import { ColorControl } from "../ColorControl.tsx";
|
|
12
12
|
import { radioGroupKeys } from "./ChoiceGroup.tsx";
|
|
13
13
|
import { NumberField, ResetButton, type NumberSpec } from "./NumberRow.tsx";
|
|
14
|
+
import { HintedSwitch } from "./HintedSwitch.tsx";
|
|
14
15
|
|
|
15
16
|
/** W-237: the Icon section's own controls (glyph rotation, flip, drop shadow, loop). */
|
|
16
17
|
|
|
@@ -224,7 +225,7 @@ const DEFAULT_DURATION: Record<Looping["type"], number> = { spin: 2000, pulse: 1
|
|
|
224
225
|
const looping = (a: IconAnimation | undefined): Looping | undefined =>
|
|
225
226
|
a && a.type !== "none" ? a : undefined;
|
|
226
227
|
|
|
227
|
-
/** A
|
|
228
|
+
/** A spin or pulse (Normal only) that stops after about 5 s; reduced motion sees it still. */
|
|
228
229
|
const ANIMATION_LABELS: Record<string, string> = { none: "None", spin: "Spin", pulse: "Pulse" };
|
|
229
230
|
|
|
230
231
|
/**
|
|
@@ -263,7 +264,8 @@ export function IconAnimationControl({
|
|
|
263
264
|
setType(picked);
|
|
264
265
|
if (picked === "spin" || picked === "pulse") {
|
|
265
266
|
const duration = own?.duration ?? from?.duration ?? DEFAULT_DURATION[picked];
|
|
266
|
-
|
|
267
|
+
const loop = own?.loop ?? from?.loop;
|
|
268
|
+
onChange(loop ? { type: picked, duration, loop } : { type: picked, duration });
|
|
267
269
|
} else onChange(from ? { type: "none" } : undefined);
|
|
268
270
|
}}
|
|
269
271
|
>
|
|
@@ -280,11 +282,26 @@ export function IconAnimationControl({
|
|
|
280
282
|
onCommit={(n) => onChange({ ...own, duration: n ?? DEFAULT_DURATION[own.type] })}
|
|
281
283
|
/>
|
|
282
284
|
)}
|
|
283
|
-
{own &&
|
|
285
|
+
{own && (
|
|
286
|
+
<HintedSwitch
|
|
287
|
+
label="Loop forever"
|
|
288
|
+
checked={own.loop === true}
|
|
289
|
+
onCheckedChange={(loop) => {
|
|
290
|
+
const { loop: _old, ...rest } = own;
|
|
291
|
+
onChange(loop ? { ...rest, loop: true } : rest);
|
|
292
|
+
}}
|
|
293
|
+
data={{ "data-emvb-icon-loop": "" }}
|
|
294
|
+
hint={
|
|
295
|
+
own.loop
|
|
296
|
+
? "Keeps going, for a loading spinner. Off for visitors who prefer reduced motion."
|
|
297
|
+
: "Stops on its own after about 5 seconds. Off for visitors who prefer reduced motion."
|
|
298
|
+
}
|
|
299
|
+
/>
|
|
300
|
+
)}
|
|
284
301
|
{!value && from && (
|
|
285
302
|
<p className="emvb-helper">
|
|
286
|
-
Inherited from a wider device ({ANIMATION_LABELS[from.type]}, {from.duration} ms
|
|
287
|
-
None to stop it on this one.
|
|
303
|
+
Inherited from a wider device ({ANIMATION_LABELS[from.type]}, {from.duration} ms
|
|
304
|
+
{from.loop ? ", loops forever" : ""}). Pick None to stop it on this one.
|
|
288
305
|
</p>
|
|
289
306
|
)}
|
|
290
307
|
{value?.type === "none" && from && (
|
|
@@ -309,14 +326,17 @@ export function IconSingleColorRow({
|
|
|
309
326
|
onChange: (next: boolean) => void;
|
|
310
327
|
}) {
|
|
311
328
|
return (
|
|
312
|
-
<
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
329
|
+
<HintedSwitch
|
|
330
|
+
label="Force single color"
|
|
331
|
+
checked={checked}
|
|
332
|
+
onCheckedChange={onChange}
|
|
333
|
+
data={{ "data-emvb-icon-single-color": "" }}
|
|
334
|
+
hint={
|
|
335
|
+
checked
|
|
316
336
|
? "Every part of this SVG uses the icon color, so details drawn over filled shapes can disappear."
|
|
317
|
-
: "This SVG keeps its own colors. Turn on to paint it in the icon color."
|
|
318
|
-
|
|
319
|
-
|
|
337
|
+
: "This SVG keeps its own colors. Turn on to paint it in the icon color."
|
|
338
|
+
}
|
|
339
|
+
/>
|
|
320
340
|
);
|
|
321
341
|
}
|
|
322
342
|
|
|
@@ -128,6 +128,8 @@ export function IconPicker({
|
|
|
128
128
|
const remove = () => {
|
|
129
129
|
const { iconId: _id, iconSvg: _svg, ...rest } = propsOf(node);
|
|
130
130
|
onChange({ ...node, props: rest } as LayoutNode);
|
|
131
|
+
// W-838: Remove unmounts itself; keyboard focus moves to Choose instead of the page body.
|
|
132
|
+
refocus();
|
|
131
133
|
};
|
|
132
134
|
|
|
133
135
|
return (
|
|
@@ -33,7 +33,9 @@ export function parseSources(text: string): { sources: Source[] } | { error: str
|
|
|
33
33
|
if (lines.length > MAX_SOURCES) return { error: `Up to ${MAX_SOURCES} extra sources.` };
|
|
34
34
|
const sources: Source[] = [];
|
|
35
35
|
for (const line of lines) {
|
|
36
|
-
|
|
36
|
+
// W-545: a site path may hold a space ("/uploads/my photo-400.jpg 400"); the width is the
|
|
37
|
+
// last word.
|
|
38
|
+
const match = /^(\S(?:.*\S)?)\s+(\d{1,4})\s*(?:w|px)?$/i.exec(line);
|
|
37
39
|
const width = match ? Number(match[2]) : Number.NaN;
|
|
38
40
|
if (!match || !Number.isInteger(width) || width < 1 || width > 8000) {
|
|
39
41
|
return {
|
|
@@ -48,6 +48,9 @@ const childrenOf = (node: LayoutNode): LayoutNode[] =>
|
|
|
48
48
|
"children" in node && Array.isArray(node.children) ? (node.children as LayoutNode[]) : [];
|
|
49
49
|
|
|
50
50
|
/** One reorder of `kids`, moving `fromId` to `toIndex`. Same place or an unknown id changes nothing. */
|
|
51
|
+
/** Drag type for an item row, so text dragged from a title field never reorders. */
|
|
52
|
+
const ITEM_DRAG = "application/x-emvb-item";
|
|
53
|
+
|
|
51
54
|
export function reorderItems(
|
|
52
55
|
kids: LayoutNode[],
|
|
53
56
|
fromId: string,
|
|
@@ -135,17 +138,27 @@ export function ItemList({
|
|
|
135
138
|
className="emvb-item-row"
|
|
136
139
|
data-emvb-item={child.id}
|
|
137
140
|
draggable
|
|
141
|
+
// W-611: in Chrome a draggable row drags itself when the mouse goes down in its
|
|
142
|
+
// title field, so text can't be selected. The row only drags from outside a field.
|
|
143
|
+
onPointerDown={(event) => {
|
|
144
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
145
|
+
event.currentTarget.draggable = !target?.closest("input, textarea, select");
|
|
146
|
+
}}
|
|
138
147
|
onDragStart={(event) => {
|
|
139
|
-
|
|
148
|
+
// A text drag from the title field keeps the browser's own data (W-605).
|
|
149
|
+
if (event.target !== event.currentTarget) return;
|
|
150
|
+
event.dataTransfer.setData(ITEM_DRAG, child.id);
|
|
140
151
|
event.dataTransfer.effectAllowed = "move";
|
|
141
152
|
}}
|
|
142
153
|
onDragOver={(event) => {
|
|
154
|
+
if (!event.dataTransfer.types.includes(ITEM_DRAG)) return;
|
|
143
155
|
event.preventDefault();
|
|
144
156
|
event.dataTransfer.dropEffect = "move";
|
|
145
157
|
}}
|
|
146
158
|
onDrop={(event) => {
|
|
159
|
+
if (!event.dataTransfer.types.includes(ITEM_DRAG)) return;
|
|
147
160
|
event.preventDefault();
|
|
148
|
-
const next = reorderItems(kids, event.dataTransfer.getData(
|
|
161
|
+
const next = reorderItems(kids, event.dataTransfer.getData(ITEM_DRAG), index);
|
|
149
162
|
if (next) onChange({ ...node, children: next } as LayoutNode);
|
|
150
163
|
}}
|
|
151
164
|
>
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from "./length-units.ts";
|
|
13
13
|
import type { StyleKey } from "./style-sections.ts";
|
|
14
14
|
import { bindKind, boundRef, lengthRef, VariableButton, VariableChip } from "./VariableBinding.tsx";
|
|
15
|
+
import { isCommitEnter } from "../../ime.ts";
|
|
15
16
|
|
|
16
17
|
const isLiteral = (value: unknown): value is LengthLiteral =>
|
|
17
18
|
typeof value === "object" &&
|
|
@@ -53,11 +54,12 @@ export function LengthRow({
|
|
|
53
54
|
}) {
|
|
54
55
|
const units = unitsFor(styleKey);
|
|
55
56
|
// W-213: a plain number is a unitless line height, shown with the `x` unit.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
// W-603: memoized, so a plain number doesn't make a new object each render; the effect below
|
|
58
|
+
// would reset the draft on every keystroke and nothing typed over a unitless value would stick.
|
|
59
|
+
const literal = React.useMemo<{ value: number; unit: NumericUnit } | undefined>(
|
|
60
|
+
() => (isLiteral(value) ? value : typeof value === "number" ? { value, unit: "x" } : undefined),
|
|
61
|
+
[value],
|
|
62
|
+
);
|
|
61
63
|
const numericUnit = literal?.unit ?? firstNumeric(units);
|
|
62
64
|
const [draft, setDraft] = React.useState(literal ? String(literal.value) : "");
|
|
63
65
|
const [unit, setUnit] = React.useState<UnitChoice>(value === "auto" ? "auto" : numericUnit);
|
|
@@ -146,7 +148,7 @@ export function LengthRow({
|
|
|
146
148
|
}}
|
|
147
149
|
onBlur={commit}
|
|
148
150
|
onKeyDown={(event) => {
|
|
149
|
-
if (event
|
|
151
|
+
if (isCommitEnter(event)) commit();
|
|
150
152
|
}}
|
|
151
153
|
/>
|
|
152
154
|
<InputGroup.Addon align="end" className="emvb-unit-addon">
|