@ninebone/datagrid 0.1.3 → 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 CHANGED
@@ -71,6 +71,11 @@ npm install @ninebone/datagrid
71
71
  ]);
72
72
  });
73
73
  </script>
74
+
75
+ ```
76
+
77
+ ```html
78
+ <ninelab-table show-footer="true">
74
79
  ```
75
80
 
76
81
 
@@ -1740,6 +1740,11 @@ col {
1740
1740
  width: attr(width px);
1741
1741
  }
1742
1742
 
1743
+ col:last-child {
1744
+ width: 100% !important;
1745
+ }
1746
+
1747
+
1743
1748
  thead {
1744
1749
  display: table-header-group;
1745
1750
  position: sticky;
@@ -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.#i();
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
- if (r < 0) {
1250
- this.#e.style.userSelect = "", this.#e.style.webkitUserSelect = "";
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.3/dist/css/nine-table.css\";"];
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.3"), this.#e = this.attachShadow({ mode: "open" }), this.#t = new o(this), this.#r = new I(this), this.#i = new L(this), this.#c();
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, r) {
3469
- return super.getExprValue(e, t, n, r);
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 = !1;
3911
- #i;
3912
- #a;
3913
- #o;
3916
+ #r;
3914
3917
  constructor() {
3915
3918
  super();
3916
3919
  }
3917
3920
  connectedCallback() {
3918
- this.#x(), this.#i = this.querySelector("nine-table-simple"), setTimeout(() => {
3919
- this.#a = this.#i.shadowRoot.querySelector("nine-table-sheet"), this.#b();
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
- #s = (e, t, n, i) => {
3923
- let a = this.querySelector("nine-table-simple");
3924
- if (!a || !e || e.length === 0) return;
3925
- let o = this.#e.closest("th,td").getAttribute("items"), s = [];
3926
- s = o ? o.split(",").map((e) => e.trim()) : [n].filter(Boolean);
3927
- let c = s.length, l = a.shadowRoot.querySelector("nine-table-sheet");
3928
- l.source.table.querySelectorAll("colgroup col, tbody td").forEach((e, t) => {
3929
- let n = parseInt(e.dataset.col, 10);
3930
- n >= 2 && (e.style.display = n - 2 >= c ? "none" : "");
3931
- }), a.shadowRoot.querySelectorAll("table colgroup col").forEach((e, t) => {
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"), a.shadowRoot.querySelectorAll("colgroup col").forEach((e, t) => {
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" && l.col.autoFit(n);
3938
+ n >= 2 && e.style.display !== "none" && this.#r.col.autoFit(n);
3949
3939
  });
3950
- let e = this.#i.fields.get();
3951
- if (i) {
3952
- let t = this.#e.value ? String(this.#e.value).split(this.#o).map((e) => e.trim()) : [], n = e.indexOf("k"), r = e.indexOf("CHK");
3953
- this.#i.data.getArray().forEach((e) => {
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.#a.view.getArray().findIndex((e, r) => e.v[n] === t[0]);
3957
- this.#_(i);
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.#e.value, n = e.indexOf("k"), r = this.#a.view.getArray().findIndex((e, r) => e.v[n] === t);
3960
- this.#_(r);
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 }), i && this.#e.value, u.length * this.#a.template.height >= this.offsetHeight ? this.classList.add("expand") : this.classList.remove("expand"), a.data.set(u);
3953
+ }, { once: !0 }), e.length > this.#e ? this.classList.add("expand") : this.classList.remove("expand"), this.#n.data.set(e);
3964
3954
  };
3965
- #c = (e) => {
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
- #l = (e, t = 0) => {
3970
- let n = e.closest(".ng-sheet-body"), r = e.getBoundingClientRect(), i = n.getBoundingClientRect();
3971
- return (t ? i.bottom - r.bottom : r.top - i.top) - 5;
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
- #u = (e) => {
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, t, n, r, i, a) => {
3978
- this.#e = e, this.#t = n, this.#n = r, this.#r = !0, this.#o = a, this.classList.add("active"), this.style.opacity = "0", setTimeout(() => {
3979
- if (!this.querySelector("nine-table-simple") || !t) return;
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 a = e.closest(".ng-sheet-body"), o = e.getBoundingClientRect(), s = a.getBoundingClientRect(), c = this.#c(e), l = this.#l(e, c), u = this.#u(e), d = c ? o.bottom - s.top : o.top - s.top - l;
3982
- this.style.height = `${l}px`, this.style.left = `${u}px`, this.style.top = `${d}px`, i ? (this.classList.add("multi"), this.#i.classList.add("multi")) : (this.classList.remove("multi"), this.#i.classList.remove("multi")), this.#s(t, n, r, i);
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.#r = !1, this.#e && this.#e.cell && this.#e.cell.focus();
3988
+ this.classList.remove("active"), this.#t && this.#t.cell && this.#t.cell.focus({ preventScroll: !0 });
3987
3989
  };
3988
- #d = (e) => {
3990
+ #c = (e) => {
3989
3991
  let t = e.target.closest("th,td");
3990
- if (this.#i.classList.contains("multi")) {
3992
+ if (this.#n.classList.contains("multi")) {
3991
3993
  let e = parseInt(t?.dataset.index, 10);
3992
- this.#g(e);
3993
- } else parseInt(t?.dataset.col, 10) >= 2 && this.#h();
3994
+ this.#p(e);
3995
+ } else parseInt(t?.dataset.col, 10) >= 2 && this.#f();
3994
3996
  };
3995
- #f = (e) => {
3997
+ #l = (e) => {
3996
3998
  switch (e.code) {
3997
3999
  case "Enter":
3998
4000
  case "ArrowDown":
3999
- let e = this.#i.row.at();
4000
- e < 0 ? this.#_(0) : this.#_(e);
4001
+ let e = this.#n.row.at();
4002
+ e < 0 ? this.#m(0) : this.#m(e);
4001
4003
  break;
4002
- case "Tab": this.#_(this.#i.row.at());
4004
+ case "Tab": this.#m(this.#n.row.at());
4003
4005
  }
4004
4006
  };
4005
- #p = (e) => {
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.#m() : this.#h();
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.#i.row.at(), t < 0 && this.#_(0);
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.#g(this.#i.row.at());
4022
+ case "Space": e.preventDefault(), ["TH", "TD"].includes(e.target.tagName) && this.#p(this.#n.row.at());
4021
4023
  }
4022
4024
  };
4023
- #m = () => {
4024
- let e = this.#i.fields.get(), t = e.indexOf("k"), n = e.indexOf("CHK"), r = [];
4025
- this.#a.view.getArray().forEach((e) => {
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.#e.value = r.join(this.#o), this.#e.sheet.rowManager.refresh(!0), this.close();
4029
+ }), this.#t.value = r.join(this.#t.separator), this.#t.sheet.rowManager.refresh(!0), this.close();
4028
4030
  };
4029
- #h = () => {
4030
- let e = this.#i.row.at();
4031
+ #f = () => {
4032
+ let e = this.#n.row.at();
4031
4033
  if (e >= 0) {
4032
- let t = this.#a.view.get(e);
4033
- this.#e.value = t.k, this.#e.sheet.rowManager.refresh(!0), this.close();
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
- #g = (e) => {
4037
- if (this.#i.classList.contains("multi") && e >= 0) {
4038
- let t = this.#a.view.get(e);
4039
- this.#i.data.setValue(t.m._[r.META.INDEX.ROWID], "CHK", t.CHK === "Y" ? "N" : "Y"), this.#i.refresh();
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
- #_ = (e) => {
4043
- e === -1 ? (this.#a.row.focus(-1, () => {}), setTimeout(() => {
4044
- this.#a.selection.clear(), this.#a.navigation.currentCell = this.#a.querySelector("tr[data-index=\"0\"] td[data-col=\"2\"]"), this.#a.focus(), this.#a.invalidate();
4045
- })) : this.#a.row.focus(e, () => {
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.#a.querySelector(`tr[data-index="${e}"] td[data-col="2"]`);
4048
- this.#a.navigation.currentCell = t, t.focus(), this.#a.invalidate();
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
- #v = (e) => {
4053
- let t = this.#i.fields.get().indexOf("CHK");
4054
- this.#i.data.getArray().forEach((n) => {
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.#a.invalidate();
4058
+ }), this.#r.invalidate();
4057
4059
  };
4058
- #y = (e) => {
4060
+ #g = (e) => {
4059
4061
  let t = e.target.value.toLowerCase().trim();
4060
- if (!t) this.#a.filtering.clear();
4062
+ if (!t) this.#r.filtering.clear();
4061
4063
  else {
4062
- let e = this.#i.data.getArray(), n = this.#i.fields.get(), r = "tmp1", i = n.indexOf(r), a = [];
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.#a.filtering.set({ [r]: [...new Set(a)] });
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.#e;
4072
+ return this.#t;
4074
4073
  }
4075
- #b = () => {
4076
- this.querySelector(".search-input").addEventListener("input", this.#y), this.querySelector(".search-input").addEventListener("keydown", this.#f), this.querySelector("#btnOk").addEventListener("click", this.#m), this.querySelector("#chkAll").addEventListener("change", this.#v), this.#a.addEventListener("keydown", this.#p), this.#a.addEventListener("click", this.#d), document.addEventListener("mousedown", (e) => {
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
- #x = () => {
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.#l();
4093
+ super.connectedCallback(), this.#a();
4099
4094
  }
4100
4095
  rerenderer = () => {
4101
- this.#u(), this.refresh();
4096
+ this.#o(), this.refresh();
4102
4097
  };
4103
4098
  refresh = () => {
4104
- let e = super.refresh();
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
- #s = () => {
4101
+ #r = () => {
4108
4102
  if (!this.value || !Array.isArray(this.#t)) return "";
4109
- if (this.#i) {
4110
- let e = String(this.value).split(this.#a);
4111
- return this.#t.filter((t) => e.includes(String(t[this.#n]))).map((e) => e[this.#r]).join(this.#a);
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.#n]) === String(this.value));
4115
- return e ? e[this.#r] : this.value;
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
- #c = () => {
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.#i ? String(this.value).split(this.#a) : [this.value];
4121
- for (let t of e) if (this.#t.findIndex((e) => String(t) === String(e[this.#n])) < 0) {
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
- #l = () => {
4127
- this.#d(), this.#n = this.cell.getAttribute("key-name") || "k", this.#r = this.cell.getAttribute("value-name") || "v", this.#i = this.cell.getAttribute("multi") === "true", this.#a = this.cell.getAttribute("multi-separator") || ",", this.#u(), this.#f();
4120
+ #a = () => {
4121
+ this.#s(), this.#o(), this.#c();
4128
4122
  };
4129
- #u = () => {
4130
- if (!super.sheet || !super.cell) return;
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
- #d = () => {
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
- #f = () => {
4130
+ #c = () => {
4138
4131
  this.querySelectorAll("button").forEach((e) => {
4139
4132
  e.addEventListener("click", (e) => {
4140
- e.stopPropagation(), this.#p();
4133
+ e.stopPropagation(), this.#l();
4141
4134
  });
4142
4135
  }), this.cell.addEventListener("keydown", (e) => {
4143
- ["Space"].includes(e.code) && this.#p();
4136
+ ["Space"].includes(e.code) && this.#l();
4144
4137
  });
4145
4138
  };
4146
- #p = () => {
4147
- this.#o || (this.#o = super.sheet.querySelector("cell-combo-panel"), this.#o || (this.#o = document.createElement("cell-combo-panel"), super.sheet.appendChild(this.#o))), this.#o.isOpen && this.#o.targetCell === this ? this.#o.close() : this.#o.open(this, this.#t, this.#n, this.#r, this.#i, this.#a);
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