@ninebone/datagrid 0.1.6 → 0.2.1
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/css/nine-table.css +76 -5
- package/dist/nine-table.js +580 -337
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +56 -19
- package/dist/nine-table.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/nine-table.js
CHANGED
|
@@ -103,6 +103,7 @@ var n = new class extends e.constructor {
|
|
|
103
103
|
this.#e = e, this.#t = t, this.#a();
|
|
104
104
|
}
|
|
105
105
|
#i = () => (this.#t.rawRecords || []).filter((e) => e.m._[r.META.INDEX.ROW_STATE] !== r.ROW_STATE.DELETE);
|
|
106
|
+
getRawRecords = () => this.#t.rawRecords || [];
|
|
106
107
|
get count() {
|
|
107
108
|
return this.length;
|
|
108
109
|
}
|
|
@@ -636,115 +637,19 @@ var f = class extends HTMLElement {
|
|
|
636
637
|
};
|
|
637
638
|
};
|
|
638
639
|
customElements.get("nine-table-hscrollbar") || customElements.define("nine-table-hscrollbar", f);
|
|
639
|
-
// src/layout/nine-table-vscrollbar.js
|
|
640
|
-
var p = class extends HTMLElement {
|
|
641
|
-
#e;
|
|
642
|
-
#t;
|
|
643
|
-
#n = !1;
|
|
644
|
-
#r;
|
|
645
|
-
#i = 0;
|
|
646
|
-
#a = 0;
|
|
647
|
-
constructor() {
|
|
648
|
-
super();
|
|
649
|
-
}
|
|
650
|
-
connectedCallback() {
|
|
651
|
-
this.#e = this.getRootNode().host, this.#t = this.closest("nine-table-sheet"), this.innerHTML = "\n <button class='scroll-top' disabled><div class='scroll-icon'></div></button>\n <div class='scroll-track'><div class='scroll-thumb'></div></div>\n <button class='scroll-bottom' disabled><div class='scroll-icon'></div></button>\n ";
|
|
652
|
-
let e = () => {
|
|
653
|
-
let t = this.#t.querySelector(".ng-sheet-body");
|
|
654
|
-
t ? (this.#r = {
|
|
655
|
-
container: t,
|
|
656
|
-
track: this.querySelector(".scroll-track"),
|
|
657
|
-
thumb: this.querySelector(".scroll-thumb"),
|
|
658
|
-
top: this.querySelector(".scroll-top"),
|
|
659
|
-
bottom: this.querySelector(".scroll-bottom")
|
|
660
|
-
}, this.#s(), this.refresh()) : setTimeout(e, 10);
|
|
661
|
-
};
|
|
662
|
-
e();
|
|
663
|
-
}
|
|
664
|
-
#o = () => {
|
|
665
|
-
let e = this.#t.view.getArray(), t = e ? e.length : 0, n = this.#t.elements?.scrollHolder, r = n && parseFloat(n.style.height) || 0;
|
|
666
|
-
(!r || r <= 0) && (r = this.#t.sourceTable?.querySelector("tbody tr[grouping='true']") && this.#t.rowManager ? body.scrollHeight > body.clientHeight ? body.scrollHeight : t * 30 : t * (this.#t.getRowHeight() || 1));
|
|
667
|
-
let i = 15e6, a = r > i, o = 1, s = r;
|
|
668
|
-
return a && (o = i / r, s = i), {
|
|
669
|
-
rawContentHeight: r,
|
|
670
|
-
contentHeight: s,
|
|
671
|
-
scaleFactor: o,
|
|
672
|
-
useScaling: a,
|
|
673
|
-
totalCount: t
|
|
674
|
-
};
|
|
675
|
-
};
|
|
676
|
-
refresh = () => {
|
|
677
|
-
if (this.#n || !this.#t || !this.#t.elements || !this.#r) return;
|
|
678
|
-
let e = this.#r.container, t = this.#r.track, n = this.#r.thumb, { contentHeight: r } = this.#o(), i = (this.#t.querySelector("thead")?.offsetHeight || 0) + (this.#t.querySelector("tfoot")?.offsetHeight || 0) + (this.#t.querySelector("tbody.head")?.offsetHeight || 0), a = this.#t.querySelector(".ng-sheet-body").offsetHeight || 0, o = a - i, s = this.#t.view.getArray().length, c = this.#t.getRowHeight() * s, l = c > o;
|
|
679
|
-
if (this.#t.classList.toggle("vscroll-visible", l), !l) return;
|
|
680
|
-
let u = t.clientHeight;
|
|
681
|
-
if (u <= 0) return;
|
|
682
|
-
let d = Math.max(Math.min(a / c * u, u), 20);
|
|
683
|
-
n.style.height = `${d}px`;
|
|
684
|
-
let f = e.scrollTop, p = Math.max(r - this.#t.rowManager.getRowHeight(), 1), m = 0;
|
|
685
|
-
p > 0 && (m = f / p * (u - d));
|
|
686
|
-
let h = u - d;
|
|
687
|
-
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;
|
|
688
|
-
};
|
|
689
|
-
#s = () => {
|
|
690
|
-
this.#r.thumb.addEventListener("mousedown", (e) => {
|
|
691
|
-
if (e.button !== 0) return;
|
|
692
|
-
e.stopPropagation(), e.preventDefault(), this.#n = !0, this.#i = e.clientY, this.#a = parseFloat(this.#r.thumb.style.top) || 0;
|
|
693
|
-
let t = this.#r.track.getBoundingClientRect().height - this.#r.thumb.clientHeight, n = (e) => {
|
|
694
|
-
if (!this.#n || t <= 0) return;
|
|
695
|
-
let n = e.clientY - this.#i, r = this.#a + n;
|
|
696
|
-
r < 0 && (r = 0), r > t && (r = t), this.#r.thumb.style.top = `${r}px`;
|
|
697
|
-
let i = r / t, a = this.#t.getRowHeight(), o = (this.#t.querySelector(".ng-sheet-body").offsetHeight || 0) - (this.#t.elements.body.thead?.offsetHeight || 0) - (this.#t.elements.body.tfoot?.offsetHeight || 0) - (this.#t.elements.body.tbody.head.offsetHeight || 0), s = Math.floor(o / a), { totalCount: c } = this.#o(), l = Math.floor(i * (c - s + 1));
|
|
698
|
-
this.#t.rowManager.scrollToDataRow(l);
|
|
699
|
-
let { rawContentHeight: u, contentHeight: d } = this.#o(), f = this.#r.container.scrollTop, p = Math.max(d - this.#t.rowManager.getRowHeight(), 0);
|
|
700
|
-
this.#r.top.disabled = f <= 0, this.#r.bottom.disabled = f >= p - 1;
|
|
701
|
-
}, r = () => {
|
|
702
|
-
this.#n = !1, document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", r);
|
|
703
|
-
};
|
|
704
|
-
document.addEventListener("mousemove", n), document.addEventListener("mouseup", r);
|
|
705
|
-
}), this.#r.track.addEventListener("mousedown", (e) => {
|
|
706
|
-
if (e.button !== 0 || e.target === this.#r.thumb) return;
|
|
707
|
-
let t = this.#r.track.getBoundingClientRect(), n = this.#r.thumb.clientHeight, r = this.#r.track.clientHeight - n;
|
|
708
|
-
if (r > 0) {
|
|
709
|
-
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));
|
|
710
|
-
s >= 0 && this.#t.rowManager && typeof this.#t.rowManager.scrollToDataRow == "function" && this.#t.rowManager.scrollToDataRow(s, "top");
|
|
711
|
-
}
|
|
712
|
-
this.refresh();
|
|
713
|
-
});
|
|
714
|
-
let e = null, t = (t) => {
|
|
715
|
-
if (e) return;
|
|
716
|
-
let n = () => {
|
|
717
|
-
let e = this.#t.querySelector("tbody.body tr");
|
|
718
|
-
if (!e || e.dataset.row === void 0 || t === "down" && this.#t.isLastRow()) return;
|
|
719
|
-
let n = parseInt(e.dataset.row, 10), r = t === "down" ? n + 1 : Math.max(0, n - 1);
|
|
720
|
-
this.#t.rowManager.scrollToDataRow(r, null, () => {
|
|
721
|
-
this.refresh();
|
|
722
|
-
});
|
|
723
|
-
};
|
|
724
|
-
n(), e = setInterval(n, 200);
|
|
725
|
-
}, n = () => {
|
|
726
|
-
e &&= (clearInterval(e), null);
|
|
727
|
-
};
|
|
728
|
-
this.#r.top.addEventListener("mousedown", (e) => {
|
|
729
|
-
e.button === 0 && t("up");
|
|
730
|
-
}), this.#r.bottom.addEventListener("mousedown", (e) => {
|
|
731
|
-
e.button === 0 && t("down");
|
|
732
|
-
}), document.addEventListener("mouseup", n), this.#r.top.addEventListener("mouseleave", n), this.#r.bottom.addEventListener("mouseleave", n);
|
|
733
|
-
};
|
|
734
|
-
};
|
|
735
|
-
customElements.get("nine-table-vscrollbar") || customElements.define("nine-table-vscrollbar", p);
|
|
736
640
|
// src/data/Grouping.js
|
|
737
|
-
var
|
|
641
|
+
var p = {
|
|
738
642
|
ID: 0,
|
|
739
643
|
DEPTH: 1,
|
|
740
644
|
NAME: 2,
|
|
741
645
|
CHILDREN: 3
|
|
742
|
-
},
|
|
646
|
+
}, m = class {
|
|
743
647
|
#e;
|
|
744
648
|
#t;
|
|
745
649
|
#n = [];
|
|
746
650
|
#r = /* @__PURE__ */ new Map();
|
|
747
|
-
#i =
|
|
651
|
+
#i = /* @__PURE__ */ new Map();
|
|
652
|
+
#a = !1;
|
|
748
653
|
constructor(e) {
|
|
749
654
|
this.#e = e, this.#t = this.#e.getRootNode().host;
|
|
750
655
|
}
|
|
@@ -754,6 +659,19 @@ var m = {
|
|
|
754
659
|
get groupMap() {
|
|
755
660
|
return this.#r;
|
|
756
661
|
}
|
|
662
|
+
setGroupMap(e) {
|
|
663
|
+
this.#r = e;
|
|
664
|
+
}
|
|
665
|
+
toggleGroup(e) {
|
|
666
|
+
let t = this.#i.get(e) || !1;
|
|
667
|
+
this.#i.set(e, !t), this.#e.invalidate();
|
|
668
|
+
}
|
|
669
|
+
isCollapsed(e) {
|
|
670
|
+
return this.#i.get(e) || !1;
|
|
671
|
+
}
|
|
672
|
+
get collapsedMap() {
|
|
673
|
+
return this.#i;
|
|
674
|
+
}
|
|
757
675
|
initialize = () => {
|
|
758
676
|
let e = [], t = this.#e.sourceTable;
|
|
759
677
|
t && t.querySelectorAll("tbody tr[grouping=\"true\"]").forEach((t) => {
|
|
@@ -762,19 +680,10 @@ var m = {
|
|
|
762
680
|
}), this.#n = e;
|
|
763
681
|
};
|
|
764
682
|
apply() {
|
|
765
|
-
|
|
766
|
-
this.#i = !0;
|
|
767
|
-
let e = [], t = this.#e.sourceTable;
|
|
768
|
-
t && t.querySelectorAll("tbody tr[grouping=\"true\"]").forEach((t) => {
|
|
769
|
-
let n = t.querySelector("[cell-type=\"tree\"]");
|
|
770
|
-
n && n.dataset.bind && e.push(n.dataset.bind);
|
|
771
|
-
}), this.#n = e, this.#i = !1, this.#e.scrollToY(0), this.#e.view.refresh();
|
|
683
|
+
this.#a || (this.#a = !0, this.initialize(), this.#a = !1, this.#e.scrollToY(0), this.#e.view.refresh());
|
|
772
684
|
}
|
|
773
685
|
clear() {
|
|
774
|
-
this.#n = [], this.#r.clear(), this.#i = !1, this.#e.scrollToY(0), this.#e.view.refresh();
|
|
775
|
-
}
|
|
776
|
-
setGroupMap(e) {
|
|
777
|
-
this.#r = e;
|
|
686
|
+
this.#n = [], this.#r.clear(), this.#i.clear(), this.#a = !1, this.#e.scrollToY(0), this.#e.view.refresh();
|
|
778
687
|
}
|
|
779
688
|
getChildrenRowIds(e) {
|
|
780
689
|
return this.#r.get(e) || [];
|
|
@@ -783,37 +692,38 @@ var m = {
|
|
|
783
692
|
let t = this.getChildrenRowIds(e), n = this.#t.data;
|
|
784
693
|
return t.map((e) => n.getArray(e)).filter(Boolean);
|
|
785
694
|
}
|
|
786
|
-
},
|
|
787
|
-
static apply(t, n = [], r = []) {
|
|
695
|
+
}, h = class e {
|
|
696
|
+
static apply(t, n = [], r = [], i = /* @__PURE__ */ new Map()) {
|
|
788
697
|
if (!n || n.length === 0) return {
|
|
789
698
|
headers: [],
|
|
790
699
|
renderItems: [],
|
|
791
700
|
groupMap: /* @__PURE__ */ new Map()
|
|
792
701
|
};
|
|
793
|
-
let
|
|
794
|
-
return e.#e(
|
|
795
|
-
headers:
|
|
796
|
-
renderItems:
|
|
797
|
-
groupMap:
|
|
702
|
+
let a = t.filter((e) => !e.__ng?.deleted), o = /* @__PURE__ */ new Map(), s = e.#t(a, n, r), c = [], l = [];
|
|
703
|
+
return e.#e(s, 0, n, c, l, o, "", i), {
|
|
704
|
+
headers: c,
|
|
705
|
+
renderItems: l,
|
|
706
|
+
groupMap: o
|
|
798
707
|
};
|
|
799
708
|
}
|
|
800
|
-
static #e(t, n, r, i, a, o, s) {
|
|
801
|
-
let
|
|
802
|
-
for (let [
|
|
803
|
-
let t = s ? `${s}_${
|
|
804
|
-
o.set(t,
|
|
805
|
-
let
|
|
806
|
-
p
|
|
709
|
+
static #e(t, n, r, i, a, o, s, c) {
|
|
710
|
+
let l = 0, u = n === r.length - 1;
|
|
711
|
+
for (let [d, f] of t.entries()) {
|
|
712
|
+
let t = s ? `${s}_${l++}` : `g_${l++}`, m = c.get(t) || !1, h = e.#n(f);
|
|
713
|
+
o.set(t, h);
|
|
714
|
+
let g = [];
|
|
715
|
+
g[p.ID] = t, g[p.DEPTH] = n, g[p.NAME] = d, g[p.CHILDREN] = h, g.__isGroupHeader = !0, g.__groupId = t, g.__collapsed = m, i.push(g), a.push({
|
|
807
716
|
type: "group",
|
|
808
|
-
record:
|
|
809
|
-
groupId: t
|
|
810
|
-
|
|
717
|
+
record: g,
|
|
718
|
+
groupId: t,
|
|
719
|
+
collapsed: m
|
|
720
|
+
}), m || (!u && f instanceof Map ? e.#e(f, n + 1, r, i, a, o, t, c) : e.#r(f).forEach((e) => {
|
|
811
721
|
e.__isGroupHeader = !1, e.__groupId = t, i.push(e), a.push({
|
|
812
722
|
type: "data",
|
|
813
723
|
record: e,
|
|
814
724
|
groupId: t
|
|
815
725
|
});
|
|
816
|
-
});
|
|
726
|
+
}));
|
|
817
727
|
}
|
|
818
728
|
}
|
|
819
729
|
static #t(t, n, r) {
|
|
@@ -840,19 +750,148 @@ var m = {
|
|
|
840
750
|
else Array.isArray(t) && (n = n.concat(t));
|
|
841
751
|
return n;
|
|
842
752
|
}
|
|
843
|
-
},
|
|
753
|
+
}, g = class extends HTMLElement {
|
|
754
|
+
#e;
|
|
755
|
+
#t;
|
|
756
|
+
#n = !1;
|
|
757
|
+
#r;
|
|
758
|
+
#i = 0;
|
|
759
|
+
#a = 0;
|
|
760
|
+
constructor() {
|
|
761
|
+
super();
|
|
762
|
+
}
|
|
763
|
+
connectedCallback() {
|
|
764
|
+
this.#e = this.getRootNode().host, this.#t = this.closest("nine-table-sheet"), this.innerHTML = "\n <button class='scroll-top' disabled><div class='scroll-icon'></div></button>\n <div class='scroll-track'><div class='scroll-thumb'></div></div>\n <button class='scroll-bottom' disabled><div class='scroll-icon'></div></button>\n ";
|
|
765
|
+
let e = () => {
|
|
766
|
+
let t = this.#t.querySelector(".ng-sheet-body");
|
|
767
|
+
t ? (this.#r = {
|
|
768
|
+
container: t,
|
|
769
|
+
track: this.querySelector(".scroll-track"),
|
|
770
|
+
thumb: this.querySelector(".scroll-thumb"),
|
|
771
|
+
top: this.querySelector(".scroll-top"),
|
|
772
|
+
bottom: this.querySelector(".scroll-bottom")
|
|
773
|
+
}, this.#u(), this.refresh()) : setTimeout(e, 10);
|
|
774
|
+
};
|
|
775
|
+
e();
|
|
776
|
+
}
|
|
777
|
+
#o = () => {
|
|
778
|
+
let e = this.#t.view.getArray(), t = e ? e.length : 0, n = this.#t.elements.scrollHolder, r = n && parseFloat(n.style.height) || 0;
|
|
779
|
+
if (this.#t.sourceTable?.querySelector("tbody tr[grouping='true']")) {
|
|
780
|
+
let t = (e) => {
|
|
781
|
+
if (e.type === "group") {
|
|
782
|
+
let t = e.record[p.DEPTH];
|
|
783
|
+
return this.#t.template.heights[t];
|
|
784
|
+
}
|
|
785
|
+
{
|
|
786
|
+
let e = this.#t.template.height - this.#t.template.group.height;
|
|
787
|
+
return e > 0 ? e : this.#t.template.height;
|
|
788
|
+
}
|
|
789
|
+
}, n = 0;
|
|
790
|
+
for (let r = 0; r < e.length; r++) n += t(e[r]);
|
|
791
|
+
r = n;
|
|
792
|
+
} else r = t * this.#t.template.height;
|
|
793
|
+
let i = 15e6, a = r > i, o = 1, s = r;
|
|
794
|
+
return a && (o = i / r, s = i), {
|
|
795
|
+
contentHeight: s,
|
|
796
|
+
scaleFactor: o,
|
|
797
|
+
useScaling: a,
|
|
798
|
+
totalCount: t
|
|
799
|
+
};
|
|
800
|
+
};
|
|
801
|
+
refresh = () => {
|
|
802
|
+
if (this.#n || !this.#t || !this.#t.elements || !this.#r) return;
|
|
803
|
+
let e = this.#r.container, t = this.#r.track, n = this.#r.thumb, { contentHeight: r } = this.#o(), i = (this.#t.querySelector("thead")?.offsetHeight || 0) + (this.#t.querySelector("tfoot")?.offsetHeight || 0) + (this.#t.querySelector("tbody.head")?.offsetHeight || 0), a = (this.#t.querySelector(".ng-sheet-body").offsetHeight || 0) - i, o = r, s = o > a;
|
|
804
|
+
if (this.#t.classList.toggle("vscroll-visible", s), !s) return;
|
|
805
|
+
let c = t.clientHeight;
|
|
806
|
+
if (c <= 0) return;
|
|
807
|
+
let l = Math.max(Math.min(a / o * c, c), 20);
|
|
808
|
+
n.style.height = `${l}px`;
|
|
809
|
+
let u = e.scrollTop, d = Math.max(o - a, 1), f = 0;
|
|
810
|
+
d > 0 && (f = u / d * (c - l));
|
|
811
|
+
let p = c - l;
|
|
812
|
+
f < 0 && (f = 0), f > p && (f = p), n.style.top = `${f}px`, this.#r.top.disabled = u <= 0, this.#r.bottom.disabled = u >= d - 1;
|
|
813
|
+
};
|
|
814
|
+
#s = () => {
|
|
815
|
+
this.#n = !1;
|
|
816
|
+
};
|
|
817
|
+
#c = (e) => {
|
|
818
|
+
e.button === 0 && (e.stopPropagation(), e.preventDefault(), this.#n = !0, this.#i = e.clientY, this.#a = parseFloat(this.#r.thumb.style.top) || 0);
|
|
819
|
+
};
|
|
820
|
+
#l = (e) => {
|
|
821
|
+
if (!this.#n) return;
|
|
822
|
+
let t = this.#r.track.getBoundingClientRect().height - this.#r.thumb.clientHeight;
|
|
823
|
+
if (t <= 0) return;
|
|
824
|
+
let n = e.clientY - this.#i, r = this.#a + n;
|
|
825
|
+
r < 0 && (r = 0), r > t && (r = t), this.#r.thumb.style.top = `${r}px`;
|
|
826
|
+
let i = t > 0 ? r / t : 0, a = this.#r.container, o = (this.#t.elements.body?.thead?.offsetHeight || 0) + (this.#t.elements.body?.tfoot?.offsetHeight || 0) + (this.#t.elements.body?.tbody.head.offsetHeight || 0), s = a.clientHeight - o, { contentHeight: c } = this.#o(), l = Math.max(c - s, 0);
|
|
827
|
+
a.scrollTop = i * l;
|
|
828
|
+
let u = a.scrollTop;
|
|
829
|
+
this.#r.top.disabled = u <= 0, this.#r.bottom.disabled = u >= l - 1;
|
|
830
|
+
};
|
|
831
|
+
#u = () => {
|
|
832
|
+
document.addEventListener("mouseup", this.#s), document.addEventListener("mousemove", this.#l), this.#r.thumb.addEventListener("mousedown", this.#c), this.#r.track.addEventListener("mousedown", (e) => {
|
|
833
|
+
if (e.button !== 0 || e.target === this.#r.thumb) return;
|
|
834
|
+
let t = this.#r.track.getBoundingClientRect(), n = this.#r.thumb.clientHeight, r = this.#r.track.clientHeight - n;
|
|
835
|
+
if (r > 0) {
|
|
836
|
+
let i = e.clientY - t.top - n / 2, a = Math.max(0, Math.min(1, i / r)), o = this.#r.container, s = (this.#t.elements.body?.thead?.offsetHeight || 0) + (this.#t.elements.body?.tfoot?.offsetHeight || 0) + (this.#t.elements.body?.tbody.head.offsetHeight || 0), c = o.clientHeight - s, { contentHeight: l } = this.#o();
|
|
837
|
+
o.scrollTop = a * Math.max(l - c, 0), this.#t.rowManager?.refresh(!0);
|
|
838
|
+
}
|
|
839
|
+
this.refresh();
|
|
840
|
+
});
|
|
841
|
+
let e = null, t = (t) => {
|
|
842
|
+
if (e) return;
|
|
843
|
+
let n = this.#t.view.getArray(), r = (this.#t.querySelector("thead")?.offsetHeight || 0) + (this.#t.querySelector("tfoot")?.offsetHeight || 0) + (this.#t.querySelector("tbody.head")?.offsetHeight || 0), i = 400, a = () => {
|
|
844
|
+
let o = this.#r.container, s = o.scrollTop, c = o.getBoundingClientRect().top + r, l = Array.from(this.#t.querySelectorAll(".ng-container-body tbody.body tr"));
|
|
845
|
+
if (l.length === 0) return;
|
|
846
|
+
let u = l.find((e) => e.style.display !== "none");
|
|
847
|
+
if (!u) return;
|
|
848
|
+
let d = parseInt(u.dataset.index, 10), f = l.filter((e) => e.style.display !== "none" && e.dataset.index === u.dataset.index).map((e) => e.getBoundingClientRect()), p = Math.min(...f.map((e) => e.top)), m = u.getAttribute("grouping") === "true", h = s, g = 0;
|
|
849
|
+
if (t === "down") {
|
|
850
|
+
if (m) {
|
|
851
|
+
let e = Math.max(...f.map((e) => e.bottom)) - p;
|
|
852
|
+
g = c > p ? e - (c - p) : e;
|
|
853
|
+
} else g = c > p ? this.#t.template.height - this.#t.template.group.height - (c - p) : this.#t.template.height - this.#t.template.group.height;
|
|
854
|
+
h = s + g;
|
|
855
|
+
} else {
|
|
856
|
+
if (p >= c) {
|
|
857
|
+
if (d > 0) {
|
|
858
|
+
if (n[d - 1].type === "group") {
|
|
859
|
+
let e = n[d - 1].groupId.split("_").length - 2;
|
|
860
|
+
g = this.#t.template.group.heights[e];
|
|
861
|
+
} else g = this.#t.template.height - this.#t.template.group.height;
|
|
862
|
+
}
|
|
863
|
+
} else g = c - p;
|
|
864
|
+
h = Math.max(0, s - g);
|
|
865
|
+
}
|
|
866
|
+
o.scrollTop = h, this.#t.rowManager?.refresh(!0), this.refresh(), i = Math.max(1, Math.floor(i * .7)), e = setTimeout(a, i);
|
|
867
|
+
};
|
|
868
|
+
a();
|
|
869
|
+
}, n = () => {
|
|
870
|
+
e &&= (clearTimeout(e), null);
|
|
871
|
+
};
|
|
872
|
+
this.#r.top.addEventListener("mousedown", (e) => {
|
|
873
|
+
e.button === 0 && t("up");
|
|
874
|
+
}), this.#r.bottom.addEventListener("mousedown", (e) => {
|
|
875
|
+
e.button === 0 && t("down");
|
|
876
|
+
}), document.addEventListener("mouseup", n), this.#r.top.addEventListener("mouseleave", n), this.#r.bottom.addEventListener("mouseleave", n);
|
|
877
|
+
};
|
|
878
|
+
};
|
|
879
|
+
customElements.get("nine-table-vscrollbar") || customElements.define("nine-table-vscrollbar", g);
|
|
880
|
+
// src/layout/core/RowManager.js
|
|
881
|
+
var _ = class {
|
|
844
882
|
#e = 3;
|
|
845
883
|
#t;
|
|
846
884
|
#n;
|
|
847
885
|
#r;
|
|
848
|
-
#i
|
|
849
|
-
#a =
|
|
850
|
-
#o =
|
|
851
|
-
#s;
|
|
852
|
-
#c
|
|
886
|
+
#i;
|
|
887
|
+
#a = /* @__PURE__ */ new Map();
|
|
888
|
+
#o = null;
|
|
889
|
+
#s = 0;
|
|
890
|
+
#c;
|
|
853
891
|
#l = !1;
|
|
892
|
+
#u = !1;
|
|
854
893
|
constructor(e) {
|
|
855
|
-
this.#t = e.getRootNode().host, this.#n = e, this.#
|
|
894
|
+
this.#t = e.getRootNode().host, this.#n = e, this.#b();
|
|
856
895
|
}
|
|
857
896
|
getRowHeight() {
|
|
858
897
|
return this.#n.template.height;
|
|
@@ -860,15 +899,15 @@ var m = {
|
|
|
860
899
|
refresh = (e = !1) => {
|
|
861
900
|
if (!this.#n.classList.contains("active")) return;
|
|
862
901
|
let t = this.#n.querySelector(".ng-sheet-body");
|
|
863
|
-
t && ((!this.#n.template.height || this.#n.template.height <= 0) && (this.#
|
|
902
|
+
t && ((!this.#n.template.height || this.#n.template.height <= 0) && (this.#h(), this.#n.template.height && this.#n.template.height > 0 && this.#_()), this.#i = this.#t.data.getArray(), this.#d(t.scrollTop, e), this.#n.querySelector("nine-table-vscrollbar")?.refresh());
|
|
864
903
|
};
|
|
865
|
-
#
|
|
866
|
-
if (this.#l) {
|
|
867
|
-
this.#d(e, t);
|
|
868
|
-
return;
|
|
869
|
-
}
|
|
904
|
+
#d = (e, t = !1) => {
|
|
870
905
|
let n = this.#n.template.height;
|
|
871
906
|
if (!n || n <= 0) return;
|
|
907
|
+
if (this.#u) {
|
|
908
|
+
this.#f(e, t);
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
872
911
|
let i = this.#n.view.getArray(), a = i.length;
|
|
873
912
|
if (a === 0) {
|
|
874
913
|
this.#n.elements.scrollHolder.style.height = "0px";
|
|
@@ -884,7 +923,7 @@ var m = {
|
|
|
884
923
|
this.#n.elements.body.tbody.body,
|
|
885
924
|
this.#n.elements.right.tbody.body
|
|
886
925
|
].forEach((e, t) => {
|
|
887
|
-
e && e.
|
|
926
|
+
e && e.trs.forEach((e, t) => {
|
|
888
927
|
let n = g + Math.floor(t / this.#n.template.length);
|
|
889
928
|
if (n >= a) {
|
|
890
929
|
e.style.display = "none", e.dataset.matrixRow = null, e.dataset.row = null, e.dataset.index = null;
|
|
@@ -900,92 +939,89 @@ var m = {
|
|
|
900
939
|
});
|
|
901
940
|
}), this.#n.selection.refresh());
|
|
902
941
|
};
|
|
903
|
-
#
|
|
904
|
-
let n = this.#n.view.getArray() || [],
|
|
905
|
-
if (
|
|
942
|
+
#f = (e, t = !1) => {
|
|
943
|
+
let n = this.#n.view.getArray() || [], i = n.length;
|
|
944
|
+
if (i === 0) {
|
|
906
945
|
this.#n.elements.scrollHolder.style.height = "0px";
|
|
907
946
|
return;
|
|
908
947
|
}
|
|
909
|
-
|
|
948
|
+
this.#n.querySelector(".ng-sheet-body");
|
|
949
|
+
let a = this.#n.querySelector(".ng-sheet-body .ng-sheet-body-content"), o = this.#n.template.length, s = (e) => {
|
|
910
950
|
if (e.type === "group") {
|
|
911
|
-
let t = e.record[
|
|
912
|
-
return this.#n.template.
|
|
951
|
+
let t = e.record[p.DEPTH];
|
|
952
|
+
return this.#n.template.heights[t];
|
|
913
953
|
}
|
|
914
954
|
{
|
|
915
|
-
let e =
|
|
916
|
-
|
|
917
|
-
return e = this.#n.template.height - n, e > 0 ? e : this.#n.template.height;
|
|
955
|
+
let e = this.#n.template.height - this.#n.template.group.height;
|
|
956
|
+
return e > 0 ? e : this.#n.template.height;
|
|
918
957
|
}
|
|
919
|
-
},
|
|
920
|
-
for (let e = 0; e <
|
|
921
|
-
let t =
|
|
922
|
-
|
|
958
|
+
}, c = 0, l = Array(i);
|
|
959
|
+
for (let e = 0; e < i; e++) {
|
|
960
|
+
let t = s(n[e]);
|
|
961
|
+
l[e] = t, c += t;
|
|
923
962
|
}
|
|
924
|
-
this.#n.
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
963
|
+
let u = Math.max(c - this.#n.viewport.height + this.#n.viewport.fixedHeight, 0), d = 15e6, f = u > d, m = 1, h = u;
|
|
964
|
+
f && (m = d / u, h = d), this.#n.elements.scrollHolder.style.height = `${h}px`;
|
|
965
|
+
let g = f ? e / m : e, _ = Math.min(g, u), v = 0, y = 0;
|
|
966
|
+
for (let e = 0; e < i; e++) {
|
|
967
|
+
let t = l[e];
|
|
968
|
+
if (v + t > _) {
|
|
969
|
+
y = e;
|
|
930
970
|
break;
|
|
931
971
|
}
|
|
932
|
-
|
|
972
|
+
v += t, y = e;
|
|
933
973
|
}
|
|
934
|
-
let
|
|
935
|
-
|
|
936
|
-
e.style.top = `-${Math.max(0,
|
|
974
|
+
let b = _ - v;
|
|
975
|
+
a && a.querySelectorAll("tbody.body").forEach((e) => {
|
|
976
|
+
e.style.top = `-${Math.max(0, b)}px`;
|
|
937
977
|
});
|
|
938
|
-
let
|
|
939
|
-
if (
|
|
940
|
-
let
|
|
941
|
-
[
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
].forEach((e) => {
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
let
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
o.forEach((e) => {
|
|
978
|
+
let x = Math.min(i, y + this.#n.viewport.tr.length), S = n.slice(y, x);
|
|
979
|
+
if (S.length === 0) return;
|
|
980
|
+
let C = [];
|
|
981
|
+
S.find((e) => !(e.type === "group" && C.includes(e.groupId))), [
|
|
982
|
+
this.#n.elements.left.tbody.body,
|
|
983
|
+
this.#n.elements.body.tbody.body,
|
|
984
|
+
this.#n.elements.right.tbody.body
|
|
985
|
+
].forEach((e, t) => {
|
|
986
|
+
if (!e) return;
|
|
987
|
+
let i = y;
|
|
988
|
+
for (let t = 0; t < e.trs.length; t += o) {
|
|
989
|
+
let a = Math.floor(t / o), s = S[a], c = e.trs.slice(t, t + o);
|
|
990
|
+
if (!s || a >= S.length) {
|
|
991
|
+
c.forEach((e) => {
|
|
953
992
|
e.style.display = "none", e.dataset.matrixRow = null, e.dataset.row = null, e.dataset.index = null;
|
|
954
993
|
});
|
|
955
994
|
continue;
|
|
956
995
|
}
|
|
957
|
-
let
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
e.dataset.virtualIndex = a, e.dataset.row = i.type === "data" ? s : "";
|
|
996
|
+
let l = y + a;
|
|
997
|
+
c.forEach((e, t) => {
|
|
998
|
+
e.dataset.virtualIndex = i, e.dataset.row = s.type === "data" ? l : "";
|
|
961
999
|
let o = e.getAttribute("grouping") === "true";
|
|
962
|
-
if (
|
|
1000
|
+
if (s.type === "group") o && t === s.record[p.DEPTH] ? (e.style.display = "", this.#m(e, n, s.record, y + a)) : (e.style.display = "none", e.dataset.matrixRow = null, e.dataset.row = null, e.dataset.index = null);
|
|
963
1001
|
else if (o) e.style.display = "none", e.dataset.matrixRow = null, e.dataset.row = null, e.dataset.index = null;
|
|
964
1002
|
else {
|
|
965
1003
|
e.style.display = "";
|
|
966
|
-
let t =
|
|
967
|
-
this.#p(e,
|
|
1004
|
+
let t = s.record.m._[r.META.INDEX.ROWID];
|
|
1005
|
+
this.#p(e, s.record, t, y + a);
|
|
968
1006
|
}
|
|
969
1007
|
});
|
|
970
1008
|
}
|
|
971
1009
|
}), this.#n.selection.refresh();
|
|
972
1010
|
};
|
|
973
|
-
#f = (e, t, n, r) => {
|
|
974
|
-
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) : [];
|
|
975
|
-
e.dataset.virtualIndex = r, e.dataset.row = "", e.dataset.matrixRow = o, e.data = l, e.dataset.groupId = n[m.ID], Array.from(e.cells).forEach((e) => {
|
|
976
|
-
e.dataset.row = r;
|
|
977
|
-
let t = Array.from(e.children).find((e) => e.tagName.toLowerCase().startsWith("cell-") || typeof e.refresh == "function");
|
|
978
|
-
t !== void 0 && typeof t.refresh == "function" && t?.refresh();
|
|
979
|
-
});
|
|
980
|
-
};
|
|
981
1011
|
#p = (e, t, n, r) => {
|
|
982
1012
|
let i = this.#n.templateLength || 1, a = parseInt(e.dataset.subrow, 10) || 0, o = r * i + a;
|
|
983
1013
|
e.dataset.index = r, e.dataset.row = n, e.dataset.matrixRow = o, e.data = t, Array.from(e.cells).forEach((e) => {
|
|
984
1014
|
e.dataset.index = r, e.dataset.row = n, Array.from(e.children).find((e) => e.tagName.toLowerCase().startsWith("cell-") && typeof e.refresh == "function")?.refresh();
|
|
985
1015
|
});
|
|
986
1016
|
};
|
|
1017
|
+
#m = (e, t, n, r) => {
|
|
1018
|
+
let i = this.#n.templateLength || 1, a = parseInt(e.dataset.subrow, 10) || 0, o = r * i + a, s = n[p.CHILDREN], c = s ? s.map((e) => this.#i[e]).filter(Boolean) : [];
|
|
1019
|
+
e.dataset.virtualIndex = r, e.dataset.index = r, e.dataset.row = "", e.dataset.matrixRow = o, e.data = c, e.dataset.groupId = n[p.ID], Array.from(e.cells).forEach((e) => {
|
|
1020
|
+
e.dataset.index = r, e.dataset.row = r, Array.from(e.children).find((e) => e.tagName.toLowerCase().startsWith("cell-") || typeof e.refresh == "function")?.refresh?.();
|
|
1021
|
+
});
|
|
1022
|
+
};
|
|
987
1023
|
initialize = () => {
|
|
988
|
-
this.#
|
|
1024
|
+
this.#u = !!this.#n.sourceTable.querySelector("tbody tr[grouping='true']"), this.#a.clear(), this.#r = {
|
|
989
1025
|
scrollTables: this.#n.querySelectorAll(".ng-sheet-body table"),
|
|
990
1026
|
firstTr: this.#n.querySelector(".ng-sheet-body .ng-container-body tbody.body tr")
|
|
991
1027
|
}, [
|
|
@@ -1000,59 +1036,82 @@ var m = {
|
|
|
1000
1036
|
let r = n.querySelector("tbody.body");
|
|
1001
1037
|
if (!r) return;
|
|
1002
1038
|
let i = Array.from(r.querySelectorAll("tr")).map((e) => e.cloneNode(!0));
|
|
1003
|
-
this.#
|
|
1039
|
+
this.#a.set(e, i);
|
|
1004
1040
|
});
|
|
1005
1041
|
let e = this.#n.querySelector(".ng-sheet-body");
|
|
1006
|
-
e && (this.#
|
|
1042
|
+
e && (this.#s = e.clientHeight, this.#h(), this.#_(), this.#d(e.scrollTop, !0), e.addEventListener("scroll", (t) => {
|
|
1007
1043
|
if (this.#n.querySelectorAll("cell-combo-panel").forEach((e) => {
|
|
1008
1044
|
e.classList.remove("active");
|
|
1009
|
-
}), this.#
|
|
1045
|
+
}), this.#l) return;
|
|
1010
1046
|
let n = this.#n.template.height || 0;
|
|
1011
|
-
(this.#n.view.getArray()?.length || 0) * n <= e.clientHeight || (this.#
|
|
1047
|
+
(this.#n.view.getArray()?.length || 0) * n <= e.clientHeight || (this.#d(e.scrollTop), this.#n.querySelector("nine-table-vscrollbar").refresh());
|
|
1012
1048
|
}, { passive: !0 }));
|
|
1013
1049
|
};
|
|
1014
1050
|
scrollToDataRow(e, t = "top", n) {
|
|
1015
|
-
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;
|
|
1016
|
-
if (this.#
|
|
1017
|
-
let e =
|
|
1018
|
-
o =
|
|
1051
|
+
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, s = 15e6;
|
|
1052
|
+
if (this.#u) {
|
|
1053
|
+
let e = this.#n.view.getArray() || [], t = Array.from(this.#n.sourceTable?.querySelectorAll("tbody.body tr") || []), n = t.length || 1, r = 0, i = 0, c = 0;
|
|
1054
|
+
for (let o = 0; o < a; o++) {
|
|
1055
|
+
let s = e[o], l = 0;
|
|
1056
|
+
for (let e = 0; e < n; e++) {
|
|
1057
|
+
let n = t[e];
|
|
1058
|
+
if (!n) continue;
|
|
1059
|
+
let r = n.getAttribute("grouping") === "true", i = !1;
|
|
1060
|
+
if (s.type === "group") {
|
|
1061
|
+
if (r) {
|
|
1062
|
+
let t = s.record[p.DEPTH];
|
|
1063
|
+
e === t && (i = !0);
|
|
1064
|
+
}
|
|
1065
|
+
} else r || (i = !0);
|
|
1066
|
+
if (i) {
|
|
1067
|
+
if (r) {
|
|
1068
|
+
let e = s.record[p.DEPTH];
|
|
1069
|
+
l += this.#n.template.group.heights[e];
|
|
1070
|
+
} else this.#n.template.height - this.#n.template.group.height, l += (this.#n.template.height - this.#n.template.group.height) / (this.#n.template.length - this.#n.template.group.length);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
s.type === "data" && (r === a && (c = i), r++), i += l;
|
|
1074
|
+
}
|
|
1075
|
+
r <= a && (c = i);
|
|
1076
|
+
let l = i > s, u = 1;
|
|
1077
|
+
l && (u = s / i), o = Math.max(0, c * u);
|
|
1019
1078
|
} else {
|
|
1020
|
-
let e = this.#n.template.height, 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,
|
|
1021
|
-
u && (d =
|
|
1079
|
+
let e = this.#n.template.height, 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, c = r.offsetHeight || 0, l = Math.max(i * e - e + n - c - e, 0), u = l > s, d = 1;
|
|
1080
|
+
u && (d = s / l), o = t * d;
|
|
1022
1081
|
}
|
|
1023
|
-
this.#
|
|
1082
|
+
this.#l = !0, r.scrollTop = o, this.#d(o), requestAnimationFrame(() => {
|
|
1024
1083
|
requestAnimationFrame(() => {
|
|
1025
|
-
this.#
|
|
1084
|
+
this.#l = !1, typeof n == "function" && n();
|
|
1026
1085
|
});
|
|
1027
1086
|
});
|
|
1028
1087
|
}
|
|
1029
1088
|
destroy = () => {
|
|
1030
|
-
this.#
|
|
1031
|
-
};
|
|
1032
|
-
#m = () => {
|
|
1033
|
-
this.#h();
|
|
1089
|
+
this.#o &&= (this.#o.disconnect(), null);
|
|
1034
1090
|
};
|
|
1035
1091
|
#h = () => {
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1092
|
+
this.#g();
|
|
1093
|
+
};
|
|
1094
|
+
#g = () => {
|
|
1095
|
+
if (this.#n.viewport.innerHeight > 0 && this.#n.template.height > 0) {
|
|
1096
|
+
let e = Math.ceil(this.#n.viewport.innerHeight / (this.#n.template.height - this.#n.template.group.height)), t = this.#e;
|
|
1097
|
+
if (this.#u) {
|
|
1098
|
+
let e = Math.ceil(this.#n.viewport.innerHeight / this.#n.template.group.height) + this.#e;
|
|
1099
|
+
t += this.#n.viewport.group.length * e;
|
|
1041
1100
|
}
|
|
1042
|
-
this.#
|
|
1101
|
+
this.#c = e + t;
|
|
1043
1102
|
}
|
|
1044
1103
|
};
|
|
1045
|
-
#
|
|
1104
|
+
#_ = () => {
|
|
1046
1105
|
[
|
|
1047
1106
|
".ng-container-body",
|
|
1048
1107
|
".ng-container-left",
|
|
1049
1108
|
".ng-container-right"
|
|
1050
1109
|
].forEach((e) => {
|
|
1051
1110
|
let t = this.#n.querySelector(`.ng-sheet-body ${e}`);
|
|
1052
|
-
t && t.querySelector("tbody") && this.#
|
|
1053
|
-
}), this.#
|
|
1111
|
+
t && t.querySelector("tbody") && this.#v(t);
|
|
1112
|
+
}), this.#y();
|
|
1054
1113
|
};
|
|
1055
|
-
#
|
|
1114
|
+
#v = (e) => {
|
|
1056
1115
|
let t = null;
|
|
1057
1116
|
e.classList.contains("ng-container-left") ? t = "left" : e.classList.contains("ng-container-right") && (t = "right");
|
|
1058
1117
|
let n = Array.from(this.#n.sourceTable.querySelectorAll("tbody.body tr")).map((e) => {
|
|
@@ -1069,10 +1128,19 @@ var m = {
|
|
|
1069
1128
|
let r = e.querySelector("tbody.body");
|
|
1070
1129
|
r.querySelectorAll("tr").forEach((e) => e.remove());
|
|
1071
1130
|
let i = document.createDocumentFragment();
|
|
1072
|
-
for (let e = 0; e < this.#
|
|
1073
|
-
r.appendChild(i)
|
|
1131
|
+
for (let e = 0; e < this.#c; e++) n.forEach((e) => i.appendChild(e.cloneNode(!0)));
|
|
1132
|
+
r.appendChild(i);
|
|
1133
|
+
let a = document.createDocumentFragment(), o = 0, s = n.filter((e) => e.getAttribute("grouping") === "true").length;
|
|
1134
|
+
n.forEach((e) => {
|
|
1135
|
+
if (e.getAttribute("grouping") === "true") {
|
|
1136
|
+
let t = e.cloneNode(!0);
|
|
1137
|
+
t.style.position = "relative", t.style.zIndex = (s - o) * 10, a.appendChild(t), o++;
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
let c = e.querySelector("thead.foot");
|
|
1141
|
+
c && (c.querySelectorAll("tr").forEach((e) => e.remove()), c.appendChild(a)), e.classList.contains("ng-container-body") && (this.#r.firstTr = r.querySelector("tr")), r.trs = Array.from(e.querySelectorAll("tbody.body tr"));
|
|
1074
1142
|
};
|
|
1075
|
-
#
|
|
1143
|
+
#y = () => {
|
|
1076
1144
|
let e = this.#n.querySelector(".ng-sheet-body .ng-container-left table"), t = this.#n.querySelector(".ng-sheet-body .ng-container-body table"), n = this.#n.querySelector(".ng-sheet-body .ng-container-right table");
|
|
1077
1145
|
if (t) {
|
|
1078
1146
|
let r = e ? Array.from(e.querySelectorAll("tbody tr")) : [], i = Array.from(t.querySelectorAll("tbody tr")), a = n ? Array.from(n.querySelectorAll("tbody tr")) : [], o = Math.max(r.length, i.length, a.length);
|
|
@@ -1086,14 +1154,14 @@ var m = {
|
|
|
1086
1154
|
}
|
|
1087
1155
|
}
|
|
1088
1156
|
};
|
|
1089
|
-
#
|
|
1090
|
-
this.#n && this.#n instanceof HTMLElement && (this.#
|
|
1157
|
+
#b = () => {
|
|
1158
|
+
this.#n && this.#n instanceof HTMLElement && (this.#o = new ResizeObserver((e) => {
|
|
1091
1159
|
for (let t of e) {
|
|
1092
1160
|
if (!t.target.classList.contains("active")) continue;
|
|
1093
1161
|
let e = t.contentRect.height;
|
|
1094
|
-
t.contentRect.width > 0 && this.#n.isAutoFitCol && this.#n.autoFit(!0), e > 0 && this.#
|
|
1162
|
+
t.contentRect.width > 0 && this.#n.isAutoFitCol && this.#n.autoFit(!0), e > 0 && this.#s !== e && (this.#s = e, this.#g(), this.#n.template.height !== null && (this.#_(), this.refresh()));
|
|
1095
1163
|
}
|
|
1096
|
-
}), this.#
|
|
1164
|
+
}), this.#o.observe(this.#n));
|
|
1097
1165
|
};
|
|
1098
1166
|
}, v = class e {
|
|
1099
1167
|
static compile(t) {
|
|
@@ -1150,11 +1218,11 @@ var m = {
|
|
|
1150
1218
|
subRowIndex: -1,
|
|
1151
1219
|
matrixRow: -1
|
|
1152
1220
|
};
|
|
1153
|
-
let n = e.closest("tbody")
|
|
1221
|
+
let n = e.closest("tbody");
|
|
1154
1222
|
return {
|
|
1155
1223
|
dataRow: t,
|
|
1156
|
-
subRowIndex:
|
|
1157
|
-
matrixRow:
|
|
1224
|
+
subRowIndex: Array.from(n.querySelectorAll("tr")).filter((e) => parseInt(e.dataset.index, 10) === t).indexOf(e),
|
|
1225
|
+
matrixRow: parseInt(e.dataset.matrixRow, 10)
|
|
1158
1226
|
};
|
|
1159
1227
|
}
|
|
1160
1228
|
setFocus(e, t) {
|
|
@@ -1284,7 +1352,7 @@ var m = {
|
|
|
1284
1352
|
#n = null;
|
|
1285
1353
|
#r = null;
|
|
1286
1354
|
constructor(e) {
|
|
1287
|
-
this.#e = e, this.#t = e.getRootNode().host, this.#
|
|
1355
|
+
this.#e = e, this.#t = e.getRootNode().host, this.#h();
|
|
1288
1356
|
}
|
|
1289
1357
|
get currentCell() {
|
|
1290
1358
|
return this.#n;
|
|
@@ -1326,8 +1394,6 @@ var m = {
|
|
|
1326
1394
|
let n = !1;
|
|
1327
1395
|
switch (e.code) {
|
|
1328
1396
|
case "Enter":
|
|
1329
|
-
e.shiftKey, this.#f(t) && (n = !0);
|
|
1330
|
-
break;
|
|
1331
1397
|
case "ArrowDown":
|
|
1332
1398
|
this.#f(t) && (n = !0);
|
|
1333
1399
|
break;
|
|
@@ -1338,32 +1404,26 @@ var m = {
|
|
|
1338
1404
|
return;
|
|
1339
1405
|
}
|
|
1340
1406
|
}
|
|
1341
|
-
let n =
|
|
1407
|
+
let n = this.#e.querySelector(".ng-sheet-body");
|
|
1408
|
+
if (!n) return;
|
|
1409
|
+
let r = t || this.#n;
|
|
1410
|
+
if (!r) return;
|
|
1411
|
+
let i = n.getBoundingClientRect(), a = r.getBoundingClientRect(), o = n.querySelector("thead")?.offsetHeight || 0, s = 0;
|
|
1342
1412
|
switch (e.code) {
|
|
1343
1413
|
case "Enter":
|
|
1344
|
-
if (e.shiftKey) {
|
|
1345
|
-
let e = this.#h();
|
|
1346
|
-
r = Math.max(n - e + 0, 0);
|
|
1347
|
-
} else r = Math.min(n, this.#e.view.count());
|
|
1348
|
-
break;
|
|
1349
|
-
case "ArrowDown":
|
|
1350
|
-
r = Math.min(n, this.#e.view.count());
|
|
1351
|
-
break;
|
|
1352
|
-
case "ArrowUp":
|
|
1353
|
-
let t = this.#h();
|
|
1354
|
-
r = Math.max(n - t + 0, 0);
|
|
1355
|
-
}
|
|
1356
|
-
if (r < 0) return;
|
|
1357
|
-
let i = parseInt(this.#r.dataset.matrixRow, 10), a = parseInt(this.#n.dataset.col, 10), o = parseInt(this.#n.rowSpan, 10) || 1;
|
|
1358
|
-
switch (e.code) {
|
|
1359
1414
|
case "ArrowDown":
|
|
1360
|
-
i
|
|
1415
|
+
s = a.top - a.height - (i.top + o);
|
|
1361
1416
|
break;
|
|
1362
|
-
case "ArrowUp": i
|
|
1417
|
+
case "ArrowUp": s = a.bottom + a.height - i.bottom;
|
|
1363
1418
|
}
|
|
1364
|
-
this.#
|
|
1365
|
-
|
|
1366
|
-
e
|
|
1419
|
+
let c = parseInt(t ? t.closest("tr")?.dataset.matrixRow : this.#r.dataset.matrixRow, 10), l = parseInt(t ? t.dataset.col : this.#n.dataset.col, 10);
|
|
1420
|
+
s !== 0 && (n.scrollTop += s), setTimeout(() => {
|
|
1421
|
+
let e = this.#c(c, l);
|
|
1422
|
+
if (e) {
|
|
1423
|
+
this.currentCell = e;
|
|
1424
|
+
let t = e.closest("tr");
|
|
1425
|
+
t && this.#e.selection.setRange(t.dataset.matrixRow, e.dataset.col, t.dataset.matrixRow, e.dataset.col);
|
|
1426
|
+
}
|
|
1367
1427
|
});
|
|
1368
1428
|
};
|
|
1369
1429
|
moveCell = (e) => {
|
|
@@ -1430,12 +1490,14 @@ var m = {
|
|
|
1430
1490
|
}))), i;
|
|
1431
1491
|
};
|
|
1432
1492
|
#l = () => {
|
|
1433
|
-
let e = parseInt(this.#n.dataset.col, 10), t = parseInt(this.#r.dataset.matrixRow, 10);
|
|
1434
|
-
|
|
1493
|
+
let e = parseInt(this.#n.dataset.col, 10), t = parseInt(this.#r.dataset.matrixRow, 10), n = null;
|
|
1494
|
+
for (let r = 0; r < 100 && (n = this.#c(t - 1 - r, e), !n); r++);
|
|
1495
|
+
return n;
|
|
1435
1496
|
};
|
|
1436
1497
|
#u = () => {
|
|
1437
|
-
let e = parseInt(this.#n.dataset.col, 10), t = parseInt(this.#r.dataset.matrixRow, 10), n = parseInt(this.#n.rowSpan, 10) || 1;
|
|
1438
|
-
|
|
1498
|
+
let e = parseInt(this.#n.dataset.col, 10), t = parseInt(this.#r.dataset.matrixRow, 10), n = parseInt(this.#n.rowSpan, 10) || 1, r = null;
|
|
1499
|
+
for (let i = 0; i < 100 && (r = this.#c(t + n + i, e), !r); i++);
|
|
1500
|
+
return r;
|
|
1439
1501
|
};
|
|
1440
1502
|
#d = (e) => {
|
|
1441
1503
|
let t = this.#e.querySelector(".ng-sheet-body");
|
|
@@ -1461,11 +1523,7 @@ var m = {
|
|
|
1461
1523
|
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
1462
1524
|
return n.right <= r.right;
|
|
1463
1525
|
};
|
|
1464
|
-
#h
|
|
1465
|
-
let e = this.#e.querySelector(".ng-sheet-body"), t = e.clientHeight - (e.querySelector("thead")?.offsetHeight || 0), n = this.#e.rowManager.getRowHeight();
|
|
1466
|
-
return Math.max(1, Math.floor(t / n));
|
|
1467
|
-
};
|
|
1468
|
-
#g() {
|
|
1526
|
+
#h() {
|
|
1469
1527
|
this.#e.addEventListener("mousedown", (e) => {
|
|
1470
1528
|
if (e.button !== 0) return;
|
|
1471
1529
|
let t = e.target.closest("td, th");
|
|
@@ -1538,10 +1596,10 @@ var m = {
|
|
|
1538
1596
|
if (r = Array.from(this.#e.querySelectorAll(`table colgroup col[data-col="${e}"]`)), r.length === 0) return;
|
|
1539
1597
|
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");
|
|
1540
1598
|
r.forEach((e) => {
|
|
1541
|
-
e.setAttribute("width", t), e.style.width = `${t}px`;
|
|
1599
|
+
e.setAttribute("width", t), e.style.width = e.style.minWidth = e.style.maxWidth = `${t}px`;
|
|
1542
1600
|
});
|
|
1543
1601
|
let o = this.#e.sourceTable?.querySelector(`colgroup col[data-col="${e}"]`);
|
|
1544
|
-
o && (o.setAttribute("width", t), o.style.width = `${t}px`), this.refreshLayout(a), (a === "left" || a === "right") && this.refreshLayout("body"), this.#e.rowManager?.refresh();
|
|
1602
|
+
o && (o.setAttribute("width", t), o.style.width = o.style.minWidth = o.style.maxWidth = `${t}px`), this.refreshLayout(a), (a === "left" || a === "right") && this.refreshLayout("body"), this.#e.rowManager?.refresh();
|
|
1545
1603
|
}
|
|
1546
1604
|
#p(e) {
|
|
1547
1605
|
if (this.#e.isAutoFitCol) return !0;
|
|
@@ -2318,7 +2376,7 @@ var k = class {
|
|
|
2318
2376
|
if (e < 0 || e >= n.length) return null;
|
|
2319
2377
|
let r = n[e];
|
|
2320
2378
|
if (t != null) {
|
|
2321
|
-
let e = this.#t.
|
|
2379
|
+
let e = this.#t.fields.get().indexOf(t);
|
|
2322
2380
|
return e >= 0 && r.v ? r.v[e] : null;
|
|
2323
2381
|
}
|
|
2324
2382
|
return r;
|
|
@@ -2357,10 +2415,10 @@ var k = class {
|
|
|
2357
2415
|
let i = e.m?._?.[r.META.INDEX.FILTER];
|
|
2358
2416
|
i && i[this.#e.index] === !1 || t.push(n);
|
|
2359
2417
|
}), this.#n.length > 0 && (t = this.#o(t, e)), this.#r = t;
|
|
2360
|
-
let n = t.map((t) => e[t]), i = this.#e.grouping?.columns || [];
|
|
2361
|
-
if (
|
|
2362
|
-
let e =
|
|
2363
|
-
this.#i =
|
|
2418
|
+
let n = t.map((t) => e[t]), i = this.#e.grouping, a = i?.columns || [];
|
|
2419
|
+
if (a.length > 0) {
|
|
2420
|
+
let e = i.collapsedMap || /* @__PURE__ */ new Map(), t = h.apply(n, a, this.#t.data.getHostFields(), e);
|
|
2421
|
+
this.#i = t.renderItems, i.setGroupMap(t.groupMap);
|
|
2364
2422
|
} else this.#i = n;
|
|
2365
2423
|
};
|
|
2366
2424
|
setSorting = (e) => {
|
|
@@ -2463,13 +2521,16 @@ var k = class {
|
|
|
2463
2521
|
let n = e.getAttribute("width") || parseInt(e.style.width, 10) || r;
|
|
2464
2522
|
e.setAttribute("width", n);
|
|
2465
2523
|
let i = String(n).includes("px") ? n : `${n}px`;
|
|
2466
|
-
e.style.width = i;
|
|
2524
|
+
e.style.width = e.style.minWidth = e.style.maxWidth = i;
|
|
2467
2525
|
});
|
|
2468
2526
|
}
|
|
2469
2527
|
static #a(e) {
|
|
2470
|
-
|
|
2471
|
-
|
|
2528
|
+
let t = e.querySelector("thead:not(.foot)");
|
|
2529
|
+
t ||= document.createElement("thead");
|
|
2530
|
+
let n = e.querySelector("colgroup");
|
|
2472
2531
|
n ? n.after(t) : e.prepend(t);
|
|
2532
|
+
let r = e.querySelector("thead.foot");
|
|
2533
|
+
r || (r = document.createElement("thead"), r.classList.add("foot"), t.after(r));
|
|
2473
2534
|
}
|
|
2474
2535
|
static #o(e) {
|
|
2475
2536
|
e.querySelectorAll("thead th, thead td").forEach((e) => {
|
|
@@ -2496,8 +2557,8 @@ var k = class {
|
|
|
2496
2557
|
let i = `__ds_${Date.now()}_${++r}`;
|
|
2497
2558
|
e && (e[i] = () => n), t.setAttribute("data-source", `host.${i}()`), a.remove();
|
|
2498
2559
|
}
|
|
2499
|
-
let o = t.dataset.expr;
|
|
2500
|
-
|
|
2560
|
+
let o = t.closest("tr"), s = t.dataset.expr;
|
|
2561
|
+
s && t.setAttribute("data-expr", e.exprEngine.precompile(s, o.getAttribute("grouping") === "true")), Array.from(t.attributes).forEach((n) => {
|
|
2501
2562
|
[
|
|
2502
2563
|
"data-bind",
|
|
2503
2564
|
"data-expr",
|
|
@@ -2531,18 +2592,37 @@ var k = class {
|
|
|
2531
2592
|
let i = Math.max(10, Math.floor(16 / r));
|
|
2532
2593
|
if (!isNaN(n)) for (let t = 0; t < r; t++) {
|
|
2533
2594
|
let r = e.querySelector(`colgroup col[data-col="${n + t}"]`);
|
|
2534
|
-
r && (r.setAttribute("width", i), r.style.width = `${i}px`);
|
|
2595
|
+
r && (r.setAttribute("width", i), r.style.width = r.style.minWidth = r.style.maxWidth`${i}px`);
|
|
2535
2596
|
}
|
|
2536
2597
|
} else o.classList.remove("collapsed"), o.classList.add("expand"), o.setAttribute("collapsed", "false"), t.style.color = "";
|
|
2537
2598
|
});
|
|
2538
2599
|
}
|
|
2539
2600
|
static #u(e, t) {
|
|
2540
|
-
let n = e.getAttribute("row-indicator") === "true" ? 48 : 4, r = e.querySelector("colgroup")
|
|
2541
|
-
|
|
2601
|
+
let n = e.getAttribute("row-indicator") === "true" ? 48 : 4, r = e.querySelector("colgroup");
|
|
2602
|
+
if (r && !r.querySelector(".row-indicator-col")) {
|
|
2603
|
+
let e = document.createElement("col");
|
|
2604
|
+
e.className = "row-indicator-col", e.setAttribute("fixed", "left"), e.setAttribute("width", n), e.style.width = e.style.minWidth = e.style.maxWidth = `${n}px`, r.prepend(e);
|
|
2605
|
+
}
|
|
2606
|
+
e.querySelectorAll("thead, tbody, tfoot").forEach((e) => {
|
|
2542
2607
|
let t = Array.from(e.querySelectorAll("tr"));
|
|
2543
2608
|
if (t.length === 0) return;
|
|
2544
|
-
let n =
|
|
2545
|
-
|
|
2609
|
+
let n = [], r = null;
|
|
2610
|
+
t.forEach((e) => {
|
|
2611
|
+
e.classList.contains("col-indicator-rowgroup") || (e.getAttribute("grouping") === "true" ? (n.push({
|
|
2612
|
+
isGrouping: !0,
|
|
2613
|
+
rows: [e]
|
|
2614
|
+
}), r = null) : !r || r.isGrouping !== !1 ? (r = {
|
|
2615
|
+
isGrouping: !1,
|
|
2616
|
+
rows: [e]
|
|
2617
|
+
}, n.push(r)) : r.rows.push(e));
|
|
2618
|
+
}), n.forEach((e) => {
|
|
2619
|
+
let t = e.rows;
|
|
2620
|
+
if (t.length === 0) return;
|
|
2621
|
+
let n = t[0];
|
|
2622
|
+
if (n.querySelector(":scope > th.row-indicator")) return;
|
|
2623
|
+
let r = document.createElement("th");
|
|
2624
|
+
r.className = "row-indicator", r.setAttribute("cell-type", "row-indicator"), !e.isGrouping && t.length > 1 && (r.rowSpan = t.length), n.insertBefore(r, n.firstElementChild);
|
|
2625
|
+
});
|
|
2546
2626
|
});
|
|
2547
2627
|
}
|
|
2548
2628
|
static #d(e) {
|
|
@@ -2554,15 +2634,75 @@ var k = class {
|
|
|
2554
2634
|
let r = n + t, a = e.querySelector(`colgroup col[data-col="${r}"]`);
|
|
2555
2635
|
a && (i += parseInt(a.getAttribute("width"), 10) || 100);
|
|
2556
2636
|
}
|
|
2557
|
-
i > 0 && `${i}`;
|
|
2558
2637
|
});
|
|
2559
2638
|
}
|
|
2560
2639
|
}, M = class {
|
|
2561
2640
|
#e;
|
|
2562
2641
|
#t;
|
|
2642
|
+
#n;
|
|
2563
2643
|
constructor(e) {
|
|
2564
2644
|
this.#e = e, this.#t = e.getRootNode().host;
|
|
2565
2645
|
}
|
|
2646
|
+
#r = () => {
|
|
2647
|
+
this.#n = {
|
|
2648
|
+
viewport: this.#e.querySelector(".ng-sheet-body"),
|
|
2649
|
+
thead: this.#e.querySelector("thead"),
|
|
2650
|
+
tbody: this.#e.querySelector("tbody.body"),
|
|
2651
|
+
tfoot: this.#e.querySelector("tfoot"),
|
|
2652
|
+
thead_foot: this.#e.querySelector("thead.foot"),
|
|
2653
|
+
tbody_head: this.#e.querySelector("tbody.head"),
|
|
2654
|
+
tbody_foot: this.#e.querySelector("tbody.foot")
|
|
2655
|
+
};
|
|
2656
|
+
};
|
|
2657
|
+
get elem() {
|
|
2658
|
+
return this.#n?.tbody_foot || (this.#n = {
|
|
2659
|
+
viewport: this.#e.querySelector(".ng-sheet-body"),
|
|
2660
|
+
thead: this.#e.querySelector("thead"),
|
|
2661
|
+
tbody: this.#e.querySelector("tbody.body"),
|
|
2662
|
+
tfoot: this.#e.querySelector("tfoot"),
|
|
2663
|
+
thead_foot: this.#e.querySelector("thead.foot"),
|
|
2664
|
+
tbody_head: this.#e.querySelector("tbody.head"),
|
|
2665
|
+
tbody_foot: this.#e.querySelector("tbody.foot")
|
|
2666
|
+
}), this.#n;
|
|
2667
|
+
}
|
|
2668
|
+
get viewport() {
|
|
2669
|
+
let e = this;
|
|
2670
|
+
return {
|
|
2671
|
+
get tr() {
|
|
2672
|
+
return {
|
|
2673
|
+
get length() {
|
|
2674
|
+
return Math.ceil(e.#e.querySelector(".ng-container-body tbody.body tr:last-child").sectionRowIndex / e.#e.template.length);
|
|
2675
|
+
},
|
|
2676
|
+
count() {
|
|
2677
|
+
return this.length;
|
|
2678
|
+
}
|
|
2679
|
+
};
|
|
2680
|
+
},
|
|
2681
|
+
get group() {
|
|
2682
|
+
return {
|
|
2683
|
+
get length() {
|
|
2684
|
+
return e.#e.source.table.querySelectorAll("tbody tr[grouping='true']").length;
|
|
2685
|
+
},
|
|
2686
|
+
count() {
|
|
2687
|
+
return this.length;
|
|
2688
|
+
}
|
|
2689
|
+
};
|
|
2690
|
+
},
|
|
2691
|
+
get fixedHeight() {
|
|
2692
|
+
let t = () => (e.elem.thead?.offsetHeight || 0) + (e.elem.thead_foot?.offsetHeight || 0) + (e.elem.tfoot?.offsetHeight || 0) + (e.elem.tbody_head?.offsetHeight || 0), n = t();
|
|
2693
|
+
return n === 0 && (e.#r(), n = t()), n;
|
|
2694
|
+
},
|
|
2695
|
+
get height() {
|
|
2696
|
+
return e.elem.viewport.offsetHeight;
|
|
2697
|
+
},
|
|
2698
|
+
get innerHeight() {
|
|
2699
|
+
return e.elem.viewport.clientHeight - this.fixedHeight;
|
|
2700
|
+
},
|
|
2701
|
+
get outerHeight() {
|
|
2702
|
+
return e.elem.viewport.offsetHeight;
|
|
2703
|
+
}
|
|
2704
|
+
};
|
|
2705
|
+
}
|
|
2566
2706
|
col = {
|
|
2567
2707
|
setWidth: (e, t, n = null) => {
|
|
2568
2708
|
Array.from(this.#e.querySelectorAll(`table colgroup col[data-col="${e}"]`)).forEach((e) => {
|
|
@@ -2657,7 +2797,12 @@ var k = class {
|
|
|
2657
2797
|
#h = {
|
|
2658
2798
|
length: 0,
|
|
2659
2799
|
height: 0,
|
|
2660
|
-
heights: []
|
|
2800
|
+
heights: [],
|
|
2801
|
+
group: {
|
|
2802
|
+
length: 0,
|
|
2803
|
+
height: 0,
|
|
2804
|
+
heights: []
|
|
2805
|
+
}
|
|
2661
2806
|
};
|
|
2662
2807
|
static SCROLLBAR_SIZE = 16;
|
|
2663
2808
|
constructor() {
|
|
@@ -2743,7 +2888,7 @@ var k = class {
|
|
|
2743
2888
|
}
|
|
2744
2889
|
#_ = () => {
|
|
2745
2890
|
let e = this.querySelector(".ng-container-body thead"), t = this.querySelector(".nodata-overlay");
|
|
2746
|
-
t.style.top = `${e?.offsetHeight}px
|
|
2891
|
+
t && (t.style.top = `${e?.offsetHeight}px`);
|
|
2747
2892
|
};
|
|
2748
2893
|
get view() {
|
|
2749
2894
|
return !this.#f && this.#t?.data && (this.#f = new A(this)), this.#f;
|
|
@@ -2825,9 +2970,22 @@ var k = class {
|
|
|
2825
2970
|
if (n(!0), this.#e = t, this.#p = {
|
|
2826
2971
|
table: v.compile(e),
|
|
2827
2972
|
tbody: { tr: e.querySelectorAll("tbody tr") }
|
|
2828
|
-
}, this.querySelector(".ng-container-body").appendChild(this.#p.table), this.#h
|
|
2829
|
-
|
|
2830
|
-
|
|
2973
|
+
}, this.querySelector(".ng-container-body").appendChild(this.#p.table), this.#h = {
|
|
2974
|
+
height: 0,
|
|
2975
|
+
heights: [],
|
|
2976
|
+
length: 0,
|
|
2977
|
+
group: {
|
|
2978
|
+
height: 0,
|
|
2979
|
+
heights: [],
|
|
2980
|
+
length: 0
|
|
2981
|
+
}
|
|
2982
|
+
}, this.querySelectorAll(".ng-container-body tbody.body tr").forEach((e) => {
|
|
2983
|
+
let t = Math.max(e.offsetHeight || 0, 28);
|
|
2984
|
+
this.#h.height += t, this.#h.heights.push(t);
|
|
2985
|
+
}), this.querySelectorAll(".ng-container-body tbody.body tr[grouping=\"true\"]").forEach((e) => {
|
|
2986
|
+
let t = Math.max(e.offsetHeight || 0, 28);
|
|
2987
|
+
this.#h.group.height += t, this.#h.group.heights.push(t);
|
|
2988
|
+
}), this.#h.length = this.#h.heights.length, this.#h.group.length = this.#h.group.heights.length, this.#e === 0) {
|
|
2831
2989
|
let e = parseInt(this.#t.getAttribute("display-min-rows"), 10), t = parseInt(this.#t.getAttribute("display-max-rows"), 10), n = (this.querySelector("nine-table-toolbar")?.offsetHeight || 0) + (this.querySelector("nine-table-footer")?.offsetHeight || 0) + (this.querySelector("thead")?.offsetHeight || 0) + (this.querySelector("tfoot")?.offsetHeight || 0) + (this.querySelector("tbody.head")?.offsetHeight || 0);
|
|
2832
2990
|
this.#t.getAttribute("auto-height") !== "true" && isNaN(e) && isNaN(t) || this.#t.setAttribute("scroll-bar", "none"), isNaN(e) || (this.#t.style.minHeight = n + this.#h.height * e + "px"), isNaN(t) || (this.#t.style.maxHeight = n + this.#h.height * t + "px");
|
|
2833
2991
|
}
|
|
@@ -2915,7 +3073,7 @@ var k = class {
|
|
|
2915
3073
|
t && (t.scrollTop = e);
|
|
2916
3074
|
};
|
|
2917
3075
|
#S = () => {
|
|
2918
|
-
this.#C(), this.#r = new y(this), this.#i = new b(this), this.#a = new S(this), this.#o = new w(this), this.#s = new T(this), this.#f = new A(this), this.#l = new O(this), this.#u = new
|
|
3076
|
+
this.#C(), this.#r = new y(this), this.#i = new b(this), this.#a = new S(this), this.#o = new w(this), this.#s = new T(this), this.#f = new A(this), this.#l = new O(this), this.#u = new m(this), this.#g || (this.#c = new k(this)), this.#m.mainBody.addEventListener("scroll", (e) => {
|
|
2919
3077
|
this.querySelectorAll("nine-table-filter-panel,cell-combo-panel").forEach((e) => {
|
|
2920
3078
|
e.classList.remove("active");
|
|
2921
3079
|
}), this.querySelector("nine-table-hscrollbar").refresh();
|
|
@@ -2996,10 +3154,14 @@ var P = class {
|
|
|
2996
3154
|
e ? this.#e.classList.add("loading") : this.#e.classList.remove("loading");
|
|
2997
3155
|
}
|
|
2998
3156
|
#n = () => {
|
|
2999
|
-
let e = Array.from(this.#e.children).filter((e) => e.tagName.toUpperCase() === "TABLE"), t = e.length
|
|
3157
|
+
let e = Array.from(this.#e.children).filter((e) => e.tagName.toUpperCase() === "TABLE"), t = e.length;
|
|
3158
|
+
e.forEach((e) => {
|
|
3159
|
+
j.initializeTable(this.#e, e);
|
|
3160
|
+
});
|
|
3161
|
+
let n = e.map((e, n) => {
|
|
3000
3162
|
let r = n === 0 ? "active" : "", i = e.id || `sheet${n + 1}`;
|
|
3001
3163
|
return `<nine-table-sheet class="${r}" data-index="${n}" data-sheet-id="${i}" id="${i}"></nine-table-sheet>` + (n < t - 1 ? `<nine-splitter class="h" data-split-index="${n}"></nine-splitter>` : "");
|
|
3002
|
-
}).join(""), r = ["@import \"https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.1
|
|
3164
|
+
}).join(""), r = ["@import \"https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.2.1/dist/css/nine-table.css\";"];
|
|
3003
3165
|
nine["nine-table"] && nine["nine-table"].cssFile && r.push(`@import "${nine["nine-table"].cssFile}";`), this.#e.shadowRoot.innerHTML = `
|
|
3004
3166
|
<style>
|
|
3005
3167
|
${r.join("\n")}
|
|
@@ -3020,9 +3182,7 @@ var P = class {
|
|
|
3020
3182
|
<nine-table-analysis></nine-table-analysis>
|
|
3021
3183
|
</nine-table-body>
|
|
3022
3184
|
<nine-table-footer></nine-table-footer>
|
|
3023
|
-
`, e.forEach((
|
|
3024
|
-
j.initializeTable(this.#e, e);
|
|
3025
|
-
}), this.#e.shadowRoot.querySelectorAll("nine-table-sheet").forEach((t, n) => {
|
|
3185
|
+
`, this.#e.shadowRoot.querySelectorAll("nine-table-sheet").forEach((t, n) => {
|
|
3026
3186
|
t.classList.add("active"), t.generateTemplate(e[n], n);
|
|
3027
3187
|
}), this.#e.shadowRoot.querySelectorAll("nine-table-sheet").forEach((e) => {
|
|
3028
3188
|
setTimeout(() => {
|
|
@@ -3070,24 +3230,59 @@ var P = class {
|
|
|
3070
3230
|
return n >= 0 ? `rowItem.v[${n}]` : e;
|
|
3071
3231
|
});
|
|
3072
3232
|
}
|
|
3073
|
-
|
|
3074
|
-
return e
|
|
3233
|
+
rewriteExprGroup(e) {
|
|
3234
|
+
return e;
|
|
3075
3235
|
}
|
|
3076
|
-
|
|
3236
|
+
precompile(e, t) {
|
|
3237
|
+
return e && (t ? this.rewriteExprGroup(e) : this.rewriteExpr(e));
|
|
3238
|
+
}
|
|
3239
|
+
evaluate(e, t, n = 0, r = !1) {
|
|
3077
3240
|
if (e == null) return "";
|
|
3078
3241
|
try {
|
|
3079
|
-
let
|
|
3080
|
-
if (
|
|
3081
|
-
let e = this.#n.get(
|
|
3082
|
-
return e || (e = Function("
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3242
|
+
let i = String(e).trim(), a = r ? this.rewriteExprGroup(i) : this.rewriteExpr(i);
|
|
3243
|
+
if (a.includes("provider.") || a.includes("host.") || a.includes("data.") || a.includes("rowItem.v") || a.includes("(")) {
|
|
3244
|
+
let e = this.#n.get(a);
|
|
3245
|
+
return r ? e || (e = Function("childrenItems", "row", "host", `
|
|
3246
|
+
const children = childrenItems || [];
|
|
3247
|
+
const fields = ${JSON.stringify(this.#t)};
|
|
3248
|
+
|
|
3249
|
+
const data = new Proxy(children, {
|
|
3250
|
+
get(target, prop) {
|
|
3251
|
+
if (prop in target || typeof prop === 'symbol') return target[prop];
|
|
3252
|
+
|
|
3253
|
+
const idx = fields.indexOf(prop);
|
|
3254
|
+
if (idx >= 0) {
|
|
3255
|
+
return target.map(r => r.v ? r.v[idx] : r[prop]);
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3258
|
+
return target[prop];
|
|
3259
|
+
}
|
|
3260
|
+
});
|
|
3261
|
+
|
|
3262
|
+
const provider = host;
|
|
3263
|
+
|
|
3264
|
+
// 💡 1. 수식 안에서 바로 쓸 수 있는 집계 함수들 선언
|
|
3265
|
+
|
|
3266
|
+
const sum = (arr) => Array.isArray(arr) ? arr.reduce((a, b) => a + (Number(b) || 0), 0) : 0;
|
|
3267
|
+
const avg = (arr) => Array.isArray(arr) && arr.length > 0 ? sum(arr) / arr.length : 0;
|
|
3268
|
+
const max = (arr) => Array.isArray(arr) && arr.length > 0 ? Math.max(...arr.map(Number)) : 0;
|
|
3269
|
+
const min = (arr) => Array.isArray(arr) && arr.length > 0 ? Math.min(...arr.map(Number)) : 0;
|
|
3270
|
+
|
|
3271
|
+
// 만약 꼭 'Math.sum' 형태로 쓰고 싶다면 아래처럼 Math 객체에 잠시 붙여줄 수도 있습니다.
|
|
3272
|
+
if (!Math.sum) Math.sum = sum;
|
|
3273
|
+
if (!Math.avg) Math.avg = avg;
|
|
3274
|
+
|
|
3275
|
+
if (!data && !host) return "";
|
|
3276
|
+
return ${a};
|
|
3277
|
+
`), this.#n.set(a, e)) : e || (e = Function("rowItem", "row", "host", `
|
|
3278
|
+
const data = rowItem;
|
|
3279
|
+
const provider = host;
|
|
3280
|
+
|
|
3281
|
+
if (!data && !host) return "";
|
|
3282
|
+
return ${a};
|
|
3283
|
+
`), this.#n.set(a, e)), e(t, n, this.#e);
|
|
3089
3284
|
}
|
|
3090
|
-
return
|
|
3285
|
+
return a;
|
|
3091
3286
|
} catch {
|
|
3092
3287
|
return e;
|
|
3093
3288
|
}
|
|
@@ -3112,7 +3307,11 @@ var P = class {
|
|
|
3112
3307
|
}, L = class {
|
|
3113
3308
|
#e;
|
|
3114
3309
|
constructor(e) {
|
|
3115
|
-
this.#e = e, [
|
|
3310
|
+
this.#e = e, [
|
|
3311
|
+
"col",
|
|
3312
|
+
"row",
|
|
3313
|
+
"viewport"
|
|
3314
|
+
].forEach((e) => {
|
|
3116
3315
|
this[e] = new Proxy({}, { get: (t, n) => {
|
|
3117
3316
|
let r = this.#t();
|
|
3118
3317
|
if (!r || !r[e]) return;
|
|
@@ -3136,7 +3335,7 @@ var P = class {
|
|
|
3136
3335
|
#i;
|
|
3137
3336
|
#a = 0;
|
|
3138
3337
|
constructor() {
|
|
3139
|
-
super(), ["NINE-TABLE"].includes(this.tagName) && n.log("Welcome nine-table", "0.1
|
|
3338
|
+
super(), ["NINE-TABLE"].includes(this.tagName) && n.log("Welcome nine-table", "0.2.1"), this.#e = this.attachShadow({ mode: "open" }), this.#t = new o(this), this.#r = new I(this), this.#i = new L(this), this.#c();
|
|
3140
3339
|
}
|
|
3141
3340
|
connectedCallback() {
|
|
3142
3341
|
setTimeout(() => {
|
|
@@ -3258,7 +3457,7 @@ var z = class extends HTMLElement {
|
|
|
3258
3457
|
super();
|
|
3259
3458
|
}
|
|
3260
3459
|
get #a() {
|
|
3261
|
-
return this.#r.getAttribute("update-row-state")
|
|
3460
|
+
return this.#r.getAttribute("update-row-state") !== "false";
|
|
3262
3461
|
}
|
|
3263
3462
|
get host() {
|
|
3264
3463
|
return this.#e;
|
|
@@ -3361,14 +3560,21 @@ var z = class extends HTMLElement {
|
|
|
3361
3560
|
return !this.isValid();
|
|
3362
3561
|
}
|
|
3363
3562
|
getDisplayText = (e = "") => {
|
|
3364
|
-
if (!this.#r || !this.#r.closest("tbody") || !this.#n.data) return e;
|
|
3563
|
+
if (!this.#r || !this.#r.closest("tbody") && !this.#r.closest("thead.foot") && !this.#r.closest("tfoot") || !this.#n.data) return e;
|
|
3365
3564
|
let t = this.#r.dataset.expr, n = this.#r.dataset.bind, r = parseInt(this.#r.dataset.row, 10);
|
|
3366
3565
|
if (t) try {
|
|
3367
|
-
return this.#
|
|
3566
|
+
return this.#e.exprEngine.evaluate(t, this.#n.data, r, this.#n.getAttribute("grouping") === "true");
|
|
3368
3567
|
} catch {
|
|
3369
3568
|
return e;
|
|
3370
3569
|
}
|
|
3371
|
-
|
|
3570
|
+
if (n) {
|
|
3571
|
+
if (this.#n.getAttribute("grouping") === "true") {
|
|
3572
|
+
let e = this.#e.fields.get().indexOf(n);
|
|
3573
|
+
return this.#n.data[0].v[e];
|
|
3574
|
+
}
|
|
3575
|
+
return this.value ?? e;
|
|
3576
|
+
}
|
|
3577
|
+
return e;
|
|
3372
3578
|
};
|
|
3373
3579
|
refresh() {
|
|
3374
3580
|
if (!this.#r || !this.#n) return;
|
|
@@ -3383,7 +3589,7 @@ var z = class extends HTMLElement {
|
|
|
3383
3589
|
].forEach((e) => {
|
|
3384
3590
|
let t = this.#i[e];
|
|
3385
3591
|
if (t) {
|
|
3386
|
-
let n = this.#e.exprEngine.evaluate(t, this.#n.data, parseInt(this.#r.dataset.row, 10));
|
|
3592
|
+
let n = this.#e.exprEngine.evaluate(t, this.#n.data, parseInt(this.#r.dataset.row, 10), this.#n.getAttribute("grouping") === "true");
|
|
3387
3593
|
e === "validator" ? n || this.#r.classList.add("invalid") : e === "visible" ? this.style.display = n ? "" : "none" : e === "enable" ? (this.querySelectorAll("input, button, textarea, select").forEach((e) => {
|
|
3388
3594
|
e.disabled = !n;
|
|
3389
3595
|
}), n ? this.#r.removeAttribute("disabled") : this.#r.setAttribute("disabled", "true")) : this.#r.style[e] = n;
|
|
@@ -3391,7 +3597,7 @@ var z = class extends HTMLElement {
|
|
|
3391
3597
|
}), e;
|
|
3392
3598
|
}
|
|
3393
3599
|
getExprValue(e, t, n) {
|
|
3394
|
-
return !this.#e || !this.#e.exprEngine || e == null || e === "" ? e : this.#e.exprEngine.evaluate(e, t, n);
|
|
3600
|
+
return !this.#e || !this.#e.exprEngine || e == null || e === "" ? e : this.#e.exprEngine.evaluate(e, t, n, this.#n.getAttribute("grouping") === "true");
|
|
3395
3601
|
}
|
|
3396
3602
|
getGroupExprValue = (e, t, n, r) => {
|
|
3397
3603
|
if (!e) return "";
|
|
@@ -3792,6 +3998,8 @@ var q = class extends H {
|
|
|
3792
3998
|
super.sheet.querySelector(`tbody.body [data-col="${super.cell.dataset.col}"] cell-checkbox`)?.selectAll(e.target.checked);
|
|
3793
3999
|
}), this.#e.addEventListener("change", (e) => {
|
|
3794
4000
|
this.closest("tbody") && (this.#s ? (this.selectAll(!1), this.value = this.trueValue) : this.value = e.target.checked ? this.trueValue : this.falseValue, this.sheet.rowManager.refresh(!0));
|
|
4001
|
+
}), this.cell.addEventListener("keydown", (e) => {
|
|
4002
|
+
this.cell.hasAttribute("readonly") || this.cell.classList.contains("readonly") || this.cell.getAttribute("disabled") !== "true" && this.style.display !== "none" && e.code === "Space" && (e.preventDefault(), this.value = this.#e.checked ? this.falseValue : this.trueValue, this.sheet.rowManager.refresh(!0));
|
|
3795
4003
|
});
|
|
3796
4004
|
};
|
|
3797
4005
|
#r = () => {
|
|
@@ -3856,7 +4064,7 @@ var J = class extends H {
|
|
|
3856
4064
|
}
|
|
3857
4065
|
#r = () => {
|
|
3858
4066
|
this.cell.addEventListener("keydown", (e) => {
|
|
3859
|
-
if (!(this.cell.hasAttribute("readonly") || this.cell.classList.contains("readonly")) && this.cell.getAttribute("disabled") !== "true" && e.code === "Space") {
|
|
4067
|
+
if (!(this.cell.hasAttribute("readonly") || this.cell.classList.contains("readonly")) && this.cell.getAttribute("disabled") !== "true" && this.style.display !== "none" && e.code === "Space") {
|
|
3860
4068
|
e.preventDefault();
|
|
3861
4069
|
let t = -1;
|
|
3862
4070
|
this.#t.forEach((e, n) => {
|
|
@@ -4214,8 +4422,45 @@ var Q = class extends V {
|
|
|
4214
4422
|
};
|
|
4215
4423
|
};
|
|
4216
4424
|
customElements.get("cell-button") || customElements.define("cell-button", Q);
|
|
4217
|
-
// src/cell/cell-
|
|
4425
|
+
// src/cell/cell-tree.js
|
|
4218
4426
|
var $ = class extends V {
|
|
4427
|
+
#e;
|
|
4428
|
+
#t;
|
|
4429
|
+
constructor() {
|
|
4430
|
+
super();
|
|
4431
|
+
}
|
|
4432
|
+
connectedCallback() {
|
|
4433
|
+
super.connectedCallback(), this.#i();
|
|
4434
|
+
}
|
|
4435
|
+
refresh() {
|
|
4436
|
+
if (this.tr.style.display === "none") return;
|
|
4437
|
+
let e = this.tr.dataset.groupId, t = this.data;
|
|
4438
|
+
if (!t) return;
|
|
4439
|
+
let n = e ? e?.split("_").length - 2 : this.sheet.grouping.columns.length;
|
|
4440
|
+
this.style.setProperty("--tree-level", n), this.#t.textContent = this.getDisplayText(), this.#n(t);
|
|
4441
|
+
}
|
|
4442
|
+
#n(e) {
|
|
4443
|
+
let t = this.#r(e), n = this.sheet.grouping.isCollapsed(this.tr.dataset.groupId);
|
|
4444
|
+
this.#e.className = "icon", this.#e.classList.remove("expand-on,expand-off"), t ? this.#e.classList.add(n ? "expand-off" : "expand-on") : this.#e.classList.add("node");
|
|
4445
|
+
}
|
|
4446
|
+
#r(e) {
|
|
4447
|
+
return this.tr.data.length > 0;
|
|
4448
|
+
}
|
|
4449
|
+
#i = () => {
|
|
4450
|
+
this.#a(), this.#o();
|
|
4451
|
+
};
|
|
4452
|
+
#a = () => {
|
|
4453
|
+
this.innerHTML = "\n <div class=\"item\">\n <div class=\"icon\"></div>\n <span class=\"tree-text\"></span>\n </div>\n ", this.#e = this.querySelector(".icon"), this.#t = this.querySelector(".tree-text");
|
|
4454
|
+
};
|
|
4455
|
+
#o = () => {
|
|
4456
|
+
this.#e.addEventListener("click", (e) => {
|
|
4457
|
+
e.stopPropagation(), this.sheet.grouping.toggleGroup(this.tr.dataset.groupId);
|
|
4458
|
+
});
|
|
4459
|
+
};
|
|
4460
|
+
};
|
|
4461
|
+
customElements.get("cell-tree") || customElements.define("cell-tree", $);
|
|
4462
|
+
// src/cell/cell-row-indicator.js
|
|
4463
|
+
var ee = class extends V {
|
|
4219
4464
|
#e;
|
|
4220
4465
|
#t;
|
|
4221
4466
|
#n;
|
|
@@ -4231,10 +4476,8 @@ var $ = class extends V {
|
|
|
4231
4476
|
refresh = () => {
|
|
4232
4477
|
if (!this.cell || !this.tr) return;
|
|
4233
4478
|
this.classList.remove("is-insert", "is-update", "is-delete");
|
|
4234
|
-
let e = this.
|
|
4235
|
-
if (
|
|
4236
|
-
let t = this.tr.data;
|
|
4237
|
-
if (t) switch (t.m._[r.META.INDEX.ROW_STATE]) {
|
|
4479
|
+
let e = this.tr.data;
|
|
4480
|
+
if (e && e.m !== void 0) switch (e.m._[r.META.INDEX.ROW_STATE]) {
|
|
4238
4481
|
case r.ROW_STATE.INSERT:
|
|
4239
4482
|
this.classList.add("is-insert");
|
|
4240
4483
|
break;
|
|
@@ -4243,22 +4486,22 @@ var $ = class extends V {
|
|
|
4243
4486
|
break;
|
|
4244
4487
|
case r.ROW_STATE.DELETE: this.classList.add("is-delete");
|
|
4245
4488
|
}
|
|
4246
|
-
let
|
|
4247
|
-
if (
|
|
4248
|
-
let e =
|
|
4489
|
+
let t = this.index + 1, n = t.toLocaleString();
|
|
4490
|
+
if (t >= 1e4) {
|
|
4491
|
+
let e = n.length - 4, t = n.substring(0, e + 1), r = n.substring(e + 1);
|
|
4249
4492
|
this.#e.innerHTML = `
|
|
4250
4493
|
<span class="ng-row-prefix">${t}</span>
|
|
4251
|
-
<span class="ng-row-suffix">${
|
|
4494
|
+
<span class="ng-row-suffix">${r}</span>
|
|
4252
4495
|
<div class="row-status"></div>
|
|
4253
4496
|
`;
|
|
4254
|
-
} else this.#e.innerHTML = `${
|
|
4255
|
-
let
|
|
4256
|
-
this.#t.innerHTML =
|
|
4497
|
+
} else this.#e.innerHTML = `${n}`;
|
|
4498
|
+
let i = !!this.sheet.querySelector("thead .asc,thead .desc"), a = !!this.sheet.querySelector("thead nine-table-filter-button.filtered");
|
|
4499
|
+
this.#t.innerHTML = this.row, this.#t.style.display = i || a ? "" : "none";
|
|
4257
4500
|
};
|
|
4258
4501
|
};
|
|
4259
|
-
customElements.get("cell-row-indicator") || customElements.define("cell-row-indicator",
|
|
4502
|
+
customElements.get("cell-row-indicator") || customElements.define("cell-row-indicator", ee);
|
|
4260
4503
|
// src/col/col-expand.js
|
|
4261
|
-
var
|
|
4504
|
+
var te = class extends HTMLElement {
|
|
4262
4505
|
#e;
|
|
4263
4506
|
#t;
|
|
4264
4507
|
constructor() {
|
|
@@ -4306,9 +4549,9 @@ var ee = class extends HTMLElement {
|
|
|
4306
4549
|
this.removeEventListener("click", this.#n);
|
|
4307
4550
|
}
|
|
4308
4551
|
};
|
|
4309
|
-
customElements.get("nine-table-col-expand") || customElements.define("nine-table-col-expand",
|
|
4552
|
+
customElements.get("nine-table-col-expand") || customElements.define("nine-table-col-expand", te);
|
|
4310
4553
|
// src/menu/nine-table-menu.js
|
|
4311
|
-
var
|
|
4554
|
+
var ne = class extends HTMLElement {
|
|
4312
4555
|
#e;
|
|
4313
4556
|
#t;
|
|
4314
4557
|
connectedCallback() {
|
|
@@ -4477,9 +4720,9 @@ var te = class extends HTMLElement {
|
|
|
4477
4720
|
this.#e?.removeEventListener("contextmenu", this.#n);
|
|
4478
4721
|
}
|
|
4479
4722
|
};
|
|
4480
|
-
customElements.get("nine-table-menu") || customElements.define("nine-table-menu",
|
|
4723
|
+
customElements.get("nine-table-menu") || customElements.define("nine-table-menu", ne);
|
|
4481
4724
|
// src/menu/nine-table-menu-panel.js
|
|
4482
|
-
var
|
|
4725
|
+
var re = class extends HTMLElement {
|
|
4483
4726
|
#e;
|
|
4484
4727
|
#t = null;
|
|
4485
4728
|
constructor() {
|
|
@@ -4556,7 +4799,7 @@ var ne = class extends HTMLElement {
|
|
|
4556
4799
|
this.close();
|
|
4557
4800
|
}
|
|
4558
4801
|
};
|
|
4559
|
-
customElements.get("nine-table-menu-panel") || customElements.define("nine-table-menu-panel",
|
|
4802
|
+
customElements.get("nine-table-menu-panel") || customElements.define("nine-table-menu-panel", re);
|
|
4560
4803
|
export { r as NINE_TABLE };
|
|
4561
4804
|
|
|
4562
4805
|
//# sourceMappingURL=nine-table.js.map
|