@html-graph/html-graph 3.15.0 → 3.16.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.js +188 -187
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/html-graph.js
CHANGED
|
@@ -51,8 +51,8 @@ class ue {
|
|
|
51
51
|
this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.element.removeChild(this.host), this.host.removeChild(this.container);
|
|
52
52
|
}
|
|
53
53
|
updateNodePosition(e) {
|
|
54
|
-
const t = this.graphStore.getNode(e), { width: s, height: i } = t.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale,
|
|
55
|
-
t.element.style.transform = `translate(${
|
|
54
|
+
const t = this.graphStore.getNode(e), { width: s, height: i } = t.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, h = t.centerFn(s, i), a = t.x - n * h.x, d = t.y - n * h.y;
|
|
55
|
+
t.element.style.transform = `translate(${a}px, ${d}px)`;
|
|
56
56
|
}
|
|
57
57
|
updateNodePriority(e) {
|
|
58
58
|
const t = this.graphStore.getNode(e);
|
|
@@ -65,17 +65,17 @@ class ue {
|
|
|
65
65
|
this.edgeIdToElementMap.set(e, s.shape.svg), this.container.appendChild(s.shape.svg);
|
|
66
66
|
}
|
|
67
67
|
renderEdge(e) {
|
|
68
|
-
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), i = this.graphStore.getPort(t.to), n = s.element.getBoundingClientRect(),
|
|
68
|
+
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), i = this.graphStore.getPort(t.to), n = s.element.getBoundingClientRect(), h = i.element.getBoundingClientRect(), a = this.host.getBoundingClientRect(), d = this.viewportStore.getViewportMatrix(), c = this.createEdgeRenderPort(
|
|
69
69
|
t.from,
|
|
70
70
|
s,
|
|
71
71
|
n,
|
|
72
|
-
|
|
72
|
+
a,
|
|
73
73
|
d
|
|
74
74
|
), l = this.createEdgeRenderPort(
|
|
75
75
|
t.to,
|
|
76
76
|
i,
|
|
77
|
-
a,
|
|
78
77
|
h,
|
|
78
|
+
a,
|
|
79
79
|
d
|
|
80
80
|
);
|
|
81
81
|
t.shape.render({ from: c, to: l });
|
|
@@ -85,13 +85,13 @@ class ue {
|
|
|
85
85
|
t.shape.svg.style.zIndex = `${t.priority}`;
|
|
86
86
|
}
|
|
87
87
|
createEdgeRenderPort(e, t, s, i, n) {
|
|
88
|
-
const
|
|
88
|
+
const h = {
|
|
89
89
|
x: s.left - i.left,
|
|
90
90
|
y: s.top - i.top
|
|
91
|
-
},
|
|
91
|
+
}, a = T(n, h);
|
|
92
92
|
return {
|
|
93
|
-
x:
|
|
94
|
-
y:
|
|
93
|
+
x: a.x,
|
|
94
|
+
y: a.y,
|
|
95
95
|
width: s.width * n.scale,
|
|
96
96
|
height: s.height * n.scale,
|
|
97
97
|
direction: t.direction,
|
|
@@ -116,8 +116,8 @@ class Ie {
|
|
|
116
116
|
return t.x >= this.xFrom && t.x <= this.xTo && t.y >= this.yFrom && t.y <= this.yTo;
|
|
117
117
|
}
|
|
118
118
|
hasEdge(e) {
|
|
119
|
-
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from).nodeId, i = this.graphStore.getPort(t.to).nodeId, n = this.graphStore.getNode(s),
|
|
120
|
-
return
|
|
119
|
+
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from).nodeId, i = this.graphStore.getPort(t.to).nodeId, n = this.graphStore.getNode(s), h = this.graphStore.getNode(i), a = Math.min(n.x, h.x), d = Math.max(n.x, h.x), c = Math.min(n.y, h.y), l = Math.max(n.y, h.y);
|
|
120
|
+
return a <= this.xTo && d >= this.xFrom && c <= this.yTo && l >= this.yFrom;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
class Ue {
|
|
@@ -128,20 +128,20 @@ class Ue {
|
|
|
128
128
|
o(this, "updateViewport", (e) => {
|
|
129
129
|
this.renderingBox.setRenderingBox(e);
|
|
130
130
|
const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
131
|
-
this.graphStore.getAllNodeIds().forEach((
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
}), this.graphStore.getAllEdgeIds().forEach((
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
}), n.forEach((
|
|
138
|
-
this.handleDetachEdge(
|
|
139
|
-
}), s.forEach((
|
|
140
|
-
this.handleDetachNode(
|
|
141
|
-
}), t.forEach((
|
|
142
|
-
this.attachedNodes.has(
|
|
143
|
-
}), i.forEach((
|
|
144
|
-
this.handleAttachEdge(
|
|
131
|
+
this.graphStore.getAllNodeIds().forEach((h) => {
|
|
132
|
+
const a = this.renderingBox.hasNode(h), d = this.attachedNodes.has(h);
|
|
133
|
+
a && !d ? t.add(h) : !a && d && s.add(h);
|
|
134
|
+
}), this.graphStore.getAllEdgeIds().forEach((h) => {
|
|
135
|
+
const a = this.renderingBox.hasEdge(h), d = this.attachedEdges.has(h), c = this.graphStore.getEdge(h), l = this.graphStore.getPort(c.from).nodeId, g = this.graphStore.getPort(c.to).nodeId;
|
|
136
|
+
a && (this.renderingBox.hasNode(l) || (t.add(l), s.delete(l)), this.renderingBox.hasNode(g) || (t.add(g), s.delete(g))), a && !d ? i.add(h) : !a && d && n.add(h);
|
|
137
|
+
}), n.forEach((h) => {
|
|
138
|
+
this.handleDetachEdge(h);
|
|
139
|
+
}), s.forEach((h) => {
|
|
140
|
+
this.handleDetachNode(h);
|
|
141
|
+
}), t.forEach((h) => {
|
|
142
|
+
this.attachedNodes.has(h) || this.handleAttachNode(h);
|
|
143
|
+
}), i.forEach((h) => {
|
|
144
|
+
this.handleAttachEdge(h);
|
|
145
145
|
});
|
|
146
146
|
});
|
|
147
147
|
this.htmlView = e, this.graphStore = t, this.trigger = s, this.renderingBox = new Ie(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
@@ -880,8 +880,8 @@ class Y {
|
|
|
880
880
|
}
|
|
881
881
|
}
|
|
882
882
|
const Fe = (r, e, t) => {
|
|
883
|
-
const { x: s, y: i, width: n, height:
|
|
884
|
-
return e >= s && e <= s + n && t >= i && t <= i +
|
|
883
|
+
const { x: s, y: i, width: n, height: h } = r.getBoundingClientRect();
|
|
884
|
+
return e >= s && e <= s + n && t >= i && t <= i + h;
|
|
885
885
|
}, Oe = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, L = (r, e, t, s) => Fe(e, t, s) && Oe(r, t, s), U = (r, e) => {
|
|
886
886
|
e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
|
|
887
887
|
}, V = (r) => {
|
|
@@ -942,11 +942,11 @@ class ze {
|
|
|
942
942
|
), n = {
|
|
943
943
|
x: s.x + this.params.sourceDirection.x * this.params.curvature,
|
|
944
944
|
y: s.y + this.params.sourceDirection.y * this.params.curvature
|
|
945
|
-
},
|
|
945
|
+
}, h = {
|
|
946
946
|
x: i.x - this.params.targetDirection.x * this.params.curvature,
|
|
947
947
|
y: i.y - this.params.targetDirection.y * this.params.curvature
|
|
948
|
-
},
|
|
949
|
-
this.path = `${d}${
|
|
948
|
+
}, a = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${h.x} ${h.y}, ${i.x} ${i.y}`, d = this.params.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${s.x} ${s.y} `, c = this.params.hasTargetArrow ? "" : ` M ${i.x} ${i.y} L ${this.params.to.x} ${this.params.to.y}`;
|
|
949
|
+
this.path = `${d}${a}${c}`;
|
|
950
950
|
}
|
|
951
951
|
}
|
|
952
952
|
const ye = (r, e, t, s) => ({
|
|
@@ -969,19 +969,19 @@ class Xe {
|
|
|
969
969
|
},
|
|
970
970
|
this.params.targetDirection,
|
|
971
971
|
this.params.to
|
|
972
|
-
) : this.params.to, i = this.params.arrowLength, n = Math.cos(this.params.detourDirection) * this.params.detourDistance,
|
|
972
|
+
) : 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 = m(
|
|
973
973
|
{ x: i, y: w.y },
|
|
974
974
|
this.params.sourceDirection,
|
|
975
975
|
w
|
|
976
976
|
), l = {
|
|
977
|
-
x: c.x +
|
|
977
|
+
x: c.x + a,
|
|
978
978
|
y: c.y + d
|
|
979
979
|
}, g = m(
|
|
980
980
|
{ x: this.params.to.x - i, y: this.params.to.y },
|
|
981
981
|
this.params.targetDirection,
|
|
982
982
|
this.params.to
|
|
983
983
|
), p = {
|
|
984
|
-
x: g.x +
|
|
984
|
+
x: g.x + a,
|
|
985
985
|
y: g.y + d
|
|
986
986
|
}, f = {
|
|
987
987
|
x: (l.x + p.x) / 2,
|
|
@@ -993,10 +993,10 @@ class Xe {
|
|
|
993
993
|
x: g.x - this.params.curvature * this.params.targetDirection.x,
|
|
994
994
|
y: g.y - this.params.curvature * this.params.targetDirection.y
|
|
995
995
|
}, E = {
|
|
996
|
-
x: c.x +
|
|
996
|
+
x: c.x + a,
|
|
997
997
|
y: c.y + d
|
|
998
998
|
}, x = {
|
|
999
|
-
x: g.x +
|
|
999
|
+
x: g.x + a,
|
|
1000
1000
|
y: g.y + d
|
|
1001
1001
|
};
|
|
1002
1002
|
this.path = [
|
|
@@ -1012,17 +1012,17 @@ const C = (r, e) => {
|
|
|
1012
1012
|
const t = [];
|
|
1013
1013
|
if (r.length > 0 && t.push(`M ${r[0].x} ${r[0].y}`), r.length === 2 && t.push(`L ${r[1].x} ${r[1].y}`), r.length > 2) {
|
|
1014
1014
|
const s = r.length - 1;
|
|
1015
|
-
let i = 0, n = 0,
|
|
1016
|
-
r.forEach((
|
|
1015
|
+
let i = 0, n = 0, h = 0;
|
|
1016
|
+
r.forEach((a, d) => {
|
|
1017
1017
|
let c = 0, l = 0, g = 0;
|
|
1018
1018
|
const p = d > 0, f = d < s, v = p && f;
|
|
1019
|
-
if (p && (c = -i, l = -n, g =
|
|
1019
|
+
if (p && (c = -i, l = -n, g = h), f) {
|
|
1020
1020
|
const R = r[d + 1];
|
|
1021
|
-
i = R.x -
|
|
1021
|
+
i = R.x - a.x, n = R.y - a.y, h = Math.sqrt(i * i + n * n);
|
|
1022
1022
|
}
|
|
1023
|
-
const E =
|
|
1023
|
+
const E = h !== 0 ? Math.min((v ? e : 0) / h, d < s - 1 ? 0.5 : 1) : 0, x = v ? { x: a.x + i * E, y: a.y + n * E } : a, D = g !== 0 ? Math.min((v ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, N = v ? { x: a.x + c * D, y: a.y + l * D } : a;
|
|
1024
1024
|
d > 0 && t.push(`L ${N.x} ${N.y}`), v && t.push(
|
|
1025
|
-
`C ${
|
|
1025
|
+
`C ${a.x} ${a.y} ${a.x} ${a.y} ${x.x} ${x.y}`
|
|
1026
1026
|
);
|
|
1027
1027
|
});
|
|
1028
1028
|
}
|
|
@@ -1046,23 +1046,23 @@ class Ye {
|
|
|
1046
1046
|
},
|
|
1047
1047
|
this.params.targetDirection,
|
|
1048
1048
|
this.params.to
|
|
1049
|
-
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset,
|
|
1050
|
-
{ x:
|
|
1049
|
+
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = n - this.params.roundness, a = m(
|
|
1050
|
+
{ x: h, y: w.y },
|
|
1051
1051
|
this.params.sourceDirection,
|
|
1052
1052
|
w
|
|
1053
1053
|
), d = m(
|
|
1054
|
-
{ x: this.params.to.x -
|
|
1054
|
+
{ x: this.params.to.x - h, y: this.params.to.y },
|
|
1055
1055
|
this.params.targetDirection,
|
|
1056
1056
|
this.params.to
|
|
1057
|
-
), c = Math.max((
|
|
1057
|
+
), c = Math.max((a.x + d.x) / 2, n), l = this.params.to.y / 2, g = {
|
|
1058
1058
|
x: this.params.flipX > 0 ? c : -n,
|
|
1059
|
-
y:
|
|
1059
|
+
y: a.y
|
|
1060
1060
|
}, p = { x: g.x, y: l }, f = {
|
|
1061
1061
|
x: this.params.flipX > 0 ? this.params.to.x - c : this.params.to.x + n,
|
|
1062
1062
|
y: d.y
|
|
1063
1063
|
}, v = { x: f.x, y: l };
|
|
1064
1064
|
this.path = C(
|
|
1065
|
-
[s,
|
|
1065
|
+
[s, a, g, p, v, f, d, i],
|
|
1066
1066
|
this.params.roundness
|
|
1067
1067
|
);
|
|
1068
1068
|
}
|
|
@@ -1087,7 +1087,7 @@ class H {
|
|
|
1087
1087
|
{ x: i, y: w.y },
|
|
1088
1088
|
this.params.sourceDirection,
|
|
1089
1089
|
w
|
|
1090
|
-
),
|
|
1090
|
+
), 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 = m(
|
|
1091
1091
|
{ x: this.params.to.x - i, y: this.params.to.y },
|
|
1092
1092
|
this.params.targetDirection,
|
|
1093
1093
|
this.params.to
|
|
@@ -1116,16 +1116,16 @@ class He {
|
|
|
1116
1116
|
},
|
|
1117
1117
|
this.params.targetDirection,
|
|
1118
1118
|
this.params.to
|
|
1119
|
-
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset,
|
|
1119
|
+
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = m(
|
|
1120
1120
|
{ x: n, y: w.y },
|
|
1121
1121
|
this.params.sourceDirection,
|
|
1122
1122
|
w
|
|
1123
|
-
),
|
|
1123
|
+
), a = m(
|
|
1124
1124
|
{ x: this.params.to.x - n, y: this.params.to.y },
|
|
1125
1125
|
this.params.targetDirection,
|
|
1126
1126
|
this.params.to
|
|
1127
1127
|
);
|
|
1128
|
-
this.path = C([s,
|
|
1128
|
+
this.path = C([s, h, a, i], this.params.roundness);
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
1131
|
class je {
|
|
@@ -1146,23 +1146,23 @@ class je {
|
|
|
1146
1146
|
},
|
|
1147
1147
|
this.params.targetDirection,
|
|
1148
1148
|
this.params.to
|
|
1149
|
-
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset,
|
|
1150
|
-
{ x:
|
|
1149
|
+
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = n - this.params.roundness, a = m(
|
|
1150
|
+
{ x: h, y: w.y },
|
|
1151
1151
|
this.params.sourceDirection,
|
|
1152
1152
|
w
|
|
1153
1153
|
), d = m(
|
|
1154
|
-
{ x: this.params.to.x -
|
|
1154
|
+
{ x: this.params.to.x - h, y: this.params.to.y },
|
|
1155
1155
|
this.params.targetDirection,
|
|
1156
1156
|
this.params.to
|
|
1157
|
-
), c = Math.max((
|
|
1158
|
-
x:
|
|
1157
|
+
), c = Math.max((a.y + d.y) / 2, n), l = this.params.to.x / 2, g = {
|
|
1158
|
+
x: a.x,
|
|
1159
1159
|
y: this.params.flipY > 0 ? c : -n
|
|
1160
1160
|
}, p = { x: l, y: g.y }, f = {
|
|
1161
1161
|
x: d.x,
|
|
1162
1162
|
y: this.params.flipY > 0 ? this.params.to.y - c : this.params.to.y + n
|
|
1163
1163
|
}, v = { x: l, y: f.y };
|
|
1164
1164
|
this.path = C(
|
|
1165
|
-
[s,
|
|
1165
|
+
[s, a, g, p, v, f, d, i],
|
|
1166
1166
|
this.params.roundness
|
|
1167
1167
|
);
|
|
1168
1168
|
}
|
|
@@ -1172,7 +1172,7 @@ class j {
|
|
|
1172
1172
|
o(this, "path");
|
|
1173
1173
|
o(this, "midpoint");
|
|
1174
1174
|
this.params = e;
|
|
1175
|
-
const t = this.params.arrowOffset, s = this.params.side, i = this.params.arrowLength + t, n = i + 2 * s,
|
|
1175
|
+
const t = this.params.arrowOffset, s = this.params.side, i = this.params.arrowLength + t, n = i + 2 * s, a = [
|
|
1176
1176
|
{ x: this.params.arrowLength, y: w.y },
|
|
1177
1177
|
{ x: i, y: w.y },
|
|
1178
1178
|
{ x: i, y: this.params.side },
|
|
@@ -1183,8 +1183,8 @@ class j {
|
|
|
1183
1183
|
{ x: this.params.arrowLength, y: w.y }
|
|
1184
1184
|
].map(
|
|
1185
1185
|
(c) => m(c, this.params.sourceDirection, w)
|
|
1186
|
-
), d = `M ${w.x} ${w.y} L ${
|
|
1187
|
-
this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : d}${C(
|
|
1186
|
+
), d = `M ${w.x} ${w.y} L ${a[0].x} ${a[0].y} `;
|
|
1187
|
+
this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : d}${C(a, this.params.roundness)}`, this.midpoint = { x: (a[3].x + a[4].x) / 2, y: (a[3].y + a[4].y) / 2 };
|
|
1188
1188
|
}
|
|
1189
1189
|
}
|
|
1190
1190
|
class Ge {
|
|
@@ -1192,7 +1192,7 @@ class Ge {
|
|
|
1192
1192
|
o(this, "path");
|
|
1193
1193
|
o(this, "midpoint");
|
|
1194
1194
|
this.params = e;
|
|
1195
|
-
const t = this.params.smallRadius, s = this.params.radius, i = t + s, n = t * s / i,
|
|
1195
|
+
const t = this.params.smallRadius, s = this.params.radius, i = t + s, n = t * s / i, h = Math.sqrt(i * i - t * t), a = h * t / i, d = h + s + this.params.arrowLength, c = this.params.arrowLength + a, g = [
|
|
1196
1196
|
{ x: this.params.arrowLength, y: w.y },
|
|
1197
1197
|
{ x: c, y: n },
|
|
1198
1198
|
{ x: c, y: -n },
|
|
@@ -1267,12 +1267,12 @@ const Ee = (r, e) => {
|
|
|
1267
1267
|
}, s = {
|
|
1268
1268
|
x: e.x + e.width / 2,
|
|
1269
1269
|
y: e.y + e.height / 2
|
|
1270
|
-
}, i = Math.min(t.x, s.x), n = Math.min(t.y, s.y),
|
|
1270
|
+
}, i = Math.min(t.x, s.x), n = Math.min(t.y, s.y), h = Math.abs(s.x - t.x), a = Math.abs(s.y - t.y), d = t.x <= s.x ? 1 : -1, c = t.y <= s.y ? 1 : -1;
|
|
1271
1271
|
return {
|
|
1272
1272
|
x: i,
|
|
1273
1273
|
y: n,
|
|
1274
|
-
width:
|
|
1275
|
-
height:
|
|
1274
|
+
width: h,
|
|
1275
|
+
height: a,
|
|
1276
1276
|
flipX: d,
|
|
1277
1277
|
flipY: c
|
|
1278
1278
|
};
|
|
@@ -1281,8 +1281,8 @@ const Ee = (r, e) => {
|
|
|
1281
1281
|
w,
|
|
1282
1282
|
{ x: t, y: s },
|
|
1283
1283
|
{ x: t, y: -s }
|
|
1284
|
-
].map((c) => m(c, r, w)).map((c) => ({ x: c.x + e.x, y: c.y + e.y })),
|
|
1285
|
-
return `${
|
|
1284
|
+
].map((c) => m(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}`;
|
|
1285
|
+
return `${h} ${a} ${d} Z`;
|
|
1286
1286
|
}, u = Object.freeze({
|
|
1287
1287
|
color: "#777777",
|
|
1288
1288
|
width: 1,
|
|
@@ -1314,19 +1314,19 @@ class W {
|
|
|
1314
1314
|
this.params = e, [this.afterRenderEmitter, this.onAfterRender] = A(), this.svg = Ae(e.color), this.svg.appendChild(this.group), this.line = Se(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = B(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = B(), this.group.appendChild(this.targetArrow));
|
|
1315
1315
|
}
|
|
1316
1316
|
render(e) {
|
|
1317
|
-
const { x: t, y: s, width: i, height: n, flipX:
|
|
1317
|
+
const { x: t, y: s, width: i, height: n, flipX: h, flipY: a } = be(
|
|
1318
1318
|
e.from,
|
|
1319
1319
|
e.to
|
|
1320
1320
|
);
|
|
1321
|
-
Ee(this.svg, { x: t, y: s, width: i, height: n }), this.group.style.transform = `scale(${
|
|
1321
|
+
Ee(this.svg, { x: t, y: s, width: i, height: n }), this.group.style.transform = `scale(${h}, ${a})`;
|
|
1322
1322
|
const d = ne(
|
|
1323
1323
|
e.from.direction,
|
|
1324
|
-
|
|
1325
|
-
|
|
1324
|
+
h,
|
|
1325
|
+
a
|
|
1326
1326
|
), c = ne(
|
|
1327
1327
|
e.to.direction,
|
|
1328
|
-
|
|
1329
|
-
|
|
1328
|
+
h,
|
|
1329
|
+
a
|
|
1330
1330
|
), l = {
|
|
1331
1331
|
x: i,
|
|
1332
1332
|
y: n
|
|
@@ -1337,8 +1337,8 @@ class W {
|
|
|
1337
1337
|
d,
|
|
1338
1338
|
c,
|
|
1339
1339
|
l,
|
|
1340
|
-
|
|
1341
|
-
|
|
1340
|
+
h,
|
|
1341
|
+
a
|
|
1342
1342
|
);
|
|
1343
1343
|
this.line.setAttribute("d", v.path);
|
|
1344
1344
|
let y = null;
|
|
@@ -1681,11 +1681,11 @@ class Pe {
|
|
|
1681
1681
|
[this.afterRenderEmitter, this.onAfterRender] = A(), this.color = (e == null ? void 0 : e.color) ?? u.color, this.width = (e == null ? void 0 : e.width) ?? u.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? u.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? u.preOffset, this.svg = Ae(this.color), this.svg.appendChild(this.group), this.line = Se(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = B(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = B(), this.group.appendChild(this.targetArrow));
|
|
1682
1682
|
}
|
|
1683
1683
|
render(e) {
|
|
1684
|
-
const { x: t, y: s, width: i, height: n, flipX:
|
|
1684
|
+
const { x: t, y: s, width: i, height: n, flipX: h, flipY: a } = be(
|
|
1685
1685
|
e.from,
|
|
1686
1686
|
e.to
|
|
1687
1687
|
);
|
|
1688
|
-
Ee(this.svg, { x: t, y: s, width: i, height: n }), this.group.style.transform = `scale(${
|
|
1688
|
+
Ee(this.svg, { x: t, y: s, width: i, height: n }), this.group.style.transform = `scale(${h}, ${a})`;
|
|
1689
1689
|
const d = { x: i, y: n }, c = new Ke({
|
|
1690
1690
|
to: d,
|
|
1691
1691
|
sourceOffset: this.sourceOffset,
|
|
@@ -1921,13 +1921,13 @@ class K {
|
|
|
1921
1921
|
const i = this.graph.getNode(e);
|
|
1922
1922
|
if (i === null)
|
|
1923
1923
|
return;
|
|
1924
|
-
const n = this.canvas.viewport.getContentMatrix(),
|
|
1924
|
+
const n = this.canvas.viewport.getContentMatrix(), h = T(n, {
|
|
1925
1925
|
x: i.x,
|
|
1926
1926
|
y: i.y
|
|
1927
|
-
}),
|
|
1927
|
+
}), a = T(
|
|
1928
1928
|
{ scale: 1, x: t, y: s },
|
|
1929
|
-
|
|
1930
|
-
), d = this.canvas.viewport.getViewportMatrix(), c = T(d,
|
|
1929
|
+
h
|
|
1930
|
+
), d = this.canvas.viewport.getViewportMatrix(), c = T(d, a);
|
|
1931
1931
|
this.canvas.updateNode(e, { x: c.x, y: c.y }), this.config.onNodeDrag({
|
|
1932
1932
|
nodeId: e,
|
|
1933
1933
|
element: i.element,
|
|
@@ -1986,19 +1986,19 @@ const rt = (r, e, t) => ({
|
|
|
1986
1986
|
y: r.scale * (1 - e) * s + r.y
|
|
1987
1987
|
}), I = (r) => {
|
|
1988
1988
|
const e = [], t = r.touches.length;
|
|
1989
|
-
for (let
|
|
1990
|
-
e.push([r.touches[
|
|
1989
|
+
for (let a = 0; a < t; a++)
|
|
1990
|
+
e.push([r.touches[a].clientX, r.touches[a].clientY]);
|
|
1991
1991
|
const s = e.reduce(
|
|
1992
|
-
(
|
|
1992
|
+
(a, d) => [a[0] + d[0], a[1] + d[1]],
|
|
1993
1993
|
[0, 0]
|
|
1994
|
-
), i = [s[0] / t, s[1] / t],
|
|
1995
|
-
(
|
|
1994
|
+
), i = [s[0] / t, s[1] / t], h = e.map((a) => [a[0] - i[0], a[1] - i[1]]).reduce(
|
|
1995
|
+
(a, d) => a + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
|
|
1996
1996
|
0
|
|
1997
1997
|
);
|
|
1998
1998
|
return {
|
|
1999
1999
|
x: i[0],
|
|
2000
2000
|
y: i[1],
|
|
2001
|
-
scale:
|
|
2001
|
+
scale: h / t,
|
|
2002
2002
|
touchesCnt: t,
|
|
2003
2003
|
touches: e
|
|
2004
2004
|
};
|
|
@@ -2039,8 +2039,8 @@ class $ {
|
|
|
2039
2039
|
o(this, "onWheelScroll", (e) => {
|
|
2040
2040
|
if (!this.params.mouseWheelEventVerifier(e))
|
|
2041
2041
|
return;
|
|
2042
|
-
const { left: t, top: s } = this.element.getBoundingClientRect(), i = e.clientX - t, n = e.clientY - s,
|
|
2043
|
-
this.wheelFinishTimer === null && this.params.onTransformStarted(), this.scaleViewport(
|
|
2042
|
+
const { left: t, top: s } = this.element.getBoundingClientRect(), i = e.clientX - t, n = e.clientY - s, a = 1 / (e.deltaY < 0 ? this.params.wheelSensitivity : 1 / this.params.wheelSensitivity);
|
|
2043
|
+
this.wheelFinishTimer === null && this.params.onTransformStarted(), this.scaleViewport(a, i, n), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
2044
2044
|
this.transformInProgress || this.params.onTransformFinished(), this.wheelFinishTimer = null;
|
|
2045
2045
|
}, this.params.scaleWheelFinishTimeout);
|
|
2046
2046
|
});
|
|
@@ -2069,8 +2069,8 @@ class $ {
|
|
|
2069
2069
|
-(t.x - this.prevTouches.x),
|
|
2070
2070
|
-(t.y - this.prevTouches.y)
|
|
2071
2071
|
), t.touchesCnt === 2) {
|
|
2072
|
-
const { left: i, top: n } = this.element.getBoundingClientRect(),
|
|
2073
|
-
this.scaleViewport(c,
|
|
2072
|
+
const { left: i, top: n } = this.element.getBoundingClientRect(), h = this.prevTouches.x - i, a = this.prevTouches.y - n, c = 1 / (t.scale / this.prevTouches.scale);
|
|
2073
|
+
this.scaleViewport(c, h, a);
|
|
2074
2074
|
}
|
|
2075
2075
|
this.prevTouches = t;
|
|
2076
2076
|
});
|
|
@@ -2103,20 +2103,20 @@ class $ {
|
|
|
2103
2103
|
new $(e, t, s, i);
|
|
2104
2104
|
}
|
|
2105
2105
|
moveViewport(e, t) {
|
|
2106
|
-
const s = this.viewport.getViewportMatrix(), i = rt(s, e, t), { width: n, height:
|
|
2106
|
+
const s = this.viewport.getViewportMatrix(), i = rt(s, e, t), { width: n, height: h } = this.element.getBoundingClientRect(), a = this.params.transformPreprocessor({
|
|
2107
2107
|
prevTransform: s,
|
|
2108
2108
|
nextTransform: i,
|
|
2109
2109
|
canvasWidth: n,
|
|
2110
|
-
canvasHeight:
|
|
2110
|
+
canvasHeight: h
|
|
2111
2111
|
});
|
|
2112
|
-
this.performTransform(
|
|
2112
|
+
this.performTransform(a);
|
|
2113
2113
|
}
|
|
2114
2114
|
scaleViewport(e, t, s) {
|
|
2115
|
-
const i = this.canvas.viewport.getViewportMatrix(), n = ot(i, e, t, s), { width:
|
|
2115
|
+
const i = this.canvas.viewport.getViewportMatrix(), n = ot(i, e, t, s), { width: h, height: a } = this.element.getBoundingClientRect(), d = this.params.transformPreprocessor({
|
|
2116
2116
|
prevTransform: i,
|
|
2117
2117
|
nextTransform: n,
|
|
2118
|
-
canvasWidth:
|
|
2119
|
-
canvasHeight:
|
|
2118
|
+
canvasWidth: h,
|
|
2119
|
+
canvasHeight: a
|
|
2120
2120
|
});
|
|
2121
2121
|
this.performTransform(d);
|
|
2122
2122
|
}
|
|
@@ -2143,7 +2143,7 @@ class $ {
|
|
|
2143
2143
|
}
|
|
2144
2144
|
}
|
|
2145
2145
|
class Z {
|
|
2146
|
-
constructor(e, t, s, i, n,
|
|
2146
|
+
constructor(e, t, s, i, n, h) {
|
|
2147
2147
|
o(this, "canvasResizeObserver");
|
|
2148
2148
|
o(this, "nodeHorizontal");
|
|
2149
2149
|
o(this, "nodeVertical");
|
|
@@ -2174,11 +2174,11 @@ class Z {
|
|
|
2174
2174
|
this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
|
|
2175
2175
|
});
|
|
2176
2176
|
o(this, "userTransformInProgress", !1);
|
|
2177
|
-
this.canvas = e, this.element = t, this.window = s, this.trigger = n, this.params =
|
|
2177
|
+
this.canvas = e, this.element = t, this.window = s, this.trigger = n, this.params = h, this.nodeHorizontal = this.params.nodeContainingRadius.horizontal, this.nodeVertical = this.params.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((d) => {
|
|
2178
2178
|
const c = d[0];
|
|
2179
2179
|
this.viewportWidth = c.contentRect.width, this.viewportHeight = c.contentRect.height, this.scheduleLoadAreaAroundViewport();
|
|
2180
2180
|
}), this.viewport = e.viewport;
|
|
2181
|
-
const
|
|
2181
|
+
const a = {
|
|
2182
2182
|
...i,
|
|
2183
2183
|
onResizeTransformStarted: () => {
|
|
2184
2184
|
this.userTransformInProgress = !0, i.onResizeTransformStarted();
|
|
@@ -2202,17 +2202,17 @@ class Z {
|
|
|
2202
2202
|
e,
|
|
2203
2203
|
this.element,
|
|
2204
2204
|
this.window,
|
|
2205
|
-
|
|
2205
|
+
a
|
|
2206
2206
|
), 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);
|
|
2207
2207
|
}
|
|
2208
|
-
static configure(e, t, s, i, n,
|
|
2208
|
+
static configure(e, t, s, i, n, h) {
|
|
2209
2209
|
new Z(
|
|
2210
2210
|
e,
|
|
2211
2211
|
t,
|
|
2212
2212
|
s,
|
|
2213
2213
|
i,
|
|
2214
2214
|
n,
|
|
2215
|
-
|
|
2215
|
+
h
|
|
2216
2216
|
);
|
|
2217
2217
|
}
|
|
2218
2218
|
scheduleLoadAreaAroundViewport() {
|
|
@@ -2221,12 +2221,12 @@ class Z {
|
|
|
2221
2221
|
});
|
|
2222
2222
|
}
|
|
2223
2223
|
scheduleEnsureViewportAreaLoaded() {
|
|
2224
|
-
const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - this.nodeHorizontal, i = this.viewportMatrix.y - this.nodeVertical, n = this.viewportMatrix.x + e + this.nodeHorizontal,
|
|
2225
|
-
this.loadedArea.xFrom < s && this.loadedArea.xTo > n && this.loadedArea.yFrom < i && this.loadedArea.yTo >
|
|
2224
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - this.nodeHorizontal, i = this.viewportMatrix.y - this.nodeVertical, n = this.viewportMatrix.x + e + this.nodeHorizontal, h = this.viewportMatrix.y + t + this.nodeVertical;
|
|
2225
|
+
this.loadedArea.xFrom < s && this.loadedArea.xTo > n && this.loadedArea.yFrom < i && this.loadedArea.yTo > h || this.scheduleLoadAreaAroundViewport();
|
|
2226
2226
|
}
|
|
2227
2227
|
loadAreaAroundViewport() {
|
|
2228
|
-
const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - e - this.nodeHorizontal, i = this.viewportMatrix.y - t - this.nodeVertical, n = 3 * e + 2 * this.nodeHorizontal,
|
|
2229
|
-
this.trigger.emit({ x: s, y: i, width: n, height:
|
|
2228
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - e - this.nodeHorizontal, i = this.viewportMatrix.y - t - this.nodeVertical, n = 3 * e + 2 * this.nodeHorizontal, h = 3 * t + 2 * this.nodeVertical;
|
|
2229
|
+
this.trigger.emit({ x: s, y: i, width: n, height: h });
|
|
2230
2230
|
}
|
|
2231
2231
|
}
|
|
2232
2232
|
const st = () => {
|
|
@@ -2257,8 +2257,8 @@ class J {
|
|
|
2257
2257
|
o(this, "resizeObserver", new ResizeObserver((e) => {
|
|
2258
2258
|
const t = e[0], { width: s, height: i } = t.contentRect;
|
|
2259
2259
|
this.svg.setAttribute("width", `${s}`), this.svg.setAttribute("height", `${i}`), this.patternRenderingRectangle.setAttribute("width", `${s}`), this.patternRenderingRectangle.setAttribute("height", `${i}`);
|
|
2260
|
-
const n = this.tileWidth / s,
|
|
2261
|
-
this.pattern.setAttribute("width", `${n}`), this.pattern.setAttribute("height", `${
|
|
2260
|
+
const n = this.tileWidth / s, h = this.tileHeight / i;
|
|
2261
|
+
this.pattern.setAttribute("width", `${n}`), this.pattern.setAttribute("height", `${h}`);
|
|
2262
2262
|
}));
|
|
2263
2263
|
o(this, "onAfterTransformUpdated", () => {
|
|
2264
2264
|
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})`;
|
|
@@ -2407,15 +2407,15 @@ class Q {
|
|
|
2407
2407
|
onStopDrag: () => {
|
|
2408
2408
|
this.resetDragState();
|
|
2409
2409
|
},
|
|
2410
|
-
onPortPointerDown: (
|
|
2411
|
-
const d = this.params.connectionTypeResolver(
|
|
2412
|
-
return d === null ? !1 : (this.grabPort(
|
|
2410
|
+
onPortPointerDown: (h, a) => {
|
|
2411
|
+
const d = this.params.connectionTypeResolver(h);
|
|
2412
|
+
return d === null ? !1 : (this.grabPort(h, a, d), !0);
|
|
2413
2413
|
},
|
|
2414
|
-
onPointerMove: (
|
|
2415
|
-
this.moveDraggingPort(
|
|
2414
|
+
onPointerMove: (h) => {
|
|
2415
|
+
this.moveDraggingPort(h);
|
|
2416
2416
|
},
|
|
2417
|
-
onPointerUp: (
|
|
2418
|
-
this.tryCreateConnection(
|
|
2417
|
+
onPointerUp: (h) => {
|
|
2418
|
+
this.tryCreateConnection(h);
|
|
2419
2419
|
}
|
|
2420
2420
|
}
|
|
2421
2421
|
);
|
|
@@ -2432,9 +2432,9 @@ class Q {
|
|
|
2432
2432
|
grabPort(e, t, s) {
|
|
2433
2433
|
const i = this.canvas.graph.getPort(e);
|
|
2434
2434
|
this.staticPortId = e;
|
|
2435
|
-
const n = i.element.getBoundingClientRect(),
|
|
2436
|
-
x:
|
|
2437
|
-
y:
|
|
2435
|
+
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 = T(c, {
|
|
2436
|
+
x: h - d.x,
|
|
2437
|
+
y: a - d.y
|
|
2438
2438
|
}), g = T(c, {
|
|
2439
2439
|
x: t.x - d.x,
|
|
2440
2440
|
y: t.y - d.y
|
|
@@ -2467,8 +2467,8 @@ class Q {
|
|
|
2467
2467
|
);
|
|
2468
2468
|
return;
|
|
2469
2469
|
}
|
|
2470
|
-
const s = this.isTargetDragging ? this.staticPortId : t, i = this.isTargetDragging ? t : this.staticPortId, n = { from: s, to: i },
|
|
2471
|
-
|
|
2470
|
+
const s = this.isTargetDragging ? this.staticPortId : t, i = this.isTargetDragging ? t : this.staticPortId, n = { from: s, to: i }, h = this.params.connectionPreprocessor(n);
|
|
2471
|
+
h !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(h), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.params.onEdgeCreationPrevented(n);
|
|
2472
2472
|
}
|
|
2473
2473
|
moveDraggingPort(e) {
|
|
2474
2474
|
const t = this.overlayLayer.getBoundingClientRect(), s = {
|
|
@@ -2503,12 +2503,12 @@ class _ {
|
|
|
2503
2503
|
onStopDrag: () => {
|
|
2504
2504
|
this.resetDragState();
|
|
2505
2505
|
},
|
|
2506
|
-
onPortPointerDown: (
|
|
2507
|
-
onPointerMove: (
|
|
2508
|
-
this.moveDraggingPort(
|
|
2506
|
+
onPortPointerDown: (h, a) => this.tryStartEdgeDragging(h, a),
|
|
2507
|
+
onPointerMove: (h) => {
|
|
2508
|
+
this.moveDraggingPort(h);
|
|
2509
2509
|
},
|
|
2510
|
-
onPointerUp: (
|
|
2511
|
-
this.tryCreateConnection(
|
|
2510
|
+
onPointerUp: (h) => {
|
|
2511
|
+
this.tryCreateConnection(h);
|
|
2512
2512
|
}
|
|
2513
2513
|
}
|
|
2514
2514
|
);
|
|
@@ -2529,9 +2529,9 @@ class _ {
|
|
|
2529
2529
|
const i = this.canvas.graph.getEdge(s);
|
|
2530
2530
|
if (i === null)
|
|
2531
2531
|
return !1;
|
|
2532
|
-
const n = e === i.from,
|
|
2533
|
-
this.staticPortId =
|
|
2534
|
-
const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(
|
|
2532
|
+
const n = e === i.from, h = e === i.to, a = n ? i.to : i.from;
|
|
2533
|
+
this.staticPortId = a, this.isTargetDragging = h;
|
|
2534
|
+
const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(a), l = c.element.getBoundingClientRect(), g = {
|
|
2535
2535
|
x: l.x + l.width / 2,
|
|
2536
2536
|
y: l.y + l.height / 2
|
|
2537
2537
|
}, p = this.canvas.viewport.getViewportMatrix(), f = this.overlayLayer.getBoundingClientRect(), v = T(p, {
|
|
@@ -2582,32 +2582,33 @@ class _ {
|
|
|
2582
2582
|
tryCreateConnection(e) {
|
|
2583
2583
|
const t = ve(this.canvas.graph, e);
|
|
2584
2584
|
if (this.overlayCanvas.removeEdge(b.Edge), t === null) {
|
|
2585
|
-
const
|
|
2585
|
+
const d = this.draggingEdgePayload;
|
|
2586
2586
|
this.params.onEdgeReattachInterrupted({
|
|
2587
|
-
id:
|
|
2588
|
-
from:
|
|
2589
|
-
to:
|
|
2590
|
-
shape:
|
|
2591
|
-
priority:
|
|
2587
|
+
id: d.id,
|
|
2588
|
+
from: d.from,
|
|
2589
|
+
to: d.to,
|
|
2590
|
+
shape: d.shape,
|
|
2591
|
+
priority: d.priority
|
|
2592
2592
|
});
|
|
2593
2593
|
return;
|
|
2594
2594
|
}
|
|
2595
|
-
const [s, i] = this.isTargetDragging ? [this.staticPortId, t] : [t, this.staticPortId], n = {
|
|
2595
|
+
const [s, i] = this.isTargetDragging ? [this.staticPortId, t] : [t, this.staticPortId], n = this.draggingEdgePayload, h = {
|
|
2596
|
+
id: n.id,
|
|
2596
2597
|
from: s,
|
|
2597
2598
|
to: i,
|
|
2598
|
-
shape:
|
|
2599
|
-
priority:
|
|
2600
|
-
}, a = this.params.connectionPreprocessor(
|
|
2599
|
+
shape: n.shape,
|
|
2600
|
+
priority: n.priority
|
|
2601
|
+
}, a = this.params.connectionPreprocessor(h);
|
|
2601
2602
|
if (a !== null)
|
|
2602
2603
|
this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeReattached), this.canvas.addEdge(a), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeReattached);
|
|
2603
2604
|
else {
|
|
2604
|
-
const
|
|
2605
|
+
const d = this.draggingEdgePayload;
|
|
2605
2606
|
this.params.onEdgeReattachPrevented({
|
|
2606
|
-
id:
|
|
2607
|
-
from:
|
|
2608
|
-
to:
|
|
2609
|
-
shape:
|
|
2610
|
-
priority:
|
|
2607
|
+
id: d.id,
|
|
2608
|
+
from: d.from,
|
|
2609
|
+
to: d.to,
|
|
2610
|
+
shape: d.shape,
|
|
2611
|
+
priority: d.priority
|
|
2611
2612
|
});
|
|
2612
2613
|
}
|
|
2613
2614
|
}
|
|
@@ -2718,7 +2719,7 @@ const X = (r) => () => r, ce = X(0), dt = () => {
|
|
|
2718
2719
|
});
|
|
2719
2720
|
}
|
|
2720
2721
|
}, gt = (r) => {
|
|
2721
|
-
var t, s, i, n,
|
|
2722
|
+
var t, s, i, n, h;
|
|
2722
2723
|
const e = ct(
|
|
2723
2724
|
(t = r.nodes) == null ? void 0 : t.priority,
|
|
2724
2725
|
(s = r.edges) == null ? void 0 : s.priority
|
|
@@ -2732,7 +2733,7 @@ const X = (r) => () => r, ce = X(0), dt = () => {
|
|
|
2732
2733
|
direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
|
|
2733
2734
|
},
|
|
2734
2735
|
edges: {
|
|
2735
|
-
shapeFactory: q(((
|
|
2736
|
+
shapeFactory: q(((h = r.edges) == null ? void 0 : h.shape) ?? {}),
|
|
2736
2737
|
priorityFn: e.edgesPriorityFn
|
|
2737
2738
|
}
|
|
2738
2739
|
};
|
|
@@ -2740,11 +2741,11 @@ const X = (r) => () => r, ce = X(0), dt = () => {
|
|
|
2740
2741
|
var p, f, v, y, E, x;
|
|
2741
2742
|
const e = ((p = r == null ? void 0 : r.events) == null ? void 0 : p.onNodeDrag) ?? (() => {
|
|
2742
2743
|
}), t = ((f = r == null ? void 0 : r.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), s = ((v = r == null ? void 0 : r.events) == null ? void 0 : v.onNodeDragFinished) ?? (() => {
|
|
2743
|
-
}), i = (r == null ? void 0 : r.moveOnTop) !== !1, n = (r == null ? void 0 : r.moveEdgesOnTop) !== !1 && i,
|
|
2744
|
+
}), i = (r == null ? void 0 : r.moveOnTop) !== !1, n = (r == null ? void 0 : r.moveEdgesOnTop) !== !1 && i, h = (y = r == null ? void 0 : r.mouse) == null ? void 0 : y.dragCursor, a = h !== void 0 ? h : "grab", d = (E = r == null ? void 0 : r.mouse) == null ? void 0 : E.mouseDownEventVerifier, c = d !== void 0 ? d : (P) => P.button === 0, l = (x = r == null ? void 0 : r.mouse) == null ? void 0 : x.mouseUpEventVerifier;
|
|
2744
2745
|
return {
|
|
2745
2746
|
moveOnTop: i,
|
|
2746
2747
|
moveEdgesOnTop: n,
|
|
2747
|
-
dragCursor:
|
|
2748
|
+
dragCursor: a,
|
|
2748
2749
|
mouseDownEventVerifier: c,
|
|
2749
2750
|
mouseUpEventVerifier: l !== void 0 ? l : (P) => P.button === 0,
|
|
2750
2751
|
onNodeDrag: e,
|
|
@@ -2754,27 +2755,27 @@ const X = (r) => () => r, ce = X(0), dt = () => {
|
|
|
2754
2755
|
}, ut = (r) => {
|
|
2755
2756
|
const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0, s = r.minY !== null ? r.minY : -1 / 0, i = r.maxY !== null ? r.maxY : 1 / 0;
|
|
2756
2757
|
return (n) => {
|
|
2757
|
-
let
|
|
2758
|
-
|
|
2758
|
+
let h = n.nextTransform.x, a = n.nextTransform.y;
|
|
2759
|
+
h < e && h < n.prevTransform.x && (h = Math.min(n.prevTransform.x, e));
|
|
2759
2760
|
const d = n.canvasWidth * n.prevTransform.scale, c = t - d;
|
|
2760
|
-
|
|
2761
|
+
h > c && h > n.prevTransform.x && (h = Math.max(n.prevTransform.x, c)), a < s && a < n.prevTransform.y && (a = Math.min(n.prevTransform.y, s));
|
|
2761
2762
|
const l = n.canvasHeight * n.prevTransform.scale, g = i - l;
|
|
2762
|
-
return
|
|
2763
|
+
return a > g && a > n.prevTransform.y && (a = Math.max(n.prevTransform.y, g)), { scale: n.nextTransform.scale, x: h, y: a };
|
|
2763
2764
|
};
|
|
2764
2765
|
}, pt = (r) => {
|
|
2765
2766
|
const e = r.maxContentScale, t = r.minContentScale, s = e !== null ? 1 / e : 0, i = t !== null ? 1 / t : 1 / 0;
|
|
2766
2767
|
return (n) => {
|
|
2767
|
-
const
|
|
2768
|
-
let d =
|
|
2769
|
-
if (
|
|
2770
|
-
d = Math.max(
|
|
2771
|
-
const g = (d -
|
|
2772
|
-
c =
|
|
2768
|
+
const h = n.prevTransform, a = n.nextTransform;
|
|
2769
|
+
let d = a.scale, c = a.x, l = a.y;
|
|
2770
|
+
if (a.scale > i && a.scale > h.scale) {
|
|
2771
|
+
d = Math.max(h.scale, i), c = h.x, l = h.y;
|
|
2772
|
+
const g = (d - h.scale) / (a.scale - h.scale);
|
|
2773
|
+
c = h.x + (a.x - h.x) * g, l = h.y + (a.y - h.y) * g;
|
|
2773
2774
|
}
|
|
2774
|
-
if (
|
|
2775
|
-
d = Math.min(
|
|
2776
|
-
const g = (d -
|
|
2777
|
-
c =
|
|
2775
|
+
if (a.scale < s && a.scale < h.scale) {
|
|
2776
|
+
d = Math.min(h.scale, s), c = h.x, l = h.y;
|
|
2777
|
+
const g = (d - h.scale) / (a.scale - h.scale);
|
|
2778
|
+
c = h.x + (a.x - h.x) * g, l = h.y + (a.y - h.y) * g;
|
|
2778
2779
|
}
|
|
2779
2780
|
return {
|
|
2780
2781
|
scale: d,
|
|
@@ -2816,8 +2817,8 @@ const X = (r) => () => r, ce = X(0), dt = () => {
|
|
|
2816
2817
|
(M) => ge(M)
|
|
2817
2818
|
)
|
|
2818
2819
|
) : i = ge(s) : i = (M) => M.nextTransform;
|
|
2819
|
-
const n = ((y = r == null ? void 0 : r.shift) == null ? void 0 : y.cursor) !== void 0 ? r.shift.cursor : "grab",
|
|
2820
|
-
}),
|
|
2820
|
+
const n = ((y = r == null ? void 0 : r.shift) == null ? void 0 : y.cursor) !== void 0 ? r.shift.cursor : "grab", h = ((E = r == null ? void 0 : r.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
|
|
2821
|
+
}), a = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onTransformChange) ?? (() => {
|
|
2821
2822
|
}), d = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseDownEventVerifier, c = d !== void 0 ? d : (M) => M.button === 0, l = (D = r == null ? void 0 : r.shift) == null ? void 0 : D.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;
|
|
2822
2823
|
return {
|
|
2823
2824
|
wheelSensitivity: t,
|
|
@@ -2825,8 +2826,8 @@ const X = (r) => () => r, ce = X(0), dt = () => {
|
|
|
2825
2826
|
}),
|
|
2826
2827
|
onTransformFinished: ((ee = r == null ? void 0 : r.events) == null ? void 0 : ee.onTransformFinished) ?? (() => {
|
|
2827
2828
|
}),
|
|
2828
|
-
onBeforeTransformChange:
|
|
2829
|
-
onTransformChange:
|
|
2829
|
+
onBeforeTransformChange: h,
|
|
2830
|
+
onTransformChange: a,
|
|
2830
2831
|
transformPreprocessor: i,
|
|
2831
2832
|
shiftCursor: n,
|
|
2832
2833
|
mouseDownEventVerifier: c,
|
|
@@ -2857,8 +2858,8 @@ const X = (r) => () => r, ce = X(0), dt = () => {
|
|
|
2857
2858
|
};
|
|
2858
2859
|
}, yt = (r, e, t) => {
|
|
2859
2860
|
var c, l, g;
|
|
2860
|
-
const s = () => "direct", i = (p) => p, n = (p) => p.button === 0,
|
|
2861
|
-
},
|
|
2861
|
+
const s = () => "direct", i = (p) => p, n = (p) => p.button === 0, h = () => {
|
|
2862
|
+
}, a = () => {
|
|
2862
2863
|
}, d = () => {
|
|
2863
2864
|
};
|
|
2864
2865
|
return {
|
|
@@ -2866,9 +2867,9 @@ const X = (r) => () => r, ce = X(0), dt = () => {
|
|
|
2866
2867
|
connectionPreprocessor: r.connectionPreprocessor ?? i,
|
|
2867
2868
|
mouseDownEventVerifier: r.mouseDownEventVerifier ?? n,
|
|
2868
2869
|
mouseUpEventVerifier: r.mouseUpEventVerifier ?? n,
|
|
2869
|
-
onAfterEdgeCreated: ((c = r.events) == null ? void 0 : c.onAfterEdgeCreated) ??
|
|
2870
|
+
onAfterEdgeCreated: ((c = r.events) == null ? void 0 : c.onAfterEdgeCreated) ?? h,
|
|
2870
2871
|
onEdgeCreationInterrupted: ((l = r.events) == null ? void 0 : l.onEdgeCreationInterrupted) ?? d,
|
|
2871
|
-
onEdgeCreationPrevented: ((g = r.events) == null ? void 0 : g.onEdgeCreationPrevented) ??
|
|
2872
|
+
onEdgeCreationPrevented: ((g = r.events) == null ? void 0 : g.onEdgeCreationPrevented) ?? a,
|
|
2872
2873
|
dragPortDirection: r.dragPortDirection ?? t,
|
|
2873
2874
|
edgeShapeFactory: r.edgeShape !== void 0 ? q(r.edgeShape) : e
|
|
2874
2875
|
};
|
|
@@ -2877,8 +2878,8 @@ const X = (r) => () => r, ce = X(0), dt = () => {
|
|
|
2877
2878
|
const t = (p) => p, s = (p) => p.button === 0 && p.ctrlKey, i = (p) => p.button === 0, n = (p) => {
|
|
2878
2879
|
const f = e.getPortAdjacentEdgeIds(p);
|
|
2879
2880
|
return f.length > 0 ? f[f.length - 1] : null;
|
|
2880
|
-
}, a = () => {
|
|
2881
2881
|
}, h = () => {
|
|
2882
|
+
}, a = () => {
|
|
2882
2883
|
}, d = () => {
|
|
2883
2884
|
};
|
|
2884
2885
|
return {
|
|
@@ -2887,9 +2888,9 @@ const X = (r) => () => r, ce = X(0), dt = () => {
|
|
|
2887
2888
|
mouseUpEventVerifier: r.mouseUpEventVerifier ?? i,
|
|
2888
2889
|
draggingEdgeResolver: r.draggingEdgeResolver ?? n,
|
|
2889
2890
|
draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? q(r.draggingEdgeShape) : null,
|
|
2890
|
-
onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ??
|
|
2891
|
+
onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? h,
|
|
2891
2892
|
onEdgeReattachInterrupted: ((l = r.events) == null ? void 0 : l.onEdgeReattachInterrupted) ?? d,
|
|
2892
|
-
onEdgeReattachPrevented: ((g = r.events) == null ? void 0 : g.onEdgeReattachPrevented) ??
|
|
2893
|
+
onEdgeReattachPrevented: ((g = r.events) == null ? void 0 : g.onEdgeReattachPrevented) ?? a
|
|
2893
2894
|
};
|
|
2894
2895
|
};
|
|
2895
2896
|
class St {
|
|
@@ -2988,30 +2989,30 @@ class St {
|
|
|
2988
2989
|
i.main
|
|
2989
2990
|
);
|
|
2990
2991
|
e !== void 0 && (n = new Ue(n, t, e));
|
|
2991
|
-
const
|
|
2992
|
+
const h = gt(this.canvasDefaults), a = new we(
|
|
2992
2993
|
this.element,
|
|
2993
2994
|
t,
|
|
2994
2995
|
s,
|
|
2995
2996
|
n,
|
|
2996
|
-
|
|
2997
|
+
h
|
|
2997
2998
|
);
|
|
2998
2999
|
if (this.hasBackground && J.configure(
|
|
2999
|
-
|
|
3000
|
+
a,
|
|
3000
3001
|
mt(this.backgroundConfig),
|
|
3001
3002
|
i.background
|
|
3002
|
-
), this.hasResizeReactiveNodes && Y.configure(
|
|
3003
|
-
|
|
3003
|
+
), this.hasResizeReactiveNodes && Y.configure(a), this.hasDraggableNode && K.configure(
|
|
3004
|
+
a,
|
|
3004
3005
|
i.main,
|
|
3005
3006
|
this.window,
|
|
3006
3007
|
lt(this.dragConfig)
|
|
3007
3008
|
), this.hasUserConnectablePorts) {
|
|
3008
3009
|
const c = yt(
|
|
3009
3010
|
this.connectablePortsConfig,
|
|
3010
|
-
|
|
3011
|
-
|
|
3011
|
+
h.edges.shapeFactory,
|
|
3012
|
+
h.ports.direction
|
|
3012
3013
|
);
|
|
3013
3014
|
Q.configure(
|
|
3014
|
-
|
|
3015
|
+
a,
|
|
3015
3016
|
i.overlayConnectablePorts,
|
|
3016
3017
|
s,
|
|
3017
3018
|
this.window,
|
|
@@ -3021,10 +3022,10 @@ class St {
|
|
|
3021
3022
|
if (this.hasUserDraggableEdges) {
|
|
3022
3023
|
const c = Et(
|
|
3023
3024
|
this.draggableEdgesConfig,
|
|
3024
|
-
|
|
3025
|
+
a.graph
|
|
3025
3026
|
);
|
|
3026
3027
|
_.configure(
|
|
3027
|
-
|
|
3028
|
+
a,
|
|
3028
3029
|
i.overlayDraggableEdges,
|
|
3029
3030
|
s,
|
|
3030
3031
|
this.window,
|
|
@@ -3032,22 +3033,22 @@ class St {
|
|
|
3032
3033
|
);
|
|
3033
3034
|
}
|
|
3034
3035
|
this.virtualScrollConfig !== void 0 ? Z.configure(
|
|
3035
|
-
|
|
3036
|
+
a,
|
|
3036
3037
|
i.main,
|
|
3037
3038
|
this.window,
|
|
3038
3039
|
le(this.transformConfig),
|
|
3039
3040
|
e,
|
|
3040
3041
|
this.virtualScrollConfig
|
|
3041
3042
|
) : this.hasTransformableViewport && $.configure(
|
|
3042
|
-
|
|
3043
|
+
a,
|
|
3043
3044
|
i.main,
|
|
3044
3045
|
this.window,
|
|
3045
3046
|
le(this.transformConfig)
|
|
3046
3047
|
), this.reset();
|
|
3047
3048
|
const d = () => {
|
|
3048
|
-
i.destroy(),
|
|
3049
|
+
i.destroy(), a.onBeforeDestroy.unsubscribe(d);
|
|
3049
3050
|
};
|
|
3050
|
-
return
|
|
3051
|
+
return a.onBeforeDestroy.subscribe(d), a;
|
|
3051
3052
|
}
|
|
3052
3053
|
/**
|
|
3053
3054
|
* @deprecated
|