e-virt-table 0.1.8 → 0.1.9

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
@@ -1,4 +1,4 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(':root{--e-virt-table-color-white: #fff;--e-virt-table-color-black: #000000;--e-virt-table-color-primary: rgb(82, 146, 247);--e-virt-table-text-color-primary: #333;--e-virt-table-text-color-regular: #666;--e-virt-table-text-color-secondary: #999;--e-virt-table-box-shadow: 0 2px 12px 0 #0000001a;--e-virt-table-editor-bg-color: #fff;--e-virt-table-border-color: #e1e6eb}.e-virt-table-container{position:relative;outline:none}.e-virt-table-stage{position:relative;overflow:hidden;outline:none;z-index:10;border-radius:8px;border:1px solid var(--e-virt-table-border-color)}.e-virt-table-canvas{position:absolute;left:0;top:0;box-sizing:border-box;border:none;outline:none;z-index:10px}.e-virt-table-editor{position:absolute;top:-10000px;left:-10000px;text-align:left;height:auto;line-height:0;z-index:100;overflow:hidden;background-color:var(--e-virt-table-editor-bg-color);border:2px solid var(--e-virt-table-color-primary);box-sizing:border-box;box-shadow:var(--e-virt-table-box-shadow);display:flex;align-items:center}.e-virt-table-overlayer{position:"absolute";left:0;top:0;overflow:hidden;z-index:10}.e-virt-table-editor-textarea{width:100%;box-sizing:border-box;outline:none;font-weight:400;padding:8px;font-size:12px;color:inherit;white-space:pre-wrap;word-wrap:break-word;word-break:break-all;line-height:1.5;margin:0;border:none;vertical-align:middle;background:var(--e-virt-table-color-white);overflow-y:auto;resize:none}.e-virt-table-context-menu{position:absolute;font-size:14px;color:var(--e-virt-table-text-color-regular);background-color:var(--e-virt-table-color-white);border-radius:4px;border:1px solid #e4e7ed;box-shadow:var(--e-virt-table-box-shadow);width:fit-content;padding:6px 0;z-index:9999;left:-99999px;top:-99999px}.e-virt-table-context-menu-item{cursor:pointer;padding:8px 24px;color:var(--e-virt-table-text-color-regular)}.e-virt-table-context-menu-item:hover{color:var(--e-virt-table-color-primary);background-color:#f5f7fa}')),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(":root{--e-virt-table-color-white: #fff;--e-virt-table-color-black: #000000;--e-virt-table-color-primary: rgb(82, 146, 247);--e-virt-table-text-color-primary: #333;--e-virt-table-text-color-regular: #666;--e-virt-table-text-color-secondary: #999;--e-virt-table-box-shadow: 0 2px 12px 0 #0000001a;--e-virt-table-editor-bg-color: #fff;--e-virt-table-border-color: #e1e6eb}.e-virt-table-container{position:relative;outline:none}.e-virt-table-stage{position:relative;overflow:hidden;outline:none;z-index:10;border-radius:8px;border:1px solid var(--e-virt-table-border-color)}.e-virt-table-canvas{position:absolute;left:0;top:0;box-sizing:border-box;border:none;outline:none;z-index:10}.e-virt-table-editor{position:absolute;top:-10000px;left:-10000px;text-align:left;height:auto;line-height:0;z-index:100;overflow:hidden;background-color:var(--e-virt-table-editor-bg-color);border:2px solid var(--e-virt-table-color-primary);box-sizing:border-box;box-shadow:var(--e-virt-table-box-shadow);display:flex;align-items:center}.e-virt-table-overlayer{position:absolute;left:0;top:0;overflow:hidden;z-index:100;pointer-events:none}.e-virt-table-editor-textarea{width:100%;box-sizing:border-box;outline:none;font-weight:400;padding:8px;font-size:12px;color:inherit;white-space:pre-wrap;word-wrap:break-word;word-break:break-all;line-height:1.5;margin:0;border:none;vertical-align:middle;background:var(--e-virt-table-color-white);overflow-y:auto;resize:none}.e-virt-table-context-menu{position:absolute;font-size:14px;color:var(--e-virt-table-text-color-regular);background-color:var(--e-virt-table-color-white);border-radius:4px;border:1px solid #e4e7ed;box-shadow:var(--e-virt-table-box-shadow);width:fit-content;padding:6px 0;z-index:9999;left:-99999px;top:-99999px}.e-virt-table-context-menu-item{cursor:pointer;padding:8px 24px;color:var(--e-virt-table-text-color-regular)}.e-virt-table-context-menu-item:hover{color:var(--e-virt-table-color-primary);background-color:#f5f7fa}")),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
2
  var me = Object.defineProperty;
3
3
  var Ee = (n, t, e) => t in n ? me(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
4
4
  var h = (n, t, e) => Ee(n, typeof t != "symbol" ? t + "" : t, e);
@@ -1034,7 +1034,7 @@ class ii {
1034
1034
  });
1035
1035
  return s.forEach((a) => {
1036
1036
  r.push(this.ctx.database.getRowDataItemForRowKey(a));
1037
- }), this.ctx.emit("change", o, r), e && this.ctx.history.pushState({
1037
+ }), this.validationErrorMap.size === 0 && this.changedDataMap.size > 0 && this.ctx.emit("validateChangedData", this.getChangedData()), this.ctx.emit("change", o, r), e && this.ctx.history.pushState({
1038
1038
  changeList: i,
1039
1039
  scrollX: this.ctx.scrollX,
1040
1040
  scrollY: this.ctx.scrollY,
@@ -1079,7 +1079,7 @@ class ii {
1079
1079
  value: x,
1080
1080
  row: u
1081
1081
  };
1082
- this.ctx.emit("change", [g], [u]), this.ctx.emit("editChange", {
1082
+ this.validationErrorMap.size === 0 && this.changedDataMap.size > 0 && this.ctx.emit("validateChangedData", this.getChangedData()), this.ctx.emit("change", [g], [u]), this.ctx.emit("editChange", {
1083
1083
  rowKey: t,
1084
1084
  key: e,
1085
1085
  oldValue: l,
@@ -1313,6 +1313,9 @@ class ii {
1313
1313
  clearValidate() {
1314
1314
  this.validationErrorMap.clear();
1315
1315
  }
1316
+ hasValidationError() {
1317
+ return this.validationErrorMap.size !== 0;
1318
+ }
1316
1319
  getValidator(t, e) {
1317
1320
  return new Promise((i) => {
1318
1321
  const s = this.rowKeyMap.get(t), r = this.headerMap.get(e), { BODY_CELL_RULES_METHOD: o } = this.ctx.config, a = r.column;
@@ -1347,7 +1350,7 @@ class ii {
1347
1350
  colIndex: r.colIndex
1348
1351
  };
1349
1352
  new nt(c).validate(f).then(() => {
1350
- this.setValidationError(t, e, []), i([]);
1353
+ this.clearValidationError(t, e), i([]), this.validationErrorMap.size === 0 && this.changedDataMap.size > 0 && this.ctx.emit("validateChangedData", this.getChangedData());
1351
1354
  }).catch(({ errors: x }) => {
1352
1355
  const u = x.map((g) => ({
1353
1356
  ...g,
@@ -1388,6 +1391,10 @@ class ii {
1388
1391
  const s = `${t}​_${e}`;
1389
1392
  this.validationErrorMap.set(s, i);
1390
1393
  }
1394
+ clearValidationError(t, e) {
1395
+ const i = `${t}​_${e}`;
1396
+ this.validationErrorMap.has(i) && this.validationErrorMap.delete(i);
1397
+ }
1391
1398
  getValidationError(t, e) {
1392
1399
  const i = `${t}​_${e}`;
1393
1400
  return this.validationErrorMap.get(i) || [];
@@ -2248,7 +2255,8 @@ class ee extends te {
2248
2255
  left: e,
2249
2256
  top: i,
2250
2257
  width: `${this.visibleWidth}px`,
2251
- height: `${this.visibleHeight}px`
2258
+ height: `${this.visibleHeight}px`,
2259
+ pointerEvents: "initial"
2252
2260
  };
2253
2261
  }
2254
2262
  draw() {
@@ -2512,7 +2520,8 @@ class ie extends te {
2512
2520
  left: e,
2513
2521
  top: `${this.drawY + 1}px`,
2514
2522
  width: `${this.width}px`,
2515
- height: `${this.height - 2}px`
2523
+ height: `${this.height - 2}px`,
2524
+ pointerEvents: "initial"
2516
2525
  };
2517
2526
  }
2518
2527
  }
@@ -2696,6 +2705,8 @@ class li {
2696
2705
  // 自动填充移动中
2697
2706
  h(this, "selectorMove", !1);
2698
2707
  // 选择器移动中
2708
+ h(this, "adjustPositioning", !1);
2709
+ // 调整位置中
2699
2710
  h(this, "editing", !1);
2700
2711
  // 编辑中
2701
2712
  h(this, "scrollY", 0);
@@ -3591,6 +3602,10 @@ class ui {
3591
3602
  }
3592
3603
  this.isMultipleRow = !1, this.click(e.shiftKey);
3593
3604
  }
3605
+ }), this.ctx.on("mouseup", () => {
3606
+ const t = setTimeout(() => {
3607
+ this.ctx.adjustPositioning = !1, clearTimeout(t);
3608
+ }, 0);
3594
3609
  }), this.ctx.on("cellHeaderHoverChange", (t) => {
3595
3610
  this.ctx.mousedown && this.selectCols(t);
3596
3611
  }), this.ctx.on("cellHeaderMousedown", (t) => {
@@ -3773,7 +3788,7 @@ class ui {
3773
3788
  return;
3774
3789
  const { value: t } = this.ctx.getSelectedData(), e = ei(t);
3775
3790
  navigator.clipboard ? navigator.clipboard.writeText(e).then(() => {
3776
- this.ctx.selector.xArrCopy = this.ctx.selector.xArr.slice(), this.ctx.selector.yArrCopy = this.ctx.selector.yArr.slice(), this.ctx.emit("setCopy", this.ctx.selector), this.ctx.emit("drawView");
3791
+ this.ctx.selector.xArrCopy = this.ctx.selector.xArr.slice(), this.ctx.selector.yArrCopy = this.ctx.selector.yArr.slice(), this.ctx.emit("setCopy", this.ctx.selector), this.ctx.emit("draw");
3777
3792
  }).catch((i) => console.error("复制失败:", i)) : console.error("当前浏览器不支持Clipboard API");
3778
3793
  }
3779
3794
  clearSelectedData(t, e, i = !1) {
@@ -3801,7 +3816,7 @@ class ui {
3801
3816
  let o = [];
3802
3817
  return r.forEach((a) => {
3803
3818
  o.push(this.ctx.database.getRowDataItemForRowKey(a));
3804
- }), this.ctx.emit("clearSelectedDataChange", s, o), this.ctx.emit("drawView"), s;
3819
+ }), this.ctx.emit("clearSelectedDataChange", s, o), this.ctx.emit("draw"), s;
3805
3820
  }
3806
3821
  paste() {
3807
3822
  if (!navigator.clipboard) {
@@ -3849,7 +3864,7 @@ class ui {
3849
3864
  let l = [];
3850
3865
  s.forEach((c) => {
3851
3866
  l.push(this.ctx.database.getRowDataItemForRowKey(c));
3852
- }), this.ctx.emit("pasteChange", a, l), this.clearCopyLine(), this.ctx.emit("drawView");
3867
+ }), this.ctx.emit("pasteChange", a, l), this.clearCopyLine(), this.ctx.emit("draw");
3853
3868
  }).catch((r) => {
3854
3869
  console.error("获取剪贴板内容失败:", r);
3855
3870
  });
@@ -3881,7 +3896,7 @@ class ui {
3881
3896
  break;
3882
3897
  }
3883
3898
  const c = [i, i], f = [s, s], d = this.getCell(s, i);
3884
- d && (d.operation || this.isInSettingRange(d.rowIndex, d.colIndex) && (this.ctx.setFocusCell(d), this.setSelector(c, f), this.adjustBoundaryPosition(), this.ctx.emit("drawView")));
3899
+ d && (d.operation || this.isInSettingRange(d.rowIndex, d.colIndex) && (this.ctx.setFocusCell(d), this.setSelector(c, f), this.adjustBoundaryPosition(), this.ctx.emit("draw")));
3885
3900
  }
3886
3901
  stopAdjustPosition() {
3887
3902
  this.adjustPositionX = "", this.adjustPositionY = "", this.timerX && (clearInterval(this.timerX), this.timerX = 0), this.timerY && (clearInterval(this.timerY), this.timerY = 0);
@@ -3948,7 +3963,7 @@ class ui {
3948
3963
  if (i.fixed && !(y || p) || !(g || w || y || p))
3949
3964
  return;
3950
3965
  const b = r - i.drawX + 1, m = i.drawX + i.width - (e - s) + 1, E = o.height - i.drawY, C = i.drawY + i.height - (t - u - d);
3951
- m > 0 && !i.fixed ? this.ctx.setScrollX(c + m) : b > 0 && !i.fixed && this.ctx.setScrollX(c - b), E > 0 ? this.ctx.setScrollY(f - E) : C > 0 && this.ctx.setScrollY(f + C), this.ctx.emit("adjustBoundaryPosition", i);
3966
+ this.ctx.adjustPositioning = !0, m > 0 && !i.fixed ? this.ctx.setScrollX(c + m) : b > 0 && !i.fixed && this.ctx.setScrollX(c - b), E > 0 ? this.ctx.setScrollY(f - E) : C > 0 && this.ctx.setScrollY(f + C), this.ctx.emit("adjustBoundaryPosition", i);
3952
3967
  }
3953
3968
  destroy() {
3954
3969
  this.timerX && (clearTimeout(this.timerX), this.timerX = 0), this.timerY && (clearTimeout(this.timerY), this.timerY = 0);
@@ -5103,9 +5118,11 @@ class qi {
5103
5118
  }
5104
5119
  this.startEdit();
5105
5120
  }
5121
+ }), this.ctx.on("adjustBoundaryPosition", (t) => {
5122
+ this.cellTarget = t;
5106
5123
  }), this.ctx.on("cellClick", (t) => {
5107
5124
  var e, i;
5108
- 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());
5125
+ 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()));
5109
5126
  });
5110
5127
  }
5111
5128
  initTextEditor() {
@@ -5627,6 +5644,9 @@ class Qi {
5627
5644
  r.length ? (e(r), this.ctx.emit("draw")) : (t([]), this.ctx.emit("draw"));
5628
5645
  });
5629
5646
  }
5647
+ hasValidationError() {
5648
+ return this.ctx.database.hasValidationError();
5649
+ }
5630
5650
  scrollTo(t, e) {
5631
5651
  this.scrollXTo(t), this.scrollYTo(e);
5632
5652
  }