@html-graph/html-graph 3.5.0 → 3.6.0
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/html-graph.d.ts +19 -16
- package/dist/html-graph.js +598 -530
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/html-graph.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (t, e, o) =>
|
|
4
|
-
const
|
|
1
|
+
var he = Object.defineProperty;
|
|
2
|
+
var de = (t, e, o) => e in t ? he(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
|
|
3
|
+
var i = (t, e, o) => de(t, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
const ce = () => {
|
|
5
5
|
const t = document.createElement("div");
|
|
6
6
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
|
|
7
|
-
},
|
|
7
|
+
}, ae = () => {
|
|
8
8
|
const t = document.createElement("div");
|
|
9
9
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
|
|
10
|
-
},
|
|
10
|
+
}, le = () => {
|
|
11
11
|
const t = document.createElement("div");
|
|
12
12
|
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class re {
|
|
15
15
|
constructor(e, o, r) {
|
|
16
|
-
i(this, "host",
|
|
17
|
-
i(this, "container",
|
|
16
|
+
i(this, "host", le());
|
|
17
|
+
i(this, "container", ce());
|
|
18
18
|
i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
19
19
|
i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
20
20
|
i(this, "applyTransform", () => {
|
|
@@ -24,7 +24,7 @@ class ne {
|
|
|
24
24
|
this.graphStore = e, this.viewportStore = o, this.element = r, this.element.appendChild(this.host), this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
|
|
25
25
|
}
|
|
26
26
|
attachNode(e) {
|
|
27
|
-
const o = this.graphStore.getNode(e), r =
|
|
27
|
+
const o = this.graphStore.getNode(e), r = ae();
|
|
28
28
|
r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(e, r), this.updateNodePosition(e), this.updateNodePriority(e), r.style.visibility = "visible";
|
|
29
29
|
}
|
|
30
30
|
detachNode(e) {
|
|
@@ -64,15 +64,15 @@ class ne {
|
|
|
64
64
|
this.edgeIdToElementMap.set(e, r.shape.svg), this.container.appendChild(r.shape.svg);
|
|
65
65
|
}
|
|
66
66
|
renderEdge(e) {
|
|
67
|
-
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), h = r.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = h.left - d.left, l = h.top - d.top, g = n.left - d.left, y = n.top - d.top,
|
|
67
|
+
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), h = r.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = h.left - d.left, l = h.top - d.top, g = n.left - d.left, y = n.top - d.top, p = {
|
|
68
68
|
x: c.scale * a + c.x,
|
|
69
69
|
y: c.scale * l + c.y
|
|
70
70
|
}, f = {
|
|
71
71
|
x: c.scale * g + c.x,
|
|
72
72
|
y: c.scale * y + c.y
|
|
73
|
-
},
|
|
74
|
-
x:
|
|
75
|
-
y:
|
|
73
|
+
}, E = {
|
|
74
|
+
x: p.x,
|
|
75
|
+
y: p.y,
|
|
76
76
|
width: h.width * c.scale,
|
|
77
77
|
height: h.height * c.scale,
|
|
78
78
|
direction: r.direction,
|
|
@@ -87,14 +87,14 @@ class ne {
|
|
|
87
87
|
portId: o.to,
|
|
88
88
|
nodeId: s.nodeId
|
|
89
89
|
};
|
|
90
|
-
o.shape.render({ from:
|
|
90
|
+
o.shape.render({ from: E, to: x });
|
|
91
91
|
}
|
|
92
92
|
updateEdgePriority(e) {
|
|
93
93
|
const o = this.graphStore.getEdge(e);
|
|
94
94
|
o.shape.svg.style.zIndex = `${o.priority}`;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
class
|
|
97
|
+
class ge {
|
|
98
98
|
constructor(e) {
|
|
99
99
|
i(this, "xFrom", 1 / 0);
|
|
100
100
|
i(this, "yFrom", 1 / 0);
|
|
@@ -114,7 +114,7 @@ class fe {
|
|
|
114
114
|
return d <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
class
|
|
117
|
+
class ue {
|
|
118
118
|
constructor(e, o, r) {
|
|
119
119
|
i(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
120
120
|
i(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
@@ -138,7 +138,7 @@ class ye {
|
|
|
138
138
|
this.handleAttachEdge(n);
|
|
139
139
|
});
|
|
140
140
|
});
|
|
141
|
-
this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new
|
|
141
|
+
this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new ge(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
142
142
|
}
|
|
143
143
|
attachNode(e) {
|
|
144
144
|
this.renderingBox.hasNode(e) && this.handleAttachNode(e);
|
|
@@ -192,7 +192,7 @@ class ye {
|
|
|
192
192
|
this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
class
|
|
195
|
+
class ie {
|
|
196
196
|
constructor() {
|
|
197
197
|
i(this, "callbacks", /* @__PURE__ */ new Set());
|
|
198
198
|
}
|
|
@@ -208,11 +208,11 @@ class he {
|
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
const
|
|
212
|
-
const t = new
|
|
211
|
+
const A = () => {
|
|
212
|
+
const t = new ie();
|
|
213
213
|
return [t, t];
|
|
214
214
|
};
|
|
215
|
-
class
|
|
215
|
+
class we {
|
|
216
216
|
constructor(e) {
|
|
217
217
|
i(this, "onBeforeUpdated");
|
|
218
218
|
i(this, "onAfterUpdated");
|
|
@@ -225,7 +225,7 @@ class ve {
|
|
|
225
225
|
return { ...this.viewportStore.getContentMatrix() };
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
class
|
|
228
|
+
class fe {
|
|
229
229
|
constructor(e) {
|
|
230
230
|
i(this, "onAfterNodeAdded");
|
|
231
231
|
i(this, "onAfterNodeUpdated");
|
|
@@ -301,7 +301,7 @@ class pe {
|
|
|
301
301
|
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
|
-
class
|
|
304
|
+
class C {
|
|
305
305
|
constructor(e) {
|
|
306
306
|
i(this, "counter", 0);
|
|
307
307
|
this.checkExists = e;
|
|
@@ -323,85 +323,31 @@ class S extends Error {
|
|
|
323
323
|
i(this, "name", "HtmlGraphError");
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
const
|
|
326
|
+
const ve = (t, e) => ({
|
|
327
327
|
x: t / 2,
|
|
328
328
|
y: e / 2
|
|
329
|
-
}),
|
|
329
|
+
}), $ = (t) => () => t, Q = $(0), ye = () => {
|
|
330
330
|
let t = 0;
|
|
331
331
|
return () => t++;
|
|
332
|
-
},
|
|
333
|
-
let o =
|
|
334
|
-
const s =
|
|
335
|
-
return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o =
|
|
332
|
+
}, pe = (t, e) => {
|
|
333
|
+
let o = Q, r = Q;
|
|
334
|
+
const s = ye();
|
|
335
|
+
return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o = $(t)), typeof e == "number" && (r = $(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
|
|
336
336
|
nodesPriorityFn: o,
|
|
337
337
|
edgesPriorityFn: r
|
|
338
338
|
};
|
|
339
|
-
},
|
|
339
|
+
}, v = (t, e, o) => ({
|
|
340
340
|
x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
|
|
341
341
|
y: e.y * t.x + e.x * t.y + ((1 - e.x) * o.y - e.y * o.x)
|
|
342
|
-
}),
|
|
342
|
+
}), w = {
|
|
343
343
|
x: 0,
|
|
344
344
|
y: 0
|
|
345
|
-
},
|
|
346
|
-
const
|
|
347
|
-
w,
|
|
348
|
-
{ x: o, y: r },
|
|
349
|
-
{ x: o, y: -r }
|
|
350
|
-
].map((a) => p(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${h[0].x} ${h[0].y}`, d = `L ${h[1].x} ${h[1].y}`, c = `L ${h[2].x} ${h[2].y}`;
|
|
351
|
-
return `${n} ${d} ${c}`;
|
|
352
|
-
}, B = (t, e) => {
|
|
353
|
-
const o = [];
|
|
354
|
-
if (t.length > 0 && o.push(`M ${t[0].x} ${t[0].y}`), t.length === 2 && o.push(`L ${t[1].x} ${t[1].y}`), t.length > 2) {
|
|
355
|
-
const r = t.length - 1;
|
|
356
|
-
let s = 0, h = 0, n = 0;
|
|
357
|
-
t.forEach((d, c) => {
|
|
358
|
-
let a = 0, l = 0, g = 0;
|
|
359
|
-
const y = c > 0, v = c < r, f = y && v;
|
|
360
|
-
if (y && (a = -s, l = -h, g = n), v) {
|
|
361
|
-
const I = t[c + 1];
|
|
362
|
-
s = I.x - d.x, h = I.y - d.y, n = Math.sqrt(s * s + h * h);
|
|
363
|
-
}
|
|
364
|
-
const x = n !== 0 ? Math.min((f ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, b = f ? { x: d.x + s * x, y: d.y + h * x } : d, m = g !== 0 ? Math.min((f ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, R = f ? { x: d.x + a * m, y: d.y + l * m } : d;
|
|
365
|
-
c > 0 && o.push(`L ${R.x} ${R.y}`), f && o.push(
|
|
366
|
-
`C ${d.x} ${d.y} ${d.x} ${d.y} ${b.x} ${b.y}`
|
|
367
|
-
);
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
return o.join(" ");
|
|
371
|
-
}, $ = () => {
|
|
372
|
-
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
373
|
-
return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
|
|
374
|
-
}, W = () => {
|
|
375
|
-
const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
376
|
-
return t.style.transformOrigin = "50% 50%", t;
|
|
377
|
-
}, F = (t, e) => {
|
|
378
|
-
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
379
|
-
return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
|
|
380
|
-
}, P = (t) => {
|
|
381
|
-
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
382
|
-
return e.setAttribute("fill", t), e;
|
|
383
|
-
}, z = (t, e) => {
|
|
384
|
-
const o = {
|
|
385
|
-
x: t.x + t.width / 2,
|
|
386
|
-
y: t.y + t.height / 2
|
|
387
|
-
}, r = {
|
|
388
|
-
x: e.x + e.width / 2,
|
|
389
|
-
y: e.y + e.height / 2
|
|
390
|
-
}, s = Math.min(o.x, r.x), h = Math.min(o.y, r.y), n = Math.abs(r.x - o.x), d = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, a = o.y <= r.y ? 1 : -1;
|
|
391
|
-
return {
|
|
392
|
-
x: s,
|
|
393
|
-
y: h,
|
|
394
|
-
width: n,
|
|
395
|
-
height: d,
|
|
396
|
-
flipX: c,
|
|
397
|
-
flipY: a
|
|
398
|
-
};
|
|
399
|
-
}, Se = (t) => {
|
|
400
|
-
const e = p(
|
|
345
|
+
}, xe = (t) => {
|
|
346
|
+
const e = v(
|
|
401
347
|
{ x: t.arrowLength, y: w.y },
|
|
402
348
|
t.fromVector,
|
|
403
349
|
w
|
|
404
|
-
), o =
|
|
350
|
+
), o = v(
|
|
405
351
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
406
352
|
t.toVector,
|
|
407
353
|
t.to
|
|
@@ -413,36 +359,36 @@ const xe = (t, e) => ({
|
|
|
413
359
|
y: o.y - t.toVector.y * t.curvature
|
|
414
360
|
}, h = `M ${e.x} ${e.y} C ${r.x} ${r.y}, ${s.x} ${s.y}, ${o.x} ${o.y}`, n = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, d = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
|
|
415
361
|
return `${n}${h}${d}`;
|
|
416
|
-
},
|
|
417
|
-
const e = t.hasSourceArrow ?
|
|
362
|
+
}, Ee = (t) => {
|
|
363
|
+
const e = t.hasSourceArrow ? v(
|
|
418
364
|
{ x: t.arrowLength, y: w.y },
|
|
419
365
|
t.fromVector,
|
|
420
366
|
w
|
|
421
|
-
) : w, o = t.hasTargetArrow ?
|
|
367
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
422
368
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
423
369
|
t.toVector,
|
|
424
370
|
t.to
|
|
425
|
-
) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, d = h * t.flipY, c =
|
|
371
|
+
) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, d = h * t.flipY, c = v(
|
|
426
372
|
{ x: r, y: w.y },
|
|
427
373
|
t.fromVector,
|
|
428
374
|
w
|
|
429
375
|
), a = {
|
|
430
376
|
x: c.x + n,
|
|
431
377
|
y: c.y + d
|
|
432
|
-
}, l =
|
|
378
|
+
}, l = v(
|
|
433
379
|
{ x: t.to.x - r, y: t.to.y },
|
|
434
380
|
t.toVector,
|
|
435
381
|
t.to
|
|
436
382
|
), g = {
|
|
437
383
|
x: l.x + n,
|
|
438
384
|
y: l.y + d
|
|
439
|
-
}, y = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 },
|
|
385
|
+
}, y = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, p = {
|
|
440
386
|
x: c.x + t.curvature * t.fromVector.x,
|
|
441
387
|
y: c.y + t.curvature * t.fromVector.y
|
|
442
388
|
}, f = {
|
|
443
389
|
x: l.x - t.curvature * t.toVector.x,
|
|
444
390
|
y: l.y - t.curvature * t.toVector.y
|
|
445
|
-
},
|
|
391
|
+
}, E = {
|
|
446
392
|
x: c.x + n,
|
|
447
393
|
y: c.y + d
|
|
448
394
|
}, x = {
|
|
@@ -452,24 +398,43 @@ const xe = (t, e) => ({
|
|
|
452
398
|
return [
|
|
453
399
|
`M ${e.x} ${e.y}`,
|
|
454
400
|
`L ${c.x} ${c.y}`,
|
|
455
|
-
`C ${
|
|
401
|
+
`C ${p.x} ${p.y} ${E.x} ${E.y} ${y.x} ${y.y}`,
|
|
456
402
|
`C ${x.x} ${x.y} ${f.x} ${f.y} ${l.x} ${l.y}`,
|
|
457
403
|
`L ${o.x} ${o.y}`
|
|
458
404
|
].join(" ");
|
|
459
|
-
},
|
|
460
|
-
const
|
|
405
|
+
}, L = (t, e) => {
|
|
406
|
+
const o = [];
|
|
407
|
+
if (t.length > 0 && o.push(`M ${t[0].x} ${t[0].y}`), t.length === 2 && o.push(`L ${t[1].x} ${t[1].y}`), t.length > 2) {
|
|
408
|
+
const r = t.length - 1;
|
|
409
|
+
let s = 0, h = 0, n = 0;
|
|
410
|
+
t.forEach((d, c) => {
|
|
411
|
+
let a = 0, l = 0, g = 0;
|
|
412
|
+
const y = c > 0, p = c < r, f = y && p;
|
|
413
|
+
if (y && (a = -s, l = -h, g = n), p) {
|
|
414
|
+
const V = t[c + 1];
|
|
415
|
+
s = V.x - d.x, h = V.y - d.y, n = Math.sqrt(s * s + h * h);
|
|
416
|
+
}
|
|
417
|
+
const x = n !== 0 ? Math.min((f ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, T = f ? { x: d.x + s * x, y: d.y + h * x } : d, m = g !== 0 ? Math.min((f ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, D = f ? { x: d.x + a * m, y: d.y + l * m } : d;
|
|
418
|
+
c > 0 && o.push(`L ${D.x} ${D.y}`), f && o.push(
|
|
419
|
+
`C ${d.x} ${d.y} ${d.x} ${d.y} ${T.x} ${T.y}`
|
|
420
|
+
);
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
return o.join(" ");
|
|
424
|
+
}, Ae = (t) => {
|
|
425
|
+
const e = t.hasSourceArrow ? v(
|
|
461
426
|
{ x: t.arrowLength, y: w.y },
|
|
462
427
|
t.fromVector,
|
|
463
428
|
w
|
|
464
|
-
) : w, o = t.hasTargetArrow ?
|
|
429
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
465
430
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
466
431
|
t.toVector,
|
|
467
432
|
t.to
|
|
468
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h =
|
|
433
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h = v(
|
|
469
434
|
{ x: s, y: w.y },
|
|
470
435
|
t.fromVector,
|
|
471
436
|
w
|
|
472
|
-
), n =
|
|
437
|
+
), n = v(
|
|
473
438
|
{ x: t.to.x - s, y: t.to.y },
|
|
474
439
|
t.toVector,
|
|
475
440
|
t.to
|
|
@@ -480,65 +445,65 @@ const xe = (t, e) => ({
|
|
|
480
445
|
x: t.flipX > 0 ? t.to.x - d : t.to.x + r,
|
|
481
446
|
y: n.y
|
|
482
447
|
}, y = { x: g.x, y: c };
|
|
483
|
-
return
|
|
448
|
+
return L(
|
|
484
449
|
[e, h, a, l, y, g, n, o],
|
|
485
450
|
t.roundness
|
|
486
451
|
);
|
|
487
|
-
},
|
|
488
|
-
const e = t.hasSourceArrow ?
|
|
452
|
+
}, F = (t) => {
|
|
453
|
+
const e = t.hasSourceArrow ? v(
|
|
489
454
|
{ x: t.arrowLength, y: w.y },
|
|
490
455
|
t.fromVector,
|
|
491
456
|
w
|
|
492
|
-
) : w, o = t.hasTargetArrow ?
|
|
457
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
493
458
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
494
459
|
t.toVector,
|
|
495
460
|
t.to
|
|
496
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, s =
|
|
461
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = v(
|
|
497
462
|
{ x: r, y: w.y },
|
|
498
463
|
t.fromVector,
|
|
499
464
|
w
|
|
500
|
-
), h = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, d = h * t.flipX, c = n * t.flipY, a = { x: s.x + d, y: s.y + c }, l =
|
|
465
|
+
), h = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, d = h * t.flipX, c = n * t.flipY, a = { x: s.x + d, y: s.y + c }, l = v(
|
|
501
466
|
{ x: t.to.x - r, y: t.to.y },
|
|
502
467
|
t.toVector,
|
|
503
468
|
t.to
|
|
504
469
|
), g = { x: l.x + d, y: l.y + c };
|
|
505
|
-
return
|
|
470
|
+
return L(
|
|
506
471
|
[e, s, a, g, l, o],
|
|
507
472
|
t.roundness
|
|
508
473
|
);
|
|
509
|
-
},
|
|
510
|
-
const e = t.hasSourceArrow ?
|
|
474
|
+
}, Se = (t) => {
|
|
475
|
+
const e = t.hasSourceArrow ? v(
|
|
511
476
|
{ x: t.arrowLength, y: w.y },
|
|
512
477
|
t.fromVector,
|
|
513
478
|
w
|
|
514
|
-
) : w, o = t.hasTargetArrow ?
|
|
479
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
515
480
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
516
481
|
t.toVector,
|
|
517
482
|
t.to
|
|
518
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, s =
|
|
483
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = v(
|
|
519
484
|
{ x: r, y: w.y },
|
|
520
485
|
t.fromVector,
|
|
521
486
|
w
|
|
522
|
-
), h =
|
|
487
|
+
), h = v(
|
|
523
488
|
{ x: t.to.x - r, y: t.to.y },
|
|
524
489
|
t.toVector,
|
|
525
490
|
t.to
|
|
526
491
|
);
|
|
527
|
-
return
|
|
528
|
-
},
|
|
529
|
-
const e = t.hasSourceArrow ?
|
|
492
|
+
return L([e, s, h, o], t.roundness);
|
|
493
|
+
}, Te = (t) => {
|
|
494
|
+
const e = t.hasSourceArrow ? v(
|
|
530
495
|
{ x: t.arrowLength, y: w.y },
|
|
531
496
|
t.fromVector,
|
|
532
497
|
w
|
|
533
|
-
) : w, o = t.hasTargetArrow ?
|
|
498
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
534
499
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
535
500
|
t.toVector,
|
|
536
501
|
t.to
|
|
537
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h =
|
|
502
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h = v(
|
|
538
503
|
{ x: s, y: w.y },
|
|
539
504
|
t.fromVector,
|
|
540
505
|
w
|
|
541
|
-
), n =
|
|
506
|
+
), n = v(
|
|
542
507
|
{ x: t.to.x - s, y: t.to.y },
|
|
543
508
|
t.toVector,
|
|
544
509
|
t.to
|
|
@@ -549,11 +514,11 @@ const xe = (t, e) => ({
|
|
|
549
514
|
x: n.x,
|
|
550
515
|
y: t.flipY > 0 ? t.to.y - d : t.to.y + r
|
|
551
516
|
}, y = { x: c, y: g.y };
|
|
552
|
-
return
|
|
517
|
+
return L(
|
|
553
518
|
[e, h, a, l, y, g, n, o],
|
|
554
519
|
t.roundness
|
|
555
520
|
);
|
|
556
|
-
},
|
|
521
|
+
}, z = (t) => {
|
|
557
522
|
const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, s = r + 2 * o, n = [
|
|
558
523
|
{ x: t.arrowLength, y: w.y },
|
|
559
524
|
{ x: r, y: w.y },
|
|
@@ -564,16 +529,16 @@ const xe = (t, e) => ({
|
|
|
564
529
|
{ x: r, y: w.y },
|
|
565
530
|
{ x: t.arrowLength, y: w.y }
|
|
566
531
|
].map(
|
|
567
|
-
(c) =>
|
|
532
|
+
(c) => v(c, t.fromVector, w)
|
|
568
533
|
), d = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
|
|
569
|
-
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${
|
|
570
|
-
},
|
|
534
|
+
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${L(n, t.roundness)}`;
|
|
535
|
+
}, me = (t) => {
|
|
571
536
|
const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), s = e + o, h = t.arrowLength + r * (1 - o / s), n = e * o / s, c = [
|
|
572
537
|
{ x: t.arrowLength, y: w.y },
|
|
573
538
|
{ x: h, y: n },
|
|
574
539
|
{ x: h, y: -n }
|
|
575
540
|
].map(
|
|
576
|
-
(g) =>
|
|
541
|
+
(g) => v(g, t.fromVector, w)
|
|
577
542
|
), a = [
|
|
578
543
|
`M ${c[0].x} ${c[0].y}`,
|
|
579
544
|
`A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
|
|
@@ -597,96 +562,170 @@ const xe = (t, e) => ({
|
|
|
597
562
|
detourDirectionVertical: 0,
|
|
598
563
|
smallCycleRadius: 15,
|
|
599
564
|
curvature: 90
|
|
600
|
-
})
|
|
601
|
-
|
|
565
|
+
}), Z = (t, e, o, r) => {
|
|
566
|
+
const h = [
|
|
567
|
+
w,
|
|
568
|
+
{ x: o, y: r },
|
|
569
|
+
{ x: o, y: -r }
|
|
570
|
+
].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${h[0].x} ${h[0].y}`, d = `L ${h[1].x} ${h[1].y}`, c = `L ${h[2].x} ${h[2].y}`;
|
|
571
|
+
return `${n} ${d} ${c}`;
|
|
572
|
+
}, _ = (t) => {
|
|
573
|
+
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
574
|
+
return e.setAttribute("fill", t), e;
|
|
575
|
+
}, be = () => {
|
|
576
|
+
const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
577
|
+
return t.style.transformOrigin = "50% 50%", t;
|
|
578
|
+
}, Pe = (t, e) => {
|
|
579
|
+
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
580
|
+
return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
|
|
581
|
+
}, Ne = (t, e) => {
|
|
582
|
+
const o = {
|
|
583
|
+
x: t.x + t.width / 2,
|
|
584
|
+
y: t.y + t.height / 2
|
|
585
|
+
}, r = {
|
|
586
|
+
x: e.x + e.width / 2,
|
|
587
|
+
y: e.y + e.height / 2
|
|
588
|
+
}, s = Math.min(o.x, r.x), h = Math.min(o.y, r.y), n = Math.abs(r.x - o.x), d = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, a = o.y <= r.y ? 1 : -1;
|
|
589
|
+
return {
|
|
590
|
+
x: s,
|
|
591
|
+
y: h,
|
|
592
|
+
width: n,
|
|
593
|
+
height: d,
|
|
594
|
+
flipX: c,
|
|
595
|
+
flipY: a
|
|
596
|
+
};
|
|
597
|
+
}, Me = () => {
|
|
598
|
+
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
599
|
+
return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
|
|
600
|
+
}, q = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) });
|
|
601
|
+
class I {
|
|
602
602
|
constructor(e) {
|
|
603
|
-
i(this, "svg",
|
|
604
|
-
i(this, "group",
|
|
603
|
+
i(this, "svg", Me());
|
|
604
|
+
i(this, "group", be());
|
|
605
605
|
i(this, "line");
|
|
606
606
|
i(this, "sourceArrow", null);
|
|
607
607
|
i(this, "targetArrow", null);
|
|
608
|
-
|
|
609
|
-
i(this, "arrowWidth");
|
|
610
|
-
i(this, "curvature");
|
|
611
|
-
i(this, "portCycleRadius");
|
|
612
|
-
i(this, "portCycleSmallRadius");
|
|
613
|
-
i(this, "detourDirection");
|
|
614
|
-
i(this, "detourDistance");
|
|
615
|
-
i(this, "hasSourceArrow");
|
|
616
|
-
i(this, "hasTargetArrow");
|
|
617
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? u.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
618
|
-
const o = (e == null ? void 0 : e.color) ?? u.color, r = (e == null ? void 0 : e.width) ?? u.width;
|
|
619
|
-
this.svg.appendChild(this.group), this.line = F(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(o), this.group.appendChild(this.targetArrow));
|
|
608
|
+
this.params = e, this.svg.appendChild(this.group), this.line = Pe(e.color, e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = _(e.color), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = _(e.color), this.group.appendChild(this.targetArrow));
|
|
620
609
|
}
|
|
621
610
|
render(e) {
|
|
622
|
-
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } =
|
|
611
|
+
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = Ne(
|
|
623
612
|
e.from,
|
|
624
613
|
e.to
|
|
625
614
|
);
|
|
626
615
|
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
|
|
627
|
-
const c =
|
|
616
|
+
const c = q(
|
|
628
617
|
e.from.direction,
|
|
629
618
|
n,
|
|
630
619
|
d
|
|
631
|
-
), a =
|
|
620
|
+
), a = q(
|
|
621
|
+
e.to.direction,
|
|
622
|
+
n,
|
|
623
|
+
d
|
|
624
|
+
), l = {
|
|
632
625
|
x: s,
|
|
633
626
|
y: h
|
|
634
627
|
};
|
|
635
|
-
let g, y = a,
|
|
636
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
637
|
-
|
|
628
|
+
let g, y = a, p = -this.params.arrowLength;
|
|
629
|
+
if (e.from.portId === e.to.portId ? (g = this.params.createCyclePath(
|
|
630
|
+
c,
|
|
631
|
+
a,
|
|
632
|
+
l,
|
|
633
|
+
n,
|
|
634
|
+
d
|
|
635
|
+
), y = c, p = this.params.arrowLength) : e.from.nodeId === e.to.nodeId ? g = this.params.createDetourPath(
|
|
636
|
+
c,
|
|
637
|
+
a,
|
|
638
|
+
l,
|
|
639
|
+
n,
|
|
640
|
+
d
|
|
641
|
+
) : g = this.params.createLinePath(
|
|
642
|
+
c,
|
|
643
|
+
a,
|
|
644
|
+
l,
|
|
645
|
+
n,
|
|
646
|
+
d
|
|
647
|
+
), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
648
|
+
const f = Z(
|
|
649
|
+
c,
|
|
650
|
+
w,
|
|
651
|
+
this.params.arrowLength,
|
|
652
|
+
this.params.arrowWidth
|
|
653
|
+
);
|
|
654
|
+
this.sourceArrow.setAttribute("d", f);
|
|
655
|
+
}
|
|
656
|
+
if (this.targetArrow) {
|
|
657
|
+
const f = Z(
|
|
658
|
+
y,
|
|
659
|
+
l,
|
|
660
|
+
p,
|
|
661
|
+
this.params.arrowWidth
|
|
662
|
+
);
|
|
663
|
+
this.targetArrow.setAttribute("d", f);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
class De {
|
|
668
|
+
constructor(e) {
|
|
669
|
+
i(this, "svg");
|
|
670
|
+
i(this, "arrowLength");
|
|
671
|
+
i(this, "arrowWidth");
|
|
672
|
+
i(this, "curvature");
|
|
673
|
+
i(this, "portCycleRadius");
|
|
674
|
+
i(this, "portCycleSmallRadius");
|
|
675
|
+
i(this, "detourDirection");
|
|
676
|
+
i(this, "detourDistance");
|
|
677
|
+
i(this, "hasSourceArrow");
|
|
678
|
+
i(this, "hasTargetArrow");
|
|
679
|
+
i(this, "genericShape");
|
|
680
|
+
i(this, "createCyclePath", (e) => me({
|
|
681
|
+
fromVector: e,
|
|
638
682
|
radius: this.portCycleRadius,
|
|
639
683
|
smallRadius: this.portCycleSmallRadius,
|
|
640
684
|
arrowLength: this.arrowLength,
|
|
641
685
|
hasSourceArrow: this.hasSourceArrow,
|
|
642
686
|
hasTargetArrow: this.hasTargetArrow
|
|
643
|
-
})
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
687
|
+
}));
|
|
688
|
+
i(this, "createDetourPath", (e, o, r, s, h) => Ee({
|
|
689
|
+
to: r,
|
|
690
|
+
fromVector: e,
|
|
691
|
+
toVector: o,
|
|
692
|
+
flipX: s,
|
|
693
|
+
flipY: h,
|
|
649
694
|
arrowLength: this.arrowLength,
|
|
650
695
|
detourDirection: this.detourDirection,
|
|
651
696
|
detourDistance: this.detourDistance,
|
|
652
697
|
curvature: this.curvature,
|
|
653
698
|
hasSourceArrow: this.hasSourceArrow,
|
|
654
699
|
hasTargetArrow: this.hasTargetArrow
|
|
655
|
-
})
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
700
|
+
}));
|
|
701
|
+
i(this, "createLinePath", (e, o, r) => xe({
|
|
702
|
+
to: r,
|
|
703
|
+
fromVector: e,
|
|
704
|
+
toVector: o,
|
|
659
705
|
arrowLength: this.arrowLength,
|
|
660
706
|
curvature: this.curvature,
|
|
661
707
|
hasSourceArrow: this.hasSourceArrow,
|
|
662
708
|
hasTargetArrow: this.hasTargetArrow
|
|
663
|
-
})
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
this.
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
);
|
|
679
|
-
this.targetArrow.setAttribute("d", f);
|
|
680
|
-
}
|
|
709
|
+
}));
|
|
710
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? u.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.genericShape = new I({
|
|
711
|
+
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
712
|
+
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
713
|
+
arrowLength: this.arrowLength,
|
|
714
|
+
arrowWidth: this.arrowWidth,
|
|
715
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
716
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
717
|
+
createCyclePath: this.createCyclePath,
|
|
718
|
+
createDetourPath: this.createDetourPath,
|
|
719
|
+
createLinePath: this.createLinePath
|
|
720
|
+
}), this.svg = this.genericShape.svg;
|
|
721
|
+
}
|
|
722
|
+
render(e) {
|
|
723
|
+
this.genericShape.render(e);
|
|
681
724
|
}
|
|
682
725
|
}
|
|
683
|
-
class
|
|
726
|
+
class Ve {
|
|
684
727
|
constructor(e) {
|
|
685
|
-
i(this, "svg"
|
|
686
|
-
i(this, "group", W());
|
|
687
|
-
i(this, "line");
|
|
688
|
-
i(this, "sourceArrow", null);
|
|
689
|
-
i(this, "targetArrow", null);
|
|
728
|
+
i(this, "svg");
|
|
690
729
|
i(this, "arrowLength");
|
|
691
730
|
i(this, "arrowWidth");
|
|
692
731
|
i(this, "arrowOffset");
|
|
@@ -696,45 +735,22 @@ class Me {
|
|
|
696
735
|
i(this, "detourDistance");
|
|
697
736
|
i(this, "hasSourceArrow");
|
|
698
737
|
i(this, "hasTargetArrow");
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
o,
|
|
703
|
-
this.arrowOffset,
|
|
704
|
-
this.cycleSquareSide / 2
|
|
705
|
-
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
706
|
-
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
707
|
-
this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
|
|
708
|
-
}
|
|
709
|
-
render(e) {
|
|
710
|
-
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
|
|
711
|
-
e.from,
|
|
712
|
-
e.to
|
|
713
|
-
);
|
|
714
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
|
|
715
|
-
const c = T(
|
|
716
|
-
e.from.direction,
|
|
717
|
-
n,
|
|
718
|
-
d
|
|
719
|
-
), a = T(e.to.direction, n, d), l = {
|
|
720
|
-
x: s,
|
|
721
|
-
y: h
|
|
722
|
-
};
|
|
723
|
-
let g, y = a, v = -this.arrowLength;
|
|
724
|
-
if (e.from.portId === e.to.portId ? (g = j({
|
|
725
|
-
fromVector: c,
|
|
738
|
+
i(this, "genericShape");
|
|
739
|
+
i(this, "createCyclePath", (e) => z({
|
|
740
|
+
fromVector: e,
|
|
726
741
|
arrowLength: this.arrowLength,
|
|
727
742
|
side: this.cycleSquareSide,
|
|
728
743
|
arrowOffset: this.arrowOffset,
|
|
729
744
|
roundness: this.roundness,
|
|
730
745
|
hasSourceArrow: this.hasSourceArrow,
|
|
731
746
|
hasTargetArrow: this.hasTargetArrow
|
|
732
|
-
})
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
747
|
+
}));
|
|
748
|
+
i(this, "createDetourPath", (e, o, r, s, h) => F({
|
|
749
|
+
to: r,
|
|
750
|
+
fromVector: e,
|
|
751
|
+
toVector: o,
|
|
752
|
+
flipX: s,
|
|
753
|
+
flipY: h,
|
|
738
754
|
arrowLength: this.arrowLength,
|
|
739
755
|
arrowOffset: this.arrowOffset,
|
|
740
756
|
roundness: this.roundness,
|
|
@@ -742,43 +758,43 @@ class Me {
|
|
|
742
758
|
detourDistance: this.detourDistance,
|
|
743
759
|
hasSourceArrow: this.hasSourceArrow,
|
|
744
760
|
hasTargetArrow: this.hasTargetArrow
|
|
745
|
-
})
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
761
|
+
}));
|
|
762
|
+
i(this, "createLinePath", (e, o, r, s) => Ae({
|
|
763
|
+
to: r,
|
|
764
|
+
fromVector: e,
|
|
765
|
+
toVector: o,
|
|
766
|
+
flipX: s,
|
|
750
767
|
arrowLength: this.arrowLength,
|
|
751
768
|
arrowOffset: this.arrowOffset,
|
|
752
769
|
roundness: this.roundness,
|
|
753
770
|
hasSourceArrow: this.hasSourceArrow,
|
|
754
771
|
hasTargetArrow: this.hasTargetArrow
|
|
755
|
-
})
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
this.
|
|
772
|
-
}
|
|
772
|
+
}));
|
|
773
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
774
|
+
const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
775
|
+
this.roundness = Math.min(
|
|
776
|
+
o,
|
|
777
|
+
this.arrowOffset,
|
|
778
|
+
this.cycleSquareSide / 2
|
|
779
|
+
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.genericShape = new I({
|
|
780
|
+
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
781
|
+
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
782
|
+
arrowLength: this.arrowLength,
|
|
783
|
+
arrowWidth: this.arrowWidth,
|
|
784
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
785
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
786
|
+
createCyclePath: this.createCyclePath,
|
|
787
|
+
createDetourPath: this.createDetourPath,
|
|
788
|
+
createLinePath: this.createLinePath
|
|
789
|
+
}), this.svg = this.genericShape.svg;
|
|
790
|
+
}
|
|
791
|
+
render(e) {
|
|
792
|
+
this.genericShape.render(e);
|
|
773
793
|
}
|
|
774
794
|
}
|
|
775
|
-
class
|
|
795
|
+
class Le {
|
|
776
796
|
constructor(e) {
|
|
777
|
-
i(this, "svg"
|
|
778
|
-
i(this, "group", W());
|
|
779
|
-
i(this, "line");
|
|
780
|
-
i(this, "sourceArrow", null);
|
|
781
|
-
i(this, "targetArrow", null);
|
|
797
|
+
i(this, "svg");
|
|
782
798
|
i(this, "arrowLength");
|
|
783
799
|
i(this, "arrowWidth");
|
|
784
800
|
i(this, "arrowOffset");
|
|
@@ -788,45 +804,22 @@ class Ve {
|
|
|
788
804
|
i(this, "detourDistance");
|
|
789
805
|
i(this, "hasSourceArrow");
|
|
790
806
|
i(this, "hasTargetArrow");
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
o,
|
|
795
|
-
this.arrowOffset,
|
|
796
|
-
this.cycleSquareSide / 2
|
|
797
|
-
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
798
|
-
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
799
|
-
this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
|
|
800
|
-
}
|
|
801
|
-
render(e) {
|
|
802
|
-
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
|
|
803
|
-
e.from,
|
|
804
|
-
e.to
|
|
805
|
-
);
|
|
806
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
|
|
807
|
-
const c = T(
|
|
808
|
-
e.from.direction,
|
|
809
|
-
n,
|
|
810
|
-
d
|
|
811
|
-
), a = T(e.to.direction, n, d), l = {
|
|
812
|
-
x: s,
|
|
813
|
-
y: h
|
|
814
|
-
};
|
|
815
|
-
let g, y = a, v = -this.arrowLength;
|
|
816
|
-
if (e.from.portId === e.to.portId ? (g = j({
|
|
817
|
-
fromVector: c,
|
|
807
|
+
i(this, "genericShape");
|
|
808
|
+
i(this, "createCyclePath", (e) => z({
|
|
809
|
+
fromVector: e,
|
|
818
810
|
arrowLength: this.arrowLength,
|
|
819
811
|
side: this.cycleSquareSide,
|
|
820
812
|
arrowOffset: this.arrowOffset,
|
|
821
813
|
roundness: this.roundness,
|
|
822
814
|
hasSourceArrow: this.hasSourceArrow,
|
|
823
815
|
hasTargetArrow: this.hasTargetArrow
|
|
824
|
-
})
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
816
|
+
}));
|
|
817
|
+
i(this, "createDetourPath", (e, o, r, s, h) => F({
|
|
818
|
+
to: r,
|
|
819
|
+
fromVector: e,
|
|
820
|
+
toVector: o,
|
|
821
|
+
flipX: s,
|
|
822
|
+
flipY: h,
|
|
830
823
|
arrowLength: this.arrowLength,
|
|
831
824
|
arrowOffset: this.arrowOffset,
|
|
832
825
|
roundness: this.roundness,
|
|
@@ -834,42 +827,42 @@ class Ve {
|
|
|
834
827
|
detourDistance: this.detourDistance,
|
|
835
828
|
hasSourceArrow: this.hasSourceArrow,
|
|
836
829
|
hasTargetArrow: this.hasTargetArrow
|
|
837
|
-
})
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
830
|
+
}));
|
|
831
|
+
i(this, "createLinePath", (e, o, r) => Se({
|
|
832
|
+
to: r,
|
|
833
|
+
fromVector: e,
|
|
834
|
+
toVector: o,
|
|
841
835
|
arrowLength: this.arrowLength,
|
|
842
836
|
arrowOffset: this.arrowOffset,
|
|
843
837
|
roundness: this.roundness,
|
|
844
838
|
hasSourceArrow: this.hasSourceArrow,
|
|
845
839
|
hasTargetArrow: this.hasTargetArrow
|
|
846
|
-
})
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
this.
|
|
863
|
-
}
|
|
840
|
+
}));
|
|
841
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
842
|
+
const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
843
|
+
this.roundness = Math.min(
|
|
844
|
+
o,
|
|
845
|
+
this.arrowOffset,
|
|
846
|
+
this.cycleSquareSide / 2
|
|
847
|
+
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.genericShape = new I({
|
|
848
|
+
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
849
|
+
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
850
|
+
arrowLength: this.arrowLength,
|
|
851
|
+
arrowWidth: this.arrowWidth,
|
|
852
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
853
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
854
|
+
createCyclePath: this.createCyclePath,
|
|
855
|
+
createDetourPath: this.createDetourPath,
|
|
856
|
+
createLinePath: this.createLinePath
|
|
857
|
+
}), this.svg = this.genericShape.svg;
|
|
858
|
+
}
|
|
859
|
+
render(e) {
|
|
860
|
+
this.genericShape.render(e);
|
|
864
861
|
}
|
|
865
862
|
}
|
|
866
|
-
class
|
|
863
|
+
class Re {
|
|
867
864
|
constructor(e) {
|
|
868
|
-
i(this, "svg"
|
|
869
|
-
i(this, "group", W());
|
|
870
|
-
i(this, "line");
|
|
871
|
-
i(this, "sourceArrow", null);
|
|
872
|
-
i(this, "targetArrow", null);
|
|
865
|
+
i(this, "svg");
|
|
873
866
|
i(this, "arrowLength");
|
|
874
867
|
i(this, "arrowWidth");
|
|
875
868
|
i(this, "arrowOffset");
|
|
@@ -879,45 +872,22 @@ class Le {
|
|
|
879
872
|
i(this, "detourDistance");
|
|
880
873
|
i(this, "hasSourceArrow");
|
|
881
874
|
i(this, "hasTargetArrow");
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
o,
|
|
886
|
-
this.arrowOffset,
|
|
887
|
-
this.cycleSquareSide / 2
|
|
888
|
-
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
889
|
-
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
890
|
-
this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
|
|
891
|
-
}
|
|
892
|
-
render(e) {
|
|
893
|
-
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
|
|
894
|
-
e.from,
|
|
895
|
-
e.to
|
|
896
|
-
);
|
|
897
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
|
|
898
|
-
const c = T(
|
|
899
|
-
e.from.direction,
|
|
900
|
-
n,
|
|
901
|
-
d
|
|
902
|
-
), a = T(e.to.direction, n, d), l = {
|
|
903
|
-
x: s,
|
|
904
|
-
y: h
|
|
905
|
-
};
|
|
906
|
-
let g, y = a, v = -this.arrowLength;
|
|
907
|
-
if (e.from.portId === e.to.portId ? (g = j({
|
|
908
|
-
fromVector: c,
|
|
875
|
+
i(this, "genericShape");
|
|
876
|
+
i(this, "createCyclePath", (e) => z({
|
|
877
|
+
fromVector: e,
|
|
909
878
|
arrowLength: this.arrowLength,
|
|
910
879
|
side: this.cycleSquareSide,
|
|
911
880
|
arrowOffset: this.arrowOffset,
|
|
912
881
|
roundness: this.roundness,
|
|
913
882
|
hasSourceArrow: this.hasSourceArrow,
|
|
914
883
|
hasTargetArrow: this.hasTargetArrow
|
|
915
|
-
})
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
884
|
+
}));
|
|
885
|
+
i(this, "createDetourPath", (e, o, r, s, h) => F({
|
|
886
|
+
to: r,
|
|
887
|
+
fromVector: e,
|
|
888
|
+
toVector: o,
|
|
889
|
+
flipX: s,
|
|
890
|
+
flipY: h,
|
|
921
891
|
arrowLength: this.arrowLength,
|
|
922
892
|
arrowOffset: this.arrowOffset,
|
|
923
893
|
roundness: this.roundness,
|
|
@@ -925,42 +895,46 @@ class Le {
|
|
|
925
895
|
detourDistance: this.detourDistance,
|
|
926
896
|
hasSourceArrow: this.hasSourceArrow,
|
|
927
897
|
hasTargetArrow: this.hasTargetArrow
|
|
928
|
-
})
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
898
|
+
}));
|
|
899
|
+
i(this, "createLinePath", (e, o, r, s, h) => Te({
|
|
900
|
+
to: r,
|
|
901
|
+
fromVector: e,
|
|
902
|
+
toVector: o,
|
|
903
|
+
flipY: h,
|
|
933
904
|
arrowLength: this.arrowLength,
|
|
934
905
|
arrowOffset: this.arrowOffset,
|
|
935
906
|
roundness: this.roundness,
|
|
936
907
|
hasSourceArrow: this.hasSourceArrow,
|
|
937
908
|
hasTargetArrow: this.hasTargetArrow
|
|
938
|
-
})
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
this.
|
|
955
|
-
}
|
|
909
|
+
}));
|
|
910
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
911
|
+
const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
912
|
+
this.roundness = Math.min(
|
|
913
|
+
o,
|
|
914
|
+
this.arrowOffset,
|
|
915
|
+
this.cycleSquareSide / 2
|
|
916
|
+
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.genericShape = new I({
|
|
917
|
+
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
918
|
+
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
919
|
+
arrowLength: this.arrowLength,
|
|
920
|
+
arrowWidth: this.arrowWidth,
|
|
921
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
922
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
923
|
+
createCyclePath: this.createCyclePath,
|
|
924
|
+
createDetourPath: this.createDetourPath,
|
|
925
|
+
createLinePath: this.createLinePath
|
|
926
|
+
}), this.svg = this.genericShape.svg;
|
|
927
|
+
}
|
|
928
|
+
render(e) {
|
|
929
|
+
this.genericShape.render(e);
|
|
956
930
|
}
|
|
957
931
|
}
|
|
958
|
-
const
|
|
932
|
+
const Be = (t) => {
|
|
959
933
|
if (typeof t == "function")
|
|
960
934
|
return t;
|
|
961
935
|
switch (t == null ? void 0 : t.type) {
|
|
962
936
|
case "straight":
|
|
963
|
-
return () => new
|
|
937
|
+
return () => new Le({
|
|
964
938
|
color: t.color,
|
|
965
939
|
width: t.width,
|
|
966
940
|
arrowLength: t.arrowLength,
|
|
@@ -974,7 +948,7 @@ const Re = (t) => {
|
|
|
974
948
|
detourDirection: t.detourDirection
|
|
975
949
|
});
|
|
976
950
|
case "horizontal":
|
|
977
|
-
return () => new
|
|
951
|
+
return () => new Ve({
|
|
978
952
|
color: t.color,
|
|
979
953
|
width: t.width,
|
|
980
954
|
arrowLength: t.arrowLength,
|
|
@@ -988,7 +962,7 @@ const Re = (t) => {
|
|
|
988
962
|
detourDirection: t.detourDirection
|
|
989
963
|
});
|
|
990
964
|
case "vertical":
|
|
991
|
-
return () => new
|
|
965
|
+
return () => new Re({
|
|
992
966
|
color: t.color,
|
|
993
967
|
width: t.width,
|
|
994
968
|
arrowLength: t.arrowLength,
|
|
@@ -1018,25 +992,25 @@ const Re = (t) => {
|
|
|
1018
992
|
}
|
|
1019
993
|
}, Ie = (t) => {
|
|
1020
994
|
var o, r, s, h, n;
|
|
1021
|
-
const e =
|
|
995
|
+
const e = pe(
|
|
1022
996
|
(o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
|
|
1023
997
|
(r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
|
|
1024
998
|
);
|
|
1025
999
|
return {
|
|
1026
1000
|
nodes: {
|
|
1027
|
-
centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ??
|
|
1001
|
+
centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? ve,
|
|
1028
1002
|
priorityFn: e.nodesPriorityFn
|
|
1029
1003
|
},
|
|
1030
1004
|
ports: {
|
|
1031
1005
|
direction: ((h = t == null ? void 0 : t.ports) == null ? void 0 : h.direction) ?? 0
|
|
1032
1006
|
},
|
|
1033
1007
|
edges: {
|
|
1034
|
-
shapeFactory:
|
|
1008
|
+
shapeFactory: Be(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
|
|
1035
1009
|
priorityFn: e.edgesPriorityFn
|
|
1036
1010
|
}
|
|
1037
1011
|
};
|
|
1038
1012
|
};
|
|
1039
|
-
class
|
|
1013
|
+
class se {
|
|
1040
1014
|
constructor(e, o, r, s, h) {
|
|
1041
1015
|
/**
|
|
1042
1016
|
* provides api for accessing model of rendered graph
|
|
@@ -1047,13 +1021,13 @@ class de {
|
|
|
1047
1021
|
*/
|
|
1048
1022
|
i(this, "viewport");
|
|
1049
1023
|
i(this, "defaults");
|
|
1050
|
-
i(this, "nodeIdGenerator", new
|
|
1024
|
+
i(this, "nodeIdGenerator", new C(
|
|
1051
1025
|
(e) => this.graph.getNode(e) !== null
|
|
1052
1026
|
));
|
|
1053
|
-
i(this, "portIdGenerator", new
|
|
1027
|
+
i(this, "portIdGenerator", new C(
|
|
1054
1028
|
(e) => this.graph.getPort(e) !== null
|
|
1055
1029
|
));
|
|
1056
|
-
i(this, "edgeIdGenerator", new
|
|
1030
|
+
i(this, "edgeIdGenerator", new C(
|
|
1057
1031
|
(e) => this.graph.getEdge(e) !== null
|
|
1058
1032
|
));
|
|
1059
1033
|
i(this, "onAfterNodeAdded", (e) => {
|
|
@@ -1105,13 +1079,13 @@ class de {
|
|
|
1105
1079
|
* emits event just before destruction of canvas
|
|
1106
1080
|
*/
|
|
1107
1081
|
i(this, "onBeforeDestroy");
|
|
1108
|
-
this.element = e, this.graphStore = o, this.viewportStore = r, this.htmlView = s, this.defaults = Ie(h), this.graph = new
|
|
1082
|
+
this.element = e, this.graphStore = o, this.viewportStore = r, this.htmlView = s, this.defaults = Ie(h), this.graph = new fe(this.graphStore), this.viewport = new we(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
|
|
1109
1083
|
this.onAfterNodePriorityUpdated
|
|
1110
1084
|
), this.graphStore.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.subscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.subscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.subscribe(
|
|
1111
1085
|
this.onAfterEdgeShapeUpdated
|
|
1112
1086
|
), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
|
|
1113
1087
|
this.onAfterEdgePriorityUpdated
|
|
1114
|
-
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] =
|
|
1088
|
+
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = A();
|
|
1115
1089
|
}
|
|
1116
1090
|
/**
|
|
1117
1091
|
* adds new node
|
|
@@ -1247,7 +1221,7 @@ class de {
|
|
|
1247
1221
|
* canvas element gets rolled back to initial state, and can not be reused
|
|
1248
1222
|
*/
|
|
1249
1223
|
destroy() {
|
|
1250
|
-
this.
|
|
1224
|
+
this.clear(), this.onBeforeDestroyEmitter.emit(), this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
|
|
1251
1225
|
this.onAfterNodePriorityUpdated
|
|
1252
1226
|
), this.graphStore.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.unsubscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.unsubscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.unsubscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.unsubscribe(
|
|
1253
1227
|
this.onAfterEdgeShapeUpdated
|
|
@@ -1256,7 +1230,7 @@ class de {
|
|
|
1256
1230
|
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
|
|
1257
1231
|
}
|
|
1258
1232
|
}
|
|
1259
|
-
class
|
|
1233
|
+
class ne {
|
|
1260
1234
|
constructor() {
|
|
1261
1235
|
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
1262
1236
|
i(this, "ports", /* @__PURE__ */ new Map());
|
|
@@ -1290,7 +1264,7 @@ class ce {
|
|
|
1290
1264
|
i(this, "onBeforeEdgeRemoved");
|
|
1291
1265
|
i(this, "beforeClearEmitter");
|
|
1292
1266
|
i(this, "onBeforeClear");
|
|
1293
|
-
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] =
|
|
1267
|
+
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] = A(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = A(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = A(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = A(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = A(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = A(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = A(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = A(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = A(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = A(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = A(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = A(), [this.beforeClearEmitter, this.onBeforeClear] = A();
|
|
1294
1268
|
}
|
|
1295
1269
|
addNode(e) {
|
|
1296
1270
|
const o = /* @__PURE__ */ new Map(), r = {
|
|
@@ -1428,24 +1402,24 @@ class ce {
|
|
|
1428
1402
|
this.cycleEdges.get(r).delete(e), this.cycleEdges.get(s).delete(e), this.incomingEdges.get(r).delete(e), this.incomingEdges.get(s).delete(e), this.outcomingEdges.get(r).delete(e), this.outcomingEdges.get(s).delete(e), this.edges.delete(e);
|
|
1429
1403
|
}
|
|
1430
1404
|
}
|
|
1431
|
-
const
|
|
1405
|
+
const ee = (t) => ({
|
|
1432
1406
|
scale: 1 / t.scale,
|
|
1433
1407
|
x: -t.x / t.scale,
|
|
1434
1408
|
y: -t.y / t.scale
|
|
1435
|
-
}),
|
|
1409
|
+
}), te = {
|
|
1436
1410
|
scale: 1,
|
|
1437
1411
|
x: 0,
|
|
1438
1412
|
y: 0
|
|
1439
1413
|
};
|
|
1440
|
-
class
|
|
1414
|
+
class Ue {
|
|
1441
1415
|
constructor() {
|
|
1442
|
-
i(this, "viewportMatrix",
|
|
1443
|
-
i(this, "contentMatrix",
|
|
1416
|
+
i(this, "viewportMatrix", te);
|
|
1417
|
+
i(this, "contentMatrix", te);
|
|
1444
1418
|
i(this, "afterUpdateEmitter");
|
|
1445
1419
|
i(this, "onAfterUpdated");
|
|
1446
1420
|
i(this, "beforeUpdateEmitter");
|
|
1447
1421
|
i(this, "onBeforeUpdated");
|
|
1448
|
-
[this.afterUpdateEmitter, this.onAfterUpdated] =
|
|
1422
|
+
[this.afterUpdateEmitter, this.onAfterUpdated] = A(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = A();
|
|
1449
1423
|
}
|
|
1450
1424
|
getViewportMatrix() {
|
|
1451
1425
|
return this.viewportMatrix;
|
|
@@ -1458,17 +1432,17 @@ class Be {
|
|
|
1458
1432
|
scale: e.scale ?? this.viewportMatrix.scale,
|
|
1459
1433
|
x: e.x ?? this.viewportMatrix.x,
|
|
1460
1434
|
y: e.y ?? this.viewportMatrix.y
|
|
1461
|
-
}, this.contentMatrix =
|
|
1435
|
+
}, this.contentMatrix = ee(this.viewportMatrix), this.afterUpdateEmitter.emit();
|
|
1462
1436
|
}
|
|
1463
1437
|
patchContentMatrix(e) {
|
|
1464
1438
|
this.beforeUpdateEmitter.emit(), this.contentMatrix = {
|
|
1465
1439
|
scale: e.scale ?? this.contentMatrix.scale,
|
|
1466
1440
|
x: e.x ?? this.contentMatrix.x,
|
|
1467
1441
|
y: e.y ?? this.contentMatrix.y
|
|
1468
|
-
}, this.viewportMatrix =
|
|
1442
|
+
}, this.viewportMatrix = ee(this.contentMatrix), this.afterUpdateEmitter.emit();
|
|
1469
1443
|
}
|
|
1470
1444
|
}
|
|
1471
|
-
class
|
|
1445
|
+
class k {
|
|
1472
1446
|
constructor(e) {
|
|
1473
1447
|
i(this, "elementToNodeId", /* @__PURE__ */ new Map());
|
|
1474
1448
|
i(this, "nodesResizeObserver");
|
|
@@ -1494,39 +1468,37 @@ class G {
|
|
|
1494
1468
|
}), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1495
1469
|
}
|
|
1496
1470
|
static configure(e) {
|
|
1497
|
-
new
|
|
1471
|
+
new k(e);
|
|
1498
1472
|
}
|
|
1499
1473
|
handleNodeResize(e) {
|
|
1500
1474
|
const o = this.elementToNodeId.get(e);
|
|
1501
|
-
this.canvas.updateNode(o)
|
|
1502
|
-
this.canvas.updateEdge(s);
|
|
1503
|
-
});
|
|
1475
|
+
this.canvas.updateNode(o);
|
|
1504
1476
|
}
|
|
1505
1477
|
}
|
|
1506
|
-
const
|
|
1507
|
-
var g, y,
|
|
1478
|
+
const Ce = (t) => {
|
|
1479
|
+
var g, y, p, f, E, x;
|
|
1508
1480
|
const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
|
|
1509
|
-
}), o = ((y = t == null ? void 0 : t.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), r = ((
|
|
1510
|
-
}), s = (t == null ? void 0 : t.moveOnTop) === !1, h = (f = t == null ? void 0 : t.mouse) == null ? void 0 : f.dragCursor, n = h !== void 0 ? h : "grab", d = (
|
|
1481
|
+
}), o = ((y = t == null ? void 0 : t.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), r = ((p = t == null ? void 0 : t.events) == null ? void 0 : p.onNodeDragFinished) ?? (() => {
|
|
1482
|
+
}), s = (t == null ? void 0 : t.moveOnTop) === !1, h = (f = t == null ? void 0 : t.mouse) == null ? void 0 : f.dragCursor, n = h !== void 0 ? h : "grab", d = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseDownEventVerifier, c = d !== void 0 ? d : (T) => T.button === 0, a = (x = t == null ? void 0 : t.mouse) == null ? void 0 : x.mouseUpEventVerifier;
|
|
1511
1483
|
return {
|
|
1512
1484
|
freezePriority: s,
|
|
1513
1485
|
dragCursor: n,
|
|
1514
1486
|
mouseDownEventVerifier: c,
|
|
1515
|
-
mouseUpEventVerifier: a !== void 0 ? a : (
|
|
1487
|
+
mouseUpEventVerifier: a !== void 0 ? a : (T) => T.button === 0,
|
|
1516
1488
|
onNodeDrag: e,
|
|
1517
1489
|
onBeforeNodeDrag: o,
|
|
1518
1490
|
onNodeDragFinished: r
|
|
1519
1491
|
};
|
|
1520
|
-
},
|
|
1492
|
+
}, We = (t, e, o) => {
|
|
1521
1493
|
const { x: r, y: s, width: h, height: n } = t.getBoundingClientRect();
|
|
1522
1494
|
return e >= r && e <= r + h && o >= s && o <= s + n;
|
|
1523
|
-
}, $e = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight,
|
|
1495
|
+
}, $e = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, M = (t, e, o, r) => We(e, o, r) && $e(t, o, r), B = (t, e) => {
|
|
1524
1496
|
e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
|
|
1525
|
-
},
|
|
1497
|
+
}, N = (t, e) => ({
|
|
1526
1498
|
x: t.scale * e.x + t.x,
|
|
1527
1499
|
y: t.scale * e.y + t.y
|
|
1528
1500
|
});
|
|
1529
|
-
class
|
|
1501
|
+
class O {
|
|
1530
1502
|
constructor(e, o, r, s) {
|
|
1531
1503
|
i(this, "grabbedNodeId", null);
|
|
1532
1504
|
i(this, "maxNodePriority", 0);
|
|
@@ -1536,7 +1508,11 @@ class J {
|
|
|
1536
1508
|
i(this, "onAfterNodeAdded", (e) => {
|
|
1537
1509
|
this.updateMaxNodePriority(e);
|
|
1538
1510
|
const o = this.graph.getNode(e);
|
|
1539
|
-
this.nodeIds.set(o.element, e), o.element.addEventListener("mousedown", this.onMouseDown
|
|
1511
|
+
this.nodeIds.set(o.element, e), o.element.addEventListener("mousedown", this.onMouseDown, {
|
|
1512
|
+
passive: !0
|
|
1513
|
+
}), o.element.addEventListener("touchstart", this.onTouchStart, {
|
|
1514
|
+
passive: !0
|
|
1515
|
+
});
|
|
1540
1516
|
});
|
|
1541
1517
|
i(this, "onAfterNodeUpdated", (e) => {
|
|
1542
1518
|
this.updateMaxNodePriority(e);
|
|
@@ -1562,7 +1538,11 @@ class J {
|
|
|
1562
1538
|
element: s.element,
|
|
1563
1539
|
x: s.x,
|
|
1564
1540
|
y: s.y
|
|
1565
|
-
}) && (e.stopImmediatePropagation(), this.grabbedNodeId = r,
|
|
1541
|
+
}) && (e.stopImmediatePropagation(), this.grabbedNodeId = r, B(this.element, this.config.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
1542
|
+
passive: !0
|
|
1543
|
+
}), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
1544
|
+
passive: !0
|
|
1545
|
+
}));
|
|
1566
1546
|
});
|
|
1567
1547
|
i(this, "onTouchStart", (e) => {
|
|
1568
1548
|
if (e.touches.length !== 1)
|
|
@@ -1577,10 +1557,16 @@ class J {
|
|
|
1577
1557
|
element: s.element,
|
|
1578
1558
|
x: s.x,
|
|
1579
1559
|
y: s.y
|
|
1580
|
-
}) && (this.grabbedNodeId = r, this.moveNodeOnTop(r), this.window.addEventListener("touchmove", this.onWindowTouchMove
|
|
1560
|
+
}) && (this.grabbedNodeId = r, this.moveNodeOnTop(r), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
1561
|
+
passive: !0
|
|
1562
|
+
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
1563
|
+
passive: !0
|
|
1564
|
+
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
1565
|
+
passive: !0
|
|
1566
|
+
}));
|
|
1581
1567
|
});
|
|
1582
1568
|
i(this, "onWindowMouseMove", (e) => {
|
|
1583
|
-
if (!
|
|
1569
|
+
if (!M(
|
|
1584
1570
|
this.window,
|
|
1585
1571
|
this.element,
|
|
1586
1572
|
e.clientX,
|
|
@@ -1598,7 +1584,7 @@ class J {
|
|
|
1598
1584
|
if (e.touches.length !== 1)
|
|
1599
1585
|
return;
|
|
1600
1586
|
const o = e.touches[0];
|
|
1601
|
-
if (!
|
|
1587
|
+
if (!M(
|
|
1602
1588
|
this.window,
|
|
1603
1589
|
this.element,
|
|
1604
1590
|
o.clientX,
|
|
@@ -1619,22 +1605,22 @@ class J {
|
|
|
1619
1605
|
this.previousTouchCoordinates = null, this.cancelTouchDrag();
|
|
1620
1606
|
});
|
|
1621
1607
|
i(this, "config");
|
|
1622
|
-
this.canvas = e, this.element = o, this.window = r, this.config =
|
|
1608
|
+
this.canvas = e, this.element = o, this.window = r, this.config = Ce(s), this.graph = e.graph, this.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1623
1609
|
}
|
|
1624
1610
|
static configure(e, o, r, s) {
|
|
1625
|
-
new
|
|
1611
|
+
new O(e, o, r, s);
|
|
1626
1612
|
}
|
|
1627
1613
|
dragNode(e, o, r) {
|
|
1628
1614
|
const s = this.graph.getNode(e);
|
|
1629
1615
|
if (s === null)
|
|
1630
1616
|
return;
|
|
1631
|
-
const h = this.canvas.viewport.getContentMatrix(), n =
|
|
1617
|
+
const h = this.canvas.viewport.getContentMatrix(), n = N(h, {
|
|
1632
1618
|
x: s.x,
|
|
1633
1619
|
y: s.y
|
|
1634
|
-
}), d =
|
|
1620
|
+
}), d = N(
|
|
1635
1621
|
{ scale: 1, x: o, y: r },
|
|
1636
1622
|
n
|
|
1637
|
-
), c = this.canvas.viewport.getViewportMatrix(), a =
|
|
1623
|
+
), c = this.canvas.viewport.getViewportMatrix(), a = N(c, d);
|
|
1638
1624
|
this.canvas.updateNode(e, { x: a.x, y: a.y }), this.config.onNodeDrag({
|
|
1639
1625
|
nodeId: e,
|
|
1640
1626
|
element: s.element,
|
|
@@ -1658,7 +1644,7 @@ class J {
|
|
|
1658
1644
|
element: e.element,
|
|
1659
1645
|
x: e.x,
|
|
1660
1646
|
y: e.y
|
|
1661
|
-
}), this.grabbedNodeId = null,
|
|
1647
|
+
}), this.grabbedNodeId = null, B(this.element, null), this.removeMouseDragListeners();
|
|
1662
1648
|
}
|
|
1663
1649
|
removeMouseDragListeners() {
|
|
1664
1650
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
@@ -1681,7 +1667,7 @@ class J {
|
|
|
1681
1667
|
this.maxNodePriority = Math.max(this.maxNodePriority, o);
|
|
1682
1668
|
}
|
|
1683
1669
|
}
|
|
1684
|
-
const
|
|
1670
|
+
const Fe = (t) => {
|
|
1685
1671
|
const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0, r = t.minY !== null ? t.minY : -1 / 0, s = t.maxY !== null ? t.maxY : 1 / 0;
|
|
1686
1672
|
return (h) => {
|
|
1687
1673
|
let n = h.nextTransform.x, d = h.nextTransform.y;
|
|
@@ -1691,7 +1677,7 @@ const We = (t) => {
|
|
|
1691
1677
|
const l = h.canvasHeight * h.prevTransform.scale, g = s - l;
|
|
1692
1678
|
return d > g && d > h.prevTransform.y && (d = Math.max(h.prevTransform.y, g)), { scale: h.nextTransform.scale, x: n, y: d };
|
|
1693
1679
|
};
|
|
1694
|
-
},
|
|
1680
|
+
}, ze = (t) => {
|
|
1695
1681
|
const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
|
|
1696
1682
|
return (h) => {
|
|
1697
1683
|
const n = h.prevTransform, d = h.nextTransform;
|
|
@@ -1712,7 +1698,7 @@ const We = (t) => {
|
|
|
1712
1698
|
y: l
|
|
1713
1699
|
};
|
|
1714
1700
|
};
|
|
1715
|
-
},
|
|
1701
|
+
}, ke = (t) => (e) => t.reduce(
|
|
1716
1702
|
(o, r) => r({
|
|
1717
1703
|
prevTransform: e.prevTransform,
|
|
1718
1704
|
nextTransform: o,
|
|
@@ -1720,40 +1706,40 @@ const We = (t) => {
|
|
|
1720
1706
|
canvasHeight: e.canvasHeight
|
|
1721
1707
|
}),
|
|
1722
1708
|
e.nextTransform
|
|
1723
|
-
),
|
|
1709
|
+
), oe = (t) => {
|
|
1724
1710
|
if (typeof t == "function")
|
|
1725
1711
|
return t;
|
|
1726
1712
|
switch (t.type) {
|
|
1727
1713
|
case "scale-limit":
|
|
1728
|
-
return
|
|
1714
|
+
return ze({
|
|
1729
1715
|
minContentScale: t.minContentScale ?? 0,
|
|
1730
1716
|
maxContentScale: t.maxContentScale ?? 1 / 0
|
|
1731
1717
|
});
|
|
1732
1718
|
case "shift-limit":
|
|
1733
|
-
return
|
|
1719
|
+
return Fe({
|
|
1734
1720
|
minX: t.minX ?? -1 / 0,
|
|
1735
1721
|
maxX: t.maxX ?? 1 / 0,
|
|
1736
1722
|
minY: t.minY ?? -1 / 0,
|
|
1737
1723
|
maxY: t.maxY ?? 1 / 0
|
|
1738
1724
|
});
|
|
1739
1725
|
}
|
|
1740
|
-
},
|
|
1741
|
-
var f,
|
|
1726
|
+
}, Oe = (t) => {
|
|
1727
|
+
var f, E, x, T, b, m, D, V, j, G, J, K;
|
|
1742
1728
|
const e = (f = t == null ? void 0 : t.scale) == null ? void 0 : f.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, r = t == null ? void 0 : t.transformPreprocessor;
|
|
1743
1729
|
let s;
|
|
1744
|
-
r !== void 0 ? Array.isArray(r) ? s =
|
|
1730
|
+
r !== void 0 ? Array.isArray(r) ? s = ke(
|
|
1745
1731
|
r.map(
|
|
1746
|
-
(
|
|
1732
|
+
(P) => oe(P)
|
|
1747
1733
|
)
|
|
1748
|
-
) : s =
|
|
1749
|
-
const h = ((
|
|
1750
|
-
}), d = ((
|
|
1751
|
-
}), c = (
|
|
1734
|
+
) : s = oe(r) : s = (P) => P.nextTransform;
|
|
1735
|
+
const h = ((E = t == null ? void 0 : t.shift) == null ? void 0 : E.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((x = t == null ? void 0 : t.events) == null ? void 0 : x.onBeforeTransformChange) ?? (() => {
|
|
1736
|
+
}), d = ((T = t == null ? void 0 : t.events) == null ? void 0 : T.onTransformChange) ?? (() => {
|
|
1737
|
+
}), c = (b = t == null ? void 0 : t.shift) == null ? void 0 : b.mouseDownEventVerifier, a = c !== void 0 ? c : (P) => P.button === 0, l = (m = t == null ? void 0 : t.shift) == null ? void 0 : m.mouseUpEventVerifier, g = l !== void 0 ? l : (P) => P.button === 0, y = (D = t == null ? void 0 : t.scale) == null ? void 0 : D.mouseWheelEventVerifier, p = y !== void 0 ? y : () => !0;
|
|
1752
1738
|
return {
|
|
1753
1739
|
wheelSensitivity: o,
|
|
1754
|
-
onTransformStarted: ((
|
|
1740
|
+
onTransformStarted: ((V = t == null ? void 0 : t.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
|
|
1755
1741
|
}),
|
|
1756
|
-
onTransformFinished: ((
|
|
1742
|
+
onTransformFinished: ((j = t == null ? void 0 : t.events) == null ? void 0 : j.onTransformFinished) ?? (() => {
|
|
1757
1743
|
}),
|
|
1758
1744
|
onBeforeTransformChange: n,
|
|
1759
1745
|
onTransformChange: d,
|
|
@@ -1761,22 +1747,22 @@ const We = (t) => {
|
|
|
1761
1747
|
shiftCursor: h,
|
|
1762
1748
|
mouseDownEventVerifier: a,
|
|
1763
1749
|
mouseUpEventVerifier: g,
|
|
1764
|
-
mouseWheelEventVerifier:
|
|
1765
|
-
scaleWheelFinishTimeout: ((
|
|
1766
|
-
onResizeTransformStarted: ((
|
|
1750
|
+
mouseWheelEventVerifier: p,
|
|
1751
|
+
scaleWheelFinishTimeout: ((G = t == null ? void 0 : t.scale) == null ? void 0 : G.wheelFinishTimeout) ?? 500,
|
|
1752
|
+
onResizeTransformStarted: ((J = t == null ? void 0 : t.events) == null ? void 0 : J.onResizeTransformStarted) ?? (() => {
|
|
1767
1753
|
}),
|
|
1768
|
-
onResizeTransformFinished: ((
|
|
1754
|
+
onResizeTransformFinished: ((K = t == null ? void 0 : t.events) == null ? void 0 : K.onResizeTransformFinished) ?? (() => {
|
|
1769
1755
|
})
|
|
1770
1756
|
};
|
|
1771
|
-
},
|
|
1757
|
+
}, Xe = (t, e, o) => ({
|
|
1772
1758
|
scale: t.scale,
|
|
1773
1759
|
x: t.x + t.scale * e,
|
|
1774
1760
|
y: t.y + t.scale * o
|
|
1775
|
-
}),
|
|
1761
|
+
}), Ye = (t, e, o, r) => ({
|
|
1776
1762
|
scale: t.scale * e,
|
|
1777
1763
|
x: t.scale * (1 - e) * o + t.x,
|
|
1778
1764
|
y: t.scale * (1 - e) * r + t.y
|
|
1779
|
-
}),
|
|
1765
|
+
}), R = (t) => {
|
|
1780
1766
|
const e = [], o = t.touches.length;
|
|
1781
1767
|
for (let d = 0; d < o; d++)
|
|
1782
1768
|
e.push([t.touches[d].clientX, t.touches[d].clientY]);
|
|
@@ -1795,20 +1781,24 @@ const We = (t) => {
|
|
|
1795
1781
|
touches: e
|
|
1796
1782
|
};
|
|
1797
1783
|
};
|
|
1798
|
-
class
|
|
1784
|
+
class U {
|
|
1799
1785
|
constructor(e, o, r, s) {
|
|
1800
1786
|
i(this, "viewport");
|
|
1801
1787
|
i(this, "prevTouches", null);
|
|
1802
1788
|
i(this, "wheelFinishTimer", null);
|
|
1803
1789
|
i(this, "transformInProgress", !1);
|
|
1804
1790
|
i(this, "onBeforeDestroy", () => {
|
|
1805
|
-
this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
1791
|
+
this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.element.removeEventListener("wheel", this.preventWheelScaleListener), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
1806
1792
|
});
|
|
1807
1793
|
i(this, "onMouseDown", (e) => {
|
|
1808
|
-
this.element === null || !this.config.mouseDownEventVerifier(e) || (
|
|
1794
|
+
this.element === null || !this.config.mouseDownEventVerifier(e) || (B(this.element, this.config.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
1795
|
+
passive: !0
|
|
1796
|
+
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
1797
|
+
passive: !0
|
|
1798
|
+
}), this.startRegisteredTransform());
|
|
1809
1799
|
});
|
|
1810
1800
|
i(this, "onWindowMouseMove", (e) => {
|
|
1811
|
-
const o =
|
|
1801
|
+
const o = M(
|
|
1812
1802
|
this.window,
|
|
1813
1803
|
this.element,
|
|
1814
1804
|
e.clientX,
|
|
@@ -1827,7 +1817,6 @@ class k {
|
|
|
1827
1817
|
i(this, "onWheelScroll", (e) => {
|
|
1828
1818
|
if (!this.config.mouseWheelEventVerifier(e))
|
|
1829
1819
|
return;
|
|
1830
|
-
e.preventDefault();
|
|
1831
1820
|
const { left: o, top: r } = this.element.getBoundingClientRect(), s = e.clientX - o, h = e.clientY - r, d = 1 / (e.deltaY < 0 ? this.config.wheelSensitivity : 1 / this.config.wheelSensitivity);
|
|
1832
1821
|
this.wheelFinishTimer === null && this.config.onTransformStarted(), this.scaleViewport(d, s, h), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
1833
1822
|
this.transformInProgress || this.config.onTransformFinished(), this.wheelFinishTimer = null;
|
|
@@ -1835,15 +1824,21 @@ class k {
|
|
|
1835
1824
|
});
|
|
1836
1825
|
i(this, "onTouchStart", (e) => {
|
|
1837
1826
|
if (this.prevTouches !== null) {
|
|
1838
|
-
this.prevTouches =
|
|
1827
|
+
this.prevTouches = R(e);
|
|
1839
1828
|
return;
|
|
1840
1829
|
}
|
|
1841
|
-
this.prevTouches =
|
|
1830
|
+
this.prevTouches = R(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
1831
|
+
passive: !0
|
|
1832
|
+
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
1833
|
+
passive: !0
|
|
1834
|
+
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
1835
|
+
passive: !0
|
|
1836
|
+
}), this.startRegisteredTransform();
|
|
1842
1837
|
});
|
|
1843
1838
|
i(this, "onWindowTouchMove", (e) => {
|
|
1844
|
-
const o =
|
|
1839
|
+
const o = R(e);
|
|
1845
1840
|
if (!o.touches.every(
|
|
1846
|
-
(s) =>
|
|
1841
|
+
(s) => M(this.window, this.element, s[0], s[1])
|
|
1847
1842
|
)) {
|
|
1848
1843
|
this.stopTouchDrag();
|
|
1849
1844
|
return;
|
|
@@ -1858,7 +1853,7 @@ class k {
|
|
|
1858
1853
|
this.prevTouches = o;
|
|
1859
1854
|
});
|
|
1860
1855
|
i(this, "onWindowTouchFinish", (e) => {
|
|
1861
|
-
e.touches.length > 0 ? this.prevTouches =
|
|
1856
|
+
e.touches.length > 0 ? this.prevTouches = R(e) : this.stopTouchDrag();
|
|
1862
1857
|
});
|
|
1863
1858
|
i(this, "observer", new ResizeObserver(() => {
|
|
1864
1859
|
const e = this.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), s = this.config.transformPreprocessor({
|
|
@@ -1870,10 +1865,21 @@ class k {
|
|
|
1870
1865
|
this.config.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.config.onResizeTransformFinished();
|
|
1871
1866
|
}));
|
|
1872
1867
|
i(this, "config");
|
|
1873
|
-
|
|
1868
|
+
i(this, "preventWheelScaleListener", (e) => {
|
|
1869
|
+
e.preventDefault();
|
|
1870
|
+
});
|
|
1871
|
+
this.canvas = e, this.element = o, this.window = r, this.element.addEventListener("wheel", this.preventWheelScaleListener, {
|
|
1872
|
+
passive: !1
|
|
1873
|
+
}), this.config = Oe(s), this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown, {
|
|
1874
|
+
passive: !0
|
|
1875
|
+
}), this.element.addEventListener("wheel", this.onWheelScroll, {
|
|
1876
|
+
passive: !0
|
|
1877
|
+
}), this.element.addEventListener("touchstart", this.onTouchStart, {
|
|
1878
|
+
passive: !0
|
|
1879
|
+
}), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1874
1880
|
}
|
|
1875
1881
|
static configure(e, o, r, s) {
|
|
1876
|
-
new
|
|
1882
|
+
new U(
|
|
1877
1883
|
e,
|
|
1878
1884
|
o,
|
|
1879
1885
|
r,
|
|
@@ -1881,7 +1887,7 @@ class k {
|
|
|
1881
1887
|
);
|
|
1882
1888
|
}
|
|
1883
1889
|
moveViewport(e, o) {
|
|
1884
|
-
const r = this.viewport.getViewportMatrix(), s =
|
|
1890
|
+
const r = this.viewport.getViewportMatrix(), s = Xe(r, e, o), { width: h, height: n } = this.element.getBoundingClientRect(), d = this.config.transformPreprocessor({
|
|
1885
1891
|
prevTransform: r,
|
|
1886
1892
|
nextTransform: s,
|
|
1887
1893
|
canvasWidth: h,
|
|
@@ -1890,7 +1896,7 @@ class k {
|
|
|
1890
1896
|
this.performTransform(d);
|
|
1891
1897
|
}
|
|
1892
1898
|
scaleViewport(e, o, r) {
|
|
1893
|
-
const s = this.canvas.viewport.getViewportMatrix(), h =
|
|
1899
|
+
const s = this.canvas.viewport.getViewportMatrix(), h = Ye(s, e, o, r), { width: n, height: d } = this.element.getBoundingClientRect(), c = this.config.transformPreprocessor({
|
|
1894
1900
|
prevTransform: s,
|
|
1895
1901
|
nextTransform: h,
|
|
1896
1902
|
canvasWidth: n,
|
|
@@ -1899,7 +1905,7 @@ class k {
|
|
|
1899
1905
|
this.performTransform(c);
|
|
1900
1906
|
}
|
|
1901
1907
|
stopMouseDrag() {
|
|
1902
|
-
|
|
1908
|
+
B(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
|
|
1903
1909
|
}
|
|
1904
1910
|
removeMouseDragListeners() {
|
|
1905
1911
|
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
@@ -1920,7 +1926,7 @@ class k {
|
|
|
1920
1926
|
this.transformInProgress = !1, this.config.onTransformFinished();
|
|
1921
1927
|
}
|
|
1922
1928
|
}
|
|
1923
|
-
class
|
|
1929
|
+
class X {
|
|
1924
1930
|
constructor(e, o, r, s, h, n) {
|
|
1925
1931
|
i(this, "canvasResizeObserver");
|
|
1926
1932
|
i(this, "nodeHorizontal");
|
|
@@ -1952,16 +1958,16 @@ class K {
|
|
|
1952
1958
|
this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
|
|
1953
1959
|
});
|
|
1954
1960
|
i(this, "userTransformInProgress", !1);
|
|
1955
|
-
var
|
|
1956
|
-
this.canvas = e, this.element = o, this.window = r, this.trigger = h, this.virtualScrollOptions = n, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((
|
|
1957
|
-
const m =
|
|
1961
|
+
var p, f, E, x, T;
|
|
1962
|
+
this.canvas = e, this.element = o, this.window = r, this.trigger = h, this.virtualScrollOptions = n, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((b) => {
|
|
1963
|
+
const m = b[0];
|
|
1958
1964
|
this.viewportWidth = m.contentRect.width, this.viewportHeight = m.contentRect.height, this.scheduleLoadAreaAroundViewport();
|
|
1959
1965
|
}), this.viewport = e.viewport;
|
|
1960
|
-
const d = ((
|
|
1966
|
+
const d = ((p = s == null ? void 0 : s.events) == null ? void 0 : p.onResizeTransformStarted) ?? (() => {
|
|
1961
1967
|
}), c = ((f = s == null ? void 0 : s.events) == null ? void 0 : f.onResizeTransformFinished) ?? (() => {
|
|
1962
|
-
}), a = ((
|
|
1968
|
+
}), a = ((E = s == null ? void 0 : s.events) == null ? void 0 : E.onTransformChange) ?? (() => {
|
|
1963
1969
|
}), l = ((x = s == null ? void 0 : s.events) == null ? void 0 : x.onBeforeTransformChange) ?? (() => {
|
|
1964
|
-
}), g = ((
|
|
1970
|
+
}), g = ((T = s == null ? void 0 : s.events) == null ? void 0 : T.onTransformFinished) ?? (() => {
|
|
1965
1971
|
}), y = {
|
|
1966
1972
|
...s,
|
|
1967
1973
|
events: {
|
|
@@ -1977,15 +1983,15 @@ class K {
|
|
|
1977
1983
|
},
|
|
1978
1984
|
onTransformChange: () => {
|
|
1979
1985
|
this.userTransformInProgress = !1;
|
|
1980
|
-
const
|
|
1981
|
-
this.viewportMatrix = this.viewport.getViewportMatrix(),
|
|
1986
|
+
const b = this.viewportMatrix;
|
|
1987
|
+
this.viewportMatrix = this.viewport.getViewportMatrix(), b.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), a();
|
|
1982
1988
|
},
|
|
1983
1989
|
onTransformFinished: () => {
|
|
1984
1990
|
this.scheduleLoadAreaAroundViewport(), g();
|
|
1985
1991
|
}
|
|
1986
1992
|
}
|
|
1987
1993
|
};
|
|
1988
|
-
|
|
1994
|
+
U.configure(
|
|
1989
1995
|
e,
|
|
1990
1996
|
this.element,
|
|
1991
1997
|
this.window,
|
|
@@ -1993,7 +1999,7 @@ class K {
|
|
|
1993
1999
|
), this.viewportMatrix = this.viewport.getViewportMatrix(), this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1994
2000
|
}
|
|
1995
2001
|
static configure(e, o, r, s, h, n) {
|
|
1996
|
-
new
|
|
2002
|
+
new X(
|
|
1997
2003
|
e,
|
|
1998
2004
|
o,
|
|
1999
2005
|
r,
|
|
@@ -2016,29 +2022,29 @@ class K {
|
|
|
2016
2022
|
this.trigger.emit({ x: r, y: s, width: h, height: n });
|
|
2017
2023
|
}
|
|
2018
2024
|
}
|
|
2019
|
-
const
|
|
2025
|
+
const He = () => {
|
|
2020
2026
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
2021
2027
|
return t.style.position = "absolute", t.style.inset = "0", t;
|
|
2022
|
-
},
|
|
2028
|
+
}, je = () => {
|
|
2023
2029
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
2024
2030
|
return t.setAttribute("fill", "url(#pattern)"), t;
|
|
2025
|
-
},
|
|
2031
|
+
}, Ge = () => {
|
|
2026
2032
|
const t = document.createElementNS(
|
|
2027
2033
|
"http://www.w3.org/2000/svg",
|
|
2028
2034
|
"pattern"
|
|
2029
2035
|
);
|
|
2030
2036
|
return t.setAttribute("id", "pattern"), t;
|
|
2031
|
-
},
|
|
2037
|
+
}, Je = (t, e) => {
|
|
2032
2038
|
const o = document.createElementNS(
|
|
2033
2039
|
"http://www.w3.org/2000/svg",
|
|
2034
2040
|
"circle"
|
|
2035
2041
|
);
|
|
2036
2042
|
return o.setAttribute("cx", "0"), o.setAttribute("cy", "0"), o.setAttribute("r", `${t}`), o.setAttribute("fill", `${e}`), o;
|
|
2037
|
-
},
|
|
2043
|
+
}, Ke = (t) => t instanceof SVGElement ? t : Je(
|
|
2038
2044
|
(t == null ? void 0 : t.radius) ?? 1.5,
|
|
2039
2045
|
(t == null ? void 0 : t.color) ?? "#d8d8d8"
|
|
2040
|
-
),
|
|
2041
|
-
const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, r = (e == null ? void 0 : e.height) ?? 25, s =
|
|
2046
|
+
), Qe = (t) => {
|
|
2047
|
+
const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, r = (e == null ? void 0 : e.height) ?? 25, s = Ke(t.renderer ?? {});
|
|
2042
2048
|
return {
|
|
2043
2049
|
tileWidth: o,
|
|
2044
2050
|
tileHeight: r,
|
|
@@ -2046,11 +2052,11 @@ const Xe = () => {
|
|
|
2046
2052
|
maxViewportScale: t.maxViewportScale ?? 10
|
|
2047
2053
|
};
|
|
2048
2054
|
};
|
|
2049
|
-
class
|
|
2055
|
+
class Y {
|
|
2050
2056
|
constructor(e, o, r) {
|
|
2051
|
-
i(this, "svg",
|
|
2052
|
-
i(this, "patternRenderingRectangle",
|
|
2053
|
-
i(this, "pattern",
|
|
2057
|
+
i(this, "svg", He());
|
|
2058
|
+
i(this, "patternRenderingRectangle", je());
|
|
2059
|
+
i(this, "pattern", Ge());
|
|
2054
2060
|
i(this, "patternContent");
|
|
2055
2061
|
i(this, "tileWidth");
|
|
2056
2062
|
i(this, "tileHeight");
|
|
@@ -2074,7 +2080,7 @@ class Q {
|
|
|
2074
2080
|
), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2075
2081
|
});
|
|
2076
2082
|
this.canvas = e, this.host = r;
|
|
2077
|
-
const s =
|
|
2083
|
+
const s = Qe(o);
|
|
2078
2084
|
this.tileWidth = s.tileWidth, this.tileHeight = s.tileHeight, this.halfTileWidth = this.tileWidth / 2, this.halfTileHeight = this.tileHeight / 2, this.patternContent = s.renderer, this.maxViewportScale = s.maxViewportScale;
|
|
2079
2085
|
const h = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
|
|
2080
2086
|
this.patternContent.setAttribute("transform", h), this.pattern.appendChild(this.patternContent);
|
|
@@ -2082,47 +2088,97 @@ class Q {
|
|
|
2082
2088
|
n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.resizeObserver.observe(this.host), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated(), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2083
2089
|
}
|
|
2084
2090
|
static configure(e, o, r) {
|
|
2085
|
-
new
|
|
2091
|
+
new Y(e, o, r);
|
|
2086
2092
|
}
|
|
2087
2093
|
updateVisibility() {
|
|
2088
2094
|
const o = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
|
|
2089
2095
|
o && this.visible ? (this.visible = !1, this.host.removeChild(this.svg)) : !o && !this.visible && (this.visible = !0, this.host.appendChild(this.svg));
|
|
2090
2096
|
}
|
|
2091
2097
|
}
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2094
|
-
|
|
2098
|
+
const Ze = (t) => {
|
|
2099
|
+
var d, c, a;
|
|
2100
|
+
const e = () => "direct", o = (l) => l, r = (l) => l.button === 0, s = () => {
|
|
2101
|
+
}, h = () => {
|
|
2102
|
+
}, n = () => {
|
|
2103
|
+
};
|
|
2095
2104
|
return {
|
|
2096
|
-
connectionTypeResolver: t.connectionTypeResolver ??
|
|
2097
|
-
connectionPreprocessor: t.connectionPreprocessor ??
|
|
2098
|
-
mouseDownEventVerifier: t.mouseDownEventVerifier ??
|
|
2099
|
-
mouseUpEventVerifier: t.mouseUpEventVerifier ??
|
|
2100
|
-
onAfterEdgeCreated: ((
|
|
2105
|
+
connectionTypeResolver: t.connectionTypeResolver ?? e,
|
|
2106
|
+
connectionPreprocessor: t.connectionPreprocessor ?? o,
|
|
2107
|
+
mouseDownEventVerifier: t.mouseDownEventVerifier ?? r,
|
|
2108
|
+
mouseUpEventVerifier: t.mouseUpEventVerifier ?? r,
|
|
2109
|
+
onAfterEdgeCreated: ((d = t.events) == null ? void 0 : d.onAfterEdgeCreated) ?? s,
|
|
2110
|
+
onEdgeCreationInterrupted: ((c = t.events) == null ? void 0 : c.onEdgeCreationInterrupted) ?? n,
|
|
2111
|
+
onEdgeCreationPrevented: ((a = t.events) == null ? void 0 : a.onEdgeCreationPrevented) ?? h,
|
|
2112
|
+
dragPortDirection: t.dragPortDirection ?? void 0
|
|
2101
2113
|
};
|
|
2102
2114
|
};
|
|
2103
|
-
class
|
|
2115
|
+
class _e {
|
|
2116
|
+
constructor() {
|
|
2117
|
+
i(this, "singleToMultiMap", /* @__PURE__ */ new Map());
|
|
2118
|
+
i(this, "multiToSingleMap", /* @__PURE__ */ new Map());
|
|
2119
|
+
}
|
|
2120
|
+
addRecord(e, o) {
|
|
2121
|
+
const r = this.singleToMultiMap.get(e);
|
|
2122
|
+
r === void 0 ? this.singleToMultiMap.set(e, /* @__PURE__ */ new Set([o])) : r.add(o), this.multiToSingleMap.set(o, e);
|
|
2123
|
+
}
|
|
2124
|
+
getFirstBySingle(e) {
|
|
2125
|
+
const o = this.singleToMultiMap.get(e);
|
|
2126
|
+
return o === void 0 ? void 0 : Array.from(o.values())[0];
|
|
2127
|
+
}
|
|
2128
|
+
removeByMulti(e) {
|
|
2129
|
+
const o = this.multiToSingleMap.get(e), r = this.singleToMultiMap.get(o);
|
|
2130
|
+
r.delete(e), r.size === 0 && this.singleToMultiMap.delete(o), this.multiToSingleMap.delete(e);
|
|
2131
|
+
}
|
|
2132
|
+
getByMulti(e) {
|
|
2133
|
+
return this.multiToSingleMap.get(e);
|
|
2134
|
+
}
|
|
2135
|
+
removeBySingle(e) {
|
|
2136
|
+
this.singleToMultiMap.get(e).forEach((r) => {
|
|
2137
|
+
this.multiToSingleMap.delete(r);
|
|
2138
|
+
}), this.singleToMultiMap.delete(e);
|
|
2139
|
+
}
|
|
2140
|
+
clear() {
|
|
2141
|
+
this.singleToMultiMap.clear(), this.multiToSingleMap.clear();
|
|
2142
|
+
}
|
|
2143
|
+
forEachSingle(e) {
|
|
2144
|
+
this.singleToMultiMap.forEach((o, r) => {
|
|
2145
|
+
e(r);
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
hasSingle(e) {
|
|
2149
|
+
return this.singleToMultiMap.get(e) !== void 0;
|
|
2150
|
+
}
|
|
2151
|
+
hasMulti(e) {
|
|
2152
|
+
return this.multiToSingleMap.get(e) !== void 0;
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
class H {
|
|
2104
2156
|
constructor(e, o, r, s, h, n) {
|
|
2105
2157
|
i(this, "config");
|
|
2106
2158
|
i(this, "overlayCanvas");
|
|
2107
|
-
i(this, "ports",
|
|
2159
|
+
i(this, "ports", new _e());
|
|
2108
2160
|
i(this, "staticOverlayPortId", "static");
|
|
2109
2161
|
i(this, "draggingOverlayPortId", "dragging");
|
|
2110
2162
|
i(this, "staticPortId", null);
|
|
2111
2163
|
i(this, "isDirect", !0);
|
|
2112
2164
|
i(this, "onAfterPortMarked", (e) => {
|
|
2113
2165
|
const o = this.canvas.graph.getPort(e);
|
|
2114
|
-
this.hookPortEvents(o.element), this.ports.
|
|
2166
|
+
this.ports.hasSingle(o.element) || this.hookPortEvents(o.element), this.ports.addRecord(o.element, e);
|
|
2115
2167
|
});
|
|
2116
2168
|
i(this, "onBeforePortUnmarked", (e) => {
|
|
2117
2169
|
const o = this.canvas.graph.getPort(e);
|
|
2118
|
-
this.
|
|
2170
|
+
this.ports.removeByMulti(e), this.ports.hasSingle(o.element) || this.unhookPortEvents(o.element);
|
|
2119
2171
|
});
|
|
2120
2172
|
i(this, "onPortMouseDown", (e) => {
|
|
2121
2173
|
const o = e.currentTarget;
|
|
2122
|
-
this.config.mouseDownEventVerifier(e) && this.isPortConnectionAllowed(o) && (e.stopPropagation(), this.grabPort(o, { x: e.clientX, y: e.clientY }), this.window.addEventListener("mousemove", this.onWindowMouseMove
|
|
2174
|
+
this.config.mouseDownEventVerifier(e) && this.isPortConnectionAllowed(o) && (e.stopPropagation(), this.grabPort(o, { x: e.clientX, y: e.clientY }), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
2175
|
+
passive: !0
|
|
2176
|
+
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
2177
|
+
passive: !0
|
|
2178
|
+
}));
|
|
2123
2179
|
});
|
|
2124
2180
|
i(this, "onWindowMouseMove", (e) => {
|
|
2125
|
-
if (!
|
|
2181
|
+
if (!M(
|
|
2126
2182
|
this.window,
|
|
2127
2183
|
this.overlayLayer,
|
|
2128
2184
|
e.clientX,
|
|
@@ -2142,11 +2198,17 @@ class Z {
|
|
|
2142
2198
|
return;
|
|
2143
2199
|
e.stopPropagation();
|
|
2144
2200
|
const s = e.touches[0];
|
|
2145
|
-
this.grabPort(o, { x: s.clientX, y: s.clientY }), this.window.addEventListener("touchmove", this.onWindowTouchMove
|
|
2201
|
+
this.grabPort(o, { x: s.clientX, y: s.clientY }), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
2202
|
+
passive: !0
|
|
2203
|
+
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
2204
|
+
passive: !0
|
|
2205
|
+
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
2206
|
+
passive: !0
|
|
2207
|
+
});
|
|
2146
2208
|
});
|
|
2147
2209
|
i(this, "onWindowTouchMove", (e) => {
|
|
2148
2210
|
const o = e.touches[0];
|
|
2149
|
-
if (!
|
|
2211
|
+
if (!M(
|
|
2150
2212
|
this.window,
|
|
2151
2213
|
this.overlayLayer,
|
|
2152
2214
|
o.clientX,
|
|
@@ -2162,8 +2224,8 @@ class Z {
|
|
|
2162
2224
|
this.tryCreateConnection({ x: o.clientX, y: o.clientY }), this.stopTouchDrag();
|
|
2163
2225
|
});
|
|
2164
2226
|
i(this, "onBeforeClear", () => {
|
|
2165
|
-
this.ports.
|
|
2166
|
-
this.unhookPortEvents(
|
|
2227
|
+
this.ports.forEachSingle((e) => {
|
|
2228
|
+
this.unhookPortEvents(e);
|
|
2167
2229
|
}), this.ports.clear();
|
|
2168
2230
|
});
|
|
2169
2231
|
i(this, "onBeforeDestroy", () => {
|
|
@@ -2174,13 +2236,13 @@ class Z {
|
|
|
2174
2236
|
i(this, "onEdgeCreated", (e) => {
|
|
2175
2237
|
this.config.onAfterEdgeCreated(e);
|
|
2176
2238
|
});
|
|
2177
|
-
this.canvas = e, this.overlayLayer = o, this.viewportStore = r, this.window = s, this.config =
|
|
2178
|
-
const d = new
|
|
2239
|
+
this.canvas = e, this.overlayLayer = o, this.viewportStore = r, this.window = s, this.config = Ze(n);
|
|
2240
|
+
const d = new ne(), c = new re(
|
|
2179
2241
|
d,
|
|
2180
2242
|
this.viewportStore,
|
|
2181
2243
|
this.overlayLayer
|
|
2182
2244
|
);
|
|
2183
|
-
this.overlayCanvas = new
|
|
2245
|
+
this.overlayCanvas = new se(
|
|
2184
2246
|
this.overlayLayer,
|
|
2185
2247
|
d,
|
|
2186
2248
|
this.viewportStore,
|
|
@@ -2189,7 +2251,7 @@ class Z {
|
|
|
2189
2251
|
), this.canvas.graph.onAfterPortMarked.subscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.subscribe(this.onBeforePortUnmarked), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2190
2252
|
}
|
|
2191
2253
|
static configure(e, o, r, s, h, n) {
|
|
2192
|
-
new
|
|
2254
|
+
new H(
|
|
2193
2255
|
e,
|
|
2194
2256
|
o,
|
|
2195
2257
|
r,
|
|
@@ -2199,29 +2261,33 @@ class Z {
|
|
|
2199
2261
|
);
|
|
2200
2262
|
}
|
|
2201
2263
|
grabPort(e, o) {
|
|
2202
|
-
const r = this.ports.
|
|
2264
|
+
const r = this.ports.getFirstBySingle(e), s = this.canvas.graph.getPort(r);
|
|
2203
2265
|
this.staticPortId = r;
|
|
2204
|
-
const h = this.config.connectionTypeResolver(this.staticPortId), n = e.getBoundingClientRect(), d = n.x + n.width / 2, c = n.y + n.height / 2, a = this.overlayLayer.getBoundingClientRect(), l = this.canvas.viewport.getViewportMatrix(), g =
|
|
2266
|
+
const h = this.config.connectionTypeResolver(this.staticPortId), n = e.getBoundingClientRect(), d = n.x + n.width / 2, c = n.y + n.height / 2, a = this.overlayLayer.getBoundingClientRect(), l = this.canvas.viewport.getViewportMatrix(), g = N(l, {
|
|
2205
2267
|
x: d - a.x,
|
|
2206
2268
|
y: c - a.y
|
|
2207
|
-
}), y =
|
|
2269
|
+
}), y = N(l, {
|
|
2208
2270
|
x: o.x - a.x,
|
|
2209
2271
|
y: o.y - a.y
|
|
2210
|
-
}),
|
|
2272
|
+
}), p = {
|
|
2211
2273
|
overlayId: this.staticOverlayPortId,
|
|
2212
2274
|
portCoords: g,
|
|
2213
2275
|
portDirection: s.direction
|
|
2214
2276
|
}, f = {
|
|
2215
2277
|
overlayId: this.draggingOverlayPortId,
|
|
2216
2278
|
portCoords: y,
|
|
2217
|
-
portDirection:
|
|
2279
|
+
portDirection: this.config.dragPortDirection
|
|
2218
2280
|
};
|
|
2219
2281
|
this.isDirect = h === "direct";
|
|
2220
|
-
const
|
|
2221
|
-
this.createOverlayGraph(
|
|
2282
|
+
const E = this.isDirect ? p : f, x = this.isDirect ? f : p;
|
|
2283
|
+
this.createOverlayGraph(E, x);
|
|
2222
2284
|
}
|
|
2223
2285
|
hookPortEvents(e) {
|
|
2224
|
-
e.addEventListener("mousedown", this.onPortMouseDown
|
|
2286
|
+
e.addEventListener("mousedown", this.onPortMouseDown, {
|
|
2287
|
+
passive: !0
|
|
2288
|
+
}), e.addEventListener("touchstart", this.onPortTouchStart, {
|
|
2289
|
+
passive: !0
|
|
2290
|
+
});
|
|
2225
2291
|
}
|
|
2226
2292
|
unhookPortEvents(e) {
|
|
2227
2293
|
e.removeEventListener("mousedown", this.onPortMouseDown), e.removeEventListener("touchstart", this.onPortTouchStart);
|
|
@@ -2262,16 +2328,18 @@ class Z {
|
|
|
2262
2328
|
}
|
|
2263
2329
|
tryCreateConnection(e) {
|
|
2264
2330
|
const o = this.findPortAtPoint(e);
|
|
2265
|
-
if (o === null)
|
|
2331
|
+
if (o === null) {
|
|
2332
|
+
this.config.onEdgeCreationInterrupted(this.staticPortId, this.isDirect);
|
|
2266
2333
|
return;
|
|
2334
|
+
}
|
|
2267
2335
|
const r = this.isDirect ? this.staticPortId : o, s = this.isDirect ? o : this.staticPortId, h = { from: r, to: s }, n = this.config.connectionPreprocessor(h);
|
|
2268
|
-
n !== null
|
|
2336
|
+
n !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(n), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.config.onEdgeCreationPrevented(h);
|
|
2269
2337
|
}
|
|
2270
2338
|
moveDraggingNode(e) {
|
|
2271
2339
|
const o = this.overlayLayer.getBoundingClientRect(), r = {
|
|
2272
2340
|
x: e.x - o.x,
|
|
2273
2341
|
y: e.y - o.y
|
|
2274
|
-
}, s = this.canvas.viewport.getViewportMatrix(), h =
|
|
2342
|
+
}, s = this.canvas.viewport.getViewportMatrix(), h = N(s, r);
|
|
2275
2343
|
this.overlayCanvas.updateNode(this.draggingOverlayPortId, {
|
|
2276
2344
|
x: h.x,
|
|
2277
2345
|
y: h.y
|
|
@@ -2288,35 +2356,35 @@ class Z {
|
|
|
2288
2356
|
}
|
|
2289
2357
|
findPortAtElement(e) {
|
|
2290
2358
|
let o = e, r = null;
|
|
2291
|
-
for (; o !== null && (r = this.ports.
|
|
2359
|
+
for (; o !== null && (r = this.ports.getFirstBySingle(o) ?? null, r === null); )
|
|
2292
2360
|
o = o.parentElement;
|
|
2293
2361
|
return r;
|
|
2294
2362
|
}
|
|
2295
2363
|
isPortConnectionAllowed(e) {
|
|
2296
|
-
const o = this.ports.
|
|
2364
|
+
const o = this.ports.getFirstBySingle(e);
|
|
2297
2365
|
return this.config.connectionTypeResolver(o) !== null;
|
|
2298
2366
|
}
|
|
2299
2367
|
}
|
|
2300
|
-
const
|
|
2368
|
+
const qe = () => {
|
|
2301
2369
|
const t = document.createElement("div");
|
|
2302
2370
|
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t;
|
|
2303
|
-
},
|
|
2371
|
+
}, W = () => {
|
|
2304
2372
|
const t = document.createElement("div");
|
|
2305
2373
|
return t.style.position = "absolute", t.style.inset = "0", t;
|
|
2306
2374
|
};
|
|
2307
|
-
class
|
|
2375
|
+
class et {
|
|
2308
2376
|
constructor(e) {
|
|
2309
|
-
i(this, "background",
|
|
2310
|
-
i(this, "main",
|
|
2311
|
-
i(this, "overlay",
|
|
2312
|
-
i(this, "host",
|
|
2377
|
+
i(this, "background", W());
|
|
2378
|
+
i(this, "main", W());
|
|
2379
|
+
i(this, "overlay", W());
|
|
2380
|
+
i(this, "host", qe());
|
|
2313
2381
|
this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main), this.overlay.style.pointerEvents = "none", this.host.appendChild(this.overlay);
|
|
2314
2382
|
}
|
|
2315
2383
|
destroy() {
|
|
2316
2384
|
this.host.removeChild(this.background), this.host.removeChild(this.main), this.host.removeChild(this.overlay), this.element.removeChild(this.host);
|
|
2317
2385
|
}
|
|
2318
2386
|
}
|
|
2319
|
-
class
|
|
2387
|
+
class ot {
|
|
2320
2388
|
constructor(e) {
|
|
2321
2389
|
i(this, "element", null);
|
|
2322
2390
|
i(this, "canvasDefaults", {});
|
|
@@ -2399,15 +2467,15 @@ class st {
|
|
|
2399
2467
|
"unable to build canvas when no attach element specified"
|
|
2400
2468
|
);
|
|
2401
2469
|
let e = this.boxRenderingTrigger;
|
|
2402
|
-
this.virtualScrollConfig !== void 0 && e === void 0 && (e = new
|
|
2403
|
-
const o = new
|
|
2404
|
-
let h = new
|
|
2470
|
+
this.virtualScrollConfig !== void 0 && e === void 0 && (e = new ie());
|
|
2471
|
+
const o = new ne(), r = new Ue(), s = new et(this.element);
|
|
2472
|
+
let h = new re(
|
|
2405
2473
|
o,
|
|
2406
2474
|
r,
|
|
2407
2475
|
s.main
|
|
2408
2476
|
);
|
|
2409
|
-
e !== void 0 && (h = new
|
|
2410
|
-
const n = new
|
|
2477
|
+
e !== void 0 && (h = new ue(h, o, e));
|
|
2478
|
+
const n = new se(
|
|
2411
2479
|
this.element,
|
|
2412
2480
|
o,
|
|
2413
2481
|
r,
|
|
@@ -2416,30 +2484,30 @@ class st {
|
|
|
2416
2484
|
), d = () => {
|
|
2417
2485
|
s.destroy(), n.onBeforeDestroy.unsubscribe(d);
|
|
2418
2486
|
};
|
|
2419
|
-
return n.onBeforeDestroy.subscribe(d), this.hasBackground &&
|
|
2487
|
+
return n.onBeforeDestroy.subscribe(d), this.hasBackground && Y.configure(
|
|
2420
2488
|
n,
|
|
2421
2489
|
this.backgroundConfig,
|
|
2422
2490
|
s.background
|
|
2423
|
-
), this.hasResizeReactiveNodes &&
|
|
2491
|
+
), this.hasResizeReactiveNodes && k.configure(n), this.hasDraggableNode && O.configure(
|
|
2424
2492
|
n,
|
|
2425
2493
|
s.main,
|
|
2426
2494
|
this.window,
|
|
2427
2495
|
this.dragConfig
|
|
2428
|
-
), this.hasUserConnectablePorts &&
|
|
2496
|
+
), this.hasUserConnectablePorts && H.configure(
|
|
2429
2497
|
n,
|
|
2430
2498
|
s.overlay,
|
|
2431
2499
|
r,
|
|
2432
2500
|
this.window,
|
|
2433
2501
|
this.canvasDefaults,
|
|
2434
2502
|
this.connectablePortsConfig
|
|
2435
|
-
), this.virtualScrollConfig !== void 0 ?
|
|
2503
|
+
), this.virtualScrollConfig !== void 0 ? X.configure(
|
|
2436
2504
|
n,
|
|
2437
2505
|
s.main,
|
|
2438
2506
|
this.window,
|
|
2439
2507
|
this.transformConfig,
|
|
2440
2508
|
e,
|
|
2441
2509
|
this.virtualScrollConfig
|
|
2442
|
-
) : this.hasTransformableViewport &&
|
|
2510
|
+
) : this.hasTransformableViewport && U.configure(
|
|
2443
2511
|
n,
|
|
2444
2512
|
s.main,
|
|
2445
2513
|
this.window,
|
|
@@ -2456,10 +2524,10 @@ class st {
|
|
|
2456
2524
|
}
|
|
2457
2525
|
export {
|
|
2458
2526
|
De as BezierEdgeShape,
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2527
|
+
ot as CanvasBuilder,
|
|
2528
|
+
ie as EventSubject,
|
|
2529
|
+
Ve as HorizontalEdgeShape,
|
|
2462
2530
|
S as HtmlGraphError,
|
|
2463
|
-
|
|
2464
|
-
|
|
2531
|
+
Le as StraightEdgeShape,
|
|
2532
|
+
Re as VerticalEdgeShape
|
|
2465
2533
|
};
|