@buffcore/admin-shell 0.8.44 → 0.8.45
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/dist/components/Markdown.d.ts +9 -3
- package/dist/components/Markdown.js +84 -34
- package/dist/components/Sheet.d.ts +5 -1
- package/dist/components/Sheet.js +8 -2
- package/dist/components/TextArea.d.ts +3 -1
- package/dist/components/TextArea.js +3 -3
- package/dist/components/icons.d.ts +1 -0
- package/dist/components/icons.js +1 -0
- package/dist/workbench/app/ServedPrototype.js +5 -0
- package/dist/workbench/app/__snapshots__/places-dom.test.tsx.snap +7 -7
- package/dist/workbench/app/actions.d.ts +4 -2
- package/dist/workbench/app/actions.js +9 -4
- package/dist/workbench/app/brief-short.d.ts +14 -0
- package/dist/workbench/app/brief-short.js +103 -0
- package/dist/workbench/app/chat-session.d.ts +3 -3
- package/dist/workbench/app/chat-session.js +8 -3
- package/dist/workbench/app/chat.d.ts +15 -2
- package/dist/workbench/app/chat.js +9 -4
- package/dist/workbench/app/loop.js +2 -18
- package/dist/workbench/app/prototype.js +3 -0
- package/dist/workbench/app/test/loop-fixture.d.ts +10 -0
- package/dist/workbench/app/useStudio.d.ts +2 -1
- package/dist/workbench/studio/frame/AgentPanel.js +24 -1
- package/dist/workbench/studio/frame/PanelList.js +1 -1
- package/dist/workbench/studio/frame/Segmented.d.ts +3 -1
- package/dist/workbench/studio/frame/Segmented.js +4 -3
- package/dist/workbench/studio/frame/StudioFrame.js +3 -3
- package/dist/workbench/studio/frame/StudioRegions.js +4 -1
- package/dist/workbench/studio/frame/TurnControls.d.ts +2 -1
- package/dist/workbench/studio/frame/TurnControls.js +4 -1
- package/dist/workbench/studio/frame/layout.d.ts +2 -0
- package/dist/workbench/studio/frame/layout.js +2 -0
- package/dist/workbench/studio/frame/panelControls.d.ts +21 -1
- package/dist/workbench/studio/frame/scrollbars.d.ts +1 -1
- package/dist/workbench/studio/frame/scrollbars.js +5 -3
- package/dist/workbench/studio/frame/useTurnDraft.d.ts +20 -2
- package/dist/workbench/studio/frame/useTurnDraft.js +39 -10
- package/dist/workbench/studio/i18n/index.js +6 -0
- package/dist/workbench/studio/i18n/loop.en.d.ts +11 -38
- package/dist/workbench/studio/i18n/loop.en.js +11 -38
- package/dist/workbench/studio/i18n/loop.es.json +11 -38
- package/dist/workbench/studio/i18n/marks.en.d.ts +41 -0
- package/dist/workbench/studio/i18n/marks.en.js +42 -0
- package/dist/workbench/studio/i18n/marks.es.json +40 -0
- package/dist/workbench/studio/i18n/start.en.d.ts +5 -0
- package/dist/workbench/studio/i18n/start.en.js +7 -2
- package/dist/workbench/studio/i18n/start.es.json +7 -2
- package/dist/workbench/studio/i18n/workspace.en.d.ts +45 -0
- package/dist/workbench/studio/i18n/workspace.en.js +46 -0
- package/dist/workbench/studio/i18n/workspace.es.json +44 -0
- package/dist/workbench/studio/loop/BriefDocument.d.ts +9 -6
- package/dist/workbench/studio/loop/BriefDocument.js +48 -76
- package/dist/workbench/studio/loop/BriefLists.d.ts +11 -0
- package/dist/workbench/studio/loop/BriefLists.js +42 -0
- package/dist/workbench/studio/loop/BriefPage.d.ts +6 -2
- package/dist/workbench/studio/loop/BriefPage.js +32 -4
- package/dist/workbench/studio/loop/BriefReading.d.ts +19 -0
- package/dist/workbench/studio/loop/BriefReading.js +22 -0
- package/dist/workbench/studio/loop/BriefSection.d.ts +22 -0
- package/dist/workbench/studio/loop/BriefSection.js +47 -0
- package/dist/workbench/studio/loop/BriefWho.d.ts +6 -0
- package/dist/workbench/studio/loop/BriefWho.js +56 -0
- package/dist/workbench/studio/loop/CanvasBar.d.ts +0 -1
- package/dist/workbench/studio/loop/CanvasBar.js +2 -3
- package/dist/workbench/studio/loop/ConsoleFrame.d.ts +13 -0
- package/dist/workbench/studio/loop/ConsoleFrame.js +29 -0
- package/dist/workbench/studio/loop/NotThisCard.d.ts +6 -1
- package/dist/workbench/studio/loop/NotThisCard.js +28 -20
- package/dist/workbench/studio/loop/ProtoJourneys.d.ts +1 -8
- package/dist/workbench/studio/loop/ProtoJourneys.js +0 -14
- package/dist/workbench/studio/loop/PrototypeApp.d.ts +3 -1
- package/dist/workbench/studio/loop/PrototypeApp.js +24 -9
- package/dist/workbench/studio/loop/PrototypeAttempt.js +55 -14
- package/dist/workbench/studio/loop/PrototypePage.d.ts +4 -2
- package/dist/workbench/studio/loop/PrototypePage.js +25 -1
- package/dist/workbench/studio/loop/PrototypePreview.d.ts +35 -6
- package/dist/workbench/studio/loop/PrototypePreview.js +126 -80
- package/dist/workbench/studio/loop/PrototypePreviewSlot.d.ts +13 -0
- package/dist/workbench/studio/loop/PrototypePreviewSlot.js +23 -0
- package/dist/workbench/studio/loop/PrototypeScenes.d.ts +1 -1
- package/dist/workbench/studio/loop/ServedPlanning.js +1 -1
- package/dist/workbench/studio/loop/StudioLoop.d.ts +7 -2
- package/dist/workbench/studio/loop/StudioLoop.js +4 -10
- package/dist/workbench/studio/loop/WorkspaceBar.d.ts +15 -0
- package/dist/workbench/studio/loop/WorkspaceBar.js +52 -0
- package/dist/workbench/studio/loop/WorkspaceJourneys.d.ts +17 -0
- package/dist/workbench/studio/loop/WorkspaceJourneys.js +99 -0
- package/dist/workbench/studio/loop/WorkspaceLeft.d.ts +14 -0
- package/dist/workbench/studio/loop/WorkspaceLeft.js +42 -0
- package/dist/workbench/studio/loop/WorkspaceStage.d.ts +24 -0
- package/dist/workbench/studio/loop/WorkspaceStage.js +142 -0
- package/dist/workbench/studio/loop/WorkspaceSteps.d.ts +20 -0
- package/dist/workbench/studio/loop/WorkspaceSteps.js +96 -0
- package/dist/workbench/studio/loop/moments.js +0 -3
- package/dist/workbench/studio/loop/prototype-document.d.ts +2 -0
- package/dist/workbench/studio/loop/prototype-document.js +12 -0
- package/dist/workbench/studio/loop/prototype-part.d.ts +43 -0
- package/dist/workbench/studio/loop/prototype-part.js +104 -0
- package/dist/workbench/studio/loop/types.d.ts +26 -26
- package/dist/workbench/studio/loop/types.js +0 -3
- package/dist/workbench/studio/loop/usePrototypeFrame.d.ts +3 -0
- package/dist/workbench/studio/loop/usePrototypeFrame.js +2 -0
- package/dist/workbench/studio/loop/workspace-journeys.d.ts +22 -0
- package/dist/workbench/studio/loop/workspace-journeys.js +63 -0
- package/dist/workbench/studio/loop/workspace-state.d.ts +94 -0
- package/dist/workbench/studio/loop/workspace-state.js +50 -0
- package/dist/workbench/studio/marks/ChangeList.d.ts +7 -0
- package/dist/workbench/studio/marks/ChangeList.js +70 -0
- package/dist/workbench/studio/marks/MarkHint.d.ts +18 -0
- package/dist/workbench/studio/marks/MarkHint.js +58 -0
- package/dist/workbench/studio/marks/MarkNumber.d.ts +6 -0
- package/dist/workbench/studio/marks/MarkNumber.js +24 -0
- package/dist/workbench/studio/marks/MarksLayer.d.ts +15 -0
- package/dist/workbench/studio/marks/MarksLayer.js +144 -0
- package/dist/workbench/studio/marks/PinNote.d.ts +13 -0
- package/dist/workbench/studio/marks/PinNote.js +49 -0
- package/dist/workbench/studio/marks/QueuedChanges.d.ts +6 -0
- package/dist/workbench/studio/marks/QueuedChanges.js +51 -0
- package/dist/workbench/studio/marks/WorkspaceMarks.d.ts +15 -0
- package/dist/workbench/studio/marks/WorkspaceMarks.js +67 -0
- package/dist/workbench/studio/marks/marks-message.d.ts +13 -0
- package/dist/workbench/studio/marks/marks-message.js +93 -0
- package/dist/workbench/studio/marks/marks.d.ts +105 -0
- package/dist/workbench/studio/marks/marks.js +133 -0
- package/dist/workbench/studio/marks/useMarking.d.ts +36 -0
- package/dist/workbench/studio/marks/useMarking.js +111 -0
- package/dist/workbench/studio/marks/useSendMarks.d.ts +18 -0
- package/dist/workbench/studio/marks/useSendMarks.js +80 -0
- package/dist/workbench/studio/work/StudioLater.js +0 -1
- package/dist/workbench/studio/work/work-test-data.d.ts +5 -0
- package/package.json +6 -6
- package/dist/workbench/studio/loop/FsPlan.d.ts +0 -7
- package/dist/workbench/studio/loop/FsPlan.js +0 -64
- package/dist/workbench/studio/loop/FsStage.d.ts +0 -6
- package/dist/workbench/studio/loop/FsStage.js +0 -74
- package/dist/workbench/studio/loop/FsToolbar.d.ts +0 -6
- package/dist/workbench/studio/loop/FsToolbar.js +0 -61
- package/dist/workbench/studio/loop/FullScreen.d.ts +0 -5
- package/dist/workbench/studio/loop/FullScreen.js +0 -89
- package/dist/workbench/studio/loop/PrototypePreviewMenus.d.ts +0 -18
- package/dist/workbench/studio/loop/PrototypePreviewMenus.js +0 -75
- package/dist/workbench/studio/loop/PrototypePreviewToolbar.d.ts +0 -27
- package/dist/workbench/studio/loop/PrototypePreviewToolbar.js +0 -52
- package/dist/workbench/studio/loop/fsViews.d.ts +0 -12
- package/dist/workbench/studio/loop/fsViews.js +0 -6
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const named = (planned, count) => Array.from({ length: count }, (_, i) => planned[i] ?? '');
|
|
2
|
+
/**
|
|
3
|
+
* Each planned app journey's match among the app's: by key first, across every plan row, then by
|
|
4
|
+
* title among the app's journeys no row took. One app journey is never two rows.
|
|
5
|
+
*/
|
|
6
|
+
function matches(roles, live) {
|
|
7
|
+
const rows = roles.flatMap((role) => (role.where === 'app' ? role.journeys : []));
|
|
8
|
+
const found = new Map();
|
|
9
|
+
const used = new Set();
|
|
10
|
+
const take = (row, by) => {
|
|
11
|
+
const entry = found.has(row) ? undefined : live.find((e) => !used.has(e.key) && by(e));
|
|
12
|
+
if (!entry)
|
|
13
|
+
return;
|
|
14
|
+
found.set(row, entry);
|
|
15
|
+
used.add(entry.key);
|
|
16
|
+
};
|
|
17
|
+
for (const row of rows)
|
|
18
|
+
take(row, (entry) => entry.key === row.id);
|
|
19
|
+
for (const row of rows)
|
|
20
|
+
take(row, (entry) => entry.title === row.name);
|
|
21
|
+
return { found, used };
|
|
22
|
+
}
|
|
23
|
+
export function workspaceGroups(roles, live) {
|
|
24
|
+
const { found, used } = matches(roles, live);
|
|
25
|
+
const planned = roles.map((role) => ({
|
|
26
|
+
role: role.role,
|
|
27
|
+
where: role.where,
|
|
28
|
+
journeys: role.journeys.map((journey) => {
|
|
29
|
+
const match = found.get(journey);
|
|
30
|
+
return {
|
|
31
|
+
id: journey.id,
|
|
32
|
+
name: journey.name,
|
|
33
|
+
where: role.where,
|
|
34
|
+
steps: named(journey.steps, match?.steps ?? journey.steps.length),
|
|
35
|
+
...(match ? { key: match.key } : {}),
|
|
36
|
+
};
|
|
37
|
+
}),
|
|
38
|
+
}));
|
|
39
|
+
const unplanned = new Map();
|
|
40
|
+
for (const entry of live) {
|
|
41
|
+
if (used.has(entry.key))
|
|
42
|
+
continue;
|
|
43
|
+
const list = unplanned.get(entry.role || undefined) ?? [];
|
|
44
|
+
list.push({
|
|
45
|
+
id: entry.key,
|
|
46
|
+
name: entry.title,
|
|
47
|
+
where: 'app',
|
|
48
|
+
steps: named([], entry.steps),
|
|
49
|
+
key: entry.key,
|
|
50
|
+
});
|
|
51
|
+
unplanned.set(entry.role || undefined, list);
|
|
52
|
+
}
|
|
53
|
+
const rest = Array.from(unplanned, ([role, journeys]) => ({ ...(role ? { role } : {}), where: 'app', journeys }));
|
|
54
|
+
// The customer app's groups first, then the console's, each in the plan's order.
|
|
55
|
+
return [...planned, ...rest]
|
|
56
|
+
.filter((group) => group.journeys.length > 0)
|
|
57
|
+
.sort((a, b) => Number(a.where === 'console') - Number(b.where === 'console'));
|
|
58
|
+
}
|
|
59
|
+
/** The journey the shown app has open: the app's playing one or one looked at, or the console's. */
|
|
60
|
+
export function openJourney(groups, where, id, key) {
|
|
61
|
+
const all = groups.flatMap((group) => group.journeys).filter((j) => j.where === where);
|
|
62
|
+
return (key ? all.find((j) => j.key === key) : undefined) ?? all.find((j) => j.id === id);
|
|
63
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { PrototypePart } from './prototype-part.ts';
|
|
3
|
+
import type { ProtoView } from './protoView.ts';
|
|
4
|
+
export type WorkspaceTool = 'select' | 'comment' | 'draw' | 'area';
|
|
5
|
+
export type WorkspaceApp = 'app' | 'console';
|
|
6
|
+
export declare const WORKSPACE_TOOLS: readonly WorkspaceTool[];
|
|
7
|
+
export type WorkspaceScreen = {
|
|
8
|
+
scene: string;
|
|
9
|
+
label: string;
|
|
10
|
+
};
|
|
11
|
+
/** What the page gives the workspace: where the console runs, the listed screens, the overlay. */
|
|
12
|
+
export interface WorkspaceSetup {
|
|
13
|
+
/** The console's own address (the stack's admin); none when it is not known. */
|
|
14
|
+
consoleUrl?: string;
|
|
15
|
+
/** The customer app's address, for its screens' links. */
|
|
16
|
+
appUrl?: string;
|
|
17
|
+
screens?: {
|
|
18
|
+
app: readonly WorkspaceScreen[];
|
|
19
|
+
console: readonly WorkspaceScreen[];
|
|
20
|
+
};
|
|
21
|
+
/** Drawn over the device's screen, in screen pixels (see `WorkspaceStage`). */
|
|
22
|
+
overlay?: ReactNode;
|
|
23
|
+
/** How many marks wait to be sent; the phone-wide foot bar's Changes shows it. */
|
|
24
|
+
changes?: number;
|
|
25
|
+
/** The tool, when the page holds it; otherwise the workspace keeps its own (Select first). */
|
|
26
|
+
tool?: WorkspaceTool;
|
|
27
|
+
onTool?: (tool: WorkspaceTool) => void;
|
|
28
|
+
/** What stands in for the live console (a drawn scene); none frames the console at its address. */
|
|
29
|
+
console?: ReactNode;
|
|
30
|
+
}
|
|
31
|
+
/** Where a workspace starts (a drawn scene's moment); a person starts on the customer app. */
|
|
32
|
+
export type WorkspaceStart = Partial<Pick<WorkspaceState, 'app' | 'tool' | 'console'>>;
|
|
33
|
+
export interface WorkspaceState {
|
|
34
|
+
app: WorkspaceApp;
|
|
35
|
+
tool: WorkspaceTool;
|
|
36
|
+
/** The console's open journey (a plan id) and its step from 0; the person follows it by hand. */
|
|
37
|
+
console: {
|
|
38
|
+
journey?: string;
|
|
39
|
+
step: number;
|
|
40
|
+
};
|
|
41
|
+
/** The console has been shown once, so its frame stays loaded from then on. */
|
|
42
|
+
consoleShown: boolean;
|
|
43
|
+
setup: WorkspaceSetup;
|
|
44
|
+
setApp: (app: WorkspaceApp) => void;
|
|
45
|
+
setTool: (tool: WorkspaceTool) => void;
|
|
46
|
+
setConsole: (console: {
|
|
47
|
+
journey?: string;
|
|
48
|
+
step: number;
|
|
49
|
+
}) => void;
|
|
50
|
+
}
|
|
51
|
+
/** Holds the workspace's choices for everything inside it (the page's preview). */
|
|
52
|
+
export declare function PrototypeWorkspace({ setup, start, children, }: {
|
|
53
|
+
setup: WorkspaceSetup;
|
|
54
|
+
start?: WorkspaceStart;
|
|
55
|
+
children: ReactNode;
|
|
56
|
+
}): import("react").JSX.Element;
|
|
57
|
+
/** The workspace's choices: the page's, or (a preview drawn on its own) a set of its own. */
|
|
58
|
+
export declare function useWorkspace(): WorkspaceState;
|
|
59
|
+
/**
|
|
60
|
+
* The device stage, for what draws over it (marking). `screen` is the element the shown app fills,
|
|
61
|
+
* at the device's own size in CSS pixels and drawn at `zoom` (1 on a phone-wide studio's bare
|
|
62
|
+
* screen); the overlay sits over it in screen pixels, so an app point is a screen point / zoom.
|
|
63
|
+
* The framed app is the `iframe` inside `screen`. `where` says what the shown app is showing.
|
|
64
|
+
*/
|
|
65
|
+
export interface WorkspaceStage {
|
|
66
|
+
tool: WorkspaceTool;
|
|
67
|
+
app: WorkspaceApp;
|
|
68
|
+
device: NonNullable<ProtoView['device']>;
|
|
69
|
+
orientation: NonNullable<ProtoView['orientation']>;
|
|
70
|
+
screen: HTMLElement | null;
|
|
71
|
+
zoom: number;
|
|
72
|
+
/** `data`: the sample data shown, when no journey plays on the customer app. */
|
|
73
|
+
where: {
|
|
74
|
+
journey?: string;
|
|
75
|
+
step?: number;
|
|
76
|
+
screen: string;
|
|
77
|
+
data?: string;
|
|
78
|
+
};
|
|
79
|
+
/** The running customer app's part at a point of its page (a name, a box, its scroll). */
|
|
80
|
+
partAt?: (x: number, y: number) => Promise<PrototypePart | undefined>;
|
|
81
|
+
/** Shows the customer app at this device, journey step or sample data again. */
|
|
82
|
+
show?: (place: StageShow) => void;
|
|
83
|
+
}
|
|
84
|
+
/** What `WorkspaceStage.show` takes: a marked place of the customer app. */
|
|
85
|
+
export interface StageShow {
|
|
86
|
+
device: NonNullable<ProtoView['device']>;
|
|
87
|
+
orientation?: 'landscape';
|
|
88
|
+
journey?: string;
|
|
89
|
+
step?: number;
|
|
90
|
+
data?: string;
|
|
91
|
+
}
|
|
92
|
+
export declare const WorkspaceStageContext: import("react").Context<WorkspaceStage | undefined>;
|
|
93
|
+
/** The stage while it is drawn; undefined outside it. */
|
|
94
|
+
export declare const useWorkspaceStage: () => WorkspaceStage | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// The prototype workspace's own choices: which app is shown, which tool a click uses, and where the
|
|
3
|
+
// console's journey is. They live above the framed app, so the app coming up or a step changing
|
|
4
|
+
// never resets them, and switching apps keeps each app's step.
|
|
5
|
+
//
|
|
6
|
+
// For marking (built on top of this): `useWorkspaceStage()` gives the chosen tool and the device's
|
|
7
|
+
// screen while the stage is drawn, and `WorkspaceSetup.overlay` is drawn over that screen.
|
|
8
|
+
import { createContext, useContext, useMemo, useState } from 'react';
|
|
9
|
+
export const WORKSPACE_TOOLS = ['select', 'comment', 'draw', 'area'];
|
|
10
|
+
const StateContext = createContext(undefined);
|
|
11
|
+
function useWorkspaceValue(setup, start = {}) {
|
|
12
|
+
const [app, setShown] = useState(start.app ?? 'app');
|
|
13
|
+
const [consoleShown, setConsoleShown] = useState(false);
|
|
14
|
+
const [ownTool, setOwnTool] = useState(start.tool ?? 'select');
|
|
15
|
+
const [console, setConsole] = useState(start.console ?? { step: 0 });
|
|
16
|
+
// Marking is on the customer app: the console is not pictured yet, so a click there selects.
|
|
17
|
+
const tool = app === 'console' ? 'select' : (setup.tool ?? ownTool);
|
|
18
|
+
const { onTool } = setup;
|
|
19
|
+
return useMemo(() => ({
|
|
20
|
+
app,
|
|
21
|
+
tool,
|
|
22
|
+
console,
|
|
23
|
+
consoleShown: consoleShown || app === 'console',
|
|
24
|
+
setup,
|
|
25
|
+
setApp: (next) => {
|
|
26
|
+
if (next === 'console')
|
|
27
|
+
setConsoleShown(true);
|
|
28
|
+
setShown(next);
|
|
29
|
+
},
|
|
30
|
+
setTool: (next) => {
|
|
31
|
+
setOwnTool(next);
|
|
32
|
+
onTool?.(next);
|
|
33
|
+
},
|
|
34
|
+
setConsole,
|
|
35
|
+
}), [app, tool, console, consoleShown, setup, onTool]);
|
|
36
|
+
}
|
|
37
|
+
/** Holds the workspace's choices for everything inside it (the page's preview). */
|
|
38
|
+
export function PrototypeWorkspace({ setup, start, children, }) {
|
|
39
|
+
const value = useWorkspaceValue(setup, start);
|
|
40
|
+
return _jsx(StateContext.Provider, { value: value, children: children });
|
|
41
|
+
}
|
|
42
|
+
const NO_SETUP = {};
|
|
43
|
+
/** The workspace's choices: the page's, or (a preview drawn on its own) a set of its own. */
|
|
44
|
+
export function useWorkspace() {
|
|
45
|
+
const own = useWorkspaceValue(NO_SETUP);
|
|
46
|
+
return useContext(StateContext) ?? own;
|
|
47
|
+
}
|
|
48
|
+
export const WorkspaceStageContext = createContext(undefined);
|
|
49
|
+
/** The stage while it is drawn; undefined outside it. */
|
|
50
|
+
export const useWorkspaceStage = () => useContext(WorkspaceStageContext);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ControlledAgent } from '../frame/panelControls.ts';
|
|
2
|
+
import { type MarkSheet, type MarksPage } from './marks.ts';
|
|
3
|
+
export declare function ChangeList({ agent, page, sheet, }: {
|
|
4
|
+
agent: ControlledAgent;
|
|
5
|
+
page: MarksPage;
|
|
6
|
+
sheet: MarkSheet;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The change list, riding on the chat's box while there are marks: every mark with its number,
|
|
3
|
+
// kind, screen and device (a click shows it), its note and Remove; Clear all; the box for anything
|
|
4
|
+
// else; and one Send that takes them all as one message.
|
|
5
|
+
import { useT } from '@buffcore/i18n/react';
|
|
6
|
+
import { Banner } from '../../../components/Banner.js';
|
|
7
|
+
import { Button } from '../../../components/Button.js';
|
|
8
|
+
import { Icon } from '../../../components/Icon.js';
|
|
9
|
+
import { IconButton } from '../../../components/IconButton.js';
|
|
10
|
+
import { captionText } from '../../../components/styles.js';
|
|
11
|
+
import { TextArea } from '../../../components/TextArea.js';
|
|
12
|
+
import { KIND_ICON, MarkNumber } from './MarkNumber.js';
|
|
13
|
+
import { marks } from './marks.js';
|
|
14
|
+
import { markWhat, markWhere } from './marks-message.js';
|
|
15
|
+
import { NOTE } from './PinNote.js';
|
|
16
|
+
import { useSendMarks } from './useSendMarks.js';
|
|
17
|
+
/** What the person says besides the marks: one message's words stay well inside its limit. */
|
|
18
|
+
const MORE = 2_000;
|
|
19
|
+
function MarkItem({ sheet, mark, n }) {
|
|
20
|
+
const t = useT();
|
|
21
|
+
return (_jsxs("li", { "data-mark": n, style: { display: 'grid', gap: 'var(--space-2)' }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 'var(--space-2)', minWidth: 0 }, children: [_jsx(MarkNumber, { n: n }), _jsx(Icon, { name: KIND_ICON[mark.kind], size: "var(--icon-sm)" }), _jsxs("button", { type: "button", "aria-label": t('studio.marks.mark.show', { n }), onClick: () => marks.show(sheet, mark.id), style: {
|
|
22
|
+
flex: 1,
|
|
23
|
+
minWidth: 0,
|
|
24
|
+
minBlockSize: 'var(--target)',
|
|
25
|
+
display: 'grid',
|
|
26
|
+
alignContent: 'center',
|
|
27
|
+
padding: 0,
|
|
28
|
+
border: 0,
|
|
29
|
+
background: 'transparent',
|
|
30
|
+
textAlign: 'start',
|
|
31
|
+
cursor: 'pointer',
|
|
32
|
+
fontFamily: 'var(--font-body)',
|
|
33
|
+
}, children: [_jsx("strong", { style: {
|
|
34
|
+
color: 'var(--text-strong)',
|
|
35
|
+
fontSize: 'var(--font-size-label)',
|
|
36
|
+
overflowWrap: 'anywhere',
|
|
37
|
+
}, children: markWhat(mark, t) }), _jsx("span", { style: captionText, children: markWhere(mark, t) })] }), _jsx(IconButton, { icon: "trash-2", size: "sm", label: t('studio.marks.mark.remove', { n }), onClick: () => marks.remove(sheet, mark.id) })] }), _jsx(TextArea, { label: t('studio.marks.mark.note', { n }), labelHidden: true, rows: 2, maxLength: NOTE, value: mark.note, onChange: (note) => marks.update(sheet, mark.id, { note }) })] }));
|
|
38
|
+
}
|
|
39
|
+
const tray = {
|
|
40
|
+
display: 'grid',
|
|
41
|
+
gridTemplateColumns: 'minmax(0, 1fr)',
|
|
42
|
+
gap: 'var(--space-3)',
|
|
43
|
+
minInlineSize: 0,
|
|
44
|
+
padding: 'var(--space-3) var(--space-4)',
|
|
45
|
+
borderBlockStart: 'var(--border-width-hairline) solid var(--border-hairline)',
|
|
46
|
+
background: 'var(--surface-page)',
|
|
47
|
+
overflowWrap: 'anywhere',
|
|
48
|
+
};
|
|
49
|
+
export function ChangeList({ agent, page, sheet, }) {
|
|
50
|
+
const t = useT();
|
|
51
|
+
const turn = agent.turn;
|
|
52
|
+
const { send, shooting, missing, ready } = useSendMarks(page, sheet, turn?.composer);
|
|
53
|
+
const why = turn?.blockingReason ?? (turn?.unready ? t('studio.frame.turn.agentNotReadyWhy') : '');
|
|
54
|
+
return (_jsxs("section", { "aria-label": t('studio.marks.changes.label'), "data-change-list": true, style: tray, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 'var(--space-2)' }, children: [_jsx("h2", { style: {
|
|
55
|
+
margin: 0,
|
|
56
|
+
flex: 1,
|
|
57
|
+
fontSize: 'var(--font-size-body)',
|
|
58
|
+
color: 'var(--text-strong)',
|
|
59
|
+
}, children: t('studio.marks.changes', { count: sheet.marks.length }) }), _jsx(Button, { size: "sm", variant: "ghost", onClick: () => marks.clear(page.key), children: t('studio.marks.clear') })] }), _jsx("p", { style: { ...captionText, margin: 0 }, children: t('studio.marks.changes.lead', { agent: agent.name }) }), _jsx("ol", { style: {
|
|
60
|
+
listStyle: 'none',
|
|
61
|
+
margin: 0,
|
|
62
|
+
padding: 0,
|
|
63
|
+
display: 'grid',
|
|
64
|
+
gap: 'var(--space-4)',
|
|
65
|
+
maxBlockSize: '40dvh',
|
|
66
|
+
overflow: 'auto',
|
|
67
|
+
}, children: sheet.marks.map((mark, i) => (_jsx(MarkItem, { sheet: page.key, mark: mark, n: i + 1 }, mark.id))) }), _jsx(TextArea, { label: t('studio.marks.more'), labelHidden: true, rows: 1, maxLength: MORE, placeholder: t('studio.marks.morePlaceholder'), value: sheet.more, onChange: (more) => marks.more(page.key, more) }), missing > 0 && (_jsx(Banner, { tone: "error", action: _jsx(Button, { size: "sm", variant: "secondary", disabled: !!why, onClick: () => void send(true), children: t('studio.marks.withoutPictures') }), children: t('studio.marks.shotFailed', { count: missing }) })), _jsx(Button, { icon: "send", fullWidth: true, loading: shooting, disabled: !ready || !!why, title: why || undefined, onClick: () => void send(), children: shooting
|
|
68
|
+
? t('studio.marks.shooting')
|
|
69
|
+
: t('studio.marks.send', { count: sheet.marks.length, agent: agent.name }) }), _jsx("p", { style: { ...captionText, margin: 0 }, children: why || t('studio.marks.sendNote', { agent: agent.name }) })] }));
|
|
70
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MarkTool } from './marks.ts';
|
|
2
|
+
export declare const TOOL_KEYS: Record<string, MarkTool>;
|
|
3
|
+
/**
|
|
4
|
+
* V, C, P and R choose a tool, and Escape goes back to Select, unless a field has the keys; none
|
|
5
|
+
* while the tools are `off` (the console), and Escape not while a dialog or sheet is open or
|
|
6
|
+
* something already took it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useToolKeys(onTool: (tool: MarkTool) => void, off?: boolean): void;
|
|
9
|
+
/**
|
|
10
|
+
* What the chosen tool does, as a chip that screen readers hear when it changes. On the console it
|
|
11
|
+
* says why there is no marking there: only the customer app is pictured for now.
|
|
12
|
+
*/
|
|
13
|
+
export declare function MarkHint({ tool, touch, console, }: {
|
|
14
|
+
tool: MarkTool;
|
|
15
|
+
/** A finger is the pointer: tap, not click. */
|
|
16
|
+
touch?: boolean;
|
|
17
|
+
console?: boolean;
|
|
18
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// The workspace's tools, from the keyboard (V, C, P, R and Escape), and the chip in the line above
|
|
3
|
+
// the device that says what a click does now. The workspace's bar holds the tool buttons.
|
|
4
|
+
import { useT } from '@buffcore/i18n/react';
|
|
5
|
+
import { useEffect } from 'react';
|
|
6
|
+
import { Chip } from '../../../components/Chip.js';
|
|
7
|
+
import { TOOL_ICON } from '../loop/WorkspaceBar.js';
|
|
8
|
+
export const TOOL_KEYS = {
|
|
9
|
+
v: 'select',
|
|
10
|
+
c: 'comment',
|
|
11
|
+
p: 'draw',
|
|
12
|
+
r: 'area',
|
|
13
|
+
};
|
|
14
|
+
/** An open dialog or sheet: Escape is its own (it closes), never the tools'. */
|
|
15
|
+
const DIALOG = 'dialog[open], [role="dialog"], [role="alertdialog"]';
|
|
16
|
+
/**
|
|
17
|
+
* V, C, P and R choose a tool, and Escape goes back to Select, unless a field has the keys; none
|
|
18
|
+
* while the tools are `off` (the console), and Escape not while a dialog or sheet is open or
|
|
19
|
+
* something already took it.
|
|
20
|
+
*/
|
|
21
|
+
export function useToolKeys(onTool, off = false) {
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (off)
|
|
24
|
+
return;
|
|
25
|
+
const keys = (event) => {
|
|
26
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
27
|
+
if (event.metaKey || event.ctrlKey || event.altKey || event.isComposing)
|
|
28
|
+
return;
|
|
29
|
+
if (target?.closest('input, textarea, select, [contenteditable="true"]'))
|
|
30
|
+
return;
|
|
31
|
+
if (event.key === 'Escape') {
|
|
32
|
+
if (event.defaultPrevented || document.querySelector(DIALOG))
|
|
33
|
+
return;
|
|
34
|
+
return onTool('select');
|
|
35
|
+
}
|
|
36
|
+
const chosen = TOOL_KEYS[event.key.toLowerCase()];
|
|
37
|
+
if (chosen)
|
|
38
|
+
onTool(chosen);
|
|
39
|
+
};
|
|
40
|
+
window.addEventListener('keydown', keys);
|
|
41
|
+
return () => window.removeEventListener('keydown', keys);
|
|
42
|
+
}, [onTool, off]);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* What the chosen tool does, as a chip that screen readers hear when it changes. On the console it
|
|
46
|
+
* says why there is no marking there: only the customer app is pictured for now.
|
|
47
|
+
*/
|
|
48
|
+
export function MarkHint({ tool, touch, console, }) {
|
|
49
|
+
const t = useT();
|
|
50
|
+
const words = console
|
|
51
|
+
? 'studio.workspace.hint.console'
|
|
52
|
+
: touch && tool === 'comment'
|
|
53
|
+
? 'studio.workspace.hint.tap'
|
|
54
|
+
: `studio.workspace.hint.${tool}`;
|
|
55
|
+
return (_jsx("span", { role: "status", "data-mark-hint": console ? 'console' : tool, style: { display: 'contents' }, children: _jsx(Chip, { size: "sm", tone: tool === 'select' || console ? 'neutral' : 'info', icon: TOOL_ICON[console ? 'select' : tool],
|
|
56
|
+
// Long words (the console's reason, another language) wrap at phone width.
|
|
57
|
+
style: { whiteSpace: 'normal', maxInlineSize: '100%', overflowWrap: 'anywhere' }, children: t(words) }) }));
|
|
58
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const KIND_ICON = {
|
|
3
|
+
comment: 'message-square',
|
|
4
|
+
area: 'layers',
|
|
5
|
+
draw: 'pencil',
|
|
6
|
+
};
|
|
7
|
+
export function MarkNumber({ n }) {
|
|
8
|
+
return (_jsx("span", { "aria-hidden": "true", style: {
|
|
9
|
+
flex: 'none',
|
|
10
|
+
width: 'var(--space-6)',
|
|
11
|
+
height: 'var(--space-6)',
|
|
12
|
+
boxSizing: 'border-box',
|
|
13
|
+
borderRadius: 'var(--radius-pill)',
|
|
14
|
+
background: 'var(--info-solid)',
|
|
15
|
+
color: 'var(--info-on-solid)',
|
|
16
|
+
border: 'var(--border-width-hairline) solid var(--surface-panel)',
|
|
17
|
+
display: 'inline-flex',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
justifyContent: 'center',
|
|
20
|
+
fontSize: 'var(--font-size-caption)',
|
|
21
|
+
fontWeight: 'var(--weight-bold)',
|
|
22
|
+
lineHeight: 1,
|
|
23
|
+
}, children: n }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import type { PrototypePart } from '../loop/prototype-part.ts';
|
|
3
|
+
import { type MarkPlace, type MarkTool } from './marks.ts';
|
|
4
|
+
export interface MarksLayerProps {
|
|
5
|
+
tool: MarkTool;
|
|
6
|
+
/** The sheet the marks go in: one per change and version. */
|
|
7
|
+
sheet: string;
|
|
8
|
+
/** The screen and device on view now. */
|
|
9
|
+
place: MarkPlace;
|
|
10
|
+
/** The framed app the layer lies over (it may be zoomed; the layer follows). */
|
|
11
|
+
frame: RefObject<HTMLElement | null>;
|
|
12
|
+
/** The bridge's "part at this point"; without it a comment is on "this spot". */
|
|
13
|
+
partAt?: (x: number, y: number) => Promise<PrototypePart | undefined>;
|
|
14
|
+
}
|
|
15
|
+
export declare function MarksLayer({ tool, sheet, place, frame, partAt }: MarksLayerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The marks layer: over the framed app, the chosen tool pins a numbered comment on a part (the app
|
|
3
|
+
// says which: "Comment on Price"), drags a dashed area or draws freehand. Only the marks made on
|
|
4
|
+
// this screen and device are drawn; all of them stay in the sheet until they are sent.
|
|
5
|
+
import { useT } from '@buffcore/i18n/react';
|
|
6
|
+
import { useRef, useState } from 'react';
|
|
7
|
+
import { MarkNumber } from './MarkNumber.js';
|
|
8
|
+
import { MARKS, marks, samePlace, useMarkSheet, } from './marks.js';
|
|
9
|
+
import { markWhat } from './marks-message.js';
|
|
10
|
+
import { PinNote } from './PinNote.js';
|
|
11
|
+
import { draftBox, useFrameGeometry, useMarkingPointer, } from './useMarking.js';
|
|
12
|
+
const stroke = {
|
|
13
|
+
fill: 'none',
|
|
14
|
+
stroke: 'var(--info-solid)',
|
|
15
|
+
strokeWidth: 2,
|
|
16
|
+
strokeLinecap: 'round',
|
|
17
|
+
strokeLinejoin: 'round',
|
|
18
|
+
};
|
|
19
|
+
function Shape({ kind, box, points }) {
|
|
20
|
+
if (kind === 'area' && box)
|
|
21
|
+
return (_jsx("rect", { x: box.x, y: box.y, width: box.w, height: box.h, rx: 4, vectorEffect: "non-scaling-stroke", style: { ...stroke, strokeDasharray: '6 4' } }));
|
|
22
|
+
if (kind === 'draw' && points)
|
|
23
|
+
return (_jsx("polyline", { points: points.map(([x, y]) => `${x},${y}`).join(' '), vectorEffect: "non-scaling-stroke", style: { ...stroke, strokeWidth: 3 } }));
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
/** Where a mark's number sits, in app px: a comment's point, an area's corner, a drawing's start. */
|
|
27
|
+
function anchor(mark) {
|
|
28
|
+
const first = mark.points?.[0];
|
|
29
|
+
return mark.box ? { x: mark.box.x, y: mark.box.y } : { x: first?.[0] ?? 0, y: first?.[1] ?? 0 };
|
|
30
|
+
}
|
|
31
|
+
const toLayer = (g, point) => ({
|
|
32
|
+
x: g.x + point.x * g.scale,
|
|
33
|
+
y: g.y + point.y * g.scale,
|
|
34
|
+
});
|
|
35
|
+
export function MarksLayer({ tool, sheet, place, frame, partAt }) {
|
|
36
|
+
const t = useT();
|
|
37
|
+
const layer = useRef(null);
|
|
38
|
+
const geometry = useFrameGeometry(layer, frame);
|
|
39
|
+
const all = useMarkSheet(sheet).marks;
|
|
40
|
+
const [open, setOpen] = useState();
|
|
41
|
+
const add = (shape) => {
|
|
42
|
+
if (!geometry)
|
|
43
|
+
return;
|
|
44
|
+
const view = { width: Math.round(geometry.width), height: Math.round(geometry.height) };
|
|
45
|
+
const id = marks.add(sheet, { ...shape, note: '', place, view });
|
|
46
|
+
if (id === undefined)
|
|
47
|
+
return;
|
|
48
|
+
if (shape.kind === 'comment')
|
|
49
|
+
setOpen(id);
|
|
50
|
+
// The app says which part is there (a comment's name) and how far it is scrolled (every mark).
|
|
51
|
+
const at = anchor(shape);
|
|
52
|
+
const answer = partAt?.(at.x, at.y);
|
|
53
|
+
if (answer)
|
|
54
|
+
marks.asked(id, answer);
|
|
55
|
+
void answer?.then((part) => {
|
|
56
|
+
const name = shape.kind === 'comment' && part?.name ? { part: part.name } : {};
|
|
57
|
+
if (part)
|
|
58
|
+
marks.update(sheet, id, { ...name, ...(part.scroll ? { scroll: part.scroll } : {}) });
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const { draft, handlers } = useMarkingPointer(tool, geometry, layer, add);
|
|
62
|
+
const here = all
|
|
63
|
+
.map((mark, i) => ({ mark, n: i + 1 }))
|
|
64
|
+
.filter(({ mark }) => samePlace(mark.place, place));
|
|
65
|
+
const opened = here.find(({ mark }) => mark.id === open);
|
|
66
|
+
const marking = tool !== 'select';
|
|
67
|
+
const full = marking && all.length >= MARKS;
|
|
68
|
+
return (_jsxs("div", { ref: layer, dir: "ltr", "data-marks-layer": tool, ...(marking ? handlers : {}), style: {
|
|
69
|
+
position: 'absolute',
|
|
70
|
+
inset: 0,
|
|
71
|
+
overflow: 'hidden',
|
|
72
|
+
pointerEvents: marking ? 'auto' : 'none',
|
|
73
|
+
cursor: marking ? 'crosshair' : undefined,
|
|
74
|
+
touchAction: marking ? 'none' : undefined,
|
|
75
|
+
zIndex: 1,
|
|
76
|
+
}, children: [geometry && (_jsxs("svg", { "aria-hidden": "true", viewBox: `0 0 ${geometry.width} ${geometry.height}`, style: {
|
|
77
|
+
position: 'absolute',
|
|
78
|
+
insetBlockStart: 0,
|
|
79
|
+
insetInlineStart: 0,
|
|
80
|
+
inlineSize: geometry.width * geometry.scale,
|
|
81
|
+
blockSize: geometry.height * geometry.scale,
|
|
82
|
+
transform: `translate(${geometry.x}px, ${geometry.y}px)`,
|
|
83
|
+
overflow: 'visible',
|
|
84
|
+
}, children: [here.map(({ mark }) => (_jsx(Shape, { ...mark }, mark.id))), draft && (_jsx(Shape, { kind: draft.kind, points: draft.points, box: draft.kind === 'area' ? draftBox(draft.points) : undefined }))] })), geometry && (_jsx("ol", { "aria-label": t('studio.marks.layer'), style: { listStyle: 'none', margin: 0, padding: 0 }, children: here.map(({ mark, n }) => {
|
|
85
|
+
const at = toLayer(geometry, anchor(mark));
|
|
86
|
+
return (_jsx("li", { children: _jsx("button", { type: "button", "aria-label": t('studio.marks.mark.open', { n, what: markWhat(mark, t) }), "aria-expanded": open === mark.id, onPointerDown: (event) => event.stopPropagation(), onClick: () => setOpen(open === mark.id ? undefined : mark.id), style: {
|
|
87
|
+
position: 'absolute',
|
|
88
|
+
insetBlockStart: 0,
|
|
89
|
+
insetInlineStart: 0,
|
|
90
|
+
transform: `translate(calc(${at.x}px - var(--target) / 2), calc(${at.y}px - var(--target) / 2))`,
|
|
91
|
+
inlineSize: 'var(--target)',
|
|
92
|
+
blockSize: 'var(--target)',
|
|
93
|
+
padding: 0,
|
|
94
|
+
border: 0,
|
|
95
|
+
background: 'transparent',
|
|
96
|
+
display: 'grid',
|
|
97
|
+
placeItems: 'center',
|
|
98
|
+
cursor: 'pointer',
|
|
99
|
+
pointerEvents: 'auto',
|
|
100
|
+
}, children: _jsx(MarkNumber, { n: n }) }) }, mark.id));
|
|
101
|
+
}) })), full && (_jsx("p", { role: "status", style: {
|
|
102
|
+
position: 'absolute',
|
|
103
|
+
insetBlockStart: 'var(--space-2)',
|
|
104
|
+
insetInlineStart: 'var(--space-2)',
|
|
105
|
+
insetInlineEnd: 'var(--space-2)',
|
|
106
|
+
margin: 0,
|
|
107
|
+
padding: 'var(--space-2) var(--space-3)',
|
|
108
|
+
background: 'var(--attention-tint)',
|
|
109
|
+
color: 'var(--attention-ink)',
|
|
110
|
+
border: 'var(--border-width-hairline) solid var(--attention-border)',
|
|
111
|
+
borderRadius: 'var(--radius-panel)',
|
|
112
|
+
fontSize: 'var(--font-size-caption)',
|
|
113
|
+
}, children: t('studio.marks.full') })), geometry && opened && (_jsx(PinNote, { sheet: sheet, mark: opened.mark, n: opened.n, at: noteAt(geometry, anchor(opened.mark), layer.current, here
|
|
114
|
+
.filter(({ mark }) => mark.id !== opened.mark.id)
|
|
115
|
+
.map(({ mark }) => toLayer(geometry, anchor(mark)))), onClose: () => setOpen(undefined) }))] }));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The note box beside its number, never over it: to its right, its left, under it or over it,
|
|
119
|
+
* the first with room that covers the fewest other marks' numbers, kept inside the layer.
|
|
120
|
+
*/
|
|
121
|
+
function noteAt(g, point, layer, others = []) {
|
|
122
|
+
const at = toLayer(g, point);
|
|
123
|
+
const width = layer?.clientWidth ?? 0;
|
|
124
|
+
const height = layer?.clientHeight ?? 0;
|
|
125
|
+
const box = Math.min(320, width - 16);
|
|
126
|
+
const tall = 200;
|
|
127
|
+
const clampX = (x) => Math.max(8, Math.min(x, width - box - 8));
|
|
128
|
+
const clampY = (y) => Math.max(8, Math.min(y, height - tall));
|
|
129
|
+
const sides = [
|
|
130
|
+
{ fits: at.x + 24 + box <= width - 8, x: at.x + 24, y: clampY(at.y - 12) },
|
|
131
|
+
{ fits: at.x - 24 - box >= 8, x: at.x - 24 - box, y: clampY(at.y - 12) },
|
|
132
|
+
{ fits: at.y + 28 + tall <= height, x: clampX(at.x - box / 2), y: at.y + 28 },
|
|
133
|
+
{ fits: at.y - 28 - tall >= 8, x: clampX(at.x - box / 2), y: at.y - 28 - tall },
|
|
134
|
+
].filter((side) => side.fits);
|
|
135
|
+
// A number is half a touch target wide each way (about 22 px).
|
|
136
|
+
const covers = (side) => others.filter((o) => o.x > side.x - 22 &&
|
|
137
|
+
o.x < side.x + box + 22 &&
|
|
138
|
+
o.y > side.y - 22 &&
|
|
139
|
+
o.y < side.y + tall + 22).length;
|
|
140
|
+
const best = sides.reduce((found, side) => (!found || covers(side) < covers(found) ? side : found), undefined);
|
|
141
|
+
if (best)
|
|
142
|
+
return { x: best.x, y: best.y };
|
|
143
|
+
return { x: clampX(at.x - box / 2), y: Math.max(8, at.y - 28 - tall) };
|
|
144
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Mark } from './marks.ts';
|
|
2
|
+
export declare const NOTE = 400;
|
|
3
|
+
export declare function PinNote({ sheet, mark, n, at, onClose, }: {
|
|
4
|
+
sheet: string;
|
|
5
|
+
mark: Mark;
|
|
6
|
+
n: number;
|
|
7
|
+
/** Where the box goes in the layer, in layer px. */
|
|
8
|
+
at: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The note box beside a mark on the screen: what it is ("Comment on Price"), its note, Remove and
|
|
3
|
+
// Done. The same note is the one in the change list.
|
|
4
|
+
import { isRtl } from '@buffcore/i18n';
|
|
5
|
+
import { useLocale, useT } from '@buffcore/i18n/react';
|
|
6
|
+
import { Button } from '../../../components/Button.js';
|
|
7
|
+
import { IconButton } from '../../../components/IconButton.js';
|
|
8
|
+
import { TextArea } from '../../../components/TextArea.js';
|
|
9
|
+
import { MarkNumber } from './MarkNumber.js';
|
|
10
|
+
import { marks } from './marks.js';
|
|
11
|
+
import { markWhat } from './marks-message.js';
|
|
12
|
+
export const NOTE = 400;
|
|
13
|
+
export function PinNote({ sheet, mark, n, at, onClose, }) {
|
|
14
|
+
const t = useT();
|
|
15
|
+
const { locale } = useLocale();
|
|
16
|
+
return (_jsxs("section", { dir: isRtl(locale) ? 'rtl' : 'ltr', "aria-label": t('studio.marks.mark.open', { n, what: markWhat(mark, t) }), onPointerDown: (event) => event.stopPropagation(), onKeyDown: (event) => {
|
|
17
|
+
if (event.key !== 'Escape')
|
|
18
|
+
return;
|
|
19
|
+
// The note takes Escape: it closes, and the tool stays.
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
onClose();
|
|
22
|
+
}, style: {
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
insetBlockStart: 0,
|
|
25
|
+
insetInlineStart: 0,
|
|
26
|
+
transform: `translate(${at.x}px, ${at.y}px)`,
|
|
27
|
+
inlineSize: 'min(20rem, calc(100% - var(--space-4)))',
|
|
28
|
+
boxSizing: 'border-box',
|
|
29
|
+
display: 'grid',
|
|
30
|
+
gap: 'var(--space-3)',
|
|
31
|
+
padding: 'var(--space-3)',
|
|
32
|
+
background: 'var(--surface-overlay)',
|
|
33
|
+
border: 'var(--border-width-hairline) solid var(--border-default)',
|
|
34
|
+
borderRadius: 'var(--radius-panel)',
|
|
35
|
+
boxShadow: 'var(--shadow-overlay)',
|
|
36
|
+
pointerEvents: 'auto',
|
|
37
|
+
cursor: 'auto',
|
|
38
|
+
zIndex: 2,
|
|
39
|
+
}, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 'var(--space-2)', minWidth: 0 }, children: [_jsx(MarkNumber, { n: n }), _jsx("strong", { style: {
|
|
40
|
+
flex: 1,
|
|
41
|
+
minWidth: 0,
|
|
42
|
+
color: 'var(--text-strong)',
|
|
43
|
+
fontSize: 'var(--font-size-label)',
|
|
44
|
+
overflowWrap: 'anywhere',
|
|
45
|
+
}, children: markWhat(mark, t) }), _jsx(IconButton, { icon: "trash-2", size: "sm", label: t('studio.marks.mark.remove', { n }), onClick: () => {
|
|
46
|
+
marks.remove(sheet, mark.id);
|
|
47
|
+
onClose();
|
|
48
|
+
} })] }), _jsx(TextArea, { label: t('studio.marks.mark.note', { n }), labelHidden: true, autoFocus: true, rows: 2, maxLength: NOTE, value: mark.note, onChange: (note) => marks.update(sheet, mark.id, { note }) }), _jsx(Button, { size: "sm", variant: "secondary", style: { justifySelf: 'end' }, onClick: onClose, children: t('studio.marks.pin.done') })] }));
|
|
49
|
+
}
|