@ninebone/datagrid 0.1.2 → 0.1.6
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 +19 -156
- package/dist/css/nine-table.css +5 -0
- package/dist/nine-table.js +170 -159
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +8 -8
- package/dist/nine-table.umd.js.map +1 -1
- package/package.json +4 -9
package/dist/nine-table.js
CHANGED
|
@@ -1136,7 +1136,7 @@ var m = {
|
|
|
1136
1136
|
endCol: -1
|
|
1137
1137
|
};
|
|
1138
1138
|
constructor(e) {
|
|
1139
|
-
this.#e = e, this.#t = e.getRootNode().host, this.#
|
|
1139
|
+
this.#e = e, this.#t = e.getRootNode().host, this.#d();
|
|
1140
1140
|
}
|
|
1141
1141
|
#r(e) {
|
|
1142
1142
|
if (!e) return {
|
|
@@ -1238,39 +1238,45 @@ var m = {
|
|
|
1238
1238
|
});
|
|
1239
1239
|
});
|
|
1240
1240
|
};
|
|
1241
|
-
#i
|
|
1241
|
+
#i;
|
|
1242
|
+
#a;
|
|
1243
|
+
#o;
|
|
1244
|
+
#s;
|
|
1245
|
+
#c = (e, t) => {
|
|
1246
|
+
let n = this.#e.getRootNode();
|
|
1247
|
+
if (n && typeof n.elementsFromPoint == "function") {
|
|
1248
|
+
let r = n.elementsFromPoint(e, t);
|
|
1249
|
+
for (let e of r) {
|
|
1250
|
+
let t = e.closest("td, th");
|
|
1251
|
+
if (t && this.#e.contains(t) && t.dataset.row !== void 0) return t;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
let r = this.#e.querySelectorAll(".ng-sheet-body-content tbody tr td, .ng-sheet-body-content tbody tr:not(.nodata) th");
|
|
1255
|
+
for (let n of r) {
|
|
1256
|
+
let r = n.getBoundingClientRect();
|
|
1257
|
+
if (e >= r.left && e <= r.right && t >= r.top && t <= r.bottom) return n;
|
|
1258
|
+
}
|
|
1259
|
+
return null;
|
|
1260
|
+
};
|
|
1261
|
+
#l = (e) => {
|
|
1262
|
+
let t = this.#c(e.clientX, e.clientY);
|
|
1263
|
+
if (!t || t.dataset.row === void 0 || t.dataset.col === void 0) return;
|
|
1264
|
+
let n = t.closest("tr"), { matrixRow: r } = this.#r(n), i = parseInt(t.dataset.col, 10);
|
|
1265
|
+
r < 0 || (this.#i !== r || this.#a !== i) && (this.#i = r, this.#a = i, this.setRange(this.#o, this.#s, r, i));
|
|
1266
|
+
};
|
|
1267
|
+
#u = () => {
|
|
1268
|
+
document.removeEventListener("mousemove", this.#l);
|
|
1269
|
+
};
|
|
1270
|
+
#d() {
|
|
1242
1271
|
let e = this.#e.querySelector(".ng-sheet-body");
|
|
1243
|
-
e && e.addEventListener("mousedown", (e) => {
|
|
1272
|
+
e && (document.addEventListener("mouseup", this.#u), e.addEventListener("mousedown", (e) => {
|
|
1244
1273
|
if (e.button !== 0) return;
|
|
1245
1274
|
let t = e.target.closest("td, th");
|
|
1246
1275
|
if (!t || t.dataset.row === void 0 || t.dataset.col === void 0) return;
|
|
1247
1276
|
this.#e.style.userSelect = "none", this.#e.style.webkitUserSelect = "none";
|
|
1248
1277
|
let n = t.closest("tr"), { matrixRow: r } = this.#r(n), i = parseInt(t.dataset.col, 10);
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
return;
|
|
1252
|
-
}
|
|
1253
|
-
this.setFocus(r, i), this.setRange(r, i, r, i);
|
|
1254
|
-
let a = r, o = i, s = (e) => {
|
|
1255
|
-
let t = document.elementFromPoint(e.clientX, e.clientY)?.closest("td, th");
|
|
1256
|
-
if (!t || !this.#e.contains(t)) {
|
|
1257
|
-
let n = this.#e.querySelectorAll(".ng-sheet-body-content tbody tr td, .ng-sheet-body-content tbody tr:not(.nodata) th");
|
|
1258
|
-
for (let r of n) {
|
|
1259
|
-
let n = r.getBoundingClientRect();
|
|
1260
|
-
if (e.clientX >= n.left && e.clientX <= n.right && e.clientY >= n.top && e.clientY <= n.bottom) {
|
|
1261
|
-
t = r;
|
|
1262
|
-
break;
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
if (!t || t.dataset.row === void 0 || t.dataset.col === void 0) return;
|
|
1267
|
-
let n = t.closest("tr"), { matrixRow: s } = this.#r(n), c = parseInt(t.dataset.col, 10);
|
|
1268
|
-
s < 0 || (a !== s || o !== c) && (a = s, o = c, this.setRange(r, i, s, c));
|
|
1269
|
-
}, c = () => {
|
|
1270
|
-
this.#e.style.userSelect = "", this.#e.style.webkitUserSelect = "", document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", c);
|
|
1271
|
-
};
|
|
1272
|
-
document.addEventListener("mousemove", s), document.addEventListener("mouseup", c);
|
|
1273
|
-
});
|
|
1278
|
+
this.#o = r, this.#s = i, r < 0 ? (this.#e.style.userSelect = "", this.#e.style.webkitUserSelect = "") : (this.setFocus(r, i), this.setRange(r, i, r, i), this.#i = r, this.#a = i, document.addEventListener("mousemove", this.#l));
|
|
1279
|
+
}));
|
|
1274
1280
|
}
|
|
1275
1281
|
}, b = class {
|
|
1276
1282
|
#e;
|
|
@@ -2026,7 +2032,7 @@ var w = class {
|
|
|
2026
2032
|
let s = this.querySelector(".search-box");
|
|
2027
2033
|
s.value = "", this.classList.add("active"), this.classList.add("loading"), setTimeout(() => {
|
|
2028
2034
|
try {
|
|
2029
|
-
this.#c(), this.#r.rowManager.scrollToDataRow(0), s.focus();
|
|
2035
|
+
this.#c(), this.#r.rowManager.scrollToDataRow(0), s.focus({ preventScroll: !0 });
|
|
2030
2036
|
} finally {
|
|
2031
2037
|
this.classList.remove("loading");
|
|
2032
2038
|
}
|
|
@@ -2993,7 +2999,7 @@ var P = class {
|
|
|
2993
2999
|
let e = Array.from(this.#e.children).filter((e) => e.tagName.toUpperCase() === "TABLE"), t = e.length, n = e.map((e, n) => {
|
|
2994
3000
|
let r = n === 0 ? "active" : "", i = e.id || `sheet${n + 1}`;
|
|
2995
3001
|
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>` : "");
|
|
2996
|
-
}).join(""), r = ["@import \"https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.1.
|
|
3002
|
+
}).join(""), r = ["@import \"https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.1.6/dist/css/nine-table.css\";"];
|
|
2997
3003
|
nine["nine-table"] && nine["nine-table"].cssFile && r.push(`@import "${nine["nine-table"].cssFile}";`), this.#e.shadowRoot.innerHTML = `
|
|
2998
3004
|
<style>
|
|
2999
3005
|
${r.join("\n")}
|
|
@@ -3130,7 +3136,7 @@ var P = class {
|
|
|
3130
3136
|
#i;
|
|
3131
3137
|
#a = 0;
|
|
3132
3138
|
constructor() {
|
|
3133
|
-
super(), ["NINE-TABLE"].includes(this.tagName) && n.log("Welcome nine-table", "0.1.
|
|
3139
|
+
super(), ["NINE-TABLE"].includes(this.tagName) && n.log("Welcome nine-table", "0.1.6"), this.#e = this.attachShadow({ mode: "open" }), this.#t = new o(this), this.#r = new I(this), this.#i = new L(this), this.#c();
|
|
3134
3140
|
}
|
|
3135
3141
|
connectedCallback() {
|
|
3136
3142
|
setTimeout(() => {
|
|
@@ -3465,8 +3471,8 @@ var z = class extends HTMLElement {
|
|
|
3465
3471
|
get attr() {
|
|
3466
3472
|
return super.attr;
|
|
3467
3473
|
}
|
|
3468
|
-
getExprValue(e, t, n
|
|
3469
|
-
return super.getExprValue(e, t, n
|
|
3474
|
+
getExprValue(e, t, n) {
|
|
3475
|
+
return super.getExprValue(e, t, n);
|
|
3470
3476
|
}
|
|
3471
3477
|
constructor() {
|
|
3472
3478
|
super();
|
|
@@ -3904,180 +3910,173 @@ var J = class extends H {
|
|
|
3904
3910
|
customElements.get("cell-radio") || customElements.define("cell-radio", J);
|
|
3905
3911
|
// src/cell/cell-combo-panel.js
|
|
3906
3912
|
var Y = class extends HTMLElement {
|
|
3907
|
-
#e;
|
|
3913
|
+
#e = 10;
|
|
3908
3914
|
#t;
|
|
3909
3915
|
#n;
|
|
3910
|
-
#r
|
|
3911
|
-
#i;
|
|
3912
|
-
#a;
|
|
3913
|
-
#o;
|
|
3916
|
+
#r;
|
|
3914
3917
|
constructor() {
|
|
3915
3918
|
super();
|
|
3916
3919
|
}
|
|
3917
3920
|
connectedCallback() {
|
|
3918
|
-
this.#
|
|
3919
|
-
this.#
|
|
3921
|
+
this.#v(), this.#n = this.querySelector("nine-table-simple"), setTimeout(() => {
|
|
3922
|
+
this.#r = this.#n.shadowRoot.querySelector("nine-table-sheet"), this.#_();
|
|
3920
3923
|
});
|
|
3921
3924
|
}
|
|
3922
|
-
#
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
let
|
|
3930
|
-
|
|
3931
|
-
}),
|
|
3932
|
-
let n = parseInt(e.dataset.col, 10);
|
|
3933
|
-
n >= 2 && (e.style.display = n - 2 >= c ? "none" : "");
|
|
3934
|
-
});
|
|
3935
|
-
let u = e.map((e) => {
|
|
3936
|
-
let n = {
|
|
3937
|
-
CHK: "N",
|
|
3938
|
-
k: t && e[t] !== void 0 ? e[t] : e[0] === void 0 ? "" : e[0]
|
|
3939
|
-
};
|
|
3940
|
-
return s.forEach((t, r) => {
|
|
3941
|
-
n[`tmp${r + 1}`] = e[t] === void 0 ? e[r] === void 0 ? "" : e[r] : e[t];
|
|
3942
|
-
}), n;
|
|
3943
|
-
});
|
|
3944
|
-
a.addEventListener(r.EVENT.ROW_ADDED, () => {
|
|
3925
|
+
#i = (e) => {
|
|
3926
|
+
if (!this.#n || !this.#t.dataSource || this.#t.dataSource.length === 0) return;
|
|
3927
|
+
let t = this.#t.items.length || 1;
|
|
3928
|
+
this.#r.source.table.querySelectorAll("colgroup col, tbody td").forEach((e, n) => {
|
|
3929
|
+
let r = parseInt(e.dataset.col, 10);
|
|
3930
|
+
r >= 2 && (e.style.display = r - 2 >= t ? "none" : "");
|
|
3931
|
+
}), this.#r.querySelectorAll("table colgroup col").forEach((e, n) => {
|
|
3932
|
+
let r = parseInt(e.dataset.col, 10);
|
|
3933
|
+
r >= 2 && (e.style.display = r - 2 >= t ? "none" : "");
|
|
3934
|
+
}), this.#n.addEventListener(r.EVENT.ROW_ADDED, () => {
|
|
3945
3935
|
setTimeout(() => {
|
|
3946
|
-
this.style.opacity = "", this.classList.add("active"),
|
|
3936
|
+
this.style.opacity = "", this.classList.add("active"), this.#r.querySelectorAll("colgroup col").forEach((e, t) => {
|
|
3947
3937
|
let n = parseInt(e.dataset.col, 10);
|
|
3948
|
-
n >= 2 && e.style.display !== "none" &&
|
|
3938
|
+
n >= 2 && e.style.display !== "none" && this.#r.col.autoFit(n);
|
|
3949
3939
|
});
|
|
3950
|
-
let e = this.#
|
|
3951
|
-
if (
|
|
3952
|
-
let t = this.#
|
|
3953
|
-
this.#
|
|
3940
|
+
let e = this.#n.fields.get();
|
|
3941
|
+
if (this.#t.multi) {
|
|
3942
|
+
let t = this.#t.value ? String(this.#t.value).split(this.#t.separator).map((e) => e.trim()) : [], n = e.indexOf("k"), r = e.indexOf("CHK");
|
|
3943
|
+
this.#n.data.getArray().forEach((e) => {
|
|
3954
3944
|
e.v[r] = t.includes(String(e.v[n])) ? "Y" : "N";
|
|
3955
3945
|
});
|
|
3956
|
-
let i = this.#
|
|
3957
|
-
this.#
|
|
3946
|
+
let i = this.#r.view.getArray().findIndex((e, r) => e.v[n] === t[0]);
|
|
3947
|
+
this.#m(i);
|
|
3958
3948
|
} else {
|
|
3959
|
-
let t = this.#
|
|
3960
|
-
this.#
|
|
3949
|
+
let t = this.#t.value, n = e.indexOf("k"), r = this.#r.view.getArray().findIndex((e, r) => e.v[n] === t);
|
|
3950
|
+
this.#m(r);
|
|
3961
3951
|
}
|
|
3962
3952
|
});
|
|
3963
|
-
}, { once: !0 }),
|
|
3953
|
+
}, { once: !0 }), e.length > this.#e ? this.classList.add("expand") : this.classList.remove("expand"), this.#n.data.set(e);
|
|
3964
3954
|
};
|
|
3965
|
-
#
|
|
3955
|
+
#a = (e) => {
|
|
3966
3956
|
let t = e.closest(".ng-sheet-body"), n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
3967
3957
|
return r.bottom - n.bottom >= n.top - r.top;
|
|
3968
3958
|
};
|
|
3969
|
-
#
|
|
3970
|
-
let
|
|
3971
|
-
return (
|
|
3959
|
+
#o = (e, t, n) => {
|
|
3960
|
+
let r = e.closest(".ng-sheet-body"), i = e.getBoundingClientRect(), a = r.getBoundingClientRect(), o = (t ? a.bottom - i.bottom : i.top - a.top) - 5, s = n * this.#r.template.height + (n > this.#e ? 32 : 0) + 2;
|
|
3961
|
+
return Math.min(o, s);
|
|
3972
3962
|
};
|
|
3973
|
-
#
|
|
3963
|
+
#s = (e) => {
|
|
3974
3964
|
let t = e.closest("th,td"), n = t.closest(".ng-sheet-body"), r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = r.left - i.left, o = this.offsetWidth;
|
|
3975
3965
|
return a + o > i.width && (a = Math.max(0, i.width - o - 2)), a < 0 && (a = 5), a;
|
|
3976
3966
|
};
|
|
3977
|
-
open = (e
|
|
3978
|
-
this.#
|
|
3979
|
-
|
|
3967
|
+
open = (e) => {
|
|
3968
|
+
this.#t = e, this.classList.add("active"), this.style.opacity = "0";
|
|
3969
|
+
let t = this.#t.items;
|
|
3970
|
+
t.length === 0 && t.push(this.#t.valueName);
|
|
3971
|
+
let n = this.#t.dataSource.map((e) => {
|
|
3972
|
+
let n = {
|
|
3973
|
+
CHK: "N",
|
|
3974
|
+
k: this.#t.keyName && e[this.#t.keyName] !== void 0 ? e[this.#t.keyName] : e[0] === void 0 ? "" : e[0]
|
|
3975
|
+
};
|
|
3976
|
+
return t.forEach((t, r) => {
|
|
3977
|
+
n[`tmp${r + 1}`] = e[t] === void 0 ? e[r] === void 0 ? "" : e[r] : e[t];
|
|
3978
|
+
}), n;
|
|
3979
|
+
});
|
|
3980
|
+
setTimeout(() => {
|
|
3981
|
+
if (!this.#n || !this.#t.dataSource) return;
|
|
3980
3982
|
this.querySelector(".search-input").value = "", this.querySelector("#chkAll").checked = !0;
|
|
3981
|
-
let
|
|
3982
|
-
this.style.height = `${
|
|
3983
|
+
let t = e.closest(".ng-sheet-body"), r = e.getBoundingClientRect(), i = t.getBoundingClientRect(), a = this.#a(e), o = this.#o(e, a, n.length), s = this.#s(e), c = a ? r.bottom - i.top : r.top - i.top - o;
|
|
3984
|
+
this.style.height = `${o}px`, this.style.left = `${s}px`, this.style.top = `${c}px`, this.#t.multi ? (this.classList.add("multi"), this.#n.classList.add("multi")) : (this.classList.remove("multi"), this.#n.classList.remove("multi")), this.#i(n);
|
|
3983
3985
|
}, 100);
|
|
3984
3986
|
};
|
|
3985
3987
|
close = () => {
|
|
3986
|
-
this.classList.remove("active"), this.#
|
|
3988
|
+
this.classList.remove("active"), this.#t && this.#t.cell && this.#t.cell.focus({ preventScroll: !0 });
|
|
3987
3989
|
};
|
|
3988
|
-
#
|
|
3990
|
+
#c = (e) => {
|
|
3989
3991
|
let t = e.target.closest("th,td");
|
|
3990
|
-
if (this.#
|
|
3992
|
+
if (this.#n.classList.contains("multi")) {
|
|
3991
3993
|
let e = parseInt(t?.dataset.index, 10);
|
|
3992
|
-
this.#
|
|
3993
|
-
} else parseInt(t?.dataset.col, 10) >= 2 && this.#
|
|
3994
|
+
this.#p(e);
|
|
3995
|
+
} else parseInt(t?.dataset.col, 10) >= 2 && this.#f();
|
|
3994
3996
|
};
|
|
3995
|
-
#
|
|
3997
|
+
#l = (e) => {
|
|
3996
3998
|
switch (e.code) {
|
|
3997
3999
|
case "Enter":
|
|
3998
4000
|
case "ArrowDown":
|
|
3999
|
-
let e = this.#
|
|
4000
|
-
e < 0 ? this.#
|
|
4001
|
+
let e = this.#n.row.at();
|
|
4002
|
+
e < 0 ? this.#m(0) : this.#m(e);
|
|
4001
4003
|
break;
|
|
4002
|
-
case "Tab": this.#
|
|
4004
|
+
case "Tab": this.#m(this.#n.row.at());
|
|
4003
4005
|
}
|
|
4004
4006
|
};
|
|
4005
|
-
#
|
|
4007
|
+
#u = (e) => {
|
|
4006
4008
|
let t;
|
|
4007
4009
|
switch (e.code) {
|
|
4008
4010
|
case "Escape":
|
|
4009
4011
|
this.close();
|
|
4010
4012
|
break;
|
|
4011
4013
|
case "Enter":
|
|
4012
|
-
this.classList.contains("multi") ? this.#
|
|
4014
|
+
this.classList.contains("multi") ? this.#d() : this.#f();
|
|
4013
4015
|
break;
|
|
4014
4016
|
case "Tab":
|
|
4015
|
-
this.classList.contains("expand") && (e.preventDefault(), this.querySelector("input[type='text']").focus());
|
|
4017
|
+
this.classList.contains("expand") && (e.preventDefault(), this.querySelector("input[type='text']").focus({ preventScroll: !0 }));
|
|
4016
4018
|
break;
|
|
4017
4019
|
case "ArrowDown":
|
|
4018
|
-
t = this.#
|
|
4020
|
+
t = this.#n.row.at(), t < 0 && this.#m(0);
|
|
4019
4021
|
break;
|
|
4020
|
-
case "Space": e.preventDefault(), ["TH", "TD"].includes(e.target.tagName) && this.#
|
|
4022
|
+
case "Space": e.preventDefault(), ["TH", "TD"].includes(e.target.tagName) && this.#p(this.#n.row.at());
|
|
4021
4023
|
}
|
|
4022
4024
|
};
|
|
4023
|
-
#
|
|
4024
|
-
let e = this.#
|
|
4025
|
-
this.#
|
|
4025
|
+
#d = () => {
|
|
4026
|
+
let e = this.#n.fields.get(), t = e.indexOf("k"), n = e.indexOf("CHK"), r = [];
|
|
4027
|
+
this.#r.view.getArray().forEach((e) => {
|
|
4026
4028
|
e.v[n] === "Y" && r.push(e.v[t]);
|
|
4027
|
-
}), this.#
|
|
4029
|
+
}), this.#t.value = r.join(this.#t.separator), this.#t.sheet.rowManager.refresh(!0), this.close();
|
|
4028
4030
|
};
|
|
4029
|
-
#
|
|
4030
|
-
let e = this.#
|
|
4031
|
+
#f = () => {
|
|
4032
|
+
let e = this.#n.row.at();
|
|
4031
4033
|
if (e >= 0) {
|
|
4032
|
-
let t = this.#
|
|
4033
|
-
this.#
|
|
4034
|
+
let t = this.#r.view.get(e);
|
|
4035
|
+
this.#t.value = t.k, this.#t.sheet.rowManager.refresh(!0), this.close();
|
|
4034
4036
|
}
|
|
4035
4037
|
};
|
|
4036
|
-
#
|
|
4037
|
-
if (this.#
|
|
4038
|
-
let t = this.#
|
|
4039
|
-
this.#
|
|
4038
|
+
#p = (e) => {
|
|
4039
|
+
if (this.#n.classList.contains("multi") && e >= 0) {
|
|
4040
|
+
let t = this.#r.view.get(e);
|
|
4041
|
+
this.#n.data.setValue(t.m._[r.META.INDEX.ROWID], "CHK", t.CHK === "Y" ? "N" : "Y"), this.#n.refresh();
|
|
4040
4042
|
}
|
|
4041
4043
|
};
|
|
4042
|
-
#
|
|
4043
|
-
e === -1 ? (this.#
|
|
4044
|
-
this.#
|
|
4045
|
-
})) : this.#
|
|
4044
|
+
#m = (e) => {
|
|
4045
|
+
e === -1 ? (this.#r.row.focus(-1, () => {}), setTimeout(() => {
|
|
4046
|
+
this.#r.selection.clear(), this.#r.navigation.currentCell = this.#r.querySelector("tr[data-index=\"0\"] td[data-col=\"2\"]"), this.#r.focus({ preventScroll: !0 }), this.#r.invalidate();
|
|
4047
|
+
})) : this.#r.row.focus(e, () => {
|
|
4046
4048
|
setTimeout(() => {
|
|
4047
|
-
let t = this.#
|
|
4048
|
-
this.#
|
|
4049
|
+
let t = this.#r.querySelector(`tr[data-index="${e}"] td[data-col="2"]`);
|
|
4050
|
+
this.#r.navigation.currentCell = t, t.focus({ preventScroll: !0 }), this.#r.invalidate();
|
|
4049
4051
|
});
|
|
4050
4052
|
});
|
|
4051
4053
|
};
|
|
4052
|
-
#
|
|
4053
|
-
let t = this.#
|
|
4054
|
-
this.#
|
|
4054
|
+
#h = (e) => {
|
|
4055
|
+
let t = this.#n.fields.get().indexOf("CHK");
|
|
4056
|
+
this.#n.data.getArray().forEach((n) => {
|
|
4055
4057
|
n.v[t] = e.target.checked ? "Y" : "N";
|
|
4056
|
-
}), this.#
|
|
4058
|
+
}), this.#r.invalidate();
|
|
4057
4059
|
};
|
|
4058
|
-
#
|
|
4060
|
+
#g = (e) => {
|
|
4059
4061
|
let t = e.target.value.toLowerCase().trim();
|
|
4060
|
-
if (!t) this.#
|
|
4062
|
+
if (!t) this.#r.filtering.clear();
|
|
4061
4063
|
else {
|
|
4062
|
-
let e = this.#
|
|
4064
|
+
let e = this.#n.data.getArray(), n = this.#n.fields.get(), r = "tmp1", i = n.indexOf(r), a = [];
|
|
4063
4065
|
e.forEach((e) => {
|
|
4064
4066
|
let n = i >= 0 && e.v ? e.v[i] : "";
|
|
4065
4067
|
String(n).replace(/<[^>]*>?/gm, "").toLowerCase().includes(t) && a.push(n);
|
|
4066
|
-
}), this.#
|
|
4068
|
+
}), this.#r.filtering.set({ [r]: [...new Set(a)] });
|
|
4067
4069
|
}
|
|
4068
4070
|
};
|
|
4069
|
-
get isOpen() {
|
|
4070
|
-
return this.#r;
|
|
4071
|
-
}
|
|
4072
4071
|
get targetCell() {
|
|
4073
|
-
return this.#
|
|
4072
|
+
return this.#t;
|
|
4074
4073
|
}
|
|
4075
|
-
#
|
|
4076
|
-
this.querySelector(".search-input").addEventListener("input", this.#
|
|
4074
|
+
#_ = () => {
|
|
4075
|
+
this.querySelector(".search-input").addEventListener("input", this.#g), this.querySelector(".search-input").addEventListener("keydown", this.#l), this.querySelector("#btnOk").addEventListener("click", this.#d), this.querySelector("#chkAll").addEventListener("change", this.#h), this.#r.addEventListener("keydown", this.#u), this.#r.addEventListener("click", this.#c), document.addEventListener("mousedown", (e) => {
|
|
4077
4076
|
(e.composedPath ? e.composedPath() : []).includes(this) || this.close();
|
|
4078
4077
|
});
|
|
4079
4078
|
};
|
|
4080
|
-
#
|
|
4079
|
+
#v = () => {
|
|
4081
4080
|
this.innerHTML = "\n <input type=\"text\" class=\"search-input\" placeholder=\"Search...\" />\n \n <nine-table-simple class=\"combo-list\" theme=\"simple\">\n <table auto-fit-col=\"true\">\n <colgroup>\n <col width=\"30\" fixed=\"left\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"0\" />\n </colgroup>\n <tbody>\n <tr>\n <td cell-type=\"checkbox\" data-bind=\"CHK\"></td>\n <td data-bind=\"tmp1\" />\n <td data-bind=\"tmp2\" />\n <td data-bind=\"tmp3\" />\n <td data-bind=\"tmp4\" />\n <td data-bind=\"tmp5\" />\n <td data-bind=\"tmp6\" />\n <td data-bind=\"tmp7\" />\n <td data-bind=\"tmp8\" />\n <td data-bind=\"tmp9\" />\n <td data-bind=\"tmp10\" />\n <td data-bind=\"k\" />\n </tr>\n </tbody>\n </table>\n </nine-table-simple>\n \n <div class=\"footer\">\n <label for=\"chkAll\"><input id=\"chkAll\" type=\"checkbox\" checked><span>Select All</span></label>\n <button id=\"btnOk\">OK</button>\n </div>\n ";
|
|
4082
4081
|
};
|
|
4083
4082
|
};
|
|
@@ -4087,68 +4086,80 @@ var X = class extends H {
|
|
|
4087
4086
|
#e;
|
|
4088
4087
|
#t = [];
|
|
4089
4088
|
#n;
|
|
4090
|
-
#r;
|
|
4091
|
-
#i;
|
|
4092
|
-
#a;
|
|
4093
|
-
#o;
|
|
4094
4089
|
constructor() {
|
|
4095
4090
|
super();
|
|
4096
4091
|
}
|
|
4097
4092
|
connectedCallback() {
|
|
4098
|
-
super.connectedCallback(), this.#
|
|
4093
|
+
super.connectedCallback(), this.#a();
|
|
4099
4094
|
}
|
|
4100
4095
|
rerenderer = () => {
|
|
4101
|
-
this.#
|
|
4096
|
+
this.#o(), this.refresh();
|
|
4102
4097
|
};
|
|
4103
4098
|
refresh = () => {
|
|
4104
|
-
|
|
4105
|
-
return this.#e && (this.#e.textContent = this.#s() || "Select", this.#c()), e;
|
|
4099
|
+
super.refresh(), this.#e.textContent = this.#r() || "Select", this.#i();
|
|
4106
4100
|
};
|
|
4107
|
-
#
|
|
4101
|
+
#r = () => {
|
|
4108
4102
|
if (!this.value || !Array.isArray(this.#t)) return "";
|
|
4109
|
-
if (this
|
|
4110
|
-
let e = String(this.value).split(this
|
|
4111
|
-
return this.#t.filter((t) => e.includes(String(t[this
|
|
4103
|
+
if (this.multi) {
|
|
4104
|
+
let e = String(this.value).split(this.multiSeparator);
|
|
4105
|
+
return this.#t.filter((t) => e.includes(String(t[this.keyName]))).map((e) => e[this.valueName]).join(this.multiSeparator);
|
|
4112
4106
|
}
|
|
4113
4107
|
{
|
|
4114
|
-
let e = this.#t.find((e) => String(e[this
|
|
4115
|
-
return e ? e[this
|
|
4108
|
+
let e = this.#t.find((e) => String(e[this.keyName]) === String(this.value));
|
|
4109
|
+
return e ? e[this.valueName] : this.value;
|
|
4116
4110
|
}
|
|
4117
4111
|
};
|
|
4118
|
-
#
|
|
4112
|
+
#i = () => {
|
|
4119
4113
|
if (!super.cell || (super.cell.classList.remove("invalid"), this.value === null || this.value === void 0 || this.value === "" || !Array.isArray(this.#t))) return;
|
|
4120
|
-
let e = this
|
|
4121
|
-
for (let t of e) if (this.#t.findIndex((e) => String(t) === String(e[this
|
|
4114
|
+
let e = this.multi ? String(this.value).split(this.multiSeparator) : [this.value];
|
|
4115
|
+
for (let t of e) if (this.#t.findIndex((e) => String(t) === String(e[this.keyName])) < 0) {
|
|
4122
4116
|
super.cell.classList.add("invalid");
|
|
4123
4117
|
break;
|
|
4124
4118
|
}
|
|
4125
4119
|
};
|
|
4126
|
-
#
|
|
4127
|
-
this.#
|
|
4120
|
+
#a = () => {
|
|
4121
|
+
this.#s(), this.#o(), this.#c();
|
|
4128
4122
|
};
|
|
4129
|
-
#
|
|
4130
|
-
|
|
4131
|
-
let e = super.cell?.getAttribute("data-source");
|
|
4123
|
+
#o = () => {
|
|
4124
|
+
let e = this.cell.getAttribute("data-source");
|
|
4132
4125
|
e && (this.#t = super.getExprValue(e, super.tr.data, super.tr.dataset.row));
|
|
4133
4126
|
};
|
|
4134
|
-
#
|
|
4127
|
+
#s = () => {
|
|
4135
4128
|
this.innerHTML = "\n <button class=\"btn1\" type=\"button\" tabindex=\"-1\">Select</button>\n <button class=\"btn2\" type=\"button\" tabindex=\"-1\"></button>\n ", this.#e = this.querySelector(".btn1");
|
|
4136
4129
|
};
|
|
4137
|
-
#
|
|
4130
|
+
#c = () => {
|
|
4138
4131
|
this.querySelectorAll("button").forEach((e) => {
|
|
4139
4132
|
e.addEventListener("click", (e) => {
|
|
4140
|
-
e.stopPropagation(), this.#
|
|
4133
|
+
e.stopPropagation(), this.#l();
|
|
4141
4134
|
});
|
|
4142
4135
|
}), this.cell.addEventListener("keydown", (e) => {
|
|
4143
|
-
["Space"].includes(e.code) && this.#
|
|
4136
|
+
["Space"].includes(e.code) && this.#l();
|
|
4144
4137
|
});
|
|
4145
4138
|
};
|
|
4146
|
-
#
|
|
4147
|
-
this.#
|
|
4139
|
+
#l = () => {
|
|
4140
|
+
this.#n || (this.#n = this.sheet.querySelector("cell-combo-panel"), this.#n || (this.#n = document.createElement("cell-combo-panel"), this.sheet.appendChild(this.#n))), this.#n.classList.contains("active") && this.#n.targetCell === this ? this.#n.close() : this.#n.open(this, this.#t, this.keyName, this.valueName, this.multi, this.multiSeparator);
|
|
4148
4141
|
};
|
|
4149
4142
|
get dataSource() {
|
|
4150
4143
|
return this.#t;
|
|
4151
4144
|
}
|
|
4145
|
+
get keyName() {
|
|
4146
|
+
return this.cell.getAttribute("key-name") || "k";
|
|
4147
|
+
}
|
|
4148
|
+
get valueName() {
|
|
4149
|
+
return this.cell.getAttribute("value-name") || "v";
|
|
4150
|
+
}
|
|
4151
|
+
get multi() {
|
|
4152
|
+
return this.cell.getAttribute("multi") === "true";
|
|
4153
|
+
}
|
|
4154
|
+
get multiSeparator() {
|
|
4155
|
+
return this.cell.getAttribute("multi-separator") || ",";
|
|
4156
|
+
}
|
|
4157
|
+
get items() {
|
|
4158
|
+
return this.cell.getAttribute("items")?.split(",").map((e) => e.trim()) || [];
|
|
4159
|
+
}
|
|
4160
|
+
get separator() {
|
|
4161
|
+
return this.multiSeparator;
|
|
4162
|
+
}
|
|
4152
4163
|
};
|
|
4153
4164
|
customElements.get("cell-combo") || customElements.define("cell-combo", X);
|
|
4154
4165
|
// src/cell/cell-renderer.js
|