seat-editor 3.6.34 → 3.6.35

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.
@@ -301,6 +301,23 @@ export declare const data: ({
301
301
  updated_by: string;
302
302
  })[];
303
303
  export declare const COLORS_SECTION: string[];
304
+ export declare const NODE_PROPERTIES: {
305
+ id: string;
306
+ to: string;
307
+ from: string;
308
+ toPos: {
309
+ x: number;
310
+ y: number;
311
+ name: string;
312
+ };
313
+ status: number;
314
+ fromPos: {
315
+ x: number;
316
+ y: number;
317
+ name: string;
318
+ };
319
+ waypoints: any[];
320
+ }[];
304
321
  export declare const background: {
305
322
  x: number;
306
323
  y: number;
@@ -2930,6 +2930,93 @@ export const COLORS_SECTION = [
2930
2930
  "#FBC6D3",
2931
2931
  "#D5C4F9",
2932
2932
  ];
2933
+ export const NODE_PROPERTIES = [
2934
+ {
2935
+ id: "edge-1783410035523",
2936
+ to: "01bbb9f3-cdec-4e8a-8515-fce4b603a10a",
2937
+ from: "6da49554-e25e-43c5-8873-b8df3d8ce389",
2938
+ toPos: {
2939
+ x: 2431,
2940
+ y: 463,
2941
+ name: "left",
2942
+ },
2943
+ status: 1,
2944
+ fromPos: {
2945
+ x: 2484,
2946
+ y: 321,
2947
+ name: "bottom",
2948
+ },
2949
+ waypoints: [],
2950
+ },
2951
+ {
2952
+ id: "edge-1783410036151",
2953
+ to: "c5aab141-cb77-46cc-bed1-a2222eac9ed9",
2954
+ from: "6da49554-e25e-43c5-8873-b8df3d8ce389",
2955
+ toPos: {
2956
+ x: 2351,
2957
+ y: 459,
2958
+ name: "left",
2959
+ },
2960
+ status: 1,
2961
+ fromPos: {
2962
+ x: 2484,
2963
+ y: 321,
2964
+ name: "bottom",
2965
+ },
2966
+ waypoints: [],
2967
+ },
2968
+ {
2969
+ id: "edge-1783410036683",
2970
+ to: "72477b41-bb67-4969-b622-f2ff5e3d5328",
2971
+ from: "6da49554-e25e-43c5-8873-b8df3d8ce389",
2972
+ toPos: {
2973
+ x: 2279,
2974
+ y: 460,
2975
+ name: "left",
2976
+ },
2977
+ status: 1,
2978
+ fromPos: {
2979
+ x: 2484,
2980
+ y: 321,
2981
+ name: "bottom",
2982
+ },
2983
+ waypoints: [],
2984
+ },
2985
+ {
2986
+ id: "edge-1783410037651",
2987
+ to: "73ef9906-5776-471a-98d6-86190bf32a72",
2988
+ from: "6da49554-e25e-43c5-8873-b8df3d8ce389",
2989
+ toPos: {
2990
+ x: 2126,
2991
+ y: 458,
2992
+ name: "right",
2993
+ },
2994
+ status: 1,
2995
+ fromPos: {
2996
+ x: 2484,
2997
+ y: 321,
2998
+ name: "bottom",
2999
+ },
3000
+ waypoints: [],
3001
+ },
3002
+ {
3003
+ id: "edge-1783410038349",
3004
+ to: "443e4d6e-1090-4302-9f22-7e254b3e941b",
3005
+ from: "6da49554-e25e-43c5-8873-b8df3d8ce389",
3006
+ toPos: {
3007
+ x: 1978,
3008
+ y: 458,
3009
+ name: "left",
3010
+ },
3011
+ status: 1,
3012
+ fromPos: {
3013
+ x: 2484,
3014
+ y: 321,
3015
+ name: "bottom",
3016
+ },
3017
+ waypoints: [],
3018
+ },
3019
+ ];
2933
3020
  export const background = [
2934
3021
  {
2935
3022
  x: 1108,
@@ -2,9 +2,10 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
4
  import LayerView from "../../features/view-only-5";
5
- import { data } from "./constant";
5
+ import { COLORS_SECTION, data, NODE_PROPERTIES } from "./constant";
6
6
  import { Button } from "antd";
7
7
  import { useMemo, useState } from "react";
8
+ import { selection } from "./selection";
8
9
  export default function GraphView() {
9
10
  const [isConnecting, setIsConnecting] = useState(false);
10
11
  const [actionPrivileged, setActionPrivileged] = useState({
@@ -149,9 +150,11 @@ export default function GraphView() {
149
150
  }, children: item.name }, item.key))) }), _jsx(LayerView, { componentProps: componentSection, statusKey: "section", defaultBackground: "#1e2d4a", mappingKey: "properties", keyNode: "nodes", onEdgesChange: (edges, table) => {
150
151
  console.log(edges, "edges");
151
152
  setEdges(edges);
152
- }, initialEdges: edges, isConnectEdge: isConnecting, isSelectNode: isSelectNode, connectionMatchKey: {
153
+ }, initialEdges: NODE_PROPERTIES, isConnectEdge: isConnecting, isSelectNode: isSelectNode, connectionMatchKey: {
153
154
  key: "use_checking_availability",
154
155
  value: 0
156
+ }, onTableMainConnection: (e) => {
157
+ console.log({ e });
155
158
  },
156
159
  // extraComponentProps={background}
157
160
  onSelectComponent: handleSelectItem,
@@ -182,5 +185,9 @@ export default function GraphView() {
182
185
  console.log({ e, data });
183
186
  }, allowTooltip: true, onHoldTable: (e, data) => {
184
187
  console.log({ e, data });
185
- }, showConnection: true }), _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" }) }) })] }) }));
188
+ }, showConnection: true, groupSelection: {
189
+ colorGroupSelection: COLORS_SECTION,
190
+ dataKey: "uuid_table",
191
+ selection: selection
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" }) }) })] }) }));
186
193
  }
@@ -1,9 +1,10 @@
1
1
  "use client";
2
2
  import clsx from "clsx";
3
3
  import LayerView from "../../features/view-only-5";
4
- import { data } from "./constant";
4
+ import { COLORS_SECTION, data, NODE_PROPERTIES } from "./constant";
5
5
  import { Button } from "antd";
6
6
  import { useMemo, useState } from "react";
7
+ import { selection } from "./selection";
7
8
  export default function GraphView() {
8
9
  const [isConnecting, setIsConnecting] = useState(false);
9
10
  const [actionPrivileged, setActionPrivileged] = useState({
@@ -155,9 +156,11 @@ export default function GraphView() {
155
156
  <LayerView componentProps={componentSection} statusKey="section" defaultBackground="#1e2d4a" mappingKey="properties" keyNode="nodes" onEdgesChange={(edges, table) => {
156
157
  console.log(edges, "edges");
157
158
  setEdges(edges);
158
- }} initialEdges={edges} isConnectEdge={isConnecting} isSelectNode={isSelectNode} connectionMatchKey={{
159
+ }} initialEdges={NODE_PROPERTIES} isConnectEdge={isConnecting} isSelectNode={isSelectNode} connectionMatchKey={{
159
160
  key: "use_checking_availability",
160
161
  value: 0
162
+ }} onTableMainConnection={(e) => {
163
+ console.log({ e });
161
164
  }}
162
165
  // extraComponentProps={background}
163
166
  onSelectComponent={handleSelectItem}
@@ -188,7 +191,11 @@ export default function GraphView() {
188
191
  console.log({ e, data });
189
192
  }} allowTooltip={true} onHoldTable={(e, data) => {
190
193
  console.log({ e, data });
191
- }} showConnection={true}/>
194
+ }} showConnection={true} groupSelection={{
195
+ colorGroupSelection: COLORS_SECTION,
196
+ dataKey: "uuid_table",
197
+ selection: selection
198
+ }}/>
192
199
  <div className="w-1/5 p-4" onMouseMove={handleMouseMove} onMouseLeave={handleMouseLeave}>
193
200
  <div id="table"/>
194
201
  <div className="rounded-lg bg-white p-4">
@@ -651,7 +651,8 @@ const LayerView = (props) => {
651
651
  tableMatchKey,
652
652
  statusKey,
653
653
  initialEdges: props === null || props === void 0 ? void 0 : props.initialEdges,
654
- onTableMainConnection: props === null || props === void 0 ? void 0 : props.onTableMainConnection
654
+ onTableMainConnection: props === null || props === void 0 ? void 0 : props.onTableMainConnection,
655
+ groupSelection
655
656
  });
656
657
  // ─── Render ───────────────────────────────────────────────────────────────
657
658
  const hasBoundingBox = hasBoundingBoxRef.current;
@@ -693,10 +694,7 @@ const LayerView = (props) => {
693
694
  const rotated = rotatePoint(item.width / 2, item.height / 2, (_a = item.rotation) !== null && _a !== void 0 ? _a : 0);
694
695
  return (_jsx(ConnectHandle, {
695
696
  // isAnchor={true}
696
- 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) => {
697
- graph.startConnect(nodeId, clickPos);
698
- onTableMainConnection && onTableMainConnection(nodeId);
699
- }, onEndConnect: (nodeId, clickPos) => {
697
+ 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) => {
700
698
  if (graph.draggingAnchor)
701
699
  graph.updateAnchor(nodeId, clickPos);
702
700
  else
@@ -650,7 +650,8 @@ const LayerView = (props) => {
650
650
  tableMatchKey,
651
651
  statusKey,
652
652
  initialEdges: props === null || props === void 0 ? void 0 : props.initialEdges,
653
- onTableMainConnection: props === null || props === void 0 ? void 0 : props.onTableMainConnection
653
+ onTableMainConnection: props === null || props === void 0 ? void 0 : props.onTableMainConnection,
654
+ groupSelection
654
655
  });
655
656
  // ─── Render ───────────────────────────────────────────────────────────────
656
657
  const hasBoundingBox = hasBoundingBoxRef.current;
@@ -714,10 +715,7 @@ const LayerView = (props) => {
714
715
  const rotated = rotatePoint(item.width / 2, item.height / 2, (_a = item.rotation) !== null && _a !== void 0 ? _a : 0);
715
716
  return (<ConnectHandle key={item.id}
716
717
  // isAnchor={true}
717
- 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) => {
718
- graph.startConnect(nodeId, clickPos);
719
- onTableMainConnection && onTableMainConnection(nodeId);
720
- }} onEndConnect={(nodeId, clickPos) => {
718
+ 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) => {
721
719
  if (graph.draggingAnchor)
722
720
  graph.updateAnchor(nodeId, clickPos);
723
721
  else
@@ -14,8 +14,13 @@ export type UseConnectionGraphOptions = {
14
14
  showConnection?: boolean;
15
15
  initialEdges?: EdgeType[];
16
16
  onTableMainConnection?: (id: string | null) => void;
17
+ groupSelection?: {
18
+ colorGroupSelection: string[];
19
+ dataKey: string;
20
+ selection: Record<number, string[]>;
21
+ };
17
22
  };
18
- export declare const useConnectionGraph: ({ svgRef, onEdgesChange, keyNode, mappingKey, initialEdges, onTableMainConnection }: UseConnectionGraphOptions) => {
23
+ export declare const useConnectionGraph: ({ svgRef, onEdgesChange, keyNode, mappingKey, initialEdges, onTableMainConnection, groupSelection, }: UseConnectionGraphOptions) => {
19
24
  edges: EdgeType[];
20
25
  setEdges: React.Dispatch<React.SetStateAction<EdgeType[]>>;
21
26
  selectedEdge: string;
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
3
3
  import { rotatePoint, snap } from "./utils";
4
4
  import { useAppSelector } from "../../hooks/use-redux";
5
5
  import { isEqual } from "lodash";
6
- export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey, initialEdges, onTableMainConnection }) => {
6
+ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey, initialEdges, onTableMainConnection, groupSelection, }) => {
7
7
  const components = useAppSelector((state) => state.board.components);
8
8
  const [edges, setEdges] = useState([]);
9
9
  const [selectedEdge, setSelectedEdge] = useState(null);
@@ -27,6 +27,7 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
27
27
  const startConnect = useCallback((fromId, fromPos) => {
28
28
  setConnecting({ fromId, fromPos });
29
29
  setSelectedEdge(null);
30
+ onTableMainConnection(fromId);
30
31
  }, []);
31
32
  const endConnect = useCallback((toId, toPos) => {
32
33
  if (!connecting || connecting.fromId === toId) {
@@ -179,12 +180,13 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
179
180
  //process initial edges
180
181
  const allElements = components === null || components === void 0 ? void 0 : components.map((table) => {
181
182
  if (mappingKey && (table === null || table === void 0 ? void 0 : table[mappingKey])) {
182
- return Object.assign({}, table);
183
+ return Object.assign({}, table === null || table === void 0 ? void 0 : table[mappingKey]);
183
184
  }
184
185
  return Object.assign({}, table);
185
186
  });
186
187
  const transformAllEdges = initialEdges === null || initialEdges === void 0 ? void 0 : initialEdges.map((edge) => {
187
- const fromElement = allElements === null || allElements === void 0 ? void 0 : allElements.find((el) => el.id === edge.from);
188
+ var _a, _b;
189
+ const fromElement = allElements === null || allElements === void 0 ? void 0 : allElements.find((el) => { var _a; return ((_a = el === null || el === void 0 ? void 0 : el[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _a !== void 0 ? _a : el.id) === edge.from; });
188
190
  if (!fromElement)
189
191
  return null;
190
192
  const { x: fromX, y: fromY, rotation: fromRotation, width: fromWidth, height: fromHeight, } = fromElement;
@@ -199,15 +201,15 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
199
201
  fromLx = 0;
200
202
  fromLy = -fromHh;
201
203
  }
202
- else if (connecting.fromPos.name === "right") {
204
+ else if (edge.fromPos.name === "right") {
203
205
  fromLx = fromHw;
204
206
  fromLy = 0;
205
207
  }
206
- else if (connecting.fromPos.name === "bottom") {
208
+ else if (edge.fromPos.name === "bottom") {
207
209
  fromLx = 0;
208
210
  fromLy = fromHh;
209
211
  }
210
- else if (connecting.fromPos.name === "left") {
212
+ else if (edge.fromPos.name === "left") {
211
213
  fromLx = -fromHw;
212
214
  fromLy = 0;
213
215
  }
@@ -217,7 +219,7 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
217
219
  y: fromCy + fromLx * Math.sin(rad) + fromLy * Math.cos(rad),
218
220
  name: edge.fromPos.name,
219
221
  };
220
- const toElement = allElements === null || allElements === void 0 ? void 0 : allElements.find((el) => el.id === edge.to);
222
+ const toElement = allElements === null || allElements === void 0 ? void 0 : allElements.find((el) => { var _a; return ((_a = el === null || el === void 0 ? void 0 : el[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _a !== void 0 ? _a : el.id) === edge.to; });
221
223
  if (!toElement)
222
224
  return null;
223
225
  const { x: toX, y: toY, rotation: toRotation, width: toWidth, height: toHeight, } = toElement;
@@ -250,12 +252,12 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
250
252
  y: toCy + toLx * Math.sin(rad2) + toLy * Math.cos(rad2),
251
253
  name: edge.toPos.name,
252
254
  };
253
- return Object.assign(Object.assign({}, edge), { from: fromElement.id, to: toElement.id, fromPos,
255
+ 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,
254
256
  toPos });
255
257
  });
256
258
  setEdges(transformAllEdges === null || transformAllEdges === void 0 ? void 0 : transformAllEdges.filter((el) => el !== null));
257
259
  }
258
- }, [initialEdges, components]);
260
+ }, [initialEdges, components, groupSelection, edges]);
259
261
  return {
260
262
  edges,
261
263
  setEdges,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seat-editor",
3
- "version": "3.6.34",
3
+ "version": "3.6.35",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",