e-virt-table 0.1.8 → 0.1.10
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.cjs.js +3 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +53 -27
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/Cell.d.ts +1 -0
- package/dist/lib/Cell.js +1 -0
- package/dist/lib/Cell.js.map +1 -1
- package/dist/lib/CellHeader.d.ts +1 -0
- package/dist/lib/CellHeader.js +1 -0
- package/dist/lib/CellHeader.js.map +1 -1
- package/dist/lib/Context.d.ts +1 -0
- package/dist/lib/Context.js +6 -0
- package/dist/lib/Context.js.map +1 -1
- package/dist/lib/Database.d.ts +2 -0
- package/dist/lib/Database.js +22 -3
- package/dist/lib/Database.js.map +1 -1
- package/dist/lib/EVirtTable.d.ts +1 -0
- package/dist/lib/EVirtTable.js +4 -1
- package/dist/lib/EVirtTable.js.map +1 -1
- package/dist/lib/Editor.js +8 -0
- package/dist/lib/Editor.js.map +1 -1
- package/dist/lib/Selector.js +14 -5
- package/dist/lib/Selector.js.map +1 -1
- package/package.json +1 -1
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(
|
|
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);
|
|
@@ -1013,27 +1013,31 @@ class ii {
|
|
|
1013
1013
|
batchSetItemValue(t, e = !1) {
|
|
1014
1014
|
let i = [];
|
|
1015
1015
|
const s = /* @__PURE__ */ new Set();
|
|
1016
|
-
t.forEach((
|
|
1017
|
-
const { value:
|
|
1018
|
-
s.add(
|
|
1019
|
-
rowKey:
|
|
1020
|
-
key:
|
|
1021
|
-
oldValue:
|
|
1022
|
-
newValue:
|
|
1016
|
+
t.forEach((l) => {
|
|
1017
|
+
const { value: c, rowKey: f, key: d } = l, { oldValue: x, newValue: u } = this.setItemValue(f, d, c);
|
|
1018
|
+
s.add(f), i.push({
|
|
1019
|
+
rowKey: f,
|
|
1020
|
+
key: d,
|
|
1021
|
+
oldValue: x,
|
|
1022
|
+
newValue: u
|
|
1023
1023
|
});
|
|
1024
1024
|
});
|
|
1025
1025
|
let r = [];
|
|
1026
|
-
const o = i.map((
|
|
1027
|
-
const
|
|
1026
|
+
const o = i.map((l) => {
|
|
1027
|
+
const c = this.ctx.database.getRowDataItemForRowKey(l.rowKey);
|
|
1028
1028
|
return {
|
|
1029
|
-
rowKey:
|
|
1030
|
-
key:
|
|
1031
|
-
value:
|
|
1032
|
-
row:
|
|
1029
|
+
rowKey: l.rowKey,
|
|
1030
|
+
key: l.key,
|
|
1031
|
+
value: l.newValue,
|
|
1032
|
+
row: c
|
|
1033
1033
|
};
|
|
1034
1034
|
});
|
|
1035
|
-
|
|
1036
|
-
r.push(this.ctx.database.getRowDataItemForRowKey(
|
|
1035
|
+
s.forEach((l) => {
|
|
1036
|
+
r.push(this.ctx.database.getRowDataItemForRowKey(l));
|
|
1037
|
+
});
|
|
1038
|
+
const a = o.map(({ rowKey: l, key: c }) => this.getValidator(l, c));
|
|
1039
|
+
return Promise.all(a).then(() => {
|
|
1040
|
+
this.validationErrorMap.size === 0 && this.changedDataMap.size > 0 && this.ctx.emit("validateChangedData", this.getChangedData());
|
|
1037
1041
|
}), this.ctx.emit("change", o, r), e && this.ctx.history.pushState({
|
|
1038
1042
|
changeList: i,
|
|
1039
1043
|
scrollX: this.ctx.scrollX,
|
|
@@ -1079,7 +1083,9 @@ class ii {
|
|
|
1079
1083
|
value: x,
|
|
1080
1084
|
row: u
|
|
1081
1085
|
};
|
|
1082
|
-
this.
|
|
1086
|
+
this.getValidator(t, e).then(() => {
|
|
1087
|
+
this.validationErrorMap.size === 0 && this.changedDataMap.size > 0 && this.ctx.emit("validateChangedData", this.getChangedData());
|
|
1088
|
+
}), this.ctx.emit("change", [g], [u]), this.ctx.emit("editChange", {
|
|
1083
1089
|
rowKey: t,
|
|
1084
1090
|
key: e,
|
|
1085
1091
|
oldValue: l,
|
|
@@ -1107,7 +1113,7 @@ class ii {
|
|
|
1107
1113
|
newValue: x
|
|
1108
1114
|
}
|
|
1109
1115
|
]
|
|
1110
|
-
}),
|
|
1116
|
+
}), r && this.ctx.emit("draw"), {
|
|
1111
1117
|
oldValue: l,
|
|
1112
1118
|
newValue: x
|
|
1113
1119
|
};
|
|
@@ -1313,6 +1319,9 @@ class ii {
|
|
|
1313
1319
|
clearValidate() {
|
|
1314
1320
|
this.validationErrorMap.clear();
|
|
1315
1321
|
}
|
|
1322
|
+
hasValidationError() {
|
|
1323
|
+
return this.validationErrorMap.size !== 0;
|
|
1324
|
+
}
|
|
1316
1325
|
getValidator(t, e) {
|
|
1317
1326
|
return new Promise((i) => {
|
|
1318
1327
|
const s = this.rowKeyMap.get(t), r = this.headerMap.get(e), { BODY_CELL_RULES_METHOD: o } = this.ctx.config, a = r.column;
|
|
@@ -1347,7 +1356,7 @@ class ii {
|
|
|
1347
1356
|
colIndex: r.colIndex
|
|
1348
1357
|
};
|
|
1349
1358
|
new nt(c).validate(f).then(() => {
|
|
1350
|
-
this.
|
|
1359
|
+
this.clearValidationError(t, e), i([]);
|
|
1351
1360
|
}).catch(({ errors: x }) => {
|
|
1352
1361
|
const u = x.map((g) => ({
|
|
1353
1362
|
...g,
|
|
@@ -1388,6 +1397,10 @@ class ii {
|
|
|
1388
1397
|
const s = `${t}_${e}`;
|
|
1389
1398
|
this.validationErrorMap.set(s, i);
|
|
1390
1399
|
}
|
|
1400
|
+
clearValidationError(t, e) {
|
|
1401
|
+
const i = `${t}_${e}`;
|
|
1402
|
+
this.validationErrorMap.has(i) && this.validationErrorMap.delete(i);
|
|
1403
|
+
}
|
|
1391
1404
|
getValidationError(t, e) {
|
|
1392
1405
|
const i = `${t}_${e}`;
|
|
1393
1406
|
return this.validationErrorMap.get(i) || [];
|
|
@@ -2248,7 +2261,8 @@ class ee extends te {
|
|
|
2248
2261
|
left: e,
|
|
2249
2262
|
top: i,
|
|
2250
2263
|
width: `${this.visibleWidth}px`,
|
|
2251
|
-
height: `${this.visibleHeight}px
|
|
2264
|
+
height: `${this.visibleHeight}px`,
|
|
2265
|
+
pointerEvents: "initial"
|
|
2252
2266
|
};
|
|
2253
2267
|
}
|
|
2254
2268
|
draw() {
|
|
@@ -2512,7 +2526,8 @@ class ie extends te {
|
|
|
2512
2526
|
left: e,
|
|
2513
2527
|
top: `${this.drawY + 1}px`,
|
|
2514
2528
|
width: `${this.width}px`,
|
|
2515
|
-
height: `${this.height - 2}px
|
|
2529
|
+
height: `${this.height - 2}px`,
|
|
2530
|
+
pointerEvents: "initial"
|
|
2516
2531
|
};
|
|
2517
2532
|
}
|
|
2518
2533
|
}
|
|
@@ -2696,6 +2711,8 @@ class li {
|
|
|
2696
2711
|
// 自动填充移动中
|
|
2697
2712
|
h(this, "selectorMove", !1);
|
|
2698
2713
|
// 选择器移动中
|
|
2714
|
+
h(this, "adjustPositioning", !1);
|
|
2715
|
+
// 调整位置中
|
|
2699
2716
|
h(this, "editing", !1);
|
|
2700
2717
|
// 编辑中
|
|
2701
2718
|
h(this, "scrollY", 0);
|
|
@@ -3591,6 +3608,10 @@ class ui {
|
|
|
3591
3608
|
}
|
|
3592
3609
|
this.isMultipleRow = !1, this.click(e.shiftKey);
|
|
3593
3610
|
}
|
|
3611
|
+
}), this.ctx.on("mouseup", () => {
|
|
3612
|
+
const t = setTimeout(() => {
|
|
3613
|
+
this.ctx.adjustPositioning = !1, clearTimeout(t);
|
|
3614
|
+
}, 0);
|
|
3594
3615
|
}), this.ctx.on("cellHeaderHoverChange", (t) => {
|
|
3595
3616
|
this.ctx.mousedown && this.selectCols(t);
|
|
3596
3617
|
}), this.ctx.on("cellHeaderMousedown", (t) => {
|
|
@@ -3773,7 +3794,7 @@ class ui {
|
|
|
3773
3794
|
return;
|
|
3774
3795
|
const { value: t } = this.ctx.getSelectedData(), e = ei(t);
|
|
3775
3796
|
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("
|
|
3797
|
+
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
3798
|
}).catch((i) => console.error("复制失败:", i)) : console.error("当前浏览器不支持Clipboard API");
|
|
3778
3799
|
}
|
|
3779
3800
|
clearSelectedData(t, e, i = !1) {
|
|
@@ -3801,7 +3822,7 @@ class ui {
|
|
|
3801
3822
|
let o = [];
|
|
3802
3823
|
return r.forEach((a) => {
|
|
3803
3824
|
o.push(this.ctx.database.getRowDataItemForRowKey(a));
|
|
3804
|
-
}), this.ctx.emit("clearSelectedDataChange", s, o), this.ctx.emit("
|
|
3825
|
+
}), this.ctx.emit("clearSelectedDataChange", s, o), this.ctx.emit("draw"), s;
|
|
3805
3826
|
}
|
|
3806
3827
|
paste() {
|
|
3807
3828
|
if (!navigator.clipboard) {
|
|
@@ -3849,7 +3870,7 @@ class ui {
|
|
|
3849
3870
|
let l = [];
|
|
3850
3871
|
s.forEach((c) => {
|
|
3851
3872
|
l.push(this.ctx.database.getRowDataItemForRowKey(c));
|
|
3852
|
-
}), this.ctx.emit("pasteChange", a, l), this.clearCopyLine(), this.ctx.emit("
|
|
3873
|
+
}), this.ctx.emit("pasteChange", a, l), this.clearCopyLine(), this.ctx.emit("draw");
|
|
3853
3874
|
}).catch((r) => {
|
|
3854
3875
|
console.error("获取剪贴板内容失败:", r);
|
|
3855
3876
|
});
|
|
@@ -3881,7 +3902,7 @@ class ui {
|
|
|
3881
3902
|
break;
|
|
3882
3903
|
}
|
|
3883
3904
|
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("
|
|
3905
|
+
d && (d.operation || this.isInSettingRange(d.rowIndex, d.colIndex) && (this.ctx.setFocusCell(d), this.setSelector(c, f), this.adjustBoundaryPosition(), this.ctx.emit("draw")));
|
|
3885
3906
|
}
|
|
3886
3907
|
stopAdjustPosition() {
|
|
3887
3908
|
this.adjustPositionX = "", this.adjustPositionY = "", this.timerX && (clearInterval(this.timerX), this.timerX = 0), this.timerY && (clearInterval(this.timerY), this.timerY = 0);
|
|
@@ -3948,7 +3969,7 @@ class ui {
|
|
|
3948
3969
|
if (i.fixed && !(y || p) || !(g || w || y || p))
|
|
3949
3970
|
return;
|
|
3950
3971
|
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);
|
|
3972
|
+
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
3973
|
}
|
|
3953
3974
|
destroy() {
|
|
3954
3975
|
this.timerX && (clearTimeout(this.timerX), this.timerX = 0), this.timerY && (clearTimeout(this.timerY), this.timerY = 0);
|
|
@@ -5103,9 +5124,11 @@ class qi {
|
|
|
5103
5124
|
}
|
|
5104
5125
|
this.startEdit();
|
|
5105
5126
|
}
|
|
5127
|
+
}), this.ctx.on("adjustBoundaryPosition", (t) => {
|
|
5128
|
+
this.cellTarget = t;
|
|
5106
5129
|
}), this.ctx.on("cellClick", (t) => {
|
|
5107
5130
|
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());
|
|
5131
|
+
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
5132
|
});
|
|
5110
5133
|
}
|
|
5111
5134
|
initTextEditor() {
|
|
@@ -5627,6 +5650,9 @@ class Qi {
|
|
|
5627
5650
|
r.length ? (e(r), this.ctx.emit("draw")) : (t([]), this.ctx.emit("draw"));
|
|
5628
5651
|
});
|
|
5629
5652
|
}
|
|
5653
|
+
hasValidationError() {
|
|
5654
|
+
return this.ctx.database.hasValidationError();
|
|
5655
|
+
}
|
|
5630
5656
|
scrollTo(t, e) {
|
|
5631
5657
|
this.scrollXTo(t), this.scrollYTo(e);
|
|
5632
5658
|
}
|