@ninebone/table 0.0.80 → 0.0.82

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