@phun-ky/arclace 0.3.0 → 1.1.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/CHANGELOG.md +35 -0
- package/README.md +90 -14
- package/dist/arclace.d.ts +2 -1
- package/dist/arclace.js +334 -304
- package/dist/arclace.js.map +1 -1
- package/dist/arclace.umd.cjs +1 -1
- package/dist/arclace.umd.cjs.map +1 -1
- package/dist/style.css +18 -6
- package/package.json +6 -3
- package/src/Connection.ts +57 -6
- package/src/style.css +18 -6
package/dist/arclace.js
CHANGED
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Bt = Object.defineProperty;
|
|
2
|
+
var xt = (e) => {
|
|
3
3
|
throw TypeError(e);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
class
|
|
5
|
+
var Ft = (e, t, n) => t in e ? Bt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
6
|
+
var M = (e, t, n) => Ft(e, typeof t != "symbol" ? t + "" : t, n), st = (e, t, n) => t.has(e) || xt("Cannot " + n);
|
|
7
|
+
var o = (e, t, n) => (st(e, t, "read from private field"), n ? n.call(e) : t.get(e)), p = (e, t, n) => t.has(e) ? xt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), l = (e, t, n, s) => (st(e, t, "write to private field"), s ? s.call(e, n) : t.set(e, n), n), m = (e, t, n) => (st(e, t, "access private method"), n);
|
|
8
|
+
class R extends Error {
|
|
9
9
|
constructor(n, s) {
|
|
10
10
|
super(`arclace: ${n}`, s);
|
|
11
|
-
|
|
11
|
+
M(this, "name", "ArclaceError");
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const Y = Object.freeze({
|
|
15
15
|
top: Object.freeze({ x: 0, y: -1 }),
|
|
16
16
|
right: Object.freeze({ x: 1, y: 0 }),
|
|
17
17
|
bottom: Object.freeze({ x: 0, y: 1 }),
|
|
18
18
|
left: Object.freeze({ x: -1, y: 0 })
|
|
19
|
-
}),
|
|
19
|
+
}), kt = Object.freeze({
|
|
20
20
|
top: "bottom",
|
|
21
21
|
right: "left",
|
|
22
22
|
bottom: "top",
|
|
23
23
|
left: "right"
|
|
24
|
-
}),
|
|
24
|
+
}), at = (e) => e === "left" || e === "right", Q = (e) => ({
|
|
25
25
|
x: e.left + e.width / 2,
|
|
26
26
|
y: e.top + e.height / 2
|
|
27
|
-
}),
|
|
27
|
+
}), X = (e, t, n = 1) => ({ x: e.x + t.x * n, y: e.y + t.y * n }), I = (e, t) => Math.hypot(t.x - e.x, t.y - e.y), wt = (e) => Math.round(e * 100) / 100, O = (e) => `${wt(e.x)} ${wt(e.y)}`, zt = () => "_" + Math.random().toString(36).substring(2, 11), ht = Object.freeze([
|
|
28
28
|
"top",
|
|
29
29
|
"right",
|
|
30
30
|
"bottom",
|
|
31
31
|
"left"
|
|
32
|
-
]),
|
|
33
|
-
...
|
|
32
|
+
]), Et = Object.freeze([
|
|
33
|
+
...ht,
|
|
34
34
|
"auto"
|
|
35
|
-
]),
|
|
35
|
+
]), It = Object.freeze([
|
|
36
36
|
"bezier",
|
|
37
37
|
"straight",
|
|
38
38
|
"orthogonal"
|
|
39
|
-
]),
|
|
39
|
+
]), Wt = Object.freeze([
|
|
40
40
|
"none",
|
|
41
41
|
"start",
|
|
42
42
|
"end",
|
|
43
43
|
"both"
|
|
44
|
-
]),
|
|
44
|
+
]), L = (e) => typeof e == "string" ? JSON.stringify(e) : e == null || typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) ? "an array" : typeof e == "object" ? "an object" : `a ${typeof e}`, et = (e, t) => {
|
|
45
45
|
if (typeof e != "object" || e === null || Array.isArray(e))
|
|
46
46
|
throw new TypeError(
|
|
47
|
-
`arclace: ${t} must be an object, not ${
|
|
47
|
+
`arclace: ${t} must be an object, not ${L(e)}`
|
|
48
48
|
);
|
|
49
|
-
},
|
|
50
|
-
const s = t.map((
|
|
49
|
+
}, W = (e, t, n) => {
|
|
50
|
+
const s = t.map((r) => `"${r}"`).join(", ");
|
|
51
51
|
if (typeof e != "string")
|
|
52
52
|
throw new TypeError(
|
|
53
|
-
`arclace: ${n} must be one of ${s}, not ${
|
|
53
|
+
`arclace: ${n} must be one of ${s}, not ${L(e)}`
|
|
54
54
|
);
|
|
55
55
|
if (!t.includes(e))
|
|
56
56
|
throw new RangeError(
|
|
57
|
-
`arclace: ${n} must be one of ${s}, not ${
|
|
57
|
+
`arclace: ${n} must be one of ${s}, not ${L(e)}`
|
|
58
58
|
);
|
|
59
59
|
return e;
|
|
60
|
-
},
|
|
60
|
+
}, S = (e, t, n) => {
|
|
61
61
|
if (typeof e != "number" || !Number.isFinite(e))
|
|
62
62
|
throw new TypeError(
|
|
63
|
-
`arclace: ${t} must be a finite number, not ${
|
|
63
|
+
`arclace: ${t} must be a finite number, not ${L(e)}`
|
|
64
64
|
);
|
|
65
65
|
if (n !== void 0 && e < n)
|
|
66
66
|
throw new RangeError(
|
|
67
|
-
`arclace: ${t} must be ${n} or more, not ${
|
|
67
|
+
`arclace: ${t} must be ${n} or more, not ${L(e)}`
|
|
68
68
|
);
|
|
69
69
|
return e;
|
|
70
|
-
},
|
|
70
|
+
}, J = (e, t) => {
|
|
71
71
|
if (typeof e != "boolean")
|
|
72
72
|
throw new TypeError(
|
|
73
|
-
`arclace: ${t} must be true or false, not ${
|
|
73
|
+
`arclace: ${t} must be true or false, not ${L(e)}`
|
|
74
74
|
);
|
|
75
75
|
return e;
|
|
76
|
-
},
|
|
76
|
+
}, H = (e, t, n = !1) => {
|
|
77
77
|
if (typeof e != "string" || n && e === "")
|
|
78
78
|
throw new TypeError(
|
|
79
|
-
`arclace: ${t} must be a ${n ? "non-empty " : ""}string, not ${
|
|
79
|
+
`arclace: ${t} must be a ${n ? "non-empty " : ""}string, not ${L(e)}`
|
|
80
80
|
);
|
|
81
81
|
return e;
|
|
82
|
-
},
|
|
83
|
-
|
|
82
|
+
}, Z = (e, t) => {
|
|
83
|
+
et(e, t);
|
|
84
84
|
const { x: n, y: s } = e;
|
|
85
|
-
return
|
|
86
|
-
},
|
|
87
|
-
id: (e, t) =>
|
|
88
|
-
type: (e, t) =>
|
|
89
|
-
startSide: (e, t) =>
|
|
90
|
-
endSide: (e, t) =>
|
|
91
|
-
arrow: (e, t) =>
|
|
92
|
-
label:
|
|
93
|
-
color:
|
|
94
|
-
className:
|
|
95
|
-
strokeWidth: (e, t) =>
|
|
96
|
-
dashed:
|
|
97
|
-
animated:
|
|
98
|
-
anchors:
|
|
99
|
-
gap: (e, t) =>
|
|
100
|
-
spread:
|
|
101
|
-
spacing: (e, t) =>
|
|
102
|
-
curvature: (e, t) =>
|
|
103
|
-
radius: (e, t) =>
|
|
104
|
-
offset: (e, t) =>
|
|
105
|
-
}),
|
|
106
|
-
|
|
107
|
-
for (const [n, s] of Object.entries(
|
|
108
|
-
const
|
|
109
|
-
|
|
85
|
+
return S(n, `${t}.x`), S(s, `${t}.y`), e;
|
|
86
|
+
}, Dt = Object.freeze({
|
|
87
|
+
id: (e, t) => H(e, t, !0),
|
|
88
|
+
type: (e, t) => W(e, It, t),
|
|
89
|
+
startSide: (e, t) => W(e, Et, t),
|
|
90
|
+
endSide: (e, t) => W(e, Et, t),
|
|
91
|
+
arrow: (e, t) => W(e, Wt, t),
|
|
92
|
+
label: H,
|
|
93
|
+
color: H,
|
|
94
|
+
className: H,
|
|
95
|
+
strokeWidth: (e, t) => S(e, t, 0),
|
|
96
|
+
dashed: J,
|
|
97
|
+
animated: J,
|
|
98
|
+
anchors: J,
|
|
99
|
+
gap: (e, t) => S(e, t),
|
|
100
|
+
spread: J,
|
|
101
|
+
spacing: (e, t) => S(e, t, 0),
|
|
102
|
+
curvature: (e, t) => S(e, t),
|
|
103
|
+
radius: (e, t) => S(e, t, 0),
|
|
104
|
+
offset: (e, t) => S(e, t, 0)
|
|
105
|
+
}), mt = (e, t = "options") => {
|
|
106
|
+
et(e, t);
|
|
107
|
+
for (const [n, s] of Object.entries(Dt)) {
|
|
108
|
+
const r = Object.hasOwn(e, n) ? e[n] : void 0;
|
|
109
|
+
r !== void 0 && s(r, `${t}.${n}`);
|
|
110
110
|
}
|
|
111
111
|
return e;
|
|
112
|
-
},
|
|
113
|
-
|
|
112
|
+
}, Ut = (e) => {
|
|
113
|
+
et(e, "options");
|
|
114
114
|
const { autoUpdate: t, className: n, defaults: s } = e;
|
|
115
115
|
if (t !== void 0 && typeof t != "boolean" && t !== "frame")
|
|
116
116
|
throw new RangeError(
|
|
117
|
-
`arclace: options.autoUpdate must be true, false or "frame", not ${
|
|
117
|
+
`arclace: options.autoUpdate must be true, false or "frame", not ${L(t)}`
|
|
118
118
|
);
|
|
119
|
-
if (n !== void 0 &&
|
|
119
|
+
if (n !== void 0 && H(n, "options.className"), s !== void 0 && (mt(s, "options.defaults"), s.id !== void 0))
|
|
120
120
|
throw new TypeError(
|
|
121
121
|
"arclace: options.defaults cannot set an id; ids belong to single connections"
|
|
122
122
|
);
|
|
123
123
|
return e;
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
},
|
|
124
|
+
}, qt = (e, t = 1e3) => Math.min(e / t, 1), Yt = (e, t, n) => t + (n - t) * e, Xt = (e, t = 1.1, n = 3.5, s = 1e3) => Yt(qt(e, s), t, n), Mt = (e, t, n, s) => {
|
|
125
|
+
Z(e, "start"), W(t, ht, "startSide"), Z(n, "end"), W(s, ht, "endSide");
|
|
126
|
+
}, Ht = (e, t) => (Z(e, "start"), Z(t, "end"), {
|
|
127
127
|
d: `M ${O(e)} L ${O(t)}`,
|
|
128
128
|
labelPoint: { x: (e.x + t.x) / 2, y: (e.y + t.y) / 2 }
|
|
129
|
-
}),
|
|
130
|
-
|
|
131
|
-
const i = I(e, n), c = i /
|
|
129
|
+
}), Gt = (e, t, n, s, r = 1) => {
|
|
130
|
+
Mt(e, t, n, s), S(r, "curvature");
|
|
131
|
+
const i = I(e, n), c = i / Xt(i) * r, a = X(e, Y[t], c), h = X(n, Y[s], c);
|
|
132
132
|
return {
|
|
133
133
|
d: `M ${O(e)} C ${O(a)}, ${O(h)}, ${O(n)}`,
|
|
134
134
|
// Point on the curve at t = 0.5
|
|
@@ -137,26 +137,26 @@ const B = Object.freeze({
|
|
|
137
137
|
y: (e.y + 3 * a.y + 3 * h.y + n.y) / 8
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
|
-
},
|
|
140
|
+
}, Vt = (e) => {
|
|
141
141
|
const t = e.filter(
|
|
142
142
|
(n, s) => s === 0 || I(n, e[s - 1]) > 0.01
|
|
143
143
|
);
|
|
144
144
|
return t.filter((n, s) => {
|
|
145
145
|
if (s === 0 || s === t.length - 1) return !0;
|
|
146
|
-
const
|
|
146
|
+
const r = t[s - 1], i = t[s + 1], c = (n.x - r.x) * (i.y - r.y) - (n.y - r.y) * (i.x - r.x);
|
|
147
147
|
return Math.abs(c) > 0.01;
|
|
148
148
|
});
|
|
149
|
-
},
|
|
149
|
+
}, Jt = (e, t) => {
|
|
150
150
|
if (e.length === 0) return "";
|
|
151
|
-
const n = (
|
|
152
|
-
const a = I(
|
|
151
|
+
const n = (r, i, c) => {
|
|
152
|
+
const a = I(r, i);
|
|
153
153
|
return {
|
|
154
|
-
x:
|
|
155
|
-
y:
|
|
154
|
+
x: r.x + (i.x - r.x) / a * c,
|
|
155
|
+
y: r.y + (i.y - r.y) / a * c
|
|
156
156
|
};
|
|
157
157
|
}, s = [`M ${O(e[0])}`];
|
|
158
|
-
for (let
|
|
159
|
-
const i = e[
|
|
158
|
+
for (let r = 1; r < e.length - 1; r++) {
|
|
159
|
+
const i = e[r - 1], c = e[r], a = e[r + 1], h = Math.min(
|
|
160
160
|
t,
|
|
161
161
|
I(i, c) / 2,
|
|
162
162
|
I(c, a) / 2
|
|
@@ -171,68 +171,68 @@ const B = Object.freeze({
|
|
|
171
171
|
);
|
|
172
172
|
}
|
|
173
173
|
return e.length > 1 && s.push(`L ${O(e[e.length - 1])}`), s.join(" ");
|
|
174
|
-
},
|
|
175
|
-
const t = e.slice(1).map((s,
|
|
176
|
-
let n = t.reduce((s,
|
|
174
|
+
}, Kt = (e) => {
|
|
175
|
+
const t = e.slice(1).map((s, r) => I(e[r], s));
|
|
176
|
+
let n = t.reduce((s, r) => s + r, 0) / 2;
|
|
177
177
|
for (let s = 0; s < t.length; s++) {
|
|
178
178
|
if (n <= t[s] && t[s] > 0) {
|
|
179
|
-
const
|
|
179
|
+
const r = n / t[s];
|
|
180
180
|
return {
|
|
181
|
-
x: e[s].x + (e[s + 1].x - e[s].x) *
|
|
182
|
-
y: e[s].y + (e[s + 1].y - e[s].y) *
|
|
181
|
+
x: e[s].x + (e[s + 1].x - e[s].x) * r,
|
|
182
|
+
y: e[s].y + (e[s + 1].y - e[s].y) * r
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
n -= t[s];
|
|
186
186
|
}
|
|
187
187
|
return { ...e[0] };
|
|
188
|
-
},
|
|
188
|
+
}, Ot = Object.freeze({
|
|
189
189
|
top: "left",
|
|
190
190
|
bottom: "right",
|
|
191
191
|
left: "top",
|
|
192
192
|
right: "bottom"
|
|
193
|
-
}),
|
|
193
|
+
}), ot = (e) => ({
|
|
194
194
|
x: e.y,
|
|
195
195
|
y: e.x
|
|
196
|
-
}),
|
|
197
|
-
if (!
|
|
198
|
-
return
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
).map(
|
|
205
|
-
const i =
|
|
206
|
-
if (
|
|
207
|
-
if (s ===
|
|
196
|
+
}), Pt = (e, t, n, s, r = 20) => {
|
|
197
|
+
if (!at(t))
|
|
198
|
+
return Pt(
|
|
199
|
+
ot(e),
|
|
200
|
+
Ot[t],
|
|
201
|
+
ot(n),
|
|
202
|
+
Ot[s],
|
|
203
|
+
r
|
|
204
|
+
).map(ot);
|
|
205
|
+
const i = Y[t], c = Y[s], a = X(e, i, r), h = X(n, c, r);
|
|
206
|
+
if (at(s)) {
|
|
207
|
+
if (s === kt[t]) {
|
|
208
208
|
if ((h.x - a.x) * i.x >= 0) {
|
|
209
|
-
const
|
|
210
|
-
return [e, { x:
|
|
209
|
+
const $ = (e.x + n.x) / 2;
|
|
210
|
+
return [e, { x: $, y: e.y }, { x: $, y: n.y }, n];
|
|
211
211
|
}
|
|
212
212
|
const u = (a.y + h.y) / 2;
|
|
213
213
|
return [e, a, { x: a.x, y: u }, { x: h.x, y: u }, h, n];
|
|
214
214
|
}
|
|
215
|
-
const
|
|
216
|
-
return [e, { x:
|
|
217
|
-
}
|
|
218
|
-
const
|
|
219
|
-
return (
|
|
220
|
-
},
|
|
221
|
-
|
|
222
|
-
const c =
|
|
223
|
-
|
|
215
|
+
const f = i.x > 0 ? Math.max(a.x, h.x) : Math.min(a.x, h.x);
|
|
216
|
+
return [e, { x: f, y: e.y }, { x: f, y: n.y }, n];
|
|
217
|
+
}
|
|
218
|
+
const d = { x: n.x, y: e.y };
|
|
219
|
+
return (d.x - e.x) * i.x > 0 && (d.y - n.y) * c.y > 0 ? [e, d, n] : [e, a, { x: a.x, y: h.y }, h, n];
|
|
220
|
+
}, Qt = (e, t, n, s, { radius: r = 8, offset: i = 20 } = {}) => {
|
|
221
|
+
Mt(e, t, n, s), S(r, "radius", 0), S(i, "offset", 0);
|
|
222
|
+
const c = Vt(
|
|
223
|
+
Pt(e, t, n, s, i)
|
|
224
224
|
);
|
|
225
225
|
return {
|
|
226
|
-
d:
|
|
227
|
-
labelPoint:
|
|
226
|
+
d: Jt(c, r),
|
|
227
|
+
labelPoint: Kt(c)
|
|
228
228
|
};
|
|
229
|
-
},
|
|
230
|
-
const n = document.createElementNS(
|
|
231
|
-
return
|
|
232
|
-
},
|
|
229
|
+
}, Zt = "http://www.w3.org/2000/svg", P = (e, t = {}) => {
|
|
230
|
+
const n = document.createElementNS(Zt, e);
|
|
231
|
+
return v(n, t), n;
|
|
232
|
+
}, v = (e, t) => {
|
|
233
233
|
for (const [n, s] of Object.entries(t))
|
|
234
234
|
s == null ? e.removeAttribute(n) : e.setAttribute(n, String(s));
|
|
235
|
-
},
|
|
235
|
+
}, te = Object.freeze({
|
|
236
236
|
type: "bezier",
|
|
237
237
|
startSide: "auto",
|
|
238
238
|
endSide: "auto",
|
|
@@ -247,45 +247,49 @@ const B = Object.freeze({
|
|
|
247
247
|
curvature: 1,
|
|
248
248
|
radius: 8,
|
|
249
249
|
offset: 20
|
|
250
|
-
}),
|
|
250
|
+
}), $t = (e) => Object.fromEntries(
|
|
251
251
|
Object.entries(e).filter(([, t]) => t !== void 0)
|
|
252
|
-
),
|
|
253
|
-
var
|
|
254
|
-
const
|
|
252
|
+
), rt = 4;
|
|
253
|
+
var C, G, _, B, V, k, g, T, A, E, y, Tt, lt, ut, Ct, dt, Nt, Lt;
|
|
254
|
+
const bt = class bt {
|
|
255
255
|
constructor(t) {
|
|
256
|
-
p(this,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
256
|
+
p(this, y);
|
|
257
|
+
M(this, "id");
|
|
258
|
+
M(this, "startElement");
|
|
259
|
+
M(this, "endElement");
|
|
260
260
|
/**
|
|
261
261
|
* The `<g>` element holding everything this connection draws.
|
|
262
262
|
*/
|
|
263
|
-
|
|
263
|
+
M(this, "element");
|
|
264
264
|
/**
|
|
265
265
|
* The `<path>` element of the line.
|
|
266
266
|
*/
|
|
267
|
-
|
|
268
|
-
p(this,
|
|
269
|
-
p(this,
|
|
267
|
+
M(this, "path");
|
|
268
|
+
p(this, C, null);
|
|
269
|
+
p(this, G, !1);
|
|
270
270
|
p(this, _);
|
|
271
|
-
p(this,
|
|
272
|
-
p(this,
|
|
273
|
-
p(this,
|
|
274
|
-
p(this,
|
|
271
|
+
p(this, B);
|
|
272
|
+
p(this, V);
|
|
273
|
+
p(this, k, null);
|
|
274
|
+
p(this, g, null);
|
|
275
|
+
p(this, T, null);
|
|
276
|
+
// The background's box relative to the label's anchor point, measured once
|
|
277
|
+
// per label
|
|
278
|
+
p(this, A, null);
|
|
275
279
|
p(this, E, null);
|
|
276
280
|
const {
|
|
277
281
|
id: n,
|
|
278
282
|
startElement: s,
|
|
279
|
-
endElement:
|
|
283
|
+
endElement: r,
|
|
280
284
|
options: i,
|
|
281
285
|
defaults: c = {},
|
|
282
286
|
owner: a
|
|
283
287
|
} = t;
|
|
284
|
-
this.id = n, this.startElement = s, this.endElement =
|
|
288
|
+
this.id = n, this.startElement = s, this.endElement = r, l(this, _, a), l(this, B, { ...i }), l(this, V, c), this.element = P("g", { "data-arc-id": n }), this.path = P("path", {
|
|
285
289
|
class: "arc-path",
|
|
286
290
|
fill: "none",
|
|
287
291
|
stroke: "currentColor"
|
|
288
|
-
}), this.element.appendChild(this.path),
|
|
292
|
+
}), this.element.appendChild(this.path), m(this, y, ut).call(this);
|
|
289
293
|
}
|
|
290
294
|
/**
|
|
291
295
|
* Creates a connection for its owner. Options must already be validated.
|
|
@@ -293,23 +297,23 @@ const pt = class pt {
|
|
|
293
297
|
* @internal
|
|
294
298
|
*/
|
|
295
299
|
static _create(t) {
|
|
296
|
-
return new
|
|
300
|
+
return new bt(t);
|
|
297
301
|
}
|
|
298
302
|
/**
|
|
299
303
|
* The geometry from the last update, or `null` when the connection is
|
|
300
304
|
* hidden because one of its elements is not rendered.
|
|
301
305
|
*/
|
|
302
306
|
get geometry() {
|
|
303
|
-
return
|
|
307
|
+
return o(this, C);
|
|
304
308
|
}
|
|
305
309
|
/**
|
|
306
310
|
* The connection's options merged with the instance defaults.
|
|
307
311
|
*/
|
|
308
312
|
get options() {
|
|
309
313
|
return {
|
|
310
|
-
...
|
|
311
|
-
|
|
312
|
-
|
|
314
|
+
...te,
|
|
315
|
+
...$t(o(this, V)),
|
|
316
|
+
...$t(o(this, B)),
|
|
313
317
|
id: this.id
|
|
314
318
|
};
|
|
315
319
|
}
|
|
@@ -325,42 +329,42 @@ const pt = class pt {
|
|
|
325
329
|
* @throws {ArclaceError} When the connection has been removed.
|
|
326
330
|
*/
|
|
327
331
|
setOptions(t) {
|
|
328
|
-
if (
|
|
329
|
-
throw new
|
|
330
|
-
if (
|
|
332
|
+
if (o(this, G))
|
|
333
|
+
throw new R(`connection "${this.id}" has been removed`);
|
|
334
|
+
if (mt(t), t.id !== void 0)
|
|
331
335
|
throw new TypeError("arclace: setOptions() cannot change the id");
|
|
332
|
-
return l(this,
|
|
336
|
+
return l(this, B, { ...o(this, B), ...t }), m(this, y, ut).call(this), o(this, _).update(), this;
|
|
333
337
|
}
|
|
334
338
|
/**
|
|
335
339
|
* Redraws every connection of the owning instance.
|
|
336
340
|
*/
|
|
337
341
|
update() {
|
|
338
|
-
|
|
342
|
+
o(this, _).update();
|
|
339
343
|
}
|
|
340
344
|
/**
|
|
341
345
|
* Removes this connection.
|
|
342
346
|
*/
|
|
343
347
|
remove() {
|
|
344
|
-
|
|
348
|
+
o(this, _).disconnect(this);
|
|
345
349
|
}
|
|
346
350
|
/**
|
|
347
351
|
* Draws the connection between two attachment points.
|
|
348
352
|
*
|
|
349
353
|
* @internal
|
|
350
354
|
*/
|
|
351
|
-
_draw(t, n, s,
|
|
352
|
-
const { arrow: i, strokeWidth: c } = this.options, a =
|
|
353
|
-
l(this,
|
|
355
|
+
_draw(t, n, s, r) {
|
|
356
|
+
const { arrow: i, strokeWidth: c } = this.options, a = rt * c, h = i === "start" || i === "both" ? m(this, y, lt).call(this, t, n, s, a) : t, d = i === "end" || i === "both" ? m(this, y, lt).call(this, s, r, t, a) : s, { d: f, labelPoint: u } = m(this, y, Tt).call(this, h, n, d, r);
|
|
357
|
+
l(this, C, Object.freeze({
|
|
354
358
|
start: t,
|
|
355
359
|
end: s,
|
|
356
360
|
startSide: n,
|
|
357
|
-
endSide:
|
|
361
|
+
endSide: r,
|
|
358
362
|
labelPoint: u,
|
|
359
|
-
d
|
|
360
|
-
})), this.element.removeAttribute("display"),
|
|
363
|
+
d: f
|
|
364
|
+
})), this.element.removeAttribute("display"), v(this.element, {
|
|
361
365
|
"data-start-side": n,
|
|
362
|
-
"data-end-side":
|
|
363
|
-
}), this.path.setAttribute("d",
|
|
366
|
+
"data-end-side": r
|
|
367
|
+
}), this.path.setAttribute("d", f), o(this, g) && m(this, y, dt).call(this, u), o(this, E) && (v(o(this, E)[0], { cx: t.x, cy: t.y }), v(o(this, E)[1], { cx: s.x, cy: s.y }));
|
|
364
368
|
}
|
|
365
369
|
/**
|
|
366
370
|
* Hides the connection.
|
|
@@ -368,7 +372,7 @@ const pt = class pt {
|
|
|
368
372
|
* @internal
|
|
369
373
|
*/
|
|
370
374
|
_hide() {
|
|
371
|
-
l(this,
|
|
375
|
+
l(this, C, null), this.element.setAttribute("display", "none");
|
|
372
376
|
}
|
|
373
377
|
/**
|
|
374
378
|
* Removes the connection's elements from the overlay.
|
|
@@ -376,94 +380,120 @@ const pt = class pt {
|
|
|
376
380
|
* @internal
|
|
377
381
|
*/
|
|
378
382
|
_dispose() {
|
|
379
|
-
l(this,
|
|
383
|
+
l(this, G, !0), this.element.remove();
|
|
380
384
|
}
|
|
381
385
|
};
|
|
382
|
-
|
|
386
|
+
C = new WeakMap(), G = new WeakMap(), _ = new WeakMap(), B = new WeakMap(), V = new WeakMap(), k = new WeakMap(), g = new WeakMap(), T = new WeakMap(), A = new WeakMap(), E = new WeakMap(), y = new WeakSet(), Tt = function(t, n, s, r) {
|
|
383
387
|
const { type: i, curvature: c, radius: a, offset: h } = this.options;
|
|
384
|
-
return i === "straight" ?
|
|
388
|
+
return i === "straight" ? Ht(t, s) : i === "orthogonal" ? Qt(t, n, s, r, {
|
|
385
389
|
radius: a,
|
|
386
390
|
offset: h
|
|
387
|
-
}) :
|
|
388
|
-
},
|
|
389
|
-
const i = I(t, s), c = Math.min(
|
|
390
|
-
return this.options.type !== "straight" ?
|
|
391
|
+
}) : Gt(t, n, s, r, c);
|
|
392
|
+
}, lt = function(t, n, s, r) {
|
|
393
|
+
const i = I(t, s), c = Math.min(r, i / 3);
|
|
394
|
+
return this.options.type !== "straight" ? X(t, Y[n], c) : i === 0 ? t : {
|
|
391
395
|
x: t.x + (s.x - t.x) / i * c,
|
|
392
396
|
y: t.y + (s.y - t.y) / i * c
|
|
393
397
|
};
|
|
394
|
-
},
|
|
398
|
+
}, ut = function() {
|
|
395
399
|
const {
|
|
396
400
|
type: t,
|
|
397
401
|
arrow: n,
|
|
398
402
|
label: s,
|
|
399
|
-
color:
|
|
403
|
+
color: r,
|
|
400
404
|
strokeWidth: i,
|
|
401
405
|
dashed: c,
|
|
402
406
|
animated: a,
|
|
403
407
|
anchors: h,
|
|
404
|
-
className:
|
|
405
|
-
} = this.options,
|
|
406
|
-
(c || a) &&
|
|
407
|
-
class:
|
|
408
|
+
className: d
|
|
409
|
+
} = this.options, f = ["arc-connection", `arc-${t}`];
|
|
410
|
+
(c || a) && f.push("arc-dashed"), a && f.push("arc-animated"), d && f.push(...d.split(/\s+/).filter(Boolean)), v(this.element, {
|
|
411
|
+
class: f.join(" "),
|
|
408
412
|
"data-type": t
|
|
409
|
-
}), this.element.style.color =
|
|
413
|
+
}), this.element.style.color = r ?? "", v(this.path, {
|
|
410
414
|
"stroke-width": i,
|
|
411
415
|
"stroke-dasharray": c || a ? "6 6" : null
|
|
412
|
-
}),
|
|
413
|
-
},
|
|
416
|
+
}), m(this, y, Ct).call(this, n), m(this, y, Nt).call(this, s), m(this, y, Lt).call(this, h, i);
|
|
417
|
+
}, Ct = function(t) {
|
|
414
418
|
var s;
|
|
415
419
|
if (t === "none") {
|
|
416
|
-
(s =
|
|
420
|
+
(s = o(this, k)) == null || s.remove(), l(this, k, null), v(this.path, { "marker-start": null, "marker-end": null });
|
|
417
421
|
return;
|
|
418
422
|
}
|
|
419
|
-
|
|
420
|
-
id: `arc-arrow-${
|
|
423
|
+
o(this, k) || (l(this, k, P("marker", {
|
|
424
|
+
id: `arc-arrow-${zt()}`,
|
|
421
425
|
class: "arc-marker",
|
|
422
426
|
viewBox: "0 0 10 10",
|
|
423
427
|
refX: 0,
|
|
424
428
|
refY: 5,
|
|
425
|
-
markerWidth:
|
|
426
|
-
markerHeight:
|
|
429
|
+
markerWidth: rt,
|
|
430
|
+
markerHeight: rt,
|
|
427
431
|
markerUnits: "strokeWidth",
|
|
428
432
|
orient: "auto-start-reverse"
|
|
429
|
-
})),
|
|
430
|
-
|
|
433
|
+
})), o(this, k).appendChild(
|
|
434
|
+
P("path", {
|
|
431
435
|
d: "M 0 0 L 10 5 L 0 10 z",
|
|
432
436
|
fill: "currentColor"
|
|
433
437
|
})
|
|
434
|
-
), this.element.insertBefore(
|
|
435
|
-
const n = `url(#${
|
|
436
|
-
|
|
438
|
+
), this.element.insertBefore(o(this, k), this.path));
|
|
439
|
+
const n = `url(#${o(this, k).id})`;
|
|
440
|
+
v(this.path, {
|
|
437
441
|
"marker-start": t === "start" || t === "both" ? n : null,
|
|
438
442
|
"marker-end": t === "end" || t === "both" ? n : null
|
|
439
443
|
});
|
|
440
|
-
},
|
|
444
|
+
}, dt = function(t) {
|
|
441
445
|
var n;
|
|
442
|
-
if (
|
|
443
|
-
|
|
446
|
+
if (v(o(this, g), { ...t }), !((n = o(this, A)) != null && n.width) && typeof o(this, g).getBBox == "function") {
|
|
447
|
+
const { x: s, y: r, width: i, height: c } = o(this, g).getBBox(), a = getComputedStyle(o(this, T)), [h, d, f, u] = [
|
|
448
|
+
a.paddingTop,
|
|
449
|
+
a.paddingRight,
|
|
450
|
+
a.paddingBottom,
|
|
451
|
+
a.paddingLeft
|
|
452
|
+
].map(($) => parseFloat($) || 0);
|
|
453
|
+
l(this, A, {
|
|
454
|
+
x: s - t.x - u,
|
|
455
|
+
y: r - t.y - h,
|
|
456
|
+
width: i + u + d,
|
|
457
|
+
height: c + h + f
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
o(this, A) && v(o(this, T), {
|
|
461
|
+
x: t.x + o(this, A).x,
|
|
462
|
+
y: t.y + o(this, A).y,
|
|
463
|
+
width: o(this, A).width,
|
|
464
|
+
height: o(this, A).height
|
|
465
|
+
});
|
|
466
|
+
}, Nt = function(t) {
|
|
467
|
+
var n, s;
|
|
468
|
+
if (l(this, A, null), !t) {
|
|
469
|
+
(n = o(this, g)) == null || n.remove(), (s = o(this, T)) == null || s.remove(), l(this, g, null), l(this, T, null);
|
|
444
470
|
return;
|
|
445
471
|
}
|
|
446
|
-
|
|
472
|
+
o(this, g) || (l(this, g, P("text", {
|
|
447
473
|
class: "arc-label",
|
|
448
474
|
fill: "currentColor",
|
|
449
475
|
"text-anchor": "middle",
|
|
450
476
|
"dominant-baseline": "central"
|
|
451
|
-
})),
|
|
452
|
-
|
|
477
|
+
})), l(this, T, P("rect", {
|
|
478
|
+
class: "arc-label-bg",
|
|
479
|
+
fill: "none",
|
|
480
|
+
rx: 4
|
|
481
|
+
})), this.path.after(o(this, T), o(this, g))), o(this, g).textContent = t, o(this, C) && m(this, y, dt).call(this, o(this, C).labelPoint);
|
|
482
|
+
}, Lt = function(t, n) {
|
|
453
483
|
var s;
|
|
454
484
|
if (!t) {
|
|
455
|
-
(s =
|
|
485
|
+
(s = o(this, E)) == null || s.forEach((r) => r.remove()), l(this, E, null);
|
|
456
486
|
return;
|
|
457
487
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
]), this.element.append(...
|
|
462
|
-
(
|
|
488
|
+
o(this, E) || (l(this, E, [
|
|
489
|
+
P("circle", { class: "arc-anchor arc-anchor-start" }),
|
|
490
|
+
P("circle", { class: "arc-anchor arc-anchor-end" })
|
|
491
|
+
]), this.element.append(...o(this, E))), o(this, E).forEach(
|
|
492
|
+
(r) => v(r, { r: n + 2, fill: "currentColor" })
|
|
463
493
|
);
|
|
464
494
|
};
|
|
465
|
-
let
|
|
466
|
-
const
|
|
495
|
+
let tt = bt;
|
|
496
|
+
const ee = (e) => {
|
|
467
497
|
const t = e.getBoundingClientRect(), { clientWidth: n, clientHeight: s } = e;
|
|
468
498
|
return {
|
|
469
499
|
left: t.left,
|
|
@@ -471,28 +501,28 @@ const Qt = (e) => {
|
|
|
471
501
|
scaleX: n > 0 && t.width > 0 ? t.width / n : 1,
|
|
472
502
|
scaleY: s > 0 && t.height > 0 ? t.height / s : 1
|
|
473
503
|
};
|
|
474
|
-
},
|
|
475
|
-
const n = e.getBoundingClientRect(), s = (n.left - t.left) / t.scaleX,
|
|
504
|
+
}, vt = (e, t) => {
|
|
505
|
+
const n = e.getBoundingClientRect(), s = (n.left - t.left) / t.scaleX, r = (n.top - t.top) / t.scaleY, i = n.width / t.scaleX, c = n.height / t.scaleY;
|
|
476
506
|
return {
|
|
477
507
|
left: s,
|
|
478
|
-
top:
|
|
508
|
+
top: r,
|
|
479
509
|
width: i,
|
|
480
510
|
height: c,
|
|
481
511
|
right: s + i,
|
|
482
|
-
bottom:
|
|
512
|
+
bottom: r + c
|
|
483
513
|
};
|
|
484
|
-
},
|
|
514
|
+
}, At = (e) => e.isConnected && e.getClientRects().length > 0, Rt = (e, t = "element") => {
|
|
485
515
|
try {
|
|
486
516
|
return document.querySelector(e);
|
|
487
517
|
} catch (n) {
|
|
488
|
-
throw new
|
|
518
|
+
throw new R(`${t} "${e}" is not a valid selector`, {
|
|
489
519
|
cause: n
|
|
490
520
|
});
|
|
491
521
|
}
|
|
492
|
-
},
|
|
522
|
+
}, K = (e, t = "element") => {
|
|
493
523
|
if (typeof e == "string") {
|
|
494
|
-
const n =
|
|
495
|
-
if (!n) throw new
|
|
524
|
+
const n = Rt(e, t);
|
|
525
|
+
if (!n) throw new R(`no ${t} matches "${e}"`);
|
|
496
526
|
return n;
|
|
497
527
|
}
|
|
498
528
|
if (!(e instanceof Element))
|
|
@@ -500,40 +530,40 @@ const Qt = (e) => {
|
|
|
500
530
|
`arclace: ${t} must be an Element or a selector string`
|
|
501
531
|
);
|
|
502
532
|
return e;
|
|
503
|
-
},
|
|
504
|
-
const n =
|
|
505
|
-
return (c === a ? Math.abs(
|
|
506
|
-
},
|
|
507
|
-
startSide: n === "auto" ?
|
|
508
|
-
endSide: s === "auto" ?
|
|
509
|
-
}),
|
|
533
|
+
}, jt = (e, t) => {
|
|
534
|
+
const n = Q(e), s = Q(t), r = s.x - n.x, i = s.y - n.y, c = Math.max(t.left - e.right, e.left - t.right), a = Math.max(t.top - e.bottom, e.top - t.bottom);
|
|
535
|
+
return (c === a ? Math.abs(r) >= Math.abs(i) : c > a) ? r >= 0 ? "right" : "left" : i >= 0 ? "bottom" : "top";
|
|
536
|
+
}, ne = (e, t, n = "auto", s = "auto") => ({
|
|
537
|
+
startSide: n === "auto" ? jt(e, t) : n,
|
|
538
|
+
endSide: s === "auto" ? kt[jt(e, t)] : s
|
|
539
|
+
}), St = (e, t, {
|
|
510
540
|
index: n = 0,
|
|
511
541
|
count: s = 1,
|
|
512
|
-
spacing:
|
|
542
|
+
spacing: r = 16,
|
|
513
543
|
gap: i = 0
|
|
514
544
|
} = {}) => {
|
|
515
|
-
const c = t === "top" || t === "bottom" ? e.width : e.height, a = s > 1 ? Math.min(
|
|
545
|
+
const c = t === "top" || t === "bottom" ? e.width : e.height, a = s > 1 ? Math.min(r, c / s) : 0, h = (n - (s - 1) / 2) * a, { x: d, y: f } = Q(e);
|
|
516
546
|
let u;
|
|
517
547
|
switch (t) {
|
|
518
548
|
case "top":
|
|
519
|
-
u = { x:
|
|
549
|
+
u = { x: d + h, y: e.top };
|
|
520
550
|
break;
|
|
521
551
|
case "bottom":
|
|
522
|
-
u = { x:
|
|
552
|
+
u = { x: d + h, y: e.bottom };
|
|
523
553
|
break;
|
|
524
554
|
case "left":
|
|
525
|
-
u = { x: e.left, y:
|
|
555
|
+
u = { x: e.left, y: f + h };
|
|
526
556
|
break;
|
|
527
557
|
case "right":
|
|
528
|
-
u = { x: e.right, y:
|
|
558
|
+
u = { x: e.right, y: f + h };
|
|
529
559
|
break;
|
|
530
560
|
}
|
|
531
|
-
return
|
|
532
|
-
},
|
|
561
|
+
return X(u, Y[t], i);
|
|
562
|
+
}, it = (e) => typeof requestAnimationFrame == "function" ? requestAnimationFrame(e) : setTimeout(e, 16), ct = (e) => {
|
|
533
563
|
typeof cancelAnimationFrame == "function" ? cancelAnimationFrame(e) : clearTimeout(e);
|
|
534
564
|
};
|
|
535
|
-
var
|
|
536
|
-
class
|
|
565
|
+
var D, b, j, F, N, x, U, q, w, ft, pt, yt, z, _t;
|
|
566
|
+
class se {
|
|
537
567
|
/**
|
|
538
568
|
* @throws {TypeError} When an option has the wrong type.
|
|
539
569
|
* @throws {RangeError} When an option is out of range.
|
|
@@ -541,31 +571,31 @@ class te {
|
|
|
541
571
|
* found.
|
|
542
572
|
*/
|
|
543
573
|
constructor(t = {}) {
|
|
544
|
-
p(this,
|
|
574
|
+
p(this, w);
|
|
545
575
|
/**
|
|
546
576
|
* The element the overlay was added to.
|
|
547
577
|
*/
|
|
548
|
-
|
|
578
|
+
M(this, "container");
|
|
549
579
|
/**
|
|
550
580
|
* The SVG overlay all lines are drawn in.
|
|
551
581
|
*/
|
|
552
|
-
|
|
553
|
-
p(this,
|
|
582
|
+
M(this, "svg");
|
|
583
|
+
p(this, D);
|
|
554
584
|
p(this, b, /* @__PURE__ */ new Map());
|
|
555
|
-
p(this,
|
|
556
|
-
p(this,
|
|
557
|
-
p(this,
|
|
585
|
+
p(this, j, 0);
|
|
586
|
+
p(this, F, 0);
|
|
587
|
+
p(this, N, !1);
|
|
558
588
|
p(this, x, null);
|
|
559
|
-
p(this, D, null);
|
|
560
589
|
p(this, U, null);
|
|
561
|
-
p(this,
|
|
562
|
-
|
|
563
|
-
|
|
590
|
+
p(this, q, null);
|
|
591
|
+
p(this, z, () => {
|
|
592
|
+
o(this, j) || o(this, N) || l(this, j, it(() => {
|
|
593
|
+
l(this, j, 0), this.update();
|
|
564
594
|
}));
|
|
565
595
|
});
|
|
566
596
|
if (typeof document > "u")
|
|
567
|
-
throw new
|
|
568
|
-
l(this,
|
|
597
|
+
throw new R("a DOM is required");
|
|
598
|
+
l(this, D, Ut(t)), this.container = t.container ? K(t.container, "container") : document.body, this.container !== document.body && getComputedStyle(this.container).position === "static" && (l(this, q, this.container.style.position), this.container.style.position = "relative"), this.svg = P("svg", {
|
|
569
599
|
class: ["arc-svg", t.className].filter(Boolean).join(" "),
|
|
570
600
|
"aria-hidden": "true"
|
|
571
601
|
}), Object.assign(this.svg.style, {
|
|
@@ -576,13 +606,13 @@ class te {
|
|
|
576
606
|
height: "100%",
|
|
577
607
|
overflow: "visible",
|
|
578
608
|
pointerEvents: "none"
|
|
579
|
-
}), this.container.prepend(this.svg),
|
|
609
|
+
}), this.container.prepend(this.svg), m(this, w, _t).call(this);
|
|
580
610
|
}
|
|
581
611
|
/**
|
|
582
612
|
* All current connections, in the order they were made.
|
|
583
613
|
*/
|
|
584
614
|
get connections() {
|
|
585
|
-
return [...
|
|
615
|
+
return [...o(this, b).values()];
|
|
586
616
|
}
|
|
587
617
|
/**
|
|
588
618
|
* Connects two elements and draws the line right away.
|
|
@@ -600,8 +630,8 @@ class te {
|
|
|
600
630
|
* ```
|
|
601
631
|
*/
|
|
602
632
|
connect(t, n, s = {}) {
|
|
603
|
-
const
|
|
604
|
-
return this.update(),
|
|
633
|
+
const r = m(this, w, pt).call(this, m(this, w, ft).call(this, t, n, s, "options"));
|
|
634
|
+
return this.update(), r;
|
|
605
635
|
}
|
|
606
636
|
/**
|
|
607
637
|
* Connects many pairs of elements and draws them in one go. Every
|
|
@@ -625,23 +655,23 @@ class te {
|
|
|
625
655
|
throw new TypeError(
|
|
626
656
|
"arclace: connectAll() needs an array of definitions"
|
|
627
657
|
);
|
|
628
|
-
const n = /* @__PURE__ */ new Set(),
|
|
658
|
+
const n = /* @__PURE__ */ new Set(), r = t.map((i, c) => {
|
|
629
659
|
const a = `definitions[${c}]`;
|
|
630
|
-
|
|
631
|
-
const { startElement: h, endElement:
|
|
660
|
+
et(i, a);
|
|
661
|
+
const { startElement: h, endElement: d, ...f } = i, u = m(this, w, ft).call(this, h, d, f, a);
|
|
632
662
|
if (n.has(u.id))
|
|
633
|
-
throw new
|
|
663
|
+
throw new R(
|
|
634
664
|
`${a}.id "${u.id}" is used more than once`
|
|
635
665
|
);
|
|
636
666
|
return n.add(u.id), u;
|
|
637
|
-
}).map((i) =>
|
|
638
|
-
return this.update(),
|
|
667
|
+
}).map((i) => m(this, w, pt).call(this, i));
|
|
668
|
+
return this.update(), r;
|
|
639
669
|
}
|
|
640
670
|
/**
|
|
641
671
|
* Returns the connection with the given id.
|
|
642
672
|
*/
|
|
643
673
|
get(t) {
|
|
644
|
-
return
|
|
674
|
+
return o(this, b).get(t);
|
|
645
675
|
}
|
|
646
676
|
/**
|
|
647
677
|
* Returns every connection that starts or ends at an element. A selector
|
|
@@ -651,7 +681,7 @@ class te {
|
|
|
651
681
|
* @throws {ArclaceError} When the selector is invalid.
|
|
652
682
|
*/
|
|
653
683
|
find(t) {
|
|
654
|
-
const n = typeof t == "string" ?
|
|
684
|
+
const n = typeof t == "string" ? Rt(t) : K(t);
|
|
655
685
|
return n ? this.connections.filter(
|
|
656
686
|
(s) => s.startElement === n || s.endElement === n
|
|
657
687
|
) : [];
|
|
@@ -675,10 +705,10 @@ class te {
|
|
|
675
705
|
disconnect(t) {
|
|
676
706
|
let n;
|
|
677
707
|
if (t != null) {
|
|
678
|
-
if (t instanceof
|
|
708
|
+
if (t instanceof tt)
|
|
679
709
|
n = [t];
|
|
680
|
-
else if (typeof t == "string" &&
|
|
681
|
-
n = [
|
|
710
|
+
else if (typeof t == "string" && o(this, b).has(t))
|
|
711
|
+
n = [o(this, b).get(t)];
|
|
682
712
|
else if (typeof t == "string" || t instanceof Element)
|
|
683
713
|
n = this.find(t);
|
|
684
714
|
else
|
|
@@ -686,7 +716,7 @@ class te {
|
|
|
686
716
|
"arclace: disconnect() needs a connection, an id, an element or a selector"
|
|
687
717
|
);
|
|
688
718
|
for (const s of n)
|
|
689
|
-
|
|
719
|
+
o(this, b).get(s.id) === s && (o(this, b).delete(s.id), s._dispose(), m(this, w, yt).call(this, s.startElement), m(this, w, yt).call(this, s.endElement));
|
|
690
720
|
n.length > 0 && this.update();
|
|
691
721
|
}
|
|
692
722
|
}
|
|
@@ -695,9 +725,9 @@ class te {
|
|
|
695
725
|
*/
|
|
696
726
|
clear() {
|
|
697
727
|
var t;
|
|
698
|
-
for (const n of
|
|
728
|
+
for (const n of o(this, b).values())
|
|
699
729
|
n._dispose();
|
|
700
|
-
|
|
730
|
+
o(this, b).clear(), (t = o(this, x)) == null || t.disconnect(), o(this, x) && o(this, x).observe(this.container);
|
|
701
731
|
}
|
|
702
732
|
/**
|
|
703
733
|
* Remeasures every element and redraws every connection. Called
|
|
@@ -705,29 +735,29 @@ class te {
|
|
|
705
735
|
* elements in ways the page can't observe.
|
|
706
736
|
*/
|
|
707
737
|
update() {
|
|
708
|
-
if (
|
|
709
|
-
|
|
710
|
-
const t =
|
|
711
|
-
const h = { index: 0, count: 1 },
|
|
738
|
+
if (o(this, N)) return;
|
|
739
|
+
o(this, j) && (ct(o(this, j)), l(this, j, 0));
|
|
740
|
+
const t = ee(this.svg), n = [], s = /* @__PURE__ */ new Map(), r = (i, c, a) => {
|
|
741
|
+
const h = { index: 0, count: 1 }, d = Q(a);
|
|
712
742
|
return s.has(i) || s.set(i, { top: [], right: [], bottom: [], left: [] }), s.get(i)[c].push({
|
|
713
743
|
slot: h,
|
|
714
|
-
key:
|
|
744
|
+
key: at(c) ? d.y : d.x
|
|
715
745
|
}), h;
|
|
716
746
|
};
|
|
717
|
-
for (const i of
|
|
747
|
+
for (const i of o(this, b).values()) {
|
|
718
748
|
const { startElement: c, endElement: a } = i;
|
|
719
|
-
if (!
|
|
749
|
+
if (!At(c) || !At(a)) {
|
|
720
750
|
i._hide();
|
|
721
751
|
continue;
|
|
722
752
|
}
|
|
723
|
-
const { spread: h, startSide:
|
|
753
|
+
const { spread: h, startSide: d, endSide: f } = i.options, u = vt(c, t), $ = vt(a, t), nt = ne(u, $, d, f), gt = { index: 0, count: 1 };
|
|
724
754
|
n.push({
|
|
725
755
|
connection: i,
|
|
726
756
|
startRect: u,
|
|
727
|
-
endRect:
|
|
728
|
-
...
|
|
729
|
-
startSlot: h ?
|
|
730
|
-
endSlot: h ?
|
|
757
|
+
endRect: $,
|
|
758
|
+
...nt,
|
|
759
|
+
startSlot: h ? r(c, nt.startSide, $) : gt,
|
|
760
|
+
endSlot: h ? r(a, nt.endSide, u) : { ...gt }
|
|
731
761
|
});
|
|
732
762
|
}
|
|
733
763
|
for (const i of s.values())
|
|
@@ -736,16 +766,16 @@ class te {
|
|
|
736
766
|
a.slot.index = h, a.slot.count = c.length;
|
|
737
767
|
});
|
|
738
768
|
for (const i of n) {
|
|
739
|
-
const { connection: c, startRect: a, endRect: h, startSide:
|
|
769
|
+
const { connection: c, startRect: a, endRect: h, startSide: d, endSide: f } = i, { spacing: u, gap: $ } = c.options;
|
|
740
770
|
c._draw(
|
|
741
|
-
|
|
771
|
+
St(a, d, {
|
|
742
772
|
...i.startSlot,
|
|
743
773
|
spacing: u,
|
|
744
|
-
gap:
|
|
774
|
+
gap: $
|
|
745
775
|
}),
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
776
|
+
d,
|
|
777
|
+
St(h, f, { ...i.endSlot, spacing: u, gap: $ }),
|
|
778
|
+
f
|
|
749
779
|
);
|
|
750
780
|
}
|
|
751
781
|
}
|
|
@@ -755,70 +785,70 @@ class te {
|
|
|
755
785
|
*/
|
|
756
786
|
destroy() {
|
|
757
787
|
var t, n;
|
|
758
|
-
|
|
788
|
+
o(this, N) || (this.clear(), l(this, N, !0), o(this, j) && ct(o(this, j)), o(this, F) && ct(o(this, F)), window.removeEventListener("resize", o(this, z)), document.removeEventListener("scroll", o(this, z), {
|
|
759
789
|
capture: !0
|
|
760
|
-
}), (t =
|
|
790
|
+
}), (t = o(this, x)) == null || t.disconnect(), (n = o(this, U)) == null || n.disconnect(), this.svg.remove(), o(this, q) !== null && (this.container.style.position = o(this, q)));
|
|
761
791
|
}
|
|
762
792
|
}
|
|
763
|
-
|
|
793
|
+
D = new WeakMap(), b = new WeakMap(), j = new WeakMap(), F = new WeakMap(), N = new WeakMap(), x = new WeakMap(), U = new WeakMap(), q = new WeakMap(), w = new WeakSet(), /**
|
|
764
794
|
* Checks a connection without adding anything, so a bad option can't leave
|
|
765
795
|
* a connection behind that breaks every later update.
|
|
766
796
|
*/
|
|
767
|
-
|
|
768
|
-
if (
|
|
769
|
-
throw new
|
|
770
|
-
|
|
771
|
-
const i =
|
|
772
|
-
if (
|
|
773
|
-
throw new
|
|
797
|
+
ft = function(t, n, s, r) {
|
|
798
|
+
if (o(this, N))
|
|
799
|
+
throw new R("this instance has been destroyed");
|
|
800
|
+
mt(s, r);
|
|
801
|
+
const i = K(t, "startElement"), c = K(n, "endElement"), a = s, h = a.id ?? `arc-${zt()}`;
|
|
802
|
+
if (o(this, b).has(h))
|
|
803
|
+
throw new R(`a connection with id "${h}" exists`);
|
|
774
804
|
return { id: h, startElement: i, endElement: c, options: a };
|
|
775
|
-
},
|
|
805
|
+
}, pt = function({
|
|
776
806
|
id: t,
|
|
777
807
|
startElement: n,
|
|
778
808
|
endElement: s,
|
|
779
|
-
options:
|
|
809
|
+
options: r
|
|
780
810
|
}) {
|
|
781
811
|
var c, a;
|
|
782
|
-
const i =
|
|
812
|
+
const i = tt._create({
|
|
783
813
|
id: t,
|
|
784
814
|
startElement: n,
|
|
785
815
|
endElement: s,
|
|
786
|
-
options:
|
|
787
|
-
defaults:
|
|
816
|
+
options: r,
|
|
817
|
+
defaults: o(this, D).defaults,
|
|
788
818
|
owner: this
|
|
789
819
|
});
|
|
790
|
-
return
|
|
791
|
-
},
|
|
792
|
-
if (!
|
|
820
|
+
return o(this, b).set(t, i), this.svg.appendChild(i.element), (c = o(this, x)) == null || c.observe(n), (a = o(this, x)) == null || a.observe(s), i;
|
|
821
|
+
}, yt = function(t) {
|
|
822
|
+
if (!o(this, x) || t === this.container) return;
|
|
793
823
|
this.connections.some(
|
|
794
824
|
(s) => s.startElement === t || s.endElement === t
|
|
795
|
-
) ||
|
|
796
|
-
},
|
|
825
|
+
) || o(this, x).unobserve(t);
|
|
826
|
+
}, z = new WeakMap(), _t = function() {
|
|
797
827
|
var n;
|
|
798
|
-
const { autoUpdate: t = !0 } =
|
|
828
|
+
const { autoUpdate: t = !0 } = o(this, D);
|
|
799
829
|
if (t !== !1) {
|
|
800
830
|
if (t === "frame") {
|
|
801
831
|
const s = () => {
|
|
802
|
-
this.update(), l(this,
|
|
832
|
+
this.update(), l(this, F, it(s));
|
|
803
833
|
};
|
|
804
|
-
l(this,
|
|
834
|
+
l(this, F, it(s));
|
|
805
835
|
return;
|
|
806
836
|
}
|
|
807
|
-
window.addEventListener("resize",
|
|
837
|
+
window.addEventListener("resize", o(this, z)), document.addEventListener("scroll", o(this, z), {
|
|
808
838
|
capture: !0,
|
|
809
839
|
passive: !0
|
|
810
|
-
}), typeof ResizeObserver < "u" && (l(this, x, new ResizeObserver(
|
|
811
|
-
s.some((
|
|
812
|
-
})),
|
|
840
|
+
}), typeof ResizeObserver < "u" && (l(this, x, new ResizeObserver(o(this, z))), o(this, x).observe(this.container)), typeof MutationObserver < "u" && (l(this, U, new MutationObserver((s) => {
|
|
841
|
+
s.some((r) => !this.svg.contains(r.target)) && o(this, z).call(this);
|
|
842
|
+
})), o(this, U).observe(this.container, {
|
|
813
843
|
subtree: !0,
|
|
814
844
|
childList: !0,
|
|
815
845
|
attributes: !0,
|
|
816
846
|
attributeFilter: ["style", "class", "hidden"]
|
|
817
|
-
})), (n = document.fonts) == null || n.ready.then(
|
|
847
|
+
})), (n = document.fonts) == null || n.ready.then(o(this, z));
|
|
818
848
|
}
|
|
819
849
|
};
|
|
820
|
-
const
|
|
821
|
-
const n = new
|
|
850
|
+
const re = (e, t) => {
|
|
851
|
+
const n = new se(t);
|
|
822
852
|
try {
|
|
823
853
|
n.connectAll(e);
|
|
824
854
|
} catch (s) {
|
|
@@ -827,13 +857,13 @@ const ne = (e, t) => {
|
|
|
827
857
|
return n;
|
|
828
858
|
};
|
|
829
859
|
export {
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
860
|
+
se as Arclace,
|
|
861
|
+
R as ArclaceError,
|
|
862
|
+
tt as Connection,
|
|
863
|
+
te as DEFAULT_CONNECTION_OPTIONS,
|
|
864
|
+
Gt as bezierPath,
|
|
865
|
+
re as createConnections,
|
|
866
|
+
Qt as orthogonalPath,
|
|
867
|
+
Ht as straightPath
|
|
838
868
|
};
|
|
839
869
|
//# sourceMappingURL=arclace.js.map
|