e-virt-table 0.1.18 → 0.1.20

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
@@ -662,17 +662,17 @@ function Zt(n, t) {
662
662
  }, t - o));
663
663
  };
664
664
  }
665
- function Jt(n) {
666
- return n ? n.map((t) => Jt(t.children) + 1).sort((t, e) => e - t)[0] : 0;
665
+ function Jt(n = []) {
666
+ return n.length ? n.map((t) => Jt(t.children) + 1).sort((t, e) => e - t)[0] : 0;
667
667
  }
668
668
  function Je(n = []) {
669
669
  let t = [], e = [], i = [];
670
670
  return n.forEach((s) => {
671
671
  s.fixed === "left" ? t.push(s) : s.fixed === "right" ? i.push(s) : e.push(s);
672
672
  }), [
673
- ...t.sort((s, r) => s.sort - r.sort),
674
- ...e.sort((s, r) => s.sort - r.sort),
675
- ...i.sort((s, r) => s.sort - r.sort)
673
+ ...t.sort((s, r) => (s.sort ?? 0) - (r.sort ?? 0)),
674
+ ...e.sort((s, r) => (s.sort ?? 0) - (r.sort ?? 0)),
675
+ ...i.sort((s, r) => (s.sort ?? 0) - (r.sort ?? 0))
676
676
  ];
677
677
  }
678
678
  function Qt(n = [], t = 1, e = 0) {
@@ -684,7 +684,7 @@ function Qt(n = [], t = 1, e = 0) {
684
684
  });
685
685
  const o = Qt(i.children, t - 1, e + 1);
686
686
  return o && o.forEach((a) => {
687
- s += a.colspan;
687
+ s += a.colspan ?? 0;
688
688
  }), {
689
689
  ...i,
690
690
  width: i.width,
@@ -1959,7 +1959,7 @@ class te {
1959
1959
  l(this, "height", 0);
1960
1960
  l(this, "fixed");
1961
1961
  l(this, "cellType");
1962
- this.ctx = t, this.x = e, this.y = i, this.width = s, this.height = r, this.fixed = o, this.cellType = a;
1962
+ this.ctx = t, this.x = e, this.y = i, this.width = s, this.height = r, this.fixed = a, this.cellType = o;
1963
1963
  }
1964
1964
  isHorizontalVisible() {
1965
1965
  if (this.fixed)
@@ -1998,7 +1998,7 @@ class te {
1998
1998
  }
1999
1999
  class ee extends te {
2000
2000
  constructor(e, i, s, r, o, a, h, c, f, d = "body") {
2001
- super(e, r, o, a, h, c.fixed, d);
2001
+ super(e, r, o, a, h, d, c.fixed);
2002
2002
  l(this, "formatter");
2003
2003
  l(this, "formatterFooter");
2004
2004
  l(this, "hoverIconName", "");
@@ -2048,7 +2048,7 @@ class ee extends te {
2048
2048
  l(this, "overflowTooltipShow", !0);
2049
2049
  l(this, "overflowTooltipMaxWidth", 500);
2050
2050
  l(this, "overflowTooltipPlacement", "top");
2051
- this.visibleWidth = this.width, this.visibleHeight = this.height, this.colIndex = s, this.rowIndex = i, this.key = c.key, this.type = c.type || "text", this.editorType = c.editorType || "text", this.cellType = d, this.align = c.align || "center", this.verticalAlign = c.verticalAlign || "middle", this.fixed = c.fixed, this.level = c.level, this.operation = c.operation || !1, this.column = c, this.rules = c.rules, this.row = f, this.rowKey = this.cellType === "body" ? this.ctx.database.getRowKeyForRowIndex(i) : `${this.cellType}_${this.rowIndex}`, this.value = this.getValue(), this.render = c.render, this.overflowTooltipShow = c.overflowTooltipShow !== !1, this.overflowTooltipMaxWidth = c.overflowTooltipMaxWidth || 500, this.overflowTooltipPlacement = c.overflowTooltipPlacement || "top", this.renderFooter = c.renderFooter, this.hoverIconName = c.hoverIconName, this.formatter = c.formatter, this.formatterFooter = c.formatterFooter, this.update();
2051
+ this.visibleWidth = this.width, this.visibleHeight = this.height, this.colIndex = s, this.rowIndex = i, this.key = c.key, this.type = c.type || "", this.editorType = c.editorType || "text", this.cellType = d, this.align = c.align || "center", this.verticalAlign = c.verticalAlign || "middle", this.fixed = c.fixed, this.level = c.level || 0, this.operation = c.operation || !1, this.column = c, this.rules = c.rules || {}, this.row = f, this.rowKey = this.cellType === "body" ? this.ctx.database.getRowKeyForRowIndex(i) : `${this.cellType}_${this.rowIndex}`, this.value = this.getValue(), this.render = c.render, this.overflowTooltipShow = c.overflowTooltipShow !== !1, this.overflowTooltipMaxWidth = c.overflowTooltipMaxWidth || 500, this.overflowTooltipPlacement = c.overflowTooltipPlacement || "top", this.renderFooter = c.renderFooter, this.hoverIconName = c.hoverIconName, this.formatter = c.formatter, this.formatterFooter = c.formatterFooter, this.update();
2052
2052
  }
2053
2053
  getValidationMessage() {
2054
2054
  const e = this.ctx.database.getValidationError(this.rowKey, this.key);
@@ -2440,7 +2440,7 @@ class ee extends te {
2440
2440
  }
2441
2441
  class ie extends te {
2442
2442
  constructor(e, i, s, r, o, a, h) {
2443
- super(e, s, r, o, a, h.fixed, "header");
2443
+ super(e, s, r, o, a, "header", h.fixed);
2444
2444
  l(this, "align");
2445
2445
  l(this, "verticalAlign", "middle");
2446
2446
  l(this, "fixed");
@@ -2453,6 +2453,7 @@ class ie extends te {
2453
2453
  l(this, "displayText", "");
2454
2454
  l(this, "colspan");
2455
2455
  l(this, "rowspan");
2456
+ l(this, "row");
2456
2457
  l(this, "key");
2457
2458
  l(this, "required", !1);
2458
2459
  l(this, "readonly", !1);
@@ -2474,7 +2475,7 @@ class ie extends te {
2474
2475
  l(this, "drawImageHeight", 0);
2475
2476
  l(this, "drawImageName", "");
2476
2477
  l(this, "drawImageSource");
2477
- this.ctx = e, this.x = s, this.y = r, this.width = o, this.height = a, this.colIndex = i, this.key = h.key, this.type = h.type, this.editorType = h.editorType || "text", this.align = h.align || "center", this.verticalAlign = h.verticalAlign || "middle", this.fixed = h.fixed, this.level = h.level, this.operation = h.operation || !1, this.text = h.title, this.column = h, this.colspan = h.colspan, this.widthFillDisable = h.widthFillDisable, this.rowspan = h.rowspan, this.rules = h.rules, this.readonly = h.readonly, this.required = h.required, this.rowKey = Ut(), this.hasChildren = h.children && h.children.length > 0 || !1, this.render = h.renderHeader;
2478
+ this.ctx = e, this.x = s, this.y = r, this.width = o, this.height = a, this.colIndex = i, this.key = h.key, this.type = h.type || "", this.editorType = h.editorType || "text", this.align = h.align || "center", this.verticalAlign = h.verticalAlign || "middle", this.fixed = h.fixed, this.level = h.level || 0, this.operation = h.operation || !1, this.text = h.title, this.column = h, this.colspan = h.colspan || 1, this.widthFillDisable = h.widthFillDisable || !1, this.rowspan = h.rowspan || 1, this.rules = h.rules, this.readonly = h.readonly || !1, this.required = h.required || !1, this.rowKey = Ut(), this.hasChildren = h.children && h.children.length > 0 || !1, this.render = h.renderHeader;
2478
2479
  }
2479
2480
  /**
2480
2481
  * 是否可见,覆盖基类方法,表头是跟y滚动条没有关系的所以不需要加滚动参数
@@ -2948,7 +2949,7 @@ class Pt {
2948
2949
  const { offsetX: e, offsetY: i, clientX: s, clientY: r } = t;
2949
2950
  if (!(s == this.clientX && r == this.clientY)) {
2950
2951
  if (this.isOnScrollbar(e, i))
2951
- this.clientX = s, this.clientY = r, this.isDragging = !0, this.ctx.scrollerMove = !0, this.isFocus = !0, this.dragStart = this.scroll;
2952
+ this.clientX = s, this.clientY = r, this.isDragging = !0, this.ctx.scrollerMove = !0, this.isFocus = !0, this.dragStart = this.scroll, t.preventDefault();
2952
2953
  else if (this.isOnTrack(e, i)) {
2953
2954
  let o = 0;
2954
2955
  this.type === "vertical" ? o = (i - this.ctx.header.height - this.barHeight / 2) / (this.visibleDistance - this.barHeight) * this.distance : o = (e - this.barWidth / 2) / (this.visibleDistance - this.barWidth) * this.distance, this.scroll = Math.max(0, Math.min(o, this.distance));
@@ -3226,7 +3227,7 @@ class di {
3226
3227
  let s = e;
3227
3228
  const { HEADER_HEIGHT: r = 0 } = this.ctx.config;
3228
3229
  for (let o = 0; o < i; o++) {
3229
- const a = t[o], h = r * (a.rowspan || 1), c = r * a.level;
3230
+ const a = t[o], h = r * (a.rowspan || 0), c = r * (a.level || 0);
3230
3231
  let f = a.width || 100;
3231
3232
  a.children && (f = _t(a.children).reduce((u, g) => u + ((g == null ? void 0 : g.width) || 100), 0));
3232
3233
  const d = new ie(this.ctx, this.columnIndex, s, c, f, h, a);
@@ -3390,7 +3391,7 @@ class fi {
3390
3391
  const { top: u } = t.getBoundingClientRect();
3391
3392
  this.width = e.width, this.visibleWidth = this.ctx.stageWidth - r;
3392
3393
  const g = this.ctx.footer.height;
3393
- this.data.length || (this.height = a);
3394
+ !this.data.length && !o ? this.height = a : !this.data.length && o && (this.height = o - e.height - g - r);
3394
3395
  const w = this.data.length ? "not-empty" : "empty";
3395
3396
  this.ctx.emit("emptyChange", {
3396
3397
  isEmpty: w,
@@ -3645,7 +3646,7 @@ class ui {
3645
3646
  this.isMultipleRow = !0, this.selectRows(t);
3646
3647
  return;
3647
3648
  }
3648
- this.isMultipleRow = !1, this.click(e.shiftKey);
3649
+ e.preventDefault(), this.isMultipleRow = !1, this.click(e.shiftKey);
3649
3650
  }
3650
3651
  }), this.ctx.on("mouseup", () => {
3651
3652
  this.mousedownHeader = !1;
@@ -3654,8 +3655,8 @@ class ui {
3654
3655
  }, 0);
3655
3656
  }), this.ctx.on("cellHeaderHoverChange", (t) => {
3656
3657
  this.ctx.mousedown && this.selectCols(t);
3657
- }), this.ctx.on("cellHeaderMousedown", (t) => {
3658
- this.ctx.stageElement.style.cursor !== "pointer" && (this.ctx.isPointer || (this.mousedownHeader = !0, this.selectCols(t)));
3658
+ }), this.ctx.on("cellHeaderMousedown", (t, e) => {
3659
+ this.ctx.stageElement.style.cursor !== "pointer" && (this.ctx.isPointer || (e.preventDefault(), this.mousedownHeader = !0, this.selectCols(t)));
3659
3660
  }), this.ctx.on("keydown", (t) => {
3660
3661
  if (t.ctrlKey && t.code === "KeyV" || t.metaKey && t.code === "KeyV") {
3661
3662
  t.preventDefault(), this.paste();
@@ -5083,7 +5084,7 @@ let $i = class {
5083
5084
  const i = this.ctx.containerElement.getBoundingClientRect();
5084
5085
  if (!i)
5085
5086
  return;
5086
- this.enable = !0, this.contentEl.style.maxWidth = `${t.overflowTooltipMaxWidth || 500}px`, this.contentEl.style.width = "100%", this.contentEl.style.display = "inline-block", this.contentEl.style.wordBreak = "break-all", this.contentEl.style.lineHeight = "1.5", this.contentEl.innerText = e;
5087
+ this.enable = !0, this.contentEl.style.maxWidth = `${t.overflowTooltipMaxWidth || 500}px`, this.contentEl.style.minWidth = "100px", this.contentEl.style.width = "100%", this.contentEl.style.display = "inline-block", this.contentEl.style.wordBreak = "break-all", this.contentEl.style.lineHeight = "1.5", this.contentEl.innerText = e;
5087
5088
  const s = t.drawX + i.x, r = t.drawY + i.y;
5088
5089
  pe({
5089
5090
  getBoundingClientRect() {
@@ -5236,7 +5237,7 @@ class qi {
5236
5237
  header: c
5237
5238
  } = this.ctx;
5238
5239
  let f = this.ctx.body.visibleHeight;
5239
- if (a > f && (a = f), this.editorEl.style.left = `${r - 1}px`, this.editorEl.style.top = `${o - 1}px`, this.editorEl.style.bottom = "auto", this.editorEl.style.maxHeight = `${f}px`, s === "text") {
5240
+ if (a > f && (a = f), this.editorEl.style.display = "inline-block", this.editorEl.style.left = `${r - 1}px`, this.editorEl.style.top = `${o - 1}px`, this.editorEl.style.bottom = "auto", this.editorEl.style.maxHeight = `${f}px`, s === "text") {
5240
5241
  this.inputEl.style.display = "block", this.inputEl.style.minWidth = `${i - 1}px`, this.inputEl.style.minHeight = `${a - 1}px`, this.inputEl.style.maxHeight = `${f}px`, this.inputEl.style.width = `${i - 1}px`, this.inputEl.style.height = "auto", this.inputEl.style.padding = `${h}px`, e !== null && (this.inputEl.value = e), this.inputEl.focus();
5241
5242
  const d = this.inputEl.value.length;
5242
5243
  this.inputEl.setSelectionRange(d, d);
@@ -5245,7 +5246,7 @@ class qi {
5245
5246
  (this.inputEl.scrollHeight > a || o < c.height) && this.autoSize();
5246
5247
  }
5247
5248
  doneEditByInput() {
5248
- if (this.cellTarget && (this.editorEl.style.left = "-10000px", this.editorEl.style.top = "-10000px", this.editorEl.style.bottom = "atuo", this.cellTarget.editorType === "text")) {
5249
+ if (this.cellTarget && (this.editorEl.style.display = "none", this.cellTarget.editorType === "text")) {
5249
5250
  const { rowKey: t, key: e } = this.cellTarget, i = this.cellTarget.getValue(), s = this.inputEl.value;
5250
5251
  s !== i && !(s === "" && i === null) && this.ctx.database.setItemValue(t, e, s, !0, !0, !0), this.inputEl.value = "";
5251
5252
  }
@@ -5275,7 +5276,7 @@ class qi {
5275
5276
  r && !h && (this.enable = !0, this.ctx.editing = !0, this.cellTarget = r, this.startEditByInput(this.cellTarget), this.ctx.emit("startEdit", this.cellTarget));
5276
5277
  }
5277
5278
  doneEdit() {
5278
- this.enable && (this.doneEditByInput(), this.ctx.emit("doneEdit", this.cellTarget), this.enable = !1, this.ctx.stageElement.focus(), this.ctx.editing = !1, this.ctx.emit("draw"));
5279
+ this.enable && (this.doneEditByInput(), this.ctx.emit("doneEdit", this.cellTarget), this.enable = !1, this.ctx.stageElement.focus(), this.ctx.editing = !1);
5279
5280
  }
5280
5281
  destroy() {
5281
5282
  var t;