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