@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.
Files changed (208) hide show
  1. package/README.md +2 -2
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/package.json +7 -7
  4. package/src/admin/access/RequireEditor.tsx +7 -7
  5. package/src/admin/access/role.ts +5 -2
  6. package/src/admin/content-api.ts +10 -3
  7. package/src/admin/content-item.ts +1 -1
  8. package/src/admin/editor/A11yCopilot.tsx +104 -56
  9. package/src/admin/editor/CommandPalette.tsx +29 -13
  10. package/src/admin/editor/DialogCloseButton.tsx +16 -0
  11. package/src/admin/editor/Editor.tsx +115 -20
  12. package/src/admin/editor/EditorToasts.tsx +26 -0
  13. package/src/admin/editor/PerfMeter.tsx +92 -73
  14. package/src/admin/editor/SavedSectionDialogs.tsx +169 -0
  15. package/src/admin/editor/ShareLink.tsx +102 -72
  16. package/src/admin/editor/ShortcutsDialog.tsx +37 -18
  17. package/src/admin/editor/Timeline.tsx +250 -160
  18. package/src/admin/editor/TopBar.tsx +71 -14
  19. package/src/admin/editor/canvas/CanvasFrame.tsx +10 -1
  20. package/src/admin/editor/canvas/CanvasTextEdit.tsx +8 -2
  21. package/src/admin/editor/canvas/drop-line.ts +11 -3
  22. package/src/admin/editor/canvas/frame-focus-ring.ts +37 -0
  23. package/src/admin/editor/canvas/use-canvas-dnd.ts +32 -3
  24. package/src/admin/editor/canvas/vnode-react.tsx +7 -0
  25. package/src/admin/editor/collection-previews.ts +10 -0
  26. package/src/admin/editor/dialogs.tsx +41 -28
  27. package/src/admin/editor/dnd/drop-target.ts +26 -1
  28. package/src/admin/editor/edited-noun.ts +15 -0
  29. package/src/admin/editor/editor-chrome.tsx +43 -7
  30. package/src/admin/editor/editor-commands.ts +17 -2
  31. package/src/admin/editor/editor-css.ts +75 -24
  32. package/src/admin/editor/element-chrome.ts +21 -11
  33. package/src/admin/editor/feature-css.ts +56 -14
  34. package/src/admin/editor/focus-when-lost.ts +23 -0
  35. package/src/admin/editor/icons/IconLibraryDialog.tsx +54 -18
  36. package/src/admin/editor/icons/library.ts +1 -1
  37. package/src/admin/editor/icons/use-icon-library.ts +5 -2
  38. package/src/admin/editor/ime.ts +29 -0
  39. package/src/admin/editor/palette-items.ts +27 -3
  40. package/src/admin/editor/panels/AddPanel.tsx +44 -11
  41. package/src/admin/editor/panels/ClassesSection.tsx +18 -7
  42. package/src/admin/editor/panels/ColorControl.tsx +130 -23
  43. package/src/admin/editor/panels/ConditionsEditor.tsx +52 -26
  44. package/src/admin/editor/panels/ElementPanel.tsx +134 -24
  45. package/src/admin/editor/panels/LayersPanel.tsx +61 -20
  46. package/src/admin/editor/panels/LeftPanel.tsx +9 -1
  47. package/src/admin/editor/panels/PageSettings.tsx +66 -35
  48. package/src/admin/editor/panels/SavedSectionsGroup.tsx +246 -0
  49. package/src/admin/editor/panels/SiteStylesDrawer.tsx +224 -42
  50. package/src/admin/editor/panels/TokenScales.tsx +88 -48
  51. package/src/admin/editor/panels/TriggerSettings.tsx +50 -12
  52. package/src/admin/editor/panels/TriggersEditor.tsx +3 -2
  53. package/src/admin/editor/panels/VariableSection.tsx +48 -18
  54. package/src/admin/editor/panels/color-space.ts +23 -29
  55. package/src/admin/editor/panels/settings/AdvancedFields.tsx +12 -2
  56. package/src/admin/editor/panels/settings/AudienceEditor.tsx +87 -74
  57. package/src/admin/editor/panels/settings/BackgroundControls.tsx +55 -11
  58. package/src/admin/editor/panels/settings/BackgroundFill.tsx +3 -2
  59. package/src/admin/editor/panels/settings/BindingsEditor.tsx +15 -18
  60. package/src/admin/editor/panels/settings/BoxControl.tsx +2 -1
  61. package/src/admin/editor/panels/settings/ClassChip.tsx +21 -9
  62. package/src/admin/editor/panels/settings/ClassChipInput.tsx +24 -16
  63. package/src/admin/editor/panels/settings/DraftTextField.tsx +41 -3
  64. package/src/admin/editor/panels/settings/EffectsControls.tsx +38 -14
  65. package/src/admin/editor/panels/settings/FieldBindControl.tsx +46 -28
  66. package/src/admin/editor/panels/settings/FieldControl.tsx +20 -8
  67. package/src/admin/editor/panels/settings/FormBindControl.tsx +2 -2
  68. package/src/admin/editor/panels/settings/HintedSwitch.tsx +33 -0
  69. package/src/admin/editor/panels/settings/IconControls.tsx +33 -13
  70. package/src/admin/editor/panels/settings/IconPicker.tsx +2 -0
  71. package/src/admin/editor/panels/settings/ImageSourcesField.tsx +3 -1
  72. package/src/admin/editor/panels/settings/ItemList.tsx +15 -2
  73. package/src/admin/editor/panels/settings/LengthRow.tsx +8 -6
  74. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +1 -1
  75. package/src/admin/editor/panels/settings/MediaPicker.tsx +127 -23
  76. package/src/admin/editor/panels/settings/MotionControl.tsx +28 -15
  77. package/src/admin/editor/panels/settings/NumberRow.tsx +9 -3
  78. package/src/admin/editor/panels/settings/PanelSelect.tsx +50 -0
  79. package/src/admin/editor/panels/settings/QueryStyleRows.tsx +25 -18
  80. package/src/admin/editor/panels/settings/RequiredFieldsNotice.tsx +66 -1
  81. package/src/admin/editor/panels/settings/StyleRow.tsx +10 -3
  82. package/src/admin/editor/panels/settings/StyleSources.tsx +4 -1
  83. package/src/admin/editor/panels/settings/VariantEditor.tsx +10 -1
  84. package/src/admin/editor/panels/settings/box-link-name.ts +6 -2
  85. package/src/admin/editor/panels/settings/class-suggest.ts +7 -7
  86. package/src/admin/editor/panels/settings/query-style.ts +38 -9
  87. package/src/admin/editor/panels/settings/svg-images.ts +13 -0
  88. package/src/admin/editor/panels/site-list.tsx +20 -6
  89. package/src/admin/editor/panels/variable-values.ts +11 -4
  90. package/src/admin/editor/restore-deleted.ts +21 -2
  91. package/src/admin/editor/section-templates.ts +81 -12
  92. package/src/admin/editor/shortcuts.ts +31 -2
  93. package/src/admin/editor/store.ts +7 -0
  94. package/src/admin/editor/useEditorCommands.ts +61 -15
  95. package/src/admin/editor/useEditorData.ts +4 -2
  96. package/src/admin/editor/useEditorShortcuts.ts +17 -7
  97. package/src/admin/editor/useNodeActions.ts +61 -6
  98. package/src/admin/editor/useSave.ts +22 -7
  99. package/src/admin/editor/useSavedSections.ts +197 -0
  100. package/src/admin/forms-api.ts +2 -0
  101. package/src/admin/image-editor/Canvas.tsx +61 -17
  102. package/src/admin/image-editor/CurvesPanel.tsx +2 -1
  103. package/src/admin/image-editor/ExportDialog.tsx +48 -18
  104. package/src/admin/image-editor/ImageEditorDialog.tsx +179 -8
  105. package/src/admin/image-editor/MetadataPanel.tsx +15 -4
  106. package/src/admin/image-editor/crop-geometry.ts +3 -2
  107. package/src/admin/image-editor/image-editor-css.ts +15 -10
  108. package/src/admin/image-editor/load.ts +9 -2
  109. package/src/admin/image-editor/parts.tsx +69 -19
  110. package/src/admin/image-editor/save.ts +54 -8
  111. package/src/admin/media-api.ts +2 -1
  112. package/src/admin/pages/AgentsPage.tsx +138 -27
  113. package/src/admin/pages/CreateDialog.tsx +97 -30
  114. package/src/admin/pages/NewPageDialog.tsx +21 -3
  115. package/src/admin/pages/NewThemePartDialog.tsx +11 -3
  116. package/src/admin/pages/PageList.tsx +14 -6
  117. package/src/admin/pages/SetupShell.tsx +28 -12
  118. package/src/admin/pages/ThemePartList.tsx +59 -11
  119. package/src/admin/pages/list-kit.tsx +106 -24
  120. package/src/admin/saved-sections-api.ts +51 -0
  121. package/src/admin/search.ts +15 -0
  122. package/src/admin/setup/useSetupStatus.ts +1 -1
  123. package/src/admin/theme-api.ts +16 -5
  124. package/src/admin/ui.ts +82 -22
  125. package/src/astro/floats/runtime.ts +21 -0
  126. package/src/astro/menu/runtime.ts +34 -1
  127. package/src/astro/popups/runtime.ts +41 -9
  128. package/src/astro/render.ts +3 -0
  129. package/src/astro/resolve-theme.ts +53 -11
  130. package/src/astro/resolve.ts +9 -1
  131. package/src/astro/tabs/runtime.ts +12 -0
  132. package/src/astro/theme-posts.ts +2 -2
  133. package/src/astro/visitor.ts +2 -0
  134. package/src/constants.ts +1 -1
  135. package/src/core/a11y/audit.ts +196 -24
  136. package/src/core/arrange.ts +48 -12
  137. package/src/core/audience/rules.ts +5 -1
  138. package/src/core/audience/variants.ts +29 -3
  139. package/src/core/clipboard.ts +7 -0
  140. package/src/core/css/generate.ts +31 -6
  141. package/src/core/css/print.ts +5 -0
  142. package/src/core/data/bindings.ts +8 -1
  143. package/src/core/design/classes.ts +39 -16
  144. package/src/core/design/devices.ts +7 -13
  145. package/src/core/design/diff.ts +6 -0
  146. package/src/core/design/merge.ts +90 -2
  147. package/src/core/design/states.ts +7 -13
  148. package/src/core/design/tokens.ts +16 -2
  149. package/src/core/design/transfer.ts +33 -6
  150. package/src/core/design/variables.ts +30 -9
  151. package/src/core/elements/dynamic-elements.ts +53 -14
  152. package/src/core/elements/form-elements.ts +55 -16
  153. package/src/core/elements/index.ts +84 -39
  154. package/src/core/elements/menu.ts +40 -19
  155. package/src/core/elements/select-prompt.ts +3 -0
  156. package/src/core/elements/svg-ids.ts +39 -0
  157. package/src/core/forms/binding.ts +57 -16
  158. package/src/core/forms/definition.ts +72 -0
  159. package/src/core/history/diff.ts +18 -1
  160. package/src/core/icons/animation-runs.ts +11 -0
  161. package/src/core/icons/catalog.ts +3 -2
  162. package/src/core/image-edit/schema.ts +11 -1
  163. package/src/core/image-edit/summary.ts +6 -3
  164. package/src/core/index.ts +35 -1
  165. package/src/core/limits.ts +12 -1
  166. package/src/core/migrate/index.ts +3 -0
  167. package/src/core/perf/meter.ts +42 -7
  168. package/src/core/recipes/index.ts +5 -4
  169. package/src/core/render/context.ts +8 -0
  170. package/src/core/render/dynamic-post.ts +69 -12
  171. package/src/core/render/extras.ts +77 -4
  172. package/src/core/render/form.ts +140 -6
  173. package/src/core/render/index.ts +156 -20
  174. package/src/core/render/loop.ts +44 -8
  175. package/src/core/render/pagination.ts +18 -4
  176. package/src/core/render/section.ts +27 -0
  177. package/src/core/render/tabs.ts +12 -3
  178. package/src/core/render/vnode.ts +1 -1
  179. package/src/core/sanitize/css.ts +29 -8
  180. package/src/core/sanitize/embed-url.ts +42 -5
  181. package/src/core/sanitize/url.ts +2 -1
  182. package/src/core/saved-sections.ts +318 -0
  183. package/src/core/schema/design.ts +1 -1
  184. package/src/core/schema/layout.ts +16 -7
  185. package/src/core/schema/style.ts +4 -2
  186. package/src/core/stats.ts +2 -1
  187. package/src/core/theme/conditions.ts +3 -1
  188. package/src/core/theme/dynamic.ts +36 -5
  189. package/src/core/theme/float.ts +12 -2
  190. package/src/core/theme/pagination.ts +50 -29
  191. package/src/core/theme/part-types.ts +4 -4
  192. package/src/core/theme/popup-markup.ts +23 -5
  193. package/src/core/theme/popup-rules.ts +1 -0
  194. package/src/core/theme/triggers.ts +3 -2
  195. package/src/core/tree-ops.ts +27 -0
  196. package/src/mcp/ports.ts +22 -1
  197. package/src/mcp/rate-limit.ts +2 -1
  198. package/src/mcp/read.ts +15 -3
  199. package/src/mcp/refs.ts +18 -0
  200. package/src/mcp/sections.ts +183 -0
  201. package/src/mcp/tools.ts +44 -0
  202. package/src/mcp/write.ts +178 -14
  203. package/src/server/agent-settings.ts +1 -1
  204. package/src/server/hooks.ts +5 -3
  205. package/src/server/icon-routes.ts +30 -9
  206. package/src/server/mcp-routes.ts +8 -1
  207. package/src/server/plugin.ts +14 -0
  208. package/src/server/saved-sections.ts +163 -0
@@ -1,4 +1,4 @@
1
- import { Button, Input, Select } from "@cloudflare/kumo";
1
+ import { Button, Input, Loader, Select } from "@cloudflare/kumo";
2
2
  import { PlusIcon } from "@phosphor-icons/react";
3
3
  import * as React from "react";
4
4
  import {
@@ -23,7 +23,14 @@ import {
23
23
  } from "./color-space.ts";
24
24
  import { InlineError } from "./inline-error.tsx";
25
25
  import { pickerHex, withPreviousAlpha } from "./variable-values.ts";
26
+ import { isCommitEnter } from "../ime.ts";
27
+ import { useMediaQuery } from "../useMediaQuery.ts";
26
28
 
29
+ /**
30
+ * W-673: Kumo's Input `variant="error"` is deprecated (and warns), and its `error` prop would print
31
+ * a second message under our InlineError, so a refused field gets Kumo's error ring as classes.
32
+ */
33
+ const INVALID = " !ring-kumo-danger focus:ring-kumo-danger/50 focus:ring-[1.5px]";
27
34
  const HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
28
35
  const NONE = "__none__";
29
36
  const CUSTOM = "__custom__";
@@ -39,7 +46,7 @@ function Swatch({ color }: { color: string }) {
39
46
  }
40
47
 
41
48
  const uniqueId = (design: DesignSystem, name: string) => {
42
- const base = slugify(name).slice(0, 34) || "color";
49
+ const base = slugify(name).slice(0, 34).replace(/-+$/, "") || "color";
43
50
  const taken = new Set(design.variables.colors.map((color) => color.id));
44
51
  let id = base;
45
52
  for (let n = 2; taken.has(id); n++) id = `${base}-${n}`;
@@ -71,6 +78,17 @@ export function ColorControl({
71
78
  const colors = design.variables.colors;
72
79
  const bound = value && typeof value === "object" ? colors.find((c) => c.id === value.var) : null;
73
80
  const [creating, setCreating] = React.useState(false);
81
+ // W-818: Cancel and Create unmount the form, which dropped keyboard focus to the page body.
82
+ // Focus goes back to New variable when the form closes, unless it already moved elsewhere.
83
+ const newVariableRef = React.useRef<HTMLButtonElement>(null);
84
+ const wasCreating = React.useRef(false);
85
+ React.useEffect(() => {
86
+ const closed = wasCreating.current && !creating;
87
+ wasCreating.current = creating;
88
+ if (!closed) return;
89
+ const active = document.activeElement;
90
+ if (!active || active === document.body) newVariableRef.current?.focus();
91
+ }, [creating]);
74
92
  const [customOpen, setCustomOpen] = React.useState(false);
75
93
  // The hex an out-of-gamut OKLCH entry was clipped to. It lives here because committing a custom
76
94
  // colour remounts CustomColor (W-183).
@@ -197,6 +215,7 @@ export function ColorControl({
197
215
  variant="ghost"
198
216
  className={BUTTON}
199
217
  icon={<PlusIcon aria-hidden="true" />}
218
+ ref={newVariableRef}
200
219
  onClick={() => setCreating(true)}
201
220
  disabled={variableListFull(design, "color")}
202
221
  >
@@ -262,15 +281,14 @@ function CustomColor({
262
281
  <div className="emvb-custom-color-row">
263
282
  <Input
264
283
  label="Custom color"
265
- className={`${FIELD} emvb-mono`}
284
+ className={`${FIELD} emvb-mono${error?.field === "hex" ? INVALID : ""}`}
266
285
  placeholder="#1a2b3c"
267
286
  value={draft}
268
- variant={error?.field === "hex" ? "error" : undefined}
269
287
  aria-invalid={error?.field === "hex" ? true : undefined}
270
288
  onChange={(event) => setDraft(event.target.value)}
271
289
  onBlur={() => commit(draft)}
272
290
  onKeyDown={(event) => {
273
- if (event.key === "Enter") commit(draft);
291
+ if (isCommitEnter(event)) commit(draft);
274
292
  }}
275
293
  />
276
294
  <input
@@ -358,17 +376,16 @@ function NotationRow({
358
376
  <>
359
377
  <Input
360
378
  label={label}
361
- className={`${FIELD} emvb-mono`}
379
+ className={`${FIELD} emvb-mono${error ? INVALID : ""}`}
362
380
  placeholder={placeholder}
363
381
  value={draft}
364
- variant={error ? "error" : undefined}
365
382
  aria-invalid={error ? true : undefined}
366
383
  onChange={(event) => setDraft(event.target.value)}
367
384
  onBlur={() => {
368
385
  if (draft.trim() !== text) onCommit(draft);
369
386
  }}
370
387
  onKeyDown={(event) => {
371
- if (event.key === "Enter") onCommit(draft);
388
+ if (isCommitEnter(event)) onCommit(draft);
372
389
  }}
373
390
  />
374
391
  {error && <InlineError>{error}</InlineError>}
@@ -387,7 +404,10 @@ function VariableValue({
387
404
  }) {
388
405
  const [draft, setDraft] = React.useState(value);
389
406
  const [error, setError] = React.useState<string | null>(null);
407
+ const [phase, setPhase] = React.useState<"idle" | "saving" | "saved">("idle");
408
+ const pending = React.useRef(false);
390
409
  const commit = async () => {
410
+ if (pending.current) return;
391
411
  const hex = hexInput(draft);
392
412
  if (hex === value) return;
393
413
  if (!hex) {
@@ -396,30 +416,53 @@ function VariableValue({
396
416
  }
397
417
  setError(null);
398
418
  setDraft(hex);
419
+ pending.current = true;
420
+ setPhase("saving");
399
421
  try {
400
422
  await onCommit(hex);
423
+ setPhase("saved");
401
424
  } catch (failure) {
402
425
  setError(errorText(failure));
426
+ setPhase("idle");
427
+ } finally {
428
+ pending.current = false;
403
429
  }
404
430
  };
405
431
  return (
406
432
  <>
407
433
  <Input
408
434
  label={`${name} value`}
409
- className={`${FIELD} emvb-mono`}
435
+ className={`${FIELD} emvb-mono${error ? INVALID : ""}`}
410
436
  value={draft}
411
- variant={error ? "error" : undefined}
412
- onChange={(event) => setDraft(event.target.value)}
437
+ readOnly={phase === "saving"}
438
+ aria-busy={phase === "saving"}
439
+ aria-invalid={error ? true : undefined}
440
+ onChange={(event) => {
441
+ setDraft(event.target.value);
442
+ setPhase("idle");
443
+ }}
413
444
  onBlur={() => void commit()}
414
445
  onKeyDown={(event) => {
415
- if (event.key === "Enter") void commit();
446
+ if (isCommitEnter(event)) void commit();
416
447
  }}
417
448
  />
418
- {error ? (
419
- <InlineError>{error}</InlineError>
420
- ) : (
421
- <p className="emvb-helper">Style changes stay unpublished until you publish styles.</p>
422
- )}
449
+ <div className="emvb-variable-value-feedback">
450
+ <p
451
+ className="emvb-helper"
452
+ role="status"
453
+ aria-label="Color variable status"
454
+ aria-live="polite"
455
+ >
456
+ {error
457
+ ? ""
458
+ : phase === "saving"
459
+ ? "Saving color variable…"
460
+ : phase === "saved"
461
+ ? "Color variable saved. Publish styles to make it live."
462
+ : "Style changes stay unpublished until you publish styles."}
463
+ </p>
464
+ {error && <InlineError>{error}</InlineError>}
465
+ </div>
423
466
  </>
424
467
  );
425
468
  }
@@ -434,24 +477,55 @@ function NewVariable({
434
477
  const [name, setName] = React.useState("");
435
478
  const [hex, setHex] = React.useState("");
436
479
  const [error, setError] = React.useState<string | null>(null);
480
+ // W-820: a refused name or value focuses that field and marks it invalid, like W-813.
481
+ const [invalid, setInvalid] = React.useState<"name" | "value" | null>(null);
482
+ const nameRef = React.useRef<HTMLInputElement>(null);
483
+ const valueRef = React.useRef<HTMLInputElement>(null);
437
484
  const [busy, setBusy] = React.useState(false);
485
+ const pending = React.useRef(false);
486
+ const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
487
+ const refuse = (field: "name" | "value", message: string) => {
488
+ setError(message);
489
+ setInvalid(field);
490
+ (field === "name" ? nameRef : valueRef).current?.focus();
491
+ };
438
492
  const create = async () => {
439
- if (!name.trim()) return setError("Enter a name for the variable.");
493
+ if (pending.current) return;
494
+ if (!name.trim()) return refuse("name", "Enter a name for the variable.");
440
495
  const typed = hexInput(hex);
441
- if (!typed) return setError(BAD_HEX);
496
+ if (!typed) return refuse("value", BAD_HEX);
442
497
  setError(null);
498
+ setInvalid(null);
499
+ pending.current = true;
443
500
  setBusy(true);
444
501
  try {
445
502
  await onCreate(name.trim(), typed);
446
503
  } catch (failure) {
447
504
  setError(errorText(failure));
505
+ } finally {
506
+ pending.current = false;
448
507
  setBusy(false);
449
508
  }
450
509
  };
451
510
  return (
452
- <div className="emvb-new-variable" data-emvb-form="new-variable">
511
+ <div
512
+ className="emvb-new-variable"
513
+ data-emvb-form="new-variable"
514
+ onKeyDown={(event) => {
515
+ // W-821: Escape cancels the form like Cancel (W-818 returns focus to New variable).
516
+ // The editor's own Escape must not also run; a pending create can't be cancelled.
517
+ if (event.key !== "Escape" || event.defaultPrevented) return;
518
+ event.preventDefault();
519
+ event.stopPropagation();
520
+ if (!pending.current) onCancel();
521
+ }}
522
+ >
453
523
  <Input
454
524
  label="Variable name"
525
+ ref={nameRef}
526
+ aria-invalid={invalid === "name" || undefined}
527
+ readOnly={busy}
528
+ aria-disabled={busy}
455
529
  className={FIELD}
456
530
  value={name}
457
531
  autoFocus
@@ -459,20 +533,53 @@ function NewVariable({
459
533
  />
460
534
  <Input
461
535
  label="Value"
536
+ ref={valueRef}
537
+ aria-invalid={invalid === "value" || undefined}
538
+ readOnly={busy}
539
+ aria-disabled={busy}
462
540
  className={`${FIELD} emvb-mono`}
463
541
  placeholder="#1a2b3c"
464
542
  value={hex}
465
543
  onChange={(event) => setHex(event.target.value)}
466
544
  onKeyDown={(event) => {
467
- if (event.key === "Enter") void create();
545
+ if (isCommitEnter(event)) void create();
468
546
  }}
469
547
  />
470
548
  {error && <InlineError>{error}</InlineError>}
549
+ <p
550
+ className="emvb-helper emvb-new-variable-status"
551
+ role="status"
552
+ aria-label="Color variable status"
553
+ aria-live="polite"
554
+ >
555
+ {busy ? "Creating color variable…" : ""}
556
+ </p>
471
557
  <div className="emvb-row-actions">
472
- <Button variant="secondary" className={BUTTON} onClick={onCancel}>
558
+ {/* W-822: locked, not disabled, while creating, so keyboard focus stays in the form. */}
559
+ <Button
560
+ variant="secondary"
561
+ className={BUTTON}
562
+ aria-disabled={busy}
563
+ onClick={() => {
564
+ if (!pending.current) onCancel();
565
+ }}
566
+ >
473
567
  Cancel
474
568
  </Button>
475
- <Button variant="secondary" className={BUTTON} loading={busy} onClick={() => void create()}>
569
+ <Button
570
+ variant="secondary"
571
+ className={BUTTON}
572
+ icon={
573
+ busy && !reducedMotion ? (
574
+ <Loader size={14} />
575
+ ) : (
576
+ <PlusIcon size={14} aria-hidden="true" />
577
+ )
578
+ }
579
+ aria-disabled={busy}
580
+ aria-busy={busy}
581
+ onClick={() => void create()}
582
+ >
476
583
  Create variable
477
584
  </Button>
478
585
  </div>
@@ -6,7 +6,9 @@ import {
6
6
  type ConditionRule,
7
7
  type ConditionsDoc,
8
8
  } from "../../../core/index.ts";
9
- import { BUTTON, FIELD } from "../../ui.ts";
9
+ import { conditionRuleLabel } from "../../theme-api.ts";
10
+ import { BUTTON } from "../../ui.ts";
11
+ import { PanelSelect } from "./settings/PanelSelect.tsx";
10
12
 
11
13
  type Props = {
12
14
  conditions: ConditionsDoc | undefined;
@@ -18,6 +20,8 @@ const GROUP_OPTIONS = [
18
20
  { value: "singular:front", label: "Front page", group: "singular", name: "front" },
19
21
  { value: "singular:all", label: "All singular", group: "singular", name: "all" },
20
22
  { value: "singular:not_found", label: "404 page", group: "singular", name: "not_found" },
23
+ // W-694: the Archive part's default rule; the menu showed it as "Entire site".
24
+ { value: "archive:all", label: "All archives", group: "archive", name: "all" },
21
25
  {
22
26
  value: "singular:collection:pages",
23
27
  label: "Pages (all)",
@@ -63,6 +67,22 @@ const GROUP_OPTIONS = [
63
67
  },
64
68
  ] as const;
65
69
 
70
+ /** The menu value that keeps a rule the menu can't build (one entry, one term, another collection). */
71
+ const CURRENT_RULE = "current";
72
+
73
+ /**
74
+ * The menu value for a rule: its option, or CURRENT_RULE when no option builds it exactly.
75
+ * W-694: such rules (from MCP, an import or an older EmVB) showed as "Entire site", and touching
76
+ * the menu replaced them; they now show their Theme Builder label, e.g. "Tag: news".
77
+ */
78
+ function menuValue(rule: ConditionRule): string {
79
+ const value = optionValue(rule);
80
+ const option = GROUP_OPTIONS.find((o) => o.value === value);
81
+ if (!option) return CURRENT_RULE;
82
+ const expected = "args" in option ? Object.keys(option.args).length : 0;
83
+ return Object.keys(rule.args).length === expected ? value : CURRENT_RULE;
84
+ }
85
+
66
86
  export function optionValue(rule: ConditionRule): string {
67
87
  if (rule.group === "singular" && rule.name === "collection") {
68
88
  return `singular:collection:${String(rule.args["collection"] ?? "")}`;
@@ -130,36 +150,39 @@ export function ConditionsEditor({ conditions, onChange }: Props) {
130
150
  <ul className="emvb-condition-list">
131
151
  {doc.rules.map((rule) => (
132
152
  <li key={rule.id} className="emvb-condition-row" data-emvb-condition={rule.id}>
133
- <select
153
+ <PanelSelect
134
154
  className="emvb-condition-op"
135
- aria-label="Include or exclude"
155
+ label="Include or exclude"
136
156
  value={rule.op}
137
- onChange={(event) =>
138
- update(rule.id, { op: event.target.value === "exclude" ? "exclude" : "include" })
157
+ options={[
158
+ { value: "include", label: "Include" },
159
+ { value: "exclude", label: "Exclude" },
160
+ ]}
161
+ onChange={(value) =>
162
+ update(rule.id, { op: value === "exclude" ? "exclude" : "include" })
139
163
  }
140
- >
141
- <option value="include">Include</option>
142
- <option value="exclude">Exclude</option>
143
- </select>
144
- <select
145
- className={`emvb-condition-where ${FIELD}`}
146
- aria-label="Where"
147
- value={optionValue(rule)}
148
- onChange={(event) => {
149
- const next = ruleFromOption(event.target.value, rule.op, rule.id);
150
- update(rule.id, next);
164
+ />
165
+ <PanelSelect
166
+ className="emvb-condition-where"
167
+ label="Where"
168
+ value={menuValue(rule)}
169
+ options={[
170
+ ...(menuValue(rule) === CURRENT_RULE
171
+ ? [{ value: CURRENT_RULE, label: conditionRuleLabel(rule) }]
172
+ : []),
173
+ ...GROUP_OPTIONS.map((option) => ({ value: option.value, label: option.label })),
174
+ ]}
175
+ onChange={(value) => {
176
+ if (value === CURRENT_RULE) return;
177
+ update(rule.id, ruleFromOption(value, rule.op, rule.id));
151
178
  }}
152
- >
153
- {GROUP_OPTIONS.map((option) => (
154
- <option key={option.value} value={option.value}>
155
- {option.label}
156
- </option>
157
- ))}
158
- </select>
179
+ />
159
180
  <Button
160
181
  type="button"
161
182
  variant="ghost"
162
- className={BUTTON}
183
+ shape="square"
184
+ // W-767: the 28 px icon button its grid column expects; the text-button size overflowed.
185
+ className="emvb-icon-btn"
163
186
  aria-label="Remove condition"
164
187
  icon={<TrashIcon aria-hidden="true" />}
165
188
  onClick={() => remove(rule.id)}
@@ -167,6 +190,7 @@ export function ConditionsEditor({ conditions, onChange }: Props) {
167
190
  </li>
168
191
  ))}
169
192
  </ul>
193
+ {/* UX-051: sentence case; the plus says "add", so both fit on one row at 264 px. */}
170
194
  <div className="emvb-condition-actions">
171
195
  <Button
172
196
  type="button"
@@ -176,8 +200,9 @@ export function ConditionsEditor({ conditions, onChange }: Props) {
176
200
  disabled={full}
177
201
  title={full ? fullReason : undefined}
178
202
  onClick={() => add("include")}
203
+ aria-label="Add include rule"
179
204
  >
180
- Add Include
205
+ Include
181
206
  </Button>
182
207
  <Button
183
208
  type="button"
@@ -187,8 +212,9 @@ export function ConditionsEditor({ conditions, onChange }: Props) {
187
212
  disabled={full}
188
213
  title={full ? fullReason : undefined}
189
214
  onClick={() => add("exclude")}
215
+ aria-label="Add exclude rule"
190
216
  >
191
- Add Exclude
217
+ Exclude
192
218
  </Button>
193
219
  </div>
194
220
  {full && (
@@ -12,7 +12,11 @@ import { ELEMENT_NAMES, elementIcon } from "../element-chrome.ts";
12
12
  import { indexLayout } from "../../../core/tree-ops.ts";
13
13
  import type { ThemePartType } from "../../../core/theme/part-types.ts";
14
14
  import { sharedPartH1 } from "./settings/heading-warning.ts";
15
- import { UNNAMED_BOX_LINK_NOTE, unnamedBoxLink } from "./settings/box-link-name.ts";
15
+ import {
16
+ HELD_BACK_BOX_LINK_NOTE,
17
+ UNNAMED_BOX_LINK_NOTE,
18
+ unnamedBoxLink,
19
+ } from "./settings/box-link-name.ts";
16
20
  import { imageAltNote } from "./settings/image-alt.ts";
17
21
  import { loopContextNote } from "./settings/loop-context.ts";
18
22
  import { buttonUrlNote } from "./settings/button-url.ts";
@@ -25,6 +29,7 @@ import {
25
29
  localStylesToClass,
26
30
  localToClassRefusal,
27
31
  isFormNode,
32
+ loneAbTests,
28
33
  type DesignSystem,
29
34
  type ElementDescriptor,
30
35
  type Layout,
@@ -41,6 +46,7 @@ import {
41
46
  STYLE_STATES,
42
47
  type StyleProps,
43
48
  type StyleStates,
49
+ boxLinkHeldBack,
44
50
  } from "../../../core/index.ts";
45
51
  import { applyStylePatch } from "./style-target.ts";
46
52
  import { FieldControl } from "./settings/FieldControl.tsx";
@@ -82,6 +88,22 @@ const enclosingFormId = (layout: Layout, nodeId: string): string | undefined =>
82
88
  return undefined;
83
89
  };
84
90
 
91
+ const GRID_ITEM_KEYS = new Set<string>([
92
+ "gridColumnSpan",
93
+ "gridColumnStart",
94
+ "gridRowSpan",
95
+ "gridRowStart",
96
+ ]);
97
+
98
+ /** Whether the node sits directly in a box that lays its children out on a grid. */
99
+ const inGridParent = (layout: Layout | null | undefined, nodeId: string): boolean => {
100
+ if (!layout) return true;
101
+ const index = indexLayout(layout);
102
+ const parentId = index.parentOf.get(nodeId);
103
+ const parent = parentId ? index.byId.get(parentId) : undefined;
104
+ return parent?.type === "grid" || parent?.type === "loop";
105
+ };
106
+
85
107
  const sectionKey = (type: string) => `emvb-style-sections:${type}`;
86
108
 
87
109
  /**
@@ -269,6 +291,60 @@ function Alert({
269
291
  );
270
292
  }
271
293
 
294
+ /**
295
+ * UX-028: settings that only matter once another is set stay out of the way
296
+ * until then. A value already stored always shows, so nothing set is ever hidden.
297
+ */
298
+ const DEPENDS_ON: Readonly<Record<string, string>> = {
299
+ iconPosition: "iconId",
300
+ iconSize: "iconId",
301
+ iconGap: "iconId",
302
+ // UX-072: a new tab needs a link, typed or bound to live data (W-276 drops the target without one).
303
+ newTab: "href",
304
+ };
305
+
306
+ /** UX-040: number pairs that read as one setting share a row (X beside Y, width beside height). */
307
+ const PAIRED: Readonly<Record<string, string>> = { focalX: "focalY", width: "height" };
308
+
309
+ function pairFields<F extends { key: string }>(fields: readonly F[]): F[][] {
310
+ const rows: F[][] = [];
311
+ for (let i = 0; i < fields.length; i += 1) {
312
+ const field = fields[i] as F;
313
+ const next = fields[i + 1];
314
+ if (next && PAIRED[field.key] === next.key) {
315
+ rows.push([field, next]);
316
+ i += 1;
317
+ } else rows.push([field]);
318
+ }
319
+ return rows;
320
+ }
321
+
322
+ /** UX-071: fields that only apply to some values of another field on the same element. */
323
+ const SHOWN_WHEN: Readonly<
324
+ Record<string, (props: Record<string, unknown>, device: PopupDevice) => boolean>
325
+ > = {
326
+ "loop.columns": (props) => props["display"] === "grid" || props["display"] === "cards",
327
+ "pagination.countText": (props) => props["showCount"] === true,
328
+ // Post Link always links to its post, so its new-tab switch always applies.
329
+ "post-link.newTab": () => true,
330
+ // UX-075: each device's tracks show on that device, as Columns does (W-139).
331
+ "grid.columnTracks": (_props, device) => device === "desktop",
332
+ "grid.columnTracksTablet": (_props, device) => device === "tablet",
333
+ "grid.columnTracksMobile": (_props, device) => device === "mobile",
334
+ };
335
+
336
+ function fieldShown(key: string, node: LayoutNode, device: PopupDevice = "desktop"): boolean {
337
+ const props = node.props as Record<string, unknown>;
338
+ // A stored value always shows, so it can be seen and reset.
339
+ if (props[key] !== undefined) return true;
340
+ const when = SHOWN_WHEN[`${node.type}.${key}`];
341
+ if (when) return when(props, device);
342
+ const parent = DEPENDS_ON[key];
343
+ if (!parent) return true;
344
+ const bound = (node as { bind?: Record<string, unknown> }).bind?.[parent] !== undefined;
345
+ return (props[parent] !== undefined && props[parent] !== "") || bound;
346
+ }
347
+
272
348
  /** Right panel with an element selected (IA / W-021): descriptor Content + Style sections. */
273
349
  export function ElementPanel(props: Props) {
274
350
  const descriptor = ELEMENT_DESCRIPTORS.find((d) => d.type === props.node.type);
@@ -360,6 +436,7 @@ function KnownElementPanel({
360
436
  ? { ...fromBelow, ...ownInherited }
361
437
  : ownInherited;
362
438
  const position = positionInEffect(node, design, cls);
439
+ const inGrid = inGridParent(layout, node.id);
363
440
  const iconSvg =
364
441
  node.type === "icon" && typeof node.props.iconSvg === "string" ? node.props.iconSvg : undefined;
365
442
  const strokeAdjustable = React.useMemo(
@@ -446,13 +523,20 @@ function KnownElementPanel({
446
523
  {crumbs.map((crumb, index) => (
447
524
  <React.Fragment key={crumb.id ?? "page"}>
448
525
  {index > 0 && <span aria-hidden="true"> › </span>}
449
- <button
450
- type="button"
451
- className="emvb-breadcrumb-part"
452
- onClick={() => onSelect(crumb.id)}
453
- >
454
- {crumb.label}
455
- </button>
526
+ {index === crumbs.length - 1 ? (
527
+ // UX-065: the element being edited is where you are, not a link back to itself.
528
+ <span className="emvb-breadcrumb-current" aria-current="location">
529
+ {crumb.label}
530
+ </span>
531
+ ) : (
532
+ <button
533
+ type="button"
534
+ className="emvb-breadcrumb-part"
535
+ onClick={() => onSelect(crumb.id)}
536
+ >
537
+ {crumb.label}
538
+ </button>
539
+ )}
456
540
  </React.Fragment>
457
541
  ))}
458
542
  </nav>
@@ -481,26 +565,39 @@ function KnownElementPanel({
481
565
  : "This element has no content settings."}
482
566
  </p>
483
567
  ) : (
484
- descriptor.fields.map((field) => (
485
- <FieldControl
486
- key={field.key}
487
- field={field}
488
- node={node}
489
- onChange={onChange}
490
- fetcher={fetcher}
491
- parentFormId={layout ? enclosingFormId(layout, node.id) : undefined}
492
- duplicateName={
493
- field.key === "field" && layout ? duplicateFieldName(layout, node.id) : false
494
- }
495
- device={device}
496
- />
497
- ))
568
+ pairFields(
569
+ descriptor.fields.filter((field) => fieldShown(field.key, node, device)),
570
+ ).map((row) => {
571
+ const controls = row.map((field) => (
572
+ <React.Fragment key={field.key}>
573
+ <FieldControl
574
+ field={field}
575
+ node={node}
576
+ onChange={onChange}
577
+ fetcher={fetcher}
578
+ parentFormId={layout ? enclosingFormId(layout, node.id) : undefined}
579
+ duplicateName={
580
+ field.key === "field" && layout ? duplicateFieldName(layout, node.id) : false
581
+ }
582
+ device={device}
583
+ />
584
+ </React.Fragment>
585
+ ));
586
+ return row.length === 2 ? (
587
+ <div className="emvb-field-pair" key={row[0]?.key} data-emvb-field-pair="">
588
+ {controls}
589
+ </div>
590
+ ) : (
591
+ controls
592
+ );
593
+ })
498
594
  )}
499
595
  <BindingsEditor node={node} onChange={onChange} post={SAMPLE_POST} />
500
596
  <AudienceEditor node={node} isRoot={layout?.root.id === node.id} onChange={onChange} />
501
597
  <VariantEditor
502
598
  node={node}
503
599
  isRoot={layout?.root.id === node.id}
600
+ lone={Boolean(layout && node.variant && loneAbTests(layout).has(node.variant.test))}
504
601
  onChange={onChange}
505
602
  onArrange={onArrange}
506
603
  />
@@ -531,6 +628,11 @@ function KnownElementPanel({
531
628
  {imageAltNote(node)}
532
629
  </p>
533
630
  )}
631
+ {boxLinkHeldBack(node) && (
632
+ <p className="emvb-helper" data-emvb-held-back-link>
633
+ {HELD_BACK_BOX_LINK_NOTE}
634
+ </p>
635
+ )}
534
636
  {unnamedBoxLink(node) && (
535
637
  <p className="emvb-helper" data-emvb-unnamed-link>
536
638
  {UNNAMED_BOX_LINK_NOTE}
@@ -568,8 +670,12 @@ function KnownElementPanel({
568
670
  onChange={setStyleState}
569
671
  />
570
672
  ) : (
571
- <p className="emvb-helper">
572
- These override Desktop. State styles apply on every device.
673
+ // UX-063: say which device is being edited, as states say "Editing Hover".
674
+ <p className="emvb-helper" data-emvb-device-note={device}>
675
+ {device === "mobile"
676
+ ? "Editing Mobile. These styles override Tablet and Desktop."
677
+ : "Editing Tablet. These styles override Desktop."}{" "}
678
+ Hover, Focus and Active are set on Desktop and apply on every device.
573
679
  </p>
574
680
  )}
575
681
  {!cls && <StyleSources node={node} design={design} device={device} state={styleState} />}
@@ -597,6 +703,10 @@ function KnownElementPanel({
597
703
  const keys = keysFor(node.type, id, style, position).filter(
598
704
  (key) =>
599
705
  (styleState === "normal" || !NORMAL_ONLY_KEYS.has(key)) &&
706
+ // UX-034: spans and starts only place an element inside a Grid (or a Loop's grid).
707
+ (!GRID_ITEM_KEYS.has(key) ||
708
+ inGrid ||
709
+ (style as Record<string, unknown> | undefined)?.[key] !== undefined) &&
600
710
  // W-237: Stroke width only for stroke-drawn icons (or once set, so it can be reset).
601
711
  (key !== "iconStrokeWidth" ||
602
712
  strokeAdjustable ||