@bigplay/tree-view-core 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +277 -197
- package/dist/index.js.map +1 -1
- package/dist/media.d.ts +15 -2
- package/dist/rounds.d.ts +28 -0
- package/dist/scroll.d.ts +18 -3
- package/dist/types.d.ts +19 -1
- package/package.json +1 -1
- package/styles.css +73 -2
package/dist/index.js
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
|
-
const
|
|
1
|
+
const H = {
|
|
2
2
|
nodeWidth: 180,
|
|
3
3
|
nodeHeight: 64,
|
|
4
4
|
levelGap: 60,
|
|
5
5
|
siblingGap: 16,
|
|
6
6
|
direction: "top-to-bottom",
|
|
7
|
-
linkStyle: "elbow"
|
|
7
|
+
linkStyle: "elbow",
|
|
8
|
+
levelLayout: "tree"
|
|
8
9
|
};
|
|
9
|
-
function
|
|
10
|
-
return { ...
|
|
10
|
+
function G(e) {
|
|
11
|
+
return { ...H, ...e };
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
+
function U(e) {
|
|
13
14
|
return e?.children;
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
+
function R(e) {
|
|
16
17
|
return e?.id;
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function ut(e, t = {}) {
|
|
19
20
|
if (e == null) return [];
|
|
20
21
|
const n = Array.isArray(e) ? e : [e];
|
|
21
|
-
return n.length === 0 ? [] : t.getParentId ?
|
|
22
|
-
}
|
|
23
|
-
function
|
|
24
|
-
const n = t.getId ??
|
|
25
|
-
function s(r,
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
return { id:
|
|
22
|
+
return n.length === 0 ? [] : t.getParentId ? X(n, t) : Y(n, t);
|
|
23
|
+
}
|
|
24
|
+
function Y(e, t) {
|
|
25
|
+
const n = t.getId ?? R, i = t.getChildren ?? U, o = /* @__PURE__ */ new Set();
|
|
26
|
+
function s(r, h, c, l) {
|
|
27
|
+
const a = A(n(r), l);
|
|
28
|
+
W(a, o);
|
|
29
|
+
const u = (i(r) ?? []).map((f, p) => s(f, h + 1, a, `${l}.${p}`));
|
|
30
|
+
return { id: a, data: r, depth: h, parentId: c, children: u, hasChildren: u.length > 0, collapsed: !1 };
|
|
30
31
|
}
|
|
31
|
-
return e.map((r,
|
|
32
|
-
}
|
|
33
|
-
function
|
|
34
|
-
const n = t.getId ??
|
|
35
|
-
const
|
|
36
|
-
return
|
|
37
|
-
}), s = new Map(o.map((
|
|
38
|
-
if (o.forEach((
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
-
r.push(
|
|
32
|
+
return e.map((r, h) => s(r, 0, null, String(h)));
|
|
33
|
+
}
|
|
34
|
+
function X(e, t) {
|
|
35
|
+
const n = t.getId ?? R, i = /* @__PURE__ */ new Set(), o = e.map((c, l) => {
|
|
36
|
+
const a = A(n(c), String(l));
|
|
37
|
+
return W(a, i), { id: a, data: c, depth: 0, parentId: null, children: [], hasChildren: !1, collapsed: !1 };
|
|
38
|
+
}), s = new Map(o.map((c) => [c.id, c])), r = [];
|
|
39
|
+
if (o.forEach((c, l) => {
|
|
40
|
+
const a = t.getParentId(e[l]), d = a == null ? void 0 : s.get(String(a));
|
|
41
|
+
if (!d) {
|
|
42
|
+
r.push(c);
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
}),
|
|
45
|
+
c.parentId = d.id, d.children.push(c), d.hasChildren = !0;
|
|
46
|
+
}), N(r) !== o.length)
|
|
46
47
|
throw new Error("[tree-view] В данных есть цикл: часть узлов ссылается друг на друга по кругу.");
|
|
47
48
|
return r;
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
+
function N(e) {
|
|
50
51
|
const t = [...e];
|
|
51
52
|
for (let n = 0; n < t.length; n += 1) {
|
|
52
53
|
const i = t[n];
|
|
@@ -55,21 +56,21 @@ function V(e) {
|
|
|
55
56
|
}
|
|
56
57
|
return t.length;
|
|
57
58
|
}
|
|
58
|
-
function
|
|
59
|
+
function A(e, t) {
|
|
59
60
|
return e == null || e === "" ? t : String(e);
|
|
60
61
|
}
|
|
61
|
-
function
|
|
62
|
+
function W(e, t) {
|
|
62
63
|
if (t.has(e))
|
|
63
64
|
throw new Error(`[tree-view] Повторяющийся id узла: "${e}". Идентификаторы должны быть уникальными.`);
|
|
64
65
|
t.add(e);
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
+
function ft(e, t = {}) {
|
|
67
68
|
const n = e.filter((s) => s.length > 0);
|
|
68
69
|
if (n.length === 0) return [];
|
|
69
70
|
const i = n.length - 1, o = n.map(
|
|
70
|
-
(s, r) => s.map((
|
|
71
|
-
id: F(
|
|
72
|
-
data:
|
|
71
|
+
(s, r) => s.map((h, c) => ({
|
|
72
|
+
id: F(h, r, c, t.getId),
|
|
73
|
+
data: h,
|
|
73
74
|
// Финал — корень, поэтому глубина считается от последнего уровня.
|
|
74
75
|
depth: i - r,
|
|
75
76
|
parentId: null,
|
|
@@ -79,10 +80,10 @@ function at(e, t = {}) {
|
|
|
79
80
|
}))
|
|
80
81
|
);
|
|
81
82
|
for (let s = 0; s < i; s += 1) {
|
|
82
|
-
const r = o[s],
|
|
83
|
-
r.forEach((l,
|
|
84
|
-
const
|
|
85
|
-
l.parentId =
|
|
83
|
+
const r = o[s], h = o[s + 1], c = Math.ceil(r.length / h.length);
|
|
84
|
+
r.forEach((l, a) => {
|
|
85
|
+
const d = h[Math.min(Math.floor(a / c), h.length - 1)];
|
|
86
|
+
l.parentId = d.id, d.children.push(l), d.hasChildren = !0;
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
89
|
return o[i];
|
|
@@ -91,7 +92,7 @@ function F(e, t, n, i) {
|
|
|
91
92
|
const o = i ? i(e, t, n) : e?.id;
|
|
92
93
|
return o == null || o === "" ? `${t}.${n}` : String(o);
|
|
93
94
|
}
|
|
94
|
-
function
|
|
95
|
+
function pt(e, t) {
|
|
95
96
|
if (t.size === 0) return e;
|
|
96
97
|
function n(i) {
|
|
97
98
|
const o = t.has(i.id);
|
|
@@ -103,22 +104,22 @@ function dt(e, t) {
|
|
|
103
104
|
}
|
|
104
105
|
return e.map(n);
|
|
105
106
|
}
|
|
106
|
-
function
|
|
107
|
+
function gt(e, t) {
|
|
107
108
|
const n = new Set(e);
|
|
108
109
|
return n.delete(t) || n.add(t), n;
|
|
109
110
|
}
|
|
110
|
-
const
|
|
111
|
-
function
|
|
112
|
-
const n = e?.teams ?? [], i = Math.max(t.rows ??
|
|
113
|
-
const
|
|
111
|
+
const z = 2, V = 40;
|
|
112
|
+
function mt(e, t = {}) {
|
|
113
|
+
const n = e?.teams ?? [], i = Math.max(t.rows ?? z, n.length), o = t.techDefeatLabel ?? "ТП", s = n.map((r, h) => {
|
|
114
|
+
const c = r.isTechDefeat === !0, l = r.isWinner === !0;
|
|
114
115
|
return {
|
|
115
|
-
key: String(r.id ?? `team-${
|
|
116
|
+
key: String(r.id ?? `team-${h}`),
|
|
116
117
|
team: r,
|
|
117
|
-
score:
|
|
118
|
+
score: c ? o : String(r.score ?? ""),
|
|
118
119
|
isWinner: l,
|
|
119
120
|
isLoser: !l,
|
|
120
121
|
isMyTeam: r.isMyTeam === !0,
|
|
121
|
-
isTechDefeat:
|
|
122
|
+
isTechDefeat: c,
|
|
122
123
|
isEmpty: !1
|
|
123
124
|
};
|
|
124
125
|
});
|
|
@@ -135,48 +136,61 @@ function ft(e, t = {}) {
|
|
|
135
136
|
});
|
|
136
137
|
return { rows: s, hasMyTeam: n.some((r) => r.isMyTeam === !0) };
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
+
function wt(e, t = {}) {
|
|
139
140
|
const n = e?.teams ?? [];
|
|
140
|
-
return Math.max(t.rows ??
|
|
141
|
+
return Math.max(t.rows ?? z, n.length) * (t.rowHeight ?? V);
|
|
141
142
|
}
|
|
142
|
-
const
|
|
143
|
-
function
|
|
143
|
+
const I = { min: 0.2, max: 3 }, S = { x: 0, y: 0, scale: 1 };
|
|
144
|
+
function L(e, t, n) {
|
|
144
145
|
return Math.min(Math.max(e, t), n);
|
|
145
146
|
}
|
|
146
|
-
function
|
|
147
|
+
function Z(e, t, n = 24, i = I) {
|
|
147
148
|
if (e.width <= 0 || e.height <= 0 || t.width <= 0 || t.height <= 0)
|
|
148
|
-
return { ...
|
|
149
|
-
const o = Math.max(t.width - n * 2, 1), s = Math.max(t.height - n * 2, 1), r = Math.min(o / e.width, s / e.height, 1),
|
|
149
|
+
return { ...S };
|
|
150
|
+
const o = Math.max(t.width - n * 2, 1), s = Math.max(t.height - n * 2, 1), r = Math.min(o / e.width, s / e.height, 1), h = L(r, i.min, i.max);
|
|
150
151
|
return {
|
|
151
|
-
scale:
|
|
152
|
-
x: (t.width - e.width *
|
|
153
|
-
y: (t.height - e.height *
|
|
152
|
+
scale: h,
|
|
153
|
+
x: (t.width - e.width * h) / 2,
|
|
154
|
+
y: (t.height - e.height * h) / 2
|
|
154
155
|
};
|
|
155
156
|
}
|
|
156
|
-
function
|
|
157
|
+
function q(e, t, n) {
|
|
157
158
|
return { ...e, x: e.x + t, y: e.y + n };
|
|
158
159
|
}
|
|
159
|
-
function
|
|
160
|
-
const o =
|
|
160
|
+
function $(e, t, n, i = I) {
|
|
161
|
+
const o = L(e.scale * t, i.min, i.max);
|
|
161
162
|
if (o === e.scale) return e;
|
|
162
163
|
const s = (n.x - e.x) / e.scale, r = (n.y - e.y) / e.scale;
|
|
163
164
|
return { scale: o, x: n.x - s * o, y: n.y - r * o };
|
|
164
165
|
}
|
|
165
|
-
function
|
|
166
|
+
function yt(e) {
|
|
166
167
|
return `translate(${e.x}px, ${e.y}px) scale(${e.scale})`;
|
|
167
168
|
}
|
|
168
|
-
function
|
|
169
|
+
function xt(e, t) {
|
|
169
170
|
const n = t.nodeWidth + t.levelGap, i = (e ?? []).map((o, s) => {
|
|
170
171
|
const r = o.id ?? s;
|
|
171
172
|
return { key: String(r), id: r, name: o.name, index: s, width: n };
|
|
172
173
|
});
|
|
173
174
|
return { columns: i, width: n * i.length, offset: t.levelGap / 2 };
|
|
174
175
|
}
|
|
175
|
-
function
|
|
176
|
+
function Et(e) {
|
|
176
177
|
const t = e.left + e.width / 2 - e.viewport / 2;
|
|
177
|
-
return
|
|
178
|
+
return L(t, 0, Math.max(0, e.scrollWidth - e.viewport));
|
|
178
179
|
}
|
|
179
|
-
function
|
|
180
|
+
function Mt(e, t) {
|
|
181
|
+
return Math.max(0, e - t);
|
|
182
|
+
}
|
|
183
|
+
function Lt(e, t, n) {
|
|
184
|
+
return t <= 0 || n <= 0 ? 0 : L(Math.round(e / t), 0, n - 1);
|
|
185
|
+
}
|
|
186
|
+
function vt(e, t, n) {
|
|
187
|
+
return n ? t - 1 - e : e;
|
|
188
|
+
}
|
|
189
|
+
const K = 4;
|
|
190
|
+
function Ct(e, t) {
|
|
191
|
+
return t * L(e, 1, K);
|
|
192
|
+
}
|
|
193
|
+
function bt(e) {
|
|
180
194
|
if (typeof window > "u") return null;
|
|
181
195
|
let t = e?.parentElement ?? null;
|
|
182
196
|
for (; t; ) {
|
|
@@ -186,41 +200,62 @@ function yt(e) {
|
|
|
186
200
|
}
|
|
187
201
|
return null;
|
|
188
202
|
}
|
|
189
|
-
function
|
|
203
|
+
function $t(e, t) {
|
|
190
204
|
if (typeof e.scrollTo == "function") {
|
|
191
205
|
e.scrollTo({ left: t, behavior: "smooth" });
|
|
192
206
|
return;
|
|
193
207
|
}
|
|
194
208
|
e.scrollLeft = t;
|
|
195
209
|
}
|
|
196
|
-
function
|
|
210
|
+
function j(e, t) {
|
|
197
211
|
return e.getBoundingClientRect().left - t.getBoundingClientRect().left + t.scrollLeft;
|
|
198
212
|
}
|
|
199
|
-
const
|
|
200
|
-
function
|
|
213
|
+
const Q = ".tree-view__node";
|
|
214
|
+
function St(e, t, n, i) {
|
|
201
215
|
const o = e.getBoundingClientRect().left + i;
|
|
202
|
-
return Array.from(e.querySelectorAll(
|
|
203
|
-
const
|
|
204
|
-
return Math.floor((
|
|
216
|
+
return Array.from(e.querySelectorAll(Q)).filter((r) => {
|
|
217
|
+
const h = r.getBoundingClientRect();
|
|
218
|
+
return Math.floor((h.left + h.width / 2 - o) / n) === t;
|
|
205
219
|
});
|
|
206
220
|
}
|
|
207
|
-
function
|
|
208
|
-
return
|
|
221
|
+
function It(e, t) {
|
|
222
|
+
return { left: j(e, t), width: e.getBoundingClientRect().width };
|
|
209
223
|
}
|
|
210
|
-
const
|
|
211
|
-
function
|
|
224
|
+
const J = "tv-hidden";
|
|
225
|
+
function Pt(e, t, n) {
|
|
226
|
+
e.querySelectorAll("[data-depth]").forEach((i) => {
|
|
227
|
+
const o = Number(i.getAttribute("data-depth"));
|
|
228
|
+
i.classList.toggle(J, n(o) < t);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
const Tt = "(max-width: 768px)";
|
|
232
|
+
function Dt(e, t) {
|
|
212
233
|
if (typeof window > "u" || typeof window.matchMedia != "function") return () => {
|
|
213
234
|
};
|
|
214
235
|
const n = window.matchMedia(e), i = () => t(n.matches);
|
|
215
236
|
return i(), typeof n.addEventListener == "function" ? (n.addEventListener("change", i), () => n.removeEventListener("change", i)) : (n.addListener(i), () => n.removeListener(i));
|
|
216
237
|
}
|
|
217
|
-
function
|
|
238
|
+
function Rt(e, t) {
|
|
239
|
+
if (!e) return () => {
|
|
240
|
+
};
|
|
241
|
+
if (t(e.clientWidth), typeof ResizeObserver > "u") return () => {
|
|
242
|
+
};
|
|
243
|
+
const n = new ResizeObserver(() => t(e.clientWidth));
|
|
244
|
+
return n.observe(e), () => n.disconnect();
|
|
245
|
+
}
|
|
246
|
+
function At(e, t) {
|
|
247
|
+
if (!e || typeof MutationObserver > "u") return () => {
|
|
248
|
+
};
|
|
249
|
+
const n = new MutationObserver(t);
|
|
250
|
+
return n.observe(e, { childList: !0, subtree: !0 }), () => n.disconnect();
|
|
251
|
+
}
|
|
252
|
+
function E(e) {
|
|
218
253
|
return Math.round(e * 100) / 100;
|
|
219
254
|
}
|
|
220
|
-
function
|
|
255
|
+
function tt(e) {
|
|
221
256
|
return e === "top-to-bottom" || e === "bottom-to-top";
|
|
222
257
|
}
|
|
223
|
-
function
|
|
258
|
+
function et(e, t, n) {
|
|
224
259
|
const i = e.x + e.width / 2, o = e.y + e.height / 2, s = t.x + t.width / 2, r = t.y + t.height / 2;
|
|
225
260
|
switch (n) {
|
|
226
261
|
case "top-to-bottom":
|
|
@@ -233,102 +268,138 @@ function J(e, t, n) {
|
|
|
233
268
|
return { from: { x: e.x, y: o }, to: { x: t.x + t.width, y: r } };
|
|
234
269
|
}
|
|
235
270
|
}
|
|
236
|
-
function
|
|
237
|
-
const o =
|
|
271
|
+
function nt(e, t, n, i) {
|
|
272
|
+
const o = E(e.x), s = E(e.y), r = E(t.x), h = E(t.y);
|
|
238
273
|
if (n === "straight")
|
|
239
|
-
return `M ${o} ${s} L ${r} ${
|
|
240
|
-
const
|
|
241
|
-
return n === "elbow" ?
|
|
274
|
+
return `M ${o} ${s} L ${r} ${h}`;
|
|
275
|
+
const c = tt(i), l = E((o + r) / 2), a = E((s + h) / 2);
|
|
276
|
+
return n === "elbow" ? c ? `M ${o} ${s} L ${o} ${a} L ${r} ${a} L ${r} ${h}` : `M ${o} ${s} L ${l} ${s} L ${l} ${h} L ${r} ${h}` : c ? `M ${o} ${s} C ${o} ${a} ${r} ${a} ${r} ${h}` : `M ${o} ${s} C ${l} ${s} ${l} ${h} ${r} ${h}`;
|
|
242
277
|
}
|
|
243
|
-
function
|
|
278
|
+
function it(e, t) {
|
|
244
279
|
const n = new Map(e.map((o) => [o.id, o])), i = [];
|
|
245
280
|
for (const o of e) {
|
|
246
281
|
const s = o.parentId == null ? void 0 : n.get(o.parentId);
|
|
247
282
|
if (!s) continue;
|
|
248
|
-
const { from: r, to:
|
|
283
|
+
const { from: r, to: h } = et(s, o, t.direction);
|
|
249
284
|
i.push({
|
|
250
285
|
id: `${s.id}->${o.id}`,
|
|
251
286
|
source: s,
|
|
252
287
|
target: o,
|
|
253
|
-
path:
|
|
288
|
+
path: nt(r, h, t.linkStyle, t.direction)
|
|
254
289
|
});
|
|
255
290
|
}
|
|
256
291
|
return i;
|
|
257
292
|
}
|
|
258
|
-
function
|
|
293
|
+
function C(e, t) {
|
|
259
294
|
return typeof e == "function" ? e(t) : e;
|
|
260
295
|
}
|
|
261
|
-
function
|
|
262
|
-
|
|
296
|
+
function O(e, t, n) {
|
|
297
|
+
return typeof e == "function" ? e(t, n) : e;
|
|
298
|
+
}
|
|
299
|
+
function ot(e) {
|
|
300
|
+
const t = [];
|
|
301
|
+
for (const n of P(e)) t[n.depth] = (t[n.depth] ?? 0) + 1;
|
|
302
|
+
return t;
|
|
303
|
+
}
|
|
304
|
+
function k(e, t, n) {
|
|
305
|
+
const i = [];
|
|
306
|
+
let o = 0;
|
|
307
|
+
for (let c = 0; c < t.length; c += 1)
|
|
308
|
+
i[c] = o, o += (t[c] ?? 0) + n;
|
|
263
309
|
let s = 0;
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
r[a.depth] = Math.max(r[a.depth] ?? 0, S);
|
|
268
|
-
const T = s, O = o.length;
|
|
269
|
-
let g = s;
|
|
270
|
-
if (a.children.length > 0) {
|
|
271
|
-
const E = a.children.map(c), b = E[0], P = E[E.length - 1], B = b.across + b.acrossSize / 2, H = P.across + P.acrossSize / 2;
|
|
272
|
-
g = (B + H) / 2 - y / 2;
|
|
273
|
-
const D = T - g;
|
|
274
|
-
if (D > 0) {
|
|
275
|
-
for (let L = O; L < o.length; L += 1) o[L].across += D;
|
|
276
|
-
g = T;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
const x = { depth: a.depth, along: 0, across: g, alongSize: S, acrossSize: y };
|
|
280
|
-
return i.set(a.id, x), o.push(x), s = Math.max(s, g + y + t.siblingGap), x;
|
|
310
|
+
for (const c of e) {
|
|
311
|
+
const l = t[c.depth] ?? c.alongSize;
|
|
312
|
+
c.along = i[c.depth] + (l - c.alongSize) / 2, s = Math.max(s, c.across + c.acrossSize);
|
|
281
313
|
}
|
|
282
|
-
|
|
314
|
+
const r = t.length - 1;
|
|
315
|
+
return { alongExtent: r < 0 ? 0 : i[r] + t[r], acrossExtent: s };
|
|
316
|
+
}
|
|
317
|
+
function rt(e, t) {
|
|
318
|
+
const n = t.direction === "top-to-bottom" || t.direction === "bottom-to-top", i = /* @__PURE__ */ new Map(), o = [], s = [], r = [];
|
|
319
|
+
for (const a of P(e)) (r[a.depth] ??= []).push(a);
|
|
320
|
+
const h = [], c = [];
|
|
321
|
+
r.forEach((a, d) => {
|
|
322
|
+
const u = [];
|
|
323
|
+
let f = 0;
|
|
324
|
+
for (const m of a) {
|
|
325
|
+
const g = C(t.nodeWidth, m), w = C(t.nodeHeight, m), y = n ? w : g, M = n ? g : w;
|
|
326
|
+
s[d] = Math.max(s[d] ?? 0, y);
|
|
327
|
+
const x = { depth: d, along: 0, across: f, alongSize: y, acrossSize: M };
|
|
328
|
+
i.set(m.id, x), u.push(x), o.push(x), f += M + O(t.siblingGap, m, a.length);
|
|
329
|
+
}
|
|
330
|
+
const p = u[u.length - 1];
|
|
331
|
+
h[d] = u, c[d] = p ? p.across + p.acrossSize : 0;
|
|
332
|
+
});
|
|
333
|
+
const l = Math.max(0, ...c);
|
|
334
|
+
return h.forEach((a, d) => {
|
|
335
|
+
const u = (l - (c[d] ?? 0)) / 2;
|
|
336
|
+
if (u > 0) for (const f of a) f.across += u;
|
|
337
|
+
}), { byId: i, ...k(o, s, t.levelGap) };
|
|
338
|
+
}
|
|
339
|
+
function st(e, t) {
|
|
340
|
+
if (t.levelLayout === "stack") return rt(e, t);
|
|
341
|
+
const n = t.direction === "top-to-bottom" || t.direction === "bottom-to-top", i = ot(e), o = /* @__PURE__ */ new Map(), s = [];
|
|
342
|
+
let r = 0;
|
|
283
343
|
const h = [];
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
h[
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
344
|
+
function c(l) {
|
|
345
|
+
const a = C(t.nodeWidth, l), d = C(t.nodeHeight, l), u = n ? d : a, f = n ? a : d;
|
|
346
|
+
h[l.depth] = Math.max(h[l.depth] ?? 0, u);
|
|
347
|
+
const p = r, m = s.length;
|
|
348
|
+
let g = r;
|
|
349
|
+
if (l.children.length > 0) {
|
|
350
|
+
const y = l.children.map(c), M = y[0], x = y[y.length - 1], _ = M.across + M.acrossSize / 2, B = x.across + x.acrossSize / 2;
|
|
351
|
+
g = (_ + B) / 2 - f / 2;
|
|
352
|
+
const T = p - g;
|
|
353
|
+
if (T > 0) {
|
|
354
|
+
for (let b = m; b < s.length; b += 1) s[b].across += T;
|
|
355
|
+
g = p;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
const w = { depth: l.depth, along: 0, across: g, alongSize: u, acrossSize: f };
|
|
359
|
+
return o.set(l.id, w), s.push(w), r = Math.max(
|
|
360
|
+
r,
|
|
361
|
+
g + f + O(t.siblingGap, l, i[l.depth] ?? 1)
|
|
362
|
+
), w;
|
|
291
363
|
}
|
|
292
|
-
|
|
293
|
-
return { byId: i, alongExtent: p, acrossExtent: d };
|
|
364
|
+
return e.forEach(c), { byId: o, ...k(s, h, t.levelGap) };
|
|
294
365
|
}
|
|
295
|
-
function
|
|
366
|
+
function P(e) {
|
|
296
367
|
const t = [];
|
|
297
368
|
function n(i) {
|
|
298
369
|
t.push(i), i.children.forEach(n);
|
|
299
370
|
}
|
|
300
371
|
return e.forEach(n), t;
|
|
301
372
|
}
|
|
302
|
-
function
|
|
303
|
-
const n =
|
|
373
|
+
function Wt(e, t) {
|
|
374
|
+
const n = G(t);
|
|
304
375
|
if (e.length === 0)
|
|
305
376
|
return { nodes: [], links: [], width: 0, height: 0 };
|
|
306
|
-
const i = n.direction === "top-to-bottom" || n.direction === "bottom-to-top", { byId: o, alongExtent: s, acrossExtent: r } =
|
|
307
|
-
const { along:
|
|
377
|
+
const i = n.direction === "top-to-bottom" || n.direction === "bottom-to-top", { byId: o, alongExtent: s, acrossExtent: r } = st(e, n), h = n.direction === "bottom-to-top" || n.direction === "right-to-left", c = P(e).map((l) => {
|
|
378
|
+
const { along: a, across: d, alongSize: u, acrossSize: f } = o.get(l.id), p = h ? s - u - a : a;
|
|
308
379
|
return {
|
|
309
380
|
id: l.id,
|
|
310
381
|
data: l.data,
|
|
311
382
|
depth: l.depth,
|
|
312
383
|
parentId: l.parentId,
|
|
313
|
-
x: i ?
|
|
314
|
-
y: i ?
|
|
315
|
-
width: i ?
|
|
316
|
-
height: i ?
|
|
384
|
+
x: i ? d : p,
|
|
385
|
+
y: i ? p : d,
|
|
386
|
+
width: i ? f : u,
|
|
387
|
+
height: i ? u : f,
|
|
317
388
|
hasChildren: l.hasChildren,
|
|
318
389
|
collapsed: l.collapsed
|
|
319
390
|
};
|
|
320
391
|
});
|
|
321
392
|
return {
|
|
322
|
-
nodes:
|
|
323
|
-
links:
|
|
393
|
+
nodes: c,
|
|
394
|
+
links: it(c, n),
|
|
324
395
|
width: i ? r : s,
|
|
325
396
|
height: i ? s : r
|
|
326
397
|
};
|
|
327
398
|
}
|
|
328
|
-
const
|
|
329
|
-
class
|
|
399
|
+
const v = 1.2;
|
|
400
|
+
class zt {
|
|
330
401
|
constructor(t) {
|
|
331
|
-
this.params = t, this.transform = { ...
|
|
402
|
+
this.params = t, this.transform = { ...S }, this.element = null, this.pointers = /* @__PURE__ */ new Map(), this.lastPinchDistance = 0, this.onPointerDown = (n) => {
|
|
332
403
|
this.isPannable() && (n.target?.closest?.("[data-tv-no-pan]") || (this.pointers.set(n.pointerId, { x: n.clientX, y: n.clientY }), this.element?.setPointerCapture?.(n.pointerId)));
|
|
333
404
|
}, this.onPointerMove = (n) => {
|
|
334
405
|
const i = this.pointers.get(n.pointerId);
|
|
@@ -337,15 +408,15 @@ class It {
|
|
|
337
408
|
this.pinch();
|
|
338
409
|
return;
|
|
339
410
|
}
|
|
340
|
-
this.set(
|
|
411
|
+
this.set(q(this.transform, n.clientX - i.x, n.clientY - i.y));
|
|
341
412
|
}
|
|
342
413
|
}, this.onPointerUp = (n) => {
|
|
343
414
|
this.pointers.delete(n.pointerId), this.pointers.size < 2 && (this.lastPinchDistance = 0);
|
|
344
415
|
}, this.onWheel = (n) => {
|
|
345
416
|
if (!this.isZoomable()) return;
|
|
346
417
|
n.preventDefault();
|
|
347
|
-
const i = n.deltaY < 0 ?
|
|
348
|
-
this.set(
|
|
418
|
+
const i = n.deltaY < 0 ? v : 1 / v;
|
|
419
|
+
this.set($(this.transform, i, this.toLocalPoint(n), this.limits));
|
|
349
420
|
};
|
|
350
421
|
}
|
|
351
422
|
/** Подписывается на события элемента. Повторный вызов сначала отписывается. */
|
|
@@ -361,7 +432,7 @@ class It {
|
|
|
361
432
|
fit(t, n = 24) {
|
|
362
433
|
const i = this.element;
|
|
363
434
|
i && this.set(
|
|
364
|
-
|
|
435
|
+
Z(
|
|
365
436
|
t,
|
|
366
437
|
{ width: i.clientWidth, height: i.clientHeight },
|
|
367
438
|
n,
|
|
@@ -370,20 +441,20 @@ class It {
|
|
|
370
441
|
);
|
|
371
442
|
}
|
|
372
443
|
zoomIn() {
|
|
373
|
-
this.zoomToCenter(
|
|
444
|
+
this.zoomToCenter(v);
|
|
374
445
|
}
|
|
375
446
|
zoomOut() {
|
|
376
|
-
this.zoomToCenter(1 /
|
|
447
|
+
this.zoomToCenter(1 / v);
|
|
377
448
|
}
|
|
378
449
|
reset() {
|
|
379
|
-
this.set({ ...
|
|
450
|
+
this.set({ ...S });
|
|
380
451
|
}
|
|
381
452
|
/** Устанавливает состояние напрямую (например, восстановление после перезагрузки). */
|
|
382
453
|
set(t) {
|
|
383
454
|
this.transform = { ...t }, this.params.onChange(this.transform);
|
|
384
455
|
}
|
|
385
456
|
get limits() {
|
|
386
|
-
return this.params.limits?.() ??
|
|
457
|
+
return this.params.limits?.() ?? I;
|
|
387
458
|
}
|
|
388
459
|
isPannable() {
|
|
389
460
|
return this.params.pannable?.() ?? !0;
|
|
@@ -398,7 +469,7 @@ class It {
|
|
|
398
469
|
}
|
|
399
470
|
zoomToCenter(t) {
|
|
400
471
|
const n = this.element, i = { x: (n?.clientWidth ?? 0) / 2, y: (n?.clientHeight ?? 0) / 2 };
|
|
401
|
-
this.set(
|
|
472
|
+
this.set($(this.transform, t, i, this.limits));
|
|
402
473
|
}
|
|
403
474
|
/** Два пальца: масштабируем вокруг точки ровно между ними. */
|
|
404
475
|
pinch() {
|
|
@@ -411,21 +482,21 @@ class It {
|
|
|
411
482
|
clientX: (t.x + n.x) / 2,
|
|
412
483
|
clientY: (t.y + n.y) / 2
|
|
413
484
|
});
|
|
414
|
-
this.set(
|
|
485
|
+
this.set($(this.transform, i / this.lastPinchDistance, o, this.limits));
|
|
415
486
|
}
|
|
416
487
|
this.lastPinchDistance = i;
|
|
417
488
|
}
|
|
418
489
|
}
|
|
419
|
-
function
|
|
490
|
+
function Ot(e, t = "tree-view-styles") {
|
|
420
491
|
if (typeof document > "u" || document.getElementById(t)) return;
|
|
421
492
|
const n = document.createElement("style");
|
|
422
493
|
n.id = t, n.textContent = e, document.head.appendChild(n);
|
|
423
494
|
}
|
|
424
|
-
const
|
|
425
|
-
function
|
|
495
|
+
const ct = 400, ht = 150;
|
|
496
|
+
function D(e, t) {
|
|
426
497
|
return e.x <= t.x + t.width && e.x + e.width >= t.x && e.y <= t.y + t.height && e.y + e.height >= t.y;
|
|
427
498
|
}
|
|
428
|
-
function
|
|
499
|
+
function lt(e) {
|
|
429
500
|
const { source: t, target: n } = e, i = Math.min(t.x, n.x), o = Math.min(t.y, n.y);
|
|
430
501
|
return {
|
|
431
502
|
x: i,
|
|
@@ -434,24 +505,24 @@ function st(e) {
|
|
|
434
505
|
height: Math.max(t.y + t.height, n.y + n.height) - o
|
|
435
506
|
};
|
|
436
507
|
}
|
|
437
|
-
function
|
|
508
|
+
function at(e, t) {
|
|
438
509
|
return { x: e.x - t, y: e.y - t, width: e.width + t * 2, height: e.height + t * 2 };
|
|
439
510
|
}
|
|
440
|
-
function
|
|
441
|
-
if (!t || e.nodes.length <
|
|
511
|
+
function kt(e, t, n = ct) {
|
|
512
|
+
if (!t || e.nodes.length < ht) return e;
|
|
442
513
|
if (t.width <= 0 || t.height <= 0)
|
|
443
514
|
return { nodes: [], links: [], width: e.width, height: e.height };
|
|
444
|
-
const i =
|
|
515
|
+
const i = at(t, n), o = [], s = [];
|
|
445
516
|
for (const r of e.nodes)
|
|
446
|
-
|
|
517
|
+
D(i, r) && o.push(r);
|
|
447
518
|
for (const r of e.links)
|
|
448
|
-
|
|
519
|
+
D(i, lt(r)) && s.push(r);
|
|
449
520
|
return { nodes: o, links: s, width: e.width, height: e.height };
|
|
450
521
|
}
|
|
451
|
-
function
|
|
522
|
+
function _t() {
|
|
452
523
|
return typeof window > "u" ? null : { x: 0, y: 0, width: window.innerWidth, height: window.innerHeight };
|
|
453
524
|
}
|
|
454
|
-
function
|
|
525
|
+
function Bt(e, t) {
|
|
455
526
|
if (!e || typeof window > "u" || t <= 0) return null;
|
|
456
527
|
const n = e.getBoundingClientRect(), i = Math.max(n.left, 0), o = Math.max(n.top, 0), s = Math.min(n.right, window.innerWidth), r = Math.min(n.bottom, window.innerHeight);
|
|
457
528
|
return s <= i || r <= o ? { x: 0, y: 0, width: 0, height: 0 } : {
|
|
@@ -462,47 +533,56 @@ function Pt(e, t) {
|
|
|
462
533
|
};
|
|
463
534
|
}
|
|
464
535
|
export {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
Pt as
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
536
|
+
z as DEFAULT_BRACKET_ROWS,
|
|
537
|
+
V as DEFAULT_BRACKET_ROW_HEIGHT,
|
|
538
|
+
H as DEFAULT_OPTIONS,
|
|
539
|
+
ct as DEFAULT_OVERSCAN,
|
|
540
|
+
I as DEFAULT_SCALE_LIMITS,
|
|
541
|
+
J as HIDDEN_CLASS,
|
|
542
|
+
S as IDENTITY_TRANSFORM,
|
|
543
|
+
K as MAX_GAP_STEPS,
|
|
544
|
+
Tt as MOBILE_MEDIA_QUERY,
|
|
545
|
+
zt as PanZoomController,
|
|
546
|
+
Q as TREE_NODE_SELECTOR,
|
|
547
|
+
ht as VIRTUALIZE_THRESHOLD,
|
|
548
|
+
v as ZOOM_STEP,
|
|
549
|
+
pt as applyCollapsed,
|
|
550
|
+
wt as bracketCardHeight,
|
|
551
|
+
mt as buildBracketCard,
|
|
552
|
+
xt as buildBracketRounds,
|
|
553
|
+
it as buildLinks,
|
|
554
|
+
nt as buildPath,
|
|
555
|
+
L as clamp,
|
|
556
|
+
_t as estimateVisibleRect,
|
|
557
|
+
at as expandRect,
|
|
558
|
+
bt as findScrollParent,
|
|
559
|
+
Z as fitToViewport,
|
|
560
|
+
P as flatten,
|
|
561
|
+
ft as fromLevels,
|
|
562
|
+
et as getAnchors,
|
|
563
|
+
Pt as hideRoundsBefore,
|
|
564
|
+
It as horizontalBox,
|
|
565
|
+
Ot as injectStyles,
|
|
566
|
+
Wt as layoutTree,
|
|
567
|
+
Mt as levelGapForWidth,
|
|
568
|
+
Bt as measureVisibleRect,
|
|
569
|
+
St as nodesInColumn,
|
|
570
|
+
j as offsetWithin,
|
|
571
|
+
q as panBy,
|
|
572
|
+
st as placeNodes,
|
|
573
|
+
G as resolveOptions,
|
|
574
|
+
Lt as roundAtScroll,
|
|
575
|
+
vt as roundOfDepth,
|
|
576
|
+
Et as roundScrollLeft,
|
|
577
|
+
Ct as roundSiblingGap,
|
|
578
|
+
$t as smoothScrollLeft,
|
|
579
|
+
yt as toCssTransform,
|
|
580
|
+
ut as toTree,
|
|
581
|
+
gt as toggleCollapsed,
|
|
582
|
+
kt as visibleLayout,
|
|
583
|
+
At as watchChildren,
|
|
584
|
+
Dt as watchMedia,
|
|
585
|
+
Rt as watchWidth,
|
|
586
|
+
$ as zoomAtPoint
|
|
507
587
|
};
|
|
508
588
|
//# sourceMappingURL=index.js.map
|