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