e-virt-table 1.3.19 → 1.3.21

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
@@ -6748,22 +6748,21 @@ class Oi {
6748
6748
  this.enable && this.doneEdit();
6749
6749
  }), this.ctx.on("hoverIconClick", (t) => {
6750
6750
  this.editCell(t.rowIndex, t.colIndex);
6751
- }), this.ctx.on("cellMousedown", () => {
6752
- this.inputEl.focus({ preventScroll: !0 });
6753
6751
  }), this.ctx.on("keydown", (t) => {
6754
6752
  if (!this.ctx.isTarget(t) || !this.ctx.focusCell || this.ctx.finding)
6755
6753
  return;
6756
- if (t.code === "Escape" && this.ctx.editing) {
6754
+ const { focusCell: e } = this.ctx;
6755
+ if (e.isVerticalVisible() && e.isHorizontalVisible() || this.ctx.emit("scrollToIndex", e.rowIndex, e.colIndex), t.code === "Escape" && this.ctx.editing) {
6757
6756
  this.cancel = !0;
6758
- const { focusCell: l } = this.ctx;
6759
- l && (this.ctx.emit("setSelectorCell", l), this.cellTarget = l), this.doneEdit();
6757
+ const { focusCell: f } = this.ctx;
6758
+ f && (this.ctx.emit("setSelectorCell", f), this.cellTarget = f), this.doneEdit();
6760
6759
  return;
6761
6760
  }
6762
6761
  if ((t.altKey || t.metaKey) && t.key === "Enter" && this.ctx.editing && this.inputEl) {
6763
6762
  t.preventDefault();
6764
- const l = this.inputEl.selectionStart, h = this.inputEl.value.substring(0, l), d = this.inputEl.value.substring(l);
6765
- this.inputEl.value = h + `
6766
- ` + d, this.inputEl.selectionStart = this.inputEl.selectionEnd = l + 1, this.autoSize();
6763
+ const f = this.inputEl.selectionStart, u = this.inputEl.value.substring(0, f), x = this.inputEl.value.substring(f);
6764
+ this.inputEl.value = u + `
6765
+ ` + x, this.inputEl.selectionStart = this.inputEl.selectionEnd = f + 1, this.autoSize();
6767
6766
  return;
6768
6767
  }
6769
6768
  if (t.code === "Tab" && this.ctx.editing) {
@@ -6786,8 +6785,8 @@ class Oi {
6786
6785
  t.preventDefault(), this.startEdit();
6787
6786
  return;
6788
6787
  }
6789
- const e = t.key, i = t.ctrlKey, s = t.altKey, o = t.shiftKey, r = t.metaKey;
6790
- i || s || o || r || [
6788
+ const s = t.key, o = t.ctrlKey, r = t.altKey, a = t.shiftKey, l = t.metaKey;
6789
+ if (o || r || a || l || [
6791
6790
  "Enter",
6792
6791
  "Escape",
6793
6792
  "Tab",
@@ -6814,7 +6813,14 @@ class Oi {
6814
6813
  "F10",
6815
6814
  "F11",
6816
6815
  "F12"
6817
- ].includes(e) || this.startEdit(!0);
6816
+ ].includes(s))
6817
+ return;
6818
+ const d = document.activeElement === this.inputEl;
6819
+ if (!this.ctx.selectOnlyOne || !d) {
6820
+ t.preventDefault(), this.inputEl.blur();
6821
+ return;
6822
+ }
6823
+ this.startEdit(!0);
6818
6824
  }), this.ctx.on("cellMouseup", (t) => {
6819
6825
  if (this.ctx.isPointer || !this.isInSelectorRange(t.rowIndex, t.colIndex))
6820
6826
  return;
@@ -6829,7 +6835,7 @@ class Oi {
6829
6835
  return;
6830
6836
  }
6831
6837
  }
6832
- if (this.selectorArrStr = s, this.doneEdit(), this.cellTarget = t, this.resetEditorStyle(), this.ctx.config.ENABLE_EDIT_SINGLE_CLICK) {
6838
+ if (this.selectorArrStr = s, this.doneEdit(), this.cellTarget = t, this.ctx.selectOnlyOne && this.inputEl.focus({ preventScroll: !0 }), this.resetEditorStyle(), this.ctx.config.ENABLE_EDIT_SINGLE_CLICK) {
6833
6839
  if (this.ctx.config.ENABLE_MERGE_CELL_LINK && this.ctx.onlyMergeCell) {
6834
6840
  this.startEdit();
6835
6841
  return;
@@ -6837,7 +6843,7 @@ class Oi {
6837
6843
  this.ctx.selectOnlyOne && this.startEdit();
6838
6844
  }
6839
6845
  }), this.ctx.on("mousedownBodyOutside", () => {
6840
- this.enable && this.doneEdit(), this.cellTarget = null;
6846
+ this.clearEditor();
6841
6847
  });
6842
6848
  }
6843
6849
  isInSelectorRange(t, e) {
@@ -6874,7 +6880,7 @@ class Oi {
6874
6880
  header: d
6875
6881
  } = this.ctx;
6876
6882
  let f = this.ctx.body.visibleHeight;
6877
- o > f && (o = f), this.editorEl.style.display = "inline-block", this.editorEl.style.zIndex = "100", this.editorEl.style.left = `${this.drawX - 1}px`, this.editorEl.style.top = `${this.drawY - 1}px`, this.editorEl.style.bottom = "auto", this.editorEl.style.maxHeight = `${f}px`, s === "text" ? (this.inputEl.style.display = "inline-block", this.inputEl.style.minWidth = `${r - 1}px`, this.inputEl.style.minHeight = `${o - 1}px`, this.inputEl.style.maxHeight = `${f}px`, this.inputEl.style.width = `${r - 1}px`, this.inputEl.style.height = "auto", this.inputEl.style.padding = `${h}px`, this.inputEl.value = "", i !== null && (this.inputEl.value = i, this.inputEl.focus({ preventScroll: !0 }))) : this.inputEl.style.display = "none", (this.inputEl.scrollHeight > o || this.drawY < d.height) && this.autoSize();
6883
+ o > f && (o = f), this.editorEl.style.zIndex = "100", this.editorEl.style.left = `${this.drawX - 1}px`, this.editorEl.style.top = `${this.drawY}px`, this.editorEl.style.bottom = "auto", this.editorEl.style.maxWidth = "none", this.editorEl.style.maxHeight = `${f}px`, ["text"].includes(s) ? (this.inputEl.style.opacity = "1", this.inputEl.style.position = "relative", this.inputEl.style.minWidth = `${r - 1}px`, this.inputEl.style.minHeight = `${o - 1}px`, this.inputEl.style.maxHeight = `${f}px`, this.inputEl.style.width = `${r}px`, this.inputEl.style.height = "auto", this.inputEl.style.padding = `${h}px`, this.inputEl.value = "", i !== null && (this.inputEl.value = i)) : (this.inputEl.style.opacity = "0", this.inputEl.style.width = "1px", this.inputEl.style.height = "1px", this.inputEl.style.position = "absolute", this.inputEl.style.left = "0px", this.inputEl.style.top = "0px"), (this.inputEl.scrollHeight > o || this.drawY < d.height) && this.autoSize();
6878
6884
  }
6879
6885
  doneEditByInput() {
6880
6886
  if (this.cellTarget && this.cellTarget.editorType === "text") {
@@ -6914,10 +6920,10 @@ class Oi {
6914
6920
  }
6915
6921
  resetEditorStyle() {
6916
6922
  const t = this.cellTarget;
6917
- t && (this.editorEl.style.left = `${t.drawX}px`, this.editorEl.style.top = `${t.drawY}px`, this.editorEl.style.maxHeight = `${t.visibleHeight}px`, this.editorEl.style.zIndex = "-1");
6923
+ t && (this.editorEl.style.left = `${t.drawX}px`, this.editorEl.style.top = `${t.drawY}px`, this.editorEl.style.maxWidth = "1px", this.editorEl.style.maxHeight = "1px", this.editorEl.style.zIndex = "-1");
6918
6924
  }
6919
6925
  clearEditor() {
6920
- this.doneEdit(), this.cellTarget = null, this.selectorArrStr = "", this.ctx.clearSelector(), this.ctx.focusCell = void 0, this.ctx.emit("draw");
6926
+ this.doneEdit(), this.cellTarget = null, this.selectorArrStr = "", this.ctx.clearSelector(), this.ctx.focusCell = void 0, this.inputEl.blur(), this.ctx.emit("draw");
6921
6927
  }
6922
6928
  destroy() {
6923
6929
  var t;