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