@perkyzz/emvb 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/package.json +1 -1
  2. package/src/admin/access/RequireEditor.tsx +7 -7
  3. package/src/admin/access/role.ts +5 -2
  4. package/src/admin/content-api.ts +10 -3
  5. package/src/admin/content-item.ts +1 -1
  6. package/src/admin/editor/A11yCopilot.tsx +104 -56
  7. package/src/admin/editor/CommandPalette.tsx +29 -13
  8. package/src/admin/editor/Editor.tsx +82 -20
  9. package/src/admin/editor/EditorToasts.tsx +26 -0
  10. package/src/admin/editor/PerfMeter.tsx +97 -72
  11. package/src/admin/editor/ShareLink.tsx +107 -72
  12. package/src/admin/editor/ShortcutsDialog.tsx +27 -16
  13. package/src/admin/editor/Timeline.tsx +255 -160
  14. package/src/admin/editor/TopBar.tsx +71 -14
  15. package/src/admin/editor/canvas/CanvasFrame.tsx +10 -1
  16. package/src/admin/editor/canvas/CanvasTextEdit.tsx +8 -2
  17. package/src/admin/editor/canvas/drop-line.ts +11 -3
  18. package/src/admin/editor/canvas/frame-focus-ring.ts +37 -0
  19. package/src/admin/editor/canvas/use-canvas-dnd.ts +32 -3
  20. package/src/admin/editor/canvas/vnode-react.tsx +7 -0
  21. package/src/admin/editor/collection-previews.ts +10 -0
  22. package/src/admin/editor/dialogs.tsx +38 -14
  23. package/src/admin/editor/dnd/drop-target.ts +26 -1
  24. package/src/admin/editor/edited-noun.ts +15 -0
  25. package/src/admin/editor/editor-chrome.tsx +59 -7
  26. package/src/admin/editor/editor-commands.ts +2 -1
  27. package/src/admin/editor/editor-css.ts +72 -22
  28. package/src/admin/editor/element-chrome.ts +21 -11
  29. package/src/admin/editor/feature-css.ts +45 -13
  30. package/src/admin/editor/icons/IconLibraryDialog.tsx +52 -11
  31. package/src/admin/editor/icons/library.ts +1 -1
  32. package/src/admin/editor/icons/use-icon-library.ts +5 -2
  33. package/src/admin/editor/ime.ts +29 -0
  34. package/src/admin/editor/palette-items.ts +10 -3
  35. package/src/admin/editor/panels/AddPanel.tsx +35 -10
  36. package/src/admin/editor/panels/ClassesSection.tsx +18 -7
  37. package/src/admin/editor/panels/ColorControl.tsx +130 -23
  38. package/src/admin/editor/panels/ConditionsEditor.tsx +52 -26
  39. package/src/admin/editor/panels/ElementPanel.tsx +134 -24
  40. package/src/admin/editor/panels/LayersPanel.tsx +55 -19
  41. package/src/admin/editor/panels/PageSettings.tsx +66 -35
  42. package/src/admin/editor/panels/SiteStylesDrawer.tsx +170 -32
  43. package/src/admin/editor/panels/TokenScales.tsx +76 -36
  44. package/src/admin/editor/panels/TriggerSettings.tsx +50 -12
  45. package/src/admin/editor/panels/TriggersEditor.tsx +2 -1
  46. package/src/admin/editor/panels/VariableSection.tsx +48 -18
  47. package/src/admin/editor/panels/color-space.ts +9 -3
  48. package/src/admin/editor/panels/settings/AdvancedFields.tsx +12 -2
  49. package/src/admin/editor/panels/settings/AudienceEditor.tsx +51 -35
  50. package/src/admin/editor/panels/settings/BackgroundControls.tsx +55 -11
  51. package/src/admin/editor/panels/settings/BackgroundFill.tsx +3 -2
  52. package/src/admin/editor/panels/settings/BindingsEditor.tsx +15 -18
  53. package/src/admin/editor/panels/settings/BoxControl.tsx +2 -1
  54. package/src/admin/editor/panels/settings/ClassChip.tsx +21 -9
  55. package/src/admin/editor/panels/settings/ClassChipInput.tsx +24 -16
  56. package/src/admin/editor/panels/settings/DraftTextField.tsx +41 -3
  57. package/src/admin/editor/panels/settings/EffectsControls.tsx +38 -14
  58. package/src/admin/editor/panels/settings/FieldBindControl.tsx +46 -28
  59. package/src/admin/editor/panels/settings/FieldControl.tsx +20 -8
  60. package/src/admin/editor/panels/settings/FormBindControl.tsx +2 -2
  61. package/src/admin/editor/panels/settings/HintedSwitch.tsx +33 -0
  62. package/src/admin/editor/panels/settings/IconControls.tsx +12 -8
  63. package/src/admin/editor/panels/settings/IconPicker.tsx +2 -0
  64. package/src/admin/editor/panels/settings/ImageSourcesField.tsx +3 -1
  65. package/src/admin/editor/panels/settings/ItemList.tsx +15 -2
  66. package/src/admin/editor/panels/settings/LengthRow.tsx +8 -6
  67. package/src/admin/editor/panels/settings/MediaPicker.tsx +127 -23
  68. package/src/admin/editor/panels/settings/MotionControl.tsx +28 -15
  69. package/src/admin/editor/panels/settings/NumberRow.tsx +9 -3
  70. package/src/admin/editor/panels/settings/PanelSelect.tsx +50 -0
  71. package/src/admin/editor/panels/settings/QueryStyleRows.tsx +25 -18
  72. package/src/admin/editor/panels/settings/RequiredFieldsNotice.tsx +66 -1
  73. package/src/admin/editor/panels/settings/StyleRow.tsx +10 -3
  74. package/src/admin/editor/panels/settings/StyleSources.tsx +4 -1
  75. package/src/admin/editor/panels/settings/VariantEditor.tsx +10 -1
  76. package/src/admin/editor/panels/settings/box-link-name.ts +6 -2
  77. package/src/admin/editor/panels/settings/class-suggest.ts +7 -7
  78. package/src/admin/editor/panels/settings/query-style.ts +38 -9
  79. package/src/admin/editor/panels/settings/svg-images.ts +13 -0
  80. package/src/admin/editor/panels/site-list.tsx +20 -6
  81. package/src/admin/editor/panels/variable-values.ts +11 -4
  82. package/src/admin/editor/restore-deleted.ts +21 -2
  83. package/src/admin/editor/section-templates.ts +81 -12
  84. package/src/admin/editor/shortcuts.ts +17 -2
  85. package/src/admin/editor/store.ts +7 -0
  86. package/src/admin/editor/useEditorCommands.ts +61 -15
  87. package/src/admin/editor/useEditorData.ts +4 -2
  88. package/src/admin/editor/useEditorShortcuts.ts +17 -7
  89. package/src/admin/editor/useNodeActions.ts +61 -6
  90. package/src/admin/editor/useSave.ts +22 -7
  91. package/src/admin/forms-api.ts +2 -0
  92. package/src/admin/image-editor/CurvesPanel.tsx +2 -1
  93. package/src/admin/image-editor/ExportDialog.tsx +48 -18
  94. package/src/admin/image-editor/ImageEditorDialog.tsx +49 -7
  95. package/src/admin/image-editor/MetadataPanel.tsx +15 -4
  96. package/src/admin/image-editor/crop-geometry.ts +3 -2
  97. package/src/admin/image-editor/image-editor-css.ts +4 -2
  98. package/src/admin/image-editor/load.ts +9 -2
  99. package/src/admin/image-editor/parts.tsx +51 -2
  100. package/src/admin/image-editor/save.ts +23 -7
  101. package/src/admin/media-api.ts +2 -1
  102. package/src/admin/pages/AgentsPage.tsx +138 -27
  103. package/src/admin/pages/CreateDialog.tsx +97 -30
  104. package/src/admin/pages/NewPageDialog.tsx +21 -3
  105. package/src/admin/pages/NewThemePartDialog.tsx +11 -3
  106. package/src/admin/pages/PageList.tsx +14 -6
  107. package/src/admin/pages/SetupShell.tsx +28 -12
  108. package/src/admin/pages/ThemePartList.tsx +27 -7
  109. package/src/admin/pages/list-kit.tsx +106 -24
  110. package/src/admin/search.ts +15 -0
  111. package/src/admin/setup/useSetupStatus.ts +1 -1
  112. package/src/admin/theme-api.ts +13 -3
  113. package/src/admin/ui.ts +73 -22
  114. package/src/astro/floats/runtime.ts +21 -0
  115. package/src/astro/menu/runtime.ts +34 -1
  116. package/src/astro/popups/runtime.ts +33 -3
  117. package/src/astro/render.ts +3 -0
  118. package/src/astro/resolve-theme.ts +53 -11
  119. package/src/astro/resolve.ts +9 -1
  120. package/src/astro/tabs/runtime.ts +12 -0
  121. package/src/astro/theme-posts.ts +2 -2
  122. package/src/astro/visitor.ts +2 -0
  123. package/src/constants.ts +1 -1
  124. package/src/core/a11y/audit.ts +171 -24
  125. package/src/core/arrange.ts +27 -6
  126. package/src/core/audience/rules.ts +5 -1
  127. package/src/core/audience/variants.ts +29 -3
  128. package/src/core/clipboard.ts +7 -0
  129. package/src/core/css/generate.ts +31 -6
  130. package/src/core/data/bindings.ts +8 -1
  131. package/src/core/design/classes.ts +16 -7
  132. package/src/core/design/diff.ts +6 -0
  133. package/src/core/design/merge.ts +90 -2
  134. package/src/core/design/tokens.ts +16 -2
  135. package/src/core/design/transfer.ts +33 -6
  136. package/src/core/design/variables.ts +30 -9
  137. package/src/core/elements/dynamic-elements.ts +44 -5
  138. package/src/core/elements/form-elements.ts +55 -16
  139. package/src/core/elements/index.ts +83 -38
  140. package/src/core/elements/menu.ts +37 -19
  141. package/src/core/elements/select-prompt.ts +3 -0
  142. package/src/core/elements/svg-ids.ts +39 -0
  143. package/src/core/forms/binding.ts +57 -16
  144. package/src/core/forms/definition.ts +72 -0
  145. package/src/core/history/diff.ts +18 -1
  146. package/src/core/icons/catalog.ts +3 -2
  147. package/src/core/image-edit/schema.ts +11 -1
  148. package/src/core/image-edit/summary.ts +6 -3
  149. package/src/core/index.ts +15 -1
  150. package/src/core/limits.ts +12 -1
  151. package/src/core/perf/meter.ts +42 -7
  152. package/src/core/recipes/index.ts +5 -4
  153. package/src/core/render/context.ts +8 -0
  154. package/src/core/render/dynamic-post.ts +69 -12
  155. package/src/core/render/extras.ts +77 -4
  156. package/src/core/render/form.ts +140 -6
  157. package/src/core/render/index.ts +156 -20
  158. package/src/core/render/loop.ts +43 -7
  159. package/src/core/render/pagination.ts +18 -4
  160. package/src/core/render/section.ts +27 -0
  161. package/src/core/render/tabs.ts +12 -3
  162. package/src/core/render/vnode.ts +1 -1
  163. package/src/core/sanitize/css.ts +15 -2
  164. package/src/core/sanitize/embed-url.ts +42 -5
  165. package/src/core/sanitize/url.ts +2 -1
  166. package/src/core/schema/layout.ts +15 -6
  167. package/src/core/stats.ts +2 -1
  168. package/src/core/theme/conditions.ts +3 -1
  169. package/src/core/theme/dynamic.ts +36 -5
  170. package/src/core/theme/float.ts +9 -2
  171. package/src/core/theme/pagination.ts +31 -11
  172. package/src/core/theme/popup-markup.ts +23 -5
  173. package/src/core/theme/popup-rules.ts +1 -0
  174. package/src/core/theme/triggers.ts +3 -2
  175. package/src/core/tree-ops.ts +27 -0
  176. package/src/mcp/rate-limit.ts +2 -1
  177. package/src/mcp/read.ts +14 -2
  178. package/src/mcp/refs.ts +18 -0
  179. package/src/mcp/write.ts +174 -10
  180. package/src/server/agent-settings.ts +1 -1
  181. package/src/server/hooks.ts +5 -3
  182. package/src/server/icon-routes.ts +30 -9
  183. package/src/server/mcp-routes.ts +6 -1
@@ -1,3 +1,4 @@
1
+ import { selectPrompt } from "./select-prompt.ts";
1
2
  import { controlId } from "./field-id.ts";
2
3
  import type {
3
4
  CheckboxNode,
@@ -43,14 +44,14 @@ const FORM_FIELD_CSS =
43
44
  ":where(.emvb-form .ec-form-input:focus-visible){outline:2px solid currentColor;outline-offset:1px;border-color:currentColor}" +
44
45
  ':where(.emvb-form .ec-form-input[aria-invalid="true"]){border-color:#b3261e}' +
45
46
  ':where(.emvb-form input[type="checkbox"],.emvb-form input[type="radio"]){width:1.1em;height:1.1em;margin:0;accent-color:currentColor}' +
46
- ":where(.emvb-form .emvb-form-checkbox-label,.emvb-form .emvb-form-radio-label){display:inline-flex;align-items:center;gap:.5em}" +
47
+ ":where(.emvb-form .emvb-form-checkbox-label,.emvb-form .emvb-form-radio-label){display:inline-flex;align-items:center;gap:.5em;overflow-wrap:anywhere}" +
47
48
  ":where(.emvb-form .emvb-radio-group){display:flex;flex-direction:column;gap:6px;margin:0;padding:0;border:0;min-width:0}" +
48
49
  ":where(.emvb-form .emvb-radio-group>legend){float:left;width:100%;margin:0 0 -2px;padding:0}" +
49
50
  ":where(.emvb-form .ec-form-error){font-size:.875em;color:#b3261e}";
50
51
 
51
52
  export const form: ElementDefinition<FormNode> = {
52
53
  baseCss:
53
- ".emvb-form{display:flex;flex-direction:column;gap:12px;min-width:0}.emvb-form-unbound{min-height:48px;padding:12px;color:var(--text-color-kumo-subtle,#666);background:var(--color-kumo-tint,#eee)}.ec-form-hp{position:absolute;left:-9999px}" +
54
+ ".emvb-form{display:flex;flex-direction:column;gap:12px;min-width:0}.emvb-form-unbound{min-height:48px;padding:12px;color:var(--text-color-kumo-subtle,#666);background:var(--color-kumo-tint,#eee)}.emvb-form-field[hidden]{display:none!important}.ec-form-hp{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}" +
54
55
  ":where(.emvb-form-paused){padding:12px 16px;border:1px solid rgba(128,128,128,.5);border:1px solid color-mix(in srgb,currentColor 25%,transparent);border-radius:6px}:where(.emvb-form-paused p){margin:0}" +
55
56
  FORM_FIELD_CSS,
56
57
  defaults: () => ({ type: "form", props: { formId: "" }, children: [] }),
@@ -65,12 +66,24 @@ export const form: ElementDefinition<FormNode> = {
65
66
  };
66
67
 
67
68
  /** Where the forms runtime writes a field's validation message. */
68
- const errorSlot = (name: string): VNode => ({
69
+ const errorSlot = (name: string, controlFor: string): VNode => ({
69
70
  tag: "span",
70
- attrs: { class: "ec-form-error", "data-error-for": name, "aria-live": "polite" },
71
+ attrs: {
72
+ class: "ec-form-error",
73
+ id: errorId(controlFor),
74
+ "data-error-for": name,
75
+ "aria-live": "polite",
76
+ },
71
77
  children: [],
72
78
  });
73
79
 
80
+ /**
81
+ * W-780: the message was only announced as it appeared; back on the field it wasn't read. Each
82
+ * control now names its error slot in aria-describedby (an empty slot adds nothing).
83
+ */
84
+ const errorId = (controlFor: string) => `${controlFor}-error`;
85
+ const describedBy = (controlFor: string) => ({ "aria-describedby": errorId(controlFor) });
86
+
74
87
  const fieldBox = (attrs: Record<string, string>, children: VNode["children"]): VNode => ({
75
88
  tag: "div",
76
89
  attrs: { ...attrs, class: `${attrs.class ?? ""} emvb-form-field`.trim() },
@@ -85,7 +98,8 @@ const fieldWrap = (
85
98
  attrs: Record<string, string>,
86
99
  ): VNode =>
87
100
  fieldBox(attrs, [
88
- ...(labelText
101
+ // W-587: a blank label is no label.
102
+ ...(labelText?.trim()
89
103
  ? [
90
104
  {
91
105
  tag: "label",
@@ -94,10 +108,24 @@ const fieldWrap = (
94
108
  } as VNode,
95
109
  ]
96
110
  : []),
97
- control,
98
- errorSlot(name),
111
+ withDescription(labelText?.trim() ? control : named(control, name), controlFor),
112
+ errorSlot(name, controlFor),
99
113
  ]);
100
114
 
115
+ const withDescription = (control: VNode, controlFor: string): VNode => ({
116
+ ...control,
117
+ attrs: { ...control.attrs, ...describedBy(controlFor) },
118
+ });
119
+
120
+ /**
121
+ * W-753: a field with no label (and no placeholder to read out) had no name at all, so a screen
122
+ * reader said only "edit text" or "group". It falls back to the field name, as a checkbox does.
123
+ */
124
+ const named = (control: VNode, name: string): VNode =>
125
+ control.attrs.placeholder?.trim() || !name.trim()
126
+ ? control
127
+ : { ...control, attrs: { ...control.attrs, "aria-label": name } };
128
+
101
129
  /** A text input or textarea bound to `field`, with its optional placeholder. */
102
130
  const textControl = (
103
131
  tag: "input" | "textarea",
@@ -146,13 +174,14 @@ export const textareaEl: ElementDefinition<TextareaNode> = {
146
174
  export const selectEl: ElementDefinition<SelectNode> = {
147
175
  baseCss: ".emvb-select{display:flex;flex-direction:column;gap:4px}",
148
176
  defaults: () => ({ type: "select", props: { field: "choice", label: "Choice" } }),
149
- descriptor: fieldDescriptor("select", "Select", NAME_AND_LABEL),
177
+ // W-686: the Placeholder words the empty first choice ("Choose…"), for sites in other languages.
178
+ descriptor: fieldDescriptor("select", "Select", TEXT_FIELDS),
150
179
  build: (node, attrs) => {
151
180
  const name = node.props.field;
152
181
  const control: VNode = {
153
182
  tag: "select",
154
183
  attrs: { class: "ec-form-input", id: controlId(node.id), name },
155
- children: [{ tag: "option", attrs: { value: "" }, children: ["Choose…"] }],
184
+ children: [{ tag: "option", attrs: { value: "" }, children: [selectPrompt(node.props)] }],
156
185
  };
157
186
  return fieldWrap(controlId(node.id), name, node.props.label, control, attrs);
158
187
  },
@@ -166,15 +195,21 @@ export const checkbox: ElementDefinition<CheckboxNode> = {
166
195
  const name = node.props.field;
167
196
  const input: VNode = {
168
197
  tag: "input",
169
- attrs: { type: "checkbox", id: controlId(node.id), name, value: "true" },
198
+ attrs: {
199
+ type: "checkbox",
200
+ id: controlId(node.id),
201
+ name,
202
+ value: "true",
203
+ ...describedBy(controlId(node.id)),
204
+ },
170
205
  children: [],
171
206
  };
172
207
  const labelEl: VNode = {
173
208
  tag: "label",
174
209
  attrs: { class: "emvb-form-checkbox-label" },
175
- children: [input, ` ${node.props.label ?? name}`],
210
+ children: [input, ` ${node.props.label?.trim() || name}`],
176
211
  };
177
- return fieldBox(attrs, [labelEl, errorSlot(name)]);
212
+ return fieldBox(attrs, [labelEl, errorSlot(name, controlId(node.id))]);
178
213
  },
179
214
  };
180
215
 
@@ -188,7 +223,7 @@ export const radio: ElementDefinition<RadioNode> = {
188
223
  const id = controlId(node.id);
189
224
  // W-524: the question is the fieldset's <legend>, so the group is named natively (it was a
190
225
  // <label> pointing at nothing plus aria-labelledby, W-442). The id stays for old references.
191
- const legend: VNode[] = node.props.label
226
+ const legend: VNode[] = node.props.label?.trim()
192
227
  ? [
193
228
  {
194
229
  tag: "legend",
@@ -199,7 +234,11 @@ export const radio: ElementDefinition<RadioNode> = {
199
234
  : [];
200
235
  const control: VNode = {
201
236
  tag: "fieldset",
202
- attrs: { class: "emvb-radio-group" },
237
+ attrs: {
238
+ class: "emvb-radio-group",
239
+ ...describedBy(id),
240
+ ...(legend.length || !name.trim() ? {} : { "aria-label": name }),
241
+ },
203
242
  children: [
204
243
  ...legend,
205
244
  {
@@ -212,12 +251,12 @@ export const radio: ElementDefinition<RadioNode> = {
212
251
  },
213
252
  ],
214
253
  };
215
- return fieldBox(attrs, [control, errorSlot(name)]);
254
+ return fieldBox(attrs, [control, errorSlot(name, id)]);
216
255
  },
217
256
  };
218
257
 
219
258
  export const submit: ElementDefinition<SubmitNode> = {
220
- baseCss: ".emvb-submit{display:inline-flex}",
259
+ baseCss: ".emvb-submit{display:inline-flex;max-width:100%;overflow-wrap:anywhere}",
221
260
  defaults: () => ({ type: "submit", props: { label: "Submit" } }),
222
261
  descriptor: fieldDescriptor("submit", "Submit", [
223
262
  { key: "label", kind: "text", label: "Label", optional: true },
@@ -26,6 +26,7 @@ import { CONTAINER_TAGS, TEXT_TAGS } from "../schema/layout.ts";
26
26
  import type { ElementDescriptor } from "../schema/descriptors.ts";
27
27
  import { sanitizeHref } from "../sanitize/href.ts";
28
28
  import { sanitizeSvgMarkup } from "../sanitize/svg.ts";
29
+ import { scopeSvgIds } from "./svg-ids.ts";
29
30
  import { sanitizeMediaUrl } from "../sanitize/media-url.ts";
30
31
  import { getBundledIcon } from "../icons/catalog.ts";
31
32
  import { resolveEmbedUrl } from "../sanitize/embed-url.ts";
@@ -53,6 +54,19 @@ export const HEADING_TAGS = ["h1", "h2", "h3", "h4", "h5", "h6"] as const;
53
54
  const newTabAttrs = (newTab: boolean | undefined): Record<string, string> =>
54
55
  newTab ? { target: "_blank", rel: "noopener noreferrer" } : {};
55
56
 
57
+ /** UX-059: tag choices read as words; p, which isn't one, names itself. */
58
+ const TAG_LABELS: Record<(typeof CONTAINER_TAGS)[number] | (typeof TEXT_TAGS)[number], string> = {
59
+ div: "Div",
60
+ section: "Section",
61
+ header: "Header",
62
+ footer: "Footer",
63
+ main: "Main",
64
+ article: "Article",
65
+ aside: "Aside",
66
+ nav: "Nav",
67
+ p: "Paragraph (p)",
68
+ };
69
+
56
70
  const LINK_MESSAGE = "Use a full URL such as https://example.com or a path such as /pricing.";
57
71
 
58
72
  /** Optional Link and new-tab fields for elements that wrap their content in a link (W-141). */
@@ -112,13 +126,21 @@ const heading: ElementDefinition<HeadingNode> = {
112
126
  /** A box link is checked like any link, so a bad URL gets an inline error, not a silent drop (W-176). */
113
127
  const BOX_LINK_FIELDS = [
114
128
  { key: "href", kind: "href" as const, label: "Link", optional: true, message: LINK_MESSAGE },
115
- { key: "newTab", kind: "boolean" as const, label: "Open in new tab", optional: true },
129
+ { key: "newTab", kind: "boolean" as const, label: "Open in a new tab", optional: true },
116
130
  ];
117
131
 
132
+ /**
133
+ * W-797: a linked box is an <a>, so without this its whole content took the browser's blue,
134
+ * underlined link look. Like a heading link it inherits; :where() lets site and local styles win.
135
+ * Every box type ships it, as any of them can be the link (W-792: CSS ships with its element).
136
+ */
137
+ const BOX_LINK_CSS = ":where(a.emvb-box-link){color:inherit;text-decoration:inherit}";
138
+
118
139
  const container: ElementDefinition<ContainerNode> = {
119
140
  // W-299: a word longer than the line (a pasted URL) breaks instead of widening the page on a phone.
120
141
  baseCss:
121
- ".emvb-container{display:flex;flex-direction:column;min-width:0;overflow-wrap:break-word}",
142
+ ".emvb-container{display:flex;flex-direction:column;min-width:0;overflow-wrap:break-word}" +
143
+ BOX_LINK_CSS,
122
144
  defaults: () => ({ type: "container", props: {}, children: [] }),
123
145
  descriptor: {
124
146
  type: "container",
@@ -131,7 +153,7 @@ const container: ElementDefinition<ContainerNode> = {
131
153
  kind: "select",
132
154
  label: "HTML tag",
133
155
  optional: true,
134
- options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: tag })),
156
+ options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: TAG_LABELS[tag] })),
135
157
  message: "Pick a landmark or div.",
136
158
  },
137
159
  ...BOX_LINK_FIELDS,
@@ -201,7 +223,7 @@ const text: ElementDefinition<TextNode> = {
201
223
  kind: "select",
202
224
  label: "HTML tag",
203
225
  optional: true,
204
- options: TEXT_TAGS.map((tag) => ({ value: tag, label: tag })),
226
+ options: TEXT_TAGS.map((tag) => ({ value: tag, label: TAG_LABELS[tag] })),
205
227
  },
206
228
  ],
207
229
  },
@@ -258,7 +280,7 @@ const link: ElementDefinition<LinkNode> = {
258
280
  const button: ElementDefinition<ButtonNode> = {
259
281
  baseCss:
260
282
  // The look sits in :where() so site tag defaults, classes and local styles all win (W-148).
261
- ".emvb-button{display:inline-flex;align-items:center;justify-content:center;gap:0.5em;margin:0;font:inherit;text-decoration:none;cursor:pointer}:where(.emvb-button){color:inherit;background:transparent;border:1px solid currentColor;border-radius:6px;padding:0.625em 1.25em;line-height:1.2}.emvb-button-icon{display:inline-flex;flex:none}.emvb-button-icon svg{width:100%;height:100%;display:block}.emvb-button-icon--sm{width:1em;height:1em}.emvb-button-icon--md{width:1.25em;height:1.25em}.emvb-button-icon--lg{width:1.5em;height:1.5em}.emvb-figure{margin:0}.emvb-figcaption{margin-top:0.35em}.emvb-image-link{display:contents}",
283
+ ".emvb-button{display:inline-flex;align-items:center;justify-content:center;gap:0.5em;overflow-wrap:anywhere;text-align:center;margin:0;font:inherit;text-decoration:none;cursor:pointer}:where(.emvb-button){color:inherit;background:transparent;border:1px solid currentColor;border-radius:6px;padding:0.625em 1.25em;line-height:1.2}.emvb-button-icon{display:inline-flex;flex:none}.emvb-button-icon svg{width:100%;height:100%;display:block}.emvb-button-icon--sm{width:1em;height:1em}.emvb-button-icon--md{width:1.25em;height:1.25em}.emvb-button-icon--lg{width:1.5em;height:1.5em}",
262
284
  defaults: () => ({ type: "button", props: { text: "Button" } }),
263
285
  descriptor: {
264
286
  type: "button",
@@ -356,7 +378,9 @@ function buttonChildren(node: ButtonNode): (VNode | string)[] {
356
378
  }
357
379
 
358
380
  const list: ElementDefinition<ListNode> = {
359
- baseCss: ".emvb-list{margin:0;padding-inline-start:1.25em}.emvb-list li{margin:0}",
381
+ // W-796: "100." is wider than 1.25em, so three-digit numbers sat outside the list's box.
382
+ baseCss:
383
+ ".emvb-list{margin:0;padding-inline-start:1.25em}.emvb-list li{margin:0}.emvb-list--wide{padding-inline-start:2.25em}",
360
384
  defaults: () => ({ type: "list", props: { items: ["Item"] } }),
361
385
  descriptor: {
362
386
  type: "list",
@@ -368,21 +392,26 @@ const list: ElementDefinition<ListNode> = {
368
392
  { key: "items", kind: "list-items", label: "Items" },
369
393
  ],
370
394
  },
371
- build: (node, attrs) => ({
372
- tag: node.props.ordered ? "ol" : "ul",
373
- attrs,
395
+ build: (node, attrs) => {
374
396
  // W-275: blank items would be empty bullets on the page; a list of only blanks has none.
375
- children: node.props.items
376
- .filter((item) => item.trim() !== "")
377
- .map((item) => ({ tag: "li", attrs: {}, children: [item] })),
378
- }),
397
+ const items = node.props.items.filter((item) => item.trim() !== "");
398
+ const wide = node.props.ordered === true && items.length >= 100;
399
+ return {
400
+ tag: node.props.ordered ? "ol" : "ul",
401
+ attrs: wide ? { ...attrs, class: `${attrs.class ?? ""} emvb-list--wide`.trim() } : attrs,
402
+ children: items.map((item) => ({ tag: "li", attrs: {}, children: [item] })),
403
+ };
404
+ },
379
405
  };
380
406
 
381
407
  const image: ElementDefinition<ImageNode> = {
382
408
  // W-269: natural size, at most the container's width. A container's default stretch made a
383
409
  // 400 px image 1184 px wide (blurry); a Width (px) attribute or a style width still sets it.
384
410
  baseCss:
385
- ".emvb-image{display:block;max-width:100%;height:auto}:where(img.emvb-image:not([width])){width:fit-content}",
411
+ ".emvb-image{display:block;max-width:100%;height:auto}:where(img.emvb-image:not([width])){width:fit-content}" +
412
+ // W-792: these sat in the Button's base CSS, so a page without a Button gave a captioned
413
+ // image the browser's 40 px figure margins and a linked image a stray inline box.
414
+ ".emvb-figure{margin:0}.emvb-figcaption{margin-top:0.35em}.emvb-image-link{display:contents}",
386
415
  defaults: () => ({
387
416
  type: "image",
388
417
  props: { src: "", alt: "Image", decorative: false },
@@ -404,7 +433,7 @@ const image: ElementDefinition<ImageNode> = {
404
433
  {
405
434
  key: "decorative",
406
435
  kind: "boolean",
407
- label: "Decorative (empty alt)",
436
+ label: "Decorative",
408
437
  optional: true,
409
438
  },
410
439
  // The first big image people see (hero, LCP) shouldn't wait for lazy loading (W-226).
@@ -504,25 +533,33 @@ function imageSources(
504
533
  width: number | undefined,
505
534
  ): string | undefined {
506
535
  if (!sources || sources.length === 0) return undefined;
507
- const parts: string[] = [];
508
- const seen = new Set<string>();
536
+ const main = srcsetUrl(src);
509
537
  let srcWidth: number | undefined;
510
538
  for (const source of sources) {
511
- const url = srcsetUrl(sanitizeMediaUrl(source.src));
512
539
  if (!validSourceWidth(source.width)) continue;
513
- if (url === srcsetUrl(src)) {
514
- srcWidth ??= source.width;
515
- continue;
540
+ if (srcsetUrl(sanitizeMediaUrl(source.src)) === main) {
541
+ srcWidth = source.width;
542
+ break;
516
543
  }
544
+ }
545
+ srcWidth ??= validSourceWidth(width) ? width : undefined;
546
+ const mainListed = srcWidth !== undefined && main !== undefined && !/[\s,]/.test(main);
547
+ const parts: string[] = [];
548
+ const seen = new Set<string>();
549
+ // W-541: two candidates with one width make the whole srcset invalid; the first wins, and the
550
+ // main image's width is kept for the main image.
551
+ const widths = new Set<number>(mainListed ? [srcWidth as number] : []);
552
+ for (const source of sources) {
553
+ const url = srcsetUrl(sanitizeMediaUrl(source.src));
554
+ if (!validSourceWidth(source.width) || url === main) continue;
517
555
  // A comma or space is another srcset candidate, so one field would request a second host.
518
- if (!url || /[\s,]/.test(url) || seen.has(url)) continue;
556
+ if (!url || /[\s,]/.test(url) || seen.has(url) || widths.has(source.width)) continue;
519
557
  seen.add(url);
558
+ widths.add(source.width);
520
559
  parts.push(`${url} ${source.width}w`);
521
560
  }
522
561
  if (parts.length === 0) return undefined;
523
- srcWidth ??= validSourceWidth(width) ? width : undefined;
524
- const main = srcsetUrl(src);
525
- if (srcWidth !== undefined && main && !/[\s,]/.test(main)) parts.push(`${main} ${srcWidth}w`);
562
+ if (mainListed) parts.push(`${main} ${srcWidth}w`);
526
563
  return parts.join(", ");
527
564
  }
528
565
 
@@ -533,7 +570,8 @@ const icon: ElementDefinition<IconNode> = {
533
570
  baseCss:
534
571
  // W-237: the glyph reads the wrapper's icon custom properties (rotate, flip, shadow, loop,
535
572
  // stroke); unset they change nothing. The svg inherits the wrapper's transition for hover.
536
- ".emvb-icon{display:inline-flex;align-items:center;justify-content:center;line-height:0;color:inherit}.emvb-icon-link{display:inline-flex;color:inherit}.emvb-icon svg{display:block;rotate:var(--emvb-icon-rotate,0deg);scale:var(--emvb-icon-flip,1 1);filter:var(--emvb-icon-shadow,none);animation:var(--emvb-icon-animation,none);transition:inherit}" +
573
+ // W-803: an icon larger than its box (512 px on a phone) shrinks to fit, keeping its shape.
574
+ ".emvb-icon{display:inline-flex;align-items:center;justify-content:center;line-height:0;color:inherit}.emvb-icon-link{display:inline-flex;max-width:100%;color:inherit}.emvb-icon svg{display:block;max-width:100%;rotate:var(--emvb-icon-rotate,0deg);scale:var(--emvb-icon-flip,1 1);filter:var(--emvb-icon-shadow,none);animation:var(--emvb-icon-animation,none);transition:inherit}" +
537
575
  ICON_STROKE_WIDTHS.map(
538
576
  (width) =>
539
577
  `.emvb-icon-sw${width.replace(".", "_")}{stroke-width:var(--emvb-icon-stroke,${width})}`,
@@ -554,7 +592,7 @@ const icon: ElementDefinition<IconNode> = {
554
592
  {
555
593
  key: "decorative",
556
594
  kind: "boolean",
557
- label: "Decorative (hide from assistive tech)",
595
+ label: "Decorative",
558
596
  optional: true,
559
597
  },
560
598
  {
@@ -754,13 +792,15 @@ const video: ElementDefinition<VideoNode> = {
754
792
  children: [],
755
793
  };
756
794
  }
795
+ // W-549: an empty Title left the player unnamed for screen readers.
796
+ const title = String(node.props.title ?? "").trim() || "Video";
757
797
  if (target.kind === "iframe") {
758
798
  return {
759
799
  tag: "iframe",
760
800
  attrs: {
761
801
  ...attrs,
762
802
  src: target.src,
763
- title: node.props.title,
803
+ title,
764
804
  loading: "lazy",
765
805
  referrerpolicy: "strict-origin-when-cross-origin",
766
806
  allow: "encrypted-media; picture-in-picture; fullscreen",
@@ -776,7 +816,7 @@ const video: ElementDefinition<VideoNode> = {
776
816
  attrs: {
777
817
  ...attrs,
778
818
  src: target.src,
779
- title: node.props.title,
819
+ title,
780
820
  controls: "",
781
821
  preload: "metadata",
782
822
  },
@@ -831,7 +871,7 @@ const svgEl: ElementDefinition<SvgNode> = {
831
871
  {
832
872
  key: "decorative",
833
873
  kind: "boolean",
834
- label: "Decorative (hide from assistive tech)",
874
+ label: "Decorative",
835
875
  optional: true,
836
876
  },
837
877
  {
@@ -876,7 +916,7 @@ const svgEl: ElementDefinition<SvgNode> = {
876
916
  return {
877
917
  tag: "span",
878
918
  attrs,
879
- children: [{ tag: "svg", attrs: svgAttrs, children: tree.children }],
919
+ children: [{ tag: "svg", attrs: svgAttrs, children: scopeSvgIds(tree.children, node.id) }],
880
920
  };
881
921
  },
882
922
  };
@@ -900,7 +940,7 @@ const tabPanel: ElementDefinition<TabPanelNode> = {
900
940
 
901
941
  const tabs: ElementDefinition<TabsNode> = {
902
942
  baseCss:
903
- ".emvb-tabs{display:flex;flex-direction:column;min-width:0;gap:0}.emvb-tab-input{position:absolute;opacity:0;pointer-events:none;width:1px;height:1px}.emvb-tab-list{display:flex;flex-wrap:wrap;gap:0;border-bottom:1px solid currentColor;margin:0;padding:0}.emvb-tab-label{display:inline-block;padding:8px 12px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px}.emvb-tab-panels{min-width:0}.emvb-tab-panel{display:none;padding-top:12px;min-width:0}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(1):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(1){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(1):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(1){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(2):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(2){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(2):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(2){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(3):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(3){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(3):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(3){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(4):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(4){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(4):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(4){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(5):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(5){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(5):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(5){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(6):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(6){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(6):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(6){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(7):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(7){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(7):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(7){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(8):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(8){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(8):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(8){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(9):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(9){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(9):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(9){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(10):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(10){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(10):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(10){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(11):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(11){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(11):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(11){display:block}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(12):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(12){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(12):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(12){display:block}",
943
+ ".emvb-tabs{display:flex;flex-direction:column;min-width:0;gap:0}.emvb-tab-input{position:absolute;opacity:0;pointer-events:none;width:1px;height:1px}.emvb-tab-list{display:flex;flex-wrap:wrap;gap:0;border-bottom:1px solid currentColor;margin:0;padding:0}.emvb-tab-label{display:inline-block;padding:8px 12px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;min-width:0;overflow-wrap:anywhere}.emvb-tab-panels{min-width:0}.emvb-tab-panel{padding-top:12px;min-width:0}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(1):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(1){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(1):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(1)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(2):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(2){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(2):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(2)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(3):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(3){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(3):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(3)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(4):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(4){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(4):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(4)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(5):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(5){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(5):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(5)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(6):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(6){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(6):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(6)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(7):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(7){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(7):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(7)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(8):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(8){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(8):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(8)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(9):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(9){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(9):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(9)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(10):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(10){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(10):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(10)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(11):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(11){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(11):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(11)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(12):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(12){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(12):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(12)){display:none!important}",
904
944
  defaults: () => ({
905
945
  type: "tabs",
906
946
  props: {},
@@ -918,7 +958,7 @@ const tabs: ElementDefinition<TabsNode> = {
918
958
  };
919
959
 
920
960
  const divBlock: ElementDefinition<DivBlockNode> = {
921
- baseCss: ".emvb-div-block{display:block;min-width:0}",
961
+ baseCss: ".emvb-div-block{display:block;min-width:0}" + BOX_LINK_CSS,
922
962
  defaults: () => ({ type: "div-block", props: {}, children: [] }),
923
963
  descriptor: {
924
964
  type: "div-block",
@@ -968,7 +1008,7 @@ const layoutSection: ElementDefinition<LayoutSectionNode> = {
968
1008
  kind: "select",
969
1009
  label: "HTML tag",
970
1010
  optional: true,
971
- options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: tag })),
1011
+ options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: TAG_LABELS[tag] })),
972
1012
  message: "Pick a landmark or div. A section is a section by default.",
973
1013
  },
974
1014
  ],
@@ -986,7 +1026,7 @@ const TRACKS_HINT =
986
1026
  "Up to 12 tracks, one per line: 1fr, 2fr, 3fr, auto, min-content, max-content, or a length.";
987
1027
 
988
1028
  const grid: ElementDefinition<GridNode> = {
989
- baseCss: ".emvb-grid{display:grid;min-width:0}",
1029
+ baseCss: ".emvb-grid{display:grid;min-width:0}" + BOX_LINK_CSS,
990
1030
  defaults: () => ({ type: "grid", props: { columns: 3 }, children: [] }),
991
1031
  descriptor: {
992
1032
  type: "grid",
@@ -1033,7 +1073,10 @@ const grid: ElementDefinition<GridNode> = {
1033
1073
 
1034
1074
  const flexbox: ElementDefinition<FlexboxNode> = {
1035
1075
  baseCss:
1036
- ".emvb-flexbox{display:flex;flex-direction:row;flex-wrap:wrap;align-items:stretch;min-width:0;gap:16px}",
1076
+ // W-800: a word longer than the line (a pasted URL) widened a row or a centred column and the
1077
+ // page scrolled sideways on a phone; break-word (W-299) doesn't shrink a flex item, anywhere does.
1078
+ ".emvb-flexbox{display:flex;flex-direction:row;flex-wrap:wrap;align-items:stretch;min-width:0;gap:16px;overflow-wrap:anywhere}" +
1079
+ BOX_LINK_CSS,
1037
1080
  defaults: () => ({
1038
1081
  type: "flexbox",
1039
1082
  props: {},
@@ -1074,11 +1117,13 @@ const accordionItem: ElementDefinition<AccordionItemNode> = {
1074
1117
  defaultTab: "content",
1075
1118
  fields: [
1076
1119
  { key: "summary", kind: "text", label: "Title" },
1077
- { key: "open", kind: "boolean", label: "Open", optional: true },
1120
+ { key: "open", kind: "boolean", label: "Open by default", optional: true },
1078
1121
  ],
1079
1122
  },
1080
1123
  build: (node, attrs, children) => {
1081
- const summary: VNode = { tag: "summary", attrs: {}, children: [node.props.summary] };
1124
+ // W-664: a title of only spaces left a blank, unnamed toggle.
1125
+ const title = node.props.summary.trim() || "Details";
1126
+ const summary: VNode = { tag: "summary", attrs: {}, children: [title] };
1082
1127
  const body: VNode = { tag: "div", attrs: { class: "emvb-accordion-body" }, children };
1083
1128
  return {
1084
1129
  tag: "details",
@@ -27,14 +27,17 @@ function stampGroup(children: VNode["children"], name: string): VNode["children"
27
27
  }
28
28
 
29
29
  /** Runs of menu items become a list. Other elements stay in the panel beside that list. */
30
- function groupItems(children: VNode["children"]): VNode["children"] {
30
+ function groupItems(
31
+ children: VNode["children"],
32
+ listClass = "emvb-menu__list emvb-menu__list--sub",
33
+ ): VNode["children"] {
31
34
  const out: VNode["children"] = [];
32
35
  let batch: VNode[] = [];
33
36
  const flush = () => {
34
37
  if (batch.length === 0) return;
35
38
  out.push({
36
39
  tag: "ul",
37
- attrs: { class: "emvb-menu__list emvb-menu__list--sub" },
40
+ attrs: { class: listClass },
38
41
  children: batch,
39
42
  });
40
43
  batch = [];
@@ -63,15 +66,24 @@ const MENU_CSS = [
63
66
  ".emvb-menu-item__toggle{display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;padding:0;cursor:pointer;list-style:none}",
64
67
  ".emvb-menu-item__toggle::-webkit-details-marker{display:none}",
65
68
  ".emvb-menu-item__toggle::before{content:'';width:.4rem;height:.4rem;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(45deg) translateY(-1px)}",
69
+ // W-614: the text toggle reads "Shop ⌄": text first, the chevron after it.
70
+ ".emvb-menu-item__toggle--label{width:auto;gap:.6rem;padding-inline-end:.35rem}",
71
+ ".emvb-menu-item__toggle--label::before{order:1}",
66
72
  ".emvb-menu-panel{display:none;position:absolute;z-index:30;top:100%;inset-inline-start:0;min-width:12rem;padding:.75rem;background:canvas;color:canvastext;border:1px solid #00000014;box-shadow:0 12px 32px #00000029}",
67
73
  ".emvb-menu-item__disclosure[open]>.emvb-menu-panel{display:block}",
68
- "@media (hover:hover) and (pointer:fine){.emvb-menu-item:hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel,.emvb-menu-item:focus-within>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel{display:block}}",
74
+ "@media (hover:hover) and (pointer:fine){.emvb-menu-item:not([data-emvb-menu-dismissed]):hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel,.emvb-menu-item:not([data-emvb-menu-dismissed]):focus-within>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel{display:block}}",
69
75
  // W-267: a closed <details> hides its content (::details-content is content-visibility:hidden),
70
76
  // so the hover rule above showed nothing until the details' content is made visible too. Its own
71
77
  // rule: a browser without ::details-content drops only this one. Hover only: keyboard users open
72
78
  // a dropdown with its toggle, and Tab doesn't walk through every closed dropdown's links.
73
- "@media (hover:hover) and (pointer:fine){.emvb-menu-item:hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure::details-content{content-visibility:visible}}",
79
+ "@media (hover:hover) and (pointer:fine){.emvb-menu-item:not([data-emvb-menu-dismissed]):hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure::details-content{content-visibility:visible}}",
80
+ // W-783: Escape marks the hovered item [data-emvb-menu-dismissed] (menu runtime) so a hover-shown
81
+ // panel can be dismissed without moving the pointer (WCAG 1.4.13).
74
82
  ".emvb-menu-panel--wide{inset-inline:0;min-width:0}",
83
+ // W-784: a column menu's items stretch to its width, so a flyout placed at the item's end
84
+ // opened far from its toggle (off the page in a full-width menu). Anchor it to the bar.
85
+ ".emvb-menu--column .emvb-menu-item{position:static}",
86
+ ".emvb-menu--column .emvb-menu-item__bar{position:relative;width:fit-content;max-width:100%}",
75
87
  ".emvb-menu--column .emvb-menu-panel{top:0;inset-inline-start:100%}",
76
88
  ".emvb-menu--column .emvb-menu-panel--wide{inset-inline:auto;inset-inline-start:100%;min-width:18rem}",
77
89
  ].join("");
@@ -118,13 +130,9 @@ export const menu: ElementDefinition<MenuNode> = {
118
130
  return {
119
131
  tag: "nav",
120
132
  attrs: { ...attrs, class: classes, "aria-label": label },
121
- children: [
122
- {
123
- tag: "ul",
124
- attrs: { class: "emvb-menu__list" },
125
- children: stampGroup(children, `emvb-menu-${node.id}`),
126
- },
127
- ],
133
+ // W-601: an imported layout can put a non-item straight in the Menu; it sits beside the
134
+ // list, since a <ul> holds only <li>.
135
+ children: groupItems(stampGroup(children, `emvb-menu-${node.id}`), "emvb-menu__list"),
128
136
  };
129
137
  },
130
138
  };
@@ -138,11 +146,12 @@ export const menuItem: ElementDefinition<MenuItemNode> = {
138
146
  group: "content",
139
147
  defaultTab: "content",
140
148
  fields: [
141
- { key: "text", kind: "text", label: "Label" },
149
+ // UX-044: a menu item is a link, so its fields read like the Link and Button elements'.
150
+ { key: "text", kind: "text", label: "Text" },
142
151
  {
143
152
  key: "href",
144
153
  kind: "href",
145
- label: "Link",
154
+ label: "URL",
146
155
  optional: true,
147
156
  message: "Use a full URL such as https://example.com or a path such as /pricing.",
148
157
  },
@@ -161,18 +170,27 @@ export const menuItem: ElementDefinition<MenuItemNode> = {
161
170
  children: [node.props.text],
162
171
  }
163
172
  : { tag: "span", attrs: { class: "emvb-menu-item__label" }, children: [node.props.text] };
164
- const bar: VNode["children"] = [label];
173
+ // W-614: with no link, the item's text is the dropdown's toggle, so tapping "Shop" opens it
174
+ // (the chevron alone was a 28 px target, and the text did nothing on touch screens).
175
+ const textToggle = !href && children.length > 0;
176
+ const bar: VNode["children"] = textToggle ? [] : [label];
165
177
  if (children.length > 0) {
166
178
  const panelClass = wide ? "emvb-menu-panel emvb-menu-panel--wide" : "emvb-menu-panel";
167
179
  bar.push({
168
180
  tag: "details",
169
181
  attrs: { class: "emvb-menu-item__disclosure" },
170
182
  children: [
171
- {
172
- tag: "summary",
173
- attrs: { class: "emvb-menu-item__toggle", "aria-label": `Open ${node.props.text}` },
174
- children: [],
175
- },
183
+ textToggle
184
+ ? {
185
+ tag: "summary",
186
+ attrs: { class: "emvb-menu-item__toggle emvb-menu-item__toggle--label" },
187
+ children: [node.props.text],
188
+ }
189
+ : {
190
+ tag: "summary",
191
+ attrs: { class: "emvb-menu-item__toggle", "aria-label": `Open ${node.props.text}` },
192
+ children: [],
193
+ },
176
194
  {
177
195
  tag: "div",
178
196
  attrs: { class: panelClass },
@@ -0,0 +1,3 @@
1
+ /** The Select's empty first choice: its Placeholder, or "Choose…" (W-686). */
2
+ export const selectPrompt = (props: { placeholder?: string | undefined }): string =>
3
+ props.placeholder?.trim() || "Choose…";
@@ -0,0 +1,39 @@
1
+ import type { VNode } from "../render/vnode.ts";
2
+
3
+ const URL_REF = /url\(\s*(['"]?)#([^'")\s]+)\1\s*\)/g;
4
+ const ID_LIST_ATTRS = new Set(["aria-labelledby", "aria-describedby"]);
5
+
6
+ /**
7
+ * W-785: ids inside pasted SVG markup ("g", "a", "clip0") were rendered as-is, so two SVGs on
8
+ * a page using the same id resolved every url(#id) and href="#id" to the first one: a second
9
+ * gradient icon painted with the first one's colors. Prefix each internal id with the element's
10
+ * own id and rewrite the references to it. References to ids the SVG doesn't define are left.
11
+ */
12
+ export function scopeSvgIds(children: (VNode | string)[], prefix: string): (VNode | string)[] {
13
+ const ids = new Set<string>();
14
+ const collect = (node: VNode | string): void => {
15
+ if (typeof node === "string") return;
16
+ if (node.attrs.id) ids.add(node.attrs.id);
17
+ node.children.forEach(collect);
18
+ };
19
+ children.forEach(collect);
20
+ if (ids.size === 0) return children;
21
+ const scoped = (id: string) => (ids.has(id) ? `${prefix}-${id}` : id);
22
+ const rewrite = (node: VNode | string): VNode | string => {
23
+ if (typeof node === "string") return node;
24
+ const attrs: Record<string, string> = {};
25
+ for (const [name, value] of Object.entries(node.attrs)) {
26
+ if (name === "id") attrs[name] = scoped(value);
27
+ else if ((name === "href" || name === "xlink:href") && value.startsWith("#"))
28
+ attrs[name] = `#${scoped(value.slice(1))}`;
29
+ else if (ID_LIST_ATTRS.has(name)) attrs[name] = value.split(/\s+/).map(scoped).join(" ");
30
+ else
31
+ attrs[name] = value.replace(
32
+ URL_REF,
33
+ (_m, q: string, id: string) => `url(${q}#${scoped(id)}${q})`,
34
+ );
35
+ }
36
+ return { ...node, attrs, children: node.children.map(rewrite) };
37
+ };
38
+ return children.map(rewrite);
39
+ }