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