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