@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
@@ -17,7 +17,7 @@ export function fieldNameError(name: string): string | null {
17
17
  return null;
18
18
  }
19
19
 
20
- /** The Field name box: keeps what you type, stores it only once it's a valid name (W-202). */
20
+ /** The Field name box shares its draft with the definition picker (W-720). */
21
21
  function FieldNameInput({
22
22
  value,
23
23
  onChange,
@@ -27,24 +27,16 @@ function FieldNameInput({
27
27
  onChange: (name: string) => void;
28
28
  manual?: boolean;
29
29
  }) {
30
- const [draft, setDraft] = React.useState(value);
31
- React.useEffect(() => {
32
- setDraft((current) => (fieldNameError(current.trim()) === null ? value : current));
33
- }, [value]);
34
- const error = fieldNameError(draft.trim());
30
+ const error = fieldNameError(value.trim());
35
31
  return (
36
32
  <>
37
33
  <Input
38
34
  label="Field name"
39
35
  className={`${FIELD} emvb-mono`}
40
- value={draft}
36
+ value={value}
41
37
  aria-invalid={error ? true : undefined}
42
38
  {...(manual ? { "data-emvb-field-bind": "manual" } : {})}
43
- onChange={(event) => {
44
- const next = event.target.value;
45
- setDraft(next);
46
- if (fieldNameError(next.trim()) === null) onChange(next.trim());
47
- }}
39
+ onChange={(event) => onChange(event.target.value)}
48
40
  />
49
41
  {error && (
50
42
  <p className="emvb-inline-error" data-emvb-field-name-error>
@@ -70,32 +62,57 @@ export function FieldBindControl({
70
62
  onChange: (field: string, label?: string) => void;
71
63
  }) {
72
64
  const [fields, setFields] = React.useState<DefinitionField[] | null>(null);
65
+ const [loading, setLoading] = React.useState(Boolean(formId));
66
+ const [draft, setDraft] = React.useState(value);
67
+
68
+ React.useEffect(() => {
69
+ setDraft(value);
70
+ }, [value]);
71
+
72
+ const changeName = (next: string) => {
73
+ setDraft(next);
74
+ if (fieldNameError(next.trim()) === null) onChange(next.trim());
75
+ };
73
76
 
74
77
  React.useEffect(() => {
75
78
  let cancelled = false;
76
- if (!formId) {
77
- setFields(null);
78
- return;
79
- }
79
+ setLoading(Boolean(formId));
80
+ setFields(null);
81
+ if (!formId) return;
80
82
  void loadFormFields(fetcher, formId).then((next) => {
81
- if (!cancelled) setFields(next);
83
+ if (!cancelled) {
84
+ setFields(next);
85
+ setLoading(false);
86
+ }
82
87
  });
83
88
  return () => {
84
89
  cancelled = true;
85
90
  };
86
91
  }, [fetcher, formId]);
87
92
 
88
- if (fields && fields.length > 0) {
89
- const known = fields.some((field) => field.name === value);
90
- return (
91
- <div data-emvb-field-bind="list">
93
+ const hasFields = fields !== null && fields.length > 0;
94
+ const name = draft.trim();
95
+ const known = fields?.some((field) => field.name === name);
96
+ let feedback = "";
97
+ if (!formId)
98
+ feedback =
99
+ "Choose a form on the parent Form element to list its fields, or enter a field name manually.";
100
+ else if (loading) feedback = "Loading form fields… You can enter a field name.";
101
+ else if (fields === null) feedback = "Could not load form fields. Enter a field name manually.";
102
+ else if (fields.length === 0)
103
+ feedback = "This form has no fields yet. Enter a field name manually.";
104
+
105
+ return (
106
+ <div className="emvb-field-group" data-emvb-field-bind={hasFields ? "list" : undefined}>
107
+ {hasFields && (
92
108
  <Select
93
109
  label="Field"
94
110
  className={FIELD}
95
- value={known ? value : MANUAL}
111
+ value={known ? name : MANUAL}
96
112
  onValueChange={(next) => {
97
113
  if (!next || next === MANUAL) return;
98
114
  const picked = fields.find((each) => each.name === next);
115
+ setDraft(next);
99
116
  onChange(next, picked?.label);
100
117
  }}
101
118
  renderValue={(current: unknown) => {
@@ -110,10 +127,11 @@ export function FieldBindControl({
110
127
  </Select.Option>
111
128
  ))}
112
129
  </Select>
113
- <FieldNameInput value={value} onChange={(name) => onChange(name)} />
114
- </div>
115
- );
116
- }
117
-
118
- return <FieldNameInput value={value} onChange={(name) => onChange(name)} manual />;
130
+ )}
131
+ <FieldNameInput value={draft} onChange={changeName} manual={!hasFields} />
132
+ <p className="emvb-helper" role="status" aria-label="Form fields status" aria-live="polite">
133
+ {feedback}
134
+ </p>
135
+ </div>
136
+ );
119
137
  }
@@ -1,11 +1,12 @@
1
1
  import * as React from "react";
2
- import { Select, Switch } from "@cloudflare/kumo";
2
+ import { Select } from "@cloudflare/kumo";
3
3
  import type { FieldDescriptor, LayoutNode } from "../../../../core/index.ts";
4
4
  import type { Fetcher } from "../../../api.ts";
5
5
  import { FIELD } from "../../../ui.ts";
6
6
  import { DraftTextField } from "./DraftTextField.tsx";
7
7
  import { FieldBindControl } from "./FieldBindControl.tsx";
8
8
  import { FormBindControl } from "./FormBindControl.tsx";
9
+ import { HintedSwitch } from "./HintedSwitch.tsx";
9
10
  import { RequiredFieldsNotice } from "./RequiredFieldsNotice.tsx";
10
11
  import { LoopItemBindControl } from "./LoopItemBindControl.tsx";
11
12
  import { IconPicker } from "./IconPicker.tsx";
@@ -129,13 +130,14 @@ export function FieldControl({
129
130
 
130
131
  if (field.kind === "boolean") {
131
132
  return (
132
- <div className="emvb-field-group" data-emvb-field={field.key}>
133
- <Switch
134
- label={field.label}
135
- checked={Boolean(raw)}
136
- onCheckedChange={(checked) => onChange(withProp(node, field.key, checked || undefined))}
137
- />
138
- </div>
133
+ <HintedSwitch
134
+ label={field.label}
135
+ checked={Boolean(raw)}
136
+ onCheckedChange={(checked) => onChange(withProp(node, field.key, checked || undefined))}
137
+ hint={SWITCH_HINTS[`${node.type}.${field.key}`]}
138
+ data={{ "data-emvb-field": field.key }}
139
+ hintData={{ "data-emvb-field-hint": "" }}
140
+ />
139
141
  );
140
142
  }
141
143
 
@@ -181,6 +183,16 @@ export function FieldControl({
181
183
  return <DraftTextField field={field} node={node} onChange={onChange} />;
182
184
  }
183
185
 
186
+ /** UX-042, UX-043: switches whose label alone doesn't say when to turn them on. */
187
+ const SWITCH_HINTS: Readonly<Record<string, string>> = {
188
+ "image.decorative": "For images that add nothing to the text. Screen readers skip them.",
189
+ "image.priority": "For the first large image on the page. Others load as they scroll into view.",
190
+ "post-image.decorative": "For images that add nothing to the text. Screen readers skip them.",
191
+ "icon.decorative": "For icons that repeat nearby text. Screen readers skip them.",
192
+ "svg.decorative": "For graphics that add nothing to the text. Screen readers skip them.",
193
+ "menu-item.wide": "The dropdown spans the width of the menu.",
194
+ };
195
+
184
196
  const DEVICE_NAMES = { tablet: "tablet", mobile: "mobile" } as const;
185
197
 
186
198
  /**
@@ -52,7 +52,7 @@ export function FormBindControl({
52
52
  const known = capability.forms.some((form) => form.id === value);
53
53
  const placeholder = !known && value ? "Current id (not in list)" : "Choose a form…";
54
54
  return (
55
- <div data-emvb-form-bind="list">
55
+ <div className="emvb-field-group" data-emvb-form-bind="list">
56
56
  <Select
57
57
  label="Form"
58
58
  className={FIELD}
@@ -89,7 +89,7 @@ export function FormBindControl({
89
89
  }
90
90
 
91
91
  return (
92
- <div data-emvb-form-bind="manual">
92
+ <div className="emvb-field-group" data-emvb-form-bind="manual">
93
93
  <Input
94
94
  label="Form id"
95
95
  className={`${FIELD} emvb-mono`}
@@ -0,0 +1,33 @@
1
+ import { Switch } from "@cloudflare/kumo";
2
+ import * as React from "react";
3
+
4
+ type Props = {
5
+ label: string;
6
+ checked: boolean;
7
+ onCheckedChange: (checked: boolean) => void;
8
+ /** One line on when to turn it on; it describes the switch and lines up with its label. */
9
+ hint?: React.ReactNode;
10
+ /** Data attributes for the wrapper and the hint, so tests and styles can find them. */
11
+ data?: Record<`data-${string}`, string>;
12
+ hintData?: Record<`data-${string}`, string>;
13
+ };
14
+
15
+ /** A panel switch with its explanation under the label (UX-042, UX-046). */
16
+ export function HintedSwitch({ label, checked, onCheckedChange, hint, data, hintData }: Props) {
17
+ const hintId = React.useId();
18
+ return (
19
+ <div className="emvb-field-group" {...data}>
20
+ <Switch
21
+ label={label}
22
+ checked={checked}
23
+ aria-describedby={hint ? hintId : undefined}
24
+ onCheckedChange={(next) => onCheckedChange(next === true)}
25
+ />
26
+ {hint && (
27
+ <p className="emvb-helper emvb-switch-hint" id={hintId} {...hintData}>
28
+ {hint}
29
+ </p>
30
+ )}
31
+ </div>
32
+ );
33
+ }
@@ -1,4 +1,4 @@
1
- import { Button, Select, Switch } from "@cloudflare/kumo";
1
+ import { Button, Select } from "@cloudflare/kumo";
2
2
  import {
3
3
  FlipHorizontalIcon,
4
4
  FlipVerticalIcon,
@@ -11,6 +11,7 @@ import { BUTTON, FIELD } from "../../../ui.ts";
11
11
  import { ColorControl } from "../ColorControl.tsx";
12
12
  import { radioGroupKeys } from "./ChoiceGroup.tsx";
13
13
  import { NumberField, ResetButton, type NumberSpec } from "./NumberRow.tsx";
14
+ import { HintedSwitch } from "./HintedSwitch.tsx";
14
15
 
15
16
  /** W-237: the Icon section's own controls (glyph rotation, flip, drop shadow, loop). */
16
17
 
@@ -224,7 +225,7 @@ const DEFAULT_DURATION: Record<Looping["type"], number> = { spin: 2000, pulse: 1
224
225
  const looping = (a: IconAnimation | undefined): Looping | undefined =>
225
226
  a && a.type !== "none" ? a : undefined;
226
227
 
227
- /** A looping spin or pulse (Normal only); visitors who prefer reduced motion see it still. */
228
+ /** A spin or pulse (Normal only) that stops after about 5 s; reduced motion sees it still. */
228
229
  const ANIMATION_LABELS: Record<string, string> = { none: "None", spin: "Spin", pulse: "Pulse" };
229
230
 
230
231
  /**
@@ -263,7 +264,8 @@ export function IconAnimationControl({
263
264
  setType(picked);
264
265
  if (picked === "spin" || picked === "pulse") {
265
266
  const duration = own?.duration ?? from?.duration ?? DEFAULT_DURATION[picked];
266
- onChange({ type: picked, duration });
267
+ const loop = own?.loop ?? from?.loop;
268
+ onChange(loop ? { type: picked, duration, loop } : { type: picked, duration });
267
269
  } else onChange(from ? { type: "none" } : undefined);
268
270
  }}
269
271
  >
@@ -280,11 +282,26 @@ export function IconAnimationControl({
280
282
  onCommit={(n) => onChange({ ...own, duration: n ?? DEFAULT_DURATION[own.type] })}
281
283
  />
282
284
  )}
283
- {own && <p className="emvb-helper">Off for visitors who prefer reduced motion.</p>}
285
+ {own && (
286
+ <HintedSwitch
287
+ label="Loop forever"
288
+ checked={own.loop === true}
289
+ onCheckedChange={(loop) => {
290
+ const { loop: _old, ...rest } = own;
291
+ onChange(loop ? { ...rest, loop: true } : rest);
292
+ }}
293
+ data={{ "data-emvb-icon-loop": "" }}
294
+ hint={
295
+ own.loop
296
+ ? "Keeps going, for a loading spinner. Off for visitors who prefer reduced motion."
297
+ : "Stops on its own after about 5 seconds. Off for visitors who prefer reduced motion."
298
+ }
299
+ />
300
+ )}
284
301
  {!value && from && (
285
302
  <p className="emvb-helper">
286
- Inherited from a wider device ({ANIMATION_LABELS[from.type]}, {from.duration} ms). Pick
287
- None to stop it on this one.
303
+ Inherited from a wider device ({ANIMATION_LABELS[from.type]}, {from.duration} ms
304
+ {from.loop ? ", loops forever" : ""}). Pick None to stop it on this one.
288
305
  </p>
289
306
  )}
290
307
  {value?.type === "none" && from && (
@@ -309,14 +326,17 @@ export function IconSingleColorRow({
309
326
  onChange: (next: boolean) => void;
310
327
  }) {
311
328
  return (
312
- <div className="emvb-field-group" data-emvb-icon-single-color="">
313
- <Switch label="Force single color" checked={checked} onCheckedChange={onChange} />
314
- <p className="emvb-helper">
315
- {checked
329
+ <HintedSwitch
330
+ label="Force single color"
331
+ checked={checked}
332
+ onCheckedChange={onChange}
333
+ data={{ "data-emvb-icon-single-color": "" }}
334
+ hint={
335
+ checked
316
336
  ? "Every part of this SVG uses the icon color, so details drawn over filled shapes can disappear."
317
- : "This SVG keeps its own colors. Turn on to paint it in the icon color."}
318
- </p>
319
- </div>
337
+ : "This SVG keeps its own colors. Turn on to paint it in the icon color."
338
+ }
339
+ />
320
340
  );
321
341
  }
322
342
 
@@ -128,6 +128,8 @@ export function IconPicker({
128
128
  const remove = () => {
129
129
  const { iconId: _id, iconSvg: _svg, ...rest } = propsOf(node);
130
130
  onChange({ ...node, props: rest } as LayoutNode);
131
+ // W-838: Remove unmounts itself; keyboard focus moves to Choose instead of the page body.
132
+ refocus();
131
133
  };
132
134
 
133
135
  return (
@@ -33,7 +33,9 @@ export function parseSources(text: string): { sources: Source[] } | { error: str
33
33
  if (lines.length > MAX_SOURCES) return { error: `Up to ${MAX_SOURCES} extra sources.` };
34
34
  const sources: Source[] = [];
35
35
  for (const line of lines) {
36
- const match = /^(\S+)\s+(\d{1,4})\s*(?:w|px)?$/i.exec(line);
36
+ // W-545: a site path may hold a space ("/uploads/my photo-400.jpg 400"); the width is the
37
+ // last word.
38
+ const match = /^(\S(?:.*\S)?)\s+(\d{1,4})\s*(?:w|px)?$/i.exec(line);
37
39
  const width = match ? Number(match[2]) : Number.NaN;
38
40
  if (!match || !Number.isInteger(width) || width < 1 || width > 8000) {
39
41
  return {
@@ -48,6 +48,9 @@ const childrenOf = (node: LayoutNode): LayoutNode[] =>
48
48
  "children" in node && Array.isArray(node.children) ? (node.children as LayoutNode[]) : [];
49
49
 
50
50
  /** One reorder of `kids`, moving `fromId` to `toIndex`. Same place or an unknown id changes nothing. */
51
+ /** Drag type for an item row, so text dragged from a title field never reorders. */
52
+ const ITEM_DRAG = "application/x-emvb-item";
53
+
51
54
  export function reorderItems(
52
55
  kids: LayoutNode[],
53
56
  fromId: string,
@@ -135,17 +138,27 @@ export function ItemList({
135
138
  className="emvb-item-row"
136
139
  data-emvb-item={child.id}
137
140
  draggable
141
+ // W-611: in Chrome a draggable row drags itself when the mouse goes down in its
142
+ // title field, so text can't be selected. The row only drags from outside a field.
143
+ onPointerDown={(event) => {
144
+ const target = event.target instanceof Element ? event.target : null;
145
+ event.currentTarget.draggable = !target?.closest("input, textarea, select");
146
+ }}
138
147
  onDragStart={(event) => {
139
- event.dataTransfer.setData("text/plain", child.id);
148
+ // A text drag from the title field keeps the browser's own data (W-605).
149
+ if (event.target !== event.currentTarget) return;
150
+ event.dataTransfer.setData(ITEM_DRAG, child.id);
140
151
  event.dataTransfer.effectAllowed = "move";
141
152
  }}
142
153
  onDragOver={(event) => {
154
+ if (!event.dataTransfer.types.includes(ITEM_DRAG)) return;
143
155
  event.preventDefault();
144
156
  event.dataTransfer.dropEffect = "move";
145
157
  }}
146
158
  onDrop={(event) => {
159
+ if (!event.dataTransfer.types.includes(ITEM_DRAG)) return;
147
160
  event.preventDefault();
148
- const next = reorderItems(kids, event.dataTransfer.getData("text/plain"), index);
161
+ const next = reorderItems(kids, event.dataTransfer.getData(ITEM_DRAG), index);
149
162
  if (next) onChange({ ...node, children: next } as LayoutNode);
150
163
  }}
151
164
  >
@@ -12,6 +12,7 @@ import {
12
12
  } from "./length-units.ts";
13
13
  import type { StyleKey } from "./style-sections.ts";
14
14
  import { bindKind, boundRef, lengthRef, VariableButton, VariableChip } from "./VariableBinding.tsx";
15
+ import { isCommitEnter } from "../../ime.ts";
15
16
 
16
17
  const isLiteral = (value: unknown): value is LengthLiteral =>
17
18
  typeof value === "object" &&
@@ -53,11 +54,12 @@ export function LengthRow({
53
54
  }) {
54
55
  const units = unitsFor(styleKey);
55
56
  // W-213: a plain number is a unitless line height, shown with the `x` unit.
56
- const literal: { value: number; unit: NumericUnit } | undefined = isLiteral(value)
57
- ? value
58
- : typeof value === "number"
59
- ? { value, unit: "x" }
60
- : undefined;
57
+ // W-603: memoized, so a plain number doesn't make a new object each render; the effect below
58
+ // would reset the draft on every keystroke and nothing typed over a unitless value would stick.
59
+ const literal = React.useMemo<{ value: number; unit: NumericUnit } | undefined>(
60
+ () => (isLiteral(value) ? value : typeof value === "number" ? { value, unit: "x" } : undefined),
61
+ [value],
62
+ );
61
63
  const numericUnit = literal?.unit ?? firstNumeric(units);
62
64
  const [draft, setDraft] = React.useState(literal ? String(literal.value) : "");
63
65
  const [unit, setUnit] = React.useState<UnitChoice>(value === "auto" ? "auto" : numericUnit);
@@ -146,7 +148,7 @@ export function LengthRow({
146
148
  }}
147
149
  onBlur={commit}
148
150
  onKeyDown={(event) => {
149
- if (event.key === "Enter") commit();
151
+ if (isCommitEnter(event)) commit();
150
152
  }}
151
153
  />
152
154
  <InputGroup.Addon align="end" className="emvb-unit-addon">
@@ -18,7 +18,7 @@ export function LoopItemBindControl({
18
18
  fetcher,
19
19
  onChange,
20
20
  partType = "loop_item",
21
- label = "Loop Item",
21
+ label = "Loop item",
22
22
  emptyLabel = "Use nested elements",
23
23
  marker = "loop-item",
24
24
  }: {