seat-editor 3.6.27 → 3.6.29
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/graph-view-new/constant.d.ts +108 -0
- package/dist/app/graph-view-new/constant.js +2 -0
- package/dist/app/graph-view-new/page.js +37 -23
- package/dist/app/graph-view-new/page.jsx +37 -23
- package/dist/features/view-only-5/connect-handle.js +2 -2
- package/dist/features/view-only-5/connect-handle.jsx +2 -2
- package/dist/features/view-only-5/connection-layer.d.ts +9 -0
- package/dist/features/view-only-5/connection-layer.js +60 -40
- package/dist/features/view-only-5/connection-layer.jsx +121 -63
- package/dist/features/view-only-5/index.d.ts +4 -0
- package/dist/features/view-only-5/index.js +12 -9
- package/dist/features/view-only-5/index.jsx +12 -9
- package/dist/features/view-only-5/use-connection-graph.js +6 -5
- package/dist/features/view-only-5/utils.d.ts +4 -0
- package/dist/features/view-only-5/utils.js +20 -8
- package/package.json +4 -1
|
@@ -7,6 +7,7 @@ export declare const data: ({
|
|
|
7
7
|
code: string;
|
|
8
8
|
name: string;
|
|
9
9
|
capacity: number;
|
|
10
|
+
use_connection: number;
|
|
10
11
|
pax: {
|
|
11
12
|
adults: number;
|
|
12
13
|
};
|
|
@@ -132,6 +133,109 @@ export declare const data: ({
|
|
|
132
133
|
uuid: string;
|
|
133
134
|
image: any;
|
|
134
135
|
}[];
|
|
136
|
+
} | {
|
|
137
|
+
uuid_table: string;
|
|
138
|
+
uuid_rsvp: any;
|
|
139
|
+
uuid_event_outlet: any;
|
|
140
|
+
uuid_reserved: any;
|
|
141
|
+
uuid_rsvp_table: any;
|
|
142
|
+
code: string;
|
|
143
|
+
name: string;
|
|
144
|
+
capacity: number;
|
|
145
|
+
use_connection: number;
|
|
146
|
+
pax: any;
|
|
147
|
+
req_pax: any;
|
|
148
|
+
total_pax: any;
|
|
149
|
+
total_req_pax: any;
|
|
150
|
+
uuid_status: any;
|
|
151
|
+
status_bg_color: any;
|
|
152
|
+
status_name: any;
|
|
153
|
+
status_color: any;
|
|
154
|
+
status_icon: any;
|
|
155
|
+
title: any;
|
|
156
|
+
firstname: any;
|
|
157
|
+
lastname: any;
|
|
158
|
+
fullname: any;
|
|
159
|
+
ranks: any;
|
|
160
|
+
tags: any;
|
|
161
|
+
rank_sp: any;
|
|
162
|
+
rank_ts: any;
|
|
163
|
+
start_date: any;
|
|
164
|
+
end_date: any;
|
|
165
|
+
start_time: any;
|
|
166
|
+
end_time: any;
|
|
167
|
+
walk_in: any;
|
|
168
|
+
dp_amount: any;
|
|
169
|
+
dp_status: any;
|
|
170
|
+
online_payment: any;
|
|
171
|
+
rsvp_type: any;
|
|
172
|
+
rsvp_input: any;
|
|
173
|
+
is_reserved: number;
|
|
174
|
+
is_hold: number;
|
|
175
|
+
is_lock: number;
|
|
176
|
+
is_overtime: number;
|
|
177
|
+
is_upcoming: number;
|
|
178
|
+
conflicted: number;
|
|
179
|
+
is_late: number;
|
|
180
|
+
properties: {
|
|
181
|
+
x: number;
|
|
182
|
+
y: number;
|
|
183
|
+
id: string;
|
|
184
|
+
fill: string;
|
|
185
|
+
tags: ({
|
|
186
|
+
gap: string;
|
|
187
|
+
key: string;
|
|
188
|
+
items: {
|
|
189
|
+
type: string;
|
|
190
|
+
value: string;
|
|
191
|
+
}[];
|
|
192
|
+
direction: string;
|
|
193
|
+
offsetX?: undefined;
|
|
194
|
+
offsetY?: undefined;
|
|
195
|
+
} | {
|
|
196
|
+
gap: string;
|
|
197
|
+
key: string;
|
|
198
|
+
items: {
|
|
199
|
+
type: string;
|
|
200
|
+
value: string;
|
|
201
|
+
}[];
|
|
202
|
+
offsetX: string;
|
|
203
|
+
offsetY: string;
|
|
204
|
+
direction: string;
|
|
205
|
+
})[];
|
|
206
|
+
text: string;
|
|
207
|
+
shape: string;
|
|
208
|
+
width: number;
|
|
209
|
+
height: number;
|
|
210
|
+
labels: {
|
|
211
|
+
x: number;
|
|
212
|
+
y: number;
|
|
213
|
+
label: string;
|
|
214
|
+
fontSize: number;
|
|
215
|
+
fontColor: string;
|
|
216
|
+
}[];
|
|
217
|
+
points: any[];
|
|
218
|
+
opacity: number;
|
|
219
|
+
rotation: number;
|
|
220
|
+
seatCount: number;
|
|
221
|
+
uuid_table: string;
|
|
222
|
+
stroke?: undefined;
|
|
223
|
+
seatFill?: undefined;
|
|
224
|
+
openSpace?: undefined;
|
|
225
|
+
seatPositions?: undefined;
|
|
226
|
+
};
|
|
227
|
+
image_mapping: {
|
|
228
|
+
x: number;
|
|
229
|
+
y: number;
|
|
230
|
+
id: string;
|
|
231
|
+
fill: string;
|
|
232
|
+
shape: string;
|
|
233
|
+
width: number;
|
|
234
|
+
height: number;
|
|
235
|
+
}[];
|
|
236
|
+
upcomings: any[];
|
|
237
|
+
areas: any;
|
|
238
|
+
sections: any;
|
|
135
239
|
} | {
|
|
136
240
|
uuid_table: string;
|
|
137
241
|
uuid_rsvp: string;
|
|
@@ -261,6 +365,7 @@ export declare const data: ({
|
|
|
261
365
|
uuid: string;
|
|
262
366
|
image: any;
|
|
263
367
|
}[];
|
|
368
|
+
use_connection?: undefined;
|
|
264
369
|
} | {
|
|
265
370
|
uuid_table: string;
|
|
266
371
|
uuid_rsvp: any;
|
|
@@ -363,6 +468,7 @@ export declare const data: ({
|
|
|
363
468
|
upcomings: any[];
|
|
364
469
|
areas: any;
|
|
365
470
|
sections: any;
|
|
471
|
+
use_connection?: undefined;
|
|
366
472
|
} | {
|
|
367
473
|
uuid_table: string;
|
|
368
474
|
uuid_rsvp: any;
|
|
@@ -471,6 +577,7 @@ export declare const data: ({
|
|
|
471
577
|
upcomings: any[];
|
|
472
578
|
areas: any;
|
|
473
579
|
sections: any;
|
|
580
|
+
use_connection?: undefined;
|
|
474
581
|
} | {
|
|
475
582
|
uuid_table: string;
|
|
476
583
|
uuid_rsvp: any;
|
|
@@ -578,6 +685,7 @@ export declare const data: ({
|
|
|
578
685
|
upcomings: any[];
|
|
579
686
|
areas: any;
|
|
580
687
|
sections: any;
|
|
688
|
+
use_connection?: undefined;
|
|
581
689
|
})[];
|
|
582
690
|
export declare const COLORS_SECTION: string[];
|
|
583
691
|
export declare const background: {
|
|
@@ -8,6 +8,7 @@ export const data = [
|
|
|
8
8
|
code: "T1",
|
|
9
9
|
name: "TABLE 1",
|
|
10
10
|
capacity: 5,
|
|
11
|
+
use_connection: 1,
|
|
11
12
|
pax: {
|
|
12
13
|
adults: 4,
|
|
13
14
|
},
|
|
@@ -168,6 +169,7 @@ export const data = [
|
|
|
168
169
|
code: "V1",
|
|
169
170
|
name: "VIP 1",
|
|
170
171
|
capacity: 8,
|
|
172
|
+
use_connection: 1,
|
|
171
173
|
pax: null,
|
|
172
174
|
req_pax: null,
|
|
173
175
|
total_pax: null,
|
|
@@ -2,10 +2,9 @@
|
|
|
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 {
|
|
5
|
+
import { data } from "./constant";
|
|
6
6
|
import { Button } from "antd";
|
|
7
7
|
import { useMemo, useState } from "react";
|
|
8
|
-
import { selection } from "./selection";
|
|
9
8
|
export default function GraphView() {
|
|
10
9
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
11
10
|
const [actionPrivileged, setActionPrivileged] = useState({
|
|
@@ -36,10 +35,13 @@ export default function GraphView() {
|
|
|
36
35
|
},
|
|
37
36
|
]);
|
|
38
37
|
const [sectionActive, setSectionActive] = useState(null);
|
|
39
|
-
const componentSection = useMemo(() =>
|
|
38
|
+
const componentSection = useMemo(() => {
|
|
40
39
|
var _a;
|
|
41
|
-
return (
|
|
42
|
-
|
|
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]);
|
|
43
45
|
const onMakeSelection = (datas) => {
|
|
44
46
|
setSections((prev) => {
|
|
45
47
|
const uuidSet = new Set(datas.map((d) => d.uuid_table));
|
|
@@ -143,31 +145,43 @@ export default function GraphView() {
|
|
|
143
145
|
setDataDrag(null);
|
|
144
146
|
}
|
|
145
147
|
};
|
|
148
|
+
const [edges, setEdges] = useState([]);
|
|
149
|
+
console.log({ edges });
|
|
146
150
|
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: () => {
|
|
147
151
|
setActionPrivileged((prev) => (Object.assign(Object.assign({}, prev), { [item.key]: !prev[item.key] })));
|
|
148
|
-
}, children: item.name }, item.key))) }), _jsx(LayerView, { componentProps: componentSection, statusKey: "section", defaultBackground: "#1e2d4a", mappingKey: "properties", keyNode: "nodes", onEdgesChange: (
|
|
152
|
+
}, children: item.name }, item.key))) }), _jsx(LayerView, { componentProps: componentSection, statusKey: "section", defaultBackground: "#1e2d4a", mappingKey: "properties", keyNode: "nodes", onEdgesChange: (edges, table) => {
|
|
153
|
+
console.log(edges, "edges");
|
|
154
|
+
setEdges(edges);
|
|
155
|
+
}, initialEdges: edges, isConnectEdge: isConnecting, isSelectNode: isSelectNode, connectionMatchKey: {
|
|
156
|
+
key: "use_connection",
|
|
157
|
+
value: 1
|
|
158
|
+
},
|
|
149
159
|
// extraComponentProps={background}
|
|
150
160
|
onSelectComponent: handleSelectItem,
|
|
151
161
|
// actionPrivileged={{
|
|
152
162
|
// select: true,
|
|
153
163
|
// }}
|
|
154
|
-
onMakeSelection: onMakeSelection,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
164
|
+
onMakeSelection: onMakeSelection,
|
|
165
|
+
// tableMatchKey={[
|
|
166
|
+
// // {
|
|
167
|
+
// // key: "capacity",
|
|
168
|
+
// // value: 5,
|
|
169
|
+
// // properties: {
|
|
170
|
+
// // fill: "#000000",
|
|
171
|
+
// // },
|
|
172
|
+
// // element: {
|
|
173
|
+
// // icon: undefined,
|
|
174
|
+
// // props: {},
|
|
175
|
+
// // },
|
|
176
|
+
// },
|
|
177
|
+
// ]}
|
|
178
|
+
onDragTable: (_, data) => setDataDrag(data), actionPrivileged: actionPrivileged,
|
|
179
|
+
// groupSelection={{
|
|
180
|
+
// colorGroupSelection: COLORS_SECTION,
|
|
181
|
+
// dataKey: "uuid_table",
|
|
182
|
+
// selection: selection
|
|
183
|
+
// }}
|
|
184
|
+
onRightClick: (e, data) => {
|
|
171
185
|
console.log({ e, data });
|
|
172
186
|
}, allowTooltip: true, onHoldTable: (e, data) => {
|
|
173
187
|
console.log({ e, data });
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import LayerView from "../../features/view-only-5";
|
|
4
|
-
import {
|
|
4
|
+
import { data } from "./constant";
|
|
5
5
|
import { Button } from "antd";
|
|
6
6
|
import { useMemo, useState } from "react";
|
|
7
|
-
import { selection } from "./selection";
|
|
8
7
|
export default function GraphView() {
|
|
9
8
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
10
9
|
const [actionPrivileged, setActionPrivileged] = useState({
|
|
@@ -35,10 +34,13 @@ export default function GraphView() {
|
|
|
35
34
|
},
|
|
36
35
|
]);
|
|
37
36
|
const [sectionActive, setSectionActive] = useState(null);
|
|
38
|
-
const componentSection = useMemo(() =>
|
|
37
|
+
const componentSection = useMemo(() => {
|
|
39
38
|
var _a;
|
|
40
|
-
return (
|
|
41
|
-
|
|
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]);
|
|
42
44
|
const onMakeSelection = (datas) => {
|
|
43
45
|
setSections((prev) => {
|
|
44
46
|
const uuidSet = new Set(datas.map((d) => d.uuid_table));
|
|
@@ -142,6 +144,8 @@ export default function GraphView() {
|
|
|
142
144
|
setDataDrag(null);
|
|
143
145
|
}
|
|
144
146
|
};
|
|
147
|
+
const [edges, setEdges] = useState([]);
|
|
148
|
+
console.log({ edges });
|
|
145
149
|
return (<div className="w-full h-screen flex relative">
|
|
146
150
|
<div className="flex">
|
|
147
151
|
<div className="absolute top-0 left-0 z-10 flex gap-2">
|
|
@@ -151,29 +155,39 @@ export default function GraphView() {
|
|
|
151
155
|
{item.name}
|
|
152
156
|
</Button>))}
|
|
153
157
|
</div>
|
|
154
|
-
<LayerView componentProps={componentSection} statusKey="section" defaultBackground="#1e2d4a" mappingKey="properties" keyNode="nodes" onEdgesChange={(
|
|
158
|
+
<LayerView componentProps={componentSection} statusKey="section" defaultBackground="#1e2d4a" mappingKey="properties" keyNode="nodes" onEdgesChange={(edges, table) => {
|
|
159
|
+
console.log(edges, "edges");
|
|
160
|
+
setEdges(edges);
|
|
161
|
+
}} initialEdges={edges} isConnectEdge={isConnecting} isSelectNode={isSelectNode} connectionMatchKey={{
|
|
162
|
+
key: "use_connection",
|
|
163
|
+
value: 1
|
|
164
|
+
}}
|
|
155
165
|
// extraComponentProps={background}
|
|
156
166
|
onSelectComponent={handleSelectItem}
|
|
157
167
|
// actionPrivileged={{
|
|
158
168
|
// select: true,
|
|
159
169
|
// }}
|
|
160
|
-
onMakeSelection={onMakeSelection}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
onMakeSelection={onMakeSelection}
|
|
171
|
+
// tableMatchKey={[
|
|
172
|
+
// // {
|
|
173
|
+
// // key: "capacity",
|
|
174
|
+
// // value: 5,
|
|
175
|
+
// // properties: {
|
|
176
|
+
// // fill: "#000000",
|
|
177
|
+
// // },
|
|
178
|
+
// // element: {
|
|
179
|
+
// // icon: undefined,
|
|
180
|
+
// // props: {},
|
|
181
|
+
// // },
|
|
182
|
+
// },
|
|
183
|
+
// ]}
|
|
184
|
+
onDragTable={(_, data) => setDataDrag(data)} actionPrivileged={actionPrivileged}
|
|
185
|
+
// groupSelection={{
|
|
186
|
+
// colorGroupSelection: COLORS_SECTION,
|
|
187
|
+
// dataKey: "uuid_table",
|
|
188
|
+
// selection: selection
|
|
189
|
+
// }}
|
|
190
|
+
onRightClick={(e, data) => {
|
|
177
191
|
console.log({ e, data });
|
|
178
192
|
}} allowTooltip={true} onHoldTable={(e, data) => {
|
|
179
193
|
console.log({ e, data });
|
|
@@ -79,11 +79,11 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
|
|
|
79
79
|
};
|
|
80
80
|
if (!showConnection)
|
|
81
81
|
return null;
|
|
82
|
-
return (_jsxs("g", { transform: `translate(${cx}, ${cy}) rotate(${rotation})`, children: [_jsx("rect", { x: -hw - 4, y: -hh - 4, width: width + 8, height: height + 8, fill: "transparent", stroke: isActive ? "#
|
|
82
|
+
return (_jsxs("g", { transform: `translate(${cx}, ${cy}) rotate(${rotation})`, children: [_jsx("rect", { x: -hw - 4, y: -hh - 4, width: width + 8, height: height + 8, fill: "transparent", stroke: (isActive && (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) === nodeId) ? "#5014D0" : hovered ? "#3E97FF" : "transparent", strokeWidth: isActive ? 1 : 1, strokeDasharray: (isActive && hovered) ? "solid" : "none", rx: 4, style: { pointerEvents: "none" } }), _jsx("rect", { x: -hw - 4, y: -hh - 4, width: width + 8, height: height + 8, fill: "transparent", style: {
|
|
83
83
|
cursor: isConnectEdge ? "crosshair" : "pointer",
|
|
84
84
|
pointerEvents: isConnectEdge ? "all" : "none",
|
|
85
85
|
}, onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), onPointerDown: (e) => {
|
|
86
86
|
handlePointerDown(e);
|
|
87
87
|
} }), ((hovered && isConnectEdge) || isActive) &&
|
|
88
|
-
anchors.map((a, i) => (_jsx("circle", { cx: a.x, cy: a.y, r: 3, fill: isActive ? "#
|
|
88
|
+
anchors.map((a, i) => (_jsx("circle", { cx: a.x, cy: a.y, r: 3, fill: isActive ? "#7239EA" : "#38bdf8", opacity: 0.5, style: { pointerEvents: "none" } }, i)))] }));
|
|
89
89
|
};
|
|
@@ -80,7 +80,7 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
|
|
|
80
80
|
return null;
|
|
81
81
|
return (<g transform={`translate(${cx}, ${cy}) rotate(${rotation})`}>
|
|
82
82
|
{/* Border visual */}
|
|
83
|
-
<rect x={-hw - 4} y={-hh - 4} width={width + 8} height={height + 8} fill="transparent" stroke={isActive ? "#
|
|
83
|
+
<rect x={-hw - 4} y={-hh - 4} width={width + 8} height={height + 8} fill={"transparent"} stroke={(isActive && (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) === nodeId) ? "#5014D0" : hovered ? "#3E97FF" : "transparent"} strokeWidth={isActive ? 1 : 1} strokeDasharray={(isActive && hovered) ? "solid" : "none"} rx={4} style={{ pointerEvents: "none" }}/>
|
|
84
84
|
|
|
85
85
|
{/* Hit area */}
|
|
86
86
|
<rect x={-hw - 4} y={-hh - 4} width={width + 8} height={height + 8} fill="transparent" style={{
|
|
@@ -92,7 +92,7 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
|
|
|
92
92
|
|
|
93
93
|
{/* Anchor dots — muncul saat hover atau active */}
|
|
94
94
|
{((hovered && isConnectEdge) || isActive) &&
|
|
95
|
-
anchors.map((a, i) => (<circle key={i} cx={a.x} cy={a.y} r={3} fill={isActive ? "#
|
|
95
|
+
anchors.map((a, i) => (<circle key={i} cx={a.x} cy={a.y} r={3} fill={isActive ? "#7239EA" : "#38bdf8"} opacity={0.5} style={{ pointerEvents: "none" }}/>))}
|
|
96
96
|
|
|
97
97
|
</g>);
|
|
98
98
|
};
|
|
@@ -32,6 +32,15 @@ type Props = {
|
|
|
32
32
|
selectedNodeId: string | null;
|
|
33
33
|
showConnection?: boolean;
|
|
34
34
|
renderedElements?: ComponentProps[];
|
|
35
|
+
groupSelection?: {
|
|
36
|
+
colorGroupSelection: string[];
|
|
37
|
+
dataKey: string;
|
|
38
|
+
selection: Record<number, string[]>;
|
|
39
|
+
};
|
|
40
|
+
connectionMatchKey?: {
|
|
41
|
+
key: string;
|
|
42
|
+
value: string | number;
|
|
43
|
+
};
|
|
35
44
|
};
|
|
36
45
|
export declare const ConnectionLayer: React.FC<Props>;
|
|
37
46
|
export {};
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useState } from "react";
|
|
3
3
|
import { buildPath, getRectEdge, GRID_SIZE, NODE_WIDTH, NODE_HEIGHT, snap, rotatePoint, } from "./utils";
|
|
4
|
-
const LEVEL_COLORS = [
|
|
5
|
-
"#22c55e",
|
|
6
|
-
"#f59e0b",
|
|
7
|
-
"#f97316",
|
|
8
|
-
"#ef4444",
|
|
9
|
-
"#a78bfa",
|
|
10
|
-
"#38bdf8",
|
|
11
|
-
];
|
|
4
|
+
const LEVEL_COLORS = ["#7239EA", "#3E97FF"];
|
|
12
5
|
const getLevelColor = (level) => LEVEL_COLORS[Math.min(level, LEVEL_COLORS.length - 1)];
|
|
13
6
|
const floodFill = (seedIds, edges) => {
|
|
14
7
|
const levelMap = new Map();
|
|
@@ -52,8 +45,14 @@ const quadraticMidpoint = (from, to) => {
|
|
|
52
45
|
y: mt * mt * from.y + 2 * mt * t * cpy + t * t * to.y,
|
|
53
46
|
};
|
|
54
47
|
};
|
|
55
|
-
export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAnchor, mousePos, isConnectEdge, getNodeById, onSelectEdge, onDeleteEdge, onStartDragWaypoint, onInsertWaypoint, onRemoveWaypoint, onStartDragAnchor, selectedNodeId, showConnection, renderedElements, }) => {
|
|
48
|
+
export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAnchor, mousePos, isConnectEdge, getNodeById, onSelectEdge, onDeleteEdge, onStartDragWaypoint, onInsertWaypoint, onRemoveWaypoint, onStartDragAnchor, selectedNodeId, showConnection, renderedElements, groupSelection, connectionMatchKey, }) => {
|
|
56
49
|
const [hoveredEdge, setHoveredEdge] = useState(null);
|
|
50
|
+
const tableMatchConnectionKey = useMemo(() => renderedElements === null || renderedElements === void 0 ? void 0 : renderedElements.filter((el) => {
|
|
51
|
+
if (connectionMatchKey) {
|
|
52
|
+
return (el === null || el === void 0 ? void 0 : el[connectionMatchKey === null || connectionMatchKey === void 0 ? void 0 : connectionMatchKey.key]) === (connectionMatchKey === null || connectionMatchKey === void 0 ? void 0 : connectionMatchKey.value);
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}), [renderedElements, connectionMatchKey]);
|
|
57
56
|
const nodeHighlightMap = useMemo(() => {
|
|
58
57
|
if (!selectedEdge)
|
|
59
58
|
return new Map();
|
|
@@ -63,7 +62,7 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
63
62
|
return floodFill([sel.from, sel.to], edges);
|
|
64
63
|
}, [selectedEdge, edges]);
|
|
65
64
|
const nodeHighlightMapByNode = useMemo(() => {
|
|
66
|
-
if (selectedNodeId) {
|
|
65
|
+
if (selectedNodeId || connecting) {
|
|
67
66
|
return floodFill([selectedNodeId], edges);
|
|
68
67
|
}
|
|
69
68
|
if (selectedEdge) {
|
|
@@ -74,6 +73,12 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
74
73
|
}
|
|
75
74
|
return new Map();
|
|
76
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]);
|
|
77
82
|
const edgePaths = useMemo(() => {
|
|
78
83
|
const map = new Map();
|
|
79
84
|
edges.forEach((edge) => {
|
|
@@ -107,16 +112,7 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
107
112
|
if (!showConnection) {
|
|
108
113
|
return null;
|
|
109
114
|
}
|
|
110
|
-
|
|
111
|
-
// const dx = world.x - cx;
|
|
112
|
-
// const dy = world.y - cy;
|
|
113
|
-
// const rad = -(rotation * Math.PI) / 180;
|
|
114
|
-
// return {
|
|
115
|
-
// x: dx * Math.cos(rad) - dy * Math.sin(rad),
|
|
116
|
-
// y: dx * Math.sin(rad) + dy * Math.cos(rad),
|
|
117
|
-
// };
|
|
118
|
-
// };
|
|
119
|
-
return (_jsxs("g", { id: "connection-layer", children: [Array.from(nodeHighlightMap.entries()).map(([nodeId, level]) => {
|
|
115
|
+
return (_jsxs("g", { id: "connection-layer", children: [Array.from(nodeHighlightMapByConnecting.entries()).map(([nodeId, level]) => {
|
|
120
116
|
var _a, _b, _c;
|
|
121
117
|
const node = getNodeById(nodeId);
|
|
122
118
|
if (!node)
|
|
@@ -126,7 +122,26 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
126
122
|
const rotation = (_c = node.rotation) !== null && _c !== void 0 ? _c : 0;
|
|
127
123
|
const color = getLevelColor(level);
|
|
128
124
|
const padding = 4;
|
|
129
|
-
|
|
125
|
+
if (level > 1)
|
|
126
|
+
return null;
|
|
127
|
+
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,
|
|
128
|
+
// strokeDasharray={level === 0 ? "none" : "5 3"}
|
|
129
|
+
rx: 5 })] }, `highlight-${nodeId}`));
|
|
130
|
+
}), Array.from(nodeHighlightMap.entries()).map(([nodeId, level]) => {
|
|
131
|
+
var _a, _b, _c;
|
|
132
|
+
const node = getNodeById(nodeId);
|
|
133
|
+
if (!node)
|
|
134
|
+
return null;
|
|
135
|
+
const w = (_a = node.width) !== null && _a !== void 0 ? _a : NODE_WIDTH;
|
|
136
|
+
const h = (_b = node.height) !== null && _b !== void 0 ? _b : NODE_HEIGHT;
|
|
137
|
+
const rotation = (_c = node.rotation) !== null && _c !== void 0 ? _c : 0;
|
|
138
|
+
const color = getLevelColor(level);
|
|
139
|
+
const padding = 4;
|
|
140
|
+
if (level > 0)
|
|
141
|
+
return null;
|
|
142
|
+
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,
|
|
143
|
+
// strokeDasharray={level === 0 ? "none" : "5 3"}
|
|
144
|
+
rx: 5, opacity: level === 0 ? 1 : 0.75 }), _jsx("g", { transform: `translate(${w / 2 + padding - 2}, ${-h / 2 - padding})` })] }, `highlight-${nodeId}`));
|
|
130
145
|
}), Array.from(nodeHighlightMapByNode.entries()).map(([nodeId, level]) => {
|
|
131
146
|
var _a, _b, _c;
|
|
132
147
|
const node = getNodeById(nodeId);
|
|
@@ -137,7 +152,12 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
137
152
|
const rotation = (_c = node.rotation) !== null && _c !== void 0 ? _c : 0;
|
|
138
153
|
const color = getLevelColor(level);
|
|
139
154
|
const padding = 4;
|
|
140
|
-
|
|
155
|
+
// console.log("nodeHighlightMapByNode", nodeId, level, color);
|
|
156
|
+
if (level > 1)
|
|
157
|
+
return null;
|
|
158
|
+
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,
|
|
159
|
+
// strokeDasharray={level === 0 ? "none" : "5 3"}
|
|
160
|
+
rx: 5, opacity: level === 0 ? 1 : 0.75 }), _jsx("g", { transform: `translate(${w / 2 + padding - 2}, ${-h / 2 - padding})` })] }, `highlight-${nodeId}`));
|
|
141
161
|
}), edges.map((edge) => {
|
|
142
162
|
var _a;
|
|
143
163
|
const ep = edgePaths.get(edge.id);
|
|
@@ -146,34 +166,34 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
146
166
|
const { pathD, allPoints, fromPos, toPos, midX, midY } = ep;
|
|
147
167
|
const isSel = selectedEdge === edge.id;
|
|
148
168
|
const isHov = hoveredEdge === edge.id;
|
|
169
|
+
const connectionMatch = tableMatchConnectionKey === null || tableMatchConnectionKey === void 0 ? void 0 : tableMatchConnectionKey.some((el) => el.id === edge.to || el.id === edge.from);
|
|
149
170
|
const fromLevel = nodeHighlightMap.get(edge.from);
|
|
150
171
|
const toLevel = nodeHighlightMap.get(edge.to);
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
: "#38bdf8";
|
|
172
|
+
const isStillConnectingProcess = (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) === edge.from || (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) === edge.to;
|
|
173
|
+
const isRing1 = (selectedNodeId && selectedNodeId === edge.from) ||
|
|
174
|
+
selectedNodeId === edge.to;
|
|
155
175
|
const isDraggingFrom = (draggingAnchor === null || draggingAnchor === void 0 ? void 0 : draggingAnchor.edgeId) === edge.id && draggingAnchor.side === "from";
|
|
156
176
|
const isDraggingTo = (draggingAnchor === null || draggingAnchor === void 0 ? void 0 : draggingAnchor.edgeId) === edge.id && draggingAnchor.side === "to";
|
|
157
|
-
// const currentConnection =
|
|
158
|
-
const isNotRing1 = connecting &&
|
|
159
|
-
(connecting === null || connecting === void 0 ? void 0 : connecting.fromId) !== edge.from &&
|
|
160
|
-
(connecting === null || connecting === void 0 ? void 0 : connecting.fromId) !== edge.to;
|
|
161
177
|
return (_jsxs("g", { children: [_jsx("path", { d: pathD, stroke: "transparent", strokeWidth: 14, fill: "none", style: { cursor: "pointer" }, onClick: (e) => {
|
|
162
178
|
e.stopPropagation();
|
|
163
179
|
onSelectEdge(edge.id);
|
|
164
|
-
}, 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: isSel
|
|
165
|
-
?
|
|
166
|
-
:
|
|
167
|
-
?
|
|
168
|
-
: "
|
|
169
|
-
? 0.2
|
|
170
|
-
: 0.9, strokeLinecap: "round", style: { pointerEvents: "none" } }), isSel && (_jsxs("g", { children: [isDraggingFrom && (_jsx("circle", { cx: fromPos.x, cy: fromPos.y, r: 12, fill: "#38bdf8", opacity: 0.15, style: { pointerEvents: "none" } })), _jsx("circle", { cx: fromPos.x, cy: fromPos.y, r: 10, fill: "transparent", style: { cursor: "grab" }, onMouseDown: (e) => {
|
|
180
|
+
}, 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
|
|
181
|
+
? 1
|
|
182
|
+
: connecting
|
|
183
|
+
? 0
|
|
184
|
+
: 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) => {
|
|
171
185
|
e.stopPropagation();
|
|
172
186
|
onStartDragAnchor(e, edge.id, "from");
|
|
173
|
-
} }), _jsx("circle", { cx: fromPos.x, cy: fromPos.y, r:
|
|
187
|
+
} }), _jsx("circle", { cx: fromPos.x, cy: fromPos.y, r: 3, fill: connectionMatch ? "#F1416C" : "#7239EA",
|
|
188
|
+
// stroke="#0f172a"
|
|
189
|
+
// strokeWidth={1.5}
|
|
190
|
+
style: { pointerEvents: "none" } })] }), _jsxs("g", { children: [isDraggingTo && (_jsx("circle", { cx: toPos.x, cy: toPos.y, r: 12, fill: "#7239EA", opacity: 0.15, style: { pointerEvents: "none" } })), _jsx("circle", { cx: toPos.x, cy: toPos.y, r: 10, fill: "transparent", style: { cursor: "grab" }, onMouseDown: (e) => {
|
|
174
191
|
e.stopPropagation();
|
|
175
192
|
onStartDragAnchor(e, edge.id, "to");
|
|
176
|
-
} }), _jsx("circle", { cx: toPos.x, cy: toPos.y, r:
|
|
193
|
+
} }), _jsx("circle", { cx: toPos.x, cy: toPos.y, r: 3, fill: connectionMatch ? "#F1416C" : "#7239EA",
|
|
194
|
+
// stroke="#0f172a"
|
|
195
|
+
// strokeWidth={1.5}
|
|
196
|
+
style: { pointerEvents: "none" } })] }), ((_a = edge.waypoints) !== null && _a !== void 0 ? _a : []).map((wp, i) => (_jsxs("g", { children: [_jsx("circle", { cx: wp.x, cy: wp.y, r: 12, fill: "transparent", style: { cursor: "grab" }, onMouseDown: (e) => onStartDragWaypoint(e, edge.id, i), onContextMenu: (e) => onRemoveWaypoint(e, edge.id, i) }), _jsx("circle", { cx: wp.x, cy: wp.y, r: isSel ? 8 : 5, fill: isSel ? "#1e1b2e" : "#0f172a", stroke: isSel ? "#a78bfa" : "#38bdf8", strokeWidth: isSel ? 2 : 1.2, style: { pointerEvents: "none" } }), _jsx("circle", { cx: wp.x, cy: wp.y, r: isSel ? 3 : 2, fill: isSel ? "#a78bfa" : "#38bdf8", style: { pointerEvents: "none" } })] }, `wp-${i}`))), isSel &&
|
|
177
197
|
isConnectEdge &&
|
|
178
198
|
allPoints.slice(0, -1).map((pt, i) => {
|
|
179
199
|
var _a;
|
|
@@ -191,7 +211,7 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
191
211
|
}, style: { cursor: "pointer" }, children: [_jsx("rect", { x: midX - 16, y: midY - 10, width: 32, height: 18, rx: 4, fill: "#1e1b2e", stroke: "#a78bfa", strokeWidth: 1, opacity: 0.95 }), _jsx("text", { x: midX, y: midY, textAnchor: "middle", dominantBaseline: "middle", fill: "#a78bfa", fontSize: 9, fontFamily: "monospace", fontWeight: 600, children: "DEL" })] }))] }, edge.id));
|
|
192
212
|
}), connecting &&
|
|
193
213
|
(() => {
|
|
194
|
-
const findSourceTarget = renderedElements === null || renderedElements === void 0 ? void 0 : renderedElements.find((el) => el.id === connecting.fromId);
|
|
214
|
+
const findSourceTarget = renderedElements === null || renderedElements === void 0 ? void 0 : renderedElements.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) === connecting.fromId; });
|
|
195
215
|
if (!findSourceTarget)
|
|
196
216
|
return null;
|
|
197
217
|
const { x, y, rotation, width, height } = findSourceTarget;
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import React, { useMemo, useState } from "react";
|
|
2
2
|
import { buildPath, getRectEdge, GRID_SIZE, NODE_WIDTH, NODE_HEIGHT, snap, rotatePoint, } from "./utils";
|
|
3
|
-
const LEVEL_COLORS = [
|
|
4
|
-
"#22c55e",
|
|
5
|
-
"#f59e0b",
|
|
6
|
-
"#f97316",
|
|
7
|
-
"#ef4444",
|
|
8
|
-
"#a78bfa",
|
|
9
|
-
"#38bdf8",
|
|
10
|
-
];
|
|
3
|
+
const LEVEL_COLORS = ["#7239EA", "#3E97FF"];
|
|
11
4
|
const getLevelColor = (level) => LEVEL_COLORS[Math.min(level, LEVEL_COLORS.length - 1)];
|
|
12
5
|
const floodFill = (seedIds, edges) => {
|
|
13
6
|
const levelMap = new Map();
|
|
@@ -51,8 +44,14 @@ const quadraticMidpoint = (from, to) => {
|
|
|
51
44
|
y: mt * mt * from.y + 2 * mt * t * cpy + t * t * to.y,
|
|
52
45
|
};
|
|
53
46
|
};
|
|
54
|
-
export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAnchor, mousePos, isConnectEdge, getNodeById, onSelectEdge, onDeleteEdge, onStartDragWaypoint, onInsertWaypoint, onRemoveWaypoint, onStartDragAnchor, selectedNodeId, showConnection, renderedElements, }) => {
|
|
47
|
+
export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAnchor, mousePos, isConnectEdge, getNodeById, onSelectEdge, onDeleteEdge, onStartDragWaypoint, onInsertWaypoint, onRemoveWaypoint, onStartDragAnchor, selectedNodeId, showConnection, renderedElements, groupSelection, connectionMatchKey, }) => {
|
|
55
48
|
const [hoveredEdge, setHoveredEdge] = useState(null);
|
|
49
|
+
const tableMatchConnectionKey = useMemo(() => renderedElements === null || renderedElements === void 0 ? void 0 : renderedElements.filter((el) => {
|
|
50
|
+
if (connectionMatchKey) {
|
|
51
|
+
return (el === null || el === void 0 ? void 0 : el[connectionMatchKey === null || connectionMatchKey === void 0 ? void 0 : connectionMatchKey.key]) === (connectionMatchKey === null || connectionMatchKey === void 0 ? void 0 : connectionMatchKey.value);
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}), [renderedElements, connectionMatchKey]);
|
|
56
55
|
const nodeHighlightMap = useMemo(() => {
|
|
57
56
|
if (!selectedEdge)
|
|
58
57
|
return new Map();
|
|
@@ -62,7 +61,7 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
62
61
|
return floodFill([sel.from, sel.to], edges);
|
|
63
62
|
}, [selectedEdge, edges]);
|
|
64
63
|
const nodeHighlightMapByNode = useMemo(() => {
|
|
65
|
-
if (selectedNodeId) {
|
|
64
|
+
if (selectedNodeId || connecting) {
|
|
66
65
|
return floodFill([selectedNodeId], edges);
|
|
67
66
|
}
|
|
68
67
|
if (selectedEdge) {
|
|
@@ -73,6 +72,12 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
73
72
|
}
|
|
74
73
|
return new Map();
|
|
75
74
|
}, [selectedEdge, selectedNodeId, edges]);
|
|
75
|
+
const nodeHighlightMapByConnecting = useMemo(() => {
|
|
76
|
+
if (connecting) {
|
|
77
|
+
return floodFill([connecting.fromId], edges);
|
|
78
|
+
}
|
|
79
|
+
return new Map();
|
|
80
|
+
}, [connecting, edges]);
|
|
76
81
|
const edgePaths = useMemo(() => {
|
|
77
82
|
const map = new Map();
|
|
78
83
|
edges.forEach((edge) => {
|
|
@@ -106,16 +111,27 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
106
111
|
if (!showConnection) {
|
|
107
112
|
return null;
|
|
108
113
|
}
|
|
109
|
-
// const toLocalPos = ({ cx, cy, rotation }) => {
|
|
110
|
-
// const dx = world.x - cx;
|
|
111
|
-
// const dy = world.y - cy;
|
|
112
|
-
// const rad = -(rotation * Math.PI) / 180;
|
|
113
|
-
// return {
|
|
114
|
-
// x: dx * Math.cos(rad) - dy * Math.sin(rad),
|
|
115
|
-
// y: dx * Math.sin(rad) + dy * Math.cos(rad),
|
|
116
|
-
// };
|
|
117
|
-
// };
|
|
118
114
|
return (<g id="connection-layer">
|
|
115
|
+
{Array.from(nodeHighlightMapByConnecting.entries()).map(([nodeId, level]) => {
|
|
116
|
+
var _a, _b, _c;
|
|
117
|
+
const node = getNodeById(nodeId);
|
|
118
|
+
if (!node)
|
|
119
|
+
return null;
|
|
120
|
+
const w = (_a = node.width) !== null && _a !== void 0 ? _a : NODE_WIDTH;
|
|
121
|
+
const h = (_b = node.height) !== null && _b !== void 0 ? _b : NODE_HEIGHT;
|
|
122
|
+
const rotation = (_c = node.rotation) !== null && _c !== void 0 ? _c : 0;
|
|
123
|
+
const color = getLevelColor(level);
|
|
124
|
+
const padding = 4;
|
|
125
|
+
if (level > 1)
|
|
126
|
+
return null;
|
|
127
|
+
return (<g key={`highlight-${nodeId}`} transform={`translate(${node.x}, ${node.y}) rotate(${rotation})`} style={{ pointerEvents: "none" }}>
|
|
128
|
+
<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}/>
|
|
129
|
+
<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}
|
|
130
|
+
// strokeDasharray={level === 0 ? "none" : "5 3"}
|
|
131
|
+
rx={5}/>
|
|
132
|
+
</g>);
|
|
133
|
+
})}
|
|
134
|
+
|
|
119
135
|
{/* Node highlight flood fill */}
|
|
120
136
|
{Array.from(nodeHighlightMap.entries()).map(([nodeId, level]) => {
|
|
121
137
|
var _a, _b, _c;
|
|
@@ -127,14 +143,26 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
127
143
|
const rotation = (_c = node.rotation) !== null && _c !== void 0 ? _c : 0;
|
|
128
144
|
const color = getLevelColor(level);
|
|
129
145
|
const padding = 4;
|
|
146
|
+
if (level > 0)
|
|
147
|
+
return null;
|
|
130
148
|
return (<g key={`highlight-${nodeId}`} transform={`translate(${node.x}, ${node.y}) rotate(${rotation})`} style={{ pointerEvents: "none" }}>
|
|
131
149
|
<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}/>
|
|
132
|
-
<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}
|
|
150
|
+
<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}
|
|
151
|
+
// strokeDasharray={level === 0 ? "none" : "5 3"}
|
|
152
|
+
rx={5} opacity={level === 0 ? 1 : 0.75}/>
|
|
133
153
|
<g transform={`translate(${w / 2 + padding - 2}, ${-h / 2 - padding})`}>
|
|
134
|
-
<circle r={7} fill={color} opacity={0.9}/>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
154
|
+
{/* <circle r={7} fill={color} opacity={0.9} />
|
|
155
|
+
<text
|
|
156
|
+
textAnchor="middle"
|
|
157
|
+
dominantBaseline="middle"
|
|
158
|
+
fill="white"
|
|
159
|
+
fontSize={7}
|
|
160
|
+
fontFamily="monospace"
|
|
161
|
+
fontWeight={700}
|
|
162
|
+
style={{ userSelect: "none" }}
|
|
163
|
+
>
|
|
164
|
+
{level}
|
|
165
|
+
</text> */}
|
|
138
166
|
</g>
|
|
139
167
|
</g>);
|
|
140
168
|
})}
|
|
@@ -149,14 +177,27 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
149
177
|
const rotation = (_c = node.rotation) !== null && _c !== void 0 ? _c : 0;
|
|
150
178
|
const color = getLevelColor(level);
|
|
151
179
|
const padding = 4;
|
|
180
|
+
// console.log("nodeHighlightMapByNode", nodeId, level, color);
|
|
181
|
+
if (level > 1)
|
|
182
|
+
return null;
|
|
152
183
|
return (<g key={`highlight-${nodeId}`} transform={`translate(${node.x}, ${node.y}) rotate(${rotation})`} style={{ pointerEvents: "none" }}>
|
|
153
184
|
<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}/>
|
|
154
|
-
<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}
|
|
185
|
+
<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}
|
|
186
|
+
// strokeDasharray={level === 0 ? "none" : "5 3"}
|
|
187
|
+
rx={5} opacity={level === 0 ? 1 : 0.75}/>
|
|
155
188
|
<g transform={`translate(${w / 2 + padding - 2}, ${-h / 2 - padding})`}>
|
|
156
|
-
<circle r={7} fill={color} opacity={0.9}/>
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
189
|
+
{/* <circle r={7} fill={color} opacity={0.9} />
|
|
190
|
+
<text
|
|
191
|
+
textAnchor="middle"
|
|
192
|
+
dominantBaseline="middle"
|
|
193
|
+
fill="white"
|
|
194
|
+
fontSize={7}
|
|
195
|
+
fontFamily="monospace"
|
|
196
|
+
fontWeight={700}
|
|
197
|
+
style={{ userSelect: "none" }}
|
|
198
|
+
>
|
|
199
|
+
{level}
|
|
200
|
+
</text> */}
|
|
160
201
|
</g>
|
|
161
202
|
</g>);
|
|
162
203
|
})}
|
|
@@ -170,18 +211,14 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
170
211
|
const { pathD, allPoints, fromPos, toPos, midX, midY } = ep;
|
|
171
212
|
const isSel = selectedEdge === edge.id;
|
|
172
213
|
const isHov = hoveredEdge === edge.id;
|
|
214
|
+
const connectionMatch = tableMatchConnectionKey === null || tableMatchConnectionKey === void 0 ? void 0 : tableMatchConnectionKey.some((el) => el.id === edge.to || el.id === edge.from);
|
|
173
215
|
const fromLevel = nodeHighlightMap.get(edge.from);
|
|
174
216
|
const toLevel = nodeHighlightMap.get(edge.to);
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
: "#38bdf8";
|
|
217
|
+
const isStillConnectingProcess = (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) === edge.from || (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) === edge.to;
|
|
218
|
+
const isRing1 = (selectedNodeId && selectedNodeId === edge.from) ||
|
|
219
|
+
selectedNodeId === edge.to;
|
|
179
220
|
const isDraggingFrom = (draggingAnchor === null || draggingAnchor === void 0 ? void 0 : draggingAnchor.edgeId) === edge.id && draggingAnchor.side === "from";
|
|
180
221
|
const isDraggingTo = (draggingAnchor === null || draggingAnchor === void 0 ? void 0 : draggingAnchor.edgeId) === edge.id && draggingAnchor.side === "to";
|
|
181
|
-
// const currentConnection =
|
|
182
|
-
const isNotRing1 = connecting &&
|
|
183
|
-
(connecting === null || connecting === void 0 ? void 0 : connecting.fromId) !== edge.from &&
|
|
184
|
-
(connecting === null || connecting === void 0 ? void 0 : connecting.fromId) !== edge.to;
|
|
185
222
|
return (<g key={edge.id}>
|
|
186
223
|
{/* Hit area */}
|
|
187
224
|
<path d={pathD} stroke="transparent" strokeWidth={14} fill="none" style={{ cursor: "pointer" }} onClick={(e) => {
|
|
@@ -193,35 +230,56 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
193
230
|
{(isSel || isHov) && (<path d={pathD} stroke={isSel ? "#a78bfa" : "#38bdf8"} strokeWidth={8} fill="none" opacity={isSel ? 0.12 : 0.06} style={{ pointerEvents: "none" }}/>)}
|
|
194
231
|
|
|
195
232
|
{/* Curve */}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
: 0.9} strokeLinecap="round" style={{ pointerEvents: "none" }}/>
|
|
233
|
+
|
|
234
|
+
<path d={pathD} stroke={connectionMatch ? "#F1416C" : "#7239EA"} strokeWidth={isSel ? 2 : isHov ? 2 : 1.5} fill={"none"} opacity={(isRing1 && selectedNodeId) || isStillConnectingProcess
|
|
235
|
+
? 1
|
|
236
|
+
: connecting
|
|
237
|
+
? 0
|
|
238
|
+
: 0.3} strokeLinecap="round" style={{ pointerEvents: "none" }}/>
|
|
203
239
|
|
|
204
240
|
{/* FROM dot */}
|
|
205
|
-
{isSel && (
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
241
|
+
{/* {isSel && ( */}
|
|
242
|
+
<g>
|
|
243
|
+
{isDraggingFrom && (<circle cx={fromPos.x} cy={fromPos.y} r={12} fill="#7239EA" opacity={0.15} style={{ pointerEvents: "none" }}/>)}
|
|
244
|
+
<circle cx={fromPos.x} cy={fromPos.y} r={10} fill="transparent" style={{ cursor: "grab" }} onMouseDown={(e) => {
|
|
245
|
+
e.stopPropagation();
|
|
246
|
+
onStartDragAnchor(e, edge.id, "from");
|
|
247
|
+
}}/>
|
|
248
|
+
<circle cx={fromPos.x} cy={fromPos.y} r={3} fill={connectionMatch ? "#F1416C" : "#7239EA"}
|
|
249
|
+
// stroke="#0f172a"
|
|
250
|
+
// strokeWidth={1.5}
|
|
251
|
+
style={{ pointerEvents: "none" }}/>
|
|
252
|
+
{/* <circle
|
|
253
|
+
cx={fromPos.x}
|
|
254
|
+
cy={fromPos.y}
|
|
255
|
+
r={2.5}
|
|
256
|
+
fill="#0f172a"
|
|
257
|
+
style={{ pointerEvents: "none" }}
|
|
258
|
+
/> */}
|
|
259
|
+
</g>
|
|
260
|
+
{/* )} */}
|
|
214
261
|
|
|
215
262
|
{/* TO dot */}
|
|
216
|
-
{isSel && (
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
263
|
+
{/* {isSel && ( */}
|
|
264
|
+
<g>
|
|
265
|
+
{isDraggingTo && (<circle cx={toPos.x} cy={toPos.y} r={12} fill="#7239EA" opacity={0.15} style={{ pointerEvents: "none" }}/>)}
|
|
266
|
+
<circle cx={toPos.x} cy={toPos.y} r={10} fill="transparent" style={{ cursor: "grab" }} onMouseDown={(e) => {
|
|
267
|
+
e.stopPropagation();
|
|
268
|
+
onStartDragAnchor(e, edge.id, "to");
|
|
269
|
+
}}/>
|
|
270
|
+
<circle cx={toPos.x} cy={toPos.y} r={3} fill={connectionMatch ? "#F1416C" : "#7239EA"}
|
|
271
|
+
// stroke="#0f172a"
|
|
272
|
+
// strokeWidth={1.5}
|
|
273
|
+
style={{ pointerEvents: "none" }}/>
|
|
274
|
+
{/* <circle
|
|
275
|
+
cx={toPos.x}
|
|
276
|
+
cy={toPos.y}
|
|
277
|
+
r={2.5}
|
|
278
|
+
fill="#0f172a"
|
|
279
|
+
style={{ pointerEvents: "none" }}
|
|
280
|
+
/> */}
|
|
281
|
+
</g>
|
|
282
|
+
{/* )} */}
|
|
225
283
|
|
|
226
284
|
{/* Waypoints */}
|
|
227
285
|
{((_a = edge.waypoints) !== null && _a !== void 0 ? _a : []).map((wp, i) => (<g key={`wp-${i}`}>
|
|
@@ -265,7 +323,7 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
|
|
|
265
323
|
{/* Preview saat connecting */}
|
|
266
324
|
{connecting &&
|
|
267
325
|
(() => {
|
|
268
|
-
const findSourceTarget = renderedElements === null || renderedElements === void 0 ? void 0 : renderedElements.find((el) => el.id === connecting.fromId);
|
|
326
|
+
const findSourceTarget = renderedElements === null || renderedElements === void 0 ? void 0 : renderedElements.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) === connecting.fromId; });
|
|
269
327
|
if (!findSourceTarget)
|
|
270
328
|
return null;
|
|
271
329
|
const { x, y, rotation, width, height } = findSourceTarget;
|
|
@@ -116,6 +116,10 @@ export interface LayerViewProps<TMeta = undefined> {
|
|
|
116
116
|
onHoldTable?: (e: React.PointerEvent<SVGSVGElement>, component: ComponentProps<TMeta>[]) => void;
|
|
117
117
|
showConnection?: boolean;
|
|
118
118
|
initialEdges?: EdgeType[];
|
|
119
|
+
connectionMatchKey?: {
|
|
120
|
+
key: string;
|
|
121
|
+
value: string | number;
|
|
122
|
+
};
|
|
119
123
|
}
|
|
120
124
|
declare const LayerView: <TMeta>(props: LayerViewProps<TMeta>) => import("react/jsx-runtime").JSX.Element;
|
|
121
125
|
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 } = props;
|
|
32
|
+
}, onMakeSelection, groupSelection, onHoldTable, showConnection, connectionMatchKey } = 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);
|
|
@@ -618,11 +618,12 @@ const LayerView = (props) => {
|
|
|
618
618
|
};
|
|
619
619
|
// ─── Node helper ──────────────────────────────────────────────────────────
|
|
620
620
|
const getNodeById = useCallback((id) => {
|
|
621
|
-
var _a, _b, _c;
|
|
621
|
+
var _a, _b, _c, _d;
|
|
622
622
|
const comp = componentsEditor.find((item) => {
|
|
623
|
+
var _a, _b, _c;
|
|
623
624
|
if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey]))
|
|
624
|
-
return item[mappingKey].id == id;
|
|
625
|
-
return (item === null || item === void 0 ? void 0 : item.
|
|
625
|
+
return (_b = (_a = item[mappingKey]) === null || _a === void 0 ? void 0 : _a[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _b !== void 0 ? _b : item[mappingKey].id == id;
|
|
626
|
+
return (_c = item === null || item === void 0 ? void 0 : item[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _c !== void 0 ? _c : item.id == id;
|
|
626
627
|
});
|
|
627
628
|
if (!comp)
|
|
628
629
|
return null;
|
|
@@ -632,7 +633,7 @@ const LayerView = (props) => {
|
|
|
632
633
|
const rotation = (_c = v.rotation) !== null && _c !== void 0 ? _c : 0;
|
|
633
634
|
const rotated = rotatePoint(w / 2, h / 2, rotation);
|
|
634
635
|
return {
|
|
635
|
-
id: String(v.id),
|
|
636
|
+
id: (_d = v === null || v === void 0 ? void 0 : v[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _d !== void 0 ? _d : String(v.id),
|
|
636
637
|
x: v.x + rotated.x,
|
|
637
638
|
y: v.y + rotated.y,
|
|
638
639
|
width: w,
|
|
@@ -662,7 +663,7 @@ const LayerView = (props) => {
|
|
|
662
663
|
const viewBox = isValidBoundingBox
|
|
663
664
|
? `${boundingBox.minX - (((_a = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _a === void 0 ? void 0 : _a.paddingLeft) || 0)} ${boundingBox.minY - (((_b = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _b === void 0 ? void 0 : _b.paddingTop) || 0)} ${boundingBox.width + (((_c = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _c === void 0 ? void 0 : _c.paddingRight) || 0)} ${boundingBox.height + (((_d = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _d === void 0 ? void 0 : _d.paddingBottom) || 0)}`
|
|
664
665
|
: "0 0 1000 1000";
|
|
665
|
-
const renderedElements = useMemo(() => renderElements(componentsEditor, mappingKey, tableMatchKey, graph.connecting, groupSelection), [
|
|
666
|
+
const renderedElements = useMemo(() => renderElements(componentsEditor, mappingKey, tableMatchKey, graph.connecting, groupSelection, graph.edges, connectionMatchKey), [
|
|
666
667
|
componentsEditor,
|
|
667
668
|
mappingKey,
|
|
668
669
|
tableMatchKey,
|
|
@@ -671,6 +672,8 @@ const LayerView = (props) => {
|
|
|
671
672
|
groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.selection,
|
|
672
673
|
groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey,
|
|
673
674
|
groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.colorGroupSelection,
|
|
675
|
+
graph.edges,
|
|
676
|
+
connectionMatchKey
|
|
674
677
|
]);
|
|
675
678
|
return (_jsxs("div", Object.assign({ className: "relative w-full h-full flex-1", ref: containerRef, style: { overflow: "auto", WebkitOverflowScrolling: "touch" } }, props.containerProps, { children: [loading && (_jsx("div", { className: "absolute z-10 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-opacity-50 bg-white w-full h-full flex items-center justify-center", children: (loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.element) || _jsx(Spin, {}) })), _jsx(TransformWrapper, Object.assign({ ref: transformRef, disablePadding: true, centerZoomedOut: true, panning: { disabled: panningGroup, wheelPanning: true }, wheel: { disabled: false }, onTransformed: ({ state: { scale } }) => setScale(scale), minScale: 1, maxScale: 1000, initialScale: 1, smooth: true, centerOnInit: true }, props.transformProps, { children: _jsxs(TransformComponent, { wrapperStyle: { width: "100%", height: "100%" }, contentStyle: { width: "100%", height: "100%" }, children: [_jsxs("svg", Object.assign({ id: "workspace", ref: svgRef, width: "100%", height: "100%", overflow: "hidden", viewBox: viewBox, className: "h-full", xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid meet", onContextMenu: (e) => e.preventDefault(),
|
|
676
679
|
// onDrop={(e) => handleTableEvent(e, "drop")}
|
|
@@ -684,12 +687,12 @@ const LayerView = (props) => {
|
|
|
684
687
|
userSelect: "none",
|
|
685
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,
|
|
686
689
|
// iconTags={iconTags}
|
|
687
|
-
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 }), renderedElements.map((item) => {
|
|
688
|
-
var _a, _b, _c, _d;
|
|
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) => {
|
|
691
|
+
var _a, _b, _c, _d, _e;
|
|
689
692
|
const rotated = rotatePoint(item.width / 2, item.height / 2, (_a = item.rotation) !== null && _a !== void 0 ? _a : 0);
|
|
690
693
|
return (_jsx(ConnectHandle, {
|
|
691
694
|
// isAnchor={true}
|
|
692
|
-
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: 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) => graph.startConnect(nodeId, clickPos), onEndConnect: (nodeId, clickPos) => {
|
|
693
696
|
if (graph.draggingAnchor)
|
|
694
697
|
graph.updateAnchor(nodeId, clickPos);
|
|
695
698
|
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 } = props;
|
|
31
|
+
}, onMakeSelection, groupSelection, onHoldTable, showConnection, connectionMatchKey } = 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);
|
|
@@ -617,11 +617,12 @@ const LayerView = (props) => {
|
|
|
617
617
|
};
|
|
618
618
|
// ─── Node helper ──────────────────────────────────────────────────────────
|
|
619
619
|
const getNodeById = useCallback((id) => {
|
|
620
|
-
var _a, _b, _c;
|
|
620
|
+
var _a, _b, _c, _d;
|
|
621
621
|
const comp = componentsEditor.find((item) => {
|
|
622
|
+
var _a, _b, _c;
|
|
622
623
|
if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey]))
|
|
623
|
-
return item[mappingKey].id == id;
|
|
624
|
-
return (item === null || item === void 0 ? void 0 : item.
|
|
624
|
+
return (_b = (_a = item[mappingKey]) === null || _a === void 0 ? void 0 : _a[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _b !== void 0 ? _b : item[mappingKey].id == id;
|
|
625
|
+
return (_c = item === null || item === void 0 ? void 0 : item[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _c !== void 0 ? _c : item.id == id;
|
|
625
626
|
});
|
|
626
627
|
if (!comp)
|
|
627
628
|
return null;
|
|
@@ -631,7 +632,7 @@ const LayerView = (props) => {
|
|
|
631
632
|
const rotation = (_c = v.rotation) !== null && _c !== void 0 ? _c : 0;
|
|
632
633
|
const rotated = rotatePoint(w / 2, h / 2, rotation);
|
|
633
634
|
return {
|
|
634
|
-
id: String(v.id),
|
|
635
|
+
id: (_d = v === null || v === void 0 ? void 0 : v[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _d !== void 0 ? _d : String(v.id),
|
|
635
636
|
x: v.x + rotated.x,
|
|
636
637
|
y: v.y + rotated.y,
|
|
637
638
|
width: w,
|
|
@@ -661,7 +662,7 @@ const LayerView = (props) => {
|
|
|
661
662
|
const viewBox = isValidBoundingBox
|
|
662
663
|
? `${boundingBox.minX - (((_a = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _a === void 0 ? void 0 : _a.paddingLeft) || 0)} ${boundingBox.minY - (((_b = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _b === void 0 ? void 0 : _b.paddingTop) || 0)} ${boundingBox.width + (((_c = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _c === void 0 ? void 0 : _c.paddingRight) || 0)} ${boundingBox.height + (((_d = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _d === void 0 ? void 0 : _d.paddingBottom) || 0)}`
|
|
663
664
|
: "0 0 1000 1000";
|
|
664
|
-
const renderedElements = useMemo(() => renderElements(componentsEditor, mappingKey, tableMatchKey, graph.connecting, groupSelection), [
|
|
665
|
+
const renderedElements = useMemo(() => renderElements(componentsEditor, mappingKey, tableMatchKey, graph.connecting, groupSelection, graph.edges, connectionMatchKey), [
|
|
665
666
|
componentsEditor,
|
|
666
667
|
mappingKey,
|
|
667
668
|
tableMatchKey,
|
|
@@ -670,6 +671,8 @@ const LayerView = (props) => {
|
|
|
670
671
|
groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.selection,
|
|
671
672
|
groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey,
|
|
672
673
|
groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.colorGroupSelection,
|
|
674
|
+
graph.edges,
|
|
675
|
+
connectionMatchKey
|
|
673
676
|
]);
|
|
674
677
|
return (<div className="relative w-full h-full flex-1" ref={containerRef} style={{ overflow: "auto", WebkitOverflowScrolling: "touch" }} {...props.containerProps}>
|
|
675
678
|
{loading && (<div className="absolute z-10 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-opacity-50 bg-white w-full h-full flex items-center justify-center">
|
|
@@ -703,14 +706,14 @@ const LayerView = (props) => {
|
|
|
703
706
|
eventMatchTable={eventMatchTable} privilegedTags={privilegedTags} selectionLines={selectedLines}/>
|
|
704
707
|
</g>
|
|
705
708
|
|
|
706
|
-
<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}/>
|
|
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}/>
|
|
707
710
|
|
|
708
711
|
{renderedElements.map((item) => {
|
|
709
|
-
var _a, _b, _c, _d;
|
|
712
|
+
var _a, _b, _c, _d, _e;
|
|
710
713
|
const rotated = rotatePoint(item.width / 2, item.height / 2, (_a = item.rotation) !== null && _a !== void 0 ? _a : 0);
|
|
711
714
|
return (<ConnectHandle key={item.id}
|
|
712
715
|
// isAnchor={true}
|
|
713
|
-
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={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) => graph.startConnect(nodeId, clickPos)} onEndConnect={(nodeId, clickPos) => {
|
|
714
717
|
if (graph.draggingAnchor)
|
|
715
718
|
graph.updateAnchor(nodeId, clickPos);
|
|
716
719
|
else
|
|
@@ -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([]);
|
|
@@ -170,7 +171,7 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
|
|
|
170
171
|
}, [edges]);
|
|
171
172
|
// initialize edges
|
|
172
173
|
useEffect(() => {
|
|
173
|
-
if (initialEdges) {
|
|
174
|
+
if (!isEqual(initialEdges, edges) && components) {
|
|
174
175
|
//process initial edges
|
|
175
176
|
const allElements = components === null || components === void 0 ? void 0 : components.map((table) => {
|
|
176
177
|
if (mappingKey && (table === null || table === void 0 ? void 0 : table[mappingKey])) {
|
|
@@ -178,9 +179,6 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
|
|
|
178
179
|
}
|
|
179
180
|
return Object.assign({}, table);
|
|
180
181
|
});
|
|
181
|
-
// const findSourceTarget = allElements?.find(
|
|
182
|
-
// (el) => el.id === connecting.fromId
|
|
183
|
-
// );
|
|
184
182
|
const transformAllEdges = initialEdges === null || initialEdges === void 0 ? void 0 : initialEdges.map((edge) => {
|
|
185
183
|
const fromElement = allElements === null || allElements === void 0 ? void 0 : allElements.find((el) => el.id === edge.from);
|
|
186
184
|
if (!fromElement)
|
|
@@ -213,6 +211,7 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
|
|
|
213
211
|
const fromPos = {
|
|
214
212
|
x: fromCx + fromLx * Math.cos(rad) - fromLy * Math.sin(rad),
|
|
215
213
|
y: fromCy + fromLx * Math.sin(rad) + fromLy * Math.cos(rad),
|
|
214
|
+
name: edge.fromPos.name,
|
|
216
215
|
};
|
|
217
216
|
const toElement = allElements === null || allElements === void 0 ? void 0 : allElements.find((el) => el.id === edge.to);
|
|
218
217
|
if (!toElement)
|
|
@@ -245,12 +244,14 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
|
|
|
245
244
|
const toPos = {
|
|
246
245
|
x: toCx + toLx * Math.cos(rad2) - toLy * Math.sin(rad2),
|
|
247
246
|
y: toCy + toLx * Math.sin(rad2) + toLy * Math.cos(rad2),
|
|
247
|
+
name: edge.toPos.name,
|
|
248
248
|
};
|
|
249
249
|
return Object.assign(Object.assign({}, edge), { from: fromElement.id, to: toElement.id, fromPos,
|
|
250
250
|
toPos });
|
|
251
251
|
});
|
|
252
|
+
setEdges(transformAllEdges === null || transformAllEdges === void 0 ? void 0 : transformAllEdges.filter((el) => el !== null));
|
|
252
253
|
}
|
|
253
|
-
}, [initialEdges]);
|
|
254
|
+
}, [initialEdges, components]);
|
|
254
255
|
return {
|
|
255
256
|
edges,
|
|
256
257
|
setEdges,
|
|
@@ -21,6 +21,7 @@ export type EdgeType = {
|
|
|
21
21
|
x: number;
|
|
22
22
|
y: number;
|
|
23
23
|
}[];
|
|
24
|
+
status?: number;
|
|
24
25
|
};
|
|
25
26
|
export type NodeType = {
|
|
26
27
|
id: string;
|
|
@@ -61,4 +62,7 @@ export declare const renderElements: (elementEditor: ComponentProps[], mappingKe
|
|
|
61
62
|
colorGroupSelection: string[];
|
|
62
63
|
dataKey: string;
|
|
63
64
|
selection: Record<number, string[]>;
|
|
65
|
+
}, edges?: EdgeType[], connectionMatchKey?: {
|
|
66
|
+
key: string;
|
|
67
|
+
value: string | number;
|
|
64
68
|
}) => ComponentProps[];
|
|
@@ -71,7 +71,11 @@ const findIndexByValue = (obj, targetValue) => {
|
|
|
71
71
|
const foundEntry = Object.entries(obj).find(([_, values]) => values.includes(targetValue));
|
|
72
72
|
return foundEntry ? Number(foundEntry[0]) : undefined;
|
|
73
73
|
};
|
|
74
|
-
export const renderElements = (elementEditor, mappingKey, tableMatchKey, connecting, groupSelection) => {
|
|
74
|
+
export const renderElements = (elementEditor, mappingKey, tableMatchKey, connecting, groupSelection, edges, connectionMatchKey) => {
|
|
75
|
+
var _a;
|
|
76
|
+
const allIDFromIdConnection = ((_a = edges === null || edges === void 0 ? void 0 : edges.filter((edge) => edge.from === (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) || edge.to === (connecting === null || connecting === void 0 ? void 0 : connecting.fromId)
|
|
77
|
+
//bikin ed.to di merge dengan ed.from
|
|
78
|
+
)) === null || _a === void 0 ? void 0 : _a.map((edge) => edge.to === (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) ? edge.from : edge.to)) || [];
|
|
75
79
|
return elementEditor.map((editorItem) => {
|
|
76
80
|
var _a, _b;
|
|
77
81
|
const isUsingMapping = mappingKey &&
|
|
@@ -84,9 +88,10 @@ export const renderElements = (elementEditor, mappingKey, tableMatchKey, connect
|
|
|
84
88
|
if (hasKey)
|
|
85
89
|
return item.value == (editorItem === null || editorItem === void 0 ? void 0 : editorItem[item.key]);
|
|
86
90
|
});
|
|
87
|
-
// console.log({ finalProps })
|
|
88
91
|
const findIndexSelection = findIndexByValue(groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.selection, finalProps === null || finalProps === void 0 ? void 0 : finalProps[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]);
|
|
89
92
|
let fill = finalProps === null || finalProps === void 0 ? void 0 : finalProps.fill;
|
|
93
|
+
let stroke = finalProps === null || finalProps === void 0 ? void 0 : finalProps.stroke;
|
|
94
|
+
let seatFill = finalProps === null || finalProps === void 0 ? void 0 : finalProps.seatFill;
|
|
90
95
|
if (findIndexSelection !== undefined) {
|
|
91
96
|
fill = groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.colorGroupSelection[findIndexSelection];
|
|
92
97
|
}
|
|
@@ -94,13 +99,20 @@ export const renderElements = (elementEditor, mappingKey, tableMatchKey, connect
|
|
|
94
99
|
fill = (_b = tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.properties) === null || _b === void 0 ? void 0 : _b.fill;
|
|
95
100
|
}
|
|
96
101
|
if ((connecting === null || connecting === void 0 ? void 0 : connecting.fromId) == (finalProps === null || finalProps === void 0 ? void 0 : finalProps.id)) {
|
|
97
|
-
fill = "#
|
|
102
|
+
fill = "#F8F5FF";
|
|
103
|
+
stroke = "#5014D0";
|
|
104
|
+
}
|
|
105
|
+
if ((allIDFromIdConnection === null || allIDFromIdConnection === void 0 ? void 0 : allIDFromIdConnection.includes(finalProps === null || finalProps === void 0 ? void 0 : finalProps.id)) && (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) !== (finalProps === null || finalProps === void 0 ? void 0 : finalProps.id)) {
|
|
106
|
+
fill = "#EEF6FF";
|
|
107
|
+
stroke = "#3E97FF";
|
|
108
|
+
seatFill = "#3E97FF";
|
|
109
|
+
}
|
|
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
|
+
}
|
|
112
|
+
if (connectionMatchKey) {
|
|
113
|
+
if (!(finalProps === null || finalProps === void 0 ? void 0 : finalProps[connectionMatchKey.key])) {
|
|
114
|
+
finalProps = Object.assign(Object.assign({}, finalProps), { [connectionMatchKey.key]: editorItem === null || editorItem === void 0 ? void 0 : editorItem[connectionMatchKey.key] });
|
|
98
115
|
}
|
|
99
|
-
// fill =
|
|
100
|
-
// connecting?.fromId == finalProps?.id
|
|
101
|
-
// ? "#7239EA"
|
|
102
|
-
// : tableMatch?.properties?.fill ?? finalProps?.fill;
|
|
103
|
-
finalProps = Object.assign(Object.assign(Object.assign({}, finalProps), tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.properties), { fill: fill, className: tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.className, element: tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.element });
|
|
104
116
|
}
|
|
105
117
|
return finalProps;
|
|
106
118
|
});
|
package/package.json
CHANGED