@visactor/vtable-sheet 1.26.1-alpha.0 → 1.26.1
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/core/WorkSheet.d.ts +1 -0
- package/cjs/core/WorkSheet.js +24 -3
- package/cjs/core/WorkSheet.js.map +1 -1
- package/cjs/formula/formula-engine.d.ts +12 -0
- package/cjs/formula/formula-engine.js +222 -0
- package/cjs/formula/formula-engine.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/dist/vtable-sheet.js +396 -77
- package/dist/vtable-sheet.min.js +1 -1
- package/es/core/WorkSheet.d.ts +1 -0
- package/es/core/WorkSheet.js +25 -4
- package/es/core/WorkSheet.js.map +1 -1
- package/es/formula/formula-engine.d.ts +12 -0
- package/es/formula/formula-engine.js +222 -0
- package/es/formula/formula-engine.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/package.json +5 -5
package/dist/vtable-sheet.js
CHANGED
|
@@ -788,6 +788,16 @@
|
|
|
788
788
|
return this.calculateAbs(args);
|
|
789
789
|
case 'ROUND':
|
|
790
790
|
return this.calculateRound(args);
|
|
791
|
+
case 'FLOOR':
|
|
792
|
+
return this.calculateFloor(args);
|
|
793
|
+
case 'CEILING':
|
|
794
|
+
return this.calculateCeiling(args);
|
|
795
|
+
case 'SQRT':
|
|
796
|
+
return this.calculateSqrt(args);
|
|
797
|
+
case 'POWER':
|
|
798
|
+
return this.calculatePower(args);
|
|
799
|
+
case 'MOD':
|
|
800
|
+
return this.calculateMod(args);
|
|
791
801
|
case 'INT':
|
|
792
802
|
return this.calculateInt(args);
|
|
793
803
|
case 'RAND':
|
|
@@ -816,6 +826,18 @@
|
|
|
816
826
|
return this.calculateToday(args);
|
|
817
827
|
case 'NOW':
|
|
818
828
|
return this.calculateNow(args);
|
|
829
|
+
case 'YEAR':
|
|
830
|
+
return this.calculateYear(args);
|
|
831
|
+
case 'MONTH':
|
|
832
|
+
return this.calculateMonth(args);
|
|
833
|
+
case 'DAY':
|
|
834
|
+
return this.calculateDay(args);
|
|
835
|
+
case 'HOUR':
|
|
836
|
+
return this.calculateHour(args);
|
|
837
|
+
case 'MINUTE':
|
|
838
|
+
return this.calculateMinute(args);
|
|
839
|
+
case 'SECOND':
|
|
840
|
+
return this.calculateSecond(args);
|
|
819
841
|
default:
|
|
820
842
|
return { value: null, error: `Unknown function: ${funcName}` };
|
|
821
843
|
}
|
|
@@ -870,6 +892,42 @@
|
|
|
870
892
|
}
|
|
871
893
|
return { value: Math.abs(num), error: undefined };
|
|
872
894
|
}
|
|
895
|
+
calculateFloor(args) {
|
|
896
|
+
if (args.length < 1 || args.length > 2) {
|
|
897
|
+
return { value: null, error: 'FLOOR requires 1 or 2 arguments' };
|
|
898
|
+
}
|
|
899
|
+
const num = Number(args[0]);
|
|
900
|
+
if (isNaN(num)) {
|
|
901
|
+
return { value: null, error: 'FLOOR first argument must be a number' };
|
|
902
|
+
}
|
|
903
|
+
const significance = args.length === 2 ? Number(args[1]) : 1;
|
|
904
|
+
if (isNaN(significance)) {
|
|
905
|
+
return { value: null, error: 'FLOOR significance must be a number' };
|
|
906
|
+
}
|
|
907
|
+
if (significance === 0) {
|
|
908
|
+
return { value: 0, error: undefined };
|
|
909
|
+
}
|
|
910
|
+
const factor = Math.floor(num / significance);
|
|
911
|
+
return { value: factor * significance, error: undefined };
|
|
912
|
+
}
|
|
913
|
+
calculateCeiling(args) {
|
|
914
|
+
if (args.length < 1 || args.length > 2) {
|
|
915
|
+
return { value: null, error: 'CEILING requires 1 or 2 arguments' };
|
|
916
|
+
}
|
|
917
|
+
const num = Number(args[0]);
|
|
918
|
+
if (isNaN(num)) {
|
|
919
|
+
return { value: null, error: 'CEILING first argument must be a number' };
|
|
920
|
+
}
|
|
921
|
+
const significance = args.length === 2 ? Number(args[1]) : 1;
|
|
922
|
+
if (isNaN(significance)) {
|
|
923
|
+
return { value: null, error: 'CEILING significance must be a number' };
|
|
924
|
+
}
|
|
925
|
+
if (significance === 0) {
|
|
926
|
+
return { value: 0, error: undefined };
|
|
927
|
+
}
|
|
928
|
+
const factor = Math.ceil(num / significance);
|
|
929
|
+
return { value: factor * significance, error: undefined };
|
|
930
|
+
}
|
|
873
931
|
calculateRound(args) {
|
|
874
932
|
if (args.length < 1 || args.length > 2) {
|
|
875
933
|
return { value: null, error: 'ROUND requires 1 or 2 arguments' };
|
|
@@ -885,6 +943,41 @@
|
|
|
885
943
|
const factor = Math.pow(10, digits);
|
|
886
944
|
return { value: Math.round(num * factor) / factor, error: undefined };
|
|
887
945
|
}
|
|
946
|
+
calculateSqrt(args) {
|
|
947
|
+
if (args.length !== 1) {
|
|
948
|
+
return { value: null, error: 'SQRT requires exactly 1 argument' };
|
|
949
|
+
}
|
|
950
|
+
const num = Number(args[0]);
|
|
951
|
+
if (isNaN(num) || num < 0) {
|
|
952
|
+
return { value: null, error: 'SQRT argument must be a non-negative number' };
|
|
953
|
+
}
|
|
954
|
+
return { value: Math.sqrt(num), error: undefined };
|
|
955
|
+
}
|
|
956
|
+
calculatePower(args) {
|
|
957
|
+
if (args.length !== 2) {
|
|
958
|
+
return { value: null, error: 'POWER requires exactly 2 arguments' };
|
|
959
|
+
}
|
|
960
|
+
const base = Number(args[0]);
|
|
961
|
+
const exponent = Number(args[1]);
|
|
962
|
+
if (isNaN(base) || isNaN(exponent)) {
|
|
963
|
+
return { value: null, error: 'POWER arguments must be numbers' };
|
|
964
|
+
}
|
|
965
|
+
return { value: Math.pow(base, exponent), error: undefined };
|
|
966
|
+
}
|
|
967
|
+
calculateMod(args) {
|
|
968
|
+
if (args.length !== 2) {
|
|
969
|
+
return { value: null, error: 'MOD requires exactly 2 arguments' };
|
|
970
|
+
}
|
|
971
|
+
const dividend = Number(args[0]);
|
|
972
|
+
const divisor = Number(args[1]);
|
|
973
|
+
if (isNaN(dividend) || isNaN(divisor)) {
|
|
974
|
+
return { value: null, error: 'MOD arguments must be numbers' };
|
|
975
|
+
}
|
|
976
|
+
if (divisor === 0) {
|
|
977
|
+
return { value: null, error: 'MOD divisor must not be zero' };
|
|
978
|
+
}
|
|
979
|
+
return { value: dividend % divisor, error: undefined };
|
|
980
|
+
}
|
|
888
981
|
calculateInt(args) {
|
|
889
982
|
if (args.length !== 1) {
|
|
890
983
|
return { value: null, error: 'INT requires exactly 1 argument' };
|
|
@@ -1021,6 +1114,80 @@
|
|
|
1021
1114
|
}
|
|
1022
1115
|
return { value: new Date(), error: undefined };
|
|
1023
1116
|
}
|
|
1117
|
+
toDate(value) {
|
|
1118
|
+
if (value instanceof Date) {
|
|
1119
|
+
return value;
|
|
1120
|
+
}
|
|
1121
|
+
if (typeof value === 'number' && !isNaN(value)) {
|
|
1122
|
+
const d = new Date(value);
|
|
1123
|
+
return isNaN(d.getTime()) ? null : d;
|
|
1124
|
+
}
|
|
1125
|
+
if (typeof value === 'string') {
|
|
1126
|
+
const d = new Date(value);
|
|
1127
|
+
return isNaN(d.getTime()) ? null : d;
|
|
1128
|
+
}
|
|
1129
|
+
return null;
|
|
1130
|
+
}
|
|
1131
|
+
calculateYear(args) {
|
|
1132
|
+
if (args.length !== 1) {
|
|
1133
|
+
return { value: null, error: 'YEAR requires exactly 1 argument' };
|
|
1134
|
+
}
|
|
1135
|
+
const date = this.toDate(args[0]);
|
|
1136
|
+
if (!date) {
|
|
1137
|
+
return { value: null, error: 'YEAR argument must be a valid date' };
|
|
1138
|
+
}
|
|
1139
|
+
return { value: date.getFullYear(), error: undefined };
|
|
1140
|
+
}
|
|
1141
|
+
calculateMonth(args) {
|
|
1142
|
+
if (args.length !== 1) {
|
|
1143
|
+
return { value: null, error: 'MONTH requires exactly 1 argument' };
|
|
1144
|
+
}
|
|
1145
|
+
const date = this.toDate(args[0]);
|
|
1146
|
+
if (!date) {
|
|
1147
|
+
return { value: null, error: 'MONTH argument must be a valid date' };
|
|
1148
|
+
}
|
|
1149
|
+
return { value: date.getMonth() + 1, error: undefined };
|
|
1150
|
+
}
|
|
1151
|
+
calculateDay(args) {
|
|
1152
|
+
if (args.length !== 1) {
|
|
1153
|
+
return { value: null, error: 'DAY requires exactly 1 argument' };
|
|
1154
|
+
}
|
|
1155
|
+
const date = this.toDate(args[0]);
|
|
1156
|
+
if (!date) {
|
|
1157
|
+
return { value: null, error: 'DAY argument must be a valid date' };
|
|
1158
|
+
}
|
|
1159
|
+
return { value: date.getDate(), error: undefined };
|
|
1160
|
+
}
|
|
1161
|
+
calculateHour(args) {
|
|
1162
|
+
if (args.length !== 1) {
|
|
1163
|
+
return { value: null, error: 'HOUR requires exactly 1 argument' };
|
|
1164
|
+
}
|
|
1165
|
+
const date = this.toDate(args[0]);
|
|
1166
|
+
if (!date) {
|
|
1167
|
+
return { value: null, error: 'HOUR argument must be a valid date' };
|
|
1168
|
+
}
|
|
1169
|
+
return { value: date.getHours(), error: undefined };
|
|
1170
|
+
}
|
|
1171
|
+
calculateMinute(args) {
|
|
1172
|
+
if (args.length !== 1) {
|
|
1173
|
+
return { value: null, error: 'MINUTE requires exactly 1 argument' };
|
|
1174
|
+
}
|
|
1175
|
+
const date = this.toDate(args[0]);
|
|
1176
|
+
if (!date) {
|
|
1177
|
+
return { value: null, error: 'MINUTE argument must be a valid date' };
|
|
1178
|
+
}
|
|
1179
|
+
return { value: date.getMinutes(), error: undefined };
|
|
1180
|
+
}
|
|
1181
|
+
calculateSecond(args) {
|
|
1182
|
+
if (args.length !== 1) {
|
|
1183
|
+
return { value: null, error: 'SECOND requires exactly 1 argument' };
|
|
1184
|
+
}
|
|
1185
|
+
const date = this.toDate(args[0]);
|
|
1186
|
+
if (!date) {
|
|
1187
|
+
return { value: null, error: 'SECOND argument must be a valid date' };
|
|
1188
|
+
}
|
|
1189
|
+
return { value: date.getSeconds(), error: undefined };
|
|
1190
|
+
}
|
|
1024
1191
|
flattenArgs(args) {
|
|
1025
1192
|
const result = [];
|
|
1026
1193
|
for (const arg of args) {
|
|
@@ -51130,7 +51297,7 @@
|
|
|
51130
51297
|
};
|
|
51131
51298
|
function dynamicSetX(x, screenLeft, isEnd, proxy) {
|
|
51132
51299
|
return __awaiter$7(this, void 0, void 0, function* () {
|
|
51133
|
-
if (!screenLeft) return;
|
|
51300
|
+
if (!screenLeft) return proxy.updateDeltaX(x), proxy.table.scenegraph.setBodyAndColHeaderX(-x + proxy.deltaX), void proxy.table.scenegraph.updateNextFrame();
|
|
51134
51301
|
const screenLeftCol = screenLeft.col,
|
|
51135
51302
|
screenLeftX = screenLeft.left;
|
|
51136
51303
|
let deltaCol;
|
|
@@ -51306,7 +51473,7 @@
|
|
|
51306
51473
|
};
|
|
51307
51474
|
function dynamicSetY(y, screenTop, isEnd, proxy) {
|
|
51308
51475
|
return __awaiter$6(this, void 0, void 0, function* () {
|
|
51309
|
-
if (!screenTop) return;
|
|
51476
|
+
if (!screenTop) return proxy.updateDeltaY(y), proxy.updateBody(y - proxy.deltaY), void proxy.table.scenegraph.updateNextFrame();
|
|
51310
51477
|
const screenTopRow = screenTop.row,
|
|
51311
51478
|
screenTopY = screenTop.top;
|
|
51312
51479
|
let deltaRow;
|
|
@@ -51911,7 +52078,7 @@
|
|
|
51911
52078
|
return __awaiter$3(this, void 0, void 0, function* () {
|
|
51912
52079
|
const yLimitTop = this.table.getRowsHeight(this.bodyTopRow, this.bodyTopRow + (this.rowEnd - this.rowStart + 1)) / 2,
|
|
51913
52080
|
yLimitBottom = this.table.getAllRowsHeight() - yLimitTop,
|
|
51914
|
-
screenTop = this.
|
|
52081
|
+
screenTop = this.resolveTargetRowInfo(y + this.table.scenegraph.colHeaderGroup.attribute.height);
|
|
51915
52082
|
screenTop && (this.screenTopRow = screenTop.row), y < yLimitTop && this.rowStart === this.bodyTopRow || y > yLimitBottom && this.rowEnd === this.bodyBottomRow ? (this.updateDeltaY(y), this.updateBody(y - this.deltaY)) : this.table.scenegraph.bodyGroup.firstChild && "group" === this.table.scenegraph.bodyGroup.firstChild.type && 0 !== this.table.scenegraph.bodyGroup.firstChild.childrenCount || this.table.scenegraph.rowHeaderGroup.firstChild && "group" === this.table.scenegraph.rowHeaderGroup.firstChild.type && 0 !== this.table.scenegraph.rowHeaderGroup.firstChild.childrenCount ? this.dynamicSetY(y, screenTop, isEnd) : (this.updateDeltaY(y), this.updateBody(y - this.deltaY));
|
|
51916
52083
|
});
|
|
51917
52084
|
}
|
|
@@ -51920,7 +52087,7 @@
|
|
|
51920
52087
|
return __awaiter$3(this, void 0, void 0, function* () {
|
|
51921
52088
|
const xLimitLeft = this.table.getColsWidth(this.bodyLeftCol, this.bodyLeftCol + (this.colEnd - this.colStart + 1)) / 2,
|
|
51922
52089
|
xLimitRight = this.table.getAllColsWidth() - xLimitLeft,
|
|
51923
|
-
screenLeft = this.
|
|
52090
|
+
screenLeft = this.resolveTargetColInfo(x + this.table.scenegraph.rowHeaderGroup.attribute.width + (null !== (_c = null === (_b = (_a = this.table).getFrozenColsOffset) || void 0 === _b ? void 0 : _b.call(_a)) && void 0 !== _c ? _c : 0));
|
|
51924
52091
|
screenLeft && (this.screenLeftCol = screenLeft.col), x < xLimitLeft && this.colStart === this.bodyLeftCol || x > xLimitRight && this.colEnd === this.bodyRightCol || this.table.scenegraph.bodyGroup.firstChild && "group" === this.table.scenegraph.bodyGroup.firstChild.type && 0 === this.table.scenegraph.bodyGroup.firstChild.childrenCount ? (this.updateDeltaX(x), this.table.scenegraph.setBodyAndColHeaderX(-x + this.deltaX)) : this.dynamicSetX(x, screenLeft, isEnd);
|
|
51925
52092
|
});
|
|
51926
52093
|
}
|
|
@@ -51934,6 +52101,22 @@
|
|
|
51934
52101
|
dynamicSetX(x, screenLeft, isEnd, this);
|
|
51935
52102
|
});
|
|
51936
52103
|
}
|
|
52104
|
+
resolveTargetColInfo(absoluteX) {
|
|
52105
|
+
const offsets = [0, -1, 1, -2, 2];
|
|
52106
|
+
for (let i = 0; i < offsets.length; i++) {
|
|
52107
|
+
const screenLeft = this.table.getTargetColAt(absoluteX + offsets[i]);
|
|
52108
|
+
if (screenLeft) return screenLeft;
|
|
52109
|
+
}
|
|
52110
|
+
return null;
|
|
52111
|
+
}
|
|
52112
|
+
resolveTargetRowInfo(absoluteY) {
|
|
52113
|
+
const offsets = [0, -1, 1, -2, 2];
|
|
52114
|
+
for (let i = 0; i < offsets.length; i++) {
|
|
52115
|
+
const screenTop = this.table.getTargetRowAt(absoluteY + offsets[i]);
|
|
52116
|
+
if (screenTop) return screenTop;
|
|
52117
|
+
}
|
|
52118
|
+
return null;
|
|
52119
|
+
}
|
|
51937
52120
|
updateBody(y) {
|
|
51938
52121
|
this.table.scenegraph.setBodyAndRowHeaderY(-y);
|
|
51939
52122
|
}
|
|
@@ -54254,15 +54437,17 @@
|
|
|
54254
54437
|
this.table.scenegraph.proxy.setY(-y, isEnd);
|
|
54255
54438
|
}
|
|
54256
54439
|
setBodyAndRowHeaderY(y) {
|
|
54257
|
-
var _a, _b
|
|
54258
|
-
const
|
|
54259
|
-
|
|
54260
|
-
|
|
54440
|
+
var _a, _b;
|
|
54441
|
+
const firstBodyColGroup = this.bodyGroup.firstChild,
|
|
54442
|
+
firstRowHeaderColGroup = this.rowHeaderGroup.firstChild,
|
|
54443
|
+
firstBodyCell = null !== (_a = null == firstBodyColGroup ? void 0 : firstBodyColGroup.firstChild) && void 0 !== _a ? _a : null == firstRowHeaderColGroup ? void 0 : firstRowHeaderColGroup.firstChild;
|
|
54444
|
+
let lastBodyCell = null !== (_b = null == firstBodyColGroup ? void 0 : firstBodyColGroup.lastChild) && void 0 !== _b ? _b : null == firstRowHeaderColGroup ? void 0 : firstRowHeaderColGroup.lastChild;
|
|
54445
|
+
lastBodyCell && "group" !== lastBodyCell.type && (lastBodyCell = lastBodyCell._prev), 0 === y && firstBodyCell && firstBodyCell.row === this.table.frozenRowCount && firstBodyCell.attribute.y + y < 0 ? y = -firstBodyCell.attribute.y : lastBodyCell && this.table.tableNoFrameHeight < this.table.getAllRowsHeight() && lastBodyCell.row === this.table.rowCount - this.table.bottomFrozenRowCount - 1 && lastBodyCell.attribute.y + this.table.getRowHeight(lastBodyCell.row) + y < this.table.tableNoFrameHeight - this.table.getFrozenRowsHeight() - this.table.getBottomFrozenRowsHeight() && (y = this.table.tableNoFrameHeight - this.table.getFrozenRowsHeight() - this.table.getBottomFrozenRowsHeight() - lastBodyCell.attribute.y - this.table.getRowHeight(lastBodyCell.row)), this.colHeaderGroup.attribute.height + y !== this.bodyGroup.attribute.y && (this.bodyGroup.setAttribute("y", this.colHeaderGroup.attribute.height + y), this.rowHeaderGroup.setAttribute("y", this.cornerHeaderGroup.attribute.height + y), this.bodySelectGroup.setAttribute("y", this.bodyGroup.attribute.y), this.rowHeaderSelectGroup.setAttribute("y", this.rowHeaderGroup.attribute.y), this.colHeaderSelectGroup.setAttribute("y", this.colHeaderGroup.attribute.y), this.cornerHeaderSelectGroup.setAttribute("y", this.cornerHeaderGroup.attribute.y), this.table.rightFrozenColCount > 0 && (this.rightFrozenGroup.setAttribute("y", this.rightTopCornerGroup.attribute.height + y), this.rightFrozenSelectGroup.setAttribute("y", this.rightFrozenGroup.attribute.y), this.rightTopCornerSelectGroup.setAttribute("y", this.rightTopCornerGroup.attribute.y)), this.table.bottomFrozenRowCount > 0 && (this.bottomFrozenSelectGroup.setAttribute("y", this.bottomFrozenGroup.attribute.y), this.leftBottomCornerSelectGroup.setAttribute("y", this.leftBottomCornerGroup.attribute.y)), this.table.rightFrozenColCount > 0 && this.table.bottomFrozenRowCount > 0 && this.rightBottomCornerSelectGroup.setAttribute("y", this.rightBottomCornerGroup.attribute.y), this.updateNextFrame());
|
|
54261
54446
|
}
|
|
54262
54447
|
setBodyAndColHeaderX(x) {
|
|
54263
|
-
const firstBodyCol = this.bodyGroup.firstChild
|
|
54264
|
-
|
|
54265
|
-
0 === x && firstBodyCol && firstBodyCol.col === this.table.frozenColCount && firstBodyCol.attribute.x + x < 0 ? x = -firstBodyCol.attribute.x : lastBodyCol && this.table.tableNoFrameWidth < this.table.getAllColsWidth() && lastBodyCol.col === this.table.colCount - this.table.rightFrozenColCount - 1 && lastBodyCol.attribute.x + lastBodyCol.attribute.width + x < this.table.tableNoFrameWidth - this.table.getFrozenColsWidth() - this.table.getRightFrozenColsWidth() && (x = this.table.tableNoFrameWidth - this.table.getFrozenColsWidth() - this.table.getRightFrozenColsWidth() - lastBodyCol.attribute.x - lastBodyCol.attribute.width), this.table.getFrozenColsWidth() + x !== this.bodyGroup.attribute.x && (this.bodyGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.colHeaderGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.bodySelectGroup.setAttribute("x", this.bodyGroup.attribute.x), this.colHeaderSelectGroup.setAttribute("x", this.colHeaderGroup.attribute.x), this.rowHeaderSelectGroup.setAttribute("x", this.rowHeaderGroup.attribute.x), this.cornerHeaderSelectGroup.setAttribute("x", this.cornerHeaderGroup.attribute.x), this.table.bottomFrozenRowCount > 0 && (this.bottomFrozenGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.bottomFrozenSelectGroup.setAttribute("x", this.bottomFrozenGroup.attribute.x), this.leftBottomCornerSelectGroup.setAttribute("x", this.leftBottomCornerGroup.attribute.x)), this.table.rightFrozenColCount > 0 && (this.rightFrozenSelectGroup.setAttribute("x", this.rightFrozenGroup.attribute.x), this.rightTopCornerSelectGroup.setAttribute("x", this.rightTopCornerGroup.attribute.x)), this.table.rightFrozenColCount > 0 && this.table.bottomFrozenRowCount > 0 && this.rightBottomCornerSelectGroup.setAttribute("x", this.rightBottomCornerGroup.attribute.x), this.updateNextFrame());
|
|
54448
|
+
const firstBodyCol = this.bodyGroup.firstChild;
|
|
54449
|
+
let lastBodyCol = this.bodyGroup.lastChild;
|
|
54450
|
+
lastBodyCol && "group" !== lastBodyCol.type && (lastBodyCol = lastBodyCol._prev), 0 === x && firstBodyCol && firstBodyCol.col === this.table.frozenColCount && firstBodyCol.attribute.x + x < 0 ? x = -firstBodyCol.attribute.x : lastBodyCol && this.table.tableNoFrameWidth < this.table.getAllColsWidth() && lastBodyCol.col === this.table.colCount - this.table.rightFrozenColCount - 1 && lastBodyCol.attribute.x + lastBodyCol.attribute.width + x < this.table.tableNoFrameWidth - this.table.getFrozenColsWidth() - this.table.getRightFrozenColsWidth() && (x = this.table.tableNoFrameWidth - this.table.getFrozenColsWidth() - this.table.getRightFrozenColsWidth() - lastBodyCol.attribute.x - lastBodyCol.attribute.width), this.table.getFrozenColsWidth() + x !== this.bodyGroup.attribute.x && (this.bodyGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.colHeaderGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.bodySelectGroup.setAttribute("x", this.bodyGroup.attribute.x), this.colHeaderSelectGroup.setAttribute("x", this.colHeaderGroup.attribute.x), this.rowHeaderSelectGroup.setAttribute("x", this.rowHeaderGroup.attribute.x), this.cornerHeaderSelectGroup.setAttribute("x", this.cornerHeaderGroup.attribute.x), this.table.bottomFrozenRowCount > 0 && (this.bottomFrozenGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.bottomFrozenSelectGroup.setAttribute("x", this.bottomFrozenGroup.attribute.x), this.leftBottomCornerSelectGroup.setAttribute("x", this.leftBottomCornerGroup.attribute.x)), this.table.rightFrozenColCount > 0 && (this.rightFrozenSelectGroup.setAttribute("x", this.rightFrozenGroup.attribute.x), this.rightTopCornerSelectGroup.setAttribute("x", this.rightTopCornerGroup.attribute.x)), this.table.rightFrozenColCount > 0 && this.table.bottomFrozenRowCount > 0 && this.rightBottomCornerSelectGroup.setAttribute("x", this.rightBottomCornerGroup.attribute.x), this.updateNextFrame());
|
|
54266
54451
|
}
|
|
54267
54452
|
afterScenegraphCreated() {
|
|
54268
54453
|
var _a, _b;
|
|
@@ -57699,6 +57884,7 @@
|
|
|
57699
57884
|
}
|
|
57700
57885
|
function dblclickHandler(e, table) {
|
|
57701
57886
|
var _a, _b, _c, _d, _e, _f;
|
|
57887
|
+
if ("number" == typeof e.button && 0 !== e.button) return;
|
|
57702
57888
|
const eventArgsSet = getCellEventArgsSetWithTable(e, table);
|
|
57703
57889
|
let col = -1,
|
|
57704
57890
|
row = -1;
|
|
@@ -57894,7 +58080,13 @@
|
|
|
57894
58080
|
function bindContainerDomListener(eventManager) {
|
|
57895
58081
|
const table = eventManager.table,
|
|
57896
58082
|
stateManager = table.stateManager,
|
|
57897
|
-
handler = table.internalProps.handler
|
|
58083
|
+
handler = table.internalProps.handler,
|
|
58084
|
+
afterCompleteEdit = (completeEditResult, onSuccess) => {
|
|
58085
|
+
getPromiseValue(completeEditResult, isCompleteEdit => {
|
|
58086
|
+
var _a, _b, _c, _d, _e;
|
|
58087
|
+
!1 !== isCompleteEdit ? onSuccess() : null === (_e = null === (_d = null === (_c = null === (_b = null === (_a = table.editorManager) || void 0 === _a ? void 0 : _a.editingEditor) || void 0 === _b ? void 0 : _b.getInputElement) || void 0 === _c ? void 0 : _c.call(_b)) || void 0 === _d ? void 0 : _d.focus) || void 0 === _e || _e.call(_d);
|
|
58088
|
+
});
|
|
58089
|
+
};
|
|
57898
58090
|
function handleKeydownListener(e) {
|
|
57899
58091
|
var _a;
|
|
57900
58092
|
if (table.hasListeners(TABLE_EVENT_TYPE.KEYDOWN)) {
|
|
@@ -57917,7 +58109,7 @@
|
|
|
57917
58109
|
}
|
|
57918
58110
|
eventManager.dealTableHover();
|
|
57919
58111
|
}), handler.on(table.getElement(), "keydown", e => {
|
|
57920
|
-
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, _0
|
|
58112
|
+
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, _0;
|
|
57921
58113
|
const beforeKeydownEvent = {
|
|
57922
58114
|
keyCode: null !== (_a = e.keyCode) && void 0 !== _a ? _a : e.which,
|
|
57923
58115
|
code: e.code,
|
|
@@ -57927,48 +58119,60 @@
|
|
|
57927
58119
|
if ((null === (_d = null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.moveEditCellOnArrowKeys) || void 0 === _d || !_d) && (null === (_e = table.editorManager) || void 0 === _e ? void 0 : _e.editingEditor) || !1 === (null === (_f = table.options.keyboardOptions) || void 0 === _f ? void 0 : _f.moveSelectedCellOnArrowKeys)) return;
|
|
57928
58120
|
let targetCol, targetRow;
|
|
57929
58121
|
if (e.preventDefault(), e.stopPropagation(), "ArrowUp" === e.key ? e.ctrlKey || e.metaKey ? (targetCol = stateManager.select.cellPos.col, targetRow = 0) : (e.shiftKey, targetCol = stateManager.select.cellPos.col, targetRow = Math.min(table.rowCount - 1, Math.max(0, stateManager.select.cellPos.row - 1))) : "ArrowDown" === e.key ? e.ctrlKey || e.metaKey ? (targetCol = stateManager.select.cellPos.col, targetRow = table.rowCount - 1) : (e.shiftKey, targetCol = stateManager.select.cellPos.col, targetRow = Math.min(table.rowCount - 1, Math.max(0, stateManager.select.cellPos.row + 1))) : "ArrowLeft" === e.key ? e.ctrlKey || e.metaKey ? (targetCol = 0, targetRow = stateManager.select.cellPos.row) : (e.shiftKey, targetRow = stateManager.select.cellPos.row, targetCol = Math.min(table.colCount - 1, Math.max(0, stateManager.select.cellPos.col - 1))) : "ArrowRight" === e.key && (e.ctrlKey || e.metaKey ? (targetCol = table.colCount - 1, targetRow = stateManager.select.cellPos.row) : (e.shiftKey, targetRow = stateManager.select.cellPos.row, targetCol = Math.min(table.colCount - 1, Math.max(0, stateManager.select.cellPos.col + 1)))), isCellDisableSelect(table, targetCol, targetRow)) return;
|
|
57930
|
-
const isEditingCell = !!(null === (_g = table.editorManager) || void 0 === _g ? void 0 : _g.editingEditor)
|
|
57931
|
-
|
|
57932
|
-
|
|
57933
|
-
|
|
57934
|
-
|
|
57935
|
-
|
|
57936
|
-
|
|
57937
|
-
|
|
57938
|
-
|
|
57939
|
-
|
|
57940
|
-
|
|
57941
|
-
|
|
57942
|
-
|
|
57943
|
-
|
|
58122
|
+
const isEditingCell = !!(null === (_g = table.editorManager) || void 0 === _g ? void 0 : _g.editingEditor),
|
|
58123
|
+
completeEditResult = null === (_h = table.editorManager) || void 0 === _h ? void 0 : _h.completeEdit();
|
|
58124
|
+
afterCompleteEdit(completeEditResult, () => {
|
|
58125
|
+
var _a, _b, _c, _d, _e;
|
|
58126
|
+
table.getElement().focus();
|
|
58127
|
+
const enableShiftSelectMode = null === (_b = null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.shiftMultiSelect) || void 0 === _b || _b;
|
|
58128
|
+
table.selectCell(targetCol, targetRow, e.shiftKey && enableShiftSelectMode), null !== (_d = null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.moveEditCellOnArrowKeys) && void 0 !== _d && _d && isEditingCell && table.getEditor(targetCol, targetRow) && (null === (_e = table.editorManager) || void 0 === _e || _e.startEditCell(targetCol, targetRow));
|
|
58129
|
+
});
|
|
58130
|
+
} else if ("Escape" === e.key) null === (_j = table.editorManager) || void 0 === _j || _j.cancelEdit(), table.getElement().focus();else if ("Enter" === e.key) {
|
|
58131
|
+
if (null === (_k = table.editorManager) || void 0 === _k ? void 0 : _k.editingEditor) {
|
|
58132
|
+
handleKeydownListener(e);
|
|
58133
|
+
const completeEditResult = null === (_l = table.editorManager) || void 0 === _l ? void 0 : _l.completeEdit();
|
|
58134
|
+
return void afterCompleteEdit(completeEditResult, () => {
|
|
58135
|
+
var _a, _b, _c;
|
|
58136
|
+
if (table.getElement().focus(), !0 === (null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.moveFocusCellOnEnter)) {
|
|
58137
|
+
const targetCol = stateManager.select.cellPos.col,
|
|
58138
|
+
targetRow = Math.min(table.rowCount - 1, Math.max(0, stateManager.select.cellPos.row + 1));
|
|
58139
|
+
if (isCellDisableSelect(table, targetCol, targetRow)) return;
|
|
58140
|
+
const enableShiftSelectMode = null === (_c = null === (_b = table.options.keyboardOptions) || void 0 === _b ? void 0 : _b.shiftMultiSelect) || void 0 === _c || _c;
|
|
58141
|
+
table.selectCell(targetCol, targetRow, e.shiftKey && enableShiftSelectMode);
|
|
58142
|
+
}
|
|
58143
|
+
});
|
|
57944
58144
|
}
|
|
57945
|
-
if (!0 === (null === (
|
|
58145
|
+
if (!0 === (null === (_m = table.options.keyboardOptions) || void 0 === _m ? void 0 : _m.moveFocusCellOnEnter)) {
|
|
57946
58146
|
const targetCol = stateManager.select.cellPos.col,
|
|
57947
58147
|
targetRow = Math.min(table.rowCount - 1, Math.max(0, stateManager.select.cellPos.row + 1));
|
|
57948
58148
|
if (isCellDisableSelect(table, targetCol, targetRow)) return;
|
|
57949
|
-
const enableShiftSelectMode = null === (
|
|
58149
|
+
const enableShiftSelectMode = null === (_p = null === (_o = table.options.keyboardOptions) || void 0 === _o ? void 0 : _o.shiftMultiSelect) || void 0 === _p || _p;
|
|
57950
58150
|
table.selectCell(targetCol, targetRow, e.shiftKey && enableShiftSelectMode);
|
|
57951
|
-
} else if ((null === (
|
|
58151
|
+
} else if ((null === (_r = null === (_q = table.options.keyboardOptions) || void 0 === _q ? void 0 : _q.editCellOnEnter) || void 0 === _r || _r) && 1 === (null !== (_t = null === (_s = table.stateManager.select.ranges) || void 0 === _s ? void 0 : _s.length) && void 0 !== _t ? _t : 0)) {
|
|
57952
58152
|
const startCol = table.stateManager.select.ranges[0].start.col,
|
|
57953
58153
|
startRow = table.stateManager.select.ranges[0].start.row,
|
|
57954
58154
|
endCol = table.stateManager.select.ranges[0].end.col,
|
|
57955
58155
|
endRow = table.stateManager.select.ranges[0].end.row;
|
|
57956
|
-
startCol === endCol && startRow === endRow && table.getEditor(startCol, startRow) && (null === (
|
|
58156
|
+
startCol === endCol && startRow === endRow && table.getEditor(startCol, startRow) && (null === (_u = table.editorManager) || void 0 === _u || _u.startEditCell(startCol, startRow));
|
|
57957
58157
|
}
|
|
57958
58158
|
} else if ("Tab" === e.key) {
|
|
57959
|
-
if ((null === (
|
|
58159
|
+
if ((null === (_w = null === (_v = table.options.keyboardOptions) || void 0 === _v ? void 0 : _v.moveFocusCellOnTab) || void 0 === _w || _w) && stateManager.select.cellPos.col >= 0 && stateManager.select.cellPos.row >= 0) {
|
|
57960
58160
|
if (stateManager.select.cellPos.col === table.colCount - 1 && stateManager.select.cellPos.row === table.rowCount - 1) return;
|
|
57961
58161
|
let targetCol, targetRow;
|
|
57962
58162
|
if (e.preventDefault(), stateManager.select.cellPos.col === table.colCount - 1 ? (targetRow = Math.min(table.rowCount - 1, stateManager.select.cellPos.row + 1), targetCol = table.rowHeaderLevelCount) : (targetRow = stateManager.select.cellPos.row, targetCol = stateManager.select.cellPos.col + 1), isCellDisableSelect(table, targetCol, targetRow)) return;
|
|
57963
|
-
const isEditingCell = !!(null === (
|
|
57964
|
-
|
|
58163
|
+
const isEditingCell = !!(null === (_x = table.editorManager) || void 0 === _x ? void 0 : _x.editingEditor),
|
|
58164
|
+
completeEditResult = null === (_y = table.editorManager) || void 0 === _y ? void 0 : _y.completeEdit();
|
|
58165
|
+
afterCompleteEdit(completeEditResult, () => {
|
|
58166
|
+
var _a;
|
|
58167
|
+
table.getElement().focus(), table.selectCell(targetCol, targetRow), isEditingCell && table.getEditor(targetCol, targetRow) && (null === (_a = table.editorManager) || void 0 === _a || _a.startEditCell(targetCol, targetRow));
|
|
58168
|
+
});
|
|
57965
58169
|
}
|
|
57966
58170
|
} else if (!e.ctrlKey && !e.metaKey) {
|
|
57967
58171
|
const editCellTrigger = table.options.editCellTrigger,
|
|
57968
58172
|
selectedRanges = table.stateManager.select.ranges;
|
|
57969
|
-
if (1 === selectedRanges.length && selectedRanges[0].start.col === selectedRanges[0].end.col && selectedRanges[0].start.row === selectedRanges[0].end.row && ("keydown" === editCellTrigger || Array.isArray(editCellTrigger) && editCellTrigger.includes("keydown")) && !(null === (
|
|
58173
|
+
if (1 === selectedRanges.length && selectedRanges[0].start.col === selectedRanges[0].end.col && selectedRanges[0].start.row === selectedRanges[0].end.row && ("keydown" === editCellTrigger || Array.isArray(editCellTrigger) && editCellTrigger.includes("keydown")) && !(null === (_z = table.editorManager) || void 0 === _z ? void 0 : _z.editingEditor)) {
|
|
57970
58174
|
const allowedKeys = /^[a-zA-Z0-9+\-*\/%=.,\s]$/;
|
|
57971
|
-
e.key.match(allowedKeys) && (table.editorManager && (table.editorManager.beginTriggerEditCellMode = "keydown"), null === (
|
|
58175
|
+
e.key.match(allowedKeys) && (table.editorManager && (table.editorManager.beginTriggerEditCellMode = "keydown"), null === (_0 = table.editorManager) || void 0 === _0 || _0.startEditCell(stateManager.select.cellPos.col, stateManager.select.cellPos.row, ""));
|
|
57972
58176
|
}
|
|
57973
58177
|
}
|
|
57974
58178
|
handleKeydownListener(e);
|
|
@@ -61230,7 +61434,7 @@
|
|
|
61230
61434
|
}
|
|
61231
61435
|
constructor(container, options = {}) {
|
|
61232
61436
|
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;
|
|
61233
|
-
if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.1
|
|
61437
|
+
if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.1", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "undefined" != typeof window) {
|
|
61234
61438
|
const g = window;
|
|
61235
61439
|
g[this.id] = this;
|
|
61236
61440
|
const registry = g.__vtable__ || (g.__vtable__ = {
|
|
@@ -71274,11 +71478,6 @@
|
|
|
71274
71478
|
} else for (let i = 0; i < selectCells.length; i++) for (let j = 0; j < selectCells[i].length; j++) tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, "", workOnEditableCell);
|
|
71275
71479
|
}
|
|
71276
71480
|
|
|
71277
|
-
const MENU_CONTAINER_CLASS = "vtable-context-menu-container";
|
|
71278
|
-
const MENU_ITEM_CLASS = "vtable-context-menu-item";
|
|
71279
|
-
const MENU_ITEM_DISABLED_CLASS = "vtable-context-menu-item-disabled";
|
|
71280
|
-
const MENU_ITEM_SEPARATOR_CLASS = "vtable-context-menu-item-separator";
|
|
71281
|
-
const MENU_ITEM_SUBMENU_CLASS = "vtable-context-menu-item-submenu";
|
|
71282
71481
|
const MENU_STYLES = {
|
|
71283
71482
|
menuContainer: {
|
|
71284
71483
|
position: "absolute",
|
|
@@ -71286,7 +71485,7 @@
|
|
|
71286
71485
|
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.2)",
|
|
71287
71486
|
borderRadius: "4px",
|
|
71288
71487
|
padding: "5px 0",
|
|
71289
|
-
zIndex:
|
|
71488
|
+
zIndex: "1000",
|
|
71290
71489
|
minWidth: "180px",
|
|
71291
71490
|
maxHeight: "300px",
|
|
71292
71491
|
overflowY: "auto",
|
|
@@ -71305,7 +71504,7 @@
|
|
|
71305
71504
|
backgroundColor: "#f5f5f5"
|
|
71306
71505
|
},
|
|
71307
71506
|
menuItemDisabled: {
|
|
71308
|
-
opacity: .5,
|
|
71507
|
+
opacity: "0.5",
|
|
71309
71508
|
cursor: "not-allowed"
|
|
71310
71509
|
},
|
|
71311
71510
|
menuItemSeparator: {
|
|
@@ -71322,7 +71521,7 @@
|
|
|
71322
71521
|
justifyContent: "center"
|
|
71323
71522
|
},
|
|
71324
71523
|
menuItemText: {
|
|
71325
|
-
flex: 1
|
|
71524
|
+
flex: "1"
|
|
71326
71525
|
},
|
|
71327
71526
|
menuItemShortcut: {
|
|
71328
71527
|
marginLeft: "20px",
|
|
@@ -71342,7 +71541,7 @@
|
|
|
71342
71541
|
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.2)",
|
|
71343
71542
|
borderRadius: "4px",
|
|
71344
71543
|
padding: "5px 0",
|
|
71345
|
-
zIndex: 1001,
|
|
71544
|
+
zIndex: "1001",
|
|
71346
71545
|
minWidth: "180px",
|
|
71347
71546
|
fontSize: "12px"
|
|
71348
71547
|
},
|
|
@@ -71376,17 +71575,83 @@
|
|
|
71376
71575
|
fontSize: "12px"
|
|
71377
71576
|
}
|
|
71378
71577
|
};
|
|
71578
|
+
const MENU_CLASSES = {
|
|
71579
|
+
menuContainer: "vtable-context-menu-container",
|
|
71580
|
+
submenuContainer: "vtable-context-submenu-container",
|
|
71581
|
+
menuItem: "vtable-context-menu-item",
|
|
71582
|
+
menuItemSeparator: "vtable-context-menu-item-separator",
|
|
71583
|
+
menuItemSubmenu: "vtable-context-menu-item-submenu",
|
|
71584
|
+
menuItemDisabled: "vtable-context-menu-item-disabled"
|
|
71585
|
+
};
|
|
71586
|
+
const DANGEROUS_SVG_ELEMENTS = new Set(["script", "iframe", "object", "embed", "form", "input", "textarea", "select", "button"]),
|
|
71587
|
+
DANGEROUS_ATTR_PREFIXES = ["on"],
|
|
71588
|
+
DANGEROUS_URL_ATTRS = new Set(["href", "xlink:href"]);
|
|
71589
|
+
function sanitizeSvg(svgString) {
|
|
71590
|
+
const doc = new DOMParser().parseFromString(svgString, "image/svg+xml");
|
|
71591
|
+
if (doc.querySelector("parsererror")) return "";
|
|
71592
|
+
const svg = doc.documentElement;
|
|
71593
|
+
if ("svg" !== svg.tagName.toLowerCase()) return "";
|
|
71594
|
+
sanitizeNode(svg);
|
|
71595
|
+
return new XMLSerializer().serializeToString(svg);
|
|
71596
|
+
}
|
|
71597
|
+
function sanitizeNode(node) {
|
|
71598
|
+
const children = Array.from(node.children);
|
|
71599
|
+
for (const child of children) DANGEROUS_SVG_ELEMENTS.has(child.tagName.toLowerCase()) ? node.removeChild(child) : sanitizeNode(child);
|
|
71600
|
+
const attrs = Array.from(node.attributes);
|
|
71601
|
+
for (const attr of attrs) {
|
|
71602
|
+
const name = attr.name.toLowerCase();
|
|
71603
|
+
if (DANGEROUS_ATTR_PREFIXES.some(prefix => name.startsWith(prefix))) node.removeAttribute(attr.name);else if (DANGEROUS_URL_ATTRS.has(name)) {
|
|
71604
|
+
const value = attr.value.trim().toLowerCase();
|
|
71605
|
+
(value.startsWith("javascript:") || value.startsWith("data:")) && node.removeAttribute(attr.name);
|
|
71606
|
+
}
|
|
71607
|
+
}
|
|
71608
|
+
}
|
|
71609
|
+
function mergeStyles(styles) {
|
|
71610
|
+
if (!styles) return Object.assign({}, MENU_STYLES);
|
|
71611
|
+
const result = {};
|
|
71612
|
+
for (const _key in MENU_STYLES) {
|
|
71613
|
+
const key = _key;
|
|
71614
|
+
styles[key] ? result[key] = Object.assign(Object.assign({}, MENU_STYLES[key]), styles[key]) : result[key] = Object.assign({}, MENU_STYLES[key]);
|
|
71615
|
+
}
|
|
71616
|
+
return result;
|
|
71617
|
+
}
|
|
71618
|
+
function mergeClasses(classes) {
|
|
71619
|
+
if (!classes) return Object.assign({}, MENU_CLASSES);
|
|
71620
|
+
const result = {};
|
|
71621
|
+
for (const _key in MENU_CLASSES) {
|
|
71622
|
+
const key = _key;
|
|
71623
|
+
classes[key] ? result[key] = `${MENU_CLASSES[key]} ${normalizeClassName(classes[key]).join(" ")}` : result[key] = MENU_CLASSES[key];
|
|
71624
|
+
}
|
|
71625
|
+
return result;
|
|
71626
|
+
}
|
|
71379
71627
|
function createElement$1(tag, className, styles) {
|
|
71380
71628
|
const element = document.createElement(tag);
|
|
71381
71629
|
return className && (element.className = className), styles && applyStyles$1(element, styles), element;
|
|
71382
71630
|
}
|
|
71383
71631
|
function applyStyles$1(element, styles) {
|
|
71384
|
-
|
|
71385
|
-
|
|
71386
|
-
|
|
71632
|
+
for (const key in styles) {
|
|
71633
|
+
const value = styles[key];
|
|
71634
|
+
void 0 !== value && (element.style[key] = value);
|
|
71635
|
+
}
|
|
71387
71636
|
}
|
|
71388
|
-
function createIcon(
|
|
71389
|
-
|
|
71637
|
+
function createIcon(icon, menuItem, iconStyles = MENU_STYLES.menuItemIcon) {
|
|
71638
|
+
if ("function" == typeof icon) {
|
|
71639
|
+
const element = icon(menuItem);
|
|
71640
|
+
return applyStyles$1(element, iconStyles), element;
|
|
71641
|
+
}
|
|
71642
|
+
if ("object" == typeof icon && "svg" in icon) {
|
|
71643
|
+
const svgConfig = icon,
|
|
71644
|
+
iconElement = createElement$1("span"),
|
|
71645
|
+
safeSvg = sanitizeSvg(svgConfig.svg);
|
|
71646
|
+
if (safeSvg) {
|
|
71647
|
+
iconElement.innerHTML = safeSvg;
|
|
71648
|
+
const svgEl = iconElement.querySelector("svg");
|
|
71649
|
+
svgEl && (void 0 !== svgConfig.width && svgEl.setAttribute("width", String(svgConfig.width)), void 0 !== svgConfig.height && svgEl.setAttribute("height", String(svgConfig.height)));
|
|
71650
|
+
}
|
|
71651
|
+
return applyStyles$1(iconElement, iconStyles), iconElement;
|
|
71652
|
+
}
|
|
71653
|
+
const iconName = icon,
|
|
71654
|
+
iconElement = createElement$1("span");
|
|
71390
71655
|
switch (iconName) {
|
|
71391
71656
|
case "copy":
|
|
71392
71657
|
iconElement.innerHTML = "📋";
|
|
@@ -71430,20 +71695,30 @@
|
|
|
71430
71695
|
default:
|
|
71431
71696
|
iconElement.innerHTML = "•";
|
|
71432
71697
|
}
|
|
71433
|
-
return applyStyles$1(iconElement,
|
|
71698
|
+
return applyStyles$1(iconElement, iconStyles), iconElement;
|
|
71699
|
+
}
|
|
71700
|
+
function normalizeItemClassNameConfig(classNames) {
|
|
71701
|
+
const normalized = {};
|
|
71702
|
+
return classNames && Object.keys(classNames).forEach(item => {
|
|
71703
|
+
const className = classNames[item];
|
|
71704
|
+
className && (normalized[item] = normalizeClassName(className));
|
|
71705
|
+
}), normalized;
|
|
71706
|
+
}
|
|
71707
|
+
function normalizeClassName(className) {
|
|
71708
|
+
return className ? isArray$8(className) ? className : className.split(" ").filter(Boolean) : [];
|
|
71434
71709
|
}
|
|
71435
71710
|
|
|
71436
71711
|
let MenuManager$1 = class MenuManager {
|
|
71437
|
-
constructor() {
|
|
71712
|
+
constructor(styles, classes) {
|
|
71438
71713
|
this.menuContainer = null, this.activeSubmenus = [], this.clickCallback = null, this.table = null, this.context = {}, this.hideTimeout = null, this.showTimeout = null, this.submenuShowDelay = 100, this.submenuHideDelay = 500, this.menuInitializationDelay = 200, this.handleDocumentClick = event => {
|
|
71439
71714
|
if (!this.menuContainer || event.target !== this.menuContainer && !this.menuContainer.contains(event.target)) {
|
|
71440
71715
|
for (const submenu of this.activeSubmenus) if (event.target === submenu || submenu.contains(event.target)) return;
|
|
71441
71716
|
this.release();
|
|
71442
71717
|
}
|
|
71443
|
-
};
|
|
71718
|
+
}, this.styles = null != styles ? styles : MENU_STYLES, this.classes = null != classes ? classes : MENU_CLASSES;
|
|
71444
71719
|
}
|
|
71445
71720
|
showMenu(menuItems, x, y, context, table) {
|
|
71446
|
-
this.context = context, this.table = table, this.release(), this.menuContainer = createElement$1("div",
|
|
71721
|
+
this.context = context, this.table = table, this.release(), this.menuContainer = createElement$1("div"), this.menuContainer.classList.add(...normalizeClassName(this.classes.menuContainer)), applyStyles$1(this.menuContainer, this.styles.menuContainer), document.body.appendChild(this.menuContainer), this.menuContainer.addEventListener("contextmenu", e => {
|
|
71447
71722
|
e.preventDefault();
|
|
71448
71723
|
}), this.createMenuItems(menuItems, this.menuContainer), this.positionMenu(this.menuContainer, x, y), this.menuContainer.style.pointerEvents = "none", setTimeout(() => {
|
|
71449
71724
|
this.menuContainer && (this.menuContainer.style.pointerEvents = "auto");
|
|
@@ -71456,25 +71731,29 @@
|
|
|
71456
71731
|
}
|
|
71457
71732
|
createMenuItems(items, container, parentItem) {
|
|
71458
71733
|
items.forEach(item => {
|
|
71734
|
+
var _a;
|
|
71459
71735
|
if ("string" == typeof item && "---" === item) {
|
|
71460
|
-
const separator = createElement$1("div"
|
|
71461
|
-
applyStyles$1(separator,
|
|
71736
|
+
const separator = createElement$1("div");
|
|
71737
|
+
separator.classList.add(...normalizeClassName(this.classes.menuItemSeparator)), applyStyles$1(separator, this.styles.menuItemSeparator), container.appendChild(separator);
|
|
71462
71738
|
} else if ("object" == typeof item) {
|
|
71463
71739
|
const menuItem = item,
|
|
71464
|
-
|
|
71465
|
-
|
|
71740
|
+
customClassName = normalizeItemClassNameConfig(item.customClassName),
|
|
71741
|
+
menuItemElement = createElement$1("div");
|
|
71742
|
+
menuItemElement.classList.add(...normalizeClassName(this.classes.menuItem)), customClassName.item && menuItemElement.classList.add(...customClassName.item), applyStyles$1(menuItemElement, this.styles.menuItem);
|
|
71466
71743
|
const leftContainer = createElement$1("div");
|
|
71467
|
-
|
|
71468
|
-
|
|
71469
|
-
|
|
71744
|
+
customClassName.leftContainer && leftContainer.classList.add(...customClassName.leftContainer), leftContainer.style.display = "flex", leftContainer.style.alignItems = "center";
|
|
71745
|
+
const iconValue = null !== (_a = menuItem.customIcon) && void 0 !== _a ? _a : menuItem.iconName;
|
|
71746
|
+
if (iconValue) {
|
|
71747
|
+
const icon = createIcon(iconValue, menuItem, this.styles.menuItemIcon);
|
|
71748
|
+
customClassName.icon && icon.classList.add(...customClassName.icon), leftContainer.appendChild(icon);
|
|
71470
71749
|
} else if (menuItem.iconPlaceholder) {
|
|
71471
71750
|
const placeholder = createElement$1("span");
|
|
71472
|
-
applyStyles$1(placeholder,
|
|
71751
|
+
applyStyles$1(placeholder, this.styles.menuItemIcon), leftContainer.appendChild(placeholder);
|
|
71473
71752
|
}
|
|
71474
71753
|
const text = createElement$1("span");
|
|
71475
|
-
if (text.textContent = menuItem.text, applyStyles$1(text,
|
|
71754
|
+
if (customClassName.text && text.classList.add(...customClassName.text), text.textContent = menuItem.text, applyStyles$1(text, this.styles.menuItemText), leftContainer.appendChild(text), item.inputDefaultValue) {
|
|
71476
71755
|
const input = createElement$1("input");
|
|
71477
|
-
input.type = "number", input.min = "1", input.value = item.inputDefaultValue.toString(), applyStyles$1(input,
|
|
71756
|
+
customClassName.input && input.classList.add(...customClassName.input), input.type = "number", input.min = "1", input.value = item.inputDefaultValue.toString(), applyStyles$1(input, this.styles.inputField), leftContainer.appendChild(input), input.addEventListener("keydown", e => {
|
|
71478
71757
|
"Enter" === e.key && this.handleMenuItemClick(Object.assign({
|
|
71479
71758
|
menuKey: menuItem.menuKey,
|
|
71480
71759
|
menuText: menuItem.text,
|
|
@@ -71484,26 +71763,26 @@
|
|
|
71484
71763
|
}
|
|
71485
71764
|
menuItemElement.appendChild(leftContainer);
|
|
71486
71765
|
const rightContainer = createElement$1("div");
|
|
71487
|
-
if (rightContainer.style.display = "flex", rightContainer.style.alignItems = "center", menuItem.shortcut) {
|
|
71766
|
+
if (customClassName.rightContainer && rightContainer.classList.add(...customClassName.rightContainer), rightContainer.style.display = "flex", rightContainer.style.alignItems = "center", menuItem.shortcut) {
|
|
71488
71767
|
const shortcut = createElement$1("span");
|
|
71489
|
-
shortcut.textContent = menuItem.shortcut, applyStyles$1(shortcut,
|
|
71768
|
+
customClassName.shortcut && shortcut.classList.add(...customClassName.shortcut), shortcut.textContent = menuItem.shortcut, applyStyles$1(shortcut, this.styles.menuItemShortcut), rightContainer.appendChild(shortcut);
|
|
71490
71769
|
}
|
|
71491
71770
|
if (menuItem.children && menuItem.children.length > 0) {
|
|
71492
|
-
menuItemElement.classList.add(
|
|
71771
|
+
menuItemElement.classList.add(...normalizeClassName(this.classes.menuItemSubmenu));
|
|
71493
71772
|
const arrow = createElement$1("span");
|
|
71494
|
-
arrow.textContent = "▶", applyStyles$1(arrow,
|
|
71773
|
+
customClassName.arrow && arrow.classList.add(...customClassName.arrow), arrow.textContent = "▶", applyStyles$1(arrow, this.styles.submenuArrow), rightContainer.appendChild(arrow);
|
|
71495
71774
|
}
|
|
71496
|
-
menuItemElement.appendChild(rightContainer), menuItem.disabled && (menuItemElement.classList.add(
|
|
71775
|
+
menuItemElement.appendChild(rightContainer), menuItem.disabled && (menuItemElement.classList.add(...normalizeClassName(this.classes.menuItemDisabled)), customClassName.itemDisabled && menuItemElement.classList.add(...customClassName.itemDisabled), applyStyles$1(menuItemElement, this.styles.menuItemDisabled)), menuItem.disabled || (menuItem.children && 0 !== menuItem.children.length || menuItemElement.addEventListener("click", e => {
|
|
71497
71776
|
e.target instanceof HTMLInputElement || this.handleMenuItemClick(Object.assign({
|
|
71498
71777
|
menuKey: menuItem.menuKey,
|
|
71499
71778
|
menuText: menuItem.text
|
|
71500
71779
|
}, this.context));
|
|
71501
71780
|
}), menuItemElement.addEventListener("mouseenter", () => {
|
|
71502
|
-
applyStyles$1(menuItemElement,
|
|
71781
|
+
applyStyles$1(menuItemElement, this.styles.menuItemHover), null !== this.hideTimeout && (clearTimeout(this.hideTimeout), this.hideTimeout = null), null !== this.showTimeout && (clearTimeout(this.showTimeout), this.showTimeout = null), menuItem.children && menuItem.children.length > 0 ? (this.closeAllSubmenus(), this.showTimeout = setTimeout(() => {
|
|
71503
71782
|
document.body.contains(menuItemElement) && this.showSubmenu(menuItem.children, menuItemElement, menuItem);
|
|
71504
71783
|
}, this.submenuShowDelay)) : parentItem || this.closeAllSubmenus();
|
|
71505
71784
|
}), menuItemElement.addEventListener("mouseleave", () => {
|
|
71506
|
-
Object.keys(
|
|
71785
|
+
Object.keys(this.styles.menuItemHover).forEach(key => {
|
|
71507
71786
|
menuItemElement.style[key] = "";
|
|
71508
71787
|
}), menuItem.children && menuItem.children.length > 0 && (this.hideTimeout = setTimeout(() => {
|
|
71509
71788
|
this.closeAllSubmenus();
|
|
@@ -71514,8 +71793,8 @@
|
|
|
71514
71793
|
}
|
|
71515
71794
|
showSubmenu(items, parentElement, parentItem) {
|
|
71516
71795
|
const parentRect = parentElement.getBoundingClientRect(),
|
|
71517
|
-
submenu = createElement$1("div"
|
|
71518
|
-
applyStyles$1(submenu,
|
|
71796
|
+
submenu = createElement$1("div");
|
|
71797
|
+
submenu.classList.add(...normalizeClassName(this.classes.menuContainer), ...normalizeClassName(this.classes.submenuContainer)), applyStyles$1(submenu, this.styles.submenuContainer), this.createMenuItems(items, submenu, parentItem), document.body.appendChild(submenu);
|
|
71519
71798
|
const submenuRect = submenu.getBoundingClientRect();
|
|
71520
71799
|
let left = parentRect.right,
|
|
71521
71800
|
top = parentRect.top;
|
|
@@ -72987,7 +73266,7 @@
|
|
|
72987
73266
|
|
|
72988
73267
|
class ContextMenuPlugin {
|
|
72989
73268
|
constructor(pluginOptions = {}) {
|
|
72990
|
-
var _a;
|
|
73269
|
+
var _a, _b, _c;
|
|
72991
73270
|
this.id = "context-menu", this.name = "Context Menu", this.runTime = [TABLE_EVENT_TYPE.CONTEXTMENU_CELL, TABLE_EVENT_TYPE.PLUGIN_EVENT], this.handleContextMenuCell = (eventArgs, table) => {
|
|
72992
73271
|
const {
|
|
72993
73272
|
col: col,
|
|
@@ -73017,7 +73296,7 @@
|
|
|
73017
73296
|
}
|
|
73018
73297
|
}, this.handleMenuClickCallback = (args, table) => {
|
|
73019
73298
|
"function" == typeof this.pluginOptions.menuClickCallback ? this.pluginOptions.menuClickCallback(args, table) : this.handleMenuClick(args, table);
|
|
73020
|
-
}, this.id = null !== (_a = pluginOptions.id) && void 0 !== _a ? _a : this.id, this.pluginOptions = pluginOptions, this.menuManager = new MenuManager$1(), this.menuHandler = new MenuHandler(), this.initDefaultMenuItems();
|
|
73299
|
+
}, this.id = null !== (_a = pluginOptions.id) && void 0 !== _a ? _a : this.id, this.pluginOptions = pluginOptions, this.menuManager = new MenuManager$1(mergeStyles(null === (_b = pluginOptions.customMenuAttributions) || void 0 === _b ? void 0 : _b.style), mergeClasses(null === (_c = pluginOptions.customMenuAttributions) || void 0 === _c ? void 0 : _c.class)), this.menuHandler = new MenuHandler(), this.initDefaultMenuItems();
|
|
73021
73300
|
}
|
|
73022
73301
|
initDefaultMenuItems() {
|
|
73023
73302
|
this.pluginOptions.columnSeriesNumberMenuItems || (this.pluginOptions.columnSeriesNumberMenuItems = DEFAULT_COLUMN_SERIES_MENU_ITEMS), this.pluginOptions.rowSeriesNumberMenuItems || (this.pluginOptions.rowSeriesNumberMenuItems = DEFAULT_ROW_SERIES_MENU_ITEMS), this.pluginOptions.cornerSeriesNumberMenuItems || (this.pluginOptions.cornerSeriesNumberMenuItems = DEFAULT_CORNER_SERIES_MENU_ITEMS), this.pluginOptions.headerCellMenuItems || (this.pluginOptions.headerCellMenuItems = DEFAULT_HEADER_MENU_ITEMS), this.pluginOptions.bodyCellMenuItems || (this.pluginOptions.bodyCellMenuItems = DEFAULT_BODY_MENU_ITEMS);
|
|
@@ -91042,6 +91321,7 @@
|
|
|
91042
91321
|
_initializeTable() {
|
|
91043
91322
|
const tableOptions = this._generateTableOptions();
|
|
91044
91323
|
this.tableInstance = new ListTableAll(tableOptions);
|
|
91324
|
+
this._bindKeyboardSelectionVisibility();
|
|
91045
91325
|
this.element.classList.add('vtable-excel-cursor');
|
|
91046
91326
|
this.eventBus = this.vtableSheet.getEventBus();
|
|
91047
91327
|
this.eventManager = new WorkSheetEventManager(this);
|
|
@@ -91051,6 +91331,45 @@
|
|
|
91051
91331
|
this.eventManager.emitDataLoaded(this.rowCount, this.colCount);
|
|
91052
91332
|
}
|
|
91053
91333
|
}
|
|
91334
|
+
_bindKeyboardSelectionVisibility() {
|
|
91335
|
+
let isForcingKeyboardSelectionVisible = false;
|
|
91336
|
+
let previousMakeSelectCellVisible;
|
|
91337
|
+
let restoreTimer;
|
|
91338
|
+
const isArrowKeyEvent = (event) => !!event && ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(event.key);
|
|
91339
|
+
const restoreMakeSelectCellVisible = () => {
|
|
91340
|
+
const tableInstance = this.tableInstance;
|
|
91341
|
+
if (!tableInstance || !isForcingKeyboardSelectionVisible) {
|
|
91342
|
+
return;
|
|
91343
|
+
}
|
|
91344
|
+
if (tableInstance.options.select) {
|
|
91345
|
+
tableInstance.options.select.makeSelectCellVisible = previousMakeSelectCellVisible;
|
|
91346
|
+
}
|
|
91347
|
+
isForcingKeyboardSelectionVisible = false;
|
|
91348
|
+
previousMakeSelectCellVisible = undefined;
|
|
91349
|
+
};
|
|
91350
|
+
this.tableInstance?.on(TABLE_EVENT_TYPE.BEFORE_KEYDOWN, ({ event }) => {
|
|
91351
|
+
if (!isArrowKeyEvent(event)) {
|
|
91352
|
+
return;
|
|
91353
|
+
}
|
|
91354
|
+
const tableInstance = this.tableInstance;
|
|
91355
|
+
if (!tableInstance) {
|
|
91356
|
+
return;
|
|
91357
|
+
}
|
|
91358
|
+
tableInstance.options.select ??= {};
|
|
91359
|
+
previousMakeSelectCellVisible = tableInstance.options.select.makeSelectCellVisible;
|
|
91360
|
+
tableInstance.options.select.makeSelectCellVisible = true;
|
|
91361
|
+
isForcingKeyboardSelectionVisible = true;
|
|
91362
|
+
if (restoreTimer !== undefined) {
|
|
91363
|
+
window.clearTimeout(restoreTimer);
|
|
91364
|
+
}
|
|
91365
|
+
restoreTimer = window.setTimeout(restoreMakeSelectCellVisible, 0);
|
|
91366
|
+
});
|
|
91367
|
+
this.tableInstance?.on(TABLE_EVENT_TYPE.KEYDOWN, ({ event }) => {
|
|
91368
|
+
if (isArrowKeyEvent(event)) {
|
|
91369
|
+
restoreMakeSelectCellVisible();
|
|
91370
|
+
}
|
|
91371
|
+
});
|
|
91372
|
+
}
|
|
91054
91373
|
_generateTableOptions() {
|
|
91055
91374
|
let isShowTableHeader = this.options.showHeader;
|
|
91056
91375
|
if (!this.options.columns) {
|
|
@@ -95824,7 +96143,7 @@
|
|
|
95824
96143
|
importStyle();
|
|
95825
96144
|
}
|
|
95826
96145
|
|
|
95827
|
-
const version = "1.26.1
|
|
96146
|
+
const version = "1.26.1";
|
|
95828
96147
|
importStyles();
|
|
95829
96148
|
|
|
95830
96149
|
exports.TYPES = index;
|