@ninebone/table 0.0.81 → 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.
- package/dist/nine-table.js +185 -174
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +12 -12
- package/dist/nine-table.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/nine-table.js
CHANGED
|
@@ -1,104 +1,112 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var ne = Object.defineProperty;
|
|
2
|
+
var ie = (g) => {
|
|
3
|
+
throw TypeError(g);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var f = (
|
|
7
|
-
var L = (
|
|
8
|
-
var e = (
|
|
9
|
-
import { trace as
|
|
10
|
-
const Q = class Q extends
|
|
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
|
|
17
|
-
const z = new
|
|
18
|
-
var
|
|
19
|
-
const
|
|
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,
|
|
23
|
-
y(this, E);
|
|
22
|
+
y(this, v);
|
|
23
|
+
y(this, E, !1);
|
|
24
24
|
y(this, c);
|
|
25
25
|
y(this, R);
|
|
26
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,
|
|
29
|
-
const t = e(this,
|
|
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
|
|
32
|
-
if (!
|
|
33
|
-
const
|
|
34
|
-
if (t.clientWidth !== 0 &&
|
|
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)
|
|
35
43
|
$(h).show();
|
|
36
44
|
else {
|
|
37
45
|
$(h).hide();
|
|
38
46
|
return;
|
|
39
47
|
}
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const b =
|
|
45
|
-
let
|
|
46
|
-
b > 0 && (
|
|
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;
|
|
53
|
+
let l = 0;
|
|
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,
|
|
56
|
+
y(this, B, /* @__PURE__ */ f((t) => {
|
|
49
57
|
if (!e(this, c)) return;
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
52
|
-
const
|
|
53
|
-
let
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
return n > 0 &&
|
|
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,
|
|
59
|
-
const t = e(this,
|
|
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
|
|
71
|
+
const s = /* @__PURE__ */ f((r) => {
|
|
64
72
|
clearInterval(e(this, R)), clearInterval(e(this, A));
|
|
65
|
-
const h = e(this, c).track.getBoundingClientRect(),
|
|
66
|
-
e(this,
|
|
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(() => {
|
|
67
75
|
clearInterval(e(this, R)), S(this, A, setInterval(() => {
|
|
68
|
-
const
|
|
69
|
-
e(this,
|
|
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"),
|
|
80
|
+
}, "delayScroll"), p = /* @__PURE__ */ f(() => {
|
|
73
81
|
clearInterval(e(this, R)), clearInterval(e(this, A));
|
|
74
82
|
}, "clearTimer");
|
|
75
|
-
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 =
|
|
76
|
-
|
|
77
|
-
}), $(e(this, c).right).on("mousedown", (
|
|
78
|
-
|
|
79
|
-
}), $(e(this, c).
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
o(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
e(this,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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, E)) return;
|
|
96
|
-
const o = e(this, c).track.getBoundingClientRect();
|
|
97
|
-
e(this, T).call(this, t.clientX - o.left - this.shiftX);
|
|
98
|
-
}, "#thumb_onMouseMove"));
|
|
99
107
|
}
|
|
100
108
|
connectedCallback() {
|
|
101
|
-
S(this,
|
|
109
|
+
S(this, v, this.getRootNode().host), e(this, v) && (this.innerHTML = `
|
|
102
110
|
<style>
|
|
103
111
|
nine-table-hscrollbar {
|
|
104
112
|
display: flex;
|
|
@@ -161,78 +169,81 @@ const U = class U extends HTMLElement {
|
|
|
161
169
|
<div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
|
|
162
170
|
<button class='ng-scroll-right'><div class='ng-scroll-icon'></div></button>
|
|
163
171
|
`, S(this, c, {
|
|
164
|
-
container: e(this,
|
|
172
|
+
container: e(this, v).querySelector(".ng-container-body"),
|
|
165
173
|
track: this.querySelector(".ng-scroll-track"),
|
|
166
174
|
thumb: this.querySelector(".ng-scroll-thumb"),
|
|
167
175
|
left: this.querySelector(".ng-scroll-left"),
|
|
168
176
|
right: this.querySelector(".ng-scroll-right")
|
|
169
|
-
}), e(this, N).call(this), requestAnimationFrame(() => {
|
|
177
|
+
}), e(this, X).call(this), e(this, N).call(this), requestAnimationFrame(() => {
|
|
170
178
|
this.refresh();
|
|
171
179
|
}));
|
|
172
180
|
}
|
|
181
|
+
disconnectedCallback() {
|
|
182
|
+
e(this, T) && e(this, T).disconnect();
|
|
183
|
+
}
|
|
173
184
|
};
|
|
174
|
-
|
|
175
|
-
let
|
|
176
|
-
customElements.get("nine-table-hscrollbar") || customElements.define("nine-table-hscrollbar",
|
|
177
|
-
var C,
|
|
178
|
-
const
|
|
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 {
|
|
179
190
|
constructor() {
|
|
180
191
|
super();
|
|
181
192
|
y(this, C, null);
|
|
182
193
|
L(this, "init", /* @__PURE__ */ f((t) => {
|
|
183
194
|
if (!t) return;
|
|
184
|
-
const
|
|
185
|
-
const b = /* @__PURE__ */ f((
|
|
186
|
-
if (
|
|
187
|
-
const d =
|
|
188
|
-
for (let
|
|
189
|
-
const
|
|
190
|
-
|
|
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);
|
|
191
202
|
}
|
|
192
|
-
|
|
193
|
-
}, "ensureColgroup"), a = /* @__PURE__ */ f((
|
|
194
|
-
if (
|
|
195
|
-
const d = document.createElement("thead"), x =
|
|
196
|
-
x ? x.after(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);
|
|
197
208
|
}, "ensureThead");
|
|
198
209
|
return b(n), a(n), n.classList.add("nine-table-element"), n;
|
|
199
|
-
}, "initializeTable"),
|
|
200
|
-
S(this, C,
|
|
201
|
-
const
|
|
202
|
-
const
|
|
203
|
-
return d.forEach((m,
|
|
204
|
-
const
|
|
205
|
-
(a ? !
|
|
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);
|
|
206
217
|
}), x.reverse().forEach((m) => {
|
|
207
|
-
d[m] && d[m].remove(),
|
|
208
|
-
const
|
|
209
|
-
|
|
218
|
+
d[m] && d[m].remove(), l.querySelectorAll("tr").forEach((k) => {
|
|
219
|
+
const w = k.querySelectorAll("th, td");
|
|
220
|
+
w[m] && w[m].remove();
|
|
210
221
|
});
|
|
211
|
-
}),
|
|
222
|
+
}), l;
|
|
212
223
|
}, "filterTableByFixed");
|
|
213
224
|
if (h) {
|
|
214
|
-
const n =
|
|
225
|
+
const n = u(e(this, C), null, !0);
|
|
215
226
|
h.innerHTML = "", h.appendChild(n);
|
|
216
227
|
}
|
|
217
|
-
if (
|
|
218
|
-
const n =
|
|
228
|
+
if (r) {
|
|
229
|
+
const n = u(e(this, C), "left", !1);
|
|
219
230
|
let b = 0;
|
|
220
|
-
n.querySelectorAll("col").forEach((
|
|
221
|
-
const d = parseInt(
|
|
231
|
+
n.querySelectorAll("col").forEach((l) => {
|
|
232
|
+
const d = parseInt(l.getAttribute("width"), 10);
|
|
222
233
|
isNaN(d) || (b += d);
|
|
223
|
-
}),
|
|
234
|
+
}), r.innerHTML = "", r.appendChild(n);
|
|
224
235
|
const a = b > 0 ? b : 0;
|
|
225
|
-
|
|
236
|
+
r.style.flex = `0 0 ${a}px`, r.style.width = `${a}px`;
|
|
226
237
|
}
|
|
227
|
-
if (
|
|
228
|
-
const n =
|
|
238
|
+
if (o) {
|
|
239
|
+
const n = u(e(this, C), "right", !1);
|
|
229
240
|
let b = 0;
|
|
230
|
-
n.querySelectorAll("col").forEach((
|
|
231
|
-
const d = parseInt(
|
|
241
|
+
n.querySelectorAll("col").forEach((l) => {
|
|
242
|
+
const d = parseInt(l.getAttribute("width"), 10);
|
|
232
243
|
isNaN(d) || (b += d);
|
|
233
|
-
}),
|
|
244
|
+
}), o.innerHTML = "", o.appendChild(n);
|
|
234
245
|
const a = b > 0 ? b : 0;
|
|
235
|
-
|
|
246
|
+
o.style.flex = `0 0 ${a}px`, o.style.width = `${a}px`;
|
|
236
247
|
}
|
|
237
248
|
if (h) {
|
|
238
249
|
const n = this.getRowCount();
|
|
@@ -248,15 +259,15 @@ const B = class B extends HTMLElement {
|
|
|
248
259
|
}, "init"));
|
|
249
260
|
L(this, "getRowCount", /* @__PURE__ */ f(() => e(this, C) ? e(this, C).querySelectorAll("tbody tr").length : 0, "getRowCount"));
|
|
250
261
|
L(this, "scrollToX", /* @__PURE__ */ f((t) => {
|
|
251
|
-
const
|
|
252
|
-
|
|
262
|
+
const s = this.querySelector(".ng-container-body");
|
|
263
|
+
s && (s.scrollLeft = t);
|
|
253
264
|
}, "scrollToX"));
|
|
254
265
|
L(this, "scrollToY", /* @__PURE__ */ f((t) => {
|
|
255
|
-
const
|
|
256
|
-
|
|
266
|
+
const s = this.querySelector(".ng-container-body");
|
|
267
|
+
s && (s.scrollTop = t);
|
|
257
268
|
}, "scrollToY"));
|
|
258
|
-
y(this,
|
|
259
|
-
const t =
|
|
269
|
+
y(this, O, /* @__PURE__ */ f(() => {
|
|
270
|
+
const t = I.SCROLLBAR_SIZE;
|
|
260
271
|
this.innerHTML = `
|
|
261
272
|
<style>
|
|
262
273
|
nine-table-sheet {
|
|
@@ -373,48 +384,48 @@ const B = class B extends HTMLElement {
|
|
|
373
384
|
}, "#render"));
|
|
374
385
|
}
|
|
375
386
|
connectedCallback() {
|
|
376
|
-
e(this,
|
|
387
|
+
e(this, O).call(this);
|
|
377
388
|
}
|
|
378
389
|
disconnectedCallback() {
|
|
379
390
|
this.innerHTML = "", z.log("NineTableSheet destroyed.");
|
|
380
391
|
}
|
|
381
392
|
};
|
|
382
|
-
C = new WeakMap(),
|
|
383
|
-
let Z =
|
|
393
|
+
C = new WeakMap(), O = new WeakMap(), f(I, "NineTableSheet"), L(I, "SCROLLBAR_SIZE", 16);
|
|
394
|
+
let Z = I;
|
|
384
395
|
customElements.get("nine-table-sheet") || customElements.define("nine-table-sheet", Z);
|
|
385
396
|
var j;
|
|
386
|
-
const
|
|
397
|
+
const _ = class _ extends HTMLElement {
|
|
387
398
|
constructor() {
|
|
388
399
|
super();
|
|
389
400
|
y(this, j, /* @__PURE__ */ f(() => {
|
|
390
401
|
const t = this.querySelector(".nine-tab-bar");
|
|
391
|
-
t && (t.addEventListener("click", (
|
|
392
|
-
const
|
|
393
|
-
if (!
|
|
394
|
-
const
|
|
395
|
-
this.switchSheet(h,
|
|
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);
|
|
396
407
|
}), this.switchSheet(0, !1));
|
|
397
408
|
}, "#init"));
|
|
398
|
-
L(this, "switchSheet", /* @__PURE__ */ f((t,
|
|
399
|
-
const
|
|
409
|
+
L(this, "switchSheet", /* @__PURE__ */ f((t, s = !1) => {
|
|
410
|
+
const p = /* @__PURE__ */ f(() => {
|
|
400
411
|
const a = this.querySelector("nine-table-sheets-body");
|
|
401
412
|
a.querySelectorAll("nine-splitter").forEach((d) => {
|
|
402
|
-
const x = parseInt(d.dataset.splitIndex, 10), m = a.querySelector(`nine-table-sheet[data-index="${x - 1}"]`),
|
|
403
|
-
m &&
|
|
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");
|
|
404
415
|
});
|
|
405
|
-
}, "updateSplitters"),
|
|
406
|
-
if (!
|
|
407
|
-
if (!
|
|
408
|
-
|
|
409
|
-
a.classList.toggle("active",
|
|
410
|
-
const d = h.querySelector(`nine-table-sheet[data-index="${
|
|
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}"]`);
|
|
411
422
|
d && (d.style.flex = "");
|
|
412
|
-
}),
|
|
413
|
-
a.classList.toggle("active",
|
|
423
|
+
}), u.forEach((a, l) => {
|
|
424
|
+
a.classList.toggle("active", l === t);
|
|
414
425
|
});
|
|
415
426
|
else {
|
|
416
|
-
const a =
|
|
417
|
-
if (a.classList.contains("active") &&
|
|
427
|
+
const a = o[t], l = r.querySelectorAll(".nine-tab-item.active");
|
|
428
|
+
if (a.classList.contains("active") && l.length <= 1)
|
|
418
429
|
return;
|
|
419
430
|
a.classList.toggle("active");
|
|
420
431
|
const d = h.querySelector(`nine-table-sheet[data-index="${t}"]`);
|
|
@@ -423,14 +434,14 @@ const V = class V extends HTMLElement {
|
|
|
423
434
|
const n = Array.from(h.querySelectorAll("nine-table-sheet.active"));
|
|
424
435
|
if (n.length > 1) {
|
|
425
436
|
const a = 1 / n.length;
|
|
426
|
-
n.forEach((
|
|
427
|
-
(!
|
|
437
|
+
n.forEach((l) => {
|
|
438
|
+
(!l.style.flex || l.style.flex === "1 1 100%") && (l.style.flex = `${a} ${a} 0px`);
|
|
428
439
|
});
|
|
429
440
|
} else
|
|
430
441
|
n.forEach((a) => {
|
|
431
442
|
a.style.flex = "1 1 100%";
|
|
432
443
|
});
|
|
433
|
-
|
|
444
|
+
p();
|
|
434
445
|
const b = h.querySelector("nine-table-sheet.active");
|
|
435
446
|
if (b && typeof b.getRowCount == "function") {
|
|
436
447
|
const a = this.querySelector("#row-count");
|
|
@@ -442,32 +453,32 @@ const V = class V extends HTMLElement {
|
|
|
442
453
|
e(this, j).call(this);
|
|
443
454
|
}
|
|
444
455
|
};
|
|
445
|
-
j = new WeakMap(), f(
|
|
446
|
-
let
|
|
447
|
-
customElements.get("nine-table-sheets") || customElements.define("nine-table-sheets",
|
|
448
|
-
var q,
|
|
449
|
-
const
|
|
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 {
|
|
450
461
|
constructor(i) {
|
|
451
462
|
y(this, q);
|
|
452
|
-
y(this,
|
|
453
|
-
y(this,
|
|
463
|
+
y(this, M, null);
|
|
464
|
+
y(this, F, /* @__PURE__ */ f(() => {
|
|
454
465
|
const i = e(this, q).host;
|
|
455
|
-
i && (S(this,
|
|
456
|
-
for (let
|
|
457
|
-
i.getAttribute("auto-height") === "true" && e(this,
|
|
458
|
-
})), e(this,
|
|
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));
|
|
459
470
|
}, "#observeResize"));
|
|
460
|
-
y(this,
|
|
461
|
-
var
|
|
462
|
-
const t = (
|
|
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");
|
|
463
474
|
if (!t) return;
|
|
464
|
-
const
|
|
465
|
-
i.style.height = `${x}px`, i.style.maxHeight = `${
|
|
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`;
|
|
466
477
|
const m = e(this, q).querySelector("nine-table-sheets-body");
|
|
467
|
-
m && (m.style.overflowY =
|
|
478
|
+
m && (m.style.overflowY = s > p ? "auto" : "hidden");
|
|
468
479
|
}, "#applyAutoHeight"));
|
|
469
|
-
y(this,
|
|
470
|
-
const i = e(this, q).host,
|
|
480
|
+
y(this, K, /* @__PURE__ */ f(() => {
|
|
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("");
|
|
471
482
|
e(this, q).innerHTML = `
|
|
472
483
|
<style>
|
|
473
484
|
:host {
|
|
@@ -475,7 +486,7 @@ const _ = class _ {
|
|
|
475
486
|
flex-direction: column;
|
|
476
487
|
position: relative;
|
|
477
488
|
overflow: hidden;
|
|
478
|
-
height: ${
|
|
489
|
+
height: ${p ? "auto" : "100%"};
|
|
479
490
|
background: #fff;
|
|
480
491
|
}
|
|
481
492
|
nine-table-header { height: 40px; display: block; flex-shrink: 0; border-bottom: 1px solid #e5e7eb; background: #fff; }
|
|
@@ -556,7 +567,7 @@ const _ = class _ {
|
|
|
556
567
|
<nine-table-body>
|
|
557
568
|
<nine-table-summary></nine-table-summary>
|
|
558
569
|
<nine-table-sheets>
|
|
559
|
-
<nine-table-sheets-body>${
|
|
570
|
+
<nine-table-sheets-body>${r}</nine-table-sheets-body>
|
|
560
571
|
<nine-table-sheets-footer>
|
|
561
572
|
<div class="nine-tab-bar">${h}</div>
|
|
562
573
|
<div class="sheets-counter">Total : <span id="row-count">0</span></div>
|
|
@@ -566,20 +577,20 @@ const _ = class _ {
|
|
|
566
577
|
</nine-table-body>
|
|
567
578
|
<nine-table-footer></nine-table-footer>
|
|
568
579
|
`;
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
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);
|
|
573
584
|
});
|
|
574
585
|
});
|
|
575
586
|
}, "#render"));
|
|
576
|
-
S(this, q, i), e(this,
|
|
587
|
+
S(this, q, i), e(this, K).call(this), e(this, F).call(this);
|
|
577
588
|
}
|
|
578
589
|
};
|
|
579
|
-
q = new WeakMap(),
|
|
580
|
-
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;
|
|
581
592
|
var W;
|
|
582
|
-
const
|
|
593
|
+
const te = class te extends HTMLElement {
|
|
583
594
|
constructor() {
|
|
584
595
|
super();
|
|
585
596
|
y(this, W, !1);
|
|
@@ -592,7 +603,7 @@ const ee = class ee extends HTMLElement {
|
|
|
592
603
|
z.log("NineTable disconnected.");
|
|
593
604
|
}
|
|
594
605
|
};
|
|
595
|
-
W = new WeakMap(), f(
|
|
596
|
-
let J =
|
|
606
|
+
W = new WeakMap(), f(te, "NineTable");
|
|
607
|
+
let J = te;
|
|
597
608
|
customElements.get("nine-table") || customElements.define("nine-table", J);
|
|
598
609
|
//# sourceMappingURL=nine-table.js.map
|