seat-editor 3.4.7 → 3.5.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/constant.d.ts +1 -1
- package/dist/app/graph-view/page.d.ts +1 -0
- package/dist/app/graph-view/page.js +343 -0
- package/dist/app/graph-view/page.jsx +445 -0
- package/dist/app/graph-view-new/constant.d.ts +581 -0
- package/dist/app/graph-view-new/constant.js +6973 -0
- package/dist/app/graph-view-new/page.d.ts +1 -0
- package/dist/app/graph-view-new/page.js +71 -0
- package/dist/app/graph-view-new/page.jsx +98 -0
- package/dist/app/new-board/page.js +43 -7
- package/dist/app/new-board/page.jsx +45 -12
- package/dist/components/button-tools/index.js +7 -5
- package/dist/components/button-tools/index.jsx +21 -9
- package/dist/components/form-tools/label.js +9 -20
- package/dist/components/form-tools/label.jsx +38 -28
- package/dist/components/form-tools/shape.js +5 -5
- package/dist/components/form-tools/shape.jsx +8 -8
- package/dist/components/layer-v3/index.js +44 -3
- package/dist/components/layer-v3/index.jsx +120 -3
- package/dist/components/layer-v4/index.js +3 -2
- package/dist/components/layer-v4/index.jsx +3 -2
- package/dist/components/layer-v5/constant.d.ts +60 -0
- package/dist/components/layer-v5/constant.js +93 -0
- package/dist/components/layer-v5/index.d.ts +24 -0
- package/dist/components/layer-v5/index.js +927 -0
- package/dist/components/layer-v5/index.jsx +1049 -0
- package/dist/features/board-v3/index.js +350 -72
- package/dist/features/board-v3/index.jsx +369 -75
- package/dist/features/board-v3/resize-element.js +5 -0
- package/dist/features/board-v3/utils.d.ts +8 -0
- package/dist/features/board-v3/utils.js +23 -7
- package/dist/features/package/index.d.ts +2 -0
- package/dist/features/package/index.js +1 -1
- package/dist/features/package/index.jsx +6 -1
- package/dist/features/panel/index.d.ts +8 -0
- package/dist/features/panel/index.js +160 -38
- package/dist/features/panel/index.jsx +173 -46
- package/dist/features/panel/polygon.d.ts +2 -0
- package/dist/features/panel/polygon.js +44 -0
- package/dist/features/panel/polygon.jsx +70 -0
- package/dist/features/panel/select-tool.js +3 -0
- package/dist/features/panel/select-tool.jsx +3 -0
- package/dist/features/panel/selected-group.js +24 -26
- package/dist/features/panel/selected-group.jsx +56 -51
- package/dist/features/panel/text-tool.js +17 -2
- package/dist/features/panel/text-tool.jsx +19 -2
- package/dist/features/panel/upload-tool.js +17 -3
- package/dist/features/panel/upload-tool.jsx +23 -4
- package/dist/features/side-tool/index.js +43 -6
- package/dist/features/side-tool/index.jsx +47 -10
- package/dist/features/view-only-4/connect-handle.d.ts +13 -0
- package/dist/features/view-only-4/connect-handle.js +23 -0
- package/dist/features/view-only-4/connect-handle.jsx +30 -0
- package/dist/features/view-only-4/connection-layer.d.ts +21 -0
- package/dist/features/view-only-4/connection-layer.js +219 -0
- package/dist/features/view-only-4/connection-layer.jsx +291 -0
- package/dist/features/view-only-4/index.d.ts +99 -0
- package/dist/features/view-only-4/index.js +684 -0
- package/dist/features/view-only-4/index.jsx +722 -0
- package/dist/features/view-only-4/integration-guide.d.ts +0 -0
- package/dist/features/view-only-4/integration-guide.js +0 -0
- package/dist/features/view-only-4/use-connection-graph.d.ts +41 -0
- package/dist/features/view-only-4/use-connection-graph.js +182 -0
- package/dist/features/view-only-4/utils.d.ts +74 -0
- package/dist/features/view-only-4/utils.js +106 -0
- package/dist/features/view-only-5/connect-handle.d.ts +30 -0
- package/dist/features/view-only-5/connect-handle.js +88 -0
- package/dist/features/view-only-5/connect-handle.jsx +96 -0
- package/dist/features/view-only-5/connection-layer.d.ts +34 -0
- package/dist/features/view-only-5/connection-layer.js +182 -0
- package/dist/features/view-only-5/connection-layer.jsx +265 -0
- package/dist/features/view-only-5/index.d.ts +102 -0
- package/dist/features/view-only-5/index.js +585 -0
- package/dist/features/view-only-5/index.jsx +614 -0
- package/dist/features/view-only-5/use-connection-graph.d.ts +57 -0
- package/dist/features/view-only-5/use-connection-graph.js +196 -0
- package/dist/features/view-only-5/utils.d.ts +52 -0
- package/dist/features/view-only-5/utils.js +80 -0
- package/dist/features/view-only-6/connect-handle.d.ts +13 -0
- package/dist/features/view-only-6/connect-handle.js +20 -0
- package/dist/features/view-only-6/connect-handle.jsx +21 -0
- package/dist/features/view-only-6/connection-layer.d.ts +22 -0
- package/dist/features/view-only-6/connection-layer.js +191 -0
- package/dist/features/view-only-6/connection-layer.jsx +244 -0
- package/dist/features/view-only-6/index.d.ts +99 -0
- package/dist/features/view-only-6/index.js +687 -0
- package/dist/features/view-only-6/index.jsx +724 -0
- package/dist/features/view-only-6/use-connection-graph.d.ts +26 -0
- package/dist/features/view-only-6/use-connection-graph.js +103 -0
- package/dist/features/view-only-6/utils.d.ts +66 -0
- package/dist/features/view-only-6/utils.js +96 -0
- package/dist/features/view-only-7/connect-handle.d.ts +13 -0
- package/dist/features/view-only-7/connect-handle.js +23 -0
- package/dist/features/view-only-7/connect-handle.jsx +30 -0
- package/dist/features/view-only-7/connection-layer.d.ts +22 -0
- package/dist/features/view-only-7/connection-layer.js +165 -0
- package/dist/features/view-only-7/connection-layer.jsx +217 -0
- package/dist/features/view-only-7/index.d.ts +99 -0
- package/dist/features/view-only-7/index.js +687 -0
- package/dist/features/view-only-7/index.jsx +724 -0
- package/dist/features/view-only-7/use-connection-graph.d.ts +26 -0
- package/dist/features/view-only-7/use-connection-graph.js +104 -0
- package/dist/features/view-only-7/utils.d.ts +69 -0
- package/dist/features/view-only-7/utils.js +144 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/seat-editor.css +1 -1
- package/package.json +1 -1
package/dist/app/constant.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function DrawIO(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useRef, useCallback } from "react";
|
|
4
|
+
const GRID_SIZE = 20;
|
|
5
|
+
const NODE_WIDTH = 120;
|
|
6
|
+
const NODE_HEIGHT = 50;
|
|
7
|
+
const snap = (v) => Math.round(v / GRID_SIZE) * GRID_SIZE;
|
|
8
|
+
const getRectEdge = (from, to) => {
|
|
9
|
+
const dx = to.x - from.x;
|
|
10
|
+
const dy = to.y - from.y;
|
|
11
|
+
const angle = Math.atan2(dy, dx);
|
|
12
|
+
const absCos = Math.abs(Math.cos(angle));
|
|
13
|
+
const absSin = Math.abs(Math.sin(angle));
|
|
14
|
+
const offset = (NODE_HEIGHT / 2) * absCos <= (NODE_WIDTH / 2) * absSin
|
|
15
|
+
? NODE_HEIGHT / 2 / absSin
|
|
16
|
+
: NODE_WIDTH / 2 / absCos;
|
|
17
|
+
return {
|
|
18
|
+
x: snap(from.x + Math.cos(angle) * offset),
|
|
19
|
+
y: snap(from.y + Math.sin(angle) * offset),
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
// Build orthogonal path through waypoints
|
|
23
|
+
const buildPath = (points) => {
|
|
24
|
+
if (points.length < 2)
|
|
25
|
+
return "";
|
|
26
|
+
let d = `M ${points[0].x} ${points[0].y}`;
|
|
27
|
+
for (let i = 1; i < points.length; i++) {
|
|
28
|
+
const prev = points[i - 1];
|
|
29
|
+
const curr = points[i];
|
|
30
|
+
const midX = snap((prev.x + curr.x) / 2);
|
|
31
|
+
if (i === points.length - 1) {
|
|
32
|
+
d += ` H ${midX} V ${curr.y} H ${curr.x}`;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
d += ` H ${midX} V ${curr.y} H ${curr.x}`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return d;
|
|
39
|
+
};
|
|
40
|
+
// Generate default waypoints between two nodes
|
|
41
|
+
const defaultWaypoints = (start, end) => {
|
|
42
|
+
const midX = snap((start.x + end.x) / 2);
|
|
43
|
+
const midY = snap((start.y + end.y) / 2);
|
|
44
|
+
return [{ x: midX, y: midY }];
|
|
45
|
+
};
|
|
46
|
+
const NODE_COLORS = [
|
|
47
|
+
{ bg: "#1e293b", border: "#38bdf8", text: "#e0f2fe" },
|
|
48
|
+
{ bg: "#1e1b2e", border: "#a78bfa", text: "#ede9fe" },
|
|
49
|
+
{ bg: "#0f2720", border: "#34d399", text: "#d1fae5" },
|
|
50
|
+
{ bg: "#2d1515", border: "#f87171", text: "#fee2e2" },
|
|
51
|
+
{ bg: "#1a1a10", border: "#fbbf24", text: "#fef9c3" },
|
|
52
|
+
];
|
|
53
|
+
let nodeCounter = 3;
|
|
54
|
+
const initialNodes = [
|
|
55
|
+
{ id: "1", x: 100, y: 160, label: "Start", colorIdx: 2 },
|
|
56
|
+
{ id: "2", x: 380, y: 260, label: "Process", colorIdx: 0 },
|
|
57
|
+
{ id: "3", x: 660, y: 160, label: "End", colorIdx: 3 },
|
|
58
|
+
];
|
|
59
|
+
export default function DrawIO() {
|
|
60
|
+
const [nodes, setNodes] = useState(initialNodes);
|
|
61
|
+
const [edges, setEdges] = useState(() => {
|
|
62
|
+
const e1start = getRectEdge(initialNodes[0], initialNodes[1]);
|
|
63
|
+
const e1end = getRectEdge(initialNodes[1], initialNodes[0]);
|
|
64
|
+
const e2start = getRectEdge(initialNodes[1], initialNodes[2]);
|
|
65
|
+
const e2end = getRectEdge(initialNodes[2], initialNodes[1]);
|
|
66
|
+
return [
|
|
67
|
+
{
|
|
68
|
+
id: "e1",
|
|
69
|
+
from: "1",
|
|
70
|
+
to: "2",
|
|
71
|
+
waypoints: defaultWaypoints(e1start, e1end),
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: "e2",
|
|
75
|
+
from: "2",
|
|
76
|
+
to: "3",
|
|
77
|
+
waypoints: defaultWaypoints(e2start, e2end),
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
});
|
|
81
|
+
const [draggingNode, setDraggingNode] = useState(null);
|
|
82
|
+
const [draggingWP, setDraggingWP] = useState(null); // { edgeId, index }
|
|
83
|
+
const [connecting, setConnecting] = useState(null);
|
|
84
|
+
const [selectedNode, setSelectedNode] = useState(null);
|
|
85
|
+
const [selectedEdge, setSelectedEdge] = useState(null);
|
|
86
|
+
const [mousePos, setMousePos] = useState({ x: 0, y: 0 });
|
|
87
|
+
const [showGrid, setShowGrid] = useState(true);
|
|
88
|
+
const svgRef = useRef(null);
|
|
89
|
+
const getSVGPoint = useCallback((e) => {
|
|
90
|
+
const rect = svgRef.current.getBoundingClientRect();
|
|
91
|
+
return { x: e.clientX - rect.left, y: e.clientY - rect.top };
|
|
92
|
+
}, []);
|
|
93
|
+
const handleMouseMove = useCallback((e) => {
|
|
94
|
+
const pt = getSVGPoint(e);
|
|
95
|
+
setMousePos(pt);
|
|
96
|
+
if (draggingNode) {
|
|
97
|
+
const snappedX = snap(pt.x - draggingNode.offsetX);
|
|
98
|
+
const snappedY = snap(pt.y - draggingNode.offsetY);
|
|
99
|
+
setNodes((prev) => prev.map((n) => n.id === draggingNode.id ? Object.assign(Object.assign({}, n), { x: snappedX, y: snappedY }) : n));
|
|
100
|
+
}
|
|
101
|
+
if (draggingWP) {
|
|
102
|
+
setEdges((prev) => prev.map((ed) => {
|
|
103
|
+
if (ed.id !== draggingWP.edgeId)
|
|
104
|
+
return ed;
|
|
105
|
+
const newWP = ed.waypoints.map((wp, i) => i === draggingWP.index ? { x: snap(pt.x), y: snap(pt.y) } : wp);
|
|
106
|
+
return Object.assign(Object.assign({}, ed), { waypoints: newWP });
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
}, [draggingNode, draggingWP, getSVGPoint]);
|
|
110
|
+
const handleMouseUp = useCallback(() => {
|
|
111
|
+
setDraggingNode(null);
|
|
112
|
+
setDraggingWP(null);
|
|
113
|
+
}, []);
|
|
114
|
+
const handleNodeMouseDown = (e, nodeId) => {
|
|
115
|
+
e.stopPropagation();
|
|
116
|
+
if (connecting)
|
|
117
|
+
return;
|
|
118
|
+
const pt = getSVGPoint(e);
|
|
119
|
+
const node = nodes.find((n) => n.id === nodeId);
|
|
120
|
+
setDraggingNode({
|
|
121
|
+
id: nodeId,
|
|
122
|
+
offsetX: pt.x - node.x,
|
|
123
|
+
offsetY: pt.y - node.y,
|
|
124
|
+
});
|
|
125
|
+
setSelectedNode(nodeId);
|
|
126
|
+
setSelectedEdge(null);
|
|
127
|
+
};
|
|
128
|
+
const handleWaypointMouseDown = (e, edgeId, index) => {
|
|
129
|
+
e.stopPropagation();
|
|
130
|
+
setDraggingWP({ edgeId, index });
|
|
131
|
+
setSelectedEdge(edgeId);
|
|
132
|
+
setSelectedNode(null);
|
|
133
|
+
};
|
|
134
|
+
// Add waypoint on edge double-click
|
|
135
|
+
const handleEdgeDoubleClick = (e, edgeId) => {
|
|
136
|
+
e.stopPropagation();
|
|
137
|
+
const pt = getSVGPoint(e);
|
|
138
|
+
setEdges((prev) => prev.map((ed) => {
|
|
139
|
+
if (ed.id !== edgeId)
|
|
140
|
+
return ed;
|
|
141
|
+
// Insert waypoint near click position
|
|
142
|
+
const newWP = [...ed.waypoints, { x: snap(pt.x), y: snap(pt.y) }];
|
|
143
|
+
// Sort by proximity to path order (simple: by x if mostly horizontal)
|
|
144
|
+
return Object.assign(Object.assign({}, ed), { waypoints: newWP });
|
|
145
|
+
}));
|
|
146
|
+
};
|
|
147
|
+
// Remove waypoint on right-click
|
|
148
|
+
const handleWaypointRightClick = (e, edgeId, index) => {
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
e.stopPropagation();
|
|
151
|
+
setEdges((prev) => prev.map((ed) => {
|
|
152
|
+
if (ed.id !== edgeId)
|
|
153
|
+
return ed;
|
|
154
|
+
if (ed.waypoints.length <= 1)
|
|
155
|
+
return ed; // keep at least 1
|
|
156
|
+
return Object.assign(Object.assign({}, ed), { waypoints: ed.waypoints.filter((_, i) => i !== index) });
|
|
157
|
+
}));
|
|
158
|
+
};
|
|
159
|
+
const handleConnectStart = (e, nodeId) => {
|
|
160
|
+
e.stopPropagation();
|
|
161
|
+
setConnecting({ fromId: nodeId });
|
|
162
|
+
setSelectedNode(null);
|
|
163
|
+
setSelectedEdge(null);
|
|
164
|
+
};
|
|
165
|
+
const handleConnectEnd = (e, nodeId) => {
|
|
166
|
+
e.stopPropagation();
|
|
167
|
+
if (connecting && connecting.fromId !== nodeId) {
|
|
168
|
+
const exists = edges.find((ed) => (ed.from === connecting.fromId && ed.to === nodeId) ||
|
|
169
|
+
(ed.from === nodeId && ed.to === connecting.fromId));
|
|
170
|
+
if (!exists) {
|
|
171
|
+
const fromNode = nodes.find((n) => n.id === connecting.fromId);
|
|
172
|
+
const toNode = nodes.find((n) => n.id === nodeId);
|
|
173
|
+
const start = getRectEdge(fromNode, toNode);
|
|
174
|
+
const end = getRectEdge(toNode, fromNode);
|
|
175
|
+
setEdges((prev) => [
|
|
176
|
+
...prev,
|
|
177
|
+
{
|
|
178
|
+
id: `e${Date.now()}`,
|
|
179
|
+
from: connecting.fromId,
|
|
180
|
+
to: nodeId,
|
|
181
|
+
waypoints: defaultWaypoints(start, end),
|
|
182
|
+
},
|
|
183
|
+
]);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
setConnecting(null);
|
|
187
|
+
};
|
|
188
|
+
const addNode = () => {
|
|
189
|
+
nodeCounter++;
|
|
190
|
+
setNodes((prev) => [
|
|
191
|
+
...prev,
|
|
192
|
+
{
|
|
193
|
+
id: String(nodeCounter),
|
|
194
|
+
x: snap(120 + Math.random() * 380),
|
|
195
|
+
y: snap(80 + Math.random() * 220),
|
|
196
|
+
label: `Node ${nodeCounter}`,
|
|
197
|
+
colorIdx: Math.floor(Math.random() * NODE_COLORS.length),
|
|
198
|
+
},
|
|
199
|
+
]);
|
|
200
|
+
};
|
|
201
|
+
const deleteSelected = () => {
|
|
202
|
+
if (selectedNode) {
|
|
203
|
+
setNodes((prev) => prev.filter((n) => n.id !== selectedNode));
|
|
204
|
+
setEdges((prev) => prev.filter((e) => e.from !== selectedNode && e.to !== selectedNode));
|
|
205
|
+
setSelectedNode(null);
|
|
206
|
+
}
|
|
207
|
+
if (selectedEdge) {
|
|
208
|
+
setEdges((prev) => prev.filter((e) => e.id !== selectedEdge));
|
|
209
|
+
setSelectedEdge(null);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
const renameSelected = () => {
|
|
213
|
+
if (!selectedNode)
|
|
214
|
+
return;
|
|
215
|
+
const node = nodes.find((n) => n.id === selectedNode);
|
|
216
|
+
const label = window.prompt("Rename node:", node.label);
|
|
217
|
+
if (label)
|
|
218
|
+
setNodes((prev) => prev.map((n) => (n.id === selectedNode ? Object.assign(Object.assign({}, n), { label }) : n)));
|
|
219
|
+
};
|
|
220
|
+
return (_jsxs("div", { style: {
|
|
221
|
+
width: "100vw",
|
|
222
|
+
height: "100vh",
|
|
223
|
+
background: "#0a0e1a",
|
|
224
|
+
display: "flex",
|
|
225
|
+
flexDirection: "column",
|
|
226
|
+
fontFamily: "'IBM Plex Mono', monospace",
|
|
227
|
+
color: "#94a3b8",
|
|
228
|
+
}, children: [_jsxs("div", { style: {
|
|
229
|
+
display: "flex",
|
|
230
|
+
alignItems: "center",
|
|
231
|
+
gap: 8,
|
|
232
|
+
padding: "10px 20px",
|
|
233
|
+
background: "#0f1629",
|
|
234
|
+
borderBottom: "1px solid #1e2d4a",
|
|
235
|
+
flexShrink: 0,
|
|
236
|
+
}, children: [_jsx("span", { style: {
|
|
237
|
+
color: "#38bdf8",
|
|
238
|
+
fontWeight: 700,
|
|
239
|
+
fontSize: 15,
|
|
240
|
+
marginRight: 16,
|
|
241
|
+
letterSpacing: 2,
|
|
242
|
+
}, children: "\u25C8 DIAGRAM" }), [
|
|
243
|
+
{ label: "+ Node", action: addNode, color: "#34d399" },
|
|
244
|
+
{
|
|
245
|
+
label: "✎ Rename",
|
|
246
|
+
action: renameSelected,
|
|
247
|
+
color: "#fbbf24",
|
|
248
|
+
disabled: !selectedNode,
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
label: "✕ Delete",
|
|
252
|
+
action: deleteSelected,
|
|
253
|
+
color: "#f87171",
|
|
254
|
+
disabled: !selectedNode && !selectedEdge,
|
|
255
|
+
},
|
|
256
|
+
].map((btn) => (_jsx("button", { onClick: btn.action, disabled: btn.disabled, style: {
|
|
257
|
+
background: "transparent",
|
|
258
|
+
border: `1px solid ${btn.disabled ? "#1e2d4a" : btn.color}`,
|
|
259
|
+
color: btn.disabled ? "#2d3f5a" : btn.color,
|
|
260
|
+
padding: "5px 14px",
|
|
261
|
+
borderRadius: 4,
|
|
262
|
+
cursor: btn.disabled ? "default" : "pointer",
|
|
263
|
+
fontSize: 12,
|
|
264
|
+
fontFamily: "inherit",
|
|
265
|
+
letterSpacing: 1,
|
|
266
|
+
}, children: btn.label }, btn.label))), _jsxs("label", { style: {
|
|
267
|
+
marginLeft: "auto",
|
|
268
|
+
display: "flex",
|
|
269
|
+
alignItems: "center",
|
|
270
|
+
gap: 6,
|
|
271
|
+
fontSize: 12,
|
|
272
|
+
cursor: "pointer",
|
|
273
|
+
}, children: [_jsx("input", { type: "checkbox", checked: showGrid, onChange: (e) => setShowGrid(e.target.checked) }), " ", "Grid"] }), connecting && (_jsx("span", { style: { color: "#a78bfa", fontSize: 12, marginLeft: 8 }, children: "\u27F3 Click target node\u2026 (ESC)" }))] }), _jsx("div", { style: {
|
|
274
|
+
padding: "4px 20px",
|
|
275
|
+
fontSize: 11,
|
|
276
|
+
color: "#2d3f5a",
|
|
277
|
+
background: "#0a0e1a",
|
|
278
|
+
borderBottom: "1px solid #111827",
|
|
279
|
+
}, children: "Drag nodes \u00B7 \u2295 to connect \u00B7 Double-click edge to add waypoint \u00B7 Drag waypoint \u25CF to reshape \u00B7 Right-click waypoint to remove" }), _jsxs("svg", { ref: svgRef, style: { flex: 1, cursor: connecting ? "crosshair" : "default" }, onMouseMove: handleMouseMove, onMouseUp: handleMouseUp, onClick: () => {
|
|
280
|
+
setSelectedNode(null);
|
|
281
|
+
setSelectedEdge(null);
|
|
282
|
+
if (connecting)
|
|
283
|
+
setConnecting(null);
|
|
284
|
+
}, tabIndex: 0, onKeyDown: (e) => e.key === "Escape" && setConnecting(null), children: [_jsxs("defs", { children: [_jsx("pattern", { id: "sg", width: GRID_SIZE, height: GRID_SIZE, patternUnits: "userSpaceOnUse", children: _jsx("path", { d: `M ${GRID_SIZE} 0 L 0 0 0 ${GRID_SIZE}`, fill: "none", stroke: "#111827", strokeWidth: 0.5 }) }), _jsxs("pattern", { id: "bg", width: GRID_SIZE * 5, height: GRID_SIZE * 5, patternUnits: "userSpaceOnUse", children: [_jsx("rect", { width: GRID_SIZE * 5, height: GRID_SIZE * 5, fill: "url(#sg)" }), _jsx("path", { d: `M ${GRID_SIZE * 5} 0 L 0 0 0 ${GRID_SIZE * 5}`, fill: "none", stroke: "#1a2540", strokeWidth: 1 })] }), _jsx("marker", { id: "arrow", markerWidth: "8", markerHeight: "8", refX: "7", refY: "3", orient: "auto", children: _jsx("path", { d: "M 0 0 L 8 3 L 0 6 Z", fill: "#38bdf8", opacity: 0.8 }) }), _jsx("marker", { id: "arrow-sel", markerWidth: "8", markerHeight: "8", refX: "7", refY: "3", orient: "auto", children: _jsx("path", { d: "M 0 0 L 8 3 L 0 6 Z", fill: "#a78bfa" }) }), _jsx("marker", { id: "arrow-preview", markerWidth: "8", markerHeight: "8", refX: "7", refY: "3", orient: "auto", children: _jsx("path", { d: "M 0 0 L 8 3 L 0 6 Z", fill: "#a78bfa", opacity: 0.8 }) }), _jsxs("filter", { id: "glow", children: [_jsx("feGaussianBlur", { stdDeviation: "3", result: "coloredBlur" }), _jsxs("feMerge", { children: [_jsx("feMergeNode", { in: "coloredBlur" }), _jsx("feMergeNode", { in: "SourceGraphic" })] })] })] }), showGrid && _jsx("rect", { width: "100%", height: "100%", fill: "url(#bg)" }), edges.map((edge) => {
|
|
285
|
+
const fromNode = nodes.find((n) => n.id === edge.from);
|
|
286
|
+
const toNode = nodes.find((n) => n.id === edge.to);
|
|
287
|
+
if (!fromNode || !toNode)
|
|
288
|
+
return null;
|
|
289
|
+
const start = getRectEdge(fromNode, toNode);
|
|
290
|
+
const end = getRectEdge(toNode, fromNode);
|
|
291
|
+
const allPoints = [start, ...edge.waypoints, end];
|
|
292
|
+
const pathD = buildPath(allPoints);
|
|
293
|
+
const isSelected = selectedEdge === edge.id;
|
|
294
|
+
return (_jsxs("g", { children: [_jsx("path", { d: pathD, stroke: "transparent", strokeWidth: 12, fill: "none", style: { cursor: "pointer" }, onClick: (e) => {
|
|
295
|
+
e.stopPropagation();
|
|
296
|
+
setSelectedEdge(edge.id);
|
|
297
|
+
setSelectedNode(null);
|
|
298
|
+
}, onDoubleClick: (e) => handleEdgeDoubleClick(e, edge.id) }), isSelected && (_jsx("path", { d: pathD, stroke: "#a78bfa", strokeWidth: 6, fill: "none", opacity: 0.15 })), _jsx("path", { d: pathD, stroke: isSelected ? "#a78bfa" : "#38bdf8", strokeWidth: isSelected ? 2 : 1.5, fill: "none", opacity: 0.85, markerEnd: isSelected ? "url(#arrow-sel)" : "url(#arrow)", style: { pointerEvents: "none" } }), edge.waypoints.map((wp, i) => (_jsxs("g", { children: [_jsx("circle", { cx: wp.x, cy: wp.y, r: isSelected ? 8 : 5, fill: isSelected ? "#1e1b2e" : "#0a0e1a", stroke: isSelected ? "#a78bfa" : "#38bdf8", strokeWidth: isSelected ? 2 : 1, style: { cursor: "grab" }, onMouseDown: (e) => handleWaypointMouseDown(e, edge.id, i), onContextMenu: (e) => handleWaypointRightClick(e, edge.id, i) }), _jsx("circle", { cx: wp.x, cy: wp.y, r: isSelected ? 3 : 2, fill: isSelected ? "#a78bfa" : "#38bdf8", style: { pointerEvents: "none" } })] }, i))), isSelected &&
|
|
299
|
+
allPoints.slice(0, -1).map((pt, i) => {
|
|
300
|
+
const next = allPoints[i + 1];
|
|
301
|
+
const mx = snap((pt.x + next.x) / 2);
|
|
302
|
+
const my = snap((pt.y + next.y) / 2);
|
|
303
|
+
return (_jsx("circle", { cx: mx, cy: my, r: 4, fill: "#1e1b2e", stroke: "#a78bfa", strokeWidth: 1, strokeDasharray: "2 2", style: { cursor: "crosshair" }, onMouseDown: (e) => {
|
|
304
|
+
e.stopPropagation();
|
|
305
|
+
// Insert new waypoint at this midpoint
|
|
306
|
+
setEdges((prev) => prev.map((ed) => {
|
|
307
|
+
if (ed.id !== edge.id)
|
|
308
|
+
return ed;
|
|
309
|
+
const newWP = [...ed.waypoints];
|
|
310
|
+
// Insert after i-1 (offset by 1 for start point)
|
|
311
|
+
newWP.splice(i, 0, { x: mx, y: my });
|
|
312
|
+
return Object.assign(Object.assign({}, ed), { waypoints: newWP });
|
|
313
|
+
}));
|
|
314
|
+
setDraggingWP({ edgeId: edge.id, index: i });
|
|
315
|
+
} }, `mid-${i}`));
|
|
316
|
+
})] }, edge.id));
|
|
317
|
+
}), connecting &&
|
|
318
|
+
(() => {
|
|
319
|
+
const fromNode = nodes.find((n) => n.id === connecting.fromId);
|
|
320
|
+
if (!fromNode)
|
|
321
|
+
return null;
|
|
322
|
+
const start = getRectEdge(fromNode, mousePos);
|
|
323
|
+
const pathD = buildPath([
|
|
324
|
+
start,
|
|
325
|
+
{ x: snap(mousePos.x), y: snap(mousePos.y) },
|
|
326
|
+
]);
|
|
327
|
+
return (_jsx("path", { d: pathD, stroke: "#a78bfa", strokeWidth: 1.5, fill: "none", strokeDasharray: "6 3", markerEnd: "url(#arrow-preview)", opacity: 0.8 }));
|
|
328
|
+
})(), nodes.map((node) => {
|
|
329
|
+
const c = NODE_COLORS[node.colorIdx % NODE_COLORS.length];
|
|
330
|
+
const isSelected = selectedNode === node.id;
|
|
331
|
+
const hw = NODE_WIDTH / 2;
|
|
332
|
+
const hh = NODE_HEIGHT / 2;
|
|
333
|
+
return (_jsxs("g", { transform: `translate(${node.x}, ${node.y})`, onMouseDown: (e) => handleNodeMouseDown(e, node.id), onMouseUp: (e) => connecting && handleConnectEnd(e, node.id), style: {
|
|
334
|
+
cursor: (draggingNode === null || draggingNode === void 0 ? void 0 : draggingNode.id) === node.id ? "grabbing" : "grab",
|
|
335
|
+
}, children: [isSelected && (_jsx("rect", { x: -hw - 4, y: -hh - 4, width: NODE_WIDTH + 8, height: NODE_HEIGHT + 8, fill: "none", stroke: c.border, strokeWidth: 1, rx: 6, opacity: 0.4, filter: "url(#glow)" })), _jsx("rect", { x: -hw, y: -hh, width: NODE_WIDTH, height: NODE_HEIGHT, fill: c.bg, stroke: c.border, strokeWidth: isSelected ? 2 : 1, rx: 4, filter: isSelected ? "url(#glow)" : "none" }), _jsx("rect", { x: -hw, y: -hh, width: NODE_WIDTH, height: 3, fill: c.border, rx: 4, opacity: 0.8 }), _jsx("text", { textAnchor: "middle", dominantBaseline: "middle", y: 2, fill: c.text, fontSize: 12, fontFamily: "'IBM Plex Mono', monospace", fontWeight: 500, style: { pointerEvents: "none", userSelect: "none" }, children: node.label }), _jsxs("g", { transform: `translate(${hw - 2}, ${-hh - 8})`, style: { cursor: "crosshair" }, onMouseDown: (e) => {
|
|
336
|
+
e.stopPropagation();
|
|
337
|
+
handleConnectStart(e, node.id);
|
|
338
|
+
}, children: [_jsx("circle", { r: 7, fill: "#0a0e1a", stroke: c.border, strokeWidth: 1 }), _jsx("text", { textAnchor: "middle", dominantBaseline: "middle", fill: c.border, fontSize: 10, fontWeight: 700, style: { pointerEvents: "none" }, children: "\u2295" })] })] }, node.id));
|
|
339
|
+
})] }), _jsx("style", { children: `
|
|
340
|
+
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;700&display=swap');
|
|
341
|
+
* { box-sizing: border-box; }
|
|
342
|
+
` })] }));
|
|
343
|
+
}
|