seat-editor 3.6.26 → 3.6.28

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.
@@ -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 { COLORS_SECTION, data } from "./constant";
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({
@@ -17,7 +16,7 @@ export default function GraphView() {
17
16
  double: false,
18
17
  selection: false,
19
18
  selectNode: false,
20
- connectingNode: false,
19
+ connectingNode: true,
21
20
  dragTransferTable: false
22
21
  });
23
22
  const [isSelectNode, setIsSelectNode] = useState(false);
@@ -36,10 +35,13 @@ export default function GraphView() {
36
35
  },
37
36
  ]);
38
37
  const [sectionActive, setSectionActive] = useState(null);
39
- const componentSection = useMemo(() => data === null || data === void 0 ? void 0 : data.map((data) => {
38
+ const componentSection = useMemo(() => {
40
39
  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
- }), [data, sections]);
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));
@@ -145,31 +147,38 @@ export default function GraphView() {
145
147
  };
146
148
  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
149
  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: (table, edges) => console.log({ edges, table }), isConnectEdge: isConnecting, isSelectNode: isSelectNode,
150
+ }, children: item.name }, item.key))) }), _jsx(LayerView, { componentProps: componentSection, statusKey: "section", defaultBackground: "#1e2d4a", mappingKey: "properties", keyNode: "nodes", onEdgesChange: (table, edges) => console.log({ edges, table }), isConnectEdge: isConnecting, isSelectNode: isSelectNode, connectionMatchKey: {
151
+ key: "use_connection",
152
+ value: 1
153
+ },
149
154
  // extraComponentProps={background}
150
155
  onSelectComponent: handleSelectItem,
151
156
  // actionPrivileged={{
152
157
  // select: true,
153
158
  // }}
154
- onMakeSelection: onMakeSelection, tableMatchKey: [
155
- {
156
- key: "capacity",
157
- value: 5,
158
- properties: {
159
- fill: "#000000",
160
- },
161
- // element: {
162
- // icon: undefined,
163
- // props: {},
164
- // },
165
- },
166
- ], onDragTable: (_, data) => setDataDrag(data), actionPrivileged: actionPrivileged, groupSelection: {
167
- colorGroupSelection: COLORS_SECTION,
168
- dataKey: "uuid_table",
169
- selection: selection
170
- }, onRightClick: (e, data) => {
159
+ onMakeSelection: onMakeSelection,
160
+ // tableMatchKey={[
161
+ // // {
162
+ // // key: "capacity",
163
+ // // value: 5,
164
+ // // properties: {
165
+ // // fill: "#000000",
166
+ // // },
167
+ // // element: {
168
+ // // icon: undefined,
169
+ // // props: {},
170
+ // // },
171
+ // },
172
+ // ]}
173
+ onDragTable: (_, data) => setDataDrag(data), actionPrivileged: actionPrivileged,
174
+ // groupSelection={{
175
+ // colorGroupSelection: COLORS_SECTION,
176
+ // dataKey: "uuid_table",
177
+ // selection: selection
178
+ // }}
179
+ onRightClick: (e, data) => {
171
180
  console.log({ e, data });
172
181
  }, allowTooltip: true, onHoldTable: (e, data) => {
173
182
  console.log({ e, data });
174
- } }), _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" }) }) })] }) }));
183
+ }, 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" }) }) })] }) }));
175
184
  }
@@ -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 { COLORS_SECTION, data } from "./constant";
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({
@@ -16,7 +15,7 @@ export default function GraphView() {
16
15
  double: false,
17
16
  selection: false,
18
17
  selectNode: false,
19
- connectingNode: false,
18
+ connectingNode: true,
20
19
  dragTransferTable: false
21
20
  });
22
21
  const [isSelectNode, setIsSelectNode] = useState(false);
@@ -35,10 +34,13 @@ export default function GraphView() {
35
34
  },
36
35
  ]);
37
36
  const [sectionActive, setSectionActive] = useState(null);
38
- const componentSection = useMemo(() => data === null || data === void 0 ? void 0 : data.map((data) => {
37
+ const componentSection = useMemo(() => {
39
38
  var _a;
40
- return (Object.assign(Object.assign({}, data), { section: (_a = sections.find((section) => section.items.some((item) => item.uuid_table === data.uuid_table))) === null || _a === void 0 ? void 0 : _a.id }));
41
- }), [data, sections]);
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));
@@ -151,33 +153,40 @@ export default function GraphView() {
151
153
  {item.name}
152
154
  </Button>))}
153
155
  </div>
154
- <LayerView componentProps={componentSection} statusKey="section" defaultBackground="#1e2d4a" mappingKey="properties" keyNode="nodes" onEdgesChange={(table, edges) => console.log({ edges, table })} isConnectEdge={isConnecting} isSelectNode={isSelectNode}
156
+ <LayerView componentProps={componentSection} statusKey="section" defaultBackground="#1e2d4a" mappingKey="properties" keyNode="nodes" onEdgesChange={(table, edges) => console.log({ edges, table })} isConnectEdge={isConnecting} isSelectNode={isSelectNode} connectionMatchKey={{
157
+ key: "use_connection",
158
+ value: 1
159
+ }}
155
160
  // extraComponentProps={background}
156
161
  onSelectComponent={handleSelectItem}
157
162
  // actionPrivileged={{
158
163
  // select: true,
159
164
  // }}
160
- onMakeSelection={onMakeSelection} tableMatchKey={[
161
- {
162
- key: "capacity",
163
- value: 5,
164
- properties: {
165
- fill: "#000000",
166
- },
167
- // element: {
168
- // icon: undefined,
169
- // props: {},
170
- // },
171
- },
172
- ]} onDragTable={(_, data) => setDataDrag(data)} actionPrivileged={actionPrivileged} groupSelection={{
173
- colorGroupSelection: COLORS_SECTION,
174
- dataKey: "uuid_table",
175
- selection: selection
176
- }} onRightClick={(e, data) => {
165
+ onMakeSelection={onMakeSelection}
166
+ // tableMatchKey={[
167
+ // // {
168
+ // // key: "capacity",
169
+ // // value: 5,
170
+ // // properties: {
171
+ // // fill: "#000000",
172
+ // // },
173
+ // // element: {
174
+ // // icon: undefined,
175
+ // // props: {},
176
+ // // },
177
+ // },
178
+ // ]}
179
+ onDragTable={(_, data) => setDataDrag(data)} actionPrivileged={actionPrivileged}
180
+ // groupSelection={{
181
+ // colorGroupSelection: COLORS_SECTION,
182
+ // dataKey: "uuid_table",
183
+ // selection: selection
184
+ // }}
185
+ onRightClick={(e, data) => {
177
186
  console.log({ e, data });
178
187
  }} allowTooltip={true} onHoldTable={(e, data) => {
179
188
  console.log({ e, data });
180
- }}/>
189
+ }} showConnection={true}/>
181
190
  <div className="w-1/5 p-4" onMouseMove={handleMouseMove} onMouseLeave={handleMouseLeave}>
182
191
  <div id="table"/>
183
192
  <div className="rounded-lg bg-white p-4">
@@ -11,10 +11,12 @@ type Props = {
11
11
  onStartConnect: (nodeId: string, clickPos: {
12
12
  x: number;
13
13
  y: number;
14
+ name: string;
14
15
  }) => void;
15
16
  onEndConnect: (nodeId: string, clickPos: {
16
17
  x: number;
17
18
  y: number;
19
+ name: string;
18
20
  }) => void;
19
21
  isConnectEdge?: boolean;
20
22
  onSelectNode: (nodeId: string) => void;
@@ -30,8 +32,24 @@ type Props = {
30
32
  fromPos: {
31
33
  x: number;
32
34
  y: number;
35
+ name: string;
33
36
  };
34
37
  } | null;
38
+ showConnection?: boolean;
39
+ };
40
+ export declare const getLocalAnchors: (w: number, h: number) => {
41
+ x: number;
42
+ y: number;
43
+ name: string;
44
+ }[];
45
+ export declare const nearestAnchor: (lx: number, ly: number, anchors: {
46
+ x: number;
47
+ y: number;
48
+ name: string;
49
+ }[]) => {
50
+ x: number;
51
+ y: number;
52
+ name: string;
35
53
  };
36
54
  export declare const ConnectHandle: React.FC<Props>;
37
55
  export {};
@@ -1,17 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
3
  // 4 titik per sisi dalam local space
4
- const getLocalAnchors = (w, h) => {
4
+ export const getLocalAnchors = (w, h) => {
5
5
  const hw = w / 2;
6
6
  const hh = h / 2;
7
7
  return [
8
- { x: 0, y: -hh }, // top center
9
- { x: hw, y: 0 }, // right center
10
- { x: 0, y: hh }, // bottom center
11
- { x: -hw, y: 0 }, // left center
8
+ { x: 0, y: -hh, name: "top" }, // index 0
9
+ { x: hw, y: 0, name: "right" }, // index 1
10
+ { x: 0, y: hh, name: "bottom" }, // index 2
11
+ { x: -hw, y: 0, name: "left" }, // index 3
12
12
  ];
13
13
  };
14
- const nearestAnchor = (lx, ly, anchors) => {
14
+ export const nearestAnchor = (lx, ly, anchors) => {
15
15
  let best = anchors[0];
16
16
  let bestD = Infinity;
17
17
  for (const a of anchors) {
@@ -21,9 +21,9 @@ const nearestAnchor = (lx, ly, anchors) => {
21
21
  best = a;
22
22
  }
23
23
  }
24
- return best;
24
+ return best; // Sekarang mengembalikan objek lengkap termasuk property 'name'
25
25
  };
26
- export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isConnecting, isDraggingAnchor, onStartConnect, onEndConnect, isConnectEdge, onSelectNode, isSelectNode, onSelectEdge, edges, connecting, }) => {
26
+ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isConnecting, isDraggingAnchor, onStartConnect, onEndConnect, isConnectEdge, onSelectNode, isSelectNode, onSelectEdge, edges, connecting, showConnection }) => {
27
27
  const hw = width / 2;
28
28
  const hh = height / 2;
29
29
  const [hovered, setHovered] = useState(false);
@@ -45,24 +45,24 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
45
45
  y: dx * Math.sin(rad) + dy * Math.cos(rad),
46
46
  };
47
47
  };
48
- const toWorld = (lx, ly) => {
48
+ const toWorld = (lx, ly, name) => {
49
49
  const rad = (rotation * Math.PI) / 180;
50
50
  return {
51
51
  x: cx + lx * Math.cos(rad) - ly * Math.sin(rad),
52
52
  y: cy + lx * Math.sin(rad) + ly * Math.cos(rad),
53
+ name,
53
54
  };
54
55
  };
55
56
  useEffect(() => {
56
57
  if (!isActiveSelectEdge) {
57
58
  onSelectEdge && onSelectEdge("");
58
- onSelectEdge && onSelectNode("");
59
59
  }
60
60
  }, [isActiveSelectEdge]);
61
61
  const handlePointerDown = (e) => {
62
62
  e.stopPropagation();
63
63
  const local = toLocalPos(e);
64
64
  const snapped = nearestAnchor(local.x, local.y, anchors);
65
- const worldPos = toWorld(snapped.x, snapped.y);
65
+ const worldPos = toWorld(snapped.x, snapped.y, snapped.name);
66
66
  if (isActiveSelectEdge) {
67
67
  const findEdge = edges.find((e) => e.from === nodeId || e.to === nodeId);
68
68
  onSelectEdge(findEdge === null || findEdge === void 0 ? void 0 : findEdge.id);
@@ -77,15 +77,13 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
77
77
  onStartConnect(nodeId, worldPos);
78
78
  }
79
79
  };
80
- 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 ? "#a78bfa" : hovered ? "#38bdf8" : "transparent", strokeWidth: isActive ? 2 : 1.5, strokeDasharray: isActive ? "4 2" : "none", rx: 4, style: { pointerEvents: "none" } }), _jsx("rect", { x: -hw - 4, y: -hh - 4, width: width + 8, height: height + 8, fill: "transparent", style: {
80
+ if (!showConnection)
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 && (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: {
81
83
  cursor: isConnectEdge ? "crosshair" : "pointer",
82
84
  pointerEvents: isConnectEdge ? "all" : "none",
83
85
  }, onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), onPointerDown: (e) => {
84
- // console.log({ isConnectEdge, isSelectNode });
85
- // console.log({ isConnectEdge, isSelectNode })
86
- // if (!isConnectEdge ) return;
87
- // if (!isSelectNode) return;
88
86
  handlePointerDown(e);
89
87
  } }), ((hovered && isConnectEdge) || isActive) &&
90
- anchors.map((a, i) => (_jsx("circle", { cx: a.x, cy: a.y, r: 3, fill: isActive ? "#a78bfa" : "#38bdf8", opacity: 0.5, style: { pointerEvents: "none" } }, i)))] }));
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)))] }));
91
89
  };
@@ -1,16 +1,16 @@
1
1
  import React, { useEffect, useState } from "react";
2
2
  // 4 titik per sisi dalam local space
3
- const getLocalAnchors = (w, h) => {
3
+ export const getLocalAnchors = (w, h) => {
4
4
  const hw = w / 2;
5
5
  const hh = h / 2;
6
6
  return [
7
- { x: 0, y: -hh }, // top center
8
- { x: hw, y: 0 }, // right center
9
- { x: 0, y: hh }, // bottom center
10
- { x: -hw, y: 0 }, // left center
7
+ { x: 0, y: -hh, name: "top" }, // index 0
8
+ { x: hw, y: 0, name: "right" }, // index 1
9
+ { x: 0, y: hh, name: "bottom" }, // index 2
10
+ { x: -hw, y: 0, name: "left" }, // index 3
11
11
  ];
12
12
  };
13
- const nearestAnchor = (lx, ly, anchors) => {
13
+ export const nearestAnchor = (lx, ly, anchors) => {
14
14
  let best = anchors[0];
15
15
  let bestD = Infinity;
16
16
  for (const a of anchors) {
@@ -20,9 +20,9 @@ const nearestAnchor = (lx, ly, anchors) => {
20
20
  best = a;
21
21
  }
22
22
  }
23
- return best;
23
+ return best; // Sekarang mengembalikan objek lengkap termasuk property 'name'
24
24
  };
25
- export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isConnecting, isDraggingAnchor, onStartConnect, onEndConnect, isConnectEdge, onSelectNode, isSelectNode, onSelectEdge, edges, connecting, }) => {
25
+ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isConnecting, isDraggingAnchor, onStartConnect, onEndConnect, isConnectEdge, onSelectNode, isSelectNode, onSelectEdge, edges, connecting, showConnection }) => {
26
26
  const hw = width / 2;
27
27
  const hh = height / 2;
28
28
  const [hovered, setHovered] = useState(false);
@@ -44,24 +44,24 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
44
44
  y: dx * Math.sin(rad) + dy * Math.cos(rad),
45
45
  };
46
46
  };
47
- const toWorld = (lx, ly) => {
47
+ const toWorld = (lx, ly, name) => {
48
48
  const rad = (rotation * Math.PI) / 180;
49
49
  return {
50
50
  x: cx + lx * Math.cos(rad) - ly * Math.sin(rad),
51
51
  y: cy + lx * Math.sin(rad) + ly * Math.cos(rad),
52
+ name,
52
53
  };
53
54
  };
54
55
  useEffect(() => {
55
56
  if (!isActiveSelectEdge) {
56
57
  onSelectEdge && onSelectEdge("");
57
- onSelectEdge && onSelectNode("");
58
58
  }
59
59
  }, [isActiveSelectEdge]);
60
60
  const handlePointerDown = (e) => {
61
61
  e.stopPropagation();
62
62
  const local = toLocalPos(e);
63
63
  const snapped = nearestAnchor(local.x, local.y, anchors);
64
- const worldPos = toWorld(snapped.x, snapped.y);
64
+ const worldPos = toWorld(snapped.x, snapped.y, snapped.name);
65
65
  if (isActiveSelectEdge) {
66
66
  const findEdge = edges.find((e) => e.from === nodeId || e.to === nodeId);
67
67
  onSelectEdge(findEdge === null || findEdge === void 0 ? void 0 : findEdge.id);
@@ -76,25 +76,23 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
76
76
  onStartConnect(nodeId, worldPos);
77
77
  }
78
78
  };
79
+ if (!showConnection)
80
+ return null;
79
81
  return (<g transform={`translate(${cx}, ${cy}) rotate(${rotation})`}>
80
82
  {/* Border visual */}
81
- <rect x={-hw - 4} y={-hh - 4} width={width + 8} height={height + 8} fill="transparent" stroke={isActive ? "#a78bfa" : hovered ? "#38bdf8" : "transparent"} strokeWidth={isActive ? 2 : 1.5} strokeDasharray={isActive ? "4 2" : "none"} rx={4} style={{ pointerEvents: "none" }}/>
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" }}/>
82
84
 
83
85
  {/* Hit area */}
84
86
  <rect x={-hw - 4} y={-hh - 4} width={width + 8} height={height + 8} fill="transparent" style={{
85
87
  cursor: isConnectEdge ? "crosshair" : "pointer",
86
88
  pointerEvents: isConnectEdge ? "all" : "none",
87
89
  }} onMouseEnter={() => setHovered(true)} onMouseLeave={() => setHovered(false)} onPointerDown={(e) => {
88
- // console.log({ isConnectEdge, isSelectNode });
89
- // console.log({ isConnectEdge, isSelectNode })
90
- // if (!isConnectEdge ) return;
91
- // if (!isSelectNode) return;
92
90
  handlePointerDown(e);
93
91
  }}/>
94
92
 
95
93
  {/* Anchor dots — muncul saat hover atau active */}
96
94
  {((hovered && isConnectEdge) || isActive) &&
97
- anchors.map((a, i) => (<circle key={i} cx={a.x} cy={a.y} r={3} fill={isActive ? "#a78bfa" : "#38bdf8"} opacity={0.5} style={{ pointerEvents: "none" }}/>))}
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" }}/>))}
98
96
 
99
97
  </g>);
100
98
  };
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { EdgeType, NodeType } from "./utils";
3
+ import { ComponentProps } from "../view-only-3";
3
4
  export type DraggingAnchor = {
4
5
  edgeId: string;
5
6
  side: "from" | "to";
@@ -12,6 +13,7 @@ type Props = {
12
13
  fromPos: {
13
14
  x: number;
14
15
  y: number;
16
+ name: string;
15
17
  };
16
18
  } | null;
17
19
  draggingAnchor: DraggingAnchor | null;
@@ -28,6 +30,17 @@ type Props = {
28
30
  onStartDragAnchor: (e: React.MouseEvent, edgeId: string, side: "from" | "to") => void;
29
31
  isConnectEdge: boolean;
30
32
  selectedNodeId: string | null;
33
+ showConnection?: boolean;
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
+ };
31
44
  };
32
45
  export declare const ConnectionLayer: React.FC<Props>;
33
46
  export {};