@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 { Banner, Button, Input } from "@cloudflare/kumo";
1
+ import { Banner, Button, Input, SkeletonLine } from "@cloudflare/kumo";
2
2
  import { PlusIcon, WarningCircleIcon } from "@phosphor-icons/react";
3
3
  import * as React from "react";
4
4
  import type { Fetcher } from "../api.ts";
@@ -13,8 +13,11 @@ type ListState<T> =
13
13
  /** Loads a list for `fetcher`, ignoring an answer that arrives after unmount. */
14
14
  export function useList<T>(fetcher: Fetcher, load: (fetcher: Fetcher) => Promise<T[]>) {
15
15
  const [list, setList] = React.useState<ListState<T>>({ state: "loading" });
16
+ const [attempt, setAttempt] = React.useState(0);
17
+ const retry = React.useCallback(() => setAttempt((value) => value + 1), []);
16
18
  React.useEffect(() => {
17
19
  let active = true;
20
+ setList({ state: "loading" });
18
21
  load(fetcher).then(
19
22
  (items) => active && setList({ state: "ready", items }),
20
23
  (error: unknown) =>
@@ -27,13 +30,31 @@ export function useList<T>(fetcher: Fetcher, load: (fetcher: Fetcher) => Promise
27
30
  return () => {
28
31
  active = false;
29
32
  };
30
- }, [fetcher, load]);
31
- return list;
33
+ }, [fetcher, load, attempt]);
34
+ return { ...list, retry };
35
+ }
36
+
37
+ /**
38
+ * W-837: Retry swaps the error for a loading card and then the list, so the focused Retry button
39
+ * vanished and focus fell to the page body. A Retry press leaves a short-lived note; the loading
40
+ * card, a fresh error's Retry, or the list's New button takes focus when it mounts.
41
+ */
42
+ let retryPressedAt = 0;
43
+ const RETRY_FOCUS_MS = 15_000;
44
+ function useRetryLanding<T extends HTMLElement>(ref: React.RefObject<T | null>, last: boolean) {
45
+ React.useEffect(() => {
46
+ if (Date.now() - retryPressedAt > RETRY_FOCUS_MS) return;
47
+ if (last) retryPressedAt = 0;
48
+ ref.current?.focus({ preventScroll: true });
49
+ }, [ref, last]);
32
50
  }
33
51
 
34
52
  export function NewButton({ label, onClick }: { label: string; onClick: () => void }) {
53
+ const ref = React.useRef<HTMLButtonElement>(null);
54
+ useRetryLanding(ref, true);
35
55
  return (
36
56
  <Button
57
+ ref={ref}
37
58
  variant="primary"
38
59
  className={BUTTON}
39
60
  style={SOLID_PRIMARY}
@@ -45,13 +66,75 @@ export function NewButton({ label, onClick }: { label: string; onClick: () => vo
45
66
  );
46
67
  }
47
68
 
48
- export function ListError({ title, message }: { title: string; message: string }) {
69
+ export function ListLoading({ label }: { label: string }) {
70
+ const ref = React.useRef<HTMLDivElement>(null);
71
+ useRetryLanding(ref, false);
72
+ return (
73
+ <div
74
+ ref={ref}
75
+ tabIndex={-1}
76
+ className="emvb-surface-card emvb-list-loading"
77
+ role="status"
78
+ aria-label={label}
79
+ >
80
+ <p className="emvb-helper">{label}</p>
81
+ <div className="emvb-list-skeleton-rows" aria-hidden="true">
82
+ {[0, 1, 2].map((row) => (
83
+ <div className="emvb-list-skeleton-row" key={row}>
84
+ <div className="emvb-list-skeleton-title">
85
+ <SkeletonLine minWidth={80} maxWidth={80} blockHeight={20} />
86
+ <SkeletonLine minWidth={55} maxWidth={55} blockHeight={16} />
87
+ </div>
88
+ <SkeletonLine minWidth={65} maxWidth={65} />
89
+ <SkeletonLine minWidth={75} maxWidth={75} />
90
+ </div>
91
+ ))}
92
+ </div>
93
+ </div>
94
+ );
95
+ }
96
+
97
+ /** A named, motion-free status for short checks that have no list shape to sketch (UX-012). */
98
+ export function LoadingStatus({ label }: { label: string }) {
99
+ return (
100
+ <p className="emvb-helper emvb-loading-status" role="status">
101
+ {label}
102
+ </p>
103
+ );
104
+ }
105
+
106
+ export function ListError({
107
+ title,
108
+ message,
109
+ onRetry,
110
+ }: {
111
+ title: string;
112
+ message: string;
113
+ onRetry: () => void;
114
+ }) {
115
+ const ref = React.useRef<HTMLButtonElement>(null);
116
+ useRetryLanding(ref, true);
49
117
  return (
50
118
  <Banner
119
+ role="alert"
51
120
  variant="error"
52
121
  icon={<WarningCircleIcon aria-hidden="true" />}
53
122
  title={title}
54
123
  description={message}
124
+ action={
125
+ <Button
126
+ ref={ref}
127
+ type="button"
128
+ variant="secondary"
129
+ className={BUTTON}
130
+ onClick={() => {
131
+ retryPressedAt = Date.now();
132
+ onRetry();
133
+ }}
134
+ >
135
+ Retry
136
+ </Button>
137
+ }
55
138
  />
56
139
  );
57
140
  }
@@ -67,42 +150,36 @@ export function StatusBadge({ status }: { status: string }) {
67
150
 
68
151
  const formatter = new Intl.DateTimeFormat(undefined, { dateStyle: "medium", timeStyle: "short" });
69
152
 
153
+ /** W-685: a time the browser can't read showed "Invalid time value" by throwing, which blanked the list. */
154
+ const readableTime = (iso: string) => {
155
+ const time = iso ? Date.parse(iso) : Number.NaN;
156
+ return Number.isNaN(time) ? "" : formatter.format(time);
157
+ };
158
+
70
159
  export function EditedTime({ iso }: { iso: string }) {
71
160
  return (
72
161
  <time dateTime={iso} title={iso} className="emvb-tabular">
73
- {iso ? formatter.format(new Date(iso)) : ""}
162
+ {readableTime(iso)}
74
163
  </time>
75
164
  );
76
165
  }
77
166
 
78
- export const fold = (text: string) =>
79
- text.normalize("NFD").replace(/\p{M}/gu, "").toLocaleLowerCase();
80
-
81
- /**
82
- * W-207: does an entry match the list search? Every word must appear in one of the fields,
83
- * ignoring case and accents, so "about us" finds "About Us" and "/about-us".
84
- */
85
- export function matchesSearch(query: string, ...fields: string[]): boolean {
86
- const haystack = fold(fields.join(" "));
87
- return fold(query)
88
- .split(/\s+/)
89
- .filter(Boolean)
90
- .every((word) => haystack.includes(word));
91
- }
92
-
93
167
  /** The search box above a list (W-207). */
94
168
  export function ListSearch({
95
169
  value,
96
170
  onChange,
97
171
  label,
172
+ inputRef,
98
173
  }: {
99
174
  value: string;
100
175
  onChange: (value: string) => void;
101
176
  label: string;
177
+ inputRef: React.Ref<HTMLInputElement>;
102
178
  }) {
103
179
  return (
104
180
  <div className="emvb-list-search">
105
181
  <Input
182
+ ref={inputRef}
106
183
  type="search"
107
184
  id="emvb-list-search"
108
185
  aria-label={label}
@@ -116,10 +193,15 @@ export function ListSearch({
116
193
  }
117
194
 
118
195
  /** Shown when a search finds nothing (W-207). */
119
- export function NoMatches({ query }: { query: string }) {
196
+ export function NoMatches({ query, onClear }: { query: string; onClear: () => void }) {
120
197
  return (
121
- <p className="emvb-helper" role="status" data-emvb-no-matches>
122
- Nothing matches "{query.trim()}".
123
- </p>
198
+ <div className="emvb-surface-card">
199
+ <p className="emvb-helper" role="status" data-emvb-no-matches>
200
+ Nothing matches "{query.trim()}".
201
+ </p>
202
+ <Button type="button" variant="secondary" className={BUTTON} onClick={onClear}>
203
+ Clear search
204
+ </Button>
205
+ </div>
124
206
  );
125
207
  }
@@ -0,0 +1,51 @@
1
+ import { PLUGIN_ID } from "../constants.ts";
2
+ import type { SavedSection, SavedSectionRecord, SavedSectionSummary } from "../core/index.ts";
3
+ import { requestJson, type Fetcher } from "./api.ts";
4
+
5
+ export type { SavedSectionSummary };
6
+
7
+ const BASE = `/_emdash/api/plugins/${PLUGIN_ID}/saved-sections`;
8
+
9
+ /** My sections, newest first (W-876). */
10
+ export async function listSavedSections(fetcher: Fetcher): Promise<SavedSectionSummary[]> {
11
+ const data = await requestJson<{ items?: SavedSectionSummary[] }>(fetcher, BASE);
12
+ return data?.items ?? [];
13
+ }
14
+
15
+ /** One section, read and upgraded by the server. */
16
+ export async function getSavedSection(fetcher: Fetcher, id: string): Promise<SavedSection> {
17
+ const data = await requestJson<{ section: SavedSection }>(fetcher, `${BASE}/get`, {
18
+ method: "POST",
19
+ body: { id },
20
+ });
21
+ return data.section;
22
+ }
23
+
24
+ /** Stores a snapshot; the server checks it again whatever the browser sent. */
25
+ export async function saveSavedSection(
26
+ fetcher: Fetcher,
27
+ record: SavedSectionRecord,
28
+ ): Promise<string> {
29
+ const data = await requestJson<{ id: string }>(fetcher, `${BASE}/save`, {
30
+ method: "POST",
31
+ body: { record },
32
+ });
33
+ return data.id;
34
+ }
35
+
36
+ export async function renameSavedSection(
37
+ fetcher: Fetcher,
38
+ id: string,
39
+ name: string,
40
+ ): Promise<SavedSectionSummary> {
41
+ const data = await requestJson<{ item: SavedSectionSummary }>(fetcher, `${BASE}/rename`, {
42
+ method: "POST",
43
+ body: { id, name },
44
+ });
45
+ return data.item;
46
+ }
47
+
48
+ /** Pages that already hold a copy keep it. */
49
+ export async function deleteSavedSection(fetcher: Fetcher, id: string): Promise<void> {
50
+ await requestJson(fetcher, `${BASE}/delete`, { method: "POST", body: { id } });
51
+ }
@@ -0,0 +1,15 @@
1
+ // W-774: "ß" folds to "ss" like the command palette, so "strasse" finds "Straße" in lists too.
2
+ export const fold = (text: string) =>
3
+ text.normalize("NFD").replace(/\p{M}/gu, "").toLocaleLowerCase().replace(/ß/g, "ss");
4
+
5
+ /**
6
+ * Every search word must appear in one of the fields,
7
+ * ignoring case and accents, so "about us" finds "About Us" and "/about-us".
8
+ */
9
+ export function matchesSearch(query: string, ...fields: string[]): boolean {
10
+ const haystack = fold(fields.join(" "));
11
+ return fold(query)
12
+ .split(/\s+/)
13
+ .filter(Boolean)
14
+ .every((word) => haystack.includes(word));
15
+ }
@@ -58,5 +58,5 @@ export function useSetupStatus(fetcher: Fetcher, role: number) {
58
58
  await refresh();
59
59
  }, [fetcher, refresh]);
60
60
 
61
- return { status, running, setup };
61
+ return { status, running, setup, retry: refresh };
62
62
  }
@@ -92,7 +92,8 @@ const RULE_LABELS: Record<string, (args: RuleArgs) => string> = {
92
92
  "archive/all": () => "All archives",
93
93
  };
94
94
 
95
- function conditionRuleLabel(r: unknown): string {
95
+ /** A rule's short label, e.g. "Tag: news" (also the Display conditions menu, W-694). */
96
+ export function conditionRuleLabel(r: unknown): string {
96
97
  const rule = r as { group?: string; name?: string; args?: RuleArgs };
97
98
  const key = `${rule.group ?? "?"}/${rule.name ?? "?"}`;
98
99
  const label = Object.hasOwn(RULE_LABELS, key) ? RULE_LABELS[key] : undefined;
@@ -118,6 +119,12 @@ export function summarizeConditions(raw: unknown): string {
118
119
  return parts.join(" · ") || "No conditions";
119
120
  }
120
121
 
122
+ const ITEM_PART_USE_SHORT: Partial<Record<ThemePartType, string>> = {
123
+ loop_item: "Used by Loops",
124
+ section: "Used by Theme sections",
125
+ page_template: "Offered in New page",
126
+ };
127
+
121
128
  export async function listThemeParts(fetcher: Fetcher): Promise<ThemePartSummary[]> {
122
129
  const items = await listAllItems<ContentItem>(fetcher, CONTENT);
123
130
  return items.map((item) => ({
@@ -126,7 +133,9 @@ export async function listThemeParts(fetcher: Fetcher): Promise<ThemePartSummary
126
133
  partType: partTypeOf(item),
127
134
  status: entryStatus(item),
128
135
  updatedAt: item.updatedAt ?? "",
129
- conditionsSummary: summarizeConditions(item.data?.["conditions"]),
136
+ // UX-061: reusable parts never match a location, so say where they're used instead.
137
+ conditionsSummary:
138
+ ITEM_PART_USE_SHORT[partTypeOf(item)] ?? summarizeConditions(item.data?.["conditions"]),
130
139
  }));
131
140
  }
132
141
 
@@ -149,14 +158,15 @@ function starterPartLayout(title: string, partType: ThemePartType): Layout {
149
158
 
150
159
  export async function createThemePart(
151
160
  fetcher: Fetcher,
152
- input: { title: string; slug: string; partType: ThemePartType },
161
+ input: { title: string; slug: string; partType: ThemePartType; layout?: Layout },
153
162
  ): Promise<string> {
154
163
  const body = await requestJson<{ item: ContentItem }>(fetcher, CONTENT, {
155
164
  method: "POST",
156
165
  body: {
157
166
  data: {
158
167
  title: input.title,
159
- layout: starterPartLayout(input.title, input.partType),
168
+ // W-876: a synced section starts from the element it was made from.
169
+ layout: input.layout ?? starterPartLayout(input.title, input.partType),
160
170
  part_type: input.partType,
161
171
  conditions: defaultConditionsFor(input.partType),
162
172
  triggers: defaultTriggers(),
@@ -182,7 +192,8 @@ export async function saveThemePart(
182
192
  body: {
183
193
  data: {
184
194
  title: draft.title,
185
- layout: draft.layout,
195
+ // UX-094: a part with no layout yet leaves the field alone; the server refuses null.
196
+ ...(draft.layout ? { layout: draft.layout } : {}),
186
197
  part_type: draft.partType,
187
198
  conditions: draft.conditions,
188
199
  triggers: draft.triggers,
package/src/admin/ui.ts CHANGED
@@ -45,7 +45,8 @@ export const UI_CSS = `
45
45
  border-radius: 6px;
46
46
  }
47
47
  .emvb-mono { font-family: var(--font-mono); }
48
- .emvb-helper { margin: 0; font-size: 12px; line-height: 16px; color: var(--text-color-kumo-subtle); }
48
+ /* W-763: helpers quote what was typed; a long value with no spaces ran off the panel. */
49
+ .emvb-helper { margin: 0; font-size: 12px; line-height: 16px; color: var(--text-color-kumo-subtle); overflow-wrap: anywhere; }
49
50
  .emvb-helper a { color: var(--text-color-kumo-default); text-decoration: underline; text-underline-offset: 2px; }
50
51
  .emvb-required-notice { margin-top: 4px; }
51
52
  .emvb-required-notice__list { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 12px; line-height: 16px; }
@@ -73,6 +74,12 @@ export const UI_CSS = `
73
74
 
74
75
  /* List / setup pages */
75
76
  .emvb-pages { display: flex; flex-direction: column; gap: 16px; }
77
+ .emvb-list-loading { min-height: 200px; }
78
+ .emvb-loading-status { margin: 0; padding: 24px 0; text-align: center; }
79
+ .emvb-list-skeleton-rows { display: grid; gap: 14px; }
80
+ .emvb-list-skeleton-row { display: grid; grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); gap: 16px; align-items: center; }
81
+ .emvb-list-skeleton-title { display: grid; gap: 4px; }
82
+ .emvb-list-loading .skeleton-line { background: var(--color-kumo-tint); }
76
83
  .emvb-list-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
77
84
  .emvb-list-search { max-width: 320px; margin: 12px 0; }
78
85
  .emvb-page-title { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 600; color: var(--text-color-kumo-default); }
@@ -82,6 +89,10 @@ export const UI_CSS = `
82
89
  .emvb-row-slug { font-family: var(--font-mono); font-size: 12px; line-height: 16px; color: var(--text-color-kumo-subtle); }
83
90
  /* W-209: a long unbroken title or slug wraps instead of pushing Status and Last edited out of the card. */
84
91
  .emvb-row-title, .emvb-row-slug { overflow-wrap: anywhere; }
92
+ /* UX-018: on narrow admin widths the short columns keep one line and the title keeps a readable
93
+ width; the card scrolls sideways before anything breaks mid-word or mid-date. */
94
+ .emvb-surface-card[data-emvb-list] :is(th, td):not(:first-child) { white-space: nowrap; }
95
+ .emvb-surface-card[data-emvb-list] td:first-child { min-width: 180px; }
85
96
  .emvb-tabular { font-variant-numeric: tabular-nums; color: var(--text-color-kumo-subtle); font-size: 13px; }
86
97
 
87
98
  /* Elevated EmVB-owned card chrome (lists, empty/setup shells) — not host sidebar/header */
@@ -99,6 +110,7 @@ export const UI_CSS = `
99
110
  /* Live MCP test: the AI agents page reads as cards with clear headings, not bare browser defaults. */
100
111
  .emvb-agents { max-width: 960px; }
101
112
  .emvb-agents-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
113
+ .emvb-agents-save { min-height: 16px; margin: 0; }
102
114
  .emvb-agents-header p { margin: 4px 0 0; font-size: 14px; line-height: 20px; color: var(--text-color-kumo-subtle); }
103
115
  .emvb-agents-status { display: inline-flex; flex: none; align-items: center; gap: 6px; margin-top: 6px; padding: 2px 10px; border: 1px solid var(--color-kumo-line); border-radius: 999px; background: var(--color-kumo-base); color: var(--text-color-kumo-default); font-size: 12px; line-height: 20px; font-weight: 600; }
104
116
  .emvb-agents-status > span { width: 8px; height: 8px; border-radius: 999px; background: var(--text-color-kumo-subtle); }
@@ -107,6 +119,8 @@ export const UI_CSS = `
107
119
  .emvb-agents-head { display: flex; align-items: flex-start; gap: 12px; }
108
120
  .emvb-agents-icon { display: grid; flex: none; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--color-kumo-tint); color: var(--text-color-kumo-default); }
109
121
  .emvb-agents-section h2 { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; color: var(--text-color-kumo-default); }
122
+ .emvb-agents-snippet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; }
123
+ .emvb-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
110
124
  .emvb-agents-section h3 { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; line-height: 20px; font-weight: 600; color: var(--text-color-kumo-default); }
111
125
  .emvb-agents-section p { margin: 0; font-size: 14px; line-height: 20px; color: var(--text-color-kumo-subtle); }
112
126
  .emvb-agents-section code { padding: 1px 5px; border-radius: 4px; background: var(--color-kumo-tint); font-family: var(--font-mono); font-size: 12px; }
@@ -115,7 +129,8 @@ export const UI_CSS = `
115
129
  .emvb-agents-field { display: grid; gap: 6px; }
116
130
  .emvb-agents-snippets { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
117
131
  .emvb-agents-snippet { display: grid; align-content: start; gap: 8px; min-width: 0; padding: 12px; border: 1px solid var(--color-kumo-line); border-radius: 8px; }
118
- .emvb-agents-section pre { margin: 0; padding: 12px; overflow-x: auto; border-radius: 6px; background: var(--color-kumo-recessed, rgba(127,127,127,.08)); font-family: var(--font-mono); font-size: 12px; line-height: 18px; }
132
+ .emvb-agents-section pre { margin: 0; padding: 12px; overflow-x: auto; border-radius: 6px; background: var(--color-kumo-tint); font-family: var(--font-mono); font-size: 12px; line-height: 18px; }
133
+ .emvb-agents-section pre:focus-visible { outline: 2px solid var(--color-kumo-brand); outline-offset: 2px; }
119
134
  .emvb-agents-table { overflow-x: auto; margin-inline: -20px; margin-bottom: -20px; border-top: 1px solid var(--color-kumo-line); }
120
135
  .emvb-agents-table table { width: 100%; }
121
136
  .emvb-agents-when { color: var(--text-color-kumo-subtle); font-variant-numeric: tabular-nums; white-space: nowrap; }
@@ -124,8 +139,14 @@ export const UI_CSS = `
124
139
  .emvb-agents-link:hover { text-decoration: underline; }
125
140
  .emvb-agents-link:focus-visible { outline: 2px solid var(--color-kumo-brand); outline-offset: 2px; border-radius: 4px; }
126
141
  .emvb-timeline-agent { display: inline-flex; flex: none; align-items: center; gap: 3px; padding: 1px 7px 1px 5px; border: 1px solid var(--color-kumo-line); border-radius: 999px; background: var(--color-kumo-base); color: var(--text-color-kumo-default); font-size: 11px; line-height: 16px; font-weight: 600; }
127
- .emvb-surface-card[data-emvb-list] { gap: 0; padding: 0; overflow: hidden; }
142
+ .emvb-surface-card[data-emvb-list] { gap: 0; padding: 0; overflow: hidden; overflow-x: auto; }
128
143
  .emvb-surface-card[data-emvb-list] table { width: 100%; }
144
+ /* UX-054: the whole row opens the page: the title link stretches over its row,
145
+ and the row tints on hover, so a click on the status or date isn't lost. */
146
+ .emvb-surface-card[data-emvb-list] tbody tr { position: relative; }
147
+ .emvb-surface-card[data-emvb-list] tbody tr:hover { background: var(--color-kumo-tint); }
148
+ .emvb-surface-card[data-emvb-list] tbody tr:hover .emvb-row-title { text-decoration: underline; text-underline-offset: 2px; }
149
+ .emvb-surface-card[data-emvb-list] .emvb-row-title::after { content: ""; position: absolute; inset: 0; }
129
150
  .emvb-surface-card .emvb-empty-shell,
130
151
  .emvb-empty-shell {
131
152
  display: flex;
@@ -175,14 +196,45 @@ export const UI_CSS = `
175
196
  .emvb-theme-filter-count { margin-left: 6px; color: var(--text-color-kumo-subtle); font-weight: 400; }
176
197
  .emvb-theme-filter:hover { color: var(--text-color-kumo-default); }
177
198
  .emvb-theme-filter:focus-visible { outline: 2px solid var(--color-kumo-brand); outline-offset: 2px; }
199
+ /* UX-038: a row that scrolls fades at the edge that has more tabs, so hidden filters aren't
200
+ mistaken for none. The fade follows the row's own scroll; a row that fits has no timeline. */
201
+ @property --emvb-fade-start { syntax: "<length>"; inherits: false; initial-value: 0px; }
202
+ @property --emvb-fade-end { syntax: "<length>"; inherits: false; initial-value: 0px; }
203
+ @keyframes emvb-edge-fade {
204
+ 0% { --emvb-fade-start: 0px; --emvb-fade-end: 32px; }
205
+ 8% { --emvb-fade-start: 32px; }
206
+ 92% { --emvb-fade-end: 32px; }
207
+ 100% { --emvb-fade-start: 32px; --emvb-fade-end: 0px; }
208
+ }
209
+ @supports (animation-timeline: scroll()) {
210
+ .emvb-theme-filters {
211
+ animation: emvb-edge-fade linear both;
212
+ animation-timeline: scroll(self inline);
213
+ mask-image: linear-gradient(to right, transparent, #000 var(--emvb-fade-start), #000 calc(100% - var(--emvb-fade-end)), transparent);
214
+ }
215
+ }
216
+ /* W-863: without scroll timelines (Firefox, older Safari) the row's data-more-* hints fade it. */
217
+ @supports not (animation-timeline: scroll()) {
218
+ .emvb-theme-filters[data-more-start] { --emvb-fade-start: 32px; }
219
+ .emvb-theme-filters[data-more-end] { --emvb-fade-end: 32px; }
220
+ .emvb-theme-filters[data-more-start],
221
+ .emvb-theme-filters[data-more-end] {
222
+ mask-image: linear-gradient(to right, transparent, #000 var(--emvb-fade-start), #000 calc(100% - var(--emvb-fade-end)), transparent);
223
+ }
224
+ }
178
225
 
179
226
  /* EmVB-owned dialog body (Kumo Dialog keeps host radius/shadow) */
180
227
  .emvb-dialog { display: flex; flex-direction: column; gap: 10px; }
181
228
  .emvb-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
229
+ /* UX-023: selects in EmVB dialogs line up with the full-width fields under them. */
230
+ .emvb-dialog .emvb-field { width: 100%; }
231
+ .emvb-create-fields { display: flex; flex-direction: column; gap: 10px; min-width: 0; margin: 0; padding: 0; border: 0; }
232
+ .emvb-create-status { min-height: 18px; }
233
+ /* UX-090: 16 px so the title stands above the 14 px field labels under it. */
182
234
  .emvb-dialog :is(h2, [data-slot="title"]) {
183
235
  margin: 0;
184
- font-size: 14px;
185
- line-height: 18px;
236
+ font-size: 16px;
237
+ line-height: 22px;
186
238
  font-weight: 600;
187
239
  color: var(--text-color-kumo-default);
188
240
  }
@@ -216,6 +268,8 @@ export const UI_CSS = `
216
268
  .emvb-device-fieldset > .emvb-helper { width: 100%; margin: 0; }
217
269
  .emvb-device-option { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; font-size: 13px; cursor: pointer; }
218
270
  .emvb-device-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--color-kumo-brand); }
271
+ /* UX-027: every native checkbox and radio EmVB draws takes the accent, not the OS blue. */
272
+ :is([data-emvb-editor], [data-emvb-page]) input:is([type="checkbox"], [type="radio"]) { accent-color: var(--color-kumo-brand); }
219
273
  .emvb-device-option input:focus-visible { outline: 2px solid var(--color-kumo-brand); outline-offset: 2px; }
220
274
 
221
275
  /* Conditions editor (theme-part settings) */
@@ -236,7 +290,7 @@ export const UI_CSS = `
236
290
  }
237
291
  .emvb-condition-row {
238
292
  display: grid;
239
- grid-template-columns: 96px 1fr 28px;
293
+ grid-template-columns: 96px minmax(0, 1fr) 28px;
240
294
  gap: 6px;
241
295
  align-items: center;
242
296
  padding: 6px;
@@ -244,26 +298,32 @@ export const UI_CSS = `
244
298
  background: var(--emvb-glass-strong, var(--color-kumo-base));
245
299
  box-shadow: var(--emvb-elevation-s);
246
300
  }
247
- .emvb-condition-op,
248
- .emvb-condition-where {
249
- height: var(--emvb-control, 28px);
250
- border-radius: 6px;
251
- border: 1px solid var(--color-kumo-hairline);
252
- background: var(--color-kumo-control, var(--color-kumo-base));
253
- color: var(--text-color-kumo-default);
254
- font: inherit;
255
- font-size: 13px;
256
- padding: 0 8px;
257
- }
258
- .emvb-condition-op:focus-visible,
259
- .emvb-condition-where:focus-visible {
260
- outline: 2px solid var(--color-kumo-brand);
261
- outline-offset: 2px;
262
- }
301
+ .emvb-panel-select { display: block; min-width: 0; }
302
+ .emvb-panel-select .emvb-field { width: 100%; min-width: 0; }
263
303
  .emvb-condition-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
264
304
 
265
305
  @media (prefers-reduced-motion: reduce) {
266
306
  [data-emvb-editor] *, [data-emvb-page] * { transition: none !important; animation: none !important; }
307
+ /* Kumo portals sit outside the editor/page roots; a dialog body identifies EmVB ownership. */
308
+ [data-base-ui-portal]:has([data-emvb-dialog]),
309
+ [data-base-ui-portal]:has([data-emvb-dialog]) *,
310
+ [data-base-ui-portal]:has([data-emvb-dialog])::before,
311
+ [data-base-ui-portal]:has([data-emvb-dialog])::after,
312
+ [data-base-ui-portal]:has([data-emvb-dialog]) *::before,
313
+ [data-base-ui-portal]:has([data-emvb-dialog]) *::after {
314
+ transition: none !important;
315
+ animation: none !important;
316
+ }
317
+ .emvb-list-loading .skeleton-line::after { animation: none !important; }
318
+ [data-emvb-toasts],
319
+ [data-emvb-toasts] *,
320
+ [data-emvb-toasts]::before,
321
+ [data-emvb-toasts]::after,
322
+ [data-emvb-toasts] *::before,
323
+ [data-emvb-toasts] *::after {
324
+ transition: none !important;
325
+ animation: none !important;
326
+ }
267
327
  }
268
328
  @media (prefers-reduced-transparency: reduce) {
269
329
  .emvb-status,
@@ -50,8 +50,29 @@ function placeFloats(): void {
50
50
  root.style.setProperty("--emvb-float-bottom", `${bottom}px`);
51
51
  }
52
52
 
53
+ const FOCUSABLE =
54
+ 'a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),summary,[tabindex]:not([tabindex="-1"])';
55
+
56
+ /**
57
+ * W-782: hiding the float that holds focus dropped focus to <body>, so the next Tab
58
+ * restarted at the top of the page. Move it to the nearest control after the float,
59
+ * else the one before it.
60
+ */
61
+ function keepFocusNear(el: HTMLElement): void {
62
+ if (!el.contains(document.activeElement)) return;
63
+ const candidates = [...document.querySelectorAll<HTMLElement>(FOCUSABLE)].filter(
64
+ (c) => !el.contains(c) && !c.closest("[hidden],[inert]"),
65
+ );
66
+ const after = candidates.find(
67
+ (c) => (el.compareDocumentPosition(c) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0,
68
+ );
69
+ const target = after ?? candidates.at(-1);
70
+ target?.focus();
71
+ }
72
+
53
73
  function hide(el: HTMLElement): void {
54
74
  const id = el.getAttribute("data-emvb-float");
75
+ keepFocusNear(el);
55
76
  el.hidden = true;
56
77
  if (id) rememberClosed(id);
57
78
  placeFloats();
@@ -5,13 +5,41 @@
5
5
  * menu item (W-254). Hosts load it when `needsMenuRuntime` is true.
6
6
  */
7
7
  const OPEN = "details.emvb-menu-item__disclosure[open]";
8
+ const DISMISSED = "emvbMenuDismissed";
9
+
10
+ /** W-783: the menu items under the pointer, so Escape can hide a hover-shown panel. */
11
+ let pointerOver: Element | null = null;
12
+
13
+ function itemsAround(node: Element | null): HTMLElement[] {
14
+ const items: HTMLElement[] = [];
15
+ let item = node?.closest<HTMLElement>(".emvb-menu .emvb-menu-item") ?? null;
16
+ while (item) {
17
+ items.push(item);
18
+ item = item.parentElement?.closest<HTMLElement>(".emvb-menu .emvb-menu-item") ?? null;
19
+ }
20
+ return items;
21
+ }
22
+
23
+ /** Forget a dismissal once the pointer or focus is somewhere else. */
24
+ function clearDismissed(target: Node | null): void {
25
+ for (const item of document.querySelectorAll<HTMLElement>("[data-emvb-menu-dismissed]")) {
26
+ if (target && item.contains(target)) continue;
27
+ delete item.dataset[DISMISSED];
28
+ }
29
+ }
8
30
 
9
31
  function onKeydown(event: KeyboardEvent): void {
10
32
  if (event.key !== "Escape" || event.defaultPrevented) return;
11
33
  const active = document.activeElement;
12
34
  const inside = active instanceof Element ? active.closest<HTMLDetailsElement>(OPEN) : null;
13
35
  const target = inside ?? document.querySelector<HTMLDetailsElement>(`.emvb-menu ${OPEN}`);
14
- if (!target) return;
36
+ // W-783: a panel shown by hover stayed up after Escape until the pointer moved away.
37
+ const hovered = itemsAround(pointerOver);
38
+ for (const item of hovered) item.dataset[DISMISSED] = "1";
39
+ if (!target) {
40
+ if (hovered.length > 0) event.preventDefault();
41
+ return;
42
+ }
15
43
  target.open = false;
16
44
  target.querySelector<HTMLElement>(":scope > summary")?.focus({ preventScroll: true });
17
45
  event.preventDefault();
@@ -20,6 +48,7 @@ function onKeydown(event: KeyboardEvent): void {
20
48
  /** W-254: an open dropdown closes once focus or a pointer press lands outside its menu item. */
21
49
  function closeOthers(event: Event): void {
22
50
  const target = event.target instanceof Node ? event.target : null;
51
+ clearDismissed(target);
23
52
  for (const details of document.querySelectorAll<HTMLDetailsElement>(`.emvb-menu ${OPEN}`)) {
24
53
  const item = details.closest(".emvb-menu-item") ?? details;
25
54
  if (target && item.contains(target)) continue;
@@ -34,4 +63,8 @@ export function initMenus(root: Document = document): void {
34
63
  root.addEventListener("keydown", onKeydown);
35
64
  root.addEventListener("focusin", closeOthers);
36
65
  root.addEventListener("pointerdown", closeOthers);
66
+ root.addEventListener("pointerover", (event) => {
67
+ pointerOver = event.target instanceof Element ? event.target : null;
68
+ clearDismissed(pointerOver);
69
+ });
37
70
  }