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