@1agh/maude 2.0.3 → 2.0.6
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/README.md +6 -5
- package/apps/hub/src/project-transactions/kernel.mjs +10 -1
- package/apps/studio/access/filters.ts +12 -5
- package/apps/studio/access/known-canvases.ts +24 -1
- package/apps/studio/access/refused-inputs.ts +89 -0
- package/apps/studio/access/request.ts +0 -1
- package/apps/studio/acp/adapter-stderr.ts +43 -13
- package/apps/studio/acp/background-tasks.ts +155 -0
- package/apps/studio/acp/bridge.ts +44 -5
- package/apps/studio/acp/connected-fact.ts +15 -4
- package/apps/studio/acp/index.ts +14 -5
- package/apps/studio/actions/agents.ts +10 -0
- package/apps/studio/actions/defs/app.ts +12 -0
- package/apps/studio/actions/defs/view.ts +12 -0
- package/apps/studio/actions.manifest.json +25 -1
- package/apps/studio/actions.parity.json +13 -1
- package/apps/studio/annotations/ui/element-node.tsx +139 -54
- package/apps/studio/annotations/ui/lod.tsx +1 -1
- package/apps/studio/annotations/ui/text-style.ts +1 -1
- package/apps/studio/annotations-layer.tsx +0 -12
- package/apps/studio/api.ts +73 -24
- package/apps/studio/artboard-live-gate.tsx +267 -0
- package/apps/studio/artboard-live.ts +336 -0
- package/apps/studio/artboard-webgl.ts +668 -0
- package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
- package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
- package/apps/studio/bin/_canvas-reasons.mjs +34 -0
- package/apps/studio/bin/_ds-check-live.mjs +37 -0
- package/apps/studio/bin/_ds-check.mjs +4 -1
- package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
- package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
- package/apps/studio/bin/_import-asset.mjs +2 -1
- package/apps/studio/bin/_perf-probe.mjs +2 -1
- package/apps/studio/bin/_png-playwright.mjs +10 -1
- package/apps/studio/bin/_pw-launch.mjs +14 -0
- package/apps/studio/bin/_studio-verb.mjs +24 -3
- package/apps/studio/bin/_thumb-blank.mjs +70 -0
- package/apps/studio/bin/_thumb-cover.mjs +35 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +93 -13
- package/apps/studio/bin/ds-check.sh +5 -1
- package/apps/studio/bin/perf.sh +11 -1
- package/apps/studio/bin/server-up.sh +7 -2
- package/apps/studio/bin/smoke.sh +19 -0
- package/apps/studio/boot-progress.ts +31 -0
- package/apps/studio/canvas-build-sandbox.ts +275 -42
- package/apps/studio/canvas-build-worker.ts +10 -0
- package/apps/studio/canvas-create.ts +24 -0
- package/apps/studio/canvas-lib.tsx +131 -12
- package/apps/studio/canvas-module-cache.ts +93 -0
- package/apps/studio/canvas-source/errors.ts +39 -0
- package/apps/studio/canvas-source/waiting.ts +290 -0
- package/apps/studio/client/actions/shell-key-handlers.js +5 -0
- package/apps/studio/client/app.jsx +19 -9
- package/apps/studio/client/canvas-url.js +13 -0
- package/apps/studio/client/github.js +23 -3
- package/apps/studio/client/home/HomeAccounts.jsx +262 -0
- package/apps/studio/client/home/Shelves.jsx +4 -3
- package/apps/studio/client/home/home-accounts-model.js +121 -0
- package/apps/studio/client/home/home-api.js +36 -19
- package/apps/studio/client/home/home-app.jsx +141 -40
- package/apps/studio/client/home/home-model.js +172 -6
- package/apps/studio/client/home/home.css +169 -5
- package/apps/studio/client/home/shell-mode.js +8 -1
- package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
- package/apps/studio/client/hooks/use-project-data.jsx +2 -0
- package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
- package/apps/studio/client/hooks/use-tabs.jsx +64 -35
- package/apps/studio/client/index-loader.ts +23 -3
- package/apps/studio/client/panels/ChatPanel.jsx +49 -57
- package/apps/studio/client/panels/CreateProject.jsx +19 -5
- package/apps/studio/client/panels/DiffView.jsx +314 -248
- package/apps/studio/client/panels/TeamProjects.jsx +119 -69
- package/apps/studio/client/panels/acp-runtime.js +25 -0
- package/apps/studio/client/panels/caps-cache.js +46 -0
- package/apps/studio/client/panels/chat-finish.js +66 -0
- package/apps/studio/client/shell/frame-cap.js +53 -0
- package/apps/studio/client/shell/viewport.jsx +45 -8
- package/apps/studio/client/styles/_index.css +2 -0
- package/apps/studio/client/tree/tree.jsx +48 -21
- package/apps/studio/client/v2/access/access-client.js +2 -0
- package/apps/studio/client/v2/access/access-host.jsx +12 -1
- package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
- package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
- package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
- package/apps/studio/client/v2/ai/Composer.jsx +27 -10
- package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
- package/apps/studio/client/v2/ai/ai-run.css +87 -3
- package/apps/studio/client/v2/ai/background-model.js +113 -0
- package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
- package/apps/studio/client/v2/ai/run-api.js +7 -3
- package/apps/studio/client/v2/ai/runs-store.js +2 -1
- package/apps/studio/client/v2/annotations/vote-store.js +11 -5
- package/apps/studio/client/v2/assets/asset-state-lane.js +6 -3
- package/apps/studio/client/v2/assets/assets-bus.js +10 -8
- package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
- package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
- package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
- package/apps/studio/client/v2/assets/spotlight.css +153 -0
- package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
- package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
- package/apps/studio/client/v2/assets/tile.jsx +3 -0
- package/apps/studio/client/v2/assets/use-assets.js +2 -1
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
- package/apps/studio/client/v2/canvases/covers.js +11 -5
- package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
- package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
- package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
- package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
- package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
- package/apps/studio/client/v2/canvases/use-pins.js +2 -1
- package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
- package/apps/studio/client/v2/code/canvas-imports-card.jsx +15 -14
- package/apps/studio/client/v2/code/canvas-imports-words.js +44 -0
- package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
- package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
- package/apps/studio/client/v2/code/code-bus.js +5 -0
- package/apps/studio/client/v2/code/code.css +67 -0
- package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
- package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
- package/apps/studio/client/v2/create/name-dialog.css +10 -0
- package/apps/studio/client/v2/ds/advanced-host.jsx +11 -23
- package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
- package/apps/studio/client/v2/ds/library-host.jsx +45 -45
- package/apps/studio/client/v2/ds/make-host.jsx +13 -12
- package/apps/studio/client/v2/ds/off-system-host.jsx +18 -16
- package/apps/studio/client/v2/ds/review-host.jsx +7 -1
- package/apps/studio/client/v2/ds/truth-host.jsx +15 -14
- package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
- package/apps/studio/client/v2/empty/arriving.jsx +29 -12
- package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
- package/apps/studio/client/v2/empty/not-local.jsx +31 -1
- package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
- package/apps/studio/client/v2/export/last-finished.js +2 -1
- package/apps/studio/client/v2/history/branch-actions.js +13 -9
- package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
- package/apps/studio/client/v2/history/git-model.js +21 -5
- package/apps/studio/client/v2/history/git-parts.jsx +76 -43
- package/apps/studio/client/v2/history/history.css +6 -0
- package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
- package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
- package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
- package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
- package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
- package/apps/studio/client/v2/presence/faces.jsx +42 -14
- package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
- package/apps/studio/client/v2/search/search-recent.js +3 -1
- package/apps/studio/client/v2/search/search-remote.js +6 -4
- package/apps/studio/client/v2/settings/connections-model.js +1 -1
- package/apps/studio/client/v2/shell/account-card.jsx +10 -4
- package/apps/studio/client/v2/shell/canvas-crash-guard.js +137 -0
- package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
- package/apps/studio/client/v2/shell/menu-runner.js +12 -0
- package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
- package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
- package/apps/studio/client/v2/shell/project-account-model.js +182 -0
- package/apps/studio/client/v2/shell/recovery-store.js +2 -1
- package/apps/studio/client/v2/shell/served-routes.js +120 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +139 -11
- package/apps/studio/client/v2/shell/share-cluster.css +58 -0
- package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
- package/apps/studio/client/v2/shell/shell-activity.js +19 -0
- package/apps/studio/client/v2/shell/team-switch.js +94 -0
- package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
- package/apps/studio/client/v2/shell/use-account.js +8 -1
- package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
- package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
- package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
- package/apps/studio/cloud/endpoints.ts +23 -1
- package/apps/studio/collab/persistence.ts +9 -1
- package/apps/studio/collab/registry.ts +32 -0
- package/apps/studio/collab/room.ts +8 -0
- package/apps/studio/config-reload-wire.ts +53 -0
- package/apps/studio/dist/client.bundle.js +1098 -1102
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds/board/specimen.tsx +12 -1
- package/apps/studio/ds/canvas-cli.ts +58 -2
- package/apps/studio/ds/check.ts +26 -1
- package/apps/studio/ds/cli.ts +7 -3
- package/apps/studio/ds/convert.ts +34 -6
- package/apps/studio/ds/ds-verb.ts +13 -0
- package/apps/studio/ds/post-build.ts +38 -0
- package/apps/studio/ds/upgrade-apply.ts +27 -5
- package/apps/studio/ds/upgrade-cli.ts +22 -2
- package/apps/studio/ds/upgrade-prove.ts +198 -15
- package/apps/studio/ds/upgrade-stage.ts +4 -1
- package/apps/studio/editing/minimap-context.tsx +3 -3
- package/apps/studio/editing/page-activity.ts +251 -0
- package/apps/studio/editing/rotate-handle.tsx +9 -5
- package/apps/studio/editing/sticky-name.tsx +4 -4
- package/apps/studio/history/restore-artboard-action.ts +40 -0
- package/apps/studio/history/trash.ts +6 -0
- package/apps/studio/home/accounts.ts +87 -0
- package/apps/studio/home/hub.ts +77 -175
- package/apps/studio/home/index-reader.ts +24 -2
- package/apps/studio/home/routes.ts +66 -8
- package/apps/studio/http.ts +131 -68
- package/apps/studio/index-flight.ts +40 -0
- package/apps/studio/managed-projects.ts +52 -24
- package/apps/studio/migrate/hub.ts +7 -1
- package/apps/studio/routes/canvas-source.ts +44 -2
- package/apps/studio/routes/ds-convert.ts +18 -0
- package/apps/studio/routes/history.ts +28 -5
- package/apps/studio/routes/hub-signin.ts +115 -0
- package/apps/studio/routes/index.ts +4 -0
- package/apps/studio/routes/table.ts +7 -0
- package/apps/studio/routes/trash.ts +19 -1
- package/apps/studio/server.ts +19 -10
- package/apps/studio/sync/accepted-cold-start.ts +54 -16
- package/apps/studio/sync/accepted-link.ts +9 -4
- package/apps/studio/sync/asset-push.ts +146 -23
- package/apps/studio/sync/asset-state.ts +3 -2
- package/apps/studio/sync/code-module-consent.ts +74 -0
- package/apps/studio/sync/file-ledger.ts +35 -0
- package/apps/studio/sync/file-membership.ts +28 -3
- package/apps/studio/sync/file-plane.ts +483 -86
- package/apps/studio/sync/file-pull.ts +304 -33
- package/apps/studio/sync/hub-browser-signin.ts +377 -0
- package/apps/studio/sync/hub-link.ts +1 -2
- package/apps/studio/sync/hub-text-undo.ts +30 -10
- package/apps/studio/sync/index.ts +381 -161
- package/apps/studio/sync/journal-client.ts +94 -5
- package/apps/studio/sync/pending-deletes.ts +100 -0
- package/apps/studio/sync/projection.ts +121 -14
- package/apps/studio/sync/pull-pacer.ts +160 -0
- package/apps/studio/sync/pull-priority.ts +119 -0
- package/apps/studio/sync/seed-progress.ts +58 -3
- package/apps/studio/sync/status.ts +3 -1
- package/apps/studio/sync/transaction-client.ts +71 -6
- package/apps/studio/sync/workspace-signin.ts +6 -256
- package/apps/studio/sync/writer-registry.ts +5 -1
- package/apps/studio/thumbs/service.ts +12 -2
- package/apps/studio/thumbs/validate.ts +7 -0
- package/apps/studio/ui-prefs-migrate.ts +4 -0
- package/apps/studio/video-comp.tsx +23 -0
- package/apps/studio/video-links-overlay.tsx +3 -2
- package/apps/studio/whats-new.json +126 -0
- package/cli/lib/bash-guard.mjs +13 -1
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/design-hook.mjs +20 -0
- package/cli/lib/studio-locate.mjs +35 -10
- package/cli/lib/workspace-plan.mjs +14 -0
- package/package.json +8 -8
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
// Undo is the run's own action: "one AI run = one version = one step" (V2-1.5). The stack is read
|
|
11
11
|
// for the entry carrying this `runId`, so a person's later edits never get undone with it.
|
|
12
12
|
|
|
13
|
+
import { fetchIfServed, servedFetch } from '../shell/served-routes.js';
|
|
14
|
+
|
|
13
15
|
const JSON_HEADERS = { 'content-type': 'application/json' };
|
|
14
16
|
|
|
15
17
|
async function json(res) {
|
|
@@ -50,7 +52,7 @@ export async function keepGoingRun(runId, fetchImpl = globalThis.fetch) {
|
|
|
50
52
|
/** This chat's runs (YOURS), for the panel that opened after they started. [] when unreachable. */
|
|
51
53
|
export async function fetchChatRuns(chatId, fetchImpl = globalThis.fetch) {
|
|
52
54
|
try {
|
|
53
|
-
const res = await
|
|
55
|
+
const res = await servedFetch('/_api/ai/runs', undefined, fetchImpl);
|
|
54
56
|
if (!res.ok) return [];
|
|
55
57
|
const body = await json(res);
|
|
56
58
|
const mine = Array.isArray(body?.mine) ? body.mine : [];
|
|
@@ -68,8 +70,10 @@ async function stackFor(run, designRel, fetchImpl) {
|
|
|
68
70
|
if (!canvas) return { ok: false, reason: 'not-found' };
|
|
69
71
|
let res;
|
|
70
72
|
try {
|
|
71
|
-
res = await
|
|
72
|
-
`/_api/project/undo-stack?canvas=${encodeURIComponent(canvasPath(designRel, canvas))}
|
|
73
|
+
res = await fetchIfServed(
|
|
74
|
+
`/_api/project/undo-stack?canvas=${encodeURIComponent(canvasPath(designRel, canvas))}`,
|
|
75
|
+
undefined,
|
|
76
|
+
fetchImpl
|
|
73
77
|
);
|
|
74
78
|
} catch {
|
|
75
79
|
return { ok: false, reason: 'unreachable' };
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { useSyncExternalStore } from 'react';
|
|
11
11
|
import { EMPTY_RUNS, finishedArtboards, normalizeRuns } from './runs-model.js';
|
|
12
|
+
import { servedFetch } from '../shell/served-routes.js';
|
|
12
13
|
|
|
13
14
|
export const RUNS_EVENT = 'maude:ai-runs';
|
|
14
15
|
const DONE_MS = 6000;
|
|
@@ -37,7 +38,7 @@ export function createRunsStore({ fetchImpl, target = globalThis.window, setTime
|
|
|
37
38
|
|
|
38
39
|
async function read() {
|
|
39
40
|
try {
|
|
40
|
-
const res = await
|
|
41
|
+
const res = await servedFetch('/_api/ai/runs', { cache: 'no-store' }, doFetch);
|
|
41
42
|
if (!res.ok) return;
|
|
42
43
|
const view = normalizeRuns(await res.json());
|
|
43
44
|
// a reply older than what we hold is a late answer to an earlier question
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
// "Start a vote…" is a shell gesture (⌘K, the artboard menu routed through the shell's own handlers). No React, no DOM: `fetchImpl` / `now` / `setTimer` are
|
|
15
15
|
// injected, so it is unit-tested without a browser.
|
|
16
16
|
|
|
17
|
+
import { fetchIfServed } from '../shell/served-routes.js';
|
|
18
|
+
|
|
17
19
|
/** The words (CONTRACT §3–§4). */
|
|
18
20
|
export const VOTE_WORDS = {
|
|
19
21
|
title: 'Start a vote',
|
|
@@ -157,11 +159,15 @@ export function resultPlace(artboards, targets) {
|
|
|
157
159
|
|
|
158
160
|
async function call(fetchImpl, method, url, body) {
|
|
159
161
|
try {
|
|
160
|
-
const r = await
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
const r = await fetchIfServed(
|
|
163
|
+
url,
|
|
164
|
+
{
|
|
165
|
+
method,
|
|
166
|
+
headers: { 'content-type': 'application/json' },
|
|
167
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
168
|
+
},
|
|
169
|
+
fetchImpl
|
|
170
|
+
);
|
|
165
171
|
return { status: r.status, data: await r.json().catch(() => null) };
|
|
166
172
|
} catch {
|
|
167
173
|
return { status: 0, data: null };
|
|
@@ -30,6 +30,7 @@ import { INDEX_CHANGED_EVENT } from '../canvases/use-canvas-index.js';
|
|
|
30
30
|
import { nativeSave } from '../export/native-save.js';
|
|
31
31
|
import { dispatchCanvasOp } from '../left-panel/left-panel-bus.js';
|
|
32
32
|
import { ASK_AI_MAX } from '../search/search-env.js';
|
|
33
|
+
import { fetchIfServed } from '../shell/served-routes.js';
|
|
33
34
|
|
|
34
35
|
/** canvas file → (rel → item): what the studio last said about each canvas. The relink gate and the
|
|
35
36
|
* Inspector's absent-picture box read it; nothing else does. */
|
|
@@ -224,9 +225,11 @@ export function createAssetStateLane(deps) {
|
|
|
224
225
|
async function ask(canvas) {
|
|
225
226
|
let res;
|
|
226
227
|
try {
|
|
227
|
-
res = await
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
res = await fetchIfServed(
|
|
229
|
+
`/_api/asset-state?canvas=${encodeURIComponent(canvas)}`,
|
|
230
|
+
{ headers: { accept: 'application/json' } },
|
|
231
|
+
fetchImpl
|
|
232
|
+
);
|
|
230
233
|
} catch {
|
|
231
234
|
return null;
|
|
232
235
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// client/v2/assets/assets-bus.js — how the registry reaches the mounted Assets tab (S8.12).
|
|
2
2
|
//
|
|
3
|
-
// `assets.place` (↵)
|
|
3
|
+
// `assets.place` (↵), `assets.details` (⌘I) and `assets.spotlight` (Space) are shell actions whose state lives in the panel: which tile is picked,
|
|
4
4
|
// where the selected artboard is. The shell's one key listener and the menu runner call `runAssetsAction(id)`; the
|
|
5
5
|
// panel binds itself here while it is mounted and runs the SAME functions its tile menu runs, so a key, the menu and the
|
|
6
6
|
// right-click row are one code path.
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// is picked AND keyboard focus is inside the tab. A tile still picked while focus moved to the canvas or a toolbar
|
|
10
10
|
// button must leave ↵ to whatever has focus.
|
|
11
11
|
|
|
12
|
-
/** @type {{ place: () => void, details: () => void, trash: () => void, generate?: () => void, addLink?: () => void, describe?: () => void, describeStop?: () => void, tileSelected: () => boolean } | null} */
|
|
12
|
+
/** @type {{ place: () => void, details: () => void, spotlight?: () => void, trash: () => void, generate?: () => void, addLink?: () => void, describe?: () => void, describeStop?: () => void, tileSelected: () => boolean } | null} */
|
|
13
13
|
let bound = null;
|
|
14
14
|
|
|
15
15
|
/** The panel binds itself on mount. @returns the unbind. */
|
|
@@ -60,7 +60,7 @@ export function takeAddLinkRequest() {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
* Run `assets.place` / `assets.details` / `assets.trash` on the picked tile, or `assets.generate` (the ask).
|
|
63
|
+
* Run `assets.place` / `assets.details` / `assets.spotlight` / `assets.trash` on the picked tile, or `assets.generate` (the ask).
|
|
64
64
|
* @returns whether a mounted panel took it. `assets.generate` with no panel mounted is held for the next mount.
|
|
65
65
|
*/
|
|
66
66
|
export function runAssetsAction(id) {
|
|
@@ -98,11 +98,13 @@ export function runAssetsAction(id) {
|
|
|
98
98
|
? bound?.place
|
|
99
99
|
: id === 'assets.details'
|
|
100
100
|
? bound?.details
|
|
101
|
-
: id === 'assets.
|
|
102
|
-
? bound?.
|
|
103
|
-
: id === 'assets.
|
|
104
|
-
? bound?.
|
|
105
|
-
:
|
|
101
|
+
: id === 'assets.spotlight'
|
|
102
|
+
? bound?.spotlight
|
|
103
|
+
: id === 'assets.trash'
|
|
104
|
+
? bound?.trash
|
|
105
|
+
: id === 'assets.rename'
|
|
106
|
+
? bound?.rename
|
|
107
|
+
: null;
|
|
106
108
|
if (!fn) return false;
|
|
107
109
|
fn();
|
|
108
110
|
return true;
|
|
@@ -41,6 +41,7 @@ export function BrowseView({
|
|
|
41
41
|
onChange,
|
|
42
42
|
onPick,
|
|
43
43
|
onMenu,
|
|
44
|
+
onOpen = undefined,
|
|
44
45
|
onBack,
|
|
45
46
|
onClear,
|
|
46
47
|
onPlace,
|
|
@@ -152,6 +153,7 @@ export function BrowseView({
|
|
|
152
153
|
pickCircle
|
|
153
154
|
onPick={(path, e, isMenu) => onPick(ids, path, e, isMenu)}
|
|
154
155
|
onMenu={onMenu}
|
|
156
|
+
onOpen={onOpen}
|
|
155
157
|
/>
|
|
156
158
|
))}
|
|
157
159
|
</div>
|
|
@@ -10,6 +10,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
10
10
|
import { StIcon } from '../../shell/icons.jsx';
|
|
11
11
|
import { crumbsOf, filesWords, useDsLibrary } from './ds-library.js';
|
|
12
12
|
import { placeAsset, SELECT_ARTBOARD_LINE } from './place-asset.js';
|
|
13
|
+
import { AssetSpotlight } from './spotlight.jsx';
|
|
13
14
|
import { AssetTile } from './tile.jsx';
|
|
14
15
|
|
|
15
16
|
/** "Placed the photo in Fotky ze zápasu." — the design system keeps the picture; nothing is copied. */
|
|
@@ -37,6 +38,8 @@ export function DsLibraryView({
|
|
|
37
38
|
const [query, setQuery] = useState('');
|
|
38
39
|
const [picked, setPicked] = useState(null);
|
|
39
40
|
const [err, setErr] = useState('');
|
|
41
|
+
// 2.0.4 (#191) — the tile open large: the path showing; ← → walk the files listed now, in order
|
|
42
|
+
const [spot, setSpot] = useState(null);
|
|
40
43
|
const rootRef = useRef(null);
|
|
41
44
|
const sentinel = useRef(null);
|
|
42
45
|
const alive = useRef(true);
|
|
@@ -96,8 +99,30 @@ export function DsLibraryView({
|
|
|
96
99
|
[readOnly, rows, placeTarget, placeLabel, onRecord, toast]
|
|
97
100
|
);
|
|
98
101
|
|
|
102
|
+
const spotIndex = spot ? rows.findIndex((r) => r.path === spot) : -1;
|
|
103
|
+
const focusTile = (path) => {
|
|
104
|
+
const tile = Array.from(rootRef.current?.querySelectorAll?.('[data-asset]') ?? []).find(
|
|
105
|
+
(el) => el.dataset.asset === path
|
|
106
|
+
);
|
|
107
|
+
tile?.focus?.({ preventScroll: true });
|
|
108
|
+
};
|
|
109
|
+
const closeSpotlight = () => {
|
|
110
|
+
if (spot) focusTile(spot);
|
|
111
|
+
setSpot(null);
|
|
112
|
+
};
|
|
113
|
+
const openSpotlight = (path) => {
|
|
114
|
+
if (byPath.has(path)) setSpot(path);
|
|
115
|
+
};
|
|
116
|
+
// the same rows the tile has in this view: Place, for a file that can be one
|
|
117
|
+
const spotAsset = spotIndex >= 0 ? rows[spotIndex] : null;
|
|
118
|
+
const spotRows =
|
|
119
|
+
spotAsset && !readOnly && spotAsset.placeable && ['image', 'video'].includes(spotAsset.kind)
|
|
120
|
+
? [{ id: 'place', label: placeLabel ? `Place in ${placeLabel}` : 'Place', keys: '↵' }]
|
|
121
|
+
: [];
|
|
122
|
+
|
|
99
123
|
if (apiRef)
|
|
100
124
|
apiRef.current = {
|
|
125
|
+
spotlight: () => (picked ? openSpotlight(picked) : undefined),
|
|
101
126
|
place: () => (picked ? place(picked) : undefined),
|
|
102
127
|
tileSelected: () => !!picked && !!rootRef.current?.contains(document.activeElement),
|
|
103
128
|
};
|
|
@@ -212,6 +237,7 @@ export function DsLibraryView({
|
|
|
212
237
|
setPicked(p);
|
|
213
238
|
setErr('');
|
|
214
239
|
}}
|
|
240
|
+
onOpen={openSpotlight}
|
|
215
241
|
onMenu={() => {}}
|
|
216
242
|
/>
|
|
217
243
|
))}
|
|
@@ -258,6 +284,27 @@ export function DsLibraryView({
|
|
|
258
284
|
{byPath.get(picked)?.name}
|
|
259
285
|
</p>
|
|
260
286
|
) : null}
|
|
287
|
+
{spotAsset ? (
|
|
288
|
+
<AssetSpotlight
|
|
289
|
+
items={rows}
|
|
290
|
+
index={spotIndex}
|
|
291
|
+
urlOf={(p) => p}
|
|
292
|
+
rows={spotRows}
|
|
293
|
+
onIndex={(i) => {
|
|
294
|
+
const a = rows[i];
|
|
295
|
+
if (!a) return;
|
|
296
|
+
setSpot(a.path);
|
|
297
|
+
setPicked(a.path);
|
|
298
|
+
setErr('');
|
|
299
|
+
}}
|
|
300
|
+
onClose={closeSpotlight}
|
|
301
|
+
onRow={(id) => {
|
|
302
|
+
const path = spot;
|
|
303
|
+
setSpot(null);
|
|
304
|
+
if (id === 'place' && path) void place(path);
|
|
305
|
+
}}
|
|
306
|
+
/>
|
|
307
|
+
) : null}
|
|
261
308
|
</div>
|
|
262
309
|
);
|
|
263
310
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// client/v2/assets/spotlight-model.js — the pure half of the asset spotlight (2.0.4, issue #191).
|
|
2
|
+
//
|
|
3
|
+
// A double-click on an Assets tile opens its picture, clip or sound large. Which tiles ← → walks, what the window says
|
|
4
|
+
// about the file and which rows it offers are decided here; the window itself is spotlight.jsx.
|
|
5
|
+
|
|
6
|
+
import { GROUP_CAP } from './library-foot.js';
|
|
7
|
+
import { sizeWords } from './tile.jsx';
|
|
8
|
+
|
|
9
|
+
/** The words the window uses (CONTRACT §3/§4: what happened · what is safe · one verb). */
|
|
10
|
+
export const SPOTLIGHT_WORDS = {
|
|
11
|
+
close: 'Close',
|
|
12
|
+
previous: 'Previous',
|
|
13
|
+
next: 'Next',
|
|
14
|
+
/** why an arrow is off at the ends (dead-controls: a disabled control says why) */
|
|
15
|
+
atFirst: 'This is the first file.',
|
|
16
|
+
atLast: 'This is the last file.',
|
|
17
|
+
noPreview: 'This file has no preview.',
|
|
18
|
+
failed: 'This picture could not be shown.',
|
|
19
|
+
/** "3 of 12" — a screen reader hears it as the position. */
|
|
20
|
+
position: (i, n) => `${i + 1} of ${n}`,
|
|
21
|
+
/** the dialog's name for a screen reader when the file has none */
|
|
22
|
+
fallbackName: 'Asset',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** @returns {'image' | 'video' | 'audio' | 'file'} how the window draws it */
|
|
26
|
+
export function previewKind(asset) {
|
|
27
|
+
const k = asset?.kind;
|
|
28
|
+
return k === 'image' || k === 'video' || k === 'audio' ? k : 'file';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Step `delta` along a list of `n`: stops at the ends (the arrows disable there), never wraps. */
|
|
32
|
+
export function stepIndex(index, delta, n) {
|
|
33
|
+
if (!(n > 0)) return -1;
|
|
34
|
+
const to = index + delta;
|
|
35
|
+
return to < 0 || to >= n ? index : to;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The file's own folder + name, with no leading slash ("assets/9f2a.jpg"; a design-system file is "…/system/club/…"). */
|
|
39
|
+
export function pathWords(asset) {
|
|
40
|
+
return String(asset?.rel || asset?.path || '').replace(/^\/+/, '');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** One line under the picture: its size ("2.3 MB"), or nothing when the studio did not say. */
|
|
44
|
+
export function sizeLine(asset) {
|
|
45
|
+
return Number(asset?.size) > 0 ? sizeWords(asset.size) : '';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The rows the tile already offers (tile-menu.jsx `tileMenuItems`) that fit a window over the picture. Move to trash is
|
|
50
|
+
* left in the menu: a bigger look is not the place to remove a file.
|
|
51
|
+
*/
|
|
52
|
+
export function spotlightRows(menuItems) {
|
|
53
|
+
return (menuItems || []).filter((it) => !it.separator && it.id !== 'trash');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Which tiles of a group the narrow tab draws: all of them for Just added, Generated and a search, the first `GROUP_CAP`
|
|
58
|
+
* for a plain Photos / Video / Sound group — unless the Not used view lists everything to tidy.
|
|
59
|
+
*/
|
|
60
|
+
export function groupShown(group, { uncapped = false } = {}) {
|
|
61
|
+
if (group.kind === 'added' || group.kind === 'generated' || group.kind === 'found' || uncapped)
|
|
62
|
+
return group.items;
|
|
63
|
+
return group.items.slice(0, GROUP_CAP);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The paths ← → walks in the narrow tab, in the order the tab draws them (the "Seen in the picture" group first). */
|
|
67
|
+
export function narrowOrder(groups, seen, { uncapped = false } = {}) {
|
|
68
|
+
const out = [];
|
|
69
|
+
const take = (p) => {
|
|
70
|
+
if (!out.includes(p)) out.push(p);
|
|
71
|
+
};
|
|
72
|
+
for (const s of seen || []) take(s.asset.path);
|
|
73
|
+
for (const g of groups || []) for (const a of groupShown(g, { uncapped })) take(a.path);
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/* client/v2/assets/spotlight.css — 2.0.4 (issue #191): an Assets tile, large (spotlight.jsx). Tokens only.
|
|
2
|
+
* Sits above the app like the shared dialogs (.gi-modal, z 9600): a scrim, then one window with the picture fitted to it. */
|
|
3
|
+
|
|
4
|
+
@layer shell {
|
|
5
|
+
.v2-spot {
|
|
6
|
+
position: fixed;
|
|
7
|
+
inset: 0;
|
|
8
|
+
z-index: 9600;
|
|
9
|
+
display: grid;
|
|
10
|
+
place-items: center;
|
|
11
|
+
padding: var(--space-5);
|
|
12
|
+
}
|
|
13
|
+
.v2-spot-scrim {
|
|
14
|
+
position: fixed;
|
|
15
|
+
inset: 0;
|
|
16
|
+
background: color-mix(in oklab, var(--bg-0) 78%, transparent);
|
|
17
|
+
}
|
|
18
|
+
.v2-spot-dialog {
|
|
19
|
+
position: relative;
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
width: min(1100px, 100%);
|
|
23
|
+
height: min(820px, 100%);
|
|
24
|
+
min-height: 0;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
background: var(--bg-2);
|
|
27
|
+
border-radius: var(--radius-xl);
|
|
28
|
+
box-shadow:
|
|
29
|
+
var(--shadow-lg),
|
|
30
|
+
inset 0 0 0 0.5px var(--island-edge);
|
|
31
|
+
animation: v2-spot-in var(--dur-route) var(--ease-out);
|
|
32
|
+
}
|
|
33
|
+
.v2-spot-dialog:focus {
|
|
34
|
+
outline: none;
|
|
35
|
+
}
|
|
36
|
+
@keyframes v2-spot-in {
|
|
37
|
+
from {
|
|
38
|
+
opacity: 0;
|
|
39
|
+
scale: 0.98;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
.v2-spot-head {
|
|
43
|
+
flex: none;
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
gap: var(--space-2);
|
|
47
|
+
padding: var(--space-2) var(--space-3);
|
|
48
|
+
}
|
|
49
|
+
.v2-spot-title {
|
|
50
|
+
flex: 1;
|
|
51
|
+
min-width: 0;
|
|
52
|
+
margin: 0;
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
text-overflow: ellipsis;
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
font-size: var(--type-md);
|
|
57
|
+
font-weight: var(--w-medium);
|
|
58
|
+
color: var(--fg-0);
|
|
59
|
+
}
|
|
60
|
+
.v2-spot-pos {
|
|
61
|
+
flex: none;
|
|
62
|
+
font-size: var(--type-xs);
|
|
63
|
+
color: var(--fg-2);
|
|
64
|
+
}
|
|
65
|
+
.v2-spot-stage {
|
|
66
|
+
flex: 1;
|
|
67
|
+
min-height: 0;
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
gap: var(--space-2);
|
|
72
|
+
padding: 0 var(--space-3);
|
|
73
|
+
background: var(--bg-1);
|
|
74
|
+
}
|
|
75
|
+
.v2-spot-img,
|
|
76
|
+
.v2-spot-video {
|
|
77
|
+
flex: 0 1 auto;
|
|
78
|
+
min-width: 0;
|
|
79
|
+
min-height: 0;
|
|
80
|
+
max-width: 100%;
|
|
81
|
+
max-height: 100%;
|
|
82
|
+
object-fit: contain;
|
|
83
|
+
border-radius: var(--radius-sm);
|
|
84
|
+
}
|
|
85
|
+
.v2-spot-sound,
|
|
86
|
+
.v2-spot-file {
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
align-items: center;
|
|
90
|
+
gap: var(--space-2);
|
|
91
|
+
max-width: 100%;
|
|
92
|
+
color: var(--fg-1);
|
|
93
|
+
text-align: center;
|
|
94
|
+
}
|
|
95
|
+
.v2-spot-file-n {
|
|
96
|
+
margin: 0;
|
|
97
|
+
max-width: 100%;
|
|
98
|
+
overflow-wrap: anywhere;
|
|
99
|
+
font-size: var(--type-md);
|
|
100
|
+
font-weight: var(--w-medium);
|
|
101
|
+
color: var(--fg-0);
|
|
102
|
+
}
|
|
103
|
+
.v2-spot-file-s {
|
|
104
|
+
margin: 0;
|
|
105
|
+
font-size: var(--type-sm);
|
|
106
|
+
color: var(--fg-2);
|
|
107
|
+
}
|
|
108
|
+
.v2-spot-nav {
|
|
109
|
+
flex: none;
|
|
110
|
+
}
|
|
111
|
+
.v2-spot-nav--prev svg {
|
|
112
|
+
rotate: 180deg;
|
|
113
|
+
}
|
|
114
|
+
.v2-spot-nav:disabled {
|
|
115
|
+
opacity: 0.35;
|
|
116
|
+
}
|
|
117
|
+
.v2-spot-foot {
|
|
118
|
+
flex: none;
|
|
119
|
+
display: flex;
|
|
120
|
+
align-items: center;
|
|
121
|
+
flex-wrap: wrap;
|
|
122
|
+
gap: var(--space-2) var(--space-3);
|
|
123
|
+
padding: var(--space-2) var(--space-3);
|
|
124
|
+
}
|
|
125
|
+
.v2-spot-meta {
|
|
126
|
+
flex: 1;
|
|
127
|
+
min-width: 0;
|
|
128
|
+
margin: 0;
|
|
129
|
+
display: flex;
|
|
130
|
+
gap: var(--space-2);
|
|
131
|
+
font-size: var(--type-xs);
|
|
132
|
+
color: var(--fg-2);
|
|
133
|
+
}
|
|
134
|
+
.v2-spot-path {
|
|
135
|
+
min-width: 0;
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
text-overflow: ellipsis;
|
|
138
|
+
white-space: nowrap;
|
|
139
|
+
}
|
|
140
|
+
.v2-spot-size {
|
|
141
|
+
flex: none;
|
|
142
|
+
}
|
|
143
|
+
.v2-spot-rows {
|
|
144
|
+
display: inline-flex;
|
|
145
|
+
gap: var(--space-2);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@media (prefers-reduced-motion: reduce) {
|
|
150
|
+
.v2-spot-dialog {
|
|
151
|
+
animation-duration: 1ms;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// client/v2/assets/spotlight.jsx — an Assets tile, large (2.0.4, issue #191; decision v2-204-asset-spotlight).
|
|
2
|
+
//
|
|
3
|
+
// A double-click on a tile (or Space on the picked one — the registry action `assets.spotlight`) opens its picture, clip or
|
|
4
|
+
// sound over the app. A picture fits the window, a clip plays with its controls, a sound plays too; anything else says its
|
|
5
|
+
// name and size. Under it: the file's name, path and size, and the rows the tile already offers. ← → walk the tiles the tab
|
|
6
|
+
// shows, esc or a click outside closes, and focus goes back to the tile. The window is modal: Tab stays inside it.
|
|
7
|
+
//
|
|
8
|
+
// `AssetSpotlight` is the pure render over the panel's state (spotlight-model.js holds the words and the order).
|
|
9
|
+
|
|
10
|
+
import { useId, useState } from 'react';
|
|
11
|
+
import { Kbd, StIcon } from '../../shell/icons.jsx';
|
|
12
|
+
import { portalToBody } from '../portal-scope.jsx';
|
|
13
|
+
import { useModalFocus } from '../shell/modal-focus.js';
|
|
14
|
+
import {
|
|
15
|
+
pathWords,
|
|
16
|
+
previewKind,
|
|
17
|
+
SPOTLIGHT_WORDS as W,
|
|
18
|
+
sizeLine,
|
|
19
|
+
stepIndex,
|
|
20
|
+
} from './spotlight-model.js';
|
|
21
|
+
|
|
22
|
+
/** The media for one asset. Keyed by path by the caller, so a step remounts it (a clip starts from its first frame). */
|
|
23
|
+
function Stage({ asset, url }) {
|
|
24
|
+
const kind = previewKind(asset);
|
|
25
|
+
const [broken, setBroken] = useState(false);
|
|
26
|
+
if (kind === 'image' && !broken)
|
|
27
|
+
return (
|
|
28
|
+
<img
|
|
29
|
+
className="v2-spot-img"
|
|
30
|
+
data-testid="spotlight-image"
|
|
31
|
+
src={url}
|
|
32
|
+
alt={asset.name}
|
|
33
|
+
draggable={false}
|
|
34
|
+
onError={() => setBroken(true)}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
if (kind === 'video' && !broken)
|
|
38
|
+
return (
|
|
39
|
+
// biome-ignore lint/a11y/useMediaCaption: the person's own footage; captions are a sidecar of the clip, not of the library
|
|
40
|
+
<video
|
|
41
|
+
className="v2-spot-video"
|
|
42
|
+
data-testid="spotlight-video"
|
|
43
|
+
src={url}
|
|
44
|
+
controls
|
|
45
|
+
playsInline
|
|
46
|
+
preload="metadata"
|
|
47
|
+
onError={() => setBroken(true)}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
if (kind === 'audio' && !broken)
|
|
51
|
+
return (
|
|
52
|
+
<div className="v2-spot-sound" data-testid="spotlight-sound">
|
|
53
|
+
<StIcon name="resolve" size={28} />
|
|
54
|
+
{/* biome-ignore lint/a11y/useMediaCaption: a sound has no captions to show */}
|
|
55
|
+
<audio src={url} controls preload="metadata" onError={() => setBroken(true)} />
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
// a font, or any file the window cannot draw: what it is, so the person knows it is the right one
|
|
59
|
+
return (
|
|
60
|
+
<div className="v2-spot-file" data-testid="spotlight-file">
|
|
61
|
+
<StIcon name="image" size={28} />
|
|
62
|
+
<p className="v2-spot-file-n">{asset.name}</p>
|
|
63
|
+
{sizeLine(asset) ? <p className="v2-spot-file-s">{sizeLine(asset)}</p> : null}
|
|
64
|
+
<p className="v2-spot-file-s">{broken ? W.failed : W.noPreview}</p>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {object} p
|
|
71
|
+
* @param {Array<{ path: string, name: string, kind: string, size?: number }>} p.items the tiles ← → walks, in the tab's order
|
|
72
|
+
* @param {number} p.index which one is showing
|
|
73
|
+
* @param {(path: string) => string} p.urlOf the SAME address the tile draws (main origin, read-only)
|
|
74
|
+
* @param {Array<{ id: string, label: string, keys?: string }>} [p.rows] the tile's own actions
|
|
75
|
+
* @param {(index: number) => void} p.onIndex
|
|
76
|
+
* @param {() => void} p.onClose esc, the close button and a click outside
|
|
77
|
+
* @param {(id: string) => void} [p.onRow]
|
|
78
|
+
*/
|
|
79
|
+
export function AssetSpotlight({ items, index, urlOf, rows = [], onIndex, onClose, onRow }) {
|
|
80
|
+
const titleId = useId();
|
|
81
|
+
const ref = useModalFocus({ onClose });
|
|
82
|
+
const asset = items[index];
|
|
83
|
+
if (!asset) return null;
|
|
84
|
+
const n = items.length;
|
|
85
|
+
const step = (delta) => {
|
|
86
|
+
const to = stepIndex(index, delta, n);
|
|
87
|
+
if (to !== index) onIndex(to);
|
|
88
|
+
};
|
|
89
|
+
const onKeyDown = (e) => {
|
|
90
|
+
if (e.defaultPrevented || e.metaKey || e.ctrlKey || e.altKey) return;
|
|
91
|
+
// a focused clip or sound keeps its own arrows (seek); everything else steps
|
|
92
|
+
if (e.target?.closest?.('video, audio, input, select, textarea')) return;
|
|
93
|
+
if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
|
|
94
|
+
e.preventDefault();
|
|
95
|
+
e.stopPropagation();
|
|
96
|
+
step(e.key === 'ArrowRight' ? 1 : -1);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const path = pathWords(asset);
|
|
100
|
+
const size = sizeLine(asset);
|
|
101
|
+
return portalToBody(
|
|
102
|
+
<div className="v2-spot" data-testid="asset-spotlight" data-asset={asset.path}>
|
|
103
|
+
<div
|
|
104
|
+
className="v2-spot-scrim"
|
|
105
|
+
data-testid="spotlight-scrim"
|
|
106
|
+
aria-hidden="true"
|
|
107
|
+
onClick={onClose}
|
|
108
|
+
/>
|
|
109
|
+
<div
|
|
110
|
+
ref={ref}
|
|
111
|
+
className="v2-spot-dialog"
|
|
112
|
+
role="dialog"
|
|
113
|
+
aria-modal="true"
|
|
114
|
+
aria-labelledby={titleId}
|
|
115
|
+
tabIndex={-1}
|
|
116
|
+
onKeyDown={onKeyDown}
|
|
117
|
+
>
|
|
118
|
+
<header className="v2-spot-head">
|
|
119
|
+
<h2 id={titleId} className="v2-spot-title" data-testid="spotlight-title">
|
|
120
|
+
{asset.name || W.fallbackName}
|
|
121
|
+
</h2>
|
|
122
|
+
<span className="v2-spot-pos" role="status" data-testid="spotlight-position">
|
|
123
|
+
{n > 1 ? W.position(index, n) : ''}
|
|
124
|
+
</span>
|
|
125
|
+
<button
|
|
126
|
+
type="button"
|
|
127
|
+
className="sh-iconbtn"
|
|
128
|
+
data-testid="spotlight-close"
|
|
129
|
+
aria-label={W.close}
|
|
130
|
+
onClick={onClose}
|
|
131
|
+
>
|
|
132
|
+
<StIcon name="x" size={14} />
|
|
133
|
+
</button>
|
|
134
|
+
</header>
|
|
135
|
+
{/* biome-ignore lint/a11y/noStaticElementInteractions lint/a11y/useKeyWithClickEvents: a click on the empty space is a pointer door; esc and the close button are the keyboard's */}
|
|
136
|
+
<div
|
|
137
|
+
className="v2-spot-stage"
|
|
138
|
+
data-testid="spotlight-stage"
|
|
139
|
+
onClick={(e) => {
|
|
140
|
+
// the empty space around the picture is "outside" too
|
|
141
|
+
if (e.target === e.currentTarget) onClose();
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
<button
|
|
145
|
+
type="button"
|
|
146
|
+
className="sh-iconbtn v2-spot-nav v2-spot-nav--prev"
|
|
147
|
+
data-testid="spotlight-prev"
|
|
148
|
+
aria-label={W.previous}
|
|
149
|
+
disabled={index <= 0}
|
|
150
|
+
title={index <= 0 ? W.atFirst : undefined}
|
|
151
|
+
onClick={() => step(-1)}
|
|
152
|
+
>
|
|
153
|
+
<StIcon name="chevron-right" size={16} />
|
|
154
|
+
</button>
|
|
155
|
+
<Stage key={asset.path} asset={asset} url={urlOf(asset.path)} />
|
|
156
|
+
<button
|
|
157
|
+
type="button"
|
|
158
|
+
className="sh-iconbtn v2-spot-nav"
|
|
159
|
+
data-testid="spotlight-next"
|
|
160
|
+
aria-label={W.next}
|
|
161
|
+
disabled={index >= n - 1}
|
|
162
|
+
title={index >= n - 1 ? W.atLast : undefined}
|
|
163
|
+
onClick={() => step(1)}
|
|
164
|
+
>
|
|
165
|
+
<StIcon name="chevron-right" size={16} />
|
|
166
|
+
</button>
|
|
167
|
+
</div>
|
|
168
|
+
<footer className="v2-spot-foot">
|
|
169
|
+
<p className="v2-spot-meta" data-testid="spotlight-meta">
|
|
170
|
+
<span className="v2-spot-path" data-testid="spotlight-path">
|
|
171
|
+
{path}
|
|
172
|
+
</span>
|
|
173
|
+
{size ? (
|
|
174
|
+
<span className="v2-spot-size" data-testid="spotlight-size">
|
|
175
|
+
{size}
|
|
176
|
+
</span>
|
|
177
|
+
) : null}
|
|
178
|
+
</p>
|
|
179
|
+
{rows.length ? (
|
|
180
|
+
<span className="v2-spot-rows">
|
|
181
|
+
{rows.map((r) => (
|
|
182
|
+
<button
|
|
183
|
+
key={r.id}
|
|
184
|
+
type="button"
|
|
185
|
+
className="btn btn--sm"
|
|
186
|
+
data-testid={`spotlight-row-${r.id}`}
|
|
187
|
+
onClick={() => onRow?.(r.id)}
|
|
188
|
+
>
|
|
189
|
+
{r.label}
|
|
190
|
+
{r.keys ? <Kbd>{r.keys}</Kbd> : null}
|
|
191
|
+
</button>
|
|
192
|
+
))}
|
|
193
|
+
</span>
|
|
194
|
+
) : null}
|
|
195
|
+
</footer>
|
|
196
|
+
</div>
|
|
197
|
+
</div>
|
|
198
|
+
);
|
|
199
|
+
}
|