@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.
- package/package.json +1 -1
- package/src/admin/access/RequireEditor.tsx +7 -7
- package/src/admin/access/role.ts +5 -2
- package/src/admin/content-api.ts +10 -3
- package/src/admin/content-item.ts +1 -1
- package/src/admin/editor/A11yCopilot.tsx +104 -56
- package/src/admin/editor/CommandPalette.tsx +29 -13
- package/src/admin/editor/Editor.tsx +82 -20
- package/src/admin/editor/EditorToasts.tsx +26 -0
- package/src/admin/editor/PerfMeter.tsx +97 -72
- package/src/admin/editor/ShareLink.tsx +107 -72
- package/src/admin/editor/ShortcutsDialog.tsx +27 -16
- package/src/admin/editor/Timeline.tsx +255 -160
- package/src/admin/editor/TopBar.tsx +71 -14
- package/src/admin/editor/canvas/CanvasFrame.tsx +10 -1
- package/src/admin/editor/canvas/CanvasTextEdit.tsx +8 -2
- package/src/admin/editor/canvas/drop-line.ts +11 -3
- package/src/admin/editor/canvas/frame-focus-ring.ts +37 -0
- package/src/admin/editor/canvas/use-canvas-dnd.ts +32 -3
- package/src/admin/editor/canvas/vnode-react.tsx +7 -0
- package/src/admin/editor/collection-previews.ts +10 -0
- package/src/admin/editor/dialogs.tsx +38 -14
- package/src/admin/editor/dnd/drop-target.ts +26 -1
- package/src/admin/editor/edited-noun.ts +15 -0
- package/src/admin/editor/editor-chrome.tsx +59 -7
- package/src/admin/editor/editor-commands.ts +2 -1
- package/src/admin/editor/editor-css.ts +72 -22
- package/src/admin/editor/element-chrome.ts +21 -11
- package/src/admin/editor/feature-css.ts +45 -13
- package/src/admin/editor/icons/IconLibraryDialog.tsx +52 -11
- package/src/admin/editor/icons/library.ts +1 -1
- package/src/admin/editor/icons/use-icon-library.ts +5 -2
- package/src/admin/editor/ime.ts +29 -0
- package/src/admin/editor/palette-items.ts +10 -3
- package/src/admin/editor/panels/AddPanel.tsx +35 -10
- package/src/admin/editor/panels/ClassesSection.tsx +18 -7
- package/src/admin/editor/panels/ColorControl.tsx +130 -23
- package/src/admin/editor/panels/ConditionsEditor.tsx +52 -26
- package/src/admin/editor/panels/ElementPanel.tsx +134 -24
- package/src/admin/editor/panels/LayersPanel.tsx +55 -19
- package/src/admin/editor/panels/PageSettings.tsx +66 -35
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +170 -32
- package/src/admin/editor/panels/TokenScales.tsx +76 -36
- package/src/admin/editor/panels/TriggerSettings.tsx +50 -12
- package/src/admin/editor/panels/TriggersEditor.tsx +2 -1
- package/src/admin/editor/panels/VariableSection.tsx +48 -18
- package/src/admin/editor/panels/color-space.ts +9 -3
- package/src/admin/editor/panels/settings/AdvancedFields.tsx +12 -2
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +51 -35
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +55 -11
- package/src/admin/editor/panels/settings/BackgroundFill.tsx +3 -2
- package/src/admin/editor/panels/settings/BindingsEditor.tsx +15 -18
- package/src/admin/editor/panels/settings/BoxControl.tsx +2 -1
- package/src/admin/editor/panels/settings/ClassChip.tsx +21 -9
- package/src/admin/editor/panels/settings/ClassChipInput.tsx +24 -16
- package/src/admin/editor/panels/settings/DraftTextField.tsx +41 -3
- package/src/admin/editor/panels/settings/EffectsControls.tsx +38 -14
- package/src/admin/editor/panels/settings/FieldBindControl.tsx +46 -28
- package/src/admin/editor/panels/settings/FieldControl.tsx +20 -8
- package/src/admin/editor/panels/settings/FormBindControl.tsx +2 -2
- package/src/admin/editor/panels/settings/HintedSwitch.tsx +33 -0
- package/src/admin/editor/panels/settings/IconControls.tsx +12 -8
- package/src/admin/editor/panels/settings/IconPicker.tsx +2 -0
- package/src/admin/editor/panels/settings/ImageSourcesField.tsx +3 -1
- package/src/admin/editor/panels/settings/ItemList.tsx +15 -2
- package/src/admin/editor/panels/settings/LengthRow.tsx +8 -6
- package/src/admin/editor/panels/settings/MediaPicker.tsx +127 -23
- package/src/admin/editor/panels/settings/MotionControl.tsx +28 -15
- package/src/admin/editor/panels/settings/NumberRow.tsx +9 -3
- package/src/admin/editor/panels/settings/PanelSelect.tsx +50 -0
- package/src/admin/editor/panels/settings/QueryStyleRows.tsx +25 -18
- package/src/admin/editor/panels/settings/RequiredFieldsNotice.tsx +66 -1
- package/src/admin/editor/panels/settings/StyleRow.tsx +10 -3
- package/src/admin/editor/panels/settings/StyleSources.tsx +4 -1
- package/src/admin/editor/panels/settings/VariantEditor.tsx +10 -1
- package/src/admin/editor/panels/settings/box-link-name.ts +6 -2
- package/src/admin/editor/panels/settings/class-suggest.ts +7 -7
- package/src/admin/editor/panels/settings/query-style.ts +38 -9
- package/src/admin/editor/panels/settings/svg-images.ts +13 -0
- package/src/admin/editor/panels/site-list.tsx +20 -6
- package/src/admin/editor/panels/variable-values.ts +11 -4
- package/src/admin/editor/restore-deleted.ts +21 -2
- package/src/admin/editor/section-templates.ts +81 -12
- package/src/admin/editor/shortcuts.ts +17 -2
- package/src/admin/editor/store.ts +7 -0
- package/src/admin/editor/useEditorCommands.ts +61 -15
- package/src/admin/editor/useEditorData.ts +4 -2
- package/src/admin/editor/useEditorShortcuts.ts +17 -7
- package/src/admin/editor/useNodeActions.ts +61 -6
- package/src/admin/editor/useSave.ts +22 -7
- package/src/admin/forms-api.ts +2 -0
- package/src/admin/image-editor/CurvesPanel.tsx +2 -1
- package/src/admin/image-editor/ExportDialog.tsx +48 -18
- package/src/admin/image-editor/ImageEditorDialog.tsx +49 -7
- package/src/admin/image-editor/MetadataPanel.tsx +15 -4
- package/src/admin/image-editor/crop-geometry.ts +3 -2
- package/src/admin/image-editor/image-editor-css.ts +4 -2
- package/src/admin/image-editor/load.ts +9 -2
- package/src/admin/image-editor/parts.tsx +51 -2
- package/src/admin/image-editor/save.ts +23 -7
- package/src/admin/media-api.ts +2 -1
- package/src/admin/pages/AgentsPage.tsx +138 -27
- package/src/admin/pages/CreateDialog.tsx +97 -30
- package/src/admin/pages/NewPageDialog.tsx +21 -3
- package/src/admin/pages/NewThemePartDialog.tsx +11 -3
- package/src/admin/pages/PageList.tsx +14 -6
- package/src/admin/pages/SetupShell.tsx +28 -12
- package/src/admin/pages/ThemePartList.tsx +27 -7
- package/src/admin/pages/list-kit.tsx +106 -24
- package/src/admin/search.ts +15 -0
- package/src/admin/setup/useSetupStatus.ts +1 -1
- package/src/admin/theme-api.ts +13 -3
- package/src/admin/ui.ts +73 -22
- package/src/astro/floats/runtime.ts +21 -0
- package/src/astro/menu/runtime.ts +34 -1
- package/src/astro/popups/runtime.ts +33 -3
- package/src/astro/render.ts +3 -0
- package/src/astro/resolve-theme.ts +53 -11
- package/src/astro/resolve.ts +9 -1
- package/src/astro/tabs/runtime.ts +12 -0
- package/src/astro/theme-posts.ts +2 -2
- package/src/astro/visitor.ts +2 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +171 -24
- package/src/core/arrange.ts +27 -6
- package/src/core/audience/rules.ts +5 -1
- package/src/core/audience/variants.ts +29 -3
- package/src/core/clipboard.ts +7 -0
- package/src/core/css/generate.ts +31 -6
- package/src/core/data/bindings.ts +8 -1
- package/src/core/design/classes.ts +16 -7
- package/src/core/design/diff.ts +6 -0
- package/src/core/design/merge.ts +90 -2
- package/src/core/design/tokens.ts +16 -2
- package/src/core/design/transfer.ts +33 -6
- package/src/core/design/variables.ts +30 -9
- package/src/core/elements/dynamic-elements.ts +44 -5
- package/src/core/elements/form-elements.ts +55 -16
- package/src/core/elements/index.ts +83 -38
- package/src/core/elements/menu.ts +37 -19
- package/src/core/elements/select-prompt.ts +3 -0
- package/src/core/elements/svg-ids.ts +39 -0
- package/src/core/forms/binding.ts +57 -16
- package/src/core/forms/definition.ts +72 -0
- package/src/core/history/diff.ts +18 -1
- package/src/core/icons/catalog.ts +3 -2
- package/src/core/image-edit/schema.ts +11 -1
- package/src/core/image-edit/summary.ts +6 -3
- package/src/core/index.ts +15 -1
- package/src/core/limits.ts +12 -1
- package/src/core/perf/meter.ts +42 -7
- package/src/core/recipes/index.ts +5 -4
- package/src/core/render/context.ts +8 -0
- package/src/core/render/dynamic-post.ts +69 -12
- package/src/core/render/extras.ts +77 -4
- package/src/core/render/form.ts +140 -6
- package/src/core/render/index.ts +156 -20
- package/src/core/render/loop.ts +43 -7
- package/src/core/render/pagination.ts +18 -4
- package/src/core/render/section.ts +27 -0
- package/src/core/render/tabs.ts +12 -3
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +15 -2
- package/src/core/sanitize/embed-url.ts +42 -5
- package/src/core/sanitize/url.ts +2 -1
- package/src/core/schema/layout.ts +15 -6
- package/src/core/stats.ts +2 -1
- package/src/core/theme/conditions.ts +3 -1
- package/src/core/theme/dynamic.ts +36 -5
- package/src/core/theme/float.ts +9 -2
- package/src/core/theme/pagination.ts +31 -11
- package/src/core/theme/popup-markup.ts +23 -5
- package/src/core/theme/popup-rules.ts +1 -0
- package/src/core/theme/triggers.ts +3 -2
- package/src/core/tree-ops.ts +27 -0
- package/src/mcp/rate-limit.ts +2 -1
- package/src/mcp/read.ts +14 -2
- package/src/mcp/refs.ts +18 -0
- package/src/mcp/write.ts +174 -10
- package/src/server/agent-settings.ts +1 -1
- package/src/server/hooks.ts +5 -3
- package/src/server/icon-routes.ts +30 -9
- package/src/server/mcp-routes.ts +6 -1
|
@@ -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
|
|
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
|
-
{
|
|
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
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
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
|
+
}
|
package/src/admin/theme-api.ts
CHANGED
|
@@ -92,7 +92,8 @@ const RULE_LABELS: Record<string, (args: RuleArgs) => string> = {
|
|
|
92
92
|
"archive/all": () => "All archives",
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
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
|
-
|
|
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-
|
|
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,36 @@ 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
|
+
}
|
|
178
216
|
|
|
179
217
|
/* EmVB-owned dialog body (Kumo Dialog keeps host radius/shadow) */
|
|
180
218
|
.emvb-dialog { display: flex; flex-direction: column; gap: 10px; }
|
|
181
219
|
.emvb-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
|
|
220
|
+
/* UX-023: selects in EmVB dialogs line up with the full-width fields under them. */
|
|
221
|
+
.emvb-dialog .emvb-field { width: 100%; }
|
|
222
|
+
.emvb-create-fields { display: flex; flex-direction: column; gap: 10px; min-width: 0; margin: 0; padding: 0; border: 0; }
|
|
223
|
+
.emvb-create-status { min-height: 18px; }
|
|
224
|
+
/* UX-090: 16 px so the title stands above the 14 px field labels under it. */
|
|
182
225
|
.emvb-dialog :is(h2, [data-slot="title"]) {
|
|
183
226
|
margin: 0;
|
|
184
|
-
font-size:
|
|
185
|
-
line-height:
|
|
227
|
+
font-size: 16px;
|
|
228
|
+
line-height: 22px;
|
|
186
229
|
font-weight: 600;
|
|
187
230
|
color: var(--text-color-kumo-default);
|
|
188
231
|
}
|
|
@@ -216,6 +259,8 @@ export const UI_CSS = `
|
|
|
216
259
|
.emvb-device-fieldset > .emvb-helper { width: 100%; margin: 0; }
|
|
217
260
|
.emvb-device-option { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; font-size: 13px; cursor: pointer; }
|
|
218
261
|
.emvb-device-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--color-kumo-brand); }
|
|
262
|
+
/* UX-027: every native checkbox and radio EmVB draws takes the accent, not the OS blue. */
|
|
263
|
+
:is([data-emvb-editor], [data-emvb-page]) input:is([type="checkbox"], [type="radio"]) { accent-color: var(--color-kumo-brand); }
|
|
219
264
|
.emvb-device-option input:focus-visible { outline: 2px solid var(--color-kumo-brand); outline-offset: 2px; }
|
|
220
265
|
|
|
221
266
|
/* Conditions editor (theme-part settings) */
|
|
@@ -236,7 +281,7 @@ export const UI_CSS = `
|
|
|
236
281
|
}
|
|
237
282
|
.emvb-condition-row {
|
|
238
283
|
display: grid;
|
|
239
|
-
grid-template-columns: 96px 1fr 28px;
|
|
284
|
+
grid-template-columns: 96px minmax(0, 1fr) 28px;
|
|
240
285
|
gap: 6px;
|
|
241
286
|
align-items: center;
|
|
242
287
|
padding: 6px;
|
|
@@ -244,26 +289,32 @@ export const UI_CSS = `
|
|
|
244
289
|
background: var(--emvb-glass-strong, var(--color-kumo-base));
|
|
245
290
|
box-shadow: var(--emvb-elevation-s);
|
|
246
291
|
}
|
|
247
|
-
.emvb-
|
|
248
|
-
.emvb-
|
|
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
|
-
}
|
|
292
|
+
.emvb-panel-select { display: block; min-width: 0; }
|
|
293
|
+
.emvb-panel-select .emvb-field { width: 100%; min-width: 0; }
|
|
263
294
|
.emvb-condition-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
|
|
264
295
|
|
|
265
296
|
@media (prefers-reduced-motion: reduce) {
|
|
266
297
|
[data-emvb-editor] *, [data-emvb-page] * { transition: none !important; animation: none !important; }
|
|
298
|
+
/* Kumo portals sit outside the editor/page roots; a dialog body identifies EmVB ownership. */
|
|
299
|
+
[data-base-ui-portal]:has([data-emvb-dialog]),
|
|
300
|
+
[data-base-ui-portal]:has([data-emvb-dialog]) *,
|
|
301
|
+
[data-base-ui-portal]:has([data-emvb-dialog])::before,
|
|
302
|
+
[data-base-ui-portal]:has([data-emvb-dialog])::after,
|
|
303
|
+
[data-base-ui-portal]:has([data-emvb-dialog]) *::before,
|
|
304
|
+
[data-base-ui-portal]:has([data-emvb-dialog]) *::after {
|
|
305
|
+
transition: none !important;
|
|
306
|
+
animation: none !important;
|
|
307
|
+
}
|
|
308
|
+
.emvb-list-loading .skeleton-line::after { animation: none !important; }
|
|
309
|
+
[data-emvb-toasts],
|
|
310
|
+
[data-emvb-toasts] *,
|
|
311
|
+
[data-emvb-toasts]::before,
|
|
312
|
+
[data-emvb-toasts]::after,
|
|
313
|
+
[data-emvb-toasts] *::before,
|
|
314
|
+
[data-emvb-toasts] *::after {
|
|
315
|
+
transition: none !important;
|
|
316
|
+
animation: none !important;
|
|
317
|
+
}
|
|
267
318
|
}
|
|
268
319
|
@media (prefers-reduced-transparency: reduce) {
|
|
269
320
|
.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
|
-
|
|
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
|
}
|
|
@@ -156,14 +156,16 @@ function createController(root: HTMLElement): Controller | null {
|
|
|
156
156
|
|
|
157
157
|
function focusables(container: HTMLElement): HTMLElement[] {
|
|
158
158
|
const nodes = container.querySelectorAll<HTMLElement>(
|
|
159
|
-
'a
|
|
159
|
+
// W-672: an accordion's or menu's <summary>, a video player and an editable area take focus
|
|
160
|
+
// too; one of them last in the dialog let Tab leave for the page behind.
|
|
161
|
+
'a[href], button:not([disabled]), textarea, input, select, summary, iframe, video[controls], audio[controls], [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"])',
|
|
160
162
|
);
|
|
161
163
|
// W-279: a form's hidden inputs and controls hidden on this device can't take focus; counting
|
|
162
164
|
// one as the last control let Tab leave the dialog from the real last one.
|
|
163
165
|
return [...nodes].filter(
|
|
164
166
|
(el) =>
|
|
165
167
|
!el.hasAttribute("disabled") &&
|
|
166
|
-
el.tabIndex >= 0 &&
|
|
168
|
+
(el.tabIndex >= 0 || (el.localName === "summary" && !el.hasAttribute("tabindex"))) &&
|
|
167
169
|
!(el instanceof HTMLInputElement && el.type === "hidden") &&
|
|
168
170
|
!el.closest("[hidden], [inert]") &&
|
|
169
171
|
(typeof el.checkVisibility !== "function" || el.checkVisibility()),
|
|
@@ -193,8 +195,23 @@ function bindA11y(ctrl: Controller): void {
|
|
|
193
195
|
}
|
|
194
196
|
});
|
|
195
197
|
ctrl.dialog.addEventListener("keydown", (event) => {
|
|
198
|
+
// W-676: while an input method is composing (Japanese, Chinese, Korean), Escape cancels the
|
|
199
|
+
// word being typed; it closed the whole popup and lost what was in the form.
|
|
200
|
+
if (event.key === "Escape" && (event.isComposing || event.keyCode === 229)) return;
|
|
196
201
|
if (event.key === "Escape") {
|
|
197
202
|
event.preventDefault();
|
|
203
|
+
// W-580: Escape in an open menu dropdown inside the popup closes that dropdown first (the
|
|
204
|
+
// menu runtime saw the event already handled, so the whole popup closed instead).
|
|
205
|
+
const active = document.activeElement;
|
|
206
|
+
const menu =
|
|
207
|
+
active instanceof Element
|
|
208
|
+
? active.closest<HTMLDetailsElement>("details.emvb-menu-item__disclosure[open]")
|
|
209
|
+
: null;
|
|
210
|
+
if (menu && ctrl.dialog.contains(menu)) {
|
|
211
|
+
menu.open = false;
|
|
212
|
+
menu.querySelector<HTMLElement>(":scope > summary")?.focus({ preventScroll: true });
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
198
215
|
ctrl.close();
|
|
199
216
|
return;
|
|
200
217
|
}
|
|
@@ -208,7 +225,11 @@ function bindA11y(ctrl: Controller): void {
|
|
|
208
225
|
const first = items[0];
|
|
209
226
|
const last = items[items.length - 1];
|
|
210
227
|
if (!first || !last) return;
|
|
211
|
-
|
|
228
|
+
// W-553: opening focuses the dialog itself; Shift+Tab from there left for the page behind.
|
|
229
|
+
if (
|
|
230
|
+
event.shiftKey &&
|
|
231
|
+
(document.activeElement === first || document.activeElement === ctrl.dialog)
|
|
232
|
+
) {
|
|
212
233
|
event.preventDefault();
|
|
213
234
|
last.focus();
|
|
214
235
|
} else if (!event.shiftKey && document.activeElement === last) {
|
|
@@ -296,9 +317,18 @@ function registerTrigger(ctrl: Controller, config: PopupConfig, trigger: OpenTri
|
|
|
296
317
|
arm?.(() => openOnce(ctrl, config), trigger as never);
|
|
297
318
|
}
|
|
298
319
|
|
|
320
|
+
/**
|
|
321
|
+
* W-757: as W-407 for floats, a second call (a host loading the script twice, or calling it again
|
|
322
|
+
* for new markup) gave a popup a second controller: it opened twice, counted two shows against
|
|
323
|
+
* "Show at most", and Escape closed it twice, handing focus to the hidden dialog.
|
|
324
|
+
*/
|
|
325
|
+
const started = new WeakSet<HTMLElement>();
|
|
326
|
+
|
|
299
327
|
export function initPopups(root: ParentNode = document): void {
|
|
300
328
|
const nodes = root.querySelectorAll<HTMLElement>("[data-emvb-popup]");
|
|
301
329
|
for (const node of nodes) {
|
|
330
|
+
if (started.has(node)) continue;
|
|
331
|
+
started.add(node);
|
|
302
332
|
const config = readConfig(node);
|
|
303
333
|
if (!config) continue;
|
|
304
334
|
const ctrl = createController(node);
|
package/src/astro/render.ts
CHANGED
|
@@ -72,6 +72,8 @@ export function renderStored(
|
|
|
72
72
|
dynamic?: ThemeDynamicData,
|
|
73
73
|
/** A theme part: generated ids get a suffix of its own (W-527). */
|
|
74
74
|
partIds = false,
|
|
75
|
+
/** The page's language, e.g. "fr-CA", for Post Dates (W-688). */
|
|
76
|
+
lang?: string,
|
|
75
77
|
): RenderedPage {
|
|
76
78
|
const { layout, problem } = inspectLayout(raw);
|
|
77
79
|
if (!layout) {
|
|
@@ -98,6 +100,7 @@ export function renderStored(
|
|
|
98
100
|
dynamic,
|
|
99
101
|
scope: pageId,
|
|
100
102
|
...(partIds ? { partIds } : {}),
|
|
103
|
+
...(lang ? { lang } : {}),
|
|
101
104
|
},
|
|
102
105
|
);
|
|
103
106
|
return {
|