@perkyzz/emvb 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/README.md +4 -0
  2. package/THIRD_PARTY_NOTICES.md +23 -1
  3. package/licenses/exif-js.LICENSE +21 -0
  4. package/licenses/fflate.LICENSE +21 -0
  5. package/licenses/glfx.js.LICENSE +19 -0
  6. package/licenses/mini-photo-editor.LICENSE +21 -0
  7. package/licenses/photocn.LICENSE +21 -0
  8. package/package.json +2 -1
  9. package/src/admin/access/RequireEditor.tsx +7 -7
  10. package/src/admin/access/role.ts +5 -2
  11. package/src/admin/content-api.ts +10 -3
  12. package/src/admin/content-item.ts +1 -1
  13. package/src/admin/editor/A11yCopilot.tsx +104 -56
  14. package/src/admin/editor/CommandPalette.tsx +29 -13
  15. package/src/admin/editor/Editor.tsx +88 -20
  16. package/src/admin/editor/EditorToasts.tsx +26 -0
  17. package/src/admin/editor/PerfMeter.tsx +97 -72
  18. package/src/admin/editor/ShareLink.tsx +107 -72
  19. package/src/admin/editor/ShortcutsDialog.tsx +27 -16
  20. package/src/admin/editor/Timeline.tsx +255 -160
  21. package/src/admin/editor/TopBar.tsx +71 -14
  22. package/src/admin/editor/canvas/CanvasFrame.tsx +10 -1
  23. package/src/admin/editor/canvas/CanvasTextEdit.tsx +8 -2
  24. package/src/admin/editor/canvas/drop-line.ts +11 -3
  25. package/src/admin/editor/canvas/frame-focus-ring.ts +37 -0
  26. package/src/admin/editor/canvas/use-canvas-dnd.ts +32 -3
  27. package/src/admin/editor/canvas/vnode-react.tsx +7 -0
  28. package/src/admin/editor/collection-previews.ts +16 -1
  29. package/src/admin/editor/dialogs.tsx +38 -14
  30. package/src/admin/editor/dnd/drop-target.ts +26 -1
  31. package/src/admin/editor/edited-noun.ts +15 -0
  32. package/src/admin/editor/editor-chrome.tsx +108 -7
  33. package/src/admin/editor/editor-commands.ts +15 -1
  34. package/src/admin/editor/editor-css.ts +75 -22
  35. package/src/admin/editor/element-chrome.ts +21 -11
  36. package/src/admin/editor/feature-css.ts +45 -13
  37. package/src/admin/editor/icons/IconLibraryDialog.tsx +52 -11
  38. package/src/admin/editor/icons/library.ts +1 -1
  39. package/src/admin/editor/icons/use-icon-library.ts +5 -2
  40. package/src/admin/editor/ime.ts +29 -0
  41. package/src/admin/editor/palette-items.ts +10 -3
  42. package/src/admin/editor/panels/AddPanel.tsx +35 -10
  43. package/src/admin/editor/panels/ClassesSection.tsx +18 -7
  44. package/src/admin/editor/panels/ColorControl.tsx +135 -27
  45. package/src/admin/editor/panels/ConditionsEditor.tsx +52 -26
  46. package/src/admin/editor/panels/ElementPanel.tsx +134 -24
  47. package/src/admin/editor/panels/LayersPanel.tsx +68 -22
  48. package/src/admin/editor/panels/PageSettings.tsx +66 -35
  49. package/src/admin/editor/panels/SiteStylesDrawer.tsx +170 -32
  50. package/src/admin/editor/panels/TokenScales.tsx +76 -36
  51. package/src/admin/editor/panels/TriggerSettings.tsx +50 -12
  52. package/src/admin/editor/panels/TriggersEditor.tsx +2 -1
  53. package/src/admin/editor/panels/VariableSection.tsx +53 -21
  54. package/src/admin/editor/panels/color-space.ts +9 -3
  55. package/src/admin/editor/panels/settings/AdvancedFields.tsx +12 -2
  56. package/src/admin/editor/panels/settings/AudienceEditor.tsx +51 -35
  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 +38 -15
  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 +12 -8
  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/MediaPicker.tsx +274 -20
  75. package/src/admin/editor/panels/settings/MotionControl.tsx +28 -15
  76. package/src/admin/editor/panels/settings/NumberRow.tsx +9 -3
  77. package/src/admin/editor/panels/settings/PanelSelect.tsx +50 -0
  78. package/src/admin/editor/panels/settings/QueryStyleRows.tsx +25 -18
  79. package/src/admin/editor/panels/settings/RequiredFieldsNotice.tsx +141 -0
  80. package/src/admin/editor/panels/settings/StyleRow.tsx +10 -3
  81. package/src/admin/editor/panels/settings/StyleSources.tsx +4 -1
  82. package/src/admin/editor/panels/settings/VariantEditor.tsx +10 -1
  83. package/src/admin/editor/panels/settings/box-link-name.ts +6 -2
  84. package/src/admin/editor/panels/settings/class-suggest.ts +7 -7
  85. package/src/admin/editor/panels/settings/query-style.ts +38 -9
  86. package/src/admin/editor/panels/settings/svg-images.ts +13 -0
  87. package/src/admin/editor/panels/site-list.tsx +20 -6
  88. package/src/admin/editor/panels/variable-values.ts +25 -4
  89. package/src/admin/editor/restore-deleted.ts +21 -2
  90. package/src/admin/editor/section-templates.ts +81 -12
  91. package/src/admin/editor/shortcuts.ts +17 -2
  92. package/src/admin/editor/store.ts +14 -3
  93. package/src/admin/editor/useEditorCommands.ts +61 -15
  94. package/src/admin/editor/useEditorData.ts +4 -2
  95. package/src/admin/editor/useEditorShortcuts.ts +17 -7
  96. package/src/admin/editor/useNodeActions.ts +61 -6
  97. package/src/admin/editor/useSave.ts +22 -7
  98. package/src/admin/forms-api.ts +2 -0
  99. package/src/admin/image-editor/BlurFocus.tsx +112 -0
  100. package/src/admin/image-editor/Canvas.tsx +261 -0
  101. package/src/admin/image-editor/CropOverlay.tsx +390 -0
  102. package/src/admin/image-editor/CurvesPanel.tsx +395 -0
  103. package/src/admin/image-editor/ExportDialog.tsx +384 -0
  104. package/src/admin/image-editor/ImageEditButton.tsx +83 -0
  105. package/src/admin/image-editor/ImageEditorDialog.tsx +828 -0
  106. package/src/admin/image-editor/MetadataPanel.tsx +194 -0
  107. package/src/admin/image-editor/announce.tsx +65 -0
  108. package/src/admin/image-editor/crop-geometry.ts +162 -0
  109. package/src/admin/image-editor/curve-math.ts +177 -0
  110. package/src/admin/image-editor/data-url-fetch.ts +59 -0
  111. package/src/admin/image-editor/engine.ts +55 -0
  112. package/src/admin/image-editor/exif.ts +82 -0
  113. package/src/admin/image-editor/flatten.ts +54 -0
  114. package/src/admin/image-editor/gpu-fit.ts +81 -0
  115. package/src/admin/image-editor/image-editor-css.ts +400 -0
  116. package/src/admin/image-editor/load.ts +116 -0
  117. package/src/admin/image-editor/panels.tsx +287 -0
  118. package/src/admin/image-editor/parts.tsx +614 -0
  119. package/src/admin/image-editor/save.ts +141 -0
  120. package/src/admin/image-editor/tone-panels.tsx +338 -0
  121. package/src/admin/image-editor/tools.ts +59 -0
  122. package/src/admin/image-editor/worker.ts +111 -0
  123. package/src/admin/media-api.ts +114 -3
  124. package/src/admin/pages/AgentsPage.tsx +138 -27
  125. package/src/admin/pages/CreateDialog.tsx +97 -30
  126. package/src/admin/pages/NewPageDialog.tsx +21 -3
  127. package/src/admin/pages/NewThemePartDialog.tsx +11 -3
  128. package/src/admin/pages/PageList.tsx +14 -6
  129. package/src/admin/pages/SetupShell.tsx +28 -12
  130. package/src/admin/pages/ThemePartList.tsx +27 -7
  131. package/src/admin/pages/list-kit.tsx +106 -24
  132. package/src/admin/search.ts +15 -0
  133. package/src/admin/setup/useSetupStatus.ts +1 -1
  134. package/src/admin/theme-api.ts +13 -3
  135. package/src/admin/ui.ts +78 -22
  136. package/src/astro/EmVBPage.astro +11 -2
  137. package/src/astro/floats/runtime.ts +21 -0
  138. package/src/astro/menu/runtime.ts +34 -1
  139. package/src/astro/popups/runtime.ts +33 -3
  140. package/src/astro/render.ts +6 -0
  141. package/src/astro/resolve-theme.ts +67 -14
  142. package/src/astro/resolve.ts +9 -1
  143. package/src/astro/tabs/runtime.ts +12 -0
  144. package/src/astro/theme-posts.ts +2 -2
  145. package/src/astro/visitor.ts +6 -3
  146. package/src/constants.ts +1 -1
  147. package/src/core/a11y/audit.ts +171 -24
  148. package/src/core/arrange.ts +29 -6
  149. package/src/core/audience/rules.ts +5 -1
  150. package/src/core/audience/variants.ts +29 -3
  151. package/src/core/clipboard.ts +7 -0
  152. package/src/core/css/generate.ts +31 -6
  153. package/src/core/data/bindings.ts +19 -6
  154. package/src/core/design/classes.ts +20 -9
  155. package/src/core/design/diff.ts +9 -1
  156. package/src/core/design/merge.ts +93 -3
  157. package/src/core/design/tokens.ts +16 -2
  158. package/src/core/design/transfer.ts +46 -8
  159. package/src/core/design/variables.ts +32 -10
  160. package/src/core/elements/dynamic-elements.ts +53 -6
  161. package/src/core/elements/form-elements.ts +68 -30
  162. package/src/core/elements/index.ts +83 -38
  163. package/src/core/elements/menu.ts +37 -19
  164. package/src/core/elements/plain-text.ts +2 -2
  165. package/src/core/elements/select-prompt.ts +3 -0
  166. package/src/core/elements/svg-ids.ts +39 -0
  167. package/src/core/forms/binding.ts +190 -2
  168. package/src/core/forms/definition.ts +72 -0
  169. package/src/core/history/diff.ts +49 -4
  170. package/src/core/icons/catalog.ts +3 -2
  171. package/src/core/image-edit/schema.ts +155 -0
  172. package/src/core/image-edit/summary.ts +61 -0
  173. package/src/core/index.ts +29 -1
  174. package/src/core/limits.ts +21 -0
  175. package/src/core/migrate/index.ts +3 -1
  176. package/src/core/perf/meter.ts +51 -8
  177. package/src/core/recipes/index.ts +5 -4
  178. package/src/core/render/context.ts +8 -0
  179. package/src/core/render/dynamic-post.ts +71 -13
  180. package/src/core/render/extras.ts +77 -4
  181. package/src/core/render/form.ts +164 -12
  182. package/src/core/render/index.ts +179 -22
  183. package/src/core/render/loop.ts +43 -7
  184. package/src/core/render/pagination.ts +18 -4
  185. package/src/core/render/section.ts +27 -0
  186. package/src/core/render/tabs.ts +12 -3
  187. package/src/core/render/vnode.ts +1 -1
  188. package/src/core/sanitize/css.ts +15 -2
  189. package/src/core/sanitize/embed-url.ts +42 -5
  190. package/src/core/sanitize/url.ts +2 -1
  191. package/src/core/schema/layout.ts +26 -7
  192. package/src/core/share/link.ts +5 -2
  193. package/src/core/stable-json.ts +15 -0
  194. package/src/core/stats.ts +2 -1
  195. package/src/core/theme/conditions.ts +3 -1
  196. package/src/core/theme/dynamic.ts +57 -23
  197. package/src/core/theme/float.ts +9 -2
  198. package/src/core/theme/pagination.ts +57 -10
  199. package/src/core/theme/popup-markup.ts +23 -5
  200. package/src/core/theme/popup-rules.ts +11 -5
  201. package/src/core/theme/triggers.ts +3 -2
  202. package/src/core/tree-ops.ts +27 -0
  203. package/src/mcp/ports.ts +8 -1
  204. package/src/mcp/rate-limit.ts +2 -1
  205. package/src/mcp/read.ts +82 -3
  206. package/src/mcp/refs.ts +18 -0
  207. package/src/mcp/tools.ts +1 -1
  208. package/src/mcp/write.ts +271 -25
  209. package/src/server/agent-settings.ts +29 -4
  210. package/src/server/hooks.ts +5 -3
  211. package/src/server/icon-routes.ts +33 -9
  212. package/src/server/mcp-routes.ts +74 -11
@@ -18,12 +18,20 @@ export function NewThemePartDialog({
18
18
  fetcher,
19
19
  open,
20
20
  onOpenChange,
21
+ defaultType = "header",
21
22
  }: {
22
23
  fetcher: Fetcher;
23
24
  open: boolean;
24
25
  onOpenChange: (open: boolean) => void;
26
+ /** UX-055: opened from a type's filter, the dialog starts on that type. */
27
+ defaultType?: ThemePartType;
25
28
  }) {
26
- const [partType, setPartType] = React.useState<ThemePartType>("header");
29
+ const [partType, setPartType] = React.useState<ThemePartType>(defaultType);
30
+ const [wasOpen, setWasOpen] = React.useState(open);
31
+ if (open !== wasOpen) {
32
+ setWasOpen(open);
33
+ if (open) setPartType(defaultType);
34
+ }
27
35
  return (
28
36
  <CreateDialog
29
37
  name="new-theme-part"
@@ -31,8 +39,8 @@ export function NewThemePartDialog({
31
39
  noun="theme part"
32
40
  emptyTitle="Enter a title."
33
41
  slugPrefix={`${partType}-`}
34
- slugHint="Internal id only — theme parts are not public URLs."
35
- submitLabel="Create"
42
+ slugHint="Tells theme parts apart. Theme parts have no public address."
43
+ submitLabel="Create theme part"
36
44
  open={open}
37
45
  onOpenChange={onOpenChange}
38
46
  create={async (title, slug) =>
@@ -1,14 +1,15 @@
1
- import { Empty, Loader, Table } from "@cloudflare/kumo";
1
+ import { Empty, Table } from "@cloudflare/kumo";
2
2
  import { FileIcon } from "@phosphor-icons/react";
3
3
  import * as React from "react";
4
4
  import type { Fetcher } from "../api.ts";
5
5
  import { listPages } from "../content-api.ts";
6
6
  import { editorUrl } from "../editor/exit.ts";
7
+ import { matchesSearch } from "../search.ts";
7
8
  import {
8
9
  EditedTime,
9
10
  ListError,
11
+ ListLoading,
10
12
  ListSearch,
11
- matchesSearch,
12
13
  NewButton,
13
14
  NoMatches,
14
15
  StatusBadge,
@@ -21,6 +22,7 @@ export function PageList({ fetcher }: { fetcher: Fetcher }) {
21
22
  const list = useList(fetcher, listPages);
22
23
  const [creating, setCreating] = React.useState(false);
23
24
  const [query, setQuery] = React.useState("");
25
+ const searchRef = React.useRef<HTMLInputElement>(null);
24
26
  const shown =
25
27
  list.state === "ready"
26
28
  ? list.items.filter((page) => matchesSearch(query, page.title, `/${page.slug}`))
@@ -34,9 +36,9 @@ export function PageList({ fetcher }: { fetcher: Fetcher }) {
34
36
  <h1 className="emvb-page-title">Pages VisualBuilder</h1>
35
37
  {list.state === "ready" && list.items.length > 0 && newPage}
36
38
  </div>
37
- {list.state === "loading" && <Loader />}
39
+ {list.state === "loading" && <ListLoading label="Loading pages…" />}
38
40
  {list.state === "error" && (
39
- <ListError title="Couldn't load your pages" message={list.message} />
41
+ <ListError title="Couldn't load your pages" message={list.message} onRetry={list.retry} />
40
42
  )}
41
43
  {list.state === "ready" && list.items.length === 0 && (
42
44
  <div className="emvb-surface-card emvb-empty-shell">
@@ -49,10 +51,16 @@ export function PageList({ fetcher }: { fetcher: Fetcher }) {
49
51
  </div>
50
52
  )}
51
53
  {list.state === "ready" && list.items.length > 0 && (
52
- <ListSearch value={query} onChange={setQuery} label="Search pages" />
54
+ <ListSearch value={query} onChange={setQuery} label="Search pages" inputRef={searchRef} />
53
55
  )}
54
56
  {list.state === "ready" && list.items.length > 0 && shown.length === 0 && (
55
- <NoMatches query={query} />
57
+ <NoMatches
58
+ query={query}
59
+ onClear={() => {
60
+ setQuery("");
61
+ searchRef.current?.focus();
62
+ }}
63
+ />
56
64
  )}
57
65
  {list.state === "ready" && shown.length > 0 && (
58
66
  <div className="emvb-surface-card" data-emvb-list="pages">
@@ -1,9 +1,11 @@
1
1
  import { Banner, Button, Empty, Loader } from "@cloudflare/kumo";
2
- import { LayoutIcon, WarningCircleIcon } from "@phosphor-icons/react";
2
+ import { LayoutIcon } from "@phosphor-icons/react";
3
3
  import * as React from "react";
4
4
  import type { Fetcher } from "../api.ts";
5
+ import { useMediaQuery } from "../editor/useMediaQuery.ts";
5
6
  import { useSetupStatus } from "../setup/useSetupStatus.ts";
6
7
  import { BUTTON, SOLID_PRIMARY, UI_CSS } from "../ui.ts";
8
+ import { ListError, ListLoading } from "./list-kit.tsx";
7
9
 
8
10
  /**
9
11
  * Shared setup chrome for the plugin's admin pages: loading/error states, the set-up and upgrade
@@ -26,17 +28,25 @@ export function SetupShell({
26
28
  keptNote: string;
27
29
  children: React.ReactNode;
28
30
  }) {
29
- const { status, running, setup } = useSetupStatus(fetcher, role);
31
+ const { status, running, setup, retry } = useSetupStatus(fetcher, role);
32
+ const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
30
33
 
31
- if (status.state === "loading") return <Loader />;
32
- if (status.state === "error") {
34
+ // UX-012: the list's own loading card and a Retry that brings Set up back after a failure.
35
+ if (status.state === "loading" || status.state === "error") {
33
36
  return (
34
- <Banner
35
- variant="error"
36
- icon={<WarningCircleIcon aria-hidden="true" />}
37
- title={`Couldn't load ${title}`}
38
- description={status.message}
39
- />
37
+ <section data-emvb-page={page} className="emvb-pages">
38
+ <style data-emvb-ui="">{UI_CSS}</style>
39
+ <h1 className="emvb-page-title">{title}</h1>
40
+ {status.state === "loading" ? (
41
+ <ListLoading label={`Loading ${title}…`} />
42
+ ) : (
43
+ <ListError
44
+ title={`Couldn't load ${title}`}
45
+ message={status.message}
46
+ onRetry={() => void retry()}
47
+ />
48
+ )}
49
+ </section>
40
50
  );
41
51
  }
42
52
  const action = (label: string) =>
@@ -45,8 +55,14 @@ export function SetupShell({
45
55
  variant="primary"
46
56
  className={BUTTON}
47
57
  style={SOLID_PRIMARY}
48
- loading={running}
49
- onClick={() => void setup()}
58
+ // W-830: Kumo's `loading` disables the button, which dropped keyboard focus to the page
59
+ // body while setup ran. It stays focusable (aria-disabled) and ignores presses instead.
60
+ icon={running && !reducedMotion ? <Loader size={14} /> : undefined}
61
+ aria-disabled={running}
62
+ aria-busy={running}
63
+ onClick={() => {
64
+ if (!running) void setup();
65
+ }}
50
66
  >
51
67
  {label}
52
68
  </Button>
@@ -1,4 +1,4 @@
1
- import { Empty, Loader, Table } from "@cloudflare/kumo";
1
+ import { Empty, Table } from "@cloudflare/kumo";
2
2
  import { SquaresFourIcon } from "@phosphor-icons/react";
3
3
  import * as React from "react";
4
4
  import type { ThemePartType } from "../../core/index.ts";
@@ -6,11 +6,12 @@ import { THEME_PARTS_COLLECTION } from "../../constants.ts";
6
6
  import type { Fetcher } from "../api.ts";
7
7
  import { listThemeParts, partTypeLabel } from "../theme-api.ts";
8
8
  import { editorUrl } from "../editor/exit.ts";
9
+ import { matchesSearch } from "../search.ts";
9
10
  import {
10
11
  EditedTime,
11
12
  ListError,
13
+ ListLoading,
12
14
  ListSearch,
13
- matchesSearch,
14
15
  NewButton,
15
16
  NoMatches,
16
17
  StatusBadge,
@@ -58,6 +59,8 @@ function FilterTabs({
58
59
  const refs = React.useRef(new Map<Filter, HTMLButtonElement>());
59
60
 
60
61
  const onKeyDown = (event: React.KeyboardEvent) => {
62
+ // W-680: Alt+Left is the browser's Back; Ctrl/Cmd keys are shortcuts.
63
+ if (event.altKey || event.ctrlKey || event.metaKey) return;
61
64
  const at = FILTERS.findIndex((f) => f.value === filter);
62
65
  const last = FILTERS.length - 1;
63
66
  const to =
@@ -119,6 +122,7 @@ export function ThemePartList({ fetcher }: { fetcher: Fetcher }) {
119
122
  const [creating, setCreating] = React.useState(false);
120
123
  const [filter, setFilter] = React.useState<Filter>("all");
121
124
  const [query, setQuery] = React.useState("");
125
+ const searchRef = React.useRef<HTMLInputElement>(null);
122
126
 
123
127
  const newPart = <NewButton label="New theme part" onClick={() => setCreating(true)} />;
124
128
 
@@ -144,12 +148,17 @@ export function ThemePartList({ fetcher }: { fetcher: Fetcher }) {
144
148
  {list.state === "ready" && list.items.length > 0 && (
145
149
  <>
146
150
  <FilterTabs filter={filter} counts={countByType(list.items)} onChange={setFilter} />
147
- <ListSearch value={query} onChange={setQuery} label="Search theme parts" />
151
+ <ListSearch
152
+ value={query}
153
+ onChange={setQuery}
154
+ label="Search theme parts"
155
+ inputRef={searchRef}
156
+ />
148
157
  </>
149
158
  )}
150
- {list.state === "loading" && <Loader />}
159
+ {list.state === "loading" && <ListLoading label="Loading theme parts…" />}
151
160
  {list.state === "error" && (
152
- <ListError title="Couldn't load theme parts" message={list.message} />
161
+ <ListError title="Couldn't load theme parts" message={list.message} onRetry={list.retry} />
153
162
  )}
154
163
  {list.state === "ready" && list.items.length === 0 && (
155
164
  <div className="emvb-surface-card emvb-empty-shell">
@@ -173,7 +182,13 @@ export function ThemePartList({ fetcher }: { fetcher: Fetcher }) {
173
182
  />
174
183
  </div>
175
184
  ) : shown.length === 0 ? (
176
- <NoMatches query={query} />
185
+ <NoMatches
186
+ query={query}
187
+ onClear={() => {
188
+ setQuery("");
189
+ searchRef.current?.focus();
190
+ }}
191
+ />
177
192
  ) : (
178
193
  <div className="emvb-surface-card" data-emvb-list="theme-parts">
179
194
  <Table data-emvb-list="theme-parts">
@@ -215,7 +230,12 @@ export function ThemePartList({ fetcher }: { fetcher: Fetcher }) {
215
230
  )}
216
231
  </div>
217
232
  )}
218
- <NewThemePartDialog fetcher={fetcher} open={creating} onOpenChange={setCreating} />
233
+ <NewThemePartDialog
234
+ fetcher={fetcher}
235
+ open={creating}
236
+ onOpenChange={setCreating}
237
+ defaultType={filter === "all" ? undefined : filter}
238
+ />
219
239
  </>
220
240
  );
221
241
  }
@@ -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,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
 
@@ -182,7 +191,8 @@ export async function saveThemePart(
182
191
  body: {
183
192
  data: {
184
193
  title: draft.title,
185
- layout: draft.layout,
194
+ // UX-094: a part with no layout yet leaves the field alone; the server refuses null.
195
+ ...(draft.layout ? { layout: draft.layout } : {}),
186
196
  part_type: draft.partType,
187
197
  conditions: draft.conditions,
188
198
  triggers: draft.triggers,