@ninebone/datagrid 0.0.4 → 0.0.5
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/README.md +13 -9
- package/dist/nine-table.js +246 -269
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +16 -27
- package/dist/nine-table.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/nine-table.js
CHANGED
|
@@ -323,10 +323,10 @@ var n = new class extends e.constructor {
|
|
|
323
323
|
})), this.#t = this.#t.filter((e) => e.name !== "" && e.name !== "__ng"), this.#t.sort((e, t) => e.name.length < t.name.length ? 1 : -1);
|
|
324
324
|
};
|
|
325
325
|
#r = () => {
|
|
326
|
-
this.#t = []
|
|
326
|
+
this.#t = [];
|
|
327
327
|
let e = Array.from(this.#e.querySelectorAll("table"));
|
|
328
328
|
if (e && e.length !== 0) {
|
|
329
|
-
for (let t of e)
|
|
329
|
+
for (let t of e) t.querySelectorAll("[data-bind]").forEach((e) => {
|
|
330
330
|
let t = e.dataset.bind, n = e.getAttribute("data-type") || "string";
|
|
331
331
|
t && this.#t.push({
|
|
332
332
|
name: t,
|
|
@@ -646,7 +646,7 @@ var p = class extends HTMLElement {
|
|
|
646
646
|
m < 0 && (m = 0), m > h && (m = h), n.style.top = `${m}px`, this.#r.top.disabled = f <= 0, this.#r.bottom.disabled = f >= p - 1;
|
|
647
647
|
};
|
|
648
648
|
#s = () => {
|
|
649
|
-
|
|
649
|
+
this.#r.thumb.addEventListener("mousedown", (e) => {
|
|
650
650
|
if (e.button !== 0) return;
|
|
651
651
|
e.stopPropagation(), e.preventDefault(), this.#n = !0, this.#i = e.clientY, this.#a = parseFloat(this.#r.thumb.style.top) || 0;
|
|
652
652
|
let t = this.#r.track.getBoundingClientRect().height - this.#r.thumb.clientHeight, n = (e) => {
|
|
@@ -663,37 +663,32 @@ var p = class extends HTMLElement {
|
|
|
663
663
|
document.addEventListener("mousemove", n), document.addEventListener("mouseup", r);
|
|
664
664
|
}), this.#r.track.addEventListener("mousedown", (e) => {
|
|
665
665
|
if (e.button !== 0 || e.target === this.#r.thumb) return;
|
|
666
|
-
let t = this.#r.track.getBoundingClientRect(),
|
|
667
|
-
if (
|
|
668
|
-
let
|
|
669
|
-
|
|
670
|
-
ratio: o,
|
|
671
|
-
clickY: a,
|
|
672
|
-
totalCount: s,
|
|
673
|
-
targetRow: c
|
|
674
|
-
}), c >= 0 && this.#t.rowManager && typeof this.#t.rowManager.scrollToDataRow == "function" && this.#t.rowManager.scrollToDataRow(c, "top");
|
|
666
|
+
let t = this.#r.track.getBoundingClientRect(), n = this.#r.thumb.clientHeight, r = this.#r.track.clientHeight - n;
|
|
667
|
+
if (r > 0) {
|
|
668
|
+
let i = e.clientY - t.top - n / 2, a = Math.max(0, Math.min(1, i / r)), { totalCount: o } = this.#o(), s = Math.max(0, Math.min(Math.floor(a * (o - 1)), o - 1));
|
|
669
|
+
s >= 0 && this.#t.rowManager && typeof this.#t.rowManager.scrollToDataRow == "function" && this.#t.rowManager.scrollToDataRow(s, "top");
|
|
675
670
|
}
|
|
676
671
|
this.refresh();
|
|
677
672
|
});
|
|
678
673
|
let e = null, t = (t) => {
|
|
679
674
|
if (e) return;
|
|
680
|
-
let
|
|
675
|
+
let n = () => {
|
|
681
676
|
let e = this.#t.querySelector("tbody.body tr");
|
|
682
|
-
if (!e || e.dataset.row === void 0 ||
|
|
683
|
-
let
|
|
684
|
-
this.#t.rowManager.scrollToDataRow(
|
|
677
|
+
if (!e || e.dataset.row === void 0 || t === "down" && this.#t.isLastRow()) return;
|
|
678
|
+
let n = parseInt(e.dataset.row, 10), r = t === "down" ? n + 1 : Math.max(0, n - 1);
|
|
679
|
+
this.#t.rowManager.scrollToDataRow(r, null, () => {
|
|
685
680
|
this.refresh();
|
|
686
681
|
});
|
|
687
682
|
};
|
|
688
|
-
|
|
689
|
-
},
|
|
683
|
+
n(), e = setInterval(n, 200);
|
|
684
|
+
}, n = () => {
|
|
690
685
|
e &&= (clearInterval(e), null);
|
|
691
686
|
};
|
|
692
687
|
this.#r.top.addEventListener("mousedown", (e) => {
|
|
693
688
|
e.button === 0 && t("up");
|
|
694
689
|
}), this.#r.bottom.addEventListener("mousedown", (e) => {
|
|
695
690
|
e.button === 0 && t("down");
|
|
696
|
-
}), document.addEventListener("mouseup",
|
|
691
|
+
}), document.addEventListener("mouseup", n), this.#r.top.addEventListener("mouseleave", n), this.#r.bottom.addEventListener("mouseleave", n);
|
|
697
692
|
};
|
|
698
693
|
};
|
|
699
694
|
customElements.get("nine-table-vscrollbar") || customElements.define("nine-table-vscrollbar", p);
|
|
@@ -726,7 +721,7 @@ var m = {
|
|
|
726
721
|
}), this.#n = e;
|
|
727
722
|
};
|
|
728
723
|
apply() {
|
|
729
|
-
if (
|
|
724
|
+
if (this.#i) return;
|
|
730
725
|
this.#i = !0;
|
|
731
726
|
let e = [], t = this.#e.sourceTable;
|
|
732
727
|
t && t.querySelectorAll("tbody tr[grouping=\"true\"]").forEach((t) => {
|
|
@@ -867,44 +862,43 @@ var m = {
|
|
|
867
862
|
}), this.#n.selection.refresh());
|
|
868
863
|
};
|
|
869
864
|
#p = (e, t = !1) => {
|
|
870
|
-
n.
|
|
871
|
-
|
|
872
|
-
if (i === 0) {
|
|
865
|
+
let n = this.#n.view.getArray() || [], r = n.length;
|
|
866
|
+
if (r === 0) {
|
|
873
867
|
this.#n.elements.scrollHolder.style.height = "0px";
|
|
874
868
|
return;
|
|
875
869
|
}
|
|
876
|
-
let
|
|
870
|
+
let i = this.#n.querySelector(".ng-sheet-body .ng-sheet-body-content"), a = this.#n.templateLength || 1, o = (e) => {
|
|
877
871
|
if (e.type === "group") {
|
|
878
872
|
let t = e.record[m.DEPTH] || 0;
|
|
879
|
-
return this.#a[t] || this.#o /
|
|
873
|
+
return this.#a[t] || this.#o / a;
|
|
880
874
|
}
|
|
881
875
|
{
|
|
882
876
|
let e = 0, t = this.#n.templateLength || 1, n = 0;
|
|
883
877
|
for (let e = 0; e < t - 1; e++) n += this.#a[e] || 0;
|
|
884
878
|
return e = this.#o - n, e > 0 ? e : this.#o;
|
|
885
879
|
}
|
|
886
|
-
},
|
|
887
|
-
for (let e = 0; e <
|
|
888
|
-
let t =
|
|
889
|
-
|
|
880
|
+
}, s = 0, c = Array(r);
|
|
881
|
+
for (let e = 0; e < r; e++) {
|
|
882
|
+
let t = o(n[e]);
|
|
883
|
+
c[e] = t, s += t;
|
|
890
884
|
}
|
|
891
|
-
this.#n.elements.scrollHolder.style.height = `${
|
|
892
|
-
let
|
|
893
|
-
for (let t = 0; t <
|
|
894
|
-
let n =
|
|
895
|
-
if (
|
|
896
|
-
|
|
885
|
+
this.#n.elements.scrollHolder.style.height = `${s}px`;
|
|
886
|
+
let l = this.#n.clientHeight, u = 0, d = 0;
|
|
887
|
+
for (let t = 0; t < r; t++) {
|
|
888
|
+
let n = c[t];
|
|
889
|
+
if (u + n > e) {
|
|
890
|
+
d = t;
|
|
897
891
|
break;
|
|
898
892
|
}
|
|
899
|
-
|
|
893
|
+
u += n, d = t;
|
|
900
894
|
}
|
|
901
|
-
let
|
|
902
|
-
|
|
903
|
-
e.style.top = `-${Math.max(0,
|
|
895
|
+
let f = e - u;
|
|
896
|
+
i && i.querySelectorAll("tbody").forEach((e) => {
|
|
897
|
+
e.style.top = `-${Math.max(0, f)}px`;
|
|
904
898
|
});
|
|
905
|
-
let
|
|
906
|
-
if (!t &&
|
|
907
|
-
let
|
|
899
|
+
let p = this.#r.firstTr, h = p && p.dataset.virtualIndex !== void 0 ? parseInt(p.dataset.virtualIndex, 10) : -1;
|
|
900
|
+
if (!t && h === d) return;
|
|
901
|
+
let g = Math.ceil(l / (this.#o / a)), _ = (this.#n.grouping.columns?.length || 1) * 15, v = d, y = Math.min(r, d + g + _), b = n.slice(v, y);
|
|
908
902
|
[
|
|
909
903
|
".ng-container-body",
|
|
910
904
|
".ng-container-left",
|
|
@@ -912,21 +906,21 @@ var m = {
|
|
|
912
906
|
].forEach((e) => {
|
|
913
907
|
let t = this.#n.querySelector(`.ng-sheet-body ${e}`);
|
|
914
908
|
if (!t) return;
|
|
915
|
-
let
|
|
916
|
-
for (let e = 0; e <
|
|
917
|
-
let t = Math.floor(e /
|
|
918
|
-
if (!i || t >=
|
|
919
|
-
|
|
909
|
+
let r = Array.from(t.querySelectorAll("tbody.body tr"));
|
|
910
|
+
for (let e = 0; e < r.length; e += a) {
|
|
911
|
+
let t = Math.floor(e / a), i = b[t], o = r.slice(e, e + a);
|
|
912
|
+
if (!i || t >= b.length) {
|
|
913
|
+
o.forEach((e) => {
|
|
920
914
|
e.style.display = "none", e.dataset.matrixRow = null, e.dataset.row = null, e.dataset.index = null;
|
|
921
915
|
});
|
|
922
916
|
continue;
|
|
923
917
|
}
|
|
924
|
-
let s =
|
|
925
|
-
|
|
926
|
-
let a =
|
|
918
|
+
let s = d + t;
|
|
919
|
+
o.forEach((e, r) => {
|
|
920
|
+
let a = d + t;
|
|
927
921
|
e.dataset.virtualIndex = a, e.dataset.row = i.type === "data" ? s : "";
|
|
928
922
|
let o = e.getAttribute("grouping") === "true";
|
|
929
|
-
if (i.type === "group") o &&
|
|
923
|
+
if (i.type === "group") o && r === i.record[m.DEPTH] ? (e.style.display = "", this.#m(e, n, i.record, a)) : (e.style.display = "none", e.dataset.matrixRow = null, e.dataset.row = null, e.dataset.index = null);
|
|
930
924
|
else if (o) e.style.display = "none", e.dataset.matrixRow = null, e.dataset.row = null, e.dataset.index = null;
|
|
931
925
|
else {
|
|
932
926
|
e.style.display = "";
|
|
@@ -935,7 +929,7 @@ var m = {
|
|
|
935
929
|
}
|
|
936
930
|
});
|
|
937
931
|
}
|
|
938
|
-
}), this.#n.selection.refresh()
|
|
932
|
+
}), this.#n.selection.refresh();
|
|
939
933
|
};
|
|
940
934
|
#m = (e, t, n, r) => {
|
|
941
935
|
let i = this.#n.templateLength || 1, a = parseInt(e.dataset.subrow, 10) || 0, o = r * i + a, s = n[m.CHILDREN], c = this.#t.data.getArray(), l = s ? s.map((e) => c[e]).filter(Boolean) : [];
|
|
@@ -972,22 +966,22 @@ var m = {
|
|
|
972
966
|
let e = this.#n.querySelector(".ng-sheet-body");
|
|
973
967
|
e && (this.#c = e.clientHeight, this.#g(), this.#v(), this.#f(e.scrollTop, !0), e.addEventListener("scroll", (t) => {
|
|
974
968
|
if (this.#u) return;
|
|
975
|
-
let
|
|
976
|
-
|
|
969
|
+
let n = this.#o || 0;
|
|
970
|
+
(this.#n.view.getArray()?.length || 0) * n <= e.clientHeight || (this.#f(e.scrollTop), this.#n.querySelector("nine-table-vscrollbar").refresh());
|
|
977
971
|
}, { passive: !0 }));
|
|
978
972
|
};
|
|
979
|
-
scrollToDataRow(e, t = "top",
|
|
980
|
-
let
|
|
973
|
+
scrollToDataRow(e, t = "top", n) {
|
|
974
|
+
let r = this.#n.querySelector(".ng-sheet-body"), i = this.#n.view.getArray()?.length || 0, a = Math.max(0, Math.min(e, i - 1)), o = 0;
|
|
981
975
|
if (this.#d) {
|
|
982
|
-
let e = Math.max(
|
|
983
|
-
|
|
976
|
+
let e = Math.max(r.scrollHeight - r.clientHeight, 1);
|
|
977
|
+
o = a / Math.max(i - 1, 1) * e;
|
|
984
978
|
} else {
|
|
985
|
-
let e = this.#o, t =
|
|
986
|
-
u && (d = l / c),
|
|
979
|
+
let e = this.#o, t = a * e, n = (this.#n.elements.body.thead?.offsetHeight || 0) + (this.#n.elements.body.tfoot?.offsetHeight || 0) + this.#n.elements.body.tbody.head.offsetHeight, s = r.offsetHeight || 0, c = Math.max(i * e + n - s, 0), l = 15e6, u = c > l, d = 1;
|
|
980
|
+
u && (d = l / c), o = t * d;
|
|
987
981
|
}
|
|
988
|
-
|
|
982
|
+
this.#u = !0, r.scrollTop = o, this.#f(o), requestAnimationFrame(() => {
|
|
989
983
|
requestAnimationFrame(() => {
|
|
990
|
-
this.#u = !1, typeof
|
|
984
|
+
this.#u = !1, typeof n == "function" && n();
|
|
991
985
|
});
|
|
992
986
|
});
|
|
993
987
|
}
|
|
@@ -998,30 +992,25 @@ var m = {
|
|
|
998
992
|
if (!this.#n.classList.contains("active") || !this.#n.sourceTable) return;
|
|
999
993
|
let e = this.#n.sourceTable?.querySelectorAll("tbody.body tr"), t = this.#n.querySelector(".ng-sheet-body .ng-container-body tbody.body");
|
|
1000
994
|
t.querySelectorAll("tr").forEach((e) => e.remove());
|
|
1001
|
-
let
|
|
1002
|
-
e.forEach((e) =>
|
|
1003
|
-
let
|
|
1004
|
-
this.#a = [],
|
|
1005
|
-
if (e?.offsetHeight === 2) {
|
|
1006
|
-
n.log("================================"), n.log(this.#n), n.log(e), n.log(e.cloneNode(!0));
|
|
1007
|
-
let t = window.getComputedStyle(e);
|
|
1008
|
-
n.log("================================", t, t.height, t.minHeight);
|
|
1009
|
-
}
|
|
995
|
+
let n = document.createDocumentFragment();
|
|
996
|
+
e.forEach((e) => n.appendChild(e.cloneNode(!0))), t.appendChild(n);
|
|
997
|
+
let r = t.querySelectorAll("tr");
|
|
998
|
+
this.#a = [], r.forEach((e) => {
|
|
1010
999
|
this.#a.push(Math.max(e.offsetHeight, 24));
|
|
1011
|
-
}),
|
|
1000
|
+
}), r.forEach((e) => e.remove()), this.#o = this.#a.reduce((e, t) => e + t, 0), this.#_();
|
|
1012
1001
|
};
|
|
1013
1002
|
#_ = () => {
|
|
1014
|
-
if (
|
|
1003
|
+
if (this.#c > 0 && this.#o > 0) {
|
|
1015
1004
|
let e = Math.ceil(this.#c / this.#o), t = this.#e;
|
|
1016
1005
|
if (this.#d && this.#n.grouping) {
|
|
1017
1006
|
let e = this.#n.grouping.columns?.length || 1;
|
|
1018
1007
|
t += e * 15;
|
|
1019
1008
|
}
|
|
1020
|
-
this.#l = e + t
|
|
1009
|
+
this.#l = e + t;
|
|
1021
1010
|
}
|
|
1022
1011
|
};
|
|
1023
1012
|
#v = () => {
|
|
1024
|
-
|
|
1013
|
+
[
|
|
1025
1014
|
".ng-container-body",
|
|
1026
1015
|
".ng-container-left",
|
|
1027
1016
|
".ng-container-right"
|
|
@@ -1114,7 +1103,7 @@ var m = {
|
|
|
1114
1103
|
endCol: -1
|
|
1115
1104
|
};
|
|
1116
1105
|
constructor(e) {
|
|
1117
|
-
this.#e = e, this.#r()
|
|
1106
|
+
this.#e = e, this.#r();
|
|
1118
1107
|
}
|
|
1119
1108
|
#n(e) {
|
|
1120
1109
|
if (!e) return {
|
|
@@ -1192,7 +1181,7 @@ var m = {
|
|
|
1192
1181
|
};
|
|
1193
1182
|
#r() {
|
|
1194
1183
|
let e = this.#e.querySelector(".ng-sheet-body");
|
|
1195
|
-
e
|
|
1184
|
+
e && e.addEventListener("mousedown", (e) => {
|
|
1196
1185
|
if (e.button !== 0) return;
|
|
1197
1186
|
let t = e.target.closest("td, th");
|
|
1198
1187
|
if (!t || t.dataset.row === void 0 || t.dataset.col === void 0) return;
|
|
@@ -1222,7 +1211,7 @@ var m = {
|
|
|
1222
1211
|
this.#e.style.userSelect = "", this.#e.style.webkitUserSelect = "", document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", c);
|
|
1223
1212
|
};
|
|
1224
1213
|
document.addEventListener("mousemove", s), document.addEventListener("mouseup", c);
|
|
1225
|
-
})
|
|
1214
|
+
});
|
|
1226
1215
|
}
|
|
1227
1216
|
}, b = class {
|
|
1228
1217
|
#e;
|
|
@@ -1230,7 +1219,7 @@ var m = {
|
|
|
1230
1219
|
#n = null;
|
|
1231
1220
|
#r = null;
|
|
1232
1221
|
constructor(e) {
|
|
1233
|
-
this.#e = e, this.#t = e.getRootNode().host, this.#g()
|
|
1222
|
+
this.#e = e, this.#t = e.getRootNode().host, this.#g();
|
|
1234
1223
|
}
|
|
1235
1224
|
get currentCell() {
|
|
1236
1225
|
return this.#n;
|
|
@@ -1324,11 +1313,7 @@ var m = {
|
|
|
1324
1313
|
"time",
|
|
1325
1314
|
"week",
|
|
1326
1315
|
"month"
|
|
1327
|
-
].includes(e.target.type))) return;
|
|
1328
|
-
if (!this.#n || !this.#r) {
|
|
1329
|
-
n.log("⚠️ [moveCell] currentCell or currentTr is missing!");
|
|
1330
|
-
return;
|
|
1331
|
-
}
|
|
1316
|
+
].includes(e.target.type)) || !this.#n || !this.#r) return;
|
|
1332
1317
|
let t;
|
|
1333
1318
|
switch (e.code) {
|
|
1334
1319
|
case "Tab":
|
|
@@ -1455,18 +1440,18 @@ var m = {
|
|
|
1455
1440
|
let t = Array.from(this.#e.querySelectorAll(`.ng-container-${e}`));
|
|
1456
1441
|
if (t.length !== 0) {
|
|
1457
1442
|
if (e === "left" || e === "right" || !this.#e.isAutoFitCol && t[0].querySelector("table")?.getAttribute("auto-fit-col") !== "true") {
|
|
1458
|
-
let
|
|
1459
|
-
if (!
|
|
1460
|
-
let
|
|
1461
|
-
Array.from(
|
|
1443
|
+
let n = t[0].querySelector("table colgroup");
|
|
1444
|
+
if (!n) return;
|
|
1445
|
+
let r = 0, i = {};
|
|
1446
|
+
Array.from(n.querySelectorAll("col")).forEach((e) => {
|
|
1462
1447
|
let t = e.getAttribute("data-col"), n = parseInt(e.getAttribute("width"), 10);
|
|
1463
|
-
isNaN(n) || (
|
|
1464
|
-
}), t.forEach((
|
|
1465
|
-
let
|
|
1466
|
-
|
|
1467
|
-
e.style.width = `${
|
|
1468
|
-
}) : (
|
|
1469
|
-
e.style.width = `${
|
|
1448
|
+
isNaN(n) || (i[t] = n, r += n);
|
|
1449
|
+
}), t.forEach((t) => {
|
|
1450
|
+
let n = t.querySelectorAll("table");
|
|
1451
|
+
e === "body" ? n.forEach((e) => {
|
|
1452
|
+
e.style.width = `${r}px`;
|
|
1453
|
+
}) : (t.style.flex = `0 0 ${r}px`, t.style.width = `${r}px`, t.style.minWidth = `${r}px`, t.style.maxWidth = `${r}px`, n.forEach((e) => {
|
|
1454
|
+
e.style.width = `${r}px`, e.style.minWidth = `${r}px`, e.style.maxWidth = `${r}px`, Object.entries(i).forEach(([t, n]) => {
|
|
1470
1455
|
e.querySelectorAll(`th[data-col="${t}"], td[data-col="${t}"]`).forEach((e) => {
|
|
1471
1456
|
e.style.width = `${n}px`, e.style.minWidth = `${n}px`, e.style.maxWidth = `${n}px`;
|
|
1472
1457
|
});
|
|
@@ -1479,16 +1464,15 @@ var m = {
|
|
|
1479
1464
|
this.#e.querySelector("nine-table-hscrollbar")?.refresh();
|
|
1480
1465
|
}
|
|
1481
1466
|
}
|
|
1482
|
-
setColumnWidth(e, t,
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
e.setAttribute("width", t), e.style.width = `${t}px`, n.log(e, t);
|
|
1467
|
+
setColumnWidth(e, t, n = null) {
|
|
1468
|
+
let r = [];
|
|
1469
|
+
if (r = Array.from(this.#e.querySelectorAll(`table colgroup col[data-col="${e}"]`)), r.length === 0) return;
|
|
1470
|
+
let i = r[0].closest(".ng-container-left, .ng-container-body, .ng-container-right"), a = n || (i?.classList.contains("ng-container-left") ? "left" : i?.classList.contains("ng-container-right") ? "right" : "body");
|
|
1471
|
+
r.forEach((e) => {
|
|
1472
|
+
e.setAttribute("width", t), e.style.width = `${t}px`;
|
|
1489
1473
|
});
|
|
1490
|
-
let
|
|
1491
|
-
|
|
1474
|
+
let o = this.#e.sourceTable?.querySelector(`colgroup col[data-col="${e}"]`);
|
|
1475
|
+
o && (o.setAttribute("width", t), o.style.width = `${t}px`), this.refreshLayout(a), (a === "left" || a === "right") && this.refreshLayout("body"), this.#e.rowManager?.refresh();
|
|
1492
1476
|
}
|
|
1493
1477
|
#p(e) {
|
|
1494
1478
|
if (this.#e.isAutoFitCol) return !0;
|
|
@@ -1520,29 +1504,29 @@ var m = {
|
|
|
1520
1504
|
a || o ? n.classList.add("resizable-edge") : n.classList.remove("resizable-edge");
|
|
1521
1505
|
};
|
|
1522
1506
|
#g = (e) => {
|
|
1523
|
-
if (
|
|
1507
|
+
if (!e.actualTarget.closest("thead")) return;
|
|
1524
1508
|
let t = e.actualTarget.closest("th, td");
|
|
1525
|
-
if (
|
|
1509
|
+
if (!t || !t.classList.contains("resizable-edge")) return;
|
|
1526
1510
|
e.preventDefault();
|
|
1527
|
-
let
|
|
1528
|
-
if (
|
|
1511
|
+
let n = t.getBoundingClientRect(), r = e.clientX - n.left, i = t;
|
|
1512
|
+
if (r <= x) {
|
|
1529
1513
|
let e = t.previousElementSibling;
|
|
1530
|
-
if (e && e.dataset.col !== void 0 && e.getAttribute("collapsed") !== "true")
|
|
1514
|
+
if (e && e.dataset.col !== void 0 && e.getAttribute("collapsed") !== "true") i = e;
|
|
1531
1515
|
else if (!t.previousElementSibling) return;
|
|
1532
1516
|
}
|
|
1533
|
-
this.#s =
|
|
1534
|
-
let
|
|
1535
|
-
if (!
|
|
1536
|
-
let
|
|
1537
|
-
if (this.#i =
|
|
1517
|
+
this.#s = i, this.#o = this.#m(i);
|
|
1518
|
+
let a = this.#e.querySelector(`.ng-container-${this.#o}`);
|
|
1519
|
+
if (!a) return;
|
|
1520
|
+
let o = parseInt(i.dataset.col, 10), s = i.colSpan || 1;
|
|
1521
|
+
if (this.#i = o + s - 1, this.#p(i)) {
|
|
1538
1522
|
this.#a = this.#i + 1;
|
|
1539
|
-
let e =
|
|
1523
|
+
let e = a.querySelector(`col[data-col="${this.#a}"]`);
|
|
1540
1524
|
e ? this.#u = parseInt(e.getAttribute("width"), 10) || 100 : this.#a = null;
|
|
1541
1525
|
} else this.#a = null;
|
|
1542
|
-
let
|
|
1543
|
-
this.#d =
|
|
1544
|
-
let
|
|
1545
|
-
this.#l =
|
|
1526
|
+
let c = i.getBoundingClientRect(), l = this.#e.getBoundingClientRect();
|
|
1527
|
+
this.#d = c.width, this.#f = c.left - l.left;
|
|
1528
|
+
let u = a.querySelector(`col[data-col="${this.#i}"]`)?.getAttribute("width");
|
|
1529
|
+
this.#l = u && !isNaN(parseInt(u, 10)) ? parseInt(u, 10) : c.width / s, this.#c = e.clientX, this.#n && (this.#n.classList.add("active"), this.#_(e.clientX)), window.addEventListener("pointermove", this.#v), window.addEventListener("pointerup", this.#y, { once: !0 });
|
|
1546
1530
|
};
|
|
1547
1531
|
#_(e) {
|
|
1548
1532
|
let t = e - this.#c, n = this.#p(this.#s);
|
|
@@ -1561,7 +1545,7 @@ var m = {
|
|
|
1561
1545
|
o && (o.textContent = `${Math.round(r)}px`);
|
|
1562
1546
|
}
|
|
1563
1547
|
#v = (e) => {
|
|
1564
|
-
|
|
1548
|
+
this.#_(e.clientX);
|
|
1565
1549
|
};
|
|
1566
1550
|
#y = (e) => {
|
|
1567
1551
|
window.removeEventListener("pointermove", this.#v);
|
|
@@ -1584,56 +1568,56 @@ var m = {
|
|
|
1584
1568
|
#b = (e) => {
|
|
1585
1569
|
let t = e.target.closest("th, td");
|
|
1586
1570
|
if (!t || !t.classList.contains("resizable-edge")) return;
|
|
1587
|
-
let
|
|
1588
|
-
e.clientX -
|
|
1589
|
-
let
|
|
1590
|
-
if (!
|
|
1591
|
-
let
|
|
1592
|
-
Array.from(
|
|
1571
|
+
let n = t.getBoundingClientRect();
|
|
1572
|
+
e.clientX - n.left <= x && (t = t.previousElementSibling);
|
|
1573
|
+
let r = parseInt(t.dataset.col, 10), i = this.#e.querySelector(`tbody.body [data-col="${r}"]`);
|
|
1574
|
+
if (!i || !i.dataset.bind || i.classList.contains("CELL-RADIO")) return;
|
|
1575
|
+
let a = 0;
|
|
1576
|
+
Array.from(i.firstElementChild.children).forEach((e) => {
|
|
1593
1577
|
switch (e.tagName) {
|
|
1594
1578
|
case "SPAN":
|
|
1595
|
-
|
|
1579
|
+
a += 8;
|
|
1596
1580
|
break;
|
|
1597
1581
|
case "DIV":
|
|
1598
|
-
|
|
1582
|
+
a += 8;
|
|
1599
1583
|
break;
|
|
1600
1584
|
case "BUTTON":
|
|
1601
|
-
|
|
1585
|
+
a += 32;
|
|
1602
1586
|
break;
|
|
1603
1587
|
case "SELECT":
|
|
1604
|
-
|
|
1588
|
+
a += 32;
|
|
1605
1589
|
break;
|
|
1606
1590
|
case "INPUT": switch ((e.type || "text").toLowerCase()) {
|
|
1607
1591
|
case "checkbox":
|
|
1608
1592
|
case "radio":
|
|
1609
|
-
|
|
1593
|
+
a += 12;
|
|
1610
1594
|
break;
|
|
1611
1595
|
case "button":
|
|
1612
1596
|
case "submit":
|
|
1613
1597
|
case "reset":
|
|
1614
1598
|
case "image":
|
|
1615
|
-
|
|
1599
|
+
a += 16;
|
|
1616
1600
|
break;
|
|
1617
1601
|
case "color":
|
|
1618
1602
|
case "file":
|
|
1619
1603
|
case "range":
|
|
1620
|
-
|
|
1604
|
+
a += 24;
|
|
1621
1605
|
break;
|
|
1622
1606
|
case "hidden":
|
|
1623
|
-
|
|
1607
|
+
a += 0;
|
|
1624
1608
|
break;
|
|
1625
|
-
default:
|
|
1609
|
+
default: a += 16;
|
|
1626
1610
|
}
|
|
1627
1611
|
}
|
|
1628
|
-
})
|
|
1629
|
-
let
|
|
1612
|
+
});
|
|
1613
|
+
let o = this.#t.fields.get().indexOf(i.dataset.bind), s = window.getComputedStyle(i).font || "12px sans-serif", c = t.innerText || "", l = (nine.measureTextSize(c, s).width || 0) + 16;
|
|
1630
1614
|
this.#t.execute(() => {
|
|
1631
1615
|
this.#e.view.getArray().forEach((e, t) => {
|
|
1632
|
-
let n = String(
|
|
1633
|
-
r.width && r.width >
|
|
1616
|
+
let n = String(i.dataset.expr ? this.#t.exprEngine.evaluate(i.dataset.expr, e, t) : e.v[o] ?? "").trim(), r = nine.measureTextSize(n, s);
|
|
1617
|
+
r.width && r.width > l && (l = r.width);
|
|
1634
1618
|
});
|
|
1635
|
-
let e = Math.max(32, Math.min(400, Math.ceil(
|
|
1636
|
-
this.setColumnWidth(
|
|
1619
|
+
let e = Math.max(32, Math.min(400, Math.ceil(l) + a));
|
|
1620
|
+
this.setColumnWidth(i.dataset.col, e, this.#m(t));
|
|
1637
1621
|
});
|
|
1638
1622
|
};
|
|
1639
1623
|
}, C = class extends HTMLElement {
|
|
@@ -1833,12 +1817,11 @@ var w = class {
|
|
|
1833
1817
|
this.#r && (window.removeEventListener("pointermove", this.#h), document.body.style.cursor = "", this.#t && (this.#t.style.display = "none", this.#t.replaceChildren()), this.#n && (this.#n.style.display = "none"), this.#o !== null && this.#a !== null && this.#o !== this.#a && this.#o !== this.#a + 1 && this.moveColumn(this.#a, this.#o), this.#r = !1, this.#i = null, this.#a = null, this.#o = null);
|
|
1834
1818
|
};
|
|
1835
1819
|
moveColumn(e, t) {
|
|
1836
|
-
n
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
s(parseInt(e.getAttribute("data-col"), 10)) && (l ? e.setAttribute("fixed", l) : e.removeAttribute("fixed"), r.insertBefore(e, i));
|
|
1820
|
+
let n = this.#e.sourceTable.querySelector("colgroup"), r = n.querySelector(`col[data-col="${t}"]`), i = this.#d(this.#i);
|
|
1821
|
+
if (!i || !i.isValidGroup) return;
|
|
1822
|
+
let a = i.colSpan, o = (t) => t >= e && t < e + a, s = this.#e.querySelector(`.ng-sheet-body-content col[data-col="${t}"]`), c = s?.closest(".ng-container-left") ? "left" : s?.closest(".ng-container-right") ? "right" : null;
|
|
1823
|
+
n.querySelectorAll("col").forEach((e) => {
|
|
1824
|
+
o(parseInt(e.getAttribute("data-col"), 10)) && (c ? e.setAttribute("fixed", c) : e.removeAttribute("fixed"), n.insertBefore(e, r));
|
|
1842
1825
|
}), [
|
|
1843
1826
|
"thead",
|
|
1844
1827
|
"tbody",
|
|
@@ -1847,7 +1830,7 @@ var w = class {
|
|
|
1847
1830
|
this.#e.sourceTable.querySelectorAll(`${e} tr`).forEach((e) => {
|
|
1848
1831
|
let n = Array.from(e.children), r = n.find((e) => parseInt(e.dataset.col, 10) >= t);
|
|
1849
1832
|
n.forEach((t) => {
|
|
1850
|
-
|
|
1833
|
+
o(parseInt(t.dataset.col, 10)) && e.insertBefore(t, r || null);
|
|
1851
1834
|
});
|
|
1852
1835
|
});
|
|
1853
1836
|
}), this.#e.recompileAndRefresh();
|
|
@@ -1892,64 +1875,64 @@ var w = class {
|
|
|
1892
1875
|
}
|
|
1893
1876
|
return !0;
|
|
1894
1877
|
}
|
|
1895
|
-
executeFixToggle(e, t,
|
|
1878
|
+
executeFixToggle(e, t, n = "left") {
|
|
1896
1879
|
if (!this.#e || !t) return;
|
|
1897
|
-
let
|
|
1898
|
-
if (!
|
|
1899
|
-
let
|
|
1900
|
-
if (isNaN(
|
|
1901
|
-
let
|
|
1902
|
-
if (!
|
|
1903
|
-
let
|
|
1904
|
-
if (e === "fix-column")
|
|
1905
|
-
parseInt(e.getAttribute("data-col"), 10) <=
|
|
1880
|
+
let r = this.#e.sourceTable;
|
|
1881
|
+
if (!r) return;
|
|
1882
|
+
let i = parseInt(t.dataset.col, 10), a = t.colSpan || 1, o = i + a - 1;
|
|
1883
|
+
if (isNaN(o)) return;
|
|
1884
|
+
let s = r.querySelector("colgroup");
|
|
1885
|
+
if (!s) return;
|
|
1886
|
+
let c = Array.from(s.querySelectorAll("col"));
|
|
1887
|
+
if (e === "fix-column") c.forEach((e) => {
|
|
1888
|
+
parseInt(e.getAttribute("data-col"), 10) <= o && e.setAttribute("fixed", n);
|
|
1906
1889
|
}), [
|
|
1907
1890
|
"thead",
|
|
1908
1891
|
"tbody",
|
|
1909
1892
|
"tfoot"
|
|
1910
1893
|
].forEach((e) => {
|
|
1911
|
-
|
|
1894
|
+
r.querySelectorAll(`${e} tr`).forEach((e) => {
|
|
1912
1895
|
Array.from(e.children).forEach((e) => {
|
|
1913
1896
|
let t = parseInt(e.dataset.col, 10);
|
|
1914
|
-
!isNaN(t) && t <=
|
|
1897
|
+
!isNaN(t) && t <= o && e.setAttribute("fixed", n);
|
|
1915
1898
|
});
|
|
1916
1899
|
});
|
|
1917
1900
|
});
|
|
1918
1901
|
else if (e === "unfix-column") {
|
|
1919
|
-
let e =
|
|
1902
|
+
let e = i, t = i + a - 1;
|
|
1920
1903
|
[
|
|
1921
1904
|
"thead",
|
|
1922
1905
|
"tbody",
|
|
1923
1906
|
"tfoot"
|
|
1924
1907
|
].forEach((n) => {
|
|
1925
|
-
|
|
1926
|
-
Array.from(n.children).forEach((
|
|
1927
|
-
let
|
|
1928
|
-
(n.sectionRowIndex ?? r) + l - 1 <
|
|
1908
|
+
r.querySelectorAll(`${n} tr`).forEach((n, r) => {
|
|
1909
|
+
Array.from(n.children).forEach((a) => {
|
|
1910
|
+
let s = parseInt(a.dataset.col, 10), c = s + (a.colSpan || 1) - 1, l = a.rowSpan || 1;
|
|
1911
|
+
(n.sectionRowIndex ?? r) + l - 1 < a.closest("tr").sectionRowIndex || a.closest("tr").sectionRowIndex + l - 1, c < i || s > o || (e = Math.min(e, s), t = Math.max(t, c));
|
|
1929
1912
|
});
|
|
1930
1913
|
});
|
|
1931
|
-
}),
|
|
1914
|
+
}), c.forEach((t) => {
|
|
1932
1915
|
parseInt(t.getAttribute("data-col"), 10) >= e && t.removeAttribute("fixed");
|
|
1933
1916
|
});
|
|
1934
1917
|
let n = !1;
|
|
1935
|
-
|
|
1918
|
+
c.forEach((e) => {
|
|
1936
1919
|
n ? e.removeAttribute("fixed") : e.getAttribute("fixed") || (n = !0);
|
|
1937
1920
|
}), [
|
|
1938
1921
|
"thead",
|
|
1939
1922
|
"tbody",
|
|
1940
1923
|
"tfoot"
|
|
1941
1924
|
].forEach((e) => {
|
|
1942
|
-
|
|
1925
|
+
r.querySelectorAll(`${e} tr`).forEach((e) => {
|
|
1943
1926
|
Array.from(e.children).forEach((e) => {
|
|
1944
1927
|
let t = parseInt(e.dataset.col, 10);
|
|
1945
1928
|
if (isNaN(t)) return;
|
|
1946
|
-
let n =
|
|
1929
|
+
let n = c.find((e) => parseInt(e.getAttribute("data-col"), 10) === t)?.getAttribute("fixed");
|
|
1947
1930
|
n ? e.setAttribute("fixed", n) : e.removeAttribute("fixed");
|
|
1948
1931
|
});
|
|
1949
1932
|
});
|
|
1950
1933
|
});
|
|
1951
1934
|
}
|
|
1952
|
-
|
|
1935
|
+
this.#e.recompileAndRefresh?.();
|
|
1953
1936
|
}
|
|
1954
1937
|
}, E = class extends HTMLElement {
|
|
1955
1938
|
#e;
|
|
@@ -2055,11 +2038,11 @@ var w = class {
|
|
|
2055
2038
|
let t = e.target.value.toLowerCase().trim();
|
|
2056
2039
|
if (!t) this.#r.filtering.clear();
|
|
2057
2040
|
else {
|
|
2058
|
-
let e = this.#n.data.getArray(),
|
|
2041
|
+
let e = this.#n.data.getArray(), n = this.#n.data.getHostFields().indexOf("DATA2"), r = [];
|
|
2059
2042
|
e.forEach((e) => {
|
|
2060
|
-
let
|
|
2061
|
-
String(
|
|
2062
|
-
}),
|
|
2043
|
+
let i = n >= 0 && e.v ? e.v[n] : "";
|
|
2044
|
+
String(i).replace(/<[^>]*>?/gm, "").toLowerCase().includes(t) && r.push(i);
|
|
2045
|
+
}), this.#r.filtering.set({ DATA2: [...new Set(r)] });
|
|
2063
2046
|
}
|
|
2064
2047
|
};
|
|
2065
2048
|
#d = (e) => {
|
|
@@ -2096,9 +2079,9 @@ var w = class {
|
|
|
2096
2079
|
this.classList.toggle("filtered", t);
|
|
2097
2080
|
};
|
|
2098
2081
|
#n = (e) => {
|
|
2099
|
-
|
|
2100
|
-
let t = this.#e.querySelector("nine-table-filter-panel"),
|
|
2101
|
-
t && t.currentCol ===
|
|
2082
|
+
e.preventDefault(), e.stopPropagation();
|
|
2083
|
+
let t = this.#e.querySelector("nine-table-filter-panel"), n = this.closest("th, td").dataset.col;
|
|
2084
|
+
t && t.currentCol === n && t.classList.contains("active") ? t.close() : t && t.open(this);
|
|
2102
2085
|
};
|
|
2103
2086
|
}, O = class {
|
|
2104
2087
|
#e;
|
|
@@ -2126,10 +2109,9 @@ var w = class {
|
|
|
2126
2109
|
clear = (e) => {
|
|
2127
2110
|
e ? delete this.#i[e] : this.#i = {}, this.#n = Object.keys(this.#i).length > 0, this.#s(), this.#e.querySelectorAll("nine-table-filter-button").forEach((e) => {
|
|
2128
2111
|
e.updateFilteredState();
|
|
2129
|
-
})
|
|
2112
|
+
});
|
|
2130
2113
|
};
|
|
2131
2114
|
set = (e) => {
|
|
2132
|
-
n.log(e);
|
|
2133
2115
|
let t = Array.isArray(e) ? Object.fromEntries(Object.keys(e[0]).map((t) => [t, [...new Set(e.map((e) => e[t]))]])) : e;
|
|
2134
2116
|
this.#i = t, this.#n = Object.keys(t).length > 0, this.#e.toggleAttribute("filtering", this.#n), this.#s();
|
|
2135
2117
|
};
|
|
@@ -2190,7 +2172,7 @@ var k = class {
|
|
|
2190
2172
|
}
|
|
2191
2173
|
});
|
|
2192
2174
|
});
|
|
2193
|
-
})
|
|
2175
|
+
});
|
|
2194
2176
|
}
|
|
2195
2177
|
#i(e, t) {
|
|
2196
2178
|
let n = t.dataset.col, r = t.closest("tr"), i = r ? r.dataset.subrow || String(r.sectionRowIndex) : "0";
|
|
@@ -2221,7 +2203,7 @@ var k = class {
|
|
|
2221
2203
|
}) : this.#n = this.#n.filter((e) => !(e.colIndex === n && e.subRowIndex === i || e.colName === o)), this.#a();
|
|
2222
2204
|
}
|
|
2223
2205
|
#a() {
|
|
2224
|
-
this.#e.view
|
|
2206
|
+
this.#e.view && (this.#e.view.setSorting(this.#n), this.#o(), this.#e.invalidate());
|
|
2225
2207
|
}
|
|
2226
2208
|
#o() {
|
|
2227
2209
|
this.#e.querySelectorAll("thead th, thead td").forEach((e) => {
|
|
@@ -2311,16 +2293,15 @@ var k = class {
|
|
|
2311
2293
|
this.#n = [], this.refresh();
|
|
2312
2294
|
};
|
|
2313
2295
|
#o = (e, t) => {
|
|
2314
|
-
n.
|
|
2315
|
-
let r = typeof this.#t.data.getHostFields == "function" ? this.#t.data.getHostFields() : [], i = this.#n.map((e) => ({
|
|
2296
|
+
let n = typeof this.#t.data.getHostFields == "function" ? this.#t.data.getHostFields() : [], r = this.#n.map((e) => ({
|
|
2316
2297
|
...e,
|
|
2317
|
-
colIndex:
|
|
2298
|
+
colIndex: n.indexOf(e.colname || e.colName)
|
|
2318
2299
|
}));
|
|
2319
2300
|
return e.sort((e, n) => {
|
|
2320
|
-
let
|
|
2321
|
-
for (let t of
|
|
2322
|
-
let
|
|
2323
|
-
o ? (s = this.#t.exprEngine.evaluate(o,
|
|
2301
|
+
let i = t[e], a = t[n];
|
|
2302
|
+
for (let t of r) {
|
|
2303
|
+
let r = t.asc, o = t.expr, s, c;
|
|
2304
|
+
o ? (s = this.#t.exprEngine.evaluate(o, i, e), c = this.#t.exprEngine.evaluate(o, a, n)) : t.colIndex >= 0 && i.v && a.v && (s = i.v[t.colIndex], c = a.v[t.colIndex]);
|
|
2324
2305
|
let l = s == null || s === "", u = c == null || c === "";
|
|
2325
2306
|
if (!(l && u)) {
|
|
2326
2307
|
if (l) return 1;
|
|
@@ -2332,7 +2313,7 @@ var k = class {
|
|
|
2332
2313
|
let t = String(s), n = String(c);
|
|
2333
2314
|
e = t > n ? 1 : t < n ? -1 : 0;
|
|
2334
2315
|
}
|
|
2335
|
-
if (e !== 0) return
|
|
2316
|
+
if (e !== 0) return r ? e : -e;
|
|
2336
2317
|
}
|
|
2337
2318
|
}
|
|
2338
2319
|
}
|
|
@@ -2589,12 +2570,12 @@ var k = class {
|
|
|
2589
2570
|
}
|
|
2590
2571
|
refreshLayout() {
|
|
2591
2572
|
requestAnimationFrame(() => {
|
|
2592
|
-
|
|
2573
|
+
this.classList.contains("active") && this.#f.table && (this.#_(), this.isAutoFitCol ? this.autoFit(!0) : this.querySelector("nine-table-hscrollbar")?.refresh(), this.#h(), this.#a?.refreshLayout(), this.#n?.refresh());
|
|
2593
2574
|
});
|
|
2594
2575
|
}
|
|
2595
2576
|
#h = () => {
|
|
2596
2577
|
let e = this.querySelector(".ng-container-body thead"), t = this.querySelector(".nodata-overlay");
|
|
2597
|
-
t.style.top = `${e.offsetHeight}px
|
|
2578
|
+
t.style.top = `${e.offsetHeight}px`;
|
|
2598
2579
|
};
|
|
2599
2580
|
get view() {
|
|
2600
2581
|
return !this.#d && this.#t?.data && (this.#d = new A(this)), this.#d;
|
|
@@ -2608,62 +2589,58 @@ var k = class {
|
|
|
2608
2589
|
});
|
|
2609
2590
|
};
|
|
2610
2591
|
#g = (e = !0) => {
|
|
2611
|
-
n.log("***************** autoFit", this);
|
|
2612
2592
|
let t = this.querySelector(".ng-sheet-body .ng-container-body");
|
|
2613
2593
|
if (!t) return;
|
|
2614
|
-
let
|
|
2615
|
-
if (
|
|
2594
|
+
let n = this.querySelector(".ng-container-body table colgroup");
|
|
2595
|
+
if (n) {
|
|
2616
2596
|
if (e) {
|
|
2617
2597
|
this.setAttribute("auto-fit-col", "true");
|
|
2618
2598
|
let e = t.clientWidth;
|
|
2619
2599
|
if (e <= 0) return;
|
|
2620
|
-
let
|
|
2621
|
-
|
|
2600
|
+
let r = 0, i = [];
|
|
2601
|
+
n.querySelectorAll("col").forEach((e) => {
|
|
2622
2602
|
let t = e.getAttribute("data-col");
|
|
2623
|
-
if (this.querySelector(`thead th[data-col="${t}"]`)?.getAttribute("collapsed") === "true")
|
|
2603
|
+
if (this.querySelector(`thead th[data-col="${t}"]`)?.getAttribute("collapsed") === "true") i.unshift({
|
|
2624
2604
|
globalColIndex: t,
|
|
2625
2605
|
width: 16,
|
|
2626
2606
|
isCollapsed: !0
|
|
2627
|
-
})
|
|
2607
|
+
});
|
|
2628
2608
|
else {
|
|
2629
|
-
let
|
|
2630
|
-
|
|
2609
|
+
let n = parseInt(e.getAttribute("width"), 10) || 100;
|
|
2610
|
+
i.push({
|
|
2631
2611
|
globalColIndex: t,
|
|
2632
|
-
width:
|
|
2612
|
+
width: n,
|
|
2633
2613
|
isCollapsed: !1
|
|
2634
|
-
}),
|
|
2614
|
+
}), r += n;
|
|
2635
2615
|
}
|
|
2636
|
-
})
|
|
2637
|
-
let
|
|
2638
|
-
if (
|
|
2639
|
-
let
|
|
2640
|
-
if (
|
|
2641
|
-
globalColIndex:
|
|
2616
|
+
});
|
|
2617
|
+
let a = i.filter((e) => e.isCollapsed).reduce((e, t) => e + t.width, 0), o = Math.max(0, e - a);
|
|
2618
|
+
if (r > 0 && i.length > 0) {
|
|
2619
|
+
let e = 0, t = i.map((t) => {
|
|
2620
|
+
if (t.isCollapsed) return {
|
|
2621
|
+
globalColIndex: t.globalColIndex,
|
|
2642
2622
|
remainder: 0,
|
|
2643
2623
|
width: 16
|
|
2644
2624
|
};
|
|
2645
|
-
let n =
|
|
2646
|
-
return
|
|
2647
|
-
globalColIndex:
|
|
2625
|
+
let n = t.width * o / r, i = Math.max(30, Math.floor(n));
|
|
2626
|
+
return e += i, {
|
|
2627
|
+
globalColIndex: t.globalColIndex,
|
|
2648
2628
|
remainder: n - Math.floor(n),
|
|
2649
|
-
width:
|
|
2629
|
+
width: i
|
|
2650
2630
|
};
|
|
2651
|
-
}),
|
|
2652
|
-
n
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
for (let e = 0; e < Math.abs(o); e++) {
|
|
2660
|
-
let t = c[e % c.length];
|
|
2631
|
+
}), n = o - e, a = t.filter((e) => !i.find((t) => t.globalColIndex === e.globalColIndex)?.isCollapsed);
|
|
2632
|
+
if (n > 0 && a.length > 0) {
|
|
2633
|
+
a.sort((e, t) => t.remainder - e.remainder);
|
|
2634
|
+
for (let e = 0; e < n; e++) a[e % a.length].width += 1;
|
|
2635
|
+
} else if (n < 0 && a.length > 0) {
|
|
2636
|
+
a.sort((e, t) => e.remainder - t.remainder);
|
|
2637
|
+
for (let e = 0; e < Math.abs(n); e++) {
|
|
2638
|
+
let t = a[e % a.length];
|
|
2661
2639
|
t.width > 30 && --t.width;
|
|
2662
2640
|
}
|
|
2663
2641
|
}
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
n.log(`[AutoFit Apply] Col Index ${e} -> ${t}px`), this.#a?.setColumnWidth(e, t, "body");
|
|
2642
|
+
t.forEach(({ globalColIndex: e, width: t }) => {
|
|
2643
|
+
this.#a?.setColumnWidth(e, t, "body");
|
|
2667
2644
|
});
|
|
2668
2645
|
}
|
|
2669
2646
|
} else this.removeAttribute("auto-fit-col");
|
|
@@ -2692,7 +2669,7 @@ var k = class {
|
|
|
2692
2669
|
}), this.#n.initialize(), this.isAutoFitCol ? this.autoFit(!0) : this.querySelector("nine-table-hscrollbar").refresh(), this.#u.initialize(), this.loaded = !0;
|
|
2693
2670
|
};
|
|
2694
2671
|
#_ = () => {
|
|
2695
|
-
|
|
2672
|
+
[
|
|
2696
2673
|
"left",
|
|
2697
2674
|
"right",
|
|
2698
2675
|
"body"
|
|
@@ -2706,8 +2683,7 @@ var k = class {
|
|
|
2706
2683
|
let t = parseInt(e.getAttribute("width"), 10);
|
|
2707
2684
|
isNaN(t) || (r += t);
|
|
2708
2685
|
}), t.forEach((t) => {
|
|
2709
|
-
|
|
2710
|
-
e === "body" ? (t.style.flex = "1", n.forEach((e) => {})) : (t.style.flex = `0 0 ${r}px`, t.style.width = `${r}px`, t.style.minWidth = `${r}px`, t.style.maxWidth = `${r}px`, n.forEach((e) => {}));
|
|
2686
|
+
t.querySelectorAll("table"), e === "body" ? t.style.flex = "1" : (t.style.flex = `0 0 ${r}px`, t.style.width = `${r}px`, t.style.minWidth = `${r}px`, t.style.maxWidth = `${r}px`);
|
|
2711
2687
|
});
|
|
2712
2688
|
});
|
|
2713
2689
|
};
|
|
@@ -2742,8 +2718,8 @@ var k = class {
|
|
|
2742
2718
|
getRowHeight = () => this.#n.getRowHeight();
|
|
2743
2719
|
getViewHeight = () => (this.#p.content.offsetHeight || 0) - ((this.#p.body.thead?.offsetHeight || 0) + (this.#p.body.tfoot?.offsetHeight || 0) + (this.#p.body.tbody.head.offsetHeight || 0));
|
|
2744
2720
|
isLastRow = () => {
|
|
2745
|
-
let e = this.querySelector(".ng-sheet-body"), t = this.querySelector(".ng-container-body tbody.body"),
|
|
2746
|
-
return
|
|
2721
|
+
let e = this.querySelector(".ng-sheet-body"), t = this.querySelector(".ng-container-body tbody.body"), n = this.#p.body.tfoot?.offsetHeight || 0, r = e.getBoundingClientRect().bottom, i = t.getBoundingClientRect().bottom;
|
|
2722
|
+
return r - n >= i;
|
|
2747
2723
|
};
|
|
2748
2724
|
scrollToX = (e) => {
|
|
2749
2725
|
let t = this.querySelector(".ng-sheet-body .ng-container-body");
|
|
@@ -2759,33 +2735,30 @@ var k = class {
|
|
|
2759
2735
|
});
|
|
2760
2736
|
};
|
|
2761
2737
|
#x = () => {
|
|
2762
|
-
this.innerHTML = "\n <div class=\"ng-sheet-body\">\n <div class=\"ng-sheet-body-content\">\n <div class=\"ng-container-left\"></div>\n <div class=\"ng-container-body\"></div>\n <div class=\"ng-container-right\"></div>\n </div>\n <div class=\"ng-virtual-height-holder\"></div>\n </div>\n\n <div class=\"nodata-overlay\">Data Not Found</div>\n\n
|
|
2738
|
+
this.innerHTML = "\n <div class=\"ng-sheet-body\">\n <div class=\"ng-sheet-body-content\">\n <div class=\"ng-container-left\"></div>\n <div class=\"ng-container-body\"></div>\n <div class=\"ng-container-right\"></div>\n </div>\n <div class=\"ng-virtual-height-holder\"></div>\n </div>\n\n <div class=\"nodata-overlay\">Data Not Found</div>\n\n <nine-table-vscrollbar></nine-table-vscrollbar>\n <nine-table-hscrollbar></nine-table-hscrollbar>\n <div class=\"scroll-edge\"></div>\n \n <nine-table-col-resizer-panel></nine-table-col-resizer-panel>\n \n <div class=\"ng-col-mover-grip\"></div>\n <div class=\"ng-col-mover-indi\"></div>\n ", this.#p = {
|
|
2763
2739
|
mainBody: this.querySelector(".ng-sheet-body .ng-container-body"),
|
|
2764
2740
|
hscrollbar: this.querySelector("nine-table-hscrollbar"),
|
|
2765
2741
|
vscrollbar: this.querySelector("nine-table-vscrollbar"),
|
|
2766
2742
|
content: this.querySelector(".ng-sheet-body .ng-sheet-body-content"),
|
|
2767
2743
|
scrollHolder: this.querySelector(".ng-sheet-body .ng-virtual-height-holder")
|
|
2768
|
-
}
|
|
2744
|
+
};
|
|
2769
2745
|
};
|
|
2770
2746
|
#S = () => {
|
|
2771
|
-
n.
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
this.#C(s, c, l);
|
|
2747
|
+
let e = this.querySelector(".ng-container-left table"), t = this.querySelector(".ng-container-body table"), n = this.querySelector(".ng-container-right table"), r = Array.from(e.querySelectorAll("thead tr:not(.col-indicator-rowgroup)")), i = Array.from(t.querySelectorAll("thead tr:not(.col-indicator-rowgroup)")), a = Array.from(n.querySelectorAll("thead tr:not(.col-indicator-rowgroup)"));
|
|
2748
|
+
this.#C(r, i, a);
|
|
2749
|
+
let o = Array.from(e.querySelectorAll("tfoot tr")), s = Array.from(t.querySelectorAll("tfoot tr")), c = Array.from(n.querySelectorAll("tfoot tr"));
|
|
2750
|
+
this.#C(o, s, c);
|
|
2776
2751
|
};
|
|
2777
|
-
#C = (e, t,
|
|
2752
|
+
#C = (e, t, n) => {
|
|
2778
2753
|
setTimeout(() => {
|
|
2779
|
-
let
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
], s = Math.max(...o);
|
|
2788
|
-
n.log(o, s), s > 0 && (e[a] && (e[a].style.height = `${s}px`), t[a] && (t[a].style.height = `${s}px`), r[a] && (r[a].style.height = `${s}px`));
|
|
2754
|
+
let r = Math.max(e.length, t.length, n.length);
|
|
2755
|
+
for (let i = 0; i < r; i++) {
|
|
2756
|
+
let r = [
|
|
2757
|
+
e[i]?.getBoundingClientRect().height || 0,
|
|
2758
|
+
t[i]?.getBoundingClientRect().height || 0,
|
|
2759
|
+
n[i]?.getBoundingClientRect().height || 0
|
|
2760
|
+
], a = Math.max(...r);
|
|
2761
|
+
a > 0 && (e[i] && (e[i].style.height = `${a}px`), t[i] && (t[i].style.height = `${a}px`), n[i] && (n[i].style.height = `${a}px`));
|
|
2789
2762
|
}
|
|
2790
2763
|
});
|
|
2791
2764
|
};
|
|
@@ -2835,15 +2808,13 @@ var N = class {
|
|
|
2835
2808
|
this.#e.style.height = `${c}px`;
|
|
2836
2809
|
};
|
|
2837
2810
|
#r = () => {
|
|
2838
|
-
let e = Array.from(this.#e.children).filter((e) => e.tagName.toUpperCase() === "TABLE"), t = this.#e.getAttribute("auto-height") === "true",
|
|
2839
|
-
let
|
|
2840
|
-
return `<nine-table-sheet class="${
|
|
2841
|
-
}).join("");
|
|
2842
|
-
|
|
2843
|
-
let a = ["@import \"https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.0.3/dist/css/nine-table.css\";"];
|
|
2844
|
-
nine["nine-table"] && nine["nine-table"].cssFile && a.push(`@import "${nine["nine-table"].cssFile}";`), this.#e.shadowRoot.innerHTML = `
|
|
2811
|
+
let e = Array.from(this.#e.children).filter((e) => e.tagName.toUpperCase() === "TABLE"), t = this.#e.getAttribute("auto-height") === "true", n = e.length, r = e.map((e, t) => {
|
|
2812
|
+
let r = t === 0 ? "active" : "", i = e.id || `sheet${t + 1}`;
|
|
2813
|
+
return `<nine-table-sheet class="${r}" data-index="${t}" data-sheet-id="${i}" id="${i}"></nine-table-sheet>` + (t < n - 1 ? `<nine-splitter class="h" data-split-index="${t}"></nine-splitter>` : "");
|
|
2814
|
+
}).join(""), i = ["@import \"https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.0.4/dist/css/nine-table.css\";"];
|
|
2815
|
+
nine["nine-table"] && nine["nine-table"].cssFile && i.push(`@import "${nine["nine-table"].cssFile}";`), this.#e.shadowRoot.innerHTML = `
|
|
2845
2816
|
<style>
|
|
2846
|
-
${
|
|
2817
|
+
${i.join("\n")}
|
|
2847
2818
|
</style>
|
|
2848
2819
|
|
|
2849
2820
|
<nine-table-toolbar></nine-table-toolbar>
|
|
@@ -2853,7 +2824,7 @@ var N = class {
|
|
|
2853
2824
|
<div class="ng-loading-bar"></div>
|
|
2854
2825
|
<nine-table-sheets>
|
|
2855
2826
|
<nine-table-sheets-body>
|
|
2856
|
-
${
|
|
2827
|
+
${r}
|
|
2857
2828
|
</nine-table-sheets-body>
|
|
2858
2829
|
<nine-table-sheets-footer></nine-table-sheets-footer>
|
|
2859
2830
|
</nine-table-sheets>
|
|
@@ -2886,10 +2857,11 @@ var N = class {
|
|
|
2886
2857
|
if (e == null) return "";
|
|
2887
2858
|
try {
|
|
2888
2859
|
let r = String(e).trim(), i = this.rewriteExpr(r);
|
|
2889
|
-
if (i.includes("
|
|
2860
|
+
if (i.includes("provider.") || i.includes("host.") || i.includes("data.") || i.includes("rowItem.v") || i.includes("(")) {
|
|
2890
2861
|
let e = this.#n.get(i);
|
|
2891
2862
|
return e || (e = Function("rowItem", "row", "host", `
|
|
2892
2863
|
const data = rowItem;
|
|
2864
|
+
const provider = host;
|
|
2893
2865
|
|
|
2894
2866
|
if (!data && !host) return "";
|
|
2895
2867
|
return ${i};
|
|
@@ -2906,16 +2878,14 @@ var N = class {
|
|
|
2906
2878
|
#n;
|
|
2907
2879
|
#r = 0;
|
|
2908
2880
|
constructor() {
|
|
2909
|
-
super(), this.#e = this.attachShadow({ mode: "open" }), this.#t = new o(this);
|
|
2881
|
+
super(), ["NINE-TABLE"].includes(this.tagName) && n.log("Welcome nine-table", "0.0.4"), this.#e = this.attachShadow({ mode: "open" }), this.#t = new o(this);
|
|
2910
2882
|
}
|
|
2911
2883
|
connectedCallback() {
|
|
2912
2884
|
setTimeout(() => {
|
|
2913
2885
|
this.#r = this.querySelectorAll("table")?.length, this.fields = new s(this), this.exprEngine = new P(this), this.#a(), this.#n = new N(this), this.#i();
|
|
2914
2886
|
});
|
|
2915
2887
|
}
|
|
2916
|
-
disconnectedCallback() {
|
|
2917
|
-
n.log("NineTable disconnected.");
|
|
2918
|
-
}
|
|
2888
|
+
disconnectedCallback() {}
|
|
2919
2889
|
#i = () => {
|
|
2920
2890
|
let e = 0, t = setInterval(() => {
|
|
2921
2891
|
e++;
|
|
@@ -2943,6 +2913,13 @@ var N = class {
|
|
|
2943
2913
|
get row() {
|
|
2944
2914
|
return this.#t.row;
|
|
2945
2915
|
}
|
|
2916
|
+
addProvider(e) {
|
|
2917
|
+
e && typeof e == "object" && setTimeout(() => {
|
|
2918
|
+
Object.entries(e).forEach(([e, t]) => {
|
|
2919
|
+
typeof t == "function" && (this[e] = t);
|
|
2920
|
+
}), this.rerenderer();
|
|
2921
|
+
});
|
|
2922
|
+
}
|
|
2946
2923
|
setData(e) {
|
|
2947
2924
|
this.#t.data.set(e), this.refresh();
|
|
2948
2925
|
}
|
|
@@ -3611,7 +3588,7 @@ customElements.get("cell-checkbox") || customElements.define("cell-checkbox", W)
|
|
|
3611
3588
|
// src/cell/cell-radio.js
|
|
3612
3589
|
var G = class extends z {
|
|
3613
3590
|
#e;
|
|
3614
|
-
#t;
|
|
3591
|
+
#t = [];
|
|
3615
3592
|
#n = [];
|
|
3616
3593
|
constructor() {
|
|
3617
3594
|
super();
|
|
@@ -3631,7 +3608,7 @@ var G = class extends z {
|
|
|
3631
3608
|
});
|
|
3632
3609
|
};
|
|
3633
3610
|
#i = () => {
|
|
3634
|
-
|
|
3611
|
+
if (!this.host) return;
|
|
3635
3612
|
let e = this.cell.getAttribute("data-source");
|
|
3636
3613
|
if (e && (this.#n = super.getExprValue(e, this.tr.data, this.tr.dataset.row), this.#e.replaceChildren(), this.#n && Array.isArray(this.#n))) {
|
|
3637
3614
|
let e = document.createDocumentFragment();
|
|
@@ -3898,7 +3875,7 @@ var X = class extends R {
|
|
|
3898
3875
|
super();
|
|
3899
3876
|
}
|
|
3900
3877
|
connectedCallback() {
|
|
3901
|
-
this.#r(), super.connectedCallback(), this.cell && (this.cell.removeAttribute("tabindex"), this.cell.dataset.bind = "rowState"
|
|
3878
|
+
this.#r(), super.connectedCallback(), this.cell && (this.cell.removeAttribute("tabindex"), this.cell.dataset.bind = "rowState"), this.#e = this.querySelector(".ng-row-main"), this.#t = this.querySelector(".ng-row-sub"), this.#n = this.querySelector(".ng-row-status");
|
|
3902
3879
|
}
|
|
3903
3880
|
#r = () => {
|
|
3904
3881
|
this.innerHTML = "\n <span class=\"ng-row-main\"></span>\n <span class=\"ng-row-sub\"></span>\n <span class=\"ng-row-status\"></span>\n ";
|
|
@@ -3908,14 +3885,14 @@ var X = class extends R {
|
|
|
3908
3885
|
let e = this.row;
|
|
3909
3886
|
if (isNaN(e)) return;
|
|
3910
3887
|
let t = this.tr.data;
|
|
3911
|
-
t && t.__ng
|
|
3888
|
+
t && t.__ng;
|
|
3912
3889
|
let n = this.index + 1, r = n.toLocaleString();
|
|
3913
3890
|
if (n >= 1e4) {
|
|
3914
3891
|
let e = r.length - 4, t = r.substring(0, e + 1), n = r.substring(e + 1);
|
|
3915
3892
|
this.#e.innerHTML = `
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3893
|
+
<span class="ng-row-prefix">${t}</span>
|
|
3894
|
+
<span class="ng-row-suffix">${n}</span>
|
|
3895
|
+
`;
|
|
3919
3896
|
} else this.#e.innerHTML = `${r}`;
|
|
3920
3897
|
let i = !!this.sheet.querySelector("thead .asc,thead .desc"), a = !!this.sheet.querySelector("thead nine-table-filter-button.filtered");
|
|
3921
3898
|
this.#t.innerHTML = e, this.#t.style.display = i || a ? "" : "none";
|