@html-graph/html-graph 3.17.0 → 3.19.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/README.md +0 -4
- package/dist/html-graph.d.ts +20 -2
- package/dist/html-graph.js +365 -316
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/html-graph.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
var Me = Object.defineProperty;
|
|
2
2
|
var Le = (r, e, t) => e in r ? Me(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
3
|
var o = (r, e, t) => Le(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
const D = (r, e) => ({
|
|
5
|
+
x: r.scale * e.x + r.x,
|
|
6
|
+
y: r.scale * e.y + r.y
|
|
7
|
+
});
|
|
8
|
+
var L = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(L || {});
|
|
4
9
|
const Re = () => {
|
|
5
10
|
const r = document.createElement("div");
|
|
6
|
-
return r.style.
|
|
11
|
+
return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r.style.overflow = "hidden", r;
|
|
7
12
|
}, Ce = () => {
|
|
8
13
|
const r = document.createElement("div");
|
|
9
|
-
return r.style.
|
|
14
|
+
return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.width = "0", r.style.height = "0", r;
|
|
10
15
|
}, Ve = (r) => {
|
|
11
16
|
r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden";
|
|
12
|
-
}
|
|
13
|
-
x: r.scale * e.x + r.x,
|
|
14
|
-
y: r.scale * e.y + r.y
|
|
15
|
-
});
|
|
16
|
-
var L = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(L || {});
|
|
17
|
+
};
|
|
17
18
|
class pe {
|
|
18
19
|
constructor(e, t, s) {
|
|
19
|
-
o(this, "host",
|
|
20
|
-
o(this, "container",
|
|
20
|
+
o(this, "host", Re());
|
|
21
|
+
o(this, "container", Ce());
|
|
21
22
|
o(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
22
23
|
o(this, "applyTransform", () => {
|
|
23
24
|
const e = this.viewportStore.getContentMatrix();
|
|
@@ -90,7 +91,7 @@ class pe {
|
|
|
90
91
|
const h = {
|
|
91
92
|
x: s.left - i.left,
|
|
92
93
|
y: s.top - i.top
|
|
93
|
-
}, a =
|
|
94
|
+
}, a = D(n, h);
|
|
94
95
|
return {
|
|
95
96
|
x: a.x,
|
|
96
97
|
y: a.y,
|
|
@@ -102,7 +103,7 @@ class pe {
|
|
|
102
103
|
};
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
class
|
|
106
|
+
class Ie {
|
|
106
107
|
constructor(e) {
|
|
107
108
|
o(this, "xFrom", 1 / 0);
|
|
108
109
|
o(this, "yFrom", 1 / 0);
|
|
@@ -122,7 +123,7 @@ class Ue {
|
|
|
122
123
|
return a <= this.xTo && d >= this.xFrom && c <= this.yTo && l >= this.yFrom;
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
|
-
class
|
|
126
|
+
class Ue {
|
|
126
127
|
constructor(e, t, s, i) {
|
|
127
128
|
o(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
128
129
|
o(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
@@ -146,7 +147,7 @@ class Ie {
|
|
|
146
147
|
this.handleAttachEdge(h);
|
|
147
148
|
});
|
|
148
149
|
});
|
|
149
|
-
this.htmlView = e, this.graphStore = t, this.trigger = s, this.params = i, this.renderingBox = new
|
|
150
|
+
this.htmlView = e, this.graphStore = t, this.trigger = s, this.params = i, this.renderingBox = new Ie(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
150
151
|
}
|
|
151
152
|
attachNode(e) {
|
|
152
153
|
this.renderingBox.hasNode(e) && this.handleAttachNode(e);
|
|
@@ -222,6 +223,10 @@ const A = () => {
|
|
|
222
223
|
};
|
|
223
224
|
class Be {
|
|
224
225
|
constructor(e) {
|
|
226
|
+
/**
|
|
227
|
+
* @deprecated
|
|
228
|
+
* do not use
|
|
229
|
+
*/
|
|
225
230
|
o(this, "onBeforeUpdated");
|
|
226
231
|
o(this, "onAfterUpdated");
|
|
227
232
|
this.viewportStore = e, this.onBeforeUpdated = this.viewportStore.onBeforeUpdated, this.onAfterUpdated = this.viewportStore.onAfterUpdated;
|
|
@@ -427,6 +432,7 @@ class fe {
|
|
|
427
432
|
this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.htmlView.clear();
|
|
428
433
|
});
|
|
429
434
|
o(this, "onBeforeDestroyEmitter");
|
|
435
|
+
o(this, "destroyed", !1);
|
|
430
436
|
/**
|
|
431
437
|
* emits event just before destruction of canvas
|
|
432
438
|
*/
|
|
@@ -577,13 +583,13 @@ class fe {
|
|
|
577
583
|
* canvas element gets rolled back to initial state, and can not be reused
|
|
578
584
|
*/
|
|
579
585
|
destroy() {
|
|
580
|
-
this.clear(), this.onBeforeDestroyEmitter.emit(), this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
|
|
586
|
+
this.destroyed || (this.clear(), this.onBeforeDestroyEmitter.emit(), this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
|
|
581
587
|
this.onAfterNodePriorityUpdated
|
|
582
588
|
), 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(
|
|
583
589
|
this.onAfterEdgeShapeUpdated
|
|
584
590
|
), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
|
|
585
591
|
this.onAfterEdgePriorityUpdated
|
|
586
|
-
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
|
|
592
|
+
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy(), this.destroyed = !0);
|
|
587
593
|
}
|
|
588
594
|
}
|
|
589
595
|
class $e {
|
|
@@ -626,7 +632,7 @@ class $e {
|
|
|
626
632
|
return this.multiToSingleMap.get(e) !== void 0;
|
|
627
633
|
}
|
|
628
634
|
}
|
|
629
|
-
class
|
|
635
|
+
class me {
|
|
630
636
|
constructor() {
|
|
631
637
|
o(this, "nodes", /* @__PURE__ */ new Map());
|
|
632
638
|
o(this, "ports", /* @__PURE__ */ new Map());
|
|
@@ -824,6 +830,10 @@ class Fe {
|
|
|
824
830
|
o(this, "afterUpdateEmitter");
|
|
825
831
|
o(this, "onAfterUpdated");
|
|
826
832
|
o(this, "beforeUpdateEmitter");
|
|
833
|
+
/**
|
|
834
|
+
* @deprecated
|
|
835
|
+
* do not use
|
|
836
|
+
*/
|
|
827
837
|
o(this, "onBeforeUpdated");
|
|
828
838
|
[this.afterUpdateEmitter, this.onAfterUpdated] = A(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = A();
|
|
829
839
|
}
|
|
@@ -848,7 +858,7 @@ class Fe {
|
|
|
848
858
|
}, this.viewportMatrix = ie(this.contentMatrix), this.afterUpdateEmitter.emit();
|
|
849
859
|
}
|
|
850
860
|
}
|
|
851
|
-
class
|
|
861
|
+
class Y {
|
|
852
862
|
constructor(e) {
|
|
853
863
|
o(this, "elementToNodeId", /* @__PURE__ */ new Map());
|
|
854
864
|
o(this, "nodesResizeObserver");
|
|
@@ -863,18 +873,15 @@ class H {
|
|
|
863
873
|
o(this, "onBeforeClear", () => {
|
|
864
874
|
this.nodesResizeObserver.disconnect(), this.elementToNodeId.clear();
|
|
865
875
|
});
|
|
866
|
-
o(this, "onBeforeDestroy", () => {
|
|
867
|
-
this.canvas.graph.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
868
|
-
});
|
|
869
876
|
this.canvas = e, this.nodesResizeObserver = new ResizeObserver((t) => {
|
|
870
877
|
t.forEach((s) => {
|
|
871
878
|
const i = s.target;
|
|
872
879
|
this.handleNodeResize(i);
|
|
873
880
|
});
|
|
874
|
-
}), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear)
|
|
881
|
+
}), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear);
|
|
875
882
|
}
|
|
876
883
|
static configure(e) {
|
|
877
|
-
new
|
|
884
|
+
new Y(e);
|
|
878
885
|
}
|
|
879
886
|
handleNodeResize(e) {
|
|
880
887
|
const t = this.elementToNodeId.get(e);
|
|
@@ -884,7 +891,7 @@ class H {
|
|
|
884
891
|
const Oe = (r, e, t) => {
|
|
885
892
|
const { x: s, y: i, width: n, height: h } = r.getBoundingClientRect();
|
|
886
893
|
return e >= s && e <= s + n && t >= i && t <= i + h;
|
|
887
|
-
}, ke = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, R = (r, e, t, s) => Oe(e, t, s) && ke(r, t, s),
|
|
894
|
+
}, ke = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, R = (r, e, t, s) => Oe(e, t, s) && ke(r, t, s), U = (r, e) => {
|
|
888
895
|
e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
|
|
889
896
|
}, B = (r) => {
|
|
890
897
|
const e = document.createElement("div");
|
|
@@ -906,7 +913,7 @@ const Oe = (r, e, t) => {
|
|
|
906
913
|
for (; t !== null && (s = r.getElementPortIds(t)[0] ?? null, s === null); )
|
|
907
914
|
t = t.parentElement;
|
|
908
915
|
return s;
|
|
909
|
-
},
|
|
916
|
+
}, ye = (r, e) => {
|
|
910
917
|
const t = document.elementsFromPoint(e.x, e.y);
|
|
911
918
|
for (const s of t) {
|
|
912
919
|
const i = ze(r, s);
|
|
@@ -916,28 +923,28 @@ const Oe = (r, e, t) => {
|
|
|
916
923
|
return null;
|
|
917
924
|
};
|
|
918
925
|
var P = /* @__PURE__ */ ((r) => (r.Static = "static", r.Dragging = "dragging", r.Edge = "edge", r))(P || {});
|
|
919
|
-
const
|
|
926
|
+
const ve = (r, e) => ({
|
|
920
927
|
x: r / 2,
|
|
921
928
|
y: e / 2
|
|
922
|
-
}),
|
|
929
|
+
}), y = (r, e, t) => ({
|
|
923
930
|
x: e.x * r.x - e.y * r.y + ((1 - e.x) * t.x + e.y * t.y),
|
|
924
931
|
y: e.y * r.x + e.x * r.y + ((1 - e.x) * t.y - e.y * t.x)
|
|
925
932
|
}), w = {
|
|
926
933
|
x: 0,
|
|
927
934
|
y: 0
|
|
928
935
|
};
|
|
929
|
-
class
|
|
936
|
+
class He {
|
|
930
937
|
constructor(e) {
|
|
931
938
|
o(this, "path");
|
|
932
939
|
o(this, "midpoint");
|
|
933
940
|
this.params = e;
|
|
934
941
|
const t = this.params.to;
|
|
935
942
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
936
|
-
const s =
|
|
943
|
+
const s = y(
|
|
937
944
|
{ x: this.params.arrowLength, y: w.y },
|
|
938
945
|
this.params.sourceDirection,
|
|
939
946
|
w
|
|
940
|
-
), i =
|
|
947
|
+
), i = y(
|
|
941
948
|
{ x: this.params.to.x - this.params.arrowLength, y: this.params.to.y },
|
|
942
949
|
this.params.targetDirection,
|
|
943
950
|
this.params.to
|
|
@@ -955,30 +962,30 @@ const Ee = (r, e, t, s) => ({
|
|
|
955
962
|
x: e * r.x + (1 - e) / 2 * s.x,
|
|
956
963
|
y: t * r.y + (1 - t) / 2 * s.y
|
|
957
964
|
});
|
|
958
|
-
class
|
|
965
|
+
class Xe {
|
|
959
966
|
constructor(e) {
|
|
960
967
|
o(this, "path");
|
|
961
968
|
o(this, "midpoint");
|
|
962
969
|
this.params = e;
|
|
963
|
-
const t = this.params.hasSourceArrow ?
|
|
970
|
+
const t = this.params.hasSourceArrow ? y(
|
|
964
971
|
{ x: this.params.arrowLength, y: w.y },
|
|
965
972
|
this.params.sourceDirection,
|
|
966
973
|
w
|
|
967
|
-
) : w, s = this.params.hasTargetArrow ?
|
|
974
|
+
) : w, s = this.params.hasTargetArrow ? y(
|
|
968
975
|
{
|
|
969
976
|
x: this.params.to.x - this.params.arrowLength,
|
|
970
977
|
y: this.params.to.y
|
|
971
978
|
},
|
|
972
979
|
this.params.targetDirection,
|
|
973
980
|
this.params.to
|
|
974
|
-
) : this.params.to, i = this.params.arrowLength, n = Math.cos(this.params.detourDirection) * this.params.detourDistance, h = Math.sin(this.params.detourDirection) * this.params.detourDistance, a = n * this.params.flipX, d = h * this.params.flipY, c =
|
|
981
|
+
) : this.params.to, i = this.params.arrowLength, n = Math.cos(this.params.detourDirection) * this.params.detourDistance, h = Math.sin(this.params.detourDirection) * this.params.detourDistance, a = n * this.params.flipX, d = h * this.params.flipY, c = y(
|
|
975
982
|
{ x: i, y: w.y },
|
|
976
983
|
this.params.sourceDirection,
|
|
977
984
|
w
|
|
978
985
|
), l = {
|
|
979
986
|
x: c.x + a,
|
|
980
987
|
y: c.y + d
|
|
981
|
-
}, g =
|
|
988
|
+
}, g = y(
|
|
982
989
|
{ x: this.params.to.x - i, y: this.params.to.y },
|
|
983
990
|
this.params.targetDirection,
|
|
984
991
|
this.params.to
|
|
@@ -988,10 +995,10 @@ class Ye {
|
|
|
988
995
|
}, f = {
|
|
989
996
|
x: (l.x + p.x) / 2,
|
|
990
997
|
y: (l.y + p.y) / 2
|
|
991
|
-
},
|
|
998
|
+
}, m = {
|
|
992
999
|
x: c.x + this.params.curvature * this.params.sourceDirection.x,
|
|
993
1000
|
y: c.y + this.params.curvature * this.params.sourceDirection.y
|
|
994
|
-
},
|
|
1001
|
+
}, v = {
|
|
995
1002
|
x: g.x - this.params.curvature * this.params.targetDirection.x,
|
|
996
1003
|
y: g.y - this.params.curvature * this.params.targetDirection.y
|
|
997
1004
|
}, E = {
|
|
@@ -1004,8 +1011,8 @@ class Ye {
|
|
|
1004
1011
|
this.path = [
|
|
1005
1012
|
`M ${t.x} ${t.y}`,
|
|
1006
1013
|
`L ${c.x} ${c.y}`,
|
|
1007
|
-
`C ${
|
|
1008
|
-
`C ${x.x} ${x.y} ${
|
|
1014
|
+
`C ${m.x} ${m.y} ${E.x} ${E.y} ${f.x} ${f.y}`,
|
|
1015
|
+
`C ${x.x} ${x.y} ${v.x} ${v.y} ${g.x} ${g.y}`,
|
|
1009
1016
|
`L ${s.x} ${s.y}`
|
|
1010
1017
|
].join(" "), this.midpoint = Ee(f, e.flipX, e.flipY, e.to);
|
|
1011
1018
|
}
|
|
@@ -1017,42 +1024,42 @@ const V = (r, e) => {
|
|
|
1017
1024
|
let i = 0, n = 0, h = 0;
|
|
1018
1025
|
r.forEach((a, d) => {
|
|
1019
1026
|
let c = 0, l = 0, g = 0;
|
|
1020
|
-
const p = d > 0, f = d < s,
|
|
1027
|
+
const p = d > 0, f = d < s, m = p && f;
|
|
1021
1028
|
if (p && (c = -i, l = -n, g = h), f) {
|
|
1022
1029
|
const C = r[d + 1];
|
|
1023
1030
|
i = C.x - a.x, n = C.y - a.y, h = Math.sqrt(i * i + n * n);
|
|
1024
1031
|
}
|
|
1025
|
-
const E = h !== 0 ? Math.min((
|
|
1026
|
-
d > 0 && t.push(`L ${N.x} ${N.y}`),
|
|
1032
|
+
const E = h !== 0 ? Math.min((m ? e : 0) / h, d < s - 1 ? 0.5 : 1) : 0, x = m ? { x: a.x + i * E, y: a.y + n * E } : a, T = g !== 0 ? Math.min((m ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, N = m ? { x: a.x + c * T, y: a.y + l * T } : a;
|
|
1033
|
+
d > 0 && t.push(`L ${N.x} ${N.y}`), m && t.push(
|
|
1027
1034
|
`C ${a.x} ${a.y} ${a.x} ${a.y} ${x.x} ${x.y}`
|
|
1028
1035
|
);
|
|
1029
1036
|
});
|
|
1030
1037
|
}
|
|
1031
1038
|
return t.join(" ");
|
|
1032
1039
|
};
|
|
1033
|
-
class
|
|
1040
|
+
class Ye {
|
|
1034
1041
|
constructor(e) {
|
|
1035
1042
|
o(this, "path");
|
|
1036
1043
|
o(this, "midpoint");
|
|
1037
1044
|
this.params = e;
|
|
1038
1045
|
const t = this.params.to;
|
|
1039
1046
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
1040
|
-
const s = this.params.hasSourceArrow ?
|
|
1047
|
+
const s = this.params.hasSourceArrow ? y(
|
|
1041
1048
|
{ x: this.params.arrowLength, y: w.y },
|
|
1042
1049
|
this.params.sourceDirection,
|
|
1043
1050
|
w
|
|
1044
|
-
) : w, i = this.params.hasTargetArrow ?
|
|
1051
|
+
) : w, i = this.params.hasTargetArrow ? y(
|
|
1045
1052
|
{
|
|
1046
1053
|
x: this.params.to.x - this.params.arrowLength,
|
|
1047
1054
|
y: this.params.to.y
|
|
1048
1055
|
},
|
|
1049
1056
|
this.params.targetDirection,
|
|
1050
1057
|
this.params.to
|
|
1051
|
-
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = n - this.params.roundness, a =
|
|
1058
|
+
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = n - this.params.roundness, a = y(
|
|
1052
1059
|
{ x: h, y: w.y },
|
|
1053
1060
|
this.params.sourceDirection,
|
|
1054
1061
|
w
|
|
1055
|
-
), d =
|
|
1062
|
+
), d = y(
|
|
1056
1063
|
{ x: this.params.to.x - h, y: this.params.to.y },
|
|
1057
1064
|
this.params.targetDirection,
|
|
1058
1065
|
this.params.to
|
|
@@ -1062,9 +1069,9 @@ class He {
|
|
|
1062
1069
|
}, p = { x: g.x, y: l }, f = {
|
|
1063
1070
|
x: this.params.flipX > 0 ? this.params.to.x - c : this.params.to.x + n,
|
|
1064
1071
|
y: d.y
|
|
1065
|
-
},
|
|
1072
|
+
}, m = { x: f.x, y: l };
|
|
1066
1073
|
this.path = V(
|
|
1067
|
-
[s, a, g, p,
|
|
1074
|
+
[s, a, g, p, m, f, d, i],
|
|
1068
1075
|
this.params.roundness
|
|
1069
1076
|
);
|
|
1070
1077
|
}
|
|
@@ -1074,22 +1081,22 @@ class j {
|
|
|
1074
1081
|
o(this, "path");
|
|
1075
1082
|
o(this, "midpoint");
|
|
1076
1083
|
this.params = e;
|
|
1077
|
-
const t = this.params.hasSourceArrow ?
|
|
1084
|
+
const t = this.params.hasSourceArrow ? y(
|
|
1078
1085
|
{ x: this.params.arrowLength, y: w.y },
|
|
1079
1086
|
this.params.sourceDirection,
|
|
1080
1087
|
w
|
|
1081
|
-
) : w, s = this.params.hasTargetArrow ?
|
|
1088
|
+
) : w, s = this.params.hasTargetArrow ? y(
|
|
1082
1089
|
{
|
|
1083
1090
|
x: this.params.to.x - this.params.arrowLength,
|
|
1084
1091
|
y: this.params.to.y
|
|
1085
1092
|
},
|
|
1086
1093
|
this.params.targetDirection,
|
|
1087
1094
|
this.params.to
|
|
1088
|
-
) : this.params.to, i = this.params.arrowLength + this.params.arrowOffset, n =
|
|
1095
|
+
) : this.params.to, i = this.params.arrowLength + this.params.arrowOffset, n = y(
|
|
1089
1096
|
{ x: i, y: w.y },
|
|
1090
1097
|
this.params.sourceDirection,
|
|
1091
1098
|
w
|
|
1092
|
-
), h = Math.cos(this.params.detourDirection) * this.params.detourDistance, a = Math.sin(this.params.detourDirection) * this.params.detourDistance, d = h * this.params.flipX, c = a * this.params.flipY, l = { x: n.x + d, y: n.y + c }, g =
|
|
1099
|
+
), h = Math.cos(this.params.detourDirection) * this.params.detourDistance, a = Math.sin(this.params.detourDirection) * this.params.detourDistance, d = h * this.params.flipX, c = a * this.params.flipY, l = { x: n.x + d, y: n.y + c }, g = y(
|
|
1093
1100
|
{ x: this.params.to.x - i, y: this.params.to.y },
|
|
1094
1101
|
this.params.targetDirection,
|
|
1095
1102
|
this.params.to
|
|
@@ -1107,22 +1114,22 @@ class je {
|
|
|
1107
1114
|
this.params = e;
|
|
1108
1115
|
const t = this.params.to;
|
|
1109
1116
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
1110
|
-
const s = this.params.hasSourceArrow ?
|
|
1117
|
+
const s = this.params.hasSourceArrow ? y(
|
|
1111
1118
|
{ x: this.params.arrowLength, y: w.y },
|
|
1112
1119
|
this.params.sourceDirection,
|
|
1113
1120
|
w
|
|
1114
|
-
) : w, i = this.params.hasTargetArrow ?
|
|
1121
|
+
) : w, i = this.params.hasTargetArrow ? y(
|
|
1115
1122
|
{
|
|
1116
1123
|
x: this.params.to.x - this.params.arrowLength,
|
|
1117
1124
|
y: this.params.to.y
|
|
1118
1125
|
},
|
|
1119
1126
|
this.params.targetDirection,
|
|
1120
1127
|
this.params.to
|
|
1121
|
-
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h =
|
|
1128
|
+
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = y(
|
|
1122
1129
|
{ x: n, y: w.y },
|
|
1123
1130
|
this.params.sourceDirection,
|
|
1124
1131
|
w
|
|
1125
|
-
), a =
|
|
1132
|
+
), a = y(
|
|
1126
1133
|
{ x: this.params.to.x - n, y: this.params.to.y },
|
|
1127
1134
|
this.params.targetDirection,
|
|
1128
1135
|
this.params.to
|
|
@@ -1137,22 +1144,22 @@ class Ge {
|
|
|
1137
1144
|
this.params = e;
|
|
1138
1145
|
const t = this.params.to;
|
|
1139
1146
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
1140
|
-
const s = this.params.hasSourceArrow ?
|
|
1147
|
+
const s = this.params.hasSourceArrow ? y(
|
|
1141
1148
|
{ x: this.params.arrowLength, y: w.y },
|
|
1142
1149
|
this.params.sourceDirection,
|
|
1143
1150
|
w
|
|
1144
|
-
) : w, i = this.params.hasTargetArrow ?
|
|
1151
|
+
) : w, i = this.params.hasTargetArrow ? y(
|
|
1145
1152
|
{
|
|
1146
1153
|
x: this.params.to.x - this.params.arrowLength,
|
|
1147
1154
|
y: this.params.to.y
|
|
1148
1155
|
},
|
|
1149
1156
|
this.params.targetDirection,
|
|
1150
1157
|
this.params.to
|
|
1151
|
-
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = n - this.params.roundness, a =
|
|
1158
|
+
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = n - this.params.roundness, a = y(
|
|
1152
1159
|
{ x: h, y: w.y },
|
|
1153
1160
|
this.params.sourceDirection,
|
|
1154
1161
|
w
|
|
1155
|
-
), d =
|
|
1162
|
+
), d = y(
|
|
1156
1163
|
{ x: this.params.to.x - h, y: this.params.to.y },
|
|
1157
1164
|
this.params.targetDirection,
|
|
1158
1165
|
this.params.to
|
|
@@ -1162,9 +1169,9 @@ class Ge {
|
|
|
1162
1169
|
}, p = { x: l, y: g.y }, f = {
|
|
1163
1170
|
x: d.x,
|
|
1164
1171
|
y: this.params.flipY > 0 ? this.params.to.y - c : this.params.to.y + n
|
|
1165
|
-
},
|
|
1172
|
+
}, m = { x: l, y: f.y };
|
|
1166
1173
|
this.path = V(
|
|
1167
|
-
[s, a, g, p,
|
|
1174
|
+
[s, a, g, p, m, f, d, i],
|
|
1168
1175
|
this.params.roundness
|
|
1169
1176
|
);
|
|
1170
1177
|
}
|
|
@@ -1184,7 +1191,7 @@ class G {
|
|
|
1184
1191
|
{ x: i, y: w.y },
|
|
1185
1192
|
{ x: this.params.arrowLength, y: w.y }
|
|
1186
1193
|
].map(
|
|
1187
|
-
(c) =>
|
|
1194
|
+
(c) => y(c, this.params.sourceDirection, w)
|
|
1188
1195
|
), d = `M ${w.x} ${w.y} L ${a[0].x} ${a[0].y} `;
|
|
1189
1196
|
this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : d}${V(a, this.params.roundness)}`, this.midpoint = { x: (a[3].x + a[4].x) / 2, y: (a[3].y + a[4].y) / 2 };
|
|
1190
1197
|
}
|
|
@@ -1200,7 +1207,7 @@ class Ke {
|
|
|
1200
1207
|
{ x: c, y: -n },
|
|
1201
1208
|
{ x: d, y: 0 }
|
|
1202
1209
|
].map(
|
|
1203
|
-
(
|
|
1210
|
+
(m) => y(m, this.params.sourceDirection, w)
|
|
1204
1211
|
), p = [
|
|
1205
1212
|
`M ${g[0].x} ${g[0].y}`,
|
|
1206
1213
|
`A ${t} ${t} 0 0 1 ${g[1].x} ${g[1].y}`,
|
|
@@ -1283,7 +1290,7 @@ const Ae = (r, e) => {
|
|
|
1283
1290
|
w,
|
|
1284
1291
|
{ x: t, y: s },
|
|
1285
1292
|
{ x: t, y: -s }
|
|
1286
|
-
].map((c) =>
|
|
1293
|
+
].map((c) => y(c, r, w)).map((c) => ({ x: c.x + e.x, y: c.y + e.y })), h = `M ${n[0].x} ${n[0].y}`, a = `L ${n[1].x} ${n[1].y}`, d = `L ${n[2].x} ${n[2].y}`;
|
|
1287
1294
|
return `${h} ${a} ${d} Z`;
|
|
1288
1295
|
}, u = Object.freeze({
|
|
1289
1296
|
color: "#777777",
|
|
@@ -1335,21 +1342,21 @@ class $ {
|
|
|
1335
1342
|
};
|
|
1336
1343
|
let g = c, p = -this.params.arrowLength, f;
|
|
1337
1344
|
e.category === L.PortCycle ? (f = this.params.createCyclePath, g = d, p = this.params.arrowLength) : e.category === L.NodeCycle ? f = this.params.createDetourPath : f = this.params.createLinePath;
|
|
1338
|
-
const
|
|
1345
|
+
const m = f(
|
|
1339
1346
|
d,
|
|
1340
1347
|
c,
|
|
1341
1348
|
l,
|
|
1342
1349
|
h,
|
|
1343
1350
|
a
|
|
1344
1351
|
);
|
|
1345
|
-
this.line.setAttribute("d",
|
|
1346
|
-
let
|
|
1347
|
-
this.sourceArrow && (
|
|
1352
|
+
this.line.setAttribute("d", m.path);
|
|
1353
|
+
let v = null;
|
|
1354
|
+
this.sourceArrow && (v = z(
|
|
1348
1355
|
d,
|
|
1349
1356
|
w,
|
|
1350
1357
|
this.params.arrowLength,
|
|
1351
1358
|
this.params.arrowWidth
|
|
1352
|
-
), this.sourceArrow.setAttribute("d",
|
|
1359
|
+
), this.sourceArrow.setAttribute("d", v));
|
|
1353
1360
|
let E = null;
|
|
1354
1361
|
this.targetArrow && (E = z(
|
|
1355
1362
|
g,
|
|
@@ -1357,8 +1364,8 @@ class $ {
|
|
|
1357
1364
|
p,
|
|
1358
1365
|
this.params.arrowWidth
|
|
1359
1366
|
), this.targetArrow.setAttribute("d", E)), this.afterRenderEmitter.emit({
|
|
1360
|
-
edgePath:
|
|
1361
|
-
sourceArrowPath:
|
|
1367
|
+
edgePath: m,
|
|
1368
|
+
sourceArrowPath: v,
|
|
1362
1369
|
targetArrowPath: E
|
|
1363
1370
|
});
|
|
1364
1371
|
}
|
|
@@ -1389,7 +1396,7 @@ class Je {
|
|
|
1389
1396
|
hasSourceArrow: this.hasSourceArrow,
|
|
1390
1397
|
hasTargetArrow: this.hasTargetArrow
|
|
1391
1398
|
}));
|
|
1392
|
-
o(this, "createDetourPath", (e, t, s, i, n) => new
|
|
1399
|
+
o(this, "createDetourPath", (e, t, s, i, n) => new Xe({
|
|
1393
1400
|
to: s,
|
|
1394
1401
|
sourceDirection: e,
|
|
1395
1402
|
targetDirection: t,
|
|
@@ -1402,7 +1409,7 @@ class Je {
|
|
|
1402
1409
|
hasSourceArrow: this.hasSourceArrow,
|
|
1403
1410
|
hasTargetArrow: this.hasTargetArrow
|
|
1404
1411
|
}));
|
|
1405
|
-
o(this, "createLinePath", (e, t, s) => new
|
|
1412
|
+
o(this, "createLinePath", (e, t, s) => new He({
|
|
1406
1413
|
to: s,
|
|
1407
1414
|
sourceDirection: e,
|
|
1408
1415
|
targetDirection: t,
|
|
@@ -1468,7 +1475,7 @@ class Qe {
|
|
|
1468
1475
|
hasSourceArrow: this.hasSourceArrow,
|
|
1469
1476
|
hasTargetArrow: this.hasTargetArrow
|
|
1470
1477
|
}));
|
|
1471
|
-
o(this, "createLinePath", (e, t, s, i) => new
|
|
1478
|
+
o(this, "createLinePath", (e, t, s, i) => new Ye({
|
|
1472
1479
|
to: s,
|
|
1473
1480
|
sourceDirection: e,
|
|
1474
1481
|
targetDirection: t,
|
|
@@ -1787,9 +1794,9 @@ class bt {
|
|
|
1787
1794
|
}
|
|
1788
1795
|
}
|
|
1789
1796
|
const Ne = (r, e) => {
|
|
1790
|
-
const t = new
|
|
1797
|
+
const t = new me(), s = new pe(t, e, r), i = {
|
|
1791
1798
|
nodes: {
|
|
1792
|
-
centerFn:
|
|
1799
|
+
centerFn: ve,
|
|
1793
1800
|
priorityFn: () => 0
|
|
1794
1801
|
},
|
|
1795
1802
|
edges: {
|
|
@@ -1808,11 +1815,117 @@ const Ne = (r, e) => {
|
|
|
1808
1815
|
i
|
|
1809
1816
|
);
|
|
1810
1817
|
};
|
|
1818
|
+
class F {
|
|
1819
|
+
constructor(e, t, s, i) {
|
|
1820
|
+
o(this, "onAfterPortMarked", (e) => {
|
|
1821
|
+
const t = this.canvas.graph.getPort(e);
|
|
1822
|
+
this.canvas.graph.getElementPortIds(t.element).length === 1 && this.hookPortEvents(t.element);
|
|
1823
|
+
});
|
|
1824
|
+
o(this, "onBeforePortUnmarked", (e) => {
|
|
1825
|
+
const t = this.canvas.graph.getPort(e);
|
|
1826
|
+
this.canvas.graph.getElementPortIds(t.element).length === 1 && this.unhookPortEvents(t.element);
|
|
1827
|
+
});
|
|
1828
|
+
o(this, "onPortMouseDown", (e) => {
|
|
1829
|
+
if (!this.params.mouseDownEventVerifier(e))
|
|
1830
|
+
return;
|
|
1831
|
+
const t = e.currentTarget, s = this.canvas.graph.getElementPortIds(t)[0];
|
|
1832
|
+
this.params.onPortPointerDown(s, {
|
|
1833
|
+
x: e.clientX,
|
|
1834
|
+
y: e.clientY
|
|
1835
|
+
}) && (e.stopPropagation(), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
1836
|
+
passive: !0
|
|
1837
|
+
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
1838
|
+
passive: !0
|
|
1839
|
+
}));
|
|
1840
|
+
});
|
|
1841
|
+
o(this, "onWindowMouseMove", (e) => {
|
|
1842
|
+
if (!R(
|
|
1843
|
+
this.window,
|
|
1844
|
+
this.element,
|
|
1845
|
+
e.clientX,
|
|
1846
|
+
e.clientY
|
|
1847
|
+
)) {
|
|
1848
|
+
this.stopMouseDrag();
|
|
1849
|
+
return;
|
|
1850
|
+
}
|
|
1851
|
+
this.params.onPointerMove({ x: e.clientX, y: e.clientY });
|
|
1852
|
+
});
|
|
1853
|
+
o(this, "onWindowMouseUp", (e) => {
|
|
1854
|
+
this.params.mouseUpEventVerifier(e) && (this.params.onPointerUp({ x: e.clientX, y: e.clientY }), this.stopMouseDrag());
|
|
1855
|
+
});
|
|
1856
|
+
o(this, "onPortTouchStart", (e) => {
|
|
1857
|
+
if (e.touches.length !== 1)
|
|
1858
|
+
return;
|
|
1859
|
+
const t = e.touches[0], s = e.currentTarget, i = this.canvas.graph.getElementPortIds(s)[0];
|
|
1860
|
+
this.params.onPortPointerDown(i, {
|
|
1861
|
+
x: t.clientX,
|
|
1862
|
+
y: t.clientY
|
|
1863
|
+
}) && (e.stopPropagation(), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
1864
|
+
passive: !0
|
|
1865
|
+
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
1866
|
+
passive: !0
|
|
1867
|
+
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
1868
|
+
passive: !0
|
|
1869
|
+
}));
|
|
1870
|
+
});
|
|
1871
|
+
o(this, "onWindowTouchMove", (e) => {
|
|
1872
|
+
const t = e.touches[0];
|
|
1873
|
+
if (!R(
|
|
1874
|
+
this.window,
|
|
1875
|
+
this.element,
|
|
1876
|
+
t.clientX,
|
|
1877
|
+
t.clientY
|
|
1878
|
+
)) {
|
|
1879
|
+
this.stopTouchDrag();
|
|
1880
|
+
return;
|
|
1881
|
+
}
|
|
1882
|
+
this.params.onPointerMove({ x: t.clientX, y: t.clientY });
|
|
1883
|
+
});
|
|
1884
|
+
o(this, "onWindowTouchFinish", (e) => {
|
|
1885
|
+
const t = e.changedTouches[0];
|
|
1886
|
+
this.params.onPointerUp({ x: t.clientX, y: t.clientY }), this.stopTouchDrag();
|
|
1887
|
+
});
|
|
1888
|
+
o(this, "onBeforeClear", () => {
|
|
1889
|
+
this.canvas.graph.getAllPortIds().forEach((e) => {
|
|
1890
|
+
const t = this.canvas.graph.getPort(e);
|
|
1891
|
+
this.unhookPortEvents(t.element);
|
|
1892
|
+
});
|
|
1893
|
+
});
|
|
1894
|
+
o(this, "onBeforeDestroy", () => {
|
|
1895
|
+
this.params.onStopDrag(), this.removeWindowMouseListeners(), this.removeWindowTouchListeners();
|
|
1896
|
+
});
|
|
1897
|
+
this.canvas = e, this.element = t, this.window = s, this.params = i, 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);
|
|
1898
|
+
}
|
|
1899
|
+
static configure(e, t, s, i) {
|
|
1900
|
+
new F(e, t, s, i);
|
|
1901
|
+
}
|
|
1902
|
+
hookPortEvents(e) {
|
|
1903
|
+
e.addEventListener("mousedown", this.onPortMouseDown, {
|
|
1904
|
+
passive: !0
|
|
1905
|
+
}), e.addEventListener("touchstart", this.onPortTouchStart, {
|
|
1906
|
+
passive: !0
|
|
1907
|
+
});
|
|
1908
|
+
}
|
|
1909
|
+
unhookPortEvents(e) {
|
|
1910
|
+
e.removeEventListener("mousedown", this.onPortMouseDown), e.removeEventListener("touchstart", this.onPortTouchStart);
|
|
1911
|
+
}
|
|
1912
|
+
stopMouseDrag() {
|
|
1913
|
+
this.params.onStopDrag(), this.removeWindowMouseListeners();
|
|
1914
|
+
}
|
|
1915
|
+
stopTouchDrag() {
|
|
1916
|
+
this.params.onStopDrag(), this.removeWindowTouchListeners();
|
|
1917
|
+
}
|
|
1918
|
+
removeWindowMouseListeners() {
|
|
1919
|
+
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
1920
|
+
}
|
|
1921
|
+
removeWindowTouchListeners() {
|
|
1922
|
+
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1811
1925
|
class Z {
|
|
1812
1926
|
constructor(e, t, s, i) {
|
|
1813
|
-
o(this, "
|
|
1927
|
+
o(this, "grabbedNode", null);
|
|
1814
1928
|
o(this, "maxNodePriority", 0);
|
|
1815
|
-
o(this, "previousTouchCoordinates", null);
|
|
1816
1929
|
o(this, "graph");
|
|
1817
1930
|
o(this, "onAfterNodeAdded", (e) => {
|
|
1818
1931
|
this.updateMaxNodePriority(e);
|
|
@@ -1831,7 +1944,7 @@ class Z {
|
|
|
1831
1944
|
t.element.removeEventListener("mousedown", this.onMouseDown), t.element.removeEventListener("touchstart", this.onTouchStart);
|
|
1832
1945
|
});
|
|
1833
1946
|
o(this, "onBeforeDestroy", () => {
|
|
1834
|
-
this.
|
|
1947
|
+
this.removeMouseDragListeners(), this.removeTouchDragListeners();
|
|
1835
1948
|
});
|
|
1836
1949
|
o(this, "onBeforeClear", () => {
|
|
1837
1950
|
this.canvas.graph.getAllNodeIds().forEach((e) => {
|
|
@@ -1840,40 +1953,58 @@ class Z {
|
|
|
1840
1953
|
}), this.maxNodePriority = 0;
|
|
1841
1954
|
});
|
|
1842
1955
|
o(this, "onMouseDown", (e) => {
|
|
1843
|
-
if (!this.
|
|
1956
|
+
if (!this.params.mouseDownEventVerifier(e))
|
|
1844
1957
|
return;
|
|
1845
1958
|
const t = e.currentTarget, s = this.graph.getElementNodeId(t), i = this.graph.getNode(s);
|
|
1846
|
-
this.
|
|
1959
|
+
if (!this.params.onBeforeNodeDrag({
|
|
1847
1960
|
nodeId: s,
|
|
1848
1961
|
element: i.element,
|
|
1849
1962
|
x: i.x,
|
|
1850
1963
|
y: i.y
|
|
1851
|
-
})
|
|
1964
|
+
}))
|
|
1965
|
+
return;
|
|
1966
|
+
e.stopPropagation();
|
|
1967
|
+
const h = this.calculateContentPoint({
|
|
1968
|
+
x: e.clientX,
|
|
1969
|
+
y: e.clientY
|
|
1970
|
+
});
|
|
1971
|
+
this.grabbedNode = {
|
|
1972
|
+
nodeId: s,
|
|
1973
|
+
dx: h.x - i.x,
|
|
1974
|
+
dy: h.y - i.y
|
|
1975
|
+
}, U(this.element, this.params.dragCursor), this.moveNodeOnTop(s), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
1852
1976
|
passive: !0
|
|
1853
|
-
}), this.window.addEventListener("
|
|
1977
|
+
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
1854
1978
|
passive: !0
|
|
1855
|
-
})
|
|
1979
|
+
});
|
|
1856
1980
|
});
|
|
1857
1981
|
o(this, "onTouchStart", (e) => {
|
|
1858
1982
|
if (e.touches.length !== 1)
|
|
1859
1983
|
return;
|
|
1860
|
-
e.
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1984
|
+
e.stopPropagation();
|
|
1985
|
+
const t = e.touches[0], s = e.currentTarget, i = this.canvas.graph.getElementNodeId(s), n = this.graph.getNode(i);
|
|
1986
|
+
if (!this.params.onBeforeNodeDrag({
|
|
1987
|
+
nodeId: i,
|
|
1988
|
+
element: n.element,
|
|
1989
|
+
x: n.x,
|
|
1990
|
+
y: n.y
|
|
1991
|
+
}))
|
|
1992
|
+
return;
|
|
1993
|
+
const a = this.calculateContentPoint({
|
|
1994
|
+
x: t.clientX,
|
|
1995
|
+
y: t.clientY
|
|
1996
|
+
});
|
|
1997
|
+
this.grabbedNode = {
|
|
1998
|
+
nodeId: i,
|
|
1999
|
+
dx: a.x - n.x,
|
|
2000
|
+
dy: a.y - n.y
|
|
2001
|
+
}, this.moveNodeOnTop(i), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
1871
2002
|
passive: !0
|
|
1872
2003
|
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
1873
2004
|
passive: !0
|
|
1874
2005
|
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
1875
2006
|
passive: !0
|
|
1876
|
-
})
|
|
2007
|
+
});
|
|
1877
2008
|
});
|
|
1878
2009
|
o(this, "onWindowMouseMove", (e) => {
|
|
1879
2010
|
if (!R(
|
|
@@ -1885,10 +2016,13 @@ class Z {
|
|
|
1885
2016
|
this.cancelMouseDrag();
|
|
1886
2017
|
return;
|
|
1887
2018
|
}
|
|
1888
|
-
this.
|
|
2019
|
+
this.grabbedNode !== null && this.moveNode(this.grabbedNode, {
|
|
2020
|
+
x: e.clientX,
|
|
2021
|
+
y: e.clientY
|
|
2022
|
+
});
|
|
1889
2023
|
});
|
|
1890
2024
|
o(this, "onWindowMouseUp", (e) => {
|
|
1891
|
-
this.
|
|
2025
|
+
this.params.mouseUpEventVerifier(e) && this.cancelMouseDrag();
|
|
1892
2026
|
});
|
|
1893
2027
|
o(this, "onWindowTouchMove", (e) => {
|
|
1894
2028
|
if (e.touches.length !== 1)
|
|
@@ -1903,43 +2037,40 @@ class Z {
|
|
|
1903
2037
|
this.cancelTouchDrag();
|
|
1904
2038
|
return;
|
|
1905
2039
|
}
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
y: e.touches[0].clientY
|
|
1911
|
-
};
|
|
1912
|
-
}
|
|
2040
|
+
this.grabbedNode !== null && this.moveNode(this.grabbedNode, {
|
|
2041
|
+
x: t.clientX,
|
|
2042
|
+
y: t.clientY
|
|
2043
|
+
});
|
|
1913
2044
|
});
|
|
1914
2045
|
o(this, "onWindowTouchFinish", () => {
|
|
1915
|
-
this.
|
|
2046
|
+
this.cancelTouchDrag();
|
|
1916
2047
|
});
|
|
1917
|
-
this.canvas = e, this.element = t, this.window = s, this.
|
|
2048
|
+
this.canvas = e, this.element = t, this.window = s, this.params = i, 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);
|
|
1918
2049
|
}
|
|
1919
2050
|
static configure(e, t, s, i) {
|
|
1920
2051
|
new Z(e, t, s, i);
|
|
1921
2052
|
}
|
|
1922
|
-
|
|
1923
|
-
const
|
|
1924
|
-
if (
|
|
2053
|
+
moveNode(e, t) {
|
|
2054
|
+
const s = this.graph.getNode(e.nodeId);
|
|
2055
|
+
if (s === null)
|
|
1925
2056
|
return;
|
|
1926
|
-
const
|
|
1927
|
-
x: i.x,
|
|
1928
|
-
y: i.y
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1931
|
-
h
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
nodeId: e,
|
|
1935
|
-
element:
|
|
1936
|
-
x:
|
|
1937
|
-
y:
|
|
2057
|
+
const i = this.calculateContentPoint(t), n = {
|
|
2058
|
+
x: i.x - e.dx,
|
|
2059
|
+
y: i.y - e.dy
|
|
2060
|
+
}, h = this.adjustNodeCoords(n);
|
|
2061
|
+
this.canvas.updateNode(e.nodeId, {
|
|
2062
|
+
x: h.x,
|
|
2063
|
+
y: h.y
|
|
2064
|
+
}), this.params.onNodeDrag({
|
|
2065
|
+
nodeId: e.nodeId,
|
|
2066
|
+
element: s.element,
|
|
2067
|
+
x: h.x,
|
|
2068
|
+
y: h.y
|
|
1938
2069
|
});
|
|
1939
2070
|
}
|
|
1940
2071
|
moveNodeOnTop(e) {
|
|
1941
|
-
if (this.
|
|
1942
|
-
if (this.maxNodePriority++, this.
|
|
2072
|
+
if (this.params.moveOnTop) {
|
|
2073
|
+
if (this.maxNodePriority++, this.params.moveEdgesOnTop) {
|
|
1943
2074
|
const t = this.maxNodePriority;
|
|
1944
2075
|
this.maxNodePriority++, this.graph.getNodeAdjacentEdgeIds(e).forEach((i) => {
|
|
1945
2076
|
this.canvas.updateEdge(i, { priority: t });
|
|
@@ -1949,26 +2080,31 @@ class Z {
|
|
|
1949
2080
|
}
|
|
1950
2081
|
}
|
|
1951
2082
|
cancelMouseDrag() {
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
2083
|
+
if (this.grabbedNode !== null) {
|
|
2084
|
+
const e = this.graph.getNode(this.grabbedNode.nodeId);
|
|
2085
|
+
e !== null && this.params.onNodeDragFinished({
|
|
2086
|
+
nodeId: this.grabbedNode.nodeId,
|
|
2087
|
+
element: e.element,
|
|
2088
|
+
x: e.x,
|
|
2089
|
+
y: e.y
|
|
2090
|
+
});
|
|
2091
|
+
}
|
|
2092
|
+
this.grabbedNode = null, U(this.element, null), this.removeMouseDragListeners();
|
|
1959
2093
|
}
|
|
1960
2094
|
removeMouseDragListeners() {
|
|
1961
2095
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
1962
2096
|
}
|
|
1963
2097
|
cancelTouchDrag() {
|
|
1964
|
-
this.
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
2098
|
+
if (this.grabbedNode !== null) {
|
|
2099
|
+
const e = this.graph.getNode(this.grabbedNode.nodeId);
|
|
2100
|
+
e !== null && this.params.onNodeDragFinished({
|
|
2101
|
+
nodeId: this.grabbedNode.nodeId,
|
|
2102
|
+
element: e.element,
|
|
2103
|
+
x: e.x,
|
|
2104
|
+
y: e.y
|
|
2105
|
+
});
|
|
2106
|
+
}
|
|
2107
|
+
this.grabbedNode = null, this.removeTouchDragListeners();
|
|
1972
2108
|
}
|
|
1973
2109
|
removeTouchDragListeners() {
|
|
1974
2110
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
@@ -1977,6 +2113,24 @@ class Z {
|
|
|
1977
2113
|
const t = this.graph.getNode(e).priority;
|
|
1978
2114
|
this.maxNodePriority = Math.max(this.maxNodePriority, t);
|
|
1979
2115
|
}
|
|
2116
|
+
calculateContentPoint(e) {
|
|
2117
|
+
const t = this.element.getBoundingClientRect(), s = {
|
|
2118
|
+
x: e.x - t.x,
|
|
2119
|
+
y: e.y - t.y
|
|
2120
|
+
}, i = this.canvas.viewport.getViewportMatrix();
|
|
2121
|
+
return D(i, s);
|
|
2122
|
+
}
|
|
2123
|
+
adjustNodeCoords(e) {
|
|
2124
|
+
const t = this.params.gridSize;
|
|
2125
|
+
if (t !== null) {
|
|
2126
|
+
const s = t / 2;
|
|
2127
|
+
return {
|
|
2128
|
+
x: Math.floor((e.x + s) / t) * t,
|
|
2129
|
+
y: Math.floor((e.y + s) / t) * t
|
|
2130
|
+
};
|
|
2131
|
+
}
|
|
2132
|
+
return e;
|
|
2133
|
+
}
|
|
1980
2134
|
}
|
|
1981
2135
|
const ot = (r, e, t) => ({
|
|
1982
2136
|
scale: r.scale,
|
|
@@ -1986,7 +2140,7 @@ const ot = (r, e, t) => ({
|
|
|
1986
2140
|
scale: r.scale * e,
|
|
1987
2141
|
x: r.scale * (1 - e) * t + r.x,
|
|
1988
2142
|
y: r.scale * (1 - e) * s + r.y
|
|
1989
|
-
}),
|
|
2143
|
+
}), I = (r) => {
|
|
1990
2144
|
const e = [], t = r.touches.length;
|
|
1991
2145
|
for (let a = 0; a < t; a++)
|
|
1992
2146
|
e.push([r.touches[a].clientX, r.touches[a].clientY]);
|
|
@@ -2005,17 +2159,17 @@ const ot = (r, e, t) => ({
|
|
|
2005
2159
|
touches: e
|
|
2006
2160
|
};
|
|
2007
2161
|
};
|
|
2008
|
-
class
|
|
2162
|
+
class O {
|
|
2009
2163
|
constructor(e, t, s, i) {
|
|
2010
2164
|
o(this, "viewport");
|
|
2011
2165
|
o(this, "prevTouches", null);
|
|
2012
2166
|
o(this, "wheelFinishTimer", null);
|
|
2013
2167
|
o(this, "transformInProgress", !1);
|
|
2014
2168
|
o(this, "onBeforeDestroy", () => {
|
|
2015
|
-
this.removeMouseDragListeners(), this.removeTouchDragListeners()
|
|
2169
|
+
this.removeMouseDragListeners(), this.removeTouchDragListeners();
|
|
2016
2170
|
});
|
|
2017
2171
|
o(this, "onMouseDown", (e) => {
|
|
2018
|
-
this.element === null || !this.params.mouseDownEventVerifier(e) || (
|
|
2172
|
+
this.element === null || !this.params.mouseDownEventVerifier(e) || (U(this.element, this.params.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
2019
2173
|
passive: !0
|
|
2020
2174
|
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
2021
2175
|
passive: !0
|
|
@@ -2048,10 +2202,10 @@ class F {
|
|
|
2048
2202
|
});
|
|
2049
2203
|
o(this, "onTouchStart", (e) => {
|
|
2050
2204
|
if (this.prevTouches !== null) {
|
|
2051
|
-
this.prevTouches =
|
|
2205
|
+
this.prevTouches = I(e);
|
|
2052
2206
|
return;
|
|
2053
2207
|
}
|
|
2054
|
-
this.prevTouches =
|
|
2208
|
+
this.prevTouches = I(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
2055
2209
|
passive: !0
|
|
2056
2210
|
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
2057
2211
|
passive: !0
|
|
@@ -2060,7 +2214,7 @@ class F {
|
|
|
2060
2214
|
}), this.startRegisteredTransform();
|
|
2061
2215
|
});
|
|
2062
2216
|
o(this, "onWindowTouchMove", (e) => {
|
|
2063
|
-
const t =
|
|
2217
|
+
const t = I(e);
|
|
2064
2218
|
if (!t.touches.every(
|
|
2065
2219
|
(i) => R(this.window, this.element, i[0], i[1])
|
|
2066
2220
|
)) {
|
|
@@ -2077,7 +2231,7 @@ class F {
|
|
|
2077
2231
|
this.prevTouches = t;
|
|
2078
2232
|
});
|
|
2079
2233
|
o(this, "onWindowTouchFinish", (e) => {
|
|
2080
|
-
e.touches.length > 0 ? this.prevTouches =
|
|
2234
|
+
e.touches.length > 0 ? this.prevTouches = I(e) : this.stopTouchDrag();
|
|
2081
2235
|
});
|
|
2082
2236
|
o(this, "observer", new ResizeObserver(() => {
|
|
2083
2237
|
const e = this.viewport.getViewportMatrix(), { width: t, height: s } = this.element.getBoundingClientRect(), i = this.params.transformPreprocessor({
|
|
@@ -2102,7 +2256,7 @@ class F {
|
|
|
2102
2256
|
}), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2103
2257
|
}
|
|
2104
2258
|
static configure(e, t, s, i) {
|
|
2105
|
-
new
|
|
2259
|
+
new O(e, t, s, i);
|
|
2106
2260
|
}
|
|
2107
2261
|
moveViewport(e, t) {
|
|
2108
2262
|
const s = this.viewport.getViewportMatrix(), i = ot(s, e, t), { width: n, height: h } = this.element.getBoundingClientRect(), a = this.params.transformPreprocessor({
|
|
@@ -2123,7 +2277,7 @@ class F {
|
|
|
2123
2277
|
this.performTransform(d);
|
|
2124
2278
|
}
|
|
2125
2279
|
stopMouseDrag() {
|
|
2126
|
-
|
|
2280
|
+
U(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
|
|
2127
2281
|
}
|
|
2128
2282
|
removeMouseDragListeners() {
|
|
2129
2283
|
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
@@ -2167,11 +2321,6 @@ class J {
|
|
|
2167
2321
|
yTo: e.y + e.height
|
|
2168
2322
|
};
|
|
2169
2323
|
});
|
|
2170
|
-
o(this, "onBeforeDestroy", () => {
|
|
2171
|
-
this.trigger.unsubscribe(this.updateLoadedArea), this.canvasResizeObserver.unobserve(this.element), this.canvas.viewport.onAfterUpdated.unsubscribe(
|
|
2172
|
-
this.onAfterViewportUpdated
|
|
2173
|
-
), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2174
|
-
});
|
|
2175
2324
|
o(this, "onAfterViewportUpdated", () => {
|
|
2176
2325
|
this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
|
|
2177
2326
|
});
|
|
@@ -2200,12 +2349,12 @@ class J {
|
|
|
2200
2349
|
this.scheduleLoadAreaAroundViewport(), i.onTransformFinished();
|
|
2201
2350
|
}
|
|
2202
2351
|
};
|
|
2203
|
-
|
|
2352
|
+
O.configure(
|
|
2204
2353
|
e,
|
|
2205
2354
|
this.element,
|
|
2206
2355
|
this.window,
|
|
2207
2356
|
a
|
|
2208
|
-
), this.viewportMatrix = this.viewport.getViewportMatrix(), this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated)
|
|
2357
|
+
), this.viewportMatrix = this.viewport.getViewportMatrix(), this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated);
|
|
2209
2358
|
}
|
|
2210
2359
|
static configure(e, t, s, i, n, h) {
|
|
2211
2360
|
new J(
|
|
@@ -2266,126 +2415,18 @@ class Q {
|
|
|
2266
2415
|
const e = this.canvas.viewport.getContentMatrix(), t = e.x - this.halfTileWidth * e.scale, s = e.y - this.halfTileHeight * e.scale, i = `matrix(${e.scale}, 0, 0, ${e.scale}, ${t}, ${s})`;
|
|
2267
2416
|
this.pattern.setAttribute("patternTransform", i), this.updateVisibility();
|
|
2268
2417
|
});
|
|
2269
|
-
|
|
2270
|
-
this.resizeObserver.unobserve(this.host), this.host.removeChild(this.svg), this.canvas.viewport.onAfterUpdated.unsubscribe(
|
|
2271
|
-
this.onAfterTransformUpdated
|
|
2272
|
-
), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2273
|
-
});
|
|
2274
|
-
this.canvas = e, this.host = s, this.tileWidth = t.tileWidth, this.tileHeight = t.tileHeight, this.halfTileWidth = this.tileWidth / 2, this.halfTileHeight = this.tileHeight / 2, this.patternContent = t.renderer, this.maxViewportScale = t.maxViewportScale;
|
|
2418
|
+
this.canvas = e, this.backgroundHost = s, this.tileWidth = t.tileWidth, this.tileHeight = t.tileHeight, this.halfTileWidth = this.tileWidth / 2, this.halfTileHeight = this.tileHeight / 2, this.patternContent = t.renderer, this.maxViewportScale = t.maxViewportScale;
|
|
2275
2419
|
const i = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
|
|
2276
2420
|
this.patternContent.setAttribute("transform", i), this.pattern.appendChild(this.patternContent);
|
|
2277
2421
|
const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
2278
|
-
n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.resizeObserver.observe(this.
|
|
2422
|
+
n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.resizeObserver.observe(this.backgroundHost), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated();
|
|
2279
2423
|
}
|
|
2280
2424
|
static configure(e, t, s) {
|
|
2281
2425
|
new Q(e, t, s);
|
|
2282
2426
|
}
|
|
2283
2427
|
updateVisibility() {
|
|
2284
2428
|
const t = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
|
|
2285
|
-
t && this.visible ? (this.visible = !1, this.
|
|
2286
|
-
}
|
|
2287
|
-
}
|
|
2288
|
-
class O {
|
|
2289
|
-
constructor(e, t, s, i) {
|
|
2290
|
-
o(this, "onAfterPortMarked", (e) => {
|
|
2291
|
-
const t = this.canvas.graph.getPort(e);
|
|
2292
|
-
this.canvas.graph.getElementPortIds(t.element).length === 1 && this.hookPortEvents(t.element);
|
|
2293
|
-
});
|
|
2294
|
-
o(this, "onBeforePortUnmarked", (e) => {
|
|
2295
|
-
const t = this.canvas.graph.getPort(e);
|
|
2296
|
-
this.canvas.graph.getElementPortIds(t.element).length === 1 && this.unhookPortEvents(t.element);
|
|
2297
|
-
});
|
|
2298
|
-
o(this, "onPortMouseDown", (e) => {
|
|
2299
|
-
if (!this.params.mouseDownEventVerifier(e))
|
|
2300
|
-
return;
|
|
2301
|
-
const t = e.currentTarget, s = this.canvas.graph.getElementPortIds(t)[0];
|
|
2302
|
-
this.params.onPortPointerDown(s, {
|
|
2303
|
-
x: e.clientX,
|
|
2304
|
-
y: e.clientY
|
|
2305
|
-
}) && (e.stopPropagation(), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
2306
|
-
passive: !0
|
|
2307
|
-
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
2308
|
-
passive: !0
|
|
2309
|
-
}));
|
|
2310
|
-
});
|
|
2311
|
-
o(this, "onWindowMouseMove", (e) => {
|
|
2312
|
-
if (!R(
|
|
2313
|
-
this.window,
|
|
2314
|
-
this.element,
|
|
2315
|
-
e.clientX,
|
|
2316
|
-
e.clientY
|
|
2317
|
-
)) {
|
|
2318
|
-
this.stopMouseDrag();
|
|
2319
|
-
return;
|
|
2320
|
-
}
|
|
2321
|
-
this.params.onPointerMove({ x: e.clientX, y: e.clientY });
|
|
2322
|
-
});
|
|
2323
|
-
o(this, "onWindowMouseUp", (e) => {
|
|
2324
|
-
this.params.mouseUpEventVerifier(e) && (this.params.onPointerUp({ x: e.clientX, y: e.clientY }), this.stopMouseDrag());
|
|
2325
|
-
});
|
|
2326
|
-
o(this, "onPortTouchStart", (e) => {
|
|
2327
|
-
if (e.touches.length !== 1)
|
|
2328
|
-
return;
|
|
2329
|
-
const t = e.touches[0], s = e.currentTarget, i = this.canvas.graph.getElementPortIds(s)[0];
|
|
2330
|
-
this.params.onPortPointerDown(i, {
|
|
2331
|
-
x: t.clientX,
|
|
2332
|
-
y: t.clientY
|
|
2333
|
-
}) && (e.stopPropagation(), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
2334
|
-
passive: !0
|
|
2335
|
-
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
2336
|
-
passive: !0
|
|
2337
|
-
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
2338
|
-
passive: !0
|
|
2339
|
-
}));
|
|
2340
|
-
});
|
|
2341
|
-
o(this, "onWindowTouchMove", (e) => {
|
|
2342
|
-
const t = e.touches[0];
|
|
2343
|
-
if (!R(
|
|
2344
|
-
this.window,
|
|
2345
|
-
this.element,
|
|
2346
|
-
t.clientX,
|
|
2347
|
-
t.clientY
|
|
2348
|
-
)) {
|
|
2349
|
-
this.stopTouchDrag();
|
|
2350
|
-
return;
|
|
2351
|
-
}
|
|
2352
|
-
this.params.onPointerMove({ x: t.clientX, y: t.clientY });
|
|
2353
|
-
});
|
|
2354
|
-
o(this, "onWindowTouchFinish", (e) => {
|
|
2355
|
-
const t = e.changedTouches[0];
|
|
2356
|
-
this.params.onPointerUp({ x: t.clientX, y: t.clientY }), this.stopTouchDrag();
|
|
2357
|
-
});
|
|
2358
|
-
o(this, "onBeforeClear", () => {
|
|
2359
|
-
this.canvas.graph.getAllPortIds().forEach((e) => {
|
|
2360
|
-
const t = this.canvas.graph.getPort(e);
|
|
2361
|
-
this.unhookPortEvents(t.element);
|
|
2362
|
-
});
|
|
2363
|
-
});
|
|
2364
|
-
o(this, "onBeforeDestroy", () => {
|
|
2365
|
-
this.stopMouseDrag(), this.stopTouchDrag(), this.canvas.graph.onAfterPortMarked.unsubscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.unsubscribe(
|
|
2366
|
-
this.onBeforePortUnmarked
|
|
2367
|
-
), this.canvas.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2368
|
-
});
|
|
2369
|
-
this.canvas = e, this.element = t, this.window = s, this.params = i, 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);
|
|
2370
|
-
}
|
|
2371
|
-
static configure(e, t, s, i) {
|
|
2372
|
-
new O(e, t, s, i);
|
|
2373
|
-
}
|
|
2374
|
-
hookPortEvents(e) {
|
|
2375
|
-
e.addEventListener("mousedown", this.onPortMouseDown, {
|
|
2376
|
-
passive: !0
|
|
2377
|
-
}), e.addEventListener("touchstart", this.onPortTouchStart, {
|
|
2378
|
-
passive: !0
|
|
2379
|
-
});
|
|
2380
|
-
}
|
|
2381
|
-
unhookPortEvents(e) {
|
|
2382
|
-
e.removeEventListener("mousedown", this.onPortMouseDown), e.removeEventListener("touchstart", this.onPortTouchStart);
|
|
2383
|
-
}
|
|
2384
|
-
stopMouseDrag() {
|
|
2385
|
-
this.params.onStopDrag(), this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
2386
|
-
}
|
|
2387
|
-
stopTouchDrag() {
|
|
2388
|
-
this.params.onStopDrag(), this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
2429
|
+
t && this.visible ? (this.visible = !1, this.backgroundHost.removeChild(this.svg)) : !t && !this.visible && (this.visible = !0, this.backgroundHost.appendChild(this.svg));
|
|
2389
2430
|
}
|
|
2390
2431
|
}
|
|
2391
2432
|
class _ {
|
|
@@ -2399,7 +2440,7 @@ class _ {
|
|
|
2399
2440
|
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = i, this.params = n, this.overlayCanvas = Ne(
|
|
2400
2441
|
this.overlayLayer,
|
|
2401
2442
|
this.viewportStore
|
|
2402
|
-
),
|
|
2443
|
+
), F.configure(
|
|
2403
2444
|
this.canvas,
|
|
2404
2445
|
this.overlayLayer,
|
|
2405
2446
|
this.window,
|
|
@@ -2434,10 +2475,10 @@ class _ {
|
|
|
2434
2475
|
grabPort(e, t, s) {
|
|
2435
2476
|
const i = this.canvas.graph.getPort(e);
|
|
2436
2477
|
this.staticPortId = e;
|
|
2437
|
-
const n = i.element.getBoundingClientRect(), h = n.x + n.width / 2, a = n.y + n.height / 2, d = this.overlayLayer.getBoundingClientRect(), c = this.canvas.viewport.getViewportMatrix(), l =
|
|
2478
|
+
const n = i.element.getBoundingClientRect(), h = n.x + n.width / 2, a = n.y + n.height / 2, d = this.overlayLayer.getBoundingClientRect(), c = this.canvas.viewport.getViewportMatrix(), l = D(c, {
|
|
2438
2479
|
x: h - d.x,
|
|
2439
2480
|
y: a - d.y
|
|
2440
|
-
}), g =
|
|
2481
|
+
}), g = D(c, {
|
|
2441
2482
|
x: t.x - d.x,
|
|
2442
2483
|
y: t.y - d.y
|
|
2443
2484
|
}), p = {
|
|
@@ -2450,10 +2491,10 @@ class _ {
|
|
|
2450
2491
|
portDirection: this.params.dragPortDirection
|
|
2451
2492
|
};
|
|
2452
2493
|
this.isTargetDragging = s === "direct";
|
|
2453
|
-
const [
|
|
2454
|
-
this.overlayCanvas.addNode(B(
|
|
2455
|
-
from:
|
|
2456
|
-
to:
|
|
2494
|
+
const [m, v] = this.isTargetDragging ? [p, f] : [f, p];
|
|
2495
|
+
this.overlayCanvas.addNode(B(m)), this.overlayCanvas.addNode(B(v)), this.overlayCanvas.addEdge({
|
|
2496
|
+
from: m.overlayId,
|
|
2497
|
+
to: v.overlayId,
|
|
2457
2498
|
shape: this.params.edgeShapeFactory(P.Edge)
|
|
2458
2499
|
});
|
|
2459
2500
|
}
|
|
@@ -2461,7 +2502,7 @@ class _ {
|
|
|
2461
2502
|
this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
|
|
2462
2503
|
}
|
|
2463
2504
|
tryCreateConnection(e) {
|
|
2464
|
-
const t =
|
|
2505
|
+
const t = ye(this.canvas.graph, e);
|
|
2465
2506
|
if (t === null) {
|
|
2466
2507
|
this.params.onEdgeCreationInterrupted(
|
|
2467
2508
|
this.staticPortId,
|
|
@@ -2476,7 +2517,7 @@ class _ {
|
|
|
2476
2517
|
const t = this.overlayLayer.getBoundingClientRect(), s = {
|
|
2477
2518
|
x: e.x - t.x,
|
|
2478
2519
|
y: e.y - t.y
|
|
2479
|
-
}, i = this.canvas.viewport.getViewportMatrix(), n =
|
|
2520
|
+
}, i = this.canvas.viewport.getViewportMatrix(), n = D(i, s);
|
|
2480
2521
|
this.overlayCanvas.updateNode(P.Dragging, {
|
|
2481
2522
|
x: n.x,
|
|
2482
2523
|
y: n.y
|
|
@@ -2495,7 +2536,7 @@ class q {
|
|
|
2495
2536
|
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = i, this.params = n, this.overlayCanvas = Ne(
|
|
2496
2537
|
this.overlayLayer,
|
|
2497
2538
|
this.viewportStore
|
|
2498
|
-
),
|
|
2539
|
+
), F.configure(
|
|
2499
2540
|
this.canvas,
|
|
2500
2541
|
this.overlayLayer,
|
|
2501
2542
|
this.window,
|
|
@@ -2536,10 +2577,10 @@ class q {
|
|
|
2536
2577
|
const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(a), l = c.element.getBoundingClientRect(), g = {
|
|
2537
2578
|
x: l.x + l.width / 2,
|
|
2538
2579
|
y: l.y + l.height / 2
|
|
2539
|
-
}, p = this.canvas.viewport.getViewportMatrix(), f = this.overlayLayer.getBoundingClientRect(),
|
|
2580
|
+
}, p = this.canvas.viewport.getViewportMatrix(), f = this.overlayLayer.getBoundingClientRect(), m = D(p, {
|
|
2540
2581
|
x: g.x - f.x,
|
|
2541
2582
|
y: g.y - f.y
|
|
2542
|
-
}),
|
|
2583
|
+
}), v = D(p, {
|
|
2543
2584
|
x: t.x - f.x,
|
|
2544
2585
|
y: t.y - f.y
|
|
2545
2586
|
});
|
|
@@ -2552,19 +2593,19 @@ class q {
|
|
|
2552
2593
|
}, this.canvas.removeEdge(s);
|
|
2553
2594
|
const E = {
|
|
2554
2595
|
overlayId: P.Static,
|
|
2555
|
-
portCoords:
|
|
2596
|
+
portCoords: m,
|
|
2556
2597
|
portDirection: c.direction
|
|
2557
2598
|
}, x = {
|
|
2558
2599
|
overlayId: P.Dragging,
|
|
2559
|
-
portCoords:
|
|
2600
|
+
portCoords: v,
|
|
2560
2601
|
portDirection: d.direction
|
|
2561
|
-
}, [b,
|
|
2562
|
-
this.overlayCanvas.addNode(B(b)), this.overlayCanvas.addNode(B(
|
|
2602
|
+
}, [b, T] = this.isTargetDragging ? [E, x] : [x, E];
|
|
2603
|
+
this.overlayCanvas.addNode(B(b)), this.overlayCanvas.addNode(B(T));
|
|
2563
2604
|
const N = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(P.Edge) : i.shape;
|
|
2564
2605
|
return this.overlayCanvas.addEdge({
|
|
2565
2606
|
id: P.Edge,
|
|
2566
2607
|
from: b.overlayId,
|
|
2567
|
-
to:
|
|
2608
|
+
to: T.overlayId,
|
|
2568
2609
|
shape: N
|
|
2569
2610
|
}), !0;
|
|
2570
2611
|
}
|
|
@@ -2575,14 +2616,14 @@ class q {
|
|
|
2575
2616
|
const t = this.overlayLayer.getBoundingClientRect(), s = {
|
|
2576
2617
|
x: e.x - t.x,
|
|
2577
2618
|
y: e.y - t.y
|
|
2578
|
-
}, i = this.canvas.viewport.getViewportMatrix(), n =
|
|
2619
|
+
}, i = this.canvas.viewport.getViewportMatrix(), n = D(i, s);
|
|
2579
2620
|
this.overlayCanvas.updateNode(P.Dragging, {
|
|
2580
2621
|
x: n.x,
|
|
2581
2622
|
y: n.y
|
|
2582
2623
|
});
|
|
2583
2624
|
}
|
|
2584
2625
|
tryCreateConnection(e) {
|
|
2585
|
-
const t =
|
|
2626
|
+
const t = ye(this.canvas.graph, e);
|
|
2586
2627
|
if (this.overlayCanvas.removeEdge(P.Edge), t === null) {
|
|
2587
2628
|
const d = this.draggingEdgePayload;
|
|
2588
2629
|
this.params.onEdgeReattachInterrupted({
|
|
@@ -2618,17 +2659,17 @@ class q {
|
|
|
2618
2659
|
const at = () => {
|
|
2619
2660
|
const r = document.createElement("div");
|
|
2620
2661
|
return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
|
|
2621
|
-
},
|
|
2662
|
+
}, H = () => {
|
|
2622
2663
|
const r = document.createElement("div");
|
|
2623
2664
|
return r.style.position = "absolute", r.style.inset = "0", r;
|
|
2624
2665
|
}, ce = () => {
|
|
2625
|
-
const r =
|
|
2666
|
+
const r = H();
|
|
2626
2667
|
return r.style.pointerEvents = "none", r;
|
|
2627
2668
|
};
|
|
2628
2669
|
class dt {
|
|
2629
2670
|
constructor(e) {
|
|
2630
|
-
o(this, "background",
|
|
2631
|
-
o(this, "main",
|
|
2671
|
+
o(this, "background", H());
|
|
2672
|
+
o(this, "main", H());
|
|
2632
2673
|
o(this, "overlayConnectablePorts", ce());
|
|
2633
2674
|
o(this, "overlayDraggableEdges", ce());
|
|
2634
2675
|
o(this, "host", at());
|
|
@@ -2638,13 +2679,13 @@ class dt {
|
|
|
2638
2679
|
this.host.removeChild(this.background), this.host.removeChild(this.main), this.host.removeChild(this.overlayConnectablePorts), this.host.removeChild(this.overlayDraggableEdges), this.element.removeChild(this.host);
|
|
2639
2680
|
}
|
|
2640
2681
|
}
|
|
2641
|
-
const
|
|
2682
|
+
const X = (r) => () => r, ge = X(0), ct = () => {
|
|
2642
2683
|
let r = 0;
|
|
2643
2684
|
return () => r++;
|
|
2644
2685
|
}, gt = (r, e) => {
|
|
2645
2686
|
let t = ge, s = ge;
|
|
2646
2687
|
const i = ct();
|
|
2647
|
-
return r === "incremental" && (t = i), e === "incremental" && (s = i), typeof r == "number" && (t =
|
|
2688
|
+
return r === "incremental" && (t = i), e === "incremental" && (s = i), typeof r == "number" && (t = X(r)), typeof e == "number" && (s = X(e)), typeof r == "function" && (t = r), typeof e == "function" && (s = e), {
|
|
2648
2689
|
nodesPriorityFn: t,
|
|
2649
2690
|
edgesPriorityFn: s
|
|
2650
2691
|
};
|
|
@@ -2728,7 +2769,7 @@ const Y = (r) => () => r, ge = Y(0), ct = () => {
|
|
|
2728
2769
|
);
|
|
2729
2770
|
return {
|
|
2730
2771
|
nodes: {
|
|
2731
|
-
centerFn: ((i = r.nodes) == null ? void 0 : i.centerFn) ??
|
|
2772
|
+
centerFn: ((i = r.nodes) == null ? void 0 : i.centerFn) ?? ve,
|
|
2732
2773
|
priorityFn: e.nodesPriorityFn
|
|
2733
2774
|
},
|
|
2734
2775
|
ports: {
|
|
@@ -2740,16 +2781,17 @@ const Y = (r) => () => r, ge = Y(0), ct = () => {
|
|
|
2740
2781
|
}
|
|
2741
2782
|
};
|
|
2742
2783
|
}, ut = (r) => {
|
|
2743
|
-
var p, f,
|
|
2744
|
-
const e = ((p = r
|
|
2745
|
-
}), t = ((f = r
|
|
2746
|
-
}), i =
|
|
2784
|
+
var p, f, m, v, E, x;
|
|
2785
|
+
const e = ((p = r.events) == null ? void 0 : p.onNodeDrag) ?? (() => {
|
|
2786
|
+
}), t = ((f = r.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), s = ((m = r.events) == null ? void 0 : m.onNodeDragFinished) ?? (() => {
|
|
2787
|
+
}), i = r.moveOnTop !== !1, n = r.moveEdgesOnTop !== !1 && i, h = (v = r.mouse) == null ? void 0 : v.dragCursor, a = h !== void 0 ? h : "grab", d = (E = r.mouse) == null ? void 0 : E.mouseDownEventVerifier, c = d !== void 0 ? d : (b) => b.button === 0, l = (x = r.mouse) == null ? void 0 : x.mouseUpEventVerifier, g = l !== void 0 ? l : (b) => b.button === 0;
|
|
2747
2788
|
return {
|
|
2748
2789
|
moveOnTop: i,
|
|
2749
2790
|
moveEdgesOnTop: n,
|
|
2750
2791
|
dragCursor: a,
|
|
2792
|
+
gridSize: r.gridSize ?? null,
|
|
2751
2793
|
mouseDownEventVerifier: c,
|
|
2752
|
-
mouseUpEventVerifier:
|
|
2794
|
+
mouseUpEventVerifier: g,
|
|
2753
2795
|
onNodeDrag: e,
|
|
2754
2796
|
onBeforeNodeDrag: t,
|
|
2755
2797
|
onNodeDragFinished: s
|
|
@@ -2811,17 +2853,17 @@ const Y = (r) => () => r, ge = Y(0), ct = () => {
|
|
|
2811
2853
|
});
|
|
2812
2854
|
}
|
|
2813
2855
|
}, ue = (r) => {
|
|
2814
|
-
var
|
|
2815
|
-
const e = (
|
|
2856
|
+
var m, v, E, x, b, T, N, C, te, re, oe, se;
|
|
2857
|
+
const e = (m = r == null ? void 0 : r.scale) == null ? void 0 : m.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
|
|
2816
2858
|
let i;
|
|
2817
2859
|
s !== void 0 ? Array.isArray(s) ? i = ft(
|
|
2818
2860
|
s.map(
|
|
2819
2861
|
(M) => le(M)
|
|
2820
2862
|
)
|
|
2821
2863
|
) : i = le(s) : i = (M) => M.nextTransform;
|
|
2822
|
-
const n = ((
|
|
2864
|
+
const n = ((v = r == null ? void 0 : r.shift) == null ? void 0 : v.cursor) !== void 0 ? r.shift.cursor : "grab", h = ((E = r == null ? void 0 : r.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
|
|
2823
2865
|
}), a = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onTransformChange) ?? (() => {
|
|
2824
|
-
}), d = (b = r == null ? void 0 : r.shift) == null ? void 0 : b.mouseDownEventVerifier, c = d !== void 0 ? d : (M) => M.button === 0, l = (
|
|
2866
|
+
}), d = (b = r == null ? void 0 : r.shift) == null ? void 0 : b.mouseDownEventVerifier, c = d !== void 0 ? d : (M) => M.button === 0, l = (T = r == null ? void 0 : r.shift) == null ? void 0 : T.mouseUpEventVerifier, g = l !== void 0 ? l : (M) => M.button === 0, p = (N = r == null ? void 0 : r.scale) == null ? void 0 : N.mouseWheelEventVerifier, f = p !== void 0 ? p : () => !0;
|
|
2825
2867
|
return {
|
|
2826
2868
|
wheelSensitivity: t,
|
|
2827
2869
|
onTransformStarted: ((C = r == null ? void 0 : r.events) == null ? void 0 : C.onTransformStarted) ?? (() => {
|
|
@@ -2841,17 +2883,17 @@ const Y = (r) => () => r, ge = Y(0), ct = () => {
|
|
|
2841
2883
|
onResizeTransformFinished: ((se = r == null ? void 0 : r.events) == null ? void 0 : se.onResizeTransformFinished) ?? (() => {
|
|
2842
2884
|
})
|
|
2843
2885
|
};
|
|
2844
|
-
},
|
|
2886
|
+
}, mt = (r, e) => {
|
|
2845
2887
|
const t = document.createElementNS(
|
|
2846
2888
|
"http://www.w3.org/2000/svg",
|
|
2847
2889
|
"circle"
|
|
2848
2890
|
);
|
|
2849
2891
|
return t.setAttribute("cx", "0"), t.setAttribute("cy", "0"), t.setAttribute("r", `${r}`), t.setAttribute("fill", `${e}`), t;
|
|
2850
|
-
},
|
|
2892
|
+
}, yt = (r) => r instanceof SVGElement ? r : mt(
|
|
2851
2893
|
(r == null ? void 0 : r.radius) ?? 1.5,
|
|
2852
2894
|
(r == null ? void 0 : r.color) ?? "#d8d8d8"
|
|
2853
|
-
),
|
|
2854
|
-
const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, s = (e == null ? void 0 : e.height) ?? 25, i =
|
|
2895
|
+
), vt = (r) => {
|
|
2896
|
+
const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, s = (e == null ? void 0 : e.height) ?? 25, i = yt(r.renderer ?? {});
|
|
2855
2897
|
return {
|
|
2856
2898
|
tileWidth: t,
|
|
2857
2899
|
tileHeight: s,
|
|
@@ -2918,7 +2960,7 @@ class Tt {
|
|
|
2918
2960
|
o(this, "virtualScrollConfig");
|
|
2919
2961
|
o(this, "hasDraggableNode", !1);
|
|
2920
2962
|
o(this, "hasTransformableViewport", !1);
|
|
2921
|
-
o(this, "
|
|
2963
|
+
o(this, "hasNodeResizeReactiveEdges", !1);
|
|
2922
2964
|
o(this, "hasBackground", !1);
|
|
2923
2965
|
o(this, "hasUserConnectablePorts", !1);
|
|
2924
2966
|
o(this, "hasUserDraggableEdges", !1);
|
|
@@ -2952,10 +2994,17 @@ class Tt {
|
|
|
2952
2994
|
return this.hasTransformableViewport = !0, this.transformConfig = e ?? {}, this;
|
|
2953
2995
|
}
|
|
2954
2996
|
/**
|
|
2955
|
-
*
|
|
2997
|
+
* @deprecated
|
|
2998
|
+
* use enableNodeResizeReactiveEdges instead
|
|
2956
2999
|
*/
|
|
2957
3000
|
enableResizeReactiveNodes() {
|
|
2958
|
-
return this.
|
|
3001
|
+
return this.hasNodeResizeReactiveEdges = !0, this;
|
|
3002
|
+
}
|
|
3003
|
+
/**
|
|
3004
|
+
* enables automatic edges update on node resize
|
|
3005
|
+
*/
|
|
3006
|
+
enableNodeResizeReactiveEdges() {
|
|
3007
|
+
return this.hasNodeResizeReactiveEdges = !0, this;
|
|
2959
3008
|
}
|
|
2960
3009
|
/**
|
|
2961
3010
|
* @deprecated
|
|
@@ -2997,13 +3046,13 @@ class Tt {
|
|
|
2997
3046
|
);
|
|
2998
3047
|
let e = this.boxRenderingTrigger;
|
|
2999
3048
|
this.virtualScrollConfig !== void 0 && e === void 0 && (e = new we());
|
|
3000
|
-
const t = new
|
|
3049
|
+
const t = new me(), s = new Fe(), i = new dt(this.element);
|
|
3001
3050
|
let n = new pe(
|
|
3002
3051
|
t,
|
|
3003
3052
|
s,
|
|
3004
3053
|
i.main
|
|
3005
3054
|
);
|
|
3006
|
-
e !== void 0 && (n = new
|
|
3055
|
+
e !== void 0 && (n = new Ue(
|
|
3007
3056
|
n,
|
|
3008
3057
|
t,
|
|
3009
3058
|
e,
|
|
@@ -3018,9 +3067,9 @@ class Tt {
|
|
|
3018
3067
|
);
|
|
3019
3068
|
if (this.hasBackground && Q.configure(
|
|
3020
3069
|
a,
|
|
3021
|
-
|
|
3070
|
+
vt(this.backgroundConfig),
|
|
3022
3071
|
i.background
|
|
3023
|
-
), this.
|
|
3072
|
+
), this.hasNodeResizeReactiveEdges && Y.configure(a), this.hasDraggableNode && Z.configure(
|
|
3024
3073
|
a,
|
|
3025
3074
|
i.main,
|
|
3026
3075
|
this.window,
|
|
@@ -3059,7 +3108,7 @@ class Tt {
|
|
|
3059
3108
|
ue(this.transformConfig),
|
|
3060
3109
|
e,
|
|
3061
3110
|
xt(this.virtualScrollConfig)
|
|
3062
|
-
) : this.hasTransformableViewport &&
|
|
3111
|
+
) : this.hasTransformableViewport && O.configure(
|
|
3063
3112
|
a,
|
|
3064
3113
|
i.main,
|
|
3065
3114
|
this.window,
|
|
@@ -3075,7 +3124,7 @@ class Tt {
|
|
|
3075
3124
|
* CanvasBuilder should be single use object
|
|
3076
3125
|
*/
|
|
3077
3126
|
reset() {
|
|
3078
|
-
this.element = null, this.canvasDefaults = {}, this.dragConfig = {}, this.transformConfig = {}, this.backgroundConfig = {}, this.virtualScrollConfig = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.
|
|
3127
|
+
this.element = null, this.canvasDefaults = {}, this.dragConfig = {}, this.transformConfig = {}, this.backgroundConfig = {}, this.virtualScrollConfig = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.hasNodeResizeReactiveEdges = !1, this.hasBackground = !1, this.boxRenderingTrigger = void 0, this.hasUserConnectablePorts = !1;
|
|
3079
3128
|
}
|
|
3080
3129
|
}
|
|
3081
3130
|
export {
|