@infinit-canvas/react 0.1.3 → 0.1.4
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/react-infinite-canvas.cjs +2 -2
- package/dist/react-infinite-canvas.js +790 -788
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as S, jsxs as
|
|
2
|
-
import { useRef as
|
|
1
|
+
import { jsx as S, jsxs as $t, Fragment as Le } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as tt, useState as Gt, useMemo as St, useEffect as ht, useCallback as F, useContext as qe, createContext as Fn, memo as Zt, useLayoutEffect as kr } from "react";
|
|
3
3
|
import { createPortal as Yn } from "react-dom";
|
|
4
4
|
const Un = 160, qn = 60;
|
|
5
5
|
function ho(t) {
|
|
@@ -63,8 +63,8 @@ function jn(t) {
|
|
|
63
63
|
function xo(t, e, n = { x: 0, y: 0, zoom: 1 }, r = !1) {
|
|
64
64
|
const s = e.x, o = e.y, i = e.x + e.width, c = e.y + e.height;
|
|
65
65
|
return t.filter((u) => {
|
|
66
|
-
const { width: l, height: y } = jn(u), m = u.position.x, C = u.position.y,
|
|
67
|
-
return r ? m < i &&
|
|
66
|
+
const { width: l, height: y } = jn(u), m = u.position.x, C = u.position.y, z = m + l, M = C + y;
|
|
67
|
+
return r ? m < i && z > s && C < c && M > o : m >= s && z <= i && C >= o && M <= c;
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
function mo(t) {
|
|
@@ -964,42 +964,42 @@ function Lr({
|
|
|
964
964
|
onNodeDrag: y,
|
|
965
965
|
onNodeDragStop: m,
|
|
966
966
|
onEdgeClick: C,
|
|
967
|
-
onEdgeDoubleClick:
|
|
967
|
+
onEdgeDoubleClick: z,
|
|
968
968
|
onEdgeMouseEnter: M,
|
|
969
969
|
onEdgeMouseMove: $,
|
|
970
|
-
onEdgeMouseLeave:
|
|
970
|
+
onEdgeMouseLeave: k,
|
|
971
971
|
onEdgeContextMenu: E,
|
|
972
|
-
onNodeDoubleClick:
|
|
973
|
-
onNodeMouseEnter:
|
|
972
|
+
onNodeDoubleClick: _,
|
|
973
|
+
onNodeMouseEnter: D,
|
|
974
974
|
onNodeMouseMove: g,
|
|
975
975
|
onNodeMouseLeave: f,
|
|
976
976
|
onNodeContextMenu: p,
|
|
977
977
|
onPaneClick: v,
|
|
978
|
-
onPaneContextMenu:
|
|
979
|
-
onPaneMouseEnter:
|
|
978
|
+
onPaneContextMenu: N,
|
|
979
|
+
onPaneMouseEnter: w,
|
|
980
980
|
onPaneMouseMove: P,
|
|
981
981
|
onPaneMouseLeave: R,
|
|
982
982
|
onSelectionChange: B,
|
|
983
983
|
onConnectStart: q,
|
|
984
|
-
onConnectEnd:
|
|
985
|
-
onInit:
|
|
986
|
-
onMoveStart:
|
|
987
|
-
onMove:
|
|
984
|
+
onConnectEnd: X,
|
|
985
|
+
onInit: K,
|
|
986
|
+
onMoveStart: at,
|
|
987
|
+
onMove: rt,
|
|
988
988
|
onMoveEnd: G,
|
|
989
989
|
onDelete: j,
|
|
990
|
-
onBeforeDelete:
|
|
991
|
-
onError:
|
|
992
|
-
isValidConnection:
|
|
993
|
-
dark:
|
|
994
|
-
gridSize:
|
|
995
|
-
zoomMin:
|
|
996
|
-
zoomMax:
|
|
997
|
-
initialCamera:
|
|
998
|
-
fitView:
|
|
999
|
-
fitViewOptions:
|
|
1000
|
-
nodesDraggable:
|
|
1001
|
-
nodesConnectable:
|
|
1002
|
-
elementsSelectable:
|
|
990
|
+
onBeforeDelete: it,
|
|
991
|
+
onError: dt,
|
|
992
|
+
isValidConnection: ot,
|
|
993
|
+
dark: ft,
|
|
994
|
+
gridSize: It = 40,
|
|
995
|
+
zoomMin: st = 0.1,
|
|
996
|
+
zoomMax: xt = 4,
|
|
997
|
+
initialCamera: Nt = { x: 0, y: 0, zoom: 1 },
|
|
998
|
+
fitView: gt = !1,
|
|
999
|
+
fitViewOptions: ct,
|
|
1000
|
+
nodesDraggable: zt = !0,
|
|
1001
|
+
nodesConnectable: Rt = !0,
|
|
1002
|
+
elementsSelectable: Lt = !0,
|
|
1003
1003
|
multiSelectionKeyCode: wt = "Shift",
|
|
1004
1004
|
selectionOnDrag: ne = !1,
|
|
1005
1005
|
selectionMode: Ie = "partial",
|
|
@@ -1027,7 +1027,7 @@ function Lr({
|
|
|
1027
1027
|
elevateNodesOnSelect: hn = !1,
|
|
1028
1028
|
edgeRouting: fe = !0
|
|
1029
1029
|
} = {}) {
|
|
1030
|
-
const
|
|
1030
|
+
const mt = tt(null), Te = tt(null), Et = tt(null), pt = tt({ ...Nt }), se = tt([...t]), Z = tt([...e]), Pt = tt([...n]), yn = tt(/* @__PURE__ */ new Map()), Se = tt(!1), te = tt(null), [gn, pn] = Gt(!1), _t = tt(null), Wt = tt(null), Me = tt(null), ie = tt(null), Ut = tt(!1), Re = tt(null), [Be, Je] = Gt({ x: Nt.x, y: Nt.y, zoom: Nt.zoom }), [Ve, ae] = Gt(null), Kt = St(() => /* @__PURE__ */ new Set(), []), he = St(() => /* @__PURE__ */ new Set(), []), ke = tt(!1), O = tt({});
|
|
1031
1031
|
O.current = {
|
|
1032
1032
|
onHudUpdate: r,
|
|
1033
1033
|
onNodesProcessed: s,
|
|
@@ -1039,34 +1039,34 @@ function Lr({
|
|
|
1039
1039
|
onNodeDrag: y,
|
|
1040
1040
|
onNodeDragStop: m,
|
|
1041
1041
|
onEdgeClick: C,
|
|
1042
|
-
onEdgeDoubleClick:
|
|
1042
|
+
onEdgeDoubleClick: z,
|
|
1043
1043
|
onEdgeMouseEnter: M,
|
|
1044
1044
|
onEdgeMouseMove: $,
|
|
1045
|
-
onEdgeMouseLeave:
|
|
1045
|
+
onEdgeMouseLeave: k,
|
|
1046
1046
|
onEdgeContextMenu: E,
|
|
1047
|
-
onNodeDoubleClick:
|
|
1048
|
-
onNodeMouseEnter:
|
|
1047
|
+
onNodeDoubleClick: _,
|
|
1048
|
+
onNodeMouseEnter: D,
|
|
1049
1049
|
onNodeMouseMove: g,
|
|
1050
1050
|
onNodeMouseLeave: f,
|
|
1051
1051
|
onNodeContextMenu: p,
|
|
1052
1052
|
onPaneClick: v,
|
|
1053
|
-
onPaneContextMenu:
|
|
1054
|
-
onPaneMouseEnter:
|
|
1053
|
+
onPaneContextMenu: N,
|
|
1054
|
+
onPaneMouseEnter: w,
|
|
1055
1055
|
onPaneMouseMove: P,
|
|
1056
1056
|
onPaneMouseLeave: R,
|
|
1057
1057
|
onSelectionChange: B,
|
|
1058
1058
|
onConnectStart: q,
|
|
1059
|
-
onConnectEnd:
|
|
1060
|
-
onInit:
|
|
1061
|
-
onMoveStart:
|
|
1062
|
-
onMove:
|
|
1059
|
+
onConnectEnd: X,
|
|
1060
|
+
onInit: K,
|
|
1061
|
+
onMoveStart: at,
|
|
1062
|
+
onMove: rt,
|
|
1063
1063
|
onMoveEnd: G,
|
|
1064
1064
|
onDelete: j,
|
|
1065
|
-
onBeforeDelete:
|
|
1066
|
-
onError:
|
|
1067
|
-
isValidConnection:
|
|
1065
|
+
onBeforeDelete: it,
|
|
1066
|
+
onError: dt,
|
|
1067
|
+
isValidConnection: ot
|
|
1068
1068
|
};
|
|
1069
|
-
const
|
|
1069
|
+
const bt = { get current() {
|
|
1070
1070
|
return O.current.onNodesChange;
|
|
1071
1071
|
} }, Dt = { get current() {
|
|
1072
1072
|
return O.current.onEdgesChange;
|
|
@@ -1074,9 +1074,9 @@ function Lr({
|
|
|
1074
1074
|
return O.current.onConnect;
|
|
1075
1075
|
} }, De = { get current() {
|
|
1076
1076
|
return O.current.onNodeClick;
|
|
1077
|
-
} }, He = { get current() {
|
|
1078
|
-
return O.current.onNodeDragStart;
|
|
1079
1077
|
} }, Ae = { get current() {
|
|
1078
|
+
return O.current.onNodeDragStart;
|
|
1079
|
+
} }, He = { get current() {
|
|
1080
1080
|
return O.current.onNodeDrag;
|
|
1081
1081
|
} }, _e = { get current() {
|
|
1082
1082
|
return O.current.onNodeDragStop;
|
|
@@ -1091,7 +1091,7 @@ function Lr({
|
|
|
1091
1091
|
} }, pe = { get current() {
|
|
1092
1092
|
return O.current.onNodesProcessed;
|
|
1093
1093
|
} };
|
|
1094
|
-
|
|
1094
|
+
ht(() => {
|
|
1095
1095
|
const a = (d) => {
|
|
1096
1096
|
d.key === wt && (Ut.current = !0), d.key === we && (ke.current = !0);
|
|
1097
1097
|
}, x = (d) => {
|
|
@@ -1107,9 +1107,9 @@ function Lr({
|
|
|
1107
1107
|
(b = ye.current) == null || b.call(ye, d);
|
|
1108
1108
|
for (const L of he) L(d);
|
|
1109
1109
|
}, [he]);
|
|
1110
|
-
|
|
1110
|
+
ht(() => {
|
|
1111
1111
|
var a;
|
|
1112
|
-
se.current = [...t], (a =
|
|
1112
|
+
se.current = [...t], (a = Et.current) == null || a.postMessage({ type: "cards", data: { cards: [...t] } });
|
|
1113
1113
|
}, [t]);
|
|
1114
1114
|
const ze = F((a) => {
|
|
1115
1115
|
const x = {};
|
|
@@ -1123,7 +1123,7 @@ function Lr({
|
|
|
1123
1123
|
L += h.position.x, I += h.position.y, h = h.parentId ? x[h.parentId] : null;
|
|
1124
1124
|
return { ...d, _absolutePosition: { x: L, y: I } };
|
|
1125
1125
|
});
|
|
1126
|
-
}, []), ee =
|
|
1126
|
+
}, []), ee = tt([]), Q = F((a) => {
|
|
1127
1127
|
const x = yn.current;
|
|
1128
1128
|
if (!x || x.size === 0) return a;
|
|
1129
1129
|
const d = {};
|
|
@@ -1137,9 +1137,9 @@ function Lr({
|
|
|
1137
1137
|
var x;
|
|
1138
1138
|
if (_t.current) return;
|
|
1139
1139
|
const a = Q(ee.current);
|
|
1140
|
-
(x =
|
|
1140
|
+
(x = Et.current) == null || x.postMessage({ type: "nodes", data: { nodes: a } });
|
|
1141
1141
|
}, [Q]);
|
|
1142
|
-
|
|
1142
|
+
ht(() => {
|
|
1143
1143
|
var d;
|
|
1144
1144
|
if (_t.current) {
|
|
1145
1145
|
const b = _t.current.id, L = /* @__PURE__ */ new Set([b, ..._t.current.selectedStarts.map((h) => h.id)]), I = {};
|
|
@@ -1155,15 +1155,15 @@ function Lr({
|
|
|
1155
1155
|
const a = ze(e);
|
|
1156
1156
|
ee.current = a;
|
|
1157
1157
|
const x = Q(a);
|
|
1158
|
-
(d =
|
|
1159
|
-
}, [e, ze, Q]),
|
|
1158
|
+
(d = Et.current) == null || d.postMessage({ type: "nodes", data: { nodes: x } });
|
|
1159
|
+
}, [e, ze, Q]), ht(() => {
|
|
1160
1160
|
var a;
|
|
1161
|
-
Pt.current = [...n], (a =
|
|
1161
|
+
Pt.current = [...n], (a = Et.current) == null || a.postMessage({ type: "edges", data: { edges: [...n] } });
|
|
1162
1162
|
}, [n]);
|
|
1163
|
-
const
|
|
1164
|
-
const d =
|
|
1163
|
+
const lt = F((a, x) => {
|
|
1164
|
+
const d = mt.current;
|
|
1165
1165
|
if (!d) return { x: 0, y: 0 };
|
|
1166
|
-
const b = d.getBoundingClientRect(), L =
|
|
1166
|
+
const b = d.getBoundingClientRect(), L = pt.current;
|
|
1167
1167
|
return {
|
|
1168
1168
|
x: (a - b.left - L.x) / L.zoom,
|
|
1169
1169
|
y: (x - b.top - L.y) / L.zoom
|
|
@@ -1210,7 +1210,7 @@ function Lr({
|
|
|
1210
1210
|
{ id: null, type: "source", x: a.position.x + x, y: a.position.y + d / 2 }
|
|
1211
1211
|
];
|
|
1212
1212
|
}, [xe]), tn = F((a, x) => {
|
|
1213
|
-
const d = Z.current, b =
|
|
1213
|
+
const d = Z.current, b = pt.current, L = Math.max(Nr, Ot) / b.zoom;
|
|
1214
1214
|
for (let I = d.length - 1; I >= 0; I--) {
|
|
1215
1215
|
const h = d[I];
|
|
1216
1216
|
if (h.hidden) continue;
|
|
@@ -1221,62 +1221,62 @@ function Lr({
|
|
|
1221
1221
|
}
|
|
1222
1222
|
return null;
|
|
1223
1223
|
}, [Ee]), ue = F((a, x) => {
|
|
1224
|
-
const b = 8 /
|
|
1224
|
+
const b = 8 / pt.current.zoom;
|
|
1225
1225
|
for (let L = Pt.current.length - 1; L >= 0; L--) {
|
|
1226
|
-
const I = Pt.current[L], h = Z.current.find((
|
|
1226
|
+
const I = Pt.current[L], h = Z.current.find((Mt) => Mt.id === I.source), A = Z.current.find((Mt) => Mt.id === I.target);
|
|
1227
1227
|
if (!h || !A) continue;
|
|
1228
|
-
const T = h.width || Vt, Y = h.height || jt,
|
|
1229
|
-
if (Ir(a, x,
|
|
1228
|
+
const T = h.width || Vt, Y = h.height || jt, H = A.height || jt, J = h.position.x + T, ut = h.position.y + Y / 2, U = A.position.x, nt = A.position.y + H / 2;
|
|
1229
|
+
if (Ir(a, x, J, ut, U, nt) < b) return I;
|
|
1230
1230
|
}
|
|
1231
1231
|
return null;
|
|
1232
1232
|
}, []);
|
|
1233
|
-
|
|
1234
|
-
const a = Te.current, x =
|
|
1233
|
+
ht(() => {
|
|
1234
|
+
const a = Te.current, x = mt.current;
|
|
1235
1235
|
if (!a || !x) return;
|
|
1236
|
-
const d = x.getBoundingClientRect(), b =
|
|
1236
|
+
const d = x.getBoundingClientRect(), b = ft !== void 0 ? ft : matchMedia("(prefers-color-scheme: dark)").matches, L = ze(Z.current);
|
|
1237
1237
|
ee.current = L;
|
|
1238
1238
|
const I = Q(L), { worker: h } = Cr(a, {
|
|
1239
1239
|
width: d.width,
|
|
1240
1240
|
height: d.height,
|
|
1241
|
-
camera:
|
|
1241
|
+
camera: pt.current,
|
|
1242
1242
|
cards: se.current,
|
|
1243
1243
|
nodes: I,
|
|
1244
1244
|
edges: Pt.current,
|
|
1245
1245
|
dark: b,
|
|
1246
|
-
gridSize:
|
|
1246
|
+
gridSize: It,
|
|
1247
1247
|
edgeRouting: fe
|
|
1248
1248
|
});
|
|
1249
|
-
h.onmessage = (
|
|
1250
|
-
var
|
|
1251
|
-
|
|
1252
|
-
},
|
|
1253
|
-
const A = new ResizeObserver((
|
|
1254
|
-
const { width:
|
|
1255
|
-
h.postMessage({ type: "resize", data: { width:
|
|
1249
|
+
h.onmessage = (H) => {
|
|
1250
|
+
var J, ut;
|
|
1251
|
+
H.data.type === "hud" && ((J = ge.current) == null || J.call(ge, H.data.data)), H.data.type === "ready" && pn(!0), H.data.type === "nodesProcessed" && ((ut = pe.current) == null || ut.call(pe, H.data.data));
|
|
1252
|
+
}, Et.current = h;
|
|
1253
|
+
const A = new ResizeObserver((H) => {
|
|
1254
|
+
const { width: J, height: ut } = H[0].contentRect;
|
|
1255
|
+
h.postMessage({ type: "resize", data: { width: J, height: ut } });
|
|
1256
1256
|
});
|
|
1257
1257
|
A.observe(x);
|
|
1258
1258
|
let T, Y;
|
|
1259
|
-
return
|
|
1260
|
-
A.disconnect(), T && Y && T.removeEventListener("change", Y),
|
|
1259
|
+
return ft === void 0 && (T = matchMedia("(prefers-color-scheme: dark)"), Y = (H) => h.postMessage({ type: "theme", data: { dark: H.matches } }), T.addEventListener("change", Y)), () => {
|
|
1260
|
+
A.disconnect(), T && Y && T.removeEventListener("change", Y), Et.current = null;
|
|
1261
1261
|
};
|
|
1262
|
-
}, []),
|
|
1262
|
+
}, []), ht(() => {
|
|
1263
1263
|
var a;
|
|
1264
|
-
|
|
1265
|
-
}, [
|
|
1264
|
+
ft !== void 0 && ((a = Et.current) == null || a.postMessage({ type: "theme", data: { dark: ft } }));
|
|
1265
|
+
}, [ft]), ht(() => {
|
|
1266
1266
|
var a;
|
|
1267
|
-
(a =
|
|
1267
|
+
(a = Et.current) == null || a.postMessage({ type: "edgeRouting", data: { enabled: fe } });
|
|
1268
1268
|
}, [fe]);
|
|
1269
|
-
const Ln =
|
|
1269
|
+
const Ln = tt(0), Ct = F((a = null) => {
|
|
1270
1270
|
var b, L, I;
|
|
1271
|
-
const x =
|
|
1271
|
+
const x = pt.current;
|
|
1272
1272
|
if (re) {
|
|
1273
|
-
const h =
|
|
1273
|
+
const h = mt.current;
|
|
1274
1274
|
if (h) {
|
|
1275
|
-
const A = h.getBoundingClientRect(), T = -re[1][0] * x.zoom + A.width, Y = -re[1][1] * x.zoom + A.height,
|
|
1276
|
-
x.x = Math.min(
|
|
1275
|
+
const A = h.getBoundingClientRect(), T = -re[1][0] * x.zoom + A.width, Y = -re[1][1] * x.zoom + A.height, H = -re[0][0] * x.zoom, J = -re[0][1] * x.zoom;
|
|
1276
|
+
x.x = Math.min(H, Math.max(T, x.x)), x.y = Math.min(J, Math.max(Y, x.y));
|
|
1277
1277
|
}
|
|
1278
1278
|
}
|
|
1279
|
-
(b =
|
|
1279
|
+
(b = Et.current) == null || b.postMessage({ type: "camera", data: { camera: { ...x } } });
|
|
1280
1280
|
const d = { x: x.x, y: x.y, zoom: x.zoom };
|
|
1281
1281
|
(I = (L = O.current).onMove) == null || I.call(L, a, d);
|
|
1282
1282
|
for (const h of Kt) h(d);
|
|
@@ -1286,162 +1286,162 @@ function Lr({
|
|
|
1286
1286
|
}, [Kt, re]), Ce = F(() => {
|
|
1287
1287
|
var d, b;
|
|
1288
1288
|
const a = Wt.current, x = Me.current;
|
|
1289
|
-
a && x ? ((d =
|
|
1289
|
+
a && x ? ((d = Et.current) == null || d.postMessage({ type: "connecting", data: { from: a.startPos, to: x, _routedPoints: null } }), ae({ source: a.sourceId, sourceHandle: a.sourceHandle, target: null, targetHandle: null })) : ((b = Et.current) == null || b.postMessage({ type: "connecting", data: null }), ae(null));
|
|
1290
1290
|
}, []), Ne = F(() => {
|
|
1291
1291
|
var x, d;
|
|
1292
1292
|
const a = ie.current;
|
|
1293
|
-
a ? (x =
|
|
1293
|
+
a ? (x = Et.current) == null || x.postMessage({ type: "selectionBox", data: a }) : (d = Et.current) == null || d.postMessage({ type: "selectionBox", data: null });
|
|
1294
1294
|
}, []), dr = F((a) => {
|
|
1295
|
-
var L, I, h, A, T, Y,
|
|
1296
|
-
const x = Z.current.length > 0, d =
|
|
1297
|
-
if (x &&
|
|
1298
|
-
const
|
|
1299
|
-
if (Yt && Re.current &&
|
|
1300
|
-
const
|
|
1301
|
-
if (
|
|
1302
|
-
const qt =
|
|
1295
|
+
var L, I, h, A, T, Y, H, J, ut, U, nt, vt, Mt, At, Xt, Ht;
|
|
1296
|
+
const x = Z.current.length > 0, d = lt(a.clientX, a.clientY), b = Ut.current;
|
|
1297
|
+
if (x && Rt) {
|
|
1298
|
+
const W = tn(d.x, d.y);
|
|
1299
|
+
if (Yt && Re.current && W) {
|
|
1300
|
+
const V = Re.current;
|
|
1301
|
+
if (W.nodeId !== V.nodeId) {
|
|
1302
|
+
const qt = V.handleType === "target" ? { source: W.nodeId, target: V.nodeId, sourceHandle: W.handleId || null, targetHandle: V.handleId } : { source: V.nodeId, target: W.nodeId, sourceHandle: V.handleId, targetHandle: W.handleId || null };
|
|
1303
1303
|
(O.current.isValidConnection ? O.current.isValidConnection(qt) : !0) && ((L = ce.current) == null || L.call(ce, { ...qt, ...be }));
|
|
1304
1304
|
}
|
|
1305
1305
|
Re.current = null;
|
|
1306
1306
|
return;
|
|
1307
1307
|
}
|
|
1308
|
-
if (Bt === "strict" ?
|
|
1308
|
+
if (Bt === "strict" ? W && W.type === "source" : W != null) {
|
|
1309
1309
|
if (Yt) {
|
|
1310
|
-
Re.current = { nodeId:
|
|
1310
|
+
Re.current = { nodeId: W.nodeId, handleId: W.handleId || null, handleType: W.type }, (h = (I = O.current).onConnectStart) == null || h.call(I, a, { nodeId: W.nodeId, handleId: W.handleId, handleType: W.type });
|
|
1311
1311
|
return;
|
|
1312
1312
|
}
|
|
1313
1313
|
Wt.current = {
|
|
1314
|
-
sourceId:
|
|
1315
|
-
sourceHandle:
|
|
1316
|
-
sourceType:
|
|
1317
|
-
startPos: { x:
|
|
1318
|
-
}, Me.current = { x: d.x, y: d.y }, (A =
|
|
1314
|
+
sourceId: W.nodeId,
|
|
1315
|
+
sourceHandle: W.handleId || null,
|
|
1316
|
+
sourceType: W.type,
|
|
1317
|
+
startPos: { x: W.x, y: W.y }
|
|
1318
|
+
}, Me.current = { x: d.x, y: d.y }, (A = mt.current) == null || A.setPointerCapture(a.pointerId), (Y = (T = O.current).onConnectStart) == null || Y.call(T, a, { nodeId: W.nodeId, handleId: W.handleId, handleType: W.type }), Ce();
|
|
1319
1319
|
return;
|
|
1320
1320
|
}
|
|
1321
1321
|
}
|
|
1322
1322
|
if (x) {
|
|
1323
|
-
const
|
|
1324
|
-
if (
|
|
1325
|
-
if (
|
|
1326
|
-
const
|
|
1323
|
+
const W = Tt(d.x, d.y);
|
|
1324
|
+
if (W) {
|
|
1325
|
+
if (bt.current && Lt) {
|
|
1326
|
+
const kt = [];
|
|
1327
1327
|
if (b)
|
|
1328
|
-
|
|
1329
|
-
else if (!
|
|
1330
|
-
for (const
|
|
1331
|
-
|
|
1328
|
+
kt.push({ id: W.id, type: "select", selected: !W.selected });
|
|
1329
|
+
else if (!W.selected) {
|
|
1330
|
+
for (const V of Z.current)
|
|
1331
|
+
V.id === W.id ? kt.push({ id: V.id, type: "select", selected: !0 }) : V.selected && kt.push({ id: V.id, type: "select", selected: !1 });
|
|
1332
1332
|
if (Dt.current) {
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1333
|
+
const V = Pt.current.filter((et) => et.selected).map((et) => ({ id: et.id, type: "select", selected: !1 }));
|
|
1334
|
+
V.length && Dt.current(V);
|
|
1335
1335
|
}
|
|
1336
1336
|
}
|
|
1337
|
-
if (
|
|
1338
|
-
if (
|
|
1339
|
-
const
|
|
1340
|
-
|
|
1341
|
-
{ id:
|
|
1342
|
-
{ type: "add", item: { ...Z.current[
|
|
1337
|
+
if (kt.length) {
|
|
1338
|
+
if (bt.current(kt), hn && !b) {
|
|
1339
|
+
const V = Z.current.findIndex((et) => et.id === W.id);
|
|
1340
|
+
V >= 0 && V < Z.current.length - 1 && bt.current([
|
|
1341
|
+
{ id: W.id, type: "remove" },
|
|
1342
|
+
{ type: "add", item: { ...Z.current[V], selected: !0 } }
|
|
1343
1343
|
]);
|
|
1344
1344
|
}
|
|
1345
1345
|
Jt();
|
|
1346
1346
|
}
|
|
1347
1347
|
}
|
|
1348
|
-
if ((
|
|
1349
|
-
const
|
|
1350
|
-
let
|
|
1351
|
-
if (
|
|
1352
|
-
const
|
|
1353
|
-
if (
|
|
1354
|
-
const qt =
|
|
1355
|
-
|
|
1348
|
+
if ((H = De.current) == null || H.call(De, a, W), zt) {
|
|
1349
|
+
const kt = b && W.selected;
|
|
1350
|
+
let V = null;
|
|
1351
|
+
if (W.parentId && W.extent === "parent") {
|
|
1352
|
+
const et = Z.current.find((qt) => qt.id === W.parentId);
|
|
1353
|
+
if (et) {
|
|
1354
|
+
const qt = et.width || Vt, Xe = et.height || jt, en = W.width || ((J = W.measured) == null ? void 0 : J.width) || Vt, Fe = W.height || ((ut = W.measured) == null ? void 0 : ut.height) || jt;
|
|
1355
|
+
V = { minX: 0, minY: 0, maxX: qt - en, maxY: Xe - Fe };
|
|
1356
1356
|
}
|
|
1357
1357
|
}
|
|
1358
1358
|
if (_t.current = {
|
|
1359
|
-
id:
|
|
1360
|
-
startPos: { ...
|
|
1359
|
+
id: W.id,
|
|
1360
|
+
startPos: { ...W.position },
|
|
1361
1361
|
startMouse: { x: d.x, y: d.y },
|
|
1362
|
-
parentClamp:
|
|
1363
|
-
parentId:
|
|
1364
|
-
selectedStarts:
|
|
1362
|
+
parentClamp: V,
|
|
1363
|
+
parentId: W.parentId || null,
|
|
1364
|
+
selectedStarts: kt ? Z.current.filter((et) => et.selected && et.id !== W.id).map((et) => {
|
|
1365
1365
|
var Xe, en;
|
|
1366
1366
|
let qt = null;
|
|
1367
|
-
if (
|
|
1368
|
-
const Fe = Z.current.find((xn) => xn.id ===
|
|
1367
|
+
if (et.parentId && et.extent === "parent") {
|
|
1368
|
+
const Fe = Z.current.find((xn) => xn.id === et.parentId);
|
|
1369
1369
|
if (Fe) {
|
|
1370
|
-
const xn = Fe.width || Vt, br = Fe.height || jt, Mr =
|
|
1370
|
+
const xn = Fe.width || Vt, br = Fe.height || jt, Mr = et.width || ((Xe = et.measured) == null ? void 0 : Xe.width) || Vt, Rr = et.height || ((en = et.measured) == null ? void 0 : en.height) || jt;
|
|
1371
1371
|
qt = { minX: 0, minY: 0, maxX: xn - Mr, maxY: br - Rr };
|
|
1372
1372
|
}
|
|
1373
1373
|
}
|
|
1374
|
-
return { id:
|
|
1374
|
+
return { id: et.id, startPos: { ...et.position }, parentClamp: qt, parentId: et.parentId || null };
|
|
1375
1375
|
}) : []
|
|
1376
|
-
}, (U =
|
|
1377
|
-
const
|
|
1376
|
+
}, (U = mt.current) == null || U.setPointerCapture(a.pointerId), (nt = Ae.current) == null || nt.call(Ae, a, W), bt.current) {
|
|
1377
|
+
const et = [{ id: W.id, type: "position", dragging: !0 }];
|
|
1378
1378
|
for (const qt of _t.current.selectedStarts)
|
|
1379
|
-
|
|
1380
|
-
|
|
1379
|
+
et.push({ id: qt.id, type: "position", dragging: !0 });
|
|
1380
|
+
bt.current(et);
|
|
1381
1381
|
}
|
|
1382
1382
|
}
|
|
1383
1383
|
return;
|
|
1384
1384
|
}
|
|
1385
1385
|
}
|
|
1386
|
-
if (Pt.current.length > 0 &&
|
|
1387
|
-
const
|
|
1388
|
-
if (
|
|
1386
|
+
if (Pt.current.length > 0 && Lt) {
|
|
1387
|
+
const W = ue(d.x, d.y);
|
|
1388
|
+
if (W) {
|
|
1389
1389
|
if (Dt.current) {
|
|
1390
|
-
const
|
|
1390
|
+
const kt = [];
|
|
1391
1391
|
if (b)
|
|
1392
|
-
|
|
1392
|
+
kt.push({ id: W.id, type: "select", selected: !W.selected });
|
|
1393
1393
|
else {
|
|
1394
|
-
for (const
|
|
1395
|
-
|
|
1396
|
-
if (
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1394
|
+
for (const V of Pt.current)
|
|
1395
|
+
V.id === W.id ? kt.push({ id: V.id, type: "select", selected: !0 }) : V.selected && kt.push({ id: V.id, type: "select", selected: !1 });
|
|
1396
|
+
if (bt.current) {
|
|
1397
|
+
const V = Z.current.filter((et) => et.selected).map((et) => ({ id: et.id, type: "select", selected: !1 }));
|
|
1398
|
+
V.length && bt.current(V);
|
|
1399
1399
|
}
|
|
1400
1400
|
}
|
|
1401
|
-
|
|
1401
|
+
kt.length && (Dt.current(kt), Jt());
|
|
1402
1402
|
}
|
|
1403
|
-
(
|
|
1403
|
+
(vt = le.current) == null || vt.call(le, a, W);
|
|
1404
1404
|
return;
|
|
1405
1405
|
}
|
|
1406
1406
|
}
|
|
1407
1407
|
if (!b) {
|
|
1408
|
-
const
|
|
1409
|
-
|
|
1408
|
+
const W = Z.current.filter((V) => V.selected).map((V) => ({ id: V.id, type: "select", selected: !1 })), kt = Pt.current.filter((V) => V.selected).map((V) => ({ id: V.id, type: "select", selected: !1 }));
|
|
1409
|
+
W.length && bt.current && bt.current(W), kt.length && Dt.current && Dt.current(kt), (W.length || kt.length) && Jt();
|
|
1410
1410
|
}
|
|
1411
|
-
if ((
|
|
1412
|
-
ie.current = { startWorld: { ...d }, endWorld: { ...d } }, (
|
|
1411
|
+
if ((Mt = We.current) == null || Mt.call(We, a), ne || b) {
|
|
1412
|
+
ie.current = { startWorld: { ...d }, endWorld: { ...d } }, (At = mt.current) == null || At.setPointerCapture(a.pointerId), Ne();
|
|
1413
1413
|
return;
|
|
1414
1414
|
}
|
|
1415
|
-
Se.current = !0, te.current = { x: a.clientX, y: a.clientY }, (Xt =
|
|
1416
|
-
}, [
|
|
1415
|
+
Se.current = !0, te.current = { x: a.clientX, y: a.clientY }, (Xt = mt.current) == null || Xt.classList.add("dragging"), (Ht = mt.current) == null || Ht.setPointerCapture(a.pointerId);
|
|
1416
|
+
}, [lt, Tt, tn, ue, zt, Rt, Lt, ne, Ce, Ne, Jt]), fr = F((a) => {
|
|
1417
1417
|
var d, b;
|
|
1418
1418
|
if (Wt.current) {
|
|
1419
|
-
if (Me.current =
|
|
1420
|
-
const L =
|
|
1419
|
+
if (Me.current = lt(a.clientX, a.clientY), Ce(), fn) {
|
|
1420
|
+
const L = mt.current;
|
|
1421
1421
|
if (L) {
|
|
1422
1422
|
const I = L.getBoundingClientRect(), h = 40, A = a.clientX - I.left, T = a.clientY - I.top;
|
|
1423
|
-
let Y = 0,
|
|
1424
|
-
A < h ? Y = Qt : A > I.width - h && (Y = -Qt), T < h ?
|
|
1423
|
+
let Y = 0, H = 0;
|
|
1424
|
+
A < h ? Y = Qt : A > I.width - h && (Y = -Qt), T < h ? H = Qt : T > I.height - h && (H = -Qt), (Y || H) && (pt.current.x += Y, pt.current.y += H, Ct(a));
|
|
1425
1425
|
}
|
|
1426
1426
|
}
|
|
1427
1427
|
return;
|
|
1428
1428
|
}
|
|
1429
1429
|
if (ie.current) {
|
|
1430
|
-
ie.current.endWorld =
|
|
1430
|
+
ie.current.endWorld = lt(a.clientX, a.clientY), Ne();
|
|
1431
1431
|
const L = ie.current, I = Math.min(L.startWorld.x, L.endWorld.x), h = Math.min(L.startWorld.y, L.endWorld.y), A = Math.max(L.startWorld.x, L.endWorld.x), T = Math.max(L.startWorld.y, L.endWorld.y);
|
|
1432
|
-
if (
|
|
1432
|
+
if (bt.current) {
|
|
1433
1433
|
const Y = [];
|
|
1434
|
-
for (const
|
|
1435
|
-
if (
|
|
1436
|
-
const
|
|
1437
|
-
U !== !!
|
|
1434
|
+
for (const H of Z.current) {
|
|
1435
|
+
if (H.hidden) continue;
|
|
1436
|
+
const J = H.width || Vt, ut = H.height || jt, U = Ie === "full" ? H.position.x >= I && H.position.x + J <= A && H.position.y >= h && H.position.y + ut <= T : H.position.x + J > I && H.position.x < A && H.position.y + ut > h && H.position.y < T;
|
|
1437
|
+
U !== !!H.selected && Y.push({ id: H.id, type: "select", selected: U });
|
|
1438
1438
|
}
|
|
1439
|
-
Y.length &&
|
|
1439
|
+
Y.length && bt.current(Y);
|
|
1440
1440
|
}
|
|
1441
1441
|
return;
|
|
1442
1442
|
}
|
|
1443
1443
|
if (_t.current) {
|
|
1444
|
-
const L =
|
|
1444
|
+
const L = lt(a.clientX, a.clientY), I = _t.current, h = L.x - I.startMouse.x, A = L.y - I.startMouse.y;
|
|
1445
1445
|
let T = { x: I.startPos.x + h, y: I.startPos.y + A };
|
|
1446
1446
|
if (me && (T = Pn(T, de)), oe && (T = Tn(T, oe)), I.parentClamp) {
|
|
1447
1447
|
const U = I.parentClamp;
|
|
@@ -1449,73 +1449,73 @@ function Lr({
|
|
|
1449
1449
|
}
|
|
1450
1450
|
const Y = [{ id: I.id, position: T }];
|
|
1451
1451
|
for (const U of I.selectedStarts) {
|
|
1452
|
-
let
|
|
1453
|
-
if (me && (
|
|
1454
|
-
const
|
|
1455
|
-
|
|
1452
|
+
let nt = { x: U.startPos.x + h, y: U.startPos.y + A };
|
|
1453
|
+
if (me && (nt = Pn(nt, de)), oe && (nt = Tn(nt, oe)), U.parentClamp) {
|
|
1454
|
+
const vt = U.parentClamp;
|
|
1455
|
+
nt = { x: Math.max(vt.minX, Math.min(nt.x, vt.maxX)), y: Math.max(vt.minY, Math.min(nt.y, vt.maxY)) };
|
|
1456
1456
|
}
|
|
1457
|
-
Y.push({ id: U.id, position:
|
|
1457
|
+
Y.push({ id: U.id, position: nt });
|
|
1458
1458
|
}
|
|
1459
|
-
const
|
|
1459
|
+
const H = [];
|
|
1460
1460
|
for (const U of Y) {
|
|
1461
|
-
const
|
|
1462
|
-
if (
|
|
1463
|
-
|
|
1464
|
-
let
|
|
1465
|
-
if (
|
|
1466
|
-
let
|
|
1467
|
-
for (;
|
|
1468
|
-
|
|
1469
|
-
|
|
1461
|
+
const nt = Z.current.find((vt) => vt.id === U.id);
|
|
1462
|
+
if (nt) {
|
|
1463
|
+
nt.position = U.position, nt.dragging = !0;
|
|
1464
|
+
let vt = U.position;
|
|
1465
|
+
if (nt.parentId) {
|
|
1466
|
+
let Mt = Z.current.find((Ht) => Ht.id === nt.parentId), At = U.position.x, Xt = U.position.y;
|
|
1467
|
+
for (; Mt; )
|
|
1468
|
+
At += Mt.position.x, Xt += Mt.position.y, Mt = Mt.parentId ? Z.current.find((Ht) => Ht.id === Mt.parentId) : null;
|
|
1469
|
+
vt = { x: At, y: Xt };
|
|
1470
1470
|
}
|
|
1471
|
-
|
|
1471
|
+
H.push({
|
|
1472
1472
|
id: U.id,
|
|
1473
1473
|
position: U.position,
|
|
1474
|
-
_absolutePosition:
|
|
1475
|
-
width:
|
|
1476
|
-
height:
|
|
1474
|
+
_absolutePosition: vt,
|
|
1475
|
+
width: nt.width,
|
|
1476
|
+
height: nt.height,
|
|
1477
1477
|
dragging: !0,
|
|
1478
|
-
selected:
|
|
1478
|
+
selected: nt.selected
|
|
1479
1479
|
});
|
|
1480
1480
|
}
|
|
1481
1481
|
}
|
|
1482
|
-
const
|
|
1482
|
+
const J = new Set(Y.map((U) => U.id));
|
|
1483
1483
|
for (const U of Z.current)
|
|
1484
|
-
if (U.parentId &&
|
|
1485
|
-
let
|
|
1486
|
-
for (;
|
|
1487
|
-
|
|
1488
|
-
|
|
1484
|
+
if (U.parentId && J.has(U.parentId) && !J.has(U.id)) {
|
|
1485
|
+
let nt = Z.current.find((At) => At.id === U.parentId), vt = U.position.x, Mt = U.position.y;
|
|
1486
|
+
for (; nt; )
|
|
1487
|
+
vt += nt.position.x, Mt += nt.position.y, nt = nt.parentId ? Z.current.find((At) => At.id === nt.parentId) : null;
|
|
1488
|
+
H.push({
|
|
1489
1489
|
id: U.id,
|
|
1490
1490
|
position: U.position,
|
|
1491
|
-
_absolutePosition: { x:
|
|
1491
|
+
_absolutePosition: { x: vt, y: Mt },
|
|
1492
1492
|
width: U.width,
|
|
1493
1493
|
height: U.height,
|
|
1494
1494
|
dragging: !1,
|
|
1495
1495
|
selected: U.selected
|
|
1496
1496
|
});
|
|
1497
1497
|
}
|
|
1498
|
-
if ((d =
|
|
1499
|
-
const U =
|
|
1498
|
+
if ((d = Et.current) == null || d.postMessage({ type: "nodePositions", data: { updates: H } }), dn) {
|
|
1499
|
+
const U = mt.current;
|
|
1500
1500
|
if (U) {
|
|
1501
|
-
const
|
|
1502
|
-
let Xt = 0,
|
|
1503
|
-
|
|
1501
|
+
const nt = U.getBoundingClientRect(), vt = 40, Mt = a.clientX - nt.left, At = a.clientY - nt.top;
|
|
1502
|
+
let Xt = 0, Ht = 0;
|
|
1503
|
+
Mt < vt ? Xt = Qt : Mt > nt.width - vt && (Xt = -Qt), At < vt ? Ht = Qt : At > nt.height - vt && (Ht = -Qt), (Xt || Ht) && (pt.current.x += Xt, pt.current.y += Ht, Ct(a));
|
|
1504
1504
|
}
|
|
1505
1505
|
}
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1506
|
+
const ut = Z.current.find((U) => U.id === I.id);
|
|
1507
|
+
ut && ((b = He.current) == null || b.call(He, a, ut));
|
|
1508
1508
|
return;
|
|
1509
1509
|
}
|
|
1510
1510
|
if (!Se.current) return;
|
|
1511
|
-
const x =
|
|
1512
|
-
x.x += a.clientX - te.current.x, x.y += a.clientY - te.current.y, te.current = { x: a.clientX, y: a.clientY },
|
|
1513
|
-
}, [
|
|
1511
|
+
const x = pt.current;
|
|
1512
|
+
x.x += a.clientX - te.current.x, x.y += a.clientY - te.current.y, te.current = { x: a.clientX, y: a.clientY }, Ct();
|
|
1513
|
+
}, [Ct, lt, Ce, Ne]), hr = F((a) => {
|
|
1514
1514
|
var x, d, b, L, I;
|
|
1515
1515
|
if (Wt.current) {
|
|
1516
|
-
const h =
|
|
1516
|
+
const h = lt(a.clientX, a.clientY), A = tn(h.x, h.y);
|
|
1517
1517
|
if (A && A.nodeId !== Wt.current.sourceId && (Bt === "loose" || A.type === "target")) {
|
|
1518
|
-
const
|
|
1518
|
+
const H = Wt.current.sourceType === "target" ? {
|
|
1519
1519
|
source: A.nodeId,
|
|
1520
1520
|
target: Wt.current.sourceId,
|
|
1521
1521
|
sourceHandle: A.handleId || null,
|
|
@@ -1526,7 +1526,7 @@ function Lr({
|
|
|
1526
1526
|
sourceHandle: Wt.current.sourceHandle,
|
|
1527
1527
|
targetHandle: A.handleId || null
|
|
1528
1528
|
};
|
|
1529
|
-
(O.current.isValidConnection ? O.current.isValidConnection(
|
|
1529
|
+
(O.current.isValidConnection ? O.current.isValidConnection(H) : !0) && ((x = ce.current) == null || x.call(ce, { ...H, ...be }));
|
|
1530
1530
|
}
|
|
1531
1531
|
(b = (d = O.current).onConnectEnd) == null || b.call(d, a.nativeEvent || a), Wt.current = null, Me.current = null, Ce();
|
|
1532
1532
|
return;
|
|
@@ -1537,23 +1537,23 @@ function Lr({
|
|
|
1537
1537
|
}
|
|
1538
1538
|
if (_t.current) {
|
|
1539
1539
|
const h = _t.current;
|
|
1540
|
-
if (
|
|
1541
|
-
const T = Z.current.find((
|
|
1540
|
+
if (bt.current) {
|
|
1541
|
+
const T = Z.current.find((H) => H.id === h.id), Y = [{
|
|
1542
1542
|
id: h.id,
|
|
1543
1543
|
type: "position",
|
|
1544
1544
|
position: T ? { ...T.position } : void 0,
|
|
1545
1545
|
dragging: !1
|
|
1546
1546
|
}];
|
|
1547
|
-
for (const
|
|
1548
|
-
const
|
|
1547
|
+
for (const H of h.selectedStarts) {
|
|
1548
|
+
const J = Z.current.find((ut) => ut.id === H.id);
|
|
1549
1549
|
Y.push({
|
|
1550
|
-
id:
|
|
1550
|
+
id: H.id,
|
|
1551
1551
|
type: "position",
|
|
1552
|
-
position:
|
|
1552
|
+
position: J ? { ...J.position } : void 0,
|
|
1553
1553
|
dragging: !1
|
|
1554
1554
|
});
|
|
1555
1555
|
}
|
|
1556
|
-
|
|
1556
|
+
bt.current(Y);
|
|
1557
1557
|
}
|
|
1558
1558
|
requestAnimationFrame(() => {
|
|
1559
1559
|
_t.current = null;
|
|
@@ -1562,27 +1562,27 @@ function Lr({
|
|
|
1562
1562
|
A && ((L = _e.current) == null || L.call(_e, a, A));
|
|
1563
1563
|
return;
|
|
1564
1564
|
}
|
|
1565
|
-
Se.current = !1, (I =
|
|
1566
|
-
}, [
|
|
1567
|
-
|
|
1568
|
-
const a =
|
|
1565
|
+
Se.current = !1, (I = mt.current) == null || I.classList.remove("dragging");
|
|
1566
|
+
}, [lt, tn, Ce, Ne, Jt]);
|
|
1567
|
+
ht(() => {
|
|
1568
|
+
const a = mt.current;
|
|
1569
1569
|
if (!a) return;
|
|
1570
1570
|
const x = (d) => {
|
|
1571
1571
|
Pe && d.preventDefault();
|
|
1572
|
-
const b =
|
|
1572
|
+
const b = pt.current;
|
|
1573
1573
|
if (Ge || ke.current) {
|
|
1574
1574
|
const T = Ze;
|
|
1575
|
-
$e === "horizontal" ? b.x -= d.deltaY * T : ($e === "vertical" || (b.x -= d.deltaX * T), b.y -= d.deltaY * T),
|
|
1575
|
+
$e === "horizontal" ? b.x -= d.deltaY * T : ($e === "vertical" || (b.x -= d.deltaX * T), b.y -= d.deltaY * T), Ct(d);
|
|
1576
1576
|
return;
|
|
1577
1577
|
}
|
|
1578
1578
|
if (!Oe) return;
|
|
1579
1579
|
const L = d.deltaY > 0 ? 0.92 : 1.08, I = a.getBoundingClientRect(), h = d.clientX - I.left, A = d.clientY - I.top;
|
|
1580
|
-
b.x = h - (h - b.x) * L, b.y = A - (A - b.y) * L, b.zoom = Math.min(
|
|
1580
|
+
b.x = h - (h - b.x) * L, b.y = A - (A - b.y) * L, b.zoom = Math.min(xt, Math.max(st, b.zoom * L)), Ct(d);
|
|
1581
1581
|
};
|
|
1582
1582
|
return a.addEventListener("wheel", x, { passive: !Pe }), () => a.removeEventListener("wheel", x);
|
|
1583
|
-
}, [
|
|
1583
|
+
}, [Ct, st, xt, Ge, $e, Ze, Oe, Pe]), ht(() => {
|
|
1584
1584
|
if (!Ke) return;
|
|
1585
|
-
const a =
|
|
1585
|
+
const a = mt.current;
|
|
1586
1586
|
if (!a) return;
|
|
1587
1587
|
let x = 0, d = null;
|
|
1588
1588
|
const b = (h) => {
|
|
@@ -1598,10 +1598,10 @@ function Lr({
|
|
|
1598
1598
|
}, L = (h) => {
|
|
1599
1599
|
if (h.touches.length === 2 && x > 0) {
|
|
1600
1600
|
h.preventDefault();
|
|
1601
|
-
const A = h.touches[0].clientX - h.touches[1].clientX, T = h.touches[0].clientY - h.touches[1].clientY, Y = Math.hypot(A, T),
|
|
1601
|
+
const A = h.touches[0].clientX - h.touches[1].clientX, T = h.touches[0].clientY - h.touches[1].clientY, Y = Math.hypot(A, T), H = Y / x;
|
|
1602
1602
|
x = Y;
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1603
|
+
const J = pt.current, ut = d.x, U = d.y;
|
|
1604
|
+
J.x = ut - (ut - J.x) * H, J.y = U - (U - J.y) * H, J.zoom = Math.min(xt, Math.max(st, J.zoom * H)), Ct(h);
|
|
1605
1605
|
}
|
|
1606
1606
|
}, I = () => {
|
|
1607
1607
|
x = 0, d = null;
|
|
@@ -1609,32 +1609,32 @@ function Lr({
|
|
|
1609
1609
|
return a.addEventListener("touchstart", b, { passive: !1 }), a.addEventListener("touchmove", L, { passive: !1 }), a.addEventListener("touchend", I), () => {
|
|
1610
1610
|
a.removeEventListener("touchstart", b), a.removeEventListener("touchmove", L), a.removeEventListener("touchend", I);
|
|
1611
1611
|
};
|
|
1612
|
-
}, [Ke,
|
|
1612
|
+
}, [Ke, Ct, st, xt]), ht(() => {
|
|
1613
1613
|
if (!Qe) return;
|
|
1614
|
-
const a =
|
|
1614
|
+
const a = mt.current;
|
|
1615
1615
|
if (!a) return;
|
|
1616
1616
|
const x = (d) => {
|
|
1617
|
-
var
|
|
1618
|
-
const b =
|
|
1617
|
+
var H, J, ut, U;
|
|
1618
|
+
const b = lt(d.clientX, d.clientY);
|
|
1619
1619
|
if (Tt(b.x, b.y)) {
|
|
1620
|
-
(
|
|
1620
|
+
(J = (H = O.current).onNodeDoubleClick) == null || J.call(H, d, Tt(b.x, b.y));
|
|
1621
1621
|
return;
|
|
1622
1622
|
}
|
|
1623
1623
|
const L = ue(b.x, b.y);
|
|
1624
1624
|
if (L) {
|
|
1625
|
-
(U = (
|
|
1625
|
+
(U = (ut = O.current).onEdgeDoubleClick) == null || U.call(ut, d, L);
|
|
1626
1626
|
return;
|
|
1627
1627
|
}
|
|
1628
|
-
const I = 1.5, h = a.getBoundingClientRect(), A = d.clientX - h.left, T = d.clientY - h.top, Y =
|
|
1629
|
-
Y.x = A - (A - Y.x) * I, Y.y = T - (T - Y.y) * I, Y.zoom = Math.min(
|
|
1628
|
+
const I = 1.5, h = a.getBoundingClientRect(), A = d.clientX - h.left, T = d.clientY - h.top, Y = pt.current;
|
|
1629
|
+
Y.x = A - (A - Y.x) * I, Y.y = T - (T - Y.y) * I, Y.zoom = Math.min(xt, Math.max(st, Y.zoom * I)), Ct(d);
|
|
1630
1630
|
};
|
|
1631
1631
|
return a.addEventListener("dblclick", x), () => a.removeEventListener("dblclick", x);
|
|
1632
|
-
}, [Qe,
|
|
1633
|
-
const a =
|
|
1632
|
+
}, [Qe, Ct, st, xt, lt, Tt, ue]), ht(() => {
|
|
1633
|
+
const a = mt.current;
|
|
1634
1634
|
if (!a) return;
|
|
1635
1635
|
const x = (d) => {
|
|
1636
|
-
var h, A, T, Y,
|
|
1637
|
-
const b =
|
|
1636
|
+
var h, A, T, Y, H, J;
|
|
1637
|
+
const b = lt(d.clientX, d.clientY), L = Tt(b.x, b.y);
|
|
1638
1638
|
if (L) {
|
|
1639
1639
|
(A = (h = O.current).onNodeContextMenu) == null || A.call(h, d, L);
|
|
1640
1640
|
return;
|
|
@@ -1644,32 +1644,32 @@ function Lr({
|
|
|
1644
1644
|
(Y = (T = O.current).onEdgeContextMenu) == null || Y.call(T, d, I);
|
|
1645
1645
|
return;
|
|
1646
1646
|
}
|
|
1647
|
-
(
|
|
1647
|
+
(J = (H = O.current).onPaneContextMenu) == null || J.call(H, d);
|
|
1648
1648
|
};
|
|
1649
1649
|
return a.addEventListener("contextmenu", x), () => a.removeEventListener("contextmenu", x);
|
|
1650
|
-
}, [
|
|
1651
|
-
const a =
|
|
1650
|
+
}, [lt, Tt, ue]), ht(() => {
|
|
1651
|
+
const a = mt.current;
|
|
1652
1652
|
if (!a) return;
|
|
1653
1653
|
let x = null, d = null;
|
|
1654
1654
|
const b = (h) => {
|
|
1655
|
-
var Y,
|
|
1656
|
-
(
|
|
1657
|
-
const A =
|
|
1658
|
-
if (T !== x && (x && ((
|
|
1659
|
-
const
|
|
1660
|
-
|
|
1655
|
+
var Y, H, J, ut, U, nt, vt, Mt, At, Xt, Ht, W, kt, V;
|
|
1656
|
+
(H = (Y = O.current).onPaneMouseMove) == null || H.call(Y, h);
|
|
1657
|
+
const A = lt(h.clientX, h.clientY), T = Tt(A.x, A.y);
|
|
1658
|
+
if (T !== x && (x && ((ut = (J = O.current).onNodeMouseLeave) == null || ut.call(J, h, x)), T && ((nt = (U = O.current).onNodeMouseEnter) == null || nt.call(U, h, T)), x = T), T && ((Mt = (vt = O.current).onNodeMouseMove) == null || Mt.call(vt, h, T)), !T) {
|
|
1659
|
+
const et = ue(A.x, A.y);
|
|
1660
|
+
et !== d && (d && ((Xt = (At = O.current).onEdgeMouseLeave) == null || Xt.call(At, h, d)), et && ((W = (Ht = O.current).onEdgeMouseEnter) == null || W.call(Ht, h, et)), d = et), et && ((V = (kt = O.current).onEdgeMouseMove) == null || V.call(kt, h, et));
|
|
1661
1661
|
}
|
|
1662
1662
|
}, L = (h) => {
|
|
1663
1663
|
var A, T;
|
|
1664
1664
|
return (T = (A = O.current).onPaneMouseEnter) == null ? void 0 : T.call(A, h);
|
|
1665
1665
|
}, I = (h) => {
|
|
1666
|
-
var A, T, Y,
|
|
1667
|
-
(T = (A = O.current).onPaneMouseLeave) == null || T.call(A, h), x && ((
|
|
1666
|
+
var A, T, Y, H, J, ut;
|
|
1667
|
+
(T = (A = O.current).onPaneMouseLeave) == null || T.call(A, h), x && ((H = (Y = O.current).onNodeMouseLeave) == null || H.call(Y, h, x), x = null), d && ((ut = (J = O.current).onEdgeMouseLeave) == null || ut.call(J, h, d), d = null);
|
|
1668
1668
|
};
|
|
1669
1669
|
return a.addEventListener("mousemove", b), a.addEventListener("mouseenter", L), a.addEventListener("mouseleave", I), () => {
|
|
1670
1670
|
a.removeEventListener("mousemove", b), a.removeEventListener("mouseenter", L), a.removeEventListener("mouseleave", I);
|
|
1671
1671
|
};
|
|
1672
|
-
}, [
|
|
1672
|
+
}, [lt, Tt, ue]), ht(() => {
|
|
1673
1673
|
const a = Array.isArray(ve) ? ve : [ve], x = async (d) => {
|
|
1674
1674
|
var b, L;
|
|
1675
1675
|
if (a.includes(d.key)) {
|
|
@@ -1678,7 +1678,7 @@ function Lr({
|
|
|
1678
1678
|
if (!I.length && !h.length || O.current.onBeforeDelete && !await O.current.onBeforeDelete({ nodes: I, edges: h }))
|
|
1679
1679
|
return;
|
|
1680
1680
|
const A = new Set(I.map((T) => T.id));
|
|
1681
|
-
if (I.length &&
|
|
1681
|
+
if (I.length && bt.current && (bt.current(I.map((T) => ({ id: T.id, type: "remove" }))), Dt.current)) {
|
|
1682
1682
|
const T = Pt.current.filter((Y) => A.has(Y.source) || A.has(Y.target));
|
|
1683
1683
|
T.length && Dt.current(T.map((Y) => ({ id: Y.id, type: "remove" })));
|
|
1684
1684
|
}
|
|
@@ -1686,9 +1686,9 @@ function Lr({
|
|
|
1686
1686
|
}
|
|
1687
1687
|
if ((d.ctrlKey || d.metaKey) && d.key === "a") {
|
|
1688
1688
|
if (d.target.tagName === "INPUT" || d.target.tagName === "TEXTAREA") return;
|
|
1689
|
-
if (d.preventDefault(),
|
|
1689
|
+
if (d.preventDefault(), bt.current) {
|
|
1690
1690
|
const I = Z.current.filter((h) => !h.selected).map((h) => ({ id: h.id, type: "select", selected: !0 }));
|
|
1691
|
-
I.length &&
|
|
1691
|
+
I.length && bt.current(I);
|
|
1692
1692
|
}
|
|
1693
1693
|
if (Dt.current) {
|
|
1694
1694
|
const I = Pt.current.filter((h) => !h.selected).map((h) => ({ id: h.id, type: "select", selected: !0 }));
|
|
@@ -1698,38 +1698,38 @@ function Lr({
|
|
|
1698
1698
|
};
|
|
1699
1699
|
return window.addEventListener("keydown", x), () => window.removeEventListener("keydown", x);
|
|
1700
1700
|
}, [ve]);
|
|
1701
|
-
const In =
|
|
1702
|
-
|
|
1701
|
+
const In = tt(!1);
|
|
1702
|
+
ht(() => {
|
|
1703
1703
|
var a, x;
|
|
1704
|
-
if (!In.current &&
|
|
1705
|
-
if (In.current = !0,
|
|
1706
|
-
const d =
|
|
1704
|
+
if (!In.current && Et.current) {
|
|
1705
|
+
if (In.current = !0, gt && Z.current.length > 0) {
|
|
1706
|
+
const d = mt.current;
|
|
1707
1707
|
if (d) {
|
|
1708
|
-
const b = d.getBoundingClientRect(), L = (
|
|
1709
|
-
|
|
1708
|
+
const b = d.getBoundingClientRect(), L = (ct == null ? void 0 : ct.padding) ?? 0.1, I = Mn(Z.current), h = Rn(I, b.width, b.height, L);
|
|
1709
|
+
ct != null && ct.maxZoom && (h.zoom = Math.min(h.zoom, ct.maxZoom)), ct != null && ct.minZoom && (h.zoom = Math.max(h.zoom, ct.minZoom)), pt.current = h, Ct();
|
|
1710
1710
|
}
|
|
1711
1711
|
}
|
|
1712
1712
|
(x = (a = O.current).onInit) == null || x.call(a, {
|
|
1713
1713
|
getNodes: () => [...Z.current],
|
|
1714
1714
|
getEdges: () => [...Pt.current],
|
|
1715
|
-
getViewport: () => ({ ...
|
|
1715
|
+
getViewport: () => ({ ...pt.current }),
|
|
1716
1716
|
fitView: (d = {}) => {
|
|
1717
|
-
const b =
|
|
1717
|
+
const b = mt.current;
|
|
1718
1718
|
if (!b || !Z.current.length) return;
|
|
1719
1719
|
const L = b.getBoundingClientRect(), I = Mn(Z.current), h = Rn(I, L.width, L.height, d.padding ?? 0.1);
|
|
1720
|
-
|
|
1720
|
+
pt.current = h, Ct();
|
|
1721
1721
|
}
|
|
1722
1722
|
});
|
|
1723
1723
|
}
|
|
1724
1724
|
});
|
|
1725
1725
|
const yr = F(() => {
|
|
1726
|
-
|
|
1727
|
-
}, [
|
|
1726
|
+
pt.current = { ...Nt }, Ct();
|
|
1727
|
+
}, [Ct, Nt]), gr = F((a) => {
|
|
1728
1728
|
var x;
|
|
1729
1729
|
if (a)
|
|
1730
1730
|
se.current.push(a);
|
|
1731
1731
|
else {
|
|
1732
|
-
const d =
|
|
1732
|
+
const d = pt.current, b = mt.current;
|
|
1733
1733
|
if (!b) return;
|
|
1734
1734
|
const L = b.getBoundingClientRect(), I = Math.round(-d.x / d.zoom + L.width / 2 / d.zoom), h = Math.round(-d.y / d.zoom + L.height / 2 / d.zoom);
|
|
1735
1735
|
se.current.push({
|
|
@@ -1741,10 +1741,10 @@ function Lr({
|
|
|
1741
1741
|
body: "Added at viewport center"
|
|
1742
1742
|
});
|
|
1743
1743
|
}
|
|
1744
|
-
(x =
|
|
1744
|
+
(x = Et.current) == null || x.postMessage({ type: "cards", data: { cards: [...se.current] } });
|
|
1745
1745
|
}, []), pr = F((a) => {
|
|
1746
1746
|
if (a.id || (a.id = "node-" + Date.now()), !a.position) {
|
|
1747
|
-
const x =
|
|
1747
|
+
const x = pt.current, d = mt.current;
|
|
1748
1748
|
if (!d) return;
|
|
1749
1749
|
const b = d.getBoundingClientRect();
|
|
1750
1750
|
a.position = {
|
|
@@ -1752,26 +1752,26 @@ function Lr({
|
|
|
1752
1752
|
y: Math.round(-x.y / x.zoom + b.height / 2 / x.zoom) - jt / 2
|
|
1753
1753
|
};
|
|
1754
1754
|
}
|
|
1755
|
-
a.data || (a.data = { label: a.id }),
|
|
1756
|
-
}, []), xr = F(() => ({ ...
|
|
1757
|
-
|
|
1758
|
-
}, [
|
|
1759
|
-
wrapRef:
|
|
1755
|
+
a.data || (a.data = { label: a.id }), bt.current && bt.current([{ type: "add", item: a }]);
|
|
1756
|
+
}, []), xr = F(() => ({ ...pt.current }), []), mr = F((a) => {
|
|
1757
|
+
pt.current = { ...pt.current, ...a }, Ct();
|
|
1758
|
+
}, [Ct]), vr = F((a) => lt(a.x, a.y), [lt]), $n = n, wr = St(() => ({
|
|
1759
|
+
wrapRef: mt,
|
|
1760
1760
|
canvasRef: Te,
|
|
1761
|
-
workerRef:
|
|
1762
|
-
cameraRef:
|
|
1761
|
+
workerRef: Et,
|
|
1762
|
+
cameraRef: pt,
|
|
1763
1763
|
nodesRef: Z,
|
|
1764
1764
|
edgesRef: Pt,
|
|
1765
1765
|
handleRegistryRef: yn,
|
|
1766
1766
|
syncNodesToWorker: Ft,
|
|
1767
|
-
onNodesChangeRef:
|
|
1767
|
+
onNodesChangeRef: bt,
|
|
1768
1768
|
onEdgesChangeRef: Dt,
|
|
1769
|
-
sendCamera:
|
|
1770
|
-
screenToWorld:
|
|
1769
|
+
sendCamera: Ct,
|
|
1770
|
+
screenToWorld: lt,
|
|
1771
1771
|
viewportListeners: Kt,
|
|
1772
1772
|
selectionListeners: he,
|
|
1773
|
-
zoomMin:
|
|
1774
|
-
zoomMax:
|
|
1773
|
+
zoomMin: st,
|
|
1774
|
+
zoomMax: xt,
|
|
1775
1775
|
snapToGrid: me,
|
|
1776
1776
|
snapGrid: de,
|
|
1777
1777
|
nodeExtent: oe,
|
|
@@ -1793,9 +1793,9 @@ function Lr({
|
|
|
1793
1793
|
get connection() {
|
|
1794
1794
|
return Ve;
|
|
1795
1795
|
}
|
|
1796
|
-
}), [e, n, $n, Be, Ve,
|
|
1796
|
+
}), [e, n, $n, Be, Ve, Ct, lt, Ft, Kt, he, st, xt, me, de, oe, be, fe]);
|
|
1797
1797
|
return {
|
|
1798
|
-
wrapRef:
|
|
1798
|
+
wrapRef: mt,
|
|
1799
1799
|
canvasRef: Te,
|
|
1800
1800
|
canvasReady: gn,
|
|
1801
1801
|
onPointerDown: dr,
|
|
@@ -1828,95 +1828,97 @@ function Ro() {
|
|
|
1828
1828
|
return qe(je);
|
|
1829
1829
|
}
|
|
1830
1830
|
function $r({ node: t, nodeType: e }) {
|
|
1831
|
-
var m, C,
|
|
1832
|
-
const n = yt(), r =
|
|
1833
|
-
|
|
1831
|
+
var m, C, z;
|
|
1832
|
+
const n = yt(), r = tt(null), s = t._absolutePosition || t.position, o = tt(null);
|
|
1833
|
+
ht(() => {
|
|
1834
1834
|
const M = r.current;
|
|
1835
1835
|
if (!M) return;
|
|
1836
|
-
const $ = new ResizeObserver((
|
|
1837
|
-
var
|
|
1838
|
-
const { width: E, height:
|
|
1839
|
-
if (E > 0 &&
|
|
1840
|
-
const v = n.nodesRef.current.find((P) => P.id === t.id),
|
|
1841
|
-
(Math.abs((
|
|
1842
|
-
{ id: t.id, type: "dimensions", dimensions: { width: E, height:
|
|
1836
|
+
const $ = new ResizeObserver((k) => {
|
|
1837
|
+
var D, g, f, p;
|
|
1838
|
+
const { width: E, height: _ } = k[0].contentRect;
|
|
1839
|
+
if (E > 0 && _ > 0) {
|
|
1840
|
+
const v = n.nodesRef.current.find((P) => P.id === t.id), N = (v == null ? void 0 : v.width) || ((D = v == null ? void 0 : v.measured) == null ? void 0 : D.width), w = (v == null ? void 0 : v.height) || ((g = v == null ? void 0 : v.measured) == null ? void 0 : g.height);
|
|
1841
|
+
(Math.abs((N || 0) - E) > 1 || Math.abs((w || 0) - _) > 1) && ((p = (f = n.onNodesChangeRef).current) == null || p.call(f, [
|
|
1842
|
+
{ id: t.id, type: "dimensions", dimensions: { width: E, height: _ }, setAttributes: !0 }
|
|
1843
1843
|
]));
|
|
1844
1844
|
}
|
|
1845
1845
|
});
|
|
1846
1846
|
return $.observe(M), () => $.disconnect();
|
|
1847
1847
|
}, [t.id, n]);
|
|
1848
1848
|
const i = F((M) => {
|
|
1849
|
-
var
|
|
1849
|
+
var B, q, X;
|
|
1850
1850
|
M.stopPropagation();
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1851
|
+
const $ = M.target.tagName;
|
|
1852
|
+
if ($ === "INPUT" || $ === "TEXTAREA" || $ === "SELECT" || $ === "BUTTON" || $ === "A" || M.target.isContentEditable) return;
|
|
1853
|
+
let k = M.target;
|
|
1854
|
+
for (; k && k !== r.current; ) {
|
|
1855
|
+
if ((B = k.classList) != null && B.contains("nodrag")) return;
|
|
1856
|
+
k = k.parentElement;
|
|
1855
1857
|
}
|
|
1856
1858
|
if (n.onNodesChangeRef.current) {
|
|
1857
|
-
const
|
|
1859
|
+
const K = [];
|
|
1858
1860
|
if (M.shiftKey)
|
|
1859
|
-
|
|
1861
|
+
K.push({ id: t.id, type: "select", selected: !t.selected });
|
|
1860
1862
|
else
|
|
1861
|
-
for (const
|
|
1862
|
-
|
|
1863
|
-
|
|
1863
|
+
for (const rt of n.nodesRef.current)
|
|
1864
|
+
rt.id === t.id && !rt.selected ? K.push({ id: rt.id, type: "select", selected: !0 }) : rt.id !== t.id && rt.selected && K.push({ id: rt.id, type: "select", selected: !1 });
|
|
1865
|
+
K.length && n.onNodesChangeRef.current(K);
|
|
1864
1866
|
}
|
|
1865
|
-
const
|
|
1866
|
-
if (!
|
|
1867
|
-
const
|
|
1867
|
+
const E = n.cameraRef.current, _ = n.wrapRef.current;
|
|
1868
|
+
if (!_) return;
|
|
1869
|
+
const D = _.getBoundingClientRect(), g = (M.clientX - D.left - E.x) / E.zoom, f = (M.clientY - D.top - E.y) / E.zoom, v = M.shiftKey && t.selected ? n.nodesRef.current.filter((K) => K.selected && K.id !== t.id).map((K) => ({ id: K.id, startPos: { ...K.position } })) : [];
|
|
1868
1870
|
o.current = {
|
|
1869
1871
|
startPos: { ...t.position },
|
|
1870
|
-
startMouse: { x:
|
|
1871
|
-
selectedStarts:
|
|
1872
|
+
startMouse: { x: g, y: f },
|
|
1873
|
+
selectedStarts: v
|
|
1872
1874
|
};
|
|
1873
|
-
const
|
|
1874
|
-
for (const
|
|
1875
|
-
|
|
1876
|
-
(
|
|
1875
|
+
const N = [{ id: t.id, type: "position", dragging: !0 }];
|
|
1876
|
+
for (const K of v)
|
|
1877
|
+
N.push({ id: K.id, type: "position", dragging: !0 });
|
|
1878
|
+
(X = (q = n.onNodesChangeRef).current) == null || X.call(q, N);
|
|
1877
1879
|
const w = r.current;
|
|
1878
1880
|
w && w.setPointerCapture(M.pointerId);
|
|
1879
|
-
const
|
|
1880
|
-
var
|
|
1881
|
+
const P = (K) => {
|
|
1882
|
+
var It, st, xt, Nt;
|
|
1881
1883
|
if (!o.current) return;
|
|
1882
|
-
const
|
|
1883
|
-
let
|
|
1884
|
-
if (n.snapToGrid && n.snapGrid && (
|
|
1885
|
-
x: n.snapGrid[0] * Math.round(
|
|
1886
|
-
y: n.snapGrid[1] * Math.round(
|
|
1884
|
+
const at = n.cameraRef.current, rt = _.getBoundingClientRect(), G = (K.clientX - rt.left - at.x) / at.zoom, j = (K.clientY - rt.top - at.y) / at.zoom, it = G - o.current.startMouse.x, dt = j - o.current.startMouse.y;
|
|
1885
|
+
let ot = { x: o.current.startPos.x + it, y: o.current.startPos.y + dt };
|
|
1886
|
+
if (n.snapToGrid && n.snapGrid && (ot = {
|
|
1887
|
+
x: n.snapGrid[0] * Math.round(ot.x / n.snapGrid[0]),
|
|
1888
|
+
y: n.snapGrid[1] * Math.round(ot.y / n.snapGrid[1])
|
|
1887
1889
|
}), t.parentId && t.extent === "parent") {
|
|
1888
|
-
const
|
|
1889
|
-
if (
|
|
1890
|
-
const
|
|
1891
|
-
|
|
1892
|
-
x: Math.max(0, Math.min(
|
|
1893
|
-
y: Math.max(0, Math.min(
|
|
1890
|
+
const gt = n.nodesRef.current.find((ct) => ct.id === t.parentId);
|
|
1891
|
+
if (gt) {
|
|
1892
|
+
const ct = gt.width || 160, zt = gt.height || 60, Rt = t.width || ((It = t.measured) == null ? void 0 : It.width) || 160, Lt = t.height || ((st = t.measured) == null ? void 0 : st.height) || 60;
|
|
1893
|
+
ot = {
|
|
1894
|
+
x: Math.max(0, Math.min(ot.x, ct - Rt)),
|
|
1895
|
+
y: Math.max(0, Math.min(ot.y, zt - Lt))
|
|
1894
1896
|
};
|
|
1895
1897
|
}
|
|
1896
1898
|
}
|
|
1897
|
-
const
|
|
1898
|
-
for (const
|
|
1899
|
-
let
|
|
1900
|
-
n.snapToGrid && n.snapGrid && (
|
|
1901
|
-
x: n.snapGrid[0] * Math.round(
|
|
1902
|
-
y: n.snapGrid[1] * Math.round(
|
|
1903
|
-
}),
|
|
1899
|
+
const ft = [{ id: t.id, type: "position", position: ot, dragging: !0 }];
|
|
1900
|
+
for (const gt of o.current.selectedStarts) {
|
|
1901
|
+
let ct = { x: gt.startPos.x + it, y: gt.startPos.y + dt };
|
|
1902
|
+
n.snapToGrid && n.snapGrid && (ct = {
|
|
1903
|
+
x: n.snapGrid[0] * Math.round(ct.x / n.snapGrid[0]),
|
|
1904
|
+
y: n.snapGrid[1] * Math.round(ct.y / n.snapGrid[1])
|
|
1905
|
+
}), ft.push({ id: gt.id, type: "position", position: ct, dragging: !0 });
|
|
1904
1906
|
}
|
|
1905
|
-
(
|
|
1906
|
-
},
|
|
1907
|
-
var
|
|
1907
|
+
(Nt = (xt = n.onNodesChangeRef).current) == null || Nt.call(xt, ft);
|
|
1908
|
+
}, R = (K) => {
|
|
1909
|
+
var rt, G;
|
|
1908
1910
|
if (!o.current) return;
|
|
1909
|
-
const
|
|
1910
|
-
for (const
|
|
1911
|
-
|
|
1912
|
-
(
|
|
1911
|
+
const at = [{ id: t.id, type: "position", dragging: !1 }];
|
|
1912
|
+
for (const j of o.current.selectedStarts)
|
|
1913
|
+
at.push({ id: j.id, type: "position", dragging: !1 });
|
|
1914
|
+
(G = (rt = n.onNodesChangeRef).current) == null || G.call(rt, at), o.current = null, w && w.releasePointerCapture(K.pointerId), w == null || w.removeEventListener("pointermove", P), w == null || w.removeEventListener("pointerup", R);
|
|
1913
1915
|
};
|
|
1914
|
-
w == null || w.addEventListener("pointermove",
|
|
1916
|
+
w == null || w.addEventListener("pointermove", P), w == null || w.addEventListener("pointerup", R);
|
|
1915
1917
|
}, [t, n]), c = F((M) => {
|
|
1916
|
-
var g, f, p, v,
|
|
1918
|
+
var g, f, p, v, N, w;
|
|
1917
1919
|
if (!t.selected) return;
|
|
1918
1920
|
const $ = M.shiftKey ? 10 : 1;
|
|
1919
|
-
let
|
|
1921
|
+
let k = 0, E = 0;
|
|
1920
1922
|
switch (M.key) {
|
|
1921
1923
|
case "ArrowUp":
|
|
1922
1924
|
E = -$;
|
|
@@ -1925,10 +1927,10 @@ function $r({ node: t, nodeType: e }) {
|
|
|
1925
1927
|
E = $;
|
|
1926
1928
|
break;
|
|
1927
1929
|
case "ArrowLeft":
|
|
1928
|
-
|
|
1930
|
+
k = -$;
|
|
1929
1931
|
break;
|
|
1930
1932
|
case "ArrowRight":
|
|
1931
|
-
|
|
1933
|
+
k = $;
|
|
1932
1934
|
break;
|
|
1933
1935
|
case "Escape":
|
|
1934
1936
|
(f = (g = n.onNodesChangeRef).current) == null || f.call(g, [{ id: t.id, type: "select", selected: !1 }]);
|
|
@@ -1941,10 +1943,10 @@ function $r({ node: t, nodeType: e }) {
|
|
|
1941
1943
|
return;
|
|
1942
1944
|
}
|
|
1943
1945
|
M.preventDefault();
|
|
1944
|
-
const
|
|
1946
|
+
const _ = { x: t.position.x + k, y: t.position.y + E }, D = [{ id: t.id, type: "position", position: _ }];
|
|
1945
1947
|
for (const P of n.nodesRef.current)
|
|
1946
|
-
P.selected && P.id !== t.id &&
|
|
1947
|
-
(
|
|
1948
|
+
P.selected && P.id !== t.id && D.push({ id: P.id, type: "position", position: { x: P.position.x + k, y: P.position.y + E } });
|
|
1949
|
+
(w = (N = n.onNodesChangeRef).current) == null || w.call(N, D);
|
|
1948
1950
|
}, [t, n]), u = t.width || ((m = t.measured) == null ? void 0 : m.width), l = t.height || ((C = t.measured) == null ? void 0 : C.height), y = !!(u && l);
|
|
1949
1951
|
return /* @__PURE__ */ S(je.Provider, { value: t.id, children: /* @__PURE__ */ S(
|
|
1950
1952
|
"div",
|
|
@@ -1965,7 +1967,7 @@ function $r({ node: t, nodeType: e }) {
|
|
|
1965
1967
|
"data-nodeid": t.id,
|
|
1966
1968
|
tabIndex: t.selectable !== !1 ? 0 : void 0,
|
|
1967
1969
|
role: "button",
|
|
1968
|
-
"aria-label": `Node ${((
|
|
1970
|
+
"aria-label": `Node ${((z = t.data) == null ? void 0 : z.label) || t.id}`,
|
|
1969
1971
|
"aria-selected": !!t.selected,
|
|
1970
1972
|
onPointerDown: i,
|
|
1971
1973
|
onKeyDown: c,
|
|
@@ -2054,35 +2056,35 @@ function Dn({ x: t, y: e, position: n, type: r, onPointerDown: s }) {
|
|
|
2054
2056
|
}
|
|
2055
2057
|
function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
2056
2058
|
var g, f, p;
|
|
2057
|
-
const s = yt(), [o, i] = Gt(null), c = F((v,
|
|
2058
|
-
var
|
|
2059
|
-
|
|
2059
|
+
const s = yt(), [o, i] = Gt(null), c = F((v, N, w, P) => {
|
|
2060
|
+
var rt;
|
|
2061
|
+
N.stopPropagation(), N.preventDefault();
|
|
2060
2062
|
const R = s.wrapRef.current;
|
|
2061
2063
|
if (!R) return;
|
|
2062
|
-
const B = v === "source" ? P :
|
|
2063
|
-
(
|
|
2064
|
+
const B = v === "source" ? P : w, q = v === "source" ? t.target : t.source;
|
|
2065
|
+
(rt = s.workerRef.current) == null || rt.postMessage({
|
|
2064
2066
|
type: "connecting",
|
|
2065
2067
|
data: { from: { x: B.x, y: B.y }, to: { x: B.x, y: B.y } }
|
|
2066
2068
|
});
|
|
2067
|
-
const
|
|
2068
|
-
var
|
|
2069
|
-
const j = s.cameraRef.current,
|
|
2070
|
-
(
|
|
2069
|
+
const X = R.getBoundingClientRect(), K = (G) => {
|
|
2070
|
+
var ot;
|
|
2071
|
+
const j = s.cameraRef.current, it = (G.clientX - X.left - j.x) / j.zoom, dt = (G.clientY - X.top - j.y) / j.zoom;
|
|
2072
|
+
(ot = s.workerRef.current) == null || ot.postMessage({
|
|
2071
2073
|
type: "connecting",
|
|
2072
|
-
data: { from: { x: B.x, y: B.y }, to: { x:
|
|
2074
|
+
data: { from: { x: B.x, y: B.y }, to: { x: it, y: dt } }
|
|
2073
2075
|
});
|
|
2074
|
-
},
|
|
2075
|
-
var
|
|
2076
|
-
const j = s.cameraRef.current,
|
|
2077
|
-
let
|
|
2078
|
-
const
|
|
2079
|
-
for (const
|
|
2080
|
-
if (
|
|
2081
|
-
const
|
|
2082
|
-
if (
|
|
2083
|
-
for (const [, Bt] of
|
|
2084
|
-
Bt.nodeId ===
|
|
2085
|
-
const Ie = ne.length > 0 ? ne :
|
|
2076
|
+
}, at = (G) => {
|
|
2077
|
+
var xt, Nt, gt, ct;
|
|
2078
|
+
const j = s.cameraRef.current, it = (G.clientX - X.left - j.x) / j.zoom, dt = (G.clientY - X.top - j.y) / j.zoom, ot = 20 / j.zoom;
|
|
2079
|
+
let ft = null, It = null;
|
|
2080
|
+
const st = (xt = s.handleRegistryRef) == null ? void 0 : xt.current;
|
|
2081
|
+
for (const zt of s.nodesRef.current) {
|
|
2082
|
+
if (zt.hidden) continue;
|
|
2083
|
+
const Rt = zt.width || On, Lt = zt.height || Qn, wt = zt._absolutePosition || zt.position, ne = [];
|
|
2084
|
+
if (st)
|
|
2085
|
+
for (const [, Bt] of st)
|
|
2086
|
+
Bt.nodeId === zt.id && ne.push(Bt);
|
|
2087
|
+
const Ie = ne.length > 0 ? ne : zt.handles || [
|
|
2086
2088
|
{ type: "target", position: "left" },
|
|
2087
2089
|
{ type: "source", position: "right" }
|
|
2088
2090
|
];
|
|
@@ -2093,37 +2095,37 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2093
2095
|
else
|
|
2094
2096
|
switch (Bt.position || (Bt.type === "source" ? "right" : "left")) {
|
|
2095
2097
|
case "top":
|
|
2096
|
-
Ot = wt.x +
|
|
2098
|
+
Ot = wt.x + Rt / 2, Yt = wt.y;
|
|
2097
2099
|
break;
|
|
2098
2100
|
case "bottom":
|
|
2099
|
-
Ot = wt.x +
|
|
2101
|
+
Ot = wt.x + Rt / 2, Yt = wt.y + Lt;
|
|
2100
2102
|
break;
|
|
2101
2103
|
case "left":
|
|
2102
|
-
Ot = wt.x, Yt = wt.y +
|
|
2104
|
+
Ot = wt.x, Yt = wt.y + Lt / 2;
|
|
2103
2105
|
break;
|
|
2104
2106
|
default:
|
|
2105
|
-
Ot = wt.x +
|
|
2107
|
+
Ot = wt.x + Rt, Yt = wt.y + Lt / 2;
|
|
2106
2108
|
break;
|
|
2107
2109
|
}
|
|
2108
|
-
if (Math.abs(
|
|
2109
|
-
|
|
2110
|
+
if (Math.abs(it - Ot) < ot && Math.abs(dt - Yt) < ot) {
|
|
2111
|
+
ft = zt, It = Bt.id || null;
|
|
2110
2112
|
break;
|
|
2111
2113
|
}
|
|
2112
2114
|
}
|
|
2113
|
-
if (
|
|
2115
|
+
if (ft) break;
|
|
2114
2116
|
}
|
|
2115
|
-
if (
|
|
2116
|
-
const
|
|
2117
|
-
(
|
|
2117
|
+
if (ft) {
|
|
2118
|
+
const zt = v === "source" ? { source: ft.id, target: q, sourceHandle: It, targetHandle: t.targetHandle } : { source: q, target: ft.id, sourceHandle: t.sourceHandle, targetHandle: It };
|
|
2119
|
+
(gt = (Nt = s.onEdgesChangeRef).current) == null || gt.call(Nt, [
|
|
2118
2120
|
{ id: t.id, type: "remove" },
|
|
2119
|
-
{ type: "add", item: { id: t.id, ...
|
|
2121
|
+
{ type: "add", item: { id: t.id, ...zt } }
|
|
2120
2122
|
]);
|
|
2121
2123
|
}
|
|
2122
|
-
(
|
|
2124
|
+
(ct = s.workerRef.current) == null || ct.postMessage({ type: "connecting", data: null }), R.removeEventListener("pointermove", K), R.removeEventListener("pointerup", at);
|
|
2123
2125
|
};
|
|
2124
|
-
R.addEventListener("pointermove",
|
|
2125
|
-
}, [t, s]), u = n.find((v) => v.id === t.source), l = n.find((v) => v.id === t.target), y = u && !!(u.width || (g = u.measured) != null && g.width), m = l && !!(l.width || (f = l.measured) != null && f.width), C = (p = s.handleRegistryRef) == null ? void 0 : p.current,
|
|
2126
|
-
return !
|
|
2126
|
+
R.addEventListener("pointermove", K), R.addEventListener("pointerup", at);
|
|
2127
|
+
}, [t, s]), u = n.find((v) => v.id === t.source), l = n.find((v) => v.id === t.target), y = u && !!(u.width || (g = u.measured) != null && g.width), m = l && !!(l.width || (f = l.measured) != null && f.width), C = (p = s.handleRegistryRef) == null ? void 0 : p.current, z = y ? Bn(u, "source", t.sourceHandle, C) : null, M = m ? Bn(l, "target", t.targetHandle, C) : null, $ = t.type === "bezier" || t.type === "simplebezier" || t.type === "default", k = s.routedEdges || s.edges, E = k == null ? void 0 : k.find((v) => v.id === t.id), _ = $ ? null : (E == null ? void 0 : E._routedPoints) || t._routedPoints || null, D = r !== !1 && t.reconnectable !== !1;
|
|
2128
|
+
return !z || !M ? null : /* @__PURE__ */ $t(
|
|
2127
2129
|
"g",
|
|
2128
2130
|
{
|
|
2129
2131
|
className: `ric-edge-wrapper ${t.selected ? "selected" : ""}`,
|
|
@@ -2137,11 +2139,11 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2137
2139
|
id: t.id,
|
|
2138
2140
|
source: t.source,
|
|
2139
2141
|
target: t.target,
|
|
2140
|
-
sourceX:
|
|
2141
|
-
sourceY:
|
|
2142
|
+
sourceX: z.x,
|
|
2143
|
+
sourceY: z.y,
|
|
2142
2144
|
targetX: M.x,
|
|
2143
2145
|
targetY: M.y,
|
|
2144
|
-
sourcePosition:
|
|
2146
|
+
sourcePosition: z.position,
|
|
2145
2147
|
targetPosition: M.position,
|
|
2146
2148
|
sourceHandleId: t.sourceHandle,
|
|
2147
2149
|
targetHandleId: t.targetHandle,
|
|
@@ -2153,18 +2155,18 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2153
2155
|
style: t.style,
|
|
2154
2156
|
selectable: t.selectable !== !1,
|
|
2155
2157
|
deletable: t.deletable !== !1,
|
|
2156
|
-
routedPoints:
|
|
2158
|
+
routedPoints: _
|
|
2157
2159
|
}
|
|
2158
2160
|
),
|
|
2159
|
-
|
|
2161
|
+
D && (o || t.selected) && /* @__PURE__ */ $t(Le, { children: [
|
|
2160
2162
|
/* @__PURE__ */ S(
|
|
2161
2163
|
Dn,
|
|
2162
2164
|
{
|
|
2163
|
-
x:
|
|
2164
|
-
y:
|
|
2165
|
-
position:
|
|
2165
|
+
x: z.x,
|
|
2166
|
+
y: z.y,
|
|
2167
|
+
position: z.position,
|
|
2166
2168
|
type: "source",
|
|
2167
|
-
onPointerDown: (v) => c("source", v,
|
|
2169
|
+
onPointerDown: (v) => c("source", v, z, M)
|
|
2168
2170
|
}
|
|
2169
2171
|
),
|
|
2170
2172
|
/* @__PURE__ */ S(
|
|
@@ -2174,7 +2176,7 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2174
2176
|
y: M.y,
|
|
2175
2177
|
position: M.position,
|
|
2176
2178
|
type: "target",
|
|
2177
|
-
onPointerDown: (v) => c("target", v,
|
|
2179
|
+
onPointerDown: (v) => c("target", v, z, M)
|
|
2178
2180
|
}
|
|
2179
2181
|
)
|
|
2180
2182
|
] })
|
|
@@ -2185,48 +2187,48 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2185
2187
|
const Dr = Zt(Br);
|
|
2186
2188
|
function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
|
|
2187
2189
|
var $;
|
|
2188
|
-
const n = yt(), [r, s] = Gt(null), o =
|
|
2189
|
-
if (
|
|
2190
|
-
const
|
|
2191
|
-
if (!
|
|
2192
|
-
let E = !1,
|
|
2193
|
-
const g = (
|
|
2194
|
-
|
|
2195
|
-
}, f = (
|
|
2196
|
-
|
|
2197
|
-
}, p = (
|
|
2198
|
-
if (!
|
|
2199
|
-
const P =
|
|
2190
|
+
const n = yt(), [r, s] = Gt(null), o = tt(null);
|
|
2191
|
+
if (ht(() => {
|
|
2192
|
+
const k = n.wrapRef.current;
|
|
2193
|
+
if (!k) return;
|
|
2194
|
+
let E = !1, _ = null, D = !1;
|
|
2195
|
+
const g = (w) => {
|
|
2196
|
+
w.key === t && (D = !0);
|
|
2197
|
+
}, f = (w) => {
|
|
2198
|
+
w.key === t && (D = !1);
|
|
2199
|
+
}, p = (w) => {
|
|
2200
|
+
if (!D) return;
|
|
2201
|
+
const P = w.target;
|
|
2200
2202
|
if (P.closest(".ric-node-wrapper") || P.closest(".ric-handle")) return;
|
|
2201
2203
|
E = !0;
|
|
2202
|
-
const R = n.cameraRef.current, B =
|
|
2203
|
-
|
|
2204
|
-
}, v = (
|
|
2205
|
-
if (!E || !
|
|
2206
|
-
const P = n.cameraRef.current, R =
|
|
2207
|
-
s({ startX:
|
|
2208
|
-
},
|
|
2209
|
-
var
|
|
2210
|
-
if (!E || !
|
|
2204
|
+
const R = n.cameraRef.current, B = k.getBoundingClientRect(), q = (w.clientX - B.left - R.x) / R.zoom, X = (w.clientY - B.top - R.y) / R.zoom;
|
|
2205
|
+
_ = { x: q, y: X }, s({ startX: q, startY: X, endX: q, endY: X }), w.stopPropagation();
|
|
2206
|
+
}, v = (w) => {
|
|
2207
|
+
if (!E || !_) return;
|
|
2208
|
+
const P = n.cameraRef.current, R = k.getBoundingClientRect(), B = (w.clientX - R.left - P.x) / P.zoom, q = (w.clientY - R.top - P.y) / P.zoom;
|
|
2209
|
+
s({ startX: _.x, startY: _.y, endX: B, endY: q });
|
|
2210
|
+
}, N = (w) => {
|
|
2211
|
+
var at, rt;
|
|
2212
|
+
if (!E || !_) return;
|
|
2211
2213
|
E = !1;
|
|
2212
|
-
const P = n.cameraRef.current, R =
|
|
2213
|
-
x: Math.min(
|
|
2214
|
-
y: Math.min(
|
|
2215
|
-
width: Math.abs(B -
|
|
2216
|
-
height: Math.abs(q -
|
|
2217
|
-
},
|
|
2214
|
+
const P = n.cameraRef.current, R = k.getBoundingClientRect(), B = (w.clientX - R.left - P.x) / P.zoom, q = (w.clientY - R.top - P.y) / P.zoom, X = {
|
|
2215
|
+
x: Math.min(_.x, B),
|
|
2216
|
+
y: Math.min(_.y, q),
|
|
2217
|
+
width: Math.abs(B - _.x),
|
|
2218
|
+
height: Math.abs(q - _.y)
|
|
2219
|
+
}, K = [];
|
|
2218
2220
|
for (const G of n.nodesRef.current) {
|
|
2219
|
-
const j = G._absolutePosition || G.position,
|
|
2220
|
-
let
|
|
2221
|
-
e === "full" ?
|
|
2221
|
+
const j = G._absolutePosition || G.position, it = G.width || 160, dt = G.height || 60;
|
|
2222
|
+
let ot;
|
|
2223
|
+
e === "full" ? ot = j.x >= X.x && j.y >= X.y && j.x + it <= X.x + X.width && j.y + dt <= X.y + X.height : ot = j.x + it > X.x && j.x < X.x + X.width && j.y + dt > X.y && j.y < X.y + X.height, K.push({ id: G.id, type: "select", selected: ot });
|
|
2222
2224
|
}
|
|
2223
|
-
|
|
2225
|
+
K.length && ((rt = (at = n.onNodesChangeRef).current) == null || rt.call(at, K)), _ = null, s(null);
|
|
2224
2226
|
};
|
|
2225
|
-
return
|
|
2226
|
-
|
|
2227
|
+
return k.addEventListener("pointerdown", p, !0), k.addEventListener("pointermove", v), k.addEventListener("pointerup", N), window.addEventListener("keydown", g), window.addEventListener("keyup", f), () => {
|
|
2228
|
+
k.removeEventListener("pointerdown", p, !0), k.removeEventListener("pointermove", v), k.removeEventListener("pointerup", N), window.removeEventListener("keydown", g), window.removeEventListener("keyup", f);
|
|
2227
2229
|
};
|
|
2228
2230
|
}, [n, t, e]), !r) return null;
|
|
2229
|
-
const i = (($ = n.cameraRef) == null ? void 0 : $.current) || { x: 0, y: 0, zoom: 1 }, c = Math.min(r.startX, r.endX), u = Math.min(r.startY, r.endY), l = Math.abs(r.endX - r.startX), y = Math.abs(r.endY - r.startY), m = c * i.zoom + i.x, C = u * i.zoom + i.y,
|
|
2231
|
+
const i = (($ = n.cameraRef) == null ? void 0 : $.current) || { x: 0, y: 0, zoom: 1 }, c = Math.min(r.startX, r.endX), u = Math.min(r.startY, r.endY), l = Math.abs(r.endX - r.startX), y = Math.abs(r.endY - r.startY), m = c * i.zoom + i.x, C = u * i.zoom + i.y, z = l * i.zoom, M = y * i.zoom;
|
|
2230
2232
|
return /* @__PURE__ */ S(
|
|
2231
2233
|
"div",
|
|
2232
2234
|
{
|
|
@@ -2236,7 +2238,7 @@ function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
|
|
|
2236
2238
|
position: "absolute",
|
|
2237
2239
|
left: m,
|
|
2238
2240
|
top: C,
|
|
2239
|
-
width:
|
|
2241
|
+
width: z,
|
|
2240
2242
|
height: M,
|
|
2241
2243
|
border: "1px dashed #3b82f6",
|
|
2242
2244
|
background: "rgba(59, 130, 246, 0.08)",
|
|
@@ -2247,7 +2249,7 @@ function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
|
|
|
2247
2249
|
);
|
|
2248
2250
|
}
|
|
2249
2251
|
Kn.displayName = "SelectionBox";
|
|
2250
|
-
const
|
|
2252
|
+
const Ar = Zt(Kn);
|
|
2251
2253
|
function Jn(t, e) {
|
|
2252
2254
|
var s, o, i, c;
|
|
2253
2255
|
const n = (s = t.handleRegistryRef) == null ? void 0 : s.current;
|
|
@@ -2263,12 +2265,12 @@ function Jn(t, e) {
|
|
|
2263
2265
|
]), (c = t.syncNodesToWorker) == null || c.call(t);
|
|
2264
2266
|
}
|
|
2265
2267
|
const vn = /* @__PURE__ */ new Set();
|
|
2266
|
-
function
|
|
2268
|
+
function An(t, e) {
|
|
2267
2269
|
vn.has(e) || (vn.add(e), queueMicrotask(() => {
|
|
2268
2270
|
vn.delete(e), Jn(t, e);
|
|
2269
2271
|
}));
|
|
2270
2272
|
}
|
|
2271
|
-
function
|
|
2273
|
+
function Hr(t, e) {
|
|
2272
2274
|
const n = t.closest(".ric-node-wrapper");
|
|
2273
2275
|
if (!n) return null;
|
|
2274
2276
|
const r = n.getBoundingClientRect(), s = t.getBoundingClientRect(), o = e || 1;
|
|
@@ -2290,128 +2292,128 @@ function on({
|
|
|
2290
2292
|
onConnect: l,
|
|
2291
2293
|
...y
|
|
2292
2294
|
}) {
|
|
2293
|
-
const m = qe(je), C = yt(),
|
|
2295
|
+
const m = qe(je), C = yt(), z = tt(null), M = tt(C);
|
|
2294
2296
|
M.current = C;
|
|
2295
2297
|
const $ = F(() => {
|
|
2296
|
-
var
|
|
2297
|
-
const
|
|
2298
|
-
if (!
|
|
2299
|
-
const g = M.current, f = (
|
|
2298
|
+
var w, P, R;
|
|
2299
|
+
const D = z.current;
|
|
2300
|
+
if (!D || !m) return;
|
|
2301
|
+
const g = M.current, f = (w = g.handleRegistryRef) == null ? void 0 : w.current;
|
|
2300
2302
|
if (!f) return;
|
|
2301
|
-
const p = `${m}__${n || t}`, v = (R = (P = g.cameraRef) == null ? void 0 : P.current) == null ? void 0 : R.zoom,
|
|
2302
|
-
if (
|
|
2303
|
-
const B = { nodeId: m, id: n || null, type: t, position: e, x:
|
|
2303
|
+
const p = `${m}__${n || t}`, v = (R = (P = g.cameraRef) == null ? void 0 : P.current) == null ? void 0 : R.zoom, N = Hr(D, v);
|
|
2304
|
+
if (N) {
|
|
2305
|
+
const B = { nodeId: m, id: n || null, type: t, position: e, x: N.x, y: N.y };
|
|
2304
2306
|
f.set(p, B);
|
|
2305
2307
|
}
|
|
2306
2308
|
}, [m, n, t, e]);
|
|
2307
2309
|
kr(() => {
|
|
2308
2310
|
$();
|
|
2309
|
-
}, [$]),
|
|
2311
|
+
}, [$]), ht(() => {
|
|
2310
2312
|
if (!m) return;
|
|
2311
|
-
const
|
|
2312
|
-
|
|
2313
|
-
const g =
|
|
2314
|
-
$(),
|
|
2313
|
+
const D = M.current;
|
|
2314
|
+
An(D, m);
|
|
2315
|
+
const g = z.current, f = g == null ? void 0 : g.closest(".ric-node-wrapper"), p = new ResizeObserver(() => {
|
|
2316
|
+
$(), An(M.current, m);
|
|
2315
2317
|
});
|
|
2316
2318
|
return f && p.observe(f), () => {
|
|
2317
2319
|
var P;
|
|
2318
2320
|
p.disconnect();
|
|
2319
|
-
const v = M.current,
|
|
2320
|
-
|
|
2321
|
+
const v = M.current, N = (P = v.handleRegistryRef) == null ? void 0 : P.current, w = `${m}__${n || t}`;
|
|
2322
|
+
N == null || N.delete(w), Jn(v, m);
|
|
2321
2323
|
};
|
|
2322
2324
|
}, [m, n, t, e, $]);
|
|
2323
|
-
const
|
|
2325
|
+
const k = F(() => {
|
|
2324
2326
|
var R;
|
|
2325
|
-
const
|
|
2327
|
+
const D = M.current, g = D.nodesRef.current.find((B) => B.id === m);
|
|
2326
2328
|
if (!g) return null;
|
|
2327
|
-
const f = g._absolutePosition || g.position, p = (R =
|
|
2328
|
-
if (
|
|
2329
|
-
return { x: f.x +
|
|
2330
|
-
const
|
|
2329
|
+
const f = g._absolutePosition || g.position, p = (R = D.handleRegistryRef) == null ? void 0 : R.current, v = `${m}__${n || t}`, N = p == null ? void 0 : p.get(v);
|
|
2330
|
+
if (N && N.x !== void 0 && N.y !== void 0)
|
|
2331
|
+
return { x: f.x + N.x, y: f.y + N.y };
|
|
2332
|
+
const w = g.width || 160, P = g.height || 60;
|
|
2331
2333
|
switch (e) {
|
|
2332
2334
|
case "top":
|
|
2333
|
-
return { x: f.x +
|
|
2335
|
+
return { x: f.x + w / 2, y: f.y };
|
|
2334
2336
|
case "bottom":
|
|
2335
|
-
return { x: f.x +
|
|
2337
|
+
return { x: f.x + w / 2, y: f.y + P };
|
|
2336
2338
|
case "left":
|
|
2337
2339
|
return { x: f.x, y: f.y + P / 2 };
|
|
2338
2340
|
default:
|
|
2339
|
-
return { x: f.x +
|
|
2341
|
+
return { x: f.x + w, y: f.y + P / 2 };
|
|
2340
2342
|
}
|
|
2341
|
-
}, [m, n, t, e]), E = F((
|
|
2343
|
+
}, [m, n, t, e]), E = F((D) => {
|
|
2342
2344
|
var q;
|
|
2343
2345
|
if (!r || !s) return;
|
|
2344
|
-
|
|
2346
|
+
D.stopPropagation(), D.preventDefault();
|
|
2345
2347
|
const g = M.current, f = g.cameraRef.current, p = g.wrapRef.current;
|
|
2346
2348
|
if (!p) return;
|
|
2347
|
-
const v = p.getBoundingClientRect(),
|
|
2348
|
-
if (!
|
|
2349
|
-
const
|
|
2349
|
+
const v = p.getBoundingClientRect(), N = k();
|
|
2350
|
+
if (!N) return;
|
|
2351
|
+
const w = N.x, P = N.y;
|
|
2350
2352
|
(q = g.workerRef.current) == null || q.postMessage({
|
|
2351
2353
|
type: "connecting",
|
|
2352
|
-
data: { from: { x:
|
|
2353
|
-
}), p.setPointerCapture(
|
|
2354
|
-
const R = (
|
|
2355
|
-
var
|
|
2356
|
-
const
|
|
2357
|
-
(
|
|
2354
|
+
data: { from: { x: w, y: P }, to: { x: w, y: P } }
|
|
2355
|
+
}), p.setPointerCapture(D.pointerId);
|
|
2356
|
+
const R = (X) => {
|
|
2357
|
+
var rt;
|
|
2358
|
+
const K = (X.clientX - v.left - f.x) / f.zoom, at = (X.clientY - v.top - f.y) / f.zoom;
|
|
2359
|
+
(rt = g.workerRef.current) == null || rt.postMessage({
|
|
2358
2360
|
type: "connecting",
|
|
2359
|
-
data: { from: { x:
|
|
2361
|
+
data: { from: { x: w, y: P }, to: { x: K, y: at } }
|
|
2360
2362
|
});
|
|
2361
|
-
}, B = (
|
|
2362
|
-
var
|
|
2363
|
-
const
|
|
2363
|
+
}, B = (X) => {
|
|
2364
|
+
var dt, ot, ft, It;
|
|
2365
|
+
const K = (X.clientX - v.left - f.x) / f.zoom, at = (X.clientY - v.top - f.y) / f.zoom, rt = 20 / f.zoom;
|
|
2364
2366
|
let G = null, j = null;
|
|
2365
|
-
const
|
|
2366
|
-
for (const
|
|
2367
|
-
if (
|
|
2368
|
-
const
|
|
2369
|
-
if (
|
|
2370
|
-
for (const [,
|
|
2371
|
-
|
|
2372
|
-
const
|
|
2367
|
+
const it = (dt = g.handleRegistryRef) == null ? void 0 : dt.current;
|
|
2368
|
+
for (const st of g.nodesRef.current) {
|
|
2369
|
+
if (st.id === m || st.hidden) continue;
|
|
2370
|
+
const xt = st.width || 160, Nt = st.height || 60, gt = st._absolutePosition || st.position, ct = [];
|
|
2371
|
+
if (it)
|
|
2372
|
+
for (const [, Rt] of it)
|
|
2373
|
+
Rt.nodeId === st.id && ct.push(Rt);
|
|
2374
|
+
const zt = ct.length > 0 ? ct : st.handles || [
|
|
2373
2375
|
{ type: "target", position: "left" },
|
|
2374
2376
|
{ type: "source", position: "right" }
|
|
2375
2377
|
];
|
|
2376
|
-
for (const
|
|
2377
|
-
let
|
|
2378
|
-
if (
|
|
2379
|
-
|
|
2378
|
+
for (const Rt of zt) {
|
|
2379
|
+
let Lt, wt;
|
|
2380
|
+
if (Rt.x !== void 0 && Rt.y !== void 0)
|
|
2381
|
+
Lt = gt.x + Rt.x, wt = gt.y + Rt.y;
|
|
2380
2382
|
else
|
|
2381
|
-
switch (
|
|
2383
|
+
switch (Rt.position || (Rt.type === "source" ? "right" : "left")) {
|
|
2382
2384
|
case "top":
|
|
2383
|
-
|
|
2385
|
+
Lt = gt.x + xt / 2, wt = gt.y;
|
|
2384
2386
|
break;
|
|
2385
2387
|
case "bottom":
|
|
2386
|
-
|
|
2388
|
+
Lt = gt.x + xt / 2, wt = gt.y + Nt;
|
|
2387
2389
|
break;
|
|
2388
2390
|
case "left":
|
|
2389
|
-
|
|
2391
|
+
Lt = gt.x, wt = gt.y + Nt / 2;
|
|
2390
2392
|
break;
|
|
2391
2393
|
default:
|
|
2392
|
-
|
|
2394
|
+
Lt = gt.x + xt, wt = gt.y + Nt / 2;
|
|
2393
2395
|
break;
|
|
2394
2396
|
}
|
|
2395
|
-
if (Math.abs(
|
|
2396
|
-
G =
|
|
2397
|
+
if (Math.abs(K - Lt) < rt && Math.abs(at - wt) < rt) {
|
|
2398
|
+
G = st, j = Rt.id || null;
|
|
2397
2399
|
break;
|
|
2398
2400
|
}
|
|
2399
2401
|
}
|
|
2400
2402
|
if (G) break;
|
|
2401
2403
|
}
|
|
2402
2404
|
if (G) {
|
|
2403
|
-
const
|
|
2405
|
+
const st = {
|
|
2404
2406
|
source: t === "source" ? m : G.id,
|
|
2405
2407
|
target: t === "source" ? G.id : m,
|
|
2406
2408
|
sourceHandle: t === "source" ? n || null : j,
|
|
2407
2409
|
targetHandle: t === "source" ? j : n || null
|
|
2408
2410
|
};
|
|
2409
|
-
(
|
|
2411
|
+
(ft = (ot = g.onEdgesChangeRef) == null ? void 0 : ot.current) == null || ft.call(ot, [{ type: "add", item: { id: `e-${st.source}-${st.target}`, ...st } }]);
|
|
2410
2412
|
}
|
|
2411
|
-
(
|
|
2413
|
+
(It = g.workerRef.current) == null || It.postMessage({ type: "connecting", data: null }), p.removeEventListener("pointermove", R), p.removeEventListener("pointerup", B);
|
|
2412
2414
|
};
|
|
2413
2415
|
p.addEventListener("pointermove", R), p.addEventListener("pointerup", B);
|
|
2414
|
-
}, [m, n, t, e, r, s,
|
|
2416
|
+
}, [m, n, t, e, r, s, k]), _ = {
|
|
2415
2417
|
top: { top: 0, left: "50%", transform: "translate(-50%, -50%)" },
|
|
2416
2418
|
bottom: { bottom: 0, left: "50%", transform: "translate(-50%, 50%)" },
|
|
2417
2419
|
left: { top: "50%", left: 0, transform: "translate(-50%, -50%)" },
|
|
@@ -2420,7 +2422,7 @@ function on({
|
|
|
2420
2422
|
return /* @__PURE__ */ S(
|
|
2421
2423
|
"div",
|
|
2422
2424
|
{
|
|
2423
|
-
ref:
|
|
2425
|
+
ref: z,
|
|
2424
2426
|
className: `ric-handle ric-handle-${e} ric-handle-${t} ${c}`,
|
|
2425
2427
|
"data-handleid": n || null,
|
|
2426
2428
|
"data-nodeid": m,
|
|
@@ -2437,7 +2439,7 @@ function on({
|
|
|
2437
2439
|
zIndex: 10,
|
|
2438
2440
|
cursor: r ? "crosshair" : "default",
|
|
2439
2441
|
boxSizing: "border-box",
|
|
2440
|
-
...
|
|
2442
|
+
..._,
|
|
2441
2443
|
...u
|
|
2442
2444
|
},
|
|
2443
2445
|
...y,
|
|
@@ -2454,7 +2456,7 @@ function ko({
|
|
|
2454
2456
|
hideSourceHandle: o = !1,
|
|
2455
2457
|
hideTargetHandle: i = !1
|
|
2456
2458
|
}) {
|
|
2457
|
-
return /* @__PURE__ */
|
|
2459
|
+
return /* @__PURE__ */ $t(
|
|
2458
2460
|
"div",
|
|
2459
2461
|
{
|
|
2460
2462
|
className: `ric-default-node${n ? " selected" : ""}`,
|
|
@@ -2483,7 +2485,7 @@ function _r({
|
|
|
2483
2485
|
sourcePosition: r = "right",
|
|
2484
2486
|
hideSourceHandle: s = !1
|
|
2485
2487
|
}) {
|
|
2486
|
-
return /* @__PURE__ */
|
|
2488
|
+
return /* @__PURE__ */ $t(
|
|
2487
2489
|
"div",
|
|
2488
2490
|
{
|
|
2489
2491
|
className: `ric-input-node${n ? " selected" : ""}`,
|
|
@@ -2512,7 +2514,7 @@ function Wr({
|
|
|
2512
2514
|
targetPosition: r = "left",
|
|
2513
2515
|
hideTargetHandle: s = !1
|
|
2514
2516
|
}) {
|
|
2515
|
-
return /* @__PURE__ */
|
|
2517
|
+
return /* @__PURE__ */ $t(
|
|
2516
2518
|
"div",
|
|
2517
2519
|
{
|
|
2518
2520
|
className: `ric-output-node${n ? " selected" : ""}`,
|
|
@@ -2576,10 +2578,10 @@ function Vn({
|
|
|
2576
2578
|
className: l = "",
|
|
2577
2579
|
...y
|
|
2578
2580
|
}) {
|
|
2579
|
-
const [m, C] = Gt({ x: 1, y: 0, width: 0, height: 0 }),
|
|
2580
|
-
return
|
|
2581
|
-
if (
|
|
2582
|
-
const M =
|
|
2581
|
+
const [m, C] = Gt({ x: 1, y: 0, width: 0, height: 0 }), z = tt(null);
|
|
2582
|
+
return ht(() => {
|
|
2583
|
+
if (z.current) {
|
|
2584
|
+
const M = z.current.getBBox();
|
|
2583
2585
|
C({
|
|
2584
2586
|
x: M.x,
|
|
2585
2587
|
y: M.y,
|
|
@@ -2587,7 +2589,7 @@ function Vn({
|
|
|
2587
2589
|
height: M.height
|
|
2588
2590
|
});
|
|
2589
2591
|
}
|
|
2590
|
-
}, [n]), n ? /* @__PURE__ */
|
|
2592
|
+
}, [n]), n ? /* @__PURE__ */ $t(
|
|
2591
2593
|
"g",
|
|
2592
2594
|
{
|
|
2593
2595
|
transform: `translate(${t - m.width / 2} ${e - m.height / 2})`,
|
|
@@ -2614,7 +2616,7 @@ function Vn({
|
|
|
2614
2616
|
className: "ric-edge-text",
|
|
2615
2617
|
y: m.height / 2,
|
|
2616
2618
|
dy: "0.3em",
|
|
2617
|
-
ref:
|
|
2619
|
+
ref: z,
|
|
2618
2620
|
style: r,
|
|
2619
2621
|
children: n
|
|
2620
2622
|
}
|
|
@@ -2626,7 +2628,7 @@ function Vn({
|
|
|
2626
2628
|
}
|
|
2627
2629
|
Vn.displayName = "EdgeText";
|
|
2628
2630
|
const Fr = Zt(Vn);
|
|
2629
|
-
function
|
|
2631
|
+
function Hn(t) {
|
|
2630
2632
|
return t != null && t !== "" && !isNaN(Number(t));
|
|
2631
2633
|
}
|
|
2632
2634
|
function un({
|
|
@@ -2643,11 +2645,11 @@ function un({
|
|
|
2643
2645
|
interactionWidth: y = 20,
|
|
2644
2646
|
style: m,
|
|
2645
2647
|
markerEnd: C,
|
|
2646
|
-
markerStart:
|
|
2648
|
+
markerStart: z,
|
|
2647
2649
|
className: M = "",
|
|
2648
2650
|
...$
|
|
2649
2651
|
}) {
|
|
2650
|
-
return /* @__PURE__ */
|
|
2652
|
+
return /* @__PURE__ */ $t(Le, { children: [
|
|
2651
2653
|
/* @__PURE__ */ S(
|
|
2652
2654
|
"path",
|
|
2653
2655
|
{
|
|
@@ -2659,7 +2661,7 @@ function un({
|
|
|
2659
2661
|
className: `ric-edge-path ${M}`,
|
|
2660
2662
|
style: m,
|
|
2661
2663
|
markerEnd: C,
|
|
2662
|
-
markerStart:
|
|
2664
|
+
markerStart: z,
|
|
2663
2665
|
...$
|
|
2664
2666
|
}
|
|
2665
2667
|
),
|
|
@@ -2674,7 +2676,7 @@ function un({
|
|
|
2674
2676
|
style: { pointerEvents: "stroke" }
|
|
2675
2677
|
}
|
|
2676
2678
|
) : null,
|
|
2677
|
-
s &&
|
|
2679
|
+
s && Hn(n) && Hn(r) ? /* @__PURE__ */ S(
|
|
2678
2680
|
Fr,
|
|
2679
2681
|
{
|
|
2680
2682
|
x: n,
|
|
@@ -2717,61 +2719,61 @@ const tr = Zt(function({
|
|
|
2717
2719
|
labelShowBg: y,
|
|
2718
2720
|
labelBgStyle: m,
|
|
2719
2721
|
labelBgPadding: C,
|
|
2720
|
-
labelBgBorderRadius:
|
|
2722
|
+
labelBgBorderRadius: z,
|
|
2721
2723
|
style: M,
|
|
2722
2724
|
markerEnd: $,
|
|
2723
|
-
markerStart:
|
|
2725
|
+
markerStart: k,
|
|
2724
2726
|
interactionWidth: E
|
|
2725
2727
|
}) {
|
|
2726
|
-
let
|
|
2727
|
-
const f = _n(n, r, i), p = _n(s, o, c), v = Math.abs(p.x - f.x),
|
|
2728
|
-
let
|
|
2728
|
+
let _, D, g;
|
|
2729
|
+
const f = _n(n, r, i), p = _n(s, o, c), v = Math.abs(p.x - f.x), N = Math.max(50, v * 0.5);
|
|
2730
|
+
let w, P, R, B;
|
|
2729
2731
|
switch (i) {
|
|
2730
2732
|
case "left":
|
|
2731
|
-
|
|
2733
|
+
w = f.x - N, P = f.y;
|
|
2732
2734
|
break;
|
|
2733
2735
|
case "top":
|
|
2734
|
-
|
|
2736
|
+
w = f.x, P = f.y - N;
|
|
2735
2737
|
break;
|
|
2736
2738
|
case "bottom":
|
|
2737
|
-
|
|
2739
|
+
w = f.x, P = f.y + N;
|
|
2738
2740
|
break;
|
|
2739
2741
|
default:
|
|
2740
|
-
|
|
2742
|
+
w = f.x + N, P = f.y;
|
|
2741
2743
|
break;
|
|
2742
2744
|
}
|
|
2743
2745
|
switch (c) {
|
|
2744
2746
|
case "right":
|
|
2745
|
-
R = p.x +
|
|
2747
|
+
R = p.x + N, B = p.y;
|
|
2746
2748
|
break;
|
|
2747
2749
|
case "top":
|
|
2748
|
-
R = p.x, B = p.y -
|
|
2750
|
+
R = p.x, B = p.y - N;
|
|
2749
2751
|
break;
|
|
2750
2752
|
case "bottom":
|
|
2751
|
-
R = p.x, B = p.y +
|
|
2753
|
+
R = p.x, B = p.y + N;
|
|
2752
2754
|
break;
|
|
2753
2755
|
default:
|
|
2754
|
-
R = p.x -
|
|
2756
|
+
R = p.x - N, B = p.y;
|
|
2755
2757
|
break;
|
|
2756
2758
|
}
|
|
2757
|
-
|
|
2758
|
-
const q = 0.5,
|
|
2759
|
-
return
|
|
2759
|
+
_ = `M ${n},${r} L ${f.x},${f.y} C ${w},${P} ${R},${B} ${p.x},${p.y} L ${s},${o}`;
|
|
2760
|
+
const q = 0.5, X = 0.5;
|
|
2761
|
+
return D = X * X * X * f.x + 3 * X * X * q * w + 3 * X * q * q * R + q * q * q * p.x, g = X * X * X * f.y + 3 * X * X * q * P + 3 * X * q * q * B + q * q * q * p.y, /* @__PURE__ */ S(
|
|
2760
2762
|
un,
|
|
2761
2763
|
{
|
|
2762
2764
|
id: e,
|
|
2763
|
-
path:
|
|
2764
|
-
labelX:
|
|
2765
|
+
path: _,
|
|
2766
|
+
labelX: D,
|
|
2765
2767
|
labelY: g,
|
|
2766
2768
|
label: u,
|
|
2767
2769
|
labelStyle: l,
|
|
2768
2770
|
labelShowBg: y,
|
|
2769
2771
|
labelBgStyle: m,
|
|
2770
2772
|
labelBgPadding: C,
|
|
2771
|
-
labelBgBorderRadius:
|
|
2773
|
+
labelBgBorderRadius: z,
|
|
2772
2774
|
style: M,
|
|
2773
2775
|
markerEnd: $,
|
|
2774
|
-
markerStart:
|
|
2776
|
+
markerStart: k,
|
|
2775
2777
|
interactionWidth: E
|
|
2776
2778
|
}
|
|
2777
2779
|
);
|
|
@@ -2791,7 +2793,7 @@ function nr({
|
|
|
2791
2793
|
curvature: i = 0.25
|
|
2792
2794
|
}) {
|
|
2793
2795
|
const c = Math.abs(n - t), u = Math.abs(r - e), l = Math.sqrt(c * c + u * u), y = Math.max(l * i, 50);
|
|
2794
|
-
let m, C,
|
|
2796
|
+
let m, C, z, M;
|
|
2795
2797
|
switch (s) {
|
|
2796
2798
|
case "top":
|
|
2797
2799
|
m = t, C = e - y;
|
|
@@ -2808,20 +2810,20 @@ function nr({
|
|
|
2808
2810
|
}
|
|
2809
2811
|
switch (o) {
|
|
2810
2812
|
case "top":
|
|
2811
|
-
|
|
2813
|
+
z = n, M = r - y;
|
|
2812
2814
|
break;
|
|
2813
2815
|
case "bottom":
|
|
2814
|
-
|
|
2816
|
+
z = n, M = r + y;
|
|
2815
2817
|
break;
|
|
2816
2818
|
case "right":
|
|
2817
|
-
|
|
2819
|
+
z = n + y, M = r;
|
|
2818
2820
|
break;
|
|
2819
2821
|
default:
|
|
2820
|
-
|
|
2822
|
+
z = n - y, M = r;
|
|
2821
2823
|
break;
|
|
2822
2824
|
}
|
|
2823
|
-
const $ = `M ${t},${e} C ${m},${C} ${
|
|
2824
|
-
return [$,
|
|
2825
|
+
const $ = `M ${t},${e} C ${m},${C} ${z},${M} ${n},${r}`, k = 0.5, E = 1 - k, _ = E * E * E * t + 3 * E * E * k * m + 3 * E * k * k * z + k * k * k * n, D = E * E * E * e + 3 * E * E * k * C + 3 * E * k * k * M + k * k * k * r;
|
|
2826
|
+
return [$, _, D, 0, 0];
|
|
2825
2827
|
}
|
|
2826
2828
|
function rr({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
|
|
2827
2829
|
const s = Math.abs(n - t), o = Math.max(s * 0.5, 50), i = t + o, c = n - o, u = `M ${t},${e} C ${i},${e} ${c},${r} ${n},${r}`, l = 0.5, y = 0.5, m = y * y * y * t + 3 * y * y * l * i + 3 * y * l * l * c + l * l * l * n, C = y * y * y * e + 3 * y * y * l * e + 3 * y * l * l * r + l * l * l * r;
|
|
@@ -2841,8 +2843,8 @@ function kn({
|
|
|
2841
2843
|
if (u) {
|
|
2842
2844
|
if (Math.abs(r - e) < 1)
|
|
2843
2845
|
return [`M ${t},${e} L ${n},${r}`, (t + n) / 2, e, 0, 0];
|
|
2844
|
-
const
|
|
2845
|
-
return [`M ${t},${e} L ${
|
|
2846
|
+
const z = (t + n) / 2, M = r > e ? 1 : -1;
|
|
2847
|
+
return [`M ${t},${e} L ${z - l},${e} Q ${z},${e} ${z},${e + M * l} L ${z},${r - M * l} Q ${z},${r} ${z + (n > z ? l : -l)},${r} L ${n},${r}`, z, (e + r) / 2, 0, 0];
|
|
2846
2848
|
}
|
|
2847
2849
|
const y = (e + r) / 2, m = n > t ? 1 : -1;
|
|
2848
2850
|
return [`M ${t},${e} L ${t},${y - l} Q ${t},${y} ${t + m * l},${y} L ${n - m * l},${y} Q ${n},${y} ${n},${y + (r > y ? l : -l)} L ${n},${r}`, (t + n) / 2, y, 0, 0];
|
|
@@ -2907,11 +2909,11 @@ function Yr(t, e, n, r, s, o, i, c) {
|
|
|
2907
2909
|
if (l <= s || u >= s + i || m <= o || y >= o + c) return !1;
|
|
2908
2910
|
const C = 0.5;
|
|
2909
2911
|
if (t > s + C && t < s + i - C && e > o + C && e < o + c - C || n > s + C && n < s + i - C && r > o + C && r < o + c - C) return !0;
|
|
2910
|
-
const
|
|
2911
|
-
if (
|
|
2912
|
+
const z = (t + n) / 2, M = (e + r) / 2;
|
|
2913
|
+
if (z > s + C && z < s + i - C && M > o + C && M < o + c - C) return !0;
|
|
2912
2914
|
const $ = [[s, o], [s + i, o], [s + i, o + c], [s, o + c]];
|
|
2913
|
-
for (let
|
|
2914
|
-
if (Ur(t, e, n, r, $[
|
|
2915
|
+
for (let k = 0; k < 4; k++)
|
|
2916
|
+
if (Ur(t, e, n, r, $[k][0], $[k][1], $[(k + 1) % 4][0], $[(k + 1) % 4][1])) return !0;
|
|
2915
2917
|
return !1;
|
|
2916
2918
|
}
|
|
2917
2919
|
function Ur(t, e, n, r, s, o, i, c) {
|
|
@@ -2963,37 +2965,37 @@ function sr(t, e, n) {
|
|
|
2963
2965
|
const i = [...r].sort((R, B) => R - B), c = [...s].sort((R, B) => R - B), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
2964
2966
|
for (let R = 0; R < i.length; R++) u.set(i[R], R);
|
|
2965
2967
|
for (let R = 0; R < c.length; R++) l.set(c[R], R);
|
|
2966
|
-
const y = i.length, m = c.length, C = (R, B) => B * y + R,
|
|
2967
|
-
if (
|
|
2968
|
-
const E = C(
|
|
2969
|
-
|
|
2970
|
-
const
|
|
2971
|
-
for (;
|
|
2968
|
+
const y = i.length, m = c.length, C = (R, B) => B * y + R, z = u.get(t.x), M = l.get(t.y), $ = u.get(e.x), k = l.get(e.y);
|
|
2969
|
+
if (z === void 0 || M === void 0 || $ === void 0 || k === void 0) return null;
|
|
2970
|
+
const E = C(z, M), _ = C($, k), D = new Float64Array(y * m).fill(1 / 0), g = new Float64Array(y * m).fill(1 / 0), f = new Int32Array(y * m).fill(-1), p = new Int8Array(y * m).fill(-1), v = new Uint8Array(y * m);
|
|
2971
|
+
D[E] = 0, g[E] = Math.abs(i[$] - t.x) + Math.abs(c[k] - t.y);
|
|
2972
|
+
const N = [E], w = 15, P = [[1, 0], [-1, 0], [0, 1], [0, -1]];
|
|
2973
|
+
for (; N.length > 0; ) {
|
|
2972
2974
|
let R = 0;
|
|
2973
|
-
for (let G = 1; G <
|
|
2974
|
-
g[
|
|
2975
|
-
const B =
|
|
2976
|
-
if (
|
|
2975
|
+
for (let G = 1; G < N.length; G++)
|
|
2976
|
+
g[N[G]] < g[N[R]] && (R = G);
|
|
2977
|
+
const B = N[R];
|
|
2978
|
+
if (N[R] = N[N.length - 1], N.pop(), B === _) {
|
|
2977
2979
|
const G = [];
|
|
2978
|
-
let j =
|
|
2980
|
+
let j = _;
|
|
2979
2981
|
for (; j !== -1 && j !== E; ) {
|
|
2980
|
-
const
|
|
2981
|
-
G.unshift({ x: i[
|
|
2982
|
+
const it = j / y | 0, dt = j % y;
|
|
2983
|
+
G.unshift({ x: i[dt], y: c[it] }), j = f[j];
|
|
2982
2984
|
}
|
|
2983
2985
|
return G.unshift({ x: t.x, y: t.y }), jr(G, n);
|
|
2984
2986
|
}
|
|
2985
2987
|
if (v[B]) continue;
|
|
2986
2988
|
v[B] = 1;
|
|
2987
|
-
const q = B / y | 0,
|
|
2989
|
+
const q = B / y | 0, X = B % y, K = i[X], at = c[q], rt = p[B];
|
|
2988
2990
|
for (let G = 0; G < 4; G++) {
|
|
2989
|
-
const j =
|
|
2990
|
-
if (j < 0 || j >= y ||
|
|
2991
|
-
const
|
|
2992
|
-
if (v[
|
|
2993
|
-
const
|
|
2994
|
-
if (qr(
|
|
2995
|
-
const
|
|
2996
|
-
|
|
2991
|
+
const j = X + P[G][0], it = q + P[G][1];
|
|
2992
|
+
if (j < 0 || j >= y || it < 0 || it >= m) continue;
|
|
2993
|
+
const dt = C(j, it);
|
|
2994
|
+
if (v[dt]) continue;
|
|
2995
|
+
const ot = i[j], ft = c[it];
|
|
2996
|
+
if (qr(ot, ft, n) || !zn(K, at, ot, ft, n)) continue;
|
|
2997
|
+
const It = Math.abs(ot - K) + Math.abs(ft - at), st = rt >= 0 && rt !== G ? w : 0, xt = D[B] + It + st;
|
|
2998
|
+
xt < D[dt] && (f[dt] = B, p[dt] = G, D[dt] = xt, g[dt] = xt + Math.abs(i[$] - ot) + Math.abs(c[k] - ft), N.push(dt));
|
|
2997
2999
|
}
|
|
2998
3000
|
}
|
|
2999
3001
|
return null;
|
|
@@ -3073,8 +3075,8 @@ function En(t, e = 6, n = !1) {
|
|
|
3073
3075
|
for (let o = 1; o < t.length - 1; o++) {
|
|
3074
3076
|
const i = t[o - 1], c = t[o], u = t[o + 1], l = Math.abs(c.x - i.x) + Math.abs(c.y - i.y), y = Math.abs(u.x - c.x) + Math.abs(u.y - c.y), m = Math.min(r, l / 2, y / 2);
|
|
3075
3077
|
if (m > 0.5) {
|
|
3076
|
-
const C = c.x - i.x,
|
|
3077
|
-
s += ` L ${c.x - C /
|
|
3078
|
+
const C = c.x - i.x, z = c.y - i.y, M = u.x - c.x, $ = u.y - c.y, k = Math.sqrt(C * C + z * z) || 1, E = Math.sqrt(M * M + $ * $) || 1;
|
|
3079
|
+
s += ` L ${c.x - C / k * m},${c.y - z / k * m}`, s += ` Q ${c.x},${c.y} ${c.x + M / E * m},${c.y + $ / E * m}`;
|
|
3078
3080
|
} else
|
|
3079
3081
|
s += ` L ${c.x},${c.y}`;
|
|
3080
3082
|
}
|
|
@@ -3117,15 +3119,15 @@ function No(t, e) {
|
|
|
3117
3119
|
const n = {};
|
|
3118
3120
|
for (const o of t) n[o.id] = o;
|
|
3119
3121
|
const r = or(t, null), s = e.map((o) => {
|
|
3120
|
-
var p, v,
|
|
3122
|
+
var p, v, N, w;
|
|
3121
3123
|
const i = o.type || "default";
|
|
3122
3124
|
if (i === "bezier" || i === "simplebezier" || i === "default") return o;
|
|
3123
3125
|
const c = n[o.source], u = n[o.target];
|
|
3124
3126
|
if (!c || !u || c.hidden || u.hidden) return o;
|
|
3125
|
-
const l = Wn(c, "source", o.sourceHandle), y = Wn(u, "target", o.targetHandle), m = ln(l, cn), C = ln(y, cn),
|
|
3126
|
-
M.push({ id: o.source, x: $.x -
|
|
3127
|
-
const
|
|
3128
|
-
if (M.push({ id: o.target, x:
|
|
3127
|
+
const l = Wn(c, "source", o.sourceHandle), y = Wn(u, "target", o.targetHandle), m = ln(l, cn), C = ln(y, cn), z = 5, M = r.filter((P) => P.id !== o.source && P.id !== o.target), $ = c._absolutePosition || c.position, k = c.width || ((p = c.measured) == null ? void 0 : p.width) || sn, E = c.height || ((v = c.measured) == null ? void 0 : v.height) || an;
|
|
3128
|
+
M.push({ id: o.source, x: $.x - z, y: $.y - z, w: k + 2 * z, h: E + 2 * z });
|
|
3129
|
+
const _ = u._absolutePosition || u.position, D = u.width || ((N = u.measured) == null ? void 0 : N.width) || sn, g = u.height || ((w = u.measured) == null ? void 0 : w.height) || an;
|
|
3130
|
+
if (M.push({ id: o.target, x: _.x - z, y: _.y - z, w: D + 2 * z, h: g + 2 * z }), M.length === 0) return o;
|
|
3129
3131
|
const f = sr(m, C, M);
|
|
3130
3132
|
return f && f.length >= 2 ? (f.unshift({ x: l.x, y: l.y }), f.push({ x: y.x, y: y.y }), { ...o, _routedPoints: f }) : o;
|
|
3131
3133
|
});
|
|
@@ -3134,8 +3136,8 @@ function No(t, e) {
|
|
|
3134
3136
|
function Lo(t, e, n, r, s, o, i, c) {
|
|
3135
3137
|
const u = or(i, c ? new Set(c) : null);
|
|
3136
3138
|
if (u.length === 0) return null;
|
|
3137
|
-
const l = { x: t, y: e, dir: s || "right" }, y = { x: n, y: r, dir: o || "left" }, m = ln(l, cn), C = ln(y, cn),
|
|
3138
|
-
return
|
|
3139
|
+
const l = { x: t, y: e, dir: s || "right" }, y = { x: n, y: r, dir: o || "left" }, m = ln(l, cn), C = ln(y, cn), z = sr(m, C, u);
|
|
3140
|
+
return z && z.length >= 2 ? (z.unshift({ x: l.x, y: l.y }), z.push({ x: y.x, y: y.y }), z) : null;
|
|
3139
3141
|
}
|
|
3140
3142
|
const ir = Zt(function({
|
|
3141
3143
|
id: e,
|
|
@@ -3150,25 +3152,25 @@ const ir = Zt(function({
|
|
|
3150
3152
|
labelBgPadding: y,
|
|
3151
3153
|
labelBgBorderRadius: m,
|
|
3152
3154
|
style: C,
|
|
3153
|
-
markerEnd:
|
|
3155
|
+
markerEnd: z,
|
|
3154
3156
|
markerStart: M,
|
|
3155
3157
|
interactionWidth: $,
|
|
3156
|
-
routedPoints:
|
|
3158
|
+
routedPoints: k
|
|
3157
3159
|
}) {
|
|
3158
|
-
let E,
|
|
3159
|
-
if (
|
|
3160
|
-
E = En(
|
|
3161
|
-
const g = Cn(
|
|
3162
|
-
|
|
3160
|
+
let E, _, D;
|
|
3161
|
+
if (k && k.length >= 2) {
|
|
3162
|
+
E = En(k);
|
|
3163
|
+
const g = Cn(k);
|
|
3164
|
+
_ = g.x, D = g.y;
|
|
3163
3165
|
} else
|
|
3164
|
-
[E,
|
|
3166
|
+
[E, _, D] = er({ sourceX: n, sourceY: r, targetX: s, targetY: o });
|
|
3165
3167
|
return /* @__PURE__ */ S(
|
|
3166
3168
|
un,
|
|
3167
3169
|
{
|
|
3168
3170
|
id: e,
|
|
3169
3171
|
path: E,
|
|
3170
|
-
labelX:
|
|
3171
|
-
labelY:
|
|
3172
|
+
labelX: _,
|
|
3173
|
+
labelY: D,
|
|
3172
3174
|
label: i,
|
|
3173
3175
|
labelStyle: c,
|
|
3174
3176
|
labelShowBg: u,
|
|
@@ -3176,7 +3178,7 @@ const ir = Zt(function({
|
|
|
3176
3178
|
labelBgPadding: y,
|
|
3177
3179
|
labelBgBorderRadius: m,
|
|
3178
3180
|
style: C,
|
|
3179
|
-
markerEnd:
|
|
3181
|
+
markerEnd: z,
|
|
3180
3182
|
markerStart: M,
|
|
3181
3183
|
interactionWidth: $
|
|
3182
3184
|
}
|
|
@@ -3196,18 +3198,18 @@ const ar = Zt(function({
|
|
|
3196
3198
|
labelShowBg: y,
|
|
3197
3199
|
labelBgStyle: m,
|
|
3198
3200
|
labelBgPadding: C,
|
|
3199
|
-
labelBgBorderRadius:
|
|
3201
|
+
labelBgBorderRadius: z,
|
|
3200
3202
|
style: M,
|
|
3201
3203
|
markerEnd: $,
|
|
3202
|
-
markerStart:
|
|
3204
|
+
markerStart: k,
|
|
3203
3205
|
pathOptions: E,
|
|
3204
|
-
interactionWidth:
|
|
3205
|
-
routedPoints:
|
|
3206
|
+
interactionWidth: _,
|
|
3207
|
+
routedPoints: D
|
|
3206
3208
|
}) {
|
|
3207
3209
|
let g, f, p;
|
|
3208
|
-
if (
|
|
3209
|
-
g = En(
|
|
3210
|
-
const v = Cn(
|
|
3210
|
+
if (D && D.length >= 2) {
|
|
3211
|
+
g = En(D);
|
|
3212
|
+
const v = Cn(D);
|
|
3211
3213
|
f = v.x, p = v.y;
|
|
3212
3214
|
} else
|
|
3213
3215
|
[g, f, p] = kn({
|
|
@@ -3232,11 +3234,11 @@ const ar = Zt(function({
|
|
|
3232
3234
|
labelShowBg: y,
|
|
3233
3235
|
labelBgStyle: m,
|
|
3234
3236
|
labelBgPadding: C,
|
|
3235
|
-
labelBgBorderRadius:
|
|
3237
|
+
labelBgBorderRadius: z,
|
|
3236
3238
|
style: M,
|
|
3237
3239
|
markerEnd: $,
|
|
3238
|
-
markerStart:
|
|
3239
|
-
interactionWidth:
|
|
3240
|
+
markerStart: k,
|
|
3241
|
+
interactionWidth: _
|
|
3240
3242
|
}
|
|
3241
3243
|
);
|
|
3242
3244
|
});
|
|
@@ -3266,20 +3268,20 @@ const cr = Zt(function({
|
|
|
3266
3268
|
labelShowBg: y,
|
|
3267
3269
|
labelBgStyle: m,
|
|
3268
3270
|
labelBgPadding: C,
|
|
3269
|
-
labelBgBorderRadius:
|
|
3271
|
+
labelBgBorderRadius: z,
|
|
3270
3272
|
style: M,
|
|
3271
3273
|
markerEnd: $,
|
|
3272
|
-
markerStart:
|
|
3274
|
+
markerStart: k,
|
|
3273
3275
|
interactionWidth: E,
|
|
3274
|
-
routedPoints:
|
|
3276
|
+
routedPoints: _
|
|
3275
3277
|
}) {
|
|
3276
|
-
let
|
|
3277
|
-
if (
|
|
3278
|
-
|
|
3279
|
-
const p = Cn(
|
|
3278
|
+
let D, g, f;
|
|
3279
|
+
if (_ && _.length >= 2) {
|
|
3280
|
+
D = En(_);
|
|
3281
|
+
const p = Cn(_);
|
|
3280
3282
|
g = p.x, f = p.y;
|
|
3281
3283
|
} else
|
|
3282
|
-
[
|
|
3284
|
+
[D, g, f] = rr({
|
|
3283
3285
|
sourceX: n,
|
|
3284
3286
|
sourceY: r,
|
|
3285
3287
|
targetX: s,
|
|
@@ -3289,7 +3291,7 @@ const cr = Zt(function({
|
|
|
3289
3291
|
un,
|
|
3290
3292
|
{
|
|
3291
3293
|
id: e,
|
|
3292
|
-
path:
|
|
3294
|
+
path: D,
|
|
3293
3295
|
labelX: g,
|
|
3294
3296
|
labelY: f,
|
|
3295
3297
|
label: u,
|
|
@@ -3297,10 +3299,10 @@ const cr = Zt(function({
|
|
|
3297
3299
|
labelShowBg: y,
|
|
3298
3300
|
labelBgStyle: m,
|
|
3299
3301
|
labelBgPadding: C,
|
|
3300
|
-
labelBgBorderRadius:
|
|
3302
|
+
labelBgBorderRadius: z,
|
|
3301
3303
|
style: M,
|
|
3302
3304
|
markerEnd: $,
|
|
3303
|
-
markerStart:
|
|
3305
|
+
markerStart: k,
|
|
3304
3306
|
interactionWidth: E
|
|
3305
3307
|
}
|
|
3306
3308
|
);
|
|
@@ -3334,43 +3336,43 @@ function Io({
|
|
|
3334
3336
|
// Zoom/Camera
|
|
3335
3337
|
zoomMin: m,
|
|
3336
3338
|
zoomMax: C,
|
|
3337
|
-
initialCamera:
|
|
3339
|
+
initialCamera: z,
|
|
3338
3340
|
fitView: M,
|
|
3339
3341
|
fitViewOptions: $,
|
|
3340
3342
|
// Node/Edge callbacks
|
|
3341
|
-
onNodesChange:
|
|
3343
|
+
onNodesChange: k,
|
|
3342
3344
|
onEdgesChange: E,
|
|
3343
|
-
onConnect:
|
|
3344
|
-
onConnectStart:
|
|
3345
|
+
onConnect: _,
|
|
3346
|
+
onConnectStart: D,
|
|
3345
3347
|
onConnectEnd: g,
|
|
3346
3348
|
onNodeClick: f,
|
|
3347
3349
|
onNodeDoubleClick: p,
|
|
3348
3350
|
onNodeMouseEnter: v,
|
|
3349
|
-
onNodeMouseMove:
|
|
3350
|
-
onNodeMouseLeave:
|
|
3351
|
+
onNodeMouseMove: N,
|
|
3352
|
+
onNodeMouseLeave: w,
|
|
3351
3353
|
onNodeContextMenu: P,
|
|
3352
3354
|
onNodeDragStart: R,
|
|
3353
3355
|
onNodeDrag: B,
|
|
3354
3356
|
onNodeDragStop: q,
|
|
3355
|
-
onEdgeClick:
|
|
3356
|
-
onEdgeDoubleClick:
|
|
3357
|
-
onEdgeMouseEnter:
|
|
3358
|
-
onEdgeMouseMove:
|
|
3357
|
+
onEdgeClick: X,
|
|
3358
|
+
onEdgeDoubleClick: K,
|
|
3359
|
+
onEdgeMouseEnter: at,
|
|
3360
|
+
onEdgeMouseMove: rt,
|
|
3359
3361
|
onEdgeMouseLeave: G,
|
|
3360
3362
|
onEdgeContextMenu: j,
|
|
3361
|
-
onPaneClick:
|
|
3362
|
-
onPaneContextMenu:
|
|
3363
|
-
onPaneMouseEnter:
|
|
3364
|
-
onPaneMouseMove:
|
|
3365
|
-
onPaneMouseLeave:
|
|
3366
|
-
onSelectionChange:
|
|
3367
|
-
onInit:
|
|
3368
|
-
onMoveStart:
|
|
3369
|
-
onMove:
|
|
3370
|
-
onMoveEnd:
|
|
3371
|
-
onDelete:
|
|
3372
|
-
onBeforeDelete:
|
|
3373
|
-
onError:
|
|
3363
|
+
onPaneClick: it,
|
|
3364
|
+
onPaneContextMenu: dt,
|
|
3365
|
+
onPaneMouseEnter: ot,
|
|
3366
|
+
onPaneMouseMove: ft,
|
|
3367
|
+
onPaneMouseLeave: It,
|
|
3368
|
+
onSelectionChange: st,
|
|
3369
|
+
onInit: xt,
|
|
3370
|
+
onMoveStart: Nt,
|
|
3371
|
+
onMove: gt,
|
|
3372
|
+
onMoveEnd: ct,
|
|
3373
|
+
onDelete: zt,
|
|
3374
|
+
onBeforeDelete: Rt,
|
|
3375
|
+
onError: Lt,
|
|
3374
3376
|
// Drag and drop
|
|
3375
3377
|
onDragOver: wt,
|
|
3376
3378
|
onDrop: ne,
|
|
@@ -3399,10 +3401,10 @@ function Io({
|
|
|
3399
3401
|
zoomOnDoubleClick: Nn,
|
|
3400
3402
|
zoomOnPinch: hn,
|
|
3401
3403
|
preventScrolling: fe,
|
|
3402
|
-
translateExtent:
|
|
3404
|
+
translateExtent: mt,
|
|
3403
3405
|
nodeExtent: Te,
|
|
3404
|
-
autoPanOnNodeDrag:
|
|
3405
|
-
autoPanOnConnect:
|
|
3406
|
+
autoPanOnNodeDrag: Et,
|
|
3407
|
+
autoPanOnConnect: pt,
|
|
3406
3408
|
autoPanSpeed: se,
|
|
3407
3409
|
edgesReconnectable: Z,
|
|
3408
3410
|
elevateNodesOnSelect: Pt,
|
|
@@ -3418,71 +3420,71 @@ function Io({
|
|
|
3418
3420
|
children: Me,
|
|
3419
3421
|
...ie
|
|
3420
3422
|
}) {
|
|
3421
|
-
const [Ut, Re] = Gt({ wx: 0, wy: 0, zoom: "1.00" }), Be =
|
|
3423
|
+
const [Ut, Re] = Gt({ wx: 0, wy: 0, zoom: "1.00" }), Be = tt(null), Je = tt(null), Ve = F(
|
|
3422
3424
|
(Q) => {
|
|
3423
3425
|
Re(Q), te == null || te(Q);
|
|
3424
3426
|
},
|
|
3425
3427
|
[te]
|
|
3426
3428
|
), ae = St(() => ({ ...Qr, ...r }), [r]), Kt = St(() => ({ ...Kr, ...s }), [s]), he = St(() => {
|
|
3427
3429
|
const Q = e.filter((Ft) => Ft.type && ae[Ft.type]);
|
|
3428
|
-
return Q.sort((Ft,
|
|
3429
|
-
const Tt = Ft.type === "group" || !Ft.parentId && Q.some((Ee) => Ee.parentId === Ft.id), xe =
|
|
3430
|
+
return Q.sort((Ft, lt) => {
|
|
3431
|
+
const Tt = Ft.type === "group" || !Ft.parentId && Q.some((Ee) => Ee.parentId === Ft.id), xe = lt.type === "group" || !lt.parentId && Q.some((Ee) => Ee.parentId === lt.id);
|
|
3430
3432
|
return Tt && !xe ? -1 : !Tt && xe ? 1 : 0;
|
|
3431
3433
|
});
|
|
3432
|
-
}, [e, ae]), ke = St(() => n.filter((Q) => Q.type && Kt[Q.type]), [n, Kt]), O = St(() => e.map((Q) => Q.type && ae[Q.type] ? { ...Q, _customRendered: !0 } : Q), [e, ae]),
|
|
3434
|
+
}, [e, ae]), ke = St(() => n.filter((Q) => Q.type && Kt[Q.type]), [n, Kt]), O = St(() => e.map((Q) => Q.type && ae[Q.type] ? { ...Q, _customRendered: !0 } : Q), [e, ae]), bt = St(() => n.map((Q) => Q.type && Kt[Q.type] ? { ...Q, _customRendered: !0 } : Q), [n, Kt]), {
|
|
3433
3435
|
wrapRef: Dt,
|
|
3434
3436
|
canvasRef: ce,
|
|
3435
3437
|
canvasReady: De,
|
|
3436
|
-
onPointerDown:
|
|
3437
|
-
onPointerMove:
|
|
3438
|
+
onPointerDown: Ae,
|
|
3439
|
+
onPointerMove: He,
|
|
3438
3440
|
onPointerUp: _e,
|
|
3439
3441
|
store: le
|
|
3440
3442
|
} = Lr({
|
|
3441
3443
|
cards: t,
|
|
3442
3444
|
nodes: O,
|
|
3443
|
-
edges:
|
|
3445
|
+
edges: bt,
|
|
3444
3446
|
dark: o,
|
|
3445
3447
|
gridSize: i,
|
|
3446
3448
|
zoomMin: m,
|
|
3447
3449
|
zoomMax: C,
|
|
3448
|
-
initialCamera:
|
|
3450
|
+
initialCamera: z,
|
|
3449
3451
|
fitView: M,
|
|
3450
3452
|
fitViewOptions: $,
|
|
3451
3453
|
onHudUpdate: Ve,
|
|
3452
3454
|
onNodesProcessed: gn,
|
|
3453
|
-
onNodesChange:
|
|
3455
|
+
onNodesChange: k,
|
|
3454
3456
|
onEdgesChange: E,
|
|
3455
|
-
onConnect:
|
|
3456
|
-
onConnectStart:
|
|
3457
|
+
onConnect: _,
|
|
3458
|
+
onConnectStart: D,
|
|
3457
3459
|
onConnectEnd: g,
|
|
3458
3460
|
onNodeClick: f,
|
|
3459
3461
|
onNodeDoubleClick: p,
|
|
3460
3462
|
onNodeMouseEnter: v,
|
|
3461
|
-
onNodeMouseMove:
|
|
3462
|
-
onNodeMouseLeave:
|
|
3463
|
+
onNodeMouseMove: N,
|
|
3464
|
+
onNodeMouseLeave: w,
|
|
3463
3465
|
onNodeContextMenu: P,
|
|
3464
3466
|
onNodeDragStart: R,
|
|
3465
3467
|
onNodeDrag: B,
|
|
3466
3468
|
onNodeDragStop: q,
|
|
3467
|
-
onEdgeClick:
|
|
3468
|
-
onEdgeDoubleClick:
|
|
3469
|
-
onEdgeMouseEnter:
|
|
3470
|
-
onEdgeMouseMove:
|
|
3469
|
+
onEdgeClick: X,
|
|
3470
|
+
onEdgeDoubleClick: K,
|
|
3471
|
+
onEdgeMouseEnter: at,
|
|
3472
|
+
onEdgeMouseMove: rt,
|
|
3471
3473
|
onEdgeMouseLeave: G,
|
|
3472
3474
|
onEdgeContextMenu: j,
|
|
3473
|
-
onPaneClick:
|
|
3474
|
-
onPaneContextMenu:
|
|
3475
|
-
onPaneMouseEnter:
|
|
3476
|
-
onPaneMouseMove:
|
|
3477
|
-
onPaneMouseLeave:
|
|
3478
|
-
onSelectionChange:
|
|
3479
|
-
onInit:
|
|
3480
|
-
onMoveStart:
|
|
3481
|
-
onMove:
|
|
3482
|
-
onMoveEnd:
|
|
3483
|
-
onDelete:
|
|
3484
|
-
onBeforeDelete:
|
|
3485
|
-
onError:
|
|
3475
|
+
onPaneClick: it,
|
|
3476
|
+
onPaneContextMenu: dt,
|
|
3477
|
+
onPaneMouseEnter: ot,
|
|
3478
|
+
onPaneMouseMove: ft,
|
|
3479
|
+
onPaneMouseLeave: It,
|
|
3480
|
+
onSelectionChange: st,
|
|
3481
|
+
onInit: xt,
|
|
3482
|
+
onMoveStart: Nt,
|
|
3483
|
+
onMove: gt,
|
|
3484
|
+
onMoveEnd: ct,
|
|
3485
|
+
onDelete: zt,
|
|
3486
|
+
onBeforeDelete: Rt,
|
|
3487
|
+
onError: Lt,
|
|
3486
3488
|
nodesDraggable: Ot,
|
|
3487
3489
|
nodesConnectable: Yt,
|
|
3488
3490
|
elementsSelectable: me,
|
|
@@ -3505,10 +3507,10 @@ function Io({
|
|
|
3505
3507
|
zoomOnDoubleClick: Nn,
|
|
3506
3508
|
zoomOnPinch: hn,
|
|
3507
3509
|
preventScrolling: fe,
|
|
3508
|
-
translateExtent:
|
|
3510
|
+
translateExtent: mt,
|
|
3509
3511
|
nodeExtent: Te,
|
|
3510
|
-
autoPanOnNodeDrag:
|
|
3511
|
-
autoPanOnConnect:
|
|
3512
|
+
autoPanOnNodeDrag: Et,
|
|
3513
|
+
autoPanOnConnect: pt,
|
|
3512
3514
|
autoPanSpeed: se,
|
|
3513
3515
|
edgesReconnectable: Z,
|
|
3514
3516
|
elevateNodesOnSelect: Pt,
|
|
@@ -3524,24 +3526,24 @@ function Io({
|
|
|
3524
3526
|
get edges() {
|
|
3525
3527
|
return n;
|
|
3526
3528
|
}
|
|
3527
|
-
}), [le, e, n]), ye =
|
|
3528
|
-
|
|
3529
|
+
}), [le, e, n]), ye = tt(null), ge = tt(null), pe = tt(null), Jt = tt(null);
|
|
3530
|
+
ht(() => {
|
|
3529
3531
|
let Q;
|
|
3530
3532
|
const Ft = () => {
|
|
3531
|
-
const
|
|
3533
|
+
const lt = le.cameraRef.current, Tt = `translate(${lt.x}px, ${lt.y}px) scale(${lt.zoom})`, xe = `translate(${lt.x}, ${lt.y}) scale(${lt.zoom})`;
|
|
3532
3534
|
ye.current && (ye.current.style.transform = Tt), ge.current && ge.current.setAttribute("transform", xe), pe.current && (pe.current.style.transform = Tt), Jt.current && (Jt.current.style.transform = Tt), Q = requestAnimationFrame(Ft);
|
|
3533
3535
|
};
|
|
3534
3536
|
return Q = requestAnimationFrame(Ft), () => cancelAnimationFrame(Q);
|
|
3535
3537
|
}, [le]);
|
|
3536
3538
|
const ze = he.length > 0, ee = ke.length > 0;
|
|
3537
|
-
return /* @__PURE__ */ S(Zn.Provider, { value: We, children: /* @__PURE__ */
|
|
3539
|
+
return /* @__PURE__ */ S(Zn.Provider, { value: We, children: /* @__PURE__ */ $t(
|
|
3538
3540
|
"div",
|
|
3539
3541
|
{
|
|
3540
3542
|
ref: Dt,
|
|
3541
3543
|
className: `ric-wrap ${l}`,
|
|
3542
3544
|
style: { width: c, height: u, ...y },
|
|
3543
|
-
onPointerDown:
|
|
3544
|
-
onPointerMove:
|
|
3545
|
+
onPointerDown: Ae,
|
|
3546
|
+
onPointerMove: He,
|
|
3545
3547
|
onPointerUp: _e,
|
|
3546
3548
|
onDragOver: wt,
|
|
3547
3549
|
onDrop: ne,
|
|
@@ -3640,7 +3642,7 @@ function Io({
|
|
|
3640
3642
|
}
|
|
3641
3643
|
),
|
|
3642
3644
|
_t && /* @__PURE__ */ S("div", { className: "ric-hint", children: Wt }),
|
|
3643
|
-
pn && /* @__PURE__ */
|
|
3645
|
+
pn && /* @__PURE__ */ $t("div", { className: "ric-info", children: [
|
|
3644
3646
|
"world: (",
|
|
3645
3647
|
Ut.wx,
|
|
3646
3648
|
", ",
|
|
@@ -3648,17 +3650,17 @@ function Io({
|
|
|
3648
3650
|
") zoom: ",
|
|
3649
3651
|
Ut.zoom,
|
|
3650
3652
|
"x",
|
|
3651
|
-
Ut.nodeCount > 0 && /* @__PURE__ */
|
|
3653
|
+
Ut.nodeCount > 0 && /* @__PURE__ */ $t(Le, { children: [
|
|
3652
3654
|
" nodes: ",
|
|
3653
3655
|
Ut.nodeCount
|
|
3654
3656
|
] }),
|
|
3655
|
-
Ut.edgeCount > 0 && /* @__PURE__ */
|
|
3657
|
+
Ut.edgeCount > 0 && /* @__PURE__ */ $t(Le, { children: [
|
|
3656
3658
|
" edges: ",
|
|
3657
3659
|
Ut.edgeCount
|
|
3658
3660
|
] })
|
|
3659
3661
|
] }),
|
|
3660
3662
|
/* @__PURE__ */ S(
|
|
3661
|
-
|
|
3663
|
+
Ar,
|
|
3662
3664
|
{
|
|
3663
3665
|
selectionKeyCode: de || "Shift",
|
|
3664
3666
|
selectionMode: we || "partial"
|
|
@@ -3746,39 +3748,39 @@ function So(t) {
|
|
|
3746
3748
|
}
|
|
3747
3749
|
function eo() {
|
|
3748
3750
|
const t = yt(), e = F(() => [...t.nodesRef.current], [t]), n = F(() => [...t.edgesRef.current], [t]), r = F((g) => t.nodesRef.current.find((f) => f.id === g), [t]), s = F((g) => t.edgesRef.current.find((f) => f.id === g), [t]), o = F((g) => {
|
|
3749
|
-
var f, p, v,
|
|
3751
|
+
var f, p, v, N;
|
|
3750
3752
|
if (typeof g == "function") {
|
|
3751
|
-
const
|
|
3753
|
+
const w = g(t.nodesRef.current);
|
|
3752
3754
|
(p = (f = t.onNodesChangeRef).current) == null || p.call(f, [
|
|
3753
3755
|
...t.nodesRef.current.map((P) => ({ id: P.id, type: "remove" })),
|
|
3754
|
-
...
|
|
3756
|
+
...w.map((P) => ({ type: "add", item: P }))
|
|
3755
3757
|
]);
|
|
3756
3758
|
} else
|
|
3757
|
-
(
|
|
3758
|
-
...t.nodesRef.current.map((
|
|
3759
|
-
...g.map((
|
|
3759
|
+
(N = (v = t.onNodesChangeRef).current) == null || N.call(v, [
|
|
3760
|
+
...t.nodesRef.current.map((w) => ({ id: w.id, type: "remove" })),
|
|
3761
|
+
...g.map((w) => ({ type: "add", item: w }))
|
|
3760
3762
|
]);
|
|
3761
3763
|
}, [t]), i = F((g) => {
|
|
3762
|
-
var f, p, v,
|
|
3764
|
+
var f, p, v, N;
|
|
3763
3765
|
if (typeof g == "function") {
|
|
3764
|
-
const
|
|
3766
|
+
const w = g(t.edgesRef.current);
|
|
3765
3767
|
(p = (f = t.onEdgesChangeRef).current) == null || p.call(f, [
|
|
3766
3768
|
...t.edgesRef.current.map((P) => ({ id: P.id, type: "remove" })),
|
|
3767
|
-
...
|
|
3769
|
+
...w.map((P) => ({ type: "add", item: P }))
|
|
3768
3770
|
]);
|
|
3769
3771
|
} else
|
|
3770
|
-
(
|
|
3771
|
-
...t.edgesRef.current.map((
|
|
3772
|
-
...g.map((
|
|
3772
|
+
(N = (v = t.onEdgesChangeRef).current) == null || N.call(v, [
|
|
3773
|
+
...t.edgesRef.current.map((w) => ({ id: w.id, type: "remove" })),
|
|
3774
|
+
...g.map((w) => ({ type: "add", item: w }))
|
|
3773
3775
|
]);
|
|
3774
3776
|
}, [t]), c = F((g) => {
|
|
3775
3777
|
var p, v;
|
|
3776
3778
|
const f = Array.isArray(g) ? g : [g];
|
|
3777
|
-
(v = (p = t.onNodesChangeRef).current) == null || v.call(p, f.map((
|
|
3779
|
+
(v = (p = t.onNodesChangeRef).current) == null || v.call(p, f.map((N) => ({ type: "add", item: N })));
|
|
3778
3780
|
}, [t]), u = F((g) => {
|
|
3779
3781
|
var p, v;
|
|
3780
3782
|
const f = Array.isArray(g) ? g : [g];
|
|
3781
|
-
(v = (p = t.onEdgesChangeRef).current) == null || v.call(p, f.map((
|
|
3783
|
+
(v = (p = t.onEdgesChangeRef).current) == null || v.call(p, f.map((N) => ({ type: "add", item: N })));
|
|
3782
3784
|
}, [t]), l = F(({ nodes: g = [], edges: f = [] }) => {
|
|
3783
3785
|
if (g.length && t.onNodesChangeRef.current) {
|
|
3784
3786
|
t.onNodesChangeRef.current(g.map((v) => ({ id: v.id, type: "remove" })));
|
|
@@ -3795,40 +3797,40 @@ function eo() {
|
|
|
3795
3797
|
y: g.y ?? t.cameraRef.current.y,
|
|
3796
3798
|
zoom: g.zoom ?? t.cameraRef.current.zoom
|
|
3797
3799
|
}, t.sendCamera();
|
|
3798
|
-
}, [t]), C = F(() => t.cameraRef.current.zoom, [t]),
|
|
3800
|
+
}, [t]), C = F(() => t.cameraRef.current.zoom, [t]), z = F((g) => {
|
|
3799
3801
|
const f = t.cameraRef.current, p = t.wrapRef.current;
|
|
3800
3802
|
if (!p) return;
|
|
3801
|
-
const v = p.getBoundingClientRect(),
|
|
3802
|
-
f.x =
|
|
3803
|
+
const v = p.getBoundingClientRect(), N = v.width / 2, w = v.height / 2, P = 1.2;
|
|
3804
|
+
f.x = N - (N - f.x) * P, f.y = w - (w - f.y) * P, f.zoom = Math.min(t.zoomMax, f.zoom * P), t.sendCamera();
|
|
3803
3805
|
}, [t]), M = F((g) => {
|
|
3804
3806
|
const f = t.cameraRef.current, p = t.wrapRef.current;
|
|
3805
3807
|
if (!p) return;
|
|
3806
|
-
const v = p.getBoundingClientRect(),
|
|
3807
|
-
f.x =
|
|
3808
|
+
const v = p.getBoundingClientRect(), N = v.width / 2, w = v.height / 2, P = 1 / 1.2;
|
|
3809
|
+
f.x = N - (N - f.x) * P, f.y = w - (w - f.y) * P, f.zoom = Math.max(t.zoomMin, f.zoom * P), t.sendCamera();
|
|
3808
3810
|
}, [t]), $ = F((g) => {
|
|
3809
3811
|
const f = t.cameraRef.current, p = t.wrapRef.current;
|
|
3810
3812
|
if (!p) return;
|
|
3811
|
-
const v = p.getBoundingClientRect(),
|
|
3812
|
-
f.x =
|
|
3813
|
-
}, [t]),
|
|
3813
|
+
const v = p.getBoundingClientRect(), N = v.width / 2, w = v.height / 2, P = g / f.zoom;
|
|
3814
|
+
f.x = N - (N - f.x) * P, f.y = w - (w - f.y) * P, f.zoom = Math.min(t.zoomMax, Math.max(t.zoomMin, g)), t.sendCamera();
|
|
3815
|
+
}, [t]), k = F((g = {}) => {
|
|
3814
3816
|
const f = t.nodesRef.current;
|
|
3815
3817
|
if (!f.length) return;
|
|
3816
3818
|
const p = t.wrapRef.current;
|
|
3817
3819
|
if (!p) return;
|
|
3818
|
-
const v = p.getBoundingClientRect(),
|
|
3819
|
-
if (!
|
|
3820
|
-
const P = Mn(
|
|
3820
|
+
const v = p.getBoundingClientRect(), N = g.padding ?? 0.1, w = g.nodes ? f.filter((B) => g.nodes.some((q) => q.id === B.id)) : f;
|
|
3821
|
+
if (!w.length) return;
|
|
3822
|
+
const P = Mn(w), R = Rn(P, v.width, v.height, N);
|
|
3821
3823
|
g.maxZoom && (R.zoom = Math.min(R.zoom, g.maxZoom)), g.minZoom && (R.zoom = Math.max(R.zoom, g.minZoom)), t.cameraRef.current = R, t.sendCamera();
|
|
3822
3824
|
}, [t]), E = F((g, f, p = {}) => {
|
|
3823
3825
|
const v = t.wrapRef.current;
|
|
3824
3826
|
if (!v) return;
|
|
3825
|
-
const
|
|
3827
|
+
const N = v.getBoundingClientRect(), w = p.zoom ?? t.cameraRef.current.zoom;
|
|
3826
3828
|
t.cameraRef.current = {
|
|
3827
|
-
x:
|
|
3828
|
-
y:
|
|
3829
|
-
zoom:
|
|
3829
|
+
x: N.width / 2 - g * w,
|
|
3830
|
+
y: N.height / 2 - f * w,
|
|
3831
|
+
zoom: w
|
|
3830
3832
|
}, t.sendCamera();
|
|
3831
|
-
}, [t]),
|
|
3833
|
+
}, [t]), _ = F((g) => t.screenToWorld(g.x, g.y), [t]), D = F((g) => {
|
|
3832
3834
|
const f = t.cameraRef.current, p = t.wrapRef.current;
|
|
3833
3835
|
if (!p) return { x: 0, y: 0 };
|
|
3834
3836
|
const v = p.getBoundingClientRect();
|
|
@@ -3850,13 +3852,13 @@ function eo() {
|
|
|
3850
3852
|
getViewport: y,
|
|
3851
3853
|
setViewport: m,
|
|
3852
3854
|
getZoom: C,
|
|
3853
|
-
zoomIn:
|
|
3855
|
+
zoomIn: z,
|
|
3854
3856
|
zoomOut: M,
|
|
3855
3857
|
zoomTo: $,
|
|
3856
|
-
fitView:
|
|
3858
|
+
fitView: k,
|
|
3857
3859
|
setCenter: E,
|
|
3858
|
-
screenToFlowPosition:
|
|
3859
|
-
flowToScreenPosition:
|
|
3860
|
+
screenToFlowPosition: _,
|
|
3861
|
+
flowToScreenPosition: D
|
|
3860
3862
|
};
|
|
3861
3863
|
}
|
|
3862
3864
|
function Bo() {
|
|
@@ -3865,10 +3867,10 @@ function Bo() {
|
|
|
3865
3867
|
function Do() {
|
|
3866
3868
|
return yt().edges;
|
|
3867
3869
|
}
|
|
3868
|
-
function
|
|
3870
|
+
function Ao() {
|
|
3869
3871
|
return yt().viewport;
|
|
3870
3872
|
}
|
|
3871
|
-
function
|
|
3873
|
+
function Ho() {
|
|
3872
3874
|
return yt().connection;
|
|
3873
3875
|
}
|
|
3874
3876
|
function _o(t) {
|
|
@@ -3887,14 +3889,14 @@ function Xo({ nodeId: t, type: e, handleId: n }) {
|
|
|
3887
3889
|
return St(() => r.edges.filter((s) => e === "source" ? s.source === t && (n ? s.sourceHandle === n : !0) : s.target === t && (n ? s.targetHandle === n : !0)), [r.edges, t, e, n]);
|
|
3888
3890
|
}
|
|
3889
3891
|
function Fo({ onChange: t, onStart: e, onEnd: n }) {
|
|
3890
|
-
const r = yt(), s =
|
|
3891
|
-
|
|
3892
|
+
const r = yt(), s = tt(t), o = tt(e), i = tt(n);
|
|
3893
|
+
ht(() => {
|
|
3892
3894
|
s.current = t;
|
|
3893
|
-
}, [t]),
|
|
3895
|
+
}, [t]), ht(() => {
|
|
3894
3896
|
o.current = e;
|
|
3895
|
-
}, [e]),
|
|
3897
|
+
}, [e]), ht(() => {
|
|
3896
3898
|
i.current = n;
|
|
3897
|
-
}, [n]),
|
|
3899
|
+
}, [n]), ht(() => {
|
|
3898
3900
|
const c = (u) => {
|
|
3899
3901
|
var l;
|
|
3900
3902
|
(l = s.current) == null || l.call(s, { x: u.x, y: u.y, zoom: u.zoom });
|
|
@@ -3903,10 +3905,10 @@ function Fo({ onChange: t, onStart: e, onEnd: n }) {
|
|
|
3903
3905
|
}, [r]);
|
|
3904
3906
|
}
|
|
3905
3907
|
function Yo({ onChange: t }) {
|
|
3906
|
-
const e = yt(), n =
|
|
3907
|
-
|
|
3908
|
+
const e = yt(), n = tt(t);
|
|
3909
|
+
ht(() => {
|
|
3908
3910
|
n.current = t;
|
|
3909
|
-
}, [t]),
|
|
3911
|
+
}, [t]), ht(() => {
|
|
3910
3912
|
const r = (s) => {
|
|
3911
3913
|
var o;
|
|
3912
3914
|
(o = n.current) == null || o.call(n, s);
|
|
@@ -3916,7 +3918,7 @@ function Yo({ onChange: t }) {
|
|
|
3916
3918
|
}
|
|
3917
3919
|
function Uo(t) {
|
|
3918
3920
|
const [e, n] = Gt(!1), r = Array.isArray(t) ? t : [t];
|
|
3919
|
-
return
|
|
3921
|
+
return ht(() => {
|
|
3920
3922
|
const s = (i) => {
|
|
3921
3923
|
r.includes(i.key) && n(!0);
|
|
3922
3924
|
}, o = (i) => {
|
|
@@ -3967,50 +3969,50 @@ function Qo({
|
|
|
3967
3969
|
style: o = {},
|
|
3968
3970
|
className: i = ""
|
|
3969
3971
|
}) {
|
|
3970
|
-
const c = yt(), u =
|
|
3972
|
+
const c = yt(), u = tt(null), l = tt(null), y = F(() => {
|
|
3971
3973
|
const m = u.current;
|
|
3972
3974
|
if (!m) return;
|
|
3973
|
-
const C = m.getContext("2d"),
|
|
3974
|
-
m.width = t *
|
|
3975
|
+
const C = m.getContext("2d"), z = window.devicePixelRatio || 1;
|
|
3976
|
+
m.width = t * z, m.height = e * z, C.scale(z, z), C.clearRect(0, 0, t, e);
|
|
3975
3977
|
const M = c.nodesRef.current;
|
|
3976
3978
|
if (!M.length) return;
|
|
3977
|
-
let $ = 1 / 0,
|
|
3979
|
+
let $ = 1 / 0, k = 1 / 0, E = -1 / 0, _ = -1 / 0;
|
|
3978
3980
|
for (const R of M) {
|
|
3979
3981
|
const B = R.width || wn, q = R.height || bn;
|
|
3980
|
-
R.position.x < $ && ($ = R.position.x), R.position.y <
|
|
3982
|
+
R.position.x < $ && ($ = R.position.x), R.position.y < k && (k = R.position.y), R.position.x + B > E && (E = R.position.x + B), R.position.y + q > _ && (_ = R.position.y + q);
|
|
3981
3983
|
}
|
|
3982
|
-
const
|
|
3983
|
-
$ -=
|
|
3984
|
-
const g = E - $, f =
|
|
3984
|
+
const D = 40;
|
|
3985
|
+
$ -= D, k -= D, E += D, _ += D;
|
|
3986
|
+
const g = E - $, f = _ - k, p = Math.min(t / g, e / f), v = (t - g * p) / 2, N = (e - f * p) / 2;
|
|
3985
3987
|
for (const R of M) {
|
|
3986
3988
|
if (R.hidden) continue;
|
|
3987
|
-
const B = R.width || wn, q = R.height || bn,
|
|
3988
|
-
C.fillStyle = R.selected ? "#f59e0b" : typeof n == "function" ? n(R) : n, C.fillRect(
|
|
3989
|
+
const B = R.width || wn, q = R.height || bn, X = (R.position.x - $) * p + v, K = (R.position.y - k) * p + N, at = B * p, rt = q * p;
|
|
3990
|
+
C.fillStyle = R.selected ? "#f59e0b" : typeof n == "function" ? n(R) : n, C.fillRect(X, K, Math.max(at, 2), Math.max(rt, 2));
|
|
3989
3991
|
}
|
|
3990
|
-
const
|
|
3992
|
+
const w = c.cameraRef.current, P = c.wrapRef.current;
|
|
3991
3993
|
if (P) {
|
|
3992
|
-
const R = P.getBoundingClientRect(), B = -
|
|
3994
|
+
const R = P.getBoundingClientRect(), B = -w.x / w.zoom, q = -w.y / w.zoom, X = R.width / w.zoom, K = R.height / w.zoom;
|
|
3993
3995
|
C.fillStyle = s, C.fillRect(0, 0, t, e);
|
|
3994
|
-
const
|
|
3995
|
-
C.clearRect(
|
|
3996
|
-
for (const
|
|
3997
|
-
if (
|
|
3998
|
-
const
|
|
3999
|
-
C.fillStyle =
|
|
3996
|
+
const at = (B - $) * p + v, rt = (q - k) * p + N, G = X * p, j = K * p;
|
|
3997
|
+
C.clearRect(at, rt, G, j);
|
|
3998
|
+
for (const it of M) {
|
|
3999
|
+
if (it.hidden) continue;
|
|
4000
|
+
const dt = it.width || wn, ot = it.height || bn, ft = (it.position.x - $) * p + v, It = (it.position.y - k) * p + N;
|
|
4001
|
+
C.fillStyle = it.selected ? "#f59e0b" : typeof n == "function" ? n(it) : n, C.fillRect(ft, It, Math.max(dt * p, 2), Math.max(ot * p, 2));
|
|
4000
4002
|
}
|
|
4001
|
-
C.strokeStyle = "#3b82f6", C.lineWidth = 1.5, C.strokeRect(
|
|
4003
|
+
C.strokeStyle = "#3b82f6", C.lineWidth = 1.5, C.strokeRect(at, rt, G, j);
|
|
4002
4004
|
}
|
|
4003
4005
|
}, [c, t, e, n, r, s]);
|
|
4004
|
-
return
|
|
4006
|
+
return ht(() => {
|
|
4005
4007
|
let m = !0;
|
|
4006
4008
|
function C() {
|
|
4007
4009
|
m && (y(), l.current = requestAnimationFrame(C));
|
|
4008
4010
|
}
|
|
4009
|
-
const
|
|
4011
|
+
const z = setInterval(() => {
|
|
4010
4012
|
cancelAnimationFrame(l.current), l.current = requestAnimationFrame(C);
|
|
4011
4013
|
}, 66);
|
|
4012
4014
|
return y(), () => {
|
|
4013
|
-
m = !1, clearInterval(
|
|
4015
|
+
m = !1, clearInterval(z), cancelAnimationFrame(l.current);
|
|
4014
4016
|
};
|
|
4015
4017
|
}, [y]), /* @__PURE__ */ S(
|
|
4016
4018
|
"canvas",
|
|
@@ -4033,7 +4035,7 @@ function Qo({
|
|
|
4033
4035
|
);
|
|
4034
4036
|
}
|
|
4035
4037
|
function no() {
|
|
4036
|
-
return /* @__PURE__ */
|
|
4038
|
+
return /* @__PURE__ */ $t("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
4037
4039
|
/* @__PURE__ */ S("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
|
|
4038
4040
|
/* @__PURE__ */ S("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
4039
4041
|
] });
|
|
@@ -4045,13 +4047,13 @@ function oo() {
|
|
|
4045
4047
|
return /* @__PURE__ */ S("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ S("path", { d: "M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7" }) });
|
|
4046
4048
|
}
|
|
4047
4049
|
function so() {
|
|
4048
|
-
return /* @__PURE__ */
|
|
4050
|
+
return /* @__PURE__ */ $t("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
4049
4051
|
/* @__PURE__ */ S("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
|
|
4050
4052
|
/* @__PURE__ */ S("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })
|
|
4051
4053
|
] });
|
|
4052
4054
|
}
|
|
4053
4055
|
function io() {
|
|
4054
|
-
return /* @__PURE__ */
|
|
4056
|
+
return /* @__PURE__ */ $t("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
4055
4057
|
/* @__PURE__ */ S("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
|
|
4056
4058
|
/* @__PURE__ */ S("path", { d: "M7 11V7a5 5 0 0 1 9.9-1" })
|
|
4057
4059
|
] });
|
|
@@ -4081,18 +4083,18 @@ function ao({
|
|
|
4081
4083
|
style: y = {},
|
|
4082
4084
|
className: m = "",
|
|
4083
4085
|
"aria-label": C = "Canvas controls",
|
|
4084
|
-
children:
|
|
4086
|
+
children: z
|
|
4085
4087
|
}) {
|
|
4086
|
-
const M = yt(), { zoomIn: $, zoomOut:
|
|
4088
|
+
const M = yt(), { zoomIn: $, zoomOut: k, fitView: E, getZoom: _ } = eo(), [D, g] = Gt(!0), f = _() <= M.zoomMin, p = _() >= M.zoomMax, v = F(() => {
|
|
4087
4089
|
$(), s == null || s();
|
|
4088
|
-
}, [$, s]),
|
|
4089
|
-
|
|
4090
|
-
}, [
|
|
4090
|
+
}, [$, s]), N = F(() => {
|
|
4091
|
+
k(), o == null || o();
|
|
4092
|
+
}, [k, o]), w = F(() => {
|
|
4091
4093
|
E(r || { padding: 0.1 }), i == null || i();
|
|
4092
4094
|
}, [E, r, i]), P = F(() => {
|
|
4093
|
-
const B = !
|
|
4095
|
+
const B = !D;
|
|
4094
4096
|
g(B), c == null || c(B);
|
|
4095
|
-
}, [
|
|
4097
|
+
}, [D, c]), R = {
|
|
4096
4098
|
"top-left": { top: 10, left: 10 },
|
|
4097
4099
|
"top-right": { top: 10, right: 10 },
|
|
4098
4100
|
"top-center": { top: 10, left: "50%", transform: "translateX(-50%)" },
|
|
@@ -4100,7 +4102,7 @@ function ao({
|
|
|
4100
4102
|
"bottom-right": { bottom: 30, right: 10 },
|
|
4101
4103
|
"bottom-center": { bottom: 30, left: "50%", transform: "translateX(-50%)" }
|
|
4102
4104
|
}[u] || { bottom: 30, left: 10 };
|
|
4103
|
-
return /* @__PURE__ */
|
|
4105
|
+
return /* @__PURE__ */ $t(
|
|
4104
4106
|
"div",
|
|
4105
4107
|
{
|
|
4106
4108
|
className: `ric-controls ${m}`,
|
|
@@ -4116,7 +4118,7 @@ function ao({
|
|
|
4116
4118
|
role: "toolbar",
|
|
4117
4119
|
"aria-label": C,
|
|
4118
4120
|
children: [
|
|
4119
|
-
t && /* @__PURE__ */
|
|
4121
|
+
t && /* @__PURE__ */ $t(Le, { children: [
|
|
4120
4122
|
/* @__PURE__ */ S(
|
|
4121
4123
|
rn,
|
|
4122
4124
|
{
|
|
@@ -4131,7 +4133,7 @@ function ao({
|
|
|
4131
4133
|
/* @__PURE__ */ S(
|
|
4132
4134
|
rn,
|
|
4133
4135
|
{
|
|
4134
|
-
onClick:
|
|
4136
|
+
onClick: N,
|
|
4135
4137
|
disabled: f,
|
|
4136
4138
|
title: "Zoom out",
|
|
4137
4139
|
"aria-label": "Zoom out",
|
|
@@ -4143,7 +4145,7 @@ function ao({
|
|
|
4143
4145
|
e && /* @__PURE__ */ S(
|
|
4144
4146
|
rn,
|
|
4145
4147
|
{
|
|
4146
|
-
onClick:
|
|
4148
|
+
onClick: w,
|
|
4147
4149
|
title: "Fit view",
|
|
4148
4150
|
"aria-label": "Fit view",
|
|
4149
4151
|
className: "ric-controls-fitview",
|
|
@@ -4154,13 +4156,13 @@ function ao({
|
|
|
4154
4156
|
rn,
|
|
4155
4157
|
{
|
|
4156
4158
|
onClick: P,
|
|
4157
|
-
title:
|
|
4158
|
-
"aria-label":
|
|
4159
|
+
title: D ? "Lock interactivity" : "Unlock interactivity",
|
|
4160
|
+
"aria-label": D ? "Lock interactivity" : "Unlock interactivity",
|
|
4159
4161
|
className: "ric-controls-interactive",
|
|
4160
|
-
children:
|
|
4162
|
+
children: D ? /* @__PURE__ */ S(io, {}) : /* @__PURE__ */ S(so, {})
|
|
4161
4163
|
}
|
|
4162
4164
|
),
|
|
4163
|
-
|
|
4165
|
+
z
|
|
4164
4166
|
]
|
|
4165
4167
|
}
|
|
4166
4168
|
);
|
|
@@ -4237,32 +4239,32 @@ function ts({
|
|
|
4237
4239
|
onResize: l,
|
|
4238
4240
|
onResizeEnd: y
|
|
4239
4241
|
}) {
|
|
4240
|
-
const m = qe(je), C = yt(),
|
|
4242
|
+
const m = qe(je), C = yt(), z = tt(null), M = F((E, _) => {
|
|
4241
4243
|
E.stopPropagation(), E.preventDefault();
|
|
4242
|
-
const
|
|
4243
|
-
if (!
|
|
4244
|
-
|
|
4245
|
-
direction:
|
|
4244
|
+
const D = C.nodesRef.current.find((p) => p.id === m);
|
|
4245
|
+
if (!D) return;
|
|
4246
|
+
z.current = {
|
|
4247
|
+
direction: _,
|
|
4246
4248
|
startX: E.clientX,
|
|
4247
4249
|
startY: E.clientY,
|
|
4248
|
-
width:
|
|
4249
|
-
height:
|
|
4250
|
-
}, u == null || u(E, { width:
|
|
4250
|
+
width: D.width || 160,
|
|
4251
|
+
height: D.height || 60
|
|
4252
|
+
}, u == null || u(E, { width: z.current.width, height: z.current.height });
|
|
4251
4253
|
const g = (p) => {
|
|
4252
|
-
var q,
|
|
4253
|
-
if (!
|
|
4254
|
-
const v =
|
|
4254
|
+
var q, X;
|
|
4255
|
+
if (!z.current) return;
|
|
4256
|
+
const v = z.current, N = C.cameraRef.current, w = (p.clientX - v.startX) / N.zoom, P = (p.clientY - v.startY) / N.zoom;
|
|
4255
4257
|
let R = v.width, B = v.height;
|
|
4256
|
-
v.direction.includes("e") && (R = Math.min(n, Math.max(t, v.width +
|
|
4258
|
+
v.direction.includes("e") && (R = Math.min(n, Math.max(t, v.width + w))), v.direction.includes("w") && (R = Math.min(n, Math.max(t, v.width - w))), v.direction.includes("s") && (B = Math.min(r, Math.max(e, v.height + P))), v.direction.includes("n") && (B = Math.min(r, Math.max(e, v.height - P))), (X = (q = C.onNodesChangeRef).current) == null || X.call(q, [
|
|
4257
4259
|
{ id: m, type: "dimensions", dimensions: { width: R, height: B }, setAttributes: !0 }
|
|
4258
4260
|
]), l == null || l(p, { width: R, height: B });
|
|
4259
4261
|
}, f = (p) => {
|
|
4260
|
-
|
|
4262
|
+
z.current = null, y == null || y(p, {}), window.removeEventListener("pointermove", g), window.removeEventListener("pointerup", f);
|
|
4261
4263
|
};
|
|
4262
4264
|
window.addEventListener("pointermove", g), window.addEventListener("pointerup", f);
|
|
4263
4265
|
}, [m, C, t, e, n, r, u, l, y]);
|
|
4264
4266
|
if (!s) return null;
|
|
4265
|
-
const $ = 8,
|
|
4267
|
+
const $ = 8, k = {
|
|
4266
4268
|
position: "absolute",
|
|
4267
4269
|
width: $,
|
|
4268
4270
|
height: $,
|
|
@@ -4272,60 +4274,60 @@ function ts({
|
|
|
4272
4274
|
zIndex: 20,
|
|
4273
4275
|
...o
|
|
4274
4276
|
};
|
|
4275
|
-
return /* @__PURE__ */
|
|
4277
|
+
return /* @__PURE__ */ $t(Le, { children: [
|
|
4276
4278
|
/* @__PURE__ */ S(
|
|
4277
4279
|
"div",
|
|
4278
4280
|
{
|
|
4279
|
-
style: { ...
|
|
4281
|
+
style: { ...k, bottom: -$ / 2, right: -$ / 2, cursor: "nwse-resize" },
|
|
4280
4282
|
onPointerDown: (E) => M(E, "se")
|
|
4281
4283
|
}
|
|
4282
4284
|
),
|
|
4283
4285
|
/* @__PURE__ */ S(
|
|
4284
4286
|
"div",
|
|
4285
4287
|
{
|
|
4286
|
-
style: { ...
|
|
4288
|
+
style: { ...k, bottom: -$ / 2, left: -$ / 2, cursor: "nesw-resize" },
|
|
4287
4289
|
onPointerDown: (E) => M(E, "sw")
|
|
4288
4290
|
}
|
|
4289
4291
|
),
|
|
4290
4292
|
/* @__PURE__ */ S(
|
|
4291
4293
|
"div",
|
|
4292
4294
|
{
|
|
4293
|
-
style: { ...
|
|
4295
|
+
style: { ...k, top: -$ / 2, right: -$ / 2, cursor: "nesw-resize" },
|
|
4294
4296
|
onPointerDown: (E) => M(E, "ne")
|
|
4295
4297
|
}
|
|
4296
4298
|
),
|
|
4297
4299
|
/* @__PURE__ */ S(
|
|
4298
4300
|
"div",
|
|
4299
4301
|
{
|
|
4300
|
-
style: { ...
|
|
4302
|
+
style: { ...k, top: -$ / 2, left: -$ / 2, cursor: "nwse-resize" },
|
|
4301
4303
|
onPointerDown: (E) => M(E, "nw")
|
|
4302
4304
|
}
|
|
4303
4305
|
),
|
|
4304
4306
|
/* @__PURE__ */ S(
|
|
4305
4307
|
"div",
|
|
4306
4308
|
{
|
|
4307
|
-
style: { ...
|
|
4309
|
+
style: { ...k, top: "50%", right: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
|
|
4308
4310
|
onPointerDown: (E) => M(E, "e")
|
|
4309
4311
|
}
|
|
4310
4312
|
),
|
|
4311
4313
|
/* @__PURE__ */ S(
|
|
4312
4314
|
"div",
|
|
4313
4315
|
{
|
|
4314
|
-
style: { ...
|
|
4316
|
+
style: { ...k, top: "50%", left: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
|
|
4315
4317
|
onPointerDown: (E) => M(E, "w")
|
|
4316
4318
|
}
|
|
4317
4319
|
),
|
|
4318
4320
|
/* @__PURE__ */ S(
|
|
4319
4321
|
"div",
|
|
4320
4322
|
{
|
|
4321
|
-
style: { ...
|
|
4323
|
+
style: { ...k, left: "50%", top: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
|
|
4322
4324
|
onPointerDown: (E) => M(E, "n")
|
|
4323
4325
|
}
|
|
4324
4326
|
),
|
|
4325
4327
|
/* @__PURE__ */ S(
|
|
4326
4328
|
"div",
|
|
4327
4329
|
{
|
|
4328
|
-
style: { ...
|
|
4330
|
+
style: { ...k, left: "50%", bottom: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
|
|
4329
4331
|
onPointerDown: (E) => M(E, "s")
|
|
4330
4332
|
}
|
|
4331
4333
|
)
|
|
@@ -4515,7 +4517,7 @@ export {
|
|
|
4515
4517
|
Wr as OutputNode,
|
|
4516
4518
|
Vo as Panel,
|
|
4517
4519
|
is as Position,
|
|
4518
|
-
|
|
4520
|
+
Ar as SelectionBox,
|
|
4519
4521
|
cr as SimpleBezierEdge,
|
|
4520
4522
|
ar as SmoothStepEdge,
|
|
4521
4523
|
Or as StepEdge,
|
|
@@ -4553,7 +4555,7 @@ export {
|
|
|
4553
4555
|
Lo as routeSinglePath,
|
|
4554
4556
|
En as routedPointsToPath,
|
|
4555
4557
|
Pn as snapPosition,
|
|
4556
|
-
|
|
4558
|
+
Ho as useConnection,
|
|
4557
4559
|
Do as useEdges,
|
|
4558
4560
|
So as useEdgesState,
|
|
4559
4561
|
Xo as useHandleConnections,
|
|
@@ -4572,5 +4574,5 @@ export {
|
|
|
4572
4574
|
Zo as useStore,
|
|
4573
4575
|
Oo as useStoreApi,
|
|
4574
4576
|
qo as useUpdateNodeInternals,
|
|
4575
|
-
|
|
4577
|
+
Ao as useViewport
|
|
4576
4578
|
};
|