@sixb/app 0.2.3 → 0.2.5
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/assets/connector-icons/README.md +1 -0
- package/assets/connector-icons/ctm.png +0 -0
- package/dist/agent/activity-label.d.ts.map +1 -1
- package/dist/agent/agent-chat.d.ts +3 -1
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/agent-panel.d.ts.map +1 -1
- package/dist/agent/artifact-panel.d.ts +3 -1
- package/dist/agent/artifact-panel.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/composer-settings.d.ts +1 -1
- package/dist/agent/components/composer-settings.d.ts.map +1 -1
- package/dist/agent/components/composer.d.ts +22 -5
- package/dist/agent/components/composer.d.ts.map +1 -1
- package/dist/agent/components/context-meter.d.ts +1 -1
- package/dist/agent/components/context-meter.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts +8 -2
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/message-parts.d.ts +2 -1
- package/dist/agent/components/message-parts.d.ts.map +1 -1
- package/dist/agent/components/message-view.d.ts.map +1 -1
- package/dist/agent/components/pending-messages.d.ts +20 -0
- package/dist/agent/components/pending-messages.d.ts.map +1 -0
- package/dist/agent/components/sandbox-recovery.d.ts +11 -2
- package/dist/agent/components/sandbox-recovery.d.ts.map +1 -1
- package/dist/agent/components/threads-button.d.ts +1 -1
- package/dist/agent/components/threads-button.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/conversation.d.ts +3 -6
- package/dist/agent/conversation.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 +9 -10
- package/dist/agent/delegation/interpret.d.ts.map +1 -1
- package/dist/agent/delegation/use-children.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 +16 -4
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +114 -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 +190 -8
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/inbox-handoff.d.ts +10 -0
- package/dist/agent/inbox-handoff.d.ts.map +1 -0
- package/dist/agent/live-run.d.ts +8 -1
- package/dist/agent/live-run.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/search/interpret.d.ts +101 -0
- package/dist/agent/search/interpret.d.ts.map +1 -0
- package/dist/agent/search/search-tool-view.d.ts +10 -0
- package/dist/agent/search/search-tool-view.d.ts.map +1 -0
- package/dist/agent/thread-state.d.ts +26 -0
- package/dist/agent/thread-state.d.ts.map +1 -0
- package/dist/agent/tool-views/built-in.d.ts.map +1 -1
- package/dist/agent/tool-views/registry.d.ts +5 -6
- package/dist/agent/tool-views/registry.d.ts.map +1 -1
- package/dist/agent/types.d.ts +5 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts +2 -1
- package/dist/agent/view-file/view-file-tool-view.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/card-preview.d.ts.map +1 -1
- package/dist/artifacts/edit-session.d.ts +11 -1
- package/dist/artifacts/edit-session.d.ts.map +1 -1
- package/dist/artifacts/editor/block-handle.d.ts +20 -0
- package/dist/artifacts/editor/block-handle.d.ts.map +1 -0
- package/dist/artifacts/editor/blocks.d.ts +34 -0
- package/dist/artifacts/editor/blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/callout-view.d.ts +7 -0
- package/dist/artifacts/editor/callout-view.d.ts.map +1 -0
- package/dist/artifacts/editor/document-editor.d.ts +30 -0
- package/dist/artifacts/editor/document-editor.d.ts.map +1 -0
- package/dist/artifacts/editor/figure-view.d.ts +12 -0
- package/dist/artifacts/editor/figure-view.d.ts.map +1 -0
- package/dist/artifacts/editor/find-blocks.d.ts +6 -0
- package/dist/artifacts/editor/find-blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/markdown-document.d.ts +12 -0
- package/dist/artifacts/editor/markdown-document.d.ts.map +1 -0
- package/dist/artifacts/editor/messages.d.ts +4 -0
- package/dist/artifacts/editor/messages.d.ts.map +1 -0
- package/dist/artifacts/editor/schema.d.ts +21 -0
- package/dist/artifacts/editor/schema.d.ts.map +1 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts +35 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts.map +1 -0
- package/dist/artifacts/editor/slash-menu.d.ts +43 -0
- package/dist/artifacts/editor/slash-menu.d.ts.map +1 -0
- package/dist/artifacts/editor/upload.d.ts +12 -0
- package/dist/artifacts/editor/upload.d.ts.map +1 -0
- package/dist/artifacts/file-source.d.ts +5 -0
- package/dist/artifacts/file-source.d.ts.map +1 -1
- package/dist/artifacts/frame-editor/bundle.d.ts +7 -0
- package/dist/artifacts/frame-editor/bundle.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/commands.d.ts +93 -0
- package/dist/artifacts/frame-editor/commands.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/entry.d.ts +2 -0
- package/dist/artifacts/frame-editor/entry.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/frame.d.ts +5 -0
- package/dist/artifacts/frame-editor/frame.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/keys.d.ts +8 -0
- package/dist/artifacts/frame-editor/keys.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/protocol.d.ts +186 -0
- package/dist/artifacts/frame-editor/protocol.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/schema.d.ts +34 -0
- package/dist/artifacts/frame-editor/schema.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/style.d.ts +2 -0
- package/dist/artifacts/frame-editor/style.d.ts.map +1 -0
- package/dist/artifacts/frame.d.ts +2 -2
- package/dist/artifacts/frame.d.ts.map +1 -1
- package/dist/artifacts/live/boards.d.ts +2 -0
- package/dist/artifacts/live/boards.d.ts.map +1 -1
- package/dist/artifacts/live/document.d.ts +32 -0
- package/dist/artifacts/live/document.d.ts.map +1 -0
- package/dist/artifacts/live/header.d.ts +4 -4
- package/dist/artifacts/live/header.d.ts.map +1 -1
- package/dist/artifacts/live/presence.d.ts.map +1 -1
- package/dist/artifacts/live/session.d.ts +2 -0
- package/dist/artifacts/live/session.d.ts.map +1 -1
- package/dist/artifacts/live/view.d.ts +4 -3
- package/dist/artifacts/live/view.d.ts.map +1 -1
- package/dist/artifacts/messages.d.ts +278 -2
- package/dist/artifacts/messages.d.ts.map +1 -1
- package/dist/artifacts/pdf.d.ts +8 -0
- package/dist/artifacts/pdf.d.ts.map +1 -0
- package/dist/artifacts/queries.d.ts +80 -0
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/artifacts/references/references.d.ts +3 -3
- package/dist/artifacts/references/references.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/comment-pins.d.ts +4 -2
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments.d.ts +2 -1
- package/dist/artifacts/renderers/canvas/comments.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/artifacts/renderers/designed-document.d.ts +28 -0
- package/dist/artifacts/renderers/designed-document.d.ts.map +1 -0
- package/dist/artifacts/renderers/document-tree.d.ts +2 -0
- package/dist/artifacts/renderers/document-tree.d.ts.map +1 -1
- package/dist/artifacts/renderers/document.d.ts +9 -1
- package/dist/artifacts/renderers/document.d.ts.map +1 -1
- package/dist/artifacts/renderers/live-frame.d.ts +145 -0
- package/dist/artifacts/renderers/live-frame.d.ts.map +1 -0
- package/dist/artifacts/renderers/page-editor.d.ts +16 -0
- package/dist/artifacts/renderers/page-editor.d.ts.map +1 -0
- package/dist/artifacts/renderers/page.d.ts +10 -1
- package/dist/artifacts/renderers/page.d.ts.map +1 -1
- package/dist/artifacts/viewer.d.ts.map +1 -1
- package/dist/{chunk-001c4gnk.js → chunk-4fex83k2.js} +19965 -13027
- package/dist/chunk-4fex83k2.js.map +239 -0
- package/dist/{chunk-5crvhjp2.js → chunk-4wm09prf.js} +1633 -1999
- package/dist/chunk-4wm09prf.js.map +27 -0
- package/dist/{chunk-fwb9mxwm.js → chunk-5sgac68y.js} +1 -1
- package/dist/{chunk-kes4ygmz.js → chunk-69qgh20f.js} +1 -1
- package/dist/chunk-y51c4tsz.js +11 -0
- package/dist/chunk-y51c4tsz.js.map +10 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -6
- package/dist/index.js.map +5 -5
- package/dist/pages/console/data/messages.d.ts +6 -0
- package/dist/pages/console/data/messages.d.ts.map +1 -1
- package/dist/pages/console/data/shared.d.ts.map +1 -1
- package/dist/pages.js +12 -5
- package/dist/pages.js.map +6 -6
- package/dist/shell/search-command.d.ts.map +1 -1
- package/package.json +22 -5
- package/src/agent/activity-label.ts +9 -1
- package/src/agent/agent-chat.tsx +57 -37
- package/src/agent/agent-execution-trace.tsx +2 -2
- package/src/agent/agent-panel.tsx +6 -4
- package/src/agent/agent.css +254 -0
- package/src/agent/artifact-panel.tsx +77 -22
- package/src/agent/background/background-tool-row.tsx +24 -10
- package/src/agent/background/interpret.ts +60 -51
- package/src/agent/components/composer-settings.tsx +20 -10
- package/src/agent/components/composer.tsx +342 -104
- package/src/agent/components/context-meter.tsx +7 -3
- package/src/agent/components/conversation-panel.tsx +96 -37
- package/src/agent/components/message-parts.tsx +390 -64
- package/src/agent/components/message-view.tsx +12 -2
- package/src/agent/components/pending-messages.tsx +338 -0
- package/src/agent/components/sandbox-recovery.tsx +36 -17
- package/src/agent/components/threads-button.tsx +3 -2
- package/src/agent/components/transcript.tsx +92 -45
- package/src/agent/conversation.ts +203 -54
- 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 +64 -61
- 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 +360 -92
- package/src/agent/hooks/use-thread-stream.ts +10 -0
- package/src/agent/i18n/en.ts +134 -16
- package/src/agent/i18n/fr.ts +122 -16
- package/src/agent/inbox-handoff.ts +47 -0
- package/src/agent/live-run.ts +23 -2
- 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/react-router.tsx +2 -2
- package/src/agent/read/interpret.ts +34 -1
- package/src/agent/read/read-tool-view.tsx +20 -4
- package/src/agent/search/interpret.ts +367 -0
- package/src/agent/search/search-tool-view.tsx +235 -0
- package/src/agent/thread-state.ts +114 -0
- package/src/agent/tool-views/built-in.tsx +33 -6
- package/src/agent/tool-views/registry.tsx +28 -2
- package/src/agent/types.ts +7 -0
- package/src/agent/view-file/view-file-tool-view.tsx +33 -19
- package/src/agent/waits.ts +50 -0
- package/src/artifacts/artifacts.css +434 -0
- package/src/artifacts/card-preview.tsx +6 -1
- package/src/artifacts/edit-session.tsx +15 -1
- package/src/artifacts/editor/block-handle.tsx +278 -0
- package/src/artifacts/editor/blocks.ts +216 -0
- package/src/artifacts/editor/callout-view.tsx +31 -0
- package/src/artifacts/editor/document-editor.tsx +484 -0
- package/src/artifacts/editor/figure-view.tsx +66 -0
- package/src/artifacts/editor/find-blocks.ts +19 -0
- package/src/artifacts/editor/markdown-document.tsx +72 -0
- package/src/artifacts/editor/messages.ts +4 -0
- package/src/artifacts/editor/schema.ts +159 -0
- package/src/artifacts/editor/selection-toolbar.tsx +364 -0
- package/src/artifacts/editor/slash-menu.tsx +251 -0
- package/src/artifacts/editor/upload.ts +40 -0
- package/src/artifacts/file-source.ts +11 -0
- package/src/artifacts/frame-editor/bundle.ts +8 -0
- package/src/artifacts/frame-editor/commands.ts +565 -0
- package/src/artifacts/frame-editor/entry.ts +6 -0
- package/src/artifacts/frame-editor/frame.ts +847 -0
- package/src/artifacts/frame-editor/generated/editor.txt +149 -0
- package/src/artifacts/frame-editor/generated.d.ts +5 -0
- package/src/artifacts/frame-editor/keys.ts +323 -0
- package/src/artifacts/frame-editor/protocol.ts +151 -0
- package/src/artifacts/frame-editor/schema.ts +293 -0
- package/src/artifacts/frame-editor/style.ts +58 -0
- package/src/artifacts/frame.tsx +14 -5
- package/src/artifacts/live/boards.ts +46 -3
- package/src/artifacts/live/document.ts +89 -0
- package/src/artifacts/live/header.tsx +9 -14
- package/src/artifacts/live/presence.ts +5 -1
- package/src/artifacts/live/session.ts +4 -2
- package/src/artifacts/live/view.ts +14 -8
- package/src/artifacts/messages.ts +192 -2
- package/src/artifacts/pdf.ts +50 -0
- package/src/artifacts/references/references.tsx +46 -11
- package/src/artifacts/renderers/canvas/board-editor.tsx +44 -155
- package/src/artifacts/renderers/canvas/board.tsx +70 -8
- package/src/artifacts/renderers/canvas/canvas.tsx +66 -15
- package/src/artifacts/renderers/canvas/comment-pins.tsx +5 -0
- package/src/artifacts/renderers/canvas/comments-panel.tsx +58 -1
- package/src/artifacts/renderers/canvas/comments.ts +8 -4
- 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/renderers/designed-document.tsx +277 -0
- package/src/artifacts/renderers/document-tree.ts +9 -0
- package/src/artifacts/renderers/document.tsx +13 -102
- package/src/artifacts/renderers/live-frame.ts +163 -0
- package/src/artifacts/renderers/page-editor.tsx +613 -0
- package/src/artifacts/renderers/page.tsx +21 -4
- package/src/artifacts/viewer.tsx +101 -41
- package/src/index.ts +8 -0
- package/src/pages/console/data/messages.ts +6 -0
- package/src/pages/console/data/projections.tsx +4 -0
- package/src/pages/console/data/shared.tsx +1 -0
- package/src/pages/console/ontology/lineage/trail.tsx +3 -0
- package/src/shell/search-command.tsx +2 -0
- package/dist/chunk-001c4gnk.js.map +0 -204
- package/dist/chunk-5crvhjp2.js.map +0 -28
- /package/dist/{chunk-fwb9mxwm.js.map → chunk-5sgac68y.js.map} +0 -0
- /package/dist/{chunk-kes4ygmz.js.map → chunk-69qgh20f.js.map} +0 -0
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
import {
|
|
3
3
|
useArtifactView,
|
|
4
4
|
useAgentDraft,
|
|
5
|
-
formatFileSize,
|
|
6
5
|
useArtifactMessages,
|
|
7
6
|
artifactChanged,
|
|
8
|
-
useFileText,
|
|
9
|
-
versionFileSource,
|
|
10
7
|
useBoardPreviews,
|
|
11
8
|
boardPreviewSize,
|
|
12
9
|
boardPreviewUrl,
|
|
10
|
+
useStartEditing,
|
|
13
11
|
livePersonName,
|
|
14
12
|
useLivePresence,
|
|
15
13
|
moveItems,
|
|
@@ -23,14 +21,25 @@ import {
|
|
|
23
21
|
TONE_COLORS,
|
|
24
22
|
ArtifactFrame,
|
|
25
23
|
useSharedGuest2,
|
|
26
|
-
|
|
24
|
+
GuestBadge,
|
|
27
25
|
PersonAvatar,
|
|
28
26
|
useCurrentUser2,
|
|
27
|
+
CommentActionError,
|
|
28
|
+
useArtifactComments,
|
|
29
|
+
addComment,
|
|
30
|
+
resolveComment,
|
|
31
|
+
deleteComment,
|
|
32
|
+
canManageComment,
|
|
33
|
+
useCommentAuthors,
|
|
34
|
+
CommentComposer,
|
|
35
|
+
CanvasCommentPins,
|
|
29
36
|
commentsContext,
|
|
37
|
+
liveBoardSource,
|
|
30
38
|
canvasGraph,
|
|
39
|
+
BoardStage,
|
|
31
40
|
ArtifactLink,
|
|
32
41
|
ArtifactEmbed
|
|
33
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-4fex83k2.js";
|
|
34
43
|
|
|
35
44
|
// src/artifacts/renderers/canvas/canvas.tsx
|
|
36
45
|
import { CANVAS_FIT_PADDING } from "@sixb/core/artifacts";
|
|
@@ -41,16 +50,16 @@ import {
|
|
|
41
50
|
Panel as Panel3,
|
|
42
51
|
ReactFlow,
|
|
43
52
|
ReactFlowProvider,
|
|
44
|
-
useReactFlow as
|
|
45
|
-
useStore as
|
|
46
|
-
useStoreApi as
|
|
53
|
+
useReactFlow as useReactFlow3,
|
|
54
|
+
useStore as useStore3,
|
|
55
|
+
useStoreApi as useStoreApi5
|
|
47
56
|
} from "@xyflow/react";
|
|
48
57
|
import {
|
|
49
|
-
memo as
|
|
58
|
+
memo as memo4,
|
|
50
59
|
useCallback as useCallback8,
|
|
51
|
-
useEffect as
|
|
60
|
+
useEffect as useEffect10,
|
|
52
61
|
useMemo as useMemo6,
|
|
53
|
-
useRef as
|
|
62
|
+
useRef as useRef11,
|
|
54
63
|
useState as useState11
|
|
55
64
|
} from "react";
|
|
56
65
|
|
|
@@ -71,7 +80,7 @@ import { AppWindow, ArrowUpRight, Link2, Maximize2 } from "lucide-react";
|
|
|
71
80
|
import { memo, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
72
81
|
|
|
73
82
|
// src/artifacts/renderers/canvas/board.tsx
|
|
74
|
-
import { CANVAS_FILE } from "@sixb/core/artifacts";
|
|
83
|
+
import { CANVAS_FILE, parseFrameEvent } from "@sixb/core/artifacts";
|
|
75
84
|
import { cn } from "@sixb/ui/lib/utils";
|
|
76
85
|
import { useStoreApi } from "@xyflow/react";
|
|
77
86
|
import {
|
|
@@ -260,14 +269,21 @@ function LiveBoard({
|
|
|
260
269
|
title,
|
|
261
270
|
tile
|
|
262
271
|
}) {
|
|
263
|
-
const { version } = useContext(LiveBoardsContext);
|
|
272
|
+
const { version, interactive = false, gestures = null } = useContext(LiveBoardsContext);
|
|
264
273
|
const live = useLive(id);
|
|
265
274
|
const pages = usePagesVersion(version);
|
|
266
275
|
const [ready, setReady] = useState(null);
|
|
267
276
|
const running = live && pages !== null && ready === pages;
|
|
277
|
+
const usable = running && interactive;
|
|
278
|
+
const page = useRef(null);
|
|
279
|
+
const handle = useRef(null);
|
|
280
|
+
const [loads, setLoads] = useState(0);
|
|
281
|
+
useCanvasPort(id, gestures, handle, loads, page);
|
|
268
282
|
return /* @__PURE__ */ jsxs("div", {
|
|
283
|
+
ref: page,
|
|
269
284
|
className: "group/board relative size-full",
|
|
270
285
|
"data-running": running ? "" : undefined,
|
|
286
|
+
"data-interactive": usable ? "" : undefined,
|
|
271
287
|
children: [
|
|
272
288
|
/* @__PURE__ */ jsx("div", {
|
|
273
289
|
className: "size-full transition-[visibility] delay-300 group-data-[running]/board:invisible",
|
|
@@ -277,16 +293,40 @@ function LiveBoard({
|
|
|
277
293
|
version: pages,
|
|
278
294
|
entry: file,
|
|
279
295
|
title,
|
|
280
|
-
decorative:
|
|
296
|
+
decorative: !usable,
|
|
297
|
+
handle,
|
|
281
298
|
className: "absolute inset-0 overflow-hidden rounded-[10px]",
|
|
282
299
|
onEvent: (event) => {
|
|
283
|
-
if (event.event
|
|
284
|
-
|
|
300
|
+
if (event.event !== "ready")
|
|
301
|
+
return;
|
|
302
|
+
setReady(pages);
|
|
303
|
+
setLoads((count) => count + 1);
|
|
285
304
|
}
|
|
286
305
|
}) : null
|
|
287
306
|
]
|
|
288
307
|
});
|
|
289
308
|
}
|
|
309
|
+
function useCanvasPort(id, gestures, handle, loads, page) {
|
|
310
|
+
useEffect(() => {
|
|
311
|
+
if (loads === 0 || !gestures)
|
|
312
|
+
return;
|
|
313
|
+
const channel = new MessageChannel;
|
|
314
|
+
channel.port1.onmessage = (message) => {
|
|
315
|
+
const event = parseFrameEvent(message.data);
|
|
316
|
+
if (event)
|
|
317
|
+
gestures.receive(id, event, page.current);
|
|
318
|
+
};
|
|
319
|
+
const tell = (moving, transfer = []) => {
|
|
320
|
+
handle.current?.send("canvas", { moving }, transfer).catch(() => {});
|
|
321
|
+
};
|
|
322
|
+
tell(gestures.moving(), [channel.port2]);
|
|
323
|
+
const stop = gestures.onMoving((moving) => tell(moving));
|
|
324
|
+
return () => {
|
|
325
|
+
stop();
|
|
326
|
+
channel.port1.close();
|
|
327
|
+
};
|
|
328
|
+
}, [id, gestures, handle, loads, page]);
|
|
329
|
+
}
|
|
290
330
|
|
|
291
331
|
// src/artifacts/renderers/canvas/editing.tsx
|
|
292
332
|
import { ARTIFACT_LIMITS } from "@sixb/core/artifacts";
|
|
@@ -867,571 +907,13 @@ function FloatingArrow({ id, source, target, data, selected }) {
|
|
|
867
907
|
});
|
|
868
908
|
}
|
|
869
909
|
|
|
870
|
-
// src/artifacts/renderers/canvas/comment-pins.tsx
|
|
871
|
-
import { cn as cn5 } from "@sixb/ui/lib/utils";
|
|
872
|
-
import { useStore, ViewportPortal } from "@xyflow/react";
|
|
873
|
-
import { ArrowUp, LoaderCircle, X } from "lucide-react";
|
|
874
|
-
import {
|
|
875
|
-
memo as memo3,
|
|
876
|
-
useCallback,
|
|
877
|
-
useId,
|
|
878
|
-
useState as useState3
|
|
879
|
-
} from "react";
|
|
880
|
-
|
|
881
|
-
// src/artifacts/guest-badge.tsx
|
|
882
|
-
import { cn as cn4 } from "@sixb/ui/lib/utils";
|
|
883
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
884
|
-
function GuestBadge({ className }) {
|
|
885
|
-
const messages = useArtifactMessages().canvas.comments;
|
|
886
|
-
return /* @__PURE__ */ jsx5("span", {
|
|
887
|
-
title: messages.guestHint,
|
|
888
|
-
className: cn4("inline-flex h-4 shrink-0 items-center rounded-full bg-muted px-1.5 text-[10.5px] leading-none font-medium tracking-[0.01em] text-muted-foreground ring-1 ring-border/70 ring-inset", className),
|
|
889
|
-
children: messages.guest
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
// src/artifacts/renderers/canvas/comments.ts
|
|
894
|
-
import {
|
|
895
|
-
addArtifactComment,
|
|
896
|
-
deleteArtifactComment,
|
|
897
|
-
isSixbApiError,
|
|
898
|
-
resolveArtifactComment
|
|
899
|
-
} from "@sixb/client";
|
|
900
|
-
import { listArtifactCommentsOptions, listArtifactCommentsQueryKey } from "@sixb/client/hooks";
|
|
901
|
-
import { useQuery } from "@tanstack/react-query";
|
|
902
|
-
import { useMemo } from "react";
|
|
903
|
-
class CommentActionError extends Error {
|
|
904
|
-
failure;
|
|
905
|
-
name = "CommentActionError";
|
|
906
|
-
constructor(failure) {
|
|
907
|
-
super(`[SixbApp] The comment action failed: ${failure}.`);
|
|
908
|
-
this.failure = failure;
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
function commentThreads(comments) {
|
|
912
|
-
const replies = new Map;
|
|
913
|
-
for (const comment of comments) {
|
|
914
|
-
if (!comment.parentId)
|
|
915
|
-
continue;
|
|
916
|
-
const list = replies.get(comment.parentId) ?? [];
|
|
917
|
-
list.push(comment);
|
|
918
|
-
replies.set(comment.parentId, list);
|
|
919
|
-
}
|
|
920
|
-
return comments.filter((comment) => !comment.parentId).map((comment, index) => ({
|
|
921
|
-
comment,
|
|
922
|
-
replies: replies.get(comment.id) ?? [],
|
|
923
|
-
number: index + 1
|
|
924
|
-
}));
|
|
925
|
-
}
|
|
926
|
-
var NO_COMMENTS = [];
|
|
927
|
-
function useArtifactComments(artifactId) {
|
|
928
|
-
const query = useQuery({
|
|
929
|
-
...listArtifactCommentsOptions({ path: { artifactId: artifactId ?? "" } }),
|
|
930
|
-
enabled: artifactId !== null,
|
|
931
|
-
retry: false
|
|
932
|
-
});
|
|
933
|
-
const comments = query.data?.comments ?? NO_COMMENTS;
|
|
934
|
-
const threads = useMemo(() => commentThreads(comments), [comments]);
|
|
935
|
-
return { threads, loading: query.isLoading, failed: query.isError };
|
|
936
|
-
}
|
|
937
|
-
function commentsKey(artifactId) {
|
|
938
|
-
return listArtifactCommentsQueryKey({ path: { artifactId } });
|
|
939
|
-
}
|
|
940
|
-
function updateCached(queries, artifactId, update) {
|
|
941
|
-
queries.setQueryData(commentsKey(artifactId), (current) => current ? { ...current, comments: [...update(current.comments)] } : current);
|
|
942
|
-
}
|
|
943
|
-
async function addComment(queries, artifactId, body) {
|
|
944
|
-
try {
|
|
945
|
-
const { data } = await addArtifactComment({
|
|
946
|
-
path: { artifactId },
|
|
947
|
-
body,
|
|
948
|
-
throwOnError: true
|
|
949
|
-
});
|
|
950
|
-
updateCached(queries, artifactId, (comments) => comments.some((comment) => comment.id === data.id) ? comments : [...comments, data]);
|
|
951
|
-
return data;
|
|
952
|
-
} catch (error) {
|
|
953
|
-
throw commentError(error);
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
async function resolveComment(queries, artifactId, commentId, resolved) {
|
|
957
|
-
try {
|
|
958
|
-
const { data } = await resolveArtifactComment({
|
|
959
|
-
path: { artifactId, commentId },
|
|
960
|
-
body: { resolved },
|
|
961
|
-
throwOnError: true
|
|
962
|
-
});
|
|
963
|
-
updateCached(queries, artifactId, (comments) => comments.map((comment) => comment.id === data.id ? data : comment));
|
|
964
|
-
} catch (error) {
|
|
965
|
-
throw commentError(error);
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
async function deleteComment(queries, artifactId, commentId) {
|
|
969
|
-
try {
|
|
970
|
-
await deleteArtifactComment({ path: { artifactId, commentId }, throwOnError: true });
|
|
971
|
-
updateCached(queries, artifactId, (comments) => comments.filter((comment) => comment.id !== commentId && comment.parentId !== commentId));
|
|
972
|
-
} catch (error) {
|
|
973
|
-
throw commentError(error);
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
function commentError(error) {
|
|
977
|
-
if (!isSixbApiError(error))
|
|
978
|
-
return new CommentActionError("failed");
|
|
979
|
-
switch (error.code) {
|
|
980
|
-
case "comments_full":
|
|
981
|
-
return new CommentActionError("full");
|
|
982
|
-
case "invalid_comment":
|
|
983
|
-
return new CommentActionError("invalid");
|
|
984
|
-
case "name_required":
|
|
985
|
-
case "invalid_name":
|
|
986
|
-
return new CommentActionError("name");
|
|
987
|
-
case "not_allowed":
|
|
988
|
-
return new CommentActionError("notAllowed");
|
|
989
|
-
case "comment_not_found":
|
|
990
|
-
case "artifact_not_found":
|
|
991
|
-
return new CommentActionError("gone");
|
|
992
|
-
default:
|
|
993
|
-
return new CommentActionError("failed");
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
function canManageComment(comment, access, userId) {
|
|
997
|
-
if (access === "owner" || access === "update")
|
|
998
|
-
return true;
|
|
999
|
-
return comment.author.type === "user" && comment.author.id === userId;
|
|
1000
|
-
}
|
|
1001
|
-
function useCommentAuthors() {
|
|
1002
|
-
const user = useCurrentUser2();
|
|
1003
|
-
const guest = useSharedGuest2();
|
|
1004
|
-
const messages = useArtifactMessages().canvas.comments;
|
|
1005
|
-
return ({ author, authorName, origin }) => {
|
|
1006
|
-
if (author.type === "guest") {
|
|
1007
|
-
const name = authorName ?? messages.guest;
|
|
1008
|
-
return { name, you: author.id === guest?.id, guest: true };
|
|
1009
|
-
}
|
|
1010
|
-
const own = author.type === "user" && author.id === user?.id;
|
|
1011
|
-
if (origin) {
|
|
1012
|
-
const name = own ? messages.you.toLowerCase() : authorName ?? messages.someone;
|
|
1013
|
-
return { name: messages.agentFor(name), you: false, agent: true };
|
|
1014
|
-
}
|
|
1015
|
-
if (own)
|
|
1016
|
-
return { name: user.displayName ?? user.email ?? authorName ?? "", you: true };
|
|
1017
|
-
return authorName ? { name: authorName, you: false } : null;
|
|
1018
|
-
};
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
// src/artifacts/renderers/canvas/comment-pins.tsx
|
|
1022
|
-
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1023
|
-
function pinPoint(pin, index) {
|
|
1024
|
-
return pin.point ?? { x: 1, y: 0.02 + index * 0.06 };
|
|
1025
|
-
}
|
|
1026
|
-
var CARD_WIDTH = 288;
|
|
1027
|
-
function cardPlace(x, width) {
|
|
1028
|
-
const card = Math.min(CARD_WIDTH, width - 16);
|
|
1029
|
-
const beside = 36;
|
|
1030
|
-
const left = Math.max(8 - x, Math.min(beside, width - 8 - card - x));
|
|
1031
|
-
return { left, width: card };
|
|
1032
|
-
}
|
|
1033
|
-
function CommentPin({
|
|
1034
|
-
number,
|
|
1035
|
-
label,
|
|
1036
|
-
active,
|
|
1037
|
-
resolved,
|
|
1038
|
-
draft = false,
|
|
1039
|
-
onClick,
|
|
1040
|
-
style
|
|
1041
|
-
}) {
|
|
1042
|
-
return /* @__PURE__ */ jsx6("button", {
|
|
1043
|
-
type: "button",
|
|
1044
|
-
"aria-label": label,
|
|
1045
|
-
title: label,
|
|
1046
|
-
"aria-pressed": onClick ? active : undefined,
|
|
1047
|
-
"data-comment-pin": number ?? "draft",
|
|
1048
|
-
onClick: (event) => {
|
|
1049
|
-
event.stopPropagation();
|
|
1050
|
-
onClick?.();
|
|
1051
|
-
},
|
|
1052
|
-
className: cn5("nodrag nopan nowheel pointer-events-auto absolute flex h-7 min-w-7 origin-bottom-left -translate-y-full items-center justify-center rounded-full rounded-bl-[4px] px-1.5 text-[12px] font-semibold tabular-nums shadow-[0_1px_2px_rgb(0_0_0/0.12),0_6px_16px_-6px_rgb(0_0_0/0.35)] outline-none ring-2 ring-background transition-[transform,background-color] duration-150 focus-visible:ring-ring motion-safe:hover:scale-110", draft || active ? "bg-primary text-primary-foreground" : resolved ? "bg-muted text-muted-foreground" : "bg-foreground text-background", draft && "motion-safe:animate-in motion-safe:zoom-in-50 motion-safe:fade-in-0"),
|
|
1053
|
-
style,
|
|
1054
|
-
children: draft ? /* @__PURE__ */ jsx6("span", {
|
|
1055
|
-
className: "size-1.5 rounded-full bg-current",
|
|
1056
|
-
"aria-hidden": "true"
|
|
1057
|
-
}) : number
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
function CommentComposer({
|
|
1061
|
-
placeholder,
|
|
1062
|
-
onSubmit,
|
|
1063
|
-
onCancel,
|
|
1064
|
-
autoFocus = true,
|
|
1065
|
-
compact = false,
|
|
1066
|
-
className
|
|
1067
|
-
}) {
|
|
1068
|
-
const messages = useArtifactMessages().canvas.comments;
|
|
1069
|
-
const guest = useSharedGuest2();
|
|
1070
|
-
const giveName = useGiveGuestName();
|
|
1071
|
-
const [body, setBody] = useState3("");
|
|
1072
|
-
const [name, setName] = useState3("");
|
|
1073
|
-
const [sending, setSending] = useState3(false);
|
|
1074
|
-
const [failure, setFailure] = useState3(null);
|
|
1075
|
-
const naming = guest !== null && guest.name === undefined;
|
|
1076
|
-
const ready = body.trim().length > 0 && (!naming || name.trim().length > 0) && !sending;
|
|
1077
|
-
const submit = async () => {
|
|
1078
|
-
if (!ready)
|
|
1079
|
-
return;
|
|
1080
|
-
setSending(true);
|
|
1081
|
-
setFailure(null);
|
|
1082
|
-
try {
|
|
1083
|
-
if (naming) {
|
|
1084
|
-
await giveName(name).catch(() => {
|
|
1085
|
-
throw new CommentActionError("name");
|
|
1086
|
-
});
|
|
1087
|
-
}
|
|
1088
|
-
await onSubmit(body.trim());
|
|
1089
|
-
setBody("");
|
|
1090
|
-
} catch (error) {
|
|
1091
|
-
setFailure(error instanceof CommentActionError ? error.failure : "failed");
|
|
1092
|
-
} finally {
|
|
1093
|
-
setSending(false);
|
|
1094
|
-
}
|
|
1095
|
-
};
|
|
1096
|
-
const onKeyDown = (event) => {
|
|
1097
|
-
event.stopPropagation();
|
|
1098
|
-
const composing = event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229;
|
|
1099
|
-
if (event.key === "Enter" && !event.shiftKey && !composing) {
|
|
1100
|
-
event.preventDefault();
|
|
1101
|
-
submit();
|
|
1102
|
-
}
|
|
1103
|
-
if (event.key === "Escape") {
|
|
1104
|
-
event.preventDefault();
|
|
1105
|
-
onCancel?.();
|
|
1106
|
-
}
|
|
1107
|
-
};
|
|
1108
|
-
return /* @__PURE__ */ jsxs5("div", {
|
|
1109
|
-
className: cn5("flex flex-col gap-1.5", className),
|
|
1110
|
-
"data-board-tools": "",
|
|
1111
|
-
children: [
|
|
1112
|
-
naming ? /* @__PURE__ */ jsx6(GuestNameField, {
|
|
1113
|
-
value: name,
|
|
1114
|
-
onChange: setName,
|
|
1115
|
-
autoFocus,
|
|
1116
|
-
invalid: failure === "name",
|
|
1117
|
-
onKeyDown
|
|
1118
|
-
}) : null,
|
|
1119
|
-
/* @__PURE__ */ jsxs5("div", {
|
|
1120
|
-
className: "flex items-end gap-1.5 rounded-xl border border-border bg-background px-2.5 py-1.5 focus-within:ring-2 focus-within:ring-ring/40",
|
|
1121
|
-
children: [
|
|
1122
|
-
/* @__PURE__ */ jsx6("textarea", {
|
|
1123
|
-
autoFocus: autoFocus && !naming,
|
|
1124
|
-
value: body,
|
|
1125
|
-
rows: 1,
|
|
1126
|
-
maxLength: 4000,
|
|
1127
|
-
"aria-label": placeholder,
|
|
1128
|
-
placeholder,
|
|
1129
|
-
onChange: (event) => setBody(event.target.value),
|
|
1130
|
-
onKeyDown,
|
|
1131
|
-
className: "max-h-40 min-h-6 flex-1 resize-none bg-transparent py-0.5 text-sm leading-5 outline-none [field-sizing:content] placeholder:text-muted-foreground"
|
|
1132
|
-
}),
|
|
1133
|
-
/* @__PURE__ */ jsx6("button", {
|
|
1134
|
-
type: "button",
|
|
1135
|
-
"aria-label": compact ? messages.reply : messages.post,
|
|
1136
|
-
title: compact ? messages.reply : messages.post,
|
|
1137
|
-
disabled: !ready,
|
|
1138
|
-
onClick: () => void submit(),
|
|
1139
|
-
className: "mb-0.5 flex size-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background outline-none transition-colors hover:bg-foreground/85 focus-visible:ring-2 focus-visible:ring-ring disabled:bg-foreground/20 [&_svg]:size-3.5",
|
|
1140
|
-
children: sending ? /* @__PURE__ */ jsx6(LoaderCircle, {
|
|
1141
|
-
className: "animate-spin motion-reduce:animate-none",
|
|
1142
|
-
"aria-hidden": "true"
|
|
1143
|
-
}) : /* @__PURE__ */ jsx6(ArrowUp, {
|
|
1144
|
-
"aria-hidden": "true"
|
|
1145
|
-
})
|
|
1146
|
-
})
|
|
1147
|
-
]
|
|
1148
|
-
}),
|
|
1149
|
-
failure ? /* @__PURE__ */ jsx6("p", {
|
|
1150
|
-
role: "alert",
|
|
1151
|
-
className: "m-0 px-1 text-xs text-destructive",
|
|
1152
|
-
children: messages.failures[failure]
|
|
1153
|
-
}) : null
|
|
1154
|
-
]
|
|
1155
|
-
});
|
|
1156
|
-
}
|
|
1157
|
-
function GuestNameField({
|
|
1158
|
-
value,
|
|
1159
|
-
onChange,
|
|
1160
|
-
autoFocus,
|
|
1161
|
-
invalid,
|
|
1162
|
-
onKeyDown
|
|
1163
|
-
}) {
|
|
1164
|
-
const messages = useArtifactMessages().canvas.comments;
|
|
1165
|
-
const id = useId();
|
|
1166
|
-
return /* @__PURE__ */ jsxs5("div", {
|
|
1167
|
-
className: "flex flex-col gap-1 px-1 pt-0.5",
|
|
1168
|
-
children: [
|
|
1169
|
-
/* @__PURE__ */ jsxs5("div", {
|
|
1170
|
-
className: "flex items-center gap-2",
|
|
1171
|
-
children: [
|
|
1172
|
-
/* @__PURE__ */ jsx6(PersonAvatar, {
|
|
1173
|
-
name: value.trim() || messages.guest,
|
|
1174
|
-
size: "xs"
|
|
1175
|
-
}),
|
|
1176
|
-
/* @__PURE__ */ jsx6("input", {
|
|
1177
|
-
id,
|
|
1178
|
-
autoFocus,
|
|
1179
|
-
value,
|
|
1180
|
-
maxLength: GUEST_NAME_INPUT_LENGTH,
|
|
1181
|
-
autoComplete: "name",
|
|
1182
|
-
"aria-label": messages.guestName,
|
|
1183
|
-
"aria-invalid": invalid,
|
|
1184
|
-
"aria-describedby": `${id}-hint`,
|
|
1185
|
-
placeholder: messages.guestName,
|
|
1186
|
-
onChange: (event) => onChange(event.target.value),
|
|
1187
|
-
onKeyDown,
|
|
1188
|
-
className: "h-7 min-w-0 flex-1 bg-transparent text-sm font-medium text-foreground outline-none placeholder:font-normal placeholder:text-muted-foreground"
|
|
1189
|
-
}),
|
|
1190
|
-
/* @__PURE__ */ jsx6(GuestBadge, {})
|
|
1191
|
-
]
|
|
1192
|
-
}),
|
|
1193
|
-
/* @__PURE__ */ jsx6("p", {
|
|
1194
|
-
id: `${id}-hint`,
|
|
1195
|
-
className: "m-0 pl-7 text-[11px] leading-4 text-muted-foreground",
|
|
1196
|
-
children: messages.guestNameHint
|
|
1197
|
-
})
|
|
1198
|
-
]
|
|
1199
|
-
});
|
|
1200
|
-
}
|
|
1201
|
-
var GUEST_NAME_INPUT_LENGTH = 80;
|
|
1202
|
-
function DraftCard({
|
|
1203
|
-
anchor,
|
|
1204
|
-
onSubmit,
|
|
1205
|
-
onCancel
|
|
1206
|
-
}) {
|
|
1207
|
-
const messages = useArtifactMessages().canvas.comments;
|
|
1208
|
-
return /* @__PURE__ */ jsxs5("div", {
|
|
1209
|
-
role: "dialog",
|
|
1210
|
-
"aria-label": messages.newPin,
|
|
1211
|
-
className: "nodrag nopan nowheel pointer-events-auto w-full min-w-56 rounded-2xl border border-border bg-popover p-1.5 text-popover-foreground shadow-[0_2px_4px_rgb(0_0_0/0.06),0_18px_40px_-16px_rgb(0_0_0/0.35)] motion-safe:animate-in motion-safe:fade-in-0 motion-safe:zoom-in-95 motion-safe:slide-in-from-top-1",
|
|
1212
|
-
onPointerDown: (event) => event.stopPropagation(),
|
|
1213
|
-
children: [
|
|
1214
|
-
/* @__PURE__ */ jsxs5("div", {
|
|
1215
|
-
className: "flex h-7 items-center gap-1 pr-0.5 pl-2",
|
|
1216
|
-
children: [
|
|
1217
|
-
/* @__PURE__ */ jsx6("p", {
|
|
1218
|
-
className: "m-0 min-w-0 flex-1 truncate text-xs text-muted-foreground",
|
|
1219
|
-
children: anchor ? messages.about(anchor) : messages.newPin
|
|
1220
|
-
}),
|
|
1221
|
-
/* @__PURE__ */ jsx6("button", {
|
|
1222
|
-
type: "button",
|
|
1223
|
-
"aria-label": messages.cancel,
|
|
1224
|
-
title: messages.cancel,
|
|
1225
|
-
onClick: onCancel,
|
|
1226
|
-
className: "flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",
|
|
1227
|
-
children: /* @__PURE__ */ jsx6(X, {
|
|
1228
|
-
"aria-hidden": "true"
|
|
1229
|
-
})
|
|
1230
|
-
})
|
|
1231
|
-
]
|
|
1232
|
-
}),
|
|
1233
|
-
/* @__PURE__ */ jsx6(CommentComposer, {
|
|
1234
|
-
placeholder: messages.placeholder,
|
|
1235
|
-
onSubmit,
|
|
1236
|
-
onCancel
|
|
1237
|
-
})
|
|
1238
|
-
]
|
|
1239
|
-
});
|
|
1240
|
-
}
|
|
1241
|
-
var CanvasCommentPins = memo3(function CanvasCommentPins({
|
|
1242
|
-
pins,
|
|
1243
|
-
active,
|
|
1244
|
-
draft,
|
|
1245
|
-
onOpen,
|
|
1246
|
-
onSubmitDraft,
|
|
1247
|
-
onCancelDraft
|
|
1248
|
-
}) {
|
|
1249
|
-
const messages = useArtifactMessages().canvas.comments;
|
|
1250
|
-
const zoom = useStore((state) => state.transform[2]);
|
|
1251
|
-
const view = useStore(viewOf, sameView);
|
|
1252
|
-
const boards = [...new Set([...pins.map((pin) => pin.board), ...draft ? [draft.board] : []])];
|
|
1253
|
-
const boxes = useBoardBoxes(boards);
|
|
1254
|
-
const unplaced = new Map;
|
|
1255
|
-
const scale = `scale(${1 / zoom})`;
|
|
1256
|
-
const draftBox = draft ? boxes.get(draft.board) : undefined;
|
|
1257
|
-
if (boxes.size === 0)
|
|
1258
|
-
return null;
|
|
1259
|
-
return /* @__PURE__ */ jsxs5(ViewportPortal, {
|
|
1260
|
-
children: [
|
|
1261
|
-
pins.map((pin) => {
|
|
1262
|
-
const box = boxes.get(pin.board);
|
|
1263
|
-
if (!box)
|
|
1264
|
-
return null;
|
|
1265
|
-
const index = pin.point ? 0 : unplaced.get(pin.board) ?? 0;
|
|
1266
|
-
if (!pin.point)
|
|
1267
|
-
unplaced.set(pin.board, index + 1);
|
|
1268
|
-
const at = pinPoint(pin, index);
|
|
1269
|
-
return /* @__PURE__ */ jsx6("div", {
|
|
1270
|
-
className: "pointer-events-none absolute top-0 left-0",
|
|
1271
|
-
style: {
|
|
1272
|
-
transform: `translate(${box.x + at.x * box.w}px, ${box.y + at.y * box.h}px) ${scale}`,
|
|
1273
|
-
transformOrigin: "0 0"
|
|
1274
|
-
},
|
|
1275
|
-
children: /* @__PURE__ */ jsx6(CommentPin, {
|
|
1276
|
-
number: pin.number,
|
|
1277
|
-
label: pin.label,
|
|
1278
|
-
active: active === pin.id,
|
|
1279
|
-
resolved: pin.resolved,
|
|
1280
|
-
onClick: () => onOpen(pin.id)
|
|
1281
|
-
})
|
|
1282
|
-
}, pin.id);
|
|
1283
|
-
}),
|
|
1284
|
-
draft && draftBox ? /* @__PURE__ */ jsxs5(DraftAt, {
|
|
1285
|
-
box: draftBox,
|
|
1286
|
-
draft,
|
|
1287
|
-
scale,
|
|
1288
|
-
children: [
|
|
1289
|
-
/* @__PURE__ */ jsx6(CommentPin, {
|
|
1290
|
-
label: messages.newPin,
|
|
1291
|
-
active: true,
|
|
1292
|
-
resolved: false,
|
|
1293
|
-
draft: true
|
|
1294
|
-
}),
|
|
1295
|
-
/* @__PURE__ */ jsx6("div", {
|
|
1296
|
-
className: "absolute top-0",
|
|
1297
|
-
style: cardPlace(view.x + (draftBox.x + draft.point.x * draftBox.w) * zoom, view.width),
|
|
1298
|
-
children: /* @__PURE__ */ jsx6(DraftCard, {
|
|
1299
|
-
...draft.anchor ? { anchor: draft.anchor } : {},
|
|
1300
|
-
onSubmit: onSubmitDraft,
|
|
1301
|
-
onCancel: onCancelDraft
|
|
1302
|
-
})
|
|
1303
|
-
})
|
|
1304
|
-
]
|
|
1305
|
-
}) : null
|
|
1306
|
-
]
|
|
1307
|
-
});
|
|
1308
|
-
});
|
|
1309
|
-
function DraftAt({
|
|
1310
|
-
box,
|
|
1311
|
-
draft,
|
|
1312
|
-
scale,
|
|
1313
|
-
children
|
|
1314
|
-
}) {
|
|
1315
|
-
return /* @__PURE__ */ jsx6("div", {
|
|
1316
|
-
className: "pointer-events-none absolute top-0 left-0",
|
|
1317
|
-
style: {
|
|
1318
|
-
transform: `translate(${box.x + draft.point.x * box.w}px, ${box.y + draft.point.y * box.h}px) ${scale}`,
|
|
1319
|
-
transformOrigin: "0 0"
|
|
1320
|
-
},
|
|
1321
|
-
children
|
|
1322
|
-
});
|
|
1323
|
-
}
|
|
1324
|
-
function viewOf(state) {
|
|
1325
|
-
return { x: state.transform[0] ?? 0, width: state.width };
|
|
1326
|
-
}
|
|
1327
|
-
function sameView(left, right) {
|
|
1328
|
-
return left.x === right.x && left.width === right.width;
|
|
1329
|
-
}
|
|
1330
|
-
function useBoardBoxes(ids) {
|
|
1331
|
-
const key = ids.join(`
|
|
1332
|
-
`);
|
|
1333
|
-
const select = useCallback((state) => {
|
|
1334
|
-
const boxes = new Map;
|
|
1335
|
-
for (const id of key ? key.split(`
|
|
1336
|
-
`) : []) {
|
|
1337
|
-
const node = state.nodeLookup.get(id);
|
|
1338
|
-
const w = node?.measured.width ?? node?.width;
|
|
1339
|
-
const h = node?.measured.height ?? node?.height;
|
|
1340
|
-
if (!node || w === undefined || h === undefined)
|
|
1341
|
-
continue;
|
|
1342
|
-
const { x, y } = node.internals.positionAbsolute;
|
|
1343
|
-
boxes.set(id, { x, y, w, h });
|
|
1344
|
-
}
|
|
1345
|
-
return boxes;
|
|
1346
|
-
}, [key]);
|
|
1347
|
-
return useStore(select, sameBoxes);
|
|
1348
|
-
}
|
|
1349
|
-
function sameBoxes(left, right) {
|
|
1350
|
-
if (left.size !== right.size)
|
|
1351
|
-
return false;
|
|
1352
|
-
for (const [id, box] of left) {
|
|
1353
|
-
const other = right.get(id);
|
|
1354
|
-
if (!other || other.x !== box.x || other.y !== box.y || other.w !== box.w || other.h !== box.h) {
|
|
1355
|
-
return false;
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
return true;
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
910
|
// src/artifacts/renderers/canvas/commenting.tsx
|
|
1362
911
|
import { boardElements } from "@sixb/core/artifacts/live";
|
|
1363
|
-
import { cn as
|
|
912
|
+
import { cn as cn4 } from "@sixb/ui/lib/utils";
|
|
1364
913
|
import { useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
1365
914
|
import { MessageSquare, MessageSquarePlus } from "lucide-react";
|
|
1366
|
-
import { useCallback
|
|
1367
|
-
|
|
1368
|
-
// src/artifacts/live/boards.ts
|
|
1369
|
-
import { LIVE_FILES } from "@sixb/core/artifacts/live";
|
|
1370
|
-
import { useCallback as useCallback2, useMemo as useMemo2, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
1371
|
-
import * as Y from "yjs";
|
|
1372
|
-
function liveBoardSource(doc, path) {
|
|
1373
|
-
const entry = doc.getMap(LIVE_FILES).get(path);
|
|
1374
|
-
return entry instanceof Y.Text ? entry.toString() : null;
|
|
1375
|
-
}
|
|
1376
|
-
function liveStoredFiles(doc) {
|
|
1377
|
-
const files = new Map;
|
|
1378
|
-
doc.getMap(LIVE_FILES).forEach((entry, path) => {
|
|
1379
|
-
if (entry instanceof Y.Text || entry instanceof Y.Map)
|
|
1380
|
-
return;
|
|
1381
|
-
if (isFileRef(entry))
|
|
1382
|
-
files.set(path, entry);
|
|
1383
|
-
});
|
|
1384
|
-
return files;
|
|
1385
|
-
}
|
|
1386
|
-
function isFileRef(value) {
|
|
1387
|
-
return typeof value === "object" && value !== null && typeof value.blobId === "string";
|
|
1388
|
-
}
|
|
1389
|
-
function useLiveBoardSource(live, path) {
|
|
1390
|
-
const subscribe = useCallback2((listener) => {
|
|
1391
|
-
if (!live)
|
|
1392
|
-
return () => {};
|
|
1393
|
-
const files = live.doc.getMap(LIVE_FILES);
|
|
1394
|
-
let text = null;
|
|
1395
|
-
const follow = () => {
|
|
1396
|
-
text?.unobserve(listener);
|
|
1397
|
-
const entry = files.get(path);
|
|
1398
|
-
text = entry instanceof Y.Text ? entry : null;
|
|
1399
|
-
text?.observe(listener);
|
|
1400
|
-
};
|
|
1401
|
-
const onFiles = (event) => {
|
|
1402
|
-
if (!event.keysChanged.has(path))
|
|
1403
|
-
return;
|
|
1404
|
-
follow();
|
|
1405
|
-
listener();
|
|
1406
|
-
};
|
|
1407
|
-
follow();
|
|
1408
|
-
files.observe(onFiles);
|
|
1409
|
-
return () => {
|
|
1410
|
-
files.unobserve(onFiles);
|
|
1411
|
-
text?.unobserve(listener);
|
|
1412
|
-
};
|
|
1413
|
-
}, [live, path]);
|
|
1414
|
-
return useSyncExternalStore3(subscribe, () => live ? liveBoardSource(live.doc, path) : null, () => null);
|
|
1415
|
-
}
|
|
1416
|
-
function useLiveStoredFiles(live) {
|
|
1417
|
-
const subscribe = useCallback2((listener) => {
|
|
1418
|
-
if (!live)
|
|
1419
|
-
return () => {};
|
|
1420
|
-
const files = live.doc.getMap(LIVE_FILES);
|
|
1421
|
-
files.observe(listener);
|
|
1422
|
-
return () => files.unobserve(listener);
|
|
1423
|
-
}, [live]);
|
|
1424
|
-
const snapshot = useCallback2(() => live ? storedFilesKey(live.doc) : "", [live]);
|
|
1425
|
-
const key = useSyncExternalStore3(subscribe, snapshot, () => "");
|
|
1426
|
-
return useMemo2(() => live ? liveStoredFiles(live.doc) : new Map, [live, key]);
|
|
1427
|
-
}
|
|
1428
|
-
function storedFilesKey(doc) {
|
|
1429
|
-
return [...liveStoredFiles(doc)].map(([path, ref]) => `${path}:${ref.digest}`).join(`
|
|
1430
|
-
`);
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
// src/artifacts/renderers/canvas/commenting.tsx
|
|
1434
|
-
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
915
|
+
import { useCallback, useMemo, useRef as useRef3, useState as useState3 } from "react";
|
|
916
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1435
917
|
function useCanvasCommenting({
|
|
1436
918
|
artifactId,
|
|
1437
919
|
live,
|
|
@@ -1446,14 +928,14 @@ function useCanvasCommenting({
|
|
|
1446
928
|
const agentDraft = useAgentDraft();
|
|
1447
929
|
const { threads, loading, failed } = useArtifactComments(artifactId);
|
|
1448
930
|
const nameOf = useCommentAuthors();
|
|
1449
|
-
const [commenting, setCommenting] =
|
|
1450
|
-
const [panel, setPanel] =
|
|
1451
|
-
const [filter, setFilter] =
|
|
1452
|
-
const [active, setActive] =
|
|
1453
|
-
const [draft, setDraft] =
|
|
1454
|
-
const titles =
|
|
931
|
+
const [commenting, setCommenting] = useState3(false);
|
|
932
|
+
const [panel, setPanel] = useState3(false);
|
|
933
|
+
const [filter, setFilter] = useState3("open");
|
|
934
|
+
const [active, setActive] = useState3(null);
|
|
935
|
+
const [draft, setDraft] = useState3(null);
|
|
936
|
+
const titles = useMemo(() => new Map(boards.map((board) => [board.id, board.title ?? board.id])), [boards]);
|
|
1455
937
|
const addresses = useRef3(new Map);
|
|
1456
|
-
const placeOf =
|
|
938
|
+
const placeOf = useCallback((thread) => {
|
|
1457
939
|
const { anchor } = thread.comment;
|
|
1458
940
|
const board = anchor.board ? boards.find((each) => each.id === anchor.board) : undefined;
|
|
1459
941
|
const name = anchor.board ? titles.get(anchor.board) ?? anchor.board : null;
|
|
@@ -1478,7 +960,7 @@ function useCanvasCommenting({
|
|
|
1478
960
|
gone
|
|
1479
961
|
};
|
|
1480
962
|
}, [boards, titles, live]);
|
|
1481
|
-
const pins =
|
|
963
|
+
const pins = useMemo(() => threads.flatMap((thread) => {
|
|
1482
964
|
const { comment } = thread;
|
|
1483
965
|
const resolved = Boolean(comment.resolvedAt);
|
|
1484
966
|
if (!comment.anchor.board)
|
|
@@ -1496,13 +978,13 @@ function useCanvasCommenting({
|
|
|
1496
978
|
}
|
|
1497
979
|
];
|
|
1498
980
|
}), [threads, filter, messages, nameOf]);
|
|
1499
|
-
const pick =
|
|
981
|
+
const pick = useCallback((board, place, where) => setDraft({
|
|
1500
982
|
board,
|
|
1501
983
|
...place,
|
|
1502
984
|
anchor: place.anchor ?? (place.label ? `\u201C${place.label}\u201D` : titles.get(board) ?? board),
|
|
1503
985
|
where
|
|
1504
986
|
}), [titles]);
|
|
1505
|
-
const submitDraft =
|
|
987
|
+
const submitDraft = useCallback(async (body) => {
|
|
1506
988
|
if (!draft || !artifactId)
|
|
1507
989
|
return;
|
|
1508
990
|
const created = await addComment(queries, artifactId, {
|
|
@@ -1520,25 +1002,25 @@ function useCanvasCommenting({
|
|
|
1520
1002
|
setFilter("open");
|
|
1521
1003
|
setPanel(true);
|
|
1522
1004
|
}, [draft, artifactId, queries, revision]);
|
|
1523
|
-
const reply =
|
|
1005
|
+
const reply = useCallback(async (thread, body) => {
|
|
1524
1006
|
if (!artifactId)
|
|
1525
1007
|
return;
|
|
1526
1008
|
await addComment(queries, artifactId, { body, parentId: thread.comment.id });
|
|
1527
1009
|
}, [artifactId, queries]);
|
|
1528
|
-
const resolve =
|
|
1010
|
+
const resolve = useCallback(async (thread, resolved) => {
|
|
1529
1011
|
if (!artifactId)
|
|
1530
1012
|
return;
|
|
1531
1013
|
await resolveComment(queries, artifactId, thread.comment.id, resolved);
|
|
1532
1014
|
if (resolved)
|
|
1533
1015
|
setActive((current) => current === thread.comment.id ? null : current);
|
|
1534
1016
|
}, [artifactId, queries]);
|
|
1535
|
-
const remove =
|
|
1017
|
+
const remove = useCallback(async (thread) => {
|
|
1536
1018
|
if (!artifactId)
|
|
1537
1019
|
return;
|
|
1538
1020
|
await deleteComment(queries, artifactId, thread.comment.id);
|
|
1539
1021
|
setActive((current) => current === thread.comment.id ? null : current);
|
|
1540
1022
|
}, [artifactId, queries]);
|
|
1541
|
-
const send =
|
|
1023
|
+
const send = useMemo(() => agentDraft && artifactId ? (chosen) => {
|
|
1542
1024
|
if (chosen.length === 0)
|
|
1543
1025
|
return;
|
|
1544
1026
|
const { context } = commentsContext({
|
|
@@ -1551,7 +1033,7 @@ function useCanvasCommenting({
|
|
|
1551
1033
|
} : null, [agentDraft, messages, title, artifactId]);
|
|
1552
1034
|
const access = view?.access ?? "read";
|
|
1553
1035
|
const userId = user?.id ?? null;
|
|
1554
|
-
const canManage =
|
|
1036
|
+
const canManage = useCallback((comment) => canManageComment(comment, access, userId), [access, userId]);
|
|
1555
1037
|
return {
|
|
1556
1038
|
enabled: artifactId !== null,
|
|
1557
1039
|
threads,
|
|
@@ -1590,35 +1072,35 @@ function CommentTools({
|
|
|
1590
1072
|
}) {
|
|
1591
1073
|
const messages = useArtifactMessages().canvas.comments;
|
|
1592
1074
|
const active = commenting.commenting;
|
|
1593
|
-
return /* @__PURE__ */
|
|
1594
|
-
className:
|
|
1075
|
+
return /* @__PURE__ */ jsxs5("div", {
|
|
1076
|
+
className: cn4("flex items-center gap-0.5 rounded-xl border border-border bg-background/95 p-1 shadow-[0_1px_2px_rgb(0_0_0/0.06),0_8px_24px_-12px_rgb(0_0_0/0.25)] backdrop-blur", className),
|
|
1595
1077
|
role: "group",
|
|
1596
1078
|
"aria-label": messages.title,
|
|
1597
1079
|
children: [
|
|
1598
|
-
/* @__PURE__ */
|
|
1080
|
+
/* @__PURE__ */ jsx5("button", {
|
|
1599
1081
|
type: "button",
|
|
1600
1082
|
"aria-label": messages.tool,
|
|
1601
1083
|
title: messages.toolHint,
|
|
1602
1084
|
"aria-pressed": active,
|
|
1603
1085
|
"aria-keyshortcuts": "C",
|
|
1604
1086
|
onClick: commenting.toggleCommenting,
|
|
1605
|
-
className:
|
|
1606
|
-
children: /* @__PURE__ */
|
|
1087
|
+
className: cn4("flex size-8 items-center justify-center rounded-lg text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-4", active && "bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground"),
|
|
1088
|
+
children: /* @__PURE__ */ jsx5(MessageSquarePlus, {
|
|
1607
1089
|
"aria-hidden": "true"
|
|
1608
1090
|
})
|
|
1609
1091
|
}),
|
|
1610
|
-
/* @__PURE__ */
|
|
1092
|
+
/* @__PURE__ */ jsxs5("button", {
|
|
1611
1093
|
type: "button",
|
|
1612
1094
|
"aria-label": messages.toggle(commenting.open),
|
|
1613
1095
|
title: messages.toggle(commenting.open),
|
|
1614
1096
|
"aria-pressed": commenting.panel,
|
|
1615
1097
|
onClick: () => commenting.setPanel(!commenting.panel),
|
|
1616
|
-
className:
|
|
1098
|
+
className: cn4("flex h-8 items-center gap-1.5 rounded-lg px-2 text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-4", commenting.panel && "bg-muted text-foreground"),
|
|
1617
1099
|
children: [
|
|
1618
|
-
/* @__PURE__ */
|
|
1100
|
+
/* @__PURE__ */ jsx5(MessageSquare, {
|
|
1619
1101
|
"aria-hidden": "true"
|
|
1620
1102
|
}),
|
|
1621
|
-
commenting.open > 0 ? /* @__PURE__ */
|
|
1103
|
+
commenting.open > 0 ? /* @__PURE__ */ jsx5("span", {
|
|
1622
1104
|
className: "text-xs font-medium tabular-nums",
|
|
1623
1105
|
children: commenting.open
|
|
1624
1106
|
}) : null
|
|
@@ -1629,19 +1111,19 @@ function CommentTools({
|
|
|
1629
1111
|
}
|
|
1630
1112
|
function CommentModeHint({ onExit }) {
|
|
1631
1113
|
const messages = useArtifactMessages().canvas.comments;
|
|
1632
|
-
return /* @__PURE__ */
|
|
1114
|
+
return /* @__PURE__ */ jsxs5("div", {
|
|
1633
1115
|
role: "status",
|
|
1634
1116
|
className: "pointer-events-auto flex max-w-[calc(100vw-2rem)] items-center gap-2 rounded-full border border-border bg-background/95 py-1 pr-1 pl-3 text-xs text-muted-foreground shadow-[0_1px_2px_rgb(0_0_0/0.06),0_8px_24px_-12px_rgb(0_0_0/0.25)] backdrop-blur motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1",
|
|
1635
1117
|
children: [
|
|
1636
|
-
/* @__PURE__ */
|
|
1118
|
+
/* @__PURE__ */ jsx5(MessageSquarePlus, {
|
|
1637
1119
|
className: "size-3.5 shrink-0 text-foreground",
|
|
1638
1120
|
"aria-hidden": "true"
|
|
1639
1121
|
}),
|
|
1640
|
-
/* @__PURE__ */
|
|
1122
|
+
/* @__PURE__ */ jsx5("span", {
|
|
1641
1123
|
className: "min-w-0 truncate",
|
|
1642
1124
|
children: messages.modeHint
|
|
1643
1125
|
}),
|
|
1644
|
-
/* @__PURE__ */
|
|
1126
|
+
/* @__PURE__ */ jsx5("button", {
|
|
1645
1127
|
type: "button",
|
|
1646
1128
|
onClick: onExit,
|
|
1647
1129
|
"aria-label": messages.exit,
|
|
@@ -1670,25 +1152,27 @@ import {
|
|
|
1670
1152
|
DropdownMenuTrigger
|
|
1671
1153
|
} from "@sixb/ui/components";
|
|
1672
1154
|
import { useLocale } from "@sixb/ui/lib/i18n";
|
|
1673
|
-
import { cn as
|
|
1155
|
+
import { cn as cn5 } from "@sixb/ui/lib/utils";
|
|
1674
1156
|
import {
|
|
1675
1157
|
Check,
|
|
1676
1158
|
CornerDownRight,
|
|
1159
|
+
Eye,
|
|
1160
|
+
Lock,
|
|
1677
1161
|
MessageSquare as MessageSquare2,
|
|
1678
1162
|
MessageSquarePlus as MessageSquarePlus2,
|
|
1679
1163
|
MoreHorizontal,
|
|
1680
1164
|
RotateCcw,
|
|
1681
1165
|
Sparkles,
|
|
1682
1166
|
Trash2,
|
|
1683
|
-
X
|
|
1167
|
+
X
|
|
1684
1168
|
} from "lucide-react";
|
|
1685
1169
|
import {
|
|
1686
1170
|
forwardRef,
|
|
1687
1171
|
useEffect as useEffect2,
|
|
1688
1172
|
useRef as useRef4,
|
|
1689
|
-
useState as
|
|
1173
|
+
useState as useState4
|
|
1690
1174
|
} from "react";
|
|
1691
|
-
import { jsx as
|
|
1175
|
+
import { jsx as jsx6, jsxs as jsxs6, Fragment as Fragment4 } from "react/jsx-runtime";
|
|
1692
1176
|
function CommentsPanel({
|
|
1693
1177
|
threads,
|
|
1694
1178
|
loading,
|
|
@@ -1710,10 +1194,12 @@ function CommentsPanel({
|
|
|
1710
1194
|
const open = threads.filter((thread) => !thread.comment.resolvedAt);
|
|
1711
1195
|
const resolved = threads.filter((thread) => thread.comment.resolvedAt);
|
|
1712
1196
|
const shown = filter === "open" ? open : resolved;
|
|
1713
|
-
const [choosing, setChoosing] =
|
|
1714
|
-
const [chosen, setChosen] =
|
|
1715
|
-
const [sent, setSent] =
|
|
1716
|
-
const [failure, setFailure] =
|
|
1197
|
+
const [choosing, setChoosing] = useState4(false);
|
|
1198
|
+
const [chosen, setChosen] = useState4(new Set);
|
|
1199
|
+
const [sent, setSent] = useState4(false);
|
|
1200
|
+
const [failure, setFailure] = useState4(null);
|
|
1201
|
+
const member = useSharedGuest2() === null;
|
|
1202
|
+
const guestsHere = threads.some((thread) => thread.comment.author.type === "guest");
|
|
1717
1203
|
useEffect2(() => {
|
|
1718
1204
|
setChosen((current) => {
|
|
1719
1205
|
const ids = new Set(shown.map((thread) => thread.comment.id));
|
|
@@ -1743,66 +1229,66 @@ function CommentsPanel({
|
|
|
1743
1229
|
setChosen(new Set);
|
|
1744
1230
|
setSent(true);
|
|
1745
1231
|
};
|
|
1746
|
-
return /* @__PURE__ */
|
|
1232
|
+
return /* @__PURE__ */ jsxs6("aside", {
|
|
1747
1233
|
"aria-label": messages.panel,
|
|
1748
1234
|
"data-comments-panel": "",
|
|
1749
|
-
className:
|
|
1235
|
+
className: cn5("absolute inset-x-0 bottom-0 z-30 flex max-h-[68%] flex-col rounded-t-2xl border-t border-border bg-background text-foreground shadow-[0_-12px_32px_-18px_rgb(0_0_0/0.35)]", "motion-safe:animate-in motion-safe:slide-in-from-bottom-4 motion-safe:fade-in-0", "@3xl/canvas:relative @3xl/canvas:inset-auto @3xl/canvas:z-auto @3xl/canvas:h-full @3xl/canvas:max-h-none @3xl/canvas:w-[22rem] @3xl/canvas:shrink-0 @3xl/canvas:rounded-none @3xl/canvas:border-t-0 @3xl/canvas:border-l @3xl/canvas:shadow-none @3xl/canvas:slide-in-from-right-4 @3xl/canvas:slide-in-from-bottom-0"),
|
|
1750
1236
|
children: [
|
|
1751
|
-
/* @__PURE__ */
|
|
1237
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1752
1238
|
"aria-hidden": "true",
|
|
1753
1239
|
className: "mx-auto mt-2 h-1 w-9 shrink-0 rounded-full bg-border @3xl/canvas:hidden"
|
|
1754
1240
|
}),
|
|
1755
|
-
/* @__PURE__ */
|
|
1241
|
+
/* @__PURE__ */ jsxs6("header", {
|
|
1756
1242
|
className: "flex h-12 shrink-0 items-center gap-2 px-3",
|
|
1757
1243
|
children: [
|
|
1758
|
-
/* @__PURE__ */
|
|
1244
|
+
/* @__PURE__ */ jsx6("h2", {
|
|
1759
1245
|
className: "m-0 text-sm font-semibold",
|
|
1760
1246
|
children: messages.title
|
|
1761
1247
|
}),
|
|
1762
|
-
open.length > 0 ? /* @__PURE__ */
|
|
1248
|
+
open.length > 0 ? /* @__PURE__ */ jsx6("span", {
|
|
1763
1249
|
className: "rounded-full bg-muted px-1.5 text-xs font-medium text-muted-foreground tabular-nums",
|
|
1764
1250
|
children: open.length
|
|
1765
1251
|
}) : null,
|
|
1766
|
-
/* @__PURE__ */
|
|
1252
|
+
/* @__PURE__ */ jsxs6("div", {
|
|
1767
1253
|
className: "ml-auto flex items-center gap-1",
|
|
1768
1254
|
children: [
|
|
1769
|
-
onSend && filter === "open" && open.length > 0 && !choosing ? /* @__PURE__ */
|
|
1255
|
+
onSend && filter === "open" && open.length > 0 && !choosing ? /* @__PURE__ */ jsxs6("button", {
|
|
1770
1256
|
type: "button",
|
|
1771
1257
|
onClick: () => setChoosing(true),
|
|
1772
1258
|
className: "flex h-7 items-center gap-1.5 rounded-lg px-2 text-xs font-medium text-primary outline-none transition-colors hover:bg-[color-mix(in_oklab,var(--primary)_10%,transparent)] focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",
|
|
1773
1259
|
children: [
|
|
1774
|
-
/* @__PURE__ */
|
|
1260
|
+
/* @__PURE__ */ jsx6(Sparkles, {
|
|
1775
1261
|
"aria-hidden": "true"
|
|
1776
1262
|
}),
|
|
1777
1263
|
messages.select
|
|
1778
1264
|
]
|
|
1779
1265
|
}) : null,
|
|
1780
|
-
/* @__PURE__ */
|
|
1266
|
+
/* @__PURE__ */ jsx6(IconButton, {
|
|
1781
1267
|
label: messages.close,
|
|
1782
1268
|
onClick: onClose,
|
|
1783
|
-
children: /* @__PURE__ */
|
|
1269
|
+
children: /* @__PURE__ */ jsx6(X, {})
|
|
1784
1270
|
})
|
|
1785
1271
|
]
|
|
1786
1272
|
})
|
|
1787
1273
|
]
|
|
1788
1274
|
}),
|
|
1789
|
-
/* @__PURE__ */
|
|
1275
|
+
/* @__PURE__ */ jsx6("div", {
|
|
1790
1276
|
className: "flex shrink-0 items-center gap-2 px-3 pb-2",
|
|
1791
|
-
children: /* @__PURE__ */
|
|
1277
|
+
children: /* @__PURE__ */ jsx6("div", {
|
|
1792
1278
|
role: "group",
|
|
1793
1279
|
"aria-label": messages.filter,
|
|
1794
1280
|
className: "flex flex-1 items-center rounded-lg bg-muted/70 p-0.5",
|
|
1795
|
-
children: ["open", "resolved"].map((each) => /* @__PURE__ */
|
|
1281
|
+
children: ["open", "resolved"].map((each) => /* @__PURE__ */ jsxs6("button", {
|
|
1796
1282
|
type: "button",
|
|
1797
1283
|
"aria-pressed": filter === each,
|
|
1798
1284
|
onClick: () => {
|
|
1799
1285
|
onFilter(each);
|
|
1800
1286
|
setChoosing(false);
|
|
1801
1287
|
},
|
|
1802
|
-
className:
|
|
1288
|
+
className: cn5("flex h-7 flex-1 items-center justify-center gap-1.5 rounded-md text-xs font-medium text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring", filter === each && "bg-background text-foreground shadow-sm"),
|
|
1803
1289
|
children: [
|
|
1804
1290
|
messages[each],
|
|
1805
|
-
/* @__PURE__ */
|
|
1291
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1806
1292
|
className: "tabular-nums opacity-60",
|
|
1807
1293
|
children: (each === "open" ? open : resolved).length
|
|
1808
1294
|
})
|
|
@@ -1810,34 +1296,34 @@ function CommentsPanel({
|
|
|
1810
1296
|
}, each))
|
|
1811
1297
|
})
|
|
1812
1298
|
}),
|
|
1813
|
-
choosing ? /* @__PURE__ */
|
|
1299
|
+
choosing ? /* @__PURE__ */ jsx6("p", {
|
|
1814
1300
|
className: "m-0 shrink-0 px-4 pb-2 text-xs text-muted-foreground",
|
|
1815
1301
|
children: messages.chooseHint
|
|
1816
1302
|
}) : null,
|
|
1817
|
-
failure ? /* @__PURE__ */
|
|
1303
|
+
failure ? /* @__PURE__ */ jsx6("p", {
|
|
1818
1304
|
role: "alert",
|
|
1819
1305
|
className: "m-0 shrink-0 px-4 pb-2 text-xs text-destructive",
|
|
1820
1306
|
children: failure
|
|
1821
1307
|
}) : null,
|
|
1822
|
-
/* @__PURE__ */
|
|
1308
|
+
/* @__PURE__ */ jsx6("div", {
|
|
1823
1309
|
className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 pb-3",
|
|
1824
|
-
children: failed ? /* @__PURE__ */
|
|
1310
|
+
children: failed ? /* @__PURE__ */ jsx6(Empty, {
|
|
1825
1311
|
title: messages.loadFailed
|
|
1826
|
-
}) : loading ? /* @__PURE__ */
|
|
1312
|
+
}) : loading ? /* @__PURE__ */ jsx6("div", {
|
|
1827
1313
|
className: "flex flex-col gap-2 p-1",
|
|
1828
1314
|
"aria-busy": "true",
|
|
1829
|
-
children: [0, 1].map((index) => /* @__PURE__ */
|
|
1315
|
+
children: [0, 1].map((index) => /* @__PURE__ */ jsx6("div", {
|
|
1830
1316
|
className: "h-20 animate-pulse rounded-xl bg-muted/60"
|
|
1831
1317
|
}, index))
|
|
1832
|
-
}) : shown.length === 0 ? filter === "open" ? resolved.length > 0 ? /* @__PURE__ */
|
|
1318
|
+
}) : shown.length === 0 ? filter === "open" ? resolved.length > 0 ? /* @__PURE__ */ jsx6(Empty, {
|
|
1833
1319
|
title: messages.emptyOpen
|
|
1834
|
-
}) : /* @__PURE__ */
|
|
1320
|
+
}) : /* @__PURE__ */ jsx6(Empty, {
|
|
1835
1321
|
title: messages.empty,
|
|
1836
|
-
hint: /* @__PURE__ */
|
|
1322
|
+
hint: /* @__PURE__ */ jsxs6(Fragment4, {
|
|
1837
1323
|
children: [
|
|
1838
1324
|
messages.emptyHint.before,
|
|
1839
1325
|
" ",
|
|
1840
|
-
/* @__PURE__ */
|
|
1326
|
+
/* @__PURE__ */ jsx6(MessageSquarePlus2, {
|
|
1841
1327
|
className: "inline size-3.5 align-[-0.2em] text-foreground",
|
|
1842
1328
|
"aria-label": messages.tool
|
|
1843
1329
|
}),
|
|
@@ -1845,17 +1331,19 @@ function CommentsPanel({
|
|
|
1845
1331
|
messages.emptyHint.after
|
|
1846
1332
|
]
|
|
1847
1333
|
})
|
|
1848
|
-
}) : /* @__PURE__ */
|
|
1334
|
+
}) : /* @__PURE__ */ jsx6(Empty, {
|
|
1849
1335
|
title: messages.emptyResolved
|
|
1850
|
-
}) : /* @__PURE__ */
|
|
1336
|
+
}) : /* @__PURE__ */ jsx6("ul", {
|
|
1851
1337
|
className: "m-0 flex list-none flex-col gap-1.5 p-0",
|
|
1852
|
-
children: shown.map((thread) => /* @__PURE__ */
|
|
1338
|
+
children: shown.map((thread) => /* @__PURE__ */ jsx6(ThreadCard, {
|
|
1853
1339
|
thread,
|
|
1854
1340
|
place: placeOf(thread),
|
|
1855
1341
|
active: active === thread.comment.id,
|
|
1856
1342
|
choosing,
|
|
1857
1343
|
chosen: chosen.has(thread.comment.id),
|
|
1858
1344
|
nameOf,
|
|
1345
|
+
guest: member && thread.comment.author.type === "guest" ? nameOf(thread.comment)?.name ?? messages.guest : null,
|
|
1346
|
+
internal: guestsHere && thread.comment.author.type !== "guest",
|
|
1859
1347
|
manages: canManage(thread.comment),
|
|
1860
1348
|
onChoose: (next) => setChosen((current) => {
|
|
1861
1349
|
const updated = new Set(current);
|
|
@@ -1872,10 +1360,10 @@ function CommentsPanel({
|
|
|
1872
1360
|
}, thread.comment.id))
|
|
1873
1361
|
})
|
|
1874
1362
|
}),
|
|
1875
|
-
choosing ? /* @__PURE__ */
|
|
1363
|
+
choosing ? /* @__PURE__ */ jsxs6("footer", {
|
|
1876
1364
|
className: "flex shrink-0 items-center gap-2 border-t border-border px-3 py-2.5 pb-[max(0.625rem,env(safe-area-inset-bottom))]",
|
|
1877
1365
|
children: [
|
|
1878
|
-
/* @__PURE__ */
|
|
1366
|
+
/* @__PURE__ */ jsx6("button", {
|
|
1879
1367
|
type: "button",
|
|
1880
1368
|
onClick: () => {
|
|
1881
1369
|
setChoosing(false);
|
|
@@ -1884,24 +1372,24 @@ function CommentsPanel({
|
|
|
1884
1372
|
className: "h-8 rounded-lg px-3 text-sm text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
|
|
1885
1373
|
children: messages.cancelSelect
|
|
1886
1374
|
}),
|
|
1887
|
-
/* @__PURE__ */
|
|
1375
|
+
/* @__PURE__ */ jsxs6("button", {
|
|
1888
1376
|
type: "button",
|
|
1889
1377
|
disabled: chosen.size === 0,
|
|
1890
1378
|
onClick: send,
|
|
1891
1379
|
className: "ml-auto flex h-8 items-center gap-1.5 rounded-lg bg-primary px-3 text-sm font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-40 [&_svg]:size-4",
|
|
1892
1380
|
children: [
|
|
1893
|
-
/* @__PURE__ */
|
|
1381
|
+
/* @__PURE__ */ jsx6(Sparkles, {
|
|
1894
1382
|
"aria-hidden": "true"
|
|
1895
1383
|
}),
|
|
1896
1384
|
messages.send(chosen.size)
|
|
1897
1385
|
]
|
|
1898
1386
|
})
|
|
1899
1387
|
]
|
|
1900
|
-
}) : sent ? /* @__PURE__ */
|
|
1388
|
+
}) : sent ? /* @__PURE__ */ jsxs6("p", {
|
|
1901
1389
|
role: "status",
|
|
1902
1390
|
className: "m-0 flex shrink-0 items-center gap-2 border-t border-border px-4 py-2.5 text-xs text-muted-foreground",
|
|
1903
1391
|
children: [
|
|
1904
|
-
/* @__PURE__ */
|
|
1392
|
+
/* @__PURE__ */ jsx6(Check, {
|
|
1905
1393
|
className: "size-3.5 text-primary",
|
|
1906
1394
|
"aria-hidden": "true"
|
|
1907
1395
|
}),
|
|
@@ -1918,6 +1406,8 @@ function ThreadCard({
|
|
|
1918
1406
|
choosing,
|
|
1919
1407
|
chosen,
|
|
1920
1408
|
nameOf,
|
|
1409
|
+
guest,
|
|
1410
|
+
internal,
|
|
1921
1411
|
manages,
|
|
1922
1412
|
onChoose,
|
|
1923
1413
|
onActivate,
|
|
@@ -1928,71 +1418,71 @@ function ThreadCard({
|
|
|
1928
1418
|
const messages = useArtifactMessages().canvas.comments;
|
|
1929
1419
|
const { comment, replies, number } = thread;
|
|
1930
1420
|
const resolved = Boolean(comment.resolvedAt);
|
|
1931
|
-
const [replying, setReplying] =
|
|
1932
|
-
const [confirming, setConfirming] =
|
|
1421
|
+
const [replying, setReplying] = useState4(false);
|
|
1422
|
+
const [confirming, setConfirming] = useState4(false);
|
|
1933
1423
|
const card = useRef4(null);
|
|
1934
1424
|
useEffect2(() => {
|
|
1935
1425
|
if (active)
|
|
1936
1426
|
card.current?.scrollIntoView({ block: "nearest", behavior: "smooth" });
|
|
1937
1427
|
}, [active]);
|
|
1938
|
-
return /* @__PURE__ */
|
|
1428
|
+
return /* @__PURE__ */ jsxs6("li", {
|
|
1939
1429
|
children: [
|
|
1940
|
-
/* @__PURE__ */
|
|
1430
|
+
/* @__PURE__ */ jsxs6("article", {
|
|
1941
1431
|
ref: card,
|
|
1942
1432
|
"aria-label": messages.pin(number, nameOf(comment)?.name ?? messages.someone),
|
|
1943
1433
|
"data-comment-thread": comment.id,
|
|
1944
1434
|
"data-active": active ? "" : undefined,
|
|
1945
|
-
className:
|
|
1435
|
+
className: cn5("group relative flex gap-2.5 rounded-xl px-2.5 py-2.5 transition-colors", active ? "bg-[color-mix(in_oklab,var(--primary)_7%,var(--background))] ring-1 ring-[color-mix(in_oklab,var(--primary)_30%,transparent)]" : "hover:bg-muted/50", resolved && "opacity-80"),
|
|
1946
1436
|
children: [
|
|
1947
|
-
choosing ? /* @__PURE__ */
|
|
1437
|
+
choosing ? /* @__PURE__ */ jsx6(Checkbox, {
|
|
1948
1438
|
checked: chosen,
|
|
1949
1439
|
onCheckedChange: (value) => onChoose(value === true),
|
|
1950
1440
|
"aria-label": messages.selectLabel(number),
|
|
1951
1441
|
className: "mt-0.5"
|
|
1952
|
-
}) : /* @__PURE__ */
|
|
1442
|
+
}) : /* @__PURE__ */ jsx6("span", {
|
|
1953
1443
|
"aria-hidden": "true",
|
|
1954
|
-
className:
|
|
1444
|
+
className: cn5("mt-px flex h-5 min-w-5 items-center justify-center rounded-full rounded-bl-[3px] px-1 text-[10.5px] font-semibold tabular-nums", active ? "bg-primary text-primary-foreground" : resolved ? "bg-muted text-muted-foreground" : "bg-foreground text-background"),
|
|
1955
1445
|
children: number
|
|
1956
1446
|
}),
|
|
1957
|
-
/* @__PURE__ */
|
|
1447
|
+
/* @__PURE__ */ jsxs6("div", {
|
|
1958
1448
|
className: "min-w-0 flex-1",
|
|
1959
1449
|
children: [
|
|
1960
|
-
/* @__PURE__ */
|
|
1450
|
+
/* @__PURE__ */ jsxs6("div", {
|
|
1961
1451
|
className: "flex items-start gap-1",
|
|
1962
1452
|
children: [
|
|
1963
|
-
/* @__PURE__ */
|
|
1453
|
+
/* @__PURE__ */ jsx6("button", {
|
|
1964
1454
|
type: "button",
|
|
1965
1455
|
onClick: onActivate,
|
|
1966
1456
|
className: "min-w-0 flex-1 rounded-sm text-left text-xs text-muted-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1967
|
-
children: /* @__PURE__ */
|
|
1457
|
+
children: /* @__PURE__ */ jsx6(Where, {
|
|
1968
1458
|
place
|
|
1969
1459
|
})
|
|
1970
1460
|
}),
|
|
1971
|
-
manages ? /* @__PURE__ */
|
|
1461
|
+
manages ? /* @__PURE__ */ jsxs6("div", {
|
|
1972
1462
|
className: "-mt-1 -mr-1 flex shrink-0 items-center opacity-100 transition-opacity @3xl/canvas:opacity-0 @3xl/canvas:group-focus-within:opacity-100 @3xl/canvas:group-hover:opacity-100 @3xl/canvas:group-data-[active]:opacity-100",
|
|
1973
1463
|
children: [
|
|
1974
|
-
/* @__PURE__ */
|
|
1464
|
+
/* @__PURE__ */ jsx6(IconButton, {
|
|
1975
1465
|
label: resolved ? messages.reopen : messages.resolve,
|
|
1976
1466
|
onClick: () => void onResolve(!resolved),
|
|
1977
|
-
children: resolved ? /* @__PURE__ */
|
|
1467
|
+
children: resolved ? /* @__PURE__ */ jsx6(RotateCcw, {}) : /* @__PURE__ */ jsx6(Check, {})
|
|
1978
1468
|
}),
|
|
1979
|
-
/* @__PURE__ */
|
|
1469
|
+
/* @__PURE__ */ jsxs6(DropdownMenu, {
|
|
1980
1470
|
modal: false,
|
|
1981
1471
|
children: [
|
|
1982
|
-
/* @__PURE__ */
|
|
1472
|
+
/* @__PURE__ */ jsx6(DropdownMenuTrigger, {
|
|
1983
1473
|
asChild: true,
|
|
1984
|
-
children: /* @__PURE__ */
|
|
1474
|
+
children: /* @__PURE__ */ jsx6(IconButton, {
|
|
1985
1475
|
label: messages.more,
|
|
1986
|
-
children: /* @__PURE__ */
|
|
1476
|
+
children: /* @__PURE__ */ jsx6(MoreHorizontal, {})
|
|
1987
1477
|
})
|
|
1988
1478
|
}),
|
|
1989
|
-
/* @__PURE__ */
|
|
1479
|
+
/* @__PURE__ */ jsx6(DropdownMenuContent, {
|
|
1990
1480
|
align: "end",
|
|
1991
|
-
children: /* @__PURE__ */
|
|
1481
|
+
children: /* @__PURE__ */ jsxs6(DropdownMenuItem, {
|
|
1992
1482
|
variant: "destructive",
|
|
1993
1483
|
onSelect: () => setConfirming(true),
|
|
1994
1484
|
children: [
|
|
1995
|
-
/* @__PURE__ */
|
|
1485
|
+
/* @__PURE__ */ jsx6(Trash2, {
|
|
1996
1486
|
"aria-hidden": "true"
|
|
1997
1487
|
}),
|
|
1998
1488
|
messages.delete
|
|
@@ -2005,33 +1495,47 @@ function ThreadCard({
|
|
|
2005
1495
|
}) : null
|
|
2006
1496
|
]
|
|
2007
1497
|
}),
|
|
2008
|
-
/* @__PURE__ */
|
|
1498
|
+
/* @__PURE__ */ jsx6(Message, {
|
|
2009
1499
|
comment,
|
|
2010
|
-
nameOf
|
|
1500
|
+
nameOf,
|
|
1501
|
+
...internal ? { badge: /* @__PURE__ */ jsx6(InternalBadge, {}) } : {}
|
|
2011
1502
|
}),
|
|
2012
|
-
replies.map((reply) => /* @__PURE__ */
|
|
1503
|
+
replies.map((reply) => /* @__PURE__ */ jsx6("div", {
|
|
2013
1504
|
className: "mt-2.5 border-l-2 border-border/70 pl-2.5",
|
|
2014
|
-
children: /* @__PURE__ */
|
|
1505
|
+
children: /* @__PURE__ */ jsx6(Message, {
|
|
2015
1506
|
comment: reply,
|
|
2016
1507
|
nameOf
|
|
2017
1508
|
})
|
|
2018
1509
|
}, reply.id)),
|
|
2019
|
-
resolved ? null : replying || active ? /* @__PURE__ */
|
|
1510
|
+
resolved ? null : replying || active ? /* @__PURE__ */ jsx6(CommentComposer, {
|
|
2020
1511
|
compact: true,
|
|
2021
1512
|
autoFocus: replying,
|
|
2022
1513
|
placeholder: messages.replyPlaceholder,
|
|
1514
|
+
notice: guest ? /* @__PURE__ */ jsxs6("p", {
|
|
1515
|
+
title: messages.guestSeesHint,
|
|
1516
|
+
className: "m-0 flex items-center gap-1 text-[11px] leading-4 text-muted-foreground [&_svg]:size-3 [&_svg]:shrink-0",
|
|
1517
|
+
children: [
|
|
1518
|
+
/* @__PURE__ */ jsx6(Eye, {
|
|
1519
|
+
"aria-hidden": "true"
|
|
1520
|
+
}),
|
|
1521
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1522
|
+
className: "min-w-0 truncate",
|
|
1523
|
+
children: messages.guestSees(guest)
|
|
1524
|
+
})
|
|
1525
|
+
]
|
|
1526
|
+
}) : undefined,
|
|
2023
1527
|
onSubmit: async (body) => {
|
|
2024
1528
|
await onReply(body);
|
|
2025
1529
|
setReplying(false);
|
|
2026
1530
|
},
|
|
2027
1531
|
onCancel: () => setReplying(false),
|
|
2028
1532
|
className: "mt-2.5"
|
|
2029
|
-
}) : /* @__PURE__ */
|
|
1533
|
+
}) : /* @__PURE__ */ jsxs6("button", {
|
|
2030
1534
|
type: "button",
|
|
2031
1535
|
onClick: () => setReplying(true),
|
|
2032
1536
|
className: "mt-1.5 flex items-center gap-1 rounded-sm text-xs text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3",
|
|
2033
1537
|
children: [
|
|
2034
|
-
/* @__PURE__ */
|
|
1538
|
+
/* @__PURE__ */ jsx6(CornerDownRight, {
|
|
2035
1539
|
"aria-hidden": "true"
|
|
2036
1540
|
}),
|
|
2037
1541
|
replies.length > 0 ? messages.replies(replies.length) : messages.reply
|
|
@@ -2041,27 +1545,27 @@ function ThreadCard({
|
|
|
2041
1545
|
})
|
|
2042
1546
|
]
|
|
2043
1547
|
}),
|
|
2044
|
-
/* @__PURE__ */
|
|
1548
|
+
/* @__PURE__ */ jsx6(AlertDialog, {
|
|
2045
1549
|
open: confirming,
|
|
2046
1550
|
onOpenChange: setConfirming,
|
|
2047
|
-
children: /* @__PURE__ */
|
|
1551
|
+
children: /* @__PURE__ */ jsxs6(AlertDialogContent, {
|
|
2048
1552
|
children: [
|
|
2049
|
-
/* @__PURE__ */
|
|
1553
|
+
/* @__PURE__ */ jsxs6(AlertDialogHeader, {
|
|
2050
1554
|
children: [
|
|
2051
|
-
/* @__PURE__ */
|
|
1555
|
+
/* @__PURE__ */ jsx6(AlertDialogTitle, {
|
|
2052
1556
|
children: messages.deleteTitle
|
|
2053
1557
|
}),
|
|
2054
|
-
/* @__PURE__ */
|
|
1558
|
+
/* @__PURE__ */ jsx6(AlertDialogDescription, {
|
|
2055
1559
|
children: messages.deleteDescription
|
|
2056
1560
|
})
|
|
2057
1561
|
]
|
|
2058
1562
|
}),
|
|
2059
|
-
/* @__PURE__ */
|
|
1563
|
+
/* @__PURE__ */ jsxs6(AlertDialogFooter, {
|
|
2060
1564
|
children: [
|
|
2061
|
-
/* @__PURE__ */
|
|
1565
|
+
/* @__PURE__ */ jsx6(AlertDialogCancel, {
|
|
2062
1566
|
children: messages.cancel
|
|
2063
1567
|
}),
|
|
2064
|
-
/* @__PURE__ */
|
|
1568
|
+
/* @__PURE__ */ jsx6(AlertDialogAction, {
|
|
2065
1569
|
variant: "destructive",
|
|
2066
1570
|
onClick: () => void onDelete(),
|
|
2067
1571
|
children: messages.delete
|
|
@@ -2074,28 +1578,41 @@ function ThreadCard({
|
|
|
2074
1578
|
]
|
|
2075
1579
|
});
|
|
2076
1580
|
}
|
|
1581
|
+
function InternalBadge() {
|
|
1582
|
+
const messages = useArtifactMessages().canvas.comments;
|
|
1583
|
+
return /* @__PURE__ */ jsxs6("span", {
|
|
1584
|
+
title: messages.internalHint,
|
|
1585
|
+
className: "inline-flex h-4 shrink-0 items-center gap-0.5 rounded-full px-1.5 text-[10.5px] leading-none font-medium tracking-[0.01em] text-muted-foreground ring-1 ring-border/70 ring-inset [&_svg]:size-2.5",
|
|
1586
|
+
children: [
|
|
1587
|
+
/* @__PURE__ */ jsx6(Lock, {
|
|
1588
|
+
"aria-hidden": "true"
|
|
1589
|
+
}),
|
|
1590
|
+
messages.internal
|
|
1591
|
+
]
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
2077
1594
|
function Where({ place }) {
|
|
2078
1595
|
const messages = useArtifactMessages().canvas.comments;
|
|
2079
|
-
return /* @__PURE__ */
|
|
1596
|
+
return /* @__PURE__ */ jsxs6("span", {
|
|
2080
1597
|
className: "flex min-w-0 flex-wrap items-center gap-x-1 gap-y-0.5",
|
|
2081
1598
|
children: [
|
|
2082
|
-
/* @__PURE__ */
|
|
1599
|
+
/* @__PURE__ */ jsx6("span", {
|
|
2083
1600
|
className: "truncate font-medium text-foreground/80",
|
|
2084
1601
|
children: place.board ?? messages.onCanvas
|
|
2085
1602
|
}),
|
|
2086
|
-
place.board ? /* @__PURE__ */
|
|
1603
|
+
place.board ? /* @__PURE__ */ jsxs6(Fragment4, {
|
|
2087
1604
|
children: [
|
|
2088
|
-
/* @__PURE__ */
|
|
1605
|
+
/* @__PURE__ */ jsx6("span", {
|
|
2089
1606
|
"aria-hidden": "true",
|
|
2090
1607
|
children: "\xB7"
|
|
2091
1608
|
}),
|
|
2092
|
-
/* @__PURE__ */
|
|
2093
|
-
className:
|
|
1609
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1610
|
+
className: cn5("min-w-0 truncate", place.gone && "line-through decoration-1"),
|
|
2094
1611
|
children: place.element ? `\u201C${place.element}\u201D` : messages.wholeBoard
|
|
2095
1612
|
})
|
|
2096
1613
|
]
|
|
2097
1614
|
}) : null,
|
|
2098
|
-
place.gone ? /* @__PURE__ */
|
|
1615
|
+
place.gone ? /* @__PURE__ */ jsx6("span", {
|
|
2099
1616
|
className: "rounded-sm bg-muted px-1 text-[10.5px] text-muted-foreground",
|
|
2100
1617
|
children: messages.elementGone
|
|
2101
1618
|
}) : null
|
|
@@ -2104,41 +1621,46 @@ function Where({ place }) {
|
|
|
2104
1621
|
}
|
|
2105
1622
|
function Message({
|
|
2106
1623
|
comment,
|
|
2107
|
-
nameOf
|
|
1624
|
+
nameOf,
|
|
1625
|
+
badge
|
|
2108
1626
|
}) {
|
|
2109
1627
|
const messages = useArtifactMessages().canvas.comments;
|
|
2110
1628
|
const when = useWhen();
|
|
2111
1629
|
const author = nameOf(comment);
|
|
2112
1630
|
const name = author ? author.you ? messages.you : author.name : messages.someone;
|
|
2113
|
-
return /* @__PURE__ */
|
|
1631
|
+
return /* @__PURE__ */ jsxs6("div", {
|
|
2114
1632
|
className: "mt-1.5",
|
|
2115
1633
|
children: [
|
|
2116
|
-
/* @__PURE__ */
|
|
1634
|
+
/* @__PURE__ */ jsxs6("div", {
|
|
2117
1635
|
className: "flex items-center gap-1.5 text-xs",
|
|
2118
1636
|
children: [
|
|
2119
|
-
author?.agent ? /* @__PURE__ */
|
|
1637
|
+
author?.agent ? /* @__PURE__ */ jsx6("span", {
|
|
2120
1638
|
className: "flex size-5 shrink-0 items-center justify-center rounded-full bg-[color-mix(in_oklab,var(--primary)_14%,var(--background))] text-primary",
|
|
2121
|
-
children: /* @__PURE__ */
|
|
1639
|
+
children: /* @__PURE__ */ jsx6(Sparkles, {
|
|
2122
1640
|
className: "size-3",
|
|
2123
1641
|
"aria-hidden": "true"
|
|
2124
1642
|
})
|
|
2125
|
-
}) : /* @__PURE__ */
|
|
1643
|
+
}) : /* @__PURE__ */ jsx6(PersonAvatar, {
|
|
2126
1644
|
name: author?.name || name,
|
|
2127
1645
|
size: "xs"
|
|
2128
1646
|
}),
|
|
2129
|
-
/* @__PURE__ */
|
|
1647
|
+
/* @__PURE__ */ jsx6("span", {
|
|
2130
1648
|
className: "truncate font-medium text-foreground",
|
|
2131
1649
|
children: name
|
|
2132
1650
|
}),
|
|
2133
|
-
author?.guest ? /* @__PURE__ */
|
|
2134
|
-
/* @__PURE__ */
|
|
1651
|
+
author?.guest ? /* @__PURE__ */ jsx6(GuestBadge, {}) : null,
|
|
1652
|
+
/* @__PURE__ */ jsx6("time", {
|
|
2135
1653
|
dateTime: comment.createdAt,
|
|
2136
1654
|
className: "shrink-0 text-muted-foreground",
|
|
2137
1655
|
children: when(comment.createdAt)
|
|
2138
|
-
})
|
|
1656
|
+
}),
|
|
1657
|
+
badge ? /* @__PURE__ */ jsx6("span", {
|
|
1658
|
+
className: "ml-auto flex shrink-0 pl-1",
|
|
1659
|
+
children: badge
|
|
1660
|
+
}) : null
|
|
2139
1661
|
]
|
|
2140
1662
|
}),
|
|
2141
|
-
/* @__PURE__ */
|
|
1663
|
+
/* @__PURE__ */ jsx6("p", {
|
|
2142
1664
|
className: "m-0 mt-1 text-sm leading-5 break-words whitespace-pre-wrap text-foreground",
|
|
2143
1665
|
children: comment.body
|
|
2144
1666
|
})
|
|
@@ -2158,21 +1680,21 @@ function useWhen() {
|
|
|
2158
1680
|
};
|
|
2159
1681
|
}
|
|
2160
1682
|
function Empty({ title, hint }) {
|
|
2161
|
-
return /* @__PURE__ */
|
|
1683
|
+
return /* @__PURE__ */ jsxs6("div", {
|
|
2162
1684
|
className: "flex flex-col items-center gap-2 px-6 py-10 text-center",
|
|
2163
1685
|
children: [
|
|
2164
|
-
/* @__PURE__ */
|
|
1686
|
+
/* @__PURE__ */ jsx6("span", {
|
|
2165
1687
|
className: "flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground",
|
|
2166
|
-
children: /* @__PURE__ */
|
|
1688
|
+
children: /* @__PURE__ */ jsx6(MessageSquare2, {
|
|
2167
1689
|
className: "size-4",
|
|
2168
1690
|
"aria-hidden": "true"
|
|
2169
1691
|
})
|
|
2170
1692
|
}),
|
|
2171
|
-
/* @__PURE__ */
|
|
1693
|
+
/* @__PURE__ */ jsx6("p", {
|
|
2172
1694
|
className: "m-0 text-sm font-medium text-foreground",
|
|
2173
1695
|
children: title
|
|
2174
1696
|
}),
|
|
2175
|
-
hint ? /* @__PURE__ */
|
|
1697
|
+
hint ? /* @__PURE__ */ jsx6("p", {
|
|
2176
1698
|
className: "m-0 max-w-[24ch] text-xs text-muted-foreground",
|
|
2177
1699
|
children: hint
|
|
2178
1700
|
}) : null
|
|
@@ -2180,7 +1702,7 @@ function Empty({ title, hint }) {
|
|
|
2180
1702
|
});
|
|
2181
1703
|
}
|
|
2182
1704
|
var IconButton = forwardRef(function IconButton({ label, children, ...props }, ref) {
|
|
2183
|
-
return /* @__PURE__ */
|
|
1705
|
+
return /* @__PURE__ */ jsx6("button", {
|
|
2184
1706
|
ref,
|
|
2185
1707
|
type: "button",
|
|
2186
1708
|
"aria-label": label,
|
|
@@ -2192,76 +1714,96 @@ var IconButton = forwardRef(function IconButton({ label, children, ...props }, r
|
|
|
2192
1714
|
});
|
|
2193
1715
|
|
|
2194
1716
|
// src/artifacts/renderers/canvas/controls.tsx
|
|
2195
|
-
import {
|
|
1717
|
+
import { cn as cn6 } from "@sixb/ui/lib/utils";
|
|
1718
|
+
import { Panel, useReactFlow, useStore } from "@xyflow/react";
|
|
2196
1719
|
import { Maximize, Minus, Plus } from "lucide-react";
|
|
2197
|
-
import { jsx as
|
|
1720
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2198
1721
|
var DURATION = 220;
|
|
2199
1722
|
function CanvasControls({ padding }) {
|
|
2200
1723
|
const messages = useArtifactMessages().canvas;
|
|
2201
1724
|
const { zoomIn, zoomOut, zoomTo, fitView } = useReactFlow();
|
|
2202
|
-
const zoom =
|
|
2203
|
-
return /* @__PURE__ */
|
|
1725
|
+
const zoom = useStore((state) => state.transform[2]);
|
|
1726
|
+
return /* @__PURE__ */ jsx7(Panel, {
|
|
2204
1727
|
position: "bottom-left",
|
|
2205
1728
|
className: "!m-3",
|
|
2206
|
-
children: /* @__PURE__ */
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
})
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
1729
|
+
children: /* @__PURE__ */ jsx7(ZoomBar, {
|
|
1730
|
+
zoom,
|
|
1731
|
+
fitLabel: messages.fitView,
|
|
1732
|
+
onZoomOut: () => zoomOut({ duration: DURATION }),
|
|
1733
|
+
onActualSize: () => void zoomTo(1, { duration: DURATION }),
|
|
1734
|
+
onZoomIn: () => zoomIn({ duration: DURATION }),
|
|
1735
|
+
onFit: () => void fitView({ padding, duration: DURATION })
|
|
1736
|
+
})
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
function ZoomBar({
|
|
1740
|
+
zoom,
|
|
1741
|
+
fitLabel,
|
|
1742
|
+
onZoomOut,
|
|
1743
|
+
onActualSize,
|
|
1744
|
+
onZoomIn,
|
|
1745
|
+
onFit,
|
|
1746
|
+
className
|
|
1747
|
+
}) {
|
|
1748
|
+
const messages = useArtifactMessages().canvas;
|
|
1749
|
+
return /* @__PURE__ */ jsxs7("div", {
|
|
1750
|
+
className: cn6("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", className),
|
|
1751
|
+
children: [
|
|
1752
|
+
/* @__PURE__ */ jsx7(Control, {
|
|
1753
|
+
label: messages.zoomOut,
|
|
1754
|
+
onClick: onZoomOut,
|
|
1755
|
+
children: /* @__PURE__ */ jsx7(Minus, {
|
|
1756
|
+
className: "size-4",
|
|
1757
|
+
"aria-hidden": "true"
|
|
1758
|
+
})
|
|
1759
|
+
}),
|
|
1760
|
+
/* @__PURE__ */ jsxs7("button", {
|
|
1761
|
+
type: "button",
|
|
1762
|
+
title: messages.actualSize,
|
|
1763
|
+
onClick: onActualSize,
|
|
1764
|
+
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",
|
|
1765
|
+
children: [
|
|
1766
|
+
/* @__PURE__ */ jsx7("span", {
|
|
1767
|
+
"aria-live": "polite",
|
|
1768
|
+
children: messages.zoom(Math.round(zoom * 100))
|
|
1769
|
+
}),
|
|
1770
|
+
/* @__PURE__ */ jsxs7("span", {
|
|
1771
|
+
className: "sr-only",
|
|
1772
|
+
children: [
|
|
1773
|
+
", ",
|
|
1774
|
+
messages.actualSize
|
|
1775
|
+
]
|
|
2242
1776
|
})
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
1777
|
+
]
|
|
1778
|
+
}),
|
|
1779
|
+
/* @__PURE__ */ jsx7(Control, {
|
|
1780
|
+
label: messages.zoomIn,
|
|
1781
|
+
onClick: onZoomIn,
|
|
1782
|
+
children: /* @__PURE__ */ jsx7(Plus, {
|
|
1783
|
+
className: "size-4",
|
|
2246
1784
|
"aria-hidden": "true"
|
|
2247
|
-
}),
|
|
2248
|
-
/* @__PURE__ */ jsxs8(Control, {
|
|
2249
|
-
label: messages.fitView,
|
|
2250
|
-
onClick: () => void fitView({ padding, duration: DURATION }),
|
|
2251
|
-
wide: true,
|
|
2252
|
-
children: [
|
|
2253
|
-
/* @__PURE__ */ jsx9(Maximize, {
|
|
2254
|
-
className: "size-3.5",
|
|
2255
|
-
"aria-hidden": "true"
|
|
2256
|
-
}),
|
|
2257
|
-
/* @__PURE__ */ jsx9("span", {
|
|
2258
|
-
className: "text-xs font-medium",
|
|
2259
|
-
children: messages.fit
|
|
2260
|
-
})
|
|
2261
|
-
]
|
|
2262
1785
|
})
|
|
2263
|
-
|
|
2264
|
-
|
|
1786
|
+
}),
|
|
1787
|
+
/* @__PURE__ */ jsx7("span", {
|
|
1788
|
+
className: "mx-1 h-5 w-px bg-border",
|
|
1789
|
+
"aria-hidden": "true"
|
|
1790
|
+
}),
|
|
1791
|
+
/* @__PURE__ */ jsxs7(Control, {
|
|
1792
|
+
label: fitLabel,
|
|
1793
|
+
onClick: onFit,
|
|
1794
|
+
wide: true,
|
|
1795
|
+
children: [
|
|
1796
|
+
/* @__PURE__ */ jsx7(Maximize, {
|
|
1797
|
+
className: "size-3.5",
|
|
1798
|
+
"aria-hidden": "true"
|
|
1799
|
+
}),
|
|
1800
|
+
/* @__PURE__ */ jsx7("span", {
|
|
1801
|
+
className: "text-xs font-medium",
|
|
1802
|
+
children: messages.fit
|
|
1803
|
+
})
|
|
1804
|
+
]
|
|
1805
|
+
})
|
|
1806
|
+
]
|
|
2265
1807
|
});
|
|
2266
1808
|
}
|
|
2267
1809
|
function Control({
|
|
@@ -2270,7 +1812,7 @@ function Control({
|
|
|
2270
1812
|
wide = false,
|
|
2271
1813
|
children
|
|
2272
1814
|
}) {
|
|
2273
|
-
return /* @__PURE__ */
|
|
1815
|
+
return /* @__PURE__ */ jsx7("button", {
|
|
2274
1816
|
type: "button",
|
|
2275
1817
|
"aria-label": label,
|
|
2276
1818
|
title: label,
|
|
@@ -2288,11 +1830,11 @@ import {
|
|
|
2288
1830
|
useStoreApi as useStoreApi3
|
|
2289
1831
|
} from "@xyflow/react";
|
|
2290
1832
|
import {
|
|
2291
|
-
useCallback as
|
|
1833
|
+
useCallback as useCallback2,
|
|
2292
1834
|
useEffect as useEffect4,
|
|
2293
|
-
useMemo as
|
|
1835
|
+
useMemo as useMemo2,
|
|
2294
1836
|
useRef as useRef5,
|
|
2295
|
-
useState as
|
|
1837
|
+
useState as useState6
|
|
2296
1838
|
} from "react";
|
|
2297
1839
|
|
|
2298
1840
|
// src/artifacts/renderers/canvas/toolbar.tsx
|
|
@@ -2302,7 +1844,7 @@ import {
|
|
|
2302
1844
|
DropdownMenuItem as DropdownMenuItem2,
|
|
2303
1845
|
DropdownMenuTrigger as DropdownMenuTrigger2
|
|
2304
1846
|
} from "@sixb/ui/components";
|
|
2305
|
-
import { cn as
|
|
1847
|
+
import { cn as cn7 } from "@sixb/ui/lib/utils";
|
|
2306
1848
|
import { Panel as Panel2 } from "@xyflow/react";
|
|
2307
1849
|
import {
|
|
2308
1850
|
ChevronDown,
|
|
@@ -2316,8 +1858,8 @@ import {
|
|
|
2316
1858
|
Trash2 as Trash22,
|
|
2317
1859
|
Type
|
|
2318
1860
|
} from "lucide-react";
|
|
2319
|
-
import { useEffect as useEffect3, useState as
|
|
2320
|
-
import { jsx as
|
|
1861
|
+
import { useEffect as useEffect3, useState as useState5 } from "react";
|
|
1862
|
+
import { jsx as jsx8, jsxs as jsxs8, Fragment as Fragment5 } from "react/jsx-runtime";
|
|
2321
1863
|
var NOTE_TONES = [
|
|
2322
1864
|
null,
|
|
2323
1865
|
"positive",
|
|
@@ -2359,45 +1901,45 @@ function CanvasToolbar({
|
|
|
2359
1901
|
const size = one(texts.map((item) => item.type === "text" ? item.size : undefined));
|
|
2360
1902
|
const shape = one(shapes.map((item) => item.type === "shape" ? item.shape : undefined));
|
|
2361
1903
|
const dashed = one(arrows.map((item) => item.type === "arrow" ? item.dashed : false));
|
|
2362
|
-
return /* @__PURE__ */
|
|
1904
|
+
return /* @__PURE__ */ jsx8(Panel2, {
|
|
2363
1905
|
position: "top-center",
|
|
2364
1906
|
className: "!mt-3",
|
|
2365
|
-
children: /* @__PURE__ */
|
|
1907
|
+
children: /* @__PURE__ */ jsxs8("div", {
|
|
2366
1908
|
role: "toolbar",
|
|
2367
1909
|
"aria-label": messages.label,
|
|
2368
1910
|
className: "flex items-center gap-0.5 rounded-xl border border-border bg-background/95 p-1 shadow-[0_1px_2px_rgb(0_0_0/0.06),0_10px_28px_-14px_rgb(0_0_0/0.3)] backdrop-blur",
|
|
2369
1911
|
children: [
|
|
2370
|
-
/* @__PURE__ */
|
|
1912
|
+
/* @__PURE__ */ jsx8(Tool, {
|
|
2371
1913
|
label: messages.note,
|
|
2372
1914
|
onClick: () => onAdd("note"),
|
|
2373
|
-
children: /* @__PURE__ */
|
|
1915
|
+
children: /* @__PURE__ */ jsx8(StickyNote, {})
|
|
2374
1916
|
}),
|
|
2375
|
-
/* @__PURE__ */
|
|
1917
|
+
/* @__PURE__ */ jsx8(Tool, {
|
|
2376
1918
|
label: messages.text,
|
|
2377
1919
|
onClick: () => onAdd("text"),
|
|
2378
|
-
children: /* @__PURE__ */
|
|
1920
|
+
children: /* @__PURE__ */ jsx8(Type, {})
|
|
2379
1921
|
}),
|
|
2380
|
-
/* @__PURE__ */
|
|
1922
|
+
/* @__PURE__ */ jsxs8(DropdownMenu2, {
|
|
2381
1923
|
modal: false,
|
|
2382
1924
|
children: [
|
|
2383
|
-
/* @__PURE__ */
|
|
1925
|
+
/* @__PURE__ */ jsxs8(DropdownMenuTrigger2, {
|
|
2384
1926
|
"aria-label": messages.shape,
|
|
2385
1927
|
title: messages.shape,
|
|
2386
|
-
className:
|
|
1928
|
+
className: cn7(TOOL, "w-auto gap-0.5 px-1.5"),
|
|
2387
1929
|
children: [
|
|
2388
|
-
/* @__PURE__ */
|
|
2389
|
-
/* @__PURE__ */
|
|
1930
|
+
/* @__PURE__ */ jsx8(RectangleHorizontal, {}),
|
|
1931
|
+
/* @__PURE__ */ jsx8(ChevronDown, {
|
|
2390
1932
|
className: "!size-3 opacity-60"
|
|
2391
1933
|
})
|
|
2392
1934
|
]
|
|
2393
1935
|
}),
|
|
2394
|
-
/* @__PURE__ */
|
|
1936
|
+
/* @__PURE__ */ jsx8(DropdownMenuContent2, {
|
|
2395
1937
|
align: "center",
|
|
2396
1938
|
sideOffset: 8,
|
|
2397
|
-
children: SHAPES.map(({ shape: kind, icon: Icon }) => /* @__PURE__ */
|
|
1939
|
+
children: SHAPES.map(({ shape: kind, icon: Icon }) => /* @__PURE__ */ jsxs8(DropdownMenuItem2, {
|
|
2398
1940
|
onSelect: () => onAdd("shape", kind),
|
|
2399
1941
|
children: [
|
|
2400
|
-
/* @__PURE__ */
|
|
1942
|
+
/* @__PURE__ */ jsx8(Icon, {
|
|
2401
1943
|
"aria-hidden": "true"
|
|
2402
1944
|
}),
|
|
2403
1945
|
messages.shapes[kind]
|
|
@@ -2406,87 +1948,87 @@ function CanvasToolbar({
|
|
|
2406
1948
|
})
|
|
2407
1949
|
]
|
|
2408
1950
|
}),
|
|
2409
|
-
/* @__PURE__ */
|
|
1951
|
+
/* @__PURE__ */ jsx8(Tool, {
|
|
2410
1952
|
label: messages.section,
|
|
2411
1953
|
onClick: () => onAdd("section"),
|
|
2412
|
-
children: /* @__PURE__ */
|
|
1954
|
+
children: /* @__PURE__ */ jsx8(Frame, {})
|
|
2413
1955
|
}),
|
|
2414
|
-
selection.length > 0 ? /* @__PURE__ */
|
|
1956
|
+
selection.length > 0 ? /* @__PURE__ */ jsxs8(Fragment5, {
|
|
2415
1957
|
children: [
|
|
2416
|
-
/* @__PURE__ */
|
|
2417
|
-
toned.length > 0 ? /* @__PURE__ */
|
|
1958
|
+
/* @__PURE__ */ jsx8(Divider, {}),
|
|
1959
|
+
toned.length > 0 ? /* @__PURE__ */ jsx8("div", {
|
|
2418
1960
|
className: "flex items-center gap-1 px-1",
|
|
2419
1961
|
role: "group",
|
|
2420
1962
|
"aria-label": messages.color,
|
|
2421
|
-
children: tones.map((entry) => /* @__PURE__ */
|
|
1963
|
+
children: tones.map((entry) => /* @__PURE__ */ jsx8("button", {
|
|
2422
1964
|
type: "button",
|
|
2423
1965
|
"aria-label": messages.tones[entry ?? "default"],
|
|
2424
1966
|
title: messages.tones[entry ?? "default"],
|
|
2425
1967
|
"aria-pressed": tone === entry,
|
|
2426
1968
|
onClick: () => onStyle({ tone: entry }),
|
|
2427
1969
|
className: "flex size-6 items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
2428
|
-
children: /* @__PURE__ */
|
|
1970
|
+
children: /* @__PURE__ */ jsx8("span", {
|
|
2429
1971
|
"aria-hidden": "true",
|
|
2430
|
-
className:
|
|
1972
|
+
className: cn7("size-[18px] rounded-full ring-1 ring-[color-mix(in_oklab,var(--foreground)_14%,transparent)] transition-shadow", tone === entry && "ring-2 ring-foreground ring-offset-2 ring-offset-background"),
|
|
2431
1973
|
style: { background: swatch(entry, toned) }
|
|
2432
1974
|
})
|
|
2433
1975
|
}, entry ?? "default"))
|
|
2434
1976
|
}) : null,
|
|
2435
|
-
texts.length > 0 ? /* @__PURE__ */
|
|
1977
|
+
texts.length > 0 ? /* @__PURE__ */ jsx8(Segments, {
|
|
2436
1978
|
label: messages.size,
|
|
2437
|
-
children: SIZES.map((entry) => /* @__PURE__ */
|
|
1979
|
+
children: SIZES.map((entry) => /* @__PURE__ */ jsx8(Segment, {
|
|
2438
1980
|
label: messages.sizes[entry],
|
|
2439
1981
|
pressed: size === entry,
|
|
2440
1982
|
onClick: () => onStyle({ size: entry }),
|
|
2441
|
-
children: /* @__PURE__ */
|
|
1983
|
+
children: /* @__PURE__ */ jsx8("span", {
|
|
2442
1984
|
className: "text-xs font-semibold uppercase",
|
|
2443
1985
|
children: entry
|
|
2444
1986
|
})
|
|
2445
1987
|
}, entry))
|
|
2446
1988
|
}) : null,
|
|
2447
|
-
shapes.length > 0 ? /* @__PURE__ */
|
|
1989
|
+
shapes.length > 0 ? /* @__PURE__ */ jsx8(Segments, {
|
|
2448
1990
|
label: messages.shape,
|
|
2449
|
-
children: SHAPES.map(({ shape: kind, icon: Icon }) => /* @__PURE__ */
|
|
1991
|
+
children: SHAPES.map(({ shape: kind, icon: Icon }) => /* @__PURE__ */ jsx8(Segment, {
|
|
2450
1992
|
label: messages.shapes[kind],
|
|
2451
1993
|
pressed: shape === kind,
|
|
2452
1994
|
onClick: () => onStyle({ shape: kind }),
|
|
2453
|
-
children: /* @__PURE__ */
|
|
1995
|
+
children: /* @__PURE__ */ jsx8(Icon, {})
|
|
2454
1996
|
}, kind))
|
|
2455
1997
|
}) : null,
|
|
2456
|
-
arrows.length > 0 ? /* @__PURE__ */
|
|
1998
|
+
arrows.length > 0 ? /* @__PURE__ */ jsxs8(Segments, {
|
|
2457
1999
|
label: messages.line,
|
|
2458
2000
|
children: [
|
|
2459
|
-
/* @__PURE__ */
|
|
2001
|
+
/* @__PURE__ */ jsx8(Segment, {
|
|
2460
2002
|
label: messages.solid,
|
|
2461
2003
|
pressed: dashed === false,
|
|
2462
2004
|
onClick: () => onStyle({ dashed: false }),
|
|
2463
|
-
children: /* @__PURE__ */
|
|
2005
|
+
children: /* @__PURE__ */ jsx8(Spline, {})
|
|
2464
2006
|
}),
|
|
2465
|
-
/* @__PURE__ */
|
|
2007
|
+
/* @__PURE__ */ jsx8(Segment, {
|
|
2466
2008
|
label: messages.dashed,
|
|
2467
2009
|
pressed: dashed === true,
|
|
2468
2010
|
onClick: () => onStyle({ dashed: true }),
|
|
2469
|
-
children: /* @__PURE__ */
|
|
2011
|
+
children: /* @__PURE__ */ jsx8(Spline, {
|
|
2470
2012
|
className: "[stroke-dasharray:3_3]"
|
|
2471
2013
|
})
|
|
2472
2014
|
})
|
|
2473
2015
|
]
|
|
2474
2016
|
}) : null,
|
|
2475
|
-
arrow?.type === "arrow" ? /* @__PURE__ */
|
|
2017
|
+
arrow?.type === "arrow" ? /* @__PURE__ */ jsx8(LabelField, {
|
|
2476
2018
|
value: arrow.label ?? "",
|
|
2477
2019
|
placeholder: messages.label_,
|
|
2478
2020
|
onCommit: (label) => onStyle({ label })
|
|
2479
2021
|
}, arrow.id) : null,
|
|
2480
|
-
/* @__PURE__ */
|
|
2481
|
-
/* @__PURE__ */
|
|
2022
|
+
/* @__PURE__ */ jsx8(Divider, {}),
|
|
2023
|
+
/* @__PURE__ */ jsx8(Tool, {
|
|
2482
2024
|
label: messages.duplicate,
|
|
2483
2025
|
onClick: onDuplicate,
|
|
2484
|
-
children: /* @__PURE__ */
|
|
2026
|
+
children: /* @__PURE__ */ jsx8(Copy, {})
|
|
2485
2027
|
}),
|
|
2486
|
-
/* @__PURE__ */
|
|
2028
|
+
/* @__PURE__ */ jsx8(Tool, {
|
|
2487
2029
|
label: messages.delete,
|
|
2488
2030
|
onClick: onDelete,
|
|
2489
|
-
children: /* @__PURE__ */
|
|
2031
|
+
children: /* @__PURE__ */ jsx8(Trash22, {})
|
|
2490
2032
|
})
|
|
2491
2033
|
]
|
|
2492
2034
|
}) : null
|
|
@@ -2508,9 +2050,9 @@ function LabelField({
|
|
|
2508
2050
|
placeholder,
|
|
2509
2051
|
onCommit
|
|
2510
2052
|
}) {
|
|
2511
|
-
const [text, setText] =
|
|
2053
|
+
const [text, setText] = useState5(value);
|
|
2512
2054
|
useEffect3(() => setText(value), [value]);
|
|
2513
|
-
return /* @__PURE__ */
|
|
2055
|
+
return /* @__PURE__ */ jsx8("input", {
|
|
2514
2056
|
value: text,
|
|
2515
2057
|
"aria-label": placeholder,
|
|
2516
2058
|
placeholder,
|
|
@@ -2531,7 +2073,7 @@ function Tool({
|
|
|
2531
2073
|
onClick,
|
|
2532
2074
|
children
|
|
2533
2075
|
}) {
|
|
2534
|
-
return /* @__PURE__ */
|
|
2076
|
+
return /* @__PURE__ */ jsx8("button", {
|
|
2535
2077
|
type: "button",
|
|
2536
2078
|
"aria-label": label,
|
|
2537
2079
|
title: label,
|
|
@@ -2541,7 +2083,7 @@ function Tool({
|
|
|
2541
2083
|
});
|
|
2542
2084
|
}
|
|
2543
2085
|
function Segments({ label, children }) {
|
|
2544
|
-
return /* @__PURE__ */
|
|
2086
|
+
return /* @__PURE__ */ jsx8("div", {
|
|
2545
2087
|
role: "group",
|
|
2546
2088
|
"aria-label": label,
|
|
2547
2089
|
className: "flex items-center rounded-lg bg-muted/60 p-0.5",
|
|
@@ -2554,25 +2096,25 @@ function Segment({
|
|
|
2554
2096
|
onClick,
|
|
2555
2097
|
children
|
|
2556
2098
|
}) {
|
|
2557
|
-
return /* @__PURE__ */
|
|
2099
|
+
return /* @__PURE__ */ jsx8("button", {
|
|
2558
2100
|
type: "button",
|
|
2559
2101
|
"aria-label": label,
|
|
2560
2102
|
title: label,
|
|
2561
2103
|
"aria-pressed": pressed,
|
|
2562
2104
|
onClick,
|
|
2563
|
-
className:
|
|
2105
|
+
className: cn7("flex h-7 min-w-7 items-center justify-center rounded-md px-1.5 text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-4", pressed && "bg-background text-foreground shadow-sm"),
|
|
2564
2106
|
children
|
|
2565
2107
|
});
|
|
2566
2108
|
}
|
|
2567
2109
|
function Divider() {
|
|
2568
|
-
return /* @__PURE__ */
|
|
2110
|
+
return /* @__PURE__ */ jsx8("span", {
|
|
2569
2111
|
"aria-hidden": "true",
|
|
2570
2112
|
className: "mx-1 h-5 w-px bg-border"
|
|
2571
2113
|
});
|
|
2572
2114
|
}
|
|
2573
2115
|
|
|
2574
2116
|
// src/artifacts/renderers/canvas/edit-mode.tsx
|
|
2575
|
-
import { jsx as
|
|
2117
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
2576
2118
|
var DRAG_SHARE_MS = 50;
|
|
2577
2119
|
var GRID = 8;
|
|
2578
2120
|
var NEW_SIZES = {
|
|
@@ -2584,17 +2126,17 @@ var NEW_SIZES = {
|
|
|
2584
2126
|
function useBoardEditing(canvas, edit, onOpenBoard) {
|
|
2585
2127
|
const messages = useArtifactMessages().canvas.toolbar;
|
|
2586
2128
|
const store = useStoreApi3();
|
|
2587
|
-
const graph =
|
|
2129
|
+
const graph = useMemo2(() => canvasGraph(canvas), [canvas]);
|
|
2588
2130
|
const read = useReadGraph(graph, store);
|
|
2589
2131
|
const editing = !!edit;
|
|
2590
|
-
const [nodes, setNodes] =
|
|
2591
|
-
const [edges, setEdges] =
|
|
2592
|
-
const [madeFrom] =
|
|
2132
|
+
const [nodes, setNodes] = useState6(graph.nodes);
|
|
2133
|
+
const [edges, setEdges] = useState6(graph.edges);
|
|
2134
|
+
const [madeFrom] = useState6(() => new WeakMap);
|
|
2593
2135
|
const selected = useRef5(new Set);
|
|
2594
|
-
const [selection, setSelection] =
|
|
2595
|
-
const [typing, setTyping] =
|
|
2136
|
+
const [selection, setSelection] = useState6(new Set);
|
|
2137
|
+
const [typing, setTyping] = useState6(null);
|
|
2596
2138
|
const root = useRef5(null);
|
|
2597
|
-
const [drawnFrom, setDrawnFrom] =
|
|
2139
|
+
const [drawnFrom, setDrawnFrom] = useState6({ graph: null, editing: false });
|
|
2598
2140
|
if (drawnFrom.graph !== graph || drawnFrom.editing !== editing) {
|
|
2599
2141
|
if (editing || drawnFrom.editing)
|
|
2600
2142
|
setDrawnFrom({ graph, editing });
|
|
@@ -2643,7 +2185,7 @@ function useBoardEditing(canvas, edit, onOpenBoard) {
|
|
|
2643
2185
|
setTyping(null);
|
|
2644
2186
|
}
|
|
2645
2187
|
}, [editing]);
|
|
2646
|
-
const select =
|
|
2188
|
+
const select = useCallback2((ids) => {
|
|
2647
2189
|
const chosen = new Set(ids);
|
|
2648
2190
|
selected.current = chosen;
|
|
2649
2191
|
setSelection(chosen);
|
|
@@ -2663,14 +2205,14 @@ function useBoardEditing(canvas, edit, onOpenBoard) {
|
|
|
2663
2205
|
selected.current = next;
|
|
2664
2206
|
setSelection(next);
|
|
2665
2207
|
};
|
|
2666
|
-
const focusBoard =
|
|
2208
|
+
const focusBoard = useCallback2(() => root.current?.focus({ preventScroll: true }), []);
|
|
2667
2209
|
const share = edit?.live?.select;
|
|
2668
2210
|
useEffect4(() => {
|
|
2669
2211
|
share?.([...selection]);
|
|
2670
2212
|
}, [share, selection]);
|
|
2671
2213
|
useEffect4(() => () => share?.([]), [share]);
|
|
2672
2214
|
const dragShared = useRef5(0);
|
|
2673
|
-
const items =
|
|
2215
|
+
const items = useMemo2(() => edit ? {
|
|
2674
2216
|
typing,
|
|
2675
2217
|
startTyping: setTyping,
|
|
2676
2218
|
commitText: (id, text) => {
|
|
@@ -2783,7 +2325,7 @@ function useBoardEditing(canvas, edit, onOpenBoard) {
|
|
|
2783
2325
|
event.stopPropagation();
|
|
2784
2326
|
}
|
|
2785
2327
|
};
|
|
2786
|
-
const toolbar = /* @__PURE__ */
|
|
2328
|
+
const toolbar = /* @__PURE__ */ jsx9(CanvasToolbar, {
|
|
2787
2329
|
selection: chosenItems,
|
|
2788
2330
|
onAdd: add,
|
|
2789
2331
|
onStyle: (style) => edit.apply(styleItems(selection, style)),
|
|
@@ -2849,7 +2391,7 @@ function sameItems(left, right) {
|
|
|
2849
2391
|
return left.length === right.length && left.every((item, index) => item === right[index]);
|
|
2850
2392
|
}
|
|
2851
2393
|
function useReadGraph(graph, store) {
|
|
2852
|
-
const [measuredFrom] =
|
|
2394
|
+
const [measuredFrom] = useState6(() => new WeakMap);
|
|
2853
2395
|
const last = useRef5(null);
|
|
2854
2396
|
const { nodeLookup } = store.getState();
|
|
2855
2397
|
const measured = graph.nodes.map((node) => {
|
|
@@ -2870,1127 +2412,887 @@ function useReadGraph(graph, store) {
|
|
|
2870
2412
|
}
|
|
2871
2413
|
|
|
2872
2414
|
// src/artifacts/renderers/canvas/focus.tsx
|
|
2415
|
+
import { cn as cn10 } from "@sixb/ui/lib/utils";
|
|
2873
2416
|
import { ArrowLeft, ChevronLeft, ChevronRight } from "lucide-react";
|
|
2874
|
-
import { useCallback as useCallback6, useEffect as
|
|
2417
|
+
import { useCallback as useCallback6, useEffect as useEffect8, useMemo as useMemo4, useState as useState10 } from "react";
|
|
2875
2418
|
|
|
2876
|
-
// src/artifacts/renderers/canvas/
|
|
2877
|
-
import {
|
|
2878
|
-
import {
|
|
2879
|
-
ARTIFACT_LIMITS as ARTIFACT_LIMITS3,
|
|
2880
|
-
parseFrameEvent
|
|
2881
|
-
} from "@sixb/core/artifacts";
|
|
2882
|
-
import {
|
|
2883
|
-
boardFilePath,
|
|
2884
|
-
boardFramePatches,
|
|
2885
|
-
mergeBoardText,
|
|
2886
|
-
setBoardImage,
|
|
2887
|
-
setBoardStyle
|
|
2888
|
-
} from "@sixb/core/artifacts/live";
|
|
2889
|
-
import { Popover, PopoverContent, PopoverTrigger } from "@sixb/ui/components";
|
|
2890
|
-
import { useLocale as useLocale2 } from "@sixb/ui/lib/i18n";
|
|
2891
|
-
import { cn as cn10 } from "@sixb/ui/lib/utils";
|
|
2892
|
-
import { Code2, ImageIcon as ImageIcon2, LoaderCircle as LoaderCircle3, MessageSquarePlus as MessageSquarePlus3, Paintbrush } from "lucide-react";
|
|
2419
|
+
// src/artifacts/renderers/canvas/page-resize.tsx
|
|
2420
|
+
import { cn as cn8 } from "@sixb/ui/lib/utils";
|
|
2893
2421
|
import {
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
useMemo as useMemo5,
|
|
2899
|
-
useRef as useRef7,
|
|
2900
|
-
useState as useState9
|
|
2422
|
+
useCallback as useCallback3,
|
|
2423
|
+
useEffect as useEffect5,
|
|
2424
|
+
useRef as useRef6,
|
|
2425
|
+
useState as useState7
|
|
2901
2426
|
} from "react";
|
|
2902
2427
|
|
|
2903
|
-
// src/artifacts/renderers/canvas/
|
|
2904
|
-
import {
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
ImageUp,
|
|
2911
|
-
LoaderCircle as LoaderCircle2,
|
|
2912
|
-
RotateCcw as RotateCcw2
|
|
2913
|
-
} from "lucide-react";
|
|
2914
|
-
import { useEffect as useEffect5, useId as useId2, useRef as useRef6, useState as useState8 } from "react";
|
|
2915
|
-
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2916
|
-
var SWATCHES = [
|
|
2917
|
-
"#0f172a",
|
|
2918
|
-
"#475569",
|
|
2919
|
-
"#ffffff",
|
|
2920
|
-
"#2563eb",
|
|
2921
|
-
"#7c3aed",
|
|
2922
|
-
"#db2777",
|
|
2923
|
-
"#dc2626",
|
|
2924
|
-
"#ea580c",
|
|
2925
|
-
"#ca8a04",
|
|
2926
|
-
"#16a34a",
|
|
2927
|
-
"#0d9488"
|
|
2428
|
+
// src/artifacts/renderers/canvas/page-size.ts
|
|
2429
|
+
import { ARTIFACT_LIMITS as ARTIFACT_LIMITS3 } from "@sixb/core/artifacts";
|
|
2430
|
+
var SCREENS = [
|
|
2431
|
+
{ name: "phone", w: 390, h: 844 },
|
|
2432
|
+
{ name: "tablet", w: 768, h: 1024 },
|
|
2433
|
+
{ name: "laptop", w: 1280 },
|
|
2434
|
+
{ name: "desktop", w: 1440, h: 900 }
|
|
2928
2435
|
];
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
{ value: "left", icon: AlignLeft },
|
|
2932
|
-
{ value: "center", icon: AlignCenter },
|
|
2933
|
-
{ value: "right", icon: AlignRight }
|
|
2934
|
-
];
|
|
2935
|
-
function StylePanel({
|
|
2936
|
-
style,
|
|
2937
|
-
words,
|
|
2938
|
-
onChange
|
|
2939
|
-
}) {
|
|
2940
|
-
const messages = useArtifactMessages().canvas.edit;
|
|
2941
|
-
const background = style.background ?? style["background-color"];
|
|
2942
|
-
const setBackground = (value) => onChange(style.background !== undefined ? { background: value } : { "background-color": null, background: value });
|
|
2943
|
-
return /* @__PURE__ */ jsxs10("div", {
|
|
2944
|
-
className: "flex w-[17rem] flex-col gap-3.5",
|
|
2945
|
-
"data-board-tools": "",
|
|
2946
|
-
children: [
|
|
2947
|
-
/* @__PURE__ */ jsxs10(Section, {
|
|
2948
|
-
title: messages.colors,
|
|
2949
|
-
children: [
|
|
2950
|
-
/* @__PURE__ */ jsx12(ColorField, {
|
|
2951
|
-
label: messages.textColor,
|
|
2952
|
-
value: style.color,
|
|
2953
|
-
onChange: (value) => onChange({ color: value })
|
|
2954
|
-
}),
|
|
2955
|
-
/* @__PURE__ */ jsx12(ColorField, {
|
|
2956
|
-
label: messages.background,
|
|
2957
|
-
value: background,
|
|
2958
|
-
onChange: setBackground
|
|
2959
|
-
})
|
|
2960
|
-
]
|
|
2961
|
-
}),
|
|
2962
|
-
words ? /* @__PURE__ */ jsxs10(Section, {
|
|
2963
|
-
title: messages.typography,
|
|
2964
|
-
children: [
|
|
2965
|
-
/* @__PURE__ */ jsx12(LengthField, {
|
|
2966
|
-
label: messages.fontSize,
|
|
2967
|
-
value: style["font-size"],
|
|
2968
|
-
onChange: (value) => onChange({ "font-size": value })
|
|
2969
|
-
}),
|
|
2970
|
-
/* @__PURE__ */ jsx12(Row, {
|
|
2971
|
-
label: messages.weight,
|
|
2972
|
-
children: /* @__PURE__ */ jsx12(Segments2, {
|
|
2973
|
-
label: messages.weight,
|
|
2974
|
-
children: WEIGHTS.map((weight) => /* @__PURE__ */ jsx12(Segment2, {
|
|
2975
|
-
label: messages.weights[weight],
|
|
2976
|
-
pressed: normalWeight(style["font-weight"]) === weight,
|
|
2977
|
-
onClick: () => onChange({
|
|
2978
|
-
"font-weight": normalWeight(style["font-weight"]) === weight ? null : weight
|
|
2979
|
-
}),
|
|
2980
|
-
children: /* @__PURE__ */ jsx12("span", {
|
|
2981
|
-
className: "text-xs",
|
|
2982
|
-
style: { fontWeight: Number(weight) },
|
|
2983
|
-
children: "Aa"
|
|
2984
|
-
})
|
|
2985
|
-
}, weight))
|
|
2986
|
-
})
|
|
2987
|
-
}),
|
|
2988
|
-
/* @__PURE__ */ jsx12(Row, {
|
|
2989
|
-
label: messages.align,
|
|
2990
|
-
children: /* @__PURE__ */ jsx12(Segments2, {
|
|
2991
|
-
label: messages.align,
|
|
2992
|
-
children: ALIGNS.map(({ value, icon: Icon }) => /* @__PURE__ */ jsx12(Segment2, {
|
|
2993
|
-
label: messages.aligns[value],
|
|
2994
|
-
pressed: style["text-align"] === value,
|
|
2995
|
-
onClick: () => onChange({ "text-align": style["text-align"] === value ? null : value }),
|
|
2996
|
-
children: /* @__PURE__ */ jsx12(Icon, {})
|
|
2997
|
-
}, value))
|
|
2998
|
-
})
|
|
2999
|
-
})
|
|
3000
|
-
]
|
|
3001
|
-
}) : null,
|
|
3002
|
-
/* @__PURE__ */ jsxs10(Section, {
|
|
3003
|
-
title: messages.layout,
|
|
3004
|
-
children: [
|
|
3005
|
-
/* @__PURE__ */ jsx12(LengthField, {
|
|
3006
|
-
label: messages.padding,
|
|
3007
|
-
value: style.padding,
|
|
3008
|
-
onChange: (value) => onChange({ padding: value })
|
|
3009
|
-
}),
|
|
3010
|
-
/* @__PURE__ */ jsx12(LengthField, {
|
|
3011
|
-
label: messages.gap,
|
|
3012
|
-
value: style.gap,
|
|
3013
|
-
onChange: (value) => onChange({ gap: value })
|
|
3014
|
-
}),
|
|
3015
|
-
/* @__PURE__ */ jsx12(LengthField, {
|
|
3016
|
-
label: messages.radius,
|
|
3017
|
-
value: style["border-radius"],
|
|
3018
|
-
onChange: (value) => onChange({ "border-radius": value })
|
|
3019
|
-
})
|
|
3020
|
-
]
|
|
3021
|
-
})
|
|
3022
|
-
]
|
|
3023
|
-
});
|
|
3024
|
-
}
|
|
3025
|
-
function normalWeight(weight) {
|
|
3026
|
-
if (weight === "normal")
|
|
3027
|
-
return "400";
|
|
3028
|
-
if (weight === "bold")
|
|
3029
|
-
return "700";
|
|
3030
|
-
return weight;
|
|
3031
|
-
}
|
|
3032
|
-
function Section({ title, children }) {
|
|
3033
|
-
return /* @__PURE__ */ jsxs10("section", {
|
|
3034
|
-
className: "flex flex-col gap-2",
|
|
3035
|
-
children: [
|
|
3036
|
-
/* @__PURE__ */ jsx12("h3", {
|
|
3037
|
-
className: "m-0 text-[11px] font-semibold tracking-wide text-muted-foreground uppercase",
|
|
3038
|
-
children: title
|
|
3039
|
-
}),
|
|
3040
|
-
children
|
|
3041
|
-
]
|
|
3042
|
-
});
|
|
3043
|
-
}
|
|
3044
|
-
function Row({ label, children }) {
|
|
3045
|
-
return /* @__PURE__ */ jsxs10("div", {
|
|
3046
|
-
className: "flex items-center justify-between gap-3",
|
|
3047
|
-
children: [
|
|
3048
|
-
/* @__PURE__ */ jsx12("span", {
|
|
3049
|
-
className: "text-xs text-foreground/80",
|
|
3050
|
-
children: label
|
|
3051
|
-
}),
|
|
3052
|
-
children
|
|
3053
|
-
]
|
|
3054
|
-
});
|
|
3055
|
-
}
|
|
3056
|
-
function ColorField({
|
|
3057
|
-
label,
|
|
3058
|
-
value,
|
|
3059
|
-
onChange
|
|
3060
|
-
}) {
|
|
3061
|
-
const messages = useArtifactMessages().canvas.edit;
|
|
3062
|
-
return /* @__PURE__ */ jsxs10("div", {
|
|
3063
|
-
className: "flex flex-col gap-1.5",
|
|
3064
|
-
children: [
|
|
3065
|
-
/* @__PURE__ */ jsx12(ValueField, {
|
|
3066
|
-
label,
|
|
3067
|
-
value,
|
|
3068
|
-
onChange,
|
|
3069
|
-
swatch: value
|
|
3070
|
-
}),
|
|
3071
|
-
/* @__PURE__ */ jsx12("div", {
|
|
3072
|
-
className: "flex flex-wrap gap-1",
|
|
3073
|
-
role: "group",
|
|
3074
|
-
"aria-label": label,
|
|
3075
|
-
children: SWATCHES.map((color) => /* @__PURE__ */ jsx12("button", {
|
|
3076
|
-
type: "button",
|
|
3077
|
-
"aria-label": messages.swatch(color),
|
|
3078
|
-
title: color,
|
|
3079
|
-
"aria-pressed": value?.toLowerCase() === color,
|
|
3080
|
-
onClick: () => onChange(color),
|
|
3081
|
-
className: "flex size-5 items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
3082
|
-
children: /* @__PURE__ */ jsx12("span", {
|
|
3083
|
-
"aria-hidden": "true",
|
|
3084
|
-
className: cn9("size-4 rounded-full ring-1 ring-[color-mix(in_oklab,var(--foreground)_16%,transparent)]", value?.toLowerCase() === color && "ring-2 ring-foreground ring-offset-1 ring-offset-popover"),
|
|
3085
|
-
style: { background: color }
|
|
3086
|
-
})
|
|
3087
|
-
}, color))
|
|
3088
|
-
})
|
|
3089
|
-
]
|
|
3090
|
-
});
|
|
2436
|
+
function isScreen(name) {
|
|
2437
|
+
return SCREENS.some((screen) => screen.name === name);
|
|
3091
2438
|
}
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
function ValueField({
|
|
3104
|
-
label,
|
|
3105
|
-
value,
|
|
3106
|
-
onChange,
|
|
3107
|
-
swatch
|
|
3108
|
-
}) {
|
|
3109
|
-
const messages = useArtifactMessages().canvas.edit;
|
|
3110
|
-
const id = useId2();
|
|
3111
|
-
const [text, setText] = useState8(value ?? "");
|
|
3112
|
-
const [invalid, setInvalid] = useState8(false);
|
|
3113
|
-
useEffect5(() => {
|
|
3114
|
-
setText(value ?? "");
|
|
3115
|
-
setInvalid(false);
|
|
3116
|
-
}, [value]);
|
|
3117
|
-
const commit = () => {
|
|
3118
|
-
const next = text.trim();
|
|
3119
|
-
if (next === (value ?? ""))
|
|
3120
|
-
return;
|
|
3121
|
-
setInvalid(!onChange(next === "" ? null : next));
|
|
2439
|
+
var PAGE_MIN = { w: 240, h: 160 };
|
|
2440
|
+
var PAGE_MAX = ARTIFACT_LIMITS3.maxCanvasItemSize;
|
|
2441
|
+
var GRID2 = 8;
|
|
2442
|
+
var SNAP_REACH = 8;
|
|
2443
|
+
var ZOOM_MIN = 0.1;
|
|
2444
|
+
var ZOOM_MAX = 2.5;
|
|
2445
|
+
var ZOOM_STEP = 1.2;
|
|
2446
|
+
function clampSize(size, least = PAGE_MIN) {
|
|
2447
|
+
return {
|
|
2448
|
+
w: Math.round(Math.min(PAGE_MAX, Math.max(least.w, size.w))),
|
|
2449
|
+
h: Math.round(Math.min(PAGE_MAX, Math.max(least.h, size.h)))
|
|
3122
2450
|
};
|
|
3123
|
-
return /* @__PURE__ */ jsxs10("div", {
|
|
3124
|
-
className: "flex items-center justify-between gap-3",
|
|
3125
|
-
children: [
|
|
3126
|
-
/* @__PURE__ */ jsx12("label", {
|
|
3127
|
-
htmlFor: id,
|
|
3128
|
-
className: "text-xs text-foreground/80",
|
|
3129
|
-
children: label
|
|
3130
|
-
}),
|
|
3131
|
-
/* @__PURE__ */ jsxs10("div", {
|
|
3132
|
-
className: "flex items-center gap-1",
|
|
3133
|
-
children: [
|
|
3134
|
-
/* @__PURE__ */ jsxs10("div", {
|
|
3135
|
-
className: cn9("flex h-7 w-[8.5rem] items-center gap-1.5 rounded-md border bg-background px-1.5 text-xs focus-within:ring-2 focus-within:ring-ring", invalid ? "border-destructive" : "border-border"),
|
|
3136
|
-
children: [
|
|
3137
|
-
swatch !== undefined ? /* @__PURE__ */ jsx12("span", {
|
|
3138
|
-
"aria-hidden": "true",
|
|
3139
|
-
className: "size-3.5 shrink-0 rounded-[4px] ring-1 ring-[color-mix(in_oklab,var(--foreground)_16%,transparent)]",
|
|
3140
|
-
style: { background: swatch || "transparent" }
|
|
3141
|
-
}) : null,
|
|
3142
|
-
/* @__PURE__ */ jsx12("input", {
|
|
3143
|
-
id,
|
|
3144
|
-
value: text,
|
|
3145
|
-
placeholder: messages.inherited,
|
|
3146
|
-
"aria-invalid": invalid || undefined,
|
|
3147
|
-
spellCheck: false,
|
|
3148
|
-
onChange: (event) => setText(event.target.value),
|
|
3149
|
-
onBlur: commit,
|
|
3150
|
-
onKeyDown: (event) => {
|
|
3151
|
-
event.stopPropagation();
|
|
3152
|
-
if (event.key === "Enter")
|
|
3153
|
-
commit();
|
|
3154
|
-
},
|
|
3155
|
-
className: "h-full min-w-0 flex-1 bg-transparent font-mono text-[11px] outline-none placeholder:font-sans placeholder:text-muted-foreground/70"
|
|
3156
|
-
})
|
|
3157
|
-
]
|
|
3158
|
-
}),
|
|
3159
|
-
/* @__PURE__ */ jsx12("button", {
|
|
3160
|
-
type: "button",
|
|
3161
|
-
"aria-label": messages.reset(label),
|
|
3162
|
-
title: messages.reset(label),
|
|
3163
|
-
disabled: value === undefined,
|
|
3164
|
-
onClick: () => onChange(null),
|
|
3165
|
-
className: "flex size-6 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-30 [&_svg]:size-3.5",
|
|
3166
|
-
children: /* @__PURE__ */ jsx12(RotateCcw2, {})
|
|
3167
|
-
})
|
|
3168
|
-
]
|
|
3169
|
-
}),
|
|
3170
|
-
invalid ? /* @__PURE__ */ jsx12("span", {
|
|
3171
|
-
role: "alert",
|
|
3172
|
-
className: "sr-only",
|
|
3173
|
-
children: messages.invalid
|
|
3174
|
-
}) : null
|
|
3175
|
-
]
|
|
3176
|
-
});
|
|
3177
2451
|
}
|
|
3178
|
-
function
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
}
|
|
2452
|
+
function sizeSuggestions(board, content) {
|
|
2453
|
+
const least = { w: Math.min(PAGE_MIN.w, board.w), h: Math.min(PAGE_MIN.h, board.h) };
|
|
2454
|
+
const full = content === null ? [] : [{ name: "full", h: clampSize({ ...board, h: content }, least).h }];
|
|
2455
|
+
const widths = distinct([{ name: "board", w: board.w }, ...SCREENS], (each) => each.w);
|
|
2456
|
+
const heights = distinct([{ name: "board", h: board.h }, ...full], (each) => each.h);
|
|
2457
|
+
const sizes = distinct([{ name: "board", w: board.w, h: board.h }, ...SCREENS.filter((screen) => ("h" in screen))], (each) => `${each.w}\xD7${each.h}`);
|
|
2458
|
+
return { widths, heights, sizes, least };
|
|
3185
2459
|
}
|
|
3186
|
-
function
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
"aria-label": label,
|
|
3195
|
-
title: label,
|
|
3196
|
-
"aria-pressed": pressed,
|
|
3197
|
-
onClick,
|
|
3198
|
-
className: cn9("flex h-6 min-w-7 items-center justify-center rounded-md px-1.5 text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5", pressed && "bg-background text-foreground shadow-sm"),
|
|
3199
|
-
children
|
|
2460
|
+
function distinct(suggestions, key) {
|
|
2461
|
+
const seen = new Set;
|
|
2462
|
+
return suggestions.filter((suggestion) => {
|
|
2463
|
+
const value = key(suggestion);
|
|
2464
|
+
if (seen.has(value))
|
|
2465
|
+
return false;
|
|
2466
|
+
seen.add(value);
|
|
2467
|
+
return true;
|
|
3200
2468
|
});
|
|
3201
2469
|
}
|
|
3202
|
-
function
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
}
|
|
3212
|
-
const
|
|
3213
|
-
const
|
|
3214
|
-
const
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
const replaced = (shown) => {
|
|
3220
|
-
if (shown)
|
|
3221
|
-
description.current?.focus();
|
|
3222
|
-
};
|
|
3223
|
-
return /* @__PURE__ */ jsxs10("div", {
|
|
3224
|
-
className: "flex w-[17rem] flex-col gap-3",
|
|
3225
|
-
"data-board-tools": "",
|
|
3226
|
-
children: [
|
|
3227
|
-
/* @__PURE__ */ jsx12("input", {
|
|
3228
|
-
ref: input,
|
|
3229
|
-
type: "file",
|
|
3230
|
-
accept: "image/*",
|
|
3231
|
-
className: "sr-only",
|
|
3232
|
-
tabIndex: -1,
|
|
3233
|
-
"aria-hidden": "true",
|
|
3234
|
-
onChange: (event) => {
|
|
3235
|
-
const file = event.target.files?.[0];
|
|
3236
|
-
event.target.value = "";
|
|
3237
|
-
if (file)
|
|
3238
|
-
onUpload(file).then(replaced);
|
|
3239
|
-
}
|
|
3240
|
-
}),
|
|
3241
|
-
/* @__PURE__ */ jsxs10("button", {
|
|
3242
|
-
type: "button",
|
|
3243
|
-
disabled: uploading,
|
|
3244
|
-
onClick: () => input.current?.click(),
|
|
3245
|
-
className: "flex h-9 items-center justify-center gap-2 rounded-lg border border-dashed border-border bg-muted/40 text-sm font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60 [&_svg]:size-4",
|
|
3246
|
-
children: [
|
|
3247
|
-
uploading ? /* @__PURE__ */ jsx12(LoaderCircle2, {
|
|
3248
|
-
className: "animate-spin motion-reduce:animate-none",
|
|
3249
|
-
"aria-hidden": "true"
|
|
3250
|
-
}) : /* @__PURE__ */ jsx12(ImageUp, {
|
|
3251
|
-
"aria-hidden": "true"
|
|
3252
|
-
}),
|
|
3253
|
-
uploading ? messages.uploading : messages.upload
|
|
3254
|
-
]
|
|
3255
|
-
}),
|
|
3256
|
-
failure ? /* @__PURE__ */ jsx12("p", {
|
|
3257
|
-
role: "alert",
|
|
3258
|
-
className: "m-0 text-xs text-destructive",
|
|
3259
|
-
children: failure
|
|
3260
|
-
}) : null,
|
|
3261
|
-
/* @__PURE__ */ jsxs10("section", {
|
|
3262
|
-
className: "flex flex-col gap-2",
|
|
3263
|
-
children: [
|
|
3264
|
-
/* @__PURE__ */ jsx12("h3", {
|
|
3265
|
-
className: "m-0 text-[11px] font-semibold tracking-wide text-muted-foreground uppercase",
|
|
3266
|
-
children: messages.fromCanvas
|
|
3267
|
-
}),
|
|
3268
|
-
others.length > 0 ? /* @__PURE__ */ jsx12("div", {
|
|
3269
|
-
className: "grid max-h-40 grid-cols-4 gap-1.5 overflow-y-auto p-0.5",
|
|
3270
|
-
children: others.map((image) => /* @__PURE__ */ jsx12("button", {
|
|
3271
|
-
type: "button",
|
|
3272
|
-
title: image.path,
|
|
3273
|
-
"aria-label": image.path,
|
|
3274
|
-
onClick: () => replaced(onPick(image.path)),
|
|
3275
|
-
className: "flex aspect-square items-center justify-center overflow-hidden rounded-md bg-muted outline-none ring-1 ring-border transition-shadow hover:ring-2 hover:ring-primary focus-visible:ring-2 focus-visible:ring-ring",
|
|
3276
|
-
children: image.url ? /* @__PURE__ */ jsx12("img", {
|
|
3277
|
-
src: image.url,
|
|
3278
|
-
alt: "",
|
|
3279
|
-
loading: "lazy",
|
|
3280
|
-
className: "size-full object-cover",
|
|
3281
|
-
draggable: false
|
|
3282
|
-
}) : /* @__PURE__ */ jsx12(ImageIcon, {
|
|
3283
|
-
className: "size-4 text-muted-foreground",
|
|
3284
|
-
"aria-hidden": "true"
|
|
3285
|
-
})
|
|
3286
|
-
}, image.path))
|
|
3287
|
-
}) : /* @__PURE__ */ jsx12("p", {
|
|
3288
|
-
className: "m-0 text-xs text-muted-foreground",
|
|
3289
|
-
children: messages.noImages
|
|
3290
|
-
})
|
|
3291
|
-
]
|
|
3292
|
-
}),
|
|
3293
|
-
/* @__PURE__ */ jsxs10("div", {
|
|
3294
|
-
className: "flex flex-col gap-1.5",
|
|
3295
|
-
children: [
|
|
3296
|
-
/* @__PURE__ */ jsx12("label", {
|
|
3297
|
-
htmlFor: altId,
|
|
3298
|
-
className: "text-xs text-foreground/80",
|
|
3299
|
-
children: messages.description
|
|
3300
|
-
}),
|
|
3301
|
-
/* @__PURE__ */ jsx12("input", {
|
|
3302
|
-
ref: description,
|
|
3303
|
-
id: altId,
|
|
3304
|
-
value: text,
|
|
3305
|
-
placeholder: messages.descriptionPlaceholder,
|
|
3306
|
-
onChange: (event) => setText(event.target.value),
|
|
3307
|
-
onBlur: () => {
|
|
3308
|
-
if (text !== alt)
|
|
3309
|
-
onAlt(text);
|
|
3310
|
-
},
|
|
3311
|
-
onKeyDown: (event) => {
|
|
3312
|
-
event.stopPropagation();
|
|
3313
|
-
if (event.key === "Enter" && text !== alt)
|
|
3314
|
-
onAlt(text);
|
|
3315
|
-
},
|
|
3316
|
-
className: "h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
3317
|
-
})
|
|
3318
|
-
]
|
|
3319
|
-
})
|
|
3320
|
-
]
|
|
3321
|
-
});
|
|
2470
|
+
function snapSize(raw, edges, suggestions, reach, free = false) {
|
|
2471
|
+
const { least } = suggestions;
|
|
2472
|
+
if (free)
|
|
2473
|
+
return { size: clampSize(raw, least), w: null, h: null };
|
|
2474
|
+
if (edges.w && edges.h) {
|
|
2475
|
+
const size = nearest(suggestions.sizes, (each) => Math.abs((each.w ?? 0) - raw.w) <= reach && Math.abs((each.h ?? 0) - raw.h) <= reach ? Math.hypot((each.w ?? 0) - raw.w, (each.h ?? 0) - raw.h) : null);
|
|
2476
|
+
if (size?.w !== undefined && size.h !== undefined) {
|
|
2477
|
+
return { size: clampSize({ w: size.w, h: size.h }, least), w: size, h: size };
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
const w = edges.w ? nearestOn(suggestions.widths, "w", raw.w, reach) : null;
|
|
2481
|
+
const h = edges.h ? nearestOn(suggestions.heights, "h", raw.h, reach) : null;
|
|
2482
|
+
const size = clampSize({
|
|
2483
|
+
w: edges.w ? w?.w ?? onGrid(raw.w) : raw.w,
|
|
2484
|
+
h: edges.h ? h?.h ?? onGrid(raw.h) : raw.h
|
|
2485
|
+
}, least);
|
|
2486
|
+
return { size, w, h };
|
|
3322
2487
|
}
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
if (!element)
|
|
3329
|
-
return null;
|
|
3330
|
-
const tag = startTag(source.slice(element.start, element.end));
|
|
3331
|
-
const pattern = new RegExp(`\\s${name}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s"'=<>\`]+))`, "i");
|
|
3332
|
-
const match = pattern.exec(tag);
|
|
3333
|
-
if (!match)
|
|
3334
|
-
return null;
|
|
3335
|
-
return decodeAttribute(match[2] ?? match[3] ?? match[4] ?? "");
|
|
2488
|
+
function nearestOn(suggestions, axis, value, reach) {
|
|
2489
|
+
return nearest(suggestions, (each) => {
|
|
2490
|
+
const at = each[axis];
|
|
2491
|
+
return at !== undefined && Math.abs(at - value) <= reach ? Math.abs(at - value) : null;
|
|
2492
|
+
});
|
|
3336
2493
|
}
|
|
3337
|
-
function
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
for (const
|
|
3341
|
-
const
|
|
3342
|
-
if (
|
|
2494
|
+
function nearest(suggestions, distance) {
|
|
2495
|
+
let best = null;
|
|
2496
|
+
let least = Number.POSITIVE_INFINITY;
|
|
2497
|
+
for (const suggestion of suggestions) {
|
|
2498
|
+
const away = distance(suggestion);
|
|
2499
|
+
if (away === null || away >= least)
|
|
3343
2500
|
continue;
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
if (property && value)
|
|
3347
|
-
declarations[property] = value;
|
|
2501
|
+
best = suggestion;
|
|
2502
|
+
least = away;
|
|
3348
2503
|
}
|
|
3349
|
-
return
|
|
2504
|
+
return best;
|
|
3350
2505
|
}
|
|
3351
|
-
function
|
|
3352
|
-
|
|
3353
|
-
for (let index = 0;index < html.length; index += 1) {
|
|
3354
|
-
const char = html[index];
|
|
3355
|
-
if (quote) {
|
|
3356
|
-
if (char === quote)
|
|
3357
|
-
quote = null;
|
|
3358
|
-
} else if (char === '"' || char === "'")
|
|
3359
|
-
quote = char;
|
|
3360
|
-
else if (char === ">")
|
|
3361
|
-
return html.slice(0, index);
|
|
3362
|
-
}
|
|
3363
|
-
return html;
|
|
2506
|
+
function onGrid(value) {
|
|
2507
|
+
return Math.round(value / GRID2) * GRID2;
|
|
3364
2508
|
}
|
|
3365
|
-
function
|
|
3366
|
-
|
|
2509
|
+
function fitScale(page, room, how) {
|
|
2510
|
+
const whole = clampZoom(Math.min(room.width / page.w, room.height / page.h));
|
|
2511
|
+
if (how === "whole" || page.h <= page.w)
|
|
2512
|
+
return whole;
|
|
2513
|
+
const width = clampZoom(Math.min(room.width / page.w, Math.max(whole, 1)));
|
|
2514
|
+
return whole >= width * 0.8 ? whole : width;
|
|
3367
2515
|
}
|
|
3368
|
-
function
|
|
3369
|
-
|
|
3370
|
-
return null;
|
|
3371
|
-
const parts = board.split("/").slice(0, -1);
|
|
3372
|
-
for (const part of reference.split(/[?#]/)[0]?.split("/") ?? []) {
|
|
3373
|
-
if (part === "" || part === ".")
|
|
3374
|
-
continue;
|
|
3375
|
-
if (part === "..") {
|
|
3376
|
-
if (parts.length === 0)
|
|
3377
|
-
return null;
|
|
3378
|
-
parts.pop();
|
|
3379
|
-
continue;
|
|
3380
|
-
}
|
|
3381
|
-
try {
|
|
3382
|
-
parts.push(decodeURIComponent(part));
|
|
3383
|
-
} catch {
|
|
3384
|
-
return null;
|
|
3385
|
-
}
|
|
3386
|
-
}
|
|
3387
|
-
return parts.join("/");
|
|
2516
|
+
function zoomStep(scale, direction) {
|
|
2517
|
+
return clampZoom(direction === "in" ? scale * ZOOM_STEP : scale / ZOOM_STEP);
|
|
3388
2518
|
}
|
|
3389
|
-
function
|
|
3390
|
-
|
|
3391
|
-
const shown = [];
|
|
3392
|
-
for (const patch of patches) {
|
|
3393
|
-
const src = patch.attributes?.src;
|
|
3394
|
-
const path = src === undefined ? null : boardReferencePath(board, src);
|
|
3395
|
-
if (src === undefined || path === null || holds(path)) {
|
|
3396
|
-
shown.push(patch);
|
|
3397
|
-
continue;
|
|
3398
|
-
}
|
|
3399
|
-
const preview = previews.get(path);
|
|
3400
|
-
if (preview && patch.attributes) {
|
|
3401
|
-
shown.push({ ...patch, attributes: { ...patch.attributes, src: preview } });
|
|
3402
|
-
continue;
|
|
3403
|
-
}
|
|
3404
|
-
waiting = true;
|
|
3405
|
-
}
|
|
3406
|
-
return { patches: shown, waiting };
|
|
2519
|
+
function clampZoom(scale) {
|
|
2520
|
+
return Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, scale));
|
|
3407
2521
|
}
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
import { jsx as jsx13, jsxs as jsxs11, Fragment as Fragment6 } from "react/jsx-runtime";
|
|
3411
|
-
var IMAGE_EXTENSIONS = /\.(png|jpe?g|gif|webp|avif|svg)$/i;
|
|
3412
|
-
function useBoardFrame({
|
|
3413
|
-
version,
|
|
3414
|
-
board,
|
|
3415
|
-
live
|
|
3416
|
-
}) {
|
|
3417
|
-
const source = useLiveBoardSource(live, board.file);
|
|
3418
|
-
const patching = source !== null;
|
|
3419
|
-
const [pinned, setPinned] = useState9(version);
|
|
3420
|
-
const shows = patching ? pinned : version;
|
|
3421
|
-
const stored = useFileText(patching ? versionFileSource(pinned, board.file) : null).text;
|
|
3422
|
-
const handle = useRef7(null);
|
|
3423
|
-
const [loads, setLoads] = useState9(0);
|
|
3424
|
-
const shown = useRef7(null);
|
|
3425
|
-
const previews = useRef7(new Map);
|
|
3426
|
-
const [stale, setStale] = useState9(false);
|
|
3427
|
-
const [moved, setMoved] = useState9(false);
|
|
3428
|
-
const [holding, setHolding] = useState9(false);
|
|
3429
|
-
const ready = useCallback5(() => {
|
|
3430
|
-
shown.current = null;
|
|
3431
|
-
setLoads((count) => count + 1);
|
|
3432
|
-
}, []);
|
|
3433
|
-
useEffect6(() => {
|
|
3434
|
-
if (loads === 0 || stored === undefined || source === null)
|
|
3435
|
-
return;
|
|
3436
|
-
const patches = boardFramePatches(shown.current ?? stored, source);
|
|
3437
|
-
if (patches === null) {
|
|
3438
|
-
setStale(true);
|
|
3439
|
-
setMoved(true);
|
|
3440
|
-
return;
|
|
3441
|
-
}
|
|
3442
|
-
setMoved(false);
|
|
3443
|
-
const holds = (path) => shows.files.some((file) => file.path === path);
|
|
3444
|
-
const showable = showablePatches(patches, board.file, holds, previews.current);
|
|
3445
|
-
if (showable.waiting)
|
|
3446
|
-
setStale(true);
|
|
3447
|
-
shown.current = source;
|
|
3448
|
-
if (showable.patches.length === 0)
|
|
3449
|
-
return;
|
|
3450
|
-
handle.current?.send("edit.patch", { patches: showable.patches }).catch(() => {});
|
|
3451
|
-
}, [loads, stored, source, shows, board.file]);
|
|
3452
|
-
useEffect6(() => {
|
|
3453
|
-
if (!stale || holding && !moved || version.revision <= pinned.revision)
|
|
3454
|
-
return;
|
|
3455
|
-
setStale(false);
|
|
3456
|
-
setPinned(version);
|
|
3457
|
-
}, [stale, holding, moved, version, pinned.revision]);
|
|
3458
|
-
const resync = useCallback5(() => {
|
|
3459
|
-
shown.current = null;
|
|
3460
|
-
handle.current?.send("reload", {}).catch(() => {});
|
|
3461
|
-
}, []);
|
|
3462
|
-
return {
|
|
3463
|
-
shows,
|
|
3464
|
-
source,
|
|
3465
|
-
handle,
|
|
3466
|
-
loads,
|
|
3467
|
-
ready,
|
|
3468
|
-
resync,
|
|
3469
|
-
stale,
|
|
3470
|
-
moved,
|
|
3471
|
-
previews: previews.current,
|
|
3472
|
-
hold: setHolding
|
|
3473
|
-
};
|
|
2522
|
+
function sameSize(left, right) {
|
|
2523
|
+
return left.w === right.w && left.h === right.h;
|
|
3474
2524
|
}
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
2525
|
+
|
|
2526
|
+
// src/artifacts/renderers/canvas/page-resize.tsx
|
|
2527
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2528
|
+
var EDGES = {
|
|
2529
|
+
right: { w: true, h: false },
|
|
2530
|
+
bottom: { w: false, h: true },
|
|
2531
|
+
corner: { w: true, h: true }
|
|
2532
|
+
};
|
|
2533
|
+
var KEY_STEP = 8;
|
|
2534
|
+
var KEY_LEAP = 64;
|
|
2535
|
+
var SCROLL_ZONE = 40;
|
|
2536
|
+
var SCROLL_SPEED = SNAP_REACH * 2;
|
|
2537
|
+
var DETENT_MS = 500;
|
|
2538
|
+
function PageResizer({
|
|
2539
|
+
size,
|
|
3479
2540
|
scale,
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
draft,
|
|
3486
|
-
fallback,
|
|
3487
|
-
failure,
|
|
3488
|
-
onPress,
|
|
3489
|
-
onPick,
|
|
3490
|
-
onOpenPin,
|
|
3491
|
-
onSubmitDraft,
|
|
3492
|
-
onCancelDraft
|
|
2541
|
+
suggestions,
|
|
2542
|
+
stage,
|
|
2543
|
+
onStart,
|
|
2544
|
+
onResize,
|
|
2545
|
+
onEnd
|
|
3493
2546
|
}) {
|
|
3494
|
-
const messages = useArtifactMessages().canvas;
|
|
3495
|
-
const
|
|
3496
|
-
const
|
|
3497
|
-
const
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
const { hold } = frame;
|
|
3505
|
-
useEffect6(() => {
|
|
3506
|
-
hold(editing && selected?.kind === "text");
|
|
3507
|
-
}, [hold, editing, selected]);
|
|
3508
|
-
useEffect6(() => {
|
|
3509
|
-
if (!editing || frame.moved) {
|
|
3510
|
-
picked.current = null;
|
|
3511
|
-
setSelected(null);
|
|
3512
|
-
}
|
|
3513
|
-
}, [editing, frame.moved]);
|
|
3514
|
-
useEffect6(() => {
|
|
3515
|
-
if (!commenting || frame.moved)
|
|
3516
|
-
setHovered(null);
|
|
3517
|
-
}, [commenting, frame.moved]);
|
|
3518
|
-
useEffect6(() => {
|
|
3519
|
-
if (!draft)
|
|
3520
|
-
setHovered(null);
|
|
3521
|
-
}, [draft]);
|
|
3522
|
-
const port = useRef7(null);
|
|
3523
|
-
const onEditRef = useRef7(() => {});
|
|
3524
|
-
useEffect6(() => {
|
|
3525
|
-
if (frame.loads === 0)
|
|
2547
|
+
const messages = useArtifactMessages().canvas.size;
|
|
2548
|
+
const [drag, setDrag] = useState7(null);
|
|
2549
|
+
const dragging = useRef6(null);
|
|
2550
|
+
const update = useCallback3((next) => {
|
|
2551
|
+
dragging.current = next;
|
|
2552
|
+
setDrag(next);
|
|
2553
|
+
}, []);
|
|
2554
|
+
const move = useCallback3((at, free) => {
|
|
2555
|
+
const current = dragging.current;
|
|
2556
|
+
if (!current)
|
|
3526
2557
|
return;
|
|
3527
|
-
const
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
2558
|
+
const edges = EDGES[current.edge];
|
|
2559
|
+
const dx = at.x - current.x + (stage ? stage.scrollLeft - current.scrolled.x : 0);
|
|
2560
|
+
const dy = at.y - current.y + (stage ? stage.scrollTop - current.scrolled.y : 0);
|
|
2561
|
+
const raw = {
|
|
2562
|
+
w: current.from.w + (edges.w ? dx / scale : 0),
|
|
2563
|
+
h: current.from.h + (edges.h ? dy / scale : 0)
|
|
3532
2564
|
};
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
2565
|
+
const snapped = snapSize(raw, edges, suggestions, SNAP_REACH / scale, free);
|
|
2566
|
+
update({ ...current, at, free, snapped });
|
|
2567
|
+
onResize(snapped.size);
|
|
2568
|
+
}, [stage, scale, suggestions, onResize, update]);
|
|
2569
|
+
const end = useCallback3((cancel) => {
|
|
2570
|
+
const current = dragging.current;
|
|
2571
|
+
if (!current)
|
|
3539
2572
|
return;
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
}, [
|
|
3545
|
-
const
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
return {
|
|
3549
|
-
x: Math.min(1, Math.max(0, x / board.w)),
|
|
3550
|
-
y: Math.min(1, Math.max(0, y / board.h))
|
|
3551
|
-
};
|
|
3552
|
-
}, [board.w, board.h]);
|
|
3553
|
-
const onEvent = useCallback5((event) => {
|
|
3554
|
-
if (event.event === "ready") {
|
|
3555
|
-
picked.current = null;
|
|
3556
|
-
setSelected(null);
|
|
3557
|
-
setHovered(null);
|
|
3558
|
-
frame.ready();
|
|
3559
|
-
} else if (event.event === "press") {
|
|
3560
|
-
onPress(event.params.text);
|
|
3561
|
-
}
|
|
3562
|
-
}, [frame, onPress]);
|
|
3563
|
-
onEditRef.current = (event) => {
|
|
3564
|
-
if (moved.current)
|
|
2573
|
+
if (cancel)
|
|
2574
|
+
onResize(current.from);
|
|
2575
|
+
update(null);
|
|
2576
|
+
onEnd(cancel ? null : current.snapped);
|
|
2577
|
+
}, [onResize, onEnd, update]);
|
|
2578
|
+
const edge = drag?.edge;
|
|
2579
|
+
useEffect5(() => {
|
|
2580
|
+
if (!edge || !stage)
|
|
3565
2581
|
return;
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
2582
|
+
const edges = EDGES[edge];
|
|
2583
|
+
let frame = 0;
|
|
2584
|
+
let resting = null;
|
|
2585
|
+
const roll = (now) => {
|
|
2586
|
+
frame = requestAnimationFrame(roll);
|
|
2587
|
+
const current = dragging.current;
|
|
2588
|
+
if (!current)
|
|
3570
2589
|
return;
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
if (!target)
|
|
3576
|
-
return;
|
|
3577
|
-
setHovered(null);
|
|
3578
|
-
const element = target.address ?? target.within ?? undefined;
|
|
3579
|
-
onPick({
|
|
3580
|
-
...element ? { element } : {},
|
|
3581
|
-
...target.label ? { label: target.label } : {},
|
|
3582
|
-
...target.address === "body" ? { anchor: title } : {},
|
|
3583
|
-
point: point(at, target.rect),
|
|
3584
|
-
under: Math.min(1, (target.rect.y + target.rect.height) / board.h)
|
|
3585
|
-
});
|
|
3586
|
-
return;
|
|
3587
|
-
}
|
|
3588
|
-
if (!editing)
|
|
3589
|
-
return;
|
|
3590
|
-
picked.current = target;
|
|
3591
|
-
setSelected(target);
|
|
2590
|
+
const held = current.snapped.h ?? current.snapped.w;
|
|
2591
|
+
if (held && held !== resting?.at)
|
|
2592
|
+
resting = { at: held, until: now + DETENT_MS };
|
|
2593
|
+
if (held && resting && now < resting.until)
|
|
3592
2594
|
return;
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
return;
|
|
3599
|
-
try {
|
|
3600
|
-
canvas.editBoard(board.file, (source) => mergeBoardText(source, address, base, text));
|
|
3601
|
-
} catch {
|
|
3602
|
-
picked.current = null;
|
|
3603
|
-
setSelected(null);
|
|
3604
|
-
frame.resync();
|
|
3605
|
-
}
|
|
2595
|
+
const rect = stage.getBoundingClientRect();
|
|
2596
|
+
const speed = (past) => Math.min(1, Math.max(0, past / SCROLL_ZONE)) * SCROLL_SPEED;
|
|
2597
|
+
const x = edges.w ? speed(current.at.x - Math.max(rect.right - SCROLL_ZONE, current.x)) : 0;
|
|
2598
|
+
const y = edges.h ? speed(current.at.y - Math.max(rect.bottom - SCROLL_ZONE, current.y)) : 0;
|
|
2599
|
+
if (x === 0 && y === 0)
|
|
3606
2600
|
return;
|
|
2601
|
+
stage.scrollBy(x, y);
|
|
2602
|
+
move(current.at, current.free);
|
|
2603
|
+
};
|
|
2604
|
+
frame = requestAnimationFrame(roll);
|
|
2605
|
+
return () => cancelAnimationFrame(frame);
|
|
2606
|
+
}, [edge, stage, move]);
|
|
2607
|
+
useEffect5(() => {
|
|
2608
|
+
if (!drag)
|
|
2609
|
+
return;
|
|
2610
|
+
const onKey = (event) => {
|
|
2611
|
+
if (event.key === "Escape") {
|
|
2612
|
+
event.preventDefault();
|
|
2613
|
+
event.stopPropagation();
|
|
2614
|
+
end(true);
|
|
2615
|
+
} else if (event.key === "Alt") {
|
|
2616
|
+
const current = dragging.current;
|
|
2617
|
+
if (current)
|
|
2618
|
+
move(current.at, event.type === "keydown");
|
|
3607
2619
|
}
|
|
3608
|
-
|
|
2620
|
+
};
|
|
2621
|
+
window.addEventListener("keydown", onKey, true);
|
|
2622
|
+
window.addEventListener("keyup", onKey, true);
|
|
2623
|
+
return () => {
|
|
2624
|
+
window.removeEventListener("keydown", onKey, true);
|
|
2625
|
+
window.removeEventListener("keyup", onKey, true);
|
|
2626
|
+
};
|
|
2627
|
+
}, [drag, end, move]);
|
|
2628
|
+
const start = (edge) => (event) => {
|
|
2629
|
+
if (event.button !== 0)
|
|
2630
|
+
return;
|
|
2631
|
+
event.preventDefault();
|
|
2632
|
+
event.stopPropagation();
|
|
2633
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
2634
|
+
onStart();
|
|
2635
|
+
const at = { x: event.clientX, y: event.clientY };
|
|
2636
|
+
update({
|
|
2637
|
+
edge,
|
|
2638
|
+
from: size,
|
|
2639
|
+
x: at.x,
|
|
2640
|
+
y: at.y,
|
|
2641
|
+
pointer: event.pointerId,
|
|
2642
|
+
scrolled: { x: stage?.scrollLeft ?? 0, y: stage?.scrollTop ?? 0 },
|
|
2643
|
+
at,
|
|
2644
|
+
free: event.altKey,
|
|
2645
|
+
snapped: { size, w: null, h: null }
|
|
2646
|
+
});
|
|
2647
|
+
};
|
|
2648
|
+
const handlers = (edge) => ({
|
|
2649
|
+
onPointerDown: start(edge),
|
|
2650
|
+
onPointerMove: (event) => {
|
|
2651
|
+
if (dragging.current?.pointer !== event.pointerId)
|
|
3609
2652
|
return;
|
|
2653
|
+
move({ x: event.clientX, y: event.clientY }, event.altKey);
|
|
2654
|
+
},
|
|
2655
|
+
onPointerUp: (event) => {
|
|
2656
|
+
if (dragging.current?.pointer === event.pointerId)
|
|
2657
|
+
end(false);
|
|
2658
|
+
},
|
|
2659
|
+
onPointerCancel: (event) => {
|
|
2660
|
+
if (dragging.current?.pointer === event.pointerId)
|
|
2661
|
+
end(true);
|
|
3610
2662
|
}
|
|
2663
|
+
});
|
|
2664
|
+
const set = (next, by = {}) => {
|
|
2665
|
+
const size = clampSize(next, suggestions.least);
|
|
2666
|
+
onStart();
|
|
2667
|
+
onResize(size);
|
|
2668
|
+
onEnd({ size, w: by.w ?? null, h: by.h ?? null });
|
|
3611
2669
|
};
|
|
3612
|
-
|
|
3613
|
-
|
|
2670
|
+
const onKeyDown = (edge) => (event) => {
|
|
2671
|
+
const edges = EDGES[edge];
|
|
2672
|
+
const by = event.shiftKey ? KEY_LEAP : KEY_STEP;
|
|
2673
|
+
const moves = edges.w ? { ArrowLeft: { ...size, w: size.w - by }, ArrowRight: { ...size, w: size.w + by } } : {};
|
|
2674
|
+
if (edges.h) {
|
|
2675
|
+
moves.ArrowUp = { ...size, h: size.h - by };
|
|
2676
|
+
moves.ArrowDown = { ...size, h: size.h + by };
|
|
2677
|
+
}
|
|
2678
|
+
const next = moves[event.key];
|
|
2679
|
+
if (!next)
|
|
2680
|
+
return;
|
|
2681
|
+
event.preventDefault();
|
|
2682
|
+
event.stopPropagation();
|
|
2683
|
+
set(next);
|
|
2684
|
+
};
|
|
2685
|
+
const full = suggestions.heights.find((each) => each.name === "full");
|
|
2686
|
+
const edges = edge ? EDGES[edge] : null;
|
|
2687
|
+
return /* @__PURE__ */ jsxs9("div", {
|
|
2688
|
+
className: "pointer-events-none absolute inset-0 z-[5]",
|
|
2689
|
+
"data-page-resizer": "",
|
|
3614
2690
|
children: [
|
|
3615
|
-
/* @__PURE__ */
|
|
3616
|
-
className: "absolute inset-0
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
2691
|
+
drag ? /* @__PURE__ */ jsx10("div", {
|
|
2692
|
+
className: "absolute inset-0 rounded-[inherit] ring-1 ring-primary",
|
|
2693
|
+
"aria-hidden": true
|
|
2694
|
+
}) : null,
|
|
2695
|
+
drag && edges ? /* @__PURE__ */ jsx10(Guides, {
|
|
2696
|
+
size: drag.snapped.size,
|
|
2697
|
+
scale,
|
|
2698
|
+
edges,
|
|
2699
|
+
drag,
|
|
2700
|
+
suggestions
|
|
2701
|
+
}) : null,
|
|
2702
|
+
/* @__PURE__ */ jsx10(Handle3, {
|
|
2703
|
+
edge: "right",
|
|
2704
|
+
label: messages.resizeWidth,
|
|
2705
|
+
value: size.w,
|
|
2706
|
+
active: edge === "right",
|
|
2707
|
+
dragging: drag !== null,
|
|
2708
|
+
size,
|
|
2709
|
+
scale,
|
|
2710
|
+
chips: suggestions.widths,
|
|
2711
|
+
onKeyDown: onKeyDown("right"),
|
|
2712
|
+
onPick: (suggestion) => set({ ...size, w: suggestion.w ?? size.w }, { w: suggestion }),
|
|
2713
|
+
...handlers("right")
|
|
3632
2714
|
}),
|
|
3633
|
-
/* @__PURE__ */
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
resolved: pin.resolved,
|
|
3647
|
-
onClick: () => onOpenPin(pin.id)
|
|
3648
|
-
})
|
|
3649
|
-
}, pin.id);
|
|
3650
|
-
}),
|
|
3651
|
-
commenting && hovered && !draft ? /* @__PURE__ */ jsx13(HoverTag, {
|
|
3652
|
-
target: hovered,
|
|
3653
|
-
scale
|
|
3654
|
-
}) : null,
|
|
3655
|
-
draft ? /* @__PURE__ */ jsxs11("div", {
|
|
3656
|
-
className: "absolute",
|
|
3657
|
-
style: { left: draft.point.x * board.w * scale, top: draft.point.y * board.h * scale },
|
|
3658
|
-
children: [
|
|
3659
|
-
/* @__PURE__ */ jsx13(CommentPin, {
|
|
3660
|
-
label: messages.comments.newPin,
|
|
3661
|
-
active: true,
|
|
3662
|
-
resolved: false,
|
|
3663
|
-
draft: true
|
|
3664
|
-
}),
|
|
3665
|
-
/* @__PURE__ */ jsx13("div", {
|
|
3666
|
-
className: cn10("absolute", draftAbove(draft) ? "bottom-9" : null),
|
|
3667
|
-
style: {
|
|
3668
|
-
...cardPlace(draft.point.x * board.w * scale, board.w * scale),
|
|
3669
|
-
...draftAbove(draft) ? {} : {
|
|
3670
|
-
top: Math.max(0, ((draft.under ?? draft.point.y) - draft.point.y) * board.h * scale) + 10
|
|
3671
|
-
}
|
|
3672
|
-
},
|
|
3673
|
-
children: /* @__PURE__ */ jsx13(DraftCard, {
|
|
3674
|
-
...draft.anchor ? { anchor: draft.anchor } : {},
|
|
3675
|
-
onSubmit: onSubmitDraft,
|
|
3676
|
-
onCancel: onCancelDraft
|
|
3677
|
-
})
|
|
3678
|
-
})
|
|
3679
|
-
]
|
|
3680
|
-
}) : null,
|
|
3681
|
-
editing && selected ? /* @__PURE__ */ jsx13(ElementTools, {
|
|
3682
|
-
target: selected,
|
|
3683
|
-
scale,
|
|
3684
|
-
board,
|
|
3685
|
-
version,
|
|
3686
|
-
live,
|
|
3687
|
-
canvas,
|
|
3688
|
-
source: frame.source,
|
|
3689
|
-
previews: frame.previews,
|
|
3690
|
-
onComment: () => onPick({
|
|
3691
|
-
...selected.address !== null ? { element: selected.address, label: selected.label } : selected.within ? { element: selected.within } : {},
|
|
3692
|
-
point: point(undefined, selected.rect)
|
|
3693
|
-
})
|
|
3694
|
-
}, selected.address ?? "scripted") : null
|
|
3695
|
-
]
|
|
2715
|
+
/* @__PURE__ */ jsx10(Handle3, {
|
|
2716
|
+
edge: "bottom",
|
|
2717
|
+
label: messages.resizeHeight,
|
|
2718
|
+
value: size.h,
|
|
2719
|
+
active: edge === "bottom",
|
|
2720
|
+
dragging: drag !== null,
|
|
2721
|
+
size,
|
|
2722
|
+
scale,
|
|
2723
|
+
chips: suggestions.heights,
|
|
2724
|
+
onKeyDown: onKeyDown("bottom"),
|
|
2725
|
+
onPick: (suggestion) => set({ ...size, h: suggestion.h ?? size.h }, { h: suggestion }),
|
|
2726
|
+
onDoubleClick: full?.h === undefined ? undefined : () => set({ ...size, h: full.h ?? size.h }, { h: full }),
|
|
2727
|
+
...handlers("bottom")
|
|
3696
2728
|
}),
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
2729
|
+
/* @__PURE__ */ jsx10(Handle3, {
|
|
2730
|
+
edge: "corner",
|
|
2731
|
+
label: messages.resizeBoth,
|
|
2732
|
+
value: size.w,
|
|
2733
|
+
active: edge === "corner",
|
|
2734
|
+
dragging: drag !== null,
|
|
2735
|
+
size,
|
|
2736
|
+
scale,
|
|
2737
|
+
chips: suggestions.sizes,
|
|
2738
|
+
onKeyDown: onKeyDown("corner"),
|
|
2739
|
+
onPick: (suggestion) => set({ w: suggestion.w ?? size.w, h: suggestion.h ?? size.h }, { w: suggestion, h: suggestion }),
|
|
2740
|
+
...handlers("corner")
|
|
2741
|
+
}),
|
|
2742
|
+
drag ? /* @__PURE__ */ jsx10(Readout, {
|
|
2743
|
+
drag,
|
|
2744
|
+
scale
|
|
2745
|
+
}) : null
|
|
2746
|
+
]
|
|
2747
|
+
});
|
|
2748
|
+
}
|
|
2749
|
+
var HANDLE_PLACES = {
|
|
2750
|
+
right: "top-0 -right-[7px] h-full w-3.5 cursor-ew-resize",
|
|
2751
|
+
bottom: "left-0 -bottom-[7px] h-3.5 w-full cursor-ns-resize",
|
|
2752
|
+
corner: "-right-2.5 -bottom-2.5 size-5 cursor-nwse-resize"
|
|
2753
|
+
};
|
|
2754
|
+
function Handle3({
|
|
2755
|
+
edge,
|
|
2756
|
+
label,
|
|
2757
|
+
value,
|
|
2758
|
+
active,
|
|
2759
|
+
dragging,
|
|
2760
|
+
size,
|
|
2761
|
+
scale,
|
|
2762
|
+
chips,
|
|
2763
|
+
onKeyDown,
|
|
2764
|
+
onPick,
|
|
2765
|
+
onDoubleClick,
|
|
2766
|
+
...pointer
|
|
2767
|
+
}) {
|
|
2768
|
+
const messages = useArtifactMessages().canvas.size;
|
|
2769
|
+
const [offering, setOffering] = useState7(false);
|
|
2770
|
+
const onFocus = (event) => {
|
|
2771
|
+
if (event.target.matches(":focus-visible"))
|
|
2772
|
+
setOffering(true);
|
|
2773
|
+
};
|
|
2774
|
+
const onBlur = (event) => {
|
|
2775
|
+
if (!event.currentTarget.contains(event.relatedTarget))
|
|
2776
|
+
setOffering(false);
|
|
2777
|
+
};
|
|
2778
|
+
return /* @__PURE__ */ jsxs9("div", {
|
|
2779
|
+
onFocus,
|
|
2780
|
+
onBlur,
|
|
2781
|
+
children: [
|
|
2782
|
+
/* @__PURE__ */ jsxs9("div", {
|
|
2783
|
+
role: "separator",
|
|
2784
|
+
tabIndex: 0,
|
|
2785
|
+
"aria-label": label,
|
|
2786
|
+
"aria-orientation": edge === "bottom" ? "horizontal" : "vertical",
|
|
2787
|
+
"aria-valuenow": value,
|
|
2788
|
+
"aria-valuetext": messages.dimensions(size.w, size.h),
|
|
2789
|
+
title: edge === "bottom" ? messages.bottomHint : label,
|
|
2790
|
+
"data-edge": edge,
|
|
2791
|
+
"data-active": active ? "" : undefined,
|
|
2792
|
+
className: cn8("group/edge pointer-events-auto absolute touch-none outline-none", HANDLE_PLACES[edge]),
|
|
2793
|
+
onKeyDown,
|
|
2794
|
+
onDoubleClick: (event) => {
|
|
2795
|
+
event.stopPropagation();
|
|
2796
|
+
onDoubleClick?.();
|
|
2797
|
+
},
|
|
2798
|
+
...pointer,
|
|
3700
2799
|
children: [
|
|
3701
|
-
/* @__PURE__ */
|
|
3702
|
-
|
|
3703
|
-
"
|
|
2800
|
+
edge === "corner" ? null : /* @__PURE__ */ jsx10("span", {
|
|
2801
|
+
"aria-hidden": true,
|
|
2802
|
+
className: cn8("absolute bg-primary opacity-0 transition-opacity duration-150 group-hover/edge:opacity-60 group-data-[active]/edge:opacity-0", edge === "right" ? "inset-y-0 left-1/2 w-px" : "inset-x-0 top-1/2 h-px")
|
|
3704
2803
|
}),
|
|
3705
|
-
|
|
2804
|
+
/* @__PURE__ */ jsx10("span", {
|
|
2805
|
+
"aria-hidden": true,
|
|
2806
|
+
className: cn8("sixb-resize-handle absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 transition-opacity duration-150 group-focus-visible/edge:opacity-100 group-focus-visible/edge:ring-2 group-focus-visible/edge:ring-ring group-hover/page:opacity-100 [@media(hover:none)]:opacity-100", dragging ? "opacity-100" : "opacity-0")
|
|
2807
|
+
})
|
|
3706
2808
|
]
|
|
2809
|
+
}),
|
|
2810
|
+
offering && !dragging ? /* @__PURE__ */ jsx10("div", {
|
|
2811
|
+
role: "group",
|
|
2812
|
+
"aria-label": messages.suggestions,
|
|
2813
|
+
className: "pointer-events-auto absolute z-10 flex max-w-72 flex-wrap justify-end gap-1",
|
|
2814
|
+
style: chipsPlace(edge, size, scale),
|
|
2815
|
+
children: chips.map((chip) => /* @__PURE__ */ jsxs9("button", {
|
|
2816
|
+
type: "button",
|
|
2817
|
+
onClick: () => onPick(chip),
|
|
2818
|
+
className: "rounded-md border border-border bg-background/95 px-1.5 py-0.5 text-[11px] leading-4 font-medium whitespace-nowrap text-foreground shadow-sm outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring",
|
|
2819
|
+
children: [
|
|
2820
|
+
messages.names[chip.name],
|
|
2821
|
+
/* @__PURE__ */ jsx10("span", {
|
|
2822
|
+
className: "ml-1 text-muted-foreground tabular-nums",
|
|
2823
|
+
children: messages.dimension(edge === "bottom" ? undefined : chip.w, edge === "right" ? undefined : chip.h)
|
|
2824
|
+
})
|
|
2825
|
+
]
|
|
2826
|
+
}, `${chip.name}-${chip.w ?? ""}-${chip.h ?? ""}`))
|
|
3707
2827
|
}) : null
|
|
3708
2828
|
]
|
|
3709
2829
|
});
|
|
3710
2830
|
}
|
|
3711
|
-
function
|
|
3712
|
-
|
|
2831
|
+
function chipsPlace(edge, size, scale) {
|
|
2832
|
+
const right = size.w * scale;
|
|
2833
|
+
const bottom = size.h * scale;
|
|
2834
|
+
if (edge === "right")
|
|
2835
|
+
return { left: right - 14, top: bottom / 2, transform: "translate(-100%, -50%)" };
|
|
2836
|
+
if (edge === "bottom")
|
|
2837
|
+
return { left: right / 2, top: bottom - 14, transform: "translate(-50%, -100%)" };
|
|
2838
|
+
return { left: right - 14, top: bottom - 14, transform: "translate(-100%, -100%)" };
|
|
3713
2839
|
}
|
|
3714
|
-
function
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
2840
|
+
function Guides({
|
|
2841
|
+
size,
|
|
2842
|
+
scale,
|
|
2843
|
+
edges,
|
|
2844
|
+
drag,
|
|
2845
|
+
suggestions
|
|
2846
|
+
}) {
|
|
2847
|
+
const width = size.w * scale;
|
|
2848
|
+
const height = size.h * scale;
|
|
2849
|
+
const { w, h } = drag.snapped;
|
|
2850
|
+
return /* @__PURE__ */ jsxs9("div", {
|
|
2851
|
+
"aria-hidden": true,
|
|
2852
|
+
className: "absolute inset-0",
|
|
2853
|
+
children: [
|
|
2854
|
+
edges.w ? suggestions.widths.map((each) => each.w === undefined || each === w ? null : /* @__PURE__ */ jsx10("span", {
|
|
2855
|
+
className: "absolute -top-3.5 h-2 w-px bg-muted-foreground/50",
|
|
2856
|
+
style: { left: each.w * scale }
|
|
2857
|
+
}, `w-${each.name}`)) : null,
|
|
2858
|
+
edges.h ? suggestions.heights.map((each) => each.h === undefined || each === h ? null : /* @__PURE__ */ jsx10("span", {
|
|
2859
|
+
className: "absolute -right-3.5 h-px w-2 bg-muted-foreground/50",
|
|
2860
|
+
style: { top: each.h * scale }
|
|
2861
|
+
}, `h-${each.name}`)) : null,
|
|
2862
|
+
w ? /* @__PURE__ */ jsx10("span", {
|
|
2863
|
+
className: "absolute -top-4 -bottom-4 w-px bg-primary motion-safe:animate-in motion-safe:fade-in",
|
|
2864
|
+
style: { left: width }
|
|
2865
|
+
}) : null,
|
|
2866
|
+
h ? /* @__PURE__ */ jsx10("span", {
|
|
2867
|
+
className: "absolute -right-4 -left-4 h-px bg-primary motion-safe:animate-in motion-safe:fade-in",
|
|
2868
|
+
style: { top: height }
|
|
2869
|
+
}) : null
|
|
2870
|
+
]
|
|
3723
2871
|
});
|
|
3724
2872
|
}
|
|
3725
|
-
function
|
|
3726
|
-
|
|
3727
|
-
|
|
2873
|
+
function Readout({ drag, scale }) {
|
|
2874
|
+
const messages = useArtifactMessages().canvas.size;
|
|
2875
|
+
const { size, w, h } = drag.snapped;
|
|
2876
|
+
const width = size.w * scale;
|
|
2877
|
+
const height = size.h * scale;
|
|
2878
|
+
const place = drag.edge === "right" ? { left: width - 12, top: height / 2, transform: "translate(-100%, -50%)" } : drag.edge === "bottom" ? { left: width / 2, top: height - 12, transform: "translate(-50%, -100%)" } : { left: width - 12, top: height - 12, transform: "translate(-100%, -100%)" };
|
|
2879
|
+
const names = [...new Set([w?.name, h?.name])].filter((name) => name !== undefined);
|
|
2880
|
+
return /* @__PURE__ */ jsxs9("span", {
|
|
2881
|
+
role: "status",
|
|
2882
|
+
className: "absolute flex items-center gap-1",
|
|
2883
|
+
style: place,
|
|
2884
|
+
children: [
|
|
2885
|
+
names.map((name) => /* @__PURE__ */ jsx10("span", {
|
|
2886
|
+
className: "rounded-md bg-primary px-1.5 py-0.5 text-[11px] leading-4 font-medium whitespace-nowrap text-primary-foreground shadow-sm motion-safe:animate-in motion-safe:fade-in motion-safe:zoom-in-95",
|
|
2887
|
+
children: messages.names[name]
|
|
2888
|
+
}, name)),
|
|
2889
|
+
/* @__PURE__ */ jsx10("span", {
|
|
2890
|
+
className: "rounded-md bg-foreground px-1.5 py-0.5 text-[11px] leading-4 font-medium whitespace-nowrap text-background tabular-nums shadow-sm",
|
|
2891
|
+
children: messages.dimensions(size.w, size.h)
|
|
2892
|
+
})
|
|
2893
|
+
]
|
|
2894
|
+
});
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2897
|
+
// src/artifacts/renderers/canvas/page-size-controls.tsx
|
|
2898
|
+
import {
|
|
2899
|
+
DropdownMenu as DropdownMenu3,
|
|
2900
|
+
DropdownMenuContent as DropdownMenuContent3,
|
|
2901
|
+
DropdownMenuItem as DropdownMenuItem3,
|
|
2902
|
+
DropdownMenuLabel,
|
|
2903
|
+
DropdownMenuSeparator,
|
|
2904
|
+
DropdownMenuTrigger as DropdownMenuTrigger3
|
|
2905
|
+
} from "@sixb/ui/components";
|
|
2906
|
+
import { cn as cn9 } from "@sixb/ui/lib/utils";
|
|
2907
|
+
import { Check as Check2, Proportions, RotateCcw as RotateCcw2 } from "lucide-react";
|
|
2908
|
+
import { useRef as useRef7 } from "react";
|
|
2909
|
+
import { jsx as jsx11, jsxs as jsxs10, Fragment as Fragment6 } from "react/jsx-runtime";
|
|
2910
|
+
var MENU = ["board", "full", "phone", "tablet", "desktop"];
|
|
2911
|
+
function menuSize(name, shown, board, suggestions) {
|
|
2912
|
+
if (name === "board")
|
|
2913
|
+
return board;
|
|
2914
|
+
if (name === "full") {
|
|
2915
|
+
const full = suggestions.heights.find((each) => each.name === "full")?.h;
|
|
2916
|
+
return full === undefined ? null : { w: shown.w, h: full };
|
|
2917
|
+
}
|
|
2918
|
+
const screen = SCREENS.find((each) => each.name === name);
|
|
2919
|
+
return screen && "h" in screen ? { w: screen.w, h: screen.h } : null;
|
|
2920
|
+
}
|
|
2921
|
+
function SizeControls({
|
|
2922
|
+
shown,
|
|
3728
2923
|
board,
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
onComment
|
|
2924
|
+
suggestions,
|
|
2925
|
+
kept,
|
|
2926
|
+
onPick,
|
|
2927
|
+
onReset,
|
|
2928
|
+
onKeep
|
|
3735
2929
|
}) {
|
|
3736
|
-
const messages = useArtifactMessages().canvas;
|
|
3737
|
-
const
|
|
3738
|
-
const
|
|
3739
|
-
const
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
const left = Math.max(4, Math.min(rect.x * scale, board.w * scale - width - 4));
|
|
3744
|
-
const above = rect.y * scale >= 44;
|
|
3745
|
-
const top = above ? rect.y * scale - 40 : (rect.y + rect.height) * scale + 8;
|
|
3746
|
-
return /* @__PURE__ */ jsxs11("div", {
|
|
3747
|
-
ref: toolbar,
|
|
3748
|
-
role: "toolbar",
|
|
3749
|
-
"aria-label": messages.edit.tools,
|
|
3750
|
-
"data-board-tools": "",
|
|
3751
|
-
className: "pointer-events-auto absolute flex max-w-[calc(100%-8px)] items-center gap-0.5 rounded-xl border border-border bg-background/95 p-1 shadow-[0_1px_2px_rgb(0_0_0/0.08),0_10px_28px_-14px_rgb(0_0_0/0.35)] backdrop-blur motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1",
|
|
3752
|
-
style: { left, top },
|
|
2930
|
+
const messages = useArtifactMessages().canvas.size;
|
|
2931
|
+
const resized = !sameSize(shown, board);
|
|
2932
|
+
const pointer = useRef7(false);
|
|
2933
|
+
const sizes = MENU.map((name) => ({ name, size: menuSize(name, shown, board, suggestions) }));
|
|
2934
|
+
const current = sizes.find(({ size }) => size !== null && sameSize(size, shown))?.name;
|
|
2935
|
+
return /* @__PURE__ */ jsxs10("div", {
|
|
2936
|
+
className: "flex shrink-0 items-center gap-1",
|
|
3753
2937
|
children: [
|
|
3754
|
-
|
|
3755
|
-
|
|
2938
|
+
kept ? /* @__PURE__ */ jsxs10("span", {
|
|
2939
|
+
role: "status",
|
|
2940
|
+
className: "flex items-center gap-1.5 px-2 text-xs font-medium text-foreground motion-safe:animate-in motion-safe:fade-in",
|
|
3756
2941
|
children: [
|
|
3757
|
-
/* @__PURE__ */
|
|
3758
|
-
className: "size-3.5
|
|
2942
|
+
/* @__PURE__ */ jsx11(Check2, {
|
|
2943
|
+
className: "size-3.5 text-primary",
|
|
3759
2944
|
"aria-hidden": "true"
|
|
3760
2945
|
}),
|
|
3761
|
-
/* @__PURE__ */
|
|
3762
|
-
className: "
|
|
2946
|
+
/* @__PURE__ */ jsx11("span", {
|
|
2947
|
+
className: "@max-3xl/canvas:sr-only",
|
|
2948
|
+
children: messages.kept(kept.w, kept.h)
|
|
2949
|
+
})
|
|
2950
|
+
]
|
|
2951
|
+
}) : null,
|
|
2952
|
+
/* @__PURE__ */ jsxs10(DropdownMenu3, {
|
|
2953
|
+
modal: false,
|
|
2954
|
+
children: [
|
|
2955
|
+
/* @__PURE__ */ jsxs10(DropdownMenuTrigger3, {
|
|
2956
|
+
onPointerDown: () => {
|
|
2957
|
+
pointer.current = true;
|
|
2958
|
+
},
|
|
2959
|
+
onKeyDown: () => {
|
|
2960
|
+
pointer.current = false;
|
|
2961
|
+
},
|
|
2962
|
+
"aria-label": resized ? `${messages.menu}, ${messages.dimensions(shown.w, shown.h)}` : messages.menu,
|
|
2963
|
+
title: resized ? messages.yoursOnly : messages.menu,
|
|
2964
|
+
className: cn9("flex h-8 shrink-0 items-center gap-1.5 rounded-lg px-2 text-sm font-medium outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:bg-muted", resized ? "bg-primary/10 text-primary hover:bg-primary/15 data-[state=open]:bg-primary/15" : "text-muted-foreground hover:text-foreground data-[state=open]:text-foreground"),
|
|
2965
|
+
children: [
|
|
2966
|
+
/* @__PURE__ */ jsx11(Proportions, {
|
|
2967
|
+
className: "size-4",
|
|
2968
|
+
"aria-hidden": "true"
|
|
2969
|
+
}),
|
|
2970
|
+
resized ? /* @__PURE__ */ jsx11("span", {
|
|
2971
|
+
className: "text-xs tabular-nums max-sm:hidden",
|
|
2972
|
+
children: messages.dimensions(shown.w, shown.h)
|
|
2973
|
+
}) : /* @__PURE__ */ jsx11("span", {
|
|
2974
|
+
className: "max-md:hidden",
|
|
2975
|
+
children: messages.label
|
|
2976
|
+
})
|
|
2977
|
+
]
|
|
2978
|
+
}),
|
|
2979
|
+
/* @__PURE__ */ jsxs10(DropdownMenuContent3, {
|
|
2980
|
+
align: "end",
|
|
2981
|
+
sideOffset: 6,
|
|
2982
|
+
className: "w-[min(17rem,calc(100vw-2rem))] p-1.5",
|
|
2983
|
+
onPointerDown: () => {
|
|
2984
|
+
pointer.current = true;
|
|
2985
|
+
},
|
|
2986
|
+
onKeyDown: () => {
|
|
2987
|
+
pointer.current = false;
|
|
2988
|
+
},
|
|
2989
|
+
onCloseAutoFocus: (event) => {
|
|
2990
|
+
if (pointer.current)
|
|
2991
|
+
event.preventDefault();
|
|
2992
|
+
},
|
|
3763
2993
|
children: [
|
|
3764
|
-
/* @__PURE__ */
|
|
3765
|
-
className: "font-medium text-foreground",
|
|
3766
|
-
children: messages.
|
|
2994
|
+
/* @__PURE__ */ jsx11(DropdownMenuLabel, {
|
|
2995
|
+
className: "px-2 pt-1 pb-1.5 text-[11px] font-medium tracking-wide text-muted-foreground uppercase",
|
|
2996
|
+
children: messages.menu
|
|
3767
2997
|
}),
|
|
3768
|
-
/* @__PURE__ */
|
|
3769
|
-
|
|
2998
|
+
sizes.map(({ name, size }) => /* @__PURE__ */ jsxs10(DropdownMenuItem3, {
|
|
2999
|
+
disabled: size === null,
|
|
3000
|
+
onSelect: () => {
|
|
3001
|
+
if (name === "board")
|
|
3002
|
+
onReset();
|
|
3003
|
+
else if (size)
|
|
3004
|
+
onPick(size, name);
|
|
3005
|
+
},
|
|
3006
|
+
className: "gap-2 rounded-md py-1.5",
|
|
3770
3007
|
children: [
|
|
3771
|
-
|
|
3772
|
-
|
|
3008
|
+
/* @__PURE__ */ jsx11(Check2, {
|
|
3009
|
+
className: cn9("size-3.5", name === current ? "text-foreground" : "invisible"),
|
|
3010
|
+
"aria-hidden": "true"
|
|
3011
|
+
}),
|
|
3012
|
+
/* @__PURE__ */ jsx11("span", {
|
|
3013
|
+
className: "flex-1 text-[13px]",
|
|
3014
|
+
children: messages.names[name]
|
|
3015
|
+
}),
|
|
3016
|
+
/* @__PURE__ */ jsx11("span", {
|
|
3017
|
+
className: "text-xs text-muted-foreground tabular-nums",
|
|
3018
|
+
children: size ? messages.dimensions(size.w, size.h) : messages.measuring
|
|
3019
|
+
})
|
|
3773
3020
|
]
|
|
3774
|
-
})
|
|
3021
|
+
}, name)),
|
|
3022
|
+
resized ? /* @__PURE__ */ jsxs10(Fragment6, {
|
|
3023
|
+
children: [
|
|
3024
|
+
/* @__PURE__ */ jsx11(DropdownMenuSeparator, {
|
|
3025
|
+
className: "my-1"
|
|
3026
|
+
}),
|
|
3027
|
+
/* @__PURE__ */ jsx11("p", {
|
|
3028
|
+
className: "px-2 pt-0.5 pb-1 text-xs text-muted-foreground",
|
|
3029
|
+
children: onKeep ? messages.yoursUntilKept : messages.yoursOnly
|
|
3030
|
+
}),
|
|
3031
|
+
onKeep ? /* @__PURE__ */ jsx11(DropdownMenuItem3, {
|
|
3032
|
+
onSelect: onKeep,
|
|
3033
|
+
className: "rounded-md py-1.5 pl-[30px] text-[13px] font-medium text-primary focus:text-primary",
|
|
3034
|
+
children: messages.keep
|
|
3035
|
+
}) : null
|
|
3036
|
+
]
|
|
3037
|
+
}) : null
|
|
3775
3038
|
]
|
|
3776
3039
|
})
|
|
3777
3040
|
]
|
|
3778
|
-
})
|
|
3041
|
+
}),
|
|
3042
|
+
resized ? /* @__PURE__ */ jsxs10("span", {
|
|
3043
|
+
className: "hidden items-center gap-1 @3xl/canvas:flex",
|
|
3779
3044
|
children: [
|
|
3780
|
-
/* @__PURE__ */
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
"
|
|
3786
|
-
|
|
3045
|
+
/* @__PURE__ */ jsx11("button", {
|
|
3046
|
+
type: "button",
|
|
3047
|
+
"aria-label": messages.reset,
|
|
3048
|
+
title: messages.reset,
|
|
3049
|
+
onClick: onReset,
|
|
3050
|
+
className: "flex size-8 items-center justify-center rounded-lg text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
|
|
3051
|
+
children: /* @__PURE__ */ jsx11(RotateCcw2, {
|
|
3052
|
+
className: "size-3.5",
|
|
3053
|
+
"aria-hidden": "true"
|
|
3054
|
+
})
|
|
3787
3055
|
}),
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
source,
|
|
3795
|
-
previews
|
|
3796
|
-
}) : null,
|
|
3797
|
-
/* @__PURE__ */ jsx13(StyleTool, {
|
|
3798
|
-
address: target.address,
|
|
3799
|
-
words: target.kind === "text" || target.kind === "box",
|
|
3800
|
-
board,
|
|
3801
|
-
canvas,
|
|
3802
|
-
source
|
|
3803
|
-
})
|
|
3056
|
+
onKeep ? /* @__PURE__ */ jsx11("button", {
|
|
3057
|
+
type: "button",
|
|
3058
|
+
onClick: onKeep,
|
|
3059
|
+
className: "h-7 shrink-0 rounded-lg bg-primary px-2.5 text-xs font-medium whitespace-nowrap text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
|
|
3060
|
+
children: messages.keep
|
|
3061
|
+
}) : null
|
|
3804
3062
|
]
|
|
3805
|
-
})
|
|
3806
|
-
/* @__PURE__ */ jsx13("span", {
|
|
3807
|
-
"aria-hidden": "true",
|
|
3808
|
-
className: "mx-0.5 h-5 w-px bg-border"
|
|
3809
|
-
}),
|
|
3810
|
-
/* @__PURE__ */ jsx13(ToolButton, {
|
|
3811
|
-
label: messages.toolbar.comment,
|
|
3812
|
-
onClick: onComment,
|
|
3813
|
-
children: /* @__PURE__ */ jsx13(MessageSquarePlus3, {})
|
|
3814
|
-
})
|
|
3063
|
+
}) : null
|
|
3815
3064
|
]
|
|
3816
3065
|
});
|
|
3817
3066
|
}
|
|
3818
|
-
|
|
3819
|
-
|
|
3067
|
+
|
|
3068
|
+
// src/artifacts/renderers/canvas/page-zoom.ts
|
|
3069
|
+
import { useCallback as useCallback4, useEffect as useEffect6, useLayoutEffect as useLayoutEffect2, useRef as useRef8, useState as useState8 } from "react";
|
|
3070
|
+
var OPEN = { fit: "open" };
|
|
3071
|
+
var SETTLE_MS = 220;
|
|
3072
|
+
function pagePlacement(view, box, pad, held = null) {
|
|
3073
|
+
const left = held?.left ?? Math.max(pad.side, (view.width - box.width) / 2);
|
|
3074
|
+
const top = held?.top ?? Math.max(pad.top, pad.top + (view.height - pad.top - pad.bottom - box.height) / 2);
|
|
3075
|
+
return {
|
|
3076
|
+
left,
|
|
3077
|
+
top,
|
|
3078
|
+
width: Math.max(view.width, left + box.width + pad.side),
|
|
3079
|
+
height: Math.max(view.height, top + box.height + pad.bottom)
|
|
3080
|
+
};
|
|
3081
|
+
}
|
|
3082
|
+
function stagePadding(view) {
|
|
3083
|
+
return view.width < 640 ? { side: 12, top: 12, bottom: 64 } : { side: 24, top: 24, bottom: 24 };
|
|
3820
3084
|
}
|
|
3821
|
-
function
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
source
|
|
3085
|
+
function usePageZoom({
|
|
3086
|
+
id,
|
|
3087
|
+
page,
|
|
3088
|
+
view,
|
|
3089
|
+
stage
|
|
3827
3090
|
}) {
|
|
3828
|
-
const
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3091
|
+
const [state, setState] = useState8({
|
|
3092
|
+
id,
|
|
3093
|
+
zoom: OPEN
|
|
3094
|
+
});
|
|
3095
|
+
const zoom = state.id === id ? state.zoom : OPEN;
|
|
3096
|
+
const [held, setHeld] = useState8(null);
|
|
3097
|
+
const [settling, setSettling] = useState8(false);
|
|
3098
|
+
const pad = view ? stagePadding(view) : null;
|
|
3099
|
+
const room = view && pad ? {
|
|
3100
|
+
width: Math.max(1, view.width - pad.side * 2),
|
|
3101
|
+
height: Math.max(1, view.height - pad.top - pad.bottom)
|
|
3102
|
+
} : null;
|
|
3103
|
+
const scale = !room ? 0 : ("scale" in zoom) ? zoom.scale : fitScale(page, room, zoom.fit);
|
|
3104
|
+
const box = { width: page.w * scale, height: page.h * scale };
|
|
3105
|
+
const placement = view && pad ? pagePlacement(view, box, pad, held) : null;
|
|
3106
|
+
const anchor = useRef8(null);
|
|
3107
|
+
const latest = useRef8({ id, scale, placement, view });
|
|
3108
|
+
latest.current = { id, scale, placement, view };
|
|
3109
|
+
useLayoutEffect2(() => {
|
|
3110
|
+
const point = anchor.current;
|
|
3111
|
+
if (!point || !stage || !placement)
|
|
3112
|
+
return;
|
|
3113
|
+
anchor.current = null;
|
|
3114
|
+
stage.scrollLeft = placement.left + point.x * scale - point.vx;
|
|
3115
|
+
stage.scrollTop = placement.top + point.y * scale - point.vy;
|
|
3116
|
+
}, [stage, placement, scale]);
|
|
3117
|
+
const fitted = "fit" in zoom ? zoom.fit : null;
|
|
3118
|
+
useLayoutEffect2(() => {
|
|
3119
|
+
if (fitted === null || !stage)
|
|
3120
|
+
return;
|
|
3121
|
+
stage.scrollTop = 0;
|
|
3122
|
+
stage.scrollLeft = 0;
|
|
3123
|
+
}, [stage, fitted, id]);
|
|
3124
|
+
const zoomTo = useCallback4((next, at = null) => {
|
|
3125
|
+
const { id, scale, placement, view } = latest.current;
|
|
3126
|
+
if (!stage || !placement || !view || scale === 0)
|
|
3127
|
+
return;
|
|
3128
|
+
const pending = anchor.current;
|
|
3129
|
+
const from = pending?.scale ?? scale;
|
|
3130
|
+
const target = clampZoom(next);
|
|
3131
|
+
if (Math.abs(target - from) < 0.0001)
|
|
3132
|
+
return;
|
|
3133
|
+
if (!pending) {
|
|
3134
|
+
const vx = at ? placement.left + at.x * scale - stage.scrollLeft : view.width / 2;
|
|
3135
|
+
const vy = at ? placement.top + at.y * scale - stage.scrollTop : view.height / 2;
|
|
3136
|
+
anchor.current = {
|
|
3137
|
+
x: (stage.scrollLeft + vx - placement.left) / scale,
|
|
3138
|
+
y: (stage.scrollTop + vy - placement.top) / scale,
|
|
3139
|
+
vx,
|
|
3140
|
+
vy,
|
|
3141
|
+
scale: target
|
|
3142
|
+
};
|
|
3143
|
+
} else {
|
|
3144
|
+
anchor.current = { ...pending, scale: target };
|
|
3838
3145
|
}
|
|
3146
|
+
setState({ id, zoom: { scale: target } });
|
|
3147
|
+
}, [stage]);
|
|
3148
|
+
const current = useCallback4(() => anchor.current?.scale ?? latest.current.scale, []);
|
|
3149
|
+
const zoomBy = useCallback4((factor, at = null) => zoomTo(current() * factor, at), [zoomTo, current]);
|
|
3150
|
+
const step = useCallback4((direction) => zoomTo(zoomStep(current(), direction)), [zoomTo, current]);
|
|
3151
|
+
const fit = useCallback4((how = "whole") => {
|
|
3152
|
+
anchor.current = null;
|
|
3153
|
+
setState({ id: latest.current.id, zoom: { fit: how } });
|
|
3154
|
+
}, []);
|
|
3155
|
+
const toggle = useCallback4((at) => {
|
|
3156
|
+
if (Math.abs(current() - 1) < 0.01)
|
|
3157
|
+
fit("whole");
|
|
3158
|
+
else
|
|
3159
|
+
zoomTo(1, at);
|
|
3160
|
+
}, [fit, zoomTo, current]);
|
|
3161
|
+
const pageAt = useCallback4((clientX, clientY) => {
|
|
3162
|
+
const { scale, placement } = latest.current;
|
|
3163
|
+
if (!stage || !placement || scale === 0)
|
|
3164
|
+
return null;
|
|
3165
|
+
const rect = stage.getBoundingClientRect();
|
|
3166
|
+
return {
|
|
3167
|
+
x: (stage.scrollLeft + clientX - rect.left - placement.left) / scale,
|
|
3168
|
+
y: (stage.scrollTop + clientY - rect.top - placement.top) / scale
|
|
3169
|
+
};
|
|
3170
|
+
}, [stage]);
|
|
3171
|
+
const hold = useCallback4(() => {
|
|
3172
|
+
const { id, scale, placement } = latest.current;
|
|
3173
|
+
if (!placement)
|
|
3174
|
+
return;
|
|
3175
|
+
setState({ id, zoom: { scale } });
|
|
3176
|
+
setHeld({ left: placement.left, top: placement.top });
|
|
3177
|
+
}, []);
|
|
3178
|
+
const release = useCallback4(() => {
|
|
3179
|
+
setHeld(null);
|
|
3180
|
+
setSettling(true);
|
|
3181
|
+
}, []);
|
|
3182
|
+
useEffect6(() => {
|
|
3183
|
+
if (!settling)
|
|
3184
|
+
return;
|
|
3185
|
+
const timer = window.setTimeout(() => setSettling(false), SETTLE_MS);
|
|
3186
|
+
return () => window.clearTimeout(timer);
|
|
3187
|
+
}, [settling]);
|
|
3188
|
+
useEffect6(() => {
|
|
3189
|
+
if (!stage)
|
|
3190
|
+
return;
|
|
3191
|
+
const mac = /Mac|iPhone|iPad/.test(navigator.platform);
|
|
3192
|
+
const onWheel = (event) => {
|
|
3193
|
+
if (!(event.ctrlKey || event.metaKey))
|
|
3194
|
+
return;
|
|
3195
|
+
event.preventDefault();
|
|
3196
|
+
const unit = event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002;
|
|
3197
|
+
const factor = 2 ** (-event.deltaY * unit * (event.ctrlKey && mac ? 10 : 1));
|
|
3198
|
+
zoomBy(factor, pageAt(event.clientX, event.clientY));
|
|
3199
|
+
};
|
|
3200
|
+
let spread = 0;
|
|
3201
|
+
const spreadOf = (touches) => {
|
|
3202
|
+
const [one, two] = [touches[0], touches[1]];
|
|
3203
|
+
return one && two ? Math.hypot(one.clientX - two.clientX, one.clientY - two.clientY) : 0;
|
|
3204
|
+
};
|
|
3205
|
+
const onTouchStart = (event) => {
|
|
3206
|
+
spread = event.touches.length === 2 ? spreadOf(event.touches) : 0;
|
|
3207
|
+
};
|
|
3208
|
+
const onTouchMove = (event) => {
|
|
3209
|
+
const [one, two] = [event.touches[0], event.touches[1]];
|
|
3210
|
+
if (!one || !two || event.touches.length !== 2 || spread === 0)
|
|
3211
|
+
return;
|
|
3212
|
+
event.preventDefault();
|
|
3213
|
+
const next = spreadOf(event.touches);
|
|
3214
|
+
zoomBy(next / spread, pageAt((one.clientX + two.clientX) / 2, (one.clientY + two.clientY) / 2));
|
|
3215
|
+
spread = next;
|
|
3216
|
+
};
|
|
3217
|
+
stage.addEventListener("wheel", onWheel, { passive: false });
|
|
3218
|
+
stage.addEventListener("touchstart", onTouchStart, { passive: true });
|
|
3219
|
+
stage.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
3220
|
+
return () => {
|
|
3221
|
+
stage.removeEventListener("wheel", onWheel);
|
|
3222
|
+
stage.removeEventListener("touchstart", onTouchStart);
|
|
3223
|
+
stage.removeEventListener("touchmove", onTouchMove);
|
|
3224
|
+
};
|
|
3225
|
+
}, [stage, zoomBy, pageAt]);
|
|
3226
|
+
return {
|
|
3227
|
+
scale,
|
|
3228
|
+
placement,
|
|
3229
|
+
held: held !== null,
|
|
3230
|
+
settling,
|
|
3231
|
+
zoomTo,
|
|
3232
|
+
zoomBy,
|
|
3233
|
+
step,
|
|
3234
|
+
fit,
|
|
3235
|
+
toggle,
|
|
3236
|
+
pageAt,
|
|
3237
|
+
hold,
|
|
3238
|
+
release
|
|
3839
3239
|
};
|
|
3840
|
-
return /* @__PURE__ */ jsxs11(Popover, {
|
|
3841
|
-
modal: false,
|
|
3842
|
-
children: [
|
|
3843
|
-
/* @__PURE__ */ jsx13(PopoverTrigger, {
|
|
3844
|
-
asChild: true,
|
|
3845
|
-
children: /* @__PURE__ */ jsx13(ToolButton, {
|
|
3846
|
-
label: messages.style,
|
|
3847
|
-
children: /* @__PURE__ */ jsx13(Paintbrush, {})
|
|
3848
|
-
})
|
|
3849
|
-
}),
|
|
3850
|
-
/* @__PURE__ */ jsx13(PopoverContent, {
|
|
3851
|
-
align: "start",
|
|
3852
|
-
sideOffset: 8,
|
|
3853
|
-
className: "w-auto p-3",
|
|
3854
|
-
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
3855
|
-
children: /* @__PURE__ */ jsx13(StylePanel, {
|
|
3856
|
-
style,
|
|
3857
|
-
words,
|
|
3858
|
-
onChange: change
|
|
3859
|
-
})
|
|
3860
|
-
})
|
|
3861
|
-
]
|
|
3862
|
-
});
|
|
3863
3240
|
}
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
const
|
|
3874
|
-
const
|
|
3875
|
-
const
|
|
3876
|
-
const
|
|
3877
|
-
const
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
const images = useMemo5(() => {
|
|
3883
|
-
const listed = new Map;
|
|
3884
|
-
for (const file of version.files) {
|
|
3885
|
-
if (!IMAGE_EXTENSIONS.test(file.path))
|
|
3886
|
-
continue;
|
|
3887
|
-
const url = versionFileSource(version, file.path)?.inlineUrl;
|
|
3888
|
-
listed.set(file.path, { path: file.path, ...url ? { url } : {} });
|
|
3889
|
-
}
|
|
3890
|
-
for (const path of stored.keys()) {
|
|
3891
|
-
if (IMAGE_EXTENSIONS.test(path) && !listed.has(path)) {
|
|
3892
|
-
const preview = previews.get(path);
|
|
3893
|
-
listed.set(path, { path, ...preview ? { url: preview } : {} });
|
|
3894
|
-
}
|
|
3895
|
-
}
|
|
3896
|
-
return [...listed.values()];
|
|
3897
|
-
}, [version, stored, previews]);
|
|
3898
|
-
const change = (image, files = {}) => {
|
|
3899
|
-
try {
|
|
3900
|
-
canvas.stopCapturing();
|
|
3901
|
-
canvas.editBoard(board.file, (page) => setBoardImage(page, address, image), files);
|
|
3902
|
-
canvas.stopCapturing();
|
|
3903
|
-
return true;
|
|
3904
|
-
} catch {
|
|
3905
|
-
setFailure(messages.notImage);
|
|
3906
|
-
return false;
|
|
3241
|
+
|
|
3242
|
+
// src/artifacts/renderers/canvas/shown-size.ts
|
|
3243
|
+
import { useCallback as useCallback5, useEffect as useEffect7, useMemo as useMemo3, useRef as useRef9, useState as useState9 } from "react";
|
|
3244
|
+
function useShownSize(id, own) {
|
|
3245
|
+
const [sizes, setSizes] = useState9({});
|
|
3246
|
+
const [screen, setScreen] = useState9(null);
|
|
3247
|
+
const [heights, setHeights] = useState9({});
|
|
3248
|
+
const height = heights[id] ?? null;
|
|
3249
|
+
const suggestions = useMemo3(() => sizeSuggestions(own, height), [own, height]);
|
|
3250
|
+
const chosen = sizes[id] ?? (screen ? clampSize({ w: screen.w, h: screen.full && height !== null ? height : own.h }, suggestions.least) : null);
|
|
3251
|
+
const shown = chosen && !sameSize(chosen, own) ? chosen : own;
|
|
3252
|
+
const onContentHeight = useCallback5((next) => setHeights((last) => last[id] === next ? last : { ...last, [id]: next }), [id]);
|
|
3253
|
+
const resize = useCallback5((size) => setSizes((last) => ({ ...last, [id]: size })), [id]);
|
|
3254
|
+
const set = (size, name, full) => {
|
|
3255
|
+
if (name !== null && isScreen(name)) {
|
|
3256
|
+
setSizes({ [id]: size });
|
|
3257
|
+
setScreen({ w: size.w, full: full ?? screen?.full ?? false });
|
|
3258
|
+
return;
|
|
3907
3259
|
}
|
|
3260
|
+
resize(size);
|
|
3261
|
+
if (screen && full !== null)
|
|
3262
|
+
setScreen({ ...screen, full });
|
|
3908
3263
|
};
|
|
3909
|
-
const
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
return
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3264
|
+
const keeping = useRef9(null);
|
|
3265
|
+
useEffect7(() => {
|
|
3266
|
+
const kept = keeping.current;
|
|
3267
|
+
if (!kept || kept.id !== id || !sameSize(kept.size, own))
|
|
3268
|
+
return;
|
|
3269
|
+
keeping.current = null;
|
|
3270
|
+
setSizes(({ [id]: _, ...others }) => others);
|
|
3271
|
+
}, [id, own]);
|
|
3272
|
+
return {
|
|
3273
|
+
shown,
|
|
3274
|
+
resized: shown !== own,
|
|
3275
|
+
suggestions,
|
|
3276
|
+
onContentHeight,
|
|
3277
|
+
resize,
|
|
3278
|
+
pick: (size, name) => set(size, name, name === "full" ? true : isScreen(name) ? false : null),
|
|
3279
|
+
settle: (snapped) => {
|
|
3280
|
+
const width = snapped.w && isScreen(snapped.w.name) ? snapped.w.name : null;
|
|
3281
|
+
set(snapped.size, width, snapped.h ? snapped.h.name === "full" : null);
|
|
3282
|
+
},
|
|
3283
|
+
reset: () => {
|
|
3284
|
+
setSizes({});
|
|
3285
|
+
setScreen(null);
|
|
3286
|
+
},
|
|
3287
|
+
keep: () => {
|
|
3288
|
+
keeping.current = { id, size: shown };
|
|
3931
3289
|
}
|
|
3932
3290
|
};
|
|
3933
|
-
return /* @__PURE__ */ jsxs11(Popover, {
|
|
3934
|
-
modal: false,
|
|
3935
|
-
children: [
|
|
3936
|
-
/* @__PURE__ */ jsx13(PopoverTrigger, {
|
|
3937
|
-
asChild: true,
|
|
3938
|
-
children: /* @__PURE__ */ jsx13(ToolButton, {
|
|
3939
|
-
label: messages.replace,
|
|
3940
|
-
children: /* @__PURE__ */ jsx13(ImageIcon2, {})
|
|
3941
|
-
})
|
|
3942
|
-
}),
|
|
3943
|
-
/* @__PURE__ */ jsx13(PopoverContent, {
|
|
3944
|
-
align: "start",
|
|
3945
|
-
sideOffset: 8,
|
|
3946
|
-
className: "w-auto p-3",
|
|
3947
|
-
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
3948
|
-
children: /* @__PURE__ */ jsx13(ImagePanel, {
|
|
3949
|
-
current,
|
|
3950
|
-
alt,
|
|
3951
|
-
images,
|
|
3952
|
-
uploading,
|
|
3953
|
-
failure,
|
|
3954
|
-
onUpload: upload,
|
|
3955
|
-
onPick: show,
|
|
3956
|
-
onAlt: (text) => {
|
|
3957
|
-
change({ alt: text });
|
|
3958
|
-
}
|
|
3959
|
-
})
|
|
3960
|
-
})
|
|
3961
|
-
]
|
|
3962
|
-
});
|
|
3963
3291
|
}
|
|
3964
|
-
function imagePath(board, name) {
|
|
3965
|
-
const folder = board.split("/").slice(0, -1);
|
|
3966
|
-
const extension = /\.([a-z0-9]{1,5})$/i.exec(name)?.[1]?.toLowerCase() ?? "png";
|
|
3967
|
-
const stem = name.replace(/\.[^.]*$/, "").toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "image";
|
|
3968
|
-
const suffix = Array.from(crypto.getRandomValues(new Uint8Array(6)), (byte) => String.fromCharCode(97 + byte % 26)).join("");
|
|
3969
|
-
return [...folder, "images", `${stem}-${suffix}.${extension}`].join("/");
|
|
3970
|
-
}
|
|
3971
|
-
async function dataUrl(file) {
|
|
3972
|
-
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
3973
|
-
let binary = "";
|
|
3974
|
-
for (let at = 0;at < bytes.length; at += 32768) {
|
|
3975
|
-
binary += String.fromCharCode(...bytes.subarray(at, at + 32768));
|
|
3976
|
-
}
|
|
3977
|
-
return `data:${file.type || "application/octet-stream"};base64,${btoa(binary)}`;
|
|
3978
|
-
}
|
|
3979
|
-
var TOOL2 = "flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:bg-muted data-[state=open]:text-foreground [&_svg]:size-4";
|
|
3980
|
-
var ToolButton = forwardRef2(function ToolButton({ label, children, ...props }, ref) {
|
|
3981
|
-
return /* @__PURE__ */ jsx13("button", {
|
|
3982
|
-
ref,
|
|
3983
|
-
type: "button",
|
|
3984
|
-
"aria-label": label,
|
|
3985
|
-
title: label,
|
|
3986
|
-
className: TOOL2,
|
|
3987
|
-
...props,
|
|
3988
|
-
children
|
|
3989
|
-
});
|
|
3990
|
-
});
|
|
3991
3292
|
|
|
3992
3293
|
// src/artifacts/renderers/canvas/focus.tsx
|
|
3993
|
-
import { jsx as
|
|
3294
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3295
|
+
var KEPT_MS = 2400;
|
|
3994
3296
|
function BoardFocus({
|
|
3995
3297
|
version,
|
|
3996
3298
|
boards,
|
|
@@ -4010,29 +3312,72 @@ function BoardFocus({
|
|
|
4010
3312
|
onPick,
|
|
4011
3313
|
onOpenPin,
|
|
4012
3314
|
onSubmitDraft,
|
|
4013
|
-
onCancelDraft
|
|
3315
|
+
onCancelDraft,
|
|
3316
|
+
onResizeBoard
|
|
4014
3317
|
}) {
|
|
4015
3318
|
const messages = useArtifactMessages().canvas;
|
|
4016
3319
|
const index = boards.findIndex((board) => board.id === id);
|
|
4017
3320
|
const board = boards[index];
|
|
4018
3321
|
const previous = boards[index - 1];
|
|
4019
3322
|
const next = boards[index + 1];
|
|
3323
|
+
const [kept, setKept] = useState10(null);
|
|
3324
|
+
const own = useMemo4(() => ({ w: board?.w ?? 1, h: board?.h ?? 1 }), [board?.w, board?.h]);
|
|
3325
|
+
const size = useShownSize(id, own);
|
|
3326
|
+
const { shown, resized, suggestions } = size;
|
|
4020
3327
|
const [stage, setStage] = useState10(null);
|
|
4021
|
-
const
|
|
3328
|
+
const view = useSize(stage);
|
|
3329
|
+
const zoom = usePageZoom({ id, page: shown, view, stage });
|
|
3330
|
+
const pickSize = (picked, name) => {
|
|
3331
|
+
size.pick(picked, name);
|
|
3332
|
+
zoom.fit("open");
|
|
3333
|
+
};
|
|
3334
|
+
const reset = () => {
|
|
3335
|
+
size.reset();
|
|
3336
|
+
zoom.fit("open");
|
|
3337
|
+
};
|
|
3338
|
+
const resizedBy = (snapped) => {
|
|
3339
|
+
zoom.release();
|
|
3340
|
+
if (snapped)
|
|
3341
|
+
size.settle(snapped);
|
|
3342
|
+
};
|
|
3343
|
+
const keep = onResizeBoard && board ? () => {
|
|
3344
|
+
onResizeBoard(board.id, { x: board.x, y: board.y, w: shown.w, h: shown.h });
|
|
3345
|
+
size.keep();
|
|
3346
|
+
setKept(shown);
|
|
3347
|
+
} : undefined;
|
|
3348
|
+
useEffect8(() => {
|
|
3349
|
+
if (!kept)
|
|
3350
|
+
return;
|
|
3351
|
+
const timer = window.setTimeout(() => setKept(null), KEPT_MS);
|
|
3352
|
+
return () => window.clearTimeout(timer);
|
|
3353
|
+
}, [kept]);
|
|
3354
|
+
const { step, zoomTo, zoomBy } = zoom;
|
|
3355
|
+
const zoomStep = useCallback6((to) => to === "actual" ? zoomTo(1) : step(to), [step, zoomTo]);
|
|
3356
|
+
const onZoom = useCallback6((by) => ("step" in by) ? zoomStep(by.step) : zoomBy(by.factor, by.at), [zoomStep, zoomBy]);
|
|
4022
3357
|
const onPress = useCallback6((text) => {
|
|
4023
3358
|
const to = followedArrow(arrows, boards, id, text);
|
|
4024
3359
|
if (to)
|
|
4025
3360
|
onOpen(to);
|
|
4026
3361
|
}, [arrows, boards, id, onOpen]);
|
|
4027
3362
|
const pick = useCallback6((place) => onPick?.(id, place), [onPick, id]);
|
|
4028
|
-
|
|
3363
|
+
useEffect8(() => {
|
|
4029
3364
|
const onKey = (event) => {
|
|
4030
|
-
if (event.metaKey || event.ctrlKey
|
|
3365
|
+
if (event.metaKey || event.ctrlKey) {
|
|
3366
|
+
const to = zoomKey(event);
|
|
3367
|
+
if (to) {
|
|
3368
|
+
event.preventDefault();
|
|
3369
|
+
zoomStep(to);
|
|
3370
|
+
}
|
|
4031
3371
|
return;
|
|
4032
|
-
|
|
4033
|
-
if (
|
|
3372
|
+
}
|
|
3373
|
+
if (event.altKey)
|
|
3374
|
+
return;
|
|
3375
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
3376
|
+
if (target?.closest("input, textarea, select, [contenteditable], [data-board-tools], [role=menu]")) {
|
|
4034
3377
|
return;
|
|
4035
3378
|
}
|
|
3379
|
+
if (event.key !== "Escape" && target?.closest("[data-page-resizer]"))
|
|
3380
|
+
return;
|
|
4036
3381
|
if (event.key === "Escape") {
|
|
4037
3382
|
if (!onEscape?.())
|
|
4038
3383
|
onClose();
|
|
@@ -4046,118 +3391,183 @@ function BoardFocus({
|
|
|
4046
3391
|
};
|
|
4047
3392
|
window.addEventListener("keydown", onKey);
|
|
4048
3393
|
return () => window.removeEventListener("keydown", onKey);
|
|
4049
|
-
}, [previous, next, onOpen, onClose, onEscape]);
|
|
3394
|
+
}, [previous, next, onOpen, onClose, onEscape, zoomStep]);
|
|
4050
3395
|
if (!board)
|
|
4051
3396
|
return null;
|
|
4052
3397
|
const title = board.title ?? board.id;
|
|
4053
|
-
const scale
|
|
4054
|
-
const picture = pictureOf?.(board.id);
|
|
4055
|
-
return /* @__PURE__ */
|
|
3398
|
+
const { scale, placement } = zoom;
|
|
3399
|
+
const picture = resized ? undefined : pictureOf?.(board.id);
|
|
3400
|
+
return /* @__PURE__ */ jsxs11("div", {
|
|
4056
3401
|
role: "dialog",
|
|
4057
3402
|
"aria-label": messages.focused(title),
|
|
4058
3403
|
className: "absolute inset-0 z-10 flex flex-col bg-background motion-safe:animate-in motion-safe:fade-in motion-safe:duration-200",
|
|
4059
3404
|
children: [
|
|
4060
|
-
/* @__PURE__ */
|
|
3405
|
+
/* @__PURE__ */ jsxs11("div", {
|
|
4061
3406
|
className: "flex h-12 shrink-0 items-center gap-2 border-b border-border/70 px-2",
|
|
4062
3407
|
children: [
|
|
4063
|
-
/* @__PURE__ */
|
|
3408
|
+
/* @__PURE__ */ jsxs11("button", {
|
|
4064
3409
|
type: "button",
|
|
4065
3410
|
onClick: onClose,
|
|
4066
3411
|
className: "flex h-8 items-center gap-1.5 rounded-lg px-2.5 text-sm font-medium text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
|
|
4067
3412
|
children: [
|
|
4068
|
-
/* @__PURE__ */
|
|
3413
|
+
/* @__PURE__ */ jsx12(ArrowLeft, {
|
|
4069
3414
|
className: "size-4",
|
|
4070
3415
|
"aria-hidden": "true"
|
|
4071
3416
|
}),
|
|
4072
3417
|
messages.back
|
|
4073
3418
|
]
|
|
4074
3419
|
}),
|
|
4075
|
-
/* @__PURE__ */
|
|
3420
|
+
/* @__PURE__ */ jsx12("span", {
|
|
4076
3421
|
className: "h-5 w-px bg-border",
|
|
4077
3422
|
"aria-hidden": "true"
|
|
4078
3423
|
}),
|
|
4079
|
-
/* @__PURE__ */
|
|
3424
|
+
/* @__PURE__ */ jsx12("span", {
|
|
4080
3425
|
className: "min-w-0 truncate px-1 text-sm font-semibold",
|
|
4081
3426
|
children: title
|
|
4082
3427
|
}),
|
|
4083
|
-
mode === "edit" || mode === "comment" ? /* @__PURE__ */
|
|
3428
|
+
mode === "edit" || mode === "comment" ? /* @__PURE__ */ jsx12("span", {
|
|
4084
3429
|
className: "hidden min-w-0 truncate text-xs text-muted-foreground @5xl/canvas:inline",
|
|
4085
3430
|
children: mode === "edit" ? messages.edit.hint : messages.comments.modeHint
|
|
4086
3431
|
}) : null,
|
|
4087
|
-
|
|
3432
|
+
/* @__PURE__ */ jsxs11("div", {
|
|
4088
3433
|
className: "ml-auto flex shrink-0 items-center",
|
|
4089
|
-
children:
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
3434
|
+
children: [
|
|
3435
|
+
/* @__PURE__ */ jsx12(SizeControls, {
|
|
3436
|
+
shown,
|
|
3437
|
+
board: own,
|
|
3438
|
+
suggestions,
|
|
3439
|
+
kept,
|
|
3440
|
+
onPick: pickSize,
|
|
3441
|
+
onReset: reset,
|
|
3442
|
+
onKeep: keep
|
|
3443
|
+
}),
|
|
3444
|
+
tools
|
|
3445
|
+
]
|
|
3446
|
+
}),
|
|
3447
|
+
/* @__PURE__ */ jsx12("span", {
|
|
3448
|
+
className: "shrink-0 text-xs whitespace-nowrap text-muted-foreground tabular-nums max-sm:hidden",
|
|
4093
3449
|
children: messages.position(index + 1, boards.length)
|
|
4094
3450
|
}),
|
|
4095
|
-
/* @__PURE__ */
|
|
3451
|
+
/* @__PURE__ */ jsx12(Step, {
|
|
4096
3452
|
label: messages.previousBoard,
|
|
4097
3453
|
disabled: !previous,
|
|
4098
3454
|
onClick: () => previous && onOpen(previous.id),
|
|
4099
|
-
children: /* @__PURE__ */
|
|
3455
|
+
children: /* @__PURE__ */ jsx12(ChevronLeft, {
|
|
4100
3456
|
className: "size-4",
|
|
4101
3457
|
"aria-hidden": "true"
|
|
4102
3458
|
})
|
|
4103
3459
|
}),
|
|
4104
|
-
/* @__PURE__ */
|
|
3460
|
+
/* @__PURE__ */ jsx12(Step, {
|
|
4105
3461
|
label: messages.nextBoard,
|
|
4106
3462
|
disabled: !next,
|
|
4107
3463
|
onClick: () => next && onOpen(next.id),
|
|
4108
|
-
children: /* @__PURE__ */
|
|
3464
|
+
children: /* @__PURE__ */ jsx12(ChevronRight, {
|
|
4109
3465
|
className: "size-4",
|
|
4110
3466
|
"aria-hidden": "true"
|
|
4111
3467
|
})
|
|
4112
3468
|
})
|
|
4113
3469
|
]
|
|
4114
3470
|
}),
|
|
4115
|
-
/* @__PURE__ */
|
|
4116
|
-
className: "
|
|
4117
|
-
children:
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
className: "
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
3471
|
+
/* @__PURE__ */ jsxs11("div", {
|
|
3472
|
+
className: "relative min-h-0 flex-1 bg-muted/40",
|
|
3473
|
+
children: [
|
|
3474
|
+
/* @__PURE__ */ jsx12("div", {
|
|
3475
|
+
ref: setStage,
|
|
3476
|
+
"data-board-stage": "",
|
|
3477
|
+
className: "absolute inset-0 touch-pan-x touch-pan-y overflow-auto overscroll-contain",
|
|
3478
|
+
onDoubleClick: (event) => {
|
|
3479
|
+
if (event.target.closest("[data-board-page]"))
|
|
3480
|
+
return;
|
|
3481
|
+
const at = zoom.pageAt(event.clientX, event.clientY);
|
|
3482
|
+
if (at)
|
|
3483
|
+
zoom.toggle(at);
|
|
3484
|
+
},
|
|
3485
|
+
children: placement && scale > 0 ? /* @__PURE__ */ jsx12("div", {
|
|
3486
|
+
className: "relative",
|
|
3487
|
+
style: { width: placement.width, height: placement.height },
|
|
3488
|
+
children: /* @__PURE__ */ jsxs11("div", {
|
|
3489
|
+
"data-board-page": "",
|
|
3490
|
+
className: cn10("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", zoom.settling ? "motion-safe:transition-[left,top] motion-safe:ease-out" : null),
|
|
3491
|
+
style: {
|
|
3492
|
+
left: placement.left,
|
|
3493
|
+
top: placement.top,
|
|
3494
|
+
width: shown.w * scale,
|
|
3495
|
+
height: shown.h * scale
|
|
3496
|
+
},
|
|
4139
3497
|
children: [
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
3498
|
+
/* @__PURE__ */ jsx12(BoardStage, {
|
|
3499
|
+
version,
|
|
3500
|
+
board,
|
|
3501
|
+
size: shown,
|
|
3502
|
+
title,
|
|
3503
|
+
scale,
|
|
3504
|
+
live,
|
|
3505
|
+
canvas,
|
|
3506
|
+
mode,
|
|
3507
|
+
pins: pins.filter((pin) => pin.board === board.id),
|
|
3508
|
+
activePin,
|
|
3509
|
+
draft: draft?.board === board.id ? draft : null,
|
|
3510
|
+
fallback: picture ? /* @__PURE__ */ jsx12(BoardPicture, {
|
|
3511
|
+
src: picture
|
|
3512
|
+
}) : undefined,
|
|
3513
|
+
failure: /* @__PURE__ */ jsxs11("div", {
|
|
3514
|
+
className: "relative size-full",
|
|
3515
|
+
children: [
|
|
3516
|
+
picture ? /* @__PURE__ */ jsx12(BoardPicture, {
|
|
3517
|
+
src: picture
|
|
3518
|
+
}) : null,
|
|
3519
|
+
/* @__PURE__ */ jsx12("p", {
|
|
3520
|
+
className: "absolute inset-x-0 bottom-0 m-0 bg-background/90 px-4 py-2 text-sm text-muted-foreground",
|
|
3521
|
+
children: messages.boardFailed
|
|
3522
|
+
})
|
|
3523
|
+
]
|
|
3524
|
+
}),
|
|
3525
|
+
onPress,
|
|
3526
|
+
onPick: pick,
|
|
3527
|
+
onOpenPin: (pin) => onOpenPin?.(pin),
|
|
3528
|
+
onSubmitDraft: (body) => onSubmitDraft?.(body) ?? Promise.resolve(),
|
|
3529
|
+
onCancelDraft: () => onCancelDraft?.(),
|
|
3530
|
+
onContentHeight: size.onContentHeight,
|
|
3531
|
+
onZoom
|
|
3532
|
+
}),
|
|
3533
|
+
/* @__PURE__ */ jsx12(PageResizer, {
|
|
3534
|
+
size: shown,
|
|
3535
|
+
scale,
|
|
3536
|
+
suggestions,
|
|
3537
|
+
stage,
|
|
3538
|
+
onStart: zoom.hold,
|
|
3539
|
+
onResize: size.resize,
|
|
3540
|
+
onEnd: resizedBy
|
|
4146
3541
|
})
|
|
4147
3542
|
]
|
|
4148
|
-
})
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
3543
|
+
}, board.id)
|
|
3544
|
+
}) : null
|
|
3545
|
+
}),
|
|
3546
|
+
/* @__PURE__ */ jsx12(ZoomBar, {
|
|
3547
|
+
zoom: scale,
|
|
3548
|
+
fitLabel: messages.fitPage,
|
|
3549
|
+
onZoomOut: () => zoom.step("out"),
|
|
3550
|
+
onActualSize: () => zoom.zoomTo(1),
|
|
3551
|
+
onZoomIn: () => zoom.step("in"),
|
|
3552
|
+
onFit: () => zoom.fit("whole"),
|
|
3553
|
+
className: "absolute bottom-3 left-3 z-20"
|
|
3554
|
+
})
|
|
3555
|
+
]
|
|
4157
3556
|
})
|
|
4158
3557
|
]
|
|
4159
3558
|
});
|
|
4160
3559
|
}
|
|
3560
|
+
function zoomKey(event) {
|
|
3561
|
+
if (event.altKey)
|
|
3562
|
+
return null;
|
|
3563
|
+
if (event.key === "=" || event.key === "+")
|
|
3564
|
+
return "in";
|
|
3565
|
+
if (event.key === "-")
|
|
3566
|
+
return "out";
|
|
3567
|
+
if (event.key === "0")
|
|
3568
|
+
return "actual";
|
|
3569
|
+
return null;
|
|
3570
|
+
}
|
|
4161
3571
|
function followedArrow(arrows, boards, from, pressed) {
|
|
4162
3572
|
const words = wordsOf(pressed);
|
|
4163
3573
|
for (const arrow of arrows) {
|
|
@@ -4174,9 +3584,8 @@ function followedArrow(arrows, boards, from, pressed) {
|
|
|
4174
3584
|
function wordsOf(text) {
|
|
4175
3585
|
return text.replace(/\s+/g, " ").trim().toLowerCase();
|
|
4176
3586
|
}
|
|
4177
|
-
var MAX_SCALE = 2.5;
|
|
4178
3587
|
function BoardPicture({ src }) {
|
|
4179
|
-
return /* @__PURE__ */
|
|
3588
|
+
return /* @__PURE__ */ jsx12("img", {
|
|
4180
3589
|
src,
|
|
4181
3590
|
alt: "",
|
|
4182
3591
|
decoding: "async",
|
|
@@ -4186,7 +3595,7 @@ function BoardPicture({ src }) {
|
|
|
4186
3595
|
}
|
|
4187
3596
|
function useSize(element) {
|
|
4188
3597
|
const [size, setSize] = useState10(null);
|
|
4189
|
-
|
|
3598
|
+
useEffect8(() => {
|
|
4190
3599
|
if (!element)
|
|
4191
3600
|
return;
|
|
4192
3601
|
const measure = () => {
|
|
@@ -4207,7 +3616,7 @@ function Step({
|
|
|
4207
3616
|
onClick,
|
|
4208
3617
|
children
|
|
4209
3618
|
}) {
|
|
4210
|
-
return /* @__PURE__ */
|
|
3619
|
+
return /* @__PURE__ */ jsx12("button", {
|
|
4211
3620
|
type: "button",
|
|
4212
3621
|
"aria-label": label,
|
|
4213
3622
|
title: label,
|
|
@@ -4218,17 +3627,204 @@ function Step({
|
|
|
4218
3627
|
});
|
|
4219
3628
|
}
|
|
4220
3629
|
|
|
3630
|
+
// src/artifacts/renderers/canvas/gestures.ts
|
|
3631
|
+
import { useReactFlow as useReactFlow2, useStoreApi as useStoreApi4 } from "@xyflow/react";
|
|
3632
|
+
import { useEffect as useEffect9, useMemo as useMemo5, useRef as useRef10 } from "react";
|
|
3633
|
+
var WHEEL_PAN_SPEED = 0.5;
|
|
3634
|
+
var WHEEL_PAUSE_MS = 150;
|
|
3635
|
+
var GLIDE_MS = 420;
|
|
3636
|
+
var STEP_MS = 220;
|
|
3637
|
+
var GLIDE_MARGIN = 32;
|
|
3638
|
+
var KEYED = "input, textarea, select, button, a[href], [contenteditable], [role=menu]";
|
|
3639
|
+
function glideView(box, view, zoom, padding) {
|
|
3640
|
+
const fit = Math.min(view.width / (box.w * (1 + padding)), view.height / (box.h * (1 + padding)));
|
|
3641
|
+
const next = Math.min(zoom, Math.max(fit, Math.min(zoom, LIVE_FROM_SCALE)));
|
|
3642
|
+
const width = box.w * next;
|
|
3643
|
+
const height = box.h * next;
|
|
3644
|
+
const left = width <= view.width ? (view.width - width) / 2 : GLIDE_MARGIN;
|
|
3645
|
+
const top = height <= view.height ? (view.height - height) / 2 : GLIDE_MARGIN;
|
|
3646
|
+
return { x: left - box.x * next, y: top - box.y * next, zoom: next };
|
|
3647
|
+
}
|
|
3648
|
+
function useBoardGestures({
|
|
3649
|
+
root,
|
|
3650
|
+
pointed,
|
|
3651
|
+
reading,
|
|
3652
|
+
opened,
|
|
3653
|
+
padding,
|
|
3654
|
+
onPress
|
|
3655
|
+
}) {
|
|
3656
|
+
const store = useStoreApi4();
|
|
3657
|
+
const { setViewport, zoomIn, zoomOut, zoomTo } = useReactFlow2();
|
|
3658
|
+
const pressRef = useRef10(onPress);
|
|
3659
|
+
pressRef.current = onPress;
|
|
3660
|
+
const gestures = useMemo5(() => {
|
|
3661
|
+
let moving = false;
|
|
3662
|
+
let pause;
|
|
3663
|
+
const listeners = new Set;
|
|
3664
|
+
const tell = (next) => {
|
|
3665
|
+
if (moving === next)
|
|
3666
|
+
return;
|
|
3667
|
+
moving = next;
|
|
3668
|
+
for (const listener of listeners)
|
|
3669
|
+
listener(next);
|
|
3670
|
+
};
|
|
3671
|
+
const wheeled = () => {
|
|
3672
|
+
tell(true);
|
|
3673
|
+
clearTimeout(pause);
|
|
3674
|
+
pause = setTimeout(() => tell(false), WHEEL_PAUSE_MS);
|
|
3675
|
+
};
|
|
3676
|
+
const view = () => {
|
|
3677
|
+
const [x, y, zoom] = store.getState().transform;
|
|
3678
|
+
return { x, y, zoom };
|
|
3679
|
+
};
|
|
3680
|
+
const zoomAround = (factor, at) => {
|
|
3681
|
+
const { minZoom, maxZoom, domNode } = store.getState();
|
|
3682
|
+
const bounds = domNode?.getBoundingClientRect();
|
|
3683
|
+
if (!bounds)
|
|
3684
|
+
return;
|
|
3685
|
+
const { x, y, zoom } = view();
|
|
3686
|
+
const next = Math.min(maxZoom, Math.max(minZoom, zoom * factor));
|
|
3687
|
+
const left = at.x - bounds.left;
|
|
3688
|
+
const top = at.y - bounds.top;
|
|
3689
|
+
setViewport({
|
|
3690
|
+
x: left - (left - x) * next / zoom,
|
|
3691
|
+
y: top - (top - y) * next / zoom,
|
|
3692
|
+
zoom: next
|
|
3693
|
+
});
|
|
3694
|
+
};
|
|
3695
|
+
const pan = ({ x: right, y: down, by }) => {
|
|
3696
|
+
const speed = by === "wheel" ? WHEEL_PAN_SPEED : 1;
|
|
3697
|
+
const { x, y, zoom } = view();
|
|
3698
|
+
setViewport({ x: x - right * speed, y: y - down * speed, zoom });
|
|
3699
|
+
if (by === "wheel")
|
|
3700
|
+
wheeled();
|
|
3701
|
+
};
|
|
3702
|
+
const step = (to) => {
|
|
3703
|
+
if (to === "in")
|
|
3704
|
+
zoomIn({ duration: STEP_MS });
|
|
3705
|
+
else if (to === "out")
|
|
3706
|
+
zoomOut({ duration: STEP_MS });
|
|
3707
|
+
else
|
|
3708
|
+
zoomTo(1, { duration: STEP_MS });
|
|
3709
|
+
};
|
|
3710
|
+
const hold = (down) => {
|
|
3711
|
+
root.current?.toggleAttribute("data-panning", down);
|
|
3712
|
+
};
|
|
3713
|
+
return {
|
|
3714
|
+
wheeled,
|
|
3715
|
+
step,
|
|
3716
|
+
hold,
|
|
3717
|
+
moving: () => moving,
|
|
3718
|
+
onMoving: (listener) => {
|
|
3719
|
+
listeners.add(listener);
|
|
3720
|
+
return () => {
|
|
3721
|
+
listeners.delete(listener);
|
|
3722
|
+
};
|
|
3723
|
+
},
|
|
3724
|
+
receive: (board, event, page) => {
|
|
3725
|
+
switch (event.event) {
|
|
3726
|
+
case "zoom": {
|
|
3727
|
+
if ("step" in event.params) {
|
|
3728
|
+
step(event.params.step);
|
|
3729
|
+
return;
|
|
3730
|
+
}
|
|
3731
|
+
const bounds = page?.getBoundingClientRect();
|
|
3732
|
+
if (!bounds)
|
|
3733
|
+
return;
|
|
3734
|
+
const { zoom } = view();
|
|
3735
|
+
const { factor, at } = event.params;
|
|
3736
|
+
zoomAround(factor, { x: bounds.left + at.x * zoom, y: bounds.top + at.y * zoom });
|
|
3737
|
+
return;
|
|
3738
|
+
}
|
|
3739
|
+
case "pan":
|
|
3740
|
+
pan(event.params);
|
|
3741
|
+
return;
|
|
3742
|
+
case "space":
|
|
3743
|
+
hold(event.params.down);
|
|
3744
|
+
return;
|
|
3745
|
+
case "press":
|
|
3746
|
+
pressRef.current(board, event.params.text);
|
|
3747
|
+
return;
|
|
3748
|
+
default:
|
|
3749
|
+
return;
|
|
3750
|
+
}
|
|
3751
|
+
},
|
|
3752
|
+
glide: (box) => {
|
|
3753
|
+
const { width, height } = store.getState();
|
|
3754
|
+
const still = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
|
|
3755
|
+
setViewport(glideView(box, { width, height }, view().zoom, padding), {
|
|
3756
|
+
duration: still ? 0 : GLIDE_MS
|
|
3757
|
+
});
|
|
3758
|
+
},
|
|
3759
|
+
stop: () => {
|
|
3760
|
+
clearTimeout(pause);
|
|
3761
|
+
tell(false);
|
|
3762
|
+
}
|
|
3763
|
+
};
|
|
3764
|
+
}, [store, setViewport, zoomIn, zoomOut, zoomTo, root, padding]);
|
|
3765
|
+
useEffect9(() => gestures.stop, [gestures]);
|
|
3766
|
+
useEffect9(() => {
|
|
3767
|
+
const here = root.current;
|
|
3768
|
+
if (!here)
|
|
3769
|
+
return;
|
|
3770
|
+
const onWheel = (event) => {
|
|
3771
|
+
if (event.target instanceof Element && event.target.closest(".react-flow"))
|
|
3772
|
+
gestures.wheeled();
|
|
3773
|
+
};
|
|
3774
|
+
here.addEventListener("wheel", onWheel, { capture: true, passive: true });
|
|
3775
|
+
return () => here.removeEventListener("wheel", onWheel, { capture: true });
|
|
3776
|
+
}, [root, gestures]);
|
|
3777
|
+
useEffect9(() => {
|
|
3778
|
+
if (opened)
|
|
3779
|
+
return;
|
|
3780
|
+
const here = () => {
|
|
3781
|
+
const canvas = root.current;
|
|
3782
|
+
return canvas !== null && (pointed.current || canvas.contains(document.activeElement));
|
|
3783
|
+
};
|
|
3784
|
+
const onKey = (event) => {
|
|
3785
|
+
if (event.metaKey || event.ctrlKey) {
|
|
3786
|
+
const to = event.type === "keydown" ? zoomKey(event) : null;
|
|
3787
|
+
if (!to || !here())
|
|
3788
|
+
return;
|
|
3789
|
+
event.preventDefault();
|
|
3790
|
+
gestures.step(to);
|
|
3791
|
+
return;
|
|
3792
|
+
}
|
|
3793
|
+
if (!reading || event.key !== " " || event.altKey)
|
|
3794
|
+
return;
|
|
3795
|
+
const down = event.type === "keydown";
|
|
3796
|
+
if (down) {
|
|
3797
|
+
if (!here() || event.target instanceof Element && event.target.closest(KEYED))
|
|
3798
|
+
return;
|
|
3799
|
+
event.preventDefault();
|
|
3800
|
+
}
|
|
3801
|
+
gestures.hold(down);
|
|
3802
|
+
};
|
|
3803
|
+
const release = () => gestures.hold(false);
|
|
3804
|
+
window.addEventListener("keydown", onKey);
|
|
3805
|
+
window.addEventListener("keyup", onKey);
|
|
3806
|
+
window.addEventListener("blur", release);
|
|
3807
|
+
return () => {
|
|
3808
|
+
window.removeEventListener("keydown", onKey);
|
|
3809
|
+
window.removeEventListener("keyup", onKey);
|
|
3810
|
+
window.removeEventListener("blur", release);
|
|
3811
|
+
release();
|
|
3812
|
+
};
|
|
3813
|
+
}, [opened, reading, root, pointed, gestures]);
|
|
3814
|
+
return gestures;
|
|
3815
|
+
}
|
|
3816
|
+
|
|
4221
3817
|
// src/artifacts/renderers/canvas/presence.tsx
|
|
4222
|
-
import { useStore as
|
|
3818
|
+
import { useStore as useStore2, ViewportPortal } from "@xyflow/react";
|
|
4223
3819
|
import { Sparkles as Sparkles2 } from "lucide-react";
|
|
4224
|
-
import { memo as
|
|
4225
|
-
import { jsx as
|
|
3820
|
+
import { memo as memo3, useCallback as useCallback7 } from "react";
|
|
3821
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
4226
3822
|
var NAME_CLEARANCE = 96;
|
|
4227
3823
|
function nameBelow(box, transform) {
|
|
4228
3824
|
const [, panY = 0, zoom = 1] = transform;
|
|
4229
3825
|
return box.y * zoom + panY < NAME_CLEARANCE;
|
|
4230
3826
|
}
|
|
4231
|
-
var PresenceLayer =
|
|
3827
|
+
var PresenceLayer = memo3(function PresenceLayer({
|
|
4232
3828
|
live
|
|
4233
3829
|
}) {
|
|
4234
3830
|
const messages = useArtifactMessages().canvas.live;
|
|
@@ -4244,33 +3840,33 @@ var PresenceLayer = memo4(function PresenceLayer({
|
|
|
4244
3840
|
}
|
|
4245
3841
|
const changing = [...new Set(agents.flatMap((agent) => agent.boards))];
|
|
4246
3842
|
const boxes = useBoxes([...selected.keys(), ...changing]);
|
|
4247
|
-
const below =
|
|
3843
|
+
const below = useStore2(useCallback7((state) => [...boxes].filter(([, box]) => nameBelow(box, state.transform)).map(([id]) => id).join(`
|
|
4248
3844
|
`), [boxes]));
|
|
4249
3845
|
if (boxes.size === 0)
|
|
4250
3846
|
return null;
|
|
4251
|
-
return /* @__PURE__ */
|
|
3847
|
+
return /* @__PURE__ */ jsxs12(ViewportPortal, {
|
|
4252
3848
|
children: [
|
|
4253
3849
|
changing.map((id) => {
|
|
4254
3850
|
const box = boxes.get(id);
|
|
4255
|
-
return box ? /* @__PURE__ */
|
|
3851
|
+
return box ? /* @__PURE__ */ jsx13("div", {
|
|
4256
3852
|
"data-agent-board": id,
|
|
4257
3853
|
className: "sixb-agent-board pointer-events-none absolute rounded-[12px]",
|
|
4258
3854
|
style: place(box, 4),
|
|
4259
|
-
children: /* @__PURE__ */
|
|
3855
|
+
children: /* @__PURE__ */ jsx13("div", {
|
|
4260
3856
|
className: "@container absolute top-3 right-3 flex origin-top-right justify-end",
|
|
4261
3857
|
style: {
|
|
4262
3858
|
width: `calc(${Math.max(box.w - 16, 0)}px / ${NAME_SCALE_VALUE})`,
|
|
4263
3859
|
transform: `scale(${NAME_SCALE_VALUE})`
|
|
4264
3860
|
},
|
|
4265
|
-
children: /* @__PURE__ */
|
|
3861
|
+
children: /* @__PURE__ */ jsxs12("span", {
|
|
4266
3862
|
title: messages.agentChanging,
|
|
4267
3863
|
className: "flex max-w-full min-w-0 items-center gap-1.5 rounded-full bg-background/95 px-2.5 py-1 text-[12px] font-medium whitespace-nowrap text-primary shadow-[0_1px_2px_rgb(0_0_0/0.08),0_6px_16px_-8px_rgb(0_0_0/0.3)] ring-1 ring-[color-mix(in_oklab,var(--primary)_25%,transparent)] @max-[8rem]:px-1.5",
|
|
4268
3864
|
children: [
|
|
4269
|
-
/* @__PURE__ */
|
|
3865
|
+
/* @__PURE__ */ jsx13(Sparkles2, {
|
|
4270
3866
|
className: "size-3.5 shrink-0 motion-safe:animate-pulse",
|
|
4271
3867
|
"aria-hidden": "true"
|
|
4272
3868
|
}),
|
|
4273
|
-
/* @__PURE__ */
|
|
3869
|
+
/* @__PURE__ */ jsx13("span", {
|
|
4274
3870
|
className: "min-w-0 truncate @max-[8rem]:sr-only",
|
|
4275
3871
|
children: messages.agentChanging
|
|
4276
3872
|
})
|
|
@@ -4281,21 +3877,21 @@ var PresenceLayer = memo4(function PresenceLayer({
|
|
|
4281
3877
|
}),
|
|
4282
3878
|
[...selected].map(([id, user]) => {
|
|
4283
3879
|
const box = boxes.get(id);
|
|
4284
|
-
return box ? /* @__PURE__ */
|
|
3880
|
+
return box ? /* @__PURE__ */ jsx13("div", {
|
|
4285
3881
|
"data-peer-selection": id,
|
|
4286
3882
|
className: "pointer-events-none absolute rounded-[6px]",
|
|
4287
3883
|
style: {
|
|
4288
3884
|
...place(box, 3),
|
|
4289
3885
|
boxShadow: `0 0 0 calc(2px * ${NAME_SCALE_VALUE}) ${user.color}`
|
|
4290
3886
|
},
|
|
4291
|
-
children: /* @__PURE__ */
|
|
3887
|
+
children: /* @__PURE__ */ jsxs12("span", {
|
|
4292
3888
|
"data-name": below.split(`
|
|
4293
3889
|
`).includes(id) ? "below" : "above",
|
|
4294
3890
|
className: "absolute left-0 rounded-[4px] px-1.5 py-px text-[11px] leading-4 font-medium whitespace-nowrap text-white data-[name=above]:bottom-full data-[name=above]:mb-1 data-[name=above]:origin-bottom-left data-[name=below]:top-1 data-[name=below]:left-1 data-[name=below]:origin-top-left",
|
|
4295
3891
|
style: { backgroundColor: user.color, transform: `scale(${NAME_SCALE_VALUE})` },
|
|
4296
3892
|
children: [
|
|
4297
3893
|
livePersonName(user, labels),
|
|
4298
|
-
user.guest && user.name ? /* @__PURE__ */
|
|
3894
|
+
user.guest && user.name ? /* @__PURE__ */ jsxs12("span", {
|
|
4299
3895
|
className: "opacity-75",
|
|
4300
3896
|
children: [
|
|
4301
3897
|
" \xB7 ",
|
|
@@ -4330,7 +3926,7 @@ function useBoxes(ids) {
|
|
|
4330
3926
|
}
|
|
4331
3927
|
return boxes;
|
|
4332
3928
|
}, [key]);
|
|
4333
|
-
return
|
|
3929
|
+
return useStore2(select, sameBoxes);
|
|
4334
3930
|
}
|
|
4335
3931
|
function boxOf(node) {
|
|
4336
3932
|
const w = node.measured.width ?? node.width;
|
|
@@ -4340,7 +3936,7 @@ function boxOf(node) {
|
|
|
4340
3936
|
const { x, y } = node.internals.positionAbsolute;
|
|
4341
3937
|
return { x, y, w, h };
|
|
4342
3938
|
}
|
|
4343
|
-
function
|
|
3939
|
+
function sameBoxes(left, right) {
|
|
4344
3940
|
if (left.size !== right.size)
|
|
4345
3941
|
return false;
|
|
4346
3942
|
for (const [id, box] of left) {
|
|
@@ -4353,8 +3949,8 @@ function sameBoxes2(left, right) {
|
|
|
4353
3949
|
}
|
|
4354
3950
|
|
|
4355
3951
|
// src/artifacts/renderers/canvas/canvas.tsx
|
|
4356
|
-
import { jsx as
|
|
4357
|
-
var canvas_default =
|
|
3952
|
+
import { jsx as jsx14, jsxs as jsxs13, Fragment as Fragment7 } from "react/jsx-runtime";
|
|
3953
|
+
var canvas_default = memo4(function CanvasBoard({
|
|
4358
3954
|
canvas,
|
|
4359
3955
|
version,
|
|
4360
3956
|
title,
|
|
@@ -4364,8 +3960,8 @@ var canvas_default = memo5(function CanvasBoard({
|
|
|
4364
3960
|
live,
|
|
4365
3961
|
theme
|
|
4366
3962
|
}) {
|
|
4367
|
-
return /* @__PURE__ */
|
|
4368
|
-
children: /* @__PURE__ */
|
|
3963
|
+
return /* @__PURE__ */ jsx14(ReactFlowProvider, {
|
|
3964
|
+
children: /* @__PURE__ */ jsx14(Board, {
|
|
4369
3965
|
canvas,
|
|
4370
3966
|
title,
|
|
4371
3967
|
mode,
|
|
@@ -4394,7 +3990,7 @@ function Board({
|
|
|
4394
3990
|
const places = useMemo6(() => canvas.items.flatMap((item) => item.type === "board" || item.type === "embed" ? [{ ...item, pictured: previews[item.id] === "ready" }] : []), [canvas, previews]);
|
|
4395
3991
|
const running = useLiveSet(places);
|
|
4396
3992
|
const [opened, setOpened] = useState11(() => focus && boards.some((board) => board.id === focus) ? focus : null);
|
|
4397
|
-
const { fitView } =
|
|
3993
|
+
const { fitView } = useReactFlow3();
|
|
4398
3994
|
const close = useCallback8(() => {
|
|
4399
3995
|
const id = opened;
|
|
4400
3996
|
setOpened(null);
|
|
@@ -4402,15 +3998,9 @@ function Board({
|
|
|
4402
3998
|
return;
|
|
4403
3999
|
fitView({ nodes: [{ id }], padding: CANVAS_FIT_PADDING, maxZoom: 1, duration: 220 });
|
|
4404
4000
|
}, [opened, fitView]);
|
|
4405
|
-
const live = useMemo6(() => ({
|
|
4406
|
-
version: version ?? null,
|
|
4407
|
-
live: running,
|
|
4408
|
-
previews,
|
|
4409
|
-
mode,
|
|
4410
|
-
...version ? { open: setOpened } : {}
|
|
4411
|
-
}), [version, running, previews, mode]);
|
|
4412
4001
|
const pictureOf = useCallback8((id) => version && previews[id] === "ready" ? boardPreviewUrl(version, id, mode) : undefined, [version, previews, mode]);
|
|
4413
4002
|
const board = useBoardEditing(canvas, edit, version ? setOpened : undefined);
|
|
4003
|
+
const resizeBoard = useResizeBoard(board.editing ? board.items : null);
|
|
4414
4004
|
const editBoard = edit?.live?.editBoard;
|
|
4415
4005
|
const stopCapturing = edit?.live?.stopCapturing;
|
|
4416
4006
|
const boardEditor = useMemo6(() => editBoard && stopCapturing ? { editBoard, stopCapturing } : null, [editBoard, stopCapturing]);
|
|
@@ -4423,10 +4013,10 @@ function Board({
|
|
|
4423
4013
|
boards,
|
|
4424
4014
|
revision: view?.revision ?? version?.revision ?? 1
|
|
4425
4015
|
});
|
|
4426
|
-
const { getInternalNode, screenToFlowPosition } =
|
|
4016
|
+
const { getInternalNode, screenToFlowPosition } = useReactFlow3();
|
|
4427
4017
|
const { setCommenting, cancelDraft, draft } = commenting;
|
|
4428
|
-
const pointed =
|
|
4429
|
-
|
|
4018
|
+
const pointed = useRef11(false);
|
|
4019
|
+
useEffect10(() => {
|
|
4430
4020
|
if (!commenting.enabled)
|
|
4431
4021
|
return;
|
|
4432
4022
|
const onKey = (event) => {
|
|
@@ -4488,6 +4078,31 @@ function Board({
|
|
|
4488
4078
|
}
|
|
4489
4079
|
fitView({ nodes: [{ id: on }], padding: CANVAS_FIT_PADDING, maxZoom: 1, duration: 260 });
|
|
4490
4080
|
}, [commenting, boards, opened, fitView]);
|
|
4081
|
+
const reads = !board.editing && !commenting.commenting && opened === null;
|
|
4082
|
+
const follow = useRef11(() => {});
|
|
4083
|
+
const gestures = useBoardGestures({
|
|
4084
|
+
root: board.root,
|
|
4085
|
+
pointed,
|
|
4086
|
+
reading: reads,
|
|
4087
|
+
opened: opened !== null,
|
|
4088
|
+
padding: CANVAS_FIT_PADDING,
|
|
4089
|
+
onPress: (from, text) => follow.current(from, text)
|
|
4090
|
+
});
|
|
4091
|
+
follow.current = (from, text) => {
|
|
4092
|
+
const to = followedArrow(arrows, boards, from, text);
|
|
4093
|
+
const target = boards.find((each) => each.id === to);
|
|
4094
|
+
if (target)
|
|
4095
|
+
gestures.glide(target);
|
|
4096
|
+
};
|
|
4097
|
+
const live = useMemo6(() => ({
|
|
4098
|
+
version: version ?? null,
|
|
4099
|
+
live: running,
|
|
4100
|
+
previews,
|
|
4101
|
+
mode,
|
|
4102
|
+
interactive: reads && version !== undefined,
|
|
4103
|
+
gestures,
|
|
4104
|
+
...version ? { open: setOpened } : {}
|
|
4105
|
+
}), [version, running, previews, mode, reads, gestures]);
|
|
4491
4106
|
const open = live.open;
|
|
4492
4107
|
const reading = useMemo6(() => ({
|
|
4493
4108
|
nodesDraggable: false,
|
|
@@ -4507,7 +4122,7 @@ function Board({
|
|
|
4507
4122
|
maxZoom: 1,
|
|
4508
4123
|
...framed ? { nodes: [{ id: framed }] } : {}
|
|
4509
4124
|
}), [framed]);
|
|
4510
|
-
return /* @__PURE__ */
|
|
4125
|
+
return /* @__PURE__ */ jsxs13("div", {
|
|
4511
4126
|
ref: board.root,
|
|
4512
4127
|
tabIndex: board.editing ? -1 : undefined,
|
|
4513
4128
|
className: "sixb-canvas sixb-artboard @container/canvas relative flex size-full bg-background outline-none",
|
|
@@ -4536,15 +4151,15 @@ function Board({
|
|
|
4536
4151
|
live.open(id);
|
|
4537
4152
|
},
|
|
4538
4153
|
children: [
|
|
4539
|
-
/* @__PURE__ */
|
|
4154
|
+
/* @__PURE__ */ jsxs13("div", {
|
|
4540
4155
|
className: cn11("relative h-full min-w-0 flex-1 bg-background text-foreground", theme?.className),
|
|
4541
4156
|
style: theme?.style,
|
|
4542
4157
|
children: [
|
|
4543
|
-
/* @__PURE__ */
|
|
4158
|
+
/* @__PURE__ */ jsx14(LiveBoardsProvider, {
|
|
4544
4159
|
value: live,
|
|
4545
|
-
children: /* @__PURE__ */
|
|
4160
|
+
children: /* @__PURE__ */ jsx14(CanvasEditingProvider, {
|
|
4546
4161
|
value: board.editing ? board.items : null,
|
|
4547
|
-
children: /* @__PURE__ */
|
|
4162
|
+
children: /* @__PURE__ */ jsxs13(ReactFlow, {
|
|
4548
4163
|
nodes: board.nodes,
|
|
4549
4164
|
edges: board.edges,
|
|
4550
4165
|
nodeTypes: CANVAS_NODE_TYPES,
|
|
@@ -4565,21 +4180,21 @@ function Board({
|
|
|
4565
4180
|
...placing,
|
|
4566
4181
|
proOptions: { hideAttribution: true },
|
|
4567
4182
|
children: [
|
|
4568
|
-
/* @__PURE__ */
|
|
4183
|
+
/* @__PURE__ */ jsx14(Background, {
|
|
4569
4184
|
variant: BackgroundVariant.Dots,
|
|
4570
4185
|
gap: 24,
|
|
4571
4186
|
size: 1.3
|
|
4572
4187
|
}),
|
|
4573
|
-
/* @__PURE__ */
|
|
4188
|
+
/* @__PURE__ */ jsx14(CanvasControls, {
|
|
4574
4189
|
padding: CANVAS_FIT_PADDING
|
|
4575
4190
|
}),
|
|
4576
|
-
liveArtifact ? /* @__PURE__ */
|
|
4191
|
+
liveArtifact ? /* @__PURE__ */ jsx14(PresenceLayer, {
|
|
4577
4192
|
live: liveArtifact
|
|
4578
4193
|
}) : null,
|
|
4579
4194
|
board.editing ? board.toolbar : null,
|
|
4580
|
-
commenting.enabled ? /* @__PURE__ */
|
|
4195
|
+
commenting.enabled ? /* @__PURE__ */ jsxs13(Fragment7, {
|
|
4581
4196
|
children: [
|
|
4582
|
-
/* @__PURE__ */
|
|
4197
|
+
/* @__PURE__ */ jsx14(CanvasCommentPins, {
|
|
4583
4198
|
pins: commenting.pins,
|
|
4584
4199
|
active: commenting.active,
|
|
4585
4200
|
draft: draft?.where === "canvas" ? draft : null,
|
|
@@ -4590,14 +4205,14 @@ function Board({
|
|
|
4590
4205
|
onSubmitDraft: commenting.submitDraft,
|
|
4591
4206
|
onCancelDraft: cancelDraft
|
|
4592
4207
|
}),
|
|
4593
|
-
/* @__PURE__ */
|
|
4208
|
+
/* @__PURE__ */ jsx14(Panel3, {
|
|
4594
4209
|
position: "top-right",
|
|
4595
4210
|
className: "!m-3",
|
|
4596
|
-
children: /* @__PURE__ */
|
|
4211
|
+
children: /* @__PURE__ */ jsx14(CommentTools, {
|
|
4597
4212
|
commenting
|
|
4598
4213
|
})
|
|
4599
4214
|
}),
|
|
4600
|
-
commenting.commenting ? /* @__PURE__ */
|
|
4215
|
+
commenting.commenting ? /* @__PURE__ */ jsx14(ZoomVariable, {
|
|
4601
4216
|
root: board.root
|
|
4602
4217
|
}) : null
|
|
4603
4218
|
]
|
|
@@ -4606,13 +4221,13 @@ function Board({
|
|
|
4606
4221
|
})
|
|
4607
4222
|
})
|
|
4608
4223
|
}),
|
|
4609
|
-
commenting.enabled && commenting.commenting && !draft && !opened ? /* @__PURE__ */
|
|
4224
|
+
commenting.enabled && commenting.commenting && !draft && !opened ? /* @__PURE__ */ jsx14("div", {
|
|
4610
4225
|
className: "pointer-events-none absolute inset-x-0 bottom-4 z-20 flex justify-center px-4 max-sm:bottom-20",
|
|
4611
|
-
children: /* @__PURE__ */
|
|
4226
|
+
children: /* @__PURE__ */ jsx14(CommentModeHint, {
|
|
4612
4227
|
onExit: () => setCommenting(false)
|
|
4613
4228
|
})
|
|
4614
4229
|
}) : null,
|
|
4615
|
-
opened && version ? /* @__PURE__ */
|
|
4230
|
+
opened && version ? /* @__PURE__ */ jsx14(BoardFocus, {
|
|
4616
4231
|
version,
|
|
4617
4232
|
boards,
|
|
4618
4233
|
arrows,
|
|
@@ -4623,11 +4238,12 @@ function Board({
|
|
|
4623
4238
|
live: liveArtifact ?? null,
|
|
4624
4239
|
canvas: boardEditor,
|
|
4625
4240
|
mode: commenting.commenting ? "comment" : boardEditor ? "edit" : "read",
|
|
4241
|
+
...resizeBoard ? { onResizeBoard: resizeBoard } : {},
|
|
4626
4242
|
...commenting.enabled ? {
|
|
4627
4243
|
pins: commenting.pins,
|
|
4628
4244
|
activePin: commenting.active,
|
|
4629
4245
|
draft: draft?.where === "focus" ? draft : null,
|
|
4630
|
-
tools: /* @__PURE__ */
|
|
4246
|
+
tools: /* @__PURE__ */ jsx14(CommentTools, {
|
|
4631
4247
|
commenting,
|
|
4632
4248
|
className: "border-0 bg-transparent p-0 shadow-none"
|
|
4633
4249
|
}),
|
|
@@ -4651,7 +4267,7 @@ function Board({
|
|
|
4651
4267
|
}) : null
|
|
4652
4268
|
]
|
|
4653
4269
|
}),
|
|
4654
|
-
commenting.enabled && commenting.panel ? /* @__PURE__ */
|
|
4270
|
+
commenting.enabled && commenting.panel ? /* @__PURE__ */ jsx14(CommentsPanel, {
|
|
4655
4271
|
threads: commenting.threads,
|
|
4656
4272
|
loading: commenting.loading,
|
|
4657
4273
|
failed: commenting.failed,
|
|
@@ -4671,10 +4287,28 @@ function Board({
|
|
|
4671
4287
|
]
|
|
4672
4288
|
});
|
|
4673
4289
|
}
|
|
4290
|
+
function useResizeBoard(items) {
|
|
4291
|
+
const start = useStartEditing();
|
|
4292
|
+
const [waiting, setWaiting] = useState11(null);
|
|
4293
|
+
useEffect10(() => {
|
|
4294
|
+
if (!waiting || !items)
|
|
4295
|
+
return;
|
|
4296
|
+
items.resize(waiting.id, waiting.box);
|
|
4297
|
+
setWaiting(null);
|
|
4298
|
+
}, [waiting, items]);
|
|
4299
|
+
if (items)
|
|
4300
|
+
return items.resize;
|
|
4301
|
+
if (!start)
|
|
4302
|
+
return null;
|
|
4303
|
+
return (id, box) => {
|
|
4304
|
+
setWaiting({ id, box });
|
|
4305
|
+
start();
|
|
4306
|
+
};
|
|
4307
|
+
}
|
|
4674
4308
|
var COMMENTS = "[data-comments-panel], [data-comment-pin], [data-board-tools]";
|
|
4675
4309
|
function useNameScaleVariable(root) {
|
|
4676
|
-
const store =
|
|
4677
|
-
|
|
4310
|
+
const store = useStoreApi5();
|
|
4311
|
+
useEffect10(() => {
|
|
4678
4312
|
let last = "";
|
|
4679
4313
|
const update = () => {
|
|
4680
4314
|
const element = root.current;
|
|
@@ -4691,8 +4325,8 @@ function useNameScaleVariable(root) {
|
|
|
4691
4325
|
}, [store, root]);
|
|
4692
4326
|
}
|
|
4693
4327
|
function ZoomVariable({ root }) {
|
|
4694
|
-
const zoom =
|
|
4695
|
-
|
|
4328
|
+
const zoom = useStore3((state) => state.transform[2]);
|
|
4329
|
+
useEffect10(() => {
|
|
4696
4330
|
root.current?.style.setProperty("--sixb-zoom", String(zoom));
|
|
4697
4331
|
}, [root, zoom]);
|
|
4698
4332
|
return null;
|
|
@@ -4701,4 +4335,4 @@ export {
|
|
|
4701
4335
|
canvas_default as default
|
|
4702
4336
|
};
|
|
4703
4337
|
|
|
4704
|
-
//# debugId=
|
|
4338
|
+
//# debugId=FA0FFE725414578464756E2164756E21
|