@tldiagram/core-ui 1.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.d.ts +1 -0
- package/dist/api/client.d.ts +143 -0
- package/dist/api/transport-vscode.d.ts +8 -0
- package/dist/api/transport.d.ts +1 -0
- package/dist/components/CodePreviewPanel-vscode.d.ts +7 -0
- package/dist/components/CodePreviewPanel.d.ts +9 -0
- package/dist/components/ConfirmDialog.d.ts +12 -0
- package/dist/components/ConnectorPanel.d.ts +21 -0
- package/dist/components/ContextBoundaryElement.d.ts +11 -0
- package/dist/components/ContextNeighborElement.d.ts +29 -0
- package/dist/components/ContextStraightConnector.d.ts +4 -0
- package/dist/components/CrossBranchControls.d.ts +9 -0
- package/dist/components/DependenciesOnboarding.d.ts +5 -0
- package/dist/components/DrawingCanvas.d.ts +39 -0
- package/dist/components/ElementLibrary-vscode.d.ts +7 -0
- package/dist/components/ElementLibrary.d.ts +22 -0
- package/dist/components/ElementNode.d.ts +36 -0
- package/dist/components/ElementPanel.d.ts +25 -0
- package/dist/components/ExploreOnboarding.d.ts +5 -0
- package/dist/components/ExplorePageOnboarding.d.ts +5 -0
- package/dist/components/ExportModal.d.ts +16 -0
- package/dist/components/FloatingEdge.d.ts +9 -0
- package/dist/components/GitSourceLinker.d.ts +8 -0
- package/dist/components/HeaderContext.d.ts +16 -0
- package/dist/components/Icons.d.ts +95 -0
- package/dist/components/ImportModal.d.ts +10 -0
- package/dist/components/InlineElementAdder.d.ts +17 -0
- package/dist/components/LayoutSection.d.ts +7 -0
- package/dist/components/LocalSourceLinker.d.ts +8 -0
- package/dist/components/MiniZoomOnboarding.d.ts +5 -0
- package/dist/components/NavBreadcrumb.d.ts +6 -0
- package/dist/components/NodeBody.d.ts +12 -0
- package/dist/components/NodeContainer.d.ts +8 -0
- package/dist/components/NodeHoverCard.d.ts +10 -0
- package/dist/components/PanelHeader.d.ts +8 -0
- package/dist/components/PanelUI.d.ts +3 -0
- package/dist/components/ProxyConnectorEdge.d.ts +4 -0
- package/dist/components/ProxyConnectorPanel.d.ts +9 -0
- package/dist/components/SafeBackground.d.ts +13 -0
- package/dist/components/ScrollIndicatorWrapper.d.ts +8 -0
- package/dist/components/SetChildModal.d.ts +10 -0
- package/dist/components/SetParentModal.d.ts +10 -0
- package/dist/components/SlidingPanel.d.ts +16 -0
- package/dist/components/TagUpsert.d.ts +8 -0
- package/dist/components/TopMenuBar.d.ts +8 -0
- package/dist/components/ViewBezierConnector.d.ts +4 -0
- package/dist/components/ViewDrawMenu.d.ts +22 -0
- package/dist/components/ViewEditorEdgeLabelLayout.d.ts +16 -0
- package/dist/components/ViewEditorOnboarding.d.ts +5 -0
- package/dist/components/ViewExplorer/TagManager/ColorPicker.d.ts +7 -0
- package/dist/components/ViewExplorer/TagManager/GroupNamingPopover.d.ts +10 -0
- package/dist/components/ViewExplorer/TagManager/LayerItem.d.ts +27 -0
- package/dist/components/ViewExplorer/TagManager/TagItem.d.ts +25 -0
- package/dist/components/ViewExplorer/TagManager/index.d.ts +21 -0
- package/dist/components/ViewExplorer/ViewNavigator.d.ts +11 -0
- package/dist/components/ViewExplorer/ViewSearch.d.ts +8 -0
- package/dist/components/ViewExplorer/ViewTree.d.ts +18 -0
- package/dist/components/ViewExplorer/index.d.ts +31 -0
- package/dist/components/ViewExplorer/types.d.ts +11 -0
- package/dist/components/ViewExplorer/utils.d.ts +6 -0
- package/dist/components/ViewExplorer-vscode.d.ts +6 -0
- package/dist/components/ViewFloatingMenu-vscode.d.ts +27 -0
- package/dist/components/ViewFloatingMenu.d.ts +39 -0
- package/dist/components/ViewGridNode.d.ts +29 -0
- package/dist/components/ViewHeaderButton.d.ts +11 -0
- package/dist/components/ViewPanel.d.ts +18 -0
- package/dist/components/ViewsGridOnboarding.d.ts +5 -0
- package/dist/components/ZUI/ZUICanvas.d.ts +18 -0
- package/dist/components/ZUI/index.d.ts +2 -0
- package/dist/components/ZUI/layout.d.ts +18 -0
- package/dist/components/ZUI/proxy.d.ts +25 -0
- package/dist/components/ZUI/renderer.d.ts +30 -0
- package/dist/components/ZUI/types.d.ts +140 -0
- package/dist/components/ZUI/useZUIInteraction.d.ts +21 -0
- package/dist/config/runtime-vscode.d.ts +22 -0
- package/dist/config/runtime.d.ts +5 -0
- package/dist/constants/colors.d.ts +27 -0
- package/dist/constants/diagramColors.d.ts +1 -0
- package/dist/context/ThemeContext.d.ts +27 -0
- package/dist/crossBranch/graph.d.ts +13 -0
- package/dist/crossBranch/resolve.d.ts +22 -0
- package/dist/crossBranch/settings.d.ts +6 -0
- package/dist/crossBranch/store.d.ts +11 -0
- package/dist/crossBranch/types.d.ts +96 -0
- package/dist/demo/DemoPage.d.ts +9 -0
- package/dist/demo/seed.d.ts +9 -0
- package/dist/demo/store.d.ts +137 -0
- package/dist/demo/viewEditor.d.ts +26 -0
- package/dist/favicon.svg +35 -0
- package/dist/hooks/useSafeFitView.d.ts +16 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +19966 -0
- package/dist/lib/vscodeBridge-vscode.d.ts +13 -0
- package/dist/lib/vscodeBridge.d.ts +5 -0
- package/dist/logo-120.png +0 -0
- package/dist/logo-bw.png +0 -0
- package/dist/logo-bw.svg +15 -0
- package/dist/logo-text.svg +51 -0
- package/dist/logo.svg +35 -0
- package/dist/pages/AppearanceSettings.d.ts +3 -0
- package/dist/pages/Dependencies.d.ts +1 -0
- package/dist/pages/InfiniteZoom.d.ts +7 -0
- package/dist/pages/Settings.d.ts +7 -0
- package/dist/pages/ViewEditor/components/EditorMenus.d.ts +24 -0
- package/dist/pages/ViewEditor/components/EditorOverlays.d.ts +30 -0
- package/dist/pages/ViewEditor/components/EmptyCanvasState.d.ts +7 -0
- package/dist/pages/ViewEditor/context.d.ts +13 -0
- package/dist/pages/ViewEditor/hooks/useCanvasInteractions.d.ts +201 -0
- package/dist/pages/ViewEditor/hooks/useDrawingEngine.d.ts +40 -0
- package/dist/pages/ViewEditor/hooks/useViewContextNeighbours.d.ts +20 -0
- package/dist/pages/ViewEditor/hooks/useViewData.d.ts +74 -0
- package/dist/pages/ViewEditor/index.d.ts +8 -0
- package/dist/pages/ViewEditor/utils.d.ts +14 -0
- package/dist/pages/Views.d.ts +6 -0
- package/dist/pages/ViewsGrid.d.ts +6 -0
- package/dist/pkg/importer/mermaid.d.ts +7 -0
- package/dist/pkg/importer/mermaid.test.d.ts +1 -0
- package/dist/platform/PlatformContext.d.ts +6 -0
- package/dist/platform/context.d.ts +3 -0
- package/dist/platform/local.d.ts +2 -0
- package/dist/platform/types.d.ts +17 -0
- package/dist/slots.d.ts +67 -0
- package/dist/theme.d.ts +2 -0
- package/dist/types/index.d.ts +193 -0
- package/dist/types/vscode-messages.d.ts +60 -0
- package/dist/utils/edgeDistribution.d.ts +34 -0
- package/dist/utils/githubApi.d.ts +4 -0
- package/dist/utils/githubCache.d.ts +17 -0
- package/dist/utils/ids.d.ts +2 -0
- package/dist/utils/technologyCatalog.d.ts +15 -0
- package/dist/utils/toast.d.ts +15 -0
- package/dist/utils/treesitter.d.ts +13 -0
- package/dist/utils/url.d.ts +12 -0
- package/package.json +159 -0
- package/src/App.tsx +141 -0
- package/src/api/client.ts +618 -0
- package/src/api/transport-vscode.ts +28 -0
- package/src/api/transport.ts +7 -0
- package/src/assets/logo-mark.svg +31 -0
- package/src/assets/logo-wordmark.svg +22 -0
- package/src/assets/logo.svg +35 -0
- package/src/components/CodePreviewPanel-vscode.tsx +85 -0
- package/src/components/CodePreviewPanel.tsx +384 -0
- package/src/components/ConfirmDialog.tsx +66 -0
- package/src/components/ConnectorPanel.tsx +403 -0
- package/src/components/ContextBoundaryElement.tsx +35 -0
- package/src/components/ContextNeighborElement.tsx +282 -0
- package/src/components/ContextStraightConnector.tsx +144 -0
- package/src/components/CrossBranchControls.tsx +105 -0
- package/src/components/DependenciesOnboarding.tsx +427 -0
- package/src/components/DrawingCanvas.tsx +391 -0
- package/src/components/ElementLibrary-vscode.tsx +9 -0
- package/src/components/ElementLibrary.tsx +512 -0
- package/src/components/ElementNode.tsx +1033 -0
- package/src/components/ElementPanel.tsx +928 -0
- package/src/components/ExploreOnboarding.tsx +347 -0
- package/src/components/ExplorePageOnboarding.tsx +383 -0
- package/src/components/ExportModal.tsx +132 -0
- package/src/components/FloatingEdge.tsx +115 -0
- package/src/components/GitSourceLinker.tsx +1053 -0
- package/src/components/HeaderContext.tsx +30 -0
- package/src/components/Icons.tsx +245 -0
- package/src/components/ImportModal.tsx +219 -0
- package/src/components/InlineElementAdder.tsx +216 -0
- package/src/components/LayoutSection.tsx +624 -0
- package/src/components/LocalSourceLinker.tsx +330 -0
- package/src/components/MiniZoomOnboarding.tsx +78 -0
- package/src/components/NavBreadcrumb.tsx +24 -0
- package/src/components/NodeBody.tsx +89 -0
- package/src/components/NodeContainer.tsx +58 -0
- package/src/components/NodeHoverCard.tsx +135 -0
- package/src/components/PanelHeader.tsx +36 -0
- package/src/components/PanelUI.tsx +24 -0
- package/src/components/ProxyConnectorEdge.tsx +169 -0
- package/src/components/ProxyConnectorPanel.tsx +130 -0
- package/src/components/SafeBackground.tsx +19 -0
- package/src/components/ScrollIndicatorWrapper.tsx +117 -0
- package/src/components/SetChildModal.tsx +191 -0
- package/src/components/SetParentModal.tsx +187 -0
- package/src/components/SlidingPanel.tsx +114 -0
- package/src/components/TagUpsert.tsx +142 -0
- package/src/components/TopMenuBar.tsx +380 -0
- package/src/components/ViewBezierConnector.tsx +143 -0
- package/src/components/ViewDrawMenu.tsx +270 -0
- package/src/components/ViewEditorEdgeLabelLayout.ts +189 -0
- package/src/components/ViewEditorOnboarding.tsx +445 -0
- package/src/components/ViewExplorer/TagManager/ColorPicker.tsx +49 -0
- package/src/components/ViewExplorer/TagManager/GroupNamingPopover.tsx +96 -0
- package/src/components/ViewExplorer/TagManager/LayerItem.tsx +228 -0
- package/src/components/ViewExplorer/TagManager/TagItem.tsx +242 -0
- package/src/components/ViewExplorer/TagManager/index.tsx +418 -0
- package/src/components/ViewExplorer/ViewNavigator.tsx +121 -0
- package/src/components/ViewExplorer/ViewSearch.tsx +33 -0
- package/src/components/ViewExplorer/ViewTree.tsx +98 -0
- package/src/components/ViewExplorer/index.tsx +384 -0
- package/src/components/ViewExplorer/types.ts +13 -0
- package/src/components/ViewExplorer/utils.ts +56 -0
- package/src/components/ViewExplorer-vscode.tsx +8 -0
- package/src/components/ViewFloatingMenu-vscode.tsx +248 -0
- package/src/components/ViewFloatingMenu.tsx +379 -0
- package/src/components/ViewGridNode.tsx +451 -0
- package/src/components/ViewHeaderButton.tsx +60 -0
- package/src/components/ViewPanel.tsx +162 -0
- package/src/components/ViewsGridOnboarding.tsx +400 -0
- package/src/components/ZUI/ZUICanvas.tsx +853 -0
- package/src/components/ZUI/index.ts +3 -0
- package/src/components/ZUI/layout.ts +323 -0
- package/src/components/ZUI/proxy.ts +278 -0
- package/src/components/ZUI/renderer.ts +1189 -0
- package/src/components/ZUI/types.ts +150 -0
- package/src/components/ZUI/useZUIInteraction.ts +720 -0
- package/src/config/runtime-vscode.ts +46 -0
- package/src/config/runtime.ts +30 -0
- package/src/constants/colors.ts +80 -0
- package/src/constants/diagramColors.ts +9 -0
- package/src/context/ThemeContext.tsx +158 -0
- package/src/crossBranch/graph.ts +207 -0
- package/src/crossBranch/resolve.ts +643 -0
- package/src/crossBranch/settings.ts +59 -0
- package/src/crossBranch/store.ts +71 -0
- package/src/crossBranch/types.ts +102 -0
- package/src/demo/DemoPage.tsx +184 -0
- package/src/demo/seed.ts +67 -0
- package/src/demo/store.ts +536 -0
- package/src/demo/viewEditor.ts +110 -0
- package/src/hooks/useSafeFitView.ts +60 -0
- package/src/index.css +309 -0
- package/src/index.ts +184 -0
- package/src/kafka-ss.png +0 -0
- package/src/lib/vscodeBridge-vscode.ts +27 -0
- package/src/lib/vscodeBridge.ts +7 -0
- package/src/main.tsx +46 -0
- package/src/pages/AppearanceSettings.tsx +135 -0
- package/src/pages/Dependencies.tsx +926 -0
- package/src/pages/InfiniteZoom.tsx +404 -0
- package/src/pages/Settings.tsx +91 -0
- package/src/pages/ViewEditor/EDGE_DISTRIBUTION.md +64 -0
- package/src/pages/ViewEditor/components/EditorMenus.tsx +112 -0
- package/src/pages/ViewEditor/components/EditorOverlays.tsx +172 -0
- package/src/pages/ViewEditor/components/EmptyCanvasState.tsx +42 -0
- package/src/pages/ViewEditor/context.tsx +21 -0
- package/src/pages/ViewEditor/hooks/useCanvasInteractions.ts +1349 -0
- package/src/pages/ViewEditor/hooks/useDrawingEngine.ts +127 -0
- package/src/pages/ViewEditor/hooks/useViewContextNeighbours.ts +501 -0
- package/src/pages/ViewEditor/hooks/useViewData.ts +491 -0
- package/src/pages/ViewEditor/index.tsx +1366 -0
- package/src/pages/ViewEditor/utils.ts +88 -0
- package/src/pages/Views.tsx +171 -0
- package/src/pages/ViewsGrid.tsx +1310 -0
- package/src/pkg/importer/mermaid.test.ts +141 -0
- package/src/pkg/importer/mermaid.ts +76 -0
- package/src/platform/PlatformContext.tsx +17 -0
- package/src/platform/context.ts +9 -0
- package/src/platform/local.tsx +15 -0
- package/src/platform/types.ts +19 -0
- package/src/slots.ts +92 -0
- package/src/styles/editor-panels.css +66 -0
- package/src/styles/theme.css +56 -0
- package/src/theme.ts +336 -0
- package/src/types/index.ts +234 -0
- package/src/types/offline-ambient.d.ts +14 -0
- package/src/types/vscode-messages.ts +32 -0
- package/src/utils/edgeDistribution.ts +103 -0
- package/src/utils/githubApi.ts +121 -0
- package/src/utils/githubCache.ts +108 -0
- package/src/utils/ids.ts +9 -0
- package/src/utils/technologyCatalog.ts +143 -0
- package/src/utils/toast.ts +100 -0
- package/src/utils/treesitter.ts +147 -0
- package/src/utils/url.ts +72 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Box } from '@chakra-ui/react'
|
|
3
|
+
import { useViewport, type Node as RFNode } from 'reactflow'
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_SOURCE_HANDLE_SIDE,
|
|
6
|
+
DEFAULT_TARGET_HANDLE_SIDE,
|
|
7
|
+
getHandleFlowPosition,
|
|
8
|
+
getLogicalHandleId,
|
|
9
|
+
} from '../../../utils/edgeDistribution'
|
|
10
|
+
|
|
11
|
+
interface EditorOverlaysProps {
|
|
12
|
+
connectGhostPos: { x: number; y: number } | null
|
|
13
|
+
clickConnectMode: { sourceNodeId: string; sourceHandle: string; targetHandle?: string } | null
|
|
14
|
+
clickConnectCursorPos: { x: number; y: number } | null
|
|
15
|
+
handleReconnectDrag: {
|
|
16
|
+
endpoint: 'source' | 'target'
|
|
17
|
+
fixedNodeId: string
|
|
18
|
+
fixedHandle: string
|
|
19
|
+
movingHandle: string
|
|
20
|
+
cursorPos: { x: number; y: number }
|
|
21
|
+
} | null
|
|
22
|
+
rfNodes: RFNode[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const EditorOverlays: React.FC<EditorOverlaysProps> = ({
|
|
26
|
+
connectGhostPos,
|
|
27
|
+
clickConnectMode,
|
|
28
|
+
clickConnectCursorPos,
|
|
29
|
+
handleReconnectDrag,
|
|
30
|
+
rfNodes,
|
|
31
|
+
}) => {
|
|
32
|
+
const viewportState = useViewport()
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<>
|
|
36
|
+
{/* Ghost node during connector drag */}
|
|
37
|
+
{connectGhostPos && (
|
|
38
|
+
<Box position="fixed" left={`${connectGhostPos.x - 90}px`} top={`${connectGhostPos.y - 42}px`}
|
|
39
|
+
width="180px" minHeight="85px" bg="rgba(var(--bg-element-rgb), 0.4)"
|
|
40
|
+
border="1px solid rgba(113, 128, 150, 0.45)" rounded="lg"
|
|
41
|
+
boxShadow="0 8px 32px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.25)"
|
|
42
|
+
pointerEvents="none" zIndex={9999} display="flex" flexDir="column"
|
|
43
|
+
alignItems="center" justifyContent="center" gap="6px" py={3} backdropFilter="blur(4px)">
|
|
44
|
+
<Box w="60%" h="10px" bg="rgba(226,232,240,0.18)" rounded="sm" />
|
|
45
|
+
<Box w="38%" h="7px" bg="rgba(var(--accent-rgb), 0.22)" rounded="sm" />
|
|
46
|
+
</Box>
|
|
47
|
+
)}
|
|
48
|
+
|
|
49
|
+
{/* Click-connect ghost connector */}
|
|
50
|
+
{clickConnectMode && clickConnectCursorPos && (() => {
|
|
51
|
+
const sourceNode = rfNodes.find((n) => n.id === clickConnectMode.sourceNodeId)
|
|
52
|
+
if (!sourceNode) return null
|
|
53
|
+
const w = sourceNode.width ?? 180; const h = sourceNode.height ?? 80
|
|
54
|
+
const sp = sourceNode.positionAbsolute ?? sourceNode.position
|
|
55
|
+
const { x: fx, y: fy, side: sourceSide } = getHandleFlowPosition(
|
|
56
|
+
sp.x,
|
|
57
|
+
sp.y,
|
|
58
|
+
w,
|
|
59
|
+
h,
|
|
60
|
+
clickConnectMode.sourceHandle,
|
|
61
|
+
DEFAULT_SOURCE_HANDLE_SIDE,
|
|
62
|
+
)
|
|
63
|
+
const rfRect = document.querySelector('.react-flow')?.getBoundingClientRect()
|
|
64
|
+
const rfX = rfRect?.left ?? 0; const rfY = rfRect?.top ?? 0
|
|
65
|
+
const sx = fx * viewportState.zoom + viewportState.x + rfX
|
|
66
|
+
const sy = fy * viewportState.zoom + viewportState.y + rfY
|
|
67
|
+
const tx = clickConnectCursorPos.x; const ty = clickConnectCursorPos.y
|
|
68
|
+
const dx = Math.abs(tx - sx); const dy = Math.abs(ty - sy)
|
|
69
|
+
const CURVATURE = 0.5
|
|
70
|
+
const isHSrc = sourceSide === 'left' || sourceSide === 'right'
|
|
71
|
+
const srcMinStem = (isHSrc ? w * 0.5 : h * 0.5) * viewportState.zoom
|
|
72
|
+
let c1x = sx, c1y = sy
|
|
73
|
+
if (sourceSide === 'left') c1x = sx - Math.max(dx * CURVATURE, srcMinStem)
|
|
74
|
+
else if (sourceSide === 'right') c1x = sx + Math.max(dx * CURVATURE, srcMinStem)
|
|
75
|
+
else if (sourceSide === 'top') c1y = sy - Math.max(dy * CURVATURE, srcMinStem)
|
|
76
|
+
else c1y = sy + Math.max(dy * CURVATURE, srcMinStem)
|
|
77
|
+
let c2x = tx, c2y = ty
|
|
78
|
+
if (clickConnectMode.targetHandle) {
|
|
79
|
+
const targetSide = getLogicalHandleId(clickConnectMode.targetHandle, DEFAULT_TARGET_HANDLE_SIDE) ?? DEFAULT_TARGET_HANDLE_SIDE
|
|
80
|
+
const tgtMinStem = (targetSide === 'left' || targetSide === 'right') ? 90 * viewportState.zoom : 40 * viewportState.zoom
|
|
81
|
+
if (targetSide === 'left') c2x = tx - Math.max(dx * CURVATURE, tgtMinStem)
|
|
82
|
+
else if (targetSide === 'right') c2x = tx + Math.max(dx * CURVATURE, tgtMinStem)
|
|
83
|
+
else if (targetSide === 'top') c2y = ty - Math.max(dy * CURVATURE, tgtMinStem)
|
|
84
|
+
else c2y = ty + Math.max(dy * CURVATURE, tgtMinStem)
|
|
85
|
+
}
|
|
86
|
+
return (
|
|
87
|
+
<svg key="click-connect-connector" style={{ position: 'fixed', inset: 0, width: '100%', height: '100%', pointerEvents: 'none', zIndex: 9997 }}>
|
|
88
|
+
<path d={`M${sx},${sy} C${c1x},${c1y} ${c2x},${c2y} ${tx},${ty}`}
|
|
89
|
+
className="react-flow__connector-path" stroke="var(--theme-blue)" strokeWidth="2" fill="none" opacity="0.8" />
|
|
90
|
+
</svg>
|
|
91
|
+
)
|
|
92
|
+
})()}
|
|
93
|
+
|
|
94
|
+
{/* Handle-reconnect ghost connector */}
|
|
95
|
+
{handleReconnectDrag && (() => {
|
|
96
|
+
const fixedNode = rfNodes.find((n) => n.id === handleReconnectDrag.fixedNodeId)
|
|
97
|
+
if (!fixedNode) return null
|
|
98
|
+
const w = fixedNode.width ?? 180
|
|
99
|
+
const h = fixedNode.height ?? 80
|
|
100
|
+
const sp = fixedNode.positionAbsolute ?? fixedNode.position
|
|
101
|
+
const { x: fx, y: fy } = getHandleFlowPosition(
|
|
102
|
+
sp.x,
|
|
103
|
+
sp.y,
|
|
104
|
+
w,
|
|
105
|
+
h,
|
|
106
|
+
handleReconnectDrag.fixedHandle,
|
|
107
|
+
handleReconnectDrag.endpoint === 'source' ? DEFAULT_TARGET_HANDLE_SIDE : DEFAULT_SOURCE_HANDLE_SIDE,
|
|
108
|
+
)
|
|
109
|
+
const rfRect = document.querySelector('.react-flow')?.getBoundingClientRect()
|
|
110
|
+
const rfX = rfRect?.left ?? 0
|
|
111
|
+
const rfY = rfRect?.top ?? 0
|
|
112
|
+
const fixedScreenX = fx * viewportState.zoom + viewportState.x + rfX
|
|
113
|
+
const fixedScreenY = fy * viewportState.zoom + viewportState.y + rfY
|
|
114
|
+
const movingScreenX = handleReconnectDrag.cursorPos.x
|
|
115
|
+
const movingScreenY = handleReconnectDrag.cursorPos.y
|
|
116
|
+
|
|
117
|
+
const sourceX = handleReconnectDrag.endpoint === 'source' ? movingScreenX : fixedScreenX
|
|
118
|
+
const sourceY = handleReconnectDrag.endpoint === 'source' ? movingScreenY : fixedScreenY
|
|
119
|
+
const targetX = handleReconnectDrag.endpoint === 'source' ? fixedScreenX : movingScreenX
|
|
120
|
+
const targetY = handleReconnectDrag.endpoint === 'source' ? fixedScreenY : movingScreenY
|
|
121
|
+
const sourceSide = getLogicalHandleId(
|
|
122
|
+
handleReconnectDrag.endpoint === 'source' ? handleReconnectDrag.movingHandle : handleReconnectDrag.fixedHandle,
|
|
123
|
+
DEFAULT_SOURCE_HANDLE_SIDE,
|
|
124
|
+
) ?? DEFAULT_SOURCE_HANDLE_SIDE
|
|
125
|
+
const targetSide = getLogicalHandleId(
|
|
126
|
+
handleReconnectDrag.endpoint === 'source' ? handleReconnectDrag.fixedHandle : handleReconnectDrag.movingHandle,
|
|
127
|
+
DEFAULT_TARGET_HANDLE_SIDE,
|
|
128
|
+
) ?? DEFAULT_TARGET_HANDLE_SIDE
|
|
129
|
+
|
|
130
|
+
const dx = Math.abs(targetX - sourceX)
|
|
131
|
+
const dy = Math.abs(targetY - sourceY)
|
|
132
|
+
const CURVATURE = 0.5
|
|
133
|
+
const isHSrc = sourceSide === 'left' || sourceSide === 'right'
|
|
134
|
+
const isHTgt = targetSide === 'left' || targetSide === 'right'
|
|
135
|
+
const srcMinStem = (handleReconnectDrag.endpoint === 'source'
|
|
136
|
+
? (isHSrc ? 90 : 40)
|
|
137
|
+
: (isHSrc ? w * 0.5 : h * 0.5)) * viewportState.zoom
|
|
138
|
+
const tgtMinStem = (handleReconnectDrag.endpoint === 'target'
|
|
139
|
+
? (isHTgt ? 90 : 40)
|
|
140
|
+
: (isHTgt ? w * 0.5 : h * 0.5)) * viewportState.zoom
|
|
141
|
+
|
|
142
|
+
let c1x = sourceX
|
|
143
|
+
let c1y = sourceY
|
|
144
|
+
if (sourceSide === 'left') c1x = sourceX - Math.max(dx * CURVATURE, srcMinStem)
|
|
145
|
+
else if (sourceSide === 'right') c1x = sourceX + Math.max(dx * CURVATURE, srcMinStem)
|
|
146
|
+
else if (sourceSide === 'top') c1y = sourceY - Math.max(dy * CURVATURE, srcMinStem)
|
|
147
|
+
else c1y = sourceY + Math.max(dy * CURVATURE, srcMinStem)
|
|
148
|
+
|
|
149
|
+
let c2x = targetX
|
|
150
|
+
let c2y = targetY
|
|
151
|
+
if (targetSide === 'left') c2x = targetX - Math.max(dx * CURVATURE, tgtMinStem)
|
|
152
|
+
else if (targetSide === 'right') c2x = targetX + Math.max(dx * CURVATURE, tgtMinStem)
|
|
153
|
+
else if (targetSide === 'top') c2y = targetY - Math.max(dy * CURVATURE, tgtMinStem)
|
|
154
|
+
else c2y = targetY + Math.max(dy * CURVATURE, tgtMinStem)
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<svg key="handle-reconnect-connector" style={{ position: 'fixed', inset: 0, width: '100%', height: '100%', pointerEvents: 'none', zIndex: 9998 }}>
|
|
158
|
+
<path
|
|
159
|
+
d={`M${sourceX},${sourceY} C${c1x},${c1y} ${c2x},${c2y} ${targetX},${targetY}`}
|
|
160
|
+
className="react-flow__connector-path"
|
|
161
|
+
stroke="var(--theme-blue)"
|
|
162
|
+
strokeWidth="2"
|
|
163
|
+
fill="none"
|
|
164
|
+
opacity="0.85"
|
|
165
|
+
/>
|
|
166
|
+
</svg>
|
|
167
|
+
)
|
|
168
|
+
})()}
|
|
169
|
+
|
|
170
|
+
</>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Box, Text } from '@chakra-ui/react'
|
|
3
|
+
|
|
4
|
+
interface EmptyCanvasStateProps {
|
|
5
|
+
isMobile: boolean
|
|
6
|
+
hasNodes: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const EmptyCanvasState: React.FC<EmptyCanvasStateProps> = ({ isMobile, hasNodes }) => {
|
|
10
|
+
if (hasNodes) return null
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Box position="absolute" top="50%" left="50%" transform="translate(-50%, -50%)"
|
|
14
|
+
textAlign="center" pointerEvents="none" px={4} userSelect="none">
|
|
15
|
+
<svg width="160" height="100" viewBox="0 0 160 100" style={{ display: 'block', margin: '0 auto 20px' }} xmlns="http://www.w3.org/2000/svg">
|
|
16
|
+
<defs>
|
|
17
|
+
<marker id="es-arr" markerWidth="7" markerHeight="7" refX="5" refY="3" orient="auto">
|
|
18
|
+
<path d="M0,0 L0,6 L7,3 z" fill="#374151" />
|
|
19
|
+
</marker>
|
|
20
|
+
</defs>
|
|
21
|
+
<rect x="0" y="0" width="48" height="100" rx="6" fill="#1C2535" stroke="#1F2937" strokeWidth="1" />
|
|
22
|
+
<rect x="6" y="12" width="36" height="14" rx="3" fill="#263044" />
|
|
23
|
+
<rect x="6" y="31" width="36" height="14" rx="3" fill="#2D3A50" stroke="#3B82F6" strokeWidth="0.8" />
|
|
24
|
+
<rect x="6" y="50" width="36" height="14" rx="3" fill="#263044" />
|
|
25
|
+
<line x1="50" y1="38" x2="63" y2="50" stroke="#374151" strokeWidth="1.4" strokeDasharray="3,2" markerEnd="url(#es-arr)" />
|
|
26
|
+
<rect x="56" y="4" width="104" height="92" rx="8" fill="#111827" stroke="#1F2937" strokeWidth="1" />
|
|
27
|
+
{Array.from({ length: 4 }, (_, r) => Array.from({ length: 6 }, (_, c) => (
|
|
28
|
+
<circle key={`${r}-${c}`} cx={(c * 15 + 66).toString()} cy={(r * 22 + 18).toString()} r="0.7" fill="#1F2937" />
|
|
29
|
+
))).flat()}
|
|
30
|
+
<rect x="66" y="28" width="84" height="44" rx="6" fill="none" stroke="#374151" strokeWidth="1.2" strokeDasharray="4,3" />
|
|
31
|
+
<rect x="76" y="38" width="36" height="22" rx="4" fill="#1C2535" stroke="#3B82F6" strokeWidth="1" opacity="0.6" />
|
|
32
|
+
<text x="94" y="53" textAnchor="middle" fill="#94A3B8" fontSize="7" fontFamily="system-ui,sans-serif">Service</text>
|
|
33
|
+
</svg>
|
|
34
|
+
<Text fontSize="md" fontWeight="semibold" color="gray.500" mb={1}>Start building your view</Text>
|
|
35
|
+
<Text fontSize="xs" color="gray.600" lineHeight="tall">
|
|
36
|
+
{isMobile
|
|
37
|
+
? 'Tap/Drag from the left panel, or Hold on the canvas to bring up the menu, then tap Add Element.'
|
|
38
|
+
: <> Drag from the left panel, or press <kbd style={{ fontFamily: 'monospace', background: '#1F2937', border: '1px solid #374151', borderRadius: 3, padding: '0 4px' }}>C</kbd> to create a new element directly.</>}
|
|
39
|
+
</Text>
|
|
40
|
+
</Box>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react'
|
|
2
|
+
import type { LibraryElement, Connector } from '../../types'
|
|
3
|
+
|
|
4
|
+
export interface ViewEditorContextValue {
|
|
5
|
+
viewId: number | null
|
|
6
|
+
canEdit: boolean
|
|
7
|
+
isOwner: boolean
|
|
8
|
+
isFreePlan: boolean
|
|
9
|
+
snapToGrid: boolean
|
|
10
|
+
setSnapToGrid: (snap: boolean) => void
|
|
11
|
+
selectedElement: LibraryElement | null
|
|
12
|
+
selectedConnector: Connector | null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const ViewEditorContext = createContext<ViewEditorContextValue | null>(null)
|
|
16
|
+
|
|
17
|
+
export function useViewEditorContext(): ViewEditorContextValue {
|
|
18
|
+
const ctx = useContext(ViewEditorContext)
|
|
19
|
+
if (!ctx) throw new Error('useViewEditorContext must be used inside ViewEditor')
|
|
20
|
+
return ctx
|
|
21
|
+
}
|