seat-editor 3.6.28 → 3.6.30

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.
@@ -35,13 +35,10 @@ export default function GraphView() {
35
35
  },
36
36
  ]);
37
37
  const [sectionActive, setSectionActive] = useState(null);
38
- const componentSection = useMemo(() => {
38
+ const componentSection = useMemo(() => data === null || data === void 0 ? void 0 : data.map((data) => {
39
39
  var _a;
40
- return (_a = data === null || data === void 0 ? void 0 : data.map((data) => {
41
- var _a;
42
- return (Object.assign(Object.assign({}, data), { section: (_a = sections.find((section) => section.items.some((item) => item.uuid_table === data.uuid_table))) === null || _a === void 0 ? void 0 : _a.id }));
43
- })) === null || _a === void 0 ? void 0 : _a.slice(0, 10);
44
- }, [data, sections]);
40
+ return (Object.assign(Object.assign({}, data), { section: (_a = sections.find((section) => section.items.some((item) => item.uuid_table === data.uuid_table))) === null || _a === void 0 ? void 0 : _a.id }));
41
+ }), [data, sections]);
45
42
  const onMakeSelection = (datas) => {
46
43
  setSections((prev) => {
47
44
  const uuidSet = new Set(datas.map((d) => d.uuid_table));
@@ -145,11 +142,16 @@ export default function GraphView() {
145
142
  setDataDrag(null);
146
143
  }
147
144
  };
145
+ const [edges, setEdges] = useState([]);
146
+ console.log({ edges });
148
147
  return (_jsx("div", { className: "w-full h-screen flex relative", children: _jsxs("div", { className: "flex", children: [_jsx("div", { className: "absolute top-0 left-0 z-10 flex gap-2", children: priviledged.map((item) => (_jsx(Button, { type: actionPrivileged[item.key] ? "primary" : "default", htmlType: "button", onClick: () => {
149
148
  setActionPrivileged((prev) => (Object.assign(Object.assign({}, prev), { [item.key]: !prev[item.key] })));
150
- }, children: item.name }, item.key))) }), _jsx(LayerView, { componentProps: componentSection, statusKey: "section", defaultBackground: "#1e2d4a", mappingKey: "properties", keyNode: "nodes", onEdgesChange: (table, edges) => console.log({ edges, table }), isConnectEdge: isConnecting, isSelectNode: isSelectNode, connectionMatchKey: {
151
- key: "use_connection",
152
- value: 1
149
+ }, children: item.name }, item.key))) }), _jsx(LayerView, { componentProps: componentSection, statusKey: "section", defaultBackground: "#1e2d4a", mappingKey: "properties", keyNode: "nodes", onEdgesChange: (edges, table) => {
150
+ console.log(edges, "edges");
151
+ setEdges(edges);
152
+ }, initialEdges: edges, isConnectEdge: isConnecting, isSelectNode: isSelectNode, connectionMatchKey: {
153
+ key: "use_checking_availability",
154
+ value: 0
153
155
  },
154
156
  // extraComponentProps={background}
155
157
  onSelectComponent: handleSelectItem,
@@ -34,13 +34,10 @@ export default function GraphView() {
34
34
  },
35
35
  ]);
36
36
  const [sectionActive, setSectionActive] = useState(null);
37
- const componentSection = useMemo(() => {
37
+ const componentSection = useMemo(() => data === null || data === void 0 ? void 0 : data.map((data) => {
38
38
  var _a;
39
- return (_a = data === null || data === void 0 ? void 0 : data.map((data) => {
40
- var _a;
41
- return (Object.assign(Object.assign({}, data), { section: (_a = sections.find((section) => section.items.some((item) => item.uuid_table === data.uuid_table))) === null || _a === void 0 ? void 0 : _a.id }));
42
- })) === null || _a === void 0 ? void 0 : _a.slice(0, 10);
43
- }, [data, sections]);
39
+ return (Object.assign(Object.assign({}, data), { section: (_a = sections.find((section) => section.items.some((item) => item.uuid_table === data.uuid_table))) === null || _a === void 0 ? void 0 : _a.id }));
40
+ }), [data, sections]);
44
41
  const onMakeSelection = (datas) => {
45
42
  setSections((prev) => {
46
43
  const uuidSet = new Set(datas.map((d) => d.uuid_table));
@@ -144,6 +141,8 @@ export default function GraphView() {
144
141
  setDataDrag(null);
145
142
  }
146
143
  };
144
+ const [edges, setEdges] = useState([]);
145
+ console.log({ edges });
147
146
  return (<div className="w-full h-screen flex relative">
148
147
  <div className="flex">
149
148
  <div className="absolute top-0 left-0 z-10 flex gap-2">
@@ -153,9 +152,12 @@ export default function GraphView() {
153
152
  {item.name}
154
153
  </Button>))}
155
154
  </div>
156
- <LayerView componentProps={componentSection} statusKey="section" defaultBackground="#1e2d4a" mappingKey="properties" keyNode="nodes" onEdgesChange={(table, edges) => console.log({ edges, table })} isConnectEdge={isConnecting} isSelectNode={isSelectNode} connectionMatchKey={{
157
- key: "use_connection",
158
- value: 1
155
+ <LayerView componentProps={componentSection} statusKey="section" defaultBackground="#1e2d4a" mappingKey="properties" keyNode="nodes" onEdgesChange={(edges, table) => {
156
+ console.log(edges, "edges");
157
+ setEdges(edges);
158
+ }} initialEdges={edges} isConnectEdge={isConnecting} isSelectNode={isSelectNode} connectionMatchKey={{
159
+ key: "use_checking_availability",
160
+ value: 0
159
161
  }}
160
162
  // extraComponentProps={background}
161
163
  onSelectComponent={handleSelectItem}
@@ -71,9 +71,13 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
71
71
  }
72
72
  else if (isActive) {
73
73
  onEndConnect(nodeId, worldPos);
74
+ onSelectEdge && onSelectEdge("");
75
+ onSelectNode && onSelectNode("");
74
76
  return;
75
77
  }
76
78
  else {
79
+ onSelectNode && onSelectNode("");
80
+ onSelectEdge && onSelectEdge("");
77
81
  onStartConnect(nodeId, worldPos);
78
82
  }
79
83
  };
@@ -70,9 +70,13 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
70
70
  }
71
71
  else if (isActive) {
72
72
  onEndConnect(nodeId, worldPos);
73
+ onSelectEdge && onSelectEdge("");
74
+ onSelectNode && onSelectNode("");
73
75
  return;
74
76
  }
75
77
  else {
78
+ onSelectNode && onSelectNode("");
79
+ onSelectEdge && onSelectEdge("");
76
80
  onStartConnect(nodeId, worldPos);
77
81
  }
78
82
  };
@@ -41,6 +41,7 @@ type Props = {
41
41
  key: string;
42
42
  value: string | number;
43
43
  };
44
+ isSelectNode?: boolean;
44
45
  };
45
46
  export declare const ConnectionLayer: React.FC<Props>;
46
47
  export {};
@@ -45,7 +45,7 @@ const quadraticMidpoint = (from, to) => {
45
45
  y: mt * mt * from.y + 2 * mt * t * cpy + t * t * to.y,
46
46
  };
47
47
  };
48
- export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAnchor, mousePos, isConnectEdge, getNodeById, onSelectEdge, onDeleteEdge, onStartDragWaypoint, onInsertWaypoint, onRemoveWaypoint, onStartDragAnchor, selectedNodeId, showConnection, renderedElements, groupSelection, connectionMatchKey, }) => {
48
+ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAnchor, mousePos, isConnectEdge, getNodeById, onSelectEdge, onDeleteEdge, onStartDragWaypoint, onInsertWaypoint, onRemoveWaypoint, onStartDragAnchor, selectedNodeId, showConnection, renderedElements, groupSelection, connectionMatchKey, isSelectNode }) => {
49
49
  const [hoveredEdge, setHoveredEdge] = useState(null);
50
50
  const tableMatchConnectionKey = useMemo(() => renderedElements === null || renderedElements === void 0 ? void 0 : renderedElements.filter((el) => {
51
51
  if (connectionMatchKey) {
@@ -53,6 +53,7 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
53
53
  }
54
54
  return true;
55
55
  }), [renderedElements, connectionMatchKey]);
56
+ console.log("tableMatchConnectionKey", tableMatchConnectionKey);
56
57
  const nodeHighlightMap = useMemo(() => {
57
58
  if (!selectedEdge)
58
59
  return new Map();
@@ -62,7 +63,7 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
62
63
  return floodFill([sel.from, sel.to], edges);
63
64
  }, [selectedEdge, edges]);
64
65
  const nodeHighlightMapByNode = useMemo(() => {
65
- if (selectedNodeId) {
66
+ if (selectedNodeId || connecting) {
66
67
  return floodFill([selectedNodeId], edges);
67
68
  }
68
69
  if (selectedEdge) {
@@ -73,6 +74,12 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
73
74
  }
74
75
  return new Map();
75
76
  }, [selectedEdge, selectedNodeId, edges]);
77
+ const nodeHighlightMapByConnecting = useMemo(() => {
78
+ if (connecting) {
79
+ return floodFill([connecting.fromId], edges);
80
+ }
81
+ return new Map();
82
+ }, [connecting, edges]);
76
83
  const edgePaths = useMemo(() => {
77
84
  const map = new Map();
78
85
  edges.forEach((edge) => {
@@ -106,7 +113,22 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
106
113
  if (!showConnection) {
107
114
  return null;
108
115
  }
109
- return (_jsxs("g", { id: "connection-layer", children: [Array.from(nodeHighlightMap.entries()).map(([nodeId, level]) => {
116
+ return (_jsxs("g", { id: "connection-layer", children: [Array.from(nodeHighlightMapByConnecting.entries()).map(([nodeId, level]) => {
117
+ var _a, _b, _c;
118
+ const node = getNodeById(nodeId);
119
+ if (!node)
120
+ return null;
121
+ const w = (_a = node.width) !== null && _a !== void 0 ? _a : NODE_WIDTH;
122
+ const h = (_b = node.height) !== null && _b !== void 0 ? _b : NODE_HEIGHT;
123
+ const rotation = (_c = node.rotation) !== null && _c !== void 0 ? _c : 0;
124
+ const color = getLevelColor(level);
125
+ const padding = 4;
126
+ if (level > 1)
127
+ return null;
128
+ return (_jsxs("g", { transform: `translate(${node.x}, ${node.y}) rotate(${rotation})`, style: { pointerEvents: "none" }, children: [_jsx("rect", { x: -w / 2 - padding, y: -h / 2 - padding, width: w + padding * 2, height: h + padding * 2, fill: "none", stroke: color, strokeWidth: 8, rx: 5, opacity: 0.08 }), _jsx("rect", { x: -w / 2 - padding, y: -h / 2 - padding, width: w + padding * 2, height: h + padding * 2, fill: "none", stroke: color, strokeWidth: level === 0 ? 2.5 : 1.5,
129
+ // strokeDasharray={level === 0 ? "none" : "5 3"}
130
+ rx: 5 })] }, `highlight-${nodeId}`));
131
+ }), Array.from(nodeHighlightMap.entries()).map(([nodeId, level]) => {
110
132
  var _a, _b, _c;
111
133
  const node = getNodeById(nodeId);
112
134
  if (!node)
@@ -146,8 +168,9 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
146
168
  const isSel = selectedEdge === edge.id;
147
169
  const isHov = hoveredEdge === edge.id;
148
170
  const connectionMatch = tableMatchConnectionKey === null || tableMatchConnectionKey === void 0 ? void 0 : tableMatchConnectionKey.some((el) => el.id === edge.to || el.id === edge.from);
149
- const fromLevel = nodeHighlightMap.get(edge.from);
150
- const toLevel = nodeHighlightMap.get(edge.to);
171
+ // const fromLevel = nodeHighlightMap.get(edge.from);
172
+ // const toLevel = nodeHighlightMap.get(edge.to);
173
+ const isStillConnectingProcess = (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) === edge.from || (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) === edge.to;
151
174
  const isRing1 = (selectedNodeId && selectedNodeId === edge.from) ||
152
175
  selectedNodeId === edge.to;
153
176
  const isDraggingFrom = (draggingAnchor === null || draggingAnchor === void 0 ? void 0 : draggingAnchor.edgeId) === edge.id && draggingAnchor.side === "from";
@@ -155,7 +178,11 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
155
178
  return (_jsxs("g", { children: [_jsx("path", { d: pathD, stroke: "transparent", strokeWidth: 14, fill: "none", style: { cursor: "pointer" }, onClick: (e) => {
156
179
  e.stopPropagation();
157
180
  onSelectEdge(edge.id);
158
- }, onMouseEnter: () => setHoveredEdge(edge.id), onMouseLeave: () => setHoveredEdge(null) }), (isSel || isHov) && (_jsx("path", { d: pathD, stroke: isSel ? "#a78bfa" : "#38bdf8", strokeWidth: 8, fill: "none", opacity: isSel ? 0.12 : 0.06, style: { pointerEvents: "none" } })), _jsx("path", { d: pathD, stroke: connectionMatch ? "#F1416C" : "#7239EA", strokeWidth: isSel ? 2 : isHov ? 2 : 1.5, fill: "none", opacity: isRing1 && selectedNodeId ? 1 : 0.3, strokeLinecap: "round", style: { pointerEvents: "none" } }), _jsxs("g", { children: [isDraggingFrom && (_jsx("circle", { cx: fromPos.x, cy: fromPos.y, r: 12, fill: "#7239EA", opacity: 0.15, style: { pointerEvents: "none" } })), _jsx("circle", { cx: fromPos.x, cy: fromPos.y, r: 10, fill: "transparent", style: { cursor: "grab" }, onMouseDown: (e) => {
181
+ }, onMouseEnter: () => setHoveredEdge(edge.id), onMouseLeave: () => setHoveredEdge(null) }), (isSel || isHov) && (_jsx("path", { d: pathD, stroke: isSel ? "#a78bfa" : "#38bdf8", strokeWidth: 8, fill: "none", opacity: isSel ? 0.12 : 0.06, style: { pointerEvents: "none" } })), _jsx("path", { d: pathD, stroke: connectionMatch ? "#F1416C" : "#7239EA", strokeWidth: isSel ? 2 : isHov ? 2 : 1.5, fill: "none", opacity: (isRing1 && selectedNodeId) || isStillConnectingProcess
182
+ ? 1
183
+ : connecting
184
+ ? 0
185
+ : 0.3, strokeLinecap: "round", style: { pointerEvents: "none" } }), _jsxs("g", { children: [isDraggingFrom && (_jsx("circle", { cx: fromPos.x, cy: fromPos.y, r: 12, fill: "#7239EA", opacity: 0.15, style: { pointerEvents: "none" } })), _jsx("circle", { cx: fromPos.x, cy: fromPos.y, r: 10, fill: "transparent", style: { cursor: "grab" }, onMouseDown: (e) => {
159
186
  e.stopPropagation();
160
187
  onStartDragAnchor(e, edge.id, "from");
161
188
  } }), _jsx("circle", { cx: fromPos.x, cy: fromPos.y, r: 3, fill: connectionMatch ? "#F1416C" : "#7239EA",
@@ -44,7 +44,7 @@ const quadraticMidpoint = (from, to) => {
44
44
  y: mt * mt * from.y + 2 * mt * t * cpy + t * t * to.y,
45
45
  };
46
46
  };
47
- export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAnchor, mousePos, isConnectEdge, getNodeById, onSelectEdge, onDeleteEdge, onStartDragWaypoint, onInsertWaypoint, onRemoveWaypoint, onStartDragAnchor, selectedNodeId, showConnection, renderedElements, groupSelection, connectionMatchKey, }) => {
47
+ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAnchor, mousePos, isConnectEdge, getNodeById, onSelectEdge, onDeleteEdge, onStartDragWaypoint, onInsertWaypoint, onRemoveWaypoint, onStartDragAnchor, selectedNodeId, showConnection, renderedElements, groupSelection, connectionMatchKey, isSelectNode }) => {
48
48
  const [hoveredEdge, setHoveredEdge] = useState(null);
49
49
  const tableMatchConnectionKey = useMemo(() => renderedElements === null || renderedElements === void 0 ? void 0 : renderedElements.filter((el) => {
50
50
  if (connectionMatchKey) {
@@ -52,6 +52,7 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
52
52
  }
53
53
  return true;
54
54
  }), [renderedElements, connectionMatchKey]);
55
+ console.log("tableMatchConnectionKey", tableMatchConnectionKey);
55
56
  const nodeHighlightMap = useMemo(() => {
56
57
  if (!selectedEdge)
57
58
  return new Map();
@@ -61,7 +62,7 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
61
62
  return floodFill([sel.from, sel.to], edges);
62
63
  }, [selectedEdge, edges]);
63
64
  const nodeHighlightMapByNode = useMemo(() => {
64
- if (selectedNodeId) {
65
+ if (selectedNodeId || connecting) {
65
66
  return floodFill([selectedNodeId], edges);
66
67
  }
67
68
  if (selectedEdge) {
@@ -72,6 +73,12 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
72
73
  }
73
74
  return new Map();
74
75
  }, [selectedEdge, selectedNodeId, edges]);
76
+ const nodeHighlightMapByConnecting = useMemo(() => {
77
+ if (connecting) {
78
+ return floodFill([connecting.fromId], edges);
79
+ }
80
+ return new Map();
81
+ }, [connecting, edges]);
75
82
  const edgePaths = useMemo(() => {
76
83
  const map = new Map();
77
84
  edges.forEach((edge) => {
@@ -106,6 +113,26 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
106
113
  return null;
107
114
  }
108
115
  return (<g id="connection-layer">
116
+ {Array.from(nodeHighlightMapByConnecting.entries()).map(([nodeId, level]) => {
117
+ var _a, _b, _c;
118
+ const node = getNodeById(nodeId);
119
+ if (!node)
120
+ return null;
121
+ const w = (_a = node.width) !== null && _a !== void 0 ? _a : NODE_WIDTH;
122
+ const h = (_b = node.height) !== null && _b !== void 0 ? _b : NODE_HEIGHT;
123
+ const rotation = (_c = node.rotation) !== null && _c !== void 0 ? _c : 0;
124
+ const color = getLevelColor(level);
125
+ const padding = 4;
126
+ if (level > 1)
127
+ return null;
128
+ return (<g key={`highlight-${nodeId}`} transform={`translate(${node.x}, ${node.y}) rotate(${rotation})`} style={{ pointerEvents: "none" }}>
129
+ <rect x={-w / 2 - padding} y={-h / 2 - padding} width={w + padding * 2} height={h + padding * 2} fill="none" stroke={color} strokeWidth={8} rx={5} opacity={0.08}/>
130
+ <rect x={-w / 2 - padding} y={-h / 2 - padding} width={w + padding * 2} height={h + padding * 2} fill="none" stroke={color} strokeWidth={level === 0 ? 2.5 : 1.5}
131
+ // strokeDasharray={level === 0 ? "none" : "5 3"}
132
+ rx={5}/>
133
+ </g>);
134
+ })}
135
+
109
136
  {/* Node highlight flood fill */}
110
137
  {Array.from(nodeHighlightMap.entries()).map(([nodeId, level]) => {
111
138
  var _a, _b, _c;
@@ -186,8 +213,9 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
186
213
  const isSel = selectedEdge === edge.id;
187
214
  const isHov = hoveredEdge === edge.id;
188
215
  const connectionMatch = tableMatchConnectionKey === null || tableMatchConnectionKey === void 0 ? void 0 : tableMatchConnectionKey.some((el) => el.id === edge.to || el.id === edge.from);
189
- const fromLevel = nodeHighlightMap.get(edge.from);
190
- const toLevel = nodeHighlightMap.get(edge.to);
216
+ // const fromLevel = nodeHighlightMap.get(edge.from);
217
+ // const toLevel = nodeHighlightMap.get(edge.to);
218
+ const isStillConnectingProcess = (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) === edge.from || (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) === edge.to;
191
219
  const isRing1 = (selectedNodeId && selectedNodeId === edge.from) ||
192
220
  selectedNodeId === edge.to;
193
221
  const isDraggingFrom = (draggingAnchor === null || draggingAnchor === void 0 ? void 0 : draggingAnchor.edgeId) === edge.id && draggingAnchor.side === "from";
@@ -204,50 +232,54 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
204
232
 
205
233
  {/* Curve */}
206
234
 
207
- <path d={pathD} stroke={connectionMatch ? "#F1416C" : "#7239EA"} strokeWidth={isSel ? 2 : isHov ? 2 : 1.5} fill={"none"} opacity={isRing1 && selectedNodeId ? 1 : 0.3} strokeLinecap="round" style={{ pointerEvents: "none" }}/>
235
+ <path d={pathD} stroke={connectionMatch ? "#F1416C" : "#7239EA"} strokeWidth={isSel ? 2 : isHov ? 2 : 1.5} fill={"none"} opacity={(isRing1 && selectedNodeId) || isStillConnectingProcess
236
+ ? 1
237
+ : connecting
238
+ ? 0
239
+ : 0.3} strokeLinecap="round" style={{ pointerEvents: "none" }}/>
208
240
 
209
241
  {/* FROM dot */}
210
242
  {/* {isSel && ( */}
211
- <g>
212
- {isDraggingFrom && (<circle cx={fromPos.x} cy={fromPos.y} r={12} fill="#7239EA" opacity={0.15} style={{ pointerEvents: "none" }}/>)}
213
- <circle cx={fromPos.x} cy={fromPos.y} r={10} fill="transparent" style={{ cursor: "grab" }} onMouseDown={(e) => {
243
+ <g>
244
+ {isDraggingFrom && (<circle cx={fromPos.x} cy={fromPos.y} r={12} fill="#7239EA" opacity={0.15} style={{ pointerEvents: "none" }}/>)}
245
+ <circle cx={fromPos.x} cy={fromPos.y} r={10} fill="transparent" style={{ cursor: "grab" }} onMouseDown={(e) => {
214
246
  e.stopPropagation();
215
247
  onStartDragAnchor(e, edge.id, "from");
216
248
  }}/>
217
- <circle cx={fromPos.x} cy={fromPos.y} r={3} fill={connectionMatch ? "#F1416C" : "#7239EA"}
249
+ <circle cx={fromPos.x} cy={fromPos.y} r={3} fill={connectionMatch ? "#F1416C" : "#7239EA"}
218
250
  // stroke="#0f172a"
219
251
  // strokeWidth={1.5}
220
252
  style={{ pointerEvents: "none" }}/>
221
- {/* <circle
222
- cx={fromPos.x}
223
- cy={fromPos.y}
224
- r={2.5}
225
- fill="#0f172a"
226
- style={{ pointerEvents: "none" }}
227
- /> */}
228
- </g>
253
+ {/* <circle
254
+ cx={fromPos.x}
255
+ cy={fromPos.y}
256
+ r={2.5}
257
+ fill="#0f172a"
258
+ style={{ pointerEvents: "none" }}
259
+ /> */}
260
+ </g>
229
261
  {/* )} */}
230
262
 
231
263
  {/* TO dot */}
232
264
  {/* {isSel && ( */}
233
- <g>
234
- {isDraggingTo && (<circle cx={toPos.x} cy={toPos.y} r={12} fill="#7239EA" opacity={0.15} style={{ pointerEvents: "none" }}/>)}
235
- <circle cx={toPos.x} cy={toPos.y} r={10} fill="transparent" style={{ cursor: "grab" }} onMouseDown={(e) => {
265
+ <g>
266
+ {isDraggingTo && (<circle cx={toPos.x} cy={toPos.y} r={12} fill="#7239EA" opacity={0.15} style={{ pointerEvents: "none" }}/>)}
267
+ <circle cx={toPos.x} cy={toPos.y} r={10} fill="transparent" style={{ cursor: "grab" }} onMouseDown={(e) => {
236
268
  e.stopPropagation();
237
269
  onStartDragAnchor(e, edge.id, "to");
238
270
  }}/>
239
- <circle cx={toPos.x} cy={toPos.y} r={3} fill={connectionMatch ? "#F1416C" : "#7239EA"}
271
+ <circle cx={toPos.x} cy={toPos.y} r={3} fill={connectionMatch ? "#F1416C" : "#7239EA"}
240
272
  // stroke="#0f172a"
241
273
  // strokeWidth={1.5}
242
274
  style={{ pointerEvents: "none" }}/>
243
- {/* <circle
244
- cx={toPos.x}
245
- cy={toPos.y}
246
- r={2.5}
247
- fill="#0f172a"
248
- style={{ pointerEvents: "none" }}
249
- /> */}
250
- </g>
275
+ {/* <circle
276
+ cx={toPos.x}
277
+ cy={toPos.y}
278
+ r={2.5}
279
+ fill="#0f172a"
280
+ style={{ pointerEvents: "none" }}
281
+ /> */}
282
+ </g>
251
283
  {/* )} */}
252
284
 
253
285
  {/* Waypoints */}
@@ -120,6 +120,7 @@ export interface LayerViewProps<TMeta = undefined> {
120
120
  key: string;
121
121
  value: string | number;
122
122
  };
123
+ onTableMainConnection?: (id: string) => void;
123
124
  }
124
125
  declare const LayerView: <TMeta>(props: LayerViewProps<TMeta>) => import("react/jsx-runtime").JSX.Element;
125
126
  export default LayerView;
@@ -29,7 +29,7 @@ const LayerView = (props) => {
29
29
  selectNode: false,
30
30
  connectingNode: false,
31
31
  dragTransferTable: false,
32
- }, onMakeSelection, groupSelection, onHoldTable, showConnection, connectionMatchKey } = props;
32
+ }, onMakeSelection, groupSelection, onHoldTable, showConnection, connectionMatchKey, onTableMainConnection } = props;
33
33
  const widthTooltip = (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.minWidth) || 168;
34
34
  const tableGhost = useRef(null);
35
35
  const hoverUnderghostId = useRef(null);
@@ -687,12 +687,15 @@ const LayerView = (props) => {
687
687
  userSelect: "none",
688
688
  } }, props.svgProps, { children: [_jsx("rect", { width: "100%", height: "100%", fill: "url(#biggrid)" }), hasBoundingBox && (_jsx("defs", { children: _jsx("clipPath", { id: "contentCrop", children: _jsx("rect", { x: boundingBox.minX, y: boundingBox.minY, width: boundingBox.width, height: boundingBox.height }) }) })), _jsx("g", { id: "main-layer", clipPath: "url(#contentCrop)", children: _jsx(Layers, { components: [...extraComponentsEditor, ...renderedElements], selectedTable: selectedTable,
689
689
  // iconTags={iconTags}
690
- eventMatchTable: eventMatchTable, privilegedTags: privilegedTags, selectionLines: selectedLines }) }), _jsx(ConnectionLayer, { edges: graph.edges, selectedEdge: graph.selectedEdge, connecting: graph.connecting, draggingAnchor: graph.draggingAnchor, mousePos: graph.mousePos, getNodeById: getNodeById, onSelectEdge: graph.selectEdge, onDeleteEdge: graph.deleteEdge, onStartDragWaypoint: graph.startDragWaypoint, onInsertWaypoint: graph.insertWaypoint, onRemoveWaypoint: graph.removeWaypoint, onStartDragAnchor: graph.startDragAnchor, isConnectEdge: actionPrivileged.connectingNode, selectedNodeId: graph.selectedNode, showConnection: showConnection, renderedElements: renderedElements, groupSelection: groupSelection, connectionMatchKey: connectionMatchKey }), renderedElements.map((item) => {
690
+ eventMatchTable: eventMatchTable, privilegedTags: privilegedTags, selectionLines: selectedLines }) }), _jsx(ConnectionLayer, { edges: graph.edges, selectedEdge: graph.selectedEdge, connecting: graph.connecting, draggingAnchor: graph.draggingAnchor, mousePos: graph.mousePos, getNodeById: getNodeById, onSelectEdge: graph.selectEdge, onDeleteEdge: graph.deleteEdge, onStartDragWaypoint: graph.startDragWaypoint, onInsertWaypoint: graph.insertWaypoint, onRemoveWaypoint: graph.removeWaypoint, onStartDragAnchor: graph.startDragAnchor, isConnectEdge: actionPrivileged.connectingNode, selectedNodeId: graph.selectedNode, showConnection: showConnection, renderedElements: renderedElements, groupSelection: groupSelection, connectionMatchKey: connectionMatchKey, isSelectNode: actionPrivileged.selectNode }), renderedElements.map((item) => {
691
691
  var _a, _b, _c, _d, _e;
692
692
  const rotated = rotatePoint(item.width / 2, item.height / 2, (_a = item.rotation) !== null && _a !== void 0 ? _a : 0);
693
693
  return (_jsx(ConnectHandle, {
694
694
  // isAnchor={true}
695
- connecting: graph.connecting, cx: item.x + rotated.x, cy: item.y + rotated.y, width: (_b = item.width) !== null && _b !== void 0 ? _b : 100, height: (_c = item.height) !== null && _c !== void 0 ? _c : 50, rotation: (_d = item.rotation) !== null && _d !== void 0 ? _d : 0, nodeId: (_e = item === null || item === void 0 ? void 0 : item[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _e !== void 0 ? _e : String(item.id), isConnecting: !!graph.connecting, isDraggingAnchor: !!graph.draggingAnchor, onStartConnect: (nodeId, clickPos) => graph.startConnect(nodeId, clickPos), onEndConnect: (nodeId, clickPos) => {
695
+ connecting: graph.connecting, cx: item.x + rotated.x, cy: item.y + rotated.y, width: (_b = item.width) !== null && _b !== void 0 ? _b : 100, height: (_c = item.height) !== null && _c !== void 0 ? _c : 50, rotation: (_d = item.rotation) !== null && _d !== void 0 ? _d : 0, nodeId: (_e = item === null || item === void 0 ? void 0 : item[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _e !== void 0 ? _e : String(item.id), isConnecting: !!graph.connecting, isDraggingAnchor: !!graph.draggingAnchor, onStartConnect: (nodeId, clickPos) => {
696
+ graph.startConnect(nodeId, clickPos);
697
+ onTableMainConnection && onTableMainConnection(nodeId);
698
+ }, onEndConnect: (nodeId, clickPos) => {
696
699
  if (graph.draggingAnchor)
697
700
  graph.updateAnchor(nodeId, clickPos);
698
701
  else
@@ -28,7 +28,7 @@ const LayerView = (props) => {
28
28
  selectNode: false,
29
29
  connectingNode: false,
30
30
  dragTransferTable: false,
31
- }, onMakeSelection, groupSelection, onHoldTable, showConnection, connectionMatchKey } = props;
31
+ }, onMakeSelection, groupSelection, onHoldTable, showConnection, connectionMatchKey, onTableMainConnection } = props;
32
32
  const widthTooltip = (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.minWidth) || 168;
33
33
  const tableGhost = useRef(null);
34
34
  const hoverUnderghostId = useRef(null);
@@ -706,14 +706,17 @@ const LayerView = (props) => {
706
706
  eventMatchTable={eventMatchTable} privilegedTags={privilegedTags} selectionLines={selectedLines}/>
707
707
  </g>
708
708
 
709
- <ConnectionLayer edges={graph.edges} selectedEdge={graph.selectedEdge} connecting={graph.connecting} draggingAnchor={graph.draggingAnchor} mousePos={graph.mousePos} getNodeById={getNodeById} onSelectEdge={graph.selectEdge} onDeleteEdge={graph.deleteEdge} onStartDragWaypoint={graph.startDragWaypoint} onInsertWaypoint={graph.insertWaypoint} onRemoveWaypoint={graph.removeWaypoint} onStartDragAnchor={graph.startDragAnchor} isConnectEdge={actionPrivileged.connectingNode} selectedNodeId={graph.selectedNode} showConnection={showConnection} renderedElements={renderedElements} groupSelection={groupSelection} connectionMatchKey={connectionMatchKey}/>
709
+ <ConnectionLayer edges={graph.edges} selectedEdge={graph.selectedEdge} connecting={graph.connecting} draggingAnchor={graph.draggingAnchor} mousePos={graph.mousePos} getNodeById={getNodeById} onSelectEdge={graph.selectEdge} onDeleteEdge={graph.deleteEdge} onStartDragWaypoint={graph.startDragWaypoint} onInsertWaypoint={graph.insertWaypoint} onRemoveWaypoint={graph.removeWaypoint} onStartDragAnchor={graph.startDragAnchor} isConnectEdge={actionPrivileged.connectingNode} selectedNodeId={graph.selectedNode} showConnection={showConnection} renderedElements={renderedElements} groupSelection={groupSelection} connectionMatchKey={connectionMatchKey} isSelectNode={actionPrivileged.selectNode}/>
710
710
 
711
711
  {renderedElements.map((item) => {
712
712
  var _a, _b, _c, _d, _e;
713
713
  const rotated = rotatePoint(item.width / 2, item.height / 2, (_a = item.rotation) !== null && _a !== void 0 ? _a : 0);
714
714
  return (<ConnectHandle key={item.id}
715
715
  // isAnchor={true}
716
- connecting={graph.connecting} cx={item.x + rotated.x} cy={item.y + rotated.y} width={(_b = item.width) !== null && _b !== void 0 ? _b : 100} height={(_c = item.height) !== null && _c !== void 0 ? _c : 50} rotation={(_d = item.rotation) !== null && _d !== void 0 ? _d : 0} nodeId={(_e = item === null || item === void 0 ? void 0 : item[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _e !== void 0 ? _e : String(item.id)} isConnecting={!!graph.connecting} isDraggingAnchor={!!graph.draggingAnchor} onStartConnect={(nodeId, clickPos) => graph.startConnect(nodeId, clickPos)} onEndConnect={(nodeId, clickPos) => {
716
+ connecting={graph.connecting} cx={item.x + rotated.x} cy={item.y + rotated.y} width={(_b = item.width) !== null && _b !== void 0 ? _b : 100} height={(_c = item.height) !== null && _c !== void 0 ? _c : 50} rotation={(_d = item.rotation) !== null && _d !== void 0 ? _d : 0} nodeId={(_e = item === null || item === void 0 ? void 0 : item[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _e !== void 0 ? _e : String(item.id)} isConnecting={!!graph.connecting} isDraggingAnchor={!!graph.draggingAnchor} onStartConnect={(nodeId, clickPos) => {
717
+ graph.startConnect(nodeId, clickPos);
718
+ onTableMainConnection && onTableMainConnection(nodeId);
719
+ }} onEndConnect={(nodeId, clickPos) => {
717
720
  if (graph.draggingAnchor)
718
721
  graph.updateAnchor(nodeId, clickPos);
719
722
  else
@@ -60,4 +60,5 @@ export declare const useConnectionGraph: ({ svgRef, onEdgesChange, keyNode, mapp
60
60
  onMouseMove: (e: React.MouseEvent<SVGSVGElement>) => void;
61
61
  onMouseUp: () => void;
62
62
  selectNode: (nodeId: string) => void;
63
+ clearSelectionNode: () => void;
63
64
  };
@@ -2,6 +2,7 @@
2
2
  import { useCallback, useEffect, useRef, useState } from "react";
3
3
  import { rotatePoint, snap } from "./utils";
4
4
  import { useAppSelector } from "../../hooks/use-redux";
5
+ import { isEqual } from "lodash";
5
6
  export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey, initialEdges, }) => {
6
7
  const components = useAppSelector((state) => state.board.components);
7
8
  const [edges, setEdges] = useState([]);
@@ -137,6 +138,7 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
137
138
  deleteEdge(selectedEdge);
138
139
  }, [selectedEdge, deleteEdge]);
139
140
  const clearSelection = useCallback(() => setSelectedEdge(null), []);
141
+ const clearSelectionNode = useCallback(() => setSelectedNode(null), []);
140
142
  // ── Keyboard ─────────────────────────────────────────────────────
141
143
  useEffect(() => {
142
144
  const onKey = (e) => {
@@ -149,6 +151,7 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
149
151
  cancelConnect();
150
152
  cancelDragAnchor();
151
153
  clearSelection();
154
+ clearSelectionNode();
152
155
  }
153
156
  };
154
157
  window.addEventListener("keydown", onKey);
@@ -170,8 +173,7 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
170
173
  }, [edges]);
171
174
  // initialize edges
172
175
  useEffect(() => {
173
- var _a;
174
- if (initialEdges) {
176
+ if (!isEqual(initialEdges, edges) && components) {
175
177
  //process initial edges
176
178
  const allElements = components === null || components === void 0 ? void 0 : components.map((table) => {
177
179
  if (mappingKey && (table === null || table === void 0 ? void 0 : table[mappingKey])) {
@@ -179,10 +181,7 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
179
181
  }
180
182
  return Object.assign({}, table);
181
183
  });
182
- // const findSourceTarget = allElements?.find(
183
- // (el) => el.id === connecting.fromId
184
- // );
185
- const transformAllEdges = (_a = initialEdges === null || initialEdges === void 0 ? void 0 : initialEdges.filter((edge) => (edge === null || edge === void 0 ? void 0 : edge.status) === 1)) === null || _a === void 0 ? void 0 : _a.map((edge) => {
184
+ const transformAllEdges = initialEdges === null || initialEdges === void 0 ? void 0 : initialEdges.map((edge) => {
186
185
  const fromElement = allElements === null || allElements === void 0 ? void 0 : allElements.find((el) => el.id === edge.from);
187
186
  if (!fromElement)
188
187
  return null;
@@ -254,7 +253,7 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
254
253
  });
255
254
  setEdges(transformAllEdges === null || transformAllEdges === void 0 ? void 0 : transformAllEdges.filter((el) => el !== null));
256
255
  }
257
- }, [initialEdges]);
256
+ }, [initialEdges, components]);
258
257
  return {
259
258
  edges,
260
259
  setEdges,
@@ -279,5 +278,6 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
279
278
  onMouseMove,
280
279
  onMouseUp,
281
280
  selectNode,
281
+ clearSelectionNode
282
282
  };
283
283
  };
@@ -110,8 +110,10 @@ export const renderElements = (elementEditor, mappingKey, tableMatchKey, connect
110
110
  finalProps = Object.assign(Object.assign(Object.assign({}, finalProps), tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.properties), { fill: fill, stroke, className: tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.className, element: tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.element });
111
111
  }
112
112
  if (connectionMatchKey) {
113
+ console.log("finalProps?.[connectionMatchKey.key]", finalProps, finalProps === null || finalProps === void 0 ? void 0 : finalProps[connectionMatchKey.key]);
113
114
  if (!(finalProps === null || finalProps === void 0 ? void 0 : finalProps[connectionMatchKey.key])) {
114
115
  finalProps = Object.assign(Object.assign({}, finalProps), { [connectionMatchKey.key]: editorItem === null || editorItem === void 0 ? void 0 : editorItem[connectionMatchKey.key] });
116
+ console.log("finalProps?.[connectionMatchKey.key]", finalProps, finalProps === null || finalProps === void 0 ? void 0 : finalProps[connectionMatchKey.key]);
115
117
  }
116
118
  }
117
119
  return finalProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seat-editor",
3
- "version": "3.6.28",
3
+ "version": "3.6.30",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",