@ninebone/table 0.0.84 → 0.0.86

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.
@@ -1,115 +1,101 @@
1
- var ne = Object.defineProperty;
2
- var ie = (g) => {
3
- throw TypeError(g);
1
+ var ee = Object.defineProperty;
2
+ var te = (p) => {
3
+ throw TypeError(p);
4
4
  };
5
- var se = (g, i, t) => i in g ? ne(g, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[i] = t;
6
- var f = (g, i) => ne(g, "name", { value: i, configurable: !0 });
7
- var L = (g, i, t) => se(g, typeof i != "symbol" ? i + "" : i, t), oe = (g, i, t) => i.has(g) || ie("Cannot " + t);
8
- var e = (g, i, t) => (oe(g, i, "read from private field"), t ? t.call(g) : i.get(g)), y = (g, i, t) => i.has(g) ? ie("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(g) : i.set(g, t), w = (g, i, t, r) => (oe(g, i, "write to private field"), r ? r.call(g, t) : i.set(g, t), t);
9
- import { trace as re } from "@ninebone/util";
10
- const Q = class Q extends re.constructor {
5
+ var ie = (p, i, t) => i in p ? ee(p, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[i] = t;
6
+ var b = (p, i) => ee(p, "name", { value: i, configurable: !0 });
7
+ var C = (p, i, t) => ie(p, typeof i != "symbol" ? i + "" : i, t), ne = (p, i, t) => i.has(p) || te("Cannot " + t);
8
+ var e = (p, i, t) => (ne(p, i, "read from private field"), t ? t.call(p) : i.get(p)), y = (p, i, t) => i.has(p) ? te("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(p) : i.set(p, t), S = (p, i, t, o) => (ne(p, i, "write to private field"), o ? o.call(p, t) : i.set(p, t), t);
9
+ import { trace as oe } from "@ninebone/util";
10
+ const G = class G extends oe.constructor {
11
11
  constructor() {
12
12
  super(), this.init("nine-table", "green");
13
13
  }
14
14
  };
15
- f(Q, "Trace");
16
- let Y = Q;
17
- const z = new Y();
18
- var k, E, o, A, R, T, N, I, X;
19
- const V = class V extends HTMLElement {
15
+ b(G, "Trace");
16
+ let K = G;
17
+ const W = new K();
18
+ var E, B, c, L, R, A, z;
19
+ const J = class J extends HTMLElement {
20
20
  constructor() {
21
21
  super();
22
- y(this, k);
23
- y(this, E, !1);
24
- y(this, o);
25
- y(this, A);
22
+ y(this, E);
23
+ y(this, B);
24
+ y(this, c);
25
+ y(this, L);
26
26
  y(this, R);
27
- y(this, T);
28
- y(this, N, /* @__PURE__ */ f(() => {
29
- if (!e(this, k)) return;
30
- const t = e(this, k).querySelector(".ng-container-body");
31
- t && (w(this, T, new ResizeObserver(() => {
32
- this.refresh();
33
- })), e(this, T).observe(t));
34
- }, "#observeResize"));
35
- L(this, "refresh", /* @__PURE__ */ f(() => {
36
- if (!e(this, k) || e(this, E) || !e(this, o)) return;
37
- const t = e(this, o).container, r = t.querySelector("table");
38
- if (!r) return;
39
- const p = $(e(this, o).track, this), l = $(e(this, o).thumb, this), h = e(this, k).querySelector(".ng-container-bottom");
40
- if (t.clientWidth !== 0 && r.scrollWidth > t.clientWidth)
27
+ C(this, "refresh", /* @__PURE__ */ b(() => {
28
+ if (!e(this, E) || !e(this, c)) return;
29
+ const t = e(this, c).container, o = t.querySelector("table");
30
+ if (!o) return;
31
+ const r = $(e(this, c).track, this), d = $(e(this, c).thumb, this), h = e(this, E).querySelector(".ng-container-bottom");
32
+ if (t.clientWidth !== 0 && o.scrollWidth > t.clientWidth)
41
33
  $(h).show();
42
34
  else {
43
35
  $(h).hide();
44
36
  return;
45
37
  }
46
- const s = p.width();
38
+ const s = r.width();
47
39
  if (s <= 0) return;
48
- const u = t.clientWidth / r.scrollWidth, n = Math.max(Math.min(s * u, s), 20);
49
- l.width(n);
50
- const b = r.scrollWidth - t.clientWidth, a = s - n;
51
- let c = 0;
52
- b > 0 && (c = parseInt(t.scrollLeft / b * a, 10)), c < 0 && (c = 0), c > a && (c = a), l.css({ left: c + "px" }), e(this, o).left.disabled = t.scrollLeft <= 0, e(this, o).right.disabled = t.scrollLeft >= b;
40
+ const g = Math.min(s * t.clientWidth / o.scrollWidth, s);
41
+ d.width(Math.max(g, 20));
42
+ const n = parseInt($(o).css("left") || 0, 10);
43
+ let l = parseInt(Math.abs(n) * s / o.scrollWidth, 10);
44
+ l < 0 && (l = 0);
45
+ const a = r.width() - d.width();
46
+ l > a && (l = a), d.css({ left: l }), e(this, c).left.disabled = l == 0, e(this, c).right.disabled = l >= a;
53
47
  }, "refresh"));
54
- y(this, I, /* @__PURE__ */ f((t) => {
55
- if (!e(this, o)) return !1;
56
- const r = e(this, o).container, p = r.querySelector("table");
57
- if (!p) return !1;
58
- const l = e(this, o).track.getBoundingClientRect(), h = $(e(this, o).thumb, this).width() || 20;
48
+ y(this, A, /* @__PURE__ */ b((t) => {
49
+ if (!e(this, c)) return !1;
50
+ const o = e(this, c).container, r = o.querySelector("table");
51
+ if (!r) return !1;
52
+ const d = e(this, c).track.getBoundingClientRect(), h = e(this, c).thumb.getBoundingClientRect();
59
53
  let s = t;
60
- s < 0 && (s = 0), s + h > l.width && (s = l.width - h), s = parseInt(s, 10), e(this, o).thumb.style.left = s + "px";
61
- const u = p.scrollWidth - r.clientWidth, n = l.width - h;
62
- return n > 0 && u > 0 && (r.scrollLeft = s / n * u), e(this, o).left.disabled = s <= 0, e(this, o).right.disabled = s >= n, s > 0 && s < n;
54
+ s < 0 && (s = 0), s + h.width > d.width && (s = d.width - h.width), s = parseInt(s, 10), e(this, c).thumb.style.left = s + "px";
55
+ const g = o.clientWidth, n = r.scrollWidth;
56
+ let l = -s * (n - g) / (d.width - h.width);
57
+ -l > n - g && (l = -(n - g)), -l + 5 > n - g && (l = -(n - g)), g >= n && (l = 0), $(r).css({ left: l });
58
+ const a = d.width - h.width;
59
+ return e(this, c).left.disabled = s == 0, e(this, c).right.disabled = s >= a, s > 0 && s < a;
63
60
  }, "#thumbMoveTo"));
64
- y(this, X, /* @__PURE__ */ f(() => {
65
- const t = e(this, o).container;
66
- t && t.addEventListener("scroll", () => {
67
- e(this, E) || this.refresh();
68
- });
69
- const r = /* @__PURE__ */ f((l) => {
70
- if (!e(this, o)) return;
71
- clearInterval(e(this, A)), clearInterval(e(this, R));
72
- const h = e(this, o).track.getBoundingClientRect(), s = e(this, o).thumb.getBoundingClientRect();
73
- e(this, I).call(this, s.x - h.x + l), w(this, A, setInterval(() => {
74
- clearInterval(e(this, A)), w(this, R, setInterval(() => {
75
- if (!e(this, o)) {
76
- clearInterval(e(this, R));
77
- return;
78
- }
79
- const u = e(this, o).track.getBoundingClientRect(), n = e(this, o).thumb.getBoundingClientRect();
80
- e(this, I).call(this, n.x - u.x + l) || clearInterval(e(this, R));
61
+ y(this, z, /* @__PURE__ */ b(() => {
62
+ const t = /* @__PURE__ */ b((r) => {
63
+ clearInterval(e(this, L)), clearInterval(e(this, R));
64
+ const d = e(this, c).track.getBoundingClientRect(), h = e(this, c).thumb.getBoundingClientRect();
65
+ e(this, A).call(this, h.x - d.x + r), S(this, L, setInterval(() => {
66
+ clearInterval(e(this, L)), S(this, R, setInterval(() => {
67
+ const s = e(this, c).track.getBoundingClientRect(), g = e(this, c).thumb.getBoundingClientRect();
68
+ e(this, A).call(this, g.x - s.x + r) || clearInterval(e(this, R));
81
69
  }, 10));
82
70
  }, 500));
83
- }, "delayScroll"), p = /* @__PURE__ */ f(() => {
84
- clearInterval(e(this, A)), clearInterval(e(this, R));
71
+ }, "delayScroll"), o = /* @__PURE__ */ b(() => {
72
+ clearInterval(e(this, L)), clearInterval(e(this, R));
85
73
  }, "clearTimer");
86
- e(this, o).left.ontouchend = e(this, o).right.ontouchend = e(this, o).track.ontouchend = e(this, o).left.onmouseup = e(this, o).left.onmouseleave = e(this, o).right.onmouseup = e(this, o).right.onmouseleave = e(this, o).track.onmouseup = e(this, o).track.onmouseleave = p, $(e(this, o).left).on("mousedown", (l) => {
87
- l.buttons == 1 && r(-20);
88
- }), $(e(this, o).right).on("mousedown", (l) => {
89
- l.buttons == 1 && r(20);
90
- }), $(e(this, o).track).on("mousedown", (l) => {
91
- if (l.buttons != 1) return;
92
- l.preventDefault();
93
- const h = e(this, o).track.getBoundingClientRect(), s = $(e(this, o).thumb, this).width() || 20;
94
- e(this, I).call(this, l.clientX - h.left - s / 2);
95
- }), $(e(this, o).thumb).on("mousedown", (l) => {
96
- if (l.buttons != 1) return;
97
- l.stopPropagation(), l.preventDefault(), w(this, E, !0);
98
- const h = e(this, o).thumb.getBoundingClientRect();
99
- this.shiftX = l.clientX - h.left;
100
- const s = /* @__PURE__ */ f((n) => {
101
- if (!e(this, E) || !e(this, o)) return;
102
- const b = e(this, o).track.getBoundingClientRect();
103
- e(this, I).call(this, n.clientX - b.left - this.shiftX);
104
- }, "onMouseMove"), u = /* @__PURE__ */ f(() => {
105
- w(this, E, !1), p(), document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", u), this.refresh();
74
+ e(this, c).left.onmouseup = e(this, c).left.onmouseleave = e(this, c).right.onmouseup = e(this, c).right.onmouseleave = e(this, c).track.onmouseup = e(this, c).track.onmouseleave = o, $(e(this, c).left).on("mousedown", (r) => {
75
+ r.buttons == 1 && t(-10);
76
+ }), $(e(this, c).right).on("mousedown", (r) => {
77
+ r.buttons == 1 && t(10);
78
+ }), $(e(this, c).track).on("mousedown", (r) => {
79
+ if (r.buttons != 1) return;
80
+ r.preventDefault();
81
+ const d = e(this, c).track.getBoundingClientRect(), h = e(this, c).thumb.getBoundingClientRect().width;
82
+ e(this, A).call(this, r.clientX - d.left - h / 2);
83
+ }), $(e(this, c).thumb).on("mousedown", (r) => {
84
+ if (r.buttons != 1) return;
85
+ r.stopPropagation(), r.preventDefault(), S(this, B, !0), this.shiftX = r.clientX - e(this, c).thumb.getBoundingClientRect().left;
86
+ const d = /* @__PURE__ */ b((s) => {
87
+ if (!e(this, B)) return;
88
+ const g = e(this, c).track.getBoundingClientRect();
89
+ e(this, A).call(this, s.clientX - g.left - this.shiftX);
90
+ }, "onMouseMove"), h = /* @__PURE__ */ b(() => {
91
+ S(this, B, !1), o(), document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", h), this.refresh();
106
92
  }, "onMouseUp");
107
- document.addEventListener("mousemove", s), document.addEventListener("mouseup", u);
93
+ document.addEventListener("mousemove", d), document.addEventListener("mouseup", h);
108
94
  });
109
95
  }, "#init"));
110
96
  }
111
97
  connectedCallback() {
112
- w(this, k, this.getRootNode().host), e(this, k) && (this.innerHTML = `
98
+ S(this, E, this.getRootNode().host), e(this, E) && (this.innerHTML = `
113
99
  <style>
114
100
  nine-table-hscrollbar {
115
101
  display: flex;
@@ -170,109 +156,105 @@ const V = class V extends HTMLElement {
170
156
  </style>
171
157
  <button class='ng-scroll-left' disabled><div class='ng-scroll-icon'></div></button>
172
158
  <div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
173
- <button class='ng-scroll-right' disabled><div class='ng-scroll-icon'></div></button>
159
+ <button class='ng-scroll-right'><div class='ng-scroll-icon'></div></button>
174
160
  `, requestAnimationFrame(() => {
175
- if (!e(this, k)) return;
176
- const t = e(this, k).querySelector(".ng-container-body");
177
- t && (w(this, o, {
161
+ const t = e(this, E).querySelector(".ng-container-body");
162
+ t && (S(this, c, {
178
163
  container: t,
179
164
  track: this.querySelector(".ng-scroll-track"),
180
165
  thumb: this.querySelector(".ng-scroll-thumb"),
181
166
  left: this.querySelector(".ng-scroll-left"),
182
167
  right: this.querySelector(".ng-scroll-right")
183
- }), e(this, X).call(this), e(this, N).call(this), this.refresh());
168
+ }), e(this, z).call(this), this.refresh());
184
169
  }));
185
170
  }
186
- disconnectedCallback() {
187
- e(this, T) && e(this, T).disconnect();
188
- }
189
171
  };
190
- k = new WeakMap(), E = new WeakMap(), o = new WeakMap(), A = new WeakMap(), R = new WeakMap(), T = new WeakMap(), N = new WeakMap(), I = new WeakMap(), X = new WeakMap(), f(V, "NineTableHScrollBar");
191
- let D = V;
192
- customElements.get("nine-table-hscrollbar") || customElements.define("nine-table-hscrollbar", D);
193
- var C, O;
194
- const B = class B extends HTMLElement {
172
+ E = new WeakMap(), B = new WeakMap(), c = new WeakMap(), L = new WeakMap(), R = new WeakMap(), A = new WeakMap(), z = new WeakMap(), b(J, "NineTableHScrollBar");
173
+ let P = J;
174
+ customElements.get("nine-table-hscrollbar") || customElements.define("nine-table-hscrollbar", P);
175
+ var q, N;
176
+ const T = class T extends HTMLElement {
195
177
  constructor() {
196
178
  super();
197
- y(this, C, null);
198
- L(this, "init", /* @__PURE__ */ f((t) => {
179
+ y(this, q, null);
180
+ C(this, "init", /* @__PURE__ */ b((t) => {
199
181
  if (!t) return;
200
- const r = /* @__PURE__ */ f((n) => {
201
- const b = /* @__PURE__ */ f((c) => {
202
- if (c.querySelector("colgroup")) return;
203
- const d = c.querySelector("tbody tr") || c.querySelector("tr"), x = d ? d.querySelectorAll("th, td").length : 1, m = document.createElement("colgroup"), S = Math.max(Math.floor((c.clientWidth || 600) / x), 100);
182
+ const o = /* @__PURE__ */ b((n) => {
183
+ const l = /* @__PURE__ */ b((f) => {
184
+ if (f.querySelector("colgroup")) return;
185
+ const u = f.querySelector("tbody tr") || f.querySelector("tr"), x = u ? u.querySelectorAll("th, td").length : 1, m = document.createElement("colgroup"), w = Math.max(Math.floor((f.clientWidth || 600) / x), 100);
204
186
  for (let v = 0; v < x; v++) {
205
- const P = document.createElement("col");
206
- P.setAttribute("width", S), m.appendChild(P);
187
+ const F = document.createElement("col");
188
+ F.setAttribute("width", w), m.appendChild(F);
207
189
  }
208
- c.prepend(m);
209
- }, "ensureColgroup"), a = /* @__PURE__ */ f((c) => {
210
- if (c.querySelector("thead")) return;
211
- const d = document.createElement("thead"), x = c.querySelector("colgroup");
212
- x ? x.after(d) : c.prepend(d);
190
+ f.prepend(m);
191
+ }, "ensureColgroup"), a = /* @__PURE__ */ b((f) => {
192
+ if (f.querySelector("thead")) return;
193
+ const u = document.createElement("thead"), x = f.querySelector("colgroup");
194
+ x ? x.after(u) : f.prepend(u);
213
195
  }, "ensureThead");
214
- return b(n), a(n), n.classList.add("nine-table-element"), n;
215
- }, "initializeTable"), p = t.cloneNode(!0);
216
- w(this, C, r(p)), e(this, C).style.display = "table";
217
- const l = this.querySelector(".ng-container-left"), h = this.querySelector(".ng-container-body"), s = this.querySelector(".ng-container-right"), u = /* @__PURE__ */ f((n, b, a = !1) => {
218
- const c = n.cloneNode(!0), d = Array.from(c.querySelectorAll("colgroup col")), x = [];
219
- return d.forEach((m, S) => {
196
+ return l(n), a(n), n.classList.add("nine-table-element"), n;
197
+ }, "initializeTable"), r = t.cloneNode(!0);
198
+ S(this, q, o(r)), e(this, q).style.display = "table";
199
+ const d = this.querySelector(".ng-container-left"), h = this.querySelector(".ng-container-body"), s = this.querySelector(".ng-container-right"), g = /* @__PURE__ */ b((n, l, a = !1) => {
200
+ const f = n.cloneNode(!0), u = Array.from(f.querySelectorAll("colgroup col")), x = [];
201
+ return u.forEach((m, w) => {
220
202
  const v = m.getAttribute("fixed");
221
- (a ? !v || v === "" : v === b) || x.push(S);
203
+ (a ? !v || v === "" : v === l) || x.push(w);
222
204
  }), x.reverse().forEach((m) => {
223
- d[m] && d[m].remove(), c.querySelectorAll("tr").forEach((S) => {
224
- const v = S.querySelectorAll("th, td");
205
+ u[m] && u[m].remove(), f.querySelectorAll("tr").forEach((w) => {
206
+ const v = w.querySelectorAll("th, td");
225
207
  v[m] && v[m].remove();
226
208
  });
227
- }), c;
209
+ }), f;
228
210
  }, "filterTableByFixed");
229
211
  if (h) {
230
- const n = u(e(this, C), null, !0);
212
+ const n = g(e(this, q), null, !0);
231
213
  h.innerHTML = "", h.appendChild(n);
232
214
  }
233
- if (l) {
234
- const n = u(e(this, C), "left", !1);
235
- let b = 0;
236
- n.querySelectorAll("col").forEach((c) => {
237
- const d = parseInt(c.getAttribute("width"), 10);
238
- isNaN(d) || (b += d);
239
- }), l.innerHTML = "", l.appendChild(n);
240
- const a = b > 0 ? b : 0;
241
- l.style.flex = `0 0 ${a}px`, l.style.width = `${a}px`;
215
+ if (d) {
216
+ const n = g(e(this, q), "left", !1);
217
+ let l = 0;
218
+ n.querySelectorAll("col").forEach((f) => {
219
+ const u = parseInt(f.getAttribute("width"), 10);
220
+ isNaN(u) || (l += u);
221
+ }), d.innerHTML = "", d.appendChild(n);
222
+ const a = l > 0 ? l : 0;
223
+ d.style.flex = `0 0 ${a}px`, d.style.width = `${a}px`;
242
224
  }
243
225
  if (s) {
244
- const n = u(e(this, C), "right", !1);
245
- let b = 0;
246
- n.querySelectorAll("col").forEach((c) => {
247
- const d = parseInt(c.getAttribute("width"), 10);
248
- isNaN(d) || (b += d);
226
+ const n = g(e(this, q), "right", !1);
227
+ let l = 0;
228
+ n.querySelectorAll("col").forEach((f) => {
229
+ const u = parseInt(f.getAttribute("width"), 10);
230
+ isNaN(u) || (l += u);
249
231
  }), s.innerHTML = "", s.appendChild(n);
250
- const a = b > 0 ? b : 0;
232
+ const a = l > 0 ? l : 0;
251
233
  s.style.flex = `0 0 ${a}px`, s.style.width = `${a}px`;
252
234
  }
253
235
  if (h) {
254
236
  const n = this.getRowCount();
255
237
  h.style.overflowY = n > 10 ? "auto" : "hidden", h.addEventListener("scroll", () => {
256
- const b = this.querySelector("nine-table-hscrollbar");
257
- b && typeof b.refresh == "function" && b.refresh();
238
+ const l = this.querySelector("nine-table-hscrollbar");
239
+ l && typeof l.refresh == "function" && l.refresh();
258
240
  });
259
241
  }
260
242
  setTimeout(() => {
261
243
  const n = this.querySelector("nine-table-hscrollbar");
262
244
  n && typeof n.refresh == "function" && n.refresh();
263
- }, 0), z.log(`NineTableSheet 3-split initialized with rows: ${this.getRowCount()}`);
245
+ }, 0), W.log(`NineTableSheet 3-split initialized with rows: ${this.getRowCount()}`);
264
246
  }, "init"));
265
- L(this, "getRowCount", /* @__PURE__ */ f(() => e(this, C) ? e(this, C).querySelectorAll("tbody tr").length : 0, "getRowCount"));
266
- L(this, "scrollToX", /* @__PURE__ */ f((t) => {
267
- const r = this.querySelector(".ng-container-body");
268
- r && (r.scrollLeft = t);
247
+ C(this, "getRowCount", /* @__PURE__ */ b(() => e(this, q) ? e(this, q).querySelectorAll("tbody tr").length : 0, "getRowCount"));
248
+ C(this, "scrollToX", /* @__PURE__ */ b((t) => {
249
+ const o = this.querySelector(".ng-container-body");
250
+ o && (o.scrollLeft = t);
269
251
  }, "scrollToX"));
270
- L(this, "scrollToY", /* @__PURE__ */ f((t) => {
271
- const r = this.querySelector(".ng-container-body");
272
- r && (r.scrollTop = t);
252
+ C(this, "scrollToY", /* @__PURE__ */ b((t) => {
253
+ const o = this.querySelector(".ng-container-body");
254
+ o && (o.scrollTop = t);
273
255
  }, "scrollToY"));
274
- y(this, O, /* @__PURE__ */ f(() => {
275
- const t = B.SCROLLBAR_SIZE;
256
+ y(this, N, /* @__PURE__ */ b(() => {
257
+ const t = T.SCROLLBAR_SIZE;
276
258
  this.innerHTML = `
277
259
  <style>
278
260
  nine-table-sheet {
@@ -389,109 +371,109 @@ const B = class B extends HTMLElement {
389
371
  }, "#render"));
390
372
  }
391
373
  connectedCallback() {
392
- e(this, O).call(this);
374
+ e(this, N).call(this);
393
375
  }
394
376
  disconnectedCallback() {
395
- this.innerHTML = "", z.log("NineTableSheet destroyed.");
377
+ this.innerHTML = "", W.log("NineTableSheet destroyed.");
396
378
  }
397
379
  };
398
- C = new WeakMap(), O = new WeakMap(), f(B, "NineTableSheet"), L(B, "SCROLLBAR_SIZE", 16);
399
- let Z = B;
400
- customElements.get("nine-table-sheet") || customElements.define("nine-table-sheet", Z);
401
- var j;
402
- const _ = class _ extends HTMLElement {
380
+ q = new WeakMap(), N = new WeakMap(), b(T, "NineTableSheet"), C(T, "SCROLLBAR_SIZE", 16);
381
+ let Y = T;
382
+ customElements.get("nine-table-sheet") || customElements.define("nine-table-sheet", Y);
383
+ var X;
384
+ const Q = class Q extends HTMLElement {
403
385
  constructor() {
404
386
  super();
405
- y(this, j, /* @__PURE__ */ f(() => {
387
+ y(this, X, /* @__PURE__ */ b(() => {
406
388
  const t = this.querySelector(".nine-tab-bar");
407
- t && (t.addEventListener("click", (r) => {
408
- const p = r.target.closest(".nine-tab-item");
409
- if (!p) return;
410
- const l = r.ctrlKey || r.metaKey || r.shiftKey, h = parseInt(p.dataset.index, 10);
411
- this.switchSheet(h, l);
389
+ t && (t.addEventListener("click", (o) => {
390
+ const r = o.target.closest(".nine-tab-item");
391
+ if (!r) return;
392
+ const d = o.ctrlKey || o.metaKey || o.shiftKey, h = parseInt(r.dataset.index, 10);
393
+ this.switchSheet(h, d);
412
394
  }), this.switchSheet(0, !1));
413
395
  }, "#init"));
414
- L(this, "switchSheet", /* @__PURE__ */ f((t, r = !1) => {
415
- const p = /* @__PURE__ */ f(() => {
396
+ C(this, "switchSheet", /* @__PURE__ */ b((t, o = !1) => {
397
+ const r = /* @__PURE__ */ b(() => {
416
398
  const a = this.querySelector("nine-table-sheets-body");
417
- a.querySelectorAll("nine-splitter").forEach((d) => {
418
- const x = parseInt(d.dataset.splitIndex, 10), m = a.querySelector(`nine-table-sheet[data-index="${x - 1}"]`), S = a.querySelector(`nine-table-sheet[data-index="${x}"]`);
419
- m && S && m.classList.contains("active") && S.classList.contains("active") ? d.classList.add("active") : d.classList.remove("active");
399
+ a.querySelectorAll("nine-splitter").forEach((u) => {
400
+ const x = parseInt(u.dataset.splitIndex, 10), m = a.querySelector(`nine-table-sheet[data-index="${x - 1}"]`), w = a.querySelector(`nine-table-sheet[data-index="${x}"]`);
401
+ m && w && m.classList.contains("active") && w.classList.contains("active") ? u.classList.add("active") : u.classList.remove("active");
420
402
  });
421
- }, "updateSplitters"), l = this.querySelector(".nine-tab-bar"), h = this.querySelector("nine-table-sheets-body"), s = l.querySelectorAll(".nine-tab-item"), u = h.querySelectorAll("nine-table-sheet");
403
+ }, "updateSplitters"), d = this.querySelector(".nine-tab-bar"), h = this.querySelector("nine-table-sheets-body"), s = d.querySelectorAll(".nine-tab-item"), g = h.querySelectorAll("nine-table-sheet");
422
404
  if (!s[t]) return;
423
- if (!r)
424
- s.forEach((a, c) => {
425
- a.classList.toggle("active", c === t);
426
- const d = h.querySelector(`nine-table-sheet[data-index="${c}"]`);
427
- d && (d.style.flex = "");
428
- }), u.forEach((a, c) => {
429
- a.classList.toggle("active", c === t);
405
+ if (!o)
406
+ s.forEach((a, f) => {
407
+ a.classList.toggle("active", f === t);
408
+ const u = h.querySelector(`nine-table-sheet[data-index="${f}"]`);
409
+ u && (u.style.flex = "");
410
+ }), g.forEach((a, f) => {
411
+ a.classList.toggle("active", f === t);
430
412
  });
431
413
  else {
432
- const a = s[t], c = l.querySelectorAll(".nine-tab-item.active");
433
- if (a.classList.contains("active") && c.length <= 1)
414
+ const a = s[t], f = d.querySelectorAll(".nine-tab-item.active");
415
+ if (a.classList.contains("active") && f.length <= 1)
434
416
  return;
435
417
  a.classList.toggle("active");
436
- const d = h.querySelector(`nine-table-sheet[data-index="${t}"]`);
437
- d && (d.classList.toggle("active"), d.classList.contains("active") || (d.style.flex = ""));
418
+ const u = h.querySelector(`nine-table-sheet[data-index="${t}"]`);
419
+ u && (u.classList.toggle("active"), u.classList.contains("active") || (u.style.flex = ""));
438
420
  }
439
421
  const n = Array.from(h.querySelectorAll("nine-table-sheet.active"));
440
422
  if (n.length > 1) {
441
423
  const a = 1 / n.length;
442
- n.forEach((c) => {
443
- (!c.style.flex || c.style.flex === "1 1 100%") && (c.style.flex = `${a} ${a} 0px`);
424
+ n.forEach((f) => {
425
+ (!f.style.flex || f.style.flex === "1 1 100%") && (f.style.flex = `${a} ${a} 0px`);
444
426
  });
445
427
  } else
446
428
  n.forEach((a) => {
447
429
  a.style.flex = "1 1 100%";
448
430
  });
449
- p();
450
- const b = h.querySelector("nine-table-sheet.active");
451
- if (b && typeof b.getRowCount == "function") {
431
+ r();
432
+ const l = h.querySelector("nine-table-sheet.active");
433
+ if (l && typeof l.getRowCount == "function") {
452
434
  const a = this.querySelector("#row-count");
453
- a && (a.textContent = b.getRowCount().toLocaleString());
435
+ a && (a.textContent = l.getRowCount().toLocaleString());
454
436
  }
455
437
  }, "switchSheet"));
456
438
  }
457
439
  connectedCallback() {
458
- e(this, j).call(this);
440
+ e(this, X).call(this);
459
441
  }
460
442
  };
461
- j = new WeakMap(), f(_, "NineTableSheets");
462
- let U = _;
463
- customElements.get("nine-table-sheets") || customElements.define("nine-table-sheets", U);
464
- var q, M, F, H, K;
465
- const ee = class ee {
443
+ X = new WeakMap(), b(Q, "NineTableSheets");
444
+ let D = Q;
445
+ customElements.get("nine-table-sheets") || customElements.define("nine-table-sheets", D);
446
+ var k, I, j, M, O;
447
+ const V = class V {
466
448
  constructor(i) {
467
- y(this, q);
468
- y(this, M, null);
469
- y(this, F, /* @__PURE__ */ f(() => {
470
- const i = e(this, q).host;
471
- i && (w(this, M, new ResizeObserver((t) => {
472
- for (let r of t)
473
- i.getAttribute("auto-height") === "true" && e(this, H).call(this, i);
474
- })), e(this, M).observe(i));
449
+ y(this, k);
450
+ y(this, I, null);
451
+ y(this, j, /* @__PURE__ */ b(() => {
452
+ const i = e(this, k).host;
453
+ i && (S(this, I, new ResizeObserver((t) => {
454
+ for (let o of t)
455
+ i.getAttribute("auto-height") === "true" && e(this, M).call(this, i);
456
+ })), e(this, I).observe(i));
475
457
  }, "#observeResize"));
476
- y(this, H, /* @__PURE__ */ f((i) => {
477
- var S, v;
478
- const t = (S = i.shadowRoot) == null ? void 0 : S.querySelector("nine-table-sheet.active");
458
+ y(this, M, /* @__PURE__ */ b((i) => {
459
+ var w, v;
460
+ const t = (w = i.shadowRoot) == null ? void 0 : w.querySelector("nine-table-sheet.active");
479
461
  if (!t) return;
480
- const r = ((v = t.getRowCount) == null ? void 0 : v.call(t)) || 0, p = parseInt(i.getAttribute("max-display-row"), 10) || 10, l = Math.min(r, p), h = t.querySelector("tbody tr") || t.querySelector("tr"), s = h ? h.getBoundingClientRect().height : 32, u = e(this, q).querySelector("nine-table-header"), n = e(this, q).querySelector("nine-table-sheets-footer"), b = u ? u.getBoundingClientRect().height : 40, a = n ? n.getBoundingClientRect().height : 32, d = b + a + 16, x = l * s + d;
481
- i.style.height = `${x}px`, i.style.maxHeight = `${p * s + d}px`;
482
- const m = e(this, q).querySelector("nine-table-sheets-body");
483
- m && (m.style.overflowY = r > p ? "auto" : "hidden");
462
+ const o = ((v = t.getRowCount) == null ? void 0 : v.call(t)) || 0, r = parseInt(i.getAttribute("max-display-row"), 10) || 10, d = Math.min(o, r), h = t.querySelector("tbody tr") || t.querySelector("tr"), s = h ? h.getBoundingClientRect().height : 32, g = e(this, k).querySelector("nine-table-header"), n = e(this, k).querySelector("nine-table-sheets-footer"), l = g ? g.getBoundingClientRect().height : 40, a = n ? n.getBoundingClientRect().height : 32, u = l + a + 16, x = d * s + u;
463
+ i.style.height = `${x}px`, i.style.maxHeight = `${r * s + u}px`;
464
+ const m = e(this, k).querySelector("nine-table-sheets-body");
465
+ m && (m.style.overflowY = o > r ? "auto" : "hidden");
484
466
  }, "#applyAutoHeight"));
485
- y(this, K, /* @__PURE__ */ f(() => {
486
- const i = e(this, q).host, r = Array.from(i.children).filter((u) => u.tagName === "TABLE"), p = i.getAttribute("auto-height") === "true", l = r.map((u, n) => `<nine-table-sheet class="${n === 0 ? "active" : ""}" data-index="${n}"></nine-table-sheet>`).join(""), h = r.map((u, n) => `<div class="nine-tab-item ${n === 0 ? "active" : ""}" data-index="${n}">Sheet ${n + 1}</div>`).join("");
487
- e(this, q).innerHTML = `
467
+ y(this, O, /* @__PURE__ */ b(() => {
468
+ const i = e(this, k).host, o = Array.from(i.children).filter((g) => g.tagName === "TABLE"), r = i.getAttribute("auto-height") === "true", d = o.map((g, n) => `<nine-table-sheet class="${n === 0 ? "active" : ""}" data-index="${n}"></nine-table-sheet>`).join(""), h = o.map((g, n) => `<div class="nine-tab-item ${n === 0 ? "active" : ""}" data-index="${n}">Sheet ${n + 1}</div>`).join("");
469
+ e(this, k).innerHTML = `
488
470
  <style>
489
471
  :host {
490
472
  display: flex;
491
473
  flex-direction: column;
492
474
  position: relative;
493
475
  overflow: hidden;
494
- height: ${p ? "auto" : "100%"};
476
+ height: ${r ? "auto" : "100%"};
495
477
  background: #fff;
496
478
  }
497
479
  nine-table-header { height: 40px; display: block; flex-shrink: 0; border-bottom: 1px solid #e5e7eb; background: #fff; }
@@ -572,7 +554,7 @@ const ee = class ee {
572
554
  <nine-table-body>
573
555
  <nine-table-summary></nine-table-summary>
574
556
  <nine-table-sheets>
575
- <nine-table-sheets-body>${l}</nine-table-sheets-body>
557
+ <nine-table-sheets-body>${d}</nine-table-sheets-body>
576
558
  <nine-table-sheets-footer>
577
559
  <div class="nine-tab-bar">${h}</div>
578
560
  <div class="sheets-counter">Total : <span id="row-count">0</span></div>
@@ -582,33 +564,33 @@ const ee = class ee {
582
564
  </nine-table-body>
583
565
  <nine-table-footer></nine-table-footer>
584
566
  `;
585
- const s = e(this, q).querySelectorAll("nine-table-sheet");
586
- s == null || s.forEach((u, n) => {
587
- r[n] && setTimeout(() => {
588
- u.init(r[n]), p && e(this, H).call(this, i);
567
+ const s = e(this, k).querySelectorAll("nine-table-sheet");
568
+ s == null || s.forEach((g, n) => {
569
+ o[n] && setTimeout(() => {
570
+ g.init(o[n]), r && e(this, M).call(this, i);
589
571
  });
590
572
  });
591
573
  }, "#render"));
592
- w(this, q, i), e(this, K).call(this), e(this, F).call(this);
574
+ S(this, k, i), e(this, O).call(this), e(this, j).call(this);
593
575
  }
594
576
  };
595
- q = new WeakMap(), M = new WeakMap(), F = new WeakMap(), H = new WeakMap(), K = new WeakMap(), f(ee, "LayoutManager");
596
- let G = ee;
597
- var W;
598
- const te = class te extends HTMLElement {
577
+ k = new WeakMap(), I = new WeakMap(), j = new WeakMap(), M = new WeakMap(), O = new WeakMap(), b(V, "LayoutManager");
578
+ let Z = V;
579
+ var H;
580
+ const _ = class _ extends HTMLElement {
599
581
  constructor() {
600
582
  super();
601
- y(this, W, !1);
583
+ y(this, H, !1);
602
584
  this.attachShadow({ mode: "open" });
603
585
  }
604
586
  connectedCallback() {
605
- e(this, W) || (this.layoutManager = new G(this.shadowRoot), w(this, W, !0), z.log("NineTable connected."), this.dispatchEvent(new CustomEvent("load", { bubbles: !0, detail: { target: this } })));
587
+ e(this, H) || (this.layoutManager = new Z(this.shadowRoot), S(this, H, !0), W.log("NineTable connected."), this.dispatchEvent(new CustomEvent("load", { bubbles: !0, detail: { target: this } })));
606
588
  }
607
589
  disconnectedCallback() {
608
- z.log("NineTable disconnected.");
590
+ W.log("NineTable disconnected.");
609
591
  }
610
592
  };
611
- W = new WeakMap(), f(te, "NineTable");
612
- let J = te;
613
- customElements.get("nine-table") || customElements.define("nine-table", J);
593
+ H = new WeakMap(), b(_, "NineTable");
594
+ let U = _;
595
+ customElements.get("nine-table") || customElements.define("nine-table", U);
614
596
  //# sourceMappingURL=nine-table.js.map