@ninebone/datagrid 0.0.3 → 0.0.4

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
@@ -42,7 +42,8 @@ npm install @ninebone/datagrid
42
42
 
43
43
  <html>
44
44
  <head>
45
- <script type="text/javascript" src="[https://cdn.jsdelivr.net/npm/@ninebone/datagrid@latest/dist/nine-table.umd.js](https://cdn.jsdelivr.net/npm/@ninebone/table@latest/dist/nine-table.umd.js)"></script>
45
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@ninebone/util@latest/dist/nine-util.umd.js"></script>
46
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@ninebone/datagrid@latest/dist/nine-table.umd.js"></script>
46
47
  </head>
47
48
  <body>
48
49
 
@@ -2839,8 +2839,8 @@ var N = class {
2839
2839
  let n = t === 0 ? "active" : "", i = e.id || `sheet${t + 1}`;
2840
2840
  return `<nine-table-sheet class="${n}" data-index="${t}" data-sheet-id="${i}" id="${i}"></nine-table-sheet>` + (t < r - 1 ? `<nine-splitter class="h" data-split-index="${t}"></nine-splitter>` : "");
2841
2841
  }).join("");
2842
- n.log("Welcome nine-table", "0.2.2");
2843
- let a = ["@import \"https://cdn.jsdelivr.net/npm/@ninebone/table@0.2.2/dist/css/nine-table.css\";"];
2842
+ n.log("Welcome nine-table", "0.0.3");
2843
+ let a = ["@import \"https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.0.3/dist/css/nine-table.css\";"];
2844
2844
  nine["nine-table"] && nine["nine-table"].cssFile && a.push(`@import "${nine["nine-table"].cssFile}";`), this.#e.shadowRoot.innerHTML = `
2845
2845
  <style>
2846
2846
  ${a.join("\n")}
@@ -3009,14 +3009,10 @@ customElements.get("nine-table") || customElements.define("nine-table", F), cust
3009
3009
  });
3010
3010
  // src/cell/core/BasicCellElement.js
3011
3011
  var I = class extends HTMLElement {
3012
- static _styleCache = /* @__PURE__ */ new Map();
3013
- static _customStyleCache = /* @__PURE__ */ new Map();
3014
3012
  constructor() {
3015
3013
  super();
3016
3014
  }
3017
- applyBaseStyle() {
3018
- this.constructor.name;
3019
- }
3015
+ applyBaseStyle() {}
3020
3016
  connectedCallback() {}
3021
3017
  }, L = /* @__PURE__ */ new Map(), R = class extends I {
3022
3018
  #e;
@@ -3134,8 +3130,8 @@ var I = class extends HTMLElement {
3134
3130
  let t = this.#r.dataset.expr, n = this.#r.dataset.bind, r = parseInt(this.#r.dataset.row, 10);
3135
3131
  if (t) try {
3136
3132
  return this.#n.getAttribute("grouping") === "true" ? this.getGroupExprValue(t, this.#n.data, r, this.#r) : this.#e.exprEngine.evaluate(t, this.#n.data, r);
3137
- } catch (t) {
3138
- return console.trace(t), e;
3133
+ } catch {
3134
+ return e;
3139
3135
  }
3140
3136
  return n ? this.value ?? e : e;
3141
3137
  };
@@ -3400,7 +3396,6 @@ var H = class extends z {
3400
3396
  this.refresh();
3401
3397
  };
3402
3398
  #a = () => {
3403
- this.tr.data;
3404
3399
  let e = this.cell.getAttribute("data-source");
3405
3400
  if (e && (this.#n = super.getExprValue(e, this.tr.data, this.tr.dataset.row), this.querySelector("datalist")?.remove(), this.#n && Array.isArray(this.#n))) {
3406
3401
  let e = `color-list-${Math.random().toString(36).substr(2, 9)}`, t = document.createElement("datalist");
@@ -3690,51 +3685,50 @@ var K = class extends HTMLElement {
3690
3685
  connectedCallback() {
3691
3686
  this.#u(), this.#l();
3692
3687
  }
3693
- #i = (e, t, r, i, a) => {
3694
- let o = this.querySelector("nine-table-simple");
3695
- if (!o || !e || e.length === 0) return;
3696
- let s = this.#e.getAttribute("items"), c = [];
3697
- c = s ? s.split(",").map((e) => e.trim()) : [r].filter(Boolean);
3698
- let l = c.length;
3699
- o.shadowRoot.querySelector(".ng-container-left").style.display = i ? "" : "none", o.shadowRoot.querySelectorAll("table colgroup col, tbody td").forEach((e, t) => {
3700
- n.log(e);
3701
- let r = parseInt(e.dataset.col, 10);
3702
- r >= 2 && (e.style.display = r - 2 >= l ? "none" : "");
3688
+ #i = (e, t, n, r, i) => {
3689
+ let a = this.querySelector("nine-table-simple");
3690
+ if (!a || !e || e.length === 0) return;
3691
+ let o = this.#e.getAttribute("items"), s = [];
3692
+ s = o ? o.split(",").map((e) => e.trim()) : [n].filter(Boolean);
3693
+ let c = s.length;
3694
+ a.shadowRoot.querySelector(".ng-container-left").style.display = r ? "" : "none", a.shadowRoot.querySelectorAll("table colgroup col, tbody td").forEach((e, t) => {
3695
+ let n = parseInt(e.dataset.col, 10);
3696
+ n >= 2 && (e.style.display = n - 2 >= c ? "none" : "");
3703
3697
  });
3704
- let u = e.map((e) => {
3698
+ let l = e.map((e) => {
3705
3699
  let n = {
3706
3700
  CHK: "N",
3707
3701
  k: t && e[t] !== void 0 ? e[t] : e[0] === void 0 ? "" : e[0]
3708
3702
  };
3709
- return c.forEach((t, r) => {
3703
+ return s.forEach((t, r) => {
3710
3704
  n[`tmp${r + 1}`] = e[t] === void 0 ? e[r] === void 0 ? "" : e[r] : e[t];
3711
3705
  }), n;
3712
3706
  });
3713
- if (o.data.set(u), i && this.#e.value) {
3714
- let e = String(this.#e.value).split(a || ",");
3715
- o.data.getValidData().forEach((t) => {
3707
+ if (a.data.set(l), r && this.#e.value) {
3708
+ let e = String(this.#e.value).split(i || ",");
3709
+ a.data.getValidData().forEach((t) => {
3716
3710
  e.includes(String(t.v[1])) && (t.v[0] = "Y");
3717
- }), o.refreshData();
3711
+ }), a.refreshData();
3718
3712
  }
3719
3713
  };
3720
- open = (e, t, r, i, a, o) => {
3721
- this.#e = e, this.#t = r, this.#n = i, this.#r = !0, n.log(/* @__PURE__ */ new Date()), this.classList.add("active");
3722
- let s = this.querySelector("nine-table-simple");
3723
- if (!s || !t) return;
3724
- this.querySelector(".search-input").value = "", this.querySelector("#chkAll").checked = !0, t.length > 10 ? this.classList.add("expand") : this.classList.remove("expand"), a ? this.classList.add("multi") : this.classList.remove("multi");
3725
- let c = e.closest("nine-table-sheet"), l = e.querySelector(".btn1");
3726
- if (!l || !c) return;
3727
- let u = l.getBoundingClientRect(), d = c.getBoundingClientRect(), f = u.left - d.left, p = u.bottom - d.top + 2, m = this.offsetWidth || 250, h = this.offsetHeight || 250;
3728
- if (f + m > d.width && (f = Math.max(0, d.width - m - 5)), f < 0 && (f = 5), p + h > d.height) {
3729
- let e = u.top - d.top - h - 2;
3730
- p = e >= 0 ? e : Math.max(0, d.height - h - 5);
3714
+ open = (e, t, n, r, i, a) => {
3715
+ this.#e = e, this.#t = n, this.#n = r, this.#r = !0, this.classList.add("active");
3716
+ let o = this.querySelector("nine-table-simple");
3717
+ if (!o || !t) return;
3718
+ this.querySelector(".search-input").value = "", this.querySelector("#chkAll").checked = !0, t.length > 10 ? this.classList.add("expand") : this.classList.remove("expand"), i ? this.classList.add("multi") : this.classList.remove("multi");
3719
+ let s = e.closest("nine-table-sheet"), c = e.querySelector(".btn1");
3720
+ if (!c || !s) return;
3721
+ let l = c.getBoundingClientRect(), u = s.getBoundingClientRect(), d = l.left - u.left, f = l.bottom - u.top + 2, p = this.offsetWidth || 250, m = this.offsetHeight || 250;
3722
+ if (d + p > u.width && (d = Math.max(0, u.width - p - 5)), d < 0 && (d = 5), f + m > u.height) {
3723
+ let e = l.top - u.top - m - 2;
3724
+ f = e >= 0 ? e : Math.max(0, u.height - m - 5);
3731
3725
  }
3732
- this.style.left = `${f}px`, this.style.top = `${p}px`, n.log(/* @__PURE__ */ new Date()), setTimeout(() => {
3733
- n.log(/* @__PURE__ */ new Date()), this.#i(t, r, i, a, o), n.log(/* @__PURE__ */ new Date());
3734
- let e = s.shadowRoot.querySelector(".ng-container-body table tbody.body");
3726
+ this.style.left = `${d}px`, this.style.top = `${f}px`, setTimeout(() => {
3727
+ this.#i(t, n, r, i, a);
3728
+ let e = o.shadowRoot.querySelector(".ng-container-body table tbody.body");
3735
3729
  e.__hasClickEvent ||= (e.addEventListener("mousedown", (e) => {
3736
- n.log("==========================================", e.target), e.target.closest("tr") && (n.log("==========================================", a), a || this.#a(e));
3737
- }), !0), n.log(/* @__PURE__ */ new Date());
3730
+ e.target.closest("tr") && (i || this.#a(e));
3731
+ }), !0);
3738
3732
  }, 100);
3739
3733
  };
3740
3734
  close = () => {
@@ -3789,13 +3783,13 @@ var q = class extends z {
3789
3783
  #a;
3790
3784
  #o;
3791
3785
  constructor() {
3792
- super(), this.applyBaseStyle();
3786
+ super();
3793
3787
  }
3794
3788
  connectedCallback() {
3795
3789
  this.#u(), super.connectedCallback(), this.#n = super.cell.getAttribute("key-name") || "k", this.#r = super.cell.getAttribute("value-name") || "v", this.#i = super.cell.getAttribute("multi") === "true", this.#a = super.cell.getAttribute("multi-separator") || ",", this.#s(), this.#c();
3796
3790
  }
3797
3791
  rerenderer = () => {
3798
- n.log("rerenderer"), this.#s(), this.refresh();
3792
+ this.#s(), this.refresh();
3799
3793
  };
3800
3794
  #s = () => {
3801
3795
  if (!super.sheet || !super.cell) return;
@@ -3810,7 +3804,7 @@ var q = class extends z {
3810
3804
  });
3811
3805
  };
3812
3806
  #l = () => {
3813
- n.log(/* @__PURE__ */ new Date()), this.#o || (this.#o = super.sheet.querySelector("cell-combo-panel"), this.#o || (this.#o = document.createElement("cell-combo-panel"), super.sheet.appendChild(this.#o))), n.log(/* @__PURE__ */ new Date()), this.#o.isOpen && this.#o.targetCell === this ? this.#o.close() : this.#o.open(this, this.#t, this.#n, this.#r, this.#i, this.#a), n.log(/* @__PURE__ */ new Date());
3807
+ 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);
3814
3808
  };
3815
3809
  #u = () => {
3816
3810
  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");
@@ -3891,8 +3885,7 @@ var Y = class extends R {
3891
3885
  this.#e.innerHTML = this.getDisplayText(e);
3892
3886
  };
3893
3887
  #n = () => {
3894
- let e = this.closest("th,td");
3895
- (parseInt(e.offsetHeight, 10) || 32) - 8, this.innerHTML = "\n <button class=\"button\">...</button>\n ";
3888
+ this.innerHTML = "\n <button class=\"button\">...</button>\n ";
3896
3889
  };
3897
3890
  };
3898
3891
  customElements.get("cell-button") || customElements.define("cell-button", Y);
@@ -3902,10 +3895,10 @@ var X = class extends R {
3902
3895
  #t;
3903
3896
  #n;
3904
3897
  constructor() {
3905
- super(), this.applyBaseStyle();
3898
+ super();
3906
3899
  }
3907
3900
  connectedCallback() {
3908
- this.#r(), super.connectedCallback?.(), this.cell && (this.cell.removeAttribute("tabindex"), this.cell.dataset.bind = "rowState", this.cell.dataset.expr || (this.cell.dataset.expr = "data.__ng._[ninegrid.ROW.ORDER]"), this.cell.setAttribute("text-align", "center")), this.#e = this.querySelector(".ng-row-main"), this.#t = this.querySelector(".ng-row-sub"), this.#n = this.querySelector(".ng-row-status");
3901
+ this.#r(), super.connectedCallback(), this.cell && (this.cell.removeAttribute("tabindex"), this.cell.dataset.bind = "rowState", this.cell.dataset.expr, this.cell.setAttribute("text-align", "right")), this.#e = this.querySelector(".ng-row-main"), this.#t = this.querySelector(".ng-row-sub"), this.#n = this.querySelector(".ng-row-status");
3909
3902
  }
3910
3903
  #r = () => {
3911
3904
  this.innerHTML = "\n <span class=\"ng-row-main\"></span>\n <span class=\"ng-row-sub\"></span>\n <span class=\"ng-row-status\"></span>\n ";