@perkyzz/emvb 0.5.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/README.md +4 -0
- package/THIRD_PARTY_NOTICES.md +23 -1
- package/licenses/exif-js.LICENSE +21 -0
- package/licenses/fflate.LICENSE +21 -0
- package/licenses/glfx.js.LICENSE +19 -0
- package/licenses/mini-photo-editor.LICENSE +21 -0
- package/licenses/photocn.LICENSE +21 -0
- package/package.json +2 -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 +88 -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 +16 -1
- 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 +108 -7
- package/src/admin/editor/editor-commands.ts +15 -1
- package/src/admin/editor/editor-css.ts +75 -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 +135 -27
- 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 +68 -22
- 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 +53 -21
- 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 +38 -15
- 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 +274 -20
- 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 +141 -0
- 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 +25 -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 +14 -3
- 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/BlurFocus.tsx +112 -0
- package/src/admin/image-editor/Canvas.tsx +261 -0
- package/src/admin/image-editor/CropOverlay.tsx +390 -0
- package/src/admin/image-editor/CurvesPanel.tsx +395 -0
- package/src/admin/image-editor/ExportDialog.tsx +384 -0
- package/src/admin/image-editor/ImageEditButton.tsx +83 -0
- package/src/admin/image-editor/ImageEditorDialog.tsx +828 -0
- package/src/admin/image-editor/MetadataPanel.tsx +194 -0
- package/src/admin/image-editor/announce.tsx +65 -0
- package/src/admin/image-editor/crop-geometry.ts +162 -0
- package/src/admin/image-editor/curve-math.ts +177 -0
- package/src/admin/image-editor/data-url-fetch.ts +59 -0
- package/src/admin/image-editor/engine.ts +55 -0
- package/src/admin/image-editor/exif.ts +82 -0
- package/src/admin/image-editor/flatten.ts +54 -0
- package/src/admin/image-editor/gpu-fit.ts +81 -0
- package/src/admin/image-editor/image-editor-css.ts +400 -0
- package/src/admin/image-editor/load.ts +116 -0
- package/src/admin/image-editor/panels.tsx +287 -0
- package/src/admin/image-editor/parts.tsx +614 -0
- package/src/admin/image-editor/save.ts +141 -0
- package/src/admin/image-editor/tone-panels.tsx +338 -0
- package/src/admin/image-editor/tools.ts +59 -0
- package/src/admin/image-editor/worker.ts +111 -0
- package/src/admin/media-api.ts +114 -3
- 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 +78 -22
- package/src/astro/EmVBPage.astro +11 -2
- 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 +6 -0
- package/src/astro/resolve-theme.ts +67 -14
- 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 +6 -3
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +171 -24
- package/src/core/arrange.ts +29 -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 +19 -6
- package/src/core/design/classes.ts +20 -9
- package/src/core/design/diff.ts +9 -1
- package/src/core/design/merge.ts +93 -3
- package/src/core/design/tokens.ts +16 -2
- package/src/core/design/transfer.ts +46 -8
- package/src/core/design/variables.ts +32 -10
- package/src/core/elements/dynamic-elements.ts +53 -6
- package/src/core/elements/form-elements.ts +68 -30
- package/src/core/elements/index.ts +83 -38
- package/src/core/elements/menu.ts +37 -19
- package/src/core/elements/plain-text.ts +2 -2
- package/src/core/elements/select-prompt.ts +3 -0
- package/src/core/elements/svg-ids.ts +39 -0
- package/src/core/forms/binding.ts +190 -2
- package/src/core/forms/definition.ts +72 -0
- package/src/core/history/diff.ts +49 -4
- package/src/core/icons/catalog.ts +3 -2
- package/src/core/image-edit/schema.ts +155 -0
- package/src/core/image-edit/summary.ts +61 -0
- package/src/core/index.ts +29 -1
- package/src/core/limits.ts +21 -0
- package/src/core/migrate/index.ts +3 -1
- package/src/core/perf/meter.ts +51 -8
- package/src/core/recipes/index.ts +5 -4
- package/src/core/render/context.ts +8 -0
- package/src/core/render/dynamic-post.ts +71 -13
- package/src/core/render/extras.ts +77 -4
- package/src/core/render/form.ts +164 -12
- package/src/core/render/index.ts +179 -22
- 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 +26 -7
- package/src/core/share/link.ts +5 -2
- package/src/core/stable-json.ts +15 -0
- package/src/core/stats.ts +2 -1
- package/src/core/theme/conditions.ts +3 -1
- package/src/core/theme/dynamic.ts +57 -23
- package/src/core/theme/float.ts +9 -2
- package/src/core/theme/pagination.ts +57 -10
- package/src/core/theme/popup-markup.ts +23 -5
- package/src/core/theme/popup-rules.ts +11 -5
- package/src/core/theme/triggers.ts +3 -2
- package/src/core/tree-ops.ts +27 -0
- package/src/mcp/ports.ts +8 -1
- package/src/mcp/rate-limit.ts +2 -1
- package/src/mcp/read.ts +82 -3
- package/src/mcp/refs.ts +18 -0
- package/src/mcp/tools.ts +1 -1
- package/src/mcp/write.ts +271 -25
- package/src/server/agent-settings.ts +29 -4
- package/src/server/hooks.ts +5 -3
- package/src/server/icon-routes.ts +33 -9
- package/src/server/mcp-routes.ts +74 -11
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from "../../../core/index.ts";
|
|
10
10
|
import { BUTTON, FIELD } from "../../ui.ts";
|
|
11
11
|
import { TriggerSettings } from "./TriggerSettings.tsx";
|
|
12
|
+
import { isCommitEnter } from "../ime.ts";
|
|
12
13
|
|
|
13
14
|
type Props = {
|
|
14
15
|
triggers: TriggersDoc | undefined;
|
|
@@ -70,7 +71,7 @@ function ShowTimesField({
|
|
|
70
71
|
onChange={(event) => setDraft(event.target.value)}
|
|
71
72
|
onBlur={commit}
|
|
72
73
|
onKeyDown={(event) => {
|
|
73
|
-
if (event
|
|
74
|
+
if (isCommitEnter(event)) commit();
|
|
74
75
|
}}
|
|
75
76
|
/>
|
|
76
77
|
);
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
type VariableKind,
|
|
27
27
|
} from "../../../core/index.ts";
|
|
28
28
|
import { FIELD } from "../../ui.ts";
|
|
29
|
+
import { useEditedNoun } from "../edited-noun.ts";
|
|
29
30
|
import { InlineError } from "./inline-error.tsx";
|
|
30
31
|
import {
|
|
31
32
|
CreateRow,
|
|
@@ -41,9 +42,11 @@ import {
|
|
|
41
42
|
lengthPx,
|
|
42
43
|
parseValue,
|
|
43
44
|
pickerHex,
|
|
45
|
+
withPreviousAlpha,
|
|
44
46
|
valueText,
|
|
45
47
|
type Length,
|
|
46
48
|
} from "./variable-values.ts";
|
|
49
|
+
import { isCancelEscape, isCommitEnter } from "../ime.ts";
|
|
47
50
|
|
|
48
51
|
const VAR_TOKEN: Record<VariableKind, (id: string) => string> = {
|
|
49
52
|
color: (id) => `--emvb-c-${id}`,
|
|
@@ -162,8 +165,9 @@ function ValueEditor({
|
|
|
162
165
|
const el = picker.current;
|
|
163
166
|
if (!el) return;
|
|
164
167
|
const onChange = () => {
|
|
165
|
-
|
|
166
|
-
|
|
168
|
+
const picked = withPreviousAlpha(el.value, committed.current);
|
|
169
|
+
setText(picked);
|
|
170
|
+
commit(picked);
|
|
167
171
|
};
|
|
168
172
|
el.addEventListener("change", onChange);
|
|
169
173
|
return () => el.removeEventListener("change", onChange);
|
|
@@ -179,7 +183,7 @@ function ValueEditor({
|
|
|
179
183
|
className="emvb-site-picker"
|
|
180
184
|
aria-label={`Pick ${item.name}`}
|
|
181
185
|
value={pickerHex(error ? current : text)}
|
|
182
|
-
onChange={(event) => setText(event.target.value)}
|
|
186
|
+
onChange={(event) => setText(withPreviousAlpha(event.target.value, committed.current))}
|
|
183
187
|
/>
|
|
184
188
|
)}
|
|
185
189
|
<Input
|
|
@@ -193,8 +197,8 @@ function ValueEditor({
|
|
|
193
197
|
}}
|
|
194
198
|
onBlur={(event) => commit(event.currentTarget.value)}
|
|
195
199
|
onKeyDown={(event) => {
|
|
196
|
-
if (event
|
|
197
|
-
else if (event
|
|
200
|
+
if (isCommitEnter(event)) commit(event.currentTarget.value);
|
|
201
|
+
else if (isCancelEscape(event)) {
|
|
198
202
|
event.stopPropagation();
|
|
199
203
|
setText(committed.current);
|
|
200
204
|
setError(null);
|
|
@@ -231,9 +235,10 @@ export function VariableSection({
|
|
|
231
235
|
kind: VariableKind;
|
|
232
236
|
design: DesignSystem;
|
|
233
237
|
layout: Layout | null;
|
|
234
|
-
onSave: (design: DesignSystem) => Promise<void>;
|
|
238
|
+
onSave: (design: DesignSystem) => Promise<boolean | void>;
|
|
235
239
|
onAskDelete: (id: string, name: string) => void;
|
|
236
240
|
}) {
|
|
241
|
+
const noun = useEditedNoun();
|
|
237
242
|
const listKey = LIST_KEY[kind];
|
|
238
243
|
const items: readonly Item[] = design.variables[listKey] ?? [];
|
|
239
244
|
const [creating, setCreating] = React.useState(false);
|
|
@@ -248,8 +253,17 @@ export function VariableSection({
|
|
|
248
253
|
const [nameError, setNameError] = React.useState<string | null>(null);
|
|
249
254
|
const [open, setOpen] = React.useState<string | null>(null);
|
|
250
255
|
const [renaming, setRenaming] = React.useState<string | null>(null);
|
|
251
|
-
|
|
256
|
+
// W-616: what was typed in a rename whose save failed, so the reopened field keeps it.
|
|
257
|
+
const [renameDraft, setRenameDraft] = React.useState<string | null>(null);
|
|
258
|
+
// W-778: a failed copy says so in the row too; it used to do nothing at all.
|
|
259
|
+
const [copied, setCopied] = React.useState<{ id: string; ok: boolean } | null>(null);
|
|
252
260
|
const rows = React.useRef(new Map<string, HTMLButtonElement>());
|
|
261
|
+
// W-840: the create row goes away on Create or Cancel; focus lands on the new row or on New.
|
|
262
|
+
const section = React.useRef<HTMLElement | null>(null);
|
|
263
|
+
const focusNew = () =>
|
|
264
|
+
requestAnimationFrame(() =>
|
|
265
|
+
section.current?.querySelector<HTMLButtonElement>(".emvb-site-section-head button")?.focus(),
|
|
266
|
+
);
|
|
253
267
|
|
|
254
268
|
const saveValue = (id: string, next: string | Length) =>
|
|
255
269
|
void onSave({
|
|
@@ -288,36 +302,48 @@ export function VariableSection({
|
|
|
288
302
|
items.map((item) => item.id),
|
|
289
303
|
);
|
|
290
304
|
const entry = { id, name: trimmed, value: parsed.value };
|
|
291
|
-
|
|
305
|
+
const next = { ...design, variables: { ...design.variables, [listKey]: [...items, entry] } };
|
|
306
|
+
// W-610: a failed save keeps the row and what was typed, so it can be retried.
|
|
307
|
+
if ((await onSave(next)) === false) return;
|
|
292
308
|
setCreating(false);
|
|
293
309
|
setName("");
|
|
294
310
|
setValue(NEW_VALUE[kind]);
|
|
311
|
+
requestAnimationFrame(() => rows.current.get(id)?.focus());
|
|
295
312
|
};
|
|
296
313
|
|
|
297
|
-
const rename = (id: string, next: string | null) => {
|
|
314
|
+
const rename = async (id: string, next: string | null) => {
|
|
298
315
|
setRenaming(null);
|
|
316
|
+
setRenameDraft(null);
|
|
299
317
|
requestAnimationFrame(() => rows.current.get(id)?.focus());
|
|
300
318
|
if (next && variableNameTaken(design, kind, next, id)) {
|
|
301
319
|
setNameError(variableNameTakenMessage(next));
|
|
302
320
|
return;
|
|
303
321
|
}
|
|
304
322
|
setNameError(null);
|
|
305
|
-
if (next)
|
|
323
|
+
if (!next) return;
|
|
324
|
+
const renamed = renameVariable(design, id, kind, next);
|
|
325
|
+
if (renamed !== design && (await onSave(renamed)) === false) {
|
|
326
|
+
setRenameDraft(next);
|
|
327
|
+
setRenaming(id);
|
|
328
|
+
}
|
|
306
329
|
};
|
|
307
330
|
|
|
308
331
|
const copy = (id: string, token: string) => {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
332
|
+
const show = (ok: boolean) => {
|
|
333
|
+
const mark = { id, ok };
|
|
334
|
+
setCopied(mark);
|
|
335
|
+
setTimeout(() => setCopied((now) => (now === mark ? null : now)), ok ? 1500 : 4000);
|
|
336
|
+
};
|
|
337
|
+
if (!navigator.clipboard?.writeText) return show(false);
|
|
338
|
+
void navigator.clipboard.writeText(`var(${token})`).then(
|
|
339
|
+
() => show(true),
|
|
340
|
+
() => show(false),
|
|
315
341
|
);
|
|
316
342
|
};
|
|
317
343
|
|
|
318
344
|
const EmptyIcon = EMPTY[kind].icon;
|
|
319
345
|
return (
|
|
320
|
-
<section className="emvb-site-section" data-emvb-var-kind={kind}>
|
|
346
|
+
<section ref={section} className="emvb-site-section" data-emvb-var-kind={kind}>
|
|
321
347
|
<SectionHead
|
|
322
348
|
title={title}
|
|
323
349
|
count={items.length}
|
|
@@ -325,7 +351,7 @@ export function VariableSection({
|
|
|
325
351
|
onNew={() => setCreating(true)}
|
|
326
352
|
newDisabled={variableListFull(design, kind)}
|
|
327
353
|
/>
|
|
328
|
-
{items.length > 3 && (
|
|
354
|
+
{(items.length > 3 || filter.length > 0) && (
|
|
329
355
|
<SiteSearch
|
|
330
356
|
label={`Search ${title.toLowerCase()}`}
|
|
331
357
|
value={filter}
|
|
@@ -369,8 +395,9 @@ export function VariableSection({
|
|
|
369
395
|
<Preview kind={kind} value={item.value} />
|
|
370
396
|
<RenameInput
|
|
371
397
|
name={item.name}
|
|
398
|
+
initial={renameDraft ?? undefined}
|
|
372
399
|
label={`Rename ${item.name}`}
|
|
373
|
-
onDone={(next) => rename(item.id, next)}
|
|
400
|
+
onDone={(next) => void rename(item.id, next)}
|
|
374
401
|
/>
|
|
375
402
|
</span>
|
|
376
403
|
) : (
|
|
@@ -425,13 +452,17 @@ export function VariableSection({
|
|
|
425
452
|
)}
|
|
426
453
|
<span
|
|
427
454
|
className="emvb-site-usage"
|
|
428
|
-
title={`Used ${onPage} ${onPage === 1 ? "time" : "times"} on this
|
|
455
|
+
title={`Used ${onPage} ${onPage === 1 ? "time" : "times"} on this ${noun}${
|
|
429
456
|
inClasses ? ` and in ${inClasses} ${inClasses === 1 ? "class" : "classes"}` : ""
|
|
430
457
|
}`}
|
|
431
458
|
data-emvb-usage=""
|
|
432
459
|
aria-live="polite"
|
|
433
460
|
>
|
|
434
|
-
{copied === item.id
|
|
461
|
+
{copied?.id === item.id
|
|
462
|
+
? copied.ok
|
|
463
|
+
? "Copied"
|
|
464
|
+
: "Couldn't copy"
|
|
465
|
+
: usageText(onPage, inClasses)}
|
|
435
466
|
</span>
|
|
436
467
|
<RowMenu
|
|
437
468
|
label={`Actions for ${item.name}`}
|
|
@@ -494,6 +525,7 @@ export function VariableSection({
|
|
|
494
525
|
onCancel={() => {
|
|
495
526
|
setCreating(false);
|
|
496
527
|
setCreateError(null);
|
|
528
|
+
focusNew();
|
|
497
529
|
}}
|
|
498
530
|
onCreate={() => void create()}
|
|
499
531
|
>
|
|
@@ -66,8 +66,12 @@ export function parseRgb(text: string): Rgba | null {
|
|
|
66
66
|
.split(/[\s,/]+/)
|
|
67
67
|
.filter(Boolean);
|
|
68
68
|
if (parts.length !== 3 && parts.length !== 4) return null;
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
// W-540: CSS also writes channels as percents ("rgb(100% 50% 0%)") or with decimals.
|
|
70
|
+
const nums = parts
|
|
71
|
+
.slice(0, 3)
|
|
72
|
+
.map((part) => (part.endsWith("%") ? (Number(part.slice(0, -1)) / 100) * 255 : Number(part)));
|
|
73
|
+
if (nums.some((n) => !Number.isFinite(n) || n < 0 || n > 255)) return null;
|
|
74
|
+
for (let i = 0; i < 3; i += 1) nums[i] = Math.round(nums[i] ?? 0);
|
|
71
75
|
let a = 1;
|
|
72
76
|
const alpha = parts[3];
|
|
73
77
|
if (alpha !== undefined) {
|
|
@@ -185,7 +189,9 @@ function readOklch(text: string): Oklch | null {
|
|
|
185
189
|
const cRaw = parts[1] ?? "";
|
|
186
190
|
const c = cRaw.endsWith("%") ? (Number(cRaw.slice(0, -1)) / 100) * 0.4 : Number(cRaw);
|
|
187
191
|
const hRaw = parts[2] ?? "";
|
|
188
|
-
|
|
192
|
+
// W-540: a hue is an angle, so CSS's -30 or 400 wrap around the circle.
|
|
193
|
+
const hTurn = Number(hRaw.endsWith("deg") ? hRaw.slice(0, -3) : hRaw);
|
|
194
|
+
const h = Number.isFinite(hTurn) && hRaw !== "" ? ((hTurn % 360) + 360) % 360 : Number.NaN;
|
|
189
195
|
if (!Number.isFinite(l) || l < 0 || l > 100) return null;
|
|
190
196
|
if (!Number.isFinite(c) || c < 0 || c > 0.5) return null;
|
|
191
197
|
if (!Number.isFinite(h) || h < 0 || h > 360) return null;
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
type AttributeRow,
|
|
11
11
|
} from "./advanced-rules.ts";
|
|
12
12
|
import { QueryStyleRows } from "./QueryStyleRows.tsx";
|
|
13
|
+
import { isCommitEnter } from "../../ime.ts";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* CSS id: a value the page can't save (bad characters, or another element's id) stays in the
|
|
@@ -48,6 +49,13 @@ export function HtmlIdField({
|
|
|
48
49
|
);
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
const DIR_NAMES: Record<string, string> = {
|
|
53
|
+
site: "Site default",
|
|
54
|
+
ltr: "Left to right",
|
|
55
|
+
rtl: "Right to left",
|
|
56
|
+
auto: "Auto",
|
|
57
|
+
};
|
|
58
|
+
|
|
51
59
|
/** Text direction for this element only (W-341). Unset follows the site. */
|
|
52
60
|
export function DirectionField({
|
|
53
61
|
node,
|
|
@@ -62,6 +70,8 @@ export function DirectionField({
|
|
|
62
70
|
className={FIELD}
|
|
63
71
|
data-emvb-dir=""
|
|
64
72
|
value={node.dir ?? "site"}
|
|
73
|
+
// UX-080: the trigger shows the option's name ("Site default"), not its value ("site").
|
|
74
|
+
renderValue={(value: unknown) => DIR_NAMES[String(value)] ?? String(value)}
|
|
65
75
|
onValueChange={(value) => {
|
|
66
76
|
const dir = value === "ltr" || value === "rtl" || value === "auto" ? value : undefined;
|
|
67
77
|
onChange({ ...node, dir });
|
|
@@ -143,7 +153,7 @@ export function ContainerQueryFields({
|
|
|
143
153
|
onChange={(event) => setDraft(event.target.value)}
|
|
144
154
|
onBlur={commitMin}
|
|
145
155
|
onKeyDown={(event) => {
|
|
146
|
-
if (event
|
|
156
|
+
if (isCommitEnter(event)) commitMin();
|
|
147
157
|
}}
|
|
148
158
|
/>
|
|
149
159
|
<Button
|
|
@@ -168,7 +178,7 @@ export function ContainerQueryFields({
|
|
|
168
178
|
the current style?
|
|
169
179
|
</p>
|
|
170
180
|
<Button type="button" variant="destructive" className={BUTTON} onClick={copyStyle}>
|
|
171
|
-
Replace
|
|
181
|
+
Replace styles
|
|
172
182
|
</Button>
|
|
173
183
|
<Button
|
|
174
184
|
type="button"
|
|
@@ -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 })}
|