@infinit-canvas/react 0.1.13 → 0.1.14
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 +1 -1
- package/dist/react-infinite-canvas.js +274 -272
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as D, jsxs as
|
|
2
|
-
import bn, { useRef as K, useState as ne, useMemo as
|
|
1
|
+
import { jsx as D, jsxs as Xt, Fragment as Ye } from "react/jsx-runtime";
|
|
2
|
+
import bn, { useRef as K, useState as ne, useMemo as Ft, useEffect as gt, useCallback as F, useContext as xe, createContext as gr, memo as ie, useLayoutEffect as Yr } from "react";
|
|
3
3
|
import { createPortal as pr } from "react-dom";
|
|
4
4
|
const xr = 160, mr = 60;
|
|
5
5
|
function Xo(t) {
|
|
@@ -986,7 +986,7 @@ function Zr(t, e) {
|
|
|
986
986
|
const i = { worker: r };
|
|
987
987
|
return Zn.set(t, i), i;
|
|
988
988
|
}
|
|
989
|
-
const
|
|
989
|
+
const he = 160, ue = 60, jr = 10;
|
|
990
990
|
function Gr({
|
|
991
991
|
cards: t = [],
|
|
992
992
|
nodes: e = [],
|
|
@@ -1020,7 +1020,7 @@ function Gr({
|
|
|
1020
1020
|
onConnectStart: S,
|
|
1021
1021
|
onConnectEnd: P,
|
|
1022
1022
|
onInit: W,
|
|
1023
|
-
onMoveStart:
|
|
1023
|
+
onMoveStart: J,
|
|
1024
1024
|
onMove: ot,
|
|
1025
1025
|
onMoveEnd: et,
|
|
1026
1026
|
onDelete: st,
|
|
@@ -1034,16 +1034,16 @@ function Gr({
|
|
|
1034
1034
|
initialCamera: Lt = { x: 0, y: 0, zoom: 1 },
|
|
1035
1035
|
fitView: re = !1,
|
|
1036
1036
|
fitViewOptions: dt,
|
|
1037
|
-
nodesDraggable:
|
|
1038
|
-
nodesConnectable:
|
|
1037
|
+
nodesDraggable: Dt = !0,
|
|
1038
|
+
nodesConnectable: Ht = !0,
|
|
1039
1039
|
elementsSelectable: Ut = !0,
|
|
1040
1040
|
multiSelectionKeyCode: yt = "Shift",
|
|
1041
1041
|
selectionOnDrag: kt = !1,
|
|
1042
1042
|
selectionMode: Jt = "partial",
|
|
1043
|
-
connectionMode:
|
|
1044
|
-
connectionRadius:
|
|
1043
|
+
connectionMode: _t = "loose",
|
|
1044
|
+
connectionRadius: ye = 20,
|
|
1045
1045
|
connectOnClick: $e = !1,
|
|
1046
|
-
snapToGrid:
|
|
1046
|
+
snapToGrid: Wt = !1,
|
|
1047
1047
|
snapGrid: jt = [15, 15],
|
|
1048
1048
|
deleteKeyCode: Kt = ["Delete", "Backspace"],
|
|
1049
1049
|
panActivationKeyCode: Ae = " ",
|
|
@@ -1059,7 +1059,7 @@ function Gr({
|
|
|
1059
1059
|
defaultEdgeOptions: Be = {},
|
|
1060
1060
|
autoPanOnNodeDrag: Ln = !0,
|
|
1061
1061
|
autoPanOnConnect: Pn = !0,
|
|
1062
|
-
autoPanSpeed:
|
|
1062
|
+
autoPanSpeed: le = 5,
|
|
1063
1063
|
edgesReconnectable: rr = !1,
|
|
1064
1064
|
elevateNodesOnSelect: Tn = !1,
|
|
1065
1065
|
elevateEdgesOnSelect: $n = !1,
|
|
@@ -1070,7 +1070,7 @@ function Gr({
|
|
|
1070
1070
|
onSelectionDragStop: Dn,
|
|
1071
1071
|
edgeRouting: we = !0
|
|
1072
1072
|
} = {}) {
|
|
1073
|
-
const vt = K(null), Ze = K(null), St = K(null), ct = K({ ...Lt }), be = K([...t]), tt = K([...e]), zt = K([...n]), xn = K(/* @__PURE__ */ new Map()),
|
|
1073
|
+
const vt = K(null), Ze = K(null), St = K(null), ct = K({ ...Lt }), be = K([...t]), tt = K([...e]), zt = K([...n]), xn = K(/* @__PURE__ */ new Map()), ge = K(!1), _e = K(null), [Hn, _n] = ne(!1), qt = K(null), Gt = K(null), je = K(null), Yt = K(null), Ge = K(!1), Ne = K(null), [Oe, Wn] = ne({ x: Lt.x, y: Lt.y, zoom: Lt.zoom }), [Me, Re] = ne(null), ae = Ft(() => /* @__PURE__ */ new Set(), []), oe = Ft(() => /* @__PURE__ */ new Set(), []), We = K(!1), j = K({});
|
|
1074
1074
|
j.current = {
|
|
1075
1075
|
onHudUpdate: r,
|
|
1076
1076
|
onNodesProcessed: i,
|
|
@@ -1101,7 +1101,7 @@ function Gr({
|
|
|
1101
1101
|
onConnectStart: S,
|
|
1102
1102
|
onConnectEnd: P,
|
|
1103
1103
|
onInit: W,
|
|
1104
|
-
onMoveStart:
|
|
1104
|
+
onMoveStart: J,
|
|
1105
1105
|
onMove: ot,
|
|
1106
1106
|
onMoveEnd: et,
|
|
1107
1107
|
onDelete: st,
|
|
@@ -1161,7 +1161,7 @@ function Gr({
|
|
|
1161
1161
|
for (let C = 0; C < u.length; C++)
|
|
1162
1162
|
u[C].type === "select" && w.push({ id: u[C].id, selected: u[C].selected });
|
|
1163
1163
|
w.length > 0 && ((M = St.current) == null || M.postMessage({ type: "edgeSelections", data: { selections: w } }));
|
|
1164
|
-
},
|
|
1164
|
+
}, de = F(() => {
|
|
1165
1165
|
var y;
|
|
1166
1166
|
const u = tt.current.filter((M) => M.selected), w = zt.current.filter((M) => M.selected), c = { nodes: u, edges: w };
|
|
1167
1167
|
(y = Rt.current) == null || y.call(Rt, c);
|
|
@@ -1230,13 +1230,13 @@ function Gr({
|
|
|
1230
1230
|
x: (u - y.left - M.x) / M.zoom,
|
|
1231
1231
|
y: (w - y.top - M.y) / M.zoom
|
|
1232
1232
|
};
|
|
1233
|
-
}, []),
|
|
1233
|
+
}, []), ce = F((u, w) => {
|
|
1234
1234
|
const c = se.current.length > 0 ? se.current : tt.current;
|
|
1235
1235
|
let y = null;
|
|
1236
1236
|
for (let M = c.length - 1; M >= 0; M--) {
|
|
1237
1237
|
const C = c[M];
|
|
1238
1238
|
if (C.hidden) continue;
|
|
1239
|
-
const x = C._absolutePosition || C.position, L = C.width ||
|
|
1239
|
+
const x = C._absolutePosition || C.position, L = C.width || he, k = C.height || ue;
|
|
1240
1240
|
if (u >= x.x && u <= x.x + L && w >= x.y && w <= x.y + k) {
|
|
1241
1241
|
if (C.type === "group") {
|
|
1242
1242
|
y || (y = C);
|
|
@@ -1246,8 +1246,8 @@ function Gr({
|
|
|
1246
1246
|
}
|
|
1247
1247
|
}
|
|
1248
1248
|
return y;
|
|
1249
|
-
}, []),
|
|
1250
|
-
const c = w.width ||
|
|
1249
|
+
}, []), O = F((u, w) => {
|
|
1250
|
+
const c = w.width || he, y = w.height || ue;
|
|
1251
1251
|
if (u.x !== void 0 && u.y !== void 0)
|
|
1252
1252
|
return { x: w.position.x + u.x, y: w.position.y + u.y };
|
|
1253
1253
|
switch (u.position || (u.type === "source" ? "right" : "left")) {
|
|
@@ -1262,11 +1262,11 @@ function Gr({
|
|
|
1262
1262
|
default:
|
|
1263
1263
|
return { x: w.position.x + c, y: w.position.y + y / 2 };
|
|
1264
1264
|
}
|
|
1265
|
-
}, []),
|
|
1266
|
-
const w = u.width ||
|
|
1265
|
+
}, []), Tt = F((u) => {
|
|
1266
|
+
const w = u.width || he, c = u.height || ue;
|
|
1267
1267
|
if (u.handles && u.handles.length > 0)
|
|
1268
1268
|
return u.handles.map((k) => {
|
|
1269
|
-
const Z =
|
|
1269
|
+
const Z = O(k, u);
|
|
1270
1270
|
return { id: k.id || null, type: k.type, x: Z.x, y: Z.y };
|
|
1271
1271
|
});
|
|
1272
1272
|
const y = u.targetPosition || "left", M = u.sourcePosition || "right", C = (k) => {
|
|
@@ -1287,24 +1287,24 @@ function Gr({
|
|
|
1287
1287
|
{ id: null, type: "target", x: x.x, y: x.y },
|
|
1288
1288
|
{ id: null, type: "source", x: L.x, y: L.y }
|
|
1289
1289
|
];
|
|
1290
|
-
}, [
|
|
1291
|
-
const c = tt.current, y = ct.current, M = Math.max(jr,
|
|
1290
|
+
}, [O]), bt = F((u, w) => {
|
|
1291
|
+
const c = tt.current, y = ct.current, M = Math.max(jr, ye) / y.zoom;
|
|
1292
1292
|
for (let C = c.length - 1; C >= 0; C--) {
|
|
1293
1293
|
const x = c[C];
|
|
1294
1294
|
if (x.hidden) continue;
|
|
1295
|
-
const L =
|
|
1295
|
+
const L = Tt(x);
|
|
1296
1296
|
for (const k of L)
|
|
1297
1297
|
if (Math.abs(u - k.x) < M && Math.abs(w - k.y) < M)
|
|
1298
1298
|
return { nodeId: x.id, handleId: k.id, type: k.type, x: k.x, y: k.y };
|
|
1299
1299
|
}
|
|
1300
1300
|
return null;
|
|
1301
|
-
}, [
|
|
1301
|
+
}, [Tt]), $t = F((u, w) => {
|
|
1302
1302
|
const y = 8 / ct.current.zoom;
|
|
1303
1303
|
for (let M = zt.current.length - 1; M >= 0; M--) {
|
|
1304
1304
|
const C = zt.current[M], x = tt.current.find((it) => it.id === C.source), L = tt.current.find((it) => it.id === C.target);
|
|
1305
1305
|
if (!x || !L) continue;
|
|
1306
|
-
const k = x.width ||
|
|
1307
|
-
if (Or(u, w, G,
|
|
1306
|
+
const k = x.width || he, Z = x.height || ue, H = L.height || ue, G = x.position.x + k, Q = x.position.y + Z / 2, Mt = L.position.x, At = L.position.y + H / 2;
|
|
1307
|
+
if (Or(u, w, G, Q, Mt, At) < y) return C;
|
|
1308
1308
|
}
|
|
1309
1309
|
return null;
|
|
1310
1310
|
}, []);
|
|
@@ -1325,15 +1325,15 @@ function Gr({
|
|
|
1325
1325
|
edgeRouting: we
|
|
1326
1326
|
});
|
|
1327
1327
|
x.onmessage = (H) => {
|
|
1328
|
-
var G,
|
|
1329
|
-
H.data.type === "hud" && ((G = ze.current) == null || G.call(ze, H.data.data)), H.data.type === "ready" && _n(!0), H.data.type === "nodesProcessed" && ((
|
|
1328
|
+
var G, Q, Mt, At;
|
|
1329
|
+
H.data.type === "hud" && ((G = ze.current) == null || G.call(ze, H.data.data)), H.data.type === "ready" && _n(!0), H.data.type === "nodesProcessed" && ((Q = Xe.current) == null || Q.call(Xe, H.data.data)), H.data.type === "error" && ((At = (Mt = j.current).onError) == null || At.call(Mt, "worker-error", H.data.message || "Canvas worker error"));
|
|
1330
1330
|
}, x.onerror = (H) => {
|
|
1331
|
-
var G,
|
|
1332
|
-
(
|
|
1331
|
+
var G, Q;
|
|
1332
|
+
(Q = (G = j.current).onError) == null || Q.call(G, "worker-error", H.message || "Canvas worker crashed");
|
|
1333
1333
|
}, St.current = x;
|
|
1334
1334
|
const L = new ResizeObserver((H) => {
|
|
1335
|
-
const { width: G, height:
|
|
1336
|
-
x.postMessage({ type: "resize", data: { width: G, height:
|
|
1335
|
+
const { width: G, height: Q } = H[0].contentRect;
|
|
1336
|
+
x.postMessage({ type: "resize", data: { width: G, height: Q } });
|
|
1337
1337
|
});
|
|
1338
1338
|
L.observe(w);
|
|
1339
1339
|
let k, Z;
|
|
@@ -1347,7 +1347,7 @@ function Gr({
|
|
|
1347
1347
|
var u;
|
|
1348
1348
|
(u = St.current) == null || u.postMessage({ type: "edgeRouting", data: { enabled: we } });
|
|
1349
1349
|
}, [we]);
|
|
1350
|
-
const
|
|
1350
|
+
const fe = K(0), ut = F((u = null) => {
|
|
1351
1351
|
var y, M, C;
|
|
1352
1352
|
const w = ct.current;
|
|
1353
1353
|
if (me) {
|
|
@@ -1360,22 +1360,22 @@ function Gr({
|
|
|
1360
1360
|
(y = St.current) == null || y.postMessage({ type: "camera", data: { camera: { ...w } } });
|
|
1361
1361
|
const c = { x: w.x, y: w.y, zoom: w.zoom };
|
|
1362
1362
|
(C = (M = j.current).onMove) == null || C.call(M, u, c);
|
|
1363
|
-
for (const x of
|
|
1364
|
-
cancelAnimationFrame(
|
|
1363
|
+
for (const x of ae) x(c);
|
|
1364
|
+
cancelAnimationFrame(fe.current), fe.current = requestAnimationFrame(() => {
|
|
1365
1365
|
Wn({ x: w.x, y: w.y, zoom: w.zoom });
|
|
1366
1366
|
});
|
|
1367
|
-
}, [
|
|
1367
|
+
}, [ae, me]), Vt = F(() => {
|
|
1368
1368
|
var c, y;
|
|
1369
1369
|
const u = Gt.current, w = je.current;
|
|
1370
1370
|
u && w ? ((c = St.current) == null || c.postMessage({ type: "connecting", data: { from: u.startPos, to: w, _routedPoints: null } }), Re({ source: u.sourceId, sourceHandle: u.sourceHandle, target: null, targetHandle: null })) : ((y = St.current) == null || y.postMessage({ type: "connecting", data: null }), Re(null));
|
|
1371
1371
|
}, []), Ce = F(() => {
|
|
1372
1372
|
var w, c;
|
|
1373
|
-
const u =
|
|
1373
|
+
const u = Yt.current;
|
|
1374
1374
|
u ? (w = St.current) == null || w.postMessage({ type: "selectionBox", data: u }) : (c = St.current) == null || c.postMessage({ type: "selectionBox", data: null });
|
|
1375
1375
|
}, []), Fn = F((u) => {
|
|
1376
|
-
var x, L, k, Z, H, G,
|
|
1376
|
+
var x, L, k, Z, H, G, Q, Mt, At, nt, it, Et, Bt, Zt, te, Qt, on, pe;
|
|
1377
1377
|
const w = tt.current.length > 0, c = It(u.clientX, u.clientY), y = Ge.current;
|
|
1378
|
-
if (w &&
|
|
1378
|
+
if (w && Ht && !y) {
|
|
1379
1379
|
const q = bt(c.x, c.y);
|
|
1380
1380
|
if ($e && Ne.current && q) {
|
|
1381
1381
|
const rt = Ne.current;
|
|
@@ -1386,7 +1386,7 @@ function Gr({
|
|
|
1386
1386
|
Ne.current = null;
|
|
1387
1387
|
return;
|
|
1388
1388
|
}
|
|
1389
|
-
if (
|
|
1389
|
+
if (_t === "strict" ? q && q.type === "source" : q != null) {
|
|
1390
1390
|
if ($e) {
|
|
1391
1391
|
Ne.current = { nodeId: q.nodeId, handleId: q.handleId || null, handleType: q.type }, (k = (L = j.current).onConnectStart) == null || k.call(L, u, { nodeId: q.nodeId, handleId: q.handleId, handleType: q.type });
|
|
1392
1392
|
return;
|
|
@@ -1418,7 +1418,7 @@ function Gr({
|
|
|
1418
1418
|
return !1;
|
|
1419
1419
|
};
|
|
1420
1420
|
if (w) {
|
|
1421
|
-
const q =
|
|
1421
|
+
const q = ce(c.x, c.y);
|
|
1422
1422
|
if (q) {
|
|
1423
1423
|
if (Nt.current && Ut) {
|
|
1424
1424
|
const mt = [];
|
|
@@ -1440,16 +1440,16 @@ function Gr({
|
|
|
1440
1440
|
{ type: "add", item: { ...tt.current[rt], selected: !0 } }
|
|
1441
1441
|
]);
|
|
1442
1442
|
}
|
|
1443
|
-
|
|
1443
|
+
de();
|
|
1444
1444
|
}
|
|
1445
1445
|
}
|
|
1446
|
-
if ((
|
|
1446
|
+
if ((Q = Fe.current) == null || Q.call(Fe, u, q), Dt && !M(u.target)) {
|
|
1447
1447
|
const mt = q.selected;
|
|
1448
1448
|
let rt = null;
|
|
1449
1449
|
if (q.parentId && q.extent === "parent") {
|
|
1450
1450
|
const ft = tt.current.find((ee) => ee.id === q.parentId);
|
|
1451
1451
|
if (ft) {
|
|
1452
|
-
const ee = ft.width ||
|
|
1452
|
+
const ee = ft.width || he, sn = ft.height || ue, wn = q.width || ((Mt = q.measured) == null ? void 0 : Mt.width) || he, an = q.height || ((At = q.measured) == null ? void 0 : At.height) || ue;
|
|
1453
1453
|
rt = { minX: 0, minY: 0, maxX: ee - wn, maxY: sn - an };
|
|
1454
1454
|
}
|
|
1455
1455
|
}
|
|
@@ -1465,7 +1465,7 @@ function Gr({
|
|
|
1465
1465
|
if (ft.parentId && ft.extent === "parent") {
|
|
1466
1466
|
const an = tt.current.find((qn) => qn.id === ft.parentId);
|
|
1467
1467
|
if (an) {
|
|
1468
|
-
const qn = an.width ||
|
|
1468
|
+
const qn = an.width || he, Wr = an.height || ue, Fr = ft.width || ((sn = ft.measured) == null ? void 0 : sn.width) || he, Xr = ft.height || ((wn = ft.measured) == null ? void 0 : wn.height) || ue;
|
|
1469
1469
|
ee = { minX: 0, minY: 0, maxX: qn - Fr, maxY: Wr - Xr };
|
|
1470
1470
|
}
|
|
1471
1471
|
}
|
|
@@ -1473,7 +1473,7 @@ function Gr({
|
|
|
1473
1473
|
}) : []
|
|
1474
1474
|
}, (nt = vt.current) == null || nt.setPointerCapture(u.pointerId), (it = Qe.current) == null || it.call(Qe, u, q), qt.current.selectedStarts.length > 0) {
|
|
1475
1475
|
const ft = tt.current.filter((ee) => ee.selected);
|
|
1476
|
-
(
|
|
1476
|
+
(Bt = (Et = j.current).onSelectionDragStart) == null || Bt.call(Et, u, ft);
|
|
1477
1477
|
}
|
|
1478
1478
|
if (Nt.current) {
|
|
1479
1479
|
const ft = [{ id: q.id, type: "position", dragging: !0 }];
|
|
@@ -1486,7 +1486,7 @@ function Gr({
|
|
|
1486
1486
|
}
|
|
1487
1487
|
}
|
|
1488
1488
|
if (zt.current.length > 0 && Ut) {
|
|
1489
|
-
const q =
|
|
1489
|
+
const q = $t(c.x, c.y);
|
|
1490
1490
|
if (q) {
|
|
1491
1491
|
if (Pt.current) {
|
|
1492
1492
|
const mt = [];
|
|
@@ -1508,7 +1508,7 @@ function Gr({
|
|
|
1508
1508
|
{ type: "add", item: { ...zt.current[rt], selected: !0 } }
|
|
1509
1509
|
]);
|
|
1510
1510
|
}
|
|
1511
|
-
|
|
1511
|
+
de();
|
|
1512
1512
|
}
|
|
1513
1513
|
}
|
|
1514
1514
|
(Zt = Ve.current) == null || Zt.call(Ve, u, q);
|
|
@@ -1517,35 +1517,35 @@ function Gr({
|
|
|
1517
1517
|
}
|
|
1518
1518
|
if (!y) {
|
|
1519
1519
|
const q = tt.current.filter((rt) => rt.selected).map((rt) => ({ id: rt.id, type: "select", selected: !1 })), mt = zt.current.filter((rt) => rt.selected).map((rt) => ({ id: rt.id, type: "select", selected: !1 }));
|
|
1520
|
-
q.length && Nt.current && Nt.current(q), mt.length && Pt.current && Pt.current(mt), (q.length || mt.length) &&
|
|
1520
|
+
q.length && Nt.current && Nt.current(q), mt.length && Pt.current && Pt.current(mt), (q.length || mt.length) && de();
|
|
1521
1521
|
}
|
|
1522
1522
|
if ((te = tn.current) == null || te.call(tn, u), kt || y) {
|
|
1523
|
-
|
|
1523
|
+
Yt.current = { startWorld: { ...c }, endWorld: { ...c } }, (Qt = vt.current) == null || Qt.setPointerCapture(u.pointerId), Ce();
|
|
1524
1524
|
return;
|
|
1525
1525
|
}
|
|
1526
|
-
C(u.target) || (
|
|
1527
|
-
}, [It,
|
|
1526
|
+
C(u.target) || (ge.current = !0, _e.current = { x: u.clientX, y: u.clientY }, (on = vt.current) == null || on.classList.add("dragging"), (pe = vt.current) == null || pe.setPointerCapture(u.pointerId));
|
|
1527
|
+
}, [It, ce, bt, $t, Dt, Ht, Ut, kt, Vt, Ce, de, De, He]), Xn = F((u) => {
|
|
1528
1528
|
var c, y, M, C;
|
|
1529
1529
|
if (Gt.current) {
|
|
1530
1530
|
if (je.current = It(u.clientX, u.clientY), Vt(), Pn) {
|
|
1531
1531
|
const x = vt.current;
|
|
1532
1532
|
if (x) {
|
|
1533
1533
|
const L = x.getBoundingClientRect(), k = 40, Z = u.clientX - L.left, H = u.clientY - L.top;
|
|
1534
|
-
let G = 0,
|
|
1535
|
-
Z < k ? G =
|
|
1534
|
+
let G = 0, Q = 0;
|
|
1535
|
+
Z < k ? G = le : Z > L.width - k && (G = -le), H < k ? Q = le : H > L.height - k && (Q = -le), (G || Q) && (ct.current.x += G, ct.current.y += Q, ut(u));
|
|
1536
1536
|
}
|
|
1537
1537
|
}
|
|
1538
1538
|
return;
|
|
1539
1539
|
}
|
|
1540
|
-
if (
|
|
1541
|
-
|
|
1542
|
-
const x =
|
|
1540
|
+
if (Yt.current) {
|
|
1541
|
+
Yt.current.endWorld = It(u.clientX, u.clientY), Ce();
|
|
1542
|
+
const x = Yt.current, L = Math.min(x.startWorld.x, x.endWorld.x), k = Math.min(x.startWorld.y, x.endWorld.y), Z = Math.max(x.startWorld.x, x.endWorld.x), H = Math.max(x.startWorld.y, x.endWorld.y);
|
|
1543
1543
|
if (Nt.current) {
|
|
1544
1544
|
const G = [];
|
|
1545
|
-
for (const
|
|
1546
|
-
if (
|
|
1547
|
-
const Mt =
|
|
1548
|
-
nt !== !!
|
|
1545
|
+
for (const Q of tt.current) {
|
|
1546
|
+
if (Q.hidden) continue;
|
|
1547
|
+
const Mt = Q.width || he, At = Q.height || ue, nt = Jt === "full" ? Q.position.x >= L && Q.position.x + Mt <= Z && Q.position.y >= k && Q.position.y + At <= H : Q.position.x + Mt > L && Q.position.x < Z && Q.position.y + At > k && Q.position.y < H;
|
|
1548
|
+
nt !== !!Q.selected && G.push({ id: Q.id, type: "select", selected: nt });
|
|
1549
1549
|
}
|
|
1550
1550
|
G.length && Nt.current(G);
|
|
1551
1551
|
}
|
|
@@ -1554,32 +1554,32 @@ function Gr({
|
|
|
1554
1554
|
if (qt.current) {
|
|
1555
1555
|
const x = It(u.clientX, u.clientY), L = qt.current, k = x.x - L.startMouse.x, Z = x.y - L.startMouse.y;
|
|
1556
1556
|
let H = { x: L.startPos.x + k, y: L.startPos.y + Z };
|
|
1557
|
-
if (
|
|
1557
|
+
if (Wt && (H = sr(H, jt)), ve && (H = ir(H, ve)), L.parentClamp) {
|
|
1558
1558
|
const nt = L.parentClamp;
|
|
1559
1559
|
H = { x: Math.max(nt.minX, Math.min(H.x, nt.maxX)), y: Math.max(nt.minY, Math.min(H.y, nt.maxY)) };
|
|
1560
1560
|
}
|
|
1561
1561
|
const G = [{ id: L.id, position: H }];
|
|
1562
1562
|
for (const nt of L.selectedStarts) {
|
|
1563
1563
|
let it = { x: nt.startPos.x + k, y: nt.startPos.y + Z };
|
|
1564
|
-
if (
|
|
1564
|
+
if (Wt && (it = sr(it, jt)), ve && (it = ir(it, ve)), nt.parentClamp) {
|
|
1565
1565
|
const Et = nt.parentClamp;
|
|
1566
1566
|
it = { x: Math.max(Et.minX, Math.min(it.x, Et.maxX)), y: Math.max(Et.minY, Math.min(it.y, Et.maxY)) };
|
|
1567
1567
|
}
|
|
1568
1568
|
G.push({ id: nt.id, position: it });
|
|
1569
1569
|
}
|
|
1570
|
-
const
|
|
1570
|
+
const Q = [];
|
|
1571
1571
|
for (const nt of G) {
|
|
1572
1572
|
const it = tt.current.find((Et) => Et.id === nt.id);
|
|
1573
1573
|
if (it) {
|
|
1574
1574
|
it.position = nt.position, it.dragging = !0;
|
|
1575
1575
|
let Et = nt.position;
|
|
1576
1576
|
if (it.parentId) {
|
|
1577
|
-
let
|
|
1578
|
-
for (;
|
|
1579
|
-
Zt +=
|
|
1577
|
+
let Bt = tt.current.find((Qt) => Qt.id === it.parentId), Zt = nt.position.x, te = nt.position.y;
|
|
1578
|
+
for (; Bt; )
|
|
1579
|
+
Zt += Bt.position.x, te += Bt.position.y, Bt = Bt.parentId ? tt.current.find((Qt) => Qt.id === Bt.parentId) : null;
|
|
1580
1580
|
Et = { x: Zt, y: te };
|
|
1581
1581
|
}
|
|
1582
|
-
|
|
1582
|
+
Q.push({
|
|
1583
1583
|
id: nt.id,
|
|
1584
1584
|
position: nt.position,
|
|
1585
1585
|
_absolutePosition: Et,
|
|
@@ -1593,43 +1593,43 @@ function Gr({
|
|
|
1593
1593
|
const Mt = new Set(G.map((nt) => nt.id));
|
|
1594
1594
|
for (const nt of tt.current)
|
|
1595
1595
|
if (nt.parentId && Mt.has(nt.parentId) && !Mt.has(nt.id)) {
|
|
1596
|
-
let it = tt.current.find((Zt) => Zt.id === nt.parentId), Et = nt.position.x,
|
|
1596
|
+
let it = tt.current.find((Zt) => Zt.id === nt.parentId), Et = nt.position.x, Bt = nt.position.y;
|
|
1597
1597
|
for (; it; )
|
|
1598
|
-
Et += it.position.x,
|
|
1599
|
-
|
|
1598
|
+
Et += it.position.x, Bt += it.position.y, it = it.parentId ? tt.current.find((Zt) => Zt.id === it.parentId) : null;
|
|
1599
|
+
Q.push({
|
|
1600
1600
|
id: nt.id,
|
|
1601
1601
|
position: nt.position,
|
|
1602
|
-
_absolutePosition: { x: Et, y:
|
|
1602
|
+
_absolutePosition: { x: Et, y: Bt },
|
|
1603
1603
|
width: nt.width,
|
|
1604
1604
|
height: nt.height,
|
|
1605
1605
|
dragging: !1,
|
|
1606
1606
|
selected: nt.selected
|
|
1607
1607
|
});
|
|
1608
1608
|
}
|
|
1609
|
-
if ((c = St.current) == null || c.postMessage({ type: "nodePositions", data: { updates:
|
|
1609
|
+
if ((c = St.current) == null || c.postMessage({ type: "nodePositions", data: { updates: Q } }), Ln) {
|
|
1610
1610
|
const nt = vt.current;
|
|
1611
1611
|
if (nt) {
|
|
1612
|
-
const it = nt.getBoundingClientRect(), Et = 40,
|
|
1612
|
+
const it = nt.getBoundingClientRect(), Et = 40, Bt = u.clientX - it.left, Zt = u.clientY - it.top;
|
|
1613
1613
|
let te = 0, Qt = 0;
|
|
1614
|
-
|
|
1614
|
+
Bt < Et ? te = le : Bt > it.width - Et && (te = -le), Zt < Et ? Qt = le : Zt > it.height - Et && (Qt = -le), (te || Qt) && (ct.current.x += te, ct.current.y += Qt, ut(u));
|
|
1615
1615
|
}
|
|
1616
1616
|
}
|
|
1617
|
-
const
|
|
1618
|
-
if (
|
|
1617
|
+
const At = tt.current.find((nt) => nt.id === L.id);
|
|
1618
|
+
if (At && ((y = Je.current) == null || y.call(Je, u, At)), L.selectedStarts.length > 0) {
|
|
1619
1619
|
const nt = tt.current.filter((it) => it.selected);
|
|
1620
1620
|
(C = (M = j.current).onSelectionDrag) == null || C.call(M, u, nt);
|
|
1621
1621
|
}
|
|
1622
1622
|
return;
|
|
1623
1623
|
}
|
|
1624
|
-
if (!
|
|
1624
|
+
if (!ge.current) return;
|
|
1625
1625
|
const w = ct.current;
|
|
1626
1626
|
w.x += u.clientX - _e.current.x, w.y += u.clientY - _e.current.y, _e.current = { x: u.clientX, y: u.clientY }, ut();
|
|
1627
1627
|
}, [ut, It, Vt, Ce]), Le = F((u) => {
|
|
1628
1628
|
var w, c, y, M, C, x, L;
|
|
1629
1629
|
if (Gt.current) {
|
|
1630
1630
|
const k = It(u.clientX, u.clientY), Z = bt(k.x, k.y);
|
|
1631
|
-
if (Z && Z.nodeId !== Gt.current.sourceId && (
|
|
1632
|
-
const
|
|
1631
|
+
if (Z && Z.nodeId !== Gt.current.sourceId && (_t === "loose" || Z.type === "target")) {
|
|
1632
|
+
const Q = Gt.current.sourceType === "target" ? {
|
|
1633
1633
|
source: Z.nodeId,
|
|
1634
1634
|
target: Gt.current.sourceId,
|
|
1635
1635
|
sourceHandle: Z.handleId || null,
|
|
@@ -1640,28 +1640,28 @@ function Gr({
|
|
|
1640
1640
|
sourceHandle: Gt.current.sourceHandle,
|
|
1641
1641
|
targetHandle: Z.handleId || null
|
|
1642
1642
|
};
|
|
1643
|
-
(j.current.isValidConnection ? j.current.isValidConnection(
|
|
1643
|
+
(j.current.isValidConnection ? j.current.isValidConnection(Q) : !0) && ((w = ke.current) == null || w.call(ke, { ...Q, ...Be }));
|
|
1644
1644
|
}
|
|
1645
1645
|
(y = (c = j.current).onConnectEnd) == null || y.call(c, u.nativeEvent || u), Gt.current = null, je.current = null, Vt();
|
|
1646
1646
|
return;
|
|
1647
1647
|
}
|
|
1648
|
-
if (
|
|
1649
|
-
|
|
1648
|
+
if (Yt.current) {
|
|
1649
|
+
Yt.current = null, Ce(), de();
|
|
1650
1650
|
return;
|
|
1651
1651
|
}
|
|
1652
1652
|
if (qt.current) {
|
|
1653
1653
|
const k = qt.current;
|
|
1654
1654
|
if (Nt.current) {
|
|
1655
|
-
const H = tt.current.find((
|
|
1655
|
+
const H = tt.current.find((Q) => Q.id === k.id), G = [{
|
|
1656
1656
|
id: k.id,
|
|
1657
1657
|
type: "position",
|
|
1658
1658
|
position: H ? { ...H.position } : void 0,
|
|
1659
1659
|
dragging: !1
|
|
1660
1660
|
}];
|
|
1661
|
-
for (const
|
|
1662
|
-
const Mt = tt.current.find((
|
|
1661
|
+
for (const Q of k.selectedStarts) {
|
|
1662
|
+
const Mt = tt.current.find((At) => At.id === Q.id);
|
|
1663
1663
|
G.push({
|
|
1664
|
-
id:
|
|
1664
|
+
id: Q.id,
|
|
1665
1665
|
type: "position",
|
|
1666
1666
|
position: Mt ? { ...Mt.position } : void 0,
|
|
1667
1667
|
dragging: !1
|
|
@@ -1680,8 +1680,8 @@ function Gr({
|
|
|
1680
1680
|
Z && ((x = Ke.current) == null || x.call(Ke, u, Z));
|
|
1681
1681
|
return;
|
|
1682
1682
|
}
|
|
1683
|
-
|
|
1684
|
-
}, [It, bt, Vt, Ce,
|
|
1683
|
+
ge.current = !1, (L = vt.current) == null || L.classList.remove("dragging");
|
|
1684
|
+
}, [It, bt, Vt, Ce, de]);
|
|
1685
1685
|
gt(() => {
|
|
1686
1686
|
const u = vt.current;
|
|
1687
1687
|
if (!u) return;
|
|
@@ -1718,8 +1718,8 @@ function Gr({
|
|
|
1718
1718
|
x.preventDefault();
|
|
1719
1719
|
const L = x.touches[0].clientX - x.touches[1].clientX, k = x.touches[0].clientY - x.touches[1].clientY, Z = Math.hypot(L, k), H = Z / w;
|
|
1720
1720
|
w = Z;
|
|
1721
|
-
const G = ct.current,
|
|
1722
|
-
G.x =
|
|
1721
|
+
const G = ct.current, Q = c.x, Mt = c.y;
|
|
1722
|
+
G.x = Q - (Q - G.x) * H, G.y = Mt - (Mt - G.y) * H, G.zoom = Math.min(lt, Math.max(at, G.zoom * H)), ut(x);
|
|
1723
1723
|
}
|
|
1724
1724
|
}, C = () => {
|
|
1725
1725
|
w = 0, c = null;
|
|
@@ -1732,32 +1732,32 @@ function Gr({
|
|
|
1732
1732
|
const u = vt.current;
|
|
1733
1733
|
if (!u) return;
|
|
1734
1734
|
const w = (c) => {
|
|
1735
|
-
var H, G,
|
|
1735
|
+
var H, G, Q, Mt;
|
|
1736
1736
|
const y = It(c.clientX, c.clientY);
|
|
1737
|
-
if (
|
|
1738
|
-
(G = (H = j.current).onNodeDoubleClick) == null || G.call(H, c,
|
|
1737
|
+
if (ce(y.x, y.y)) {
|
|
1738
|
+
(G = (H = j.current).onNodeDoubleClick) == null || G.call(H, c, ce(y.x, y.y));
|
|
1739
1739
|
return;
|
|
1740
1740
|
}
|
|
1741
|
-
const M =
|
|
1741
|
+
const M = $t(y.x, y.y);
|
|
1742
1742
|
if (M) {
|
|
1743
|
-
(Mt = (
|
|
1743
|
+
(Mt = (Q = j.current).onEdgeDoubleClick) == null || Mt.call(Q, c, M);
|
|
1744
1744
|
return;
|
|
1745
1745
|
}
|
|
1746
1746
|
const C = 1.5, x = u.getBoundingClientRect(), L = c.clientX - x.left, k = c.clientY - x.top, Z = ct.current;
|
|
1747
1747
|
Z.x = L - (L - Z.x) * C, Z.y = k - (k - Z.y) * C, Z.zoom = Math.min(lt, Math.max(at, Z.zoom * C)), ut(c);
|
|
1748
1748
|
};
|
|
1749
1749
|
return u.addEventListener("dblclick", w), () => u.removeEventListener("dblclick", w);
|
|
1750
|
-
}, [gn, ut, at, lt, It,
|
|
1750
|
+
}, [gn, ut, at, lt, It, ce, $t]), gt(() => {
|
|
1751
1751
|
const u = vt.current;
|
|
1752
1752
|
if (!u) return;
|
|
1753
1753
|
const w = (c) => {
|
|
1754
1754
|
var x, L, k, Z, H, G;
|
|
1755
|
-
const y = It(c.clientX, c.clientY), M =
|
|
1755
|
+
const y = It(c.clientX, c.clientY), M = ce(y.x, y.y);
|
|
1756
1756
|
if (M) {
|
|
1757
1757
|
(L = (x = j.current).onNodeContextMenu) == null || L.call(x, c, M);
|
|
1758
1758
|
return;
|
|
1759
1759
|
}
|
|
1760
|
-
const C =
|
|
1760
|
+
const C = $t(y.x, y.y);
|
|
1761
1761
|
if (C) {
|
|
1762
1762
|
(Z = (k = j.current).onEdgeContextMenu) == null || Z.call(k, c, C);
|
|
1763
1763
|
return;
|
|
@@ -1765,29 +1765,29 @@ function Gr({
|
|
|
1765
1765
|
(G = (H = j.current).onPaneContextMenu) == null || G.call(H, c);
|
|
1766
1766
|
};
|
|
1767
1767
|
return u.addEventListener("contextmenu", w), () => u.removeEventListener("contextmenu", w);
|
|
1768
|
-
}, [It,
|
|
1768
|
+
}, [It, ce, $t]), gt(() => {
|
|
1769
1769
|
const u = vt.current;
|
|
1770
1770
|
if (!u) return;
|
|
1771
1771
|
let w = null, c = null;
|
|
1772
1772
|
const y = (x) => {
|
|
1773
|
-
var Z, H, G,
|
|
1774
|
-
if ((H = (Z = j.current).onPaneMouseMove) == null || H.call(Z, x),
|
|
1775
|
-
const L = It(x.clientX, x.clientY), k =
|
|
1776
|
-
if (k !== w && (w && ((
|
|
1777
|
-
const pe =
|
|
1778
|
-
pe !== c && (c && ((
|
|
1773
|
+
var Z, H, G, Q, Mt, At, nt, it, Et, Bt, Zt, te, Qt, on;
|
|
1774
|
+
if ((H = (Z = j.current).onPaneMouseMove) == null || H.call(Z, x), ge.current || qt.current || Gt.current || Yt.current) return;
|
|
1775
|
+
const L = It(x.clientX, x.clientY), k = ce(L.x, L.y);
|
|
1776
|
+
if (k !== w && (w && ((Q = (G = j.current).onNodeMouseLeave) == null || Q.call(G, x, w)), k && ((At = (Mt = j.current).onNodeMouseEnter) == null || At.call(Mt, x, k)), w = k), k && ((it = (nt = j.current).onNodeMouseMove) == null || it.call(nt, x, k)), !k) {
|
|
1777
|
+
const pe = $t(L.x, L.y);
|
|
1778
|
+
pe !== c && (c && ((Bt = (Et = j.current).onEdgeMouseLeave) == null || Bt.call(Et, x, c)), pe && ((te = (Zt = j.current).onEdgeMouseEnter) == null || te.call(Zt, x, pe)), c = pe), pe && ((on = (Qt = j.current).onEdgeMouseMove) == null || on.call(Qt, x, pe));
|
|
1779
1779
|
}
|
|
1780
1780
|
}, M = (x) => {
|
|
1781
1781
|
var L, k;
|
|
1782
1782
|
return (k = (L = j.current).onPaneMouseEnter) == null ? void 0 : k.call(L, x);
|
|
1783
1783
|
}, C = (x) => {
|
|
1784
|
-
var L, k, Z, H, G,
|
|
1785
|
-
(k = (L = j.current).onPaneMouseLeave) == null || k.call(L, x), w && ((H = (Z = j.current).onNodeMouseLeave) == null || H.call(Z, x, w), w = null), c && ((
|
|
1784
|
+
var L, k, Z, H, G, Q;
|
|
1785
|
+
(k = (L = j.current).onPaneMouseLeave) == null || k.call(L, x), w && ((H = (Z = j.current).onNodeMouseLeave) == null || H.call(Z, x, w), w = null), c && ((Q = (G = j.current).onEdgeMouseLeave) == null || Q.call(G, x, c), c = null);
|
|
1786
1786
|
};
|
|
1787
1787
|
return u.addEventListener("mousemove", y), u.addEventListener("mouseenter", M), u.addEventListener("mouseleave", C), () => {
|
|
1788
1788
|
u.removeEventListener("mousemove", y), u.removeEventListener("mouseenter", M), u.removeEventListener("mouseleave", C);
|
|
1789
1789
|
};
|
|
1790
|
-
}, [It,
|
|
1790
|
+
}, [It, ce, $t]), gt(() => {
|
|
1791
1791
|
const u = Array.isArray(Kt) ? Kt : [Kt], w = async (c) => {
|
|
1792
1792
|
var y, M, C, x;
|
|
1793
1793
|
if (u.includes(c.key)) {
|
|
@@ -1940,14 +1940,14 @@ function Gr({
|
|
|
1940
1940
|
if (!c) return;
|
|
1941
1941
|
const y = c.getBoundingClientRect();
|
|
1942
1942
|
u.position = {
|
|
1943
|
-
x: Math.round(-w.x / w.zoom + y.width / 2 / w.zoom) -
|
|
1944
|
-
y: Math.round(-w.y / w.zoom + y.height / 2 / w.zoom) -
|
|
1943
|
+
x: Math.round(-w.x / w.zoom + y.width / 2 / w.zoom) - he / 2,
|
|
1944
|
+
y: Math.round(-w.y / w.zoom + y.height / 2 / w.zoom) - ue / 2
|
|
1945
1945
|
};
|
|
1946
1946
|
}
|
|
1947
1947
|
u.data || (u.data = { label: u.id }), Nt.current && Nt.current([{ type: "add", item: u }]);
|
|
1948
1948
|
}, []), Yn = F(() => ({ ...ct.current }), []), Un = F((u) => {
|
|
1949
1949
|
ct.current = { ...ct.current, ...u }, ut();
|
|
1950
|
-
}, [ut]), Hr = F((u) => It(u.x, u.y), [It]), or = n, _r =
|
|
1950
|
+
}, [ut]), Hr = F((u) => It(u.x, u.y), [It]), or = n, _r = Ft(() => ({
|
|
1951
1951
|
wrapRef: vt,
|
|
1952
1952
|
canvasRef: Ze,
|
|
1953
1953
|
workerRef: St,
|
|
@@ -1960,11 +1960,11 @@ function Gr({
|
|
|
1960
1960
|
onEdgesChangeRef: Pt,
|
|
1961
1961
|
sendCamera: ut,
|
|
1962
1962
|
screenToWorld: It,
|
|
1963
|
-
viewportListeners:
|
|
1963
|
+
viewportListeners: ae,
|
|
1964
1964
|
selectionListeners: oe,
|
|
1965
1965
|
zoomMin: at,
|
|
1966
1966
|
zoomMax: lt,
|
|
1967
|
-
snapToGrid:
|
|
1967
|
+
snapToGrid: Wt,
|
|
1968
1968
|
snapGrid: jt,
|
|
1969
1969
|
nodeExtent: ve,
|
|
1970
1970
|
defaultEdgeOptions: Be,
|
|
@@ -1987,7 +1987,7 @@ function Gr({
|
|
|
1987
1987
|
get connection() {
|
|
1988
1988
|
return Me;
|
|
1989
1989
|
}
|
|
1990
|
-
}), [e, n, or, Oe, Me, ut, It, mn,
|
|
1990
|
+
}), [e, n, or, Oe, Me, ut, It, mn, ae, oe, at, lt, Wt, jt, ve, Be, we, De, He]);
|
|
1991
1991
|
return {
|
|
1992
1992
|
wrapRef: vt,
|
|
1993
1993
|
canvasRef: Ze,
|
|
@@ -2148,8 +2148,8 @@ function to({ node: t, nodeType: e }) {
|
|
|
2148
2148
|
const W = () => {
|
|
2149
2149
|
var V, ht;
|
|
2150
2150
|
P && ((ht = (V = r.current.onNodesChangeRef).current) == null || ht.call(V, P), P = null), S = null;
|
|
2151
|
-
},
|
|
2152
|
-
var
|
|
2151
|
+
}, J = (V) => {
|
|
2152
|
+
var Ht, Ut;
|
|
2153
2153
|
if (!a.current) return;
|
|
2154
2154
|
const ht = r.current.cameraRef.current, wt = A.getBoundingClientRect(), at = (V.clientX - wt.left - ht.x) / ht.zoom, lt = (V.clientY - wt.top - ht.y) / ht.zoom, Lt = at - a.current.startMouse.x, re = lt - a.current.startMouse.y;
|
|
2155
2155
|
let dt = { x: a.current.startPos.x + Lt, y: a.current.startPos.y + re };
|
|
@@ -2159,10 +2159,10 @@ function to({ node: t, nodeType: e }) {
|
|
|
2159
2159
|
}), t.parentId && t.extent === "parent") {
|
|
2160
2160
|
const yt = r.current.nodesRef.current.find((kt) => kt.id === t.parentId);
|
|
2161
2161
|
if (yt) {
|
|
2162
|
-
const kt = yt.width || 160, Jt = yt.height || 60,
|
|
2162
|
+
const kt = yt.width || 160, Jt = yt.height || 60, _t = t.width || ((Ht = t.measured) == null ? void 0 : Ht.width) || 160, ye = t.height || ((Ut = t.measured) == null ? void 0 : Ut.height) || 60;
|
|
2163
2163
|
dt = {
|
|
2164
|
-
x: Math.max(0, Math.min(dt.x, kt -
|
|
2165
|
-
y: Math.max(0, Math.min(dt.y, Jt -
|
|
2164
|
+
x: Math.max(0, Math.min(dt.x, kt - _t)),
|
|
2165
|
+
y: Math.max(0, Math.min(dt.y, Jt - ye))
|
|
2166
2166
|
};
|
|
2167
2167
|
}
|
|
2168
2168
|
}
|
|
@@ -2176,15 +2176,15 @@ function to({ node: t, nodeType: e }) {
|
|
|
2176
2176
|
const Jt = A.querySelector(`[data-nodeid="${yt.id}"]`);
|
|
2177
2177
|
Jt && (Jt.style.left = kt.x + "px", Jt.style.top = kt.y + "px");
|
|
2178
2178
|
}
|
|
2179
|
-
const
|
|
2179
|
+
const Dt = [{ id: t.id, type: "position", position: dt, dragging: !0 }];
|
|
2180
2180
|
for (const yt of a.current.selectedStarts) {
|
|
2181
2181
|
let kt = { x: yt.startPos.x + Lt, y: yt.startPos.y + re };
|
|
2182
2182
|
r.current.snapToGrid && r.current.snapGrid && (kt = {
|
|
2183
2183
|
x: r.current.snapGrid[0] * Math.round(kt.x / r.current.snapGrid[0]),
|
|
2184
2184
|
y: r.current.snapGrid[1] * Math.round(kt.y / r.current.snapGrid[1])
|
|
2185
|
-
}),
|
|
2185
|
+
}), Dt.push({ id: yt.id, type: "position", position: kt, dragging: !0 });
|
|
2186
2186
|
}
|
|
2187
|
-
P =
|
|
2187
|
+
P = Dt, S || (S = requestAnimationFrame(W));
|
|
2188
2188
|
}, ot = (V) => {
|
|
2189
2189
|
var wt, at;
|
|
2190
2190
|
if (!a.current) return;
|
|
@@ -2192,9 +2192,9 @@ function to({ node: t, nodeType: e }) {
|
|
|
2192
2192
|
const ht = [{ id: t.id, type: "position", dragging: !1 }];
|
|
2193
2193
|
for (const lt of a.current.selectedStarts)
|
|
2194
2194
|
ht.push({ id: lt.id, type: "position", dragging: !1 });
|
|
2195
|
-
(at = (wt = r.current.onNodesChangeRef).current) == null || at.call(wt, ht), a.current = null, g && g.releasePointerCapture(V.pointerId), g == null || g.removeEventListener("pointermove",
|
|
2195
|
+
(at = (wt = r.current.onNodesChangeRef).current) == null || at.call(wt, ht), a.current = null, g && g.releasePointerCapture(V.pointerId), g == null || g.removeEventListener("pointermove", J), g == null || g.removeEventListener("pointerup", ot);
|
|
2196
2196
|
};
|
|
2197
|
-
g == null || g.addEventListener("pointermove",
|
|
2197
|
+
g == null || g.addEventListener("pointermove", J), g == null || g.addEventListener("pointerup", ot);
|
|
2198
2198
|
}, [t]), p = F((N) => {
|
|
2199
2199
|
var A, I, U, X, T, v;
|
|
2200
2200
|
if (!t.selected) return;
|
|
@@ -2342,7 +2342,7 @@ function oo({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2342
2342
|
v.stopPropagation(), v.preventDefault();
|
|
2343
2343
|
const S = o.current, P = S.wrapRef.current;
|
|
2344
2344
|
if (!P) return;
|
|
2345
|
-
const W = T === "source" ? g : h,
|
|
2345
|
+
const W = T === "source" ? g : h, J = T === "source" ? t.target : t.source;
|
|
2346
2346
|
(pt = S.workerRef.current) == null || pt.postMessage({
|
|
2347
2347
|
type: "connecting",
|
|
2348
2348
|
data: { from: { x: W.x, y: W.y }, to: { x: W.x, y: W.y } }
|
|
@@ -2355,49 +2355,49 @@ function oo({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2355
2355
|
data: { from: { x: W.x, y: W.y }, to: { x: ht, y: wt } }
|
|
2356
2356
|
});
|
|
2357
2357
|
}, st = (xt) => {
|
|
2358
|
-
var dt,
|
|
2358
|
+
var dt, Dt, Ht, Ut;
|
|
2359
2359
|
const V = S.cameraRef.current, ht = (xt.clientX - ot.left - V.x) / V.zoom, wt = (xt.clientY - ot.top - V.y) / V.zoom, at = 20 / V.zoom;
|
|
2360
2360
|
let lt = null, Lt = null;
|
|
2361
2361
|
const re = (dt = S.handleRegistryRef) == null ? void 0 : dt.current;
|
|
2362
2362
|
for (const yt of S.nodesRef.current) {
|
|
2363
2363
|
if (yt.hidden) continue;
|
|
2364
|
-
const kt = yt.width || Mr, Jt = yt.height || Rr,
|
|
2364
|
+
const kt = yt.width || Mr, Jt = yt.height || Rr, _t = yt._absolutePosition || yt.position, ye = [];
|
|
2365
2365
|
if (re)
|
|
2366
|
-
for (const [,
|
|
2367
|
-
|
|
2368
|
-
const $e =
|
|
2366
|
+
for (const [, Wt] of re)
|
|
2367
|
+
Wt.nodeId === yt.id && ye.push(Wt);
|
|
2368
|
+
const $e = ye.length > 0 ? ye : yt.handles || [
|
|
2369
2369
|
{ type: "target", position: "left" },
|
|
2370
2370
|
{ type: "source", position: "right" }
|
|
2371
2371
|
];
|
|
2372
|
-
for (const
|
|
2372
|
+
for (const Wt of $e) {
|
|
2373
2373
|
let jt, Kt;
|
|
2374
|
-
if (
|
|
2375
|
-
jt =
|
|
2374
|
+
if (Wt.x !== void 0 && Wt.y !== void 0)
|
|
2375
|
+
jt = _t.x + Wt.x, Kt = _t.y + Wt.y;
|
|
2376
2376
|
else
|
|
2377
|
-
switch (
|
|
2377
|
+
switch (Wt.position || (Wt.type === "source" ? "right" : "left")) {
|
|
2378
2378
|
case "top":
|
|
2379
|
-
jt =
|
|
2379
|
+
jt = _t.x + kt / 2, Kt = _t.y;
|
|
2380
2380
|
break;
|
|
2381
2381
|
case "bottom":
|
|
2382
|
-
jt =
|
|
2382
|
+
jt = _t.x + kt / 2, Kt = _t.y + Jt;
|
|
2383
2383
|
break;
|
|
2384
2384
|
case "left":
|
|
2385
|
-
jt =
|
|
2385
|
+
jt = _t.x, Kt = _t.y + Jt / 2;
|
|
2386
2386
|
break;
|
|
2387
2387
|
default:
|
|
2388
|
-
jt =
|
|
2388
|
+
jt = _t.x + kt, Kt = _t.y + Jt / 2;
|
|
2389
2389
|
break;
|
|
2390
2390
|
}
|
|
2391
2391
|
if (Math.abs(ht - jt) < at && Math.abs(wt - Kt) < at) {
|
|
2392
|
-
lt = yt, Lt =
|
|
2392
|
+
lt = yt, Lt = Wt.id || null;
|
|
2393
2393
|
break;
|
|
2394
2394
|
}
|
|
2395
2395
|
}
|
|
2396
2396
|
if (lt) break;
|
|
2397
2397
|
}
|
|
2398
2398
|
if (lt) {
|
|
2399
|
-
const yt = T === "source" ? { source: lt.id, target:
|
|
2400
|
-
(
|
|
2399
|
+
const yt = T === "source" ? { source: lt.id, target: J, sourceHandle: Lt, targetHandle: t.targetHandle } : { source: J, target: lt.id, sourceHandle: t.sourceHandle, targetHandle: Lt };
|
|
2400
|
+
(Ht = (Dt = S.onEdgesChangeRef).current) == null || Ht.call(Dt, [
|
|
2401
2401
|
{ id: t.id, type: "remove" },
|
|
2402
2402
|
{ type: "add", item: { id: t.id, ...yt } }
|
|
2403
2403
|
]);
|
|
@@ -2406,7 +2406,7 @@ function oo({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2406
2406
|
};
|
|
2407
2407
|
P.addEventListener("pointermove", et), P.addEventListener("pointerup", st);
|
|
2408
2408
|
}, [t]), l = n.find((T) => T.id === t.source), f = n.find((T) => T.id === t.target), m = l && !!(l.width || (I = l.measured) != null && I.width), z = f && !!(f.width || (U = f.measured) != null && U.width), b = o.current, E = (X = b.handleRegistryRef) == null ? void 0 : X.current, N = m ? ur(l, "source", t.sourceHandle, E) : null, R = z ? ur(f, "target", t.targetHandle, E) : null, $ = t.type === "bezier" || t.type === "simplebezier" || t.type === "default", Y = b.routedEdges || b.edges, B = Y == null ? void 0 : Y.find((T) => T.id === t.id), _ = $ ? null : (B == null ? void 0 : B._routedPoints) || t._routedPoints || null, A = r !== !1 && t.reconnectable !== !1;
|
|
2409
|
-
return !N || !R ? null : /* @__PURE__ */
|
|
2409
|
+
return !N || !R ? null : /* @__PURE__ */ Xt(
|
|
2410
2410
|
"g",
|
|
2411
2411
|
{
|
|
2412
2412
|
className: `ric-edge-wrapper ${t.selected ? "selected" : ""}`,
|
|
@@ -2439,7 +2439,7 @@ function oo({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2439
2439
|
routedPoints: _
|
|
2440
2440
|
}
|
|
2441
2441
|
),
|
|
2442
|
-
A && (a || t.selected) && /* @__PURE__ */
|
|
2442
|
+
A && (a || t.selected) && /* @__PURE__ */ Xt(Ye, { children: [
|
|
2443
2443
|
/* @__PURE__ */ D(
|
|
2444
2444
|
lr,
|
|
2445
2445
|
{
|
|
@@ -2489,7 +2489,7 @@ function kr({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
|
|
|
2489
2489
|
const v = n.cameraRef.current, h = R.getBoundingClientRect(), g = (T.clientX - h.left - v.x) / v.zoom, S = (T.clientY - h.top - v.y) / v.zoom;
|
|
2490
2490
|
i({ startX: Y.x, startY: Y.y, endX: g, endY: S });
|
|
2491
2491
|
}, X = (T) => {
|
|
2492
|
-
var
|
|
2492
|
+
var J, ot;
|
|
2493
2493
|
if (!$ || !Y) return;
|
|
2494
2494
|
$ = !1;
|
|
2495
2495
|
const v = n.cameraRef.current, h = R.getBoundingClientRect(), g = (T.clientX - h.left - v.x) / v.zoom, S = (T.clientY - h.top - v.y) / v.zoom, P = {
|
|
@@ -2503,7 +2503,7 @@ function kr({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
|
|
|
2503
2503
|
let V;
|
|
2504
2504
|
e === "full" ? V = st.x >= P.x && st.y >= P.y && st.x + pt <= P.x + P.width && st.y + xt <= P.y + P.height : V = st.x + pt > P.x && st.x < P.x + P.width && st.y + xt > P.y && st.y < P.y + P.height, W.push({ id: et.id, type: "select", selected: V });
|
|
2505
2505
|
}
|
|
2506
|
-
W.length && ((ot = (
|
|
2506
|
+
W.length && ((ot = (J = n.onNodesChangeRef).current) == null || ot.call(J, W)), Y = null, i(null);
|
|
2507
2507
|
};
|
|
2508
2508
|
return R.addEventListener("pointerdown", I, !0), R.addEventListener("pointermove", U), R.addEventListener("pointerup", X), window.addEventListener("keydown", _), window.addEventListener("keyup", A), () => {
|
|
2509
2509
|
R.removeEventListener("pointerdown", I, !0), R.removeEventListener("pointermove", U), R.removeEventListener("pointerup", X), window.removeEventListener("keydown", _), window.removeEventListener("keyup", A);
|
|
@@ -2601,13 +2601,13 @@ function uo({
|
|
|
2601
2601
|
[z]
|
|
2602
2602
|
), N = K(E);
|
|
2603
2603
|
N.current = E, Yr(() => {
|
|
2604
|
-
var v, h, g, S, P, W,
|
|
2604
|
+
var v, h, g, S, P, W, J;
|
|
2605
2605
|
if (!m) return;
|
|
2606
2606
|
const B = N.current(), _ = (v = B.handleRegistryRef) == null ? void 0 : v.current;
|
|
2607
2607
|
if (!_) return;
|
|
2608
2608
|
const A = `${m}__${n || t}`, I = (g = (h = B.nodesRef) == null ? void 0 : h.current) == null ? void 0 : g.find((ot) => ot.id === m), U = (I == null ? void 0 : I.width) || ((S = I == null ? void 0 : I.measured) == null ? void 0 : S.width), X = (I == null ? void 0 : I.height) || ((P = I == null ? void 0 : I.measured) == null ? void 0 : P.height);
|
|
2609
2609
|
let T;
|
|
2610
|
-
U && X ? T = Jn(e, U, X) : b.current ? T = ao(b.current, (
|
|
2610
|
+
U && X ? T = Jn(e, U, X) : b.current ? T = ao(b.current, (J = (W = B.cameraRef) == null ? void 0 : W.current) == null ? void 0 : J.zoom) : T = Jn(e, 160, 60), _.set(A, { nodeId: m, id: n || null, type: t, position: e, x: T.x, y: T.y });
|
|
2611
2611
|
}, [m, n, t, e]), gt(() => {
|
|
2612
2612
|
if (!m) return;
|
|
2613
2613
|
const B = N.current();
|
|
@@ -2652,14 +2652,14 @@ function uo({
|
|
|
2652
2652
|
}), I.setPointerCapture(B.pointerId);
|
|
2653
2653
|
const h = (P) => {
|
|
2654
2654
|
var ot;
|
|
2655
|
-
const W = (P.clientX - U.left - A.x) / A.zoom,
|
|
2655
|
+
const W = (P.clientX - U.left - A.x) / A.zoom, J = (P.clientY - U.top - A.y) / A.zoom;
|
|
2656
2656
|
(ot = _.workerRef.current) == null || ot.postMessage({
|
|
2657
2657
|
type: "connecting",
|
|
2658
|
-
data: { from: { x: T, y: v }, to: { x: W, y:
|
|
2658
|
+
data: { from: { x: T, y: v }, to: { x: W, y: J } }
|
|
2659
2659
|
});
|
|
2660
2660
|
}, g = (P) => {
|
|
2661
2661
|
var xt, V, ht, wt;
|
|
2662
|
-
const W = (P.clientX - U.left - A.x) / A.zoom,
|
|
2662
|
+
const W = (P.clientX - U.left - A.x) / A.zoom, J = (P.clientY - U.top - A.y) / A.zoom, ot = 20 / A.zoom;
|
|
2663
2663
|
let et = null, st = null;
|
|
2664
2664
|
const pt = (xt = _.handleRegistryRef) == null ? void 0 : xt.current;
|
|
2665
2665
|
for (const at of _.nodesRef.current) {
|
|
@@ -2673,27 +2673,27 @@ function uo({
|
|
|
2673
2673
|
{ type: "source", position: "right" }
|
|
2674
2674
|
];
|
|
2675
2675
|
for (const dt of re) {
|
|
2676
|
-
let
|
|
2676
|
+
let Dt, Ht;
|
|
2677
2677
|
if (dt.x !== void 0 && dt.y !== void 0)
|
|
2678
|
-
|
|
2678
|
+
Dt = lt.x + dt.x, Ht = lt.y + dt.y;
|
|
2679
2679
|
else {
|
|
2680
2680
|
const Ut = at.width || 160, yt = at.height || 60;
|
|
2681
2681
|
switch (dt.position || (dt.type === "source" ? "right" : "left")) {
|
|
2682
2682
|
case "top":
|
|
2683
|
-
|
|
2683
|
+
Dt = lt.x + Ut / 2, Ht = lt.y;
|
|
2684
2684
|
break;
|
|
2685
2685
|
case "bottom":
|
|
2686
|
-
|
|
2686
|
+
Dt = lt.x + Ut / 2, Ht = lt.y + yt;
|
|
2687
2687
|
break;
|
|
2688
2688
|
case "left":
|
|
2689
|
-
|
|
2689
|
+
Dt = lt.x, Ht = lt.y + yt / 2;
|
|
2690
2690
|
break;
|
|
2691
2691
|
default:
|
|
2692
|
-
|
|
2692
|
+
Dt = lt.x + Ut, Ht = lt.y + yt / 2;
|
|
2693
2693
|
break;
|
|
2694
2694
|
}
|
|
2695
2695
|
}
|
|
2696
|
-
if (Math.abs(W -
|
|
2696
|
+
if (Math.abs(W - Dt) < ot && Math.abs(J - Ht) < ot) {
|
|
2697
2697
|
et = at, st = dt.id || null;
|
|
2698
2698
|
break;
|
|
2699
2699
|
}
|
|
@@ -2756,7 +2756,7 @@ function Vo({
|
|
|
2756
2756
|
hideSourceHandle: o = !1,
|
|
2757
2757
|
hideTargetHandle: a = !1
|
|
2758
2758
|
}) {
|
|
2759
|
-
return /* @__PURE__ */
|
|
2759
|
+
return /* @__PURE__ */ Xt(
|
|
2760
2760
|
"div",
|
|
2761
2761
|
{
|
|
2762
2762
|
className: `ric-default-node${n ? " selected" : ""}`,
|
|
@@ -2785,7 +2785,7 @@ function lo({
|
|
|
2785
2785
|
sourcePosition: r = "right",
|
|
2786
2786
|
hideSourceHandle: i = !1
|
|
2787
2787
|
}) {
|
|
2788
|
-
return /* @__PURE__ */
|
|
2788
|
+
return /* @__PURE__ */ Xt(
|
|
2789
2789
|
"div",
|
|
2790
2790
|
{
|
|
2791
2791
|
className: `ric-input-node${n ? " selected" : ""}`,
|
|
@@ -2814,7 +2814,7 @@ function fo({
|
|
|
2814
2814
|
targetPosition: r = "left",
|
|
2815
2815
|
hideTargetHandle: i = !1
|
|
2816
2816
|
}) {
|
|
2817
|
-
return /* @__PURE__ */
|
|
2817
|
+
return /* @__PURE__ */ Xt(
|
|
2818
2818
|
"div",
|
|
2819
2819
|
{
|
|
2820
2820
|
className: `ric-output-node${n ? " selected" : ""}`,
|
|
@@ -2889,7 +2889,7 @@ function Er({
|
|
|
2889
2889
|
height: E.height
|
|
2890
2890
|
});
|
|
2891
2891
|
}
|
|
2892
|
-
}, [n]), n ? /* @__PURE__ */
|
|
2892
|
+
}, [n]), n ? /* @__PURE__ */ Xt(
|
|
2893
2893
|
"g",
|
|
2894
2894
|
{
|
|
2895
2895
|
transform: `translate(${t - m.width / 2} ${e - m.height / 2})`,
|
|
@@ -2949,7 +2949,7 @@ function In({
|
|
|
2949
2949
|
className: E = "",
|
|
2950
2950
|
...N
|
|
2951
2951
|
}) {
|
|
2952
|
-
return /* @__PURE__ */
|
|
2952
|
+
return /* @__PURE__ */ Xt(Ye, { children: [
|
|
2953
2953
|
/* @__PURE__ */ D(
|
|
2954
2954
|
"path",
|
|
2955
2955
|
{
|
|
@@ -3286,15 +3286,15 @@ function Pr(t, e, n) {
|
|
|
3286
3286
|
}
|
|
3287
3287
|
if (U[g]) continue;
|
|
3288
3288
|
U[g] = 1;
|
|
3289
|
-
const S = g / f | 0, P = g % f, W = a[P],
|
|
3289
|
+
const S = g / f | 0, P = g % f, W = a[P], J = d[S], ot = I[g];
|
|
3290
3290
|
for (let et = 0; et < 4; et++) {
|
|
3291
3291
|
const st = P + v[et][0], pt = S + v[et][1];
|
|
3292
3292
|
if (st < 0 || st >= f || pt < 0 || pt >= m) continue;
|
|
3293
3293
|
const xt = z(st, pt);
|
|
3294
3294
|
if (U[xt]) continue;
|
|
3295
3295
|
const V = a[st], ht = d[pt];
|
|
3296
|
-
if (xo(V, ht, n) || !tr(W,
|
|
3297
|
-
const wt = Math.abs(V - W) + Math.abs(ht -
|
|
3296
|
+
if (xo(V, ht, n) || !tr(W, J, V, ht, n)) continue;
|
|
3297
|
+
const wt = Math.abs(V - W) + Math.abs(ht - J), at = ot >= 0 && ot !== et ? T : 0, lt = B[g] + wt + at;
|
|
3298
3298
|
lt < B[xt] && (A[xt] = g, I[xt] = et, B[xt] = lt, _[xt] = lt + Math.abs(a[N] - V) + Math.abs(d[R] - ht), X.push(xt));
|
|
3299
3299
|
}
|
|
3300
3300
|
}
|
|
@@ -3545,7 +3545,7 @@ const $r = ie(function({
|
|
|
3545
3545
|
$r.displayName = "SmoothStepEdge";
|
|
3546
3546
|
const bo = ie(function({ id: e, ...n }) {
|
|
3547
3547
|
var i;
|
|
3548
|
-
const r =
|
|
3548
|
+
const r = Ft(
|
|
3549
3549
|
() => {
|
|
3550
3550
|
var o;
|
|
3551
3551
|
return { borderRadius: 0, offset: (o = n.pathOptions) == null ? void 0 : o.offset };
|
|
@@ -3670,7 +3670,7 @@ function ss({
|
|
|
3670
3670
|
onNodeDragStop: S,
|
|
3671
3671
|
onEdgeClick: P,
|
|
3672
3672
|
onEdgeDoubleClick: W,
|
|
3673
|
-
onEdgeMouseEnter:
|
|
3673
|
+
onEdgeMouseEnter: J,
|
|
3674
3674
|
onEdgeMouseMove: ot,
|
|
3675
3675
|
onEdgeMouseLeave: et,
|
|
3676
3676
|
onEdgeContextMenu: st,
|
|
@@ -3684,18 +3684,18 @@ function ss({
|
|
|
3684
3684
|
onMoveStart: Lt,
|
|
3685
3685
|
onMove: re,
|
|
3686
3686
|
onMoveEnd: dt,
|
|
3687
|
-
onDelete:
|
|
3688
|
-
onBeforeDelete:
|
|
3687
|
+
onDelete: Dt,
|
|
3688
|
+
onBeforeDelete: Ht,
|
|
3689
3689
|
onError: Ut,
|
|
3690
3690
|
// Drag and drop
|
|
3691
3691
|
onDragOver: yt,
|
|
3692
3692
|
onDrop: kt,
|
|
3693
3693
|
onDragEnter: Jt,
|
|
3694
|
-
onDragLeave:
|
|
3694
|
+
onDragLeave: _t,
|
|
3695
3695
|
// Behavior
|
|
3696
|
-
nodesDraggable:
|
|
3696
|
+
nodesDraggable: ye,
|
|
3697
3697
|
nodesConnectable: $e,
|
|
3698
|
-
elementsSelectable:
|
|
3698
|
+
elementsSelectable: Wt,
|
|
3699
3699
|
multiSelectionKeyCode: jt,
|
|
3700
3700
|
selectionOnDrag: Kt,
|
|
3701
3701
|
selectionMode: Ae,
|
|
@@ -3711,7 +3711,7 @@ function ss({
|
|
|
3711
3711
|
panOnScroll: Be,
|
|
3712
3712
|
panOnScrollMode: Ln,
|
|
3713
3713
|
panOnScrollSpeed: Pn,
|
|
3714
|
-
zoomOnScroll:
|
|
3714
|
+
zoomOnScroll: le,
|
|
3715
3715
|
zoomOnDoubleClick: rr,
|
|
3716
3716
|
zoomOnPinch: Tn,
|
|
3717
3717
|
preventScrolling: $n,
|
|
@@ -3732,7 +3732,7 @@ function ss({
|
|
|
3732
3732
|
// Edge routing (obstacle avoidance)
|
|
3733
3733
|
edgeRouting: xn = !0,
|
|
3734
3734
|
// HUD
|
|
3735
|
-
onHudUpdate:
|
|
3735
|
+
onHudUpdate: ge,
|
|
3736
3736
|
onNodesProcessed: _e,
|
|
3737
3737
|
showHud: Hn = !0,
|
|
3738
3738
|
showHint: _n = !0,
|
|
@@ -3740,18 +3740,20 @@ function ss({
|
|
|
3740
3740
|
children: Gt,
|
|
3741
3741
|
...je
|
|
3742
3742
|
}) {
|
|
3743
|
-
const [
|
|
3744
|
-
(
|
|
3745
|
-
Ge(
|
|
3743
|
+
const [Yt, Ge] = ne({ wx: 0, wy: 0, zoom: "1.00" }), Ne = K(null), Oe = K(null), Wn = F(
|
|
3744
|
+
(O) => {
|
|
3745
|
+
Ge(O), ge == null || ge(O);
|
|
3746
3746
|
},
|
|
3747
|
-
[
|
|
3748
|
-
), Me =
|
|
3749
|
-
const
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3747
|
+
[ge]
|
|
3748
|
+
), Me = Ft(() => ({ ...Mo, ...r }), [r]), Re = Ft(() => ({ ...Ro, ...i }), [i]), ae = Ft(() => Eo(e), [e]), oe = Ft(() => {
|
|
3749
|
+
const O = ae.filter(
|
|
3750
|
+
(Tt) => Tt.type && Me[Tt.type] && (Tt.selected || Tt.dragging)
|
|
3751
|
+
);
|
|
3752
|
+
return O.sort((Tt, bt) => {
|
|
3753
|
+
const $t = Tt.type === "group" || !Tt.parentId && O.some((ut) => ut.parentId === Tt.id), fe = bt.type === "group" || !bt.parentId && O.some((ut) => ut.parentId === bt.id);
|
|
3754
|
+
return $t && !fe ? -1 : !$t && fe ? 1 : 0;
|
|
3753
3755
|
});
|
|
3754
|
-
}, [
|
|
3756
|
+
}, [ae, Me]), We = Ft(() => n.filter((O) => O.type && Re[O.type]), [n, Re]), j = Ft(() => e.map((O) => O.type && Me[O.type] && (O.selected || O.dragging) ? { ...O, _customRendered: !0 } : O), [e, Me]), ke = Ft(() => n.map((O) => O.type && Re[O.type] ? { ...O, _customRendered: !0 } : O), [n, Re]), {
|
|
3755
3757
|
wrapRef: Fe,
|
|
3756
3758
|
canvasRef: Qe,
|
|
3757
3759
|
canvasReady: Je,
|
|
@@ -3788,7 +3790,7 @@ function ss({
|
|
|
3788
3790
|
onNodeDragStop: S,
|
|
3789
3791
|
onEdgeClick: P,
|
|
3790
3792
|
onEdgeDoubleClick: W,
|
|
3791
|
-
onEdgeMouseEnter:
|
|
3793
|
+
onEdgeMouseEnter: J,
|
|
3792
3794
|
onEdgeMouseMove: ot,
|
|
3793
3795
|
onEdgeMouseLeave: et,
|
|
3794
3796
|
onEdgeContextMenu: st,
|
|
@@ -3802,12 +3804,12 @@ function ss({
|
|
|
3802
3804
|
onMoveStart: Lt,
|
|
3803
3805
|
onMove: re,
|
|
3804
3806
|
onMoveEnd: dt,
|
|
3805
|
-
onDelete:
|
|
3806
|
-
onBeforeDelete:
|
|
3807
|
+
onDelete: Dt,
|
|
3808
|
+
onBeforeDelete: Ht,
|
|
3807
3809
|
onError: Ut,
|
|
3808
|
-
nodesDraggable:
|
|
3810
|
+
nodesDraggable: ye,
|
|
3809
3811
|
nodesConnectable: $e,
|
|
3810
|
-
elementsSelectable:
|
|
3812
|
+
elementsSelectable: Wt,
|
|
3811
3813
|
multiSelectionKeyCode: jt,
|
|
3812
3814
|
selectionOnDrag: Kt,
|
|
3813
3815
|
selectionMode: Ae,
|
|
@@ -3823,7 +3825,7 @@ function ss({
|
|
|
3823
3825
|
panOnScroll: Be,
|
|
3824
3826
|
panOnScrollMode: Ln,
|
|
3825
3827
|
panOnScrollSpeed: Pn,
|
|
3826
|
-
zoomOnScroll:
|
|
3828
|
+
zoomOnScroll: le,
|
|
3827
3829
|
zoomOnDoubleClick: rr,
|
|
3828
3830
|
zoomOnPinch: Tn,
|
|
3829
3831
|
preventScrolling: $n,
|
|
@@ -3845,7 +3847,7 @@ function ss({
|
|
|
3845
3847
|
gt(() => {
|
|
3846
3848
|
Xe && queueMicrotask(() => {
|
|
3847
3849
|
ze.setState({
|
|
3848
|
-
nodes:
|
|
3850
|
+
nodes: ae,
|
|
3849
3851
|
edges: n,
|
|
3850
3852
|
nodesRef: Rt.nodesRef,
|
|
3851
3853
|
edgesRef: Rt.edgesRef,
|
|
@@ -3856,13 +3858,13 @@ function ss({
|
|
|
3856
3858
|
workerRef: Rt.workerRef
|
|
3857
3859
|
});
|
|
3858
3860
|
});
|
|
3859
|
-
}, [Xe,
|
|
3860
|
-
const Nt =
|
|
3861
|
+
}, [Xe, ae, n, Rt, ze]);
|
|
3862
|
+
const Nt = Ft(() => ({
|
|
3861
3863
|
...Rt,
|
|
3862
3864
|
edgeLabelContainerRef: Ne,
|
|
3863
3865
|
viewportPortalRef: Oe,
|
|
3864
3866
|
get nodes() {
|
|
3865
|
-
return
|
|
3867
|
+
return ae;
|
|
3866
3868
|
},
|
|
3867
3869
|
get edges() {
|
|
3868
3870
|
return n;
|
|
@@ -3880,40 +3882,40 @@ function ss({
|
|
|
3880
3882
|
return Rt.wrapRef.current;
|
|
3881
3883
|
},
|
|
3882
3884
|
get width() {
|
|
3883
|
-
var
|
|
3884
|
-
return ((
|
|
3885
|
+
var O;
|
|
3886
|
+
return ((O = Rt.wrapRef.current) == null ? void 0 : O.clientWidth) || 0;
|
|
3885
3887
|
},
|
|
3886
3888
|
get height() {
|
|
3887
|
-
var
|
|
3888
|
-
return ((
|
|
3889
|
+
var O;
|
|
3890
|
+
return ((O = Rt.wrapRef.current) == null ? void 0 : O.clientHeight) || 0;
|
|
3889
3891
|
}
|
|
3890
|
-
}), [Rt,
|
|
3892
|
+
}), [Rt, ae, n]), en = K(null), Pt = K(null), nn = K(null), de = K(null), Ie = K(null);
|
|
3891
3893
|
gt(() => {
|
|
3892
|
-
let
|
|
3893
|
-
const
|
|
3894
|
-
const bt = Rt.cameraRef.current,
|
|
3895
|
-
en.current && (en.current.style.transform =
|
|
3894
|
+
let O;
|
|
3895
|
+
const Tt = () => {
|
|
3896
|
+
const bt = Rt.cameraRef.current, $t = `translate(${bt.x}px, ${bt.y}px) scale(${bt.zoom})`, fe = `translate(${bt.x}, ${bt.y}) scale(${bt.zoom})`;
|
|
3897
|
+
en.current && (en.current.style.transform = $t), Pt.current && Pt.current.setAttribute("transform", fe), nn.current && (nn.current.style.transform = $t), de.current && (de.current.style.transform = $t);
|
|
3896
3898
|
const ut = Fe.current;
|
|
3897
3899
|
if (ut) {
|
|
3898
3900
|
const Vt = bt.zoom < 0.15 ? "lod-minimal" : bt.zoom < 0.35 ? "lod-reduced" : null;
|
|
3899
3901
|
Vt !== Ie.current && (ut.classList.remove("lod-minimal", "lod-reduced"), Vt && ut.classList.add(Vt), Ie.current = Vt);
|
|
3900
3902
|
}
|
|
3901
|
-
|
|
3903
|
+
O = requestAnimationFrame(Tt);
|
|
3902
3904
|
};
|
|
3903
|
-
return
|
|
3905
|
+
return O = requestAnimationFrame(Tt), () => cancelAnimationFrame(O);
|
|
3904
3906
|
}, [Rt]);
|
|
3905
3907
|
const [se, Ee] = ne(null);
|
|
3906
3908
|
gt(() => {
|
|
3907
3909
|
if (!oe.length) return;
|
|
3908
|
-
let
|
|
3909
|
-
const
|
|
3910
|
+
let O;
|
|
3911
|
+
const Tt = () => {
|
|
3910
3912
|
var rn, vn;
|
|
3911
|
-
const bt = Rt.cameraRef.current,
|
|
3912
|
-
if (
|
|
3913
|
-
|
|
3913
|
+
const bt = Rt.cameraRef.current, $t = Rt.wrapRef.current;
|
|
3914
|
+
if (!$t) {
|
|
3915
|
+
O = requestAnimationFrame(Tt);
|
|
3914
3916
|
return;
|
|
3915
3917
|
}
|
|
3916
|
-
const
|
|
3918
|
+
const fe = $t.getBoundingClientRect(), ut = 200, Vt = -bt.x / bt.zoom - ut, Ce = -bt.y / bt.zoom - ut, Fn = (fe.width - bt.x) / bt.zoom + ut, Xn = (fe.height - bt.y) / bt.zoom + ut, Le = /* @__PURE__ */ new Set();
|
|
3917
3919
|
for (const Ot of oe) {
|
|
3918
3920
|
const Se = Ot._absolutePosition || Ot.position, Yn = Ot.width || ((rn = Ot.measured) == null ? void 0 : rn.width) || 200, Un = Ot.height || ((vn = Ot.measured) == null ? void 0 : vn.height) || 100;
|
|
3919
3921
|
Se.x + Yn >= Vt && Se.x <= Fn && Se.y + Un >= Ce && Se.y <= Xn && Le.add(Ot.id);
|
|
@@ -3923,12 +3925,12 @@ function ss({
|
|
|
3923
3925
|
for (const Se of Le)
|
|
3924
3926
|
if (!Ot.has(Se)) return Le;
|
|
3925
3927
|
return Ot;
|
|
3926
|
-
}),
|
|
3928
|
+
}), O = requestAnimationFrame(Tt);
|
|
3927
3929
|
};
|
|
3928
|
-
return
|
|
3930
|
+
return O = requestAnimationFrame(Tt), () => cancelAnimationFrame(O);
|
|
3929
3931
|
}, [oe, Rt]);
|
|
3930
|
-
const mn =
|
|
3931
|
-
return /* @__PURE__ */ D(Te.Provider, { value: Nt, children: /* @__PURE__ */
|
|
3932
|
+
const mn = Ft(() => se ? oe.filter((O) => se.has(O.id)) : oe, [oe, se]), It = oe.length > 0, ce = We.length > 0;
|
|
3933
|
+
return /* @__PURE__ */ D(Te.Provider, { value: Nt, children: /* @__PURE__ */ Xt(
|
|
3932
3934
|
"div",
|
|
3933
3935
|
{
|
|
3934
3936
|
ref: Fe,
|
|
@@ -3940,12 +3942,12 @@ function ss({
|
|
|
3940
3942
|
onDragOver: yt,
|
|
3941
3943
|
onDrop: kt,
|
|
3942
3944
|
onDragEnter: Jt,
|
|
3943
|
-
onDragLeave:
|
|
3945
|
+
onDragLeave: _t,
|
|
3944
3946
|
tabIndex: 0,
|
|
3945
3947
|
children: [
|
|
3946
3948
|
/* @__PURE__ */ D("canvas", { ref: Qe, className: "ric-canvas" }),
|
|
3947
3949
|
!Je && /* @__PURE__ */ D("div", { className: "ric-loader", children: /* @__PURE__ */ D("div", { className: "ric-spinner" }) }),
|
|
3948
|
-
|
|
3950
|
+
ce && /* @__PURE__ */ D(
|
|
3949
3951
|
"svg",
|
|
3950
3952
|
{
|
|
3951
3953
|
className: "ric-edges-overlay",
|
|
@@ -3958,15 +3960,15 @@ function ss({
|
|
|
3958
3960
|
pointerEvents: "none",
|
|
3959
3961
|
overflow: "visible"
|
|
3960
3962
|
},
|
|
3961
|
-
children: /* @__PURE__ */ D("g", { ref: Pt, children: We.map((
|
|
3963
|
+
children: /* @__PURE__ */ D("g", { ref: Pt, children: We.map((O) => /* @__PURE__ */ D(
|
|
3962
3964
|
so,
|
|
3963
3965
|
{
|
|
3964
|
-
edge:
|
|
3965
|
-
edgeType: Re[
|
|
3966
|
+
edge: O,
|
|
3967
|
+
edgeType: Re[O.type],
|
|
3966
3968
|
nodes: e,
|
|
3967
3969
|
reconnectable: we
|
|
3968
3970
|
},
|
|
3969
|
-
|
|
3971
|
+
O.id
|
|
3970
3972
|
)) })
|
|
3971
3973
|
}
|
|
3972
3974
|
),
|
|
@@ -3985,21 +3987,21 @@ function ss({
|
|
|
3985
3987
|
pointerEvents: "none",
|
|
3986
3988
|
zIndex: 10
|
|
3987
3989
|
},
|
|
3988
|
-
children: mn.map((
|
|
3990
|
+
children: mn.map((O) => /* @__PURE__ */ D(
|
|
3989
3991
|
eo,
|
|
3990
3992
|
{
|
|
3991
|
-
node:
|
|
3992
|
-
nodeType: Me[
|
|
3993
|
+
node: O,
|
|
3994
|
+
nodeType: Me[O.type]
|
|
3993
3995
|
},
|
|
3994
|
-
|
|
3996
|
+
O.id
|
|
3995
3997
|
))
|
|
3996
3998
|
}
|
|
3997
3999
|
),
|
|
3998
4000
|
/* @__PURE__ */ D(
|
|
3999
4001
|
"div",
|
|
4000
4002
|
{
|
|
4001
|
-
ref: (
|
|
4002
|
-
Ne.current =
|
|
4003
|
+
ref: (O) => {
|
|
4004
|
+
Ne.current = O, nn.current = O;
|
|
4003
4005
|
},
|
|
4004
4006
|
className: "ric-edge-labels",
|
|
4005
4007
|
style: {
|
|
@@ -4017,8 +4019,8 @@ function ss({
|
|
|
4017
4019
|
/* @__PURE__ */ D(
|
|
4018
4020
|
"div",
|
|
4019
4021
|
{
|
|
4020
|
-
ref: (
|
|
4021
|
-
Oe.current =
|
|
4022
|
+
ref: (O) => {
|
|
4023
|
+
Oe.current = O, de.current = O;
|
|
4022
4024
|
},
|
|
4023
4025
|
className: "ric-viewport-portal",
|
|
4024
4026
|
style: {
|
|
@@ -4034,21 +4036,21 @@ function ss({
|
|
|
4034
4036
|
}
|
|
4035
4037
|
),
|
|
4036
4038
|
_n && /* @__PURE__ */ D("div", { className: "ric-hint", children: qt }),
|
|
4037
|
-
Hn && /* @__PURE__ */
|
|
4039
|
+
Hn && /* @__PURE__ */ Xt("div", { className: "ric-info", children: [
|
|
4038
4040
|
"world: (",
|
|
4039
|
-
|
|
4041
|
+
Yt.wx,
|
|
4040
4042
|
", ",
|
|
4041
|
-
|
|
4043
|
+
Yt.wy,
|
|
4042
4044
|
") zoom: ",
|
|
4043
|
-
|
|
4045
|
+
Yt.zoom,
|
|
4044
4046
|
"x",
|
|
4045
|
-
|
|
4047
|
+
Yt.nodeCount > 0 && /* @__PURE__ */ Xt(Ye, { children: [
|
|
4046
4048
|
" nodes: ",
|
|
4047
|
-
|
|
4049
|
+
Yt.nodeCount
|
|
4048
4050
|
] }),
|
|
4049
|
-
|
|
4051
|
+
Yt.edgeCount > 0 && /* @__PURE__ */ Xt(Ye, { children: [
|
|
4050
4052
|
" edges: ",
|
|
4051
|
-
|
|
4053
|
+
Yt.edgeCount
|
|
4052
4054
|
] })
|
|
4053
4055
|
] }),
|
|
4054
4056
|
/* @__PURE__ */ D(
|
|
@@ -4145,8 +4147,8 @@ function Io() {
|
|
|
4145
4147
|
if (typeof v == "function") {
|
|
4146
4148
|
const W = v(e().nodesRef.current);
|
|
4147
4149
|
(g = (h = e().onNodesChangeRef).current) == null || g.call(h, [
|
|
4148
|
-
...e().nodesRef.current.map((
|
|
4149
|
-
...W.map((
|
|
4150
|
+
...e().nodesRef.current.map((J) => ({ id: J.id, type: "remove" })),
|
|
4151
|
+
...W.map((J) => ({ type: "add", item: J }))
|
|
4150
4152
|
]);
|
|
4151
4153
|
} else
|
|
4152
4154
|
(P = (S = e().onNodesChangeRef).current) == null || P.call(S, [
|
|
@@ -4158,8 +4160,8 @@ function Io() {
|
|
|
4158
4160
|
if (typeof v == "function") {
|
|
4159
4161
|
const W = v(e().edgesRef.current);
|
|
4160
4162
|
(g = (h = e().onEdgesChangeRef).current) == null || g.call(h, [
|
|
4161
|
-
...e().edgesRef.current.map((
|
|
4162
|
-
...W.map((
|
|
4163
|
+
...e().edgesRef.current.map((J) => ({ id: J.id, type: "remove" })),
|
|
4164
|
+
...W.map((J) => ({ type: "add", item: J }))
|
|
4163
4165
|
]);
|
|
4164
4166
|
} else
|
|
4165
4167
|
(P = (S = e().onEdgesChangeRef).current) == null || P.call(S, [
|
|
@@ -4190,7 +4192,7 @@ function Io() {
|
|
|
4190
4192
|
return;
|
|
4191
4193
|
}
|
|
4192
4194
|
const g = { ...e().cameraRef.current }, S = performance.now(), P = (W) => {
|
|
4193
|
-
const
|
|
4195
|
+
const J = W - S, ot = Math.min(J / h, 1), et = 1 - Math.pow(1 - ot, 3);
|
|
4194
4196
|
e().cameraRef.current = {
|
|
4195
4197
|
x: g.x + (v.x - g.x) * et,
|
|
4196
4198
|
y: g.y + (v.y - g.y) * et,
|
|
@@ -4208,27 +4210,27 @@ function Io() {
|
|
|
4208
4210
|
}, [e, b]), N = F(() => e().cameraRef.current.zoom, [e]), R = F((v) => {
|
|
4209
4211
|
const h = e().cameraRef.current, g = e().wrapRef.current;
|
|
4210
4212
|
if (!g) return;
|
|
4211
|
-
const S = g.getBoundingClientRect(), P = S.width / 2, W = S.height / 2,
|
|
4212
|
-
x: P - (P - h.x) *
|
|
4213
|
-
y: W - (W - h.y) *
|
|
4214
|
-
zoom: Math.min(e().zoomMax, h.zoom *
|
|
4213
|
+
const S = g.getBoundingClientRect(), P = S.width / 2, W = S.height / 2, J = 1.2, ot = {
|
|
4214
|
+
x: P - (P - h.x) * J,
|
|
4215
|
+
y: W - (W - h.y) * J,
|
|
4216
|
+
zoom: Math.min(e().zoomMax, h.zoom * J)
|
|
4215
4217
|
};
|
|
4216
4218
|
b(ot, v == null ? void 0 : v.duration);
|
|
4217
4219
|
}, [e, b]), $ = F((v) => {
|
|
4218
4220
|
const h = e().cameraRef.current, g = e().wrapRef.current;
|
|
4219
4221
|
if (!g) return;
|
|
4220
|
-
const S = g.getBoundingClientRect(), P = S.width / 2, W = S.height / 2,
|
|
4221
|
-
x: P - (P - h.x) *
|
|
4222
|
-
y: W - (W - h.y) *
|
|
4223
|
-
zoom: Math.max(e().zoomMin, h.zoom *
|
|
4222
|
+
const S = g.getBoundingClientRect(), P = S.width / 2, W = S.height / 2, J = 1 / 1.2, ot = {
|
|
4223
|
+
x: P - (P - h.x) * J,
|
|
4224
|
+
y: W - (W - h.y) * J,
|
|
4225
|
+
zoom: Math.max(e().zoomMin, h.zoom * J)
|
|
4224
4226
|
};
|
|
4225
4227
|
b(ot, v == null ? void 0 : v.duration);
|
|
4226
4228
|
}, [e, b]), Y = F((v, h) => {
|
|
4227
4229
|
const g = e().cameraRef.current, S = e().wrapRef.current;
|
|
4228
4230
|
if (!S) return;
|
|
4229
|
-
const P = S.getBoundingClientRect(), W = P.width / 2,
|
|
4231
|
+
const P = S.getBoundingClientRect(), W = P.width / 2, J = P.height / 2, ot = Math.min(e().zoomMax, Math.max(e().zoomMin, v)), et = ot / g.zoom, st = {
|
|
4230
4232
|
x: W - (W - g.x) * et,
|
|
4231
|
-
y:
|
|
4233
|
+
y: J - (J - g.y) * et,
|
|
4232
4234
|
zoom: ot
|
|
4233
4235
|
};
|
|
4234
4236
|
b(st, h == null ? void 0 : h.duration);
|
|
@@ -4239,7 +4241,7 @@ function Io() {
|
|
|
4239
4241
|
if (!g) return;
|
|
4240
4242
|
const S = g.getBoundingClientRect(), P = v.padding ?? 0.1, W = v.nodes ? h.filter((et) => v.nodes.some((st) => st.id === et.id)) : h;
|
|
4241
4243
|
if (!W.length) return;
|
|
4242
|
-
const
|
|
4244
|
+
const J = Qn(W), ot = ln(J, S.width, S.height, P);
|
|
4243
4245
|
v.maxZoom && (ot.zoom = Math.min(ot.zoom, v.maxZoom)), v.minZoom && (ot.zoom = Math.max(ot.zoom, v.minZoom)), b(ot, v.duration);
|
|
4244
4246
|
}, [e, b]), _ = F((v, h = {}) => {
|
|
4245
4247
|
const g = e().wrapRef.current;
|
|
@@ -4249,12 +4251,12 @@ function Io() {
|
|
|
4249
4251
|
}, [e, b]), A = F((v, h, g = {}) => {
|
|
4250
4252
|
const S = e().wrapRef.current;
|
|
4251
4253
|
if (!S) return;
|
|
4252
|
-
const P = S.getBoundingClientRect(), W = g.zoom ?? e().cameraRef.current.zoom,
|
|
4254
|
+
const P = S.getBoundingClientRect(), W = g.zoom ?? e().cameraRef.current.zoom, J = {
|
|
4253
4255
|
x: P.width / 2 - v * W,
|
|
4254
4256
|
y: P.height / 2 - h * W,
|
|
4255
4257
|
zoom: W
|
|
4256
4258
|
};
|
|
4257
|
-
b(
|
|
4259
|
+
b(J, g.duration);
|
|
4258
4260
|
}, [e, b]), I = F(() => ({
|
|
4259
4261
|
nodes: [...e().nodesRef.current],
|
|
4260
4262
|
edges: [...e().edgesRef.current],
|
|
@@ -4269,7 +4271,7 @@ function Io() {
|
|
|
4269
4271
|
};
|
|
4270
4272
|
}, [e]), T = F((v, h) => {
|
|
4271
4273
|
var P, W;
|
|
4272
|
-
const g = e().nodesRef.current.find((
|
|
4274
|
+
const g = e().nodesRef.current.find((J) => J.id === v);
|
|
4273
4275
|
if (!g) return;
|
|
4274
4276
|
const S = typeof h == "function" ? h(g.data) : { ...g.data, ...h };
|
|
4275
4277
|
(W = (P = e().onNodesChangeRef).current) == null || W.call(P, [{ id: v, type: "replace", item: { ...g, data: S } }]);
|
|
@@ -4313,18 +4315,18 @@ function hs() {
|
|
|
4313
4315
|
}
|
|
4314
4316
|
function ys(t) {
|
|
4315
4317
|
const e = Ct(), n = Array.isArray(t) ? t : [t];
|
|
4316
|
-
return
|
|
4318
|
+
return Ft(() => n.map((r) => {
|
|
4317
4319
|
const i = e.nodes.find((o) => o.id === r);
|
|
4318
4320
|
return i ? { id: i.id, type: i.type, data: i.data } : null;
|
|
4319
4321
|
}).filter(Boolean), [e.nodes, ...n]);
|
|
4320
4322
|
}
|
|
4321
4323
|
function gs(t) {
|
|
4322
4324
|
const e = Ct();
|
|
4323
|
-
return
|
|
4325
|
+
return Ft(() => e.edges.filter((n) => n.source === t || n.target === t), [e.edges, t]);
|
|
4324
4326
|
}
|
|
4325
4327
|
function ps({ nodeId: t, type: e, handleId: n }) {
|
|
4326
4328
|
const r = Ct();
|
|
4327
|
-
return
|
|
4329
|
+
return Ft(() => r.edges.filter((i) => e === "source" ? i.source === t && (n ? i.sourceHandle === n : !0) : i.target === t && (n ? i.targetHandle === n : !0)), [r.edges, t, e, n]);
|
|
4328
4330
|
}
|
|
4329
4331
|
function xs({ onChange: t, onStart: e, onEnd: n }) {
|
|
4330
4332
|
const r = Ct(), i = K(t), o = K(e), a = K(n);
|
|
@@ -4386,7 +4388,7 @@ function bs(t = {}) {
|
|
|
4386
4388
|
}
|
|
4387
4389
|
function Ms(t) {
|
|
4388
4390
|
const e = Ct();
|
|
4389
|
-
return
|
|
4391
|
+
return Ft(() => e.nodes.find((n) => n.id === t) || void 0, [e.nodes, t]);
|
|
4390
4392
|
}
|
|
4391
4393
|
function Rs(t, e) {
|
|
4392
4394
|
return Ct(t, e);
|
|
@@ -4481,21 +4483,21 @@ function Ss({
|
|
|
4481
4483
|
const _ = $ - N, A = Y - R, I = Math.min(t / _, e / A), U = (t - _ * I) / 2, X = (e - A * I) / 2;
|
|
4482
4484
|
for (const h of E) {
|
|
4483
4485
|
if (h.hidden) continue;
|
|
4484
|
-
const g = h.width || Gn, S = h.height || On, P = (h.position.x - N) * I + U, W = (h.position.y - R) * I + X,
|
|
4485
|
-
z.fillStyle = h.selected ? "#f59e0b" : typeof n == "function" ? n(h) : n, z.fillRect(P, W, Math.max(
|
|
4486
|
+
const g = h.width || Gn, S = h.height || On, P = (h.position.x - N) * I + U, W = (h.position.y - R) * I + X, J = g * I, ot = S * I;
|
|
4487
|
+
z.fillStyle = h.selected ? "#f59e0b" : typeof n == "function" ? n(h) : n, z.fillRect(P, W, Math.max(J, 2), Math.max(ot, 2));
|
|
4486
4488
|
}
|
|
4487
4489
|
const T = d.cameraRef.current, v = d.wrapRef.current;
|
|
4488
4490
|
if (v) {
|
|
4489
4491
|
const h = v.getBoundingClientRect(), g = -T.x / T.zoom, S = -T.y / T.zoom, P = h.width / T.zoom, W = h.height / T.zoom;
|
|
4490
4492
|
z.fillStyle = i, z.fillRect(0, 0, t, e);
|
|
4491
|
-
const
|
|
4492
|
-
z.clearRect(
|
|
4493
|
+
const J = (g - N) * I + U, ot = (S - R) * I + X, et = P * I, st = W * I;
|
|
4494
|
+
z.clearRect(J, ot, et, st);
|
|
4493
4495
|
for (const pt of E) {
|
|
4494
4496
|
if (pt.hidden) continue;
|
|
4495
4497
|
const xt = pt.width || Gn, V = pt.height || On, ht = (pt.position.x - N) * I + U, wt = (pt.position.y - R) * I + X;
|
|
4496
4498
|
z.fillStyle = pt.selected ? "#f59e0b" : typeof n == "function" ? n(pt) : n, z.fillRect(ht, wt, Math.max(xt * I, 2), Math.max(V * I, 2));
|
|
4497
4499
|
}
|
|
4498
|
-
z.strokeStyle = "#3b82f6", z.lineWidth = 1.5, z.strokeRect(
|
|
4500
|
+
z.strokeStyle = "#3b82f6", z.lineWidth = 1.5, z.strokeRect(J, ot, et, st);
|
|
4499
4501
|
}
|
|
4500
4502
|
}, [d, t, e, n, r, i]);
|
|
4501
4503
|
return gt(() => {
|
|
@@ -4530,7 +4532,7 @@ function Ss({
|
|
|
4530
4532
|
);
|
|
4531
4533
|
}
|
|
4532
4534
|
function Po() {
|
|
4533
|
-
return /* @__PURE__ */
|
|
4535
|
+
return /* @__PURE__ */ Xt("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: [
|
|
4534
4536
|
/* @__PURE__ */ D("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
|
|
4535
4537
|
/* @__PURE__ */ D("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
4536
4538
|
] });
|
|
@@ -4542,13 +4544,13 @@ function $o() {
|
|
|
4542
4544
|
return /* @__PURE__ */ D("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__ */ D("path", { d: "M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7" }) });
|
|
4543
4545
|
}
|
|
4544
4546
|
function Ao() {
|
|
4545
|
-
return /* @__PURE__ */
|
|
4547
|
+
return /* @__PURE__ */ Xt("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: [
|
|
4546
4548
|
/* @__PURE__ */ D("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
|
|
4547
4549
|
/* @__PURE__ */ D("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })
|
|
4548
4550
|
] });
|
|
4549
4551
|
}
|
|
4550
4552
|
function Bo() {
|
|
4551
|
-
return /* @__PURE__ */
|
|
4553
|
+
return /* @__PURE__ */ Xt("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: [
|
|
4552
4554
|
/* @__PURE__ */ D("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
|
|
4553
4555
|
/* @__PURE__ */ D("path", { d: "M7 11V7a5 5 0 0 1 9.9-1" })
|
|
4554
4556
|
] });
|
|
@@ -4597,7 +4599,7 @@ function Do({
|
|
|
4597
4599
|
"bottom-right": { bottom: 30, right: 10 },
|
|
4598
4600
|
"bottom-center": { bottom: 30, left: "50%", transform: "translateX(-50%)" }
|
|
4599
4601
|
}[p] || { bottom: 30, left: 10 };
|
|
4600
|
-
return /* @__PURE__ */
|
|
4602
|
+
return /* @__PURE__ */ Xt(
|
|
4601
4603
|
"div",
|
|
4602
4604
|
{
|
|
4603
4605
|
className: `ric-controls ${m}`,
|
|
@@ -4613,7 +4615,7 @@ function Do({
|
|
|
4613
4615
|
role: "toolbar",
|
|
4614
4616
|
"aria-label": z,
|
|
4615
4617
|
children: [
|
|
4616
|
-
t && /* @__PURE__ */
|
|
4618
|
+
t && /* @__PURE__ */ Xt(Ye, { children: [
|
|
4617
4619
|
/* @__PURE__ */ D(
|
|
4618
4620
|
kn,
|
|
4619
4621
|
{
|
|
@@ -4769,7 +4771,7 @@ function Ps({
|
|
|
4769
4771
|
zIndex: 20,
|
|
4770
4772
|
...o
|
|
4771
4773
|
};
|
|
4772
|
-
return /* @__PURE__ */
|
|
4774
|
+
return /* @__PURE__ */ Xt(Ye, { children: [
|
|
4773
4775
|
/* @__PURE__ */ D(
|
|
4774
4776
|
"div",
|
|
4775
4777
|
{
|