@bigplay/tree-view 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.js CHANGED
@@ -1,7 +1,7 @@
1
- import { defineComponent as R, openBlock as d, createElementBlock as c, createElementVNode as C, toDisplayString as w, withModifiers as j, createCommentVNode as E, ref as g, watch as N, onBeforeUnmount as D, computed as h, onMounted as V, nextTick as P, normalizeStyle as y, normalizeClass as I, unref as W, Fragment as B, renderList as M, renderSlot as O, createVNode as Q, createTextVNode as G } from "vue";
2
- import { IDENTITY_TRANSFORM as Y, PanZoomController as Z, toTree as K, applyCollapsed as q, layoutTree as J, toggleCollapsed as X, estimateVisibleRect as ee, measureVisibleRect as te, DEFAULT_OVERSCAN as oe, visibleLayout as ne, toCssTransform as re, DEFAULT_SCALE_LIMITS as ae, buildBracketCard as ie, MOBILE_MEDIA_QUERY as le, watchMedia as se, buildBracketRounds as de, findScrollParent as ce, nodesInColumn as ue, horizontalBox as ve, offsetWithin as fe, smoothScrollLeft as pe, roundScrollLeft as he, injectStyles as be } from "@bigplay/tree-view-core";
3
- import { DEFAULT_OPTIONS as Pe, MOBILE_MEDIA_QUERY as We, bracketCardHeight as He, buildBracketCard as Ue, buildBracketRounds as je } from "@bigplay/tree-view-core";
4
- const me = { class: "tree-view-card" }, ge = { class: "tree-view-card__label" }, we = ["aria-label"], H = /* @__PURE__ */ R({
1
+ import { defineComponent as D, openBlock as s, createElementBlock as d, createElementVNode as C, toDisplayString as _, withModifiers as Q, createCommentVNode as z, ref as g, watch as O, onBeforeUnmount as P, computed as f, onMounted as V, nextTick as U, normalizeStyle as S, normalizeClass as E, unref as j, Fragment as I, renderList as M, renderSlot as R, createVNode as K, createTextVNode as q } from "vue";
2
+ import { IDENTITY_TRANSFORM as J, PanZoomController as X, toTree as ee, applyCollapsed as te, layoutTree as oe, toggleCollapsed as ne, estimateVisibleRect as ae, measureVisibleRect as re, DEFAULT_OVERSCAN as ie, visibleLayout as le, toCssTransform as se, DEFAULT_SCALE_LIMITS as de, buildBracketCard as ce, MOBILE_MEDIA_QUERY as ve, resolveOptions as ue, DEFAULT_OPTIONS as pe, levelGapForWidth as fe, buildBracketRounds as he, SWIPE_ELBOW_OFFSET as be, roundSiblingGap as we, watchMedia as me, watchWidth as ge, watchChildren as ke, hideRoundsBefore as xe, roundOfDepth as _e, roundAtScroll as ye, findScrollParent as Ce, nodesInColumn as Te, horizontalBox as ze, offsetWithin as Se, smoothScrollLeft as Ee, roundScrollLeft as $e, injectStyles as Be } from "@bigplay/tree-view-core";
3
+ import { DEFAULT_OPTIONS as at, MOBILE_MEDIA_QUERY as rt, bracketCardHeight as it, buildBracketCard as lt, buildBracketRounds as st } from "@bigplay/tree-view-core";
4
+ const Le = { class: "tree-view-card" }, Ie = { class: "tree-view-card__label" }, Oe = ["aria-label"], Y = /* @__PURE__ */ D({
5
5
  __name: "TreeNodeCard",
6
6
  props: {
7
7
  label: {},
@@ -9,70 +9,70 @@ const me = { class: "tree-view-card" }, ge = { class: "tree-view-card__label" },
9
9
  collapsed: { type: Boolean }
10
10
  },
11
11
  emits: ["toggle"],
12
- setup(t, { emit: l }) {
13
- const o = l;
14
- return (e, r) => (d(), c("div", me, [
15
- C("span", ge, w(t.label), 1),
16
- t.hasChildren ? (d(), c("button", {
12
+ setup(o, { emit: c }) {
13
+ const i = c;
14
+ return (e, a) => (s(), d("div", Le, [
15
+ C("span", Ie, _(o.label), 1),
16
+ o.hasChildren ? (s(), d("button", {
17
17
  key: 0,
18
18
  type: "button",
19
19
  class: "tree-view-card__toggle",
20
20
  "data-tv-no-pan": "",
21
- "aria-label": t.collapsed ? "Развернуть" : "Свернуть",
22
- onClick: r[0] || (r[0] = j((v) => o("toggle"), ["stop"]))
23
- }, w(t.collapsed ? "+" : "−"), 9, we)) : E("", !0)
21
+ "aria-label": o.collapsed ? "Развернуть" : "Свернуть",
22
+ onClick: a[0] || (a[0] = Q((u) => i("toggle"), ["stop"]))
23
+ }, _(o.collapsed ? "+" : "−"), 9, Oe)) : z("", !0)
24
24
  ]));
25
25
  }
26
26
  });
27
- function ke(t) {
28
- const l = g({ ...Y }), o = new Z({
29
- pannable: t.pannable,
30
- zoomable: t.zoomable,
31
- limits: t.limits,
27
+ function Me(o) {
28
+ const c = g({ ...J }), i = new X({
29
+ pannable: o.pannable,
30
+ zoomable: o.zoomable,
31
+ limits: o.limits,
32
32
  onChange: (e) => {
33
- l.value = e;
33
+ c.value = e;
34
34
  }
35
35
  });
36
- return N(
37
- t.element,
38
- (e, r, v) => {
39
- e && (o.attach(e), v(() => o.detach()));
36
+ return O(
37
+ o.element,
38
+ (e, a, u) => {
39
+ e && (i.attach(e), u(() => i.detach()));
40
40
  },
41
41
  { immediate: !0 }
42
- ), D(() => o.detach()), {
43
- transform: l,
44
- fit: (e, r) => o.fit(e, r),
45
- zoomIn: () => o.zoomIn(),
46
- zoomOut: () => o.zoomOut(),
47
- reset: () => o.reset(),
48
- setTransform: (e) => o.set(e)
42
+ ), P(() => i.detach()), {
43
+ transform: c,
44
+ fit: (e, a) => i.fit(e, a),
45
+ zoomIn: () => i.zoomIn(),
46
+ zoomOut: () => i.zoomOut(),
47
+ reset: () => i.reset(),
48
+ setTransform: (e) => i.set(e)
49
49
  };
50
50
  }
51
- function _e(t) {
52
- const l = g(/* @__PURE__ */ new Set()), o = h(() => K(t.data(), t.accessors())), e = h(() => q(o.value, l.value)), r = h(() => J(e.value, t.options()));
53
- function v(b) {
54
- return l.value.has(b);
51
+ function Re(o) {
52
+ const c = g(/* @__PURE__ */ new Set()), i = f(() => ee(o.data(), o.accessors())), e = f(() => te(i.value, c.value)), a = f(() => oe(e.value, o.options()));
53
+ function u(b) {
54
+ return c.value.has(b);
55
55
  }
56
56
  function m(b) {
57
- l.value = X(l.value, b);
57
+ c.value = ne(c.value, b);
58
58
  }
59
- function a() {
60
- l.value = /* @__PURE__ */ new Set();
59
+ function l() {
60
+ c.value = /* @__PURE__ */ new Set();
61
61
  }
62
- return { layout: r, isCollapsed: v, toggle: m, expandAll: a };
62
+ return { layout: a, isCollapsed: u, toggle: m, expandAll: l };
63
63
  }
64
- function xe(t, l, o) {
65
- const e = g(o() ? ee() : null);
66
- function r() {
67
- e.value = o() ? te(t.value, l()) : null;
64
+ function De(o, c, i) {
65
+ const e = g(i() ? ae() : null);
66
+ function a() {
67
+ e.value = i() ? re(o.value, c()) : null;
68
68
  }
69
69
  return V(() => {
70
- r(), window.addEventListener("scroll", r, { passive: !0, capture: !0 }), window.addEventListener("resize", r, { passive: !0 });
71
- }), D(() => {
72
- window.removeEventListener("scroll", r, { capture: !0 }), window.removeEventListener("resize", r);
73
- }), { rect: e, update: r };
70
+ a(), window.addEventListener("scroll", a, { passive: !0, capture: !0 }), window.addEventListener("resize", a, { passive: !0 });
71
+ }), P(() => {
72
+ window.removeEventListener("scroll", a, { capture: !0 }), window.removeEventListener("resize", a);
73
+ }), { rect: e, update: a };
74
74
  }
75
- const ye = ["width", "height"], Ce = ["d"], Te = ["onClick"], ze = /* @__PURE__ */ R({
75
+ const Ne = ["width", "height"], We = ["data-depth"], Fe = ["d"], He = ["data-depth", "onClick"], Ae = /* @__PURE__ */ D({
76
76
  __name: "TreeView",
77
77
  props: {
78
78
  data: {},
@@ -88,11 +88,11 @@ const ye = ["width", "height"], Ce = ["d"], Te = ["onClick"], ze = /* @__PURE__
88
88
  scaleLimits: { default: void 0 },
89
89
  nodeClass: { type: [String, Function], default: void 0 },
90
90
  virtualize: { type: Boolean, default: !0 },
91
- overscan: { default: oe }
91
+ overscan: { default: ie }
92
92
  },
93
93
  emits: ["node-click", "toggle", "transform"],
94
- setup(t, { expose: l, emit: o }) {
95
- const e = t, r = o, v = g(null), m = g(null), { layout: a, isCollapsed: b, toggle: i, expandAll: k } = _e({
94
+ setup(o, { expose: c, emit: i }) {
95
+ const e = o, a = i, u = g(null), m = g(null), { layout: l, isCollapsed: b, toggle: r, expandAll: w } = Re({
96
96
  data: () => e.data,
97
97
  options: () => e.options,
98
98
  accessors: () => ({
@@ -100,31 +100,31 @@ const ye = ["width", "height"], Ce = ["d"], Te = ["onClick"], ze = /* @__PURE__
100
100
  getChildren: e.getChildren,
101
101
  getParentId: e.getParentId
102
102
  })
103
- }), p = ke({
104
- element: v,
103
+ }), p = Me({
104
+ element: u,
105
105
  pannable: () => e.pannable,
106
106
  zoomable: () => e.zoomable,
107
- limits: () => e.scaleLimits ?? ae
108
- }), T = xe(
107
+ limits: () => e.scaleLimits ?? de
108
+ }), T = De(
109
109
  m,
110
110
  () => p.transform.value.scale,
111
111
  () => e.virtualize
112
- ), S = h(
113
- () => e.virtualize ? ne(a.value, T.rect.value, e.overscan) : a.value
114
- ), u = h(() => ({
115
- width: `${a.value.width}px`,
116
- height: `${a.value.height}px`,
117
- transform: re(p.transform.value)
118
- })), _ = h(() => {
112
+ ), $ = f(
113
+ () => e.virtualize ? le(l.value, T.rect.value, e.overscan) : l.value
114
+ ), k = f(() => ({
115
+ width: `${l.value.width}px`,
116
+ height: `${l.value.height}px`,
117
+ transform: se(p.transform.value)
118
+ })), N = f(() => {
119
119
  if (e.size !== "content") return;
120
120
  const { scale: n } = p.transform.value;
121
121
  return {
122
- width: `${a.value.width * n}px`,
123
- height: `${a.value.height * n}px`,
122
+ width: `${l.value.width * n}px`,
123
+ height: `${l.value.height * n}px`,
124
124
  overflow: "visible"
125
125
  };
126
126
  });
127
- function f(n) {
127
+ function W(n) {
128
128
  return {
129
129
  left: `${n.x}px`,
130
130
  top: `${n.y}px`,
@@ -132,229 +132,294 @@ const ye = ["width", "height"], Ce = ["d"], Te = ["onClick"], ze = /* @__PURE__
132
132
  height: `${n.height}px`
133
133
  };
134
134
  }
135
- function z(n) {
135
+ function F(n) {
136
136
  return typeof e.nodeClass == "function" ? e.nodeClass(n) : e.nodeClass;
137
137
  }
138
- function L(n) {
138
+ function H(n) {
139
139
  const x = n.data;
140
140
  return x?.name ?? x?.title ?? x?.label ?? n.id;
141
141
  }
142
- function $(n) {
143
- i(n.id), r("toggle", n, b(n.id));
142
+ function y(n) {
143
+ r(n.id), a("toggle", n, b(n.id));
144
144
  }
145
- function U(n, x) {
146
- r("node-click", n, x), e.collapsible && n.hasChildren && $(n);
145
+ function A(n, x) {
146
+ a("node-click", n, x), e.collapsible && n.hasChildren && y(n);
147
147
  }
148
- function A(n) {
149
- p.fit({ width: a.value.width, height: a.value.height }, n);
148
+ function B(n) {
149
+ p.fit({ width: l.value.width, height: l.value.height }, n);
150
150
  }
151
151
  return V(() => {
152
- e.fitOnMount && P(() => A());
153
- }), N(
152
+ e.fitOnMount && U(() => B());
153
+ }), O(
154
154
  () => p.transform.value,
155
155
  (n) => {
156
- T.update(), r("transform", n);
156
+ T.update(), a("transform", n);
157
157
  }
158
- ), N(a, () => {
159
- P(() => T.update());
160
- }), l({
161
- fit: A,
158
+ ), O(l, () => {
159
+ U(() => T.update());
160
+ }), c({
161
+ fit: B,
162
162
  zoomIn: p.zoomIn,
163
163
  zoomOut: p.zoomOut,
164
164
  resetTransform: p.reset,
165
165
  setTransform: p.setTransform,
166
- expandAll: k,
167
- toggle: i,
168
- layout: a,
166
+ expandAll: w,
167
+ toggle: r,
168
+ layout: l,
169
169
  transform: p.transform
170
- }), (n, x) => (d(), c("div", {
170
+ }), (n, x) => (s(), d("div", {
171
171
  ref_key: "rootElement",
172
- ref: v,
173
- class: I(["tree-view", { "tree-view--pannable": t.pannable, "tree-view--content": t.size === "content" }]),
174
- style: y(_.value)
172
+ ref: u,
173
+ class: E(["tree-view", { "tree-view--pannable": o.pannable, "tree-view--content": o.size === "content" }]),
174
+ style: S(N.value)
175
175
  }, [
176
176
  C("div", {
177
177
  ref_key: "canvasElement",
178
178
  ref: m,
179
179
  class: "tree-view__canvas",
180
- style: y(u.value)
180
+ style: S(k.value)
181
181
  }, [
182
- (d(), c("svg", {
182
+ (s(), d("svg", {
183
183
  class: "tree-view__links",
184
- width: W(a).width,
185
- height: W(a).height
184
+ width: j(l).width,
185
+ height: j(l).height
186
186
  }, [
187
- (d(!0), c(B, null, M(S.value.links, (s) => O(n.$slots, "link", { link: s }, () => [
188
- C("path", {
189
- class: "tree-view__link",
190
- d: s.path
191
- }, null, 8, Ce)
192
- ], void 0, s.id)), 128))
193
- ], 8, ye)),
194
- (d(!0), c(B, null, M(S.value.nodes, (s) => (d(), c("div", {
195
- key: s.id,
196
- class: I(["tree-view__node", z(s)]),
197
- style: y(f(s)),
198
- onClick: (F) => U(s, F)
187
+ (s(!0), d(I, null, M($.value.links, (t) => (s(), d("g", {
188
+ key: t.id,
189
+ "data-depth": t.target.depth
190
+ }, [
191
+ R(n.$slots, "link", { link: t }, () => [
192
+ C("path", {
193
+ class: "tree-view__link",
194
+ d: t.path
195
+ }, null, 8, Fe)
196
+ ])
197
+ ], 8, We))), 128))
198
+ ], 8, Ne)),
199
+ (s(!0), d(I, null, M($.value.nodes, (t) => (s(), d("div", {
200
+ key: t.id,
201
+ class: E(["tree-view__node", F(t)]),
202
+ style: S(W(t)),
203
+ "data-depth": t.depth,
204
+ onClick: (h) => A(t, h)
199
205
  }, [
200
- O(n.$slots, "node", {
201
- node: s,
202
- data: s.data,
203
- depth: s.depth,
204
- collapsed: s.collapsed,
205
- hasChildren: s.hasChildren,
206
- toggle: () => $(s)
206
+ R(n.$slots, "node", {
207
+ node: t,
208
+ data: t.data,
209
+ depth: t.depth,
210
+ collapsed: t.collapsed,
211
+ hasChildren: t.hasChildren,
212
+ toggle: () => y(t)
207
213
  }, () => [
208
- Q(H, {
209
- label: L(s),
210
- "has-children": s.hasChildren,
211
- collapsed: s.collapsed,
212
- onToggle: (F) => $(s)
214
+ K(Y, {
215
+ label: H(t),
216
+ "has-children": t.hasChildren,
217
+ collapsed: t.collapsed,
218
+ onToggle: (h) => y(t)
213
219
  }, null, 8, ["label", "has-children", "collapsed", "onToggle"])
214
220
  ])
215
- ], 14, Te))), 128))
221
+ ], 14, He))), 128))
216
222
  ], 4)
217
223
  ], 6));
218
224
  }
219
- }), $e = {
225
+ }), Pe = {
220
226
  key: 0,
221
227
  class: "tv-bracket__hint"
222
- }, Ee = ["title", "onClick", "onMouseenter"], Be = {
228
+ }, Ve = ["title", "aria-label", "aria-expanded"], Ge = { class: "tv-bracket__rows" }, Ue = ["title", "onClick", "onMouseenter"], je = {
223
229
  key: 0,
224
230
  class: "tv-bracket__tooltip"
225
- }, Se = { class: "tv-bracket__name" }, Le = { class: "tv-bracket__score" }, Ie = /* @__PURE__ */ R({
231
+ }, Qe = { class: "tv-bracket__name" }, Ye = { class: "tv-bracket__score" }, Ze = /* @__PURE__ */ D({
226
232
  __name: "BracketCard",
227
233
  props: {
228
234
  match: {},
229
235
  rows: { default: void 0 },
230
236
  myTeamHint: { default: "Нажми для перехода в матч 👇" },
231
237
  techDefeatLabel: { default: "ТП" },
232
- techDefeatHint: { default: "Техническое поражение" }
238
+ techDefeatHint: { default: "Техническое поражение" },
239
+ hasChildren: { type: Boolean, default: !1 },
240
+ collapsed: { type: Boolean, default: !1 },
241
+ collapseHint: { default: "Свернуть предыдущие матчи" },
242
+ expandHint: { default: "Показать предыдущие матчи" }
233
243
  },
234
- emits: ["select"],
235
- setup(t, { emit: l }) {
236
- const o = t, e = l, r = g(null), v = h(
237
- () => ie(o.match, { rows: o.rows, techDefeatLabel: o.techDefeatLabel })
244
+ emits: ["select", "toggle"],
245
+ setup(o, { emit: c }) {
246
+ const i = o, e = c, a = g(null), u = f(
247
+ () => ce(i.match, { rows: i.rows, techDefeatLabel: i.techDefeatLabel })
238
248
  );
239
- function m(a) {
240
- a.team && e("select", a.team, a);
249
+ function m(l) {
250
+ l.team && e("select", l.team, l);
241
251
  }
242
- return (a, b) => (d(), c("div", {
243
- class: I(["tv-bracket", { "tv-bracket--my-team": v.value.hasMyTeam }])
252
+ return (l, b) => (s(), d("div", {
253
+ class: E(["tv-bracket", { "tv-bracket--my-team": u.value.hasMyTeam }])
244
254
  }, [
245
- v.value.hasMyTeam && t.myTeamHint ? (d(), c("div", $e, w(t.myTeamHint), 1)) : E("", !0),
246
- (d(!0), c(B, null, M(v.value.rows, (i) => (d(), c("div", {
247
- key: i.key,
248
- class: I(["tv-bracket__row", {
249
- "tv-bracket__row--winner": i.isWinner,
250
- "tv-bracket__row--loser": i.isLoser && !i.isEmpty,
251
- "tv-bracket__row--my": i.isMyTeam,
252
- "tv-bracket__row--empty": i.isEmpty
253
- }]),
254
- title: i.isMyTeam ? "Моя команда" : void 0,
255
- onClick: (k) => m(i),
256
- onMouseenter: (k) => r.value = i.key,
257
- onMouseleave: b[0] || (b[0] = (k) => r.value = null)
258
- }, [
259
- i.team ? (d(), c(B, { key: 0 }, [
260
- i.isTechDefeat && r.value === i.key ? (d(), c("span", Be, w(t.techDefeatHint), 1)) : E("", !0),
261
- C("span", Se, w(i.team.name), 1),
262
- C("span", Le, w(i.score), 1)
263
- ], 64)) : E("", !0)
264
- ], 42, Ee))), 128))
255
+ u.value.hasMyTeam && o.myTeamHint ? (s(), d("div", Pe, _(o.myTeamHint), 1)) : z("", !0),
256
+ o.hasChildren ? (s(), d("button", {
257
+ key: 1,
258
+ type: "button",
259
+ class: E(["tv-bracket__toggle", { "tv-bracket__toggle--collapsed": o.collapsed }]),
260
+ title: o.collapsed ? o.expandHint : o.collapseHint,
261
+ "aria-label": o.collapsed ? o.expandHint : o.collapseHint,
262
+ "aria-expanded": !o.collapsed,
263
+ "data-tv-no-pan": "",
264
+ onClick: b[0] || (b[0] = Q((r) => e("toggle"), ["stop"]))
265
+ }, _(o.collapsed ? "+" : "−"), 11, Ve)) : z("", !0),
266
+ C("div", Ge, [
267
+ (s(!0), d(I, null, M(u.value.rows, (r) => (s(), d("div", {
268
+ key: r.key,
269
+ class: E(["tv-bracket__row", {
270
+ "tv-bracket__row--winner": r.isWinner,
271
+ "tv-bracket__row--loser": r.isLoser && !r.isEmpty,
272
+ "tv-bracket__row--my": r.isMyTeam,
273
+ "tv-bracket__row--empty": r.isEmpty
274
+ }]),
275
+ title: r.isMyTeam ? "Моя команда" : void 0,
276
+ onClick: (w) => m(r),
277
+ onMouseenter: (w) => a.value = r.key,
278
+ onMouseleave: b[1] || (b[1] = (w) => a.value = null)
279
+ }, [
280
+ r.team ? (s(), d(I, { key: 0 }, [
281
+ r.isTechDefeat && a.value === r.key ? (s(), d("span", je, _(o.techDefeatHint), 1)) : z("", !0),
282
+ C("span", Qe, _(r.team.name), 1),
283
+ C("span", Ye, _(r.score), 1)
284
+ ], 64)) : z("", !0)
285
+ ], 42, Ue))), 128))
286
+ ])
265
287
  ], 2));
266
288
  }
267
- }), Me = ["onClick"], Oe = /* @__PURE__ */ R({
289
+ }), Ke = ["onClick"], qe = /* @__PURE__ */ D({
268
290
  __name: "BracketRounds",
269
291
  props: {
270
292
  rounds: {},
271
- nodeWidth: { default: 180 },
272
- levelGap: { default: 60 },
293
+ options: { default: void 0 },
273
294
  isShow: { type: Boolean, default: !0 },
274
- scrollOnClick: { type: Boolean, default: void 0 },
275
- mobileQuery: { default: le }
295
+ swipeSiblingGap: { default: 12 },
296
+ hidePassed: { type: Boolean, default: !0 },
297
+ swipe: { type: Boolean, default: void 0 },
298
+ mobileQuery: { default: ve }
276
299
  },
277
- emits: ["select"],
278
- setup(t, { emit: l }) {
279
- const o = t, e = l, r = g(null), v = g(null), m = g(!1);
280
- let a = null;
281
- V(() => {
282
- a = se(o.mobileQuery, (u) => {
283
- m.value = u;
284
- });
285
- }), D(() => a?.());
286
- const b = h(() => o.isShow && (o.scrollOnClick ?? m.value)), i = h(
287
- () => de(o.rounds, { nodeWidth: o.nodeWidth, levelGap: o.levelGap })
288
- ), k = h(() => ({ width: `${i.value.width}px` })), p = h(
289
- () => o.isShow ? { paddingLeft: `${i.value.offset}px` } : void 0
300
+ emits: ["select", "round"],
301
+ setup(o, { expose: c, emit: i }) {
302
+ const e = o, a = i, u = g(null), m = g(null), l = g(!1), b = g(0), r = g(0), w = f(() => e.isShow && (e.swipe ?? l.value)), p = f(() => ue(e.options)), T = f(
303
+ () => typeof p.value.nodeWidth == "number" ? p.value.nodeWidth : pe.nodeWidth
304
+ ), $ = f(
305
+ () => w.value ? fe(b.value, T.value) : p.value.levelGap
306
+ ), k = f(
307
+ () => he(e.rounds, { nodeWidth: T.value, levelGap: $.value })
308
+ ), N = f(
309
+ () => p.value.direction === "right-to-left" || p.value.direction === "bottom-to-top"
310
+ ), W = f(
311
+ () => w.value ? {
312
+ ...e.options,
313
+ levelGap: $.value,
314
+ levelLayout: "stack",
315
+ siblingGap: e.swipeSiblingGap,
316
+ groupGap: (t, h) => we(h, e.swipeSiblingGap),
317
+ linkStyle: "bracket",
318
+ elbowOffset: e.options?.elbowOffset ?? be
319
+ } : { ...e.options }
320
+ ), F = f(() => ({ width: `${k.value.width}px` })), H = f(
321
+ () => e.isShow ? { paddingLeft: `${k.value.offset}px` } : void 0
290
322
  );
291
- function T(u) {
292
- const _ = r.value, f = ce(_);
293
- if (!_ || !f) return;
294
- const z = v.value, L = z ? ue(z, u.index, u.width, i.value.offset)[0] : void 0, $ = L ? ve(L, f) : { left: fe(_, f) + u.index * u.width, width: u.width };
295
- pe(
296
- f,
297
- he({
298
- ...$,
299
- viewport: f.clientWidth,
300
- scrollWidth: f.scrollWidth
323
+ function y() {
324
+ const t = m.value;
325
+ if (!t) return;
326
+ const h = w.value && e.hidePassed ? r.value : 0, v = k.value.columns.length;
327
+ xe(t, h, (L) => _e(L, v, N.value));
328
+ }
329
+ function A() {
330
+ const t = u.value;
331
+ if (!t || !w.value) return;
332
+ const h = k.value.columns[0]?.width ?? 0, v = ye(t.scrollLeft, h, k.value.columns.length);
333
+ v !== r.value && (r.value = v, a("round", v));
334
+ }
335
+ O([r, w, k], () => y());
336
+ const B = [];
337
+ V(() => {
338
+ B.push(
339
+ me(e.mobileQuery, (t) => {
340
+ l.value = t;
341
+ }),
342
+ ge(u.value?.parentElement, (t) => {
343
+ b.value = t;
344
+ }),
345
+ // Сетка перерисовывает карточки — скрытое расставляем заново.
346
+ ke(m.value, y)
347
+ ), y();
348
+ }), P(() => B.forEach((t) => t()));
349
+ function n(t) {
350
+ const h = u.value;
351
+ if (!h) return;
352
+ const v = w.value ? h : Ce(h);
353
+ if (!v) return;
354
+ const L = m.value, G = L ? Te(L, t.index, t.width, k.value.offset)[0] : void 0, Z = G ? ze(G, v) : { left: Se(h, v) + t.index * t.width, width: t.width };
355
+ Ee(
356
+ v,
357
+ $e({
358
+ ...Z,
359
+ viewport: v.clientWidth,
360
+ scrollWidth: v.scrollWidth
301
361
  })
302
362
  );
303
363
  }
304
- function S(u) {
305
- b.value && (e("select", u), T(u));
364
+ function x(t) {
365
+ a("select", t), n(t);
306
366
  }
307
- return (u, _) => (d(), c("div", {
367
+ return c({ scrollToRound: n }), (t, h) => (s(), d("div", {
308
368
  ref_key: "rootElement",
309
- ref: r,
310
- class: "tv-rounds"
369
+ ref: u,
370
+ class: E(["tv-rounds", { "tv-rounds--swipe": w.value }]),
371
+ onScroll: A
311
372
  }, [
312
- t.isShow ? (d(), c("div", {
373
+ o.isShow ? (s(), d("div", {
313
374
  key: 0,
314
375
  class: "tv-rounds__bar",
315
- style: y(k.value)
376
+ style: S(F.value)
316
377
  }, [
317
- (d(!0), c(B, null, M(i.value.columns, (f) => (d(), c("div", {
318
- key: f.key,
378
+ (s(!0), d(I, null, M(k.value.columns, (v) => (s(), d("div", {
379
+ key: v.key,
319
380
  class: "tv-rounds__item",
320
- style: y({ width: `${f.width}px` }),
321
- onClick: (z) => S(f)
381
+ style: S({ width: `${v.width}px` }),
382
+ onClick: (L) => x(v)
322
383
  }, [
323
- O(u.$slots, "round", { round: f }, () => [
324
- G(w(f.name), 1)
384
+ R(t.$slots, "round", { round: v }, () => [
385
+ q(_(v.name), 1)
325
386
  ])
326
- ], 12, Me))), 128))
327
- ], 4)) : E("", !0),
387
+ ], 12, Ke))), 128))
388
+ ], 4)) : z("", !0),
328
389
  C("div", {
329
390
  ref_key: "contentElement",
330
- ref: v,
391
+ ref: m,
331
392
  class: "tv-rounds__content",
332
- style: y(p.value)
393
+ style: S(H.value)
333
394
  }, [
334
- O(u.$slots, "default")
395
+ R(t.$slots, "default", {
396
+ options: W.value,
397
+ isSwipe: w.value,
398
+ round: r.value
399
+ })
335
400
  ], 4)
336
- ], 512));
401
+ ], 34));
337
402
  }
338
- }), Re = ".tree-view{--tv-link-color: #cbd5e1;--tv-link-width: 2px;--tv-node-bg: #ffffff;--tv-node-color: #0f172a;--tv-node-border: 1px solid #e2e8f0;--tv-node-radius: 10px;--tv-node-shadow: 0 1px 2px rgb(15 23 42 / 8%);--tv-node-padding: 8px 12px;--tv-accent: #2563eb;position:relative;width:100%;height:100%;overflow:hidden;touch-action:none}.tree-view--pannable{cursor:grab}.tree-view--content{width:auto;height:auto;overflow:visible}.tree-view__canvas{position:absolute;top:0;left:0;transform-origin:0 0}.tree-view__links{position:absolute;top:0;left:0;overflow:visible;pointer-events:none}.tree-view__link{fill:none;stroke:var(--tv-link-color);stroke-width:var(--tv-link-width)}.tree-view__node{position:absolute;box-sizing:border-box;display:flex;align-items:stretch;justify-content:stretch}.tree-view-card{box-sizing:border-box;display:flex;gap:8px;align-items:center;justify-content:space-between;width:100%;height:100%;padding:var(--tv-node-padding);overflow:hidden;color:var(--tv-node-color);background:var(--tv-node-bg);border:var(--tv-node-border);border-radius:var(--tv-node-radius);box-shadow:var(--tv-node-shadow)}.tree-view-card__label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tree-view-card__toggle{flex:none;width:20px;height:20px;padding:0;font:inherit;line-height:1;color:var(--tv-accent);cursor:pointer;background:none;border:none}.tv-bracket{--tv-bracket-winner-bg: #0427c4;--tv-bracket-winner-color: #ffffff;--tv-bracket-loser-bg: #e5e5e5;--tv-bracket-loser-color: #7d7d8d;--tv-bracket-my-bg: #00146c;--tv-bracket-my-color: #ffffff;--tv-bracket-radius: 6px;position:relative;box-sizing:border-box;display:flex;flex-direction:column;width:100%;height:100%;font-size:12px}.tv-bracket--my-team{border-radius:var(--tv-bracket-radius);outline:2px solid var(--tv-bracket-my-bg)}.tv-bracket__hint{position:absolute;right:0;bottom:100%;left:0;padding:3px 8px;overflow:hidden;font-size:11px;font-weight:600;line-height:1.2;color:var(--tv-bracket-my-color);text-align:center;text-overflow:ellipsis;white-space:nowrap;background:var(--tv-bracket-my-bg);border-radius:var(--tv-bracket-radius) var(--tv-bracket-radius) 0 0}.tv-bracket__row{position:relative;box-sizing:border-box;display:flex;flex:1 1 0;align-items:center;justify-content:space-between;min-height:0;padding:4px 8px;cursor:pointer;transition:all 75ms}.tv-bracket__row--winner{font-weight:700;color:var(--tv-bracket-winner-color);background:var(--tv-bracket-winner-bg)}.tv-bracket__row--loser{color:var(--tv-bracket-loser-color);background:var(--tv-bracket-loser-bg)}.tv-bracket__row--my{color:var(--tv-bracket-my-color);background:var(--tv-bracket-my-bg)}.tv-bracket__row--empty{cursor:default;background:var(--tv-bracket-loser-bg)}.tv-bracket__name{max-width:120px;overflow:hidden;font-weight:600;text-overflow:ellipsis;white-space:nowrap}.tv-bracket__score{display:flex;flex:none;align-items:center;justify-content:center;width:20px;height:20px;font-weight:700;font-variant-numeric:tabular-nums}.tv-bracket__tooltip{position:absolute;top:-26px;left:6px;z-index:5000;padding:4px 8px;font-weight:400;color:var(--tv-bracket-loser-color);white-space:nowrap;background:#fff;border:1px solid #d1d5db;border-radius:4px;box-shadow:0 4px 10px #0f172a26}.tv-rounds{--tv-rounds-bg: #f5f5f7;--tv-rounds-color: #9ca3af;--tv-rounds-border: 2px solid #e5e7eb;--tv-rounds-gap: 20px;display:flex;flex-direction:column;width:max-content;min-width:100%}.tv-rounds__bar{display:flex;min-width:100%;margin-bottom:var(--tv-rounds-gap);background:var(--tv-rounds-bg);border-bottom:var(--tv-rounds-border)}.tv-rounds__item{flex:none;box-sizing:border-box;padding:10px 20px;font:inherit;font-size:14px;font-weight:600;color:var(--tv-rounds-color);text-align:center;text-transform:uppercase;white-space:nowrap;background:none;border:none;border-right:var(--tv-rounds-border)}";
339
- be(Re);
340
- const Ve = {
341
- install(t) {
342
- t.component("TreeView", ze), t.component("TreeNodeCard", H), t.component("BracketCard", Ie), t.component("BracketRounds", Oe);
403
+ }), Je = ".tree-view{--tv-link-color: #cbd5e1;--tv-link-width: 2px;--tv-node-bg: #ffffff;--tv-node-color: #0f172a;--tv-node-border: 1px solid #e2e8f0;--tv-node-radius: 10px;--tv-node-shadow: 0 1px 2px rgb(15 23 42 / 8%);--tv-node-padding: 8px 12px;--tv-accent: #2563eb;position:relative;width:100%;height:100%;overflow:hidden}.tree-view--pannable{cursor:grab;touch-action:none}.tree-view--content{width:auto;height:auto;overflow:visible}.tree-view__canvas{position:absolute;top:0;left:0;transform-origin:0 0}.tree-view__links{position:absolute;top:0;left:0;overflow:visible;pointer-events:none}.tree-view__link{fill:none;stroke:var(--tv-link-color);stroke-width:var(--tv-link-width)}.tree-view__node{position:absolute;box-sizing:border-box;display:flex;align-items:stretch;justify-content:stretch}.tree-view-card{box-sizing:border-box;display:flex;gap:8px;align-items:center;justify-content:space-between;width:100%;height:100%;padding:var(--tv-node-padding);overflow:hidden;color:var(--tv-node-color);background:var(--tv-node-bg);border:var(--tv-node-border);border-radius:var(--tv-node-radius);box-shadow:var(--tv-node-shadow)}.tree-view-card__label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tree-view-card__toggle{flex:none;width:20px;height:20px;padding:0;font:inherit;line-height:1;color:var(--tv-accent);cursor:pointer;background:none;border:none}.tv-bracket{--tv-bracket-winner-bg: #0427c4;--tv-bracket-winner-color: #ffffff;--tv-bracket-loser-bg: #e5e5e5;--tv-bracket-loser-color: #7d7d8d;--tv-bracket-my-bg: #00146c;--tv-bracket-my-color: #ffffff;--tv-bracket-radius: 6px;--tv-bracket-shadow: 0 0 0 1px rgb(15 23 42 / 8%), 0 1px 3px rgb(15 23 42 / 10%);position:relative;box-sizing:border-box;display:flex;flex-direction:column;width:100%;height:100%;font-size:12px}.tv-bracket__rows{box-sizing:border-box;display:flex;flex:1 1 auto;flex-direction:column;min-height:0;overflow:hidden;border-radius:var(--tv-bracket-radius);box-shadow:var(--tv-bracket-shadow)}.tv-bracket--my-team .tv-bracket__rows{outline:2px solid var(--tv-bracket-my-bg)}.tv-bracket__hint{position:absolute;right:0;bottom:100%;left:0;padding:3px 8px;overflow:hidden;font-size:11px;font-weight:600;line-height:1.2;color:var(--tv-bracket-my-color);text-align:center;text-overflow:ellipsis;white-space:nowrap;background:var(--tv-bracket-my-bg);border-radius:var(--tv-bracket-radius) var(--tv-bracket-radius) 0 0}.tv-bracket__row{position:relative;box-sizing:border-box;display:flex;flex:1 1 0;align-items:center;justify-content:space-between;min-height:0;padding:4px 8px;cursor:pointer;transition:all 75ms}.tv-bracket__row--winner{font-weight:700;color:var(--tv-bracket-winner-color);background:var(--tv-bracket-winner-bg)}.tv-bracket__row--loser{color:var(--tv-bracket-loser-color);background:var(--tv-bracket-loser-bg)}.tv-bracket__row--my{color:var(--tv-bracket-my-color);background:var(--tv-bracket-my-bg)}.tv-bracket__row--empty{cursor:default;background:var(--tv-bracket-loser-bg)}.tv-bracket__toggle{position:absolute;top:50%;left:-11px;z-index:1;display:flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;font:inherit;font-size:13px;font-weight:700;line-height:1;color:var(--tv-bracket-winner-bg);cursor:pointer;background:#fff;border:1px solid #d1d5db;border-radius:50%;box-shadow:0 1px 3px #0f172a2e;transform:translateY(-50%)}.tv-bracket__toggle:hover{border-color:var(--tv-bracket-winner-bg)}.tv-bracket__toggle--collapsed{color:var(--tv-bracket-winner-color);background:var(--tv-bracket-winner-bg);border-color:var(--tv-bracket-winner-bg)}.tv-bracket__name{max-width:120px;overflow:hidden;font-weight:600;text-overflow:ellipsis;white-space:nowrap}.tv-bracket__score{display:flex;flex:none;align-items:center;justify-content:center;width:20px;height:20px;font-weight:700;font-variant-numeric:tabular-nums}.tv-bracket__tooltip{position:absolute;top:-26px;left:6px;z-index:5000;padding:4px 8px;font-weight:400;color:var(--tv-bracket-loser-color);white-space:nowrap;background:#fff;border:1px solid #d1d5db;border-radius:4px;box-shadow:0 4px 10px #0f172a26}.tv-rounds{--tv-rounds-bg: #f5f5f7;--tv-rounds-color: #9ca3af;--tv-rounds-border: 2px solid #e5e7eb;--tv-rounds-gap: 20px;--tv-rounds-fade: .22s;--tv-rounds-collapse-scale: .86;--tv-rounds-collapse-ease: cubic-bezier(.4, 0, .2, 1);--tv-rounds-link-color: #94a3b8;--tv-rounds-link-width: 3px;display:flex;flex-direction:column;width:max-content;min-width:100%}.tv-rounds__bar{display:flex;min-width:100%;margin-bottom:var(--tv-rounds-gap);background:var(--tv-rounds-bg);border-bottom:var(--tv-rounds-border)}.tv-rounds__item{flex:none;box-sizing:border-box;padding:10px 20px;font:inherit;font-size:14px;font-weight:600;color:var(--tv-rounds-color);text-align:center;text-transform:uppercase;white-space:nowrap;background:none;border:none;border-right:var(--tv-rounds-border)}.tv-rounds--swipe .tv-bracket__hint{display:none}.tv-rounds--swipe .tree-view{--tv-link-color: var(--tv-rounds-link-color);--tv-link-width: var(--tv-rounds-link-width)}.tv-rounds--swipe{width:100%;min-width:0;overflow-x:auto;overscroll-behavior-x:contain;scroll-snap-type:x mandatory;scrollbar-width:none}.tv-rounds--swipe::-webkit-scrollbar{display:none}.tv-rounds--swipe .tv-rounds__item{scroll-snap-align:start;scroll-snap-stop:always}.tv-rounds--swipe [data-depth]{transition:opacity var(--tv-rounds-fade, .22s) ease,transform var(--tv-rounds-fade, .22s) var(--tv-rounds-collapse-ease)}.tv-rounds--swipe [data-depth].tv-hidden{visibility:hidden;opacity:0;transition:opacity var(--tv-rounds-fade, .22s) ease,transform var(--tv-rounds-fade, .22s) var(--tv-rounds-collapse-ease),visibility 0s linear var(--tv-rounds-fade, .22s)}.tv-rounds--swipe .tree-view__node.tv-hidden{transform:scale(var(--tv-rounds-collapse-scale));transform-origin:right center}.tv-hidden{visibility:hidden}@media(prefers-reduced-motion:reduce){.tv-rounds--swipe [data-depth],.tv-rounds--swipe [data-depth].tv-hidden{transition:none}.tv-rounds--swipe .tree-view__node.tv-hidden{transform:none}}";
404
+ Be(Je);
405
+ const tt = {
406
+ install(o) {
407
+ o.component("TreeView", Ae), o.component("TreeNodeCard", Y), o.component("BracketCard", Ze), o.component("BracketRounds", qe);
343
408
  }
344
409
  };
345
410
  export {
346
- Ie as BracketCard,
347
- Oe as BracketRounds,
348
- Pe as DEFAULT_OPTIONS,
349
- We as MOBILE_MEDIA_QUERY,
350
- H as TreeNodeCard,
351
- ze as TreeView,
352
- Ve as TreeViewPlugin,
353
- He as bracketCardHeight,
354
- Ue as buildBracketCard,
355
- je as buildBracketRounds,
356
- Ve as default,
357
- ke as usePanZoom,
358
- _e as useTreeLayout
411
+ Ze as BracketCard,
412
+ qe as BracketRounds,
413
+ at as DEFAULT_OPTIONS,
414
+ rt as MOBILE_MEDIA_QUERY,
415
+ Y as TreeNodeCard,
416
+ Ae as TreeView,
417
+ tt as TreeViewPlugin,
418
+ it as bracketCardHeight,
419
+ lt as buildBracketCard,
420
+ st as buildBracketRounds,
421
+ tt as default,
422
+ Me as usePanZoom,
423
+ Re as useTreeLayout
359
424
  };
360
425
  //# sourceMappingURL=index.js.map