@visactor/vtable-sheet 1.22.6-alpha.3 → 1.22.6
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/cjs/components/vtable-sheet.js +1 -1
- package/cjs/components/vtable-sheet.js.map +1 -1
- package/cjs/core/WorkSheet.d.ts +8 -3
- package/cjs/core/WorkSheet.js +80 -10
- package/cjs/core/WorkSheet.js.map +1 -1
- package/cjs/core/table-plugins.d.ts +1 -1
- package/cjs/core/table-plugins.js +47 -3
- package/cjs/core/table-plugins.js.map +1 -1
- package/cjs/formula/formula-paste-processor.d.ts +31 -0
- package/cjs/formula/formula-paste-processor.js +72 -0
- package/cjs/formula/formula-paste-processor.js.map +1 -0
- package/cjs/formula/formula-range-selector.js +3 -3
- package/cjs/formula/formula-range-selector.js.map +1 -1
- package/cjs/formula/formula-reference-adjustor.d.ts +29 -0
- package/cjs/formula/formula-reference-adjustor.js +107 -0
- package/cjs/formula/formula-reference-adjustor.js.map +1 -0
- package/cjs/formula/formula-ui-manager.js +13 -12
- package/cjs/formula/formula-ui-manager.js.map +1 -1
- package/cjs/formula/index.d.ts +4 -0
- package/cjs/formula/index.js +21 -3
- package/cjs/formula/index.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/managers/formula-manager.d.ts +2 -2
- package/cjs/managers/formula-manager.js.map +1 -1
- package/cjs/tools/index.js +1 -2
- package/cjs/ts-types/event.js +2 -1
- package/cjs/ts-types/formula.d.ts +16 -11
- package/cjs/ts-types/formula.js.map +1 -1
- package/cjs/ts-types/sheet.d.ts +2 -2
- package/cjs/ts-types/sheet.js.map +1 -1
- package/dist/vtable-sheet.js +1080 -448
- package/dist/vtable-sheet.min.js +1 -1
- package/es/components/vtable-sheet.js +1 -1
- package/es/components/vtable-sheet.js.map +1 -1
- package/es/core/WorkSheet.d.ts +8 -3
- package/es/core/WorkSheet.js +81 -9
- package/es/core/WorkSheet.js.map +1 -1
- package/es/core/table-plugins.d.ts +1 -1
- package/es/core/table-plugins.js +47 -3
- package/es/core/table-plugins.js.map +1 -1
- package/es/formula/formula-paste-processor.d.ts +31 -0
- package/es/formula/formula-paste-processor.js +64 -0
- package/es/formula/formula-paste-processor.js.map +1 -0
- package/es/formula/formula-range-selector.js +3 -3
- package/es/formula/formula-range-selector.js.map +1 -1
- package/es/formula/formula-reference-adjustor.d.ts +29 -0
- package/es/formula/formula-reference-adjustor.js +101 -0
- package/es/formula/formula-reference-adjustor.js.map +1 -0
- package/es/formula/formula-ui-manager.js +13 -12
- package/es/formula/formula-ui-manager.js.map +1 -1
- package/es/formula/index.d.ts +4 -0
- package/es/formula/index.js +4 -0
- package/es/formula/index.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/managers/formula-manager.d.ts +2 -2
- package/es/managers/formula-manager.js.map +1 -1
- package/es/tools/index.js +1 -2
- package/es/ts-types/event.js +2 -1
- package/es/ts-types/formula.d.ts +16 -11
- package/es/ts-types/formula.js.map +1 -1
- package/es/ts-types/sheet.d.ts +2 -2
- package/es/ts-types/sheet.js.map +1 -1
- package/package.json +6 -6
package/dist/vtable-sheet.js
CHANGED
|
@@ -2294,8 +2294,8 @@
|
|
|
2294
2294
|
}
|
|
2295
2295
|
const ranges = [];
|
|
2296
2296
|
for (const range of selections) {
|
|
2297
|
-
const startAddr = addressFromCoord(range.
|
|
2298
|
-
const endAddr = addressFromCoord(range.
|
|
2297
|
+
const startAddr = addressFromCoord(range.startCol, range.startRow);
|
|
2298
|
+
const endAddr = addressFromCoord(range.endCol, range.endRow);
|
|
2299
2299
|
if (range.startRow === range.endRow && range.startCol === range.endCol) {
|
|
2300
2300
|
ranges.push(startAddr);
|
|
2301
2301
|
}
|
|
@@ -2514,7 +2514,7 @@
|
|
|
2514
2514
|
const newValue = event.newValue;
|
|
2515
2515
|
if (typeof newValue === 'string' && newValue.startsWith('=') && newValue.length > 1) {
|
|
2516
2516
|
try {
|
|
2517
|
-
const currentCellAddress = activeWorkSheet.addressFromCoord(event.
|
|
2517
|
+
const currentCellAddress = activeWorkSheet.addressFromCoord(event.col, event.row);
|
|
2518
2518
|
const cellRegex = new RegExp(`(^|[^A-Za-z0-9])${currentCellAddress}([^A-Za-z0-9]|$)`);
|
|
2519
2519
|
if (cellRegex.test(newValue)) {
|
|
2520
2520
|
activeWorkSheet.tableInstance?.changeCellValue(event.col, event.row, '#CYCLE!', true, false);
|
|
@@ -2609,7 +2609,7 @@
|
|
|
2609
2609
|
}
|
|
2610
2610
|
const editCell = formulaManager.formulaWorkingOnCell;
|
|
2611
2611
|
const safeSelections = this.formulaManager.sheet.excludeEditCellFromSelection(todoSelection, editCell?.row || 0, editCell?.col || 0);
|
|
2612
|
-
this.handleSelectionChanged([safeSelections], formulaInput, isCtrlAddSelection, (
|
|
2612
|
+
this.handleSelectionChanged([safeSelections], formulaInput, isCtrlAddSelection, (col, row) => activeWorkSheet.addressFromCoord(col, row));
|
|
2613
2613
|
}
|
|
2614
2614
|
hasFormulaDependents(cell) {
|
|
2615
2615
|
try {
|
|
@@ -10227,10 +10227,10 @@
|
|
|
10227
10227
|
}
|
|
10228
10228
|
ResourceLoader.cache = new Map(), ResourceLoader.isLoading = !1, ResourceLoader.toLoadAueue = [], ResourceLoader.onLoadSuccessCb = [];
|
|
10229
10229
|
|
|
10230
|
-
var Edge
|
|
10230
|
+
var Edge;
|
|
10231
10231
|
!function (Edge) {
|
|
10232
10232
|
Edge[Edge.Top = 1] = "Top", Edge[Edge.Right = 2] = "Right", Edge[Edge.Bottom = 4] = "Bottom", Edge[Edge.Left = 8] = "Left", Edge[Edge.ALL = 15] = "ALL";
|
|
10233
|
-
}(Edge
|
|
10233
|
+
}(Edge || (Edge = {}));
|
|
10234
10234
|
const _strokeVec4 = [!1, !1, !1, !1];
|
|
10235
10235
|
const parseStroke = stroke => {
|
|
10236
10236
|
var _a;
|
|
@@ -23773,16 +23773,16 @@
|
|
|
23773
23773
|
};
|
|
23774
23774
|
decompressFrames_1 = lib$1.decompressFrames = decompressFrames;
|
|
23775
23775
|
|
|
23776
|
-
const browser
|
|
23776
|
+
const browser = isBrowserEnv();
|
|
23777
23777
|
|
|
23778
23778
|
function _registerArc() {
|
|
23779
|
-
_registerArc.__loaded || (_registerArc.__loaded = !0, registerArcGraphic(), container.load(arcModule), container.load(browser
|
|
23779
|
+
_registerArc.__loaded || (_registerArc.__loaded = !0, registerArcGraphic(), container.load(arcModule), container.load(browser ? arcCanvasPickModule : arcMathPickModule));
|
|
23780
23780
|
}
|
|
23781
23781
|
_registerArc.__loaded = !1;
|
|
23782
23782
|
const registerArc = _registerArc;
|
|
23783
23783
|
|
|
23784
23784
|
function _registerCircle() {
|
|
23785
|
-
_registerCircle.__loaded || (_registerCircle.__loaded = !0, registerCircleGraphic(), container.load(circleModule), container.load(browser
|
|
23785
|
+
_registerCircle.__loaded || (_registerCircle.__loaded = !0, registerCircleGraphic(), container.load(circleModule), container.load(browser ? circleCanvasPickModule : circleMathPickModule));
|
|
23786
23786
|
}
|
|
23787
23787
|
_registerCircle.__loaded = !1;
|
|
23788
23788
|
const registerCircle = _registerCircle;
|
|
@@ -23794,37 +23794,37 @@
|
|
|
23794
23794
|
const registerGroup = _registerGroup;
|
|
23795
23795
|
|
|
23796
23796
|
function _registerImage() {
|
|
23797
|
-
_registerImage.__loaded || (_registerImage.__loaded = !0, registerImageGraphic(), container.load(imageModule), container.load(browser
|
|
23797
|
+
_registerImage.__loaded || (_registerImage.__loaded = !0, registerImageGraphic(), container.load(imageModule), container.load(browser ? imageCanvasPickModule : imageMathPickModule));
|
|
23798
23798
|
}
|
|
23799
23799
|
_registerImage.__loaded = !1;
|
|
23800
23800
|
const registerImage = _registerImage;
|
|
23801
23801
|
|
|
23802
23802
|
function _registerLine() {
|
|
23803
|
-
_registerLine.__loaded || (_registerLine.__loaded = !0, registerLineGraphic(), container.load(lineModule), container.load(browser
|
|
23803
|
+
_registerLine.__loaded || (_registerLine.__loaded = !0, registerLineGraphic(), container.load(lineModule), container.load(browser ? lineCanvasPickModule : lineMathPickModule));
|
|
23804
23804
|
}
|
|
23805
23805
|
_registerLine.__loaded = !1;
|
|
23806
23806
|
const registerLine = _registerLine;
|
|
23807
23807
|
|
|
23808
23808
|
function _registerPath() {
|
|
23809
|
-
_registerPath.__loaded || (_registerPath.__loaded = !0, registerPathGraphic(), container.load(pathModule), container.load(browser
|
|
23809
|
+
_registerPath.__loaded || (_registerPath.__loaded = !0, registerPathGraphic(), container.load(pathModule), container.load(browser ? pathCanvasPickModule : pathMathPickModule));
|
|
23810
23810
|
}
|
|
23811
23811
|
_registerPath.__loaded = !1;
|
|
23812
23812
|
const registerPath = _registerPath;
|
|
23813
23813
|
|
|
23814
23814
|
function _registerPolygon() {
|
|
23815
|
-
_registerPolygon.__loaded || (_registerPolygon.__loaded = !0, registerPolygonGraphic(), container.load(polygonModule), container.load(browser
|
|
23815
|
+
_registerPolygon.__loaded || (_registerPolygon.__loaded = !0, registerPolygonGraphic(), container.load(polygonModule), container.load(browser ? polygonCanvasPickModule : polygonMathPickModule));
|
|
23816
23816
|
}
|
|
23817
23817
|
_registerPolygon.__loaded = !1;
|
|
23818
23818
|
const registerPolygon = _registerPolygon;
|
|
23819
23819
|
|
|
23820
23820
|
function _registerRect() {
|
|
23821
|
-
_registerRect.__loaded || (_registerRect.__loaded = !0, registerRectGraphic(), container.load(rectModule), container.load(browser
|
|
23821
|
+
_registerRect.__loaded || (_registerRect.__loaded = !0, registerRectGraphic(), container.load(rectModule), container.load(browser ? rectCanvasPickModule : rectMathPickModule));
|
|
23822
23822
|
}
|
|
23823
23823
|
_registerRect.__loaded = !1;
|
|
23824
23824
|
const registerRect = _registerRect;
|
|
23825
23825
|
|
|
23826
23826
|
function _registerRichtext() {
|
|
23827
|
-
_registerRichtext.__loaded || (_registerRichtext.__loaded = !0, registerRichtextGraphic(), container.load(richtextModule), container.load(browser
|
|
23827
|
+
_registerRichtext.__loaded || (_registerRichtext.__loaded = !0, registerRichtextGraphic(), container.load(richtextModule), container.load(browser ? richtextCanvasPickModule : richTextMathPickModule));
|
|
23828
23828
|
}
|
|
23829
23829
|
_registerRichtext.__loaded = !1;
|
|
23830
23830
|
const registerRichtext = _registerRichtext;
|
|
@@ -23836,13 +23836,13 @@
|
|
|
23836
23836
|
const registerShadowRoot = _registerShadowRoot;
|
|
23837
23837
|
|
|
23838
23838
|
function _registerSymbol() {
|
|
23839
|
-
_registerSymbol.__loaded || (_registerSymbol.__loaded = !0, registerSymbolGraphic(), container.load(symbolModule), container.load(browser
|
|
23839
|
+
_registerSymbol.__loaded || (_registerSymbol.__loaded = !0, registerSymbolGraphic(), container.load(symbolModule), container.load(browser ? symbolCanvasPickModule : symbolMathPickModule));
|
|
23840
23840
|
}
|
|
23841
23841
|
_registerSymbol.__loaded = !1;
|
|
23842
23842
|
const registerSymbol = _registerSymbol;
|
|
23843
23843
|
|
|
23844
23844
|
function _registerText() {
|
|
23845
|
-
_registerText.__loaded || (_registerText.__loaded = !0, registerTextGraphic(), container.load(textModule), container.load(browser
|
|
23845
|
+
_registerText.__loaded || (_registerText.__loaded = !0, registerTextGraphic(), container.load(textModule), container.load(browser ? textCanvasPickModule : textMathPickModule));
|
|
23846
23846
|
}
|
|
23847
23847
|
_registerText.__loaded = !1;
|
|
23848
23848
|
const registerText = _registerText;
|
|
@@ -37741,13 +37741,7 @@
|
|
|
37741
37741
|
Safari: ua.indexOf("safari") > -1 && -1 === ua.indexOf("edge")
|
|
37742
37742
|
};
|
|
37743
37743
|
}
|
|
37744
|
-
|
|
37745
|
-
IE: IE,
|
|
37746
|
-
Chrome: Chrome,
|
|
37747
|
-
Firefox: Firefox,
|
|
37748
|
-
Edge: Edge,
|
|
37749
|
-
Safari: Safari
|
|
37750
|
-
} = analyzeUserAgent();
|
|
37744
|
+
analyzeUserAgent();
|
|
37751
37745
|
function isObject$7(obj) {
|
|
37752
37746
|
return obj === Object(obj);
|
|
37753
37747
|
}
|
|
@@ -37837,14 +37831,6 @@
|
|
|
37837
37831
|
}
|
|
37838
37832
|
return !1;
|
|
37839
37833
|
}
|
|
37840
|
-
const browser = {
|
|
37841
|
-
IE: IE,
|
|
37842
|
-
Edge: Edge,
|
|
37843
|
-
Chrome: Chrome,
|
|
37844
|
-
Firefox: Firefox,
|
|
37845
|
-
Safari: Safari,
|
|
37846
|
-
heightLimit: Chrome ? 33554431 : Firefox ? 17895588 : 10737433
|
|
37847
|
-
};
|
|
37848
37834
|
const obj = {
|
|
37849
37835
|
isObject: isObject$7
|
|
37850
37836
|
};
|
|
@@ -43763,6 +43749,19 @@
|
|
|
43763
43749
|
};
|
|
43764
43750
|
}
|
|
43765
43751
|
const regIndexReg = /radio-\d+-\d+-(\d+)/;
|
|
43752
|
+
function setDataToHTML(data) {
|
|
43753
|
+
const result = ["<table>"],
|
|
43754
|
+
META_HEAD = ['<meta name="author" content="Visactor"/>', '<style type="text/css">td{white-space:normal}br{mso-data-placement:same-cell}</style>'].join(""),
|
|
43755
|
+
rows = data.split("\r\n");
|
|
43756
|
+
return rows.forEach(function (rowCells, rowIndex) {
|
|
43757
|
+
const cells = rowCells.split("\t"),
|
|
43758
|
+
rowValues = [];
|
|
43759
|
+
0 === rowIndex && result.push("<tbody>"), cells.forEach(function (cell, cellIndex) {
|
|
43760
|
+
const parsedCellData = cell ? cell.toString().replace(/&/g, "&").replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/\n/g, "<br>").replace(/(<br(\s*|\/)>(\r\n|\n)?|\r\n|\n)/g, "<br>\r\n").replace(/\x20{2,}/gi, substring => `<span style="mso-spacerun: yes">${" ".repeat(substring.length - 1)} </span>`).replace(/\t/gi, "	") : " ";
|
|
43761
|
+
rowValues.push(`<td>${parsedCellData}</td>`);
|
|
43762
|
+
}), result.push("<tr>", ...rowValues, "</tr>"), rowIndex === rows.length - 1 && result.push("</tbody>");
|
|
43763
|
+
}), result.push("</table>"), [META_HEAD, result.join("")].join("");
|
|
43764
|
+
}
|
|
43766
43765
|
|
|
43767
43766
|
const CUSTOM_MERGE_PRE_NAME = "_custom_";
|
|
43768
43767
|
const CUSTOM_CONTAINER_NAME = "custom-container";
|
|
@@ -47903,8 +47902,11 @@
|
|
|
47903
47902
|
}, axisOption, {
|
|
47904
47903
|
orient: "left",
|
|
47905
47904
|
type: null !== (_e = null == axisOption ? void 0 : axisOption.type) && void 0 !== _e ? _e : "band",
|
|
47906
|
-
|
|
47905
|
+
label: {
|
|
47906
|
+
flush: !0
|
|
47907
|
+
},
|
|
47907
47908
|
inverse: transformInverse(axisOption, "horizontal" === (null !== (_f = null == spec ? void 0 : spec.direction) && void 0 !== _f ? _f : "scatter" === chartType ? "vertical" : "horizontal")),
|
|
47909
|
+
__vtableChartTheme: theme,
|
|
47908
47910
|
__vtableBodyChartCellPadding: bodyChartCellPadding
|
|
47909
47911
|
});
|
|
47910
47912
|
}
|
|
@@ -48031,6 +48033,9 @@
|
|
|
48031
48033
|
}, axisOption, {
|
|
48032
48034
|
orient: "bottom",
|
|
48033
48035
|
type: null !== (_o = null == axisOption ? void 0 : axisOption.type) && void 0 !== _o ? _o : "band",
|
|
48036
|
+
label: {
|
|
48037
|
+
flush: !0
|
|
48038
|
+
},
|
|
48034
48039
|
__vtableChartTheme: theme,
|
|
48035
48040
|
__vtableBodyChartCellPadding: bodyChartCellPadding
|
|
48036
48041
|
});
|
|
@@ -48395,7 +48400,7 @@
|
|
|
48395
48400
|
releaseColumnChartInstance = !0,
|
|
48396
48401
|
releaseRowChartInstance = !0
|
|
48397
48402
|
} = {}) {
|
|
48398
|
-
var _a, _b, _c, _d, _e, _f;
|
|
48403
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
48399
48404
|
if (this.activeChartInstanceHoverOnMark = null, this.justShowMarkTooltip = void 0, this.justShowMarkTooltipTimer = Date.now(), clearTimeout(this.delayRunDimensionHoverTimer), this.delayRunDimensionHoverTimer = void 0, releaseChartInstance) {
|
|
48400
48405
|
null === (_a = this.activeChartInstance) || void 0 === _a || _a.updateViewBox({
|
|
48401
48406
|
x1: -1e3,
|
|
@@ -48404,11 +48409,16 @@
|
|
|
48404
48409
|
y2: -800
|
|
48405
48410
|
}, !1, !1), null === (_b = this.activeChartInstance) || void 0 === _b || _b.release(), this.activeChartInstance = null;
|
|
48406
48411
|
const {
|
|
48407
|
-
|
|
48408
|
-
|
|
48409
|
-
|
|
48410
|
-
table = this.stage.table;
|
|
48412
|
+
col: col,
|
|
48413
|
+
row: row
|
|
48414
|
+
} = this.parent;
|
|
48411
48415
|
table.internalProps.layoutMap.isAxisCell(table.rowHeaderLevelCount - 1, row) && (null === (_d = (_c = table.scenegraph.getCell(table.rowHeaderLevelCount - 1, row).firstChild).hideLabelHoverOnAxis) || void 0 === _d || _d.call(_c)), table.internalProps.layoutMap.isAxisCell(col, table.rowCount - table.bottomFrozenRowCount) && (null === (_f = (_e = table.scenegraph.getCell(col, table.rowCount - table.bottomFrozenRowCount).firstChild).hideLabelHoverOnAxis) || void 0 === _f || _f.call(_e));
|
|
48416
|
+
} else {
|
|
48417
|
+
const {
|
|
48418
|
+
col: col,
|
|
48419
|
+
row: row
|
|
48420
|
+
} = this.parent;
|
|
48421
|
+
releaseColumnChartInstance && table.internalProps.layoutMap.isAxisCell(col, table.rowCount - table.bottomFrozenRowCount) && (null === (_h = (_g = table.scenegraph.getCell(col, table.rowCount - table.bottomFrozenRowCount).firstChild).hideLabelHoverOnAxis) || void 0 === _h || _h.call(_g)), releaseRowChartInstance && table.internalProps.layoutMap.isAxisCell(table.rowHeaderLevelCount - 1, row) && (null === (_k = (_j = table.scenegraph.getCell(table.rowHeaderLevelCount - 1, row).firstChild).hideLabelHoverOnAxis) || void 0 === _k || _k.call(_j));
|
|
48412
48422
|
}
|
|
48413
48423
|
releaseColumnChartInstance && clearChartInstanceListByColumnDirection(this.parent.col, "scatter" === this.attribute.spec.type ? this.parent.row : void 0, table), releaseRowChartInstance && clearChartInstanceListByRowDirection(this.parent.row, "scatter" === this.attribute.spec.type ? this.parent.col : void 0, table);
|
|
48414
48424
|
}
|
|
@@ -48533,7 +48543,7 @@
|
|
|
48533
48543
|
tickMode: null === (_e = axis.tick) || void 0 === _e ? void 0 : _e.tickMode
|
|
48534
48544
|
}
|
|
48535
48545
|
}, !0);
|
|
48536
|
-
}), null === (_c = null === (_b = table.internalProps.layoutMap) || void 0 === _b ? void 0 : _b.updateDataStateToActiveChartInstance) || void 0 === _c || _c.call(_b, chartInstance), "string" == typeof dataId) chartInstance.getChart().setLayoutTag(!0), chartInstance.updateDataSync(dataId, null != data ? data : []);else {
|
|
48546
|
+
}), null === (_c = null === (_b = table.internalProps.layoutMap) || void 0 === _b ? void 0 : _b.updateDataStateToActiveChartInstance) || void 0 === _c || _c.call(_b, chartInstance), "string" == typeof dataId || "number" == typeof dataId) chartInstance.getChart().setLayoutTag(!0), chartInstance.updateDataSync(dataId, null != data ? data : []);else {
|
|
48537
48547
|
const dataBatch = [];
|
|
48538
48548
|
for (const dataIdStr in dataId) {
|
|
48539
48549
|
const dataIdAndField = dataId[dataIdStr],
|
|
@@ -48685,7 +48695,7 @@
|
|
|
48685
48695
|
chartStage.needRender = !0;
|
|
48686
48696
|
const matrix = chart.globalTransMatrix.clone(),
|
|
48687
48697
|
stageMatrix = chart.stage.window.getViewBoxTransform().clone();
|
|
48688
|
-
if (stageMatrix.multiply(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f), chartStage.window.setViewBoxTransform(stageMatrix.a, stageMatrix.b, stageMatrix.c, stageMatrix.d, stageMatrix.e, stageMatrix.f), "string" == typeof dataId) activeChartInstance.updateDataSync(dataId, null != data ? data : []);else {
|
|
48698
|
+
if (stageMatrix.multiply(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f), chartStage.window.setViewBoxTransform(stageMatrix.a, stageMatrix.b, stageMatrix.c, stageMatrix.d, stageMatrix.e, stageMatrix.f), "string" == typeof dataId || "number" == typeof dataId) activeChartInstance.updateDataSync(dataId, null != data ? data : []);else {
|
|
48689
48699
|
const dataBatch = [];
|
|
48690
48700
|
for (const dataIdStr in dataId) {
|
|
48691
48701
|
const dataIdAndField = dataId[dataIdStr],
|
|
@@ -57112,7 +57122,7 @@
|
|
|
57112
57122
|
};
|
|
57113
57123
|
let EventManager$1 = class EventManager {
|
|
57114
57124
|
constructor(table) {
|
|
57115
|
-
this.isDown = !1, this.isDraging = !1, this.globalEventListeners = [], this._enableTableScroll = !0, this.cutWaitPaste = !1, this.clipboardCheckTimer = null, this.cutOperationTime = 0, this.lastClipboardContent = "", this.cutCellRange = null, this.table = table, this.handleTextStickBindId = [], this.inertiaScroll = new InertiaScroll(table.stateManager), "node" === Env$1.mode || table.options.disableInteraction || (this.bindOuterEvent(), setTimeout(() => {
|
|
57125
|
+
this.isDown = !1, this.isDraging = !1, this.globalEventListeners = [], this._enableTableScroll = !0, this.cutWaitPaste = !1, this.clipboardCheckTimer = null, this.cutOperationTime = 0, this.lastClipboardContent = "", this.cutCellRange = null, this.copySourceRange = null, this.table = table, this.handleTextStickBindId = [], this.inertiaScroll = new InertiaScroll(table.stateManager), "node" === Env$1.mode || table.options.disableInteraction || (this.bindOuterEvent(), setTimeout(() => {
|
|
57116
57126
|
this.bindSelfEvent();
|
|
57117
57127
|
}, 0));
|
|
57118
57128
|
}
|
|
@@ -57342,49 +57352,76 @@
|
|
|
57342
57352
|
this._enableTableScroll = !1;
|
|
57343
57353
|
}
|
|
57344
57354
|
handleCopy(e, isCut = !1) {
|
|
57345
|
-
var _a, _b;
|
|
57355
|
+
var _a, _b, _c, _d, _e, _f;
|
|
57346
57356
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
57347
57357
|
const table = this.table;
|
|
57348
|
-
!isCut && (this.cutWaitPaste = !1);
|
|
57349
|
-
const
|
|
57358
|
+
!isCut && (this.cutWaitPaste = !1), this.copySourceRange = null;
|
|
57359
|
+
const sourceRanges = table.stateManager.select.ranges;
|
|
57360
|
+
if (sourceRanges && 1 === sourceRanges.length) {
|
|
57361
|
+
const sourceRange = sourceRanges[0];
|
|
57362
|
+
this.copySourceRange = {
|
|
57363
|
+
startCol: Math.min(sourceRange.start.col, sourceRange.end.col),
|
|
57364
|
+
startRow: Math.min(sourceRange.start.row, sourceRange.end.row)
|
|
57365
|
+
};
|
|
57366
|
+
} else if (!(null == sourceRanges ? void 0 : sourceRanges.length)) return void (this.copySourceRange = null);
|
|
57367
|
+
const data = this.table.getCopyValue(null === (_b = null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.getCopyCellValue) || void 0 === _b ? void 0 : _b.value);
|
|
57350
57368
|
if (isValid$4(data)) {
|
|
57351
57369
|
e.preventDefault();
|
|
57352
|
-
const
|
|
57353
|
-
|
|
57354
|
-
|
|
57355
|
-
|
|
57356
|
-
|
|
57357
|
-
|
|
57358
|
-
|
|
57359
|
-
|
|
57360
|
-
|
|
57361
|
-
|
|
57362
|
-
|
|
57363
|
-
|
|
57364
|
-
|
|
57365
|
-
|
|
57366
|
-
|
|
57367
|
-
|
|
57368
|
-
|
|
57369
|
-
|
|
57370
|
-
|
|
57371
|
-
|
|
57372
|
-
|
|
57373
|
-
|
|
57374
|
-
|
|
57375
|
-
|
|
57376
|
-
|
|
57377
|
-
|
|
57378
|
-
|
|
57379
|
-
|
|
57380
|
-
|
|
57381
|
-
|
|
57382
|
-
|
|
57383
|
-
|
|
57370
|
+
const element = table.getElement();
|
|
57371
|
+
element && element !== document.activeElement && (element.focus(), yield new Promise(resolve => setTimeout(resolve, 10)));
|
|
57372
|
+
try {
|
|
57373
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
57374
|
+
let hasPermission = !0;
|
|
57375
|
+
if (navigator.permissions && navigator.permissions.query) try {
|
|
57376
|
+
hasPermission = "granted" === (yield navigator.permissions.query({
|
|
57377
|
+
name: "clipboard-write"
|
|
57378
|
+
})).state;
|
|
57379
|
+
} catch (permissionError) {
|
|
57380
|
+
hasPermission = !0;
|
|
57381
|
+
}
|
|
57382
|
+
if (hasPermission) try {
|
|
57383
|
+
if (window.ClipboardItem) {
|
|
57384
|
+
let htmlValues = data;
|
|
57385
|
+
1 === table.stateManager.select.ranges.length && (null === (_d = null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.getCopyCellValue) || void 0 === _d ? void 0 : _d.html) && (htmlValues = this.table.getCopyValue(null === (_e = table.options.keyboardOptions) || void 0 === _e ? void 0 : _e.getCopyCellValue.html));
|
|
57386
|
+
const dataHTML = setDataToHTML(htmlValues);
|
|
57387
|
+
yield navigator.clipboard.write([new ClipboardItem({
|
|
57388
|
+
"text/html": new Blob([dataHTML], {
|
|
57389
|
+
type: "text/html"
|
|
57390
|
+
}),
|
|
57391
|
+
"text/plain": new Blob([data], {
|
|
57392
|
+
type: "text/plain"
|
|
57393
|
+
})
|
|
57394
|
+
})]);
|
|
57395
|
+
} else yield navigator.clipboard.writeText(data);
|
|
57396
|
+
} catch (clipboardError) {
|
|
57397
|
+
this.fallbackCopyToClipboard(data, e);
|
|
57398
|
+
} else this.fallbackCopyToClipboard(data, e);
|
|
57399
|
+
} else this.fallbackCopyToClipboard(data, e);
|
|
57400
|
+
table.fireListeners(TABLE_EVENT_TYPE.COPY_DATA, {
|
|
57401
|
+
cellRange: table.stateManager.select.ranges,
|
|
57402
|
+
copyData: data,
|
|
57403
|
+
isCut: isCut
|
|
57404
|
+
});
|
|
57405
|
+
} catch (error) {
|
|
57406
|
+
this.fallbackCopyToClipboard(data, e);
|
|
57407
|
+
}
|
|
57384
57408
|
}
|
|
57385
|
-
(null === (
|
|
57409
|
+
(null === (_f = table.keyboardOptions) || void 0 === _f ? void 0 : _f.showCopyCellBorder) && (setActiveCellRangeState(table), table.clearSelected());
|
|
57386
57410
|
});
|
|
57387
57411
|
}
|
|
57412
|
+
fallbackCopyToClipboard(data, e) {
|
|
57413
|
+
try {
|
|
57414
|
+
if (e.clipboardData) return void e.clipboardData.setData("text/plain", data);
|
|
57415
|
+
document.activeElement && document.activeElement !== document.body && document.activeElement.blur();
|
|
57416
|
+
const textArea = document.createElement("textarea");
|
|
57417
|
+
textArea.value = data, textArea.style.position = "fixed", textArea.style.left = "-999999px", textArea.style.top = "-999999px", textArea.style.opacity = "0", textArea.setAttribute("readonly", ""), textArea.setAttribute("aria-hidden", "true"), document.body.appendChild(textArea), textArea.focus(), textArea.select(), textArea.setSelectionRange(0, data.length);
|
|
57418
|
+
try {
|
|
57419
|
+
document.execCommand("copy");
|
|
57420
|
+
} catch (execError) {} finally {
|
|
57421
|
+
document.body.removeChild(textArea);
|
|
57422
|
+
}
|
|
57423
|
+
} catch (error) {}
|
|
57424
|
+
}
|
|
57388
57425
|
handleCut(e) {
|
|
57389
57426
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
57390
57427
|
this.handleCopy(e, !0), this.cutWaitPaste = !0, this.cutCellRange = this.table.getSelectedCellInfos(), this.clipboardCheckTimer && clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = window.setTimeout(() => {
|
|
@@ -57400,36 +57437,73 @@
|
|
|
57400
57437
|
}) : this.executePaste(e);
|
|
57401
57438
|
}
|
|
57402
57439
|
executePaste(e) {
|
|
57403
|
-
var _a, _b, _c
|
|
57440
|
+
var _a, _b, _c;
|
|
57404
57441
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
57405
57442
|
const table = this.table;
|
|
57406
|
-
if (table.
|
|
57407
|
-
if (null === (
|
|
57408
|
-
|
|
57409
|
-
|
|
57410
|
-
|
|
57411
|
-
|
|
57412
|
-
|
|
57413
|
-
|
|
57414
|
-
|
|
57415
|
-
|
|
57416
|
-
|
|
57417
|
-
|
|
57418
|
-
|
|
57419
|
-
|
|
57420
|
-
|
|
57421
|
-
|
|
57422
|
-
})
|
|
57423
|
-
|
|
57424
|
-
|
|
57425
|
-
|
|
57426
|
-
|
|
57427
|
-
pasteData: values,
|
|
57428
|
-
changedCellResults: changedCellResults
|
|
57429
|
-
});
|
|
57443
|
+
if (!(null === (_a = table.editorManager) || void 0 === _a ? void 0 : _a.editingEditor)) {
|
|
57444
|
+
if (table.changeCellValues && (null === (_b = table.stateManager.select.ranges) || void 0 === _b ? void 0 : _b.length) > 0) try {
|
|
57445
|
+
if (navigator.clipboard && navigator.clipboard.read) try {
|
|
57446
|
+
const clipboardItems = yield navigator.clipboard.read();
|
|
57447
|
+
let handled = !1;
|
|
57448
|
+
for (const item of clipboardItems) {
|
|
57449
|
+
if (item.types.includes("text/html")) {
|
|
57450
|
+
yield this.pasteHtmlToTable(item), handled = !0;
|
|
57451
|
+
break;
|
|
57452
|
+
}
|
|
57453
|
+
if (item.types.includes("text/plain")) {
|
|
57454
|
+
yield this.pasteTextToTable(item), handled = !0;
|
|
57455
|
+
break;
|
|
57456
|
+
}
|
|
57457
|
+
}
|
|
57458
|
+
handled || (yield this.fallbackPasteFromClipboard(e));
|
|
57459
|
+
} catch (clipboardError) {
|
|
57460
|
+
yield this.fallbackPasteFromClipboard(e);
|
|
57461
|
+
} else yield this.fallbackPasteFromClipboard(e);
|
|
57462
|
+
} catch (error) {
|
|
57463
|
+
yield this.fallbackPasteFromClipboard(e);
|
|
57430
57464
|
}
|
|
57465
|
+
(null === (_c = table.keyboardOptions) || void 0 === _c ? void 0 : _c.showCopyCellBorder) && clearActiveCellRangeState(table);
|
|
57431
57466
|
}
|
|
57432
|
-
|
|
57467
|
+
});
|
|
57468
|
+
}
|
|
57469
|
+
fallbackPasteFromClipboard(e) {
|
|
57470
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
57471
|
+
const table = this.table,
|
|
57472
|
+
ranges = table.stateManager.select.ranges,
|
|
57473
|
+
col = Math.min(ranges[0].start.col, ranges[0].end.col),
|
|
57474
|
+
row = Math.min(ranges[0].start.row, ranges[0].end.row);
|
|
57475
|
+
try {
|
|
57476
|
+
const element = table.getElement();
|
|
57477
|
+
element && element !== document.activeElement && (element.focus(), yield new Promise(resolve => setTimeout(resolve, 10)));
|
|
57478
|
+
const clipboardData = e.clipboardData || window.clipboardData || window.Clipboard;
|
|
57479
|
+
if (clipboardData) {
|
|
57480
|
+
const pastedData = clipboardData.getData("text") || clipboardData.getData("Text");
|
|
57481
|
+
if (pastedData) return void (yield this.processPastedText(pastedData, col, row));
|
|
57482
|
+
}
|
|
57483
|
+
} catch (error) {}
|
|
57484
|
+
});
|
|
57485
|
+
}
|
|
57486
|
+
processPastedText(pastedData, col, row) {
|
|
57487
|
+
var _a;
|
|
57488
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
57489
|
+
const table = this.table,
|
|
57490
|
+
rows = pastedData.split("\n"),
|
|
57491
|
+
values = [];
|
|
57492
|
+
let processedValues;
|
|
57493
|
+
rows.forEach(function (rowCells) {
|
|
57494
|
+
const cells = rowCells.split("\t"),
|
|
57495
|
+
rowValues = [];
|
|
57496
|
+
values.push(rowValues), cells.forEach(function (cell, cellIndex) {
|
|
57497
|
+
cellIndex === cells.length - 1 && (cell = cell.trim()), rowValues.push(cell);
|
|
57498
|
+
});
|
|
57499
|
+
}), (null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.processFormulaBeforePaste) && this.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row));
|
|
57500
|
+
const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
|
|
57501
|
+
table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
|
|
57502
|
+
col: col,
|
|
57503
|
+
row: row,
|
|
57504
|
+
pasteData: processedValues || values,
|
|
57505
|
+
changedCellResults: changedCellResults
|
|
57506
|
+
});
|
|
57433
57507
|
});
|
|
57434
57508
|
}
|
|
57435
57509
|
clearCutArea(table) {
|
|
@@ -57471,7 +57545,7 @@
|
|
|
57471
57545
|
values = [];
|
|
57472
57546
|
item.getType("text/html").then(blob => {
|
|
57473
57547
|
blob.text().then(pastedData => __awaiter$1(this, void 0, void 0, function* () {
|
|
57474
|
-
var _a, _b;
|
|
57548
|
+
var _a, _b, _c;
|
|
57475
57549
|
if (pastedData && /(<table)|(<TABLE)/g.test(pastedData)) {
|
|
57476
57550
|
const matches = Array.from(pastedData.matchAll(regex));
|
|
57477
57551
|
for (const match of matches) {
|
|
@@ -57479,12 +57553,13 @@
|
|
|
57479
57553
|
rowValues = Array.from(rowContent.matchAll(cellRegex)).map(cellMatch => cellMatch[1].replace(/(<(?!br)([^>]+)>)/gi, "").replace(/<br(\s*|\/)>[\r\n]?/gim, "\n").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/	/gi, "\t").replace(/ /g, " "));
|
|
57480
57554
|
values.push(rowValues), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
|
|
57481
57555
|
}
|
|
57482
|
-
|
|
57483
|
-
|
|
57556
|
+
let processedValues;
|
|
57557
|
+
pasteValuesRowCount = null !== (_b = values.length) && void 0 !== _b ? _b : 0, values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1), (null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.processFormulaBeforePaste) && this.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row));
|
|
57558
|
+
const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
|
|
57484
57559
|
table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
|
|
57485
57560
|
col: col,
|
|
57486
57561
|
row: row,
|
|
57487
|
-
pasteData: values,
|
|
57562
|
+
pasteData: processedValues || values,
|
|
57488
57563
|
changedCellResults: changedCellResults
|
|
57489
57564
|
});
|
|
57490
57565
|
} else navigator.clipboard.read().then(clipboardItems => {
|
|
@@ -57496,7 +57571,7 @@
|
|
|
57496
57571
|
});
|
|
57497
57572
|
}
|
|
57498
57573
|
_pasteValue(pastedData) {
|
|
57499
|
-
var _a;
|
|
57574
|
+
var _a, _b;
|
|
57500
57575
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
57501
57576
|
const table = this.table,
|
|
57502
57577
|
ranges = table.stateManager.select.ranges,
|
|
@@ -57508,6 +57583,7 @@
|
|
|
57508
57583
|
let pasteValuesColCount = 0,
|
|
57509
57584
|
pasteValuesRowCount = 0,
|
|
57510
57585
|
values = [];
|
|
57586
|
+
let processedValues;
|
|
57511
57587
|
pastedData.split("\n").forEach(function (rowCells, rowIndex) {
|
|
57512
57588
|
var _a;
|
|
57513
57589
|
const cells = rowCells.split("\t"),
|
|
@@ -57515,49 +57591,55 @@
|
|
|
57515
57591
|
values.push(rowValues), cells.forEach(function (cell, cellIndex) {
|
|
57516
57592
|
cellIndex === cells.length - 1 && (cell = cell.trim()), rowValues.push(cell);
|
|
57517
57593
|
}), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
|
|
57518
|
-
}), pasteValuesRowCount = null !== (_a = values.length) && void 0 !== _a ? _a : 0, values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1);
|
|
57519
|
-
const changedCellResults = yield table.changeCellValues(col, row, values, !0);
|
|
57594
|
+
}), pasteValuesRowCount = null !== (_a = values.length) && void 0 !== _a ? _a : 0, values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1), (null === (_b = table.options.keyboardOptions) || void 0 === _b ? void 0 : _b.processFormulaBeforePaste) && this.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row));
|
|
57595
|
+
const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
|
|
57520
57596
|
table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
|
|
57521
57597
|
col: col,
|
|
57522
57598
|
row: row,
|
|
57523
|
-
pasteData: values,
|
|
57599
|
+
pasteData: processedValues || values,
|
|
57524
57600
|
changedCellResults: changedCellResults
|
|
57525
57601
|
});
|
|
57526
57602
|
});
|
|
57527
57603
|
}
|
|
57528
57604
|
pasteTextToTable(item) {
|
|
57529
|
-
|
|
57530
|
-
|
|
57531
|
-
|
|
57532
|
-
|
|
57533
|
-
|
|
57534
|
-
|
|
57535
|
-
|
|
57536
|
-
|
|
57537
|
-
|
|
57538
|
-
|
|
57539
|
-
|
|
57540
|
-
|
|
57541
|
-
|
|
57542
|
-
|
|
57543
|
-
|
|
57544
|
-
|
|
57545
|
-
const cells = rowCells.split("\t"),
|
|
57546
|
-
rowValues = [];
|
|
57547
|
-
values.push(rowValues), cells.forEach(function (cell, cellIndex) {
|
|
57548
|
-
cell.includes("\n") && (cell = cell.replace(/^"(.*)"$/, "$1").replace(/["]*/g, match => new Array(Math.floor(match.length / 2)).fill('"').join(""))), rowValues.push(cell);
|
|
57549
|
-
}), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
|
|
57550
|
-
}), pasteValuesRowCount = null !== (_a = values.length) && void 0 !== _a ? _a : 0, values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1);
|
|
57551
|
-
const changedCellResults = yield table.changeCellValues(col, row, values, !0);
|
|
57605
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
57606
|
+
const table = this.table,
|
|
57607
|
+
ranges = table.stateManager.select.ranges,
|
|
57608
|
+
selectRangeLength = ranges.length,
|
|
57609
|
+
col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col),
|
|
57610
|
+
row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row),
|
|
57611
|
+
maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col),
|
|
57612
|
+
maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
|
|
57613
|
+
try {
|
|
57614
|
+
const blob = yield item.getType("text/plain"),
|
|
57615
|
+
pastedData = yield blob.text(),
|
|
57616
|
+
values = this.parsePastedData(pastedData),
|
|
57617
|
+
pasteValuesRowCount = values.length,
|
|
57618
|
+
pasteValuesColCount = Math.max(...values.map(row => row.length), 0),
|
|
57619
|
+
processedValues = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1),
|
|
57620
|
+
changedCellResults = yield table.changeCellValues(col, row, processedValues, !0);
|
|
57552
57621
|
table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
|
|
57553
57622
|
col: col,
|
|
57554
57623
|
row: row,
|
|
57555
|
-
pasteData:
|
|
57624
|
+
pasteData: processedValues,
|
|
57556
57625
|
changedCellResults: changedCellResults
|
|
57557
57626
|
});
|
|
57558
|
-
})
|
|
57627
|
+
} catch (error) {}
|
|
57559
57628
|
});
|
|
57560
57629
|
}
|
|
57630
|
+
parsePastedData(pastedData) {
|
|
57631
|
+
const rows = pastedData.replace(/\r(?!\n)/g, "\r\n").split("\r\n"),
|
|
57632
|
+
values = [];
|
|
57633
|
+
return rows.length > 1 && "" === rows[rows.length - 1] && rows.pop(), rows.forEach(rowCells => {
|
|
57634
|
+
const rowValues = rowCells.split("\t").map(cell => this.processCellValue(cell));
|
|
57635
|
+
values.push(rowValues);
|
|
57636
|
+
}), values;
|
|
57637
|
+
}
|
|
57638
|
+
processCellValue(cell) {
|
|
57639
|
+
cell.includes("\n") && (cell = cell.replace(/^"(.*)"$/, "$1").replace(/["]*/g, match => new Array(Math.floor(match.length / 2)).fill('"').join("")));
|
|
57640
|
+
const numValue = Number(cell);
|
|
57641
|
+
return isNaN(numValue) ? cell : numValue;
|
|
57642
|
+
}
|
|
57561
57643
|
handlePasteValues(values, rowCount, colCount, selectedRowCount, selectedColCount) {
|
|
57562
57644
|
if (selectedColCount > colCount || selectedRowCount > rowCount) {
|
|
57563
57645
|
if (selectedColCount % colCount == 0 && selectedRowCount % rowCount == 0) {
|
|
@@ -59664,7 +59746,7 @@
|
|
|
59664
59746
|
}
|
|
59665
59747
|
constructor(container, options = {}) {
|
|
59666
59748
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
59667
|
-
if (super(), this.showFrozenIcon = !0, this.version = "1.22.6
|
|
59749
|
+
if (super(), this.showFrozenIcon = !0, this.version = "1.22.6", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env$1.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
|
|
59668
59750
|
this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
|
|
59669
59751
|
options: options,
|
|
59670
59752
|
container: container
|
|
@@ -61323,7 +61405,7 @@
|
|
|
61323
61405
|
end_row = this.rowCount - 1;
|
|
61324
61406
|
return Array(end_row - start_row + 1).fill(0).map((_, i) => Array(end_col - start_col + 1).fill(0).map((_, j) => this.getCellInfo(j + start_col, i + start_row)));
|
|
61325
61407
|
}
|
|
61326
|
-
getCopyValue() {
|
|
61408
|
+
getCopyValue(getCellValueFunction) {
|
|
61327
61409
|
var _a, _b, _c;
|
|
61328
61410
|
if ((null === (_b = null === (_a = this.stateManager.select) || void 0 === _a ? void 0 : _a.ranges) || void 0 === _b ? void 0 : _b.length) > 0) {
|
|
61329
61411
|
const ranges = this.stateManager.select.ranges;
|
|
@@ -61370,7 +61452,7 @@
|
|
|
61370
61452
|
copyStartCol = Math.max(rangeMinCol, cellRange.start.col), copyStartRow = Math.max(rangeMinRow, cellRange.start.row);
|
|
61371
61453
|
}
|
|
61372
61454
|
if (copyStartCol !== col || copyStartRow !== row) return "";
|
|
61373
|
-
return this.getCellValue(col, row);
|
|
61455
|
+
return getCellValueFunction ? getCellValueFunction(col, row) : this.getCellValue(col, row);
|
|
61374
61456
|
};
|
|
61375
61457
|
let copyValue = "";
|
|
61376
61458
|
for (let r = minRow; r <= maxRow; r++) {
|
|
@@ -70676,8 +70758,8 @@
|
|
|
70676
70758
|
document.addEventListener("keydown", this.handleKeyDown.bind(this), !0);
|
|
70677
70759
|
}
|
|
70678
70760
|
handleKeyDown(event) {
|
|
70679
|
-
var _a, _b;
|
|
70680
|
-
if (this.table.editorManager && this.isExcelShortcutKey(event)) {
|
|
70761
|
+
var _a, _b, _c;
|
|
70762
|
+
if ((null === (_a = this.table) || void 0 === _a ? void 0 : _a.editorManager) && this.isExcelShortcutKey(event)) {
|
|
70681
70763
|
const eventKey = event.key.toLowerCase();
|
|
70682
70764
|
if (this.table.editorManager.editingEditor && "keydown" === this.table.editorManager.beginTriggerEditCellMode) {
|
|
70683
70765
|
const {
|
|
@@ -70693,7 +70775,7 @@
|
|
|
70693
70775
|
if (!this.table.editorManager.editingEditor || eventKey !== ExcelEditCellKeyboardResponse.ENTER && eventKey !== ExcelEditCellKeyboardResponse.TAB) {
|
|
70694
70776
|
if (!this.table.editorManager.editingEditor && (eventKey === ExcelEditCellKeyboardResponse.DELETE || eventKey === ExcelEditCellKeyboardResponse.BACKSPACE)) {
|
|
70695
70777
|
const selectCells = this.table.getSelectedCellInfos();
|
|
70696
|
-
(null == selectCells ? void 0 : selectCells.length) > 0 && document.activeElement === this.table.getElement() && (deleteSelectRange(selectCells, this.table, null === (
|
|
70778
|
+
(null == selectCells ? void 0 : selectCells.length) > 0 && document.activeElement === this.table.getElement() && (deleteSelectRange(selectCells, this.table, null === (_c = null === (_b = this.pluginOptions) || void 0 === _b ? void 0 : _b.deleteWorkOnEditableCell) || void 0 === _c || _c), event.stopPropagation(), event.preventDefault());
|
|
70697
70779
|
}
|
|
70698
70780
|
} else this.table.editorManager.completeEdit(), this.table.getElement().focus(), eventKey === ExcelEditCellKeyboardResponse.ENTER ? this.table.selectCell(col, row + 1) : eventKey === ExcelEditCellKeyboardResponse.TAB && this.table.selectCell(col + 1, row), event.stopPropagation(), event.preventDefault();
|
|
70699
70781
|
}
|
|
@@ -72706,7 +72788,7 @@
|
|
|
72706
72788
|
this.engine.applyFilter(this.state, this.table);
|
|
72707
72789
|
}
|
|
72708
72790
|
shouldApplyFilter(action) {
|
|
72709
|
-
return [FilterActionType.REMOVE_FILTER, FilterActionType.ENABLE_FILTER, FilterActionType.DISABLE_FILTER, FilterActionType.CLEAR_ALL_FILTERS, FilterActionType.APPLY_FILTERS].includes(action.type)
|
|
72791
|
+
return [FilterActionType.REMOVE_FILTER, FilterActionType.ENABLE_FILTER, FilterActionType.DISABLE_FILTER, FilterActionType.CLEAR_ALL_FILTERS, FilterActionType.APPLY_FILTERS].includes(action.type);
|
|
72710
72792
|
}
|
|
72711
72793
|
}
|
|
72712
72794
|
|
|
@@ -72850,191 +72932,98 @@
|
|
|
72850
72932
|
|
|
72851
72933
|
class ValueFilter {
|
|
72852
72934
|
constructor(table, filterStateManager) {
|
|
72853
|
-
this.
|
|
72854
|
-
const filterState = state.filters.get(this.selectedField);
|
|
72855
|
-
filterState && "byValue" === filterState.type && this.updateUI(filterState);
|
|
72856
|
-
});
|
|
72857
|
-
}
|
|
72858
|
-
updateUI(filterState) {
|
|
72859
|
-
this.syncCheckboxesWithFilterState(filterState), this.syncSelectAllWithFilterState(filterState);
|
|
72935
|
+
this.selectedKeys = new Map(), this.candidateKeys = new Map(), this.formatFnCache = new Map(), this.toUnformattedCache = new Map(), this.valueFilterOptionList = new Map(), this.table = table, this.filterStateManager = filterStateManager;
|
|
72860
72936
|
}
|
|
72861
72937
|
setSelectedField(fieldId) {
|
|
72862
|
-
this.selectedField = fieldId
|
|
72863
|
-
}
|
|
72864
|
-
|
|
72865
|
-
|
|
72866
|
-
|
|
72867
|
-
|
|
72868
|
-
|
|
72869
|
-
|
|
72870
|
-
|
|
72871
|
-
|
|
72872
|
-
|
|
72873
|
-
|
|
72874
|
-
|
|
72875
|
-
|
|
72876
|
-
|
|
72877
|
-
|
|
72878
|
-
|
|
72879
|
-
if (
|
|
72880
|
-
|
|
72881
|
-
|
|
72882
|
-
|
|
72883
|
-
|
|
72884
|
-
|
|
72885
|
-
|
|
72886
|
-
|
|
72887
|
-
|
|
72888
|
-
|
|
72889
|
-
|
|
72890
|
-
|
|
72891
|
-
|
|
72892
|
-
|
|
72893
|
-
|
|
72894
|
-
|
|
72895
|
-
|
|
72896
|
-
|
|
72897
|
-
|
|
72898
|
-
|
|
72899
|
-
let rawValue, displayValue;
|
|
72900
|
-
if (-1 !== targetCol) {
|
|
72901
|
-
const row = this.table.columnHeaderLevelCount + i;
|
|
72902
|
-
row < this.table.rowCount && (rawValue = this.table.getCellOriginValue(targetCol, row), displayValue = this.table.getCellValue(targetCol, row));
|
|
72903
|
-
} else rawValue = this.table.getFieldData(String(fieldId), -1 !== targetCol ? targetCol : 0, this.table.columnHeaderLevelCount + i), displayValue = rawValue;
|
|
72904
|
-
null != rawValue && (displayValueMap.set(displayValue, (displayValueMap.get(displayValue) || 0) + 1), rawToDisplayMap.set(rawValue, displayValue), displayToRawMap.set(displayValue, rawValue));
|
|
72905
|
-
}
|
|
72906
|
-
}
|
|
72907
|
-
this.displayToRawValueMap.set(fieldId, displayToRawMap);
|
|
72908
|
-
const uniqueValues = Array.from(displayValueMap.entries()).map(([displayValue, count]) => ({
|
|
72909
|
-
value: displayValue,
|
|
72910
|
-
count: count,
|
|
72911
|
-
rawValue: displayToRawMap.get(displayValue)
|
|
72912
|
-
}));
|
|
72913
|
-
this.uniqueKeys.set(fieldId, uniqueValues);
|
|
72914
|
-
}
|
|
72915
|
-
onValueSelect(fieldId, displayValue, selected) {
|
|
72916
|
-
const displayToRawMap = this.displayToRawValueMap.get(fieldId),
|
|
72917
|
-
rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue,
|
|
72918
|
-
filter = this.filterStateManager.getFilterState(fieldId);
|
|
72919
|
-
if (filter) {
|
|
72920
|
-
const updatedValues = selected ? [...(filter.values || []), rawValue] : (filter.values || []).filter(v => v !== rawValue);
|
|
72921
|
-
this.filterStateManager.dispatch({
|
|
72922
|
-
type: FilterActionType.UPDATE_FILTER,
|
|
72923
|
-
payload: {
|
|
72924
|
-
field: fieldId,
|
|
72925
|
-
values: updatedValues
|
|
72926
|
-
}
|
|
72927
|
-
});
|
|
72928
|
-
} else this.filterStateManager.dispatch({
|
|
72929
|
-
type: FilterActionType.ADD_FILTER,
|
|
72930
|
-
payload: {
|
|
72931
|
-
field: fieldId,
|
|
72932
|
-
type: "byValue",
|
|
72933
|
-
values: [rawValue]
|
|
72934
|
-
}
|
|
72935
|
-
});
|
|
72938
|
+
this.selectedField = fieldId;
|
|
72939
|
+
}
|
|
72940
|
+
getFormatFnCache(fieldId) {
|
|
72941
|
+
let formatFn = this.formatFnCache.get(fieldId);
|
|
72942
|
+
if (null != formatFn) return formatFn;
|
|
72943
|
+
const headerAddress = this.table.internalProps.layoutMap.getHeaderCellAddressByField(String(fieldId)),
|
|
72944
|
+
bodyInfo = this.table.internalProps.layoutMap.getBody(null == headerAddress ? void 0 : headerAddress.col, null == headerAddress ? void 0 : headerAddress.row);
|
|
72945
|
+
return formatFn = bodyInfo && "fieldFormat" in bodyInfo && "function" == typeof bodyInfo.fieldFormat ? bodyInfo.fieldFormat : bodyInfo && "format" in bodyInfo && "function" == typeof bodyInfo.format ? bodyInfo.format : record => record[fieldId], this.formatFnCache.set(fieldId, formatFn), formatFn;
|
|
72946
|
+
}
|
|
72947
|
+
collectCandidateKeysForUnfilteredColumn(fieldId) {
|
|
72948
|
+
const countMap = new Map(),
|
|
72949
|
+
records = this.table.internalProps.dataSource.records,
|
|
72950
|
+
formatFn = this.getFormatFnCache(fieldId),
|
|
72951
|
+
toUnformatted = new Map();
|
|
72952
|
+
records.forEach(record => {
|
|
72953
|
+
const originalValue = record[fieldId],
|
|
72954
|
+
formattedValue = formatFn(record);
|
|
72955
|
+
if (null != formattedValue) {
|
|
72956
|
+
countMap.set(formattedValue, (countMap.get(formattedValue) || 0) + 1);
|
|
72957
|
+
const unformattedSet = toUnformatted.get(formattedValue);
|
|
72958
|
+
null != unformattedSet ? unformattedSet.add(originalValue) : toUnformatted.set(formattedValue, new Set([originalValue]));
|
|
72959
|
+
}
|
|
72960
|
+
}), this.candidateKeys.set(fieldId, countMap), this.toUnformattedCache.set(fieldId, toUnformatted);
|
|
72961
|
+
}
|
|
72962
|
+
collectCandidateKeysForFilteredColumn(candidateField) {
|
|
72963
|
+
const filteredFields = this.filterStateManager.getActiveFilterFields().filter(field => field !== candidateField),
|
|
72964
|
+
toUnformatted = new Map(),
|
|
72965
|
+
formatFn = this.getFormatFnCache(candidateField),
|
|
72966
|
+
countMap = new Map();
|
|
72967
|
+
this.table.internalProps.records.filter(record => filteredFields.every(field => this.selectedKeys.get(field).has(record[field]))).forEach(record => {
|
|
72968
|
+
const originalValue = record[candidateField],
|
|
72969
|
+
formattedValue = formatFn(record);
|
|
72970
|
+
if (countMap.set(formattedValue, (countMap.get(formattedValue) || 0) + 1), null != formattedValue) {
|
|
72971
|
+
const unformattedSet = toUnformatted.get(formattedValue);
|
|
72972
|
+
null != unformattedSet ? unformattedSet.add(originalValue) : toUnformatted.set(formattedValue, new Set([originalValue]));
|
|
72973
|
+
}
|
|
72974
|
+
}), this.candidateKeys.set(candidateField, countMap), this.toUnformattedCache.set(candidateField, toUnformatted);
|
|
72936
72975
|
}
|
|
72937
72976
|
toggleSelectAll(fieldId, selected) {
|
|
72938
|
-
|
|
72939
|
-
|
|
72940
|
-
rawValuesToUpdate = selected && (null === (_a = this.uniqueKeys.get(fieldId)) || void 0 === _a ? void 0 : _a.map(item => item.rawValue)) || [];
|
|
72941
|
-
if (filter) {
|
|
72942
|
-
const updatedValues = selected ? rawValuesToUpdate : [];
|
|
72943
|
-
this.filterStateManager.dispatch({
|
|
72944
|
-
type: FilterActionType.UPDATE_FILTER,
|
|
72945
|
-
payload: {
|
|
72946
|
-
field: fieldId,
|
|
72947
|
-
values: updatedValues
|
|
72948
|
-
}
|
|
72949
|
-
});
|
|
72950
|
-
} else this.filterStateManager.dispatch({
|
|
72951
|
-
type: FilterActionType.ADD_FILTER,
|
|
72952
|
-
payload: {
|
|
72953
|
-
field: fieldId,
|
|
72954
|
-
type: "byValue",
|
|
72955
|
-
values: rawValuesToUpdate,
|
|
72956
|
-
enable: !0
|
|
72957
|
-
}
|
|
72977
|
+
this.valueFilterOptionList.get(fieldId).forEach(option => {
|
|
72978
|
+
option.checkbox.checked = selected;
|
|
72958
72979
|
});
|
|
72959
72980
|
}
|
|
72981
|
+
syncSelectAllCheckbox(fieldId) {
|
|
72982
|
+
const options = this.valueFilterOptionList.get(fieldId) || [],
|
|
72983
|
+
allChecked = options.every(o => o.checkbox.checked),
|
|
72984
|
+
noneChecked = options.every(o => !o.checkbox.checked);
|
|
72985
|
+
this.selectAllCheckbox.checked = allChecked, this.selectAllCheckbox.indeterminate = !allChecked && !noneChecked;
|
|
72986
|
+
}
|
|
72960
72987
|
onSearch(fieldId, value) {
|
|
72961
|
-
const
|
|
72962
|
-
|
|
72988
|
+
const items = this.valueFilterOptionList.get(fieldId),
|
|
72989
|
+
filterKeywords = value.toUpperCase().split(" ").filter(s => s);
|
|
72963
72990
|
for (const item of items) {
|
|
72964
72991
|
const txtValue = item.id.toUpperCase() || "",
|
|
72965
|
-
match = filterKeywords.some(keyword => txtValue.includes(keyword))
|
|
72966
|
-
|
|
72992
|
+
match = filterKeywords.some(keyword => txtValue.includes(keyword)),
|
|
72993
|
+
isVisible = 0 === filterKeywords.length || match;
|
|
72994
|
+
item.itemContainer.style.display = isVisible ? "flex" : "none";
|
|
72967
72995
|
}
|
|
72968
72996
|
}
|
|
72969
72997
|
initFilterStateFromTableData(fieldId) {
|
|
72970
|
-
|
|
72971
|
-
|
|
72972
|
-
|
|
72973
|
-
|
|
72974
|
-
|
|
72975
|
-
|
|
72976
|
-
|
|
72977
|
-
|
|
72978
|
-
|
|
72979
|
-
|
|
72980
|
-
}
|
|
72981
|
-
}
|
|
72982
|
-
if (-1 !== targetCol) break;
|
|
72983
|
-
}
|
|
72984
|
-
const currentLength = this.table.internalProps.dataSource.length;
|
|
72985
|
-
for (let i = 0; i < currentLength; i++) {
|
|
72986
|
-
let displayValue, rawValue;
|
|
72987
|
-
if (-1 !== targetCol) {
|
|
72988
|
-
const row = this.table.columnHeaderLevelCount + i;
|
|
72989
|
-
row < this.table.rowCount && (displayValue = this.table.getCellValue(targetCol, row), rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue);
|
|
72990
|
-
} else displayValue = this.table.getFieldData(String(fieldId), -1 !== targetCol ? targetCol : 0, this.table.columnHeaderLevelCount + i), rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
|
|
72991
|
-
null != rawValue && selectedRawValues.add(rawValue);
|
|
72992
|
-
}
|
|
72993
|
-
(!filter || !arrayEqual(filter.values, Array.from(selectedRawValues))) && (filter ? this.filterStateManager.dispatch({
|
|
72994
|
-
type: FilterActionType.UPDATE_FILTER,
|
|
72995
|
-
payload: {
|
|
72996
|
-
field: fieldId,
|
|
72997
|
-
type: "byValue",
|
|
72998
|
-
values: Array.from(selectedRawValues)
|
|
72999
|
-
}
|
|
73000
|
-
}) : this.filterStateManager.dispatch({
|
|
72998
|
+
if (this.filterStateManager.getActiveFilterFields()) return;
|
|
72999
|
+
const selectedValues = new Set(),
|
|
73000
|
+
originalValues = new Set();
|
|
73001
|
+
this.table.internalProps.dataSource.records.forEach(record => {
|
|
73002
|
+
selectedValues.add(record[fieldId]);
|
|
73003
|
+
});
|
|
73004
|
+
this.table.internalProps.records.forEach(record => {
|
|
73005
|
+
originalValues.add(record[fieldId]);
|
|
73006
|
+
});
|
|
73007
|
+
!arrayEqual(Array.from(originalValues), Array.from(selectedValues)) && (this.selectedKeys.set(fieldId, selectedValues), this.filterStateManager.dispatch({
|
|
73001
73008
|
type: FilterActionType.ADD_FILTER,
|
|
73002
73009
|
payload: {
|
|
73003
73010
|
field: fieldId,
|
|
73004
73011
|
type: "byValue",
|
|
73005
|
-
values: Array.from(
|
|
73012
|
+
values: Array.from(selectedValues),
|
|
73013
|
+
enable: !0
|
|
73006
73014
|
}
|
|
73007
73015
|
}));
|
|
73008
73016
|
}
|
|
73009
|
-
syncCheckboxesWithFilterState(filter) {
|
|
73010
|
-
if (!filter) return;
|
|
73011
|
-
const selectedRawValues = filter.values || [],
|
|
73012
|
-
displayToRawMap = this.displayToRawValueMap.get(filter.field),
|
|
73013
|
-
optionDomList = this.valueFilterOptionList.get(filter.field);
|
|
73014
|
-
null == optionDomList || optionDomList.forEach(optionDom => {
|
|
73015
|
-
var _a, _b;
|
|
73016
|
-
const displayValue = optionDom.originalValue,
|
|
73017
|
-
rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
|
|
73018
|
-
optionDom.checkbox.checked = selectedRawValues.some(v => v === rawValue);
|
|
73019
|
-
const count = (null === (_b = null === (_a = this.uniqueKeys.get(filter.field)) || void 0 === _a ? void 0 : _a.find(key => String(key.value) === optionDom.id)) || void 0 === _b ? void 0 : _b.count) || 0;
|
|
73020
|
-
optionDom.countSpan.textContent = String(count), optionDom.itemContainer.style.display = 0 === count ? "none" : "flex";
|
|
73021
|
-
});
|
|
73022
|
-
}
|
|
73023
|
-
syncSelectAllWithFilterState(filter) {
|
|
73024
|
-
var _a;
|
|
73025
|
-
if (!filter || !filter.values) return this.selectAllCheckbox.checked = !1, void (this.selectAllCheckbox.indeterminate = !1);
|
|
73026
|
-
const uniqueValuesCount = (null === (_a = this.uniqueKeys.get(filter.field)) || void 0 === _a ? void 0 : _a.length) || 0;
|
|
73027
|
-
0 === uniqueValuesCount || 0 === filter.values.length ? (this.selectAllCheckbox.checked = !1, this.selectAllCheckbox.indeterminate = !1) : filter.values.length === uniqueValuesCount ? (this.selectAllCheckbox.checked = !0, this.selectAllCheckbox.indeterminate = !1) : (this.selectAllCheckbox.checked = !1, this.selectAllCheckbox.indeterminate = !0);
|
|
73028
|
-
}
|
|
73029
73017
|
applyFilter(fieldId = this.selectedField) {
|
|
73030
|
-
|
|
73031
|
-
|
|
73032
|
-
|
|
73018
|
+
const options = this.valueFilterOptionList.get(fieldId);
|
|
73019
|
+
if (!options || 0 === options.length) return;
|
|
73020
|
+
const selections = options.map(option => option.checkbox.checked ? option.originalValue : null).filter(key => null !== key).flat();
|
|
73021
|
+
this.selectedKeys.set(fieldId, new Set(selections)), selections.length > 0 && selections.length < this.valueFilterOptionList.get(fieldId).length ? this.filterStateManager.dispatch({
|
|
73033
73022
|
type: FilterActionType.APPLY_FILTERS,
|
|
73034
73023
|
payload: {
|
|
73035
73024
|
field: fieldId,
|
|
73036
73025
|
type: "byValue",
|
|
73037
|
-
values:
|
|
73026
|
+
values: selections,
|
|
73038
73027
|
enable: !0
|
|
73039
73028
|
}
|
|
73040
73029
|
}) : this.filterStateManager.dispatch({
|
|
@@ -73061,57 +73050,58 @@
|
|
|
73061
73050
|
const selectAllItemDiv = document.createElement("div");
|
|
73062
73051
|
applyStyles(selectAllItemDiv, filterStyles.optionItem);
|
|
73063
73052
|
const selectAllLabel = document.createElement("label");
|
|
73064
|
-
applyStyles(selectAllLabel, filterStyles.optionLabel), this.selectAllCheckbox = document.createElement("input"), this.selectAllCheckbox.type = "checkbox", this.selectAllCheckbox.checked = !0, applyStyles(this.selectAllCheckbox, filterStyles.checkbox), selectAllLabel.append(this.selectAllCheckbox, " 全选"), selectAllItemDiv.
|
|
73053
|
+
applyStyles(selectAllLabel, filterStyles.optionLabel), this.selectAllCheckbox = document.createElement("input"), this.selectAllCheckbox.type = "checkbox", this.selectAllCheckbox.checked = !0, applyStyles(this.selectAllCheckbox, filterStyles.checkbox), this.totalCountSpan = document.createElement("span"), this.totalCountSpan.textContent = "", applyStyles(this.totalCountSpan, filterStyles.countSpan), selectAllLabel.append(this.selectAllCheckbox, " 全选"), selectAllItemDiv.append(selectAllLabel, this.totalCountSpan), this.filterItemsContainer = document.createElement("div"), optionsContainer.append(selectAllItemDiv, this.filterItemsContainer), this.filterByValuePanel.append(searchContainer, optionsContainer), container.appendChild(this.filterByValuePanel), this.bindEventForFilterByValue();
|
|
73065
73054
|
}
|
|
73066
73055
|
renderFilterOptions(field) {
|
|
73067
|
-
var _a, _b;
|
|
73056
|
+
var _a, _b, _c;
|
|
73068
73057
|
this.filterItemsContainer.innerHTML = "", this.valueFilterOptionList.delete(field), this.valueFilterOptionList.set(field, []);
|
|
73069
|
-
|
|
73070
|
-
|
|
73071
|
-
|
|
73072
|
-
|
|
73073
|
-
|
|
73074
|
-
|
|
73075
|
-
|
|
73076
|
-
|
|
73077
|
-
|
|
73078
|
-
|
|
73058
|
+
let totalCount = 0,
|
|
73059
|
+
allChecked = !0,
|
|
73060
|
+
noneChecked = !0;
|
|
73061
|
+
const selectedKeysSet = this.selectedKeys.get(field),
|
|
73062
|
+
itemDomList = [],
|
|
73063
|
+
isFiltered = null === (_a = this.filterStateManager.getFilterState(field)) || void 0 === _a ? void 0 : _a.enable,
|
|
73064
|
+
toUnformatted = this.toUnformattedCache.get(field),
|
|
73065
|
+
candidates = this.candidateKeys.get(field);
|
|
73066
|
+
if (!candidates || 0 === candidates.size) return;
|
|
73067
|
+
const candidatesArr = [...candidates.entries()],
|
|
73068
|
+
sortedCandidatesArr = "number" == typeof candidatesArr[0][0] ? null === (_b = [...candidatesArr]) || void 0 === _b ? void 0 : _b.sort(([a], [b]) => Number(a) - Number(b)) : null === (_c = [...candidatesArr]) || void 0 === _c ? void 0 : _c.sort(([a], [b]) => String(a).localeCompare(String(b)));
|
|
73069
|
+
null == sortedCandidatesArr || sortedCandidatesArr.forEach(([val, count]) => {
|
|
73070
|
+
totalCount += count;
|
|
73071
|
+
const unformattedArr = Array.from(toUnformatted.get(val) || new Set()),
|
|
73072
|
+
itemDiv = document.createElement("div");
|
|
73073
|
+
applyStyles(itemDiv, filterStyles.optionItem), itemDiv.style.display = "flex";
|
|
73079
73074
|
const label = document.createElement("label");
|
|
73080
73075
|
applyStyles(label, filterStyles.optionLabel);
|
|
73081
73076
|
const checkbox = document.createElement("input");
|
|
73082
|
-
checkbox.type = "checkbox", checkbox.value = String(
|
|
73077
|
+
checkbox.type = "checkbox", checkbox.value = String(val), checkbox.checked = !isFiltered || unformattedArr.some(v => null == selectedKeysSet ? void 0 : selectedKeysSet.has(v)), applyStyles(checkbox, filterStyles.checkbox), checkbox.checked ? noneChecked = !1 : allChecked = !1;
|
|
73083
73078
|
const countSpan = document.createElement("span");
|
|
73084
|
-
countSpan.textContent = String(count), applyStyles(countSpan, filterStyles.countSpan), label.append(checkbox, ` ${
|
|
73079
|
+
countSpan.textContent = String(count), applyStyles(countSpan, filterStyles.countSpan), label.append(checkbox, ` ${val}`), itemDiv.append(label, countSpan), this.filterItemsContainer.appendChild(itemDiv);
|
|
73085
73080
|
const itemDom = {
|
|
73086
|
-
id: String(
|
|
73087
|
-
originalValue:
|
|
73081
|
+
id: String(val),
|
|
73082
|
+
originalValue: unformattedArr,
|
|
73088
73083
|
itemContainer: itemDiv,
|
|
73089
73084
|
checkbox: checkbox,
|
|
73090
73085
|
countSpan: countSpan
|
|
73091
73086
|
};
|
|
73092
73087
|
itemDomList.push(itemDom);
|
|
73093
|
-
}), this.valueFilterOptionList.set(field, itemDomList);
|
|
73088
|
+
}), this.valueFilterOptionList.set(field, itemDomList), this.selectAllCheckbox.checked = allChecked, this.selectAllCheckbox.indeterminate = !allChecked && !noneChecked, this.totalCountSpan.textContent = String(totalCount);
|
|
73094
73089
|
}
|
|
73095
73090
|
bindEventForFilterByValue() {
|
|
73096
|
-
this.
|
|
73091
|
+
this._onInputKeyUpHandler = event => {
|
|
73097
73092
|
const target = event.target;
|
|
73098
73093
|
if (target instanceof HTMLInputElement && "text" === target.type) {
|
|
73099
73094
|
const value = target.value;
|
|
73100
73095
|
this.onSearch(this.selectedField, value);
|
|
73101
73096
|
}
|
|
73102
|
-
}
|
|
73103
|
-
var _a, _b;
|
|
73097
|
+
}, this._onCheckboxChangeHandler = event => {
|
|
73104
73098
|
const target = event.target;
|
|
73105
|
-
|
|
73106
|
-
|
|
73107
|
-
checked = checkbox.checked,
|
|
73108
|
-
value = null === (_b = null === (_a = this.valueFilterOptionList.get(this.selectedField)) || void 0 === _a ? void 0 : _a.find(item => item.id === checkbox.value)) || void 0 === _b ? void 0 : _b.originalValue;
|
|
73109
|
-
this.onValueSelect(this.selectedField, value, checked);
|
|
73110
|
-
}
|
|
73111
|
-
});
|
|
73099
|
+
target instanceof HTMLInputElement && "checkbox" === target.type && (target === this.selectAllCheckbox ? this.toggleSelectAll(this.selectedField, this.selectAllCheckbox.checked) : this.syncSelectAllCheckbox(this.selectedField));
|
|
73100
|
+
}, this.filterByValuePanel.addEventListener("keyup", this._onInputKeyUpHandler), this.filterByValuePanel.addEventListener("change", this._onCheckboxChangeHandler);
|
|
73112
73101
|
}
|
|
73113
73102
|
show() {
|
|
73114
|
-
|
|
73103
|
+
var _a;
|
|
73104
|
+
(null === (_a = this.filterStateManager.getFilterState(this.selectedField)) || void 0 === _a ? void 0 : _a.enable) ? this.collectCandidateKeysForFilteredColumn(this.selectedField) : this.collectCandidateKeysForUnfilteredColumn(this.selectedField), this.initFilterStateFromTableData(this.selectedField), this.filterByValueSearchInput && (this.filterByValueSearchInput.value = ""), this.renderFilterOptions(this.selectedField), this.filterByValuePanel.style.display = "block";
|
|
73115
73105
|
}
|
|
73116
73106
|
hide() {
|
|
73117
73107
|
this.filterByValuePanel.style.display = "none";
|
|
@@ -73119,6 +73109,13 @@
|
|
|
73119
73109
|
clearSearchInputValue() {
|
|
73120
73110
|
this.filterByValueSearchInput.value = "";
|
|
73121
73111
|
}
|
|
73112
|
+
destroy() {
|
|
73113
|
+
if (this.filterByValuePanel && (this._onInputKeyUpHandler && this.filterByValuePanel.removeEventListener("keyup", this._onInputKeyUpHandler), this._onCheckboxChangeHandler && this.filterByValuePanel.removeEventListener("change", this._onCheckboxChangeHandler)), this._onInputKeyUpHandler = void 0, this._onCheckboxChangeHandler = void 0, this.filterByValuePanel) {
|
|
73114
|
+
const parent = this.filterByValuePanel.parentElement;
|
|
73115
|
+
parent ? parent.removeChild(this.filterByValuePanel) : this.filterByValuePanel.remove();
|
|
73116
|
+
}
|
|
73117
|
+
this.filterItemsContainer && (this.filterItemsContainer.innerHTML = ""), this.filterByValueSearchInput && (this.filterByValueSearchInput.value = ""), this.selectedKeys && this.selectedKeys.clear(), this.candidateKeys && this.candidateKeys.clear(), this.formatFnCache && this.formatFnCache.clear(), this.toUnformattedCache && this.toUnformattedCache.clear(), this.valueFilterOptionList && this.valueFilterOptionList.clear(), this.filterByValuePanel = void 0, this.filterByValueSearchInput = void 0, this.selectAllCheckbox = void 0, this.totalCountSpan = void 0, this.filterItemsContainer = void 0;
|
|
73118
|
+
}
|
|
73122
73119
|
}
|
|
73123
73120
|
|
|
73124
73121
|
class ConditionFilter {
|
|
@@ -73361,7 +73358,9 @@
|
|
|
73361
73358
|
|
|
73362
73359
|
class FilterToolbar {
|
|
73363
73360
|
constructor(table, filterStateManager) {
|
|
73364
|
-
this.valueFilter = null, this.conditionFilter = null, this.activeTab = "byValue", this.isVisible = !1, this.selectedField = null, this.filterModes = [], this.table = table, this.filterStateManager = filterStateManager, this.valueFilter = new ValueFilter(this.table, this.filterStateManager), this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager), this.filterMenuWidth = 300
|
|
73361
|
+
this.valueFilter = null, this.conditionFilter = null, this.activeTab = "byValue", this.isVisible = !1, this.selectedField = null, this.filterModes = [], this.table = table, this.filterStateManager = filterStateManager, this.valueFilter = new ValueFilter(this.table, this.filterStateManager), this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager), this.filterMenuWidth = 300, this.filterStateManager.subscribe(state => {
|
|
73362
|
+
this.isVisible && null !== this.selectedField && this.updateClearFilterButtonState(this.selectedField);
|
|
73363
|
+
});
|
|
73365
73364
|
}
|
|
73366
73365
|
onTabSwitch(tab) {
|
|
73367
73366
|
this.activeTab = tab, "byValue" === tab ? (this.valueFilter.show(), this.conditionFilter.hide()) : (this.conditionFilter.show(), this.valueFilter.hide());
|
|
@@ -73377,6 +73376,11 @@
|
|
|
73377
73376
|
clearFilter(field) {
|
|
73378
73377
|
this.valueFilter && this.valueFilter.clearFilter(field), this.conditionFilter && this.conditionFilter.clearFilter(field), this.hide();
|
|
73379
73378
|
}
|
|
73379
|
+
updateClearFilterButtonState(field) {
|
|
73380
|
+
const currentFilter = this.filterStateManager.getFilterState(field),
|
|
73381
|
+
hasActiveFilter = currentFilter && currentFilter.enable;
|
|
73382
|
+
this.clearFilterOptionLink.style.display = "inline", this.clearFilterOptionLink.style.opacity = hasActiveFilter ? "1" : "0.5", this.clearFilterOptionLink.style.pointerEvents = hasActiveFilter ? "auto" : "none", this.clearFilterOptionLink.style.cursor = hasActiveFilter ? "pointer" : "not-allowed";
|
|
73383
|
+
}
|
|
73380
73384
|
render(container) {
|
|
73381
73385
|
this.filterMenu = document.createElement("div"), applyStyles(this.filterMenu, filterStyles.filterMenu), this.filterMenu.style.width = `${this.filterMenuWidth}px`;
|
|
73382
73386
|
const filterTabsContainer = document.createElement("div");
|
|
@@ -73418,7 +73422,7 @@
|
|
|
73418
73422
|
const field = this.table.internalProps.layoutMap.getHeaderField(col, row);
|
|
73419
73423
|
this.updateSelectedField(field);
|
|
73420
73424
|
const currentFilter = this.filterStateManager.getFilterState(field);
|
|
73421
|
-
currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.onTabSwitch("byValue"), setTimeout(() => {
|
|
73425
|
+
currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.onTabSwitch("byValue"), this.updateClearFilterButtonState(field), setTimeout(() => {
|
|
73422
73426
|
this.isVisible = !0;
|
|
73423
73427
|
}, 0);
|
|
73424
73428
|
}
|
|
@@ -73543,7 +73547,7 @@
|
|
|
73543
73547
|
}));
|
|
73544
73548
|
}
|
|
73545
73549
|
release() {
|
|
73546
|
-
this.table = null, this.filterEngine = null, this.filterStateManager = null, this.filterToolbar = null;
|
|
73550
|
+
this.table = null, this.filterEngine = null, this.filterStateManager = null, this.filterToolbar.valueFilter.destroy(), this.filterToolbar = null;
|
|
73547
73551
|
}
|
|
73548
73552
|
}
|
|
73549
73553
|
|
|
@@ -73564,6 +73568,136 @@
|
|
|
73564
73568
|
DATA_TYPE.NUMBER = "number", DATA_TYPE.DATE = "date", DATA_TYPE.EXTEND_NUMBER = "extendNumber", DATA_TYPE.CHN_NUMBER = "chnNumber", DATA_TYPE.CHN_WEEK2 = "chnWeek2", DATA_TYPE.CHN_WEEK3 = "chnWeek3", DATA_TYPE.LOOP_SERIES = "loopSeries", DATA_TYPE.FORMULA = "formula", DATA_TYPE.OTHER = "other";
|
|
73565
73569
|
}(DATA_TYPE || (DATA_TYPE = {}));
|
|
73566
73570
|
|
|
73571
|
+
function getSelectedRangeArray(selectedRange) {
|
|
73572
|
+
const minCol = Math.min(selectedRange.start.col, selectedRange.end.col),
|
|
73573
|
+
minRow = Math.min(selectedRange.start.row, selectedRange.end.row),
|
|
73574
|
+
maxCol = Math.max(selectedRange.start.col, selectedRange.end.col),
|
|
73575
|
+
maxRow = Math.max(selectedRange.start.row, selectedRange.end.row),
|
|
73576
|
+
cols = [],
|
|
73577
|
+
rows = [];
|
|
73578
|
+
for (let i = minCol; i <= maxCol; i++) cols.push(i);
|
|
73579
|
+
for (let i = minRow; i <= maxRow; i++) rows.push(i);
|
|
73580
|
+
return {
|
|
73581
|
+
cols: cols,
|
|
73582
|
+
rows: rows
|
|
73583
|
+
};
|
|
73584
|
+
}
|
|
73585
|
+
function getTargetRange(direction, sourceRange, selectedRange) {
|
|
73586
|
+
return direction === Direction.DOWN || direction === Direction.UP ? {
|
|
73587
|
+
cols: selectedRange.cols,
|
|
73588
|
+
rows: selectedRange.rows.filter(row => !sourceRange.rows.includes(row))
|
|
73589
|
+
} : {
|
|
73590
|
+
cols: selectedRange.cols.filter(col => !sourceRange.cols.includes(col)),
|
|
73591
|
+
rows: selectedRange.rows
|
|
73592
|
+
};
|
|
73593
|
+
}
|
|
73594
|
+
function openAutoFillMenu(tableInstance, endCol, endRow) {
|
|
73595
|
+
const rect = tableInstance.scenegraph.highPerformanceGetCell(endCol, endRow).globalAABBBounds;
|
|
73596
|
+
tableInstance.showDropDownMenu(endCol, endRow, {
|
|
73597
|
+
content: [{
|
|
73598
|
+
type: "item",
|
|
73599
|
+
text: "复制填充",
|
|
73600
|
+
icon: {
|
|
73601
|
+
width: 16,
|
|
73602
|
+
height: 16,
|
|
73603
|
+
svg: '<svg t="1756136702877" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1474" width="200" height="200"><path d="M853.333333 981.333333h-384c-72.533333 0-128-55.466667-128-128v-384c0-72.533333 55.466667-128 128-128h384c72.533333 0 128 55.466667 128 128v384c0 72.533333-55.466667 128-128 128z m-384-554.666666c-25.6 0-42.666667 17.066667-42.666666 42.666666v384c0 25.6 17.066667 42.666667 42.666666 42.666667h384c25.6 0 42.666667-17.066667 42.666667-42.666667v-384c0-25.6-17.066667-42.666667-42.666667-42.666666h-384z" p-id="1475"></path><path d="M213.333333 682.666667H170.666667c-72.533333 0-128-55.466667-128-128V170.666667c0-72.533333 55.466667-128 128-128h384c72.533333 0 128 55.466667 128 128v42.666666c0 25.6-17.066667 42.666667-42.666667 42.666667s-42.666667-17.066667-42.666667-42.666667V170.666667c0-25.6-17.066667-42.666667-42.666666-42.666667H170.666667c-25.6 0-42.666667 17.066667-42.666667 42.666667v384c0 25.6 17.066667 42.666667 42.666667 42.666666h42.666666c25.6 0 42.666667 17.066667 42.666667 42.666667s-17.066667 42.666667-42.666667 42.666667z" p-id="1476"></path></svg>'
|
|
73604
|
+
}
|
|
73605
|
+
}, {
|
|
73606
|
+
type: "item",
|
|
73607
|
+
text: "序列填充",
|
|
73608
|
+
icon: {
|
|
73609
|
+
width: 16,
|
|
73610
|
+
height: 16,
|
|
73611
|
+
svg: '<svg t="1756136788547" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2463" width="200" height="200"><path d="M312.832482 65.167035H959.204489c35.706211 0 64.64232 29.473622 64.64232 65.832527 0 36.346107-28.936109 65.832527-64.629522 65.832527H312.819684c-35.693413 0-64.629522-29.473622-64.629522-65.832527 0-36.346107 28.936109-65.832527 64.629522-65.832527z m0 394.982363H959.204489c35.706211 0 64.64232 29.460824 64.64232 65.819729 0 36.358905-28.936109 65.832527-64.629522 65.832527H312.819684c-35.693413 0-64.629522-29.473622-64.629522-65.832527 0-36.346107 28.936109-65.819729 64.629522-65.819729z m0 394.969566H959.204489c35.706211 0 64.64232 29.473622 64.64232 65.819729 0 36.358905-28.936109 65.832527-64.629522 65.832527H312.819684c-35.693413 0-64.629522-29.473622-64.629522-65.832527 0-36.346107 28.936109-65.819729 64.629522-65.819729zM12.286008 69.108796V38.176211c9.892796 0.767876 19.836784 0.767876 29.72958 0A41.823619 41.823619 0 0 0 63.989626 25.672638c4.261709-4.671243 7.358807-10.315128 9.048133-16.458132 0.37114-3.058704 0.37114-6.143004 0-9.214506H114.413451v229.748352H65.93491V69.108796H12.286008z m0 510.176487a130.730805 130.730805 0 0 1 45.240665-49.374395 334.537763 334.537763 0 0 0 40.070304-32.250771 48.47854 48.47854 0 0 0 14.218495-33.581756 37.31875 37.31875 0 0 0-7.755543-24.354451 28.193829 28.193829 0 0 0-23.266628-9.879998 27.643518 27.643518 0 0 0-31.02217 15.139945 78.27211 78.27211 0 0 0-5.170362 28.30901H2.585181a114.311067 114.311067 0 0 1 10.340723-48.056208c12.388392-24.124089 38.086625-37.984242 64.629522-34.887144a79.897447 79.897447 0 0 1 57.539472 20.41269 71.783562 71.783562 0 0 1 21.321343 53.981648 74.637499 74.637499 0 0 1-14.858391 46.072531 152.16733 152.16733 0 0 1-32.967455 29.627197L90.481331 553.625443l-23.266628 17.763521c-4.082538 3.583419-7.563574 7.806734-10.353522 12.51637h99.542262v40.147092H0a110.945213 110.945213 0 0 1 10.340724-45.419837l1.945284 0.665492zM44.600769 948.582211a53.495327 53.495327 0 0 0 4.517668 23.036265 30.279891 30.279891 0 0 0 29.742378 17.110826c7.422797 0.255959 14.717614-2.073264 20.681447-6.578133 6.7829-6.962071 10.315128-16.547717 9.688029-26.325332a30.356678 30.356678 0 0 0-18.096266-30.945383 91.735527 91.735527 0 0 0-32.314761-8.561812V883.440772a83.903197 83.903197 0 0 0 30.382274-4.607253 27.106005 27.106005 0 0 0 14.858391-28.30901 30.612637 30.612637 0 0 0-7.755542-21.730877 27.528337 27.528337 0 0 0-21.321344-8.549014 26.939632 26.939632 0 0 0-23.279425 10.532692 44.063256 44.063256 0 0 0-7.102849 27.643519H2.585181a117.101015 117.101015 0 0 1 5.823056-32.916264 74.381541 74.381541 0 0 1 17.443572-25.019944 60.534186 60.534186 0 0 1 20.681447-12.503572 89.55988 89.55988 0 0 1 29.742378-3.289067A78.540867 78.540867 0 0 1 129.259044 801.79001a57.744238 57.744238 0 0 1 20.041551 46.085328 51.921182 51.921182 0 0 1-12.286008 34.887144c-4.159326 5.170362-9.470465 9.227304-15.511086 11.850879 6.7829 1.510155 12.900309 5.208756 17.45637 10.532692a57.821026 57.821026 0 0 1 17.443572 44.10165 75.136618 75.136618 0 0 1-20.028753 52.010768 76.122059 76.122059 0 0 1-59.471958 22.383571 71.962733 71.962733 0 0 1-64.629522-32.250771A97.52019 97.52019 0 0 1 1.279793 946.611331l43.308178 1.97088z" fill="#515151" p-id="2464"></path></svg>'
|
|
73612
|
+
}
|
|
73613
|
+
}],
|
|
73614
|
+
referencePosition: {
|
|
73615
|
+
rect: {
|
|
73616
|
+
right: rect.x2 + 110,
|
|
73617
|
+
bottom: rect.y2
|
|
73618
|
+
}
|
|
73619
|
+
}
|
|
73620
|
+
});
|
|
73621
|
+
}
|
|
73622
|
+
function getCellMatrix(table) {
|
|
73623
|
+
return {
|
|
73624
|
+
getValue: (row, col) => {
|
|
73625
|
+
const value = table.getCellValue(col, row);
|
|
73626
|
+
return "number" != typeof value && isNaN(Number(value)) ? {
|
|
73627
|
+
v: value || "",
|
|
73628
|
+
t: CellValueType.STRING
|
|
73629
|
+
} : {
|
|
73630
|
+
v: value,
|
|
73631
|
+
t: CellValueType.NUMBER
|
|
73632
|
+
};
|
|
73633
|
+
},
|
|
73634
|
+
getMaxRows: () => table.records.length,
|
|
73635
|
+
getMaxColumns: () => table.columns.length
|
|
73636
|
+
};
|
|
73637
|
+
}
|
|
73638
|
+
function isMergeCell(table, col, row) {
|
|
73639
|
+
const cellRange = table.getCellRange(col, row);
|
|
73640
|
+
return cellRange.start.col !== cellRange.end.col || cellRange.start.row !== cellRange.end.row ? cellRange : null;
|
|
73641
|
+
}
|
|
73642
|
+
|
|
73643
|
+
class DefaultFormulaAdapter {
|
|
73644
|
+
constructor(table) {
|
|
73645
|
+
this.table = table;
|
|
73646
|
+
}
|
|
73647
|
+
isFormulaCell(col, row) {
|
|
73648
|
+
const cellValue = this.table.getCellValue(col, row);
|
|
73649
|
+
return "string" == typeof cellValue && cellValue.startsWith("=");
|
|
73650
|
+
}
|
|
73651
|
+
getCellFormula(col, row) {
|
|
73652
|
+
const cellValue = this.table.getCellValue(col, row);
|
|
73653
|
+
if ("string" == typeof cellValue && cellValue.startsWith("=")) return cellValue;
|
|
73654
|
+
}
|
|
73655
|
+
setCellFormula(col, row, formula) {
|
|
73656
|
+
this.table.changeCellValue(col, row, formula);
|
|
73657
|
+
}
|
|
73658
|
+
getCalculatedValue(col, row) {
|
|
73659
|
+
return this.table.getCellValue(col, row);
|
|
73660
|
+
}
|
|
73661
|
+
refreshFormulas() {}
|
|
73662
|
+
hasFormulaEngine() {
|
|
73663
|
+
return !1;
|
|
73664
|
+
}
|
|
73665
|
+
}
|
|
73666
|
+
function createFormulaAdapter(table, customIsFormulaCell, customGetCellFormula, customSetCellFormula) {
|
|
73667
|
+
return customIsFormulaCell || customGetCellFormula || customSetCellFormula ? new CustomFormulaAdapter(table, customIsFormulaCell, customGetCellFormula, customSetCellFormula) : new DefaultFormulaAdapter(table);
|
|
73668
|
+
}
|
|
73669
|
+
class CustomFormulaAdapter {
|
|
73670
|
+
constructor(table, isFormulaCellFn, getCellFormulaFn, setCellFormulaFn) {
|
|
73671
|
+
this.table = table, this.isFormulaCellFn = isFormulaCellFn, this.getCellFormulaFn = getCellFormulaFn, this.setCellFormulaFn = setCellFormulaFn;
|
|
73672
|
+
}
|
|
73673
|
+
isFormulaCell(col, row) {
|
|
73674
|
+
if (this.isFormulaCellFn) {
|
|
73675
|
+
const cellData = this.table.getCellValue(col, row);
|
|
73676
|
+
return this.isFormulaCellFn(col, row, cellData, this.table);
|
|
73677
|
+
}
|
|
73678
|
+
const cellValue = this.table.getCellValue(col, row);
|
|
73679
|
+
return "string" == typeof cellValue && cellValue.startsWith("=");
|
|
73680
|
+
}
|
|
73681
|
+
getCellFormula(col, row) {
|
|
73682
|
+
if (this.getCellFormulaFn) {
|
|
73683
|
+
const cellData = this.table.getCellValue(col, row);
|
|
73684
|
+
return this.getCellFormulaFn(col, row, cellData, this.table);
|
|
73685
|
+
}
|
|
73686
|
+
const cellValue = this.table.getCellValue(col, row);
|
|
73687
|
+
if ("string" == typeof cellValue && cellValue.startsWith("=")) return cellValue;
|
|
73688
|
+
}
|
|
73689
|
+
setCellFormula(col, row, formula) {
|
|
73690
|
+
this.setCellFormulaFn ? this.setCellFormulaFn(col, row, formula, this.table) : this.table.changeCellValue(col, row, formula);
|
|
73691
|
+
}
|
|
73692
|
+
getCalculatedValue(col, row) {
|
|
73693
|
+
return this.table.getCellValue(col, row);
|
|
73694
|
+
}
|
|
73695
|
+
refreshFormulas() {}
|
|
73696
|
+
hasFormulaEngine() {
|
|
73697
|
+
return !1;
|
|
73698
|
+
}
|
|
73699
|
+
}
|
|
73700
|
+
|
|
73567
73701
|
/**
|
|
73568
73702
|
* A specialized version of `_.forEach` for arrays without support for
|
|
73569
73703
|
* iteratee shorthands.
|
|
@@ -75131,13 +75265,146 @@
|
|
|
75131
75265
|
function reverseIfNeed(data, reverse) {
|
|
75132
75266
|
return reverse ? data.reverse() : data;
|
|
75133
75267
|
}
|
|
75268
|
+
const formulaRule = {
|
|
75269
|
+
type: DATA_TYPE.FORMULA,
|
|
75270
|
+
priority: 1200,
|
|
75271
|
+
match: (cellData, accessor) => "string" == typeof (null == cellData ? void 0 : cellData.v) && cellData.v.startsWith("="),
|
|
75272
|
+
isContinue: (prev, cur) => {
|
|
75273
|
+
var _a;
|
|
75274
|
+
return !(prev.type !== DATA_TYPE.FORMULA || !(null === (_a = null == cur ? void 0 : cur.v) || void 0 === _a ? void 0 : _a.startsWith("=")));
|
|
75275
|
+
},
|
|
75276
|
+
applyFunctions: {
|
|
75277
|
+
[APPLY_TYPE.COPY]: (dataWithIndex, len, direction, copyDataPiece, location) => {
|
|
75278
|
+
const {
|
|
75279
|
+
data: data
|
|
75280
|
+
} = dataWithIndex;
|
|
75281
|
+
return fillCopy(data, len);
|
|
75282
|
+
},
|
|
75283
|
+
[APPLY_TYPE.SERIES]: (dataWithIndex, len, direction, copyDataPiece, location) => {
|
|
75284
|
+
const {
|
|
75285
|
+
data: data
|
|
75286
|
+
} = dataWithIndex;
|
|
75287
|
+
if (1 === data.length) return adjustFormulaReferences(data, len, direction);
|
|
75288
|
+
const adjustedFormulas = adjustFormulaReferencesInSeries(data, len);
|
|
75289
|
+
return adjustedFormulas || fillCopy(data, len);
|
|
75290
|
+
}
|
|
75291
|
+
}
|
|
75292
|
+
};
|
|
75293
|
+
function adjustFormulaReferences(formulas, len, direction, location) {
|
|
75294
|
+
var _a, _b;
|
|
75295
|
+
const result = [],
|
|
75296
|
+
baseFormula = (null === (_a = formulas[0]) || void 0 === _a ? void 0 : _a.v) || "";
|
|
75297
|
+
for (let i = 0; i < len; i++) {
|
|
75298
|
+
let newFormula = baseFormula,
|
|
75299
|
+
rowOffset = 0,
|
|
75300
|
+
colOffset = 0;
|
|
75301
|
+
switch (direction) {
|
|
75302
|
+
case Direction.DOWN:
|
|
75303
|
+
rowOffset = i + 1;
|
|
75304
|
+
break;
|
|
75305
|
+
case Direction.UP:
|
|
75306
|
+
rowOffset = -(i + 1);
|
|
75307
|
+
break;
|
|
75308
|
+
case Direction.RIGHT:
|
|
75309
|
+
colOffset = i + 1;
|
|
75310
|
+
break;
|
|
75311
|
+
case Direction.LEFT:
|
|
75312
|
+
colOffset = -(i + 1);
|
|
75313
|
+
}
|
|
75314
|
+
newFormula = adjustCellReferencesInFormula(baseFormula, rowOffset, colOffset), result.push({
|
|
75315
|
+
v: newFormula,
|
|
75316
|
+
t: null === (_b = formulas[0]) || void 0 === _b ? void 0 : _b.t
|
|
75317
|
+
});
|
|
75318
|
+
}
|
|
75319
|
+
return result;
|
|
75320
|
+
}
|
|
75321
|
+
function adjustFormulaReferencesInSeries(formulas, len, direction, location) {
|
|
75322
|
+
var _a, _b, _c;
|
|
75323
|
+
if (formulas.length < 2) return null;
|
|
75324
|
+
const baseFormula1 = (null === (_a = formulas[0]) || void 0 === _a ? void 0 : _a.v) || "",
|
|
75325
|
+
pattern = detectFormulaPattern(baseFormula1, (null === (_b = formulas[1]) || void 0 === _b ? void 0 : _b.v) || "");
|
|
75326
|
+
if (!pattern) return null;
|
|
75327
|
+
const result = [];
|
|
75328
|
+
for (let i = 0; i < len; i++) {
|
|
75329
|
+
let newFormula = baseFormula1;
|
|
75330
|
+
newFormula = applyFormulaPattern(newFormula, pattern, i + 1), result.push({
|
|
75331
|
+
v: newFormula,
|
|
75332
|
+
t: null === (_c = formulas[0]) || void 0 === _c ? void 0 : _c.t
|
|
75333
|
+
});
|
|
75334
|
+
}
|
|
75335
|
+
return result;
|
|
75336
|
+
}
|
|
75337
|
+
function detectFormulaPattern(formula1, formula2) {
|
|
75338
|
+
const cellRefRegex = /\$?([A-Z]+)\$?(\d+)/g,
|
|
75339
|
+
matches1 = [...formula1.matchAll(cellRefRegex)],
|
|
75340
|
+
matches2 = [...formula2.matchAll(cellRefRegex)];
|
|
75341
|
+
if (matches1.length !== matches2.length || 0 === matches1.length) return null;
|
|
75342
|
+
let totalRowOffset = 0,
|
|
75343
|
+
totalColOffset = 0,
|
|
75344
|
+
validMatches = 0;
|
|
75345
|
+
for (let i = 0; i < matches1.length; i++) {
|
|
75346
|
+
const col1 = matches1[i][1],
|
|
75347
|
+
row1 = parseInt(matches1[i][2], 10),
|
|
75348
|
+
col2 = matches2[i][1],
|
|
75349
|
+
row2 = parseInt(matches2[i][2], 10),
|
|
75350
|
+
colOffset = columnToNumber(col2) - columnToNumber(col1),
|
|
75351
|
+
rowOffset = row2 - row1;
|
|
75352
|
+
Math.abs(colOffset) < 100 && Math.abs(rowOffset) < 1e4 && (totalColOffset += colOffset, totalRowOffset += rowOffset, validMatches++);
|
|
75353
|
+
}
|
|
75354
|
+
return 0 === validMatches ? null : {
|
|
75355
|
+
rowOffset: totalRowOffset / validMatches,
|
|
75356
|
+
colOffset: totalColOffset / validMatches
|
|
75357
|
+
};
|
|
75358
|
+
}
|
|
75359
|
+
function applyFormulaPattern(formula, pattern, multiplier, direction) {
|
|
75360
|
+
return formula.replace(/\$?([A-Z]+)\$?(\d+)/g, (match, colStr, rowStr) => {
|
|
75361
|
+
const isColAbsolute = match.startsWith("$") && match.indexOf(colStr) > 0,
|
|
75362
|
+
isRowAbsolute = match.includes("$" + rowStr);
|
|
75363
|
+
let newCol = colStr,
|
|
75364
|
+
newRow = rowStr;
|
|
75365
|
+
if (!isColAbsolute && 0 !== pattern.colOffset) {
|
|
75366
|
+
newCol = numberToColumn(columnToNumber(colStr) + pattern.colOffset * multiplier);
|
|
75367
|
+
}
|
|
75368
|
+
if (!isRowAbsolute && 0 !== pattern.rowOffset) {
|
|
75369
|
+
newRow = (parseInt(rowStr, 10) + pattern.rowOffset * multiplier).toString();
|
|
75370
|
+
}
|
|
75371
|
+
let result = "";
|
|
75372
|
+
return isColAbsolute && (result += "$"), result += newCol, isRowAbsolute && (result += "$"), result += newRow, result;
|
|
75373
|
+
});
|
|
75374
|
+
}
|
|
75375
|
+
function adjustCellReferencesInFormula(formula, rowOffset, colOffset) {
|
|
75376
|
+
return formula.replace(/\$?([A-Z]+)\$?(\d+)/g, (match, colStr, rowStr) => {
|
|
75377
|
+
const isColAbsolute = match.startsWith("$") && match.indexOf(colStr) > 0,
|
|
75378
|
+
isRowAbsolute = match.includes("$" + rowStr);
|
|
75379
|
+
let newCol = colStr,
|
|
75380
|
+
newRow = rowStr;
|
|
75381
|
+
if (!isColAbsolute && 0 !== colOffset) {
|
|
75382
|
+
newCol = numberToColumn(columnToNumber(colStr) + colOffset);
|
|
75383
|
+
}
|
|
75384
|
+
if (!isRowAbsolute && 0 !== rowOffset) {
|
|
75385
|
+
newRow = (parseInt(rowStr, 10) + rowOffset).toString();
|
|
75386
|
+
}
|
|
75387
|
+
let result = "";
|
|
75388
|
+
return isColAbsolute && (result += "$"), result += newCol, isRowAbsolute && (result += "$"), result += newRow, result;
|
|
75389
|
+
});
|
|
75390
|
+
}
|
|
75391
|
+
function columnToNumber(col) {
|
|
75392
|
+
let result = 0;
|
|
75393
|
+
for (let i = 0; i < col.length; i++) result = 26 * result + (col.charCodeAt(i) - "A".charCodeAt(0) + 1);
|
|
75394
|
+
return result;
|
|
75395
|
+
}
|
|
75396
|
+
function numberToColumn(num) {
|
|
75397
|
+
let result = "";
|
|
75398
|
+
for (; num > 0;) num--, result = String.fromCharCode("A".charCodeAt(0) + num % 26) + result, num = Math.floor(num / 26);
|
|
75399
|
+
return result;
|
|
75400
|
+
}
|
|
75134
75401
|
|
|
75135
75402
|
class AutoFillService {
|
|
75136
75403
|
constructor() {
|
|
75137
75404
|
this._rules = [], this._init();
|
|
75138
75405
|
}
|
|
75139
75406
|
_init() {
|
|
75140
|
-
this._rules = [dateRule, numberRule, extendNumberRule, chnNumberRule, chnWeek2Rule, chnWeek3Rule, loopSeriesRule, otherRule].sort((a, b) => b.priority - a.priority);
|
|
75407
|
+
this._rules = [formulaRule, dateRule, numberRule, extendNumberRule, chnNumberRule, chnWeek2Rule, chnWeek3Rule, loopSeriesRule, otherRule].sort((a, b) => b.priority - a.priority);
|
|
75141
75408
|
}
|
|
75142
75409
|
registerRule(rule) {
|
|
75143
75410
|
if (this._rules.find(r => r.type === rule.type)) throw new Error(`Registry rule failed, type '${rule.type}' already exist!`);
|
|
@@ -75149,87 +75416,16 @@
|
|
|
75149
75416
|
}
|
|
75150
75417
|
}
|
|
75151
75418
|
|
|
75152
|
-
function getSelectedRangeArray(selectedRange) {
|
|
75153
|
-
const minCol = Math.min(selectedRange.start.col, selectedRange.end.col),
|
|
75154
|
-
minRow = Math.min(selectedRange.start.row, selectedRange.end.row),
|
|
75155
|
-
maxCol = Math.max(selectedRange.start.col, selectedRange.end.col),
|
|
75156
|
-
maxRow = Math.max(selectedRange.start.row, selectedRange.end.row),
|
|
75157
|
-
cols = [],
|
|
75158
|
-
rows = [];
|
|
75159
|
-
for (let i = minCol; i <= maxCol; i++) cols.push(i);
|
|
75160
|
-
for (let i = minRow; i <= maxRow; i++) rows.push(i);
|
|
75161
|
-
return {
|
|
75162
|
-
cols: cols,
|
|
75163
|
-
rows: rows
|
|
75164
|
-
};
|
|
75165
|
-
}
|
|
75166
|
-
function getTargetRange(direction, sourceRange, selectedRange) {
|
|
75167
|
-
return direction === Direction.DOWN || direction === Direction.UP ? {
|
|
75168
|
-
cols: selectedRange.cols,
|
|
75169
|
-
rows: selectedRange.rows.filter(row => !sourceRange.rows.includes(row))
|
|
75170
|
-
} : {
|
|
75171
|
-
cols: selectedRange.cols.filter(col => !sourceRange.cols.includes(col)),
|
|
75172
|
-
rows: selectedRange.rows
|
|
75173
|
-
};
|
|
75174
|
-
}
|
|
75175
|
-
function openAutoFillMenu(tableInstance, endCol, endRow) {
|
|
75176
|
-
const rect = tableInstance.scenegraph.highPerformanceGetCell(endCol, endRow).globalAABBBounds;
|
|
75177
|
-
tableInstance.showDropDownMenu(endCol, endRow, {
|
|
75178
|
-
content: [{
|
|
75179
|
-
type: "item",
|
|
75180
|
-
text: "复制填充",
|
|
75181
|
-
icon: {
|
|
75182
|
-
width: 16,
|
|
75183
|
-
height: 16,
|
|
75184
|
-
svg: '<svg t="1756136702877" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1474" width="200" height="200"><path d="M853.333333 981.333333h-384c-72.533333 0-128-55.466667-128-128v-384c0-72.533333 55.466667-128 128-128h384c72.533333 0 128 55.466667 128 128v384c0 72.533333-55.466667 128-128 128z m-384-554.666666c-25.6 0-42.666667 17.066667-42.666666 42.666666v384c0 25.6 17.066667 42.666667 42.666666 42.666667h384c25.6 0 42.666667-17.066667 42.666667-42.666667v-384c0-25.6-17.066667-42.666667-42.666667-42.666666h-384z" p-id="1475"></path><path d="M213.333333 682.666667H170.666667c-72.533333 0-128-55.466667-128-128V170.666667c0-72.533333 55.466667-128 128-128h384c72.533333 0 128 55.466667 128 128v42.666666c0 25.6-17.066667 42.666667-42.666667 42.666667s-42.666667-17.066667-42.666667-42.666667V170.666667c0-25.6-17.066667-42.666667-42.666666-42.666667H170.666667c-25.6 0-42.666667 17.066667-42.666667 42.666667v384c0 25.6 17.066667 42.666667 42.666667 42.666666h42.666666c25.6 0 42.666667 17.066667 42.666667 42.666667s-17.066667 42.666667-42.666667 42.666667z" p-id="1476"></path></svg>'
|
|
75185
|
-
}
|
|
75186
|
-
}, {
|
|
75187
|
-
type: "item",
|
|
75188
|
-
text: "序列填充",
|
|
75189
|
-
icon: {
|
|
75190
|
-
width: 16,
|
|
75191
|
-
height: 16,
|
|
75192
|
-
svg: '<svg t="1756136788547" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2463" width="200" height="200"><path d="M312.832482 65.167035H959.204489c35.706211 0 64.64232 29.473622 64.64232 65.832527 0 36.346107-28.936109 65.832527-64.629522 65.832527H312.819684c-35.693413 0-64.629522-29.473622-64.629522-65.832527 0-36.346107 28.936109-65.832527 64.629522-65.832527z m0 394.982363H959.204489c35.706211 0 64.64232 29.460824 64.64232 65.819729 0 36.358905-28.936109 65.832527-64.629522 65.832527H312.819684c-35.693413 0-64.629522-29.473622-64.629522-65.832527 0-36.346107 28.936109-65.819729 64.629522-65.819729z m0 394.969566H959.204489c35.706211 0 64.64232 29.473622 64.64232 65.819729 0 36.358905-28.936109 65.832527-64.629522 65.832527H312.819684c-35.693413 0-64.629522-29.473622-64.629522-65.832527 0-36.346107 28.936109-65.819729 64.629522-65.819729zM12.286008 69.108796V38.176211c9.892796 0.767876 19.836784 0.767876 29.72958 0A41.823619 41.823619 0 0 0 63.989626 25.672638c4.261709-4.671243 7.358807-10.315128 9.048133-16.458132 0.37114-3.058704 0.37114-6.143004 0-9.214506H114.413451v229.748352H65.93491V69.108796H12.286008z m0 510.176487a130.730805 130.730805 0 0 1 45.240665-49.374395 334.537763 334.537763 0 0 0 40.070304-32.250771 48.47854 48.47854 0 0 0 14.218495-33.581756 37.31875 37.31875 0 0 0-7.755543-24.354451 28.193829 28.193829 0 0 0-23.266628-9.879998 27.643518 27.643518 0 0 0-31.02217 15.139945 78.27211 78.27211 0 0 0-5.170362 28.30901H2.585181a114.311067 114.311067 0 0 1 10.340723-48.056208c12.388392-24.124089 38.086625-37.984242 64.629522-34.887144a79.897447 79.897447 0 0 1 57.539472 20.41269 71.783562 71.783562 0 0 1 21.321343 53.981648 74.637499 74.637499 0 0 1-14.858391 46.072531 152.16733 152.16733 0 0 1-32.967455 29.627197L90.481331 553.625443l-23.266628 17.763521c-4.082538 3.583419-7.563574 7.806734-10.353522 12.51637h99.542262v40.147092H0a110.945213 110.945213 0 0 1 10.340724-45.419837l1.945284 0.665492zM44.600769 948.582211a53.495327 53.495327 0 0 0 4.517668 23.036265 30.279891 30.279891 0 0 0 29.742378 17.110826c7.422797 0.255959 14.717614-2.073264 20.681447-6.578133 6.7829-6.962071 10.315128-16.547717 9.688029-26.325332a30.356678 30.356678 0 0 0-18.096266-30.945383 91.735527 91.735527 0 0 0-32.314761-8.561812V883.440772a83.903197 83.903197 0 0 0 30.382274-4.607253 27.106005 27.106005 0 0 0 14.858391-28.30901 30.612637 30.612637 0 0 0-7.755542-21.730877 27.528337 27.528337 0 0 0-21.321344-8.549014 26.939632 26.939632 0 0 0-23.279425 10.532692 44.063256 44.063256 0 0 0-7.102849 27.643519H2.585181a117.101015 117.101015 0 0 1 5.823056-32.916264 74.381541 74.381541 0 0 1 17.443572-25.019944 60.534186 60.534186 0 0 1 20.681447-12.503572 89.55988 89.55988 0 0 1 29.742378-3.289067A78.540867 78.540867 0 0 1 129.259044 801.79001a57.744238 57.744238 0 0 1 20.041551 46.085328 51.921182 51.921182 0 0 1-12.286008 34.887144c-4.159326 5.170362-9.470465 9.227304-15.511086 11.850879 6.7829 1.510155 12.900309 5.208756 17.45637 10.532692a57.821026 57.821026 0 0 1 17.443572 44.10165 75.136618 75.136618 0 0 1-20.028753 52.010768 76.122059 76.122059 0 0 1-59.471958 22.383571 71.962733 71.962733 0 0 1-64.629522-32.250771A97.52019 97.52019 0 0 1 1.279793 946.611331l43.308178 1.97088z" fill="#515151" p-id="2464"></path></svg>'
|
|
75193
|
-
}
|
|
75194
|
-
}],
|
|
75195
|
-
referencePosition: {
|
|
75196
|
-
rect: {
|
|
75197
|
-
right: rect.x2 + 110,
|
|
75198
|
-
bottom: rect.y2
|
|
75199
|
-
}
|
|
75200
|
-
}
|
|
75201
|
-
});
|
|
75202
|
-
}
|
|
75203
|
-
function getCellMatrix(table) {
|
|
75204
|
-
return {
|
|
75205
|
-
getValue: (row, col) => {
|
|
75206
|
-
const value = table.getCellValue(col, row);
|
|
75207
|
-
return "number" != typeof value && isNaN(Number(value)) ? {
|
|
75208
|
-
v: value || "",
|
|
75209
|
-
t: CellValueType.STRING
|
|
75210
|
-
} : {
|
|
75211
|
-
v: value,
|
|
75212
|
-
t: CellValueType.NUMBER
|
|
75213
|
-
};
|
|
75214
|
-
},
|
|
75215
|
-
getMaxRows: () => table.records.length,
|
|
75216
|
-
getMaxColumns: () => table.columns.length
|
|
75217
|
-
};
|
|
75218
|
-
}
|
|
75219
|
-
function isMergeCell(table, col, row) {
|
|
75220
|
-
const cellRange = table.getCellRange(col, row);
|
|
75221
|
-
return cellRange.start.col !== cellRange.end.col || cellRange.start.row !== cellRange.end.row ? cellRange : null;
|
|
75222
|
-
}
|
|
75223
|
-
|
|
75224
75419
|
class AutoFillManager {
|
|
75225
75420
|
constructor(options) {
|
|
75226
|
-
this.sourceData = [], this.options = options, this.autoFillService = new AutoFillService();
|
|
75421
|
+
this.sourceData = [], this.options = options, this.autoFillService = new AutoFillService(), this.formulaAdapter = new DefaultFormulaAdapter({});
|
|
75227
75422
|
}
|
|
75228
75423
|
setTable(table) {
|
|
75424
|
+
var _a, _b, _c;
|
|
75229
75425
|
this.headers = {
|
|
75230
75426
|
row: new Set(),
|
|
75231
75427
|
col: new Set()
|
|
75232
|
-
}, this.tableInstance = table, table.on(TABLE_EVENT_TYPE.DROPDOWN_MENU_CLICK, args => {
|
|
75428
|
+
}, this.tableInstance = table, this.formulaAdapter = createFormulaAdapter(table, null === (_a = this.options) || void 0 === _a ? void 0 : _a.isFormulaCell, null === (_b = this.options) || void 0 === _b ? void 0 : _b.getCellFormula, null === (_c = this.options) || void 0 === _c ? void 0 : _c.setCellFormula), table.on(TABLE_EVENT_TYPE.DROPDOWN_MENU_CLICK, args => {
|
|
75233
75429
|
"复制填充" === args.text ? this.fillData(APPLY_TYPE.COPY) : "序列填充" === args.text && this.fillData(APPLY_TYPE.SERIES);
|
|
75234
75430
|
});
|
|
75235
75431
|
const rowHeaderCells = this.tableInstance.getAllRowHeaderCells()[0];
|
|
@@ -75286,11 +75482,19 @@
|
|
|
75286
75482
|
};
|
|
75287
75483
|
bArray.forEach(b => {
|
|
75288
75484
|
let data;
|
|
75289
|
-
|
|
75290
|
-
|
|
75291
|
-
|
|
75292
|
-
|
|
75293
|
-
|
|
75485
|
+
const col = isVertical ? a : b,
|
|
75486
|
+
row = isVertical ? b : a;
|
|
75487
|
+
if (data = isVertical ? matrix.getValue(b, a) : matrix.getValue(a, b), data && this.formulaAdapter.isFormulaCell(col, row)) {
|
|
75488
|
+
const formula = this.formulaAdapter.getCellFormula(col, row);
|
|
75489
|
+
formula && (data = Object.assign(Object.assign({}, data), {
|
|
75490
|
+
v: formula
|
|
75491
|
+
}));
|
|
75492
|
+
}
|
|
75493
|
+
const ruleMatch = rules.find(r => r.match(data, null)) || otherRule,
|
|
75494
|
+
{
|
|
75495
|
+
type: type,
|
|
75496
|
+
isContinue: isContinue
|
|
75497
|
+
} = ruleMatch;
|
|
75294
75498
|
if (isContinue(prevData, data)) {
|
|
75295
75499
|
const typeInfo = sourceDataPiece[type],
|
|
75296
75500
|
last = typeInfo[typeInfo.length - 1];
|
|
@@ -75394,18 +75598,32 @@
|
|
|
75394
75598
|
applyDatas.push(row);
|
|
75395
75599
|
});
|
|
75396
75600
|
}
|
|
75397
|
-
const values = []
|
|
75601
|
+
const values = [],
|
|
75602
|
+
formulaUpdates = [];
|
|
75398
75603
|
targetRows.forEach((row, rowIndex) => {
|
|
75399
75604
|
const rowValues = [];
|
|
75400
75605
|
targetCols.forEach((col, colIndex) => {
|
|
75401
|
-
var _a;
|
|
75402
75606
|
const range = isMergeCell(this.tableInstance, col, row);
|
|
75403
|
-
range && this.tableInstance.unmergeCells(range.start.col, range.start.row, range.end.col, range.end.row), applyDatas[rowIndex][colIndex]
|
|
75607
|
+
if (range && this.tableInstance.unmergeCells(range.start.col, range.start.row, range.end.col, range.end.row), applyDatas[rowIndex][colIndex]) {
|
|
75608
|
+
const cellData = applyDatas[rowIndex][colIndex],
|
|
75609
|
+
cellValue = (null == cellData ? void 0 : cellData.v) + "";
|
|
75610
|
+
cellData && "string" == typeof cellData.v && cellData.v.startsWith("=") ? (formulaUpdates.push({
|
|
75611
|
+
col: col,
|
|
75612
|
+
row: row,
|
|
75613
|
+
formula: cellData.v
|
|
75614
|
+
}), rowValues.push(cellValue)) : rowValues.push(cellValue);
|
|
75615
|
+
}
|
|
75404
75616
|
}), values.push(rowValues);
|
|
75405
75617
|
});
|
|
75406
75618
|
const minRow = Math.min(...targetRows),
|
|
75407
75619
|
minCol = Math.min(...targetCols);
|
|
75408
|
-
this.tableInstance.changeCellValues(minCol, minRow, values)
|
|
75620
|
+
this.tableInstance.changeCellValues(minCol, minRow, values), formulaUpdates.length > 0 && (formulaUpdates.forEach(({
|
|
75621
|
+
col: col,
|
|
75622
|
+
row: row,
|
|
75623
|
+
formula: formula
|
|
75624
|
+
}) => {
|
|
75625
|
+
this.formulaAdapter.setCellFormula(col, row, formula);
|
|
75626
|
+
}), this.formulaAdapter.hasFormulaEngine() && this.formulaAdapter.refreshFormulas());
|
|
75409
75627
|
}
|
|
75410
75628
|
getApplyData(sourceDataPiece, csLen, asLen, direction, applyType, location) {
|
|
75411
75629
|
const applyData = [],
|
|
@@ -75465,7 +75683,7 @@
|
|
|
75465
75683
|
run(...args) {
|
|
75466
75684
|
var _a, _b;
|
|
75467
75685
|
if (args[1] === TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE) {
|
|
75468
|
-
const [
|
|
75686
|
+
const [,, table] = args;
|
|
75469
75687
|
this.table = table, this.autoFillManager.setTable(this.table), this.autoFillManager.handleStartDrag(null === (_a = this.table) || void 0 === _a ? void 0 : _a.getSelectedCellRanges()[0]);
|
|
75470
75688
|
} else if (args[1] === TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END) {
|
|
75471
75689
|
const [{
|
|
@@ -76207,10 +76425,10 @@
|
|
|
76207
76425
|
const value = formulaInput.value;
|
|
76208
76426
|
if (value.startsWith('=') && value.length > 1) {
|
|
76209
76427
|
try {
|
|
76210
|
-
const currentCellAddress = activeWorkSheet.addressFromCoord(selection.
|
|
76428
|
+
const currentCellAddress = activeWorkSheet.addressFromCoord(selection.col, selection.row);
|
|
76211
76429
|
const cellRegex = new RegExp(`(^|[^A-Za-z0-9])${currentCellAddress}([^A-Za-z0-9]|$)`);
|
|
76212
76430
|
if (cellRegex.test(value)) {
|
|
76213
|
-
activeWorkSheet.setCellValue(selection.
|
|
76431
|
+
activeWorkSheet.setCellValue(selection.col, selection.row, '#CYCLE!');
|
|
76214
76432
|
activeWorkSheet.tableInstance?.changeCellValue(selection.col, selection.row, '#CYCLE!');
|
|
76215
76433
|
formulaInput.value = '';
|
|
76216
76434
|
formulaInput.blur();
|
|
@@ -76226,14 +76444,14 @@
|
|
|
76226
76444
|
row: selection.row,
|
|
76227
76445
|
col: selection.col
|
|
76228
76446
|
});
|
|
76229
|
-
activeWorkSheet.setCellValue(selection.
|
|
76447
|
+
activeWorkSheet.setCellValue(selection.col, selection.row, result.value);
|
|
76230
76448
|
}
|
|
76231
76449
|
catch (error) {
|
|
76232
|
-
activeWorkSheet.setCellValue(selection.
|
|
76450
|
+
activeWorkSheet.setCellValue(selection.col, selection.row, '#ERROR!');
|
|
76233
76451
|
}
|
|
76234
76452
|
}
|
|
76235
76453
|
else {
|
|
76236
|
-
activeWorkSheet.setCellValue(selection.
|
|
76454
|
+
activeWorkSheet.setCellValue(selection.col, selection.row, value);
|
|
76237
76455
|
}
|
|
76238
76456
|
}
|
|
76239
76457
|
}
|
|
@@ -76263,7 +76481,7 @@
|
|
|
76263
76481
|
}
|
|
76264
76482
|
const cellAddressBox = this.formulaBarElement.querySelector('.vtable-sheet-cell-address');
|
|
76265
76483
|
if (cellAddressBox) {
|
|
76266
|
-
cellAddressBox.textContent = activeWorkSheet.addressFromCoord(selection.
|
|
76484
|
+
cellAddressBox.textContent = activeWorkSheet.addressFromCoord(selection.startCol, selection.startRow);
|
|
76267
76485
|
}
|
|
76268
76486
|
const formulaInput = this.formulaInput;
|
|
76269
76487
|
if (formulaInput) {
|
|
@@ -76285,7 +76503,7 @@
|
|
|
76285
76503
|
formulaInput.value = displayFormula;
|
|
76286
76504
|
}
|
|
76287
76505
|
else {
|
|
76288
|
-
const cellValue = activeWorkSheet.getCellValue(selection.
|
|
76506
|
+
const cellValue = activeWorkSheet.getCellValue(selection.startCol, selection.startRow);
|
|
76289
76507
|
formulaInput.value = cellValue !== undefined && cellValue !== null ? String(cellValue) : '';
|
|
76290
76508
|
}
|
|
76291
76509
|
}
|
|
@@ -76355,10 +76573,10 @@
|
|
|
76355
76573
|
const value = input.value;
|
|
76356
76574
|
if (value.startsWith('=') && value.length > 1) {
|
|
76357
76575
|
try {
|
|
76358
|
-
const currentCellAddress = activeWorkSheet.addressFromCoord(editingCell.
|
|
76576
|
+
const currentCellAddress = activeWorkSheet.addressFromCoord(editingCell.col, editingCell.row);
|
|
76359
76577
|
const cellRegex = new RegExp(`(^|[^A-Za-z0-9])${currentCellAddress}([^A-Za-z0-9]|$)`);
|
|
76360
76578
|
if (cellRegex.test(value)) {
|
|
76361
|
-
activeWorkSheet.setCellValue(editingCell.
|
|
76579
|
+
activeWorkSheet.setCellValue(editingCell.col, editingCell.row, '#CYCLE!');
|
|
76362
76580
|
activeWorkSheet.tableInstance?.changeCellValue(editingCell.col, editingCell.row, '#CYCLE!');
|
|
76363
76581
|
this.sheet.formulaManager.formulaWorkingOnCell = null;
|
|
76364
76582
|
input.value = '';
|
|
@@ -76386,13 +76604,13 @@
|
|
|
76386
76604
|
}, 0);
|
|
76387
76605
|
}
|
|
76388
76606
|
catch (error) {
|
|
76389
|
-
activeWorkSheet.setCellValue(editingCell.
|
|
76607
|
+
activeWorkSheet.setCellValue(editingCell.col, editingCell.row, '#ERROR!');
|
|
76390
76608
|
activeWorkSheet.tableInstance?.changeCellValue(editingCell.col, editingCell.row, '#ERROR!');
|
|
76391
76609
|
this.sheet.formulaManager.formulaWorkingOnCell = null;
|
|
76392
76610
|
}
|
|
76393
76611
|
}
|
|
76394
76612
|
else {
|
|
76395
|
-
activeWorkSheet.setCellValue(editingCell.
|
|
76613
|
+
activeWorkSheet.setCellValue(editingCell.col, editingCell.row, value);
|
|
76396
76614
|
activeWorkSheet.tableInstance?.changeCellValue(editingCell.col, editingCell.row, value);
|
|
76397
76615
|
this.sheet.formulaManager.formulaWorkingOnCell = null;
|
|
76398
76616
|
}
|
|
@@ -76612,6 +76830,246 @@
|
|
|
76612
76830
|
}
|
|
76613
76831
|
}
|
|
76614
76832
|
|
|
76833
|
+
class FormulaReferenceAdjustor {
|
|
76834
|
+
static CELL_REF_REGEX = /(\$?[A-Z]+\$?\d+(?::\$?[A-Z]+\$?\d+)?)/gi;
|
|
76835
|
+
static SINGLE_CELL_REGEX = /(\$?)([A-Z]+)(\$?)(\d+)/i;
|
|
76836
|
+
static parseCellReference(ref) {
|
|
76837
|
+
const match = ref.match(this.SINGLE_CELL_REGEX);
|
|
76838
|
+
if (!match) {
|
|
76839
|
+
return null;
|
|
76840
|
+
}
|
|
76841
|
+
const [, colAbsolute, colStr, rowAbsolute, rowStr] = match;
|
|
76842
|
+
const col = this.columnToNumber(colStr);
|
|
76843
|
+
const row = parseInt(rowStr, 10) - 1;
|
|
76844
|
+
let type;
|
|
76845
|
+
if (colAbsolute && rowAbsolute) {
|
|
76846
|
+
type = 'absolute';
|
|
76847
|
+
}
|
|
76848
|
+
else if (colAbsolute && !rowAbsolute) {
|
|
76849
|
+
type = 'mixed_col';
|
|
76850
|
+
}
|
|
76851
|
+
else if (!colAbsolute && rowAbsolute) {
|
|
76852
|
+
type = 'mixed_row';
|
|
76853
|
+
}
|
|
76854
|
+
else {
|
|
76855
|
+
type = 'relative';
|
|
76856
|
+
}
|
|
76857
|
+
return {
|
|
76858
|
+
type,
|
|
76859
|
+
col,
|
|
76860
|
+
row,
|
|
76861
|
+
originalColRef: colAbsolute + colStr,
|
|
76862
|
+
originalRowRef: rowAbsolute + rowStr,
|
|
76863
|
+
fullReference: ref
|
|
76864
|
+
};
|
|
76865
|
+
}
|
|
76866
|
+
static columnToNumber(col) {
|
|
76867
|
+
let result = 0;
|
|
76868
|
+
for (let i = 0; i < col.length; i++) {
|
|
76869
|
+
result = result * 26 + (col.charCodeAt(i) - 'A'.charCodeAt(0) + 1);
|
|
76870
|
+
}
|
|
76871
|
+
return result - 1;
|
|
76872
|
+
}
|
|
76873
|
+
static numberToColumn(num) {
|
|
76874
|
+
let result = '';
|
|
76875
|
+
let n = num + 1;
|
|
76876
|
+
while (n > 0) {
|
|
76877
|
+
n--;
|
|
76878
|
+
result = String.fromCharCode('A'.charCodeAt(0) + (n % 26)) + result;
|
|
76879
|
+
n = Math.floor(n / 26);
|
|
76880
|
+
}
|
|
76881
|
+
return result;
|
|
76882
|
+
}
|
|
76883
|
+
static adjustCellReference(ref, offset) {
|
|
76884
|
+
let newCol = ref.col;
|
|
76885
|
+
let newRow = ref.row;
|
|
76886
|
+
switch (ref.type) {
|
|
76887
|
+
case 'relative':
|
|
76888
|
+
newCol += offset.colOffset;
|
|
76889
|
+
newRow += offset.rowOffset;
|
|
76890
|
+
break;
|
|
76891
|
+
case 'mixed_row':
|
|
76892
|
+
newCol += offset.colOffset;
|
|
76893
|
+
newRow = ref.row;
|
|
76894
|
+
break;
|
|
76895
|
+
case 'mixed_col':
|
|
76896
|
+
newCol = ref.col;
|
|
76897
|
+
newRow += offset.rowOffset;
|
|
76898
|
+
break;
|
|
76899
|
+
case 'absolute':
|
|
76900
|
+
newCol = ref.col;
|
|
76901
|
+
newRow = ref.row;
|
|
76902
|
+
break;
|
|
76903
|
+
}
|
|
76904
|
+
if (newCol < 0) {
|
|
76905
|
+
newCol = 0;
|
|
76906
|
+
}
|
|
76907
|
+
if (newRow < 0) {
|
|
76908
|
+
newRow = 0;
|
|
76909
|
+
}
|
|
76910
|
+
let result = '';
|
|
76911
|
+
if (ref.type === 'absolute' || ref.type === 'mixed_col') {
|
|
76912
|
+
result += '$';
|
|
76913
|
+
}
|
|
76914
|
+
result += this.numberToColumn(newCol);
|
|
76915
|
+
if (ref.type === 'absolute' || ref.type === 'mixed_row') {
|
|
76916
|
+
result += '$';
|
|
76917
|
+
}
|
|
76918
|
+
result += newRow + 1;
|
|
76919
|
+
return result;
|
|
76920
|
+
}
|
|
76921
|
+
static adjustFormulaReferences(formula, colOffset, rowOffset) {
|
|
76922
|
+
const offset = {
|
|
76923
|
+
colOffset: colOffset,
|
|
76924
|
+
rowOffset: rowOffset
|
|
76925
|
+
};
|
|
76926
|
+
return typeof formula === 'string'
|
|
76927
|
+
? formula.replace(this.CELL_REF_REGEX, match => {
|
|
76928
|
+
if (match.includes(':')) {
|
|
76929
|
+
const parts = match.split(':');
|
|
76930
|
+
const startRef = this.parseCellReference(parts[0]);
|
|
76931
|
+
const endRef = this.parseCellReference(parts[1]);
|
|
76932
|
+
if (startRef && endRef) {
|
|
76933
|
+
const newStart = this.adjustCellReference(startRef, offset);
|
|
76934
|
+
const newEnd = this.adjustCellReference(endRef, offset);
|
|
76935
|
+
return `${newStart}:${newEnd}`;
|
|
76936
|
+
}
|
|
76937
|
+
return match;
|
|
76938
|
+
}
|
|
76939
|
+
const ref = this.parseCellReference(match);
|
|
76940
|
+
if (ref) {
|
|
76941
|
+
return this.adjustCellReference(ref, offset);
|
|
76942
|
+
}
|
|
76943
|
+
return match;
|
|
76944
|
+
})
|
|
76945
|
+
: formula;
|
|
76946
|
+
}
|
|
76947
|
+
static isFormula(value) {
|
|
76948
|
+
return typeof value === 'string' && value.startsWith('=');
|
|
76949
|
+
}
|
|
76950
|
+
static extractReferences(formula) {
|
|
76951
|
+
const references = [];
|
|
76952
|
+
const matches = formula.match(this.CELL_REF_REGEX);
|
|
76953
|
+
if (matches) {
|
|
76954
|
+
matches.forEach(match => {
|
|
76955
|
+
if (match.includes(':')) {
|
|
76956
|
+
const parts = match.split(':');
|
|
76957
|
+
const startRef = this.parseCellReference(parts[0]);
|
|
76958
|
+
const endRef = this.parseCellReference(parts[1]);
|
|
76959
|
+
if (startRef) {
|
|
76960
|
+
references.push(startRef);
|
|
76961
|
+
}
|
|
76962
|
+
if (endRef) {
|
|
76963
|
+
references.push(endRef);
|
|
76964
|
+
}
|
|
76965
|
+
}
|
|
76966
|
+
else {
|
|
76967
|
+
const ref = this.parseCellReference(match);
|
|
76968
|
+
if (ref) {
|
|
76969
|
+
references.push(ref);
|
|
76970
|
+
}
|
|
76971
|
+
}
|
|
76972
|
+
});
|
|
76973
|
+
}
|
|
76974
|
+
return references;
|
|
76975
|
+
}
|
|
76976
|
+
static getFormulaReferenceBounds(formula) {
|
|
76977
|
+
const references = this.extractReferences(formula);
|
|
76978
|
+
if (references.length === 0) {
|
|
76979
|
+
return null;
|
|
76980
|
+
}
|
|
76981
|
+
let minCol = Infinity;
|
|
76982
|
+
let maxCol = -Infinity;
|
|
76983
|
+
let minRow = Infinity;
|
|
76984
|
+
let maxRow = -Infinity;
|
|
76985
|
+
references.forEach(ref => {
|
|
76986
|
+
minCol = Math.min(minCol, ref.col);
|
|
76987
|
+
maxCol = Math.max(maxCol, ref.col);
|
|
76988
|
+
minRow = Math.min(minRow, ref.row);
|
|
76989
|
+
maxRow = Math.max(maxRow, ref.row);
|
|
76990
|
+
});
|
|
76991
|
+
return {
|
|
76992
|
+
minCol,
|
|
76993
|
+
maxCol,
|
|
76994
|
+
minRow,
|
|
76995
|
+
maxRow
|
|
76996
|
+
};
|
|
76997
|
+
}
|
|
76998
|
+
}
|
|
76999
|
+
|
|
77000
|
+
class FormulaPasteProcessor {
|
|
77001
|
+
static adjustFormulaForPaste(formula, context) {
|
|
77002
|
+
if (!FormulaReferenceAdjustor.isFormula(formula)) {
|
|
77003
|
+
return formula;
|
|
77004
|
+
}
|
|
77005
|
+
const colOffset = context.targetCell.col - context.sourceCell.col;
|
|
77006
|
+
const rowOffset = context.targetCell.row - context.sourceCell.row;
|
|
77007
|
+
return FormulaReferenceAdjustor.adjustFormulaReferences(formula, colOffset, rowOffset);
|
|
77008
|
+
}
|
|
77009
|
+
static adjustFormulasForPaste(formulas, context) {
|
|
77010
|
+
const colOffset = context.targetRange.startCol - context.sourceRange.startCol;
|
|
77011
|
+
const rowOffset = context.targetRange.startRow - context.sourceRange.startRow;
|
|
77012
|
+
return this.adjustFormulasForPasteWithOffset(formulas, colOffset, rowOffset);
|
|
77013
|
+
}
|
|
77014
|
+
static adjustFormulasForPasteWithOffset(formulas, colOffset, rowOffset) {
|
|
77015
|
+
const result = [];
|
|
77016
|
+
for (let row = 0; row < formulas.length; row++) {
|
|
77017
|
+
const newRow = [];
|
|
77018
|
+
for (let col = 0; col < formulas[row].length; col++) {
|
|
77019
|
+
const formula = formulas[row][col];
|
|
77020
|
+
if (FormulaReferenceAdjustor.isFormula(formula)) {
|
|
77021
|
+
const adjustedFormula = FormulaReferenceAdjustor.adjustFormulaReferences(formula, colOffset, rowOffset);
|
|
77022
|
+
newRow.push(adjustedFormula);
|
|
77023
|
+
}
|
|
77024
|
+
else {
|
|
77025
|
+
newRow.push(formula);
|
|
77026
|
+
}
|
|
77027
|
+
}
|
|
77028
|
+
result.push(newRow);
|
|
77029
|
+
}
|
|
77030
|
+
return result;
|
|
77031
|
+
}
|
|
77032
|
+
static needsFormulaAdjustment(value) {
|
|
77033
|
+
return FormulaReferenceAdjustor.isFormula(value);
|
|
77034
|
+
}
|
|
77035
|
+
static getFormulaReferences(formula) {
|
|
77036
|
+
return FormulaReferenceAdjustor.extractReferences(formula);
|
|
77037
|
+
}
|
|
77038
|
+
static validateFormulaReferences(formula, maxCol, maxRow) {
|
|
77039
|
+
const references = FormulaReferenceAdjustor.extractReferences(formula);
|
|
77040
|
+
for (const ref of references) {
|
|
77041
|
+
if (ref.col < 0 || ref.col > maxCol || ref.row < 0 || ref.row > maxRow) {
|
|
77042
|
+
return false;
|
|
77043
|
+
}
|
|
77044
|
+
}
|
|
77045
|
+
return true;
|
|
77046
|
+
}
|
|
77047
|
+
static createPasteContext(sourceStartCol, sourceStartRow, targetStartCol, targetStartRow, sourceCols, sourceRows, targetCols, targetRows) {
|
|
77048
|
+
return {
|
|
77049
|
+
sourceRange: {
|
|
77050
|
+
startCol: sourceStartCol,
|
|
77051
|
+
startRow: sourceStartRow,
|
|
77052
|
+
endCol: sourceStartCol + sourceCols - 1,
|
|
77053
|
+
endRow: sourceStartRow + sourceRows - 1
|
|
77054
|
+
},
|
|
77055
|
+
targetRange: {
|
|
77056
|
+
startCol: targetStartCol,
|
|
77057
|
+
startRow: targetStartRow,
|
|
77058
|
+
endCol: targetStartCol + targetCols - 1,
|
|
77059
|
+
endRow: targetStartRow + targetRows - 1
|
|
77060
|
+
},
|
|
77061
|
+
sourceCell: {
|
|
77062
|
+
col: sourceStartCol,
|
|
77063
|
+
row: sourceStartRow
|
|
77064
|
+
},
|
|
77065
|
+
targetCell: {
|
|
77066
|
+
col: targetStartCol,
|
|
77067
|
+
row: targetStartRow
|
|
77068
|
+
}
|
|
77069
|
+
};
|
|
77070
|
+
}
|
|
77071
|
+
}
|
|
77072
|
+
|
|
76615
77073
|
const DEFAULT_FORMULA_ENGINE_CONFIG = {
|
|
76616
77074
|
precisionRounding: 14,
|
|
76617
77075
|
caseSensitive: false,
|
|
@@ -77540,6 +77998,10 @@
|
|
|
77540
77998
|
const keyboardOptions = {
|
|
77541
77999
|
...this.options.keyboardOptions,
|
|
77542
78000
|
copySelected: true,
|
|
78001
|
+
getCopyCellValue: {
|
|
78002
|
+
html: this.getCellValueConsiderFormula.bind(this)
|
|
78003
|
+
},
|
|
78004
|
+
processFormulaBeforePaste: this.processFormulaPaste.bind(this),
|
|
77543
78005
|
pasteValueToCell: true,
|
|
77544
78006
|
showCopyCellBorder: true,
|
|
77545
78007
|
cutSelected: true
|
|
@@ -77849,7 +78311,7 @@
|
|
|
77849
78311
|
getCopiedData() {
|
|
77850
78312
|
return this.getData().map(row => (Array.isArray(row) ? row.slice() : []));
|
|
77851
78313
|
}
|
|
77852
|
-
getCellValue(
|
|
78314
|
+
getCellValue(col, row) {
|
|
77853
78315
|
if (this.tableInstance) {
|
|
77854
78316
|
try {
|
|
77855
78317
|
const value = this.tableInstance.getCellValue(col, row);
|
|
@@ -77864,7 +78326,28 @@
|
|
|
77864
78326
|
}
|
|
77865
78327
|
return null;
|
|
77866
78328
|
}
|
|
77867
|
-
|
|
78329
|
+
getCellValueConsiderFormula(col, row) {
|
|
78330
|
+
if (this.tableInstance) {
|
|
78331
|
+
try {
|
|
78332
|
+
if (this.vtableSheet.formulaManager.isCellFormula({
|
|
78333
|
+
sheet: this.getKey(),
|
|
78334
|
+
row,
|
|
78335
|
+
col
|
|
78336
|
+
})) {
|
|
78337
|
+
return this.vtableSheet.formulaManager.getCellFormula({
|
|
78338
|
+
sheet: this.getKey(),
|
|
78339
|
+
row,
|
|
78340
|
+
col
|
|
78341
|
+
});
|
|
78342
|
+
}
|
|
78343
|
+
return this.getCellValue(col, row);
|
|
78344
|
+
}
|
|
78345
|
+
catch (error) {
|
|
78346
|
+
}
|
|
78347
|
+
return null;
|
|
78348
|
+
}
|
|
78349
|
+
}
|
|
78350
|
+
setCellValue(col, row, value) {
|
|
77868
78351
|
const data = this.getData();
|
|
77869
78352
|
if (data && data[row]) {
|
|
77870
78353
|
const oldValue = data[row][col];
|
|
@@ -77885,28 +78368,28 @@
|
|
|
77885
78368
|
const coord = this.coordFromAddress(address);
|
|
77886
78369
|
return {
|
|
77887
78370
|
coord,
|
|
77888
|
-
value: this.getCellValue(coord.
|
|
78371
|
+
value: this.getCellValue(coord.col, coord.row)
|
|
77889
78372
|
};
|
|
77890
78373
|
}
|
|
77891
|
-
addressFromCoord(
|
|
77892
|
-
let
|
|
77893
|
-
let
|
|
77894
|
-
if (typeof
|
|
77895
|
-
|
|
77896
|
-
|
|
78374
|
+
addressFromCoord(coordOrCol, row) {
|
|
78375
|
+
let col;
|
|
78376
|
+
let rowNum;
|
|
78377
|
+
if (typeof coordOrCol === 'object') {
|
|
78378
|
+
col = coordOrCol.col;
|
|
78379
|
+
rowNum = coordOrCol.row;
|
|
77897
78380
|
}
|
|
77898
78381
|
else {
|
|
77899
|
-
|
|
77900
|
-
|
|
78382
|
+
col = coordOrCol;
|
|
78383
|
+
rowNum = row;
|
|
77901
78384
|
}
|
|
77902
78385
|
let colStr = '';
|
|
77903
|
-
let tempCol =
|
|
78386
|
+
let tempCol = col + 1;
|
|
77904
78387
|
do {
|
|
77905
78388
|
tempCol -= 1;
|
|
77906
78389
|
colStr = String.fromCharCode(65 + (tempCol % 26)) + colStr;
|
|
77907
78390
|
tempCol = Math.floor(tempCol / 26);
|
|
77908
78391
|
} while (tempCol > 0);
|
|
77909
|
-
return `${colStr}${
|
|
78392
|
+
return `${colStr}${rowNum + 1}`;
|
|
77910
78393
|
}
|
|
77911
78394
|
coordFromAddress(address) {
|
|
77912
78395
|
const match = address.match(/^([A-Z]+)([0-9]+)$/);
|
|
@@ -77966,6 +78449,92 @@
|
|
|
77966
78449
|
records: data
|
|
77967
78450
|
});
|
|
77968
78451
|
}
|
|
78452
|
+
processFormulaPaste(formulas, sourceStartCol, sourceStartRow, targetStartCol, targetStartRow) {
|
|
78453
|
+
if (!formulas || formulas.length === 0) {
|
|
78454
|
+
return formulas;
|
|
78455
|
+
}
|
|
78456
|
+
const colOffset = targetStartCol - sourceStartCol;
|
|
78457
|
+
const rowOffset = targetStartRow - sourceStartRow;
|
|
78458
|
+
return FormulaPasteProcessor.adjustFormulasForPasteWithOffset(formulas, colOffset, rowOffset);
|
|
78459
|
+
}
|
|
78460
|
+
getCopyData() {
|
|
78461
|
+
const selections = this.getMultipleSelections();
|
|
78462
|
+
if (selections.length === 0) {
|
|
78463
|
+
return [];
|
|
78464
|
+
}
|
|
78465
|
+
const data = this.getData();
|
|
78466
|
+
const result = [];
|
|
78467
|
+
const selection = selections[0];
|
|
78468
|
+
const rows = selection.endRow - selection.startRow + 1;
|
|
78469
|
+
const cols = selection.endCol - selection.startCol + 1;
|
|
78470
|
+
for (let row = 0; row < rows; row++) {
|
|
78471
|
+
const rowData = [];
|
|
78472
|
+
for (let col = 0; col < cols; col++) {
|
|
78473
|
+
const actualRow = selection.startRow + row;
|
|
78474
|
+
const actualCol = selection.startCol + col;
|
|
78475
|
+
if (data[actualRow] && data[actualRow][actualCol] !== undefined) {
|
|
78476
|
+
if (this.vtableSheet.formulaManager.isCellFormula({
|
|
78477
|
+
sheet: this.getKey(),
|
|
78478
|
+
row: actualRow,
|
|
78479
|
+
col: actualCol
|
|
78480
|
+
})) {
|
|
78481
|
+
const formula = this.vtableSheet.formulaManager.getCellFormula({
|
|
78482
|
+
sheet: this.getKey(),
|
|
78483
|
+
row: actualRow,
|
|
78484
|
+
col: actualCol
|
|
78485
|
+
});
|
|
78486
|
+
rowData.push(formula);
|
|
78487
|
+
}
|
|
78488
|
+
else {
|
|
78489
|
+
rowData.push(data[actualRow][actualCol]);
|
|
78490
|
+
}
|
|
78491
|
+
}
|
|
78492
|
+
else {
|
|
78493
|
+
rowData.push('');
|
|
78494
|
+
}
|
|
78495
|
+
}
|
|
78496
|
+
result.push(rowData);
|
|
78497
|
+
}
|
|
78498
|
+
return result;
|
|
78499
|
+
}
|
|
78500
|
+
pasteData(data, targetStartCol, targetStartRow) {
|
|
78501
|
+
if (!data || data.length === 0) {
|
|
78502
|
+
return;
|
|
78503
|
+
}
|
|
78504
|
+
const selections = this.getMultipleSelections();
|
|
78505
|
+
if (selections.length === 0) {
|
|
78506
|
+
return;
|
|
78507
|
+
}
|
|
78508
|
+
const sourceSelection = selections[0];
|
|
78509
|
+
const sourceStartCol = sourceSelection.startCol;
|
|
78510
|
+
const sourceStartRow = sourceSelection.startRow;
|
|
78511
|
+
const processedData = this.processFormulaPaste(data, sourceStartCol, sourceStartRow, targetStartCol, targetStartRow);
|
|
78512
|
+
const dataArray = this.getData();
|
|
78513
|
+
for (let row = 0; row < processedData.length; row++) {
|
|
78514
|
+
for (let col = 0; col < processedData[row].length; col++) {
|
|
78515
|
+
const targetRow = targetStartRow + row;
|
|
78516
|
+
const targetCol = targetStartCol + col;
|
|
78517
|
+
if (targetRow < dataArray.length && targetCol < dataArray[targetRow].length) {
|
|
78518
|
+
const value = processedData[row][col];
|
|
78519
|
+
if (FormulaPasteProcessor.needsFormulaAdjustment(value)) {
|
|
78520
|
+
this.setCellFormula(targetRow, targetCol, value);
|
|
78521
|
+
}
|
|
78522
|
+
else {
|
|
78523
|
+
this.setCellValue(targetRow, targetCol, value);
|
|
78524
|
+
}
|
|
78525
|
+
}
|
|
78526
|
+
}
|
|
78527
|
+
}
|
|
78528
|
+
}
|
|
78529
|
+
setCellFormula(row, col, formula) {
|
|
78530
|
+
if (this.vtableSheet.formulaManager) {
|
|
78531
|
+
this.vtableSheet.formulaManager.setCellContent({
|
|
78532
|
+
sheet: this.getKey(),
|
|
78533
|
+
row,
|
|
78534
|
+
col
|
|
78535
|
+
}, formula);
|
|
78536
|
+
}
|
|
78537
|
+
}
|
|
77969
78538
|
release() {
|
|
77970
78539
|
if (this.tableInstance) {
|
|
77971
78540
|
this.tableInstance.release();
|
|
@@ -77977,7 +78546,7 @@
|
|
|
77977
78546
|
}
|
|
77978
78547
|
}
|
|
77979
78548
|
|
|
77980
|
-
function getTablePlugins(sheetDefine, options) {
|
|
78549
|
+
function getTablePlugins(sheetDefine, options, vtableSheet) {
|
|
77981
78550
|
const plugins = [];
|
|
77982
78551
|
const disabledPluginsUserSetted = options?.VTablePluginModules?.filter(module => module.disabled);
|
|
77983
78552
|
let enabledPluginsUserSetted = options?.VTablePluginModules?.filter(module => !module.disabled);
|
|
@@ -78028,7 +78597,12 @@
|
|
|
78028
78597
|
enabledPluginsUserSetted = enabledPluginsUserSetted?.filter(module => module.module !== ExcelEditCellKeyboardPlugin);
|
|
78029
78598
|
}
|
|
78030
78599
|
if (!disabledPluginsUserSetted?.some(module => module.module === AutoFillPlugin)) {
|
|
78031
|
-
const
|
|
78600
|
+
const userPluginOptions = enabledPluginsUserSetted?.find(module => module.module === AutoFillPlugin)?.moduleOptions;
|
|
78601
|
+
const formulaDetectionOptions = createFormulaDetectionOptions(sheetDefine, options, vtableSheet);
|
|
78602
|
+
const autoFillPlugin = new AutoFillPlugin({
|
|
78603
|
+
...userPluginOptions,
|
|
78604
|
+
...formulaDetectionOptions
|
|
78605
|
+
});
|
|
78032
78606
|
plugins.push(autoFillPlugin);
|
|
78033
78607
|
enabledPluginsUserSetted = enabledPluginsUserSetted?.filter(module => module.module !== AutoFillPlugin);
|
|
78034
78608
|
}
|
|
@@ -78204,6 +78778,64 @@
|
|
|
78204
78778
|
});
|
|
78205
78779
|
table.scenegraph.updateNextFrame();
|
|
78206
78780
|
}
|
|
78781
|
+
function createFormulaDetectionOptions(sheetDefine, options, vtableSheet) {
|
|
78782
|
+
return {
|
|
78783
|
+
isFormulaCell: (col, row, cellData, table) => {
|
|
78784
|
+
if (vtableSheet?.formulaManager) {
|
|
78785
|
+
try {
|
|
78786
|
+
const sheetName = vtableSheet.sheetManager?._activeSheetKey || 'Sheet1';
|
|
78787
|
+
return vtableSheet.formulaManager.isCellFormula({
|
|
78788
|
+
sheet: sheetName,
|
|
78789
|
+
row: row,
|
|
78790
|
+
col: col
|
|
78791
|
+
});
|
|
78792
|
+
}
|
|
78793
|
+
catch (error) {
|
|
78794
|
+
}
|
|
78795
|
+
}
|
|
78796
|
+
if (typeof cellData === 'string' && cellData.startsWith('=')) {
|
|
78797
|
+
return true;
|
|
78798
|
+
}
|
|
78799
|
+
const cellValue = table.getCellValue(col, row);
|
|
78800
|
+
return typeof cellValue === 'string' && cellValue.startsWith('=');
|
|
78801
|
+
},
|
|
78802
|
+
getCellFormula: (col, row, cellData, table) => {
|
|
78803
|
+
if (vtableSheet?.formulaManager) {
|
|
78804
|
+
try {
|
|
78805
|
+
const sheetName = vtableSheet.sheetManager?._activeSheetKey || 'Sheet1';
|
|
78806
|
+
return vtableSheet.formulaManager.getCellFormula({
|
|
78807
|
+
sheet: sheetName,
|
|
78808
|
+
row: row,
|
|
78809
|
+
col: col
|
|
78810
|
+
});
|
|
78811
|
+
}
|
|
78812
|
+
catch (error) {
|
|
78813
|
+
}
|
|
78814
|
+
}
|
|
78815
|
+
const cellValue = table.getCellValue(col, row);
|
|
78816
|
+
if (typeof cellValue === 'string' && cellValue.startsWith('=')) {
|
|
78817
|
+
return cellValue;
|
|
78818
|
+
}
|
|
78819
|
+
return undefined;
|
|
78820
|
+
},
|
|
78821
|
+
setCellFormula: (col, row, formula, table) => {
|
|
78822
|
+
if (vtableSheet?.formulaManager) {
|
|
78823
|
+
try {
|
|
78824
|
+
const sheetName = vtableSheet.sheetManager?._activeSheetKey || 'Sheet1';
|
|
78825
|
+
vtableSheet.formulaManager.setCellContent({
|
|
78826
|
+
sheet: sheetName,
|
|
78827
|
+
row: row,
|
|
78828
|
+
col: col
|
|
78829
|
+
}, formula);
|
|
78830
|
+
return;
|
|
78831
|
+
}
|
|
78832
|
+
catch (error) {
|
|
78833
|
+
}
|
|
78834
|
+
}
|
|
78835
|
+
table.changeCellValue(col, row, formula);
|
|
78836
|
+
}
|
|
78837
|
+
};
|
|
78838
|
+
}
|
|
78207
78839
|
|
|
78208
78840
|
class EventManager {
|
|
78209
78841
|
sheet;
|
|
@@ -79150,7 +79782,7 @@
|
|
|
79150
79782
|
defaultRowHeight: this.options.defaultRowHeight,
|
|
79151
79783
|
defaultColWidth: this.options.defaultColWidth,
|
|
79152
79784
|
dragOrder: sheetDefine.dragOrder,
|
|
79153
|
-
plugins: getTablePlugins(sheetDefine, this.options),
|
|
79785
|
+
plugins: getTablePlugins(sheetDefine, this.options, this),
|
|
79154
79786
|
headerEditor: 'formula',
|
|
79155
79787
|
editor: 'formula',
|
|
79156
79788
|
select: {
|
|
@@ -80854,7 +81486,7 @@
|
|
|
80854
81486
|
importStyle();
|
|
80855
81487
|
}
|
|
80856
81488
|
|
|
80857
|
-
const version = "1.22.6
|
|
81489
|
+
const version = "1.22.6";
|
|
80858
81490
|
importStyles();
|
|
80859
81491
|
|
|
80860
81492
|
exports.TYPES = index;
|