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