seat-editor 3.6.7 → 3.6.8

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.
@@ -25,6 +25,13 @@ type Props = {
25
25
  from: string;
26
26
  to: string;
27
27
  }[];
28
+ connecting: {
29
+ fromId: string;
30
+ fromPos: {
31
+ x: number;
32
+ y: number;
33
+ };
34
+ } | null;
28
35
  };
29
36
  export declare const ConnectHandle: React.FC<Props>;
30
37
  export {};
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- // connect-handle.tsx
3
- import { useState } from "react";
2
+ import { useEffect, useState } from "react";
4
3
  // 4 titik per sisi dalam local space
5
4
  const getLocalAnchors = (w, h) => {
6
5
  const hw = w / 2;
@@ -24,7 +23,7 @@ const nearestAnchor = (lx, ly, anchors) => {
24
23
  }
25
24
  return best;
26
25
  };
27
- export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isConnecting, isDraggingAnchor, onStartConnect, onEndConnect, isConnectEdge, onSelectNode, isSelectNode, onSelectEdge, edges }) => {
26
+ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isConnecting, isDraggingAnchor, onStartConnect, onEndConnect, isConnectEdge, onSelectNode, isSelectNode, onSelectEdge, edges, connecting, }) => {
28
27
  const hw = width / 2;
29
28
  const hh = height / 2;
30
29
  const [hovered, setHovered] = useState(false);
@@ -53,15 +52,19 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
53
52
  y: cy + lx * Math.sin(rad) + ly * Math.cos(rad),
54
53
  };
55
54
  };
55
+ useEffect(() => {
56
+ if (!isActiveSelectEdge) {
57
+ onSelectEdge && onSelectEdge("");
58
+ onSelectEdge && onSelectNode("");
59
+ }
60
+ }, [isActiveSelectEdge]);
56
61
  const handlePointerDown = (e) => {
57
62
  e.stopPropagation();
58
63
  const local = toLocalPos(e);
59
64
  const snapped = nearestAnchor(local.x, local.y, anchors);
60
65
  const worldPos = toWorld(snapped.x, snapped.y);
61
- console.log({ isActiveSelectEdge });
62
66
  if (isActiveSelectEdge) {
63
- const findEdge = edges.find(e => e.from === nodeId || e.to === nodeId);
64
- console.log({ findEdge });
67
+ const findEdge = edges.find((e) => e.from === nodeId || e.to === nodeId);
65
68
  onSelectEdge(findEdge === null || findEdge === void 0 ? void 0 : findEdge.id);
66
69
  onSelectNode(nodeId);
67
70
  return;
@@ -78,7 +81,7 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
78
81
  cursor: isConnectEdge ? "crosshair" : "pointer",
79
82
  pointerEvents: isConnectEdge ? "all" : "none",
80
83
  }, onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), onPointerDown: (e) => {
81
- console.log({ isConnectEdge, isSelectNode });
84
+ // console.log({ isConnectEdge, isSelectNode });
82
85
  // console.log({ isConnectEdge, isSelectNode })
83
86
  // if (!isConnectEdge ) return;
84
87
  // if (!isSelectNode) return;
@@ -1,5 +1,4 @@
1
- // connect-handle.tsx
2
- import React, { useState } from "react";
1
+ import React, { useEffect, useState } from "react";
3
2
  // 4 titik per sisi dalam local space
4
3
  const getLocalAnchors = (w, h) => {
5
4
  const hw = w / 2;
@@ -23,7 +22,7 @@ const nearestAnchor = (lx, ly, anchors) => {
23
22
  }
24
23
  return best;
25
24
  };
26
- export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isConnecting, isDraggingAnchor, onStartConnect, onEndConnect, isConnectEdge, onSelectNode, isSelectNode, onSelectEdge, edges }) => {
25
+ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isConnecting, isDraggingAnchor, onStartConnect, onEndConnect, isConnectEdge, onSelectNode, isSelectNode, onSelectEdge, edges, connecting, }) => {
27
26
  const hw = width / 2;
28
27
  const hh = height / 2;
29
28
  const [hovered, setHovered] = useState(false);
@@ -52,15 +51,19 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
52
51
  y: cy + lx * Math.sin(rad) + ly * Math.cos(rad),
53
52
  };
54
53
  };
54
+ useEffect(() => {
55
+ if (!isActiveSelectEdge) {
56
+ onSelectEdge && onSelectEdge("");
57
+ onSelectEdge && onSelectNode("");
58
+ }
59
+ }, [isActiveSelectEdge]);
55
60
  const handlePointerDown = (e) => {
56
61
  e.stopPropagation();
57
62
  const local = toLocalPos(e);
58
63
  const snapped = nearestAnchor(local.x, local.y, anchors);
59
64
  const worldPos = toWorld(snapped.x, snapped.y);
60
- console.log({ isActiveSelectEdge });
61
65
  if (isActiveSelectEdge) {
62
- const findEdge = edges.find(e => e.from === nodeId || e.to === nodeId);
63
- console.log({ findEdge });
66
+ const findEdge = edges.find((e) => e.from === nodeId || e.to === nodeId);
64
67
  onSelectEdge(findEdge === null || findEdge === void 0 ? void 0 : findEdge.id);
65
68
  onSelectNode(nodeId);
66
69
  return;
@@ -82,7 +85,7 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
82
85
  cursor: isConnectEdge ? "crosshair" : "pointer",
83
86
  pointerEvents: isConnectEdge ? "all" : "none",
84
87
  }} onMouseEnter={() => setHovered(true)} onMouseLeave={() => setHovered(false)} onPointerDown={(e) => {
85
- console.log({ isConnectEdge, isSelectNode });
88
+ // console.log({ isConnectEdge, isSelectNode });
86
89
  // console.log({ isConnectEdge, isSelectNode })
87
90
  // if (!isConnectEdge ) return;
88
91
  // if (!isSelectNode) return;
@@ -92,5 +95,6 @@ export const ConnectHandle = ({ cx, cy, width, height, nodeId, rotation = 0, isC
92
95
  {/* Anchor dots — muncul saat hover atau active */}
93
96
  {((hovered && isConnectEdge) || isActive) &&
94
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" }}/>))}
98
+
95
99
  </g>);
96
100
  };
@@ -27,7 +27,6 @@ type Props = {
27
27
  onRemoveWaypoint: (e: React.MouseEvent, edgeId: string, index: number) => void;
28
28
  onStartDragAnchor: (e: React.MouseEvent, edgeId: string, side: "from" | "to") => void;
29
29
  isConnectEdge: boolean;
30
- isSelectNode: boolean;
31
30
  selectedNodeId: string | null;
32
31
  };
33
32
  export declare const ConnectionLayer: React.FC<Props>;
@@ -52,9 +52,9 @@ const quadraticMidpoint = (from, to) => {
52
52
  y: mt * mt * from.y + 2 * mt * t * cpy + t * t * to.y,
53
53
  };
54
54
  };
55
- export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAnchor, mousePos, isConnectEdge, isSelectNode, getNodeById, onSelectEdge, onDeleteEdge, onStartDragWaypoint, onInsertWaypoint, onRemoveWaypoint, onStartDragAnchor, selectedNodeId, }) => {
55
+ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAnchor, mousePos, isConnectEdge, getNodeById, onSelectEdge, onDeleteEdge, onStartDragWaypoint, onInsertWaypoint, onRemoveWaypoint, onStartDragAnchor, selectedNodeId, }) => {
56
56
  const [hoveredEdge, setHoveredEdge] = useState(null);
57
- console.log({ selectedEdge });
57
+ // console.log({ selectedEdge})
58
58
  const nodeHighlightMap = useMemo(() => {
59
59
  if (!selectedEdge)
60
60
  return new Map();
@@ -138,12 +138,13 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
138
138
  const fromLevel = nodeHighlightMap.get(edge.from);
139
139
  const toLevel = nodeHighlightMap.get(edge.to);
140
140
  const isInNetwork = fromLevel !== undefined && toLevel !== undefined;
141
- console.log({ isInNetwork, fromLevel, toLevel }, selectedEdge, !isSel && !isInNetwork);
142
141
  const networkColor = isInNetwork
143
142
  ? getLevelColor(Math.max(fromLevel, toLevel))
144
143
  : "#38bdf8";
145
144
  const isDraggingFrom = (draggingAnchor === null || draggingAnchor === void 0 ? void 0 : draggingAnchor.edgeId) === edge.id && draggingAnchor.side === "from";
146
145
  const isDraggingTo = (draggingAnchor === null || draggingAnchor === void 0 ? void 0 : draggingAnchor.edgeId) === edge.id && draggingAnchor.side === "to";
146
+ // const currentConnection =
147
+ const isNotRing1 = connecting && ((connecting === null || connecting === void 0 ? void 0 : connecting.fromId) !== edge.from && (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) !== edge.to);
147
148
  return (_jsxs("g", { children: [_jsx("path", { d: pathD, stroke: "transparent", strokeWidth: 14, fill: "none", style: { cursor: "pointer" }, onClick: (e) => {
148
149
  e.stopPropagation();
149
150
  onSelectEdge(edge.id);
@@ -151,7 +152,7 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
151
152
  ? "#a78bfa"
152
153
  : isInNetwork && selectedEdge
153
154
  ? networkColor
154
- : "#38bdf8", strokeWidth: isSel ? 2 : isHov ? 2 : 1.5, fill: "none", opacity: selectedEdge && !isSel && !isInNetwork ? 0.25 : 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) => {
155
+ : "#38bdf8", strokeWidth: isSel ? 2 : isHov ? 2 : 1.5, fill: "none", opacity: (selectedEdge && !isSel && !isInNetwork) || isNotRing1 ? 0.2 : 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) => {
155
156
  e.stopPropagation();
156
157
  onStartDragAnchor(e, edge.id, "from");
157
158
  } }), _jsx("circle", { cx: fromPos.x, cy: fromPos.y, r: 6, fill: isDraggingFrom ? "#a78bfa" : "#38bdf8", stroke: "#0f172a", strokeWidth: 1.5, style: { pointerEvents: "none" } }), _jsx("circle", { cx: fromPos.x, cy: fromPos.y, r: 2.5, fill: "#0f172a", style: { pointerEvents: "none" } })] })), isSel && (_jsxs("g", { children: [isDraggingTo && (_jsx("circle", { cx: toPos.x, cy: toPos.y, r: 12, fill: "#22c55e", opacity: 0.15, style: { pointerEvents: "none" } })), _jsx("circle", { cx: toPos.x, cy: toPos.y, r: 10, fill: "transparent", style: { cursor: "grab" }, onMouseDown: (e) => {
@@ -175,8 +176,9 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
175
176
  }, 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));
176
177
  }), connecting &&
177
178
  (() => {
179
+ var _a, _b;
178
180
  const pts = computePoints(connecting.fromPos, mousePos, []);
179
181
  const pathD = buildPath(pts);
180
- return (_jsxs("g", { children: [_jsx("circle", { cx: connecting.fromPos.x, cy: connecting.fromPos.y, r: 4, fill: "#a78bfa", stroke: "#0f172a", strokeWidth: 0.8, opacity: 0.9, style: { pointerEvents: "none" } }), _jsx("path", { d: pathD, stroke: "#a78bfa", strokeWidth: 1.5, fill: "none", strokeDasharray: "6 3", strokeLinecap: "round", opacity: 0.8, style: { pointerEvents: "none" } })] }));
182
+ return (_jsxs("g", { children: [_jsx("circle", { cx: (_a = connecting === null || connecting === void 0 ? void 0 : connecting.fromPos) === null || _a === void 0 ? void 0 : _a.x, cy: (_b = connecting === null || connecting === void 0 ? void 0 : connecting.fromPos) === null || _b === void 0 ? void 0 : _b.y, r: 4, fill: "#a78bfa", stroke: "#0f172a", strokeWidth: 0.8, opacity: 0.9, style: { pointerEvents: "none" } }), _jsx("path", { d: pathD, stroke: "#a78bfa", strokeWidth: 1.5, fill: "none", strokeDasharray: "6 3", strokeLinecap: "round", opacity: 0.8, style: { pointerEvents: "none" } })] }));
181
183
  })(), draggingAnchor && (_jsx("text", { x: mousePos.x + 14, y: mousePos.y - 8, fill: "#a78bfa", fontSize: 9, fontFamily: "monospace", opacity: 0.8, style: { pointerEvents: "none", userSelect: "none" }, children: "klik node tujuan" }))] }));
182
184
  };
@@ -51,9 +51,9 @@ const quadraticMidpoint = (from, to) => {
51
51
  y: mt * mt * from.y + 2 * mt * t * cpy + t * t * to.y,
52
52
  };
53
53
  };
54
- export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAnchor, mousePos, isConnectEdge, isSelectNode, getNodeById, onSelectEdge, onDeleteEdge, onStartDragWaypoint, onInsertWaypoint, onRemoveWaypoint, onStartDragAnchor, selectedNodeId, }) => {
54
+ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAnchor, mousePos, isConnectEdge, getNodeById, onSelectEdge, onDeleteEdge, onStartDragWaypoint, onInsertWaypoint, onRemoveWaypoint, onStartDragAnchor, selectedNodeId, }) => {
55
55
  const [hoveredEdge, setHoveredEdge] = useState(null);
56
- console.log({ selectedEdge });
56
+ // console.log({ selectedEdge})
57
57
  const nodeHighlightMap = useMemo(() => {
58
58
  if (!selectedEdge)
59
59
  return new Map();
@@ -162,12 +162,13 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
162
162
  const fromLevel = nodeHighlightMap.get(edge.from);
163
163
  const toLevel = nodeHighlightMap.get(edge.to);
164
164
  const isInNetwork = fromLevel !== undefined && toLevel !== undefined;
165
- console.log({ isInNetwork, fromLevel, toLevel }, selectedEdge, !isSel && !isInNetwork);
166
165
  const networkColor = isInNetwork
167
166
  ? getLevelColor(Math.max(fromLevel, toLevel))
168
167
  : "#38bdf8";
169
168
  const isDraggingFrom = (draggingAnchor === null || draggingAnchor === void 0 ? void 0 : draggingAnchor.edgeId) === edge.id && draggingAnchor.side === "from";
170
169
  const isDraggingTo = (draggingAnchor === null || draggingAnchor === void 0 ? void 0 : draggingAnchor.edgeId) === edge.id && draggingAnchor.side === "to";
170
+ // const currentConnection =
171
+ const isNotRing1 = connecting && ((connecting === null || connecting === void 0 ? void 0 : connecting.fromId) !== edge.from && (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) !== edge.to);
171
172
  return (<g key={edge.id}>
172
173
  {/* Hit area */}
173
174
  <path d={pathD} stroke="transparent" strokeWidth={14} fill="none" style={{ cursor: "pointer" }} onClick={(e) => {
@@ -183,7 +184,7 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
183
184
  ? "#a78bfa"
184
185
  : isInNetwork && selectedEdge
185
186
  ? networkColor
186
- : "#38bdf8"} strokeWidth={isSel ? 2 : isHov ? 2 : 1.5} fill="none" opacity={selectedEdge && !isSel && !isInNetwork ? 0.25 : 0.9} strokeLinecap="round" style={{ pointerEvents: "none" }}/>
187
+ : "#38bdf8"} strokeWidth={isSel ? 2 : isHov ? 2 : 1.5} fill="none" opacity={(selectedEdge && !isSel && !isInNetwork) || isNotRing1 ? 0.2 : 0.9} strokeLinecap="round" style={{ pointerEvents: "none" }}/>
187
188
 
188
189
  {/* FROM dot */}
189
190
  {isSel && (<g>
@@ -249,10 +250,11 @@ export const ConnectionLayer = ({ edges, selectedEdge, connecting, draggingAncho
249
250
  {/* Preview saat connecting */}
250
251
  {connecting &&
251
252
  (() => {
253
+ var _a, _b;
252
254
  const pts = computePoints(connecting.fromPos, mousePos, []);
253
255
  const pathD = buildPath(pts);
254
256
  return (<g>
255
- <circle cx={connecting.fromPos.x} cy={connecting.fromPos.y} r={4} fill="#a78bfa" stroke="#0f172a" strokeWidth={0.8} opacity={0.9} style={{ pointerEvents: "none" }}/>
257
+ <circle cx={(_a = connecting === null || connecting === void 0 ? void 0 : connecting.fromPos) === null || _a === void 0 ? void 0 : _a.x} cy={(_b = connecting === null || connecting === void 0 ? void 0 : connecting.fromPos) === null || _b === void 0 ? void 0 : _b.y} r={4} fill="#a78bfa" stroke="#0f172a" strokeWidth={0.8} opacity={0.9} style={{ pointerEvents: "none" }}/>
256
258
  <path d={pathD} stroke="#a78bfa" strokeWidth={1.5} fill="none" strokeDasharray="6 3" strokeLinecap="round" opacity={0.8} style={{ pointerEvents: "none" }}/>
257
259
  </g>);
258
260
  })()}
@@ -8,9 +8,14 @@ export type TableGhost = {
8
8
  event: EventHandleType;
9
9
  };
10
10
  export type TableMatchKey = {
11
- key: string | number;
11
+ value: string | number;
12
+ key: string;
12
13
  properties?: PropertiesProps;
13
14
  className?: string;
15
+ element?: {
16
+ icon: React.JSX.Element;
17
+ props: SVGAttributes<SVGElement>;
18
+ };
14
19
  };
15
20
  export type TableMatchEvent = {
16
21
  event: EventHandleType;
@@ -86,17 +91,21 @@ export interface LayerViewProps<TMeta = undefined> {
86
91
  viewOnly?: boolean;
87
92
  actionPrivileged?: {
88
93
  select?: boolean;
89
- move?: boolean;
90
- switch?: boolean;
91
- drop?: boolean;
92
94
  rightClick?: boolean;
93
95
  double?: boolean;
96
+ selection?: boolean;
97
+ grapConnection?: boolean;
98
+ viewGraph?: boolean;
99
+ dragTable?: boolean;
100
+ selectNode?: boolean;
101
+ connectingNode?: boolean;
94
102
  };
95
103
  onEdgesChange?: (edges: EdgeType[], table: PropertiesProps[]) => void;
96
104
  keyNode?: string;
97
105
  isConnectEdge?: boolean;
98
106
  isSelectNode?: boolean;
99
107
  onMakeSelection?: (component: ComponentProps<TMeta>[]) => void;
108
+ onDragTable?: (e: React.PointerEvent<SVGSVGElement>, component: ComponentProps<TMeta>) => void;
100
109
  }
101
110
  declare const LayerView: <TMeta>(props: LayerViewProps<TMeta>) => import("react/jsx-runtime").JSX.Element;
102
111
  export default LayerView;