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