@buffcore/admin-shell 0.8.43 → 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.
Files changed (157) hide show
  1. package/dist/components/Markdown.d.ts +9 -3
  2. package/dist/components/Markdown.js +84 -34
  3. package/dist/components/Sheet.d.ts +5 -1
  4. package/dist/components/Sheet.js +8 -2
  5. package/dist/components/TextArea.d.ts +3 -1
  6. package/dist/components/TextArea.js +3 -3
  7. package/dist/components/icons.d.ts +1 -0
  8. package/dist/components/icons.js +1 -0
  9. package/dist/workbench/app/ServedPrototype.d.ts +2 -0
  10. package/dist/workbench/app/ServedPrototype.js +11 -1
  11. package/dist/workbench/app/__snapshots__/places-dom.test.tsx.snap +30 -3
  12. package/dist/workbench/app/actions.d.ts +4 -2
  13. package/dist/workbench/app/actions.js +9 -4
  14. package/dist/workbench/app/brief-short.d.ts +14 -0
  15. package/dist/workbench/app/brief-short.js +103 -0
  16. package/dist/workbench/app/chat-session.d.ts +5 -5
  17. package/dist/workbench/app/chat-session.js +8 -3
  18. package/dist/workbench/app/chat.d.ts +17 -4
  19. package/dist/workbench/app/chat.js +9 -4
  20. package/dist/workbench/app/frame.js +5 -1
  21. package/dist/workbench/app/loop.js +2 -18
  22. package/dist/workbench/app/pages.js +10 -2
  23. package/dist/workbench/app/prototype.js +3 -0
  24. package/dist/workbench/app/test/loop-fixture.d.ts +13 -1
  25. package/dist/workbench/app/useStudio.d.ts +2 -1
  26. package/dist/workbench/studio/frame/AgentPanel.js +24 -1
  27. package/dist/workbench/studio/frame/Composer.js +13 -10
  28. package/dist/workbench/studio/frame/PanelList.js +1 -1
  29. package/dist/workbench/studio/frame/Segmented.d.ts +3 -1
  30. package/dist/workbench/studio/frame/Segmented.js +4 -3
  31. package/dist/workbench/studio/frame/SettingsSheet.js +10 -9
  32. package/dist/workbench/studio/frame/StudioFrame.js +7 -6
  33. package/dist/workbench/studio/frame/StudioRegions.js +4 -1
  34. package/dist/workbench/studio/frame/TurnControls.d.ts +2 -1
  35. package/dist/workbench/studio/frame/TurnControls.js +4 -1
  36. package/dist/workbench/studio/frame/layout.d.ts +2 -0
  37. package/dist/workbench/studio/frame/layout.js +2 -0
  38. package/dist/workbench/studio/frame/panelControls.d.ts +21 -1
  39. package/dist/workbench/studio/frame/scrollbars.d.ts +1 -0
  40. package/dist/workbench/studio/frame/scrollbars.js +12 -0
  41. package/dist/workbench/studio/frame/useTurnDraft.d.ts +22 -2
  42. package/dist/workbench/studio/frame/useTurnDraft.js +48 -16
  43. package/dist/workbench/studio/i18n/frame.en.d.ts +3 -0
  44. package/dist/workbench/studio/i18n/frame.en.js +4 -1
  45. package/dist/workbench/studio/i18n/frame.es.json +4 -1
  46. package/dist/workbench/studio/i18n/index.js +6 -0
  47. package/dist/workbench/studio/i18n/loop.en.d.ts +11 -38
  48. package/dist/workbench/studio/i18n/loop.en.js +11 -38
  49. package/dist/workbench/studio/i18n/loop.es.json +11 -38
  50. package/dist/workbench/studio/i18n/marks.en.d.ts +41 -0
  51. package/dist/workbench/studio/i18n/marks.en.js +42 -0
  52. package/dist/workbench/studio/i18n/marks.es.json +40 -0
  53. package/dist/workbench/studio/i18n/start.en.d.ts +5 -0
  54. package/dist/workbench/studio/i18n/start.en.js +7 -2
  55. package/dist/workbench/studio/i18n/start.es.json +7 -2
  56. package/dist/workbench/studio/i18n/workspace.en.d.ts +45 -0
  57. package/dist/workbench/studio/i18n/workspace.en.js +46 -0
  58. package/dist/workbench/studio/i18n/workspace.es.json +44 -0
  59. package/dist/workbench/studio/loop/BriefDocument.d.ts +9 -6
  60. package/dist/workbench/studio/loop/BriefDocument.js +48 -76
  61. package/dist/workbench/studio/loop/BriefLists.d.ts +11 -0
  62. package/dist/workbench/studio/loop/BriefLists.js +42 -0
  63. package/dist/workbench/studio/loop/BriefPage.d.ts +6 -2
  64. package/dist/workbench/studio/loop/BriefPage.js +32 -4
  65. package/dist/workbench/studio/loop/BriefReading.d.ts +19 -0
  66. package/dist/workbench/studio/loop/BriefReading.js +22 -0
  67. package/dist/workbench/studio/loop/BriefSection.d.ts +22 -0
  68. package/dist/workbench/studio/loop/BriefSection.js +47 -0
  69. package/dist/workbench/studio/loop/BriefWho.d.ts +6 -0
  70. package/dist/workbench/studio/loop/BriefWho.js +56 -0
  71. package/dist/workbench/studio/loop/CanvasBar.d.ts +0 -1
  72. package/dist/workbench/studio/loop/CanvasBar.js +2 -3
  73. package/dist/workbench/studio/loop/ConsoleFrame.d.ts +13 -0
  74. package/dist/workbench/studio/loop/ConsoleFrame.js +29 -0
  75. package/dist/workbench/studio/loop/NotThisCard.d.ts +6 -1
  76. package/dist/workbench/studio/loop/NotThisCard.js +28 -20
  77. package/dist/workbench/studio/loop/ProtoJourneys.d.ts +1 -8
  78. package/dist/workbench/studio/loop/ProtoJourneys.js +0 -14
  79. package/dist/workbench/studio/loop/PrototypeApp.d.ts +12 -1
  80. package/dist/workbench/studio/loop/PrototypeApp.js +30 -13
  81. package/dist/workbench/studio/loop/PrototypeAttempt.d.ts +2 -1
  82. package/dist/workbench/studio/loop/PrototypeAttempt.js +94 -29
  83. package/dist/workbench/studio/loop/PrototypePage.d.ts +4 -2
  84. package/dist/workbench/studio/loop/PrototypePage.js +25 -1
  85. package/dist/workbench/studio/loop/PrototypePreview.d.ts +35 -6
  86. package/dist/workbench/studio/loop/PrototypePreview.js +127 -76
  87. package/dist/workbench/studio/loop/PrototypePreviewSlot.d.ts +13 -0
  88. package/dist/workbench/studio/loop/PrototypePreviewSlot.js +23 -0
  89. package/dist/workbench/studio/loop/PrototypeScenes.d.ts +1 -1
  90. package/dist/workbench/studio/loop/ServedPlanning.js +1 -1
  91. package/dist/workbench/studio/loop/StudioLoop.d.ts +7 -2
  92. package/dist/workbench/studio/loop/StudioLoop.js +4 -10
  93. package/dist/workbench/studio/loop/WorkspaceBar.d.ts +15 -0
  94. package/dist/workbench/studio/loop/WorkspaceBar.js +52 -0
  95. package/dist/workbench/studio/loop/WorkspaceJourneys.d.ts +17 -0
  96. package/dist/workbench/studio/loop/WorkspaceJourneys.js +99 -0
  97. package/dist/workbench/studio/loop/WorkspaceLeft.d.ts +14 -0
  98. package/dist/workbench/studio/loop/WorkspaceLeft.js +42 -0
  99. package/dist/workbench/studio/loop/WorkspaceStage.d.ts +24 -0
  100. package/dist/workbench/studio/loop/WorkspaceStage.js +142 -0
  101. package/dist/workbench/studio/loop/WorkspaceSteps.d.ts +20 -0
  102. package/dist/workbench/studio/loop/WorkspaceSteps.js +96 -0
  103. package/dist/workbench/studio/loop/moments.js +0 -3
  104. package/dist/workbench/studio/loop/prototype-bridge.d.ts +8 -0
  105. package/dist/workbench/studio/loop/prototype-bridge.js +16 -0
  106. package/dist/workbench/studio/loop/prototype-document.d.ts +9 -0
  107. package/dist/workbench/studio/loop/prototype-document.js +90 -2
  108. package/dist/workbench/studio/loop/prototype-part.d.ts +43 -0
  109. package/dist/workbench/studio/loop/prototype-part.js +104 -0
  110. package/dist/workbench/studio/loop/types.d.ts +26 -26
  111. package/dist/workbench/studio/loop/types.js +0 -3
  112. package/dist/workbench/studio/loop/usePrototypeFrame.d.ts +6 -1
  113. package/dist/workbench/studio/loop/usePrototypeFrame.js +4 -0
  114. package/dist/workbench/studio/loop/workspace-journeys.d.ts +22 -0
  115. package/dist/workbench/studio/loop/workspace-journeys.js +63 -0
  116. package/dist/workbench/studio/loop/workspace-state.d.ts +94 -0
  117. package/dist/workbench/studio/loop/workspace-state.js +50 -0
  118. package/dist/workbench/studio/marks/ChangeList.d.ts +7 -0
  119. package/dist/workbench/studio/marks/ChangeList.js +70 -0
  120. package/dist/workbench/studio/marks/MarkHint.d.ts +18 -0
  121. package/dist/workbench/studio/marks/MarkHint.js +58 -0
  122. package/dist/workbench/studio/marks/MarkNumber.d.ts +6 -0
  123. package/dist/workbench/studio/marks/MarkNumber.js +24 -0
  124. package/dist/workbench/studio/marks/MarksLayer.d.ts +15 -0
  125. package/dist/workbench/studio/marks/MarksLayer.js +144 -0
  126. package/dist/workbench/studio/marks/PinNote.d.ts +13 -0
  127. package/dist/workbench/studio/marks/PinNote.js +49 -0
  128. package/dist/workbench/studio/marks/QueuedChanges.d.ts +6 -0
  129. package/dist/workbench/studio/marks/QueuedChanges.js +51 -0
  130. package/dist/workbench/studio/marks/WorkspaceMarks.d.ts +15 -0
  131. package/dist/workbench/studio/marks/WorkspaceMarks.js +67 -0
  132. package/dist/workbench/studio/marks/marks-message.d.ts +13 -0
  133. package/dist/workbench/studio/marks/marks-message.js +93 -0
  134. package/dist/workbench/studio/marks/marks.d.ts +105 -0
  135. package/dist/workbench/studio/marks/marks.js +133 -0
  136. package/dist/workbench/studio/marks/useMarking.d.ts +36 -0
  137. package/dist/workbench/studio/marks/useMarking.js +111 -0
  138. package/dist/workbench/studio/marks/useSendMarks.d.ts +18 -0
  139. package/dist/workbench/studio/marks/useSendMarks.js +80 -0
  140. package/dist/workbench/studio/types.d.ts +2 -0
  141. package/dist/workbench/studio/work/StudioLater.js +0 -1
  142. package/dist/workbench/studio/work/work-test-data.d.ts +6 -0
  143. package/package.json +6 -6
  144. package/dist/workbench/studio/loop/FsPlan.d.ts +0 -7
  145. package/dist/workbench/studio/loop/FsPlan.js +0 -64
  146. package/dist/workbench/studio/loop/FsStage.d.ts +0 -6
  147. package/dist/workbench/studio/loop/FsStage.js +0 -74
  148. package/dist/workbench/studio/loop/FsToolbar.d.ts +0 -6
  149. package/dist/workbench/studio/loop/FsToolbar.js +0 -61
  150. package/dist/workbench/studio/loop/FullScreen.d.ts +0 -5
  151. package/dist/workbench/studio/loop/FullScreen.js +0 -89
  152. package/dist/workbench/studio/loop/PrototypePreviewMenus.d.ts +0 -18
  153. package/dist/workbench/studio/loop/PrototypePreviewMenus.js +0 -75
  154. package/dist/workbench/studio/loop/PrototypePreviewToolbar.d.ts +0 -27
  155. package/dist/workbench/studio/loop/PrototypePreviewToolbar.js +0 -52
  156. package/dist/workbench/studio/loop/fsViews.d.ts +0 -12
  157. package/dist/workbench/studio/loop/fsViews.js +0 -6
@@ -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,6 @@
1
+ import type { IconName } from '../../../components/icons.ts';
2
+ import type { MarkKind } from './marks.ts';
3
+ export declare const KIND_ICON: Record<MarkKind, IconName>;
4
+ export declare function MarkNumber({ n }: {
5
+ n: number;
6
+ }): import("react").JSX.Element;
@@ -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
+ }
@@ -0,0 +1,6 @@
1
+ import type { MarksCard } from '../frame/panelControls.ts';
2
+ export declare function QueuedChanges({ card, agent, onUnqueue, }: {
3
+ card: MarksCard;
4
+ agent: string;
5
+ onUnqueue?: () => void;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // A message of marks waiting for the turn to end: one card that lists each mark with its note and
3
+ // place and the pictures that go with it, and the queue's own line (Edit, Back to the box).
4
+ import { useT } from '@buffcore/i18n/react';
5
+ import { Button } from '../../../components/Button.js';
6
+ import { Icon } from '../../../components/Icon.js';
7
+ import { captionText } from '../../../components/styles.js';
8
+ import { KIND_ICON, MarkNumber } from './MarkNumber.js';
9
+ import { markWhat, markWhere } from './marks-message.js';
10
+ const row = { display: 'flex', gap: 'var(--space-1)', alignItems: 'center' };
11
+ export function QueuedChanges({ card, agent, onUnqueue, }) {
12
+ const t = useT();
13
+ const title = t('studio.marks.queued.title', {
14
+ count: card.marks.length,
15
+ change: card.change,
16
+ version: card.version,
17
+ });
18
+ return (_jsxs("li", { "data-queued-marks": true, style: { display: 'grid', gap: 'var(--space-1)', justifyItems: 'end' }, children: [_jsxs("section", { "aria-label": title, style: {
19
+ marginInlineStart: 'var(--space-6)',
20
+ display: 'grid',
21
+ gap: 'var(--space-3)',
22
+ padding: 'var(--space-3)',
23
+ background: 'var(--surface-sunken)',
24
+ border: 'var(--border-width-hairline) dashed var(--border-default)',
25
+ borderRadius: 'var(--radius-panel)',
26
+ minWidth: 0,
27
+ justifySelf: 'stretch',
28
+ }, children: [_jsx("strong", { style: { color: 'var(--text-strong)', fontSize: 'var(--font-size-label)' }, children: title }), _jsx("ol", { style: {
29
+ listStyle: 'none',
30
+ margin: 0,
31
+ padding: 0,
32
+ display: 'grid',
33
+ gap: 'var(--space-2)',
34
+ }, children: card.marks.map((mark, i) => (_jsxs("li", { style: {
35
+ display: 'grid',
36
+ gridTemplateColumns: 'auto minmax(0, 1fr)',
37
+ gap: 'var(--space-2)',
38
+ }, children: [_jsx(MarkNumber, { n: i + 1 }), _jsxs("span", { style: { display: 'grid', minWidth: 0, overflowWrap: 'anywhere' }, children: [mark.note.trim() && (_jsx("span", { style: { fontSize: 'var(--font-size-label)', color: 'var(--text-body)' }, children: mark.note })), _jsxs("span", { style: { ...captionText, ...row }, children: [_jsx(Icon, { name: KIND_ICON[mark.kind], size: "var(--icon-sm)" }), markWhat(mark, t), " \u00B7 ", markWhere(mark, t)] })] })] }, mark.id))) }), _jsxs("span", { style: { ...captionText, ...row }, children: [_jsx(Icon, { name: "eye", size: "var(--icon-sm)" }), card.pictures
39
+ ? t('studio.marks.queued.pictures', { count: card.pictures })
40
+ : t('studio.marks.queued.noPictures')] })] }), _jsxs("span", { role: "status", style: {
41
+ ...captionText,
42
+ ...row,
43
+ flexWrap: 'wrap',
44
+ gap: 'var(--space-2)',
45
+ justifyContent: 'end',
46
+ }, children: [_jsx(Icon, { name: "clock", size: "var(--icon-sm)" }), t('studio.marks.queued.status', { agent }), _jsx(Button, { size: "sm", variant: "ghost", icon: "pencil", onClick: () => {
47
+ onUnqueue?.();
48
+ // The marks are listed again above the box: the first note takes the cursor.
49
+ requestAnimationFrame(() => document.querySelector('[data-change-list] textarea')?.focus());
50
+ }, children: t('studio.marks.queued.edit') }), _jsx(Button, { size: "sm", variant: "ghost", onClick: onUnqueue, children: t('studio.frame.turn.unqueue') })] })] }));
51
+ }
@@ -0,0 +1,15 @@
1
+ import { type WorkspaceSetup, type WorkspaceStage } from '../loop/workspace-state.tsx';
2
+ import { type MarkPlace, type MarksPage } from './marks.ts';
3
+ /** The place the stage shows now, as a mark records it. */
4
+ export declare function stagePlace(stage: WorkspaceStage, start: string): MarkPlace;
5
+ /** The marks layer over the stage's screen, for the sheet `sheet`; nothing outside the stage. */
6
+ export declare function MarksOverlay({ sheet }: {
7
+ sheet: string;
8
+ }): import("react").JSX.Element | null;
9
+ /**
10
+ * What marking gives the workspace for a page (a change's version on view): the overlay and the
11
+ * count of marks waiting, for the phone-wide foot bar's Changes. None without a version.
12
+ */
13
+ export declare function useWorkspaceMarks(page: (Pick<MarksPage, 'change' | 'locale' | 'shoot'> & {
14
+ version?: string;
15
+ }) | undefined): Pick<WorkspaceSetup, 'overlay' | 'changes'> | undefined;
@@ -0,0 +1,67 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Marking in the prototype workspace: the marks layer drawn over the device's screen (the
3
+ // workspace's overlay), the tool from the workspace's bar and keys, the place each mark is made on
4
+ // (the app, the device, the journey step or sample data shown), and showing a listed mark again.
5
+ import { useT } from '@buffcore/i18n/react';
6
+ import { useEffect, useMemo, useRef } from 'react';
7
+ import { pageMode } from '../frame/layout.js';
8
+ import { useWorkspace, useWorkspaceStage, } from '../loop/workspace-state.js';
9
+ import { useToolKeys } from './MarkHint.js';
10
+ import { MarksLayer } from './MarksLayer.js';
11
+ import { marks, useMarkSheet, useMarksPage, useShownMark, } from './marks.js';
12
+ /** The place the stage shows now, as a mark records it. */
13
+ export function stagePlace(stage, start) {
14
+ const { where } = stage;
15
+ const turned = stage.device === 'tablet' && stage.orientation === 'landscape';
16
+ return {
17
+ app: stage.app,
18
+ screen: where.screen || start,
19
+ device: stage.device,
20
+ ...(turned ? { orientation: 'landscape' } : {}),
21
+ ...(where.journey !== undefined ? { journey: where.journey, step: where.step ?? 0 } : {}),
22
+ ...(where.journey === undefined && where.data && where.data !== 'full'
23
+ ? { data: where.data }
24
+ : {}),
25
+ };
26
+ }
27
+ /** The marks layer over the stage's screen, for the sheet `sheet`; nothing outside the stage. */
28
+ export function MarksOverlay({ sheet }) {
29
+ const t = useT();
30
+ const stage = useWorkspaceStage();
31
+ const space = useWorkspace();
32
+ useToolKeys(space.setTool, space.app === 'console');
33
+ const screen = stage?.screen ?? null;
34
+ const frame = useMemo(() => ({ current: screen }), [screen]);
35
+ const shown = useShownMark();
36
+ const latest = useRef({ stage, space });
37
+ latest.current = { stage, space };
38
+ useEffect(() => {
39
+ if (!shown || shown.key !== sheet)
40
+ return;
41
+ const place = marks.sheet(sheet).marks.find((mark) => mark.id === shown.id)?.place;
42
+ if (!place)
43
+ return;
44
+ const { stage, space } = latest.current;
45
+ space.setApp(place.app ?? 'app');
46
+ if (place.app === 'console')
47
+ space.setConsole({ journey: place.journey, step: place.step ?? 0 });
48
+ else
49
+ stage?.show?.(place);
50
+ }, [shown, sheet]);
51
+ if (!stage)
52
+ return null;
53
+ return (_jsx(MarksLayer, { tool: stage.tool, sheet: sheet, place: stagePlace(stage, t('studio.marks.screen.start')), frame: frame, partAt: stage.app === 'app' ? stage.partAt : undefined }));
54
+ }
55
+ /**
56
+ * What marking gives the workspace for a page (a change's version on view): the overlay and the
57
+ * count of marks waiting, for the phone-wide foot bar's Changes. None without a version.
58
+ */
59
+ export function useWorkspaceMarks(page) {
60
+ const version = page?.version;
61
+ const key = page && version ? `${page.change}:${version}` : undefined;
62
+ const mode = pageMode() === 'dark' ? 'dark' : 'light';
63
+ useMarksPage(page && version && key ? { ...page, version, key, mode } : undefined);
64
+ const count = useMarkSheet(key).marks.length;
65
+ const overlay = useMemo(() => key && _jsx(MarksOverlay, { sheet: key }), [key]);
66
+ return useMemo(() => (key ? { overlay, changes: count } : undefined), [key, overlay, count]);
67
+ }
@@ -0,0 +1,13 @@
1
+ import type { T } from '@buffcore/i18n';
2
+ import type { Mark, MarkSheet } from './marks.ts';
3
+ /** What a mark is, for people: "Comment on Price", "Area", "Drawing". */
4
+ export declare function markWhat(mark: Mark, t: T): string;
5
+ /** Where a mark is, for people: "Plant detail · Desktop". */
6
+ export declare function markWhere(mark: Mark, t: T): string;
7
+ /** The marked screens, one picture each: a mark's screen and device, in the marks' order. */
8
+ export declare function markedScreens(list: readonly Mark[]): Mark[][];
9
+ export declare function marksMessage(sheet: MarkSheet, about: {
10
+ change: string;
11
+ version: string;
12
+ pictures: number;
13
+ }, t: T, locale: string): string;