@sixb/app 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/components/agent-threads.d.ts.map +1 -1
- package/dist/agent/components/composer-place.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/computer-place.d.ts +24 -6
- package/dist/agent/components/computer-place.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 +5 -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 +13 -3
- 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 +13 -0
- package/dist/agent/components/transcript.d.ts.map +1 -1
- package/dist/agent/conversation.d.ts +7 -6
- package/dist/agent/conversation.d.ts.map +1 -1
- package/dist/agent/delegation/interpret.d.ts +5 -0
- package/dist/agent/delegation/interpret.d.ts.map +1 -1
- package/dist/agent/delegation/use-children.d.ts.map +1 -1
- package/dist/agent/format.d.ts +7 -0
- package/dist/agent/format.d.ts.map +1 -1
- package/dist/agent/hooks/thread-queries.d.ts +1548 -0
- package/dist/agent/hooks/thread-queries.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +51 -6
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts +80 -3
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-place.d.ts +49 -0
- package/dist/agent/hooks/use-thread-place.d.ts.map +1 -0
- package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +107 -6
- 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 +180 -12
- 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/model-selection.d.ts +3 -2
- package/dist/agent/model-selection.d.ts.map +1 -1
- package/dist/agent/moves.d.ts +40 -0
- package/dist/agent/moves.d.ts.map +1 -0
- 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-reader-state.d.ts +30 -0
- package/dist/agent/thread-reader-state.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 +9 -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/artifacts/card-preview.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 +226 -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.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/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-pxd07kvx.js → chunk-096d52h2.js} +1 -1
- package/dist/{chunk-yrcm1pbg.js → chunk-94d7enwc.js} +491 -2128
- package/dist/chunk-94d7enwc.js.map +27 -0
- package/dist/{chunk-970s5nkn.js → chunk-ezntd3yy.js} +1 -1
- package/dist/{chunk-kymx9y5e.js → chunk-qjw5r2vk.js} +12729 -5044
- package/dist/chunk-qjw5r2vk.js.map +242 -0
- package/dist/chunk-y51c4tsz.js +11 -0
- package/dist/chunk-y51c4tsz.js.map +10 -0
- package/dist/createCustomApp.d.ts +8 -1
- package/dist/createCustomApp.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- 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/accounts.d.ts +94 -0
- package/dist/pages/console/data/accounts.d.ts.map +1 -0
- package/dist/pages/console/data/connectors.d.ts.map +1 -1
- package/dist/pages/console/data/live-updates.d.ts.map +1 -1
- package/dist/pages/console/data/messages.d.ts +52 -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/console/data/sync-button.d.ts.map +1 -1
- package/dist/pages/console/data/syncs.d.ts.map +1 -1
- package/dist/pages/settings/usage/breakdown.d.ts.map +1 -1
- package/dist/pages/settings/usage/page.d.ts +4 -1
- package/dist/pages/settings/usage/page.d.ts.map +1 -1
- package/dist/pages/settings/usage/spend-model.d.ts +43 -19
- package/dist/pages/settings/usage/spend-model.d.ts.map +1 -1
- package/dist/pages.js +23044 -22570
- package/dist/pages.js.map +17 -16
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +40 -3
- package/dist/server.js.map +3 -3
- package/dist/shell/search-command.d.ts.map +1 -1
- package/package.json +22 -5
- package/src/agent/activity-label.ts +3 -0
- package/src/agent/agent-chat.tsx +58 -39
- 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/components/agent-threads.tsx +42 -2
- package/src/agent/components/composer-place.tsx +2 -7
- package/src/agent/components/composer-settings.tsx +20 -10
- package/src/agent/components/composer.tsx +342 -104
- package/src/agent/components/computer-place.tsx +415 -70
- package/src/agent/components/context-meter.tsx +7 -3
- package/src/agent/components/conversation-panel.tsx +99 -54
- package/src/agent/components/message-parts.tsx +367 -59
- package/src/agent/components/message-view.tsx +428 -9
- package/src/agent/components/pending-messages.tsx +342 -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 +198 -38
- package/src/agent/conversation.ts +219 -55
- package/src/agent/delegation/interpret.ts +31 -7
- package/src/agent/format.ts +52 -0
- package/src/agent/hooks/thread-queries.ts +75 -0
- package/src/agent/hooks/use-agent-conversation.ts +801 -211
- package/src/agent/hooks/use-thread-lists.ts +72 -7
- package/src/agent/hooks/use-thread-place.ts +239 -0
- package/src/agent/hooks/use-thread-stream.ts +10 -0
- package/src/agent/i18n/en.ts +150 -27
- package/src/agent/i18n/fr.ts +148 -31
- package/src/agent/inbox-handoff.ts +47 -0
- package/src/agent/live-run.ts +61 -2
- package/src/agent/model-selection.ts +3 -2
- package/src/agent/moves.ts +174 -0
- package/src/agent/react-router.tsx +2 -2
- package/src/agent/search/interpret.ts +367 -0
- package/src/agent/search/search-tool-view.tsx +235 -0
- package/src/agent/thread-reader-state.ts +75 -0
- package/src/agent/thread-state.ts +114 -0
- package/src/agent/tool-views/built-in.tsx +16 -0
- package/src/agent/tool-views/registry.tsx +28 -2
- package/src/agent/types.ts +13 -0
- package/src/agent/view-file/view-file-tool-view.tsx +33 -19
- package/src/artifacts/artifacts.css +398 -0
- package/src/artifacts/card-preview.tsx +6 -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 +11 -3
- 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 +9 -2
- package/src/artifacts/live/view.ts +14 -8
- package/src/artifacts/messages.ts +138 -2
- package/src/artifacts/pdf.ts +50 -0
- package/src/artifacts/references/references.tsx +46 -11
- package/src/artifacts/renderers/canvas/board-editor.tsx +11 -144
- 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/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 +87 -41
- package/src/createCustomApp.ts +57 -3
- package/src/index.ts +10 -0
- package/src/pages/console/data/accounts.tsx +509 -0
- package/src/pages/console/data/connectors.tsx +7 -15
- package/src/pages/console/data/live-updates.ts +2 -0
- package/src/pages/console/data/messages.ts +79 -0
- package/src/pages/console/data/projections.tsx +4 -0
- package/src/pages/console/data/shared.tsx +1 -0
- package/src/pages/console/data/sync-button.tsx +56 -16
- package/src/pages/console/data/syncs.tsx +66 -41
- package/src/pages/console/ontology/lineage/trail.tsx +3 -0
- package/src/pages/section-ui.tsx +1 -1
- package/src/pages/settings/usage/breakdown.tsx +5 -2
- package/src/pages/settings/usage/filter-menu.tsx +1 -1
- package/src/pages/settings/usage/page.tsx +32 -13
- package/src/pages/settings/usage/spend-chart.tsx +2 -2
- package/src/pages/settings/usage/spend-model.ts +118 -50
- package/src/server.ts +1 -0
- package/src/shell/search-command.tsx +2 -0
- package/dist/chunk-kymx9y5e.js.map +0 -211
- package/dist/chunk-yrcm1pbg.js.map +0 -34
- /package/dist/{chunk-pxd07kvx.js.map → chunk-096d52h2.js.map} +0 -0
- /package/dist/{chunk-970s5nkn.js.map → chunk-ezntd3yy.js.map} +0 -0
|
@@ -2,11 +2,8 @@
|
|
|
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,
|
|
@@ -24,18 +21,29 @@ import {
|
|
|
24
21
|
TONE_COLORS,
|
|
25
22
|
ArtifactFrame,
|
|
26
23
|
useSharedGuest2,
|
|
27
|
-
|
|
24
|
+
GuestBadge,
|
|
28
25
|
PersonAvatar,
|
|
29
26
|
useCurrentUser2,
|
|
27
|
+
CommentActionError,
|
|
28
|
+
useArtifactComments,
|
|
29
|
+
addComment,
|
|
30
|
+
resolveComment,
|
|
31
|
+
deleteComment,
|
|
32
|
+
canManageComment,
|
|
33
|
+
useCommentAuthors,
|
|
34
|
+
CommentComposer,
|
|
35
|
+
CanvasCommentPins,
|
|
30
36
|
commentsContext,
|
|
37
|
+
liveBoardSource,
|
|
31
38
|
canvasGraph,
|
|
39
|
+
BoardStage,
|
|
32
40
|
ArtifactLink,
|
|
33
41
|
ArtifactEmbed
|
|
34
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-qjw5r2vk.js";
|
|
35
43
|
|
|
36
44
|
// src/artifacts/renderers/canvas/canvas.tsx
|
|
37
45
|
import { CANVAS_FIT_PADDING } from "@sixb/core/artifacts";
|
|
38
|
-
import { cn as
|
|
46
|
+
import { cn as cn11 } from "@sixb/ui/lib/utils";
|
|
39
47
|
import {
|
|
40
48
|
Background,
|
|
41
49
|
BackgroundVariant,
|
|
@@ -43,16 +51,16 @@ import {
|
|
|
43
51
|
ReactFlow,
|
|
44
52
|
ReactFlowProvider,
|
|
45
53
|
useReactFlow as useReactFlow3,
|
|
46
|
-
useStore as
|
|
54
|
+
useStore as useStore3,
|
|
47
55
|
useStoreApi as useStoreApi5
|
|
48
56
|
} from "@xyflow/react";
|
|
49
57
|
import {
|
|
50
|
-
memo as
|
|
51
|
-
useCallback as
|
|
52
|
-
useEffect as
|
|
53
|
-
useMemo as
|
|
54
|
-
useRef as
|
|
55
|
-
useState as
|
|
58
|
+
memo as memo4,
|
|
59
|
+
useCallback as useCallback8,
|
|
60
|
+
useEffect as useEffect10,
|
|
61
|
+
useMemo as useMemo6,
|
|
62
|
+
useRef as useRef11,
|
|
63
|
+
useState as useState11
|
|
56
64
|
} from "react";
|
|
57
65
|
|
|
58
66
|
// src/artifacts/renderers/canvas/arrows.tsx
|
|
@@ -899,571 +907,13 @@ function FloatingArrow({ id, source, target, data, selected }) {
|
|
|
899
907
|
});
|
|
900
908
|
}
|
|
901
909
|
|
|
902
|
-
// src/artifacts/renderers/canvas/comment-pins.tsx
|
|
903
|
-
import { cn as cn5 } from "@sixb/ui/lib/utils";
|
|
904
|
-
import { useStore, ViewportPortal } from "@xyflow/react";
|
|
905
|
-
import { ArrowUp, LoaderCircle, X } from "lucide-react";
|
|
906
|
-
import {
|
|
907
|
-
memo as memo3,
|
|
908
|
-
useCallback,
|
|
909
|
-
useId,
|
|
910
|
-
useState as useState3
|
|
911
|
-
} from "react";
|
|
912
|
-
|
|
913
|
-
// src/artifacts/guest-badge.tsx
|
|
914
|
-
import { cn as cn4 } from "@sixb/ui/lib/utils";
|
|
915
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
916
|
-
function GuestBadge({ className }) {
|
|
917
|
-
const messages = useArtifactMessages().canvas.comments;
|
|
918
|
-
return /* @__PURE__ */ jsx5("span", {
|
|
919
|
-
title: messages.guestHint,
|
|
920
|
-
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),
|
|
921
|
-
children: messages.guest
|
|
922
|
-
});
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
// src/artifacts/renderers/canvas/comments.ts
|
|
926
|
-
import {
|
|
927
|
-
addArtifactComment,
|
|
928
|
-
deleteArtifactComment,
|
|
929
|
-
isSixbApiError,
|
|
930
|
-
resolveArtifactComment
|
|
931
|
-
} from "@sixb/client";
|
|
932
|
-
import { listArtifactCommentsOptions, listArtifactCommentsQueryKey } from "@sixb/client/hooks";
|
|
933
|
-
import { useQuery } from "@tanstack/react-query";
|
|
934
|
-
import { useMemo } from "react";
|
|
935
|
-
class CommentActionError extends Error {
|
|
936
|
-
failure;
|
|
937
|
-
name = "CommentActionError";
|
|
938
|
-
constructor(failure) {
|
|
939
|
-
super(`[SixbApp] The comment action failed: ${failure}.`);
|
|
940
|
-
this.failure = failure;
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
function commentThreads(comments) {
|
|
944
|
-
const replies = new Map;
|
|
945
|
-
for (const comment of comments) {
|
|
946
|
-
if (!comment.parentId)
|
|
947
|
-
continue;
|
|
948
|
-
const list = replies.get(comment.parentId) ?? [];
|
|
949
|
-
list.push(comment);
|
|
950
|
-
replies.set(comment.parentId, list);
|
|
951
|
-
}
|
|
952
|
-
return comments.filter((comment) => !comment.parentId).map((comment, index) => ({
|
|
953
|
-
comment,
|
|
954
|
-
replies: replies.get(comment.id) ?? [],
|
|
955
|
-
number: index + 1
|
|
956
|
-
}));
|
|
957
|
-
}
|
|
958
|
-
var NO_COMMENTS = [];
|
|
959
|
-
function useArtifactComments(artifactId) {
|
|
960
|
-
const query = useQuery({
|
|
961
|
-
...listArtifactCommentsOptions({ path: { artifactId: artifactId ?? "" } }),
|
|
962
|
-
enabled: artifactId !== null,
|
|
963
|
-
retry: false
|
|
964
|
-
});
|
|
965
|
-
const comments = query.data?.comments ?? NO_COMMENTS;
|
|
966
|
-
const threads = useMemo(() => commentThreads(comments), [comments]);
|
|
967
|
-
return { threads, loading: query.isLoading, failed: query.isError };
|
|
968
|
-
}
|
|
969
|
-
function commentsKey(artifactId) {
|
|
970
|
-
return listArtifactCommentsQueryKey({ path: { artifactId } });
|
|
971
|
-
}
|
|
972
|
-
function updateCached(queries, artifactId, update) {
|
|
973
|
-
queries.setQueryData(commentsKey(artifactId), (current) => current ? { ...current, comments: [...update(current.comments)] } : current);
|
|
974
|
-
}
|
|
975
|
-
async function addComment(queries, artifactId, body) {
|
|
976
|
-
try {
|
|
977
|
-
const { data } = await addArtifactComment({
|
|
978
|
-
path: { artifactId },
|
|
979
|
-
body,
|
|
980
|
-
throwOnError: true
|
|
981
|
-
});
|
|
982
|
-
updateCached(queries, artifactId, (comments) => comments.some((comment) => comment.id === data.id) ? comments : [...comments, data]);
|
|
983
|
-
return data;
|
|
984
|
-
} catch (error) {
|
|
985
|
-
throw commentError(error);
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
async function resolveComment(queries, artifactId, commentId, resolved) {
|
|
989
|
-
try {
|
|
990
|
-
const { data } = await resolveArtifactComment({
|
|
991
|
-
path: { artifactId, commentId },
|
|
992
|
-
body: { resolved },
|
|
993
|
-
throwOnError: true
|
|
994
|
-
});
|
|
995
|
-
updateCached(queries, artifactId, (comments) => comments.map((comment) => comment.id === data.id ? data : comment));
|
|
996
|
-
} catch (error) {
|
|
997
|
-
throw commentError(error);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
async function deleteComment(queries, artifactId, commentId) {
|
|
1001
|
-
try {
|
|
1002
|
-
await deleteArtifactComment({ path: { artifactId, commentId }, throwOnError: true });
|
|
1003
|
-
updateCached(queries, artifactId, (comments) => comments.filter((comment) => comment.id !== commentId && comment.parentId !== commentId));
|
|
1004
|
-
} catch (error) {
|
|
1005
|
-
throw commentError(error);
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
function commentError(error) {
|
|
1009
|
-
if (!isSixbApiError(error))
|
|
1010
|
-
return new CommentActionError("failed");
|
|
1011
|
-
switch (error.code) {
|
|
1012
|
-
case "comments_full":
|
|
1013
|
-
return new CommentActionError("full");
|
|
1014
|
-
case "invalid_comment":
|
|
1015
|
-
return new CommentActionError("invalid");
|
|
1016
|
-
case "name_required":
|
|
1017
|
-
case "invalid_name":
|
|
1018
|
-
return new CommentActionError("name");
|
|
1019
|
-
case "not_allowed":
|
|
1020
|
-
return new CommentActionError("notAllowed");
|
|
1021
|
-
case "comment_not_found":
|
|
1022
|
-
case "artifact_not_found":
|
|
1023
|
-
return new CommentActionError("gone");
|
|
1024
|
-
default:
|
|
1025
|
-
return new CommentActionError("failed");
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
function canManageComment(comment, access, userId) {
|
|
1029
|
-
if (access === "owner" || access === "update")
|
|
1030
|
-
return true;
|
|
1031
|
-
return comment.author.type === "user" && comment.author.id === userId;
|
|
1032
|
-
}
|
|
1033
|
-
function useCommentAuthors() {
|
|
1034
|
-
const user = useCurrentUser2();
|
|
1035
|
-
const guest = useSharedGuest2();
|
|
1036
|
-
const messages = useArtifactMessages().canvas.comments;
|
|
1037
|
-
return ({ author, authorName, origin }) => {
|
|
1038
|
-
if (author.type === "guest") {
|
|
1039
|
-
const name = authorName ?? messages.guest;
|
|
1040
|
-
return { name, you: author.id === guest?.id, guest: true };
|
|
1041
|
-
}
|
|
1042
|
-
const own = author.type === "user" && author.id === user?.id;
|
|
1043
|
-
if (origin) {
|
|
1044
|
-
const name = own ? messages.you.toLowerCase() : authorName ?? messages.someone;
|
|
1045
|
-
return { name: messages.agentFor(name), you: false, agent: true };
|
|
1046
|
-
}
|
|
1047
|
-
if (own)
|
|
1048
|
-
return { name: user.displayName ?? user.email ?? authorName ?? "", you: true };
|
|
1049
|
-
return authorName ? { name: authorName, you: false } : null;
|
|
1050
|
-
};
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
// src/artifacts/renderers/canvas/comment-pins.tsx
|
|
1054
|
-
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1055
|
-
function pinPoint(pin, index) {
|
|
1056
|
-
return pin.point ?? { x: 1, y: 0.02 + index * 0.06 };
|
|
1057
|
-
}
|
|
1058
|
-
var CARD_WIDTH = 288;
|
|
1059
|
-
function cardPlace(x, width) {
|
|
1060
|
-
const card = Math.min(CARD_WIDTH, width - 16);
|
|
1061
|
-
const beside = 36;
|
|
1062
|
-
const left = Math.max(8 - x, Math.min(beside, width - 8 - card - x));
|
|
1063
|
-
return { left, width: card };
|
|
1064
|
-
}
|
|
1065
|
-
function CommentPin({
|
|
1066
|
-
number,
|
|
1067
|
-
label,
|
|
1068
|
-
active,
|
|
1069
|
-
resolved,
|
|
1070
|
-
draft = false,
|
|
1071
|
-
onClick,
|
|
1072
|
-
style
|
|
1073
|
-
}) {
|
|
1074
|
-
return /* @__PURE__ */ jsx6("button", {
|
|
1075
|
-
type: "button",
|
|
1076
|
-
"aria-label": label,
|
|
1077
|
-
title: label,
|
|
1078
|
-
"aria-pressed": onClick ? active : undefined,
|
|
1079
|
-
"data-comment-pin": number ?? "draft",
|
|
1080
|
-
onClick: (event) => {
|
|
1081
|
-
event.stopPropagation();
|
|
1082
|
-
onClick?.();
|
|
1083
|
-
},
|
|
1084
|
-
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"),
|
|
1085
|
-
style,
|
|
1086
|
-
children: draft ? /* @__PURE__ */ jsx6("span", {
|
|
1087
|
-
className: "size-1.5 rounded-full bg-current",
|
|
1088
|
-
"aria-hidden": "true"
|
|
1089
|
-
}) : number
|
|
1090
|
-
});
|
|
1091
|
-
}
|
|
1092
|
-
function CommentComposer({
|
|
1093
|
-
placeholder,
|
|
1094
|
-
onSubmit,
|
|
1095
|
-
onCancel,
|
|
1096
|
-
autoFocus = true,
|
|
1097
|
-
compact = false,
|
|
1098
|
-
className
|
|
1099
|
-
}) {
|
|
1100
|
-
const messages = useArtifactMessages().canvas.comments;
|
|
1101
|
-
const guest = useSharedGuest2();
|
|
1102
|
-
const giveName = useGiveGuestName();
|
|
1103
|
-
const [body, setBody] = useState3("");
|
|
1104
|
-
const [name, setName] = useState3("");
|
|
1105
|
-
const [sending, setSending] = useState3(false);
|
|
1106
|
-
const [failure, setFailure] = useState3(null);
|
|
1107
|
-
const naming = guest !== null && guest.name === undefined;
|
|
1108
|
-
const ready = body.trim().length > 0 && (!naming || name.trim().length > 0) && !sending;
|
|
1109
|
-
const submit = async () => {
|
|
1110
|
-
if (!ready)
|
|
1111
|
-
return;
|
|
1112
|
-
setSending(true);
|
|
1113
|
-
setFailure(null);
|
|
1114
|
-
try {
|
|
1115
|
-
if (naming) {
|
|
1116
|
-
await giveName(name).catch(() => {
|
|
1117
|
-
throw new CommentActionError("name");
|
|
1118
|
-
});
|
|
1119
|
-
}
|
|
1120
|
-
await onSubmit(body.trim());
|
|
1121
|
-
setBody("");
|
|
1122
|
-
} catch (error) {
|
|
1123
|
-
setFailure(error instanceof CommentActionError ? error.failure : "failed");
|
|
1124
|
-
} finally {
|
|
1125
|
-
setSending(false);
|
|
1126
|
-
}
|
|
1127
|
-
};
|
|
1128
|
-
const onKeyDown = (event) => {
|
|
1129
|
-
event.stopPropagation();
|
|
1130
|
-
const composing = event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229;
|
|
1131
|
-
if (event.key === "Enter" && !event.shiftKey && !composing) {
|
|
1132
|
-
event.preventDefault();
|
|
1133
|
-
submit();
|
|
1134
|
-
}
|
|
1135
|
-
if (event.key === "Escape") {
|
|
1136
|
-
event.preventDefault();
|
|
1137
|
-
onCancel?.();
|
|
1138
|
-
}
|
|
1139
|
-
};
|
|
1140
|
-
return /* @__PURE__ */ jsxs5("div", {
|
|
1141
|
-
className: cn5("flex flex-col gap-1.5", className),
|
|
1142
|
-
"data-board-tools": "",
|
|
1143
|
-
children: [
|
|
1144
|
-
naming ? /* @__PURE__ */ jsx6(GuestNameField, {
|
|
1145
|
-
value: name,
|
|
1146
|
-
onChange: setName,
|
|
1147
|
-
autoFocus,
|
|
1148
|
-
invalid: failure === "name",
|
|
1149
|
-
onKeyDown
|
|
1150
|
-
}) : null,
|
|
1151
|
-
/* @__PURE__ */ jsxs5("div", {
|
|
1152
|
-
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",
|
|
1153
|
-
children: [
|
|
1154
|
-
/* @__PURE__ */ jsx6("textarea", {
|
|
1155
|
-
autoFocus: autoFocus && !naming,
|
|
1156
|
-
value: body,
|
|
1157
|
-
rows: 1,
|
|
1158
|
-
maxLength: 4000,
|
|
1159
|
-
"aria-label": placeholder,
|
|
1160
|
-
placeholder,
|
|
1161
|
-
onChange: (event) => setBody(event.target.value),
|
|
1162
|
-
onKeyDown,
|
|
1163
|
-
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"
|
|
1164
|
-
}),
|
|
1165
|
-
/* @__PURE__ */ jsx6("button", {
|
|
1166
|
-
type: "button",
|
|
1167
|
-
"aria-label": compact ? messages.reply : messages.post,
|
|
1168
|
-
title: compact ? messages.reply : messages.post,
|
|
1169
|
-
disabled: !ready,
|
|
1170
|
-
onClick: () => void submit(),
|
|
1171
|
-
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",
|
|
1172
|
-
children: sending ? /* @__PURE__ */ jsx6(LoaderCircle, {
|
|
1173
|
-
className: "animate-spin motion-reduce:animate-none",
|
|
1174
|
-
"aria-hidden": "true"
|
|
1175
|
-
}) : /* @__PURE__ */ jsx6(ArrowUp, {
|
|
1176
|
-
"aria-hidden": "true"
|
|
1177
|
-
})
|
|
1178
|
-
})
|
|
1179
|
-
]
|
|
1180
|
-
}),
|
|
1181
|
-
failure ? /* @__PURE__ */ jsx6("p", {
|
|
1182
|
-
role: "alert",
|
|
1183
|
-
className: "m-0 px-1 text-xs text-destructive",
|
|
1184
|
-
children: messages.failures[failure]
|
|
1185
|
-
}) : null
|
|
1186
|
-
]
|
|
1187
|
-
});
|
|
1188
|
-
}
|
|
1189
|
-
function GuestNameField({
|
|
1190
|
-
value,
|
|
1191
|
-
onChange,
|
|
1192
|
-
autoFocus,
|
|
1193
|
-
invalid,
|
|
1194
|
-
onKeyDown
|
|
1195
|
-
}) {
|
|
1196
|
-
const messages = useArtifactMessages().canvas.comments;
|
|
1197
|
-
const id = useId();
|
|
1198
|
-
return /* @__PURE__ */ jsxs5("div", {
|
|
1199
|
-
className: "flex flex-col gap-1 px-1 pt-0.5",
|
|
1200
|
-
children: [
|
|
1201
|
-
/* @__PURE__ */ jsxs5("div", {
|
|
1202
|
-
className: "flex items-center gap-2",
|
|
1203
|
-
children: [
|
|
1204
|
-
/* @__PURE__ */ jsx6(PersonAvatar, {
|
|
1205
|
-
name: value.trim() || messages.guest,
|
|
1206
|
-
size: "xs"
|
|
1207
|
-
}),
|
|
1208
|
-
/* @__PURE__ */ jsx6("input", {
|
|
1209
|
-
id,
|
|
1210
|
-
autoFocus,
|
|
1211
|
-
value,
|
|
1212
|
-
maxLength: GUEST_NAME_INPUT_LENGTH,
|
|
1213
|
-
autoComplete: "name",
|
|
1214
|
-
"aria-label": messages.guestName,
|
|
1215
|
-
"aria-invalid": invalid,
|
|
1216
|
-
"aria-describedby": `${id}-hint`,
|
|
1217
|
-
placeholder: messages.guestName,
|
|
1218
|
-
onChange: (event) => onChange(event.target.value),
|
|
1219
|
-
onKeyDown,
|
|
1220
|
-
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"
|
|
1221
|
-
}),
|
|
1222
|
-
/* @__PURE__ */ jsx6(GuestBadge, {})
|
|
1223
|
-
]
|
|
1224
|
-
}),
|
|
1225
|
-
/* @__PURE__ */ jsx6("p", {
|
|
1226
|
-
id: `${id}-hint`,
|
|
1227
|
-
className: "m-0 pl-7 text-[11px] leading-4 text-muted-foreground",
|
|
1228
|
-
children: messages.guestNameHint
|
|
1229
|
-
})
|
|
1230
|
-
]
|
|
1231
|
-
});
|
|
1232
|
-
}
|
|
1233
|
-
var GUEST_NAME_INPUT_LENGTH = 80;
|
|
1234
|
-
function DraftCard({
|
|
1235
|
-
anchor,
|
|
1236
|
-
onSubmit,
|
|
1237
|
-
onCancel
|
|
1238
|
-
}) {
|
|
1239
|
-
const messages = useArtifactMessages().canvas.comments;
|
|
1240
|
-
return /* @__PURE__ */ jsxs5("div", {
|
|
1241
|
-
role: "dialog",
|
|
1242
|
-
"aria-label": messages.newPin,
|
|
1243
|
-
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",
|
|
1244
|
-
onPointerDown: (event) => event.stopPropagation(),
|
|
1245
|
-
children: [
|
|
1246
|
-
/* @__PURE__ */ jsxs5("div", {
|
|
1247
|
-
className: "flex h-7 items-center gap-1 pr-0.5 pl-2",
|
|
1248
|
-
children: [
|
|
1249
|
-
/* @__PURE__ */ jsx6("p", {
|
|
1250
|
-
className: "m-0 min-w-0 flex-1 truncate text-xs text-muted-foreground",
|
|
1251
|
-
children: anchor ? messages.about(anchor) : messages.newPin
|
|
1252
|
-
}),
|
|
1253
|
-
/* @__PURE__ */ jsx6("button", {
|
|
1254
|
-
type: "button",
|
|
1255
|
-
"aria-label": messages.cancel,
|
|
1256
|
-
title: messages.cancel,
|
|
1257
|
-
onClick: onCancel,
|
|
1258
|
-
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",
|
|
1259
|
-
children: /* @__PURE__ */ jsx6(X, {
|
|
1260
|
-
"aria-hidden": "true"
|
|
1261
|
-
})
|
|
1262
|
-
})
|
|
1263
|
-
]
|
|
1264
|
-
}),
|
|
1265
|
-
/* @__PURE__ */ jsx6(CommentComposer, {
|
|
1266
|
-
placeholder: messages.placeholder,
|
|
1267
|
-
onSubmit,
|
|
1268
|
-
onCancel
|
|
1269
|
-
})
|
|
1270
|
-
]
|
|
1271
|
-
});
|
|
1272
|
-
}
|
|
1273
|
-
var CanvasCommentPins = memo3(function CanvasCommentPins({
|
|
1274
|
-
pins,
|
|
1275
|
-
active,
|
|
1276
|
-
draft,
|
|
1277
|
-
onOpen,
|
|
1278
|
-
onSubmitDraft,
|
|
1279
|
-
onCancelDraft
|
|
1280
|
-
}) {
|
|
1281
|
-
const messages = useArtifactMessages().canvas.comments;
|
|
1282
|
-
const zoom = useStore((state) => state.transform[2]);
|
|
1283
|
-
const view = useStore(viewOf, sameView);
|
|
1284
|
-
const boards = [...new Set([...pins.map((pin) => pin.board), ...draft ? [draft.board] : []])];
|
|
1285
|
-
const boxes = useBoardBoxes(boards);
|
|
1286
|
-
const unplaced = new Map;
|
|
1287
|
-
const scale = `scale(${1 / zoom})`;
|
|
1288
|
-
const draftBox = draft ? boxes.get(draft.board) : undefined;
|
|
1289
|
-
if (boxes.size === 0)
|
|
1290
|
-
return null;
|
|
1291
|
-
return /* @__PURE__ */ jsxs5(ViewportPortal, {
|
|
1292
|
-
children: [
|
|
1293
|
-
pins.map((pin) => {
|
|
1294
|
-
const box = boxes.get(pin.board);
|
|
1295
|
-
if (!box)
|
|
1296
|
-
return null;
|
|
1297
|
-
const index = pin.point ? 0 : unplaced.get(pin.board) ?? 0;
|
|
1298
|
-
if (!pin.point)
|
|
1299
|
-
unplaced.set(pin.board, index + 1);
|
|
1300
|
-
const at = pinPoint(pin, index);
|
|
1301
|
-
return /* @__PURE__ */ jsx6("div", {
|
|
1302
|
-
className: "pointer-events-none absolute top-0 left-0",
|
|
1303
|
-
style: {
|
|
1304
|
-
transform: `translate(${box.x + at.x * box.w}px, ${box.y + at.y * box.h}px) ${scale}`,
|
|
1305
|
-
transformOrigin: "0 0"
|
|
1306
|
-
},
|
|
1307
|
-
children: /* @__PURE__ */ jsx6(CommentPin, {
|
|
1308
|
-
number: pin.number,
|
|
1309
|
-
label: pin.label,
|
|
1310
|
-
active: active === pin.id,
|
|
1311
|
-
resolved: pin.resolved,
|
|
1312
|
-
onClick: () => onOpen(pin.id)
|
|
1313
|
-
})
|
|
1314
|
-
}, pin.id);
|
|
1315
|
-
}),
|
|
1316
|
-
draft && draftBox ? /* @__PURE__ */ jsxs5(DraftAt, {
|
|
1317
|
-
box: draftBox,
|
|
1318
|
-
draft,
|
|
1319
|
-
scale,
|
|
1320
|
-
children: [
|
|
1321
|
-
/* @__PURE__ */ jsx6(CommentPin, {
|
|
1322
|
-
label: messages.newPin,
|
|
1323
|
-
active: true,
|
|
1324
|
-
resolved: false,
|
|
1325
|
-
draft: true
|
|
1326
|
-
}),
|
|
1327
|
-
/* @__PURE__ */ jsx6("div", {
|
|
1328
|
-
className: "absolute top-0",
|
|
1329
|
-
style: cardPlace(view.x + (draftBox.x + draft.point.x * draftBox.w) * zoom, view.width),
|
|
1330
|
-
children: /* @__PURE__ */ jsx6(DraftCard, {
|
|
1331
|
-
...draft.anchor ? { anchor: draft.anchor } : {},
|
|
1332
|
-
onSubmit: onSubmitDraft,
|
|
1333
|
-
onCancel: onCancelDraft
|
|
1334
|
-
})
|
|
1335
|
-
})
|
|
1336
|
-
]
|
|
1337
|
-
}) : null
|
|
1338
|
-
]
|
|
1339
|
-
});
|
|
1340
|
-
});
|
|
1341
|
-
function DraftAt({
|
|
1342
|
-
box,
|
|
1343
|
-
draft,
|
|
1344
|
-
scale,
|
|
1345
|
-
children
|
|
1346
|
-
}) {
|
|
1347
|
-
return /* @__PURE__ */ jsx6("div", {
|
|
1348
|
-
className: "pointer-events-none absolute top-0 left-0",
|
|
1349
|
-
style: {
|
|
1350
|
-
transform: `translate(${box.x + draft.point.x * box.w}px, ${box.y + draft.point.y * box.h}px) ${scale}`,
|
|
1351
|
-
transformOrigin: "0 0"
|
|
1352
|
-
},
|
|
1353
|
-
children
|
|
1354
|
-
});
|
|
1355
|
-
}
|
|
1356
|
-
function viewOf(state) {
|
|
1357
|
-
return { x: state.transform[0] ?? 0, width: state.width };
|
|
1358
|
-
}
|
|
1359
|
-
function sameView(left, right) {
|
|
1360
|
-
return left.x === right.x && left.width === right.width;
|
|
1361
|
-
}
|
|
1362
|
-
function useBoardBoxes(ids) {
|
|
1363
|
-
const key = ids.join(`
|
|
1364
|
-
`);
|
|
1365
|
-
const select = useCallback((state) => {
|
|
1366
|
-
const boxes = new Map;
|
|
1367
|
-
for (const id of key ? key.split(`
|
|
1368
|
-
`) : []) {
|
|
1369
|
-
const node = state.nodeLookup.get(id);
|
|
1370
|
-
const w = node?.measured.width ?? node?.width;
|
|
1371
|
-
const h = node?.measured.height ?? node?.height;
|
|
1372
|
-
if (!node || w === undefined || h === undefined)
|
|
1373
|
-
continue;
|
|
1374
|
-
const { x, y } = node.internals.positionAbsolute;
|
|
1375
|
-
boxes.set(id, { x, y, w, h });
|
|
1376
|
-
}
|
|
1377
|
-
return boxes;
|
|
1378
|
-
}, [key]);
|
|
1379
|
-
return useStore(select, sameBoxes);
|
|
1380
|
-
}
|
|
1381
|
-
function sameBoxes(left, right) {
|
|
1382
|
-
if (left.size !== right.size)
|
|
1383
|
-
return false;
|
|
1384
|
-
for (const [id, box] of left) {
|
|
1385
|
-
const other = right.get(id);
|
|
1386
|
-
if (!other || other.x !== box.x || other.y !== box.y || other.w !== box.w || other.h !== box.h) {
|
|
1387
|
-
return false;
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
return true;
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
910
|
// src/artifacts/renderers/canvas/commenting.tsx
|
|
1394
911
|
import { boardElements } from "@sixb/core/artifacts/live";
|
|
1395
|
-
import { cn as
|
|
912
|
+
import { cn as cn4 } from "@sixb/ui/lib/utils";
|
|
1396
913
|
import { useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
1397
914
|
import { MessageSquare, MessageSquarePlus } from "lucide-react";
|
|
1398
|
-
import { useCallback
|
|
1399
|
-
|
|
1400
|
-
// src/artifacts/live/boards.ts
|
|
1401
|
-
import { LIVE_FILES } from "@sixb/core/artifacts/live";
|
|
1402
|
-
import { useCallback as useCallback2, useMemo as useMemo2, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
1403
|
-
import * as Y from "yjs";
|
|
1404
|
-
function liveBoardSource(doc, path) {
|
|
1405
|
-
const entry = doc.getMap(LIVE_FILES).get(path);
|
|
1406
|
-
return entry instanceof Y.Text ? entry.toString() : null;
|
|
1407
|
-
}
|
|
1408
|
-
function liveStoredFiles(doc) {
|
|
1409
|
-
const files = new Map;
|
|
1410
|
-
doc.getMap(LIVE_FILES).forEach((entry, path) => {
|
|
1411
|
-
if (entry instanceof Y.Text || entry instanceof Y.Map)
|
|
1412
|
-
return;
|
|
1413
|
-
if (isFileRef(entry))
|
|
1414
|
-
files.set(path, entry);
|
|
1415
|
-
});
|
|
1416
|
-
return files;
|
|
1417
|
-
}
|
|
1418
|
-
function isFileRef(value) {
|
|
1419
|
-
return typeof value === "object" && value !== null && typeof value.blobId === "string";
|
|
1420
|
-
}
|
|
1421
|
-
function useLiveBoardSource(live, path) {
|
|
1422
|
-
const subscribe = useCallback2((listener) => {
|
|
1423
|
-
if (!live)
|
|
1424
|
-
return () => {};
|
|
1425
|
-
const files = live.doc.getMap(LIVE_FILES);
|
|
1426
|
-
let text = null;
|
|
1427
|
-
const follow = () => {
|
|
1428
|
-
text?.unobserve(listener);
|
|
1429
|
-
const entry = files.get(path);
|
|
1430
|
-
text = entry instanceof Y.Text ? entry : null;
|
|
1431
|
-
text?.observe(listener);
|
|
1432
|
-
};
|
|
1433
|
-
const onFiles = (event) => {
|
|
1434
|
-
if (!event.keysChanged.has(path))
|
|
1435
|
-
return;
|
|
1436
|
-
follow();
|
|
1437
|
-
listener();
|
|
1438
|
-
};
|
|
1439
|
-
follow();
|
|
1440
|
-
files.observe(onFiles);
|
|
1441
|
-
return () => {
|
|
1442
|
-
files.unobserve(onFiles);
|
|
1443
|
-
text?.unobserve(listener);
|
|
1444
|
-
};
|
|
1445
|
-
}, [live, path]);
|
|
1446
|
-
return useSyncExternalStore3(subscribe, () => live ? liveBoardSource(live.doc, path) : null, () => null);
|
|
1447
|
-
}
|
|
1448
|
-
function useLiveStoredFiles(live) {
|
|
1449
|
-
const subscribe = useCallback2((listener) => {
|
|
1450
|
-
if (!live)
|
|
1451
|
-
return () => {};
|
|
1452
|
-
const files = live.doc.getMap(LIVE_FILES);
|
|
1453
|
-
files.observe(listener);
|
|
1454
|
-
return () => files.unobserve(listener);
|
|
1455
|
-
}, [live]);
|
|
1456
|
-
const snapshot = useCallback2(() => live ? storedFilesKey(live.doc) : "", [live]);
|
|
1457
|
-
const key = useSyncExternalStore3(subscribe, snapshot, () => "");
|
|
1458
|
-
return useMemo2(() => live ? liveStoredFiles(live.doc) : new Map, [live, key]);
|
|
1459
|
-
}
|
|
1460
|
-
function storedFilesKey(doc) {
|
|
1461
|
-
return [...liveStoredFiles(doc)].map(([path, ref]) => `${path}:${ref.digest}`).join(`
|
|
1462
|
-
`);
|
|
1463
|
-
}
|
|
1464
|
-
|
|
1465
|
-
// src/artifacts/renderers/canvas/commenting.tsx
|
|
1466
|
-
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";
|
|
1467
917
|
function useCanvasCommenting({
|
|
1468
918
|
artifactId,
|
|
1469
919
|
live,
|
|
@@ -1478,14 +928,14 @@ function useCanvasCommenting({
|
|
|
1478
928
|
const agentDraft = useAgentDraft();
|
|
1479
929
|
const { threads, loading, failed } = useArtifactComments(artifactId);
|
|
1480
930
|
const nameOf = useCommentAuthors();
|
|
1481
|
-
const [commenting, setCommenting] =
|
|
1482
|
-
const [panel, setPanel] =
|
|
1483
|
-
const [filter, setFilter] =
|
|
1484
|
-
const [active, setActive] =
|
|
1485
|
-
const [draft, setDraft] =
|
|
1486
|
-
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]);
|
|
1487
937
|
const addresses = useRef3(new Map);
|
|
1488
|
-
const placeOf =
|
|
938
|
+
const placeOf = useCallback((thread) => {
|
|
1489
939
|
const { anchor } = thread.comment;
|
|
1490
940
|
const board = anchor.board ? boards.find((each) => each.id === anchor.board) : undefined;
|
|
1491
941
|
const name = anchor.board ? titles.get(anchor.board) ?? anchor.board : null;
|
|
@@ -1510,7 +960,7 @@ function useCanvasCommenting({
|
|
|
1510
960
|
gone
|
|
1511
961
|
};
|
|
1512
962
|
}, [boards, titles, live]);
|
|
1513
|
-
const pins =
|
|
963
|
+
const pins = useMemo(() => threads.flatMap((thread) => {
|
|
1514
964
|
const { comment } = thread;
|
|
1515
965
|
const resolved = Boolean(comment.resolvedAt);
|
|
1516
966
|
if (!comment.anchor.board)
|
|
@@ -1528,13 +978,13 @@ function useCanvasCommenting({
|
|
|
1528
978
|
}
|
|
1529
979
|
];
|
|
1530
980
|
}), [threads, filter, messages, nameOf]);
|
|
1531
|
-
const pick =
|
|
981
|
+
const pick = useCallback((board, place, where) => setDraft({
|
|
1532
982
|
board,
|
|
1533
983
|
...place,
|
|
1534
984
|
anchor: place.anchor ?? (place.label ? `\u201C${place.label}\u201D` : titles.get(board) ?? board),
|
|
1535
985
|
where
|
|
1536
986
|
}), [titles]);
|
|
1537
|
-
const submitDraft =
|
|
987
|
+
const submitDraft = useCallback(async (body) => {
|
|
1538
988
|
if (!draft || !artifactId)
|
|
1539
989
|
return;
|
|
1540
990
|
const created = await addComment(queries, artifactId, {
|
|
@@ -1552,25 +1002,25 @@ function useCanvasCommenting({
|
|
|
1552
1002
|
setFilter("open");
|
|
1553
1003
|
setPanel(true);
|
|
1554
1004
|
}, [draft, artifactId, queries, revision]);
|
|
1555
|
-
const reply =
|
|
1005
|
+
const reply = useCallback(async (thread, body) => {
|
|
1556
1006
|
if (!artifactId)
|
|
1557
1007
|
return;
|
|
1558
1008
|
await addComment(queries, artifactId, { body, parentId: thread.comment.id });
|
|
1559
1009
|
}, [artifactId, queries]);
|
|
1560
|
-
const resolve =
|
|
1010
|
+
const resolve = useCallback(async (thread, resolved) => {
|
|
1561
1011
|
if (!artifactId)
|
|
1562
1012
|
return;
|
|
1563
1013
|
await resolveComment(queries, artifactId, thread.comment.id, resolved);
|
|
1564
1014
|
if (resolved)
|
|
1565
1015
|
setActive((current) => current === thread.comment.id ? null : current);
|
|
1566
1016
|
}, [artifactId, queries]);
|
|
1567
|
-
const remove =
|
|
1017
|
+
const remove = useCallback(async (thread) => {
|
|
1568
1018
|
if (!artifactId)
|
|
1569
1019
|
return;
|
|
1570
1020
|
await deleteComment(queries, artifactId, thread.comment.id);
|
|
1571
1021
|
setActive((current) => current === thread.comment.id ? null : current);
|
|
1572
1022
|
}, [artifactId, queries]);
|
|
1573
|
-
const send =
|
|
1023
|
+
const send = useMemo(() => agentDraft && artifactId ? (chosen) => {
|
|
1574
1024
|
if (chosen.length === 0)
|
|
1575
1025
|
return;
|
|
1576
1026
|
const { context } = commentsContext({
|
|
@@ -1583,7 +1033,7 @@ function useCanvasCommenting({
|
|
|
1583
1033
|
} : null, [agentDraft, messages, title, artifactId]);
|
|
1584
1034
|
const access = view?.access ?? "read";
|
|
1585
1035
|
const userId = user?.id ?? null;
|
|
1586
|
-
const canManage =
|
|
1036
|
+
const canManage = useCallback((comment) => canManageComment(comment, access, userId), [access, userId]);
|
|
1587
1037
|
return {
|
|
1588
1038
|
enabled: artifactId !== null,
|
|
1589
1039
|
threads,
|
|
@@ -1622,35 +1072,35 @@ function CommentTools({
|
|
|
1622
1072
|
}) {
|
|
1623
1073
|
const messages = useArtifactMessages().canvas.comments;
|
|
1624
1074
|
const active = commenting.commenting;
|
|
1625
|
-
return /* @__PURE__ */
|
|
1626
|
-
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),
|
|
1627
1077
|
role: "group",
|
|
1628
1078
|
"aria-label": messages.title,
|
|
1629
1079
|
children: [
|
|
1630
|
-
/* @__PURE__ */
|
|
1080
|
+
/* @__PURE__ */ jsx5("button", {
|
|
1631
1081
|
type: "button",
|
|
1632
1082
|
"aria-label": messages.tool,
|
|
1633
1083
|
title: messages.toolHint,
|
|
1634
1084
|
"aria-pressed": active,
|
|
1635
1085
|
"aria-keyshortcuts": "C",
|
|
1636
1086
|
onClick: commenting.toggleCommenting,
|
|
1637
|
-
className:
|
|
1638
|
-
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, {
|
|
1639
1089
|
"aria-hidden": "true"
|
|
1640
1090
|
})
|
|
1641
1091
|
}),
|
|
1642
|
-
/* @__PURE__ */
|
|
1092
|
+
/* @__PURE__ */ jsxs5("button", {
|
|
1643
1093
|
type: "button",
|
|
1644
1094
|
"aria-label": messages.toggle(commenting.open),
|
|
1645
1095
|
title: messages.toggle(commenting.open),
|
|
1646
1096
|
"aria-pressed": commenting.panel,
|
|
1647
1097
|
onClick: () => commenting.setPanel(!commenting.panel),
|
|
1648
|
-
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"),
|
|
1649
1099
|
children: [
|
|
1650
|
-
/* @__PURE__ */
|
|
1100
|
+
/* @__PURE__ */ jsx5(MessageSquare, {
|
|
1651
1101
|
"aria-hidden": "true"
|
|
1652
1102
|
}),
|
|
1653
|
-
commenting.open > 0 ? /* @__PURE__ */
|
|
1103
|
+
commenting.open > 0 ? /* @__PURE__ */ jsx5("span", {
|
|
1654
1104
|
className: "text-xs font-medium tabular-nums",
|
|
1655
1105
|
children: commenting.open
|
|
1656
1106
|
}) : null
|
|
@@ -1661,19 +1111,19 @@ function CommentTools({
|
|
|
1661
1111
|
}
|
|
1662
1112
|
function CommentModeHint({ onExit }) {
|
|
1663
1113
|
const messages = useArtifactMessages().canvas.comments;
|
|
1664
|
-
return /* @__PURE__ */
|
|
1114
|
+
return /* @__PURE__ */ jsxs5("div", {
|
|
1665
1115
|
role: "status",
|
|
1666
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",
|
|
1667
1117
|
children: [
|
|
1668
|
-
/* @__PURE__ */
|
|
1118
|
+
/* @__PURE__ */ jsx5(MessageSquarePlus, {
|
|
1669
1119
|
className: "size-3.5 shrink-0 text-foreground",
|
|
1670
1120
|
"aria-hidden": "true"
|
|
1671
1121
|
}),
|
|
1672
|
-
/* @__PURE__ */
|
|
1122
|
+
/* @__PURE__ */ jsx5("span", {
|
|
1673
1123
|
className: "min-w-0 truncate",
|
|
1674
1124
|
children: messages.modeHint
|
|
1675
1125
|
}),
|
|
1676
|
-
/* @__PURE__ */
|
|
1126
|
+
/* @__PURE__ */ jsx5("button", {
|
|
1677
1127
|
type: "button",
|
|
1678
1128
|
onClick: onExit,
|
|
1679
1129
|
"aria-label": messages.exit,
|
|
@@ -1702,25 +1152,27 @@ import {
|
|
|
1702
1152
|
DropdownMenuTrigger
|
|
1703
1153
|
} from "@sixb/ui/components";
|
|
1704
1154
|
import { useLocale } from "@sixb/ui/lib/i18n";
|
|
1705
|
-
import { cn as
|
|
1155
|
+
import { cn as cn5 } from "@sixb/ui/lib/utils";
|
|
1706
1156
|
import {
|
|
1707
1157
|
Check,
|
|
1708
1158
|
CornerDownRight,
|
|
1159
|
+
Eye,
|
|
1160
|
+
Lock,
|
|
1709
1161
|
MessageSquare as MessageSquare2,
|
|
1710
1162
|
MessageSquarePlus as MessageSquarePlus2,
|
|
1711
1163
|
MoreHorizontal,
|
|
1712
1164
|
RotateCcw,
|
|
1713
1165
|
Sparkles,
|
|
1714
1166
|
Trash2,
|
|
1715
|
-
X
|
|
1167
|
+
X
|
|
1716
1168
|
} from "lucide-react";
|
|
1717
1169
|
import {
|
|
1718
1170
|
forwardRef,
|
|
1719
1171
|
useEffect as useEffect2,
|
|
1720
1172
|
useRef as useRef4,
|
|
1721
|
-
useState as
|
|
1173
|
+
useState as useState4
|
|
1722
1174
|
} from "react";
|
|
1723
|
-
import { jsx as
|
|
1175
|
+
import { jsx as jsx6, jsxs as jsxs6, Fragment as Fragment4 } from "react/jsx-runtime";
|
|
1724
1176
|
function CommentsPanel({
|
|
1725
1177
|
threads,
|
|
1726
1178
|
loading,
|
|
@@ -1742,10 +1194,12 @@ function CommentsPanel({
|
|
|
1742
1194
|
const open = threads.filter((thread) => !thread.comment.resolvedAt);
|
|
1743
1195
|
const resolved = threads.filter((thread) => thread.comment.resolvedAt);
|
|
1744
1196
|
const shown = filter === "open" ? open : resolved;
|
|
1745
|
-
const [choosing, setChoosing] =
|
|
1746
|
-
const [chosen, setChosen] =
|
|
1747
|
-
const [sent, setSent] =
|
|
1748
|
-
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");
|
|
1749
1203
|
useEffect2(() => {
|
|
1750
1204
|
setChosen((current) => {
|
|
1751
1205
|
const ids = new Set(shown.map((thread) => thread.comment.id));
|
|
@@ -1775,66 +1229,66 @@ function CommentsPanel({
|
|
|
1775
1229
|
setChosen(new Set);
|
|
1776
1230
|
setSent(true);
|
|
1777
1231
|
};
|
|
1778
|
-
return /* @__PURE__ */
|
|
1232
|
+
return /* @__PURE__ */ jsxs6("aside", {
|
|
1779
1233
|
"aria-label": messages.panel,
|
|
1780
1234
|
"data-comments-panel": "",
|
|
1781
|
-
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"),
|
|
1782
1236
|
children: [
|
|
1783
|
-
/* @__PURE__ */
|
|
1237
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1784
1238
|
"aria-hidden": "true",
|
|
1785
1239
|
className: "mx-auto mt-2 h-1 w-9 shrink-0 rounded-full bg-border @3xl/canvas:hidden"
|
|
1786
1240
|
}),
|
|
1787
|
-
/* @__PURE__ */
|
|
1241
|
+
/* @__PURE__ */ jsxs6("header", {
|
|
1788
1242
|
className: "flex h-12 shrink-0 items-center gap-2 px-3",
|
|
1789
1243
|
children: [
|
|
1790
|
-
/* @__PURE__ */
|
|
1244
|
+
/* @__PURE__ */ jsx6("h2", {
|
|
1791
1245
|
className: "m-0 text-sm font-semibold",
|
|
1792
1246
|
children: messages.title
|
|
1793
1247
|
}),
|
|
1794
|
-
open.length > 0 ? /* @__PURE__ */
|
|
1248
|
+
open.length > 0 ? /* @__PURE__ */ jsx6("span", {
|
|
1795
1249
|
className: "rounded-full bg-muted px-1.5 text-xs font-medium text-muted-foreground tabular-nums",
|
|
1796
1250
|
children: open.length
|
|
1797
1251
|
}) : null,
|
|
1798
|
-
/* @__PURE__ */
|
|
1252
|
+
/* @__PURE__ */ jsxs6("div", {
|
|
1799
1253
|
className: "ml-auto flex items-center gap-1",
|
|
1800
1254
|
children: [
|
|
1801
|
-
onSend && filter === "open" && open.length > 0 && !choosing ? /* @__PURE__ */
|
|
1255
|
+
onSend && filter === "open" && open.length > 0 && !choosing ? /* @__PURE__ */ jsxs6("button", {
|
|
1802
1256
|
type: "button",
|
|
1803
1257
|
onClick: () => setChoosing(true),
|
|
1804
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",
|
|
1805
1259
|
children: [
|
|
1806
|
-
/* @__PURE__ */
|
|
1260
|
+
/* @__PURE__ */ jsx6(Sparkles, {
|
|
1807
1261
|
"aria-hidden": "true"
|
|
1808
1262
|
}),
|
|
1809
1263
|
messages.select
|
|
1810
1264
|
]
|
|
1811
1265
|
}) : null,
|
|
1812
|
-
/* @__PURE__ */
|
|
1266
|
+
/* @__PURE__ */ jsx6(IconButton, {
|
|
1813
1267
|
label: messages.close,
|
|
1814
1268
|
onClick: onClose,
|
|
1815
|
-
children: /* @__PURE__ */
|
|
1269
|
+
children: /* @__PURE__ */ jsx6(X, {})
|
|
1816
1270
|
})
|
|
1817
1271
|
]
|
|
1818
1272
|
})
|
|
1819
1273
|
]
|
|
1820
1274
|
}),
|
|
1821
|
-
/* @__PURE__ */
|
|
1275
|
+
/* @__PURE__ */ jsx6("div", {
|
|
1822
1276
|
className: "flex shrink-0 items-center gap-2 px-3 pb-2",
|
|
1823
|
-
children: /* @__PURE__ */
|
|
1277
|
+
children: /* @__PURE__ */ jsx6("div", {
|
|
1824
1278
|
role: "group",
|
|
1825
1279
|
"aria-label": messages.filter,
|
|
1826
1280
|
className: "flex flex-1 items-center rounded-lg bg-muted/70 p-0.5",
|
|
1827
|
-
children: ["open", "resolved"].map((each) => /* @__PURE__ */
|
|
1281
|
+
children: ["open", "resolved"].map((each) => /* @__PURE__ */ jsxs6("button", {
|
|
1828
1282
|
type: "button",
|
|
1829
1283
|
"aria-pressed": filter === each,
|
|
1830
1284
|
onClick: () => {
|
|
1831
1285
|
onFilter(each);
|
|
1832
1286
|
setChoosing(false);
|
|
1833
1287
|
},
|
|
1834
|
-
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"),
|
|
1835
1289
|
children: [
|
|
1836
1290
|
messages[each],
|
|
1837
|
-
/* @__PURE__ */
|
|
1291
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1838
1292
|
className: "tabular-nums opacity-60",
|
|
1839
1293
|
children: (each === "open" ? open : resolved).length
|
|
1840
1294
|
})
|
|
@@ -1842,34 +1296,34 @@ function CommentsPanel({
|
|
|
1842
1296
|
}, each))
|
|
1843
1297
|
})
|
|
1844
1298
|
}),
|
|
1845
|
-
choosing ? /* @__PURE__ */
|
|
1299
|
+
choosing ? /* @__PURE__ */ jsx6("p", {
|
|
1846
1300
|
className: "m-0 shrink-0 px-4 pb-2 text-xs text-muted-foreground",
|
|
1847
1301
|
children: messages.chooseHint
|
|
1848
1302
|
}) : null,
|
|
1849
|
-
failure ? /* @__PURE__ */
|
|
1303
|
+
failure ? /* @__PURE__ */ jsx6("p", {
|
|
1850
1304
|
role: "alert",
|
|
1851
1305
|
className: "m-0 shrink-0 px-4 pb-2 text-xs text-destructive",
|
|
1852
1306
|
children: failure
|
|
1853
1307
|
}) : null,
|
|
1854
|
-
/* @__PURE__ */
|
|
1308
|
+
/* @__PURE__ */ jsx6("div", {
|
|
1855
1309
|
className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 pb-3",
|
|
1856
|
-
children: failed ? /* @__PURE__ */
|
|
1310
|
+
children: failed ? /* @__PURE__ */ jsx6(Empty, {
|
|
1857
1311
|
title: messages.loadFailed
|
|
1858
|
-
}) : loading ? /* @__PURE__ */
|
|
1312
|
+
}) : loading ? /* @__PURE__ */ jsx6("div", {
|
|
1859
1313
|
className: "flex flex-col gap-2 p-1",
|
|
1860
1314
|
"aria-busy": "true",
|
|
1861
|
-
children: [0, 1].map((index) => /* @__PURE__ */
|
|
1315
|
+
children: [0, 1].map((index) => /* @__PURE__ */ jsx6("div", {
|
|
1862
1316
|
className: "h-20 animate-pulse rounded-xl bg-muted/60"
|
|
1863
1317
|
}, index))
|
|
1864
|
-
}) : shown.length === 0 ? filter === "open" ? resolved.length > 0 ? /* @__PURE__ */
|
|
1318
|
+
}) : shown.length === 0 ? filter === "open" ? resolved.length > 0 ? /* @__PURE__ */ jsx6(Empty, {
|
|
1865
1319
|
title: messages.emptyOpen
|
|
1866
|
-
}) : /* @__PURE__ */
|
|
1320
|
+
}) : /* @__PURE__ */ jsx6(Empty, {
|
|
1867
1321
|
title: messages.empty,
|
|
1868
|
-
hint: /* @__PURE__ */
|
|
1322
|
+
hint: /* @__PURE__ */ jsxs6(Fragment4, {
|
|
1869
1323
|
children: [
|
|
1870
1324
|
messages.emptyHint.before,
|
|
1871
1325
|
" ",
|
|
1872
|
-
/* @__PURE__ */
|
|
1326
|
+
/* @__PURE__ */ jsx6(MessageSquarePlus2, {
|
|
1873
1327
|
className: "inline size-3.5 align-[-0.2em] text-foreground",
|
|
1874
1328
|
"aria-label": messages.tool
|
|
1875
1329
|
}),
|
|
@@ -1877,17 +1331,19 @@ function CommentsPanel({
|
|
|
1877
1331
|
messages.emptyHint.after
|
|
1878
1332
|
]
|
|
1879
1333
|
})
|
|
1880
|
-
}) : /* @__PURE__ */
|
|
1334
|
+
}) : /* @__PURE__ */ jsx6(Empty, {
|
|
1881
1335
|
title: messages.emptyResolved
|
|
1882
|
-
}) : /* @__PURE__ */
|
|
1336
|
+
}) : /* @__PURE__ */ jsx6("ul", {
|
|
1883
1337
|
className: "m-0 flex list-none flex-col gap-1.5 p-0",
|
|
1884
|
-
children: shown.map((thread) => /* @__PURE__ */
|
|
1338
|
+
children: shown.map((thread) => /* @__PURE__ */ jsx6(ThreadCard, {
|
|
1885
1339
|
thread,
|
|
1886
1340
|
place: placeOf(thread),
|
|
1887
1341
|
active: active === thread.comment.id,
|
|
1888
1342
|
choosing,
|
|
1889
1343
|
chosen: chosen.has(thread.comment.id),
|
|
1890
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",
|
|
1891
1347
|
manages: canManage(thread.comment),
|
|
1892
1348
|
onChoose: (next) => setChosen((current) => {
|
|
1893
1349
|
const updated = new Set(current);
|
|
@@ -1904,10 +1360,10 @@ function CommentsPanel({
|
|
|
1904
1360
|
}, thread.comment.id))
|
|
1905
1361
|
})
|
|
1906
1362
|
}),
|
|
1907
|
-
choosing ? /* @__PURE__ */
|
|
1363
|
+
choosing ? /* @__PURE__ */ jsxs6("footer", {
|
|
1908
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))]",
|
|
1909
1365
|
children: [
|
|
1910
|
-
/* @__PURE__ */
|
|
1366
|
+
/* @__PURE__ */ jsx6("button", {
|
|
1911
1367
|
type: "button",
|
|
1912
1368
|
onClick: () => {
|
|
1913
1369
|
setChoosing(false);
|
|
@@ -1916,24 +1372,24 @@ function CommentsPanel({
|
|
|
1916
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",
|
|
1917
1373
|
children: messages.cancelSelect
|
|
1918
1374
|
}),
|
|
1919
|
-
/* @__PURE__ */
|
|
1375
|
+
/* @__PURE__ */ jsxs6("button", {
|
|
1920
1376
|
type: "button",
|
|
1921
1377
|
disabled: chosen.size === 0,
|
|
1922
1378
|
onClick: send,
|
|
1923
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",
|
|
1924
1380
|
children: [
|
|
1925
|
-
/* @__PURE__ */
|
|
1381
|
+
/* @__PURE__ */ jsx6(Sparkles, {
|
|
1926
1382
|
"aria-hidden": "true"
|
|
1927
1383
|
}),
|
|
1928
1384
|
messages.send(chosen.size)
|
|
1929
1385
|
]
|
|
1930
1386
|
})
|
|
1931
1387
|
]
|
|
1932
|
-
}) : sent ? /* @__PURE__ */
|
|
1388
|
+
}) : sent ? /* @__PURE__ */ jsxs6("p", {
|
|
1933
1389
|
role: "status",
|
|
1934
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",
|
|
1935
1391
|
children: [
|
|
1936
|
-
/* @__PURE__ */
|
|
1392
|
+
/* @__PURE__ */ jsx6(Check, {
|
|
1937
1393
|
className: "size-3.5 text-primary",
|
|
1938
1394
|
"aria-hidden": "true"
|
|
1939
1395
|
}),
|
|
@@ -1950,6 +1406,8 @@ function ThreadCard({
|
|
|
1950
1406
|
choosing,
|
|
1951
1407
|
chosen,
|
|
1952
1408
|
nameOf,
|
|
1409
|
+
guest,
|
|
1410
|
+
internal,
|
|
1953
1411
|
manages,
|
|
1954
1412
|
onChoose,
|
|
1955
1413
|
onActivate,
|
|
@@ -1960,71 +1418,71 @@ function ThreadCard({
|
|
|
1960
1418
|
const messages = useArtifactMessages().canvas.comments;
|
|
1961
1419
|
const { comment, replies, number } = thread;
|
|
1962
1420
|
const resolved = Boolean(comment.resolvedAt);
|
|
1963
|
-
const [replying, setReplying] =
|
|
1964
|
-
const [confirming, setConfirming] =
|
|
1421
|
+
const [replying, setReplying] = useState4(false);
|
|
1422
|
+
const [confirming, setConfirming] = useState4(false);
|
|
1965
1423
|
const card = useRef4(null);
|
|
1966
1424
|
useEffect2(() => {
|
|
1967
1425
|
if (active)
|
|
1968
1426
|
card.current?.scrollIntoView({ block: "nearest", behavior: "smooth" });
|
|
1969
1427
|
}, [active]);
|
|
1970
|
-
return /* @__PURE__ */
|
|
1428
|
+
return /* @__PURE__ */ jsxs6("li", {
|
|
1971
1429
|
children: [
|
|
1972
|
-
/* @__PURE__ */
|
|
1430
|
+
/* @__PURE__ */ jsxs6("article", {
|
|
1973
1431
|
ref: card,
|
|
1974
1432
|
"aria-label": messages.pin(number, nameOf(comment)?.name ?? messages.someone),
|
|
1975
1433
|
"data-comment-thread": comment.id,
|
|
1976
1434
|
"data-active": active ? "" : undefined,
|
|
1977
|
-
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"),
|
|
1978
1436
|
children: [
|
|
1979
|
-
choosing ? /* @__PURE__ */
|
|
1437
|
+
choosing ? /* @__PURE__ */ jsx6(Checkbox, {
|
|
1980
1438
|
checked: chosen,
|
|
1981
1439
|
onCheckedChange: (value) => onChoose(value === true),
|
|
1982
1440
|
"aria-label": messages.selectLabel(number),
|
|
1983
1441
|
className: "mt-0.5"
|
|
1984
|
-
}) : /* @__PURE__ */
|
|
1442
|
+
}) : /* @__PURE__ */ jsx6("span", {
|
|
1985
1443
|
"aria-hidden": "true",
|
|
1986
|
-
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"),
|
|
1987
1445
|
children: number
|
|
1988
1446
|
}),
|
|
1989
|
-
/* @__PURE__ */
|
|
1447
|
+
/* @__PURE__ */ jsxs6("div", {
|
|
1990
1448
|
className: "min-w-0 flex-1",
|
|
1991
1449
|
children: [
|
|
1992
|
-
/* @__PURE__ */
|
|
1450
|
+
/* @__PURE__ */ jsxs6("div", {
|
|
1993
1451
|
className: "flex items-start gap-1",
|
|
1994
1452
|
children: [
|
|
1995
|
-
/* @__PURE__ */
|
|
1453
|
+
/* @__PURE__ */ jsx6("button", {
|
|
1996
1454
|
type: "button",
|
|
1997
1455
|
onClick: onActivate,
|
|
1998
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",
|
|
1999
|
-
children: /* @__PURE__ */
|
|
1457
|
+
children: /* @__PURE__ */ jsx6(Where, {
|
|
2000
1458
|
place
|
|
2001
1459
|
})
|
|
2002
1460
|
}),
|
|
2003
|
-
manages ? /* @__PURE__ */
|
|
1461
|
+
manages ? /* @__PURE__ */ jsxs6("div", {
|
|
2004
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",
|
|
2005
1463
|
children: [
|
|
2006
|
-
/* @__PURE__ */
|
|
1464
|
+
/* @__PURE__ */ jsx6(IconButton, {
|
|
2007
1465
|
label: resolved ? messages.reopen : messages.resolve,
|
|
2008
1466
|
onClick: () => void onResolve(!resolved),
|
|
2009
|
-
children: resolved ? /* @__PURE__ */
|
|
1467
|
+
children: resolved ? /* @__PURE__ */ jsx6(RotateCcw, {}) : /* @__PURE__ */ jsx6(Check, {})
|
|
2010
1468
|
}),
|
|
2011
|
-
/* @__PURE__ */
|
|
1469
|
+
/* @__PURE__ */ jsxs6(DropdownMenu, {
|
|
2012
1470
|
modal: false,
|
|
2013
1471
|
children: [
|
|
2014
|
-
/* @__PURE__ */
|
|
1472
|
+
/* @__PURE__ */ jsx6(DropdownMenuTrigger, {
|
|
2015
1473
|
asChild: true,
|
|
2016
|
-
children: /* @__PURE__ */
|
|
1474
|
+
children: /* @__PURE__ */ jsx6(IconButton, {
|
|
2017
1475
|
label: messages.more,
|
|
2018
|
-
children: /* @__PURE__ */
|
|
1476
|
+
children: /* @__PURE__ */ jsx6(MoreHorizontal, {})
|
|
2019
1477
|
})
|
|
2020
1478
|
}),
|
|
2021
|
-
/* @__PURE__ */
|
|
1479
|
+
/* @__PURE__ */ jsx6(DropdownMenuContent, {
|
|
2022
1480
|
align: "end",
|
|
2023
|
-
children: /* @__PURE__ */
|
|
1481
|
+
children: /* @__PURE__ */ jsxs6(DropdownMenuItem, {
|
|
2024
1482
|
variant: "destructive",
|
|
2025
1483
|
onSelect: () => setConfirming(true),
|
|
2026
1484
|
children: [
|
|
2027
|
-
/* @__PURE__ */
|
|
1485
|
+
/* @__PURE__ */ jsx6(Trash2, {
|
|
2028
1486
|
"aria-hidden": "true"
|
|
2029
1487
|
}),
|
|
2030
1488
|
messages.delete
|
|
@@ -2037,33 +1495,47 @@ function ThreadCard({
|
|
|
2037
1495
|
}) : null
|
|
2038
1496
|
]
|
|
2039
1497
|
}),
|
|
2040
|
-
/* @__PURE__ */
|
|
1498
|
+
/* @__PURE__ */ jsx6(Message, {
|
|
2041
1499
|
comment,
|
|
2042
|
-
nameOf
|
|
1500
|
+
nameOf,
|
|
1501
|
+
...internal ? { badge: /* @__PURE__ */ jsx6(InternalBadge, {}) } : {}
|
|
2043
1502
|
}),
|
|
2044
|
-
replies.map((reply) => /* @__PURE__ */
|
|
1503
|
+
replies.map((reply) => /* @__PURE__ */ jsx6("div", {
|
|
2045
1504
|
className: "mt-2.5 border-l-2 border-border/70 pl-2.5",
|
|
2046
|
-
children: /* @__PURE__ */
|
|
1505
|
+
children: /* @__PURE__ */ jsx6(Message, {
|
|
2047
1506
|
comment: reply,
|
|
2048
1507
|
nameOf
|
|
2049
1508
|
})
|
|
2050
1509
|
}, reply.id)),
|
|
2051
|
-
resolved ? null : replying || active ? /* @__PURE__ */
|
|
1510
|
+
resolved ? null : replying || active ? /* @__PURE__ */ jsx6(CommentComposer, {
|
|
2052
1511
|
compact: true,
|
|
2053
1512
|
autoFocus: replying,
|
|
2054
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,
|
|
2055
1527
|
onSubmit: async (body) => {
|
|
2056
1528
|
await onReply(body);
|
|
2057
1529
|
setReplying(false);
|
|
2058
1530
|
},
|
|
2059
1531
|
onCancel: () => setReplying(false),
|
|
2060
1532
|
className: "mt-2.5"
|
|
2061
|
-
}) : /* @__PURE__ */
|
|
1533
|
+
}) : /* @__PURE__ */ jsxs6("button", {
|
|
2062
1534
|
type: "button",
|
|
2063
1535
|
onClick: () => setReplying(true),
|
|
2064
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",
|
|
2065
1537
|
children: [
|
|
2066
|
-
/* @__PURE__ */
|
|
1538
|
+
/* @__PURE__ */ jsx6(CornerDownRight, {
|
|
2067
1539
|
"aria-hidden": "true"
|
|
2068
1540
|
}),
|
|
2069
1541
|
replies.length > 0 ? messages.replies(replies.length) : messages.reply
|
|
@@ -2073,27 +1545,27 @@ function ThreadCard({
|
|
|
2073
1545
|
})
|
|
2074
1546
|
]
|
|
2075
1547
|
}),
|
|
2076
|
-
/* @__PURE__ */
|
|
1548
|
+
/* @__PURE__ */ jsx6(AlertDialog, {
|
|
2077
1549
|
open: confirming,
|
|
2078
1550
|
onOpenChange: setConfirming,
|
|
2079
|
-
children: /* @__PURE__ */
|
|
1551
|
+
children: /* @__PURE__ */ jsxs6(AlertDialogContent, {
|
|
2080
1552
|
children: [
|
|
2081
|
-
/* @__PURE__ */
|
|
1553
|
+
/* @__PURE__ */ jsxs6(AlertDialogHeader, {
|
|
2082
1554
|
children: [
|
|
2083
|
-
/* @__PURE__ */
|
|
1555
|
+
/* @__PURE__ */ jsx6(AlertDialogTitle, {
|
|
2084
1556
|
children: messages.deleteTitle
|
|
2085
1557
|
}),
|
|
2086
|
-
/* @__PURE__ */
|
|
1558
|
+
/* @__PURE__ */ jsx6(AlertDialogDescription, {
|
|
2087
1559
|
children: messages.deleteDescription
|
|
2088
1560
|
})
|
|
2089
1561
|
]
|
|
2090
1562
|
}),
|
|
2091
|
-
/* @__PURE__ */
|
|
1563
|
+
/* @__PURE__ */ jsxs6(AlertDialogFooter, {
|
|
2092
1564
|
children: [
|
|
2093
|
-
/* @__PURE__ */
|
|
1565
|
+
/* @__PURE__ */ jsx6(AlertDialogCancel, {
|
|
2094
1566
|
children: messages.cancel
|
|
2095
1567
|
}),
|
|
2096
|
-
/* @__PURE__ */
|
|
1568
|
+
/* @__PURE__ */ jsx6(AlertDialogAction, {
|
|
2097
1569
|
variant: "destructive",
|
|
2098
1570
|
onClick: () => void onDelete(),
|
|
2099
1571
|
children: messages.delete
|
|
@@ -2106,28 +1578,41 @@ function ThreadCard({
|
|
|
2106
1578
|
]
|
|
2107
1579
|
});
|
|
2108
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
|
+
}
|
|
2109
1594
|
function Where({ place }) {
|
|
2110
1595
|
const messages = useArtifactMessages().canvas.comments;
|
|
2111
|
-
return /* @__PURE__ */
|
|
1596
|
+
return /* @__PURE__ */ jsxs6("span", {
|
|
2112
1597
|
className: "flex min-w-0 flex-wrap items-center gap-x-1 gap-y-0.5",
|
|
2113
1598
|
children: [
|
|
2114
|
-
/* @__PURE__ */
|
|
1599
|
+
/* @__PURE__ */ jsx6("span", {
|
|
2115
1600
|
className: "truncate font-medium text-foreground/80",
|
|
2116
1601
|
children: place.board ?? messages.onCanvas
|
|
2117
1602
|
}),
|
|
2118
|
-
place.board ? /* @__PURE__ */
|
|
1603
|
+
place.board ? /* @__PURE__ */ jsxs6(Fragment4, {
|
|
2119
1604
|
children: [
|
|
2120
|
-
/* @__PURE__ */
|
|
1605
|
+
/* @__PURE__ */ jsx6("span", {
|
|
2121
1606
|
"aria-hidden": "true",
|
|
2122
1607
|
children: "\xB7"
|
|
2123
1608
|
}),
|
|
2124
|
-
/* @__PURE__ */
|
|
2125
|
-
className:
|
|
1609
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1610
|
+
className: cn5("min-w-0 truncate", place.gone && "line-through decoration-1"),
|
|
2126
1611
|
children: place.element ? `\u201C${place.element}\u201D` : messages.wholeBoard
|
|
2127
1612
|
})
|
|
2128
1613
|
]
|
|
2129
1614
|
}) : null,
|
|
2130
|
-
place.gone ? /* @__PURE__ */
|
|
1615
|
+
place.gone ? /* @__PURE__ */ jsx6("span", {
|
|
2131
1616
|
className: "rounded-sm bg-muted px-1 text-[10.5px] text-muted-foreground",
|
|
2132
1617
|
children: messages.elementGone
|
|
2133
1618
|
}) : null
|
|
@@ -2136,41 +1621,46 @@ function Where({ place }) {
|
|
|
2136
1621
|
}
|
|
2137
1622
|
function Message({
|
|
2138
1623
|
comment,
|
|
2139
|
-
nameOf
|
|
1624
|
+
nameOf,
|
|
1625
|
+
badge
|
|
2140
1626
|
}) {
|
|
2141
1627
|
const messages = useArtifactMessages().canvas.comments;
|
|
2142
1628
|
const when = useWhen();
|
|
2143
1629
|
const author = nameOf(comment);
|
|
2144
1630
|
const name = author ? author.you ? messages.you : author.name : messages.someone;
|
|
2145
|
-
return /* @__PURE__ */
|
|
1631
|
+
return /* @__PURE__ */ jsxs6("div", {
|
|
2146
1632
|
className: "mt-1.5",
|
|
2147
1633
|
children: [
|
|
2148
|
-
/* @__PURE__ */
|
|
1634
|
+
/* @__PURE__ */ jsxs6("div", {
|
|
2149
1635
|
className: "flex items-center gap-1.5 text-xs",
|
|
2150
1636
|
children: [
|
|
2151
|
-
author?.agent ? /* @__PURE__ */
|
|
1637
|
+
author?.agent ? /* @__PURE__ */ jsx6("span", {
|
|
2152
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",
|
|
2153
|
-
children: /* @__PURE__ */
|
|
1639
|
+
children: /* @__PURE__ */ jsx6(Sparkles, {
|
|
2154
1640
|
className: "size-3",
|
|
2155
1641
|
"aria-hidden": "true"
|
|
2156
1642
|
})
|
|
2157
|
-
}) : /* @__PURE__ */
|
|
1643
|
+
}) : /* @__PURE__ */ jsx6(PersonAvatar, {
|
|
2158
1644
|
name: author?.name || name,
|
|
2159
1645
|
size: "xs"
|
|
2160
1646
|
}),
|
|
2161
|
-
/* @__PURE__ */
|
|
1647
|
+
/* @__PURE__ */ jsx6("span", {
|
|
2162
1648
|
className: "truncate font-medium text-foreground",
|
|
2163
1649
|
children: name
|
|
2164
1650
|
}),
|
|
2165
|
-
author?.guest ? /* @__PURE__ */
|
|
2166
|
-
/* @__PURE__ */
|
|
1651
|
+
author?.guest ? /* @__PURE__ */ jsx6(GuestBadge, {}) : null,
|
|
1652
|
+
/* @__PURE__ */ jsx6("time", {
|
|
2167
1653
|
dateTime: comment.createdAt,
|
|
2168
1654
|
className: "shrink-0 text-muted-foreground",
|
|
2169
1655
|
children: when(comment.createdAt)
|
|
2170
|
-
})
|
|
1656
|
+
}),
|
|
1657
|
+
badge ? /* @__PURE__ */ jsx6("span", {
|
|
1658
|
+
className: "ml-auto flex shrink-0 pl-1",
|
|
1659
|
+
children: badge
|
|
1660
|
+
}) : null
|
|
2171
1661
|
]
|
|
2172
1662
|
}),
|
|
2173
|
-
/* @__PURE__ */
|
|
1663
|
+
/* @__PURE__ */ jsx6("p", {
|
|
2174
1664
|
className: "m-0 mt-1 text-sm leading-5 break-words whitespace-pre-wrap text-foreground",
|
|
2175
1665
|
children: comment.body
|
|
2176
1666
|
})
|
|
@@ -2190,21 +1680,21 @@ function useWhen() {
|
|
|
2190
1680
|
};
|
|
2191
1681
|
}
|
|
2192
1682
|
function Empty({ title, hint }) {
|
|
2193
|
-
return /* @__PURE__ */
|
|
1683
|
+
return /* @__PURE__ */ jsxs6("div", {
|
|
2194
1684
|
className: "flex flex-col items-center gap-2 px-6 py-10 text-center",
|
|
2195
1685
|
children: [
|
|
2196
|
-
/* @__PURE__ */
|
|
1686
|
+
/* @__PURE__ */ jsx6("span", {
|
|
2197
1687
|
className: "flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground",
|
|
2198
|
-
children: /* @__PURE__ */
|
|
1688
|
+
children: /* @__PURE__ */ jsx6(MessageSquare2, {
|
|
2199
1689
|
className: "size-4",
|
|
2200
1690
|
"aria-hidden": "true"
|
|
2201
1691
|
})
|
|
2202
1692
|
}),
|
|
2203
|
-
/* @__PURE__ */
|
|
1693
|
+
/* @__PURE__ */ jsx6("p", {
|
|
2204
1694
|
className: "m-0 text-sm font-medium text-foreground",
|
|
2205
1695
|
children: title
|
|
2206
1696
|
}),
|
|
2207
|
-
hint ? /* @__PURE__ */
|
|
1697
|
+
hint ? /* @__PURE__ */ jsx6("p", {
|
|
2208
1698
|
className: "m-0 max-w-[24ch] text-xs text-muted-foreground",
|
|
2209
1699
|
children: hint
|
|
2210
1700
|
}) : null
|
|
@@ -2212,7 +1702,7 @@ function Empty({ title, hint }) {
|
|
|
2212
1702
|
});
|
|
2213
1703
|
}
|
|
2214
1704
|
var IconButton = forwardRef(function IconButton({ label, children, ...props }, ref) {
|
|
2215
|
-
return /* @__PURE__ */
|
|
1705
|
+
return /* @__PURE__ */ jsx6("button", {
|
|
2216
1706
|
ref,
|
|
2217
1707
|
type: "button",
|
|
2218
1708
|
"aria-label": label,
|
|
@@ -2224,19 +1714,19 @@ var IconButton = forwardRef(function IconButton({ label, children, ...props }, r
|
|
|
2224
1714
|
});
|
|
2225
1715
|
|
|
2226
1716
|
// src/artifacts/renderers/canvas/controls.tsx
|
|
2227
|
-
import { cn as
|
|
2228
|
-
import { Panel, useReactFlow, useStore
|
|
1717
|
+
import { cn as cn6 } from "@sixb/ui/lib/utils";
|
|
1718
|
+
import { Panel, useReactFlow, useStore } from "@xyflow/react";
|
|
2229
1719
|
import { Maximize, Minus, Plus } from "lucide-react";
|
|
2230
|
-
import { jsx as
|
|
1720
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2231
1721
|
var DURATION = 220;
|
|
2232
1722
|
function CanvasControls({ padding }) {
|
|
2233
1723
|
const messages = useArtifactMessages().canvas;
|
|
2234
1724
|
const { zoomIn, zoomOut, zoomTo, fitView } = useReactFlow();
|
|
2235
|
-
const zoom =
|
|
2236
|
-
return /* @__PURE__ */
|
|
1725
|
+
const zoom = useStore((state) => state.transform[2]);
|
|
1726
|
+
return /* @__PURE__ */ jsx7(Panel, {
|
|
2237
1727
|
position: "bottom-left",
|
|
2238
1728
|
className: "!m-3",
|
|
2239
|
-
children: /* @__PURE__ */
|
|
1729
|
+
children: /* @__PURE__ */ jsx7(ZoomBar, {
|
|
2240
1730
|
zoom,
|
|
2241
1731
|
fitLabel: messages.fitView,
|
|
2242
1732
|
onZoomOut: () => zoomOut({ duration: DURATION }),
|
|
@@ -2256,28 +1746,28 @@ function ZoomBar({
|
|
|
2256
1746
|
className
|
|
2257
1747
|
}) {
|
|
2258
1748
|
const messages = useArtifactMessages().canvas;
|
|
2259
|
-
return /* @__PURE__ */
|
|
2260
|
-
className:
|
|
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),
|
|
2261
1751
|
children: [
|
|
2262
|
-
/* @__PURE__ */
|
|
1752
|
+
/* @__PURE__ */ jsx7(Control, {
|
|
2263
1753
|
label: messages.zoomOut,
|
|
2264
1754
|
onClick: onZoomOut,
|
|
2265
|
-
children: /* @__PURE__ */
|
|
1755
|
+
children: /* @__PURE__ */ jsx7(Minus, {
|
|
2266
1756
|
className: "size-4",
|
|
2267
1757
|
"aria-hidden": "true"
|
|
2268
1758
|
})
|
|
2269
1759
|
}),
|
|
2270
|
-
/* @__PURE__ */
|
|
1760
|
+
/* @__PURE__ */ jsxs7("button", {
|
|
2271
1761
|
type: "button",
|
|
2272
1762
|
title: messages.actualSize,
|
|
2273
1763
|
onClick: onActualSize,
|
|
2274
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",
|
|
2275
1765
|
children: [
|
|
2276
|
-
/* @__PURE__ */
|
|
1766
|
+
/* @__PURE__ */ jsx7("span", {
|
|
2277
1767
|
"aria-live": "polite",
|
|
2278
1768
|
children: messages.zoom(Math.round(zoom * 100))
|
|
2279
1769
|
}),
|
|
2280
|
-
/* @__PURE__ */
|
|
1770
|
+
/* @__PURE__ */ jsxs7("span", {
|
|
2281
1771
|
className: "sr-only",
|
|
2282
1772
|
children: [
|
|
2283
1773
|
", ",
|
|
@@ -2286,28 +1776,28 @@ function ZoomBar({
|
|
|
2286
1776
|
})
|
|
2287
1777
|
]
|
|
2288
1778
|
}),
|
|
2289
|
-
/* @__PURE__ */
|
|
1779
|
+
/* @__PURE__ */ jsx7(Control, {
|
|
2290
1780
|
label: messages.zoomIn,
|
|
2291
1781
|
onClick: onZoomIn,
|
|
2292
|
-
children: /* @__PURE__ */
|
|
1782
|
+
children: /* @__PURE__ */ jsx7(Plus, {
|
|
2293
1783
|
className: "size-4",
|
|
2294
1784
|
"aria-hidden": "true"
|
|
2295
1785
|
})
|
|
2296
1786
|
}),
|
|
2297
|
-
/* @__PURE__ */
|
|
1787
|
+
/* @__PURE__ */ jsx7("span", {
|
|
2298
1788
|
className: "mx-1 h-5 w-px bg-border",
|
|
2299
1789
|
"aria-hidden": "true"
|
|
2300
1790
|
}),
|
|
2301
|
-
/* @__PURE__ */
|
|
1791
|
+
/* @__PURE__ */ jsxs7(Control, {
|
|
2302
1792
|
label: fitLabel,
|
|
2303
1793
|
onClick: onFit,
|
|
2304
1794
|
wide: true,
|
|
2305
1795
|
children: [
|
|
2306
|
-
/* @__PURE__ */
|
|
1796
|
+
/* @__PURE__ */ jsx7(Maximize, {
|
|
2307
1797
|
className: "size-3.5",
|
|
2308
1798
|
"aria-hidden": "true"
|
|
2309
1799
|
}),
|
|
2310
|
-
/* @__PURE__ */
|
|
1800
|
+
/* @__PURE__ */ jsx7("span", {
|
|
2311
1801
|
className: "text-xs font-medium",
|
|
2312
1802
|
children: messages.fit
|
|
2313
1803
|
})
|
|
@@ -2322,7 +1812,7 @@ function Control({
|
|
|
2322
1812
|
wide = false,
|
|
2323
1813
|
children
|
|
2324
1814
|
}) {
|
|
2325
|
-
return /* @__PURE__ */
|
|
1815
|
+
return /* @__PURE__ */ jsx7("button", {
|
|
2326
1816
|
type: "button",
|
|
2327
1817
|
"aria-label": label,
|
|
2328
1818
|
title: label,
|
|
@@ -2340,11 +1830,11 @@ import {
|
|
|
2340
1830
|
useStoreApi as useStoreApi3
|
|
2341
1831
|
} from "@xyflow/react";
|
|
2342
1832
|
import {
|
|
2343
|
-
useCallback as
|
|
1833
|
+
useCallback as useCallback2,
|
|
2344
1834
|
useEffect as useEffect4,
|
|
2345
|
-
useMemo as
|
|
1835
|
+
useMemo as useMemo2,
|
|
2346
1836
|
useRef as useRef5,
|
|
2347
|
-
useState as
|
|
1837
|
+
useState as useState6
|
|
2348
1838
|
} from "react";
|
|
2349
1839
|
|
|
2350
1840
|
// src/artifacts/renderers/canvas/toolbar.tsx
|
|
@@ -2354,7 +1844,7 @@ import {
|
|
|
2354
1844
|
DropdownMenuItem as DropdownMenuItem2,
|
|
2355
1845
|
DropdownMenuTrigger as DropdownMenuTrigger2
|
|
2356
1846
|
} from "@sixb/ui/components";
|
|
2357
|
-
import { cn as
|
|
1847
|
+
import { cn as cn7 } from "@sixb/ui/lib/utils";
|
|
2358
1848
|
import { Panel as Panel2 } from "@xyflow/react";
|
|
2359
1849
|
import {
|
|
2360
1850
|
ChevronDown,
|
|
@@ -2368,8 +1858,8 @@ import {
|
|
|
2368
1858
|
Trash2 as Trash22,
|
|
2369
1859
|
Type
|
|
2370
1860
|
} from "lucide-react";
|
|
2371
|
-
import { useEffect as useEffect3, useState as
|
|
2372
|
-
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";
|
|
2373
1863
|
var NOTE_TONES = [
|
|
2374
1864
|
null,
|
|
2375
1865
|
"positive",
|
|
@@ -2411,45 +1901,45 @@ function CanvasToolbar({
|
|
|
2411
1901
|
const size = one(texts.map((item) => item.type === "text" ? item.size : undefined));
|
|
2412
1902
|
const shape = one(shapes.map((item) => item.type === "shape" ? item.shape : undefined));
|
|
2413
1903
|
const dashed = one(arrows.map((item) => item.type === "arrow" ? item.dashed : false));
|
|
2414
|
-
return /* @__PURE__ */
|
|
1904
|
+
return /* @__PURE__ */ jsx8(Panel2, {
|
|
2415
1905
|
position: "top-center",
|
|
2416
1906
|
className: "!mt-3",
|
|
2417
|
-
children: /* @__PURE__ */
|
|
1907
|
+
children: /* @__PURE__ */ jsxs8("div", {
|
|
2418
1908
|
role: "toolbar",
|
|
2419
1909
|
"aria-label": messages.label,
|
|
2420
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",
|
|
2421
1911
|
children: [
|
|
2422
|
-
/* @__PURE__ */
|
|
1912
|
+
/* @__PURE__ */ jsx8(Tool, {
|
|
2423
1913
|
label: messages.note,
|
|
2424
1914
|
onClick: () => onAdd("note"),
|
|
2425
|
-
children: /* @__PURE__ */
|
|
1915
|
+
children: /* @__PURE__ */ jsx8(StickyNote, {})
|
|
2426
1916
|
}),
|
|
2427
|
-
/* @__PURE__ */
|
|
1917
|
+
/* @__PURE__ */ jsx8(Tool, {
|
|
2428
1918
|
label: messages.text,
|
|
2429
1919
|
onClick: () => onAdd("text"),
|
|
2430
|
-
children: /* @__PURE__ */
|
|
1920
|
+
children: /* @__PURE__ */ jsx8(Type, {})
|
|
2431
1921
|
}),
|
|
2432
|
-
/* @__PURE__ */
|
|
1922
|
+
/* @__PURE__ */ jsxs8(DropdownMenu2, {
|
|
2433
1923
|
modal: false,
|
|
2434
1924
|
children: [
|
|
2435
|
-
/* @__PURE__ */
|
|
1925
|
+
/* @__PURE__ */ jsxs8(DropdownMenuTrigger2, {
|
|
2436
1926
|
"aria-label": messages.shape,
|
|
2437
1927
|
title: messages.shape,
|
|
2438
|
-
className:
|
|
1928
|
+
className: cn7(TOOL, "w-auto gap-0.5 px-1.5"),
|
|
2439
1929
|
children: [
|
|
2440
|
-
/* @__PURE__ */
|
|
2441
|
-
/* @__PURE__ */
|
|
1930
|
+
/* @__PURE__ */ jsx8(RectangleHorizontal, {}),
|
|
1931
|
+
/* @__PURE__ */ jsx8(ChevronDown, {
|
|
2442
1932
|
className: "!size-3 opacity-60"
|
|
2443
1933
|
})
|
|
2444
1934
|
]
|
|
2445
1935
|
}),
|
|
2446
|
-
/* @__PURE__ */
|
|
1936
|
+
/* @__PURE__ */ jsx8(DropdownMenuContent2, {
|
|
2447
1937
|
align: "center",
|
|
2448
1938
|
sideOffset: 8,
|
|
2449
|
-
children: SHAPES.map(({ shape: kind, icon: Icon }) => /* @__PURE__ */
|
|
1939
|
+
children: SHAPES.map(({ shape: kind, icon: Icon }) => /* @__PURE__ */ jsxs8(DropdownMenuItem2, {
|
|
2450
1940
|
onSelect: () => onAdd("shape", kind),
|
|
2451
1941
|
children: [
|
|
2452
|
-
/* @__PURE__ */
|
|
1942
|
+
/* @__PURE__ */ jsx8(Icon, {
|
|
2453
1943
|
"aria-hidden": "true"
|
|
2454
1944
|
}),
|
|
2455
1945
|
messages.shapes[kind]
|
|
@@ -2458,87 +1948,87 @@ function CanvasToolbar({
|
|
|
2458
1948
|
})
|
|
2459
1949
|
]
|
|
2460
1950
|
}),
|
|
2461
|
-
/* @__PURE__ */
|
|
1951
|
+
/* @__PURE__ */ jsx8(Tool, {
|
|
2462
1952
|
label: messages.section,
|
|
2463
1953
|
onClick: () => onAdd("section"),
|
|
2464
|
-
children: /* @__PURE__ */
|
|
1954
|
+
children: /* @__PURE__ */ jsx8(Frame, {})
|
|
2465
1955
|
}),
|
|
2466
|
-
selection.length > 0 ? /* @__PURE__ */
|
|
1956
|
+
selection.length > 0 ? /* @__PURE__ */ jsxs8(Fragment5, {
|
|
2467
1957
|
children: [
|
|
2468
|
-
/* @__PURE__ */
|
|
2469
|
-
toned.length > 0 ? /* @__PURE__ */
|
|
1958
|
+
/* @__PURE__ */ jsx8(Divider, {}),
|
|
1959
|
+
toned.length > 0 ? /* @__PURE__ */ jsx8("div", {
|
|
2470
1960
|
className: "flex items-center gap-1 px-1",
|
|
2471
1961
|
role: "group",
|
|
2472
1962
|
"aria-label": messages.color,
|
|
2473
|
-
children: tones.map((entry) => /* @__PURE__ */
|
|
1963
|
+
children: tones.map((entry) => /* @__PURE__ */ jsx8("button", {
|
|
2474
1964
|
type: "button",
|
|
2475
1965
|
"aria-label": messages.tones[entry ?? "default"],
|
|
2476
1966
|
title: messages.tones[entry ?? "default"],
|
|
2477
1967
|
"aria-pressed": tone === entry,
|
|
2478
1968
|
onClick: () => onStyle({ tone: entry }),
|
|
2479
1969
|
className: "flex size-6 items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
2480
|
-
children: /* @__PURE__ */
|
|
1970
|
+
children: /* @__PURE__ */ jsx8("span", {
|
|
2481
1971
|
"aria-hidden": "true",
|
|
2482
|
-
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"),
|
|
2483
1973
|
style: { background: swatch(entry, toned) }
|
|
2484
1974
|
})
|
|
2485
1975
|
}, entry ?? "default"))
|
|
2486
1976
|
}) : null,
|
|
2487
|
-
texts.length > 0 ? /* @__PURE__ */
|
|
1977
|
+
texts.length > 0 ? /* @__PURE__ */ jsx8(Segments, {
|
|
2488
1978
|
label: messages.size,
|
|
2489
|
-
children: SIZES.map((entry) => /* @__PURE__ */
|
|
1979
|
+
children: SIZES.map((entry) => /* @__PURE__ */ jsx8(Segment, {
|
|
2490
1980
|
label: messages.sizes[entry],
|
|
2491
1981
|
pressed: size === entry,
|
|
2492
1982
|
onClick: () => onStyle({ size: entry }),
|
|
2493
|
-
children: /* @__PURE__ */
|
|
1983
|
+
children: /* @__PURE__ */ jsx8("span", {
|
|
2494
1984
|
className: "text-xs font-semibold uppercase",
|
|
2495
1985
|
children: entry
|
|
2496
1986
|
})
|
|
2497
1987
|
}, entry))
|
|
2498
1988
|
}) : null,
|
|
2499
|
-
shapes.length > 0 ? /* @__PURE__ */
|
|
1989
|
+
shapes.length > 0 ? /* @__PURE__ */ jsx8(Segments, {
|
|
2500
1990
|
label: messages.shape,
|
|
2501
|
-
children: SHAPES.map(({ shape: kind, icon: Icon }) => /* @__PURE__ */
|
|
1991
|
+
children: SHAPES.map(({ shape: kind, icon: Icon }) => /* @__PURE__ */ jsx8(Segment, {
|
|
2502
1992
|
label: messages.shapes[kind],
|
|
2503
1993
|
pressed: shape === kind,
|
|
2504
1994
|
onClick: () => onStyle({ shape: kind }),
|
|
2505
|
-
children: /* @__PURE__ */
|
|
1995
|
+
children: /* @__PURE__ */ jsx8(Icon, {})
|
|
2506
1996
|
}, kind))
|
|
2507
1997
|
}) : null,
|
|
2508
|
-
arrows.length > 0 ? /* @__PURE__ */
|
|
1998
|
+
arrows.length > 0 ? /* @__PURE__ */ jsxs8(Segments, {
|
|
2509
1999
|
label: messages.line,
|
|
2510
2000
|
children: [
|
|
2511
|
-
/* @__PURE__ */
|
|
2001
|
+
/* @__PURE__ */ jsx8(Segment, {
|
|
2512
2002
|
label: messages.solid,
|
|
2513
2003
|
pressed: dashed === false,
|
|
2514
2004
|
onClick: () => onStyle({ dashed: false }),
|
|
2515
|
-
children: /* @__PURE__ */
|
|
2005
|
+
children: /* @__PURE__ */ jsx8(Spline, {})
|
|
2516
2006
|
}),
|
|
2517
|
-
/* @__PURE__ */
|
|
2007
|
+
/* @__PURE__ */ jsx8(Segment, {
|
|
2518
2008
|
label: messages.dashed,
|
|
2519
2009
|
pressed: dashed === true,
|
|
2520
2010
|
onClick: () => onStyle({ dashed: true }),
|
|
2521
|
-
children: /* @__PURE__ */
|
|
2011
|
+
children: /* @__PURE__ */ jsx8(Spline, {
|
|
2522
2012
|
className: "[stroke-dasharray:3_3]"
|
|
2523
2013
|
})
|
|
2524
2014
|
})
|
|
2525
2015
|
]
|
|
2526
2016
|
}) : null,
|
|
2527
|
-
arrow?.type === "arrow" ? /* @__PURE__ */
|
|
2017
|
+
arrow?.type === "arrow" ? /* @__PURE__ */ jsx8(LabelField, {
|
|
2528
2018
|
value: arrow.label ?? "",
|
|
2529
2019
|
placeholder: messages.label_,
|
|
2530
2020
|
onCommit: (label) => onStyle({ label })
|
|
2531
2021
|
}, arrow.id) : null,
|
|
2532
|
-
/* @__PURE__ */
|
|
2533
|
-
/* @__PURE__ */
|
|
2022
|
+
/* @__PURE__ */ jsx8(Divider, {}),
|
|
2023
|
+
/* @__PURE__ */ jsx8(Tool, {
|
|
2534
2024
|
label: messages.duplicate,
|
|
2535
2025
|
onClick: onDuplicate,
|
|
2536
|
-
children: /* @__PURE__ */
|
|
2026
|
+
children: /* @__PURE__ */ jsx8(Copy, {})
|
|
2537
2027
|
}),
|
|
2538
|
-
/* @__PURE__ */
|
|
2028
|
+
/* @__PURE__ */ jsx8(Tool, {
|
|
2539
2029
|
label: messages.delete,
|
|
2540
2030
|
onClick: onDelete,
|
|
2541
|
-
children: /* @__PURE__ */
|
|
2031
|
+
children: /* @__PURE__ */ jsx8(Trash22, {})
|
|
2542
2032
|
})
|
|
2543
2033
|
]
|
|
2544
2034
|
}) : null
|
|
@@ -2560,9 +2050,9 @@ function LabelField({
|
|
|
2560
2050
|
placeholder,
|
|
2561
2051
|
onCommit
|
|
2562
2052
|
}) {
|
|
2563
|
-
const [text, setText] =
|
|
2053
|
+
const [text, setText] = useState5(value);
|
|
2564
2054
|
useEffect3(() => setText(value), [value]);
|
|
2565
|
-
return /* @__PURE__ */
|
|
2055
|
+
return /* @__PURE__ */ jsx8("input", {
|
|
2566
2056
|
value: text,
|
|
2567
2057
|
"aria-label": placeholder,
|
|
2568
2058
|
placeholder,
|
|
@@ -2583,7 +2073,7 @@ function Tool({
|
|
|
2583
2073
|
onClick,
|
|
2584
2074
|
children
|
|
2585
2075
|
}) {
|
|
2586
|
-
return /* @__PURE__ */
|
|
2076
|
+
return /* @__PURE__ */ jsx8("button", {
|
|
2587
2077
|
type: "button",
|
|
2588
2078
|
"aria-label": label,
|
|
2589
2079
|
title: label,
|
|
@@ -2593,7 +2083,7 @@ function Tool({
|
|
|
2593
2083
|
});
|
|
2594
2084
|
}
|
|
2595
2085
|
function Segments({ label, children }) {
|
|
2596
|
-
return /* @__PURE__ */
|
|
2086
|
+
return /* @__PURE__ */ jsx8("div", {
|
|
2597
2087
|
role: "group",
|
|
2598
2088
|
"aria-label": label,
|
|
2599
2089
|
className: "flex items-center rounded-lg bg-muted/60 p-0.5",
|
|
@@ -2606,25 +2096,25 @@ function Segment({
|
|
|
2606
2096
|
onClick,
|
|
2607
2097
|
children
|
|
2608
2098
|
}) {
|
|
2609
|
-
return /* @__PURE__ */
|
|
2099
|
+
return /* @__PURE__ */ jsx8("button", {
|
|
2610
2100
|
type: "button",
|
|
2611
2101
|
"aria-label": label,
|
|
2612
2102
|
title: label,
|
|
2613
2103
|
"aria-pressed": pressed,
|
|
2614
2104
|
onClick,
|
|
2615
|
-
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"),
|
|
2616
2106
|
children
|
|
2617
2107
|
});
|
|
2618
2108
|
}
|
|
2619
2109
|
function Divider() {
|
|
2620
|
-
return /* @__PURE__ */
|
|
2110
|
+
return /* @__PURE__ */ jsx8("span", {
|
|
2621
2111
|
"aria-hidden": "true",
|
|
2622
2112
|
className: "mx-1 h-5 w-px bg-border"
|
|
2623
2113
|
});
|
|
2624
2114
|
}
|
|
2625
2115
|
|
|
2626
2116
|
// src/artifacts/renderers/canvas/edit-mode.tsx
|
|
2627
|
-
import { jsx as
|
|
2117
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
2628
2118
|
var DRAG_SHARE_MS = 50;
|
|
2629
2119
|
var GRID = 8;
|
|
2630
2120
|
var NEW_SIZES = {
|
|
@@ -2636,17 +2126,17 @@ var NEW_SIZES = {
|
|
|
2636
2126
|
function useBoardEditing(canvas, edit, onOpenBoard) {
|
|
2637
2127
|
const messages = useArtifactMessages().canvas.toolbar;
|
|
2638
2128
|
const store = useStoreApi3();
|
|
2639
|
-
const graph =
|
|
2129
|
+
const graph = useMemo2(() => canvasGraph(canvas), [canvas]);
|
|
2640
2130
|
const read = useReadGraph(graph, store);
|
|
2641
2131
|
const editing = !!edit;
|
|
2642
|
-
const [nodes, setNodes] =
|
|
2643
|
-
const [edges, setEdges] =
|
|
2644
|
-
const [madeFrom] =
|
|
2132
|
+
const [nodes, setNodes] = useState6(graph.nodes);
|
|
2133
|
+
const [edges, setEdges] = useState6(graph.edges);
|
|
2134
|
+
const [madeFrom] = useState6(() => new WeakMap);
|
|
2645
2135
|
const selected = useRef5(new Set);
|
|
2646
|
-
const [selection, setSelection] =
|
|
2647
|
-
const [typing, setTyping] =
|
|
2136
|
+
const [selection, setSelection] = useState6(new Set);
|
|
2137
|
+
const [typing, setTyping] = useState6(null);
|
|
2648
2138
|
const root = useRef5(null);
|
|
2649
|
-
const [drawnFrom, setDrawnFrom] =
|
|
2139
|
+
const [drawnFrom, setDrawnFrom] = useState6({ graph: null, editing: false });
|
|
2650
2140
|
if (drawnFrom.graph !== graph || drawnFrom.editing !== editing) {
|
|
2651
2141
|
if (editing || drawnFrom.editing)
|
|
2652
2142
|
setDrawnFrom({ graph, editing });
|
|
@@ -2695,7 +2185,7 @@ function useBoardEditing(canvas, edit, onOpenBoard) {
|
|
|
2695
2185
|
setTyping(null);
|
|
2696
2186
|
}
|
|
2697
2187
|
}, [editing]);
|
|
2698
|
-
const select =
|
|
2188
|
+
const select = useCallback2((ids) => {
|
|
2699
2189
|
const chosen = new Set(ids);
|
|
2700
2190
|
selected.current = chosen;
|
|
2701
2191
|
setSelection(chosen);
|
|
@@ -2715,14 +2205,14 @@ function useBoardEditing(canvas, edit, onOpenBoard) {
|
|
|
2715
2205
|
selected.current = next;
|
|
2716
2206
|
setSelection(next);
|
|
2717
2207
|
};
|
|
2718
|
-
const focusBoard =
|
|
2208
|
+
const focusBoard = useCallback2(() => root.current?.focus({ preventScroll: true }), []);
|
|
2719
2209
|
const share = edit?.live?.select;
|
|
2720
2210
|
useEffect4(() => {
|
|
2721
2211
|
share?.([...selection]);
|
|
2722
2212
|
}, [share, selection]);
|
|
2723
2213
|
useEffect4(() => () => share?.([]), [share]);
|
|
2724
2214
|
const dragShared = useRef5(0);
|
|
2725
|
-
const items =
|
|
2215
|
+
const items = useMemo2(() => edit ? {
|
|
2726
2216
|
typing,
|
|
2727
2217
|
startTyping: setTyping,
|
|
2728
2218
|
commitText: (id, text) => {
|
|
@@ -2835,7 +2325,7 @@ function useBoardEditing(canvas, edit, onOpenBoard) {
|
|
|
2835
2325
|
event.stopPropagation();
|
|
2836
2326
|
}
|
|
2837
2327
|
};
|
|
2838
|
-
const toolbar = /* @__PURE__ */
|
|
2328
|
+
const toolbar = /* @__PURE__ */ jsx9(CanvasToolbar, {
|
|
2839
2329
|
selection: chosenItems,
|
|
2840
2330
|
onAdd: add,
|
|
2841
2331
|
onStyle: (style) => edit.apply(styleItems(selection, style)),
|
|
@@ -2901,7 +2391,7 @@ function sameItems(left, right) {
|
|
|
2901
2391
|
return left.length === right.length && left.every((item, index) => item === right[index]);
|
|
2902
2392
|
}
|
|
2903
2393
|
function useReadGraph(graph, store) {
|
|
2904
|
-
const [measuredFrom] =
|
|
2394
|
+
const [measuredFrom] = useState6(() => new WeakMap);
|
|
2905
2395
|
const last = useRef5(null);
|
|
2906
2396
|
const { nodeLookup } = store.getState();
|
|
2907
2397
|
const measured = graph.nodes.map((node) => {
|
|
@@ -2922,1148 +2412,21 @@ function useReadGraph(graph, store) {
|
|
|
2922
2412
|
}
|
|
2923
2413
|
|
|
2924
2414
|
// src/artifacts/renderers/canvas/focus.tsx
|
|
2925
|
-
import { cn as
|
|
2415
|
+
import { cn as cn10 } from "@sixb/ui/lib/utils";
|
|
2926
2416
|
import { ArrowLeft, ChevronLeft, ChevronRight } from "lucide-react";
|
|
2927
|
-
import { useCallback as
|
|
2417
|
+
import { useCallback as useCallback6, useEffect as useEffect8, useMemo as useMemo4, useState as useState10 } from "react";
|
|
2928
2418
|
|
|
2929
|
-
// src/artifacts/renderers/canvas/
|
|
2930
|
-
import {
|
|
2931
|
-
import {
|
|
2932
|
-
ARTIFACT_LIMITS as ARTIFACT_LIMITS3,
|
|
2933
|
-
parseFrameEvent as parseFrameEvent2
|
|
2934
|
-
} from "@sixb/core/artifacts";
|
|
2935
|
-
import {
|
|
2936
|
-
boardFilePath,
|
|
2937
|
-
boardFramePatches,
|
|
2938
|
-
mergeBoardText,
|
|
2939
|
-
setBoardImage,
|
|
2940
|
-
setBoardStyle
|
|
2941
|
-
} from "@sixb/core/artifacts/live";
|
|
2942
|
-
import { Popover, PopoverContent, PopoverTrigger } from "@sixb/ui/components";
|
|
2943
|
-
import { useLocale as useLocale2 } from "@sixb/ui/lib/i18n";
|
|
2944
|
-
import { cn as cn11 } from "@sixb/ui/lib/utils";
|
|
2945
|
-
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";
|
|
2946
2421
|
import {
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
useMemo as useMemo5,
|
|
2952
|
-
useRef as useRef7,
|
|
2953
|
-
useState as useState9
|
|
2954
|
-
} from "react";
|
|
2955
|
-
|
|
2956
|
-
// src/artifacts/renderers/canvas/board-properties.tsx
|
|
2957
|
-
import { cn as cn10 } from "@sixb/ui/lib/utils";
|
|
2958
|
-
import {
|
|
2959
|
-
AlignCenter,
|
|
2960
|
-
AlignLeft,
|
|
2961
|
-
AlignRight,
|
|
2962
|
-
ImageIcon,
|
|
2963
|
-
ImageUp,
|
|
2964
|
-
LoaderCircle as LoaderCircle2,
|
|
2965
|
-
RotateCcw as RotateCcw2
|
|
2966
|
-
} from "lucide-react";
|
|
2967
|
-
import { useEffect as useEffect5, useId as useId2, useRef as useRef6, useState as useState8 } from "react";
|
|
2968
|
-
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2969
|
-
var SWATCHES = [
|
|
2970
|
-
"#0f172a",
|
|
2971
|
-
"#475569",
|
|
2972
|
-
"#ffffff",
|
|
2973
|
-
"#2563eb",
|
|
2974
|
-
"#7c3aed",
|
|
2975
|
-
"#db2777",
|
|
2976
|
-
"#dc2626",
|
|
2977
|
-
"#ea580c",
|
|
2978
|
-
"#ca8a04",
|
|
2979
|
-
"#16a34a",
|
|
2980
|
-
"#0d9488"
|
|
2981
|
-
];
|
|
2982
|
-
var WEIGHTS = ["400", "500", "600", "700"];
|
|
2983
|
-
var ALIGNS = [
|
|
2984
|
-
{ value: "left", icon: AlignLeft },
|
|
2985
|
-
{ value: "center", icon: AlignCenter },
|
|
2986
|
-
{ value: "right", icon: AlignRight }
|
|
2987
|
-
];
|
|
2988
|
-
function StylePanel({
|
|
2989
|
-
style,
|
|
2990
|
-
words,
|
|
2991
|
-
onChange
|
|
2992
|
-
}) {
|
|
2993
|
-
const messages = useArtifactMessages().canvas.edit;
|
|
2994
|
-
const background = style.background ?? style["background-color"];
|
|
2995
|
-
const setBackground = (value) => onChange(style.background !== undefined ? { background: value } : { "background-color": null, background: value });
|
|
2996
|
-
return /* @__PURE__ */ jsxs10("div", {
|
|
2997
|
-
className: "flex w-[17rem] flex-col gap-3.5",
|
|
2998
|
-
"data-board-tools": "",
|
|
2999
|
-
children: [
|
|
3000
|
-
/* @__PURE__ */ jsxs10(Section, {
|
|
3001
|
-
title: messages.colors,
|
|
3002
|
-
children: [
|
|
3003
|
-
/* @__PURE__ */ jsx12(ColorField, {
|
|
3004
|
-
label: messages.textColor,
|
|
3005
|
-
value: style.color,
|
|
3006
|
-
onChange: (value) => onChange({ color: value })
|
|
3007
|
-
}),
|
|
3008
|
-
/* @__PURE__ */ jsx12(ColorField, {
|
|
3009
|
-
label: messages.background,
|
|
3010
|
-
value: background,
|
|
3011
|
-
onChange: setBackground
|
|
3012
|
-
})
|
|
3013
|
-
]
|
|
3014
|
-
}),
|
|
3015
|
-
words ? /* @__PURE__ */ jsxs10(Section, {
|
|
3016
|
-
title: messages.typography,
|
|
3017
|
-
children: [
|
|
3018
|
-
/* @__PURE__ */ jsx12(LengthField, {
|
|
3019
|
-
label: messages.fontSize,
|
|
3020
|
-
value: style["font-size"],
|
|
3021
|
-
onChange: (value) => onChange({ "font-size": value })
|
|
3022
|
-
}),
|
|
3023
|
-
/* @__PURE__ */ jsx12(Row, {
|
|
3024
|
-
label: messages.weight,
|
|
3025
|
-
children: /* @__PURE__ */ jsx12(Segments2, {
|
|
3026
|
-
label: messages.weight,
|
|
3027
|
-
children: WEIGHTS.map((weight) => /* @__PURE__ */ jsx12(Segment2, {
|
|
3028
|
-
label: messages.weights[weight],
|
|
3029
|
-
pressed: normalWeight(style["font-weight"]) === weight,
|
|
3030
|
-
onClick: () => onChange({
|
|
3031
|
-
"font-weight": normalWeight(style["font-weight"]) === weight ? null : weight
|
|
3032
|
-
}),
|
|
3033
|
-
children: /* @__PURE__ */ jsx12("span", {
|
|
3034
|
-
className: "text-xs",
|
|
3035
|
-
style: { fontWeight: Number(weight) },
|
|
3036
|
-
children: "Aa"
|
|
3037
|
-
})
|
|
3038
|
-
}, weight))
|
|
3039
|
-
})
|
|
3040
|
-
}),
|
|
3041
|
-
/* @__PURE__ */ jsx12(Row, {
|
|
3042
|
-
label: messages.align,
|
|
3043
|
-
children: /* @__PURE__ */ jsx12(Segments2, {
|
|
3044
|
-
label: messages.align,
|
|
3045
|
-
children: ALIGNS.map(({ value, icon: Icon }) => /* @__PURE__ */ jsx12(Segment2, {
|
|
3046
|
-
label: messages.aligns[value],
|
|
3047
|
-
pressed: style["text-align"] === value,
|
|
3048
|
-
onClick: () => onChange({ "text-align": style["text-align"] === value ? null : value }),
|
|
3049
|
-
children: /* @__PURE__ */ jsx12(Icon, {})
|
|
3050
|
-
}, value))
|
|
3051
|
-
})
|
|
3052
|
-
})
|
|
3053
|
-
]
|
|
3054
|
-
}) : null,
|
|
3055
|
-
/* @__PURE__ */ jsxs10(Section, {
|
|
3056
|
-
title: messages.layout,
|
|
3057
|
-
children: [
|
|
3058
|
-
/* @__PURE__ */ jsx12(LengthField, {
|
|
3059
|
-
label: messages.padding,
|
|
3060
|
-
value: style.padding,
|
|
3061
|
-
onChange: (value) => onChange({ padding: value })
|
|
3062
|
-
}),
|
|
3063
|
-
/* @__PURE__ */ jsx12(LengthField, {
|
|
3064
|
-
label: messages.gap,
|
|
3065
|
-
value: style.gap,
|
|
3066
|
-
onChange: (value) => onChange({ gap: value })
|
|
3067
|
-
}),
|
|
3068
|
-
/* @__PURE__ */ jsx12(LengthField, {
|
|
3069
|
-
label: messages.radius,
|
|
3070
|
-
value: style["border-radius"],
|
|
3071
|
-
onChange: (value) => onChange({ "border-radius": value })
|
|
3072
|
-
})
|
|
3073
|
-
]
|
|
3074
|
-
})
|
|
3075
|
-
]
|
|
3076
|
-
});
|
|
3077
|
-
}
|
|
3078
|
-
function normalWeight(weight) {
|
|
3079
|
-
if (weight === "normal")
|
|
3080
|
-
return "400";
|
|
3081
|
-
if (weight === "bold")
|
|
3082
|
-
return "700";
|
|
3083
|
-
return weight;
|
|
3084
|
-
}
|
|
3085
|
-
function Section({ title, children }) {
|
|
3086
|
-
return /* @__PURE__ */ jsxs10("section", {
|
|
3087
|
-
className: "flex flex-col gap-2",
|
|
3088
|
-
children: [
|
|
3089
|
-
/* @__PURE__ */ jsx12("h3", {
|
|
3090
|
-
className: "m-0 text-[11px] font-semibold tracking-wide text-muted-foreground uppercase",
|
|
3091
|
-
children: title
|
|
3092
|
-
}),
|
|
3093
|
-
children
|
|
3094
|
-
]
|
|
3095
|
-
});
|
|
3096
|
-
}
|
|
3097
|
-
function Row({ label, children }) {
|
|
3098
|
-
return /* @__PURE__ */ jsxs10("div", {
|
|
3099
|
-
className: "flex items-center justify-between gap-3",
|
|
3100
|
-
children: [
|
|
3101
|
-
/* @__PURE__ */ jsx12("span", {
|
|
3102
|
-
className: "text-xs text-foreground/80",
|
|
3103
|
-
children: label
|
|
3104
|
-
}),
|
|
3105
|
-
children
|
|
3106
|
-
]
|
|
3107
|
-
});
|
|
3108
|
-
}
|
|
3109
|
-
function ColorField({
|
|
3110
|
-
label,
|
|
3111
|
-
value,
|
|
3112
|
-
onChange
|
|
3113
|
-
}) {
|
|
3114
|
-
const messages = useArtifactMessages().canvas.edit;
|
|
3115
|
-
return /* @__PURE__ */ jsxs10("div", {
|
|
3116
|
-
className: "flex flex-col gap-1.5",
|
|
3117
|
-
children: [
|
|
3118
|
-
/* @__PURE__ */ jsx12(ValueField, {
|
|
3119
|
-
label,
|
|
3120
|
-
value,
|
|
3121
|
-
onChange,
|
|
3122
|
-
swatch: value
|
|
3123
|
-
}),
|
|
3124
|
-
/* @__PURE__ */ jsx12("div", {
|
|
3125
|
-
className: "flex flex-wrap gap-1",
|
|
3126
|
-
role: "group",
|
|
3127
|
-
"aria-label": label,
|
|
3128
|
-
children: SWATCHES.map((color) => /* @__PURE__ */ jsx12("button", {
|
|
3129
|
-
type: "button",
|
|
3130
|
-
"aria-label": messages.swatch(color),
|
|
3131
|
-
title: color,
|
|
3132
|
-
"aria-pressed": value?.toLowerCase() === color,
|
|
3133
|
-
onClick: () => onChange(color),
|
|
3134
|
-
className: "flex size-5 items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
3135
|
-
children: /* @__PURE__ */ jsx12("span", {
|
|
3136
|
-
"aria-hidden": "true",
|
|
3137
|
-
className: cn10("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"),
|
|
3138
|
-
style: { background: color }
|
|
3139
|
-
})
|
|
3140
|
-
}, color))
|
|
3141
|
-
})
|
|
3142
|
-
]
|
|
3143
|
-
});
|
|
3144
|
-
}
|
|
3145
|
-
function LengthField({
|
|
3146
|
-
label,
|
|
3147
|
-
value,
|
|
3148
|
-
onChange
|
|
3149
|
-
}) {
|
|
3150
|
-
return /* @__PURE__ */ jsx12(ValueField, {
|
|
3151
|
-
label,
|
|
3152
|
-
value,
|
|
3153
|
-
onChange: (next) => onChange(next !== null && /^\d+(\.\d+)?$/.test(next) ? `${next}px` : next)
|
|
3154
|
-
});
|
|
3155
|
-
}
|
|
3156
|
-
function ValueField({
|
|
3157
|
-
label,
|
|
3158
|
-
value,
|
|
3159
|
-
onChange,
|
|
3160
|
-
swatch
|
|
3161
|
-
}) {
|
|
3162
|
-
const messages = useArtifactMessages().canvas.edit;
|
|
3163
|
-
const id = useId2();
|
|
3164
|
-
const [text, setText] = useState8(value ?? "");
|
|
3165
|
-
const [invalid, setInvalid] = useState8(false);
|
|
3166
|
-
useEffect5(() => {
|
|
3167
|
-
setText(value ?? "");
|
|
3168
|
-
setInvalid(false);
|
|
3169
|
-
}, [value]);
|
|
3170
|
-
const commit = () => {
|
|
3171
|
-
const next = text.trim();
|
|
3172
|
-
if (next === (value ?? ""))
|
|
3173
|
-
return;
|
|
3174
|
-
setInvalid(!onChange(next === "" ? null : next));
|
|
3175
|
-
};
|
|
3176
|
-
return /* @__PURE__ */ jsxs10("div", {
|
|
3177
|
-
className: "flex items-center justify-between gap-3",
|
|
3178
|
-
children: [
|
|
3179
|
-
/* @__PURE__ */ jsx12("label", {
|
|
3180
|
-
htmlFor: id,
|
|
3181
|
-
className: "text-xs text-foreground/80",
|
|
3182
|
-
children: label
|
|
3183
|
-
}),
|
|
3184
|
-
/* @__PURE__ */ jsxs10("div", {
|
|
3185
|
-
className: "flex items-center gap-1",
|
|
3186
|
-
children: [
|
|
3187
|
-
/* @__PURE__ */ jsxs10("div", {
|
|
3188
|
-
className: cn10("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"),
|
|
3189
|
-
children: [
|
|
3190
|
-
swatch !== undefined ? /* @__PURE__ */ jsx12("span", {
|
|
3191
|
-
"aria-hidden": "true",
|
|
3192
|
-
className: "size-3.5 shrink-0 rounded-[4px] ring-1 ring-[color-mix(in_oklab,var(--foreground)_16%,transparent)]",
|
|
3193
|
-
style: { background: swatch || "transparent" }
|
|
3194
|
-
}) : null,
|
|
3195
|
-
/* @__PURE__ */ jsx12("input", {
|
|
3196
|
-
id,
|
|
3197
|
-
value: text,
|
|
3198
|
-
placeholder: messages.inherited,
|
|
3199
|
-
"aria-invalid": invalid || undefined,
|
|
3200
|
-
spellCheck: false,
|
|
3201
|
-
onChange: (event) => setText(event.target.value),
|
|
3202
|
-
onBlur: commit,
|
|
3203
|
-
onKeyDown: (event) => {
|
|
3204
|
-
event.stopPropagation();
|
|
3205
|
-
if (event.key === "Enter")
|
|
3206
|
-
commit();
|
|
3207
|
-
},
|
|
3208
|
-
className: "h-full min-w-0 flex-1 bg-transparent font-mono text-[11px] outline-none placeholder:font-sans placeholder:text-muted-foreground/70"
|
|
3209
|
-
})
|
|
3210
|
-
]
|
|
3211
|
-
}),
|
|
3212
|
-
/* @__PURE__ */ jsx12("button", {
|
|
3213
|
-
type: "button",
|
|
3214
|
-
"aria-label": messages.reset(label),
|
|
3215
|
-
title: messages.reset(label),
|
|
3216
|
-
disabled: value === undefined,
|
|
3217
|
-
onClick: () => onChange(null),
|
|
3218
|
-
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",
|
|
3219
|
-
children: /* @__PURE__ */ jsx12(RotateCcw2, {})
|
|
3220
|
-
})
|
|
3221
|
-
]
|
|
3222
|
-
}),
|
|
3223
|
-
invalid ? /* @__PURE__ */ jsx12("span", {
|
|
3224
|
-
role: "alert",
|
|
3225
|
-
className: "sr-only",
|
|
3226
|
-
children: messages.invalid
|
|
3227
|
-
}) : null
|
|
3228
|
-
]
|
|
3229
|
-
});
|
|
3230
|
-
}
|
|
3231
|
-
function Segments2({ label, children }) {
|
|
3232
|
-
return /* @__PURE__ */ jsx12("div", {
|
|
3233
|
-
role: "group",
|
|
3234
|
-
"aria-label": label,
|
|
3235
|
-
className: "flex items-center rounded-lg bg-muted/70 p-0.5",
|
|
3236
|
-
children
|
|
3237
|
-
});
|
|
3238
|
-
}
|
|
3239
|
-
function Segment2({
|
|
3240
|
-
label,
|
|
3241
|
-
pressed,
|
|
3242
|
-
onClick,
|
|
3243
|
-
children
|
|
3244
|
-
}) {
|
|
3245
|
-
return /* @__PURE__ */ jsx12("button", {
|
|
3246
|
-
type: "button",
|
|
3247
|
-
"aria-label": label,
|
|
3248
|
-
title: label,
|
|
3249
|
-
"aria-pressed": pressed,
|
|
3250
|
-
onClick,
|
|
3251
|
-
className: cn10("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"),
|
|
3252
|
-
children
|
|
3253
|
-
});
|
|
3254
|
-
}
|
|
3255
|
-
function ImagePanel({
|
|
3256
|
-
current,
|
|
3257
|
-
alt,
|
|
3258
|
-
images,
|
|
3259
|
-
uploading,
|
|
3260
|
-
failure,
|
|
3261
|
-
onUpload,
|
|
3262
|
-
onPick,
|
|
3263
|
-
onAlt
|
|
3264
|
-
}) {
|
|
3265
|
-
const messages = useArtifactMessages().canvas.edit;
|
|
3266
|
-
const input = useRef6(null);
|
|
3267
|
-
const altId = useId2();
|
|
3268
|
-
const description = useRef6(null);
|
|
3269
|
-
const [text, setText] = useState8(alt);
|
|
3270
|
-
useEffect5(() => setText(alt), [alt]);
|
|
3271
|
-
const others = images.filter((image) => image.path !== current);
|
|
3272
|
-
const replaced = (shown) => {
|
|
3273
|
-
if (shown)
|
|
3274
|
-
description.current?.focus();
|
|
3275
|
-
};
|
|
3276
|
-
return /* @__PURE__ */ jsxs10("div", {
|
|
3277
|
-
className: "flex w-[17rem] flex-col gap-3",
|
|
3278
|
-
"data-board-tools": "",
|
|
3279
|
-
children: [
|
|
3280
|
-
/* @__PURE__ */ jsx12("input", {
|
|
3281
|
-
ref: input,
|
|
3282
|
-
type: "file",
|
|
3283
|
-
accept: "image/*",
|
|
3284
|
-
className: "sr-only",
|
|
3285
|
-
tabIndex: -1,
|
|
3286
|
-
"aria-hidden": "true",
|
|
3287
|
-
onChange: (event) => {
|
|
3288
|
-
const file = event.target.files?.[0];
|
|
3289
|
-
event.target.value = "";
|
|
3290
|
-
if (file)
|
|
3291
|
-
onUpload(file).then(replaced);
|
|
3292
|
-
}
|
|
3293
|
-
}),
|
|
3294
|
-
/* @__PURE__ */ jsxs10("button", {
|
|
3295
|
-
type: "button",
|
|
3296
|
-
disabled: uploading,
|
|
3297
|
-
onClick: () => input.current?.click(),
|
|
3298
|
-
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",
|
|
3299
|
-
children: [
|
|
3300
|
-
uploading ? /* @__PURE__ */ jsx12(LoaderCircle2, {
|
|
3301
|
-
className: "animate-spin motion-reduce:animate-none",
|
|
3302
|
-
"aria-hidden": "true"
|
|
3303
|
-
}) : /* @__PURE__ */ jsx12(ImageUp, {
|
|
3304
|
-
"aria-hidden": "true"
|
|
3305
|
-
}),
|
|
3306
|
-
uploading ? messages.uploading : messages.upload
|
|
3307
|
-
]
|
|
3308
|
-
}),
|
|
3309
|
-
failure ? /* @__PURE__ */ jsx12("p", {
|
|
3310
|
-
role: "alert",
|
|
3311
|
-
className: "m-0 text-xs text-destructive",
|
|
3312
|
-
children: failure
|
|
3313
|
-
}) : null,
|
|
3314
|
-
/* @__PURE__ */ jsxs10("section", {
|
|
3315
|
-
className: "flex flex-col gap-2",
|
|
3316
|
-
children: [
|
|
3317
|
-
/* @__PURE__ */ jsx12("h3", {
|
|
3318
|
-
className: "m-0 text-[11px] font-semibold tracking-wide text-muted-foreground uppercase",
|
|
3319
|
-
children: messages.fromCanvas
|
|
3320
|
-
}),
|
|
3321
|
-
others.length > 0 ? /* @__PURE__ */ jsx12("div", {
|
|
3322
|
-
className: "grid max-h-40 grid-cols-4 gap-1.5 overflow-y-auto p-0.5",
|
|
3323
|
-
children: others.map((image) => /* @__PURE__ */ jsx12("button", {
|
|
3324
|
-
type: "button",
|
|
3325
|
-
title: image.path,
|
|
3326
|
-
"aria-label": image.path,
|
|
3327
|
-
onClick: () => replaced(onPick(image.path)),
|
|
3328
|
-
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",
|
|
3329
|
-
children: image.url ? /* @__PURE__ */ jsx12("img", {
|
|
3330
|
-
src: image.url,
|
|
3331
|
-
alt: "",
|
|
3332
|
-
loading: "lazy",
|
|
3333
|
-
className: "size-full object-cover",
|
|
3334
|
-
draggable: false
|
|
3335
|
-
}) : /* @__PURE__ */ jsx12(ImageIcon, {
|
|
3336
|
-
className: "size-4 text-muted-foreground",
|
|
3337
|
-
"aria-hidden": "true"
|
|
3338
|
-
})
|
|
3339
|
-
}, image.path))
|
|
3340
|
-
}) : /* @__PURE__ */ jsx12("p", {
|
|
3341
|
-
className: "m-0 text-xs text-muted-foreground",
|
|
3342
|
-
children: messages.noImages
|
|
3343
|
-
})
|
|
3344
|
-
]
|
|
3345
|
-
}),
|
|
3346
|
-
/* @__PURE__ */ jsxs10("div", {
|
|
3347
|
-
className: "flex flex-col gap-1.5",
|
|
3348
|
-
children: [
|
|
3349
|
-
/* @__PURE__ */ jsx12("label", {
|
|
3350
|
-
htmlFor: altId,
|
|
3351
|
-
className: "text-xs text-foreground/80",
|
|
3352
|
-
children: messages.description
|
|
3353
|
-
}),
|
|
3354
|
-
/* @__PURE__ */ jsx12("input", {
|
|
3355
|
-
ref: description,
|
|
3356
|
-
id: altId,
|
|
3357
|
-
value: text,
|
|
3358
|
-
placeholder: messages.descriptionPlaceholder,
|
|
3359
|
-
onChange: (event) => setText(event.target.value),
|
|
3360
|
-
onBlur: () => {
|
|
3361
|
-
if (text !== alt)
|
|
3362
|
-
onAlt(text);
|
|
3363
|
-
},
|
|
3364
|
-
onKeyDown: (event) => {
|
|
3365
|
-
event.stopPropagation();
|
|
3366
|
-
if (event.key === "Enter" && text !== alt)
|
|
3367
|
-
onAlt(text);
|
|
3368
|
-
},
|
|
3369
|
-
className: "h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
3370
|
-
})
|
|
3371
|
-
]
|
|
3372
|
-
})
|
|
3373
|
-
]
|
|
3374
|
-
});
|
|
3375
|
-
}
|
|
3376
|
-
|
|
3377
|
-
// src/artifacts/renderers/canvas/board-source.ts
|
|
3378
|
-
import { boardElement } from "@sixb/core/artifacts/live";
|
|
3379
|
-
function boardAttribute(source, address, name) {
|
|
3380
|
-
const element = boardElement(source, address);
|
|
3381
|
-
if (!element)
|
|
3382
|
-
return null;
|
|
3383
|
-
const tag = startTag(source.slice(element.start, element.end));
|
|
3384
|
-
const pattern = new RegExp(`\\s${name}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s"'=<>\`]+))`, "i");
|
|
3385
|
-
const match = pattern.exec(tag);
|
|
3386
|
-
if (!match)
|
|
3387
|
-
return null;
|
|
3388
|
-
return decodeAttribute(match[2] ?? match[3] ?? match[4] ?? "");
|
|
3389
|
-
}
|
|
3390
|
-
function boardInlineStyle(source, address) {
|
|
3391
|
-
const style = boardAttribute(source, address, "style") ?? "";
|
|
3392
|
-
const declarations = {};
|
|
3393
|
-
for (const declaration of style.split(";")) {
|
|
3394
|
-
const colon = declaration.indexOf(":");
|
|
3395
|
-
if (colon <= 0)
|
|
3396
|
-
continue;
|
|
3397
|
-
const property = declaration.slice(0, colon).trim().toLowerCase();
|
|
3398
|
-
const value = declaration.slice(colon + 1).trim();
|
|
3399
|
-
if (property && value)
|
|
3400
|
-
declarations[property] = value;
|
|
3401
|
-
}
|
|
3402
|
-
return declarations;
|
|
3403
|
-
}
|
|
3404
|
-
function startTag(html) {
|
|
3405
|
-
let quote = null;
|
|
3406
|
-
for (let index = 0;index < html.length; index += 1) {
|
|
3407
|
-
const char = html[index];
|
|
3408
|
-
if (quote) {
|
|
3409
|
-
if (char === quote)
|
|
3410
|
-
quote = null;
|
|
3411
|
-
} else if (char === '"' || char === "'")
|
|
3412
|
-
quote = char;
|
|
3413
|
-
else if (char === ">")
|
|
3414
|
-
return html.slice(0, index);
|
|
3415
|
-
}
|
|
3416
|
-
return html;
|
|
3417
|
-
}
|
|
3418
|
-
function decodeAttribute(value) {
|
|
3419
|
-
return value.replace(/"/g, '"').replace(/'|'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
3420
|
-
}
|
|
3421
|
-
function boardReferencePath(board, reference) {
|
|
3422
|
-
if (/^[a-z][a-z0-9+.-]*:|^\/\/|^\/|^#/i.test(reference))
|
|
3423
|
-
return null;
|
|
3424
|
-
const parts = board.split("/").slice(0, -1);
|
|
3425
|
-
for (const part of reference.split(/[?#]/)[0]?.split("/") ?? []) {
|
|
3426
|
-
if (part === "" || part === ".")
|
|
3427
|
-
continue;
|
|
3428
|
-
if (part === "..") {
|
|
3429
|
-
if (parts.length === 0)
|
|
3430
|
-
return null;
|
|
3431
|
-
parts.pop();
|
|
3432
|
-
continue;
|
|
3433
|
-
}
|
|
3434
|
-
try {
|
|
3435
|
-
parts.push(decodeURIComponent(part));
|
|
3436
|
-
} catch {
|
|
3437
|
-
return null;
|
|
3438
|
-
}
|
|
3439
|
-
}
|
|
3440
|
-
return parts.join("/");
|
|
3441
|
-
}
|
|
3442
|
-
function showablePatches(patches, board, holds, previews) {
|
|
3443
|
-
let waiting = false;
|
|
3444
|
-
const shown = [];
|
|
3445
|
-
for (const patch of patches) {
|
|
3446
|
-
const src = patch.attributes?.src;
|
|
3447
|
-
const path = src === undefined ? null : boardReferencePath(board, src);
|
|
3448
|
-
if (src === undefined || path === null || holds(path)) {
|
|
3449
|
-
shown.push(patch);
|
|
3450
|
-
continue;
|
|
3451
|
-
}
|
|
3452
|
-
const preview = previews.get(path);
|
|
3453
|
-
if (preview && patch.attributes) {
|
|
3454
|
-
shown.push({ ...patch, attributes: { ...patch.attributes, src: preview } });
|
|
3455
|
-
continue;
|
|
3456
|
-
}
|
|
3457
|
-
waiting = true;
|
|
3458
|
-
}
|
|
3459
|
-
return { patches: shown, waiting };
|
|
3460
|
-
}
|
|
3461
|
-
|
|
3462
|
-
// src/artifacts/renderers/canvas/board-editor.tsx
|
|
3463
|
-
import { jsx as jsx13, jsxs as jsxs11, Fragment as Fragment6 } from "react/jsx-runtime";
|
|
3464
|
-
var IMAGE_EXTENSIONS = /\.(png|jpe?g|gif|webp|avif|svg)$/i;
|
|
3465
|
-
function useBoardFrame({
|
|
3466
|
-
version,
|
|
3467
|
-
board,
|
|
3468
|
-
live
|
|
3469
|
-
}) {
|
|
3470
|
-
const source = useLiveBoardSource(live, board.file);
|
|
3471
|
-
const patching = source !== null;
|
|
3472
|
-
const [pinned, setPinned] = useState9(version);
|
|
3473
|
-
const shows = patching ? pinned : version;
|
|
3474
|
-
const stored = useFileText(patching ? versionFileSource(pinned, board.file) : null).text;
|
|
3475
|
-
const handle = useRef7(null);
|
|
3476
|
-
const [loads, setLoads] = useState9(0);
|
|
3477
|
-
const shown = useRef7(null);
|
|
3478
|
-
const previews = useRef7(new Map);
|
|
3479
|
-
const [stale, setStale] = useState9(false);
|
|
3480
|
-
const [moved, setMoved] = useState9(false);
|
|
3481
|
-
const [holding, setHolding] = useState9(false);
|
|
3482
|
-
const ready = useCallback5(() => {
|
|
3483
|
-
shown.current = null;
|
|
3484
|
-
setLoads((count) => count + 1);
|
|
3485
|
-
}, []);
|
|
3486
|
-
useEffect6(() => {
|
|
3487
|
-
if (loads === 0 || stored === undefined || source === null)
|
|
3488
|
-
return;
|
|
3489
|
-
const patches = boardFramePatches(shown.current ?? stored, source);
|
|
3490
|
-
if (patches === null) {
|
|
3491
|
-
setStale(true);
|
|
3492
|
-
setMoved(true);
|
|
3493
|
-
return;
|
|
3494
|
-
}
|
|
3495
|
-
setMoved(false);
|
|
3496
|
-
const holds = (path) => shows.files.some((file) => file.path === path);
|
|
3497
|
-
const showable = showablePatches(patches, board.file, holds, previews.current);
|
|
3498
|
-
if (showable.waiting)
|
|
3499
|
-
setStale(true);
|
|
3500
|
-
shown.current = source;
|
|
3501
|
-
if (showable.patches.length === 0)
|
|
3502
|
-
return;
|
|
3503
|
-
handle.current?.send("edit.patch", { patches: showable.patches }).catch(() => {});
|
|
3504
|
-
}, [loads, stored, source, shows, board.file]);
|
|
3505
|
-
useEffect6(() => {
|
|
3506
|
-
if (!stale || holding && !moved || version.revision <= pinned.revision)
|
|
3507
|
-
return;
|
|
3508
|
-
setStale(false);
|
|
3509
|
-
setPinned(version);
|
|
3510
|
-
}, [stale, holding, moved, version, pinned.revision]);
|
|
3511
|
-
const resync = useCallback5(() => {
|
|
3512
|
-
shown.current = null;
|
|
3513
|
-
handle.current?.send("reload", {}).catch(() => {});
|
|
3514
|
-
}, []);
|
|
3515
|
-
return {
|
|
3516
|
-
shows,
|
|
3517
|
-
source,
|
|
3518
|
-
handle,
|
|
3519
|
-
loads,
|
|
3520
|
-
ready,
|
|
3521
|
-
resync,
|
|
3522
|
-
stale,
|
|
3523
|
-
moved,
|
|
3524
|
-
previews: previews.current,
|
|
3525
|
-
hold: setHolding
|
|
3526
|
-
};
|
|
3527
|
-
}
|
|
3528
|
-
function BoardStage({
|
|
3529
|
-
version,
|
|
3530
|
-
board,
|
|
3531
|
-
size,
|
|
3532
|
-
title,
|
|
3533
|
-
scale,
|
|
3534
|
-
live,
|
|
3535
|
-
canvas,
|
|
3536
|
-
mode,
|
|
3537
|
-
pins,
|
|
3538
|
-
activePin,
|
|
3539
|
-
draft,
|
|
3540
|
-
fallback,
|
|
3541
|
-
failure,
|
|
3542
|
-
onPress,
|
|
3543
|
-
onPick,
|
|
3544
|
-
onOpenPin,
|
|
3545
|
-
onSubmitDraft,
|
|
3546
|
-
onCancelDraft,
|
|
3547
|
-
onContentHeight,
|
|
3548
|
-
onZoom
|
|
3549
|
-
}) {
|
|
3550
|
-
const messages = useArtifactMessages().canvas;
|
|
3551
|
-
const frame = useBoardFrame({ version, board, live });
|
|
3552
|
-
const editing = mode === "edit" && canvas !== null;
|
|
3553
|
-
const [selected, setSelected] = useState9(null);
|
|
3554
|
-
const [hovered, setHovered] = useState9(null);
|
|
3555
|
-
const commenting = mode === "comment";
|
|
3556
|
-
const picked = useRef7(null);
|
|
3557
|
-
picked.current = editing ? selected : null;
|
|
3558
|
-
const moved = useRef7(frame.moved);
|
|
3559
|
-
moved.current = frame.moved;
|
|
3560
|
-
const { hold } = frame;
|
|
3561
|
-
useEffect6(() => {
|
|
3562
|
-
hold(editing && selected?.kind === "text");
|
|
3563
|
-
}, [hold, editing, selected]);
|
|
3564
|
-
useEffect6(() => {
|
|
3565
|
-
if (!editing || frame.moved) {
|
|
3566
|
-
picked.current = null;
|
|
3567
|
-
setSelected(null);
|
|
3568
|
-
}
|
|
3569
|
-
}, [editing, frame.moved]);
|
|
3570
|
-
useEffect6(() => {
|
|
3571
|
-
if (!commenting || frame.moved)
|
|
3572
|
-
setHovered(null);
|
|
3573
|
-
}, [commenting, frame.moved]);
|
|
3574
|
-
useEffect6(() => {
|
|
3575
|
-
if (!draft)
|
|
3576
|
-
setHovered(null);
|
|
3577
|
-
}, [draft]);
|
|
3578
|
-
const port = useRef7(null);
|
|
3579
|
-
const onEditRef = useRef7(() => {});
|
|
3580
|
-
const onZoomRef = useRef7(onZoom);
|
|
3581
|
-
onZoomRef.current = onZoom;
|
|
3582
|
-
useEffect6(() => {
|
|
3583
|
-
if (frame.loads === 0)
|
|
3584
|
-
return;
|
|
3585
|
-
const channel = new MessageChannel;
|
|
3586
|
-
channel.port1.onmessage = (message) => {
|
|
3587
|
-
const event = parseFrameEvent2(message.data);
|
|
3588
|
-
if (event?.event === "zoom")
|
|
3589
|
-
onZoomRef.current?.(event.params);
|
|
3590
|
-
else if (event?.event.startsWith("edit."))
|
|
3591
|
-
onEditRef.current(event);
|
|
3592
|
-
};
|
|
3593
|
-
port.current = { mine: channel.port1, handed: channel.port2 };
|
|
3594
|
-
return () => channel.port1.close();
|
|
3595
|
-
}, [frame.loads]);
|
|
3596
|
-
const send = frame.handle;
|
|
3597
|
-
useEffect6(() => {
|
|
3598
|
-
if (frame.loads === 0)
|
|
3599
|
-
return;
|
|
3600
|
-
const handed = port.current?.handed;
|
|
3601
|
-
if (port.current)
|
|
3602
|
-
port.current.handed = null;
|
|
3603
|
-
send.current?.send("edit", { on: mode !== "read" && !frame.moved, typing: editing }, handed ? [handed] : []).catch(() => {});
|
|
3604
|
-
}, [frame.loads, frame.moved, mode, editing, send]);
|
|
3605
|
-
const point = useCallback5((at, rect) => {
|
|
3606
|
-
const x = at?.x ?? rect.x + rect.width;
|
|
3607
|
-
const y = at?.y ?? rect.y;
|
|
3608
|
-
return {
|
|
3609
|
-
x: Math.min(1, Math.max(0, x / size.w)),
|
|
3610
|
-
y: Math.min(1, Math.max(0, y / size.h))
|
|
3611
|
-
};
|
|
3612
|
-
}, [size.w, size.h]);
|
|
3613
|
-
const onEvent = useCallback5((event) => {
|
|
3614
|
-
if (event.event === "ready") {
|
|
3615
|
-
picked.current = null;
|
|
3616
|
-
setSelected(null);
|
|
3617
|
-
setHovered(null);
|
|
3618
|
-
frame.ready();
|
|
3619
|
-
} else if (event.event === "press") {
|
|
3620
|
-
onPress(event.params.text);
|
|
3621
|
-
} else if (event.event === "size") {
|
|
3622
|
-
onContentHeight?.(event.params.height);
|
|
3623
|
-
}
|
|
3624
|
-
}, [frame, onPress, onContentHeight]);
|
|
3625
|
-
onEditRef.current = (event) => {
|
|
3626
|
-
if (moved.current)
|
|
3627
|
-
return;
|
|
3628
|
-
switch (event.event) {
|
|
3629
|
-
case "edit.hover": {
|
|
3630
|
-
if (commenting)
|
|
3631
|
-
setHovered(event.params.target);
|
|
3632
|
-
return;
|
|
3633
|
-
}
|
|
3634
|
-
case "edit.select": {
|
|
3635
|
-
const { target, at } = event.params;
|
|
3636
|
-
if (commenting) {
|
|
3637
|
-
if (!target)
|
|
3638
|
-
return;
|
|
3639
|
-
setHovered(null);
|
|
3640
|
-
const element = target.address ?? target.within ?? undefined;
|
|
3641
|
-
onPick({
|
|
3642
|
-
...element ? { element } : {},
|
|
3643
|
-
...target.label ? { label: target.label } : {},
|
|
3644
|
-
...target.address === "body" ? { anchor: title } : {},
|
|
3645
|
-
point: point(at, target.rect),
|
|
3646
|
-
under: Math.min(1, (target.rect.y + target.rect.height) / size.h)
|
|
3647
|
-
});
|
|
3648
|
-
return;
|
|
3649
|
-
}
|
|
3650
|
-
if (!editing)
|
|
3651
|
-
return;
|
|
3652
|
-
picked.current = target;
|
|
3653
|
-
setSelected(target);
|
|
3654
|
-
return;
|
|
3655
|
-
}
|
|
3656
|
-
case "edit.text": {
|
|
3657
|
-
const chosen = picked.current;
|
|
3658
|
-
const { address, base, text } = event.params;
|
|
3659
|
-
if (!canvas || chosen?.kind !== "text" || chosen.address !== address)
|
|
3660
|
-
return;
|
|
3661
|
-
try {
|
|
3662
|
-
canvas.editBoard(board.file, (source) => mergeBoardText(source, address, base, text));
|
|
3663
|
-
} catch {
|
|
3664
|
-
picked.current = null;
|
|
3665
|
-
setSelected(null);
|
|
3666
|
-
frame.resync();
|
|
3667
|
-
}
|
|
3668
|
-
return;
|
|
3669
|
-
}
|
|
3670
|
-
default:
|
|
3671
|
-
return;
|
|
3672
|
-
}
|
|
3673
|
-
};
|
|
3674
|
-
return /* @__PURE__ */ jsxs11("div", {
|
|
3675
|
-
className: "relative size-full",
|
|
3676
|
-
children: [
|
|
3677
|
-
/* @__PURE__ */ jsx13("div", {
|
|
3678
|
-
className: "absolute inset-0 overflow-hidden rounded-[inherit]",
|
|
3679
|
-
children: /* @__PURE__ */ jsx13("div", {
|
|
3680
|
-
className: "absolute top-0 left-0 origin-top-left",
|
|
3681
|
-
style: { width: size.w, height: size.h, transform: `scale(${scale})` },
|
|
3682
|
-
children: /* @__PURE__ */ jsx13(ArtifactFrame, {
|
|
3683
|
-
version: frame.shows,
|
|
3684
|
-
entry: board.file,
|
|
3685
|
-
title: messages.boardFrame(title),
|
|
3686
|
-
className: "size-full",
|
|
3687
|
-
editable: true,
|
|
3688
|
-
handle: frame.handle,
|
|
3689
|
-
onEvent,
|
|
3690
|
-
fallback,
|
|
3691
|
-
failure
|
|
3692
|
-
}, board.id)
|
|
3693
|
-
})
|
|
3694
|
-
}),
|
|
3695
|
-
/* @__PURE__ */ jsxs11("div", {
|
|
3696
|
-
className: "pointer-events-none absolute inset-0 z-10",
|
|
3697
|
-
"data-board-overlay": "",
|
|
3698
|
-
children: [
|
|
3699
|
-
pins.map((pin, index) => {
|
|
3700
|
-
const at = pinPoint(pin, pin.point ? 0 : index);
|
|
3701
|
-
return /* @__PURE__ */ jsx13("div", {
|
|
3702
|
-
className: "absolute",
|
|
3703
|
-
style: { left: at.x * size.w * scale, top: at.y * size.h * scale },
|
|
3704
|
-
children: /* @__PURE__ */ jsx13(CommentPin, {
|
|
3705
|
-
number: pin.number,
|
|
3706
|
-
label: pin.label,
|
|
3707
|
-
active: activePin === pin.id,
|
|
3708
|
-
resolved: pin.resolved,
|
|
3709
|
-
onClick: () => onOpenPin(pin.id)
|
|
3710
|
-
})
|
|
3711
|
-
}, pin.id);
|
|
3712
|
-
}),
|
|
3713
|
-
commenting && hovered && !draft ? /* @__PURE__ */ jsx13(HoverTag, {
|
|
3714
|
-
target: hovered,
|
|
3715
|
-
scale
|
|
3716
|
-
}) : null,
|
|
3717
|
-
draft ? /* @__PURE__ */ jsxs11("div", {
|
|
3718
|
-
className: "absolute",
|
|
3719
|
-
style: { left: draft.point.x * size.w * scale, top: draft.point.y * size.h * scale },
|
|
3720
|
-
children: [
|
|
3721
|
-
/* @__PURE__ */ jsx13(CommentPin, {
|
|
3722
|
-
label: messages.comments.newPin,
|
|
3723
|
-
active: true,
|
|
3724
|
-
resolved: false,
|
|
3725
|
-
draft: true
|
|
3726
|
-
}),
|
|
3727
|
-
/* @__PURE__ */ jsx13("div", {
|
|
3728
|
-
className: cn11("absolute", draftAbove(draft) ? "bottom-9" : null),
|
|
3729
|
-
style: {
|
|
3730
|
-
...cardPlace(draft.point.x * size.w * scale, size.w * scale),
|
|
3731
|
-
...draftAbove(draft) ? {} : {
|
|
3732
|
-
top: Math.max(0, ((draft.under ?? draft.point.y) - draft.point.y) * size.h * scale) + 10
|
|
3733
|
-
}
|
|
3734
|
-
},
|
|
3735
|
-
children: /* @__PURE__ */ jsx13(DraftCard, {
|
|
3736
|
-
...draft.anchor ? { anchor: draft.anchor } : {},
|
|
3737
|
-
onSubmit: onSubmitDraft,
|
|
3738
|
-
onCancel: onCancelDraft
|
|
3739
|
-
})
|
|
3740
|
-
})
|
|
3741
|
-
]
|
|
3742
|
-
}) : null,
|
|
3743
|
-
editing && selected ? /* @__PURE__ */ jsx13(ElementTools, {
|
|
3744
|
-
target: selected,
|
|
3745
|
-
scale,
|
|
3746
|
-
width: size.w,
|
|
3747
|
-
board,
|
|
3748
|
-
version,
|
|
3749
|
-
live,
|
|
3750
|
-
canvas,
|
|
3751
|
-
source: frame.source,
|
|
3752
|
-
previews: frame.previews,
|
|
3753
|
-
onComment: () => onPick({
|
|
3754
|
-
...selected.address !== null ? { element: selected.address, label: selected.label } : selected.within ? { element: selected.within } : {},
|
|
3755
|
-
point: point(undefined, selected.rect)
|
|
3756
|
-
})
|
|
3757
|
-
}, selected.address ?? "scripted") : null
|
|
3758
|
-
]
|
|
3759
|
-
}),
|
|
3760
|
-
frame.stale ? /* @__PURE__ */ jsxs11("span", {
|
|
3761
|
-
role: "status",
|
|
3762
|
-
className: "absolute right-3 bottom-3 flex items-center gap-1.5 rounded-full bg-background/95 px-2.5 py-1 text-xs text-muted-foreground shadow-sm ring-1 ring-border",
|
|
3763
|
-
children: [
|
|
3764
|
-
/* @__PURE__ */ jsx13(LoaderCircle3, {
|
|
3765
|
-
className: "size-3 animate-spin motion-reduce:animate-none",
|
|
3766
|
-
"aria-hidden": true
|
|
3767
|
-
}),
|
|
3768
|
-
messages.edit.updating
|
|
3769
|
-
]
|
|
3770
|
-
}) : null
|
|
3771
|
-
]
|
|
3772
|
-
});
|
|
3773
|
-
}
|
|
3774
|
-
function draftAbove(draft) {
|
|
3775
|
-
return (draft.under ?? draft.point.y) > 0.7 && draft.point.y > 0.5;
|
|
3776
|
-
}
|
|
3777
|
-
function HoverTag({ target, scale }) {
|
|
3778
|
-
const messages = useArtifactMessages().canvas;
|
|
3779
|
-
const name = target.address === "body" ? messages.comments.wholeBoard : target.label ? `\u201C${target.label}\u201D` : target.address === null ? messages.comments.elsewhere : messages.edit.kinds[target.kind];
|
|
3780
|
-
const top = target.rect.y * scale;
|
|
3781
|
-
return /* @__PURE__ */ jsx13("div", {
|
|
3782
|
-
"aria-hidden": "true",
|
|
3783
|
-
className: cn11("absolute max-w-64 truncate rounded-md bg-[#0a84ff] px-1.5 py-0.5 text-[11px] leading-4 font-medium text-white shadow-sm", top < 24 ? "translate-y-1" : "-translate-y-[calc(100%+5px)]"),
|
|
3784
|
-
style: { left: target.rect.x * scale - 3, top },
|
|
3785
|
-
children: name
|
|
3786
|
-
});
|
|
3787
|
-
}
|
|
3788
|
-
function ElementTools({
|
|
3789
|
-
target,
|
|
3790
|
-
scale,
|
|
3791
|
-
width: pageWidth,
|
|
3792
|
-
board,
|
|
3793
|
-
version,
|
|
3794
|
-
live,
|
|
3795
|
-
canvas,
|
|
3796
|
-
source,
|
|
3797
|
-
previews,
|
|
3798
|
-
onComment
|
|
3799
|
-
}) {
|
|
3800
|
-
const messages = useArtifactMessages().canvas;
|
|
3801
|
-
const rect = target.rect;
|
|
3802
|
-
const toolbar = useRef7(null);
|
|
3803
|
-
const [width, setWidth] = useState9(0);
|
|
3804
|
-
useLayoutEffect2(() => {
|
|
3805
|
-
setWidth(toolbar.current?.offsetWidth ?? 0);
|
|
3806
|
-
});
|
|
3807
|
-
const left = Math.max(4, Math.min(rect.x * scale, pageWidth * scale - width - 4));
|
|
3808
|
-
const above = rect.y * scale >= 44;
|
|
3809
|
-
const top = above ? rect.y * scale - 40 : (rect.y + rect.height) * scale + 8;
|
|
3810
|
-
return /* @__PURE__ */ jsxs11("div", {
|
|
3811
|
-
ref: toolbar,
|
|
3812
|
-
role: "toolbar",
|
|
3813
|
-
"aria-label": messages.edit.tools,
|
|
3814
|
-
"data-board-tools": "",
|
|
3815
|
-
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",
|
|
3816
|
-
style: { left, top },
|
|
3817
|
-
children: [
|
|
3818
|
-
target.kind === "scripted" ? /* @__PURE__ */ jsxs11("span", {
|
|
3819
|
-
className: "flex min-w-0 items-center gap-2 px-2 text-xs",
|
|
3820
|
-
children: [
|
|
3821
|
-
/* @__PURE__ */ jsx13(Code2, {
|
|
3822
|
-
className: "size-3.5 shrink-0 text-muted-foreground",
|
|
3823
|
-
"aria-hidden": "true"
|
|
3824
|
-
}),
|
|
3825
|
-
/* @__PURE__ */ jsxs11("span", {
|
|
3826
|
-
className: "min-w-0",
|
|
3827
|
-
children: [
|
|
3828
|
-
/* @__PURE__ */ jsx13("span", {
|
|
3829
|
-
className: "font-medium text-foreground",
|
|
3830
|
-
children: messages.edit.scripted
|
|
3831
|
-
}),
|
|
3832
|
-
/* @__PURE__ */ jsxs11("span", {
|
|
3833
|
-
className: "text-muted-foreground",
|
|
3834
|
-
children: [
|
|
3835
|
-
" \xB7 ",
|
|
3836
|
-
messages.edit.scriptedHint
|
|
3837
|
-
]
|
|
3838
|
-
})
|
|
3839
|
-
]
|
|
3840
|
-
})
|
|
3841
|
-
]
|
|
3842
|
-
}) : /* @__PURE__ */ jsxs11(Fragment6, {
|
|
3843
|
-
children: [
|
|
3844
|
-
/* @__PURE__ */ jsx13("span", {
|
|
3845
|
-
className: "max-w-40 truncate px-2 text-xs font-medium text-foreground",
|
|
3846
|
-
children: messages.edit.element(messages.edit.kinds[target.kind], tagOf(target.address))
|
|
3847
|
-
}),
|
|
3848
|
-
/* @__PURE__ */ jsx13("span", {
|
|
3849
|
-
"aria-hidden": "true",
|
|
3850
|
-
className: "mx-0.5 h-5 w-px bg-border"
|
|
3851
|
-
}),
|
|
3852
|
-
target.kind === "image" ? /* @__PURE__ */ jsx13(ImageTool, {
|
|
3853
|
-
address: target.address,
|
|
3854
|
-
board,
|
|
3855
|
-
version,
|
|
3856
|
-
live,
|
|
3857
|
-
canvas,
|
|
3858
|
-
source,
|
|
3859
|
-
previews
|
|
3860
|
-
}) : null,
|
|
3861
|
-
/* @__PURE__ */ jsx13(StyleTool, {
|
|
3862
|
-
address: target.address,
|
|
3863
|
-
words: target.kind === "text" || target.kind === "box",
|
|
3864
|
-
board,
|
|
3865
|
-
canvas,
|
|
3866
|
-
source
|
|
3867
|
-
})
|
|
3868
|
-
]
|
|
3869
|
-
}),
|
|
3870
|
-
/* @__PURE__ */ jsx13("span", {
|
|
3871
|
-
"aria-hidden": "true",
|
|
3872
|
-
className: "mx-0.5 h-5 w-px bg-border"
|
|
3873
|
-
}),
|
|
3874
|
-
/* @__PURE__ */ jsx13(ToolButton, {
|
|
3875
|
-
label: messages.toolbar.comment,
|
|
3876
|
-
onClick: onComment,
|
|
3877
|
-
children: /* @__PURE__ */ jsx13(MessageSquarePlus3, {})
|
|
3878
|
-
})
|
|
3879
|
-
]
|
|
3880
|
-
});
|
|
3881
|
-
}
|
|
3882
|
-
function tagOf(address) {
|
|
3883
|
-
return address.split(">").at(-1)?.split(":")[0] ?? "";
|
|
3884
|
-
}
|
|
3885
|
-
function StyleTool({
|
|
3886
|
-
address,
|
|
3887
|
-
words,
|
|
3888
|
-
board,
|
|
3889
|
-
canvas,
|
|
3890
|
-
source
|
|
3891
|
-
}) {
|
|
3892
|
-
const messages = useArtifactMessages().canvas.edit;
|
|
3893
|
-
const style = useMemo5(() => source === null ? {} : boardInlineStyle(source, address), [source, address]);
|
|
3894
|
-
const change = (properties) => {
|
|
3895
|
-
try {
|
|
3896
|
-
canvas.stopCapturing();
|
|
3897
|
-
canvas.editBoard(board.file, (page) => setBoardStyle(page, address, properties));
|
|
3898
|
-
canvas.stopCapturing();
|
|
3899
|
-
return true;
|
|
3900
|
-
} catch {
|
|
3901
|
-
return false;
|
|
3902
|
-
}
|
|
3903
|
-
};
|
|
3904
|
-
return /* @__PURE__ */ jsxs11(Popover, {
|
|
3905
|
-
modal: false,
|
|
3906
|
-
children: [
|
|
3907
|
-
/* @__PURE__ */ jsx13(PopoverTrigger, {
|
|
3908
|
-
asChild: true,
|
|
3909
|
-
children: /* @__PURE__ */ jsx13(ToolButton, {
|
|
3910
|
-
label: messages.style,
|
|
3911
|
-
children: /* @__PURE__ */ jsx13(Paintbrush, {})
|
|
3912
|
-
})
|
|
3913
|
-
}),
|
|
3914
|
-
/* @__PURE__ */ jsx13(PopoverContent, {
|
|
3915
|
-
align: "start",
|
|
3916
|
-
sideOffset: 8,
|
|
3917
|
-
className: "w-auto p-3",
|
|
3918
|
-
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
3919
|
-
children: /* @__PURE__ */ jsx13(StylePanel, {
|
|
3920
|
-
style,
|
|
3921
|
-
words,
|
|
3922
|
-
onChange: change
|
|
3923
|
-
})
|
|
3924
|
-
})
|
|
3925
|
-
]
|
|
3926
|
-
});
|
|
3927
|
-
}
|
|
3928
|
-
function ImageTool({
|
|
3929
|
-
address,
|
|
3930
|
-
board,
|
|
3931
|
-
version,
|
|
3932
|
-
live,
|
|
3933
|
-
canvas,
|
|
3934
|
-
source,
|
|
3935
|
-
previews
|
|
3936
|
-
}) {
|
|
3937
|
-
const messages = useArtifactMessages().canvas.edit;
|
|
3938
|
-
const locale = useLocale2();
|
|
3939
|
-
const files = useArtifactMessages();
|
|
3940
|
-
const stored = useLiveStoredFiles(live);
|
|
3941
|
-
const [uploading, setUploading] = useState9(false);
|
|
3942
|
-
const [failure, setFailure] = useState9(null);
|
|
3943
|
-
const src = source === null ? null : boardAttribute(source, address, "src");
|
|
3944
|
-
const alt = source === null ? "" : boardAttribute(source, address, "alt") ?? "";
|
|
3945
|
-
const current = src === null ? null : boardReferencePath(board.file, src);
|
|
3946
|
-
const images = useMemo5(() => {
|
|
3947
|
-
const listed = new Map;
|
|
3948
|
-
for (const file of version.files) {
|
|
3949
|
-
if (!IMAGE_EXTENSIONS.test(file.path))
|
|
3950
|
-
continue;
|
|
3951
|
-
const url = versionFileSource(version, file.path)?.inlineUrl;
|
|
3952
|
-
listed.set(file.path, { path: file.path, ...url ? { url } : {} });
|
|
3953
|
-
}
|
|
3954
|
-
for (const path of stored.keys()) {
|
|
3955
|
-
if (IMAGE_EXTENSIONS.test(path) && !listed.has(path)) {
|
|
3956
|
-
const preview = previews.get(path);
|
|
3957
|
-
listed.set(path, { path, ...preview ? { url: preview } : {} });
|
|
3958
|
-
}
|
|
3959
|
-
}
|
|
3960
|
-
return [...listed.values()];
|
|
3961
|
-
}, [version, stored, previews]);
|
|
3962
|
-
const change = (image, files = {}) => {
|
|
3963
|
-
try {
|
|
3964
|
-
canvas.stopCapturing();
|
|
3965
|
-
canvas.editBoard(board.file, (page) => setBoardImage(page, address, image), files);
|
|
3966
|
-
canvas.stopCapturing();
|
|
3967
|
-
return true;
|
|
3968
|
-
} catch {
|
|
3969
|
-
setFailure(messages.notImage);
|
|
3970
|
-
return false;
|
|
3971
|
-
}
|
|
3972
|
-
};
|
|
3973
|
-
const show = (path, files = {}) => change({ src: boardFilePath(board.file, path), alt: "" }, files);
|
|
3974
|
-
const upload = async (file) => {
|
|
3975
|
-
if (file.size > ARTIFACT_LIMITS3.maxFileBytes) {
|
|
3976
|
-
setFailure(messages.tooLarge(formatFileSize(ARTIFACT_LIMITS3.maxFileBytes, locale, files.files)));
|
|
3977
|
-
return false;
|
|
3978
|
-
}
|
|
3979
|
-
setUploading(true);
|
|
3980
|
-
setFailure(null);
|
|
3981
|
-
try {
|
|
3982
|
-
const path = imagePath(board.file, file.name);
|
|
3983
|
-
const [ref, preview] = await Promise.all([
|
|
3984
|
-
uploadFile(file, { fileName: path.split("/").at(-1) ?? path }),
|
|
3985
|
-
dataUrl(file).catch(() => null)
|
|
3986
|
-
]);
|
|
3987
|
-
if (preview)
|
|
3988
|
-
previews.set(path, preview);
|
|
3989
|
-
return show(path, { [path]: ref });
|
|
3990
|
-
} catch {
|
|
3991
|
-
setFailure(messages.uploadFailed);
|
|
3992
|
-
return false;
|
|
3993
|
-
} finally {
|
|
3994
|
-
setUploading(false);
|
|
3995
|
-
}
|
|
3996
|
-
};
|
|
3997
|
-
return /* @__PURE__ */ jsxs11(Popover, {
|
|
3998
|
-
modal: false,
|
|
3999
|
-
children: [
|
|
4000
|
-
/* @__PURE__ */ jsx13(PopoverTrigger, {
|
|
4001
|
-
asChild: true,
|
|
4002
|
-
children: /* @__PURE__ */ jsx13(ToolButton, {
|
|
4003
|
-
label: messages.replace,
|
|
4004
|
-
children: /* @__PURE__ */ jsx13(ImageIcon2, {})
|
|
4005
|
-
})
|
|
4006
|
-
}),
|
|
4007
|
-
/* @__PURE__ */ jsx13(PopoverContent, {
|
|
4008
|
-
align: "start",
|
|
4009
|
-
sideOffset: 8,
|
|
4010
|
-
className: "w-auto p-3",
|
|
4011
|
-
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
4012
|
-
children: /* @__PURE__ */ jsx13(ImagePanel, {
|
|
4013
|
-
current,
|
|
4014
|
-
alt,
|
|
4015
|
-
images,
|
|
4016
|
-
uploading,
|
|
4017
|
-
failure,
|
|
4018
|
-
onUpload: upload,
|
|
4019
|
-
onPick: show,
|
|
4020
|
-
onAlt: (text) => {
|
|
4021
|
-
change({ alt: text });
|
|
4022
|
-
}
|
|
4023
|
-
})
|
|
4024
|
-
})
|
|
4025
|
-
]
|
|
4026
|
-
});
|
|
4027
|
-
}
|
|
4028
|
-
function imagePath(board, name) {
|
|
4029
|
-
const folder = board.split("/").slice(0, -1);
|
|
4030
|
-
const extension = /\.([a-z0-9]{1,5})$/i.exec(name)?.[1]?.toLowerCase() ?? "png";
|
|
4031
|
-
const stem = name.replace(/\.[^.]*$/, "").toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "image";
|
|
4032
|
-
const suffix = Array.from(crypto.getRandomValues(new Uint8Array(6)), (byte) => String.fromCharCode(97 + byte % 26)).join("");
|
|
4033
|
-
return [...folder, "images", `${stem}-${suffix}.${extension}`].join("/");
|
|
4034
|
-
}
|
|
4035
|
-
async function dataUrl(file) {
|
|
4036
|
-
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
4037
|
-
let binary = "";
|
|
4038
|
-
for (let at = 0;at < bytes.length; at += 32768) {
|
|
4039
|
-
binary += String.fromCharCode(...bytes.subarray(at, at + 32768));
|
|
4040
|
-
}
|
|
4041
|
-
return `data:${file.type || "application/octet-stream"};base64,${btoa(binary)}`;
|
|
4042
|
-
}
|
|
4043
|
-
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";
|
|
4044
|
-
var ToolButton = forwardRef2(function ToolButton({ label, children, ...props }, ref) {
|
|
4045
|
-
return /* @__PURE__ */ jsx13("button", {
|
|
4046
|
-
ref,
|
|
4047
|
-
type: "button",
|
|
4048
|
-
"aria-label": label,
|
|
4049
|
-
title: label,
|
|
4050
|
-
className: TOOL2,
|
|
4051
|
-
...props,
|
|
4052
|
-
children
|
|
4053
|
-
});
|
|
4054
|
-
});
|
|
4055
|
-
|
|
4056
|
-
// src/artifacts/renderers/canvas/page-resize.tsx
|
|
4057
|
-
import { cn as cn12 } from "@sixb/ui/lib/utils";
|
|
4058
|
-
import {
|
|
4059
|
-
useCallback as useCallback6,
|
|
4060
|
-
useEffect as useEffect7,
|
|
4061
|
-
useRef as useRef8,
|
|
4062
|
-
useState as useState10
|
|
2422
|
+
useCallback as useCallback3,
|
|
2423
|
+
useEffect as useEffect5,
|
|
2424
|
+
useRef as useRef6,
|
|
2425
|
+
useState as useState7
|
|
4063
2426
|
} from "react";
|
|
4064
2427
|
|
|
4065
2428
|
// src/artifacts/renderers/canvas/page-size.ts
|
|
4066
|
-
import { ARTIFACT_LIMITS as
|
|
2429
|
+
import { ARTIFACT_LIMITS as ARTIFACT_LIMITS3 } from "@sixb/core/artifacts";
|
|
4067
2430
|
var SCREENS = [
|
|
4068
2431
|
{ name: "phone", w: 390, h: 844 },
|
|
4069
2432
|
{ name: "tablet", w: 768, h: 1024 },
|
|
@@ -4074,7 +2437,7 @@ function isScreen(name) {
|
|
|
4074
2437
|
return SCREENS.some((screen) => screen.name === name);
|
|
4075
2438
|
}
|
|
4076
2439
|
var PAGE_MIN = { w: 240, h: 160 };
|
|
4077
|
-
var PAGE_MAX =
|
|
2440
|
+
var PAGE_MAX = ARTIFACT_LIMITS3.maxCanvasItemSize;
|
|
4078
2441
|
var GRID2 = 8;
|
|
4079
2442
|
var SNAP_REACH = 8;
|
|
4080
2443
|
var ZOOM_MIN = 0.1;
|
|
@@ -4161,7 +2524,7 @@ function sameSize(left, right) {
|
|
|
4161
2524
|
}
|
|
4162
2525
|
|
|
4163
2526
|
// src/artifacts/renderers/canvas/page-resize.tsx
|
|
4164
|
-
import { jsx as
|
|
2527
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
4165
2528
|
var EDGES = {
|
|
4166
2529
|
right: { w: true, h: false },
|
|
4167
2530
|
bottom: { w: false, h: true },
|
|
@@ -4182,13 +2545,13 @@ function PageResizer({
|
|
|
4182
2545
|
onEnd
|
|
4183
2546
|
}) {
|
|
4184
2547
|
const messages = useArtifactMessages().canvas.size;
|
|
4185
|
-
const [drag, setDrag] =
|
|
4186
|
-
const dragging =
|
|
4187
|
-
const update =
|
|
2548
|
+
const [drag, setDrag] = useState7(null);
|
|
2549
|
+
const dragging = useRef6(null);
|
|
2550
|
+
const update = useCallback3((next) => {
|
|
4188
2551
|
dragging.current = next;
|
|
4189
2552
|
setDrag(next);
|
|
4190
2553
|
}, []);
|
|
4191
|
-
const move =
|
|
2554
|
+
const move = useCallback3((at, free) => {
|
|
4192
2555
|
const current = dragging.current;
|
|
4193
2556
|
if (!current)
|
|
4194
2557
|
return;
|
|
@@ -4203,7 +2566,7 @@ function PageResizer({
|
|
|
4203
2566
|
update({ ...current, at, free, snapped });
|
|
4204
2567
|
onResize(snapped.size);
|
|
4205
2568
|
}, [stage, scale, suggestions, onResize, update]);
|
|
4206
|
-
const end =
|
|
2569
|
+
const end = useCallback3((cancel) => {
|
|
4207
2570
|
const current = dragging.current;
|
|
4208
2571
|
if (!current)
|
|
4209
2572
|
return;
|
|
@@ -4213,7 +2576,7 @@ function PageResizer({
|
|
|
4213
2576
|
onEnd(cancel ? null : current.snapped);
|
|
4214
2577
|
}, [onResize, onEnd, update]);
|
|
4215
2578
|
const edge = drag?.edge;
|
|
4216
|
-
|
|
2579
|
+
useEffect5(() => {
|
|
4217
2580
|
if (!edge || !stage)
|
|
4218
2581
|
return;
|
|
4219
2582
|
const edges = EDGES[edge];
|
|
@@ -4241,7 +2604,7 @@ function PageResizer({
|
|
|
4241
2604
|
frame = requestAnimationFrame(roll);
|
|
4242
2605
|
return () => cancelAnimationFrame(frame);
|
|
4243
2606
|
}, [edge, stage, move]);
|
|
4244
|
-
|
|
2607
|
+
useEffect5(() => {
|
|
4245
2608
|
if (!drag)
|
|
4246
2609
|
return;
|
|
4247
2610
|
const onKey = (event) => {
|
|
@@ -4321,22 +2684,22 @@ function PageResizer({
|
|
|
4321
2684
|
};
|
|
4322
2685
|
const full = suggestions.heights.find((each) => each.name === "full");
|
|
4323
2686
|
const edges = edge ? EDGES[edge] : null;
|
|
4324
|
-
return /* @__PURE__ */
|
|
2687
|
+
return /* @__PURE__ */ jsxs9("div", {
|
|
4325
2688
|
className: "pointer-events-none absolute inset-0 z-[5]",
|
|
4326
2689
|
"data-page-resizer": "",
|
|
4327
2690
|
children: [
|
|
4328
|
-
drag ? /* @__PURE__ */
|
|
2691
|
+
drag ? /* @__PURE__ */ jsx10("div", {
|
|
4329
2692
|
className: "absolute inset-0 rounded-[inherit] ring-1 ring-primary",
|
|
4330
2693
|
"aria-hidden": true
|
|
4331
2694
|
}) : null,
|
|
4332
|
-
drag && edges ? /* @__PURE__ */
|
|
2695
|
+
drag && edges ? /* @__PURE__ */ jsx10(Guides, {
|
|
4333
2696
|
size: drag.snapped.size,
|
|
4334
2697
|
scale,
|
|
4335
2698
|
edges,
|
|
4336
2699
|
drag,
|
|
4337
2700
|
suggestions
|
|
4338
2701
|
}) : null,
|
|
4339
|
-
/* @__PURE__ */
|
|
2702
|
+
/* @__PURE__ */ jsx10(Handle3, {
|
|
4340
2703
|
edge: "right",
|
|
4341
2704
|
label: messages.resizeWidth,
|
|
4342
2705
|
value: size.w,
|
|
@@ -4349,7 +2712,7 @@ function PageResizer({
|
|
|
4349
2712
|
onPick: (suggestion) => set({ ...size, w: suggestion.w ?? size.w }, { w: suggestion }),
|
|
4350
2713
|
...handlers("right")
|
|
4351
2714
|
}),
|
|
4352
|
-
/* @__PURE__ */
|
|
2715
|
+
/* @__PURE__ */ jsx10(Handle3, {
|
|
4353
2716
|
edge: "bottom",
|
|
4354
2717
|
label: messages.resizeHeight,
|
|
4355
2718
|
value: size.h,
|
|
@@ -4363,7 +2726,7 @@ function PageResizer({
|
|
|
4363
2726
|
onDoubleClick: full?.h === undefined ? undefined : () => set({ ...size, h: full.h ?? size.h }, { h: full }),
|
|
4364
2727
|
...handlers("bottom")
|
|
4365
2728
|
}),
|
|
4366
|
-
/* @__PURE__ */
|
|
2729
|
+
/* @__PURE__ */ jsx10(Handle3, {
|
|
4367
2730
|
edge: "corner",
|
|
4368
2731
|
label: messages.resizeBoth,
|
|
4369
2732
|
value: size.w,
|
|
@@ -4376,7 +2739,7 @@ function PageResizer({
|
|
|
4376
2739
|
onPick: (suggestion) => set({ w: suggestion.w ?? size.w, h: suggestion.h ?? size.h }, { w: suggestion, h: suggestion }),
|
|
4377
2740
|
...handlers("corner")
|
|
4378
2741
|
}),
|
|
4379
|
-
drag ? /* @__PURE__ */
|
|
2742
|
+
drag ? /* @__PURE__ */ jsx10(Readout, {
|
|
4380
2743
|
drag,
|
|
4381
2744
|
scale
|
|
4382
2745
|
}) : null
|
|
@@ -4403,7 +2766,7 @@ function Handle3({
|
|
|
4403
2766
|
...pointer
|
|
4404
2767
|
}) {
|
|
4405
2768
|
const messages = useArtifactMessages().canvas.size;
|
|
4406
|
-
const [offering, setOffering] =
|
|
2769
|
+
const [offering, setOffering] = useState7(false);
|
|
4407
2770
|
const onFocus = (event) => {
|
|
4408
2771
|
if (event.target.matches(":focus-visible"))
|
|
4409
2772
|
setOffering(true);
|
|
@@ -4412,11 +2775,11 @@ function Handle3({
|
|
|
4412
2775
|
if (!event.currentTarget.contains(event.relatedTarget))
|
|
4413
2776
|
setOffering(false);
|
|
4414
2777
|
};
|
|
4415
|
-
return /* @__PURE__ */
|
|
2778
|
+
return /* @__PURE__ */ jsxs9("div", {
|
|
4416
2779
|
onFocus,
|
|
4417
2780
|
onBlur,
|
|
4418
2781
|
children: [
|
|
4419
|
-
/* @__PURE__ */
|
|
2782
|
+
/* @__PURE__ */ jsxs9("div", {
|
|
4420
2783
|
role: "separator",
|
|
4421
2784
|
tabIndex: 0,
|
|
4422
2785
|
"aria-label": label,
|
|
@@ -4426,7 +2789,7 @@ function Handle3({
|
|
|
4426
2789
|
title: edge === "bottom" ? messages.bottomHint : label,
|
|
4427
2790
|
"data-edge": edge,
|
|
4428
2791
|
"data-active": active ? "" : undefined,
|
|
4429
|
-
className:
|
|
2792
|
+
className: cn8("group/edge pointer-events-auto absolute touch-none outline-none", HANDLE_PLACES[edge]),
|
|
4430
2793
|
onKeyDown,
|
|
4431
2794
|
onDoubleClick: (event) => {
|
|
4432
2795
|
event.stopPropagation();
|
|
@@ -4434,28 +2797,28 @@ function Handle3({
|
|
|
4434
2797
|
},
|
|
4435
2798
|
...pointer,
|
|
4436
2799
|
children: [
|
|
4437
|
-
edge === "corner" ? null : /* @__PURE__ */
|
|
2800
|
+
edge === "corner" ? null : /* @__PURE__ */ jsx10("span", {
|
|
4438
2801
|
"aria-hidden": true,
|
|
4439
|
-
className:
|
|
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")
|
|
4440
2803
|
}),
|
|
4441
|
-
/* @__PURE__ */
|
|
2804
|
+
/* @__PURE__ */ jsx10("span", {
|
|
4442
2805
|
"aria-hidden": true,
|
|
4443
|
-
className:
|
|
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")
|
|
4444
2807
|
})
|
|
4445
2808
|
]
|
|
4446
2809
|
}),
|
|
4447
|
-
offering && !dragging ? /* @__PURE__ */
|
|
2810
|
+
offering && !dragging ? /* @__PURE__ */ jsx10("div", {
|
|
4448
2811
|
role: "group",
|
|
4449
2812
|
"aria-label": messages.suggestions,
|
|
4450
2813
|
className: "pointer-events-auto absolute z-10 flex max-w-72 flex-wrap justify-end gap-1",
|
|
4451
2814
|
style: chipsPlace(edge, size, scale),
|
|
4452
|
-
children: chips.map((chip) => /* @__PURE__ */
|
|
2815
|
+
children: chips.map((chip) => /* @__PURE__ */ jsxs9("button", {
|
|
4453
2816
|
type: "button",
|
|
4454
2817
|
onClick: () => onPick(chip),
|
|
4455
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",
|
|
4456
2819
|
children: [
|
|
4457
2820
|
messages.names[chip.name],
|
|
4458
|
-
/* @__PURE__ */
|
|
2821
|
+
/* @__PURE__ */ jsx10("span", {
|
|
4459
2822
|
className: "ml-1 text-muted-foreground tabular-nums",
|
|
4460
2823
|
children: messages.dimension(edge === "bottom" ? undefined : chip.w, edge === "right" ? undefined : chip.h)
|
|
4461
2824
|
})
|
|
@@ -4484,23 +2847,23 @@ function Guides({
|
|
|
4484
2847
|
const width = size.w * scale;
|
|
4485
2848
|
const height = size.h * scale;
|
|
4486
2849
|
const { w, h } = drag.snapped;
|
|
4487
|
-
return /* @__PURE__ */
|
|
2850
|
+
return /* @__PURE__ */ jsxs9("div", {
|
|
4488
2851
|
"aria-hidden": true,
|
|
4489
2852
|
className: "absolute inset-0",
|
|
4490
2853
|
children: [
|
|
4491
|
-
edges.w ? suggestions.widths.map((each) => each.w === undefined || each === w ? null : /* @__PURE__ */
|
|
2854
|
+
edges.w ? suggestions.widths.map((each) => each.w === undefined || each === w ? null : /* @__PURE__ */ jsx10("span", {
|
|
4492
2855
|
className: "absolute -top-3.5 h-2 w-px bg-muted-foreground/50",
|
|
4493
2856
|
style: { left: each.w * scale }
|
|
4494
2857
|
}, `w-${each.name}`)) : null,
|
|
4495
|
-
edges.h ? suggestions.heights.map((each) => each.h === undefined || each === h ? null : /* @__PURE__ */
|
|
2858
|
+
edges.h ? suggestions.heights.map((each) => each.h === undefined || each === h ? null : /* @__PURE__ */ jsx10("span", {
|
|
4496
2859
|
className: "absolute -right-3.5 h-px w-2 bg-muted-foreground/50",
|
|
4497
2860
|
style: { top: each.h * scale }
|
|
4498
2861
|
}, `h-${each.name}`)) : null,
|
|
4499
|
-
w ? /* @__PURE__ */
|
|
2862
|
+
w ? /* @__PURE__ */ jsx10("span", {
|
|
4500
2863
|
className: "absolute -top-4 -bottom-4 w-px bg-primary motion-safe:animate-in motion-safe:fade-in",
|
|
4501
2864
|
style: { left: width }
|
|
4502
2865
|
}) : null,
|
|
4503
|
-
h ? /* @__PURE__ */
|
|
2866
|
+
h ? /* @__PURE__ */ jsx10("span", {
|
|
4504
2867
|
className: "absolute -right-4 -left-4 h-px bg-primary motion-safe:animate-in motion-safe:fade-in",
|
|
4505
2868
|
style: { top: height }
|
|
4506
2869
|
}) : null
|
|
@@ -4514,16 +2877,16 @@ function Readout({ drag, scale }) {
|
|
|
4514
2877
|
const height = size.h * scale;
|
|
4515
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%)" };
|
|
4516
2879
|
const names = [...new Set([w?.name, h?.name])].filter((name) => name !== undefined);
|
|
4517
|
-
return /* @__PURE__ */
|
|
2880
|
+
return /* @__PURE__ */ jsxs9("span", {
|
|
4518
2881
|
role: "status",
|
|
4519
2882
|
className: "absolute flex items-center gap-1",
|
|
4520
2883
|
style: place,
|
|
4521
2884
|
children: [
|
|
4522
|
-
names.map((name) => /* @__PURE__ */
|
|
2885
|
+
names.map((name) => /* @__PURE__ */ jsx10("span", {
|
|
4523
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",
|
|
4524
2887
|
children: messages.names[name]
|
|
4525
2888
|
}, name)),
|
|
4526
|
-
/* @__PURE__ */
|
|
2889
|
+
/* @__PURE__ */ jsx10("span", {
|
|
4527
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",
|
|
4528
2891
|
children: messages.dimensions(size.w, size.h)
|
|
4529
2892
|
})
|
|
@@ -4540,10 +2903,10 @@ import {
|
|
|
4540
2903
|
DropdownMenuSeparator,
|
|
4541
2904
|
DropdownMenuTrigger as DropdownMenuTrigger3
|
|
4542
2905
|
} from "@sixb/ui/components";
|
|
4543
|
-
import { cn as
|
|
4544
|
-
import { Check as Check2, Proportions, RotateCcw as
|
|
4545
|
-
import { useRef as
|
|
4546
|
-
import { jsx as
|
|
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";
|
|
4547
2910
|
var MENU = ["board", "full", "phone", "tablet", "desktop"];
|
|
4548
2911
|
function menuSize(name, shown, board, suggestions) {
|
|
4549
2912
|
if (name === "board")
|
|
@@ -4566,30 +2929,30 @@ function SizeControls({
|
|
|
4566
2929
|
}) {
|
|
4567
2930
|
const messages = useArtifactMessages().canvas.size;
|
|
4568
2931
|
const resized = !sameSize(shown, board);
|
|
4569
|
-
const pointer =
|
|
2932
|
+
const pointer = useRef7(false);
|
|
4570
2933
|
const sizes = MENU.map((name) => ({ name, size: menuSize(name, shown, board, suggestions) }));
|
|
4571
2934
|
const current = sizes.find(({ size }) => size !== null && sameSize(size, shown))?.name;
|
|
4572
|
-
return /* @__PURE__ */
|
|
2935
|
+
return /* @__PURE__ */ jsxs10("div", {
|
|
4573
2936
|
className: "flex shrink-0 items-center gap-1",
|
|
4574
2937
|
children: [
|
|
4575
|
-
kept ? /* @__PURE__ */
|
|
2938
|
+
kept ? /* @__PURE__ */ jsxs10("span", {
|
|
4576
2939
|
role: "status",
|
|
4577
2940
|
className: "flex items-center gap-1.5 px-2 text-xs font-medium text-foreground motion-safe:animate-in motion-safe:fade-in",
|
|
4578
2941
|
children: [
|
|
4579
|
-
/* @__PURE__ */
|
|
2942
|
+
/* @__PURE__ */ jsx11(Check2, {
|
|
4580
2943
|
className: "size-3.5 text-primary",
|
|
4581
2944
|
"aria-hidden": "true"
|
|
4582
2945
|
}),
|
|
4583
|
-
/* @__PURE__ */
|
|
2946
|
+
/* @__PURE__ */ jsx11("span", {
|
|
4584
2947
|
className: "@max-3xl/canvas:sr-only",
|
|
4585
2948
|
children: messages.kept(kept.w, kept.h)
|
|
4586
2949
|
})
|
|
4587
2950
|
]
|
|
4588
2951
|
}) : null,
|
|
4589
|
-
/* @__PURE__ */
|
|
2952
|
+
/* @__PURE__ */ jsxs10(DropdownMenu3, {
|
|
4590
2953
|
modal: false,
|
|
4591
2954
|
children: [
|
|
4592
|
-
/* @__PURE__ */
|
|
2955
|
+
/* @__PURE__ */ jsxs10(DropdownMenuTrigger3, {
|
|
4593
2956
|
onPointerDown: () => {
|
|
4594
2957
|
pointer.current = true;
|
|
4595
2958
|
},
|
|
@@ -4598,22 +2961,22 @@ function SizeControls({
|
|
|
4598
2961
|
},
|
|
4599
2962
|
"aria-label": resized ? `${messages.menu}, ${messages.dimensions(shown.w, shown.h)}` : messages.menu,
|
|
4600
2963
|
title: resized ? messages.yoursOnly : messages.menu,
|
|
4601
|
-
className:
|
|
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"),
|
|
4602
2965
|
children: [
|
|
4603
|
-
/* @__PURE__ */
|
|
2966
|
+
/* @__PURE__ */ jsx11(Proportions, {
|
|
4604
2967
|
className: "size-4",
|
|
4605
2968
|
"aria-hidden": "true"
|
|
4606
2969
|
}),
|
|
4607
|
-
resized ? /* @__PURE__ */
|
|
2970
|
+
resized ? /* @__PURE__ */ jsx11("span", {
|
|
4608
2971
|
className: "text-xs tabular-nums max-sm:hidden",
|
|
4609
2972
|
children: messages.dimensions(shown.w, shown.h)
|
|
4610
|
-
}) : /* @__PURE__ */
|
|
2973
|
+
}) : /* @__PURE__ */ jsx11("span", {
|
|
4611
2974
|
className: "max-md:hidden",
|
|
4612
2975
|
children: messages.label
|
|
4613
2976
|
})
|
|
4614
2977
|
]
|
|
4615
2978
|
}),
|
|
4616
|
-
/* @__PURE__ */
|
|
2979
|
+
/* @__PURE__ */ jsxs10(DropdownMenuContent3, {
|
|
4617
2980
|
align: "end",
|
|
4618
2981
|
sideOffset: 6,
|
|
4619
2982
|
className: "w-[min(17rem,calc(100vw-2rem))] p-1.5",
|
|
@@ -4628,11 +2991,11 @@ function SizeControls({
|
|
|
4628
2991
|
event.preventDefault();
|
|
4629
2992
|
},
|
|
4630
2993
|
children: [
|
|
4631
|
-
/* @__PURE__ */
|
|
2994
|
+
/* @__PURE__ */ jsx11(DropdownMenuLabel, {
|
|
4632
2995
|
className: "px-2 pt-1 pb-1.5 text-[11px] font-medium tracking-wide text-muted-foreground uppercase",
|
|
4633
2996
|
children: messages.menu
|
|
4634
2997
|
}),
|
|
4635
|
-
sizes.map(({ name, size }) => /* @__PURE__ */
|
|
2998
|
+
sizes.map(({ name, size }) => /* @__PURE__ */ jsxs10(DropdownMenuItem3, {
|
|
4636
2999
|
disabled: size === null,
|
|
4637
3000
|
onSelect: () => {
|
|
4638
3001
|
if (name === "board")
|
|
@@ -4642,30 +3005,30 @@ function SizeControls({
|
|
|
4642
3005
|
},
|
|
4643
3006
|
className: "gap-2 rounded-md py-1.5",
|
|
4644
3007
|
children: [
|
|
4645
|
-
/* @__PURE__ */
|
|
4646
|
-
className:
|
|
3008
|
+
/* @__PURE__ */ jsx11(Check2, {
|
|
3009
|
+
className: cn9("size-3.5", name === current ? "text-foreground" : "invisible"),
|
|
4647
3010
|
"aria-hidden": "true"
|
|
4648
3011
|
}),
|
|
4649
|
-
/* @__PURE__ */
|
|
3012
|
+
/* @__PURE__ */ jsx11("span", {
|
|
4650
3013
|
className: "flex-1 text-[13px]",
|
|
4651
3014
|
children: messages.names[name]
|
|
4652
3015
|
}),
|
|
4653
|
-
/* @__PURE__ */
|
|
3016
|
+
/* @__PURE__ */ jsx11("span", {
|
|
4654
3017
|
className: "text-xs text-muted-foreground tabular-nums",
|
|
4655
3018
|
children: size ? messages.dimensions(size.w, size.h) : messages.measuring
|
|
4656
3019
|
})
|
|
4657
3020
|
]
|
|
4658
3021
|
}, name)),
|
|
4659
|
-
resized ? /* @__PURE__ */
|
|
3022
|
+
resized ? /* @__PURE__ */ jsxs10(Fragment6, {
|
|
4660
3023
|
children: [
|
|
4661
|
-
/* @__PURE__ */
|
|
3024
|
+
/* @__PURE__ */ jsx11(DropdownMenuSeparator, {
|
|
4662
3025
|
className: "my-1"
|
|
4663
3026
|
}),
|
|
4664
|
-
/* @__PURE__ */
|
|
3027
|
+
/* @__PURE__ */ jsx11("p", {
|
|
4665
3028
|
className: "px-2 pt-0.5 pb-1 text-xs text-muted-foreground",
|
|
4666
3029
|
children: onKeep ? messages.yoursUntilKept : messages.yoursOnly
|
|
4667
3030
|
}),
|
|
4668
|
-
onKeep ? /* @__PURE__ */
|
|
3031
|
+
onKeep ? /* @__PURE__ */ jsx11(DropdownMenuItem3, {
|
|
4669
3032
|
onSelect: onKeep,
|
|
4670
3033
|
className: "rounded-md py-1.5 pl-[30px] text-[13px] font-medium text-primary focus:text-primary",
|
|
4671
3034
|
children: messages.keep
|
|
@@ -4676,21 +3039,21 @@ function SizeControls({
|
|
|
4676
3039
|
})
|
|
4677
3040
|
]
|
|
4678
3041
|
}),
|
|
4679
|
-
resized ? /* @__PURE__ */
|
|
3042
|
+
resized ? /* @__PURE__ */ jsxs10("span", {
|
|
4680
3043
|
className: "hidden items-center gap-1 @3xl/canvas:flex",
|
|
4681
3044
|
children: [
|
|
4682
|
-
/* @__PURE__ */
|
|
3045
|
+
/* @__PURE__ */ jsx11("button", {
|
|
4683
3046
|
type: "button",
|
|
4684
3047
|
"aria-label": messages.reset,
|
|
4685
3048
|
title: messages.reset,
|
|
4686
3049
|
onClick: onReset,
|
|
4687
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",
|
|
4688
|
-
children: /* @__PURE__ */
|
|
3051
|
+
children: /* @__PURE__ */ jsx11(RotateCcw2, {
|
|
4689
3052
|
className: "size-3.5",
|
|
4690
3053
|
"aria-hidden": "true"
|
|
4691
3054
|
})
|
|
4692
3055
|
}),
|
|
4693
|
-
onKeep ? /* @__PURE__ */
|
|
3056
|
+
onKeep ? /* @__PURE__ */ jsx11("button", {
|
|
4694
3057
|
type: "button",
|
|
4695
3058
|
onClick: onKeep,
|
|
4696
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",
|
|
@@ -4703,7 +3066,7 @@ function SizeControls({
|
|
|
4703
3066
|
}
|
|
4704
3067
|
|
|
4705
3068
|
// src/artifacts/renderers/canvas/page-zoom.ts
|
|
4706
|
-
import { useCallback as
|
|
3069
|
+
import { useCallback as useCallback4, useEffect as useEffect6, useLayoutEffect as useLayoutEffect2, useRef as useRef8, useState as useState8 } from "react";
|
|
4707
3070
|
var OPEN = { fit: "open" };
|
|
4708
3071
|
var SETTLE_MS = 220;
|
|
4709
3072
|
function pagePlacement(view, box, pad, held = null) {
|
|
@@ -4725,13 +3088,13 @@ function usePageZoom({
|
|
|
4725
3088
|
view,
|
|
4726
3089
|
stage
|
|
4727
3090
|
}) {
|
|
4728
|
-
const [state, setState] =
|
|
3091
|
+
const [state, setState] = useState8({
|
|
4729
3092
|
id,
|
|
4730
3093
|
zoom: OPEN
|
|
4731
3094
|
});
|
|
4732
3095
|
const zoom = state.id === id ? state.zoom : OPEN;
|
|
4733
|
-
const [held, setHeld] =
|
|
4734
|
-
const [settling, setSettling] =
|
|
3096
|
+
const [held, setHeld] = useState8(null);
|
|
3097
|
+
const [settling, setSettling] = useState8(false);
|
|
4735
3098
|
const pad = view ? stagePadding(view) : null;
|
|
4736
3099
|
const room = view && pad ? {
|
|
4737
3100
|
width: Math.max(1, view.width - pad.side * 2),
|
|
@@ -4740,10 +3103,10 @@ function usePageZoom({
|
|
|
4740
3103
|
const scale = !room ? 0 : ("scale" in zoom) ? zoom.scale : fitScale(page, room, zoom.fit);
|
|
4741
3104
|
const box = { width: page.w * scale, height: page.h * scale };
|
|
4742
3105
|
const placement = view && pad ? pagePlacement(view, box, pad, held) : null;
|
|
4743
|
-
const anchor =
|
|
4744
|
-
const latest =
|
|
3106
|
+
const anchor = useRef8(null);
|
|
3107
|
+
const latest = useRef8({ id, scale, placement, view });
|
|
4745
3108
|
latest.current = { id, scale, placement, view };
|
|
4746
|
-
|
|
3109
|
+
useLayoutEffect2(() => {
|
|
4747
3110
|
const point = anchor.current;
|
|
4748
3111
|
if (!point || !stage || !placement)
|
|
4749
3112
|
return;
|
|
@@ -4752,13 +3115,13 @@ function usePageZoom({
|
|
|
4752
3115
|
stage.scrollTop = placement.top + point.y * scale - point.vy;
|
|
4753
3116
|
}, [stage, placement, scale]);
|
|
4754
3117
|
const fitted = "fit" in zoom ? zoom.fit : null;
|
|
4755
|
-
|
|
3118
|
+
useLayoutEffect2(() => {
|
|
4756
3119
|
if (fitted === null || !stage)
|
|
4757
3120
|
return;
|
|
4758
3121
|
stage.scrollTop = 0;
|
|
4759
3122
|
stage.scrollLeft = 0;
|
|
4760
3123
|
}, [stage, fitted, id]);
|
|
4761
|
-
const zoomTo =
|
|
3124
|
+
const zoomTo = useCallback4((next, at = null) => {
|
|
4762
3125
|
const { id, scale, placement, view } = latest.current;
|
|
4763
3126
|
if (!stage || !placement || !view || scale === 0)
|
|
4764
3127
|
return;
|
|
@@ -4782,20 +3145,20 @@ function usePageZoom({
|
|
|
4782
3145
|
}
|
|
4783
3146
|
setState({ id, zoom: { scale: target } });
|
|
4784
3147
|
}, [stage]);
|
|
4785
|
-
const current =
|
|
4786
|
-
const zoomBy =
|
|
4787
|
-
const step =
|
|
4788
|
-
const fit =
|
|
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") => {
|
|
4789
3152
|
anchor.current = null;
|
|
4790
3153
|
setState({ id: latest.current.id, zoom: { fit: how } });
|
|
4791
3154
|
}, []);
|
|
4792
|
-
const toggle =
|
|
3155
|
+
const toggle = useCallback4((at) => {
|
|
4793
3156
|
if (Math.abs(current() - 1) < 0.01)
|
|
4794
3157
|
fit("whole");
|
|
4795
3158
|
else
|
|
4796
3159
|
zoomTo(1, at);
|
|
4797
3160
|
}, [fit, zoomTo, current]);
|
|
4798
|
-
const pageAt =
|
|
3161
|
+
const pageAt = useCallback4((clientX, clientY) => {
|
|
4799
3162
|
const { scale, placement } = latest.current;
|
|
4800
3163
|
if (!stage || !placement || scale === 0)
|
|
4801
3164
|
return null;
|
|
@@ -4805,24 +3168,24 @@ function usePageZoom({
|
|
|
4805
3168
|
y: (stage.scrollTop + clientY - rect.top - placement.top) / scale
|
|
4806
3169
|
};
|
|
4807
3170
|
}, [stage]);
|
|
4808
|
-
const hold =
|
|
3171
|
+
const hold = useCallback4(() => {
|
|
4809
3172
|
const { id, scale, placement } = latest.current;
|
|
4810
3173
|
if (!placement)
|
|
4811
3174
|
return;
|
|
4812
3175
|
setState({ id, zoom: { scale } });
|
|
4813
3176
|
setHeld({ left: placement.left, top: placement.top });
|
|
4814
3177
|
}, []);
|
|
4815
|
-
const release =
|
|
3178
|
+
const release = useCallback4(() => {
|
|
4816
3179
|
setHeld(null);
|
|
4817
3180
|
setSettling(true);
|
|
4818
3181
|
}, []);
|
|
4819
|
-
|
|
3182
|
+
useEffect6(() => {
|
|
4820
3183
|
if (!settling)
|
|
4821
3184
|
return;
|
|
4822
3185
|
const timer = window.setTimeout(() => setSettling(false), SETTLE_MS);
|
|
4823
3186
|
return () => window.clearTimeout(timer);
|
|
4824
3187
|
}, [settling]);
|
|
4825
|
-
|
|
3188
|
+
useEffect6(() => {
|
|
4826
3189
|
if (!stage)
|
|
4827
3190
|
return;
|
|
4828
3191
|
const mac = /Mac|iPhone|iPad/.test(navigator.platform);
|
|
@@ -4877,17 +3240,17 @@ function usePageZoom({
|
|
|
4877
3240
|
}
|
|
4878
3241
|
|
|
4879
3242
|
// src/artifacts/renderers/canvas/shown-size.ts
|
|
4880
|
-
import { useCallback as
|
|
3243
|
+
import { useCallback as useCallback5, useEffect as useEffect7, useMemo as useMemo3, useRef as useRef9, useState as useState9 } from "react";
|
|
4881
3244
|
function useShownSize(id, own) {
|
|
4882
|
-
const [sizes, setSizes] =
|
|
4883
|
-
const [screen, setScreen] =
|
|
4884
|
-
const [heights, setHeights] =
|
|
3245
|
+
const [sizes, setSizes] = useState9({});
|
|
3246
|
+
const [screen, setScreen] = useState9(null);
|
|
3247
|
+
const [heights, setHeights] = useState9({});
|
|
4885
3248
|
const height = heights[id] ?? null;
|
|
4886
|
-
const suggestions =
|
|
3249
|
+
const suggestions = useMemo3(() => sizeSuggestions(own, height), [own, height]);
|
|
4887
3250
|
const chosen = sizes[id] ?? (screen ? clampSize({ w: screen.w, h: screen.full && height !== null ? height : own.h }, suggestions.least) : null);
|
|
4888
3251
|
const shown = chosen && !sameSize(chosen, own) ? chosen : own;
|
|
4889
|
-
const onContentHeight =
|
|
4890
|
-
const resize =
|
|
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]);
|
|
4891
3254
|
const set = (size, name, full) => {
|
|
4892
3255
|
if (name !== null && isScreen(name)) {
|
|
4893
3256
|
setSizes({ [id]: size });
|
|
@@ -4898,8 +3261,8 @@ function useShownSize(id, own) {
|
|
|
4898
3261
|
if (screen && full !== null)
|
|
4899
3262
|
setScreen({ ...screen, full });
|
|
4900
3263
|
};
|
|
4901
|
-
const keeping =
|
|
4902
|
-
|
|
3264
|
+
const keeping = useRef9(null);
|
|
3265
|
+
useEffect7(() => {
|
|
4903
3266
|
const kept = keeping.current;
|
|
4904
3267
|
if (!kept || kept.id !== id || !sameSize(kept.size, own))
|
|
4905
3268
|
return;
|
|
@@ -4928,7 +3291,7 @@ function useShownSize(id, own) {
|
|
|
4928
3291
|
}
|
|
4929
3292
|
|
|
4930
3293
|
// src/artifacts/renderers/canvas/focus.tsx
|
|
4931
|
-
import { jsx as
|
|
3294
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
4932
3295
|
var KEPT_MS = 2400;
|
|
4933
3296
|
function BoardFocus({
|
|
4934
3297
|
version,
|
|
@@ -4957,11 +3320,11 @@ function BoardFocus({
|
|
|
4957
3320
|
const board = boards[index];
|
|
4958
3321
|
const previous = boards[index - 1];
|
|
4959
3322
|
const next = boards[index + 1];
|
|
4960
|
-
const [kept, setKept] =
|
|
4961
|
-
const own =
|
|
3323
|
+
const [kept, setKept] = useState10(null);
|
|
3324
|
+
const own = useMemo4(() => ({ w: board?.w ?? 1, h: board?.h ?? 1 }), [board?.w, board?.h]);
|
|
4962
3325
|
const size = useShownSize(id, own);
|
|
4963
3326
|
const { shown, resized, suggestions } = size;
|
|
4964
|
-
const [stage, setStage] =
|
|
3327
|
+
const [stage, setStage] = useState10(null);
|
|
4965
3328
|
const view = useSize(stage);
|
|
4966
3329
|
const zoom = usePageZoom({ id, page: shown, view, stage });
|
|
4967
3330
|
const pickSize = (picked, name) => {
|
|
@@ -4982,22 +3345,22 @@ function BoardFocus({
|
|
|
4982
3345
|
size.keep();
|
|
4983
3346
|
setKept(shown);
|
|
4984
3347
|
} : undefined;
|
|
4985
|
-
|
|
3348
|
+
useEffect8(() => {
|
|
4986
3349
|
if (!kept)
|
|
4987
3350
|
return;
|
|
4988
3351
|
const timer = window.setTimeout(() => setKept(null), KEPT_MS);
|
|
4989
3352
|
return () => window.clearTimeout(timer);
|
|
4990
3353
|
}, [kept]);
|
|
4991
3354
|
const { step, zoomTo, zoomBy } = zoom;
|
|
4992
|
-
const zoomStep =
|
|
4993
|
-
const onZoom =
|
|
4994
|
-
const onPress =
|
|
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]);
|
|
3357
|
+
const onPress = useCallback6((text) => {
|
|
4995
3358
|
const to = followedArrow(arrows, boards, id, text);
|
|
4996
3359
|
if (to)
|
|
4997
3360
|
onOpen(to);
|
|
4998
3361
|
}, [arrows, boards, id, onOpen]);
|
|
4999
|
-
const pick =
|
|
5000
|
-
|
|
3362
|
+
const pick = useCallback6((place) => onPick?.(id, place), [onPick, id]);
|
|
3363
|
+
useEffect8(() => {
|
|
5001
3364
|
const onKey = (event) => {
|
|
5002
3365
|
if (event.metaKey || event.ctrlKey) {
|
|
5003
3366
|
const to = zoomKey(event);
|
|
@@ -5034,42 +3397,42 @@ function BoardFocus({
|
|
|
5034
3397
|
const title = board.title ?? board.id;
|
|
5035
3398
|
const { scale, placement } = zoom;
|
|
5036
3399
|
const picture = resized ? undefined : pictureOf?.(board.id);
|
|
5037
|
-
return /* @__PURE__ */
|
|
3400
|
+
return /* @__PURE__ */ jsxs11("div", {
|
|
5038
3401
|
role: "dialog",
|
|
5039
3402
|
"aria-label": messages.focused(title),
|
|
5040
3403
|
className: "absolute inset-0 z-10 flex flex-col bg-background motion-safe:animate-in motion-safe:fade-in motion-safe:duration-200",
|
|
5041
3404
|
children: [
|
|
5042
|
-
/* @__PURE__ */
|
|
3405
|
+
/* @__PURE__ */ jsxs11("div", {
|
|
5043
3406
|
className: "flex h-12 shrink-0 items-center gap-2 border-b border-border/70 px-2",
|
|
5044
3407
|
children: [
|
|
5045
|
-
/* @__PURE__ */
|
|
3408
|
+
/* @__PURE__ */ jsxs11("button", {
|
|
5046
3409
|
type: "button",
|
|
5047
3410
|
onClick: onClose,
|
|
5048
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",
|
|
5049
3412
|
children: [
|
|
5050
|
-
/* @__PURE__ */
|
|
3413
|
+
/* @__PURE__ */ jsx12(ArrowLeft, {
|
|
5051
3414
|
className: "size-4",
|
|
5052
3415
|
"aria-hidden": "true"
|
|
5053
3416
|
}),
|
|
5054
3417
|
messages.back
|
|
5055
3418
|
]
|
|
5056
3419
|
}),
|
|
5057
|
-
/* @__PURE__ */
|
|
3420
|
+
/* @__PURE__ */ jsx12("span", {
|
|
5058
3421
|
className: "h-5 w-px bg-border",
|
|
5059
3422
|
"aria-hidden": "true"
|
|
5060
3423
|
}),
|
|
5061
|
-
/* @__PURE__ */
|
|
3424
|
+
/* @__PURE__ */ jsx12("span", {
|
|
5062
3425
|
className: "min-w-0 truncate px-1 text-sm font-semibold",
|
|
5063
3426
|
children: title
|
|
5064
3427
|
}),
|
|
5065
|
-
mode === "edit" || mode === "comment" ? /* @__PURE__ */
|
|
3428
|
+
mode === "edit" || mode === "comment" ? /* @__PURE__ */ jsx12("span", {
|
|
5066
3429
|
className: "hidden min-w-0 truncate text-xs text-muted-foreground @5xl/canvas:inline",
|
|
5067
3430
|
children: mode === "edit" ? messages.edit.hint : messages.comments.modeHint
|
|
5068
3431
|
}) : null,
|
|
5069
|
-
/* @__PURE__ */
|
|
3432
|
+
/* @__PURE__ */ jsxs11("div", {
|
|
5070
3433
|
className: "ml-auto flex shrink-0 items-center",
|
|
5071
3434
|
children: [
|
|
5072
|
-
/* @__PURE__ */
|
|
3435
|
+
/* @__PURE__ */ jsx12(SizeControls, {
|
|
5073
3436
|
shown,
|
|
5074
3437
|
board: own,
|
|
5075
3438
|
suggestions,
|
|
@@ -5081,34 +3444,34 @@ function BoardFocus({
|
|
|
5081
3444
|
tools
|
|
5082
3445
|
]
|
|
5083
3446
|
}),
|
|
5084
|
-
/* @__PURE__ */
|
|
3447
|
+
/* @__PURE__ */ jsx12("span", {
|
|
5085
3448
|
className: "shrink-0 text-xs whitespace-nowrap text-muted-foreground tabular-nums max-sm:hidden",
|
|
5086
3449
|
children: messages.position(index + 1, boards.length)
|
|
5087
3450
|
}),
|
|
5088
|
-
/* @__PURE__ */
|
|
3451
|
+
/* @__PURE__ */ jsx12(Step, {
|
|
5089
3452
|
label: messages.previousBoard,
|
|
5090
3453
|
disabled: !previous,
|
|
5091
3454
|
onClick: () => previous && onOpen(previous.id),
|
|
5092
|
-
children: /* @__PURE__ */
|
|
3455
|
+
children: /* @__PURE__ */ jsx12(ChevronLeft, {
|
|
5093
3456
|
className: "size-4",
|
|
5094
3457
|
"aria-hidden": "true"
|
|
5095
3458
|
})
|
|
5096
3459
|
}),
|
|
5097
|
-
/* @__PURE__ */
|
|
3460
|
+
/* @__PURE__ */ jsx12(Step, {
|
|
5098
3461
|
label: messages.nextBoard,
|
|
5099
3462
|
disabled: !next,
|
|
5100
3463
|
onClick: () => next && onOpen(next.id),
|
|
5101
|
-
children: /* @__PURE__ */
|
|
3464
|
+
children: /* @__PURE__ */ jsx12(ChevronRight, {
|
|
5102
3465
|
className: "size-4",
|
|
5103
3466
|
"aria-hidden": "true"
|
|
5104
3467
|
})
|
|
5105
3468
|
})
|
|
5106
3469
|
]
|
|
5107
3470
|
}),
|
|
5108
|
-
/* @__PURE__ */
|
|
3471
|
+
/* @__PURE__ */ jsxs11("div", {
|
|
5109
3472
|
className: "relative min-h-0 flex-1 bg-muted/40",
|
|
5110
3473
|
children: [
|
|
5111
|
-
/* @__PURE__ */
|
|
3474
|
+
/* @__PURE__ */ jsx12("div", {
|
|
5112
3475
|
ref: setStage,
|
|
5113
3476
|
"data-board-stage": "",
|
|
5114
3477
|
className: "absolute inset-0 touch-pan-x touch-pan-y overflow-auto overscroll-contain",
|
|
@@ -5119,12 +3482,12 @@ function BoardFocus({
|
|
|
5119
3482
|
if (at)
|
|
5120
3483
|
zoom.toggle(at);
|
|
5121
3484
|
},
|
|
5122
|
-
children: placement && scale > 0 ? /* @__PURE__ */
|
|
3485
|
+
children: placement && scale > 0 ? /* @__PURE__ */ jsx12("div", {
|
|
5123
3486
|
className: "relative",
|
|
5124
3487
|
style: { width: placement.width, height: placement.height },
|
|
5125
|
-
children: /* @__PURE__ */
|
|
3488
|
+
children: /* @__PURE__ */ jsxs11("div", {
|
|
5126
3489
|
"data-board-page": "",
|
|
5127
|
-
className:
|
|
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),
|
|
5128
3491
|
style: {
|
|
5129
3492
|
left: placement.left,
|
|
5130
3493
|
top: placement.top,
|
|
@@ -5132,7 +3495,7 @@ function BoardFocus({
|
|
|
5132
3495
|
height: shown.h * scale
|
|
5133
3496
|
},
|
|
5134
3497
|
children: [
|
|
5135
|
-
/* @__PURE__ */
|
|
3498
|
+
/* @__PURE__ */ jsx12(BoardStage, {
|
|
5136
3499
|
version,
|
|
5137
3500
|
board,
|
|
5138
3501
|
size: shown,
|
|
@@ -5144,16 +3507,16 @@ function BoardFocus({
|
|
|
5144
3507
|
pins: pins.filter((pin) => pin.board === board.id),
|
|
5145
3508
|
activePin,
|
|
5146
3509
|
draft: draft?.board === board.id ? draft : null,
|
|
5147
|
-
fallback: picture ? /* @__PURE__ */
|
|
3510
|
+
fallback: picture ? /* @__PURE__ */ jsx12(BoardPicture, {
|
|
5148
3511
|
src: picture
|
|
5149
3512
|
}) : undefined,
|
|
5150
|
-
failure: /* @__PURE__ */
|
|
3513
|
+
failure: /* @__PURE__ */ jsxs11("div", {
|
|
5151
3514
|
className: "relative size-full",
|
|
5152
3515
|
children: [
|
|
5153
|
-
picture ? /* @__PURE__ */
|
|
3516
|
+
picture ? /* @__PURE__ */ jsx12(BoardPicture, {
|
|
5154
3517
|
src: picture
|
|
5155
3518
|
}) : null,
|
|
5156
|
-
/* @__PURE__ */
|
|
3519
|
+
/* @__PURE__ */ jsx12("p", {
|
|
5157
3520
|
className: "absolute inset-x-0 bottom-0 m-0 bg-background/90 px-4 py-2 text-sm text-muted-foreground",
|
|
5158
3521
|
children: messages.boardFailed
|
|
5159
3522
|
})
|
|
@@ -5167,7 +3530,7 @@ function BoardFocus({
|
|
|
5167
3530
|
onContentHeight: size.onContentHeight,
|
|
5168
3531
|
onZoom
|
|
5169
3532
|
}),
|
|
5170
|
-
/* @__PURE__ */
|
|
3533
|
+
/* @__PURE__ */ jsx12(PageResizer, {
|
|
5171
3534
|
size: shown,
|
|
5172
3535
|
scale,
|
|
5173
3536
|
suggestions,
|
|
@@ -5180,7 +3543,7 @@ function BoardFocus({
|
|
|
5180
3543
|
}, board.id)
|
|
5181
3544
|
}) : null
|
|
5182
3545
|
}),
|
|
5183
|
-
/* @__PURE__ */
|
|
3546
|
+
/* @__PURE__ */ jsx12(ZoomBar, {
|
|
5184
3547
|
zoom: scale,
|
|
5185
3548
|
fitLabel: messages.fitPage,
|
|
5186
3549
|
onZoomOut: () => zoom.step("out"),
|
|
@@ -5222,7 +3585,7 @@ function wordsOf(text) {
|
|
|
5222
3585
|
return text.replace(/\s+/g, " ").trim().toLowerCase();
|
|
5223
3586
|
}
|
|
5224
3587
|
function BoardPicture({ src }) {
|
|
5225
|
-
return /* @__PURE__ */
|
|
3588
|
+
return /* @__PURE__ */ jsx12("img", {
|
|
5226
3589
|
src,
|
|
5227
3590
|
alt: "",
|
|
5228
3591
|
decoding: "async",
|
|
@@ -5231,8 +3594,8 @@ function BoardPicture({ src }) {
|
|
|
5231
3594
|
});
|
|
5232
3595
|
}
|
|
5233
3596
|
function useSize(element) {
|
|
5234
|
-
const [size, setSize] =
|
|
5235
|
-
|
|
3597
|
+
const [size, setSize] = useState10(null);
|
|
3598
|
+
useEffect8(() => {
|
|
5236
3599
|
if (!element)
|
|
5237
3600
|
return;
|
|
5238
3601
|
const measure = () => {
|
|
@@ -5253,7 +3616,7 @@ function Step({
|
|
|
5253
3616
|
onClick,
|
|
5254
3617
|
children
|
|
5255
3618
|
}) {
|
|
5256
|
-
return /* @__PURE__ */
|
|
3619
|
+
return /* @__PURE__ */ jsx12("button", {
|
|
5257
3620
|
type: "button",
|
|
5258
3621
|
"aria-label": label,
|
|
5259
3622
|
title: label,
|
|
@@ -5266,7 +3629,7 @@ function Step({
|
|
|
5266
3629
|
|
|
5267
3630
|
// src/artifacts/renderers/canvas/gestures.ts
|
|
5268
3631
|
import { useReactFlow as useReactFlow2, useStoreApi as useStoreApi4 } from "@xyflow/react";
|
|
5269
|
-
import { useEffect as
|
|
3632
|
+
import { useEffect as useEffect9, useMemo as useMemo5, useRef as useRef10 } from "react";
|
|
5270
3633
|
var WHEEL_PAN_SPEED = 0.5;
|
|
5271
3634
|
var WHEEL_PAUSE_MS = 150;
|
|
5272
3635
|
var GLIDE_MS = 420;
|
|
@@ -5292,9 +3655,9 @@ function useBoardGestures({
|
|
|
5292
3655
|
}) {
|
|
5293
3656
|
const store = useStoreApi4();
|
|
5294
3657
|
const { setViewport, zoomIn, zoomOut, zoomTo } = useReactFlow2();
|
|
5295
|
-
const pressRef =
|
|
3658
|
+
const pressRef = useRef10(onPress);
|
|
5296
3659
|
pressRef.current = onPress;
|
|
5297
|
-
const gestures =
|
|
3660
|
+
const gestures = useMemo5(() => {
|
|
5298
3661
|
let moving = false;
|
|
5299
3662
|
let pause;
|
|
5300
3663
|
const listeners = new Set;
|
|
@@ -5399,8 +3762,8 @@ function useBoardGestures({
|
|
|
5399
3762
|
}
|
|
5400
3763
|
};
|
|
5401
3764
|
}, [store, setViewport, zoomIn, zoomOut, zoomTo, root, padding]);
|
|
5402
|
-
|
|
5403
|
-
|
|
3765
|
+
useEffect9(() => gestures.stop, [gestures]);
|
|
3766
|
+
useEffect9(() => {
|
|
5404
3767
|
const here = root.current;
|
|
5405
3768
|
if (!here)
|
|
5406
3769
|
return;
|
|
@@ -5411,7 +3774,7 @@ function useBoardGestures({
|
|
|
5411
3774
|
here.addEventListener("wheel", onWheel, { capture: true, passive: true });
|
|
5412
3775
|
return () => here.removeEventListener("wheel", onWheel, { capture: true });
|
|
5413
3776
|
}, [root, gestures]);
|
|
5414
|
-
|
|
3777
|
+
useEffect9(() => {
|
|
5415
3778
|
if (opened)
|
|
5416
3779
|
return;
|
|
5417
3780
|
const here = () => {
|
|
@@ -5452,16 +3815,16 @@ function useBoardGestures({
|
|
|
5452
3815
|
}
|
|
5453
3816
|
|
|
5454
3817
|
// src/artifacts/renderers/canvas/presence.tsx
|
|
5455
|
-
import { useStore as
|
|
3818
|
+
import { useStore as useStore2, ViewportPortal } from "@xyflow/react";
|
|
5456
3819
|
import { Sparkles as Sparkles2 } from "lucide-react";
|
|
5457
|
-
import { memo as
|
|
5458
|
-
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";
|
|
5459
3822
|
var NAME_CLEARANCE = 96;
|
|
5460
3823
|
function nameBelow(box, transform) {
|
|
5461
3824
|
const [, panY = 0, zoom = 1] = transform;
|
|
5462
3825
|
return box.y * zoom + panY < NAME_CLEARANCE;
|
|
5463
3826
|
}
|
|
5464
|
-
var PresenceLayer =
|
|
3827
|
+
var PresenceLayer = memo3(function PresenceLayer({
|
|
5465
3828
|
live
|
|
5466
3829
|
}) {
|
|
5467
3830
|
const messages = useArtifactMessages().canvas.live;
|
|
@@ -5477,33 +3840,33 @@ var PresenceLayer = memo4(function PresenceLayer({
|
|
|
5477
3840
|
}
|
|
5478
3841
|
const changing = [...new Set(agents.flatMap((agent) => agent.boards))];
|
|
5479
3842
|
const boxes = useBoxes([...selected.keys(), ...changing]);
|
|
5480
|
-
const below =
|
|
3843
|
+
const below = useStore2(useCallback7((state) => [...boxes].filter(([, box]) => nameBelow(box, state.transform)).map(([id]) => id).join(`
|
|
5481
3844
|
`), [boxes]));
|
|
5482
3845
|
if (boxes.size === 0)
|
|
5483
3846
|
return null;
|
|
5484
|
-
return /* @__PURE__ */
|
|
3847
|
+
return /* @__PURE__ */ jsxs12(ViewportPortal, {
|
|
5485
3848
|
children: [
|
|
5486
3849
|
changing.map((id) => {
|
|
5487
3850
|
const box = boxes.get(id);
|
|
5488
|
-
return box ? /* @__PURE__ */
|
|
3851
|
+
return box ? /* @__PURE__ */ jsx13("div", {
|
|
5489
3852
|
"data-agent-board": id,
|
|
5490
3853
|
className: "sixb-agent-board pointer-events-none absolute rounded-[12px]",
|
|
5491
3854
|
style: place(box, 4),
|
|
5492
|
-
children: /* @__PURE__ */
|
|
3855
|
+
children: /* @__PURE__ */ jsx13("div", {
|
|
5493
3856
|
className: "@container absolute top-3 right-3 flex origin-top-right justify-end",
|
|
5494
3857
|
style: {
|
|
5495
3858
|
width: `calc(${Math.max(box.w - 16, 0)}px / ${NAME_SCALE_VALUE})`,
|
|
5496
3859
|
transform: `scale(${NAME_SCALE_VALUE})`
|
|
5497
3860
|
},
|
|
5498
|
-
children: /* @__PURE__ */
|
|
3861
|
+
children: /* @__PURE__ */ jsxs12("span", {
|
|
5499
3862
|
title: messages.agentChanging,
|
|
5500
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",
|
|
5501
3864
|
children: [
|
|
5502
|
-
/* @__PURE__ */
|
|
3865
|
+
/* @__PURE__ */ jsx13(Sparkles2, {
|
|
5503
3866
|
className: "size-3.5 shrink-0 motion-safe:animate-pulse",
|
|
5504
3867
|
"aria-hidden": "true"
|
|
5505
3868
|
}),
|
|
5506
|
-
/* @__PURE__ */
|
|
3869
|
+
/* @__PURE__ */ jsx13("span", {
|
|
5507
3870
|
className: "min-w-0 truncate @max-[8rem]:sr-only",
|
|
5508
3871
|
children: messages.agentChanging
|
|
5509
3872
|
})
|
|
@@ -5514,21 +3877,21 @@ var PresenceLayer = memo4(function PresenceLayer({
|
|
|
5514
3877
|
}),
|
|
5515
3878
|
[...selected].map(([id, user]) => {
|
|
5516
3879
|
const box = boxes.get(id);
|
|
5517
|
-
return box ? /* @__PURE__ */
|
|
3880
|
+
return box ? /* @__PURE__ */ jsx13("div", {
|
|
5518
3881
|
"data-peer-selection": id,
|
|
5519
3882
|
className: "pointer-events-none absolute rounded-[6px]",
|
|
5520
3883
|
style: {
|
|
5521
3884
|
...place(box, 3),
|
|
5522
3885
|
boxShadow: `0 0 0 calc(2px * ${NAME_SCALE_VALUE}) ${user.color}`
|
|
5523
3886
|
},
|
|
5524
|
-
children: /* @__PURE__ */
|
|
3887
|
+
children: /* @__PURE__ */ jsxs12("span", {
|
|
5525
3888
|
"data-name": below.split(`
|
|
5526
3889
|
`).includes(id) ? "below" : "above",
|
|
5527
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",
|
|
5528
3891
|
style: { backgroundColor: user.color, transform: `scale(${NAME_SCALE_VALUE})` },
|
|
5529
3892
|
children: [
|
|
5530
3893
|
livePersonName(user, labels),
|
|
5531
|
-
user.guest && user.name ? /* @__PURE__ */
|
|
3894
|
+
user.guest && user.name ? /* @__PURE__ */ jsxs12("span", {
|
|
5532
3895
|
className: "opacity-75",
|
|
5533
3896
|
children: [
|
|
5534
3897
|
" \xB7 ",
|
|
@@ -5552,7 +3915,7 @@ function place(box, margin) {
|
|
|
5552
3915
|
function useBoxes(ids) {
|
|
5553
3916
|
const key = ids.join(`
|
|
5554
3917
|
`);
|
|
5555
|
-
const select =
|
|
3918
|
+
const select = useCallback7((state) => {
|
|
5556
3919
|
const boxes = new Map;
|
|
5557
3920
|
for (const id of key ? key.split(`
|
|
5558
3921
|
`) : []) {
|
|
@@ -5563,7 +3926,7 @@ function useBoxes(ids) {
|
|
|
5563
3926
|
}
|
|
5564
3927
|
return boxes;
|
|
5565
3928
|
}, [key]);
|
|
5566
|
-
return
|
|
3929
|
+
return useStore2(select, sameBoxes);
|
|
5567
3930
|
}
|
|
5568
3931
|
function boxOf(node) {
|
|
5569
3932
|
const w = node.measured.width ?? node.width;
|
|
@@ -5573,7 +3936,7 @@ function boxOf(node) {
|
|
|
5573
3936
|
const { x, y } = node.internals.positionAbsolute;
|
|
5574
3937
|
return { x, y, w, h };
|
|
5575
3938
|
}
|
|
5576
|
-
function
|
|
3939
|
+
function sameBoxes(left, right) {
|
|
5577
3940
|
if (left.size !== right.size)
|
|
5578
3941
|
return false;
|
|
5579
3942
|
for (const [id, box] of left) {
|
|
@@ -5586,8 +3949,8 @@ function sameBoxes2(left, right) {
|
|
|
5586
3949
|
}
|
|
5587
3950
|
|
|
5588
3951
|
// src/artifacts/renderers/canvas/canvas.tsx
|
|
5589
|
-
import { jsx as
|
|
5590
|
-
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({
|
|
5591
3954
|
canvas,
|
|
5592
3955
|
version,
|
|
5593
3956
|
title,
|
|
@@ -5597,8 +3960,8 @@ var canvas_default = memo5(function CanvasBoard({
|
|
|
5597
3960
|
live,
|
|
5598
3961
|
theme
|
|
5599
3962
|
}) {
|
|
5600
|
-
return /* @__PURE__ */
|
|
5601
|
-
children: /* @__PURE__ */
|
|
3963
|
+
return /* @__PURE__ */ jsx14(ReactFlowProvider, {
|
|
3964
|
+
children: /* @__PURE__ */ jsx14(Board, {
|
|
5602
3965
|
canvas,
|
|
5603
3966
|
title,
|
|
5604
3967
|
mode,
|
|
@@ -5621,26 +3984,26 @@ function Board({
|
|
|
5621
3984
|
theme
|
|
5622
3985
|
}) {
|
|
5623
3986
|
const messages = useArtifactMessages().canvas;
|
|
5624
|
-
const boards =
|
|
5625
|
-
const arrows =
|
|
3987
|
+
const boards = useMemo6(() => canvas.items.filter((item) => item.type === "board"), [canvas]);
|
|
3988
|
+
const arrows = useMemo6(() => canvas.items.filter((item) => item.type === "arrow"), [canvas]);
|
|
5626
3989
|
const previews = useBoardPreviews(version);
|
|
5627
|
-
const places =
|
|
3990
|
+
const places = useMemo6(() => canvas.items.flatMap((item) => item.type === "board" || item.type === "embed" ? [{ ...item, pictured: previews[item.id] === "ready" }] : []), [canvas, previews]);
|
|
5628
3991
|
const running = useLiveSet(places);
|
|
5629
|
-
const [opened, setOpened] =
|
|
3992
|
+
const [opened, setOpened] = useState11(() => focus && boards.some((board) => board.id === focus) ? focus : null);
|
|
5630
3993
|
const { fitView } = useReactFlow3();
|
|
5631
|
-
const close =
|
|
3994
|
+
const close = useCallback8(() => {
|
|
5632
3995
|
const id = opened;
|
|
5633
3996
|
setOpened(null);
|
|
5634
3997
|
if (!id)
|
|
5635
3998
|
return;
|
|
5636
3999
|
fitView({ nodes: [{ id }], padding: CANVAS_FIT_PADDING, maxZoom: 1, duration: 220 });
|
|
5637
4000
|
}, [opened, fitView]);
|
|
5638
|
-
const pictureOf =
|
|
4001
|
+
const pictureOf = useCallback8((id) => version && previews[id] === "ready" ? boardPreviewUrl(version, id, mode) : undefined, [version, previews, mode]);
|
|
5639
4002
|
const board = useBoardEditing(canvas, edit, version ? setOpened : undefined);
|
|
5640
4003
|
const resizeBoard = useResizeBoard(board.editing ? board.items : null);
|
|
5641
4004
|
const editBoard = edit?.live?.editBoard;
|
|
5642
4005
|
const stopCapturing = edit?.live?.stopCapturing;
|
|
5643
|
-
const boardEditor =
|
|
4006
|
+
const boardEditor = useMemo6(() => editBoard && stopCapturing ? { editBoard, stopCapturing } : null, [editBoard, stopCapturing]);
|
|
5644
4007
|
useNameScaleVariable(board.root);
|
|
5645
4008
|
const view = useArtifactView();
|
|
5646
4009
|
const commenting = useCanvasCommenting({
|
|
@@ -5652,8 +4015,8 @@ function Board({
|
|
|
5652
4015
|
});
|
|
5653
4016
|
const { getInternalNode, screenToFlowPosition } = useReactFlow3();
|
|
5654
4017
|
const { setCommenting, cancelDraft, draft } = commenting;
|
|
5655
|
-
const pointed =
|
|
5656
|
-
|
|
4018
|
+
const pointed = useRef11(false);
|
|
4019
|
+
useEffect10(() => {
|
|
5657
4020
|
if (!commenting.enabled)
|
|
5658
4021
|
return;
|
|
5659
4022
|
const onKey = (event) => {
|
|
@@ -5680,7 +4043,7 @@ function Board({
|
|
|
5680
4043
|
window.addEventListener("keydown", onKey);
|
|
5681
4044
|
return () => window.removeEventListener("keydown", onKey);
|
|
5682
4045
|
}, [commenting, opened, draft, cancelDraft, setCommenting, board.root]);
|
|
5683
|
-
const placing =
|
|
4046
|
+
const placing = useMemo6(() => commenting.commenting ? {
|
|
5684
4047
|
nodesDraggable: false,
|
|
5685
4048
|
nodesConnectable: false,
|
|
5686
4049
|
elementsSelectable: false,
|
|
@@ -5702,7 +4065,7 @@ function Board({
|
|
|
5702
4065
|
},
|
|
5703
4066
|
onPaneClick: () => cancelDraft()
|
|
5704
4067
|
} : {}, [commenting, getInternalNode, screenToFlowPosition, boards, cancelDraft]);
|
|
5705
|
-
const showThread =
|
|
4068
|
+
const showThread = useCallback8((id) => {
|
|
5706
4069
|
commenting.setActive(id);
|
|
5707
4070
|
const thread = commenting.threads.find((each) => each.comment.id === id);
|
|
5708
4071
|
const on = thread?.comment.anchor.board;
|
|
@@ -5716,7 +4079,7 @@ function Board({
|
|
|
5716
4079
|
fitView({ nodes: [{ id: on }], padding: CANVAS_FIT_PADDING, maxZoom: 1, duration: 260 });
|
|
5717
4080
|
}, [commenting, boards, opened, fitView]);
|
|
5718
4081
|
const reads = !board.editing && !commenting.commenting && opened === null;
|
|
5719
|
-
const follow =
|
|
4082
|
+
const follow = useRef11(() => {});
|
|
5720
4083
|
const gestures = useBoardGestures({
|
|
5721
4084
|
root: board.root,
|
|
5722
4085
|
pointed,
|
|
@@ -5731,7 +4094,7 @@ function Board({
|
|
|
5731
4094
|
if (target)
|
|
5732
4095
|
gestures.glide(target);
|
|
5733
4096
|
};
|
|
5734
|
-
const live =
|
|
4097
|
+
const live = useMemo6(() => ({
|
|
5735
4098
|
version: version ?? null,
|
|
5736
4099
|
live: running,
|
|
5737
4100
|
previews,
|
|
@@ -5741,7 +4104,7 @@ function Board({
|
|
|
5741
4104
|
...version ? { open: setOpened } : {}
|
|
5742
4105
|
}), [version, running, previews, mode, reads, gestures]);
|
|
5743
4106
|
const open = live.open;
|
|
5744
|
-
const reading =
|
|
4107
|
+
const reading = useMemo6(() => ({
|
|
5745
4108
|
nodesDraggable: false,
|
|
5746
4109
|
nodesConnectable: false,
|
|
5747
4110
|
elementsSelectable: false,
|
|
@@ -5750,16 +4113,16 @@ function Board({
|
|
|
5750
4113
|
open?.(node.id);
|
|
5751
4114
|
}
|
|
5752
4115
|
}), [open]);
|
|
5753
|
-
const framed =
|
|
4116
|
+
const framed = useMemo6(() => {
|
|
5754
4117
|
const item = focus ? canvas.items.find((candidate) => candidate.id === focus) : undefined;
|
|
5755
4118
|
return item && item.type !== "arrow" && item.type !== "text" ? item.id : undefined;
|
|
5756
4119
|
}, [canvas, focus]);
|
|
5757
|
-
const fitOptions =
|
|
4120
|
+
const fitOptions = useMemo6(() => ({
|
|
5758
4121
|
padding: CANVAS_FIT_PADDING,
|
|
5759
4122
|
maxZoom: 1,
|
|
5760
4123
|
...framed ? { nodes: [{ id: framed }] } : {}
|
|
5761
4124
|
}), [framed]);
|
|
5762
|
-
return /* @__PURE__ */
|
|
4125
|
+
return /* @__PURE__ */ jsxs13("div", {
|
|
5763
4126
|
ref: board.root,
|
|
5764
4127
|
tabIndex: board.editing ? -1 : undefined,
|
|
5765
4128
|
className: "sixb-canvas sixb-artboard @container/canvas relative flex size-full bg-background outline-none",
|
|
@@ -5788,15 +4151,15 @@ function Board({
|
|
|
5788
4151
|
live.open(id);
|
|
5789
4152
|
},
|
|
5790
4153
|
children: [
|
|
5791
|
-
/* @__PURE__ */
|
|
5792
|
-
className:
|
|
4154
|
+
/* @__PURE__ */ jsxs13("div", {
|
|
4155
|
+
className: cn11("relative h-full min-w-0 flex-1 bg-background text-foreground", theme?.className),
|
|
5793
4156
|
style: theme?.style,
|
|
5794
4157
|
children: [
|
|
5795
|
-
/* @__PURE__ */
|
|
4158
|
+
/* @__PURE__ */ jsx14(LiveBoardsProvider, {
|
|
5796
4159
|
value: live,
|
|
5797
|
-
children: /* @__PURE__ */
|
|
4160
|
+
children: /* @__PURE__ */ jsx14(CanvasEditingProvider, {
|
|
5798
4161
|
value: board.editing ? board.items : null,
|
|
5799
|
-
children: /* @__PURE__ */
|
|
4162
|
+
children: /* @__PURE__ */ jsxs13(ReactFlow, {
|
|
5800
4163
|
nodes: board.nodes,
|
|
5801
4164
|
edges: board.edges,
|
|
5802
4165
|
nodeTypes: CANVAS_NODE_TYPES,
|
|
@@ -5817,21 +4180,21 @@ function Board({
|
|
|
5817
4180
|
...placing,
|
|
5818
4181
|
proOptions: { hideAttribution: true },
|
|
5819
4182
|
children: [
|
|
5820
|
-
/* @__PURE__ */
|
|
4183
|
+
/* @__PURE__ */ jsx14(Background, {
|
|
5821
4184
|
variant: BackgroundVariant.Dots,
|
|
5822
4185
|
gap: 24,
|
|
5823
4186
|
size: 1.3
|
|
5824
4187
|
}),
|
|
5825
|
-
/* @__PURE__ */
|
|
4188
|
+
/* @__PURE__ */ jsx14(CanvasControls, {
|
|
5826
4189
|
padding: CANVAS_FIT_PADDING
|
|
5827
4190
|
}),
|
|
5828
|
-
liveArtifact ? /* @__PURE__ */
|
|
4191
|
+
liveArtifact ? /* @__PURE__ */ jsx14(PresenceLayer, {
|
|
5829
4192
|
live: liveArtifact
|
|
5830
4193
|
}) : null,
|
|
5831
4194
|
board.editing ? board.toolbar : null,
|
|
5832
|
-
commenting.enabled ? /* @__PURE__ */
|
|
4195
|
+
commenting.enabled ? /* @__PURE__ */ jsxs13(Fragment7, {
|
|
5833
4196
|
children: [
|
|
5834
|
-
/* @__PURE__ */
|
|
4197
|
+
/* @__PURE__ */ jsx14(CanvasCommentPins, {
|
|
5835
4198
|
pins: commenting.pins,
|
|
5836
4199
|
active: commenting.active,
|
|
5837
4200
|
draft: draft?.where === "canvas" ? draft : null,
|
|
@@ -5842,14 +4205,14 @@ function Board({
|
|
|
5842
4205
|
onSubmitDraft: commenting.submitDraft,
|
|
5843
4206
|
onCancelDraft: cancelDraft
|
|
5844
4207
|
}),
|
|
5845
|
-
/* @__PURE__ */
|
|
4208
|
+
/* @__PURE__ */ jsx14(Panel3, {
|
|
5846
4209
|
position: "top-right",
|
|
5847
4210
|
className: "!m-3",
|
|
5848
|
-
children: /* @__PURE__ */
|
|
4211
|
+
children: /* @__PURE__ */ jsx14(CommentTools, {
|
|
5849
4212
|
commenting
|
|
5850
4213
|
})
|
|
5851
4214
|
}),
|
|
5852
|
-
commenting.commenting ? /* @__PURE__ */
|
|
4215
|
+
commenting.commenting ? /* @__PURE__ */ jsx14(ZoomVariable, {
|
|
5853
4216
|
root: board.root
|
|
5854
4217
|
}) : null
|
|
5855
4218
|
]
|
|
@@ -5858,13 +4221,13 @@ function Board({
|
|
|
5858
4221
|
})
|
|
5859
4222
|
})
|
|
5860
4223
|
}),
|
|
5861
|
-
commenting.enabled && commenting.commenting && !draft && !opened ? /* @__PURE__ */
|
|
4224
|
+
commenting.enabled && commenting.commenting && !draft && !opened ? /* @__PURE__ */ jsx14("div", {
|
|
5862
4225
|
className: "pointer-events-none absolute inset-x-0 bottom-4 z-20 flex justify-center px-4 max-sm:bottom-20",
|
|
5863
|
-
children: /* @__PURE__ */
|
|
4226
|
+
children: /* @__PURE__ */ jsx14(CommentModeHint, {
|
|
5864
4227
|
onExit: () => setCommenting(false)
|
|
5865
4228
|
})
|
|
5866
4229
|
}) : null,
|
|
5867
|
-
opened && version ? /* @__PURE__ */
|
|
4230
|
+
opened && version ? /* @__PURE__ */ jsx14(BoardFocus, {
|
|
5868
4231
|
version,
|
|
5869
4232
|
boards,
|
|
5870
4233
|
arrows,
|
|
@@ -5880,7 +4243,7 @@ function Board({
|
|
|
5880
4243
|
pins: commenting.pins,
|
|
5881
4244
|
activePin: commenting.active,
|
|
5882
4245
|
draft: draft?.where === "focus" ? draft : null,
|
|
5883
|
-
tools: /* @__PURE__ */
|
|
4246
|
+
tools: /* @__PURE__ */ jsx14(CommentTools, {
|
|
5884
4247
|
commenting,
|
|
5885
4248
|
className: "border-0 bg-transparent p-0 shadow-none"
|
|
5886
4249
|
}),
|
|
@@ -5904,7 +4267,7 @@ function Board({
|
|
|
5904
4267
|
}) : null
|
|
5905
4268
|
]
|
|
5906
4269
|
}),
|
|
5907
|
-
commenting.enabled && commenting.panel ? /* @__PURE__ */
|
|
4270
|
+
commenting.enabled && commenting.panel ? /* @__PURE__ */ jsx14(CommentsPanel, {
|
|
5908
4271
|
threads: commenting.threads,
|
|
5909
4272
|
loading: commenting.loading,
|
|
5910
4273
|
failed: commenting.failed,
|
|
@@ -5926,8 +4289,8 @@ function Board({
|
|
|
5926
4289
|
}
|
|
5927
4290
|
function useResizeBoard(items) {
|
|
5928
4291
|
const start = useStartEditing();
|
|
5929
|
-
const [waiting, setWaiting] =
|
|
5930
|
-
|
|
4292
|
+
const [waiting, setWaiting] = useState11(null);
|
|
4293
|
+
useEffect10(() => {
|
|
5931
4294
|
if (!waiting || !items)
|
|
5932
4295
|
return;
|
|
5933
4296
|
items.resize(waiting.id, waiting.box);
|
|
@@ -5945,7 +4308,7 @@ function useResizeBoard(items) {
|
|
|
5945
4308
|
var COMMENTS = "[data-comments-panel], [data-comment-pin], [data-board-tools]";
|
|
5946
4309
|
function useNameScaleVariable(root) {
|
|
5947
4310
|
const store = useStoreApi5();
|
|
5948
|
-
|
|
4311
|
+
useEffect10(() => {
|
|
5949
4312
|
let last = "";
|
|
5950
4313
|
const update = () => {
|
|
5951
4314
|
const element = root.current;
|
|
@@ -5962,8 +4325,8 @@ function useNameScaleVariable(root) {
|
|
|
5962
4325
|
}, [store, root]);
|
|
5963
4326
|
}
|
|
5964
4327
|
function ZoomVariable({ root }) {
|
|
5965
|
-
const zoom =
|
|
5966
|
-
|
|
4328
|
+
const zoom = useStore3((state) => state.transform[2]);
|
|
4329
|
+
useEffect10(() => {
|
|
5967
4330
|
root.current?.style.setProperty("--sixb-zoom", String(zoom));
|
|
5968
4331
|
}, [root, zoom]);
|
|
5969
4332
|
return null;
|
|
@@ -5972,4 +4335,4 @@ export {
|
|
|
5972
4335
|
canvas_default as default
|
|
5973
4336
|
};
|
|
5974
4337
|
|
|
5975
|
-
//# debugId=
|
|
4338
|
+
//# debugId=FA0FFE725414578464756E2164756E21
|