seat-editor 3.6.37 → 3.6.39

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.
@@ -6,6 +6,7 @@ import { COLORS_SECTION, data, NODE_PROPERTIES } from "./constant";
6
6
  import { Button } from "antd";
7
7
  import { useMemo, useState } from "react";
8
8
  import { selection } from "./selection";
9
+ import { isEmpty } from "lodash";
9
10
  export default function GraphView() {
10
11
  const [isConnecting, setIsConnecting] = useState(false);
11
12
  const [actionPrivileged, setActionPrivileged] = useState({
@@ -18,7 +19,7 @@ export default function GraphView() {
18
19
  selection: false,
19
20
  selectNode: false,
20
21
  connectingNode: true,
21
- dragTransferTable: false
22
+ dragTransferTable: false,
22
23
  });
23
24
  const [isSelectNode, setIsSelectNode] = useState(false);
24
25
  const [sections, setSections] = useState([
@@ -109,7 +110,7 @@ export default function GraphView() {
109
110
  {
110
111
  key: "dragTransferTable",
111
112
  name: "Drag Transfer Table",
112
- }
113
+ },
113
114
  ];
114
115
  const [dataDrag, setDataDrag] = useState(null);
115
116
  console.log({ dataDrag });
@@ -143,15 +144,15 @@ export default function GraphView() {
143
144
  setDataDrag(null);
144
145
  }
145
146
  };
146
- const [edges, setEdges] = useState([]);
147
+ const [edges, setEdges] = useState(NODE_PROPERTIES);
147
148
  console.log({ edges });
148
149
  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
150
  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: (edges) => {
151
- setEdges(edges);
152
- }, initialEdges: NODE_PROPERTIES, isConnectEdge: isConnecting, isSelectNode: isSelectNode, connectionMatchKey: {
151
+ }, children: item.name }, item.key))) }), _jsx(LayerView, { componentProps: componentSection, statusKey: "section", defaultBackground: "#1e2d4a", mappingKey: "properties", keyNode: "nodes", onEdgesChange: (edgesd) => {
152
+ // setEdges(edgesd);
153
+ }, initialEdges: isEmpty(edges) ? NODE_PROPERTIES : edges, isConnectEdge: isConnecting, isSelectNode: isSelectNode, connectionMatchKey: {
153
154
  key: "use_checking_availability",
154
- value: 0
155
+ value: 0,
155
156
  }, onTableMainConnection: (e) => {
156
157
  console.log({ e });
157
158
  },
@@ -187,6 +188,6 @@ export default function GraphView() {
187
188
  }, showConnection: true, groupSelection: {
188
189
  colorGroupSelection: COLORS_SECTION,
189
190
  dataKey: "uuid_table",
190
- selection: selection
191
+ selection: selection,
191
192
  } }), _jsxs("div", { className: "w-1/5 p-4", onMouseMove: handleMouseMove, onMouseLeave: handleMouseLeave, children: [_jsx("div", { id: "table" }), _jsxs("div", { className: "rounded-lg bg-white p-4", children: [_jsx("h1", { className: "text-2xl font-bold", children: "Section" }), sections.map((section) => (_jsxs("div", { className: clsx("font-bold text-white rounded-md p-2 cursor-pointer", sectionActive === section.id && "!bg-blue-500"), style: { backgroundColor: section.color }, onClick: () => setSectionActive(section.id), children: [_jsx("h2", { className: "text-lg", children: section.name }), section.items.length > 0 && (_jsx("ul", { className: "list-disc pl-5 bg-opacity-50 bg-white p-2 rounded ", children: section.items.map((item) => (_jsx("li", { children: item.name }, item.id))) }))] }, section.id)))] })] }), _jsx("div", { className: "w-1/5 p-4", children: _jsx("div", { className: "rounded-lg bg-white p-4", children: _jsx("h1", { className: "text-2xl font-bold", children: "Nodes" }) }) })] }) }));
192
193
  }
@@ -5,6 +5,7 @@ import { COLORS_SECTION, data, NODE_PROPERTIES } from "./constant";
5
5
  import { Button } from "antd";
6
6
  import { useMemo, useState } from "react";
7
7
  import { selection } from "./selection";
8
+ import { isEmpty } from "lodash";
8
9
  export default function GraphView() {
9
10
  const [isConnecting, setIsConnecting] = useState(false);
10
11
  const [actionPrivileged, setActionPrivileged] = useState({
@@ -17,7 +18,7 @@ export default function GraphView() {
17
18
  selection: false,
18
19
  selectNode: false,
19
20
  connectingNode: true,
20
- dragTransferTable: false
21
+ dragTransferTable: false,
21
22
  });
22
23
  const [isSelectNode, setIsSelectNode] = useState(false);
23
24
  const [sections, setSections] = useState([
@@ -108,7 +109,7 @@ export default function GraphView() {
108
109
  {
109
110
  key: "dragTransferTable",
110
111
  name: "Drag Transfer Table",
111
- }
112
+ },
112
113
  ];
113
114
  const [dataDrag, setDataDrag] = useState(null);
114
115
  console.log({ dataDrag });
@@ -142,7 +143,7 @@ export default function GraphView() {
142
143
  setDataDrag(null);
143
144
  }
144
145
  };
145
- const [edges, setEdges] = useState([]);
146
+ const [edges, setEdges] = useState(NODE_PROPERTIES);
146
147
  console.log({ edges });
147
148
  return (<div className="w-full h-screen flex relative">
148
149
  <div className="flex">
@@ -153,11 +154,11 @@ export default function GraphView() {
153
154
  {item.name}
154
155
  </Button>))}
155
156
  </div>
156
- <LayerView componentProps={componentSection} statusKey="section" defaultBackground="#1e2d4a" mappingKey="properties" keyNode="nodes" onEdgesChange={(edges) => {
157
- setEdges(edges);
158
- }} initialEdges={NODE_PROPERTIES} isConnectEdge={isConnecting} isSelectNode={isSelectNode} connectionMatchKey={{
157
+ <LayerView componentProps={componentSection} statusKey="section" defaultBackground="#1e2d4a" mappingKey="properties" keyNode="nodes" onEdgesChange={(edgesd) => {
158
+ // setEdges(edgesd);
159
+ }} initialEdges={isEmpty(edges) ? NODE_PROPERTIES : edges} isConnectEdge={isConnecting} isSelectNode={isSelectNode} connectionMatchKey={{
159
160
  key: "use_checking_availability",
160
- value: 0
161
+ value: 0,
161
162
  }} onTableMainConnection={(e) => {
162
163
  console.log({ e });
163
164
  }}
@@ -193,7 +194,7 @@ export default function GraphView() {
193
194
  }} showConnection={true} groupSelection={{
194
195
  colorGroupSelection: COLORS_SECTION,
195
196
  dataKey: "uuid_table",
196
- selection: selection
197
+ selection: selection,
197
198
  }}/>
198
199
  <div className="w-1/5 p-4" onMouseMove={handleMouseMove} onMouseLeave={handleMouseLeave}>
199
200
  <div id="table"/>
@@ -48,7 +48,7 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
48
48
  fromPos: connecting.fromPos,
49
49
  toPos,
50
50
  waypoints: [],
51
- status: 1
51
+ status: 1,
52
52
  },
53
53
  ];
54
54
  });
@@ -161,7 +161,7 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
161
161
  return () => window.removeEventListener("keydown", onKey);
162
162
  }, [deleteSelectedEdge, cancelConnect, cancelDragAnchor, clearSelection]);
163
163
  // ── onEdgesChange ────────────────────────────────────────────────
164
- useEffect(() => {
164
+ const onUpdateEdges = () => {
165
165
  const sourceToTargets = new Map();
166
166
  edges.forEach((e) => {
167
167
  if (!sourceToTargets.has(e.from))
@@ -169,7 +169,8 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
169
169
  sourceToTargets.get(e.from).push(e.to);
170
170
  });
171
171
  onEdgesChange === null || onEdgesChange === void 0 ? void 0 : onEdgesChange(edges);
172
- }, [edges, onEdgesChange]);
172
+ };
173
+ const hasInitialEdges = useRef(false);
173
174
  // initialize edges
174
175
  useEffect(() => {
175
176
  if (!isEqual(initialEdges, edges) && components) {
@@ -251,9 +252,16 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
251
252
  return Object.assign(Object.assign({}, edge), { from: (_a = fromElement === null || fromElement === void 0 ? void 0 : fromElement[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _a !== void 0 ? _a : fromElement.id, to: (_b = toElement === null || toElement === void 0 ? void 0 : toElement[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _b !== void 0 ? _b : toElement.id, fromPos,
252
253
  toPos });
253
254
  });
255
+ hasInitialEdges.current = true;
254
256
  setEdges(transformAllEdges === null || transformAllEdges === void 0 ? void 0 : transformAllEdges.filter((el) => el !== null));
255
257
  }
256
258
  }, [initialEdges, components, groupSelection, edges]);
259
+ useEffect(() => {
260
+ const isNotEqual = !isEqual(edges, initialEdges);
261
+ if (isNotEqual && hasInitialEdges.current) {
262
+ onUpdateEdges && onUpdateEdges();
263
+ }
264
+ }, [edges]);
257
265
  return {
258
266
  edges,
259
267
  setEdges,
@@ -278,6 +286,6 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
278
286
  onMouseMove,
279
287
  onMouseUp,
280
288
  selectNode,
281
- clearSelectionNode
289
+ clearSelectionNode,
282
290
  };
283
291
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seat-editor",
3
- "version": "3.6.37",
3
+ "version": "3.6.39",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",