e-virt-table 1.1.9 → 1.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/index.es.js CHANGED
@@ -1071,10 +1071,6 @@ class Tt extends re {
1071
1071
  }
1072
1072
  d && w && (w.rowKey === this.rowKey && (p = f), w.rowIndex >= y && w.rowIndex <= E && (p = f)), h && u && (u.rowKey === this.rowKey && (p = c), u.rowIndex >= y && u.rowIndex <= E && (p = c)), this.drawCellSkyBgColor = p;
1073
1073
  let m = e, C = o;
1074
- if (["index", "index-selection", "selection"].includes(this.type)) {
1075
- this.drawCellBgColor = e, this.drawTextColor = o;
1076
- return;
1077
- }
1078
1074
  if (this.ctx.database.getReadonly(this.rowKey, this.key) || (m = i, C = o), x && (this.rowIndex % 2 ? m = g : m = e), typeof s == "function") {
1079
1075
  const b = s, { backgroundColor: v, color: O } = b({
1080
1076
  row: this.row,
@@ -2376,7 +2372,7 @@ class hi {
2376
2372
  this.ctx = t, this.init();
2377
2373
  }
2378
2374
  init() {
2379
- this.bind(window, "resize", this.handleResize.bind(this)), this.bind(window, "mouseup", this.handleMouseUp.bind(this)), this.bind(window, "mousemove", this.handleMousemove.bind(this)), this.bind(window, "blur", this.handleOutsideMousedown.bind(this)), this.bind(window, "mousedown", this.handleOutsideMousedown.bind(this)), this.bind(this.ctx.stageElement, "click", this.handleClick.bind(this)), this.bind(window, "keydown", this.handleKeydown.bind(this)), this.bind(this.ctx.stageElement, "wheel", this.handleWheel.bind(this)), this.bind(this.ctx.stageElement, "touchstart", this.handleTouchstart.bind(this)), this.bind(this.ctx.stageElement, "touchend", this.handleTouchend.bind(this)), this.bind(this.ctx.stageElement, "touchmove", this.handleTouchmove.bind(this)), this.bind(this.ctx.stageElement, "contextmenu", this.handleContextMenu.bind(this)), this.bind(this.ctx.stageElement, "mousedown", this.handleMouseDown.bind(this)), this.bind(this.ctx.stageElement, "dblclick", this.handleDblclick.bind(this)), this.bind(this.ctx.stageElement, "mouseover", this.handleMouseover.bind(this)), this.bind(this.ctx.stageElement, "mouseout", this.handleMouseout.bind(this));
2375
+ this.bind(window, "resize", this.handleResize.bind(this)), this.bind(window, "mouseup", this.handleMouseUp.bind(this)), this.bind(window, "mousemove", this.handleMousemove.bind(this)), this.bind(window, "blur", this.handleOutsideMousedown.bind(this)), this.bind(window, "mousedown", this.handleOutsideMousedown.bind(this)), this.bind(this.ctx.stageElement, "click", this.handleClick.bind(this)), this.bind(window, "keydown", this.handleKeydown.bind(this)), this.bind(this.ctx.stageElement, "wheel", this.handleWheel.bind(this), { passive: !1 }), this.bind(this.ctx.stageElement, "touchstart", this.handleTouchstart.bind(this), { passive: !1 }), this.bind(this.ctx.stageElement, "touchend", this.handleTouchend.bind(this)), this.bind(this.ctx.stageElement, "touchmove", this.handleTouchmove.bind(this), { passive: !1 }), this.bind(this.ctx.stageElement, "contextmenu", this.handleContextMenu.bind(this)), this.bind(this.ctx.stageElement, "mousedown", this.handleMouseDown.bind(this)), this.bind(this.ctx.stageElement, "dblclick", this.handleDblclick.bind(this)), this.bind(this.ctx.stageElement, "mouseover", this.handleMouseover.bind(this)), this.bind(this.ctx.stageElement, "mouseout", this.handleMouseout.bind(this));
2380
2376
  }
2381
2377
  destroy() {
2382
2378
  this.eventTasks.forEach((t, e) => {
@@ -2858,24 +2854,30 @@ class fi {
2858
2854
  for (let e = 0; e < this.ctx.config.ICONS.length; e++) {
2859
2855
  const i = this.ctx.config.ICONS[e];
2860
2856
  let s = i.color;
2861
- const r = this.createImageFromSVG(i.svg, s).then((o) => {
2857
+ const r = this.createImageFromSVG(i.svg, s, i.isBlob).then((o) => {
2862
2858
  this.icons.set(i.name, o);
2863
2859
  });
2864
2860
  t.push(r);
2865
2861
  }
2866
2862
  await Promise.all(t), this.ctx.emit("draw");
2867
2863
  }
2868
- async createImageFromSVG(t, e) {
2869
- const r = new DOMParser().parseFromString(t, "image/svg+xml").documentElement;
2870
- e && r.querySelectorAll("*").forEach((c) => {
2864
+ async createImageFromSVG(t, e, i = !1) {
2865
+ const o = new DOMParser().parseFromString(t, "image/svg+xml").documentElement;
2866
+ e && o.querySelectorAll("*").forEach((c) => {
2871
2867
  c.setAttribute("fill", e);
2872
2868
  });
2873
- const o = new Image(), n = new Blob([new XMLSerializer().serializeToString(r)], {
2874
- type: "image/svg+xml"
2875
- }), h = URL.createObjectURL(n);
2876
- return o.src = h, new Promise((c, d) => {
2877
- o.onerror = () => d(new Error("Failed to load image")), o.onload = () => {
2878
- c(o);
2869
+ const n = new Image();
2870
+ let h = "";
2871
+ if (i) {
2872
+ const c = new Blob([new XMLSerializer().serializeToString(o)], {
2873
+ type: "image/svg+xml"
2874
+ });
2875
+ h = URL.createObjectURL(c);
2876
+ } else
2877
+ h = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(o));
2878
+ return n.src = h, new Promise((c, d) => {
2879
+ n.onerror = () => d(new Error("Failed to load image")), n.onload = () => {
2880
+ c(n);
2879
2881
  };
2880
2882
  });
2881
2883
  }
@@ -3931,32 +3933,32 @@ class pi {
3931
3933
  this.height = p, this.data = g, this.width = e.width, this.visibleWidth = this.ctx.stageWidth - o;
3932
3934
  const u = this.ctx.footer.height;
3933
3935
  !this.data.length && !n ? this.height = h : !this.data.length && n && (this.height = n - e.height - u - o);
3934
- const w = this.data.length ? "not-empty" : "empty";
3936
+ let w = this.height + e.height + o;
3937
+ w += u;
3938
+ let y = w;
3939
+ const E = window.innerHeight, { top: m } = this.containerRect || this.ctx.containerElement.getBoundingClientRect();
3940
+ if (E > m && d && !n) {
3941
+ const R = E - m - f;
3942
+ R > e.height + o ? y = R : w > c && (y = c);
3943
+ } else this.data.length && n ? y = n : this.data.length && c && w > c && (y = c);
3944
+ y > 0 && (this.ctx.stageHeight = Math.floor(y), this.ctx.stageElement.style.height = `${this.ctx.stageHeight - 0.5}px`);
3945
+ let C = this.ctx.stageHeight - e.height - o;
3946
+ r ? this.visibleHeight = C - u : this.visibleHeight = C, this.data.length || (this.height = this.visibleHeight), this.ctx.body.x = this.x, this.ctx.body.y = this.y, this.ctx.body.width = this.width, this.ctx.body.height = this.height, this.ctx.body.visibleWidth = this.visibleWidth, this.ctx.body.visibleHeight = this.visibleHeight, this.ctx.body.data = g;
3947
+ const b = window.devicePixelRatio || 1, v = this.ctx.stageWidth * b, O = this.ctx.stageHeight * b;
3948
+ t.width = Math.floor(v), t.height = Math.floor(O);
3949
+ const S = this.data.length ? "not-empty" : "empty";
3935
3950
  this.ctx.emit("emptyChange", {
3936
- isEmpty: w,
3937
- type: w,
3951
+ isEmpty: S,
3952
+ type: S,
3938
3953
  headerHeight: e.height,
3939
3954
  bodyHeight: this.height,
3940
3955
  footerHeight: u,
3941
3956
  width: this.width,
3942
3957
  height: this.data.length ? 0 : h + u
3943
- });
3944
- let y = this.height + e.height + o;
3945
- y += u;
3946
- let E = y;
3947
- const m = window.innerHeight, { top: C } = this.containerRect || this.ctx.containerElement.getBoundingClientRect();
3948
- if (this.data.length && m > C && d && !n) {
3949
- const R = m - C - f;
3950
- R > e.height + o ? E = R : y > c && (E = c);
3951
- } else this.data.length && n ? E = n : this.data.length && c && y > c && (E = c);
3952
- E > 0 && (this.ctx.stageHeight = Math.floor(E), this.ctx.stageElement.style.height = `${this.ctx.stageHeight - 0.5}px`);
3953
- let b = this.ctx.stageHeight - e.height - o;
3954
- r ? this.visibleHeight = b - u : this.visibleHeight = b, this.ctx.body.x = this.x, this.ctx.body.y = this.y, this.ctx.body.width = this.width, this.ctx.body.height = this.height, this.ctx.body.visibleWidth = this.visibleWidth, this.ctx.body.visibleHeight = this.visibleHeight, this.ctx.body.data = g;
3955
- const v = window.devicePixelRatio || 1, O = this.ctx.stageWidth * v, S = this.ctx.stageHeight * v;
3956
- t.width = Math.floor(O), t.height = Math.floor(S), this.ctx.canvasElement.setAttribute(
3958
+ }), this.ctx.canvasElement.setAttribute(
3957
3959
  "style",
3958
3960
  ` height:${this.ctx.stageHeight}px;width:${this.ctx.stageWidth}px;`
3959
- ), this.ctx.paint.scale(v);
3961
+ ), this.ctx.paint.scale(b);
3960
3962
  }
3961
3963
  // 调整行的高度
3962
3964
  initResizeRow() {
@@ -6403,7 +6405,7 @@ class rs {
6403
6405
  this.ctx.off(t, e);
6404
6406
  }
6405
6407
  filterMethod(t) {
6406
- this.ctx.setScrollY(0), this.ctx.setScrollX(0), this.ctx.database.init(), this.header.init(), this.ctx.database.setFilterMethod(t), this.ctx.emit("draw");
6408
+ this.scrollTo(0, 0), this.ctx.database.setFilterMethod(t), this.ctx.database.init(), this.ctx.emit("draw");
6407
6409
  }
6408
6410
  editCell(t, e) {
6409
6411
  this.editor.editCell(t, e);