@ninebone/table 0.0.93 → 0.0.95

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