@perkyzz/emvb 0.6.0 → 0.7.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/package.json +1 -1
- 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/Editor.tsx +82 -20
- package/src/admin/editor/EditorToasts.tsx +26 -0
- package/src/admin/editor/PerfMeter.tsx +97 -72
- package/src/admin/editor/ShareLink.tsx +107 -72
- package/src/admin/editor/ShortcutsDialog.tsx +27 -16
- package/src/admin/editor/Timeline.tsx +255 -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 +38 -14
- 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 +59 -7
- package/src/admin/editor/editor-commands.ts +2 -1
- package/src/admin/editor/editor-css.ts +72 -22
- package/src/admin/editor/element-chrome.ts +21 -11
- package/src/admin/editor/feature-css.ts +45 -13
- package/src/admin/editor/icons/IconLibraryDialog.tsx +52 -11
- 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 +10 -3
- package/src/admin/editor/panels/AddPanel.tsx +35 -10
- 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 +55 -19
- package/src/admin/editor/panels/PageSettings.tsx +66 -35
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +170 -32
- package/src/admin/editor/panels/TokenScales.tsx +76 -36
- package/src/admin/editor/panels/TriggerSettings.tsx +50 -12
- package/src/admin/editor/panels/TriggersEditor.tsx +2 -1
- package/src/admin/editor/panels/VariableSection.tsx +48 -18
- package/src/admin/editor/panels/color-space.ts +9 -3
- package/src/admin/editor/panels/settings/AdvancedFields.tsx +12 -2
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +51 -35
- 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 +12 -8
- 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/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 +17 -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/forms-api.ts +2 -0
- 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 +49 -7
- 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 +4 -2
- package/src/admin/image-editor/load.ts +9 -2
- package/src/admin/image-editor/parts.tsx +51 -2
- package/src/admin/image-editor/save.ts +23 -7
- 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 +27 -7
- package/src/admin/pages/list-kit.tsx +106 -24
- package/src/admin/search.ts +15 -0
- package/src/admin/setup/useSetupStatus.ts +1 -1
- package/src/admin/theme-api.ts +13 -3
- package/src/admin/ui.ts +73 -22
- package/src/astro/floats/runtime.ts +21 -0
- package/src/astro/menu/runtime.ts +34 -1
- package/src/astro/popups/runtime.ts +33 -3
- 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 +171 -24
- package/src/core/arrange.ts +27 -6
- 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/data/bindings.ts +8 -1
- package/src/core/design/classes.ts +16 -7
- package/src/core/design/diff.ts +6 -0
- package/src/core/design/merge.ts +90 -2
- 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 +44 -5
- package/src/core/elements/form-elements.ts +55 -16
- package/src/core/elements/index.ts +83 -38
- package/src/core/elements/menu.ts +37 -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/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 +15 -1
- package/src/core/limits.ts +12 -1
- 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 +43 -7
- 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 +15 -2
- package/src/core/sanitize/embed-url.ts +42 -5
- package/src/core/sanitize/url.ts +2 -1
- package/src/core/schema/layout.ts +15 -6
- 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 +9 -2
- package/src/core/theme/pagination.ts +31 -11
- 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/rate-limit.ts +2 -1
- package/src/mcp/read.ts +14 -2
- package/src/mcp/refs.ts +18 -0
- package/src/mcp/write.ts +174 -10
- 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 +6 -1
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type Audience,
|
|
6
6
|
type LayoutNode,
|
|
7
7
|
} from "../../../../core/index.ts";
|
|
8
|
+
import { PanelSelect } from "./PanelSelect.tsx";
|
|
8
9
|
|
|
9
10
|
const DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
10
11
|
const COUNTRY = /^[A-Z]{2}$/;
|
|
@@ -16,7 +17,10 @@ export function parseCountries(text: string): string[] {
|
|
|
16
17
|
const codes = text
|
|
17
18
|
.toUpperCase()
|
|
18
19
|
.split(/[\s,;]+/)
|
|
19
|
-
.filter((code) => COUNTRY.test(code))
|
|
20
|
+
.filter((code) => COUNTRY.test(code))
|
|
21
|
+
// W-544: visitors' country codes are ISO ones, where the United Kingdom is GB; a "UK" rule
|
|
22
|
+
// never matched anyone.
|
|
23
|
+
.map((code) => (code === "UK" ? "GB" : code));
|
|
20
24
|
return [...new Set(codes)].slice(0, 50);
|
|
21
25
|
}
|
|
22
26
|
|
|
@@ -88,6 +92,8 @@ export function AudienceEditor({
|
|
|
88
92
|
setSegmentText(node.audience?.segments?.join(", ") ?? "");
|
|
89
93
|
setZoneText(node.audience?.timeZone ?? "");
|
|
90
94
|
setZoneError(null);
|
|
95
|
+
// W-608: another element's rejected segment name isn't this one's error.
|
|
96
|
+
setSegmentError(null);
|
|
91
97
|
}, [node.id]);
|
|
92
98
|
if (isRoot) return null;
|
|
93
99
|
const audience = node.audience;
|
|
@@ -104,23 +110,25 @@ export function AudienceEditor({
|
|
|
104
110
|
<h3 className="emvb-bind-title" id={`${id}-title`}>
|
|
105
111
|
Visitors
|
|
106
112
|
</h3>
|
|
107
|
-
<
|
|
108
|
-
<span className="emvb-bind-label"
|
|
109
|
-
|
|
110
|
-
|
|
113
|
+
<div className="emvb-bind-row">
|
|
114
|
+
<span className="emvb-bind-label" id={`${id}-show`}>
|
|
115
|
+
Show to
|
|
116
|
+
</span>
|
|
117
|
+
<PanelSelect
|
|
118
|
+
labelledBy={`${id}-show`}
|
|
111
119
|
value={mode}
|
|
112
|
-
data-emvb-audience-mode
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
data={{ "data-emvb-audience-mode": "" }}
|
|
121
|
+
options={[
|
|
122
|
+
{ value: "everyone", label: "Everyone" },
|
|
123
|
+
{ value: "only", label: "Only visitors who match" },
|
|
124
|
+
{ value: "except", label: "Everyone except visitors who match" },
|
|
125
|
+
]}
|
|
126
|
+
onChange={(value) => {
|
|
115
127
|
if (value === "everyone") set(undefined);
|
|
116
128
|
else set({ ...base, hide: value === "except" });
|
|
117
129
|
}}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
<option value="only">Only visitors who match</option>
|
|
121
|
-
<option value="except">Everyone except visitors who match</option>
|
|
122
|
-
</select>
|
|
123
|
-
</label>
|
|
130
|
+
/>
|
|
131
|
+
</div>
|
|
124
132
|
{audience && (
|
|
125
133
|
<>
|
|
126
134
|
<label className="emvb-bind-row">
|
|
@@ -158,23 +166,25 @@ export function AudienceEditor({
|
|
|
158
166
|
</label>
|
|
159
167
|
))}
|
|
160
168
|
</fieldset>
|
|
161
|
-
<
|
|
162
|
-
<span className="emvb-bind-label">
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
<div className="emvb-bind-row">
|
|
170
|
+
<span className="emvb-bind-label" id={`${id}-visit`}>
|
|
171
|
+
Visit
|
|
172
|
+
</span>
|
|
173
|
+
<PanelSelect
|
|
174
|
+
labelledBy={`${id}-visit`}
|
|
165
175
|
value={base.visitor ?? "any"}
|
|
166
|
-
data-emvb-audience-visitor
|
|
167
|
-
|
|
168
|
-
|
|
176
|
+
data={{ "data-emvb-audience-visitor": "" }}
|
|
177
|
+
options={[
|
|
178
|
+
{ value: "any", label: "New or returning" },
|
|
179
|
+
{ value: "new", label: "First visit" },
|
|
180
|
+
{ value: "returning", label: "Returning visitor" },
|
|
181
|
+
]}
|
|
182
|
+
onChange={(value) => {
|
|
169
183
|
const { visitor: _v, ...rest } = base;
|
|
170
184
|
set(value === "new" || value === "returning" ? { ...rest, visitor: value } : rest);
|
|
171
185
|
}}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
<option value="new">First visit</option>
|
|
175
|
-
<option value="returning">Returning visitor</option>
|
|
176
|
-
</select>
|
|
177
|
-
</label>
|
|
186
|
+
/>
|
|
187
|
+
</div>
|
|
178
188
|
<label className="emvb-bind-row">
|
|
179
189
|
<span className="emvb-bind-label">Segments (from your site)</span>
|
|
180
190
|
<input
|
|
@@ -221,9 +231,12 @@ export function AudienceEditor({
|
|
|
221
231
|
</span>
|
|
222
232
|
)}
|
|
223
233
|
</label>
|
|
224
|
-
{
|
|
234
|
+
{ruleCount(base) === 0 && (
|
|
225
235
|
<p className="emvb-helper" data-emvb-audience-empty="">
|
|
226
|
-
|
|
236
|
+
{mode === "only"
|
|
237
|
+
? "Add a country, device, segment, or time. Until then, everyone sees this."
|
|
238
|
+
: // W-608: with no rule every visitor matches, so "except" hides it from all.
|
|
239
|
+
"Add a country, device, segment, or time. Until then, this is hidden from every visitor."}
|
|
227
240
|
</p>
|
|
228
241
|
)}
|
|
229
242
|
<div className="emvb-bind-row">
|
|
@@ -239,9 +252,11 @@ export function AudienceEditor({
|
|
|
239
252
|
onChange={(event) => {
|
|
240
253
|
const raw = event.currentTarget.value;
|
|
241
254
|
const { hours: _h, ...rest } = base;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
255
|
+
const to = base.hours?.to ?? 24;
|
|
256
|
+
// W-615: clearing one end keeps the other; only all-day (0–24) drops the rule.
|
|
257
|
+
const from = raw === "" ? 0 : Math.min(23, Math.max(0, Math.round(Number(raw))));
|
|
258
|
+
if (from === 0 && to === 24) return set(rest);
|
|
259
|
+
set({ ...rest, hours: { from, to } });
|
|
245
260
|
}}
|
|
246
261
|
/>
|
|
247
262
|
<input
|
|
@@ -255,9 +270,10 @@ export function AudienceEditor({
|
|
|
255
270
|
onChange={(event) => {
|
|
256
271
|
const raw = event.currentTarget.value;
|
|
257
272
|
const { hours: _h, ...rest } = base;
|
|
258
|
-
|
|
259
|
-
const to = Math.min(24, Math.max(0, Math.round(Number(raw))));
|
|
260
|
-
|
|
273
|
+
const from = base.hours?.from ?? 0;
|
|
274
|
+
const to = raw === "" ? 24 : Math.min(24, Math.max(0, Math.round(Number(raw))));
|
|
275
|
+
if (from === 0 && to === 24) return set(rest);
|
|
276
|
+
set({ ...rest, hours: { from, to } });
|
|
261
277
|
}}
|
|
262
278
|
/>
|
|
263
279
|
</div>
|
|
@@ -7,6 +7,7 @@ import { listImages, uploadImage, type MediaLibraryItem } from "../../../media-a
|
|
|
7
7
|
import { BUTTON, FIELD } from "../../../ui.ts";
|
|
8
8
|
import { ColorControl } from "../ColorControl.tsx";
|
|
9
9
|
import { NumberField, type NumberSpec } from "./NumberRow.tsx";
|
|
10
|
+
import { isCommitEnter } from "../../ime.ts";
|
|
10
11
|
|
|
11
12
|
type Gradient = NonNullable<StyleProps["gradient"]>;
|
|
12
13
|
type Overlay = NonNullable<StyleProps["overlay"]>;
|
|
@@ -47,10 +48,24 @@ export function BackgroundImageControl({
|
|
|
47
48
|
const src = value ?? "";
|
|
48
49
|
const [open, setOpen] = React.useState(false);
|
|
49
50
|
const [items, setItems] = React.useState<MediaLibraryItem[]>([]);
|
|
50
|
-
const [busy,
|
|
51
|
+
const [busy, setBusyState] = React.useState(false);
|
|
52
|
+
// W-824: Choose from library and Upload stay focusable while busy (aria-disabled, presses
|
|
53
|
+
// ignored), like W-819, so keyboard focus no longer drops to the page body during an upload.
|
|
54
|
+
const busyRef = React.useRef(false);
|
|
55
|
+
const setBusy = React.useCallback((next: boolean) => {
|
|
56
|
+
busyRef.current = next;
|
|
57
|
+
setBusyState(next);
|
|
58
|
+
}, []);
|
|
51
59
|
const [error, setError] = React.useState<string | null>(null);
|
|
52
60
|
const [urlDraft, setUrlDraft] = React.useState(src);
|
|
53
61
|
const fileRef = React.useRef<HTMLInputElement>(null);
|
|
62
|
+
// W-823: the background Media library didn't take focus, ignored Escape and dropped focus to
|
|
63
|
+
// the page body when it closed. It now behaves like the image picker's library (W-741/W-817).
|
|
64
|
+
const libraryOpenerRef = React.useRef<HTMLButtonElement>(null);
|
|
65
|
+
const closeLibrary = () => {
|
|
66
|
+
setOpen(false);
|
|
67
|
+
libraryOpenerRef.current?.focus();
|
|
68
|
+
};
|
|
54
69
|
|
|
55
70
|
React.useEffect(() => {
|
|
56
71
|
setUrlDraft(src);
|
|
@@ -68,7 +83,7 @@ export function BackgroundImageControl({
|
|
|
68
83
|
} finally {
|
|
69
84
|
setBusy(false);
|
|
70
85
|
}
|
|
71
|
-
}, [fetcher]);
|
|
86
|
+
}, [fetcher, setBusy]);
|
|
72
87
|
|
|
73
88
|
React.useEffect(() => {
|
|
74
89
|
if (open) void loadLibrary();
|
|
@@ -122,8 +137,11 @@ export function BackgroundImageControl({
|
|
|
122
137
|
<Button
|
|
123
138
|
type="button"
|
|
124
139
|
className={BUTTON}
|
|
125
|
-
onClick={() =>
|
|
126
|
-
|
|
140
|
+
onClick={() => {
|
|
141
|
+
if (!busyRef.current) setOpen(true);
|
|
142
|
+
}}
|
|
143
|
+
aria-disabled={busy}
|
|
144
|
+
ref={libraryOpenerRef}
|
|
127
145
|
data-emvb-bg-library=""
|
|
128
146
|
>
|
|
129
147
|
Choose from library
|
|
@@ -132,8 +150,10 @@ export function BackgroundImageControl({
|
|
|
132
150
|
type="button"
|
|
133
151
|
className={BUTTON}
|
|
134
152
|
variant="secondary"
|
|
135
|
-
onClick={() =>
|
|
136
|
-
|
|
153
|
+
onClick={() => {
|
|
154
|
+
if (!busyRef.current) fileRef.current?.click();
|
|
155
|
+
}}
|
|
156
|
+
aria-disabled={busy}
|
|
137
157
|
data-emvb-bg-upload-btn=""
|
|
138
158
|
>
|
|
139
159
|
Upload
|
|
@@ -143,6 +163,8 @@ export function BackgroundImageControl({
|
|
|
143
163
|
type="file"
|
|
144
164
|
accept="image/png,image/jpeg,image/gif,image/webp,image/avif"
|
|
145
165
|
className="emvb-sr-only"
|
|
166
|
+
tabIndex={-1}
|
|
167
|
+
aria-hidden="true"
|
|
146
168
|
data-emvb-bg-upload=""
|
|
147
169
|
onChange={(event) => {
|
|
148
170
|
const file = event.target.files?.[0];
|
|
@@ -170,18 +192,29 @@ export function BackgroundImageControl({
|
|
|
170
192
|
onChange={(event) => setUrlDraft(event.target.value)}
|
|
171
193
|
onBlur={() => commitUrl(false)}
|
|
172
194
|
onKeyDown={(event) => {
|
|
173
|
-
if (event
|
|
195
|
+
if (isCommitEnter(event)) commitUrl(true);
|
|
174
196
|
}}
|
|
175
197
|
/>
|
|
176
198
|
{open && (
|
|
177
|
-
<div
|
|
199
|
+
<div
|
|
200
|
+
className="emvb-media-dialog"
|
|
201
|
+
role="dialog"
|
|
202
|
+
aria-label="Media library"
|
|
203
|
+
onKeyDown={(event) => {
|
|
204
|
+
if (event.key !== "Escape" || event.defaultPrevented) return;
|
|
205
|
+
event.preventDefault();
|
|
206
|
+
event.stopPropagation();
|
|
207
|
+
closeLibrary();
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
178
210
|
<div className="emvb-media-dialog-head">
|
|
179
211
|
<h3 className="emvb-panel-title">Media library</h3>
|
|
180
212
|
<Button
|
|
181
213
|
type="button"
|
|
182
214
|
className={BUTTON}
|
|
183
215
|
variant="secondary"
|
|
184
|
-
|
|
216
|
+
autoFocus
|
|
217
|
+
onClick={closeLibrary}
|
|
185
218
|
>
|
|
186
219
|
Close
|
|
187
220
|
</Button>
|
|
@@ -195,7 +228,10 @@ export function BackgroundImageControl({
|
|
|
195
228
|
type="button"
|
|
196
229
|
className="emvb-media-card"
|
|
197
230
|
data-emvb-bg-media-id={item.id}
|
|
198
|
-
onClick={() =>
|
|
231
|
+
onClick={() => {
|
|
232
|
+
applyUrl(item.url);
|
|
233
|
+
libraryOpenerRef.current?.focus();
|
|
234
|
+
}}
|
|
199
235
|
>
|
|
200
236
|
<img src={item.url} alt={item.alt ?? item.filename} />
|
|
201
237
|
<span>{item.filename}</span>
|
|
@@ -229,6 +265,9 @@ const RADIAL_AT = [
|
|
|
229
265
|
"bottom right",
|
|
230
266
|
] as const;
|
|
231
267
|
|
|
268
|
+
/** "top left" → "Top left". */
|
|
269
|
+
const sentence = (text: string) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
270
|
+
|
|
232
271
|
/** Linear, radial or conic, with 2–10 stops. Angle is a slider and a number. */
|
|
233
272
|
export function GradientControl({
|
|
234
273
|
value,
|
|
@@ -268,6 +307,10 @@ export function GradientControl({
|
|
|
268
307
|
label="Gradient type"
|
|
269
308
|
className={FIELD}
|
|
270
309
|
value={value.type}
|
|
310
|
+
// UX-081: triggers show option names ("Linear", "Top left"), not raw values.
|
|
311
|
+
renderValue={(v: unknown) =>
|
|
312
|
+
GRADIENT_TYPES.find((option) => option.value === v)?.label ?? String(v)
|
|
313
|
+
}
|
|
271
314
|
onValueChange={(next) => {
|
|
272
315
|
const type = GRADIENT_TYPES.find((option) => option.value === next)?.value;
|
|
273
316
|
if (type) onChange({ ...value, type });
|
|
@@ -284,6 +327,7 @@ export function GradientControl({
|
|
|
284
327
|
label="Position"
|
|
285
328
|
className={FIELD}
|
|
286
329
|
value={value.position ?? "center"}
|
|
330
|
+
renderValue={(v: unknown) => sentence(String(v))}
|
|
287
331
|
onValueChange={(next) => {
|
|
288
332
|
const position = RADIAL_AT.find((option) => option === next);
|
|
289
333
|
if (position) onChange({ ...value, position });
|
|
@@ -291,7 +335,7 @@ export function GradientControl({
|
|
|
291
335
|
>
|
|
292
336
|
{RADIAL_AT.map((option) => (
|
|
293
337
|
<Select.Option key={option} value={option}>
|
|
294
|
-
{option}
|
|
338
|
+
{sentence(option)}
|
|
295
339
|
</Select.Option>
|
|
296
340
|
))}
|
|
297
341
|
</Select>
|
|
@@ -89,7 +89,8 @@ export function BackgroundFill({
|
|
|
89
89
|
}
|
|
90
90
|
>
|
|
91
91
|
<div className="emvb-field-group emvb-background-fill">
|
|
92
|
-
|
|
92
|
+
{/* UX-033: the section is already "Background"; these rows name their own part. */}
|
|
93
|
+
<span className="emvb-var-field-label">Fill</span>
|
|
93
94
|
<div className="emvb-fill-types" role="radiogroup" aria-label="Background type">
|
|
94
95
|
{modes.map((option) => (
|
|
95
96
|
<button
|
|
@@ -111,7 +112,7 @@ export function BackgroundFill({
|
|
|
111
112
|
)}
|
|
112
113
|
{shown === "color" && (
|
|
113
114
|
<ColorControl
|
|
114
|
-
label="Background"
|
|
115
|
+
label="Background color"
|
|
115
116
|
value={style?.backgroundColor}
|
|
116
117
|
design={design}
|
|
117
118
|
onChange={(backgroundColor) => onPatch({ backgroundColor })}
|
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
type ThemePostFields,
|
|
15
15
|
} from "../../../../core/index.ts";
|
|
16
16
|
import { siteOrigin, useLiveData } from "../../live-data.tsx";
|
|
17
|
+
import { isCommitEnter } from "../../ime.ts";
|
|
18
|
+
import { PanelSelect } from "./PanelSelect.tsx";
|
|
17
19
|
|
|
18
20
|
const KEY = /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;
|
|
19
21
|
const STATIC = "static";
|
|
@@ -72,30 +74,27 @@ export function BindingsEditor({
|
|
|
72
74
|
return (
|
|
73
75
|
<div className="emvb-bind-row" key={field.key} data-emvb-bind-field={field.key}>
|
|
74
76
|
{/* "Text source", not "Text": the field's own input is already named "Text". */}
|
|
75
|
-
<label className="emvb-bind-label"
|
|
77
|
+
<label className="emvb-bind-label" id={`${selectId}-label`}>
|
|
76
78
|
{`${field.label} source`}
|
|
77
79
|
</label>
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
className="emvb-native-select"
|
|
80
|
+
<PanelSelect
|
|
81
|
+
labelledBy={`${selectId}-label`}
|
|
81
82
|
value={source ?? STATIC}
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
data={{ "data-emvb-bind-source": field.key }}
|
|
84
|
+
options={[
|
|
85
|
+
{ value: STATIC, label: "Typed value" },
|
|
86
|
+
...BIND_SOURCES.map((s) => ({ value: s, label: BIND_SOURCE_LABELS[s] })),
|
|
87
|
+
]}
|
|
88
|
+
onChange={(next) => {
|
|
84
89
|
if (next === STATIC) onChange(withBinding(node, field.key, undefined));
|
|
85
90
|
else {
|
|
86
91
|
const src = next as BindSource;
|
|
87
92
|
onChange(withBinding(node, field.key, { source: src, key: firstKey(src) }));
|
|
88
93
|
}
|
|
89
94
|
}}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
<option key={s} value={s}>
|
|
94
|
-
{BIND_SOURCE_LABELS[s]}
|
|
95
|
-
</option>
|
|
96
|
-
))}
|
|
97
|
-
</select>
|
|
98
|
-
{binding ? (
|
|
95
|
+
/>
|
|
96
|
+
{/* UX-039: unbound, the source select is the row's last child and spans it. */}
|
|
97
|
+
{binding && (
|
|
99
98
|
<BindKeyInput
|
|
100
99
|
fieldLabel={field.label}
|
|
101
100
|
binding={binding}
|
|
@@ -103,8 +102,6 @@ export function BindingsEditor({
|
|
|
103
102
|
options={suggestions(binding.source, live.site)}
|
|
104
103
|
onCommit={(key) => onChange(withBinding(node, field.key, { ...binding, key }))}
|
|
105
104
|
/>
|
|
106
|
-
) : (
|
|
107
|
-
<span />
|
|
108
105
|
)}
|
|
109
106
|
{binding && (
|
|
110
107
|
<p className="emvb-bind-live" data-emvb-bind-live="">
|
|
@@ -189,7 +186,7 @@ function BindKeyInput({
|
|
|
189
186
|
onChange={(event) => setDraft(event.target.value)}
|
|
190
187
|
onBlur={commit}
|
|
191
188
|
onKeyDown={(event) => {
|
|
192
|
-
if (event
|
|
189
|
+
if (isCommitEnter(event)) commit();
|
|
193
190
|
}}
|
|
194
191
|
/>
|
|
195
192
|
{options.length > 0 && (
|
|
@@ -20,6 +20,7 @@ import { ResetButton } from "./NumberRow.tsx";
|
|
|
20
20
|
import { STYLE_LABELS } from "./style-sections.ts";
|
|
21
21
|
import { placeholderOf } from "./StyleRow.tsx";
|
|
22
22
|
import { bindKind, boundRef, VariableButton } from "./VariableBinding.tsx";
|
|
23
|
+
import { isCommitEnter } from "../../ime.ts";
|
|
23
24
|
|
|
24
25
|
/** Margin's "auto" menu item: auto left and right margins centre a box with a width (W-151). */
|
|
25
26
|
const autoSidesPatch = (group: BoxGroup): Partial<StyleProps> => ({
|
|
@@ -260,7 +261,7 @@ function SideBox({
|
|
|
260
261
|
onChange={(event) => setDraft(event.target.value)}
|
|
261
262
|
onBlur={() => onCommit(draft)}
|
|
262
263
|
onKeyDown={(event) => {
|
|
263
|
-
if (event
|
|
264
|
+
if (isCommitEnter(event)) onCommit(draft);
|
|
264
265
|
}}
|
|
265
266
|
/>
|
|
266
267
|
<span className="emvb-box-name" aria-hidden="true">
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from "@phosphor-icons/react";
|
|
12
12
|
import * as React from "react";
|
|
13
13
|
import { StateDot } from "./StateSwitcher.tsx";
|
|
14
|
+
import { isCancelEscape, isCommitEnter } from "../../ime.ts";
|
|
14
15
|
|
|
15
16
|
/** Keys the chip box handles itself, so the editor's window shortcuts (delete, arrange) don't. */
|
|
16
17
|
export const stopEditorShortcuts = (event: React.KeyboardEvent) => {
|
|
@@ -23,6 +24,8 @@ type Props = {
|
|
|
23
24
|
active: boolean;
|
|
24
25
|
/** The class has hover, focus or active styles (W-089). */
|
|
25
26
|
hasStates?: boolean;
|
|
27
|
+
/** UX-067: the id names no class in Site styles any more, so there is nothing to edit. */
|
|
28
|
+
missing?: boolean;
|
|
26
29
|
first: boolean;
|
|
27
30
|
last: boolean;
|
|
28
31
|
buttonRef: (el: HTMLButtonElement | null) => void;
|
|
@@ -39,7 +42,10 @@ type Props = {
|
|
|
39
42
|
* duplicates, reorders or removes it, and the × removes it. F2 renames in place.
|
|
40
43
|
*/
|
|
41
44
|
export function ClassChip(props: Props) {
|
|
42
|
-
const { id,
|
|
45
|
+
const { id, active, missing } = props;
|
|
46
|
+
// The visible label reads "Missing (id)"; names read "Remove missing class id".
|
|
47
|
+
const name = missing ? `missing class ${id}` : props.name;
|
|
48
|
+
const label = missing ? `Missing (${id})` : props.name;
|
|
43
49
|
const [renaming, setRenaming] = React.useState(false);
|
|
44
50
|
const main = React.useRef<HTMLButtonElement | null>(null);
|
|
45
51
|
/** Enter, Escape and the blur that can follow them must end one rename only once. */
|
|
@@ -66,6 +72,7 @@ export function ClassChip(props: Props) {
|
|
|
66
72
|
className="emvb-chip"
|
|
67
73
|
data-emvb-class-id={id}
|
|
68
74
|
data-active={active}
|
|
75
|
+
data-missing={missing ? "" : undefined}
|
|
69
76
|
onKeyDown={stopEditorShortcuts}
|
|
70
77
|
>
|
|
71
78
|
{renaming ? (
|
|
@@ -78,8 +85,8 @@ export function ClassChip(props: Props) {
|
|
|
78
85
|
autoFocus
|
|
79
86
|
onFocus={(event) => event.currentTarget.select()}
|
|
80
87
|
onKeyDown={(event) => {
|
|
81
|
-
if (event
|
|
82
|
-
else if (event
|
|
88
|
+
if (isCommitEnter(event)) finish(event.currentTarget.value);
|
|
89
|
+
else if (isCancelEscape(event)) finish(null);
|
|
83
90
|
}}
|
|
84
91
|
onBlur={(event) => finish(event.currentTarget.value)}
|
|
85
92
|
/>
|
|
@@ -92,17 +99,21 @@ export function ClassChip(props: Props) {
|
|
|
92
99
|
}}
|
|
93
100
|
className="emvb-chip-main"
|
|
94
101
|
aria-pressed={active}
|
|
95
|
-
title={
|
|
96
|
-
|
|
102
|
+
title={
|
|
103
|
+
missing
|
|
104
|
+
? "This class isn't in Site styles any more. Remove it from the element."
|
|
105
|
+
: `${name} · .emvb-k-${id}`
|
|
106
|
+
}
|
|
107
|
+
onClick={missing ? undefined : props.onEdit}
|
|
97
108
|
onKeyDown={(event) => {
|
|
98
|
-
if (event.key === "F2") {
|
|
109
|
+
if (event.key === "F2" && !missing) {
|
|
99
110
|
event.preventDefault();
|
|
100
111
|
startRename();
|
|
101
112
|
} else props.onKeyDown(event);
|
|
102
113
|
}}
|
|
103
114
|
>
|
|
104
115
|
<TagSimpleIcon size={12} aria-hidden="true" />
|
|
105
|
-
<span className="emvb-chip-label">{
|
|
116
|
+
<span className="emvb-chip-label">{label}</span>
|
|
106
117
|
{props.hasStates && <StateDot />}
|
|
107
118
|
</button>
|
|
108
119
|
)}
|
|
@@ -119,18 +130,19 @@ export function ClassChip(props: Props) {
|
|
|
119
130
|
</button>
|
|
120
131
|
</DropdownMenu.Trigger>
|
|
121
132
|
<DropdownMenu.Content data-emvb-chip-menu={id}>
|
|
122
|
-
<DropdownMenu.Item icon={PaintBrushIcon} onClick={props.onEdit}>
|
|
133
|
+
<DropdownMenu.Item icon={PaintBrushIcon} disabled={missing} onClick={props.onEdit}>
|
|
123
134
|
Edit class styles
|
|
124
135
|
</DropdownMenu.Item>
|
|
125
136
|
<DropdownMenu.Item
|
|
126
137
|
icon={PencilSimpleLineIcon}
|
|
138
|
+
disabled={missing}
|
|
127
139
|
onClick={() => {
|
|
128
140
|
renameAfterMenu.current = true;
|
|
129
141
|
}}
|
|
130
142
|
>
|
|
131
143
|
Rename
|
|
132
144
|
</DropdownMenu.Item>
|
|
133
|
-
<DropdownMenu.Item icon={CopySimpleIcon} onClick={props.onDuplicate}>
|
|
145
|
+
<DropdownMenu.Item icon={CopySimpleIcon} disabled={missing} onClick={props.onDuplicate}>
|
|
134
146
|
Duplicate
|
|
135
147
|
</DropdownMenu.Item>
|
|
136
148
|
<DropdownMenu.Item
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
removeClassId,
|
|
10
10
|
renameClass,
|
|
11
11
|
classNameTaken,
|
|
12
|
+
cleanClassName,
|
|
12
13
|
classNameTakenMessage,
|
|
13
14
|
replaceClassId,
|
|
14
15
|
type DesignSystem,
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
MAX_SITE_CLASSES,
|
|
24
25
|
type ClassOption,
|
|
25
26
|
} from "./class-suggest.ts";
|
|
27
|
+
import { isCancelEscape, isCommitEnter } from "../../ime.ts";
|
|
26
28
|
|
|
27
29
|
type Props = {
|
|
28
30
|
applied: readonly string[] | undefined;
|
|
@@ -157,10 +159,11 @@ export function ClassChipInput({
|
|
|
157
159
|
|
|
158
160
|
/** "Save local styles as class" (W-134): one page edit, so one Ctrl+Z puts them back. */
|
|
159
161
|
const saveLocal = async () => {
|
|
160
|
-
|
|
162
|
+
// W-558: cleaned as every class name is, so "Hero title" can't sit beside "Hero title".
|
|
163
|
+
const name = cleanClassName(localName);
|
|
161
164
|
if (!name || !onSaveLocal) return;
|
|
162
|
-
if (
|
|
163
|
-
setError(
|
|
165
|
+
if (classNameTaken(design, name)) {
|
|
166
|
+
setError(classNameTakenMessage(name));
|
|
164
167
|
return;
|
|
165
168
|
}
|
|
166
169
|
setError(null);
|
|
@@ -190,14 +193,14 @@ export function ClassChipInput({
|
|
|
190
193
|
const step = event.key === "ArrowDown" ? 1 : -1;
|
|
191
194
|
setActive(open && options.length > 0 ? (active + step + options.length) % options.length : 0);
|
|
192
195
|
setOpen(true);
|
|
193
|
-
} else if (event
|
|
196
|
+
} else if (isCommitEnter(event)) {
|
|
194
197
|
event.preventDefault();
|
|
195
198
|
if (query.trim() && appliedByName(catalog, ids, query)) {
|
|
196
199
|
setError(`"${query.trim()}" is already on this element.`);
|
|
197
200
|
return;
|
|
198
201
|
}
|
|
199
202
|
choose(current);
|
|
200
|
-
} else if (event
|
|
203
|
+
} else if (isCancelEscape(event)) {
|
|
201
204
|
if (open) setOpen(false);
|
|
202
205
|
else reset();
|
|
203
206
|
} else if (event.key === "Backspace" && query === "" && ids.length > 0) {
|
|
@@ -275,6 +278,7 @@ export function ClassChipInput({
|
|
|
275
278
|
key={id}
|
|
276
279
|
id={id}
|
|
277
280
|
name={byId.get(id)?.name ?? id}
|
|
281
|
+
missing={!byId.has(id)}
|
|
278
282
|
active={editing === id}
|
|
279
283
|
hasStates={hasStateStyles(byId.get(id))}
|
|
280
284
|
first={index === 0}
|
|
@@ -409,13 +413,17 @@ export function ClassChipInput({
|
|
|
409
413
|
setError(null);
|
|
410
414
|
}}
|
|
411
415
|
onKeyDown={(event) => {
|
|
412
|
-
if (event
|
|
416
|
+
if (isCommitEnter(event)) {
|
|
413
417
|
event.preventDefault();
|
|
414
418
|
void saveLocal();
|
|
415
|
-
} else if (event
|
|
419
|
+
} else if (isCancelEscape(event)) closeNaming();
|
|
416
420
|
}}
|
|
417
421
|
/>
|
|
418
|
-
|
|
422
|
+
{/* UX-064: Cancel, then the action, right-aligned, like New variable and dialogs. */}
|
|
423
|
+
<div className="emvb-dialog-actions emvb-save-local-actions">
|
|
424
|
+
<Button type="button" variant="secondary" className={BUTTON} onClick={closeNaming}>
|
|
425
|
+
Cancel
|
|
426
|
+
</Button>
|
|
419
427
|
<Button
|
|
420
428
|
type="button"
|
|
421
429
|
variant="primary"
|
|
@@ -425,9 +433,6 @@ export function ClassChipInput({
|
|
|
425
433
|
>
|
|
426
434
|
Save as class
|
|
427
435
|
</Button>
|
|
428
|
-
<Button type="button" variant="ghost" className={BUTTON} onClick={closeNaming}>
|
|
429
|
-
Cancel
|
|
430
|
-
</Button>
|
|
431
436
|
</div>
|
|
432
437
|
</div>
|
|
433
438
|
)}
|
|
@@ -441,11 +446,14 @@ export function ClassChipInput({
|
|
|
441
446
|
{error}
|
|
442
447
|
</p>
|
|
443
448
|
)}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
+
{/* UX-025: the cascade rule only matters once two classes can disagree. */}
|
|
450
|
+
{(full || ids.length >= 2) && (
|
|
451
|
+
<p className="emvb-helper" data-emvb-cascade-caption="">
|
|
452
|
+
{full
|
|
453
|
+
? `${MAX_ELEMENT_CLASSES} classes is the most one element can have.`
|
|
454
|
+
: "When two classes set the same property, the one lower in Site styles wins. Local styles still win."}
|
|
455
|
+
</p>
|
|
456
|
+
)}
|
|
449
457
|
</div>
|
|
450
458
|
);
|
|
451
459
|
}
|