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