@sixb/app 0.2.3 → 0.2.4
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/agent/activity-label.d.ts.map +1 -1
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/background/background-tool-row.d.ts.map +1 -1
- package/dist/agent/background/interpret.d.ts +1 -1
- package/dist/agent/background/interpret.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts +4 -1
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/message-parts.d.ts.map +1 -1
- package/dist/agent/components/transcript.d.ts +5 -0
- package/dist/agent/components/transcript.d.ts.map +1 -1
- package/dist/agent/delegation/agent-exchange.d.ts +16 -0
- package/dist/agent/delegation/agent-exchange.d.ts.map +1 -0
- package/dist/agent/delegation/child-card.d.ts +3 -3
- package/dist/agent/delegation/child-card.d.ts.map +1 -1
- package/dist/agent/delegation/child-parts.d.ts +1 -10
- package/dist/agent/delegation/child-parts.d.ts.map +1 -1
- package/dist/agent/delegation/child-work.d.ts.map +1 -1
- package/dist/agent/delegation/interpret.d.ts +4 -10
- package/dist/agent/delegation/interpret.d.ts.map +1 -1
- package/dist/agent/file-edits/file-edit-tool-view.d.ts +10 -0
- package/dist/agent/file-edits/file-edit-tool-view.d.ts.map +1 -0
- package/dist/agent/file-edits/interpret.d.ts +25 -0
- package/dist/agent/file-edits/interpret.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +6 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +46 -5
- package/dist/agent/i18n/en.d.ts.map +1 -1
- package/dist/agent/i18n/fr.d.ts.map +1 -1
- package/dist/agent/i18n/index.d.ts +76 -8
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/message-agent/interpret.d.ts +2 -2
- package/dist/agent/message-agent/interpret.d.ts.map +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
- package/dist/agent/questions/interpret.d.ts +31 -0
- package/dist/agent/questions/interpret.d.ts.map +1 -0
- package/dist/agent/questions/question-card.d.ts +16 -0
- package/dist/agent/questions/question-card.d.ts.map +1 -0
- package/dist/agent/questions/question-composer.d.ts +15 -0
- package/dist/agent/questions/question-composer.d.ts.map +1 -0
- package/dist/agent/read/interpret.d.ts +8 -1
- package/dist/agent/read/interpret.d.ts.map +1 -1
- package/dist/agent/read/read-tool-view.d.ts.map +1 -1
- package/dist/agent/tool-views/built-in.d.ts.map +1 -1
- package/dist/agent/waits.d.ts +14 -0
- package/dist/agent/waits.d.ts.map +1 -0
- package/dist/artifacts/edit-session.d.ts +11 -1
- package/dist/artifacts/edit-session.d.ts.map +1 -1
- package/dist/artifacts/frame.d.ts.map +1 -1
- package/dist/artifacts/messages.d.ts +52 -0
- package/dist/artifacts/messages.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board-editor.d.ts +11 -4
- package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board.d.ts +14 -2
- package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/canvas.d.ts +4 -3
- package/dist/artifacts/renderers/canvas/canvas.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/controls.d.ts +15 -4
- package/dist/artifacts/renderers/canvas/controls.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/focus.d.ts +19 -5
- package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/gestures.d.ts +46 -0
- package/dist/artifacts/renderers/canvas/gestures.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-resize.d.ts +21 -0
- package/dist/artifacts/renderers/canvas/page-resize.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-size-controls.d.ts +21 -0
- package/dist/artifacts/renderers/canvas/page-size-controls.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-size.d.ts +93 -0
- package/dist/artifacts/renderers/canvas/page-size.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-zoom.d.ts +64 -0
- package/dist/artifacts/renderers/canvas/page-zoom.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/shown-size.d.ts +26 -0
- package/dist/artifacts/renderers/canvas/shown-size.d.ts.map +1 -0
- package/dist/{chunk-kes4ygmz.js → chunk-970s5nkn.js} +1 -1
- package/dist/{chunk-001c4gnk.js → chunk-kymx9y5e.js} +3117 -2363
- package/dist/{chunk-001c4gnk.js.map → chunk-kymx9y5e.js.map} +36 -29
- package/dist/{chunk-fwb9mxwm.js → chunk-pxd07kvx.js} +1 -1
- package/dist/{chunk-5crvhjp2.js → chunk-yrcm1pbg.js} +1504 -233
- package/dist/chunk-yrcm1pbg.js.map +34 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +3 -3
- package/dist/pages.js +2 -2
- package/package.json +2 -2
- package/src/agent/activity-label.ts +6 -1
- package/src/agent/agent-chat.tsx +1 -0
- package/src/agent/background/background-tool-row.tsx +24 -10
- package/src/agent/background/interpret.ts +60 -51
- package/src/agent/components/conversation-panel.tsx +27 -8
- package/src/agent/components/message-parts.tsx +23 -5
- package/src/agent/components/transcript.tsx +45 -27
- package/src/agent/delegation/agent-exchange.tsx +53 -0
- package/src/agent/delegation/child-card.tsx +6 -40
- package/src/agent/delegation/child-parts.tsx +1 -84
- package/src/agent/delegation/child-work.tsx +19 -5
- package/src/agent/delegation/interpret.ts +33 -54
- package/src/agent/delegation/model.ts +1 -1
- package/src/agent/file-edits/file-edit-tool-view.tsx +126 -0
- package/src/agent/file-edits/interpret.ts +120 -0
- package/src/agent/hooks/use-agent-conversation.ts +20 -0
- package/src/agent/i18n/en.ts +47 -5
- package/src/agent/i18n/fr.ts +39 -4
- package/src/agent/message-agent/interpret.ts +4 -3
- package/src/agent/publish-artifact/interpret.ts +14 -5
- package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +2 -2
- package/src/agent/questions/interpret.ts +90 -0
- package/src/agent/questions/question-card.tsx +57 -0
- package/src/agent/questions/question-composer.tsx +257 -0
- package/src/agent/read/interpret.ts +34 -1
- package/src/agent/read/read-tool-view.tsx +20 -4
- package/src/agent/tool-views/built-in.tsx +19 -8
- package/src/agent/waits.ts +50 -0
- package/src/artifacts/artifacts.css +36 -0
- package/src/artifacts/edit-session.tsx +15 -1
- package/src/artifacts/frame.tsx +3 -2
- package/src/artifacts/messages.ts +54 -0
- package/src/artifacts/renderers/canvas/board-editor.tsx +37 -15
- package/src/artifacts/renderers/canvas/board.tsx +70 -8
- package/src/artifacts/renderers/canvas/canvas.tsx +66 -15
- package/src/artifacts/renderers/canvas/controls.tsx +64 -30
- package/src/artifacts/renderers/canvas/focus.tsx +200 -56
- package/src/artifacts/renderers/canvas/gestures.ts +265 -0
- package/src/artifacts/renderers/canvas/page-resize.tsx +542 -0
- package/src/artifacts/renderers/canvas/page-size-controls.tsx +193 -0
- package/src/artifacts/renderers/canvas/page-size.ts +218 -0
- package/src/artifacts/renderers/canvas/page-zoom.ts +280 -0
- package/src/artifacts/renderers/canvas/shown-size.ts +105 -0
- package/src/artifacts/viewer.tsx +15 -1
- package/src/index.ts +2 -0
- package/dist/chunk-5crvhjp2.js.map +0 -28
- /package/dist/{chunk-kes4ygmz.js.map → chunk-970s5nkn.js.map} +0 -0
- /package/dist/{chunk-fwb9mxwm.js.map → chunk-pxd07kvx.js.map} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cn } from "@sixb/ui/lib/utils"
|
|
1
2
|
import { Panel, useReactFlow, useStore } from "@xyflow/react"
|
|
2
3
|
import { Maximize, Minus, Plus } from "lucide-react"
|
|
3
4
|
import type { ReactNode } from "react"
|
|
@@ -6,46 +7,79 @@ import { useArtifactMessages } from "../../messages"
|
|
|
6
7
|
/** How long the board takes to move when a control moves it. */
|
|
7
8
|
const DURATION = 220
|
|
8
9
|
|
|
9
|
-
/**
|
|
10
|
-
* The board's zoom controls, floating in its corner: out, the zoom as a percent, which goes to 100%
|
|
11
|
-
* when pressed, in, and fit to everything. Each stays a comfortable target on a phone.
|
|
12
|
-
*/
|
|
10
|
+
/** The canvas's zoom controls, floating in its corner, moving the board as React Flow holds it. */
|
|
13
11
|
export function CanvasControls({ padding }: { readonly padding: number }) {
|
|
14
12
|
const messages = useArtifactMessages().canvas
|
|
15
13
|
const { zoomIn, zoomOut, zoomTo, fitView } = useReactFlow()
|
|
16
14
|
const zoom = useStore((state) => state.transform[2])
|
|
17
15
|
return (
|
|
18
16
|
<Panel position="bottom-left" className="!m-3">
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
className="h-8 w-12 rounded-lg text-center text-xs font-medium text-muted-foreground tabular-nums outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
|
|
28
|
-
>
|
|
29
|
-
<span aria-live="polite">{messages.zoom(Math.round(zoom * 100))}</span>
|
|
30
|
-
<span className="sr-only">, {messages.actualSize}</span>
|
|
31
|
-
</button>
|
|
32
|
-
<Control label={messages.zoomIn} onClick={() => zoomIn({ duration: DURATION })}>
|
|
33
|
-
<Plus className="size-4" aria-hidden="true" />
|
|
34
|
-
</Control>
|
|
35
|
-
<span className="mx-1 h-5 w-px bg-border" aria-hidden="true" />
|
|
36
|
-
<Control
|
|
37
|
-
label={messages.fitView}
|
|
38
|
-
onClick={() => void fitView({ padding, duration: DURATION })}
|
|
39
|
-
wide
|
|
40
|
-
>
|
|
41
|
-
<Maximize className="size-3.5" aria-hidden="true" />
|
|
42
|
-
<span className="text-xs font-medium">{messages.fit}</span>
|
|
43
|
-
</Control>
|
|
44
|
-
</div>
|
|
17
|
+
<ZoomBar
|
|
18
|
+
zoom={zoom}
|
|
19
|
+
fitLabel={messages.fitView}
|
|
20
|
+
onZoomOut={() => zoomOut({ duration: DURATION })}
|
|
21
|
+
onActualSize={() => void zoomTo(1, { duration: DURATION })}
|
|
22
|
+
onZoomIn={() => zoomIn({ duration: DURATION })}
|
|
23
|
+
onFit={() => void fitView({ padding, duration: DURATION })}
|
|
24
|
+
/>
|
|
45
25
|
</Panel>
|
|
46
26
|
)
|
|
47
27
|
}
|
|
48
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Zoom controls: out, the zoom as a percent, which goes to 100% when pressed, in, and fit. The
|
|
31
|
+
* canvas and an opened board show the same. Each stays a comfortable target on a phone.
|
|
32
|
+
*/
|
|
33
|
+
export function ZoomBar({
|
|
34
|
+
zoom,
|
|
35
|
+
fitLabel,
|
|
36
|
+
onZoomOut,
|
|
37
|
+
onActualSize,
|
|
38
|
+
onZoomIn,
|
|
39
|
+
onFit,
|
|
40
|
+
className,
|
|
41
|
+
}: {
|
|
42
|
+
readonly zoom: number
|
|
43
|
+
/** What fitting shows: everything on the canvas, or the whole page. */
|
|
44
|
+
readonly fitLabel: string
|
|
45
|
+
readonly onZoomOut: () => void
|
|
46
|
+
readonly onActualSize: () => void
|
|
47
|
+
readonly onZoomIn: () => void
|
|
48
|
+
readonly onFit: () => void
|
|
49
|
+
readonly className?: string
|
|
50
|
+
}) {
|
|
51
|
+
const messages = useArtifactMessages().canvas
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
className={cn(
|
|
55
|
+
"flex items-center gap-0.5 rounded-xl border border-border bg-background/90 p-1 shadow-[0_1px_2px_rgb(0_0_0/0.06),0_8px_24px_-12px_rgb(0_0_0/0.25)] backdrop-blur",
|
|
56
|
+
className
|
|
57
|
+
)}
|
|
58
|
+
>
|
|
59
|
+
<Control label={messages.zoomOut} onClick={onZoomOut}>
|
|
60
|
+
<Minus className="size-4" aria-hidden="true" />
|
|
61
|
+
</Control>
|
|
62
|
+
<button
|
|
63
|
+
type="button"
|
|
64
|
+
title={messages.actualSize}
|
|
65
|
+
onClick={onActualSize}
|
|
66
|
+
className="h-8 w-12 rounded-lg text-center text-xs font-medium text-muted-foreground tabular-nums outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
|
|
67
|
+
>
|
|
68
|
+
<span aria-live="polite">{messages.zoom(Math.round(zoom * 100))}</span>
|
|
69
|
+
<span className="sr-only">, {messages.actualSize}</span>
|
|
70
|
+
</button>
|
|
71
|
+
<Control label={messages.zoomIn} onClick={onZoomIn}>
|
|
72
|
+
<Plus className="size-4" aria-hidden="true" />
|
|
73
|
+
</Control>
|
|
74
|
+
<span className="mx-1 h-5 w-px bg-border" aria-hidden="true" />
|
|
75
|
+
<Control label={fitLabel} onClick={onFit} wide>
|
|
76
|
+
<Maximize className="size-3.5" aria-hidden="true" />
|
|
77
|
+
<span className="text-xs font-medium">{messages.fit}</span>
|
|
78
|
+
</Control>
|
|
79
|
+
</div>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
49
83
|
function Control({
|
|
50
84
|
label,
|
|
51
85
|
onClick,
|
|
@@ -1,17 +1,34 @@
|
|
|
1
|
-
import type { CanvasArrow, CanvasBoard } from "@sixb/core/artifacts"
|
|
1
|
+
import type { CanvasArrow, CanvasBoard, FrameZoom, FrameZoomStep } from "@sixb/core/artifacts"
|
|
2
|
+
import { cn } from "@sixb/ui/lib/utils"
|
|
2
3
|
import { ArrowLeft, ChevronLeft, ChevronRight } from "lucide-react"
|
|
3
|
-
import { type ReactNode, useCallback, useEffect, useState } from "react"
|
|
4
|
+
import { type ReactNode, useCallback, useEffect, useMemo, useState } from "react"
|
|
4
5
|
import type { LiveArtifact } from "../../live/session"
|
|
5
6
|
import { useArtifactMessages } from "../../messages"
|
|
6
7
|
import type { ArtifactVersion } from "../../queries"
|
|
7
8
|
import { type BoardEditor, BoardStage, type CommentPick, type StageMode } from "./board-editor"
|
|
8
9
|
import type { DraftPlace, PinPlace } from "./comment-pins"
|
|
10
|
+
import { ZoomBar } from "./controls"
|
|
11
|
+
import type { Box } from "./draft"
|
|
12
|
+
import { PageResizer } from "./page-resize"
|
|
13
|
+
import type { PageSize, SizeName, SnappedSize } from "./page-size"
|
|
14
|
+
import { SizeControls } from "./page-size-controls"
|
|
15
|
+
import { usePageZoom } from "./page-zoom"
|
|
16
|
+
import { useShownSize } from "./shown-size"
|
|
17
|
+
|
|
18
|
+
/** How long a size kept as the board's is said. */
|
|
19
|
+
const KEPT_MS = 2400
|
|
9
20
|
|
|
10
21
|
/**
|
|
11
22
|
* A board opened over the canvas: its page at the board's own size, as the canvas and its picture
|
|
12
|
-
* show it,
|
|
13
|
-
*
|
|
14
|
-
*
|
|
23
|
+
* show it, and answering like a page. Its picture shows until the page is ready, and stays, with
|
|
24
|
+
* a word, if the page never is. ← and → step through the boards in the canvas's order, and Esc
|
|
25
|
+
* goes back to the canvas.
|
|
26
|
+
*
|
|
27
|
+
* It opens fitted: whole, or, taller than wide, to its width, scrolling down it as a document's
|
|
28
|
+
* page. The zoom bar, a pinch or ⌘ with the wheel over it, ⌘ +, − and 0, and a double-click beside
|
|
29
|
+
* it zoom it. Its edges resize it for the reader alone, laid out again at that size while it is
|
|
30
|
+
* open, until they go back to the board's size; whoever may change the canvas keeps it as the
|
|
31
|
+
* board's.
|
|
15
32
|
*
|
|
16
33
|
* It is a prototype too: pressing a button or a link within the page that reads as the label of an
|
|
17
34
|
* arrow leaving the board opens the board the arrow points to.
|
|
@@ -39,6 +56,7 @@ export function BoardFocus({
|
|
|
39
56
|
onOpenPin,
|
|
40
57
|
onSubmitDraft,
|
|
41
58
|
onCancelDraft,
|
|
59
|
+
onResizeBoard,
|
|
42
60
|
}: {
|
|
43
61
|
readonly version: ArtifactVersion
|
|
44
62
|
readonly boards: readonly CanvasBoard[]
|
|
@@ -64,14 +82,68 @@ export function BoardFocus({
|
|
|
64
82
|
readonly onOpenPin?: (id: string) => void
|
|
65
83
|
readonly onSubmitDraft?: (body: string) => Promise<void>
|
|
66
84
|
readonly onCancelDraft?: () => void
|
|
85
|
+
/**
|
|
86
|
+
* Resizes a board on the canvas, as its handles do while the canvas is edited: Keep this size.
|
|
87
|
+
* Absent for whoever may not change the canvas.
|
|
88
|
+
*/
|
|
89
|
+
readonly onResizeBoard?: (id: string, box: Box) => void
|
|
67
90
|
}) {
|
|
68
91
|
const messages = useArtifactMessages().canvas
|
|
69
92
|
const index = boards.findIndex((board) => board.id === id)
|
|
70
93
|
const board = boards[index]
|
|
71
94
|
const previous = boards[index - 1]
|
|
72
95
|
const next = boards[index + 1]
|
|
96
|
+
|
|
97
|
+
const [kept, setKept] = useState<PageSize | null>(null)
|
|
98
|
+
const own = useMemo(() => ({ w: board?.w ?? 1, h: board?.h ?? 1 }), [board?.w, board?.h])
|
|
99
|
+
const size = useShownSize(id, own)
|
|
100
|
+
const { shown, resized, suggestions } = size
|
|
101
|
+
|
|
73
102
|
const [stage, setStage] = useState<HTMLDivElement | null>(null)
|
|
74
|
-
const
|
|
103
|
+
const view = useSize(stage)
|
|
104
|
+
const zoom = usePageZoom({ id, page: shown, view, stage })
|
|
105
|
+
|
|
106
|
+
/** A size picked from the menu: the page fitted at it. */
|
|
107
|
+
const pickSize = (picked: PageSize, name: SizeName) => {
|
|
108
|
+
size.pick(picked, name)
|
|
109
|
+
zoom.fit("open")
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const reset = () => {
|
|
113
|
+
size.reset()
|
|
114
|
+
zoom.fit("open")
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** A resize ends: what it snapped to says whether its width carries to the other boards. */
|
|
118
|
+
const resizedBy = (snapped: SnappedSize | null) => {
|
|
119
|
+
zoom.release()
|
|
120
|
+
if (snapped) size.settle(snapped)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const keep =
|
|
124
|
+
onResizeBoard && board
|
|
125
|
+
? () => {
|
|
126
|
+
onResizeBoard(board.id, { x: board.x, y: board.y, w: shown.w, h: shown.h })
|
|
127
|
+
size.keep()
|
|
128
|
+
setKept(shown)
|
|
129
|
+
}
|
|
130
|
+
: undefined
|
|
131
|
+
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
if (!kept) return
|
|
134
|
+
const timer = window.setTimeout(() => setKept(null), KEPT_MS)
|
|
135
|
+
return () => window.clearTimeout(timer)
|
|
136
|
+
}, [kept])
|
|
137
|
+
|
|
138
|
+
const { step, zoomTo, zoomBy } = zoom
|
|
139
|
+
const zoomStep = useCallback(
|
|
140
|
+
(to: FrameZoomStep) => (to === "actual" ? zoomTo(1) : step(to)),
|
|
141
|
+
[step, zoomTo]
|
|
142
|
+
)
|
|
143
|
+
const onZoom = useCallback(
|
|
144
|
+
(by: FrameZoom) => ("step" in by ? zoomStep(by.step) : zoomBy(by.factor, by.at)),
|
|
145
|
+
[zoomStep, zoomBy]
|
|
146
|
+
)
|
|
75
147
|
|
|
76
148
|
const onPress = useCallback(
|
|
77
149
|
(text: string) => {
|
|
@@ -84,15 +156,27 @@ export function BoardFocus({
|
|
|
84
156
|
|
|
85
157
|
useEffect(() => {
|
|
86
158
|
const onKey = (event: KeyboardEvent) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
159
|
+
// ⌘ +, − and 0 zoom the board, not the app around it.
|
|
160
|
+
if (event.metaKey || event.ctrlKey) {
|
|
161
|
+
const to = zoomKey(event)
|
|
162
|
+
if (to) {
|
|
163
|
+
event.preventDefault()
|
|
164
|
+
zoomStep(to)
|
|
165
|
+
}
|
|
166
|
+
return
|
|
167
|
+
}
|
|
168
|
+
if (event.altKey) return
|
|
169
|
+
// Keys typed into a field are the field's, and a menu's are its own; arrows on the page's
|
|
170
|
+
// handles and their suggestions resize it.
|
|
171
|
+
const target = event.target instanceof Element ? event.target : null
|
|
90
172
|
if (
|
|
91
|
-
target
|
|
92
|
-
|
|
173
|
+
target?.closest(
|
|
174
|
+
"input, textarea, select, [contenteditable], [data-board-tools], [role=menu]"
|
|
175
|
+
)
|
|
93
176
|
) {
|
|
94
177
|
return
|
|
95
178
|
}
|
|
179
|
+
if (event.key !== "Escape" && target?.closest("[data-page-resizer]")) return
|
|
96
180
|
if (event.key === "Escape") {
|
|
97
181
|
if (!onEscape?.()) onClose()
|
|
98
182
|
} else if (event.key === "ArrowLeft" && previous) onOpen(previous.id)
|
|
@@ -102,12 +186,13 @@ export function BoardFocus({
|
|
|
102
186
|
}
|
|
103
187
|
window.addEventListener("keydown", onKey)
|
|
104
188
|
return () => window.removeEventListener("keydown", onKey)
|
|
105
|
-
}, [previous, next, onOpen, onClose, onEscape])
|
|
189
|
+
}, [previous, next, onOpen, onClose, onEscape, zoomStep])
|
|
106
190
|
|
|
107
191
|
if (!board) return null
|
|
108
192
|
const title = board.title ?? board.id
|
|
109
|
-
const scale
|
|
110
|
-
const picture = pictureOf?.(board.id)
|
|
193
|
+
const { scale, placement } = zoom
|
|
194
|
+
const picture = resized ? undefined : pictureOf?.(board.id)
|
|
195
|
+
|
|
111
196
|
return (
|
|
112
197
|
<div
|
|
113
198
|
role="dialog"
|
|
@@ -130,10 +215,19 @@ export function BoardFocus({
|
|
|
130
215
|
{mode === "edit" ? messages.edit.hint : messages.comments.modeHint}
|
|
131
216
|
</span>
|
|
132
217
|
) : null}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
218
|
+
<div className="ml-auto flex shrink-0 items-center">
|
|
219
|
+
<SizeControls
|
|
220
|
+
shown={shown}
|
|
221
|
+
board={own}
|
|
222
|
+
suggestions={suggestions}
|
|
223
|
+
kept={kept}
|
|
224
|
+
onPick={pickSize}
|
|
225
|
+
onReset={reset}
|
|
226
|
+
onKeep={keep}
|
|
227
|
+
/>
|
|
228
|
+
{tools}
|
|
229
|
+
</div>
|
|
230
|
+
<span className="shrink-0 text-xs whitespace-nowrap text-muted-foreground tabular-nums max-sm:hidden">
|
|
137
231
|
{messages.position(index + 1, boards.length)}
|
|
138
232
|
</span>
|
|
139
233
|
<Step
|
|
@@ -147,49 +241,102 @@ export function BoardFocus({
|
|
|
147
241
|
<ChevronRight className="size-4" aria-hidden="true" />
|
|
148
242
|
</Step>
|
|
149
243
|
</div>
|
|
150
|
-
<div className="
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
244
|
+
<div className="relative min-h-0 flex-1 bg-muted/40">
|
|
245
|
+
{/* Scrolled over the page when it is larger than the view; pinched, zoomed instead. */}
|
|
246
|
+
<div
|
|
247
|
+
ref={setStage}
|
|
248
|
+
data-board-stage=""
|
|
249
|
+
className="absolute inset-0 touch-pan-x touch-pan-y overflow-auto overscroll-contain"
|
|
250
|
+
onDoubleClick={(event) => {
|
|
251
|
+
if ((event.target as Element).closest("[data-board-page]")) return
|
|
252
|
+
const at = zoom.pageAt(event.clientX, event.clientY)
|
|
253
|
+
if (at) zoom.toggle(at)
|
|
254
|
+
}}
|
|
255
|
+
>
|
|
256
|
+
{placement && scale > 0 ? (
|
|
257
|
+
<div className="relative" style={{ width: placement.width, height: placement.height }}>
|
|
258
|
+
{/* The box the page takes on screen; the page inside is laid out at its size. */}
|
|
259
|
+
<div
|
|
260
|
+
key={board.id}
|
|
261
|
+
data-board-page=""
|
|
262
|
+
className={cn(
|
|
263
|
+
"group/page sixb-canvas-surface absolute motion-safe:animate-in motion-safe:fade-in motion-safe:zoom-in-97 motion-safe:duration-300 motion-safe:ease-out",
|
|
264
|
+
zoom.settling ? "motion-safe:transition-[left,top] motion-safe:ease-out" : null
|
|
265
|
+
)}
|
|
266
|
+
style={{
|
|
267
|
+
left: placement.left,
|
|
268
|
+
top: placement.top,
|
|
269
|
+
width: shown.w * scale,
|
|
270
|
+
height: shown.h * scale,
|
|
271
|
+
}}
|
|
272
|
+
>
|
|
273
|
+
<BoardStage
|
|
274
|
+
version={version}
|
|
275
|
+
board={board}
|
|
276
|
+
size={shown}
|
|
277
|
+
title={title}
|
|
278
|
+
scale={scale}
|
|
279
|
+
live={live}
|
|
280
|
+
canvas={canvas}
|
|
281
|
+
mode={mode}
|
|
282
|
+
pins={pins.filter((pin) => pin.board === board.id)}
|
|
283
|
+
activePin={activePin}
|
|
284
|
+
draft={draft?.board === board.id ? draft : null}
|
|
285
|
+
// Its picture is of the board at its own size.
|
|
286
|
+
fallback={picture ? <BoardPicture src={picture} /> : undefined}
|
|
287
|
+
failure={
|
|
288
|
+
<div className="relative size-full">
|
|
289
|
+
{picture ? <BoardPicture src={picture} /> : null}
|
|
290
|
+
<p className="absolute inset-x-0 bottom-0 m-0 bg-background/90 px-4 py-2 text-sm text-muted-foreground">
|
|
291
|
+
{messages.boardFailed}
|
|
292
|
+
</p>
|
|
293
|
+
</div>
|
|
294
|
+
}
|
|
295
|
+
onPress={onPress}
|
|
296
|
+
onPick={pick}
|
|
297
|
+
onOpenPin={(pin) => onOpenPin?.(pin)}
|
|
298
|
+
onSubmitDraft={(body) => onSubmitDraft?.(body) ?? Promise.resolve()}
|
|
299
|
+
onCancelDraft={() => onCancelDraft?.()}
|
|
300
|
+
onContentHeight={size.onContentHeight}
|
|
301
|
+
onZoom={onZoom}
|
|
302
|
+
/>
|
|
303
|
+
<PageResizer
|
|
304
|
+
size={shown}
|
|
305
|
+
scale={scale}
|
|
306
|
+
suggestions={suggestions}
|
|
307
|
+
stage={stage}
|
|
308
|
+
onStart={zoom.hold}
|
|
309
|
+
onResize={size.resize}
|
|
310
|
+
onEnd={resizedBy}
|
|
311
|
+
/>
|
|
312
|
+
</div>
|
|
185
313
|
</div>
|
|
186
314
|
) : null}
|
|
187
315
|
</div>
|
|
316
|
+
|
|
317
|
+
<ZoomBar
|
|
318
|
+
zoom={scale}
|
|
319
|
+
fitLabel={messages.fitPage}
|
|
320
|
+
onZoomOut={() => zoom.step("out")}
|
|
321
|
+
onActualSize={() => zoom.zoomTo(1)}
|
|
322
|
+
onZoomIn={() => zoom.step("in")}
|
|
323
|
+
onFit={() => zoom.fit("whole")}
|
|
324
|
+
className="absolute bottom-3 left-3 z-20"
|
|
325
|
+
/>
|
|
188
326
|
</div>
|
|
189
327
|
</div>
|
|
190
328
|
)
|
|
191
329
|
}
|
|
192
330
|
|
|
331
|
+
/** ⌘ or Ctrl with +, − or 0 as a zoom step. */
|
|
332
|
+
export function zoomKey(event: KeyboardEvent): FrameZoomStep | null {
|
|
333
|
+
if (event.altKey) return null
|
|
334
|
+
if (event.key === "=" || event.key === "+") return "in"
|
|
335
|
+
if (event.key === "-") return "out"
|
|
336
|
+
if (event.key === "0") return "actual"
|
|
337
|
+
return null
|
|
338
|
+
}
|
|
339
|
+
|
|
193
340
|
/**
|
|
194
341
|
* The board an arrow leaving `from` points to, when its label reads as `pressed`, case and spaces
|
|
195
342
|
* aside: the first such arrow the canvas lists, to a board.
|
|
@@ -214,9 +361,6 @@ function wordsOf(text: string): string {
|
|
|
214
361
|
return text.replace(/\s+/g, " ").trim().toLowerCase()
|
|
215
362
|
}
|
|
216
363
|
|
|
217
|
-
/** The most an opened board is enlarged to fit the viewer, as far as the canvas zooms. */
|
|
218
|
-
const MAX_SCALE = 2.5
|
|
219
|
-
|
|
220
364
|
/** A board's picture at its own size, drawn from its top as its tile draws it. */
|
|
221
365
|
function BoardPicture({ src }: { readonly src: string }) {
|
|
222
366
|
return (
|