e-virt-table 0.1.26 → 0.1.28

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
@@ -797,7 +797,7 @@ class ii {
797
797
  if (typeof c == "function" && (w = c), d) {
798
798
  const p = i[d];
799
799
  if (this.checkboxKeyMap.has(p)) {
800
- const y = this.checkboxKeyMap.get(p);
800
+ const y = this.checkboxKeyMap.get(p) || [];
801
801
  y.push(x), this.checkboxKeyMap.set(p, y);
802
802
  } else
803
803
  this.checkboxKeyMap.set(p, [x]);
@@ -824,7 +824,10 @@ class ii {
824
824
  * @param height
825
825
  */
826
826
  setRowHeight(t, e) {
827
- const i = this.rowIndexRowKeyMap.get(t), s = this.rowKeyMap.get(i);
827
+ const i = this.rowIndexRowKeyMap.get(t);
828
+ if (i === void 0)
829
+ return;
830
+ const s = this.rowKeyMap.get(i);
828
831
  s.height = e, s.item._height = e, this.clearBufferData();
829
832
  }
830
833
  /**
@@ -970,7 +973,7 @@ class ii {
970
973
  * @returns
971
974
  */
972
975
  getRowKeyForRowIndex(t) {
973
- return this.rowIndexRowKeyMap.get(t);
976
+ return this.rowIndexRowKeyMap.get(t) || "";
974
977
  }
975
978
  getRowKeyByItem(t) {
976
979
  return this.itemRowKeyMap.get(t);
@@ -988,7 +991,7 @@ class ii {
988
991
  if (!(this.rowIndexRowKeyMap.has(t) && this.colIndexKeyMap.get(e)))
989
992
  return null;
990
993
  const s = this.rowIndexRowKeyMap.get(t), r = this.colIndexKeyMap.get(e);
991
- return {
994
+ return s === void 0 || r === void 0 ? null : {
992
995
  rowKey: s,
993
996
  key: r,
994
997
  value: this.getItemValue(s, r)
@@ -1161,7 +1164,7 @@ class ii {
1161
1164
  if (!this.rowKeyMap.has(t))
1162
1165
  return !1;
1163
1166
  const { item: s } = this.rowKeyMap.get(t), r = s[i];
1164
- this.checkboxKeyMap.has(r) && this.checkboxKeyMap.get(r).forEach((a) => {
1167
+ this.checkboxKeyMap.has(r) && (this.checkboxKeyMap.get(r) || []).forEach((a) => {
1165
1168
  const h = this.rowKeyMap.get(a);
1166
1169
  h.check = e;
1167
1170
  });
@@ -1327,7 +1330,7 @@ class ii {
1327
1330
  if (i)
1328
1331
  return !0;
1329
1332
  const s = this.rowKeyMap.get(t), r = this.headerMap.get(e), o = s == null ? void 0 : s.readonly, a = r == null ? void 0 : r.readonly, { BODY_CELL_READONLY_METHOD: h } = this.ctx.config;
1330
- if (typeof h == "function") {
1333
+ if (typeof h == "function" && r) {
1331
1334
  const d = h({
1332
1335
  row: s.item,
1333
1336
  rowIndex: s.rowIndex,
@@ -1348,7 +1351,10 @@ class ii {
1348
1351
  }
1349
1352
  getValidator(t, e) {
1350
1353
  return new Promise((i) => {
1351
- const s = this.rowKeyMap.get(t), r = this.headerMap.get(e), { BODY_CELL_RULES_METHOD: o } = this.ctx.config, a = r.column;
1354
+ const s = this.rowKeyMap.get(t), r = this.headerMap.get(e), { BODY_CELL_RULES_METHOD: o } = this.ctx.config;
1355
+ if (r === void 0)
1356
+ return i([]);
1357
+ const a = r.column;
1352
1358
  let h = a.rules;
1353
1359
  if (typeof o == "function") {
1354
1360
  const d = o({
@@ -1362,7 +1368,7 @@ class ii {
1362
1368
  }
1363
1369
  if (h) {
1364
1370
  let c = {}, d = {};
1365
- if (d[e] = this.getItemValue(t, e), Array.isArray(h) && h.length) {
1371
+ if (d[e] = this.getItemValue(t, e), Array.isArray(h)) {
1366
1372
  const x = h.map((u) => ({
1367
1373
  ...u,
1368
1374
  row: s.item,
@@ -2026,7 +2032,7 @@ class ee extends te {
2026
2032
  l(this, "render");
2027
2033
  l(this, "renderFooter");
2028
2034
  l(this, "style", {});
2029
- l(this, "rules", {});
2035
+ l(this, "rules", []);
2030
2036
  l(this, "message", "");
2031
2037
  l(this, "text", "");
2032
2038
  l(this, "displayText", "");
@@ -2052,13 +2058,13 @@ class ee extends te {
2052
2058
  l(this, "overflowTooltipShow", !0);
2053
2059
  l(this, "overflowTooltipMaxWidth", 500);
2054
2060
  l(this, "overflowTooltipPlacement", "top");
2055
- 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.editorProps = c.editorProps || {}, this.cellType = f, 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 = d, 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();
2061
+ 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.editorProps = c.editorProps || {}, this.cellType = f, 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 = d, 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();
2056
2062
  }
2057
2063
  getValidationMessage() {
2058
2064
  const e = this.ctx.database.getValidationError(this.rowKey, this.key);
2059
2065
  if (Array.isArray(e) && e.length) {
2060
2066
  const [i] = e;
2061
- this.message = i.message;
2067
+ this.message = i.message || "";
2062
2068
  }
2063
2069
  return this.message;
2064
2070
  }
@@ -2747,6 +2753,8 @@ class hi {
2747
2753
  // 自动填充移动中
2748
2754
  l(this, "selectorMove", !1);
2749
2755
  // 选择器移动中
2756
+ l(this, "selectOnlyOne", !1);
2757
+ // 只选择一个单元格
2750
2758
  l(this, "adjustPositioning", !1);
2751
2759
  // 调整位置中
2752
2760
  l(this, "editing", !1);
@@ -3003,7 +3011,7 @@ class Pt {
3003
3011
  } = this.ctx, a = s, h = i, c = e.height, d = e.width, f = t.height, x = this.ctx.footer.height;
3004
3012
  if (this.type === "vertical") {
3005
3013
  this.visibleDistance = h - r - c, this.distance = f - this.visibleDistance + x, this.trackX = a - r, this.trackY = 0, this.splitPoints = [this.trackX, c, this.trackX + r, c], this.trackWidth = r, this.trackHeight = h, this.barX = this.trackX - 0.5 + (r - o) / 2, this.barWidth = o;
3006
- const u = this.distance ? this.visibleDistance / f : 0;
3014
+ const u = this.distance ? this.visibleDistance / (f + x) : 0;
3007
3015
  let g = Math.floor(u * this.visibleDistance);
3008
3016
  g < 30 ? g = 30 : g > this.visibleDistance && (g = 0), this.barHeight = g, this.barY = c + this.scroll / this.distance * (this.visibleDistance - this.barHeight), this.scroll = Math.max(0, Math.min(this.scroll, this.distance));
3009
3017
  } else {
@@ -3313,7 +3321,7 @@ class se {
3313
3321
  l(this, "rowKey", "");
3314
3322
  l(this, "rowType", "body");
3315
3323
  l(this, "data");
3316
- this.ctx = t, this.x = i, this.y = s, this.width = r, this.height = o, this.rowIndex = e, this.rowKey = t.database.getRowKeyForRowIndex(e), this.rowType = h, this.data = a, this.update();
3324
+ this.ctx = t, this.x = i, this.y = s, this.width = r, this.height = o, this.rowIndex = e, this.rowKey = t.database.getRowKeyForRowIndex(e) || "", this.rowType = h, this.data = a, this.update();
3317
3325
  }
3318
3326
  update() {
3319
3327
  const { header: t } = this.ctx, e = [], i = [], s = [];
@@ -3742,7 +3750,7 @@ class ui {
3742
3750
  let [y, b] = r, [m, E] = o;
3743
3751
  if (y < u || b > g || m < w || E > p)
3744
3752
  return;
3745
- this.ctx.stageElement.focus(), this.ctx.selector.xArr = [Math.max(u, y), Math.min(g, b)], this.ctx.selector.yArr = [Math.max(w, m), Math.min(p, E)], this.ctx.emit("setSelector", this.ctx.selector), this.ctx.emit("drawView");
3753
+ this.ctx.stageElement.focus(), y === b && m === E ? this.ctx.selectOnlyOne = !0 : this.ctx.selectOnlyOne = !1, this.ctx.selector.xArr = [Math.max(u, y), Math.min(g, b)], this.ctx.selector.yArr = [Math.max(w, m), Math.min(p, E)], this.ctx.emit("setSelector", this.ctx.selector), this.ctx.emit("drawView");
3746
3754
  }
3747
3755
  }
3748
3756
  selectCols(t) {
@@ -3851,7 +3859,7 @@ class ui {
3851
3859
  yArr: this.ctx.selector.yArrCopy,
3852
3860
  data: t
3853
3861
  }), this.ctx.emit("draw");
3854
- }).catch((i) => console.error("复制失败:", i)) : console.error("当前浏览器不支持Clipboard API");
3862
+ }).catch((i) => console.error("Copy Failure:", i)) : console.error("current browser does not support the Clipboard API");
3855
3863
  }
3856
3864
  clearSelectedData(t, e, i = !1) {
3857
3865
  let s = [];
@@ -3882,14 +3890,17 @@ class ui {
3882
3890
  }
3883
3891
  paste() {
3884
3892
  if (!navigator.clipboard) {
3885
- console.error("当前浏览器不支持Clipboard API");
3893
+ console.error("current browser does not support the Clipboard API");
3886
3894
  return;
3887
3895
  }
3888
3896
  const { ENABLE_PASTER: t } = this.ctx.config;
3889
3897
  if (this.ctx.selector.enable && t) {
3890
3898
  const e = this.ctx.selector.yArr[0], i = this.ctx.selector.xArr[0], s = /* @__PURE__ */ new Set();
3891
3899
  navigator.clipboard.readText().then(async (r) => {
3892
- let o = ti(r), a = [];
3900
+ console.log(typeof r);
3901
+ let o = ti(r);
3902
+ console.log(o);
3903
+ let a = [];
3893
3904
  for (let d = 0; d <= o.length - 1; d++) {
3894
3905
  const f = o[d].length;
3895
3906
  for (let x = 0; x <= f - 1; x++) {
@@ -3939,7 +3950,7 @@ class ui {
3939
3950
  c.push(this.ctx.database.getRowDataItemForRowKey(d));
3940
3951
  }), this.ctx.emit("pasteChange", a, c);
3941
3952
  }).catch((r) => {
3942
- console.error("获取剪贴板内容失败:", r);
3953
+ console.error("Failed to get the clipboard content:", r);
3943
3954
  });
3944
3955
  }
3945
3956
  }
@@ -5205,9 +5216,11 @@ class qi {
5205
5216
  }
5206
5217
  }), this.ctx.on("adjustBoundaryPosition", (t) => {
5207
5218
  this.cellTarget = t;
5219
+ }), this.ctx.on("mouseup", () => {
5220
+ this.ctx.selectOnlyOne || (this.cellTarget = null);
5208
5221
  }), this.ctx.on("cellClick", (t) => {
5209
5222
  var e, i;
5210
- this.ctx.adjustPositioning || (t.rowKey === ((e = this.cellTarget) == null ? void 0 : e.rowKey) && t.key === ((i = this.cellTarget) == null ? void 0 : i.key) ? this.startEdit() : (this.doneEdit(), this.cellTarget = t, this.ctx.config.ENABLE_EDIT_SINGLE_CLICK && this.startEdit()));
5223
+ this.ctx.adjustPositioning || this.ctx.selectOnlyOne && (t.rowKey === ((e = this.cellTarget) == null ? void 0 : e.rowKey) && t.key === ((i = this.cellTarget) == null ? void 0 : i.key) ? this.startEdit() : (this.doneEdit(), this.cellTarget = t, this.ctx.config.ENABLE_EDIT_SINGLE_CLICK && this.startEdit()));
5211
5224
  });
5212
5225
  }
5213
5226
  initTextEditor() {