@ninebone/table 0.0.93 → 0.0.94

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 v = new P();
18
+ var q, 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, q);
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, q)) return;
30
+ const t = e(this, q).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 (v.log("refresh() 호출됨"), !e(this, q) || !e(this, h)) {
37
+ v.log("refresh() 중단: owner 또는 elements가 없음");
38
+ return;
39
+ }
40
+ const t = e(this, h).container, r = t.querySelector("table");
41
+ if (!r) {
42
+ v.log("refresh() 중단: table 요소를 찾을 수 없음");
32
43
  return;
33
44
  }
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");
45
+ const o = e(this, h).track, g = e(this, h).thumb, d = e(this, q).querySelector(".ng-container-bottom"), a = t.clientWidth, b = r.scrollWidth;
46
+ if (v.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
+ v.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, q).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 (v.log("NineTableHScrollBar connectedCallback 진입"), S(this, q, this.getRootNode().host), !e(this, q)) {
117
+ v.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,90 @@ 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
+ const t = e(this, q).querySelector(".ng-container-body");
184
+ if (!t) {
185
+ v.log("NineTableHScrollBar: .ng-container-body 요소를 찾지 못함");
186
+ return;
187
+ }
188
+ S(this, h, {
170
189
  container: t,
171
190
  track: this.querySelector(".ng-scroll-track"),
172
191
  thumb: this.querySelector(".ng-scroll-thumb"),
173
192
  left: this.querySelector(".ng-scroll-left"),
174
193
  right: this.querySelector(".ng-scroll-right")
175
- }), e(this, W).call(this), this.refresh());
176
- }));
194
+ }), v.log("NineTableHScrollBar elements 바인딩 완료:", e(this, h)), e(this, N).call(this), e(this, z).call(this), this.refresh();
195
+ });
196
+ }
197
+ disconnectedCallback() {
198
+ e(this, T) && e(this, T).disconnect();
177
199
  }
178
200
  };
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 {
201
+ q = 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");
202
+ let Y = Q;
203
+ customElements.get("nine-table-hscrollbar") || customElements.define("nine-table-hscrollbar", Y);
204
+ var L, X;
205
+ const H = class H extends HTMLElement {
184
206
  constructor() {
185
207
  super();
186
- y(this, E, null);
187
- C(this, "init", /* @__PURE__ */ b((t) => {
208
+ y(this, L, null);
209
+ C(this, "init", /* @__PURE__ */ u((t) => {
188
210
  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);
211
+ const r = /* @__PURE__ */ u((n) => {
212
+ const f = /* @__PURE__ */ u((l) => {
213
+ if (l.querySelector("colgroup")) return;
214
+ const c = l.querySelector("tbody tr") || l.querySelector("tr"), x = c ? c.querySelectorAll("th, td").length : 1, m = document.createElement("colgroup"), k = Math.max(Math.floor((l.clientWidth || 600) / x), 100);
215
+ for (let w = 0; w < x; w++) {
216
+ const K = document.createElement("col");
217
+ K.setAttribute("width", k), m.appendChild(K);
196
218
  }
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);
219
+ l.prepend(m);
220
+ }, "ensureColgroup"), s = /* @__PURE__ */ u((l) => {
221
+ if (l.querySelector("thead")) return;
222
+ const c = document.createElement("thead"), x = l.querySelector("colgroup");
223
+ x ? x.after(c) : l.prepend(c);
202
224
  }, "ensureThead");
203
- return f(n), r(n), n.classList.add("nine-table-element"), n;
225
+ return f(n), s(n), n.classList.add("nine-table-element"), n;
204
226
  }, "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);
227
+ S(this, L, r(o)), e(this, L).style.display = "table";
228
+ 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) => {
229
+ const l = n.cloneNode(!0), c = Array.from(l.querySelectorAll("colgroup col")), x = [];
230
+ return c.forEach((m, k) => {
231
+ const w = m.getAttribute("fixed");
232
+ (s ? !w || w === "" : w === f) || x.push(k);
211
233
  }), 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();
234
+ c[m] && c[m].remove(), l.querySelectorAll("tr").forEach((k) => {
235
+ const w = k.querySelectorAll("th, td");
236
+ w[m] && w[m].remove();
215
237
  });
216
- }), s;
238
+ }), l;
217
239
  }, "filterTableByFixed");
218
- if (h) {
219
- const n = g(e(this, E), null, !0);
220
- h.innerHTML = "", h.appendChild(n);
240
+ if (d) {
241
+ const n = b(e(this, L), null, !0);
242
+ d.innerHTML = "", d.appendChild(n);
221
243
  }
222
- if (u) {
223
- const n = g(e(this, E), "left", !1);
244
+ if (g) {
245
+ const n = b(e(this, L), "left", !1);
224
246
  let f = 0;
225
- n.querySelectorAll("col").forEach((s) => {
226
- const c = parseInt(s.getAttribute("width"), 10);
247
+ n.querySelectorAll("col").forEach((l) => {
248
+ const c = parseInt(l.getAttribute("width"), 10);
227
249
  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`;
250
+ }), g.innerHTML = "", g.appendChild(n);
251
+ const s = f > 0 ? f : 0;
252
+ g.style.flex = `0 0 ${s}px`, g.style.width = `${s}px`;
231
253
  }
232
- if (l) {
233
- const n = g(e(this, E), "right", !1);
254
+ if (a) {
255
+ const n = b(e(this, L), "right", !1);
234
256
  let f = 0;
235
- n.querySelectorAll("col").forEach((s) => {
236
- const c = parseInt(s.getAttribute("width"), 10);
257
+ n.querySelectorAll("col").forEach((l) => {
258
+ const c = parseInt(l.getAttribute("width"), 10);
237
259
  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`;
260
+ }), a.innerHTML = "", a.appendChild(n);
261
+ const s = f > 0 ? f : 0;
262
+ a.style.flex = `0 0 ${s}px`, a.style.width = `${s}px`;
241
263
  }
242
- if (h) {
264
+ if (d) {
243
265
  const n = this.getRowCount();
244
- h.style.overflowY = n > 10 ? "auto" : "hidden", h.addEventListener("scroll", () => {
266
+ d.style.overflowY = n > 10 ? "auto" : "hidden", d.addEventListener("scroll", () => {
245
267
  const f = this.querySelector("nine-table-hscrollbar");
246
268
  f && typeof f.refresh == "function" && f.refresh();
247
269
  });
@@ -249,19 +271,19 @@ const I = class I extends HTMLElement {
249
271
  setTimeout(() => {
250
272
  const n = this.querySelector("nine-table-hscrollbar");
251
273
  n && typeof n.refresh == "function" && n.refresh();
252
- }, 0), q.log(`NineTableSheet 3-split initialized with rows: ${this.getRowCount()}`);
274
+ }, 0), v.log(`NineTableSheet 3-split initialized with rows: ${this.getRowCount()}`);
253
275
  }, "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);
276
+ C(this, "getRowCount", /* @__PURE__ */ u(() => e(this, L) ? e(this, L).querySelectorAll("tbody tr").length : 0, "getRowCount"));
277
+ C(this, "scrollToX", /* @__PURE__ */ u((t) => {
278
+ const r = this.querySelector(".ng-container-body");
279
+ r && (r.scrollLeft = t);
258
280
  }, "scrollToX"));
259
- C(this, "scrollToY", /* @__PURE__ */ b((t) => {
260
- const a = this.querySelector(".ng-container-body");
261
- a && (a.scrollTop = t);
281
+ C(this, "scrollToY", /* @__PURE__ */ u((t) => {
282
+ const r = this.querySelector(".ng-container-body");
283
+ r && (r.scrollTop = t);
262
284
  }, "scrollToY"));
263
- y(this, z, /* @__PURE__ */ b(() => {
264
- const t = I.SCROLLBAR_SIZE;
285
+ y(this, X, /* @__PURE__ */ u(() => {
286
+ const t = H.SCROLLBAR_SIZE;
265
287
  this.innerHTML = `
266
288
  <style>
267
289
  nine-table-sheet {
@@ -378,102 +400,102 @@ const I = class I extends HTMLElement {
378
400
  }, "#render"));
379
401
  }
380
402
  connectedCallback() {
381
- e(this, z).call(this);
403
+ e(this, X).call(this);
382
404
  }
383
405
  disconnectedCallback() {
384
- this.innerHTML = "", q.log("NineTableSheet destroyed.");
406
+ this.innerHTML = "", v.log("NineTableSheet destroyed.");
385
407
  }
386
408
  };
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 {
409
+ L = new WeakMap(), X = new WeakMap(), u(H, "NineTableSheet"), C(H, "SCROLLBAR_SIZE", 16);
410
+ let D = H;
411
+ customElements.get("nine-table-sheet") || customElements.define("nine-table-sheet", D);
412
+ var O;
413
+ const V = class V extends HTMLElement {
392
414
  constructor() {
393
415
  super();
394
- y(this, N, /* @__PURE__ */ b(() => {
416
+ y(this, O, /* @__PURE__ */ u(() => {
395
417
  const t = this.querySelector(".nine-tab-bar");
396
- t && (t.addEventListener("click", (a) => {
397
- const o = a.target.closest(".nine-tab-item");
418
+ t && (t.addEventListener("click", (r) => {
419
+ const o = r.target.closest(".nine-tab-item");
398
420
  if (!o) return;
399
- const u = a.ctrlKey || a.metaKey || a.shiftKey, h = parseInt(o.dataset.index, 10);
400
- this.switchSheet(h, u);
421
+ const g = r.ctrlKey || r.metaKey || r.shiftKey, d = parseInt(o.dataset.index, 10);
422
+ this.switchSheet(d, g);
401
423
  }), this.switchSheet(0, !1));
402
424
  }, "#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");
425
+ C(this, "switchSheet", /* @__PURE__ */ u((t, r = !1) => {
426
+ const o = /* @__PURE__ */ u(() => {
427
+ const s = this.querySelector("nine-table-sheets-body");
428
+ s.querySelectorAll("nine-splitter").forEach((c) => {
429
+ const x = parseInt(c.dataset.splitIndex, 10), m = s.querySelector(`nine-table-sheet[data-index="${x - 1}"]`), k = s.querySelector(`nine-table-sheet[data-index="${x}"]`);
430
+ m && k && m.classList.contains("active") && k.classList.contains("active") ? c.classList.add("active") : c.classList.remove("active");
409
431
  });
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}"]`);
432
+ }, "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");
433
+ if (!a[t]) return;
434
+ if (!r)
435
+ a.forEach((s, l) => {
436
+ s.classList.toggle("active", l === t);
437
+ const c = d.querySelector(`nine-table-sheet[data-index="${l}"]`);
416
438
  c && (c.style.flex = "");
417
- }), g.forEach((r, s) => {
418
- r.classList.toggle("active", s === t);
439
+ }), b.forEach((s, l) => {
440
+ s.classList.toggle("active", l === t);
419
441
  });
420
442
  else {
421
- const r = l[t], s = u.querySelectorAll(".nine-tab-item.active");
422
- if (r.classList.contains("active") && s.length <= 1)
443
+ const s = a[t], l = g.querySelectorAll(".nine-tab-item.active");
444
+ if (s.classList.contains("active") && l.length <= 1)
423
445
  return;
424
- r.classList.toggle("active");
425
- const c = h.querySelector(`nine-table-sheet[data-index="${t}"]`);
446
+ s.classList.toggle("active");
447
+ const c = d.querySelector(`nine-table-sheet[data-index="${t}"]`);
426
448
  c && (c.classList.toggle("active"), c.classList.contains("active") || (c.style.flex = ""));
427
449
  }
428
- const n = Array.from(h.querySelectorAll("nine-table-sheet.active"));
450
+ const n = Array.from(d.querySelectorAll("nine-table-sheet.active"));
429
451
  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`);
452
+ const s = 1 / n.length;
453
+ n.forEach((l) => {
454
+ (!l.style.flex || l.style.flex === "1 1 100%") && (l.style.flex = `${s} ${s} 0px`);
433
455
  });
434
456
  } else
435
- n.forEach((r) => {
436
- r.style.flex = "1 1 100%";
457
+ n.forEach((s) => {
458
+ s.style.flex = "1 1 100%";
437
459
  });
438
460
  o();
439
- const f = h.querySelector("nine-table-sheet.active");
461
+ const f = d.querySelector("nine-table-sheet.active");
440
462
  if (f && typeof f.getRowCount == "function") {
441
- const r = this.querySelector("#row-count");
442
- r && (r.textContent = f.getRowCount().toLocaleString());
463
+ const s = this.querySelector("#row-count");
464
+ s && (s.textContent = f.getRowCount().toLocaleString());
443
465
  }
444
466
  }, "switchSheet"));
445
467
  }
446
468
  connectedCallback() {
447
- e(this, N).call(this);
469
+ e(this, O).call(this);
448
470
  }
449
471
  };
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 {
472
+ O = new WeakMap(), u(V, "NineTableSheets");
473
+ let Z = V;
474
+ customElements.get("nine-table-sheets") || customElements.define("nine-table-sheets", Z);
475
+ var E, I, j, M, F;
476
+ const _ = class _ {
455
477
  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));
478
+ y(this, E);
479
+ y(this, I, null);
480
+ y(this, j, /* @__PURE__ */ u(() => {
481
+ const i = e(this, E).host;
482
+ i && (S(this, I, new ResizeObserver((t) => {
483
+ for (let r of t)
484
+ i.getAttribute("auto-height") === "true" && e(this, M).call(this, i);
485
+ })), e(this, I).observe(i));
464
486
  }, "#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");
487
+ y(this, M, /* @__PURE__ */ u((i) => {
488
+ var k, w;
489
+ const t = (k = i.shadowRoot) == null ? void 0 : k.querySelector("nine-table-sheet.active");
468
490
  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");
491
+ 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, x = g * a + c;
492
+ i.style.height = `${x}px`, i.style.maxHeight = `${o * a + c}px`;
493
+ const m = e(this, E).querySelector("nine-table-sheets-body");
494
+ m && (m.style.overflowY = r > o ? "auto" : "hidden");
473
495
  }, "#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 = `
496
+ y(this, F, /* @__PURE__ */ u(() => {
497
+ 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("");
498
+ e(this, E).innerHTML = `
477
499
  <style>
478
500
  :host {
479
501
  display: flex;
@@ -561,9 +583,9 @@ const Q = class Q {
561
583
  <nine-table-body>
562
584
  <nine-table-summary></nine-table-summary>
563
585
  <nine-table-sheets>
564
- <nine-table-sheets-body>${u}</nine-table-sheets-body>
586
+ <nine-table-sheets-body>${g}</nine-table-sheets-body>
565
587
  <nine-table-sheets-footer>
566
- <div class="nine-tab-bar">${h}</div>
588
+ <div class="nine-tab-bar">${d}</div>
567
589
  <div class="sheets-counter">Total : <span id="row-count">0</span></div>
568
590
  </nine-table-sheets-footer>
569
591
  </nine-table-sheets>
@@ -571,33 +593,33 @@ const Q = class Q {
571
593
  </nine-table-body>
572
594
  <nine-table-footer></nine-table-footer>
573
595
  `;
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);
596
+ const a = e(this, E).querySelectorAll("nine-table-sheet");
597
+ a == null || a.forEach((b, n) => {
598
+ r[n] && setTimeout(() => {
599
+ b.init(r[n]), o && e(this, M).call(this, i);
578
600
  });
579
601
  });
580
602
  }, "#render"));
581
- S(this, k, i), e(this, j).call(this), e(this, X).call(this);
603
+ S(this, E, i), e(this, F).call(this), e(this, j).call(this);
582
604
  }
583
605
  };
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 {
606
+ E = new WeakMap(), I = new WeakMap(), j = new WeakMap(), M = new WeakMap(), F = new WeakMap(), u(_, "LayoutManager");
607
+ let U = _;
608
+ var W;
609
+ const ee = class ee extends HTMLElement {
588
610
  constructor() {
589
611
  super();
590
- y(this, H, !1);
612
+ y(this, W, !1);
591
613
  this.attachShadow({ mode: "open" });
592
614
  }
593
615
  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 } })));
616
+ e(this, W) || (this.layoutManager = new U(this.shadowRoot), S(this, W, !0), v.log("NineTable connected."), this.dispatchEvent(new CustomEvent("load", { bubbles: !0, detail: { target: this } })));
595
617
  }
596
618
  disconnectedCallback() {
597
- q.log("NineTable disconnected.");
619
+ v.log("NineTable disconnected.");
598
620
  }
599
621
  };
600
- H = new WeakMap(), b(V, "NineTable");
601
- let Z = V;
602
- customElements.get("nine-table") || customElements.define("nine-table", Z);
622
+ W = new WeakMap(), u(ee, "NineTable");
623
+ let G = ee;
624
+ customElements.get("nine-table") || customElements.define("nine-table", G);
603
625
  //# sourceMappingURL=nine-table.js.map