@html-graph/html-graph 0.1.3 → 0.1.5
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 +20 -22
- package/dist/main.d.ts +12 -10
- package/dist/main.js +297 -287
- package/dist/main.umd.cjs +1 -1
- package/package.json +5 -2
package/dist/main.js
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var n = (e, t, o) =>
|
|
4
|
-
const
|
|
1
|
+
var K = Object.defineProperty;
|
|
2
|
+
var _ = (e, t, o) => t in e ? K(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
|
|
3
|
+
var n = (e, t, o) => _(e, typeof t != "symbol" ? t + "" : t, o);
|
|
4
|
+
const J = (e, t) => ({
|
|
5
5
|
x: e / 2,
|
|
6
6
|
y: t / 2
|
|
7
|
-
}),
|
|
7
|
+
}), v = (e, t, o) => ({
|
|
8
8
|
x: t.x * e.x - t.y * e.y + ((1 - t.x) * o.x + t.y * o.y),
|
|
9
9
|
y: t.y * e.x + t.x * e.y + ((1 - t.x) * o.y - t.y * o.x)
|
|
10
10
|
}), A = (e, t, o) => ({ x: t * Math.cos(e), y: o * Math.sin(e) }), w = {
|
|
11
11
|
x: 0,
|
|
12
12
|
y: 0
|
|
13
|
-
},
|
|
13
|
+
}, T = (e, t, o, r) => {
|
|
14
14
|
const s = [
|
|
15
15
|
w,
|
|
16
16
|
{ x: o, y: r },
|
|
17
17
|
{ x: o, y: -r }
|
|
18
|
-
].map((l) =>
|
|
19
|
-
return `${h} ${
|
|
20
|
-
},
|
|
18
|
+
].map((l) => v(l, e, w)).map((l) => ({ x: l.x + t.x, y: l.y + t.y })), h = `M ${s[0].x} ${s[0].y}`, c = `L ${s[1].x} ${s[1].y}`, d = `L ${s[2].x} ${s[2].y}`;
|
|
19
|
+
return `${h} ${c} ${d}`;
|
|
20
|
+
}, P = (e, t) => {
|
|
21
21
|
const o = [];
|
|
22
22
|
if (e.length > 0 && o.push(`M ${e[0].x} ${e[0].y}`), e.length === 2 && o.push(`L ${e[1].x} ${e[1].y}`), e.length > 2) {
|
|
23
23
|
const r = e.length - 1;
|
|
24
24
|
let i = 0, s = 0, h = 0;
|
|
25
|
-
e.forEach((
|
|
25
|
+
e.forEach((c, d) => {
|
|
26
26
|
let l = 0, a = 0, g = 0;
|
|
27
|
-
const y =
|
|
27
|
+
const y = d > 0, x = d < r, f = y && x;
|
|
28
28
|
if (y && (l = -i, a = -s, g = h), x) {
|
|
29
|
-
const z = e[
|
|
30
|
-
i = z.x -
|
|
29
|
+
const z = e[d + 1];
|
|
30
|
+
i = z.x - c.x, s = z.y - c.y, h = Math.sqrt(i * i + s * s);
|
|
31
31
|
}
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
`C ${
|
|
32
|
+
const E = h !== 0 ? Math.min((f ? t : 0) / h, d < r - 1 ? 0.5 : 1) : 0, N = f ? { x: c.x + i * E, y: c.y + s * E } : c, k = g !== 0 ? Math.min((f ? t : 0) / g, d > 1 ? 0.5 : 1) : 0, B = f ? { x: c.x + l * k, y: c.y + a * k } : c;
|
|
33
|
+
d > 0 && o.push(`L ${B.x} ${B.y}`), f && o.push(
|
|
34
|
+
`C ${c.x} ${c.y} ${c.x} ${c.y} ${N.x} ${N.y}`
|
|
35
35
|
);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
return o.join(" ");
|
|
39
|
-
},
|
|
39
|
+
}, $ = () => {
|
|
40
40
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
41
41
|
return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e;
|
|
42
|
-
},
|
|
42
|
+
}, p = () => {
|
|
43
43
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
44
44
|
return e.style.transformOrigin = "50% 50%", e;
|
|
45
|
-
},
|
|
45
|
+
}, b = (e, t) => {
|
|
46
46
|
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
47
47
|
return o.setAttribute("stroke", e), o.setAttribute("stroke-width", `${t}`), o.setAttribute("fill", "none"), o;
|
|
48
|
-
},
|
|
48
|
+
}, M = (e) => {
|
|
49
49
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
50
50
|
return t.setAttribute("fill", e), t;
|
|
51
|
-
},
|
|
51
|
+
}, V = (e, t) => {
|
|
52
52
|
const o = {
|
|
53
53
|
x: e.x + e.width / 2,
|
|
54
54
|
y: e.y + e.height / 2
|
|
55
55
|
}, r = {
|
|
56
56
|
x: t.x + t.width / 2,
|
|
57
57
|
y: t.y + t.height / 2
|
|
58
|
-
}, i = Math.min(o.x, r.x), s = Math.min(o.y, r.y), h = Math.abs(r.x - o.x),
|
|
58
|
+
}, i = Math.min(o.x, r.x), s = Math.min(o.y, r.y), h = Math.abs(r.x - o.x), c = Math.abs(r.y - o.y), d = o.x <= r.x ? 1 : -1, l = o.y <= r.y ? 1 : -1;
|
|
59
59
|
return {
|
|
60
60
|
x: i,
|
|
61
61
|
y: s,
|
|
62
62
|
width: h,
|
|
63
|
-
height:
|
|
64
|
-
flipX:
|
|
63
|
+
height: c,
|
|
64
|
+
flipX: d,
|
|
65
65
|
flipY: l
|
|
66
66
|
};
|
|
67
|
-
},
|
|
68
|
-
const t =
|
|
67
|
+
}, Q = (e) => {
|
|
68
|
+
const t = v(
|
|
69
69
|
{ x: e.arrowLength, y: w.y },
|
|
70
70
|
e.fromVect,
|
|
71
71
|
w
|
|
72
|
-
), o =
|
|
72
|
+
), o = v(
|
|
73
73
|
{ x: e.to.x - e.arrowLength, y: e.to.y },
|
|
74
74
|
e.toVect,
|
|
75
75
|
e.to
|
|
@@ -79,131 +79,131 @@ const _ = (e, t) => ({
|
|
|
79
79
|
}, i = {
|
|
80
80
|
x: o.x - e.toVect.x * e.curvature,
|
|
81
81
|
y: o.y - e.toVect.y * e.curvature
|
|
82
|
-
}, s = `M ${t.x} ${t.y} C ${r.x} ${r.y}, ${i.x} ${i.y}, ${o.x} ${o.y}`, h = e.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${t.x} ${t.y} `,
|
|
83
|
-
return `${h}${s}${
|
|
84
|
-
},
|
|
85
|
-
const t = e.hasSourceArrow ?
|
|
82
|
+
}, s = `M ${t.x} ${t.y} C ${r.x} ${r.y}, ${i.x} ${i.y}, ${o.x} ${o.y}`, h = e.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${t.x} ${t.y} `, c = e.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${e.to.x} ${e.to.y}`;
|
|
83
|
+
return `${h}${s}${c}`;
|
|
84
|
+
}, Z = (e) => {
|
|
85
|
+
const t = e.hasSourceArrow ? v(
|
|
86
86
|
{ x: e.arrowLength, y: w.y },
|
|
87
87
|
e.fromVect,
|
|
88
88
|
w
|
|
89
|
-
) : w, o = e.hasTargetArrow ?
|
|
89
|
+
) : w, o = e.hasTargetArrow ? v(
|
|
90
90
|
{ x: e.to.x - e.arrowLength, y: e.to.y },
|
|
91
91
|
e.toVect,
|
|
92
92
|
e.to
|
|
93
|
-
) : e.to, r = e.arrowLength, i = Math.cos(e.detourDirection) * e.detourDistance, s = Math.sin(e.detourDirection) * e.detourDistance, h = i * e.flipX,
|
|
93
|
+
) : e.to, r = e.arrowLength, i = Math.cos(e.detourDirection) * e.detourDistance, s = Math.sin(e.detourDirection) * e.detourDistance, h = i * e.flipX, c = s * e.flipY, d = v(
|
|
94
94
|
{ x: r, y: w.y },
|
|
95
95
|
e.fromVect,
|
|
96
96
|
w
|
|
97
97
|
), l = {
|
|
98
|
-
x:
|
|
99
|
-
y:
|
|
100
|
-
}, a =
|
|
98
|
+
x: d.x + h,
|
|
99
|
+
y: d.y + c
|
|
100
|
+
}, a = v(
|
|
101
101
|
{ x: e.to.x - r, y: e.to.y },
|
|
102
102
|
e.toVect,
|
|
103
103
|
e.to
|
|
104
104
|
), g = {
|
|
105
105
|
x: a.x + h,
|
|
106
|
-
y: a.y +
|
|
106
|
+
y: a.y + c
|
|
107
107
|
}, y = { x: (l.x + g.x) / 2, y: (l.y + g.y) / 2 }, x = {
|
|
108
|
-
x:
|
|
109
|
-
y:
|
|
110
|
-
},
|
|
108
|
+
x: d.x + e.curvature * e.fromVect.x,
|
|
109
|
+
y: d.y + e.curvature * e.fromVect.y
|
|
110
|
+
}, f = {
|
|
111
111
|
x: a.x - e.curvature * e.toVect.x,
|
|
112
112
|
y: a.y - e.curvature * e.toVect.y
|
|
113
|
-
},
|
|
114
|
-
x:
|
|
115
|
-
y:
|
|
116
|
-
},
|
|
113
|
+
}, C = {
|
|
114
|
+
x: d.x + h,
|
|
115
|
+
y: d.y + c
|
|
116
|
+
}, E = {
|
|
117
117
|
x: a.x + h,
|
|
118
|
-
y: a.y +
|
|
118
|
+
y: a.y + c
|
|
119
119
|
};
|
|
120
120
|
return [
|
|
121
121
|
`M ${t.x} ${t.y}`,
|
|
122
|
-
`L ${
|
|
123
|
-
`C ${x.x} ${x.y} ${
|
|
124
|
-
`C ${
|
|
122
|
+
`L ${d.x} ${d.y}`,
|
|
123
|
+
`C ${x.x} ${x.y} ${C.x} ${C.y} ${y.x} ${y.y}`,
|
|
124
|
+
`C ${E.x} ${E.y} ${f.x} ${f.y} ${a.x} ${a.y}`,
|
|
125
125
|
`L ${o.x} ${o.y}`
|
|
126
126
|
].join(" ");
|
|
127
|
-
},
|
|
128
|
-
const t = e.hasSourceArrow ?
|
|
127
|
+
}, O = (e) => {
|
|
128
|
+
const t = e.hasSourceArrow ? v(
|
|
129
129
|
{ x: e.arrowLength, y: w.y },
|
|
130
130
|
e.fromVect,
|
|
131
131
|
w
|
|
132
|
-
) : w, o = e.hasTargetArrow ?
|
|
132
|
+
) : w, o = e.hasTargetArrow ? v(
|
|
133
133
|
{ x: e.to.x - e.arrowLength, y: e.to.y },
|
|
134
134
|
e.toVect,
|
|
135
135
|
e.to
|
|
136
|
-
) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, s =
|
|
136
|
+
) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, s = v({ x: i, y: w.y }, e.fromVect, w), h = v(
|
|
137
137
|
{ x: e.to.x - i, y: e.to.y },
|
|
138
138
|
e.toVect,
|
|
139
139
|
e.to
|
|
140
|
-
),
|
|
141
|
-
x: e.flipX > 0 ? e.to.x -
|
|
140
|
+
), c = Math.max((s.x + h.x) / 2, r), d = e.to.y / 2, l = { x: e.flipX > 0 ? c : -r, y: s.y }, a = { x: l.x, y: d }, g = {
|
|
141
|
+
x: e.flipX > 0 ? e.to.x - c : e.to.x + r,
|
|
142
142
|
y: h.y
|
|
143
|
-
}, y = { x: g.x, y:
|
|
144
|
-
return
|
|
143
|
+
}, y = { x: g.x, y: d };
|
|
144
|
+
return P(
|
|
145
145
|
[t, s, l, a, y, g, h, o],
|
|
146
146
|
e.roundness
|
|
147
147
|
);
|
|
148
|
-
},
|
|
149
|
-
const t = e.hasSourceArrow ?
|
|
148
|
+
}, Y = (e) => {
|
|
149
|
+
const t = e.hasSourceArrow ? v(
|
|
150
150
|
{ x: e.arrowLength, y: w.y },
|
|
151
151
|
e.fromVect,
|
|
152
152
|
w
|
|
153
|
-
) : w, o = e.hasTargetArrow ?
|
|
153
|
+
) : w, o = e.hasTargetArrow ? v(
|
|
154
154
|
{ x: e.to.x - e.arrowLength, y: e.to.y },
|
|
155
155
|
e.toVect,
|
|
156
156
|
e.to
|
|
157
|
-
) : e.to, r = e.arrowLength + e.arrowOffset, i =
|
|
157
|
+
) : e.to, r = e.arrowLength + e.arrowOffset, i = v(
|
|
158
158
|
{ x: r, y: w.y },
|
|
159
159
|
e.fromVect,
|
|
160
160
|
w
|
|
161
|
-
), s = Math.cos(e.detourDirection) * e.detourDistance, h = Math.sin(e.detourDirection) * e.detourDistance,
|
|
161
|
+
), s = Math.cos(e.detourDirection) * e.detourDistance, h = Math.sin(e.detourDirection) * e.detourDistance, c = s * e.flipX, d = h * e.flipY, l = { x: i.x + c, y: i.y + d }, a = v(
|
|
162
162
|
{ x: e.to.x - r, y: e.to.y },
|
|
163
163
|
e.toVect,
|
|
164
164
|
e.to
|
|
165
|
-
), g = { x: a.x +
|
|
166
|
-
return
|
|
165
|
+
), g = { x: a.x + c, y: a.y + d };
|
|
166
|
+
return P(
|
|
167
167
|
[t, i, l, g, a, o],
|
|
168
168
|
e.roundness
|
|
169
169
|
);
|
|
170
170
|
}, q = (e) => {
|
|
171
|
-
const t = e.hasSourceArrow ?
|
|
171
|
+
const t = e.hasSourceArrow ? v(
|
|
172
172
|
{ x: e.arrowLength, y: w.y },
|
|
173
173
|
e.fromVect,
|
|
174
174
|
w
|
|
175
|
-
) : w, o = e.hasTargetArrow ?
|
|
175
|
+
) : w, o = e.hasTargetArrow ? v(
|
|
176
176
|
{ x: e.to.x - e.arrowLength, y: e.to.y },
|
|
177
177
|
e.toVect,
|
|
178
178
|
e.to
|
|
179
|
-
) : e.to, r = e.arrowLength + e.arrowOffset, i =
|
|
179
|
+
) : e.to, r = e.arrowLength + e.arrowOffset, i = v({ x: r, y: w.y }, e.fromVect, w), s = v(
|
|
180
180
|
{ x: e.to.x - r, y: e.to.y },
|
|
181
181
|
e.toVect,
|
|
182
182
|
e.to
|
|
183
183
|
);
|
|
184
|
-
return
|
|
184
|
+
return P([t, i, s, o], e.roundness);
|
|
185
185
|
}, tt = (e) => {
|
|
186
|
-
const t = e.hasSourceArrow ?
|
|
186
|
+
const t = e.hasSourceArrow ? v(
|
|
187
187
|
{ x: e.arrowLength, y: w.y },
|
|
188
188
|
e.fromVect,
|
|
189
189
|
w
|
|
190
|
-
) : w, o = e.hasTargetArrow ?
|
|
190
|
+
) : w, o = e.hasTargetArrow ? v(
|
|
191
191
|
{ x: e.to.x - e.arrowLength, y: e.to.y },
|
|
192
192
|
e.toVect,
|
|
193
193
|
e.to
|
|
194
|
-
) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, s =
|
|
194
|
+
) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, s = v({ x: i, y: w.y }, e.fromVect, w), h = v(
|
|
195
195
|
{ x: e.to.x - i, y: e.to.y },
|
|
196
196
|
e.toVect,
|
|
197
197
|
e.to
|
|
198
|
-
),
|
|
198
|
+
), c = Math.max((s.y + h.y) / 2, r), d = e.to.x / 2, l = { x: s.x, y: e.flipY > 0 ? c : -r }, a = { x: d, y: l.y }, g = {
|
|
199
199
|
x: h.x,
|
|
200
|
-
y: e.flipY > 0 ? e.to.y -
|
|
201
|
-
}, y = { x:
|
|
202
|
-
return
|
|
200
|
+
y: e.flipY > 0 ? e.to.y - c : e.to.y + r
|
|
201
|
+
}, y = { x: d, y: g.y };
|
|
202
|
+
return P(
|
|
203
203
|
[t, s, l, a, y, g, h, o],
|
|
204
204
|
e.roundness
|
|
205
205
|
);
|
|
206
|
-
},
|
|
206
|
+
}, X = (e) => {
|
|
207
207
|
const t = e.arrowOffset, o = e.side, r = e.arrowLength + t, i = r + 2 * o, h = [
|
|
208
208
|
{ x: e.arrowLength, y: w.y },
|
|
209
209
|
{ x: r, y: w.y },
|
|
@@ -214,20 +214,20 @@ const _ = (e, t) => ({
|
|
|
214
214
|
{ x: r, y: w.y },
|
|
215
215
|
{ x: e.arrowLength, y: w.y }
|
|
216
216
|
].map(
|
|
217
|
-
(
|
|
218
|
-
),
|
|
219
|
-
return `${e.hasSourceArrow || e.hasTargetArrow ? "" :
|
|
217
|
+
(d) => v(d, e.fromVect, w)
|
|
218
|
+
), c = `M ${w.x} ${w.y} L ${h[0].x} ${h[0].y} `;
|
|
219
|
+
return `${e.hasSourceArrow || e.hasTargetArrow ? "" : c}${P(h, e.roundness)}`;
|
|
220
220
|
}, et = (e) => {
|
|
221
|
-
const t = e.smallRadius, o = e.radius, r = Math.sqrt(t * t + o * o), i = t + o, s = e.arrowLength + r * (1 - o / i), h = t * o / i,
|
|
221
|
+
const t = e.smallRadius, o = e.radius, r = Math.sqrt(t * t + o * o), i = t + o, s = e.arrowLength + r * (1 - o / i), h = t * o / i, d = [
|
|
222
222
|
{ x: e.arrowLength, y: w.y },
|
|
223
223
|
{ x: s, y: h },
|
|
224
224
|
{ x: s, y: -h }
|
|
225
|
-
].map((g) =>
|
|
226
|
-
`M ${
|
|
227
|
-
`A ${t} ${t} 0 0 1 ${
|
|
228
|
-
`A ${o} ${o} 0 1 0 ${
|
|
229
|
-
`A ${t} ${t} 0 0 1 ${
|
|
230
|
-
].join(" "), a = `M 0 0 L ${
|
|
225
|
+
].map((g) => v(g, e.fromVect, w)), l = [
|
|
226
|
+
`M ${d[0].x} ${d[0].y}`,
|
|
227
|
+
`A ${t} ${t} 0 0 1 ${d[1].x} ${d[1].y}`,
|
|
228
|
+
`A ${o} ${o} 0 1 0 ${d[2].x} ${d[2].y}`,
|
|
229
|
+
`A ${t} ${t} 0 0 1 ${d[0].x} ${d[0].y}`
|
|
230
|
+
].join(" "), a = `M 0 0 L ${d[0].x} ${d[0].y} `;
|
|
231
231
|
return `${e.hasSourceArrow || e.hasTargetArrow ? "" : a}${l}`;
|
|
232
232
|
}, u = Object.freeze({
|
|
233
233
|
color: "#5c5c5c",
|
|
@@ -248,8 +248,8 @@ const _ = (e, t) => ({
|
|
|
248
248
|
});
|
|
249
249
|
class ot {
|
|
250
250
|
constructor(t) {
|
|
251
|
-
n(this, "svg",
|
|
252
|
-
n(this, "group",
|
|
251
|
+
n(this, "svg", $());
|
|
252
|
+
n(this, "group", p());
|
|
253
253
|
n(this, "line");
|
|
254
254
|
n(this, "sourceArrow", null);
|
|
255
255
|
n(this, "targetArrow", null);
|
|
@@ -264,78 +264,78 @@ class ot {
|
|
|
264
264
|
n(this, "hasTargetArrow");
|
|
265
265
|
this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.curvature = (t == null ? void 0 : t.curvature) ?? u.curvature, this.portCycleRadius = (t == null ? void 0 : t.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (t == null ? void 0 : t.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
|
|
266
266
|
const o = (t == null ? void 0 : t.color) ?? u.color, r = (t == null ? void 0 : t.width) ?? u.width;
|
|
267
|
-
this.svg.appendChild(this.group), this.line =
|
|
267
|
+
this.svg.appendChild(this.group), this.line = b(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(o), this.group.appendChild(this.targetArrow));
|
|
268
268
|
}
|
|
269
269
|
render(t) {
|
|
270
|
-
const { x: o, y: r, width: i, height: s, flipX: h, flipY:
|
|
270
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = V(
|
|
271
271
|
t.source,
|
|
272
272
|
t.target
|
|
273
273
|
);
|
|
274
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${
|
|
275
|
-
const
|
|
274
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${c})`;
|
|
275
|
+
const d = A(
|
|
276
276
|
t.source.direction,
|
|
277
277
|
h,
|
|
278
|
-
|
|
278
|
+
c
|
|
279
279
|
), l = A(
|
|
280
280
|
t.target.direction,
|
|
281
281
|
h,
|
|
282
|
-
|
|
282
|
+
c
|
|
283
283
|
), a = {
|
|
284
284
|
x: i,
|
|
285
285
|
y: s
|
|
286
286
|
};
|
|
287
287
|
let g, y = l, x = -this.arrowLength;
|
|
288
288
|
if (t.source.portId === t.target.portId ? (g = et({
|
|
289
|
-
fromVect:
|
|
289
|
+
fromVect: d,
|
|
290
290
|
radius: this.portCycleRadius,
|
|
291
291
|
smallRadius: this.portCycleSmallRadius,
|
|
292
292
|
arrowLength: this.arrowLength,
|
|
293
293
|
hasSourceArrow: this.hasSourceArrow,
|
|
294
294
|
hasTargetArrow: this.hasTargetArrow
|
|
295
|
-
}), y =
|
|
295
|
+
}), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Z({
|
|
296
296
|
to: a,
|
|
297
|
-
fromVect:
|
|
297
|
+
fromVect: d,
|
|
298
298
|
toVect: l,
|
|
299
299
|
flipX: h,
|
|
300
|
-
flipY:
|
|
300
|
+
flipY: c,
|
|
301
301
|
arrowLength: this.arrowLength,
|
|
302
302
|
detourDirection: this.detourDirection,
|
|
303
303
|
detourDistance: this.detourDistance,
|
|
304
304
|
curvature: this.curvature,
|
|
305
305
|
hasSourceArrow: this.hasSourceArrow,
|
|
306
306
|
hasTargetArrow: this.hasTargetArrow
|
|
307
|
-
}) : g =
|
|
307
|
+
}) : g = Q({
|
|
308
308
|
to: a,
|
|
309
|
-
fromVect:
|
|
309
|
+
fromVect: d,
|
|
310
310
|
toVect: l,
|
|
311
311
|
arrowLength: this.arrowLength,
|
|
312
312
|
curvature: this.curvature,
|
|
313
313
|
hasSourceArrow: this.hasSourceArrow,
|
|
314
314
|
hasTargetArrow: this.hasTargetArrow
|
|
315
315
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
316
|
-
const
|
|
317
|
-
|
|
316
|
+
const f = T(
|
|
317
|
+
d,
|
|
318
318
|
w,
|
|
319
319
|
this.arrowLength,
|
|
320
320
|
this.arrowWidth
|
|
321
321
|
);
|
|
322
|
-
this.sourceArrow.setAttribute("d",
|
|
322
|
+
this.sourceArrow.setAttribute("d", f);
|
|
323
323
|
}
|
|
324
324
|
if (this.targetArrow) {
|
|
325
|
-
const
|
|
325
|
+
const f = T(
|
|
326
326
|
y,
|
|
327
327
|
a,
|
|
328
328
|
x,
|
|
329
329
|
this.arrowWidth
|
|
330
330
|
);
|
|
331
|
-
this.targetArrow.setAttribute("d",
|
|
331
|
+
this.targetArrow.setAttribute("d", f);
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
class rt {
|
|
336
336
|
constructor(t) {
|
|
337
|
-
n(this, "svg",
|
|
338
|
-
n(this, "group",
|
|
337
|
+
n(this, "svg", $());
|
|
338
|
+
n(this, "group", p());
|
|
339
339
|
n(this, "line");
|
|
340
340
|
n(this, "sourceArrow", null);
|
|
341
341
|
n(this, "targetArrow", null);
|
|
@@ -356,41 +356,41 @@ class rt {
|
|
|
356
356
|
this.cycleSquareSide / 2
|
|
357
357
|
), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
|
|
358
358
|
const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
|
|
359
|
-
this.svg.appendChild(this.group), this.line =
|
|
359
|
+
this.svg.appendChild(this.group), this.line = b(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
|
|
360
360
|
}
|
|
361
361
|
render(t) {
|
|
362
|
-
const { x: o, y: r, width: i, height: s, flipX: h, flipY:
|
|
362
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = V(
|
|
363
363
|
t.source,
|
|
364
364
|
t.target
|
|
365
365
|
);
|
|
366
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${
|
|
367
|
-
const
|
|
366
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${c})`;
|
|
367
|
+
const d = A(
|
|
368
368
|
t.source.direction,
|
|
369
369
|
h,
|
|
370
|
-
|
|
370
|
+
c
|
|
371
371
|
), l = A(
|
|
372
372
|
t.target.direction,
|
|
373
373
|
h,
|
|
374
|
-
|
|
374
|
+
c
|
|
375
375
|
), a = {
|
|
376
376
|
x: i,
|
|
377
377
|
y: s
|
|
378
378
|
};
|
|
379
379
|
let g, y = l, x = -this.arrowLength;
|
|
380
|
-
if (t.source.portId === t.target.portId ? (g =
|
|
381
|
-
fromVect:
|
|
380
|
+
if (t.source.portId === t.target.portId ? (g = X({
|
|
381
|
+
fromVect: d,
|
|
382
382
|
arrowLength: this.arrowLength,
|
|
383
383
|
side: this.cycleSquareSide,
|
|
384
384
|
arrowOffset: this.arrowOffset,
|
|
385
385
|
roundness: this.roundness,
|
|
386
386
|
hasSourceArrow: this.hasSourceArrow,
|
|
387
387
|
hasTargetArrow: this.hasTargetArrow
|
|
388
|
-
}), y =
|
|
388
|
+
}), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Y({
|
|
389
389
|
to: a,
|
|
390
|
-
fromVect:
|
|
390
|
+
fromVect: d,
|
|
391
391
|
toVect: l,
|
|
392
392
|
flipX: h,
|
|
393
|
-
flipY:
|
|
393
|
+
flipY: c,
|
|
394
394
|
arrowLength: this.arrowLength,
|
|
395
395
|
arrowOffset: this.arrowOffset,
|
|
396
396
|
roundness: this.roundness,
|
|
@@ -398,9 +398,9 @@ class rt {
|
|
|
398
398
|
detourDistance: this.detourDistance,
|
|
399
399
|
hasSourceArrow: this.hasSourceArrow,
|
|
400
400
|
hasTargetArrow: this.hasTargetArrow
|
|
401
|
-
}) : g =
|
|
401
|
+
}) : g = O({
|
|
402
402
|
to: a,
|
|
403
|
-
fromVect:
|
|
403
|
+
fromVect: d,
|
|
404
404
|
toVect: l,
|
|
405
405
|
flipX: h,
|
|
406
406
|
arrowLength: this.arrowLength,
|
|
@@ -409,29 +409,29 @@ class rt {
|
|
|
409
409
|
hasSourceArrow: this.hasSourceArrow,
|
|
410
410
|
hasTargetArrow: this.hasTargetArrow
|
|
411
411
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
412
|
-
const
|
|
413
|
-
|
|
412
|
+
const f = T(
|
|
413
|
+
d,
|
|
414
414
|
w,
|
|
415
415
|
this.arrowLength,
|
|
416
416
|
this.arrowWidth
|
|
417
417
|
);
|
|
418
|
-
this.sourceArrow.setAttribute("d",
|
|
418
|
+
this.sourceArrow.setAttribute("d", f);
|
|
419
419
|
}
|
|
420
420
|
if (this.targetArrow) {
|
|
421
|
-
const
|
|
421
|
+
const f = T(
|
|
422
422
|
y,
|
|
423
423
|
a,
|
|
424
424
|
x,
|
|
425
425
|
this.arrowWidth
|
|
426
426
|
);
|
|
427
|
-
this.targetArrow.setAttribute("d",
|
|
427
|
+
this.targetArrow.setAttribute("d", f);
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
431
|
class it {
|
|
432
432
|
constructor(t) {
|
|
433
|
-
n(this, "svg",
|
|
434
|
-
n(this, "group",
|
|
433
|
+
n(this, "svg", $());
|
|
434
|
+
n(this, "group", p());
|
|
435
435
|
n(this, "line");
|
|
436
436
|
n(this, "sourceArrow", null);
|
|
437
437
|
n(this, "targetArrow", null);
|
|
@@ -452,41 +452,41 @@ class it {
|
|
|
452
452
|
this.cycleSquareSide / 2
|
|
453
453
|
), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
|
|
454
454
|
const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
|
|
455
|
-
this.svg.appendChild(this.group), this.line =
|
|
455
|
+
this.svg.appendChild(this.group), this.line = b(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
|
|
456
456
|
}
|
|
457
457
|
render(t) {
|
|
458
|
-
const { x: o, y: r, width: i, height: s, flipX: h, flipY:
|
|
458
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = V(
|
|
459
459
|
t.source,
|
|
460
460
|
t.target
|
|
461
461
|
);
|
|
462
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${
|
|
463
|
-
const
|
|
462
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${c})`;
|
|
463
|
+
const d = A(
|
|
464
464
|
t.source.direction,
|
|
465
465
|
h,
|
|
466
|
-
|
|
466
|
+
c
|
|
467
467
|
), l = A(
|
|
468
468
|
t.target.direction,
|
|
469
469
|
h,
|
|
470
|
-
|
|
470
|
+
c
|
|
471
471
|
), a = {
|
|
472
472
|
x: i,
|
|
473
473
|
y: s
|
|
474
474
|
};
|
|
475
475
|
let g, y = l, x = -this.arrowLength;
|
|
476
|
-
if (t.source.portId === t.target.portId ? (g =
|
|
477
|
-
fromVect:
|
|
476
|
+
if (t.source.portId === t.target.portId ? (g = X({
|
|
477
|
+
fromVect: d,
|
|
478
478
|
arrowLength: this.arrowLength,
|
|
479
479
|
side: this.cycleSquareSide,
|
|
480
480
|
arrowOffset: this.arrowOffset,
|
|
481
481
|
roundness: this.roundness,
|
|
482
482
|
hasSourceArrow: this.hasSourceArrow,
|
|
483
483
|
hasTargetArrow: this.hasTargetArrow
|
|
484
|
-
}), y =
|
|
484
|
+
}), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Y({
|
|
485
485
|
to: a,
|
|
486
|
-
fromVect:
|
|
486
|
+
fromVect: d,
|
|
487
487
|
toVect: l,
|
|
488
488
|
flipX: h,
|
|
489
|
-
flipY:
|
|
489
|
+
flipY: c,
|
|
490
490
|
arrowLength: this.arrowLength,
|
|
491
491
|
arrowOffset: this.arrowOffset,
|
|
492
492
|
roundness: this.roundness,
|
|
@@ -496,7 +496,7 @@ class it {
|
|
|
496
496
|
hasTargetArrow: this.hasTargetArrow
|
|
497
497
|
}) : g = q({
|
|
498
498
|
to: a,
|
|
499
|
-
fromVect:
|
|
499
|
+
fromVect: d,
|
|
500
500
|
toVect: l,
|
|
501
501
|
arrowLength: this.arrowLength,
|
|
502
502
|
arrowOffset: this.arrowOffset,
|
|
@@ -504,29 +504,29 @@ class it {
|
|
|
504
504
|
hasSourceArrow: this.hasSourceArrow,
|
|
505
505
|
hasTargetArrow: this.hasTargetArrow
|
|
506
506
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
507
|
-
const
|
|
508
|
-
|
|
507
|
+
const f = T(
|
|
508
|
+
d,
|
|
509
509
|
w,
|
|
510
510
|
this.arrowLength,
|
|
511
511
|
this.arrowWidth
|
|
512
512
|
);
|
|
513
|
-
this.sourceArrow.setAttribute("d",
|
|
513
|
+
this.sourceArrow.setAttribute("d", f);
|
|
514
514
|
}
|
|
515
515
|
if (this.targetArrow) {
|
|
516
|
-
const
|
|
516
|
+
const f = T(
|
|
517
517
|
y,
|
|
518
518
|
a,
|
|
519
519
|
x,
|
|
520
520
|
this.arrowWidth
|
|
521
521
|
);
|
|
522
|
-
this.targetArrow.setAttribute("d",
|
|
522
|
+
this.targetArrow.setAttribute("d", f);
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
526
|
class nt {
|
|
527
527
|
constructor(t) {
|
|
528
|
-
n(this, "svg",
|
|
529
|
-
n(this, "group",
|
|
528
|
+
n(this, "svg", $());
|
|
529
|
+
n(this, "group", p());
|
|
530
530
|
n(this, "line");
|
|
531
531
|
n(this, "sourceArrow", null);
|
|
532
532
|
n(this, "targetArrow", null);
|
|
@@ -547,41 +547,41 @@ class nt {
|
|
|
547
547
|
this.cycleSquareSide / 2
|
|
548
548
|
), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
|
|
549
549
|
const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
|
|
550
|
-
this.svg.appendChild(this.group), this.line =
|
|
550
|
+
this.svg.appendChild(this.group), this.line = b(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
|
|
551
551
|
}
|
|
552
552
|
render(t) {
|
|
553
|
-
const { x: o, y: r, width: i, height: s, flipX: h, flipY:
|
|
553
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = V(
|
|
554
554
|
t.source,
|
|
555
555
|
t.target
|
|
556
556
|
);
|
|
557
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${
|
|
558
|
-
const
|
|
557
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${c})`;
|
|
558
|
+
const d = A(
|
|
559
559
|
t.source.direction,
|
|
560
560
|
h,
|
|
561
|
-
|
|
561
|
+
c
|
|
562
562
|
), l = A(
|
|
563
563
|
t.target.direction,
|
|
564
564
|
h,
|
|
565
|
-
|
|
565
|
+
c
|
|
566
566
|
), a = {
|
|
567
567
|
x: i,
|
|
568
568
|
y: s
|
|
569
569
|
};
|
|
570
570
|
let g, y = l, x = -this.arrowLength;
|
|
571
|
-
if (t.source.portId === t.target.portId ? (g =
|
|
572
|
-
fromVect:
|
|
571
|
+
if (t.source.portId === t.target.portId ? (g = X({
|
|
572
|
+
fromVect: d,
|
|
573
573
|
arrowLength: this.arrowLength,
|
|
574
574
|
side: this.cycleSquareSide,
|
|
575
575
|
arrowOffset: this.arrowOffset,
|
|
576
576
|
roundness: this.roundness,
|
|
577
577
|
hasSourceArrow: this.hasSourceArrow,
|
|
578
578
|
hasTargetArrow: this.hasTargetArrow
|
|
579
|
-
}), y =
|
|
579
|
+
}), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Y({
|
|
580
580
|
to: a,
|
|
581
|
-
fromVect:
|
|
581
|
+
fromVect: d,
|
|
582
582
|
toVect: l,
|
|
583
583
|
flipX: h,
|
|
584
|
-
flipY:
|
|
584
|
+
flipY: c,
|
|
585
585
|
arrowLength: this.arrowLength,
|
|
586
586
|
arrowOffset: this.arrowOffset,
|
|
587
587
|
roundness: this.roundness,
|
|
@@ -591,31 +591,31 @@ class nt {
|
|
|
591
591
|
hasTargetArrow: this.hasTargetArrow
|
|
592
592
|
}) : g = tt({
|
|
593
593
|
to: a,
|
|
594
|
-
fromVect:
|
|
594
|
+
fromVect: d,
|
|
595
595
|
toVect: l,
|
|
596
|
-
flipY:
|
|
596
|
+
flipY: c,
|
|
597
597
|
arrowLength: this.arrowLength,
|
|
598
598
|
arrowOffset: this.arrowOffset,
|
|
599
599
|
roundness: this.roundness,
|
|
600
600
|
hasSourceArrow: this.hasSourceArrow,
|
|
601
601
|
hasTargetArrow: this.hasTargetArrow
|
|
602
602
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
603
|
-
const
|
|
604
|
-
|
|
603
|
+
const f = T(
|
|
604
|
+
d,
|
|
605
605
|
w,
|
|
606
606
|
this.arrowLength,
|
|
607
607
|
this.arrowWidth
|
|
608
608
|
);
|
|
609
|
-
this.sourceArrow.setAttribute("d",
|
|
609
|
+
this.sourceArrow.setAttribute("d", f);
|
|
610
610
|
}
|
|
611
611
|
if (this.targetArrow) {
|
|
612
|
-
const
|
|
612
|
+
const f = T(
|
|
613
613
|
y,
|
|
614
614
|
a,
|
|
615
615
|
x,
|
|
616
616
|
this.arrowWidth
|
|
617
617
|
);
|
|
618
|
-
this.targetArrow.setAttribute("d",
|
|
618
|
+
this.targetArrow.setAttribute("d", f);
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
621
|
}
|
|
@@ -680,18 +680,18 @@ const st = (e) => {
|
|
|
680
680
|
detourDirection: e.detourDirection
|
|
681
681
|
});
|
|
682
682
|
}
|
|
683
|
-
},
|
|
683
|
+
}, R = (e) => () => e, G = R(0), W = () => {
|
|
684
684
|
let e = 0;
|
|
685
685
|
return () => e++;
|
|
686
686
|
}, ht = (e, t) => {
|
|
687
687
|
let o = G, r = G;
|
|
688
|
-
e === "incremental" && (o =
|
|
689
|
-
const i =
|
|
690
|
-
return e === "shared-incremental" && (o = i), t === "shared-incremental" && (r = i), typeof e == "number" && (o =
|
|
688
|
+
e === "incremental" && (o = W()), t === "incremental" && (r = W());
|
|
689
|
+
const i = W();
|
|
690
|
+
return e === "shared-incremental" && (o = i), t === "shared-incremental" && (r = i), typeof e == "number" && (o = R(e)), typeof t == "number" && (r = R(t)), typeof e == "function" && (o = e), typeof t == "function" && (r = t), {
|
|
691
691
|
nodesPriorityFn: o,
|
|
692
692
|
edgesPriorityFn: r
|
|
693
693
|
};
|
|
694
|
-
},
|
|
694
|
+
}, ct = (e) => {
|
|
695
695
|
var o, r, i, s, h;
|
|
696
696
|
const t = ht(
|
|
697
697
|
(o = e == null ? void 0 : e.nodes) == null ? void 0 : o.priority,
|
|
@@ -699,7 +699,7 @@ const st = (e) => {
|
|
|
699
699
|
);
|
|
700
700
|
return {
|
|
701
701
|
nodes: {
|
|
702
|
-
centerFn: ((i = e == null ? void 0 : e.nodes) == null ? void 0 : i.centerFn) ??
|
|
702
|
+
centerFn: ((i = e == null ? void 0 : e.nodes) == null ? void 0 : i.centerFn) ?? J,
|
|
703
703
|
priorityFn: t.nodesPriorityFn
|
|
704
704
|
},
|
|
705
705
|
ports: {
|
|
@@ -711,7 +711,7 @@ const st = (e) => {
|
|
|
711
711
|
}
|
|
712
712
|
};
|
|
713
713
|
};
|
|
714
|
-
class
|
|
714
|
+
class dt {
|
|
715
715
|
constructor() {
|
|
716
716
|
n(this, "nodes", /* @__PURE__ */ new Map());
|
|
717
717
|
n(this, "ports", /* @__PURE__ */ new Map());
|
|
@@ -1017,8 +1017,8 @@ class ft {
|
|
|
1017
1017
|
this.clear(), this.detach(), this.host.removeChild(this.container);
|
|
1018
1018
|
}
|
|
1019
1019
|
updateNodeCoordinates(t) {
|
|
1020
|
-
const o = this.nodeIdToWrapperElementMap.get(t), r = this.graphStore.getNode(t), { width: i, height: s } = r.element.getBoundingClientRect(), h = this.viewportTransformer.getViewportMatrix().scale,
|
|
1021
|
-
o.style.transform = `translate(${
|
|
1020
|
+
const o = this.nodeIdToWrapperElementMap.get(t), r = this.graphStore.getNode(t), { width: i, height: s } = r.element.getBoundingClientRect(), h = this.viewportTransformer.getViewportMatrix().scale, c = r.centerFn(i, s), d = r.x - h * c.x, l = r.y - h * c.y;
|
|
1021
|
+
o.style.transform = `translate(${d}px, ${l}px)`;
|
|
1022
1022
|
}
|
|
1023
1023
|
updateNodePriority(t) {
|
|
1024
1024
|
const o = this.graphStore.getNode(t), r = this.nodeIdToWrapperElementMap.get(t);
|
|
@@ -1031,25 +1031,25 @@ class ft {
|
|
|
1031
1031
|
this.edgeIdToElementMap.set(t, r.shape.svg), this.container.appendChild(r.shape.svg);
|
|
1032
1032
|
}
|
|
1033
1033
|
renderEdge(t) {
|
|
1034
|
-
const o = this.graphStore.getEdge(t), r = this.graphStore.getPort(o.from), i = this.graphStore.getPort(o.to), s = r.element.getBoundingClientRect(), h = i.element.getBoundingClientRect(),
|
|
1035
|
-
x:
|
|
1036
|
-
y:
|
|
1034
|
+
const o = this.graphStore.getEdge(t), r = this.graphStore.getPort(o.from), i = this.graphStore.getPort(o.to), s = r.element.getBoundingClientRect(), h = i.element.getBoundingClientRect(), c = this.host.getBoundingClientRect(), d = this.viewportTransformer.getViewportMatrix(), l = {
|
|
1035
|
+
x: d.scale * (s.left - c.left) + d.dx,
|
|
1036
|
+
y: d.scale * (s.top - c.top) + d.dy
|
|
1037
1037
|
}, a = {
|
|
1038
|
-
x:
|
|
1039
|
-
y:
|
|
1038
|
+
x: d.scale * (h.left - c.left) + d.dx,
|
|
1039
|
+
y: d.scale * (h.top - c.top) + d.dy
|
|
1040
1040
|
}, g = {
|
|
1041
1041
|
x: l.x,
|
|
1042
1042
|
y: l.y,
|
|
1043
|
-
width: s.width *
|
|
1044
|
-
height: s.height *
|
|
1043
|
+
width: s.width * d.scale,
|
|
1044
|
+
height: s.height * d.scale,
|
|
1045
1045
|
direction: r.direction,
|
|
1046
1046
|
portId: o.from,
|
|
1047
1047
|
nodeId: this.graphStore.getPortNodeId(o.from)
|
|
1048
1048
|
}, y = {
|
|
1049
1049
|
x: a.x,
|
|
1050
1050
|
y: a.y,
|
|
1051
|
-
width: h.width *
|
|
1052
|
-
height: h.height *
|
|
1051
|
+
width: h.width * d.scale,
|
|
1052
|
+
height: h.height * d.scale,
|
|
1053
1053
|
direction: i.direction,
|
|
1054
1054
|
portId: o.to,
|
|
1055
1055
|
nodeId: this.graphStore.getPortNodeId(o.to)
|
|
@@ -1064,7 +1064,7 @@ class ft {
|
|
|
1064
1064
|
o.shape.svg.style.zIndex = `${o.priority}`;
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
|
-
class
|
|
1067
|
+
class L {
|
|
1068
1068
|
constructor(t) {
|
|
1069
1069
|
n(this, "counter", 0);
|
|
1070
1070
|
this.checkExists = t;
|
|
@@ -1087,17 +1087,17 @@ class S extends Error {
|
|
|
1087
1087
|
}
|
|
1088
1088
|
}
|
|
1089
1089
|
class vt {
|
|
1090
|
-
constructor(t, o, r, i, s, h,
|
|
1091
|
-
n(this, "nodeIdGenerator", new
|
|
1090
|
+
constructor(t, o, r, i, s, h, c) {
|
|
1091
|
+
n(this, "nodeIdGenerator", new L(
|
|
1092
1092
|
(t) => this.graphStore.getNode(t) !== void 0
|
|
1093
1093
|
));
|
|
1094
|
-
n(this, "portIdGenerator", new
|
|
1094
|
+
n(this, "portIdGenerator", new L(
|
|
1095
1095
|
(t) => this.graphStore.getPort(t) !== void 0
|
|
1096
1096
|
));
|
|
1097
|
-
n(this, "edgeIdGenerator", new
|
|
1097
|
+
n(this, "edgeIdGenerator", new L(
|
|
1098
1098
|
(t) => this.graphStore.getEdge(t) !== void 0
|
|
1099
1099
|
));
|
|
1100
|
-
this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn = i, this.defaultPortsDirection = s, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn =
|
|
1100
|
+
this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn = i, this.defaultPortsDirection = s, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn = c;
|
|
1101
1101
|
}
|
|
1102
1102
|
attach(t) {
|
|
1103
1103
|
this.htmlController.attach(t);
|
|
@@ -1215,7 +1215,7 @@ class xt {
|
|
|
1215
1215
|
n(this, "canvasController");
|
|
1216
1216
|
n(this, "edgeShapeFactory");
|
|
1217
1217
|
this.apiOptions = t;
|
|
1218
|
-
const o =
|
|
1218
|
+
const o = ct(this.apiOptions), r = new at(), i = new dt();
|
|
1219
1219
|
this.model = new lt(i), this.transformation = new gt(r);
|
|
1220
1220
|
const s = new ft(i, r);
|
|
1221
1221
|
this.canvasController = new vt(
|
|
@@ -1306,41 +1306,52 @@ class xt {
|
|
|
1306
1306
|
this.clear(), this.canvasController.destroy();
|
|
1307
1307
|
}
|
|
1308
1308
|
}
|
|
1309
|
-
const
|
|
1309
|
+
const D = (e, t, o) => {
|
|
1310
1310
|
const { x: r, y: i, width: s, height: h } = e.getBoundingClientRect();
|
|
1311
1311
|
return t >= r && t <= r + s && o >= i && o <= i + h;
|
|
1312
|
-
},
|
|
1312
|
+
}, I = (e, t, o) => t >= 0 && t <= e.innerWidth && o >= 0 && o <= e.innerHeight, m = (e, t) => {
|
|
1313
1313
|
t !== null ? e.style.cursor = t : e.style.removeProperty("cursor");
|
|
1314
|
+
}, St = (e) => {
|
|
1315
|
+
var g, y, x, f, C, E;
|
|
1316
|
+
const t = ((g = e == null ? void 0 : e.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
|
|
1317
|
+
}), o = ((y = e == null ? void 0 : e.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), r = ((x = e == null ? void 0 : e.events) == null ? void 0 : x.onNodeDragFinished) ?? (() => {
|
|
1318
|
+
}), i = (e == null ? void 0 : e.moveOnTop) === !1, s = (f = e == null ? void 0 : e.mouse) == null ? void 0 : f.dragCursor, h = s !== void 0 ? s : "grab", c = (C = e == null ? void 0 : e.mouse) == null ? void 0 : C.mouseDownEventValidator, d = c !== void 0 ? c : (N) => N.button === 0, l = (E = e == null ? void 0 : e.mouse) == null ? void 0 : E.mouseUpEventValidator;
|
|
1319
|
+
return {
|
|
1320
|
+
freezePriority: i,
|
|
1321
|
+
dragCursor: h,
|
|
1322
|
+
mouseDownEventValidator: d,
|
|
1323
|
+
mouseUpEventValidator: l !== void 0 ? l : (N) => N.button === 0,
|
|
1324
|
+
onNodeDrag: t,
|
|
1325
|
+
onBeforeNodeDrag: o,
|
|
1326
|
+
onNodeDragFinished: r
|
|
1327
|
+
};
|
|
1314
1328
|
};
|
|
1315
|
-
class
|
|
1329
|
+
class Et {
|
|
1316
1330
|
constructor(t, o) {
|
|
1317
1331
|
n(this, "model");
|
|
1318
1332
|
n(this, "transformation");
|
|
1319
1333
|
n(this, "maxNodePriority", 0);
|
|
1320
1334
|
n(this, "nodes", /* @__PURE__ */ new Map());
|
|
1321
1335
|
n(this, "grabbedNodeId", null);
|
|
1322
|
-
n(this, "
|
|
1323
|
-
n(this, "onBeforeNodeDrag");
|
|
1324
|
-
n(this, "onNodeDragFinished");
|
|
1325
|
-
n(this, "nodeIdGenerator", new N(
|
|
1336
|
+
n(this, "nodeIdGenerator", new L(
|
|
1326
1337
|
(t) => this.nodes.has(t)
|
|
1327
1338
|
));
|
|
1328
1339
|
n(this, "element", null);
|
|
1329
1340
|
n(this, "onWindowMouseMove", (t) => {
|
|
1330
|
-
if (this.element !== null && (!
|
|
1341
|
+
if (this.element !== null && (!D(this.element, t.clientX, t.clientY) || !I(this.window, t.clientX, t.clientY))) {
|
|
1331
1342
|
this.cancelMouseDrag();
|
|
1332
1343
|
return;
|
|
1333
1344
|
}
|
|
1334
1345
|
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, t.movementX, t.movementY);
|
|
1335
1346
|
});
|
|
1336
1347
|
n(this, "onWindowMouseUp", (t) => {
|
|
1337
|
-
t
|
|
1348
|
+
this.options.mouseUpEventValidator(t) && this.cancelMouseDrag();
|
|
1338
1349
|
});
|
|
1339
1350
|
n(this, "onWindowTouchMove", (t) => {
|
|
1340
1351
|
if (t.touches.length !== 1)
|
|
1341
1352
|
return;
|
|
1342
1353
|
const o = t.touches[0];
|
|
1343
|
-
if (this.element !== null && (!
|
|
1354
|
+
if (this.element !== null && (!D(this.element, o.clientX, o.clientY) || !I(this.window, o.clientX, o.clientY))) {
|
|
1344
1355
|
this.cancelTouchDrag();
|
|
1345
1356
|
return;
|
|
1346
1357
|
}
|
|
@@ -1352,20 +1363,13 @@ class St {
|
|
|
1352
1363
|
};
|
|
1353
1364
|
}
|
|
1354
1365
|
});
|
|
1355
|
-
n(this, "onWindowTouchFinish", (
|
|
1356
|
-
|
|
1357
|
-
x: t.touches[0].clientX,
|
|
1358
|
-
y: t.touches[0].clientY
|
|
1359
|
-
} : this.cancelTouchDrag();
|
|
1366
|
+
n(this, "onWindowTouchFinish", () => {
|
|
1367
|
+
this.previousTouchCoords = null, this.cancelTouchDrag();
|
|
1360
1368
|
});
|
|
1361
1369
|
n(this, "previousTouchCoords", null);
|
|
1362
|
-
n(this, "freezePriority");
|
|
1363
1370
|
n(this, "window", window);
|
|
1364
|
-
n(this, "
|
|
1365
|
-
|
|
1366
|
-
this.canvas = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.onNodeDrag = ((r = o == null ? void 0 : o.events) == null ? void 0 : r.onNodeDrag) ?? (() => {
|
|
1367
|
-
}), this.onBeforeNodeDrag = ((i = o == null ? void 0 : o.events) == null ? void 0 : i.onBeforeNodeDrag) ?? (() => !0), this.onNodeDragFinished = ((s = o == null ? void 0 : o.events) == null ? void 0 : s.onNodeDragFinished) ?? (() => {
|
|
1368
|
-
}), this.freezePriority = (o == null ? void 0 : o.moveOnTop) === !1, this.dragCursor = (o == null ? void 0 : o.dragCursor) !== void 0 ? o.dragCursor : "grab";
|
|
1371
|
+
n(this, "options");
|
|
1372
|
+
this.canvas = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.options = St(o ?? {});
|
|
1369
1373
|
}
|
|
1370
1374
|
attach(t) {
|
|
1371
1375
|
return this.detach(), this.element = t, this.canvas.attach(this.element), this;
|
|
@@ -1377,27 +1381,29 @@ class St {
|
|
|
1377
1381
|
const o = this.nodeIdGenerator.create(t.id);
|
|
1378
1382
|
this.canvas.addNode({ ...t, id: o }), this.updateMaxNodePriority(o);
|
|
1379
1383
|
const r = (s) => {
|
|
1380
|
-
if (this.element === null || s
|
|
1384
|
+
if (this.element === null || !this.options.mouseDownEventValidator(s))
|
|
1381
1385
|
return;
|
|
1382
1386
|
const h = this.model.getNode(o);
|
|
1383
|
-
this.onBeforeNodeDrag({
|
|
1387
|
+
this.options.onBeforeNodeDrag({
|
|
1384
1388
|
nodeId: o,
|
|
1385
1389
|
element: t.element,
|
|
1386
1390
|
x: h.x,
|
|
1387
1391
|
y: h.y
|
|
1388
|
-
}) && (s.stopImmediatePropagation(), this.grabbedNodeId = o,
|
|
1392
|
+
}) && (s.stopImmediatePropagation(), this.grabbedNodeId = o, m(this.element, this.options.dragCursor), this.moveNodeOnTop(o), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
|
|
1389
1393
|
}, i = (s) => {
|
|
1394
|
+
if (s.touches.length !== 1)
|
|
1395
|
+
return;
|
|
1390
1396
|
s.stopImmediatePropagation(), this.previousTouchCoords = {
|
|
1391
1397
|
x: s.touches[0].clientX,
|
|
1392
1398
|
y: s.touches[0].clientY
|
|
1393
1399
|
};
|
|
1394
1400
|
const h = this.model.getNode(o);
|
|
1395
|
-
this.onBeforeNodeDrag({
|
|
1401
|
+
this.options.onBeforeNodeDrag({
|
|
1396
1402
|
nodeId: o,
|
|
1397
1403
|
element: t.element,
|
|
1398
1404
|
x: h.x,
|
|
1399
1405
|
y: h.y
|
|
1400
|
-
}) &&
|
|
1406
|
+
}) && (this.grabbedNodeId = o, this.moveNodeOnTop(o), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
|
|
1401
1407
|
};
|
|
1402
1408
|
return this.nodes.set(o, {
|
|
1403
1409
|
element: t.element,
|
|
@@ -1448,8 +1454,8 @@ class St {
|
|
|
1448
1454
|
const i = this.model.getNode(t);
|
|
1449
1455
|
if (i === null)
|
|
1450
1456
|
return;
|
|
1451
|
-
const s = this.canvas.transformation.getContentMatrix(), h = s.scale * i.x + s.dx,
|
|
1452
|
-
this.canvas.updateNode(t, { x: g, y }), this.onNodeDrag({
|
|
1457
|
+
const s = this.canvas.transformation.getContentMatrix(), h = s.scale * i.x + s.dx, c = s.scale * i.y + s.dy, d = h + o, l = c + r, a = this.canvas.transformation.getViewportMatrix(), g = a.scale * d + a.dx, y = a.scale * l + a.dy;
|
|
1458
|
+
this.canvas.updateNode(t, { x: g, y }), this.options.onNodeDrag({
|
|
1453
1459
|
nodeId: t,
|
|
1454
1460
|
element: i.element,
|
|
1455
1461
|
x: i.x,
|
|
@@ -1461,7 +1467,7 @@ class St {
|
|
|
1461
1467
|
this.maxNodePriority = Math.max(this.maxNodePriority, o);
|
|
1462
1468
|
}
|
|
1463
1469
|
moveNodeOnTop(t) {
|
|
1464
|
-
if (this.freezePriority)
|
|
1470
|
+
if (this.options.freezePriority)
|
|
1465
1471
|
return;
|
|
1466
1472
|
this.maxNodePriority += 2, this.updateNode(t, { priority: this.maxNodePriority });
|
|
1467
1473
|
const o = this.maxNodePriority - 1;
|
|
@@ -1471,12 +1477,12 @@ class St {
|
|
|
1471
1477
|
}
|
|
1472
1478
|
cancelMouseDrag() {
|
|
1473
1479
|
const t = this.model.getNode(this.grabbedNodeId);
|
|
1474
|
-
t !== null && this.onNodeDragFinished({
|
|
1480
|
+
t !== null && this.options.onNodeDragFinished({
|
|
1475
1481
|
nodeId: this.grabbedNodeId,
|
|
1476
1482
|
element: t.element,
|
|
1477
1483
|
x: t.x,
|
|
1478
1484
|
y: t.y
|
|
1479
|
-
}), this.grabbedNodeId = null, this.element !== null &&
|
|
1485
|
+
}), this.grabbedNodeId = null, this.element !== null && m(this.element, null), this.removeMouseDragListeners();
|
|
1480
1486
|
}
|
|
1481
1487
|
removeMouseDragListeners() {
|
|
1482
1488
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
@@ -1484,7 +1490,7 @@ class St {
|
|
|
1484
1490
|
cancelTouchDrag() {
|
|
1485
1491
|
this.previousTouchCoords = null;
|
|
1486
1492
|
const t = this.model.getNode(this.grabbedNodeId);
|
|
1487
|
-
t !== null && this.onNodeDragFinished({
|
|
1493
|
+
t !== null && this.options.onNodeDragFinished({
|
|
1488
1494
|
nodeId: this.grabbedNodeId,
|
|
1489
1495
|
element: t.element,
|
|
1490
1496
|
x: t.x,
|
|
@@ -1498,35 +1504,35 @@ class St {
|
|
|
1498
1504
|
const At = (e) => {
|
|
1499
1505
|
const t = e.minX !== null ? e.minX : -1 / 0, o = e.maxX !== null ? e.maxX : 1 / 0, r = e.minY !== null ? e.minY : -1 / 0, i = e.maxY !== null ? e.maxY : 1 / 0;
|
|
1500
1506
|
return (s) => {
|
|
1501
|
-
let h = s.nextTransform.dx,
|
|
1507
|
+
let h = s.nextTransform.dx, c = s.nextTransform.dy;
|
|
1502
1508
|
h < t && h < s.prevTransform.dx && (h = Math.min(s.prevTransform.dx, t));
|
|
1503
|
-
const
|
|
1504
|
-
h > o -
|
|
1509
|
+
const d = s.canvasWidth * s.prevTransform.scale;
|
|
1510
|
+
h > o - d && h > s.prevTransform.dx && (h = Math.max(s.prevTransform.dx, o - d)), c < r && c < s.prevTransform.dy && (c = Math.min(s.prevTransform.dy, r));
|
|
1505
1511
|
const l = s.canvasHeight * s.prevTransform.scale;
|
|
1506
|
-
return
|
|
1512
|
+
return c > i - l && c > s.prevTransform.dy && (c = Math.max(s.prevTransform.dy, i - l)), { scale: s.nextTransform.scale, dx: h, dy: c };
|
|
1507
1513
|
};
|
|
1508
|
-
},
|
|
1514
|
+
}, Tt = (e) => {
|
|
1509
1515
|
const t = e.maxContentScale, o = e.minContentScale, r = t !== null ? 1 / t : 0, i = o !== null ? 1 / o : 1 / 0;
|
|
1510
1516
|
return (s) => {
|
|
1511
|
-
const h = s.prevTransform,
|
|
1512
|
-
let
|
|
1513
|
-
if (
|
|
1514
|
-
|
|
1515
|
-
const g = (
|
|
1516
|
-
l = h.dx + (
|
|
1517
|
+
const h = s.prevTransform, c = s.nextTransform;
|
|
1518
|
+
let d = c.scale, l = c.dx, a = c.dy;
|
|
1519
|
+
if (c.scale > i && c.scale > h.scale) {
|
|
1520
|
+
d = Math.max(h.scale, i), l = h.dx, a = h.dy;
|
|
1521
|
+
const g = (d - h.scale) / (c.scale - h.scale);
|
|
1522
|
+
l = h.dx + (c.dx - h.dx) * g, a = h.dy + (c.dy - h.dy) * g;
|
|
1517
1523
|
}
|
|
1518
|
-
if (
|
|
1519
|
-
|
|
1520
|
-
const g = (
|
|
1521
|
-
l = h.dx + (
|
|
1524
|
+
if (c.scale < r && c.scale < h.scale) {
|
|
1525
|
+
d = Math.min(h.scale, r), l = h.dx, a = h.dy;
|
|
1526
|
+
const g = (d - h.scale) / (c.scale - h.scale);
|
|
1527
|
+
l = h.dx + (c.dx - h.dx) * g, a = h.dy + (c.dy - h.dy) * g;
|
|
1522
1528
|
}
|
|
1523
1529
|
return {
|
|
1524
|
-
scale:
|
|
1530
|
+
scale: d,
|
|
1525
1531
|
dx: l,
|
|
1526
1532
|
dy: a
|
|
1527
1533
|
};
|
|
1528
1534
|
};
|
|
1529
|
-
},
|
|
1535
|
+
}, Mt = (e) => (t) => e.reduce(
|
|
1530
1536
|
(o, r) => r({
|
|
1531
1537
|
prevTransform: t.prevTransform,
|
|
1532
1538
|
nextTransform: o,
|
|
@@ -1539,7 +1545,7 @@ const At = (e) => {
|
|
|
1539
1545
|
return e;
|
|
1540
1546
|
switch (e.type) {
|
|
1541
1547
|
case "scale-limit":
|
|
1542
|
-
return
|
|
1548
|
+
return Tt({
|
|
1543
1549
|
minContentScale: e.minContentScale ?? 0,
|
|
1544
1550
|
maxContentScale: e.maxContentScale ?? 1 / 0
|
|
1545
1551
|
});
|
|
@@ -1551,34 +1557,38 @@ const At = (e) => {
|
|
|
1551
1557
|
maxY: e.maxY ?? 1 / 0
|
|
1552
1558
|
});
|
|
1553
1559
|
}
|
|
1554
|
-
},
|
|
1555
|
-
var
|
|
1556
|
-
const t = (
|
|
1560
|
+
}, Ct = (e) => {
|
|
1561
|
+
var d, l, a, g, y, x;
|
|
1562
|
+
const t = (d = e == null ? void 0 : e.scale) == null ? void 0 : d.mouseWheelSensitivity, o = t !== void 0 ? t : 1.2, r = e == null ? void 0 : e.transformPreprocessor;
|
|
1557
1563
|
let i;
|
|
1558
|
-
r !== void 0 ? Array.isArray(r) ? i =
|
|
1564
|
+
r !== void 0 ? Array.isArray(r) ? i = Mt(
|
|
1559
1565
|
r.map(
|
|
1560
|
-
(
|
|
1566
|
+
(f) => U(f)
|
|
1561
1567
|
)
|
|
1562
|
-
) : i = U(r) : i = (
|
|
1563
|
-
const s = ((l = e == null ? void 0 : e.shift) == null ? void 0 : l.cursor) !== void 0 ? e.shift.cursor : "grab", h = ((a = e == null ? void 0 : e.events) == null ? void 0 : a.
|
|
1564
|
-
}),
|
|
1568
|
+
) : i = U(r) : i = (f) => f.nextTransform;
|
|
1569
|
+
const s = ((l = e == null ? void 0 : e.shift) == null ? void 0 : l.cursor) !== void 0 ? e.shift.cursor : "grab", h = ((a = e == null ? void 0 : e.events) == null ? void 0 : a.onBeforeTransformChange) ?? (() => {
|
|
1570
|
+
}), c = ((g = e == null ? void 0 : e.events) == null ? void 0 : g.onTransformChange) ?? (() => {
|
|
1565
1571
|
});
|
|
1566
1572
|
return {
|
|
1567
1573
|
wheelSensitivity: o,
|
|
1568
|
-
|
|
1569
|
-
|
|
1574
|
+
onTransformStarted: ((y = e == null ? void 0 : e.events) == null ? void 0 : y.onTransformStarted) ?? (() => {
|
|
1575
|
+
}),
|
|
1576
|
+
onTransformFinished: ((x = e == null ? void 0 : e.events) == null ? void 0 : x.onTransformFinished) ?? (() => {
|
|
1577
|
+
}),
|
|
1578
|
+
onBeforeTransformChange: h,
|
|
1579
|
+
onTransformChange: c,
|
|
1570
1580
|
transformPreprocessor: i,
|
|
1571
1581
|
shiftCursor: s
|
|
1572
1582
|
};
|
|
1573
|
-
},
|
|
1583
|
+
}, F = (e) => {
|
|
1574
1584
|
const t = [], o = e.touches.length;
|
|
1575
|
-
for (let
|
|
1576
|
-
t.push([e.touches[
|
|
1585
|
+
for (let c = 0; c < o; c++)
|
|
1586
|
+
t.push([e.touches[c].clientX, e.touches[c].clientY]);
|
|
1577
1587
|
const r = t.reduce(
|
|
1578
|
-
(
|
|
1588
|
+
(c, d) => [c[0] + d[0], c[1] + d[1]],
|
|
1579
1589
|
[0, 0]
|
|
1580
|
-
), i = [r[0] / o, r[1] / o], h = t.map((
|
|
1581
|
-
(
|
|
1590
|
+
), i = [r[0] / o, r[1] / o], h = t.map((c) => [c[0] - i[0], c[1] - i[1]]).reduce(
|
|
1591
|
+
(c, d) => c + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
|
|
1582
1592
|
0
|
|
1583
1593
|
);
|
|
1584
1594
|
return {
|
|
@@ -1592,7 +1602,7 @@ const At = (e) => {
|
|
|
1592
1602
|
scale: e.scale,
|
|
1593
1603
|
dx: e.dx + e.scale * t,
|
|
1594
1604
|
dy: e.dy + e.scale * o
|
|
1595
|
-
}),
|
|
1605
|
+
}), Lt = (e, t, o, r) => ({
|
|
1596
1606
|
scale: e.scale * t,
|
|
1597
1607
|
dx: e.scale * (1 - t) * o + e.dx,
|
|
1598
1608
|
dy: e.scale * (1 - t) * r + e.dy
|
|
@@ -1605,10 +1615,10 @@ class Pt {
|
|
|
1605
1615
|
n(this, "prevTouches", null);
|
|
1606
1616
|
n(this, "window", window);
|
|
1607
1617
|
n(this, "onMouseDown", (t) => {
|
|
1608
|
-
this.element === null || t.button !== 0 || (
|
|
1618
|
+
this.element === null || t.button !== 0 || (m(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.options.onTransformStarted());
|
|
1609
1619
|
});
|
|
1610
1620
|
n(this, "onWindowMouseMove", (t) => {
|
|
1611
|
-
if (this.element === null || !
|
|
1621
|
+
if (this.element === null || !D(this.element, t.clientX, t.clientY) || !I(this.window, t.clientX, t.clientY)) {
|
|
1612
1622
|
this.stopMouseDrag();
|
|
1613
1623
|
return;
|
|
1614
1624
|
}
|
|
@@ -1620,19 +1630,19 @@ class Pt {
|
|
|
1620
1630
|
});
|
|
1621
1631
|
n(this, "onWheelScroll", (t) => {
|
|
1622
1632
|
t.preventDefault();
|
|
1623
|
-
const { left: o, top: r } = this.element.getBoundingClientRect(), i = t.clientX - o, s = t.clientY - r,
|
|
1624
|
-
this.scaleViewport(this.element,
|
|
1633
|
+
const { left: o, top: r } = this.element.getBoundingClientRect(), i = t.clientX - o, s = t.clientY - r, c = 1 / (t.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
|
|
1634
|
+
this.scaleViewport(this.element, c, i, s);
|
|
1625
1635
|
});
|
|
1626
1636
|
n(this, "onTouchStart", (t) => {
|
|
1627
|
-
this.prevTouches =
|
|
1637
|
+
this.prevTouches = F(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
|
|
1628
1638
|
});
|
|
1629
1639
|
n(this, "onWindowTouchMove", (t) => {
|
|
1630
1640
|
const o = this.element;
|
|
1631
1641
|
if (o === null)
|
|
1632
1642
|
return;
|
|
1633
|
-
const r =
|
|
1643
|
+
const r = F(t);
|
|
1634
1644
|
if (!r.touches.every(
|
|
1635
|
-
(s) =>
|
|
1645
|
+
(s) => D(o, s[0], s[1]) && I(this.window, s[0], s[1])
|
|
1636
1646
|
)) {
|
|
1637
1647
|
this.stopTouchDrag();
|
|
1638
1648
|
return;
|
|
@@ -1642,13 +1652,13 @@ class Pt {
|
|
|
1642
1652
|
-(r.x - this.prevTouches.x),
|
|
1643
1653
|
-(r.y - this.prevTouches.y)
|
|
1644
1654
|
), r.touchesCnt === 2) {
|
|
1645
|
-
const { left: s, top: h } = o.getBoundingClientRect(),
|
|
1646
|
-
this.scaleViewport(o, a,
|
|
1655
|
+
const { left: s, top: h } = o.getBoundingClientRect(), c = this.prevTouches.x - s, d = this.prevTouches.y - h, a = 1 / (r.scale / this.prevTouches.scale);
|
|
1656
|
+
this.scaleViewport(o, a, c, d);
|
|
1647
1657
|
}
|
|
1648
1658
|
this.prevTouches = r;
|
|
1649
1659
|
});
|
|
1650
1660
|
n(this, "onWindowTouchFinish", (t) => {
|
|
1651
|
-
t.touches.length > 0 ? this.prevTouches =
|
|
1661
|
+
t.touches.length > 0 ? this.prevTouches = F(t) : this.stopTouchDrag();
|
|
1652
1662
|
});
|
|
1653
1663
|
n(this, "observer", new ResizeObserver(() => {
|
|
1654
1664
|
const t = this.canvas.transformation.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), i = this.options.transformPreprocessor({
|
|
@@ -1657,10 +1667,10 @@ class Pt {
|
|
|
1657
1667
|
canvasWidth: o,
|
|
1658
1668
|
canvasHeight: r
|
|
1659
1669
|
});
|
|
1660
|
-
this.canvas.patchViewportMatrix(i), this.options.
|
|
1670
|
+
this.canvas.patchViewportMatrix(i), this.options.onTransformChange();
|
|
1661
1671
|
}));
|
|
1662
1672
|
n(this, "options");
|
|
1663
|
-
this.canvas = t, this.options =
|
|
1673
|
+
this.canvas = t, this.options = Ct(o), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
|
|
1664
1674
|
}
|
|
1665
1675
|
attach(t) {
|
|
1666
1676
|
return this.detach(), this.element = t, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element), this;
|
|
@@ -1708,39 +1718,39 @@ class Pt {
|
|
|
1708
1718
|
this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
1709
1719
|
}
|
|
1710
1720
|
moveViewport(t, o, r) {
|
|
1711
|
-
this.options.
|
|
1712
|
-
const i = this.transformation.getViewportMatrix(), s = Nt(i, o, r), { width: h, height:
|
|
1721
|
+
this.options.onBeforeTransformChange();
|
|
1722
|
+
const i = this.transformation.getViewportMatrix(), s = Nt(i, o, r), { width: h, height: c } = t.getBoundingClientRect(), d = this.options.transformPreprocessor({
|
|
1713
1723
|
prevTransform: i,
|
|
1714
1724
|
nextTransform: s,
|
|
1715
1725
|
canvasWidth: h,
|
|
1716
|
-
canvasHeight:
|
|
1726
|
+
canvasHeight: c
|
|
1717
1727
|
});
|
|
1718
|
-
this.canvas.patchViewportMatrix(
|
|
1728
|
+
this.canvas.patchViewportMatrix(d), this.options.onTransformChange();
|
|
1719
1729
|
}
|
|
1720
1730
|
scaleViewport(t, o, r, i) {
|
|
1721
|
-
this.options.
|
|
1722
|
-
const s = this.canvas.transformation.getViewportMatrix(), h =
|
|
1731
|
+
this.options.onBeforeTransformChange();
|
|
1732
|
+
const s = this.canvas.transformation.getViewportMatrix(), h = Lt(s, o, r, i), { width: c, height: d } = t.getBoundingClientRect(), l = this.options.transformPreprocessor({
|
|
1723
1733
|
prevTransform: s,
|
|
1724
1734
|
nextTransform: h,
|
|
1725
|
-
canvasWidth:
|
|
1726
|
-
canvasHeight:
|
|
1735
|
+
canvasWidth: c,
|
|
1736
|
+
canvasHeight: d
|
|
1727
1737
|
});
|
|
1728
|
-
this.canvas.patchViewportMatrix(l), this.options.
|
|
1738
|
+
this.canvas.patchViewportMatrix(l), this.options.onTransformChange();
|
|
1729
1739
|
}
|
|
1730
1740
|
stopMouseDrag() {
|
|
1731
|
-
this.element !== null &&
|
|
1741
|
+
this.element !== null && m(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
|
|
1732
1742
|
}
|
|
1733
1743
|
removeMouseDragListeners() {
|
|
1734
1744
|
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
1735
1745
|
}
|
|
1736
1746
|
stopTouchDrag() {
|
|
1737
|
-
this.prevTouches = null, this.removeTouchDragListeners();
|
|
1747
|
+
this.prevTouches = null, this.removeTouchDragListeners(), this.options.onTransformFinished();
|
|
1738
1748
|
}
|
|
1739
1749
|
removeTouchDragListeners() {
|
|
1740
1750
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1741
1751
|
}
|
|
1742
1752
|
}
|
|
1743
|
-
class
|
|
1753
|
+
class Dt {
|
|
1744
1754
|
constructor() {
|
|
1745
1755
|
n(this, "keyMap", /* @__PURE__ */ new Map());
|
|
1746
1756
|
n(this, "valueMap", /* @__PURE__ */ new Map());
|
|
@@ -1777,12 +1787,12 @@ class Lt {
|
|
|
1777
1787
|
this.keyMap.clear(), this.valueMap.clear();
|
|
1778
1788
|
}
|
|
1779
1789
|
}
|
|
1780
|
-
class
|
|
1790
|
+
class It {
|
|
1781
1791
|
constructor(t) {
|
|
1782
1792
|
n(this, "transformation");
|
|
1783
1793
|
n(this, "model");
|
|
1784
|
-
n(this, "nodes", new
|
|
1785
|
-
n(this, "nodeIdGenerator", new
|
|
1794
|
+
n(this, "nodes", new Dt());
|
|
1795
|
+
n(this, "nodeIdGenerator", new L(
|
|
1786
1796
|
(t) => this.nodes.hasKey(t)
|
|
1787
1797
|
));
|
|
1788
1798
|
n(this, "nodesResizeObserver");
|
|
@@ -1851,7 +1861,7 @@ class Dt {
|
|
|
1851
1861
|
});
|
|
1852
1862
|
}
|
|
1853
1863
|
}
|
|
1854
|
-
class
|
|
1864
|
+
class pt {
|
|
1855
1865
|
constructor() {
|
|
1856
1866
|
n(this, "coreOptions");
|
|
1857
1867
|
n(this, "dragOptions");
|
|
@@ -1874,18 +1884,18 @@ class mt {
|
|
|
1874
1884
|
}
|
|
1875
1885
|
build() {
|
|
1876
1886
|
let t = new xt(this.coreOptions);
|
|
1877
|
-
return this.hasResizeReactiveNodes && (t = new
|
|
1887
|
+
return this.hasResizeReactiveNodes && (t = new It(t)), this.isDraggable && (t = new Et(t, this.dragOptions)), this.isTransformable && (t = new Pt(t, this.transformOptions)), t;
|
|
1878
1888
|
}
|
|
1879
1889
|
}
|
|
1880
1890
|
export {
|
|
1881
1891
|
ot as BezierEdgeShape,
|
|
1882
1892
|
xt as CanvasCore,
|
|
1883
1893
|
rt as HorizontalEdgeShape,
|
|
1884
|
-
|
|
1894
|
+
pt as HtmlGraphBuilder,
|
|
1885
1895
|
S as HtmlGraphError,
|
|
1886
|
-
|
|
1896
|
+
It as ResizeReactiveNodesCanvas,
|
|
1887
1897
|
it as StraightEdgeShape,
|
|
1888
|
-
|
|
1898
|
+
Et as UserDraggableNodesCanvas,
|
|
1889
1899
|
Pt as UserTransformableCanvas,
|
|
1890
1900
|
nt as VerticalEdgeShape
|
|
1891
1901
|
};
|