@visactor/vtable-sheet 1.26.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 +26 -4
- package/cjs/core/WorkSheet.js.map +1 -1
- package/cjs/event/vtable-sheet-event-bus.js +1 -2
- 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 +475 -104
- package/dist/vtable-sheet.min.js +1 -1
- package/es/core/WorkSheet.d.ts +1 -0
- package/es/core/WorkSheet.js +27 -5
- package/es/core/WorkSheet.js.map +1 -1
- package/es/event/vtable-sheet-event-bus.js +1 -2
- 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 +8 -7
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) {
|
|
@@ -4940,6 +5107,20 @@
|
|
|
4940
5107
|
function crossProduct(dir1, dir2) {
|
|
4941
5108
|
return dir1[0] * dir2[1] - dir1[1] * dir2[0];
|
|
4942
5109
|
}
|
|
5110
|
+
function fixPrecision$1(num, precision = 10) {
|
|
5111
|
+
return Math.round(num * precision) / precision;
|
|
5112
|
+
}
|
|
5113
|
+
function getDecimalPlaces(n) {
|
|
5114
|
+
const dStr = n.toString().split(/[eE]/),
|
|
5115
|
+
s = (dStr[0].split(".")[1] || "").length - (+dStr[1] || 0);
|
|
5116
|
+
return s > 0 ? s : 0;
|
|
5117
|
+
}
|
|
5118
|
+
function precisionAdd(a, b) {
|
|
5119
|
+
return fixPrecision$1(a + b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));
|
|
5120
|
+
}
|
|
5121
|
+
function precisionSub(a, b) {
|
|
5122
|
+
return fixPrecision$1(a - b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));
|
|
5123
|
+
}
|
|
4943
5124
|
|
|
4944
5125
|
class Point {
|
|
4945
5126
|
constructor(x = 0, y = 0, x1, y1) {
|
|
@@ -37697,42 +37878,54 @@
|
|
|
37697
37878
|
if (record) if (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && this.children) {
|
|
37698
37879
|
this.children.push(record);
|
|
37699
37880
|
const value = record.value();
|
|
37700
|
-
this.sum
|
|
37881
|
+
this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
37701
37882
|
} else if (this.field && !isNaN(parseFloat(record[this.field]))) {
|
|
37702
37883
|
const value = parseFloat(record[this.field]);
|
|
37703
|
-
this.sum
|
|
37884
|
+
this.sum = precisionAdd(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
37704
37885
|
}
|
|
37705
37886
|
this.clearCacheValue();
|
|
37706
37887
|
}
|
|
37707
37888
|
deleteRecord(record) {
|
|
37708
|
-
if (record)
|
|
37709
|
-
this.
|
|
37710
|
-
|
|
37711
|
-
|
|
37712
|
-
|
|
37713
|
-
|
|
37714
|
-
|
|
37889
|
+
if (record) {
|
|
37890
|
+
if (this.isRecord && this.records) {
|
|
37891
|
+
const index = this.records.indexOf(record);
|
|
37892
|
+
-1 !== index && this.records.splice(index, 1);
|
|
37893
|
+
}
|
|
37894
|
+
if (record.isAggregator && this.children) {
|
|
37895
|
+
const index = this.children.indexOf(record);
|
|
37896
|
+
-1 !== index && this.children.splice(index, 1);
|
|
37897
|
+
const value = record.value();
|
|
37898
|
+
this.sum = precisionSub(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionSub(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, value)));
|
|
37899
|
+
} else if (this.field && !isNaN(parseFloat(record[this.field]))) {
|
|
37900
|
+
const value = parseFloat(record[this.field]);
|
|
37901
|
+
this.sum = precisionSub(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionSub(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, value)));
|
|
37902
|
+
}
|
|
37715
37903
|
}
|
|
37716
37904
|
this.clearCacheValue();
|
|
37717
37905
|
}
|
|
37718
37906
|
updateRecord(oldRecord, newRecord) {
|
|
37719
37907
|
if (oldRecord && newRecord) {
|
|
37720
|
-
if (this.isRecord && this.records
|
|
37721
|
-
const
|
|
37722
|
-
|
|
37908
|
+
if (this.isRecord && this.records) {
|
|
37909
|
+
const index = this.records.indexOf(oldRecord);
|
|
37910
|
+
-1 !== index && (this.records[index] = newRecord);
|
|
37911
|
+
}
|
|
37912
|
+
if (oldRecord.isAggregator && this.children) {
|
|
37913
|
+
const oldValue = oldRecord.value(),
|
|
37914
|
+
index = this.children.indexOf(oldRecord);
|
|
37915
|
+
-1 !== index && (this.children[index] = newRecord);
|
|
37723
37916
|
const newValue = newRecord.value();
|
|
37724
|
-
this.
|
|
37917
|
+
this.sum = precisionAdd(this.sum, precisionSub(newValue, oldValue)), this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum = precisionSub(this.positiveSum, oldValue) : oldValue < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, oldValue)), newValue > 0 ? this.positiveSum = precisionAdd(this.positiveSum, newValue) : newValue < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, newValue)));
|
|
37725
37918
|
} else if (this.field && !isNaN(parseFloat(oldRecord[this.field]))) {
|
|
37726
37919
|
const oldValue = parseFloat(oldRecord[this.field]),
|
|
37727
37920
|
newValue = parseFloat(newRecord[this.field]);
|
|
37728
|
-
this.sum
|
|
37921
|
+
this.sum = precisionAdd(this.sum, precisionSub(newValue, oldValue)), this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum = precisionSub(this.positiveSum, oldValue) : oldValue < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, oldValue)), newValue > 0 ? this.positiveSum = precisionAdd(this.positiveSum, newValue) : newValue < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, newValue)));
|
|
37729
37922
|
}
|
|
37730
37923
|
this.clearCacheValue();
|
|
37731
37924
|
}
|
|
37732
37925
|
}
|
|
37733
37926
|
value() {
|
|
37734
|
-
var _a
|
|
37735
|
-
return null !== (_a = this.changedValue) && void 0 !== _a ? _a :
|
|
37927
|
+
var _a;
|
|
37928
|
+
return null !== (_a = this.changedValue) && void 0 !== _a ? _a : this.records && this.records.length >= 1 || !1 === this.isRecord ? this.sum : void 0;
|
|
37736
37929
|
}
|
|
37737
37930
|
positiveValue() {
|
|
37738
37931
|
return this.positiveSum;
|
|
@@ -37748,16 +37941,16 @@
|
|
|
37748
37941
|
const child = this.children[i];
|
|
37749
37942
|
if (child.isAggregator) {
|
|
37750
37943
|
const value = child.value();
|
|
37751
|
-
this.sum
|
|
37944
|
+
this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
37752
37945
|
}
|
|
37753
37946
|
} else if (this.records) for (let i = 0; i < this.records.length; i++) {
|
|
37754
37947
|
const record = this.records[i];
|
|
37755
37948
|
if (record.isAggregator) {
|
|
37756
37949
|
const value = record.value();
|
|
37757
|
-
this.sum
|
|
37950
|
+
this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
37758
37951
|
} else if (this.field && !isNaN(parseFloat(record[this.field]))) {
|
|
37759
37952
|
const value = parseFloat(record[this.field]);
|
|
37760
|
-
this.sum
|
|
37953
|
+
this.sum = precisionAdd(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
37761
37954
|
}
|
|
37762
37955
|
}
|
|
37763
37956
|
}
|
|
@@ -37800,17 +37993,43 @@
|
|
|
37800
37993
|
super(...arguments), this.type = AggregationType.AVG, this.sum = 0, this.count = 0;
|
|
37801
37994
|
}
|
|
37802
37995
|
push(record) {
|
|
37803
|
-
record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && record.type === AggregationType.AVG ? (this.children && this.children.push(record), this.sum
|
|
37996
|
+
record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && record.type === AggregationType.AVG ? (this.children && this.children.push(record), this.sum = precisionAdd(this.sum, record.sum), this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionAdd(this.sum, parseFloat(record[this.field])), this.count++)), this.clearCacheValue();
|
|
37804
37997
|
}
|
|
37805
37998
|
deleteRecord(record) {
|
|
37806
|
-
|
|
37999
|
+
if (record) {
|
|
38000
|
+
if (this.isRecord && this.records) {
|
|
38001
|
+
const index = this.records.indexOf(record);
|
|
38002
|
+
-1 !== index && this.records.splice(index, 1);
|
|
38003
|
+
}
|
|
38004
|
+
if (record.isAggregator && record.type === AggregationType.AVG) {
|
|
38005
|
+
if (this.children) {
|
|
38006
|
+
const index = this.children.indexOf(record);
|
|
38007
|
+
-1 !== index && this.children.splice(index, 1);
|
|
38008
|
+
}
|
|
38009
|
+
this.sum = precisionSub(this.sum, record.sum), this.count -= record.count;
|
|
38010
|
+
} else this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionSub(this.sum, parseFloat(record[this.field])), this.count--);
|
|
38011
|
+
}
|
|
38012
|
+
this.clearCacheValue();
|
|
37807
38013
|
}
|
|
37808
38014
|
updateRecord(oldRecord, newRecord) {
|
|
37809
|
-
|
|
38015
|
+
if (oldRecord && newRecord) {
|
|
38016
|
+
if (this.isRecord && this.records) {
|
|
38017
|
+
const index = this.records.indexOf(oldRecord);
|
|
38018
|
+
-1 !== index && (this.records[index] = newRecord);
|
|
38019
|
+
}
|
|
38020
|
+
if (oldRecord.isAggregator && oldRecord.type === AggregationType.AVG) {
|
|
38021
|
+
if (this.children && newRecord.isAggregator) {
|
|
38022
|
+
const index = this.children.indexOf(oldRecord);
|
|
38023
|
+
-1 !== index && (this.children[index] = newRecord);
|
|
38024
|
+
}
|
|
38025
|
+
this.sum = precisionAdd(this.sum, precisionSub(newRecord.sum, oldRecord.sum)), this.count += newRecord.count - oldRecord.count;
|
|
38026
|
+
} else this.field && !isNaN(parseFloat(oldRecord[this.field])) && (this.sum = precisionAdd(this.sum, precisionSub(parseFloat(newRecord[this.field]), parseFloat(oldRecord[this.field]))));
|
|
38027
|
+
this.clearCacheValue();
|
|
38028
|
+
}
|
|
37810
38029
|
}
|
|
37811
38030
|
value() {
|
|
37812
|
-
var _a
|
|
37813
|
-
return null !== (_a = this.changedValue) && void 0 !== _a ? _a :
|
|
38031
|
+
var _a;
|
|
38032
|
+
return null !== (_a = this.changedValue) && void 0 !== _a ? _a : this.records && this.records.length >= 1 || !1 === this.isRecord && this.count > 0 ? this.sum / this.count : void 0;
|
|
37814
38033
|
}
|
|
37815
38034
|
reset() {
|
|
37816
38035
|
this.changedValue = void 0, this.children = [], this.records = [], this.sum = 0, this.count = 0;
|
|
@@ -37820,11 +38039,11 @@
|
|
|
37820
38039
|
const child = this.children[i];
|
|
37821
38040
|
if (child.isAggregator && child.type === AggregationType.AVG) {
|
|
37822
38041
|
const childValue = child.value();
|
|
37823
|
-
this.sum
|
|
38042
|
+
this.sum = precisionAdd(this.sum, childValue * child.count), this.count += child.count;
|
|
37824
38043
|
}
|
|
37825
38044
|
} else if (this.records) for (let i = 0; i < this.records.length; i++) {
|
|
37826
38045
|
const record = this.records[i];
|
|
37827
|
-
record.isAggregator && record.type === AggregationType.AVG ? (this.sum
|
|
38046
|
+
record.isAggregator && record.type === AggregationType.AVG ? (this.sum = precisionAdd(this.sum, record.sum), this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionAdd(this.sum, parseFloat(record[this.field])), this.count++);
|
|
37828
38047
|
}
|
|
37829
38048
|
}
|
|
37830
38049
|
}
|
|
@@ -51078,7 +51297,7 @@
|
|
|
51078
51297
|
};
|
|
51079
51298
|
function dynamicSetX(x, screenLeft, isEnd, proxy) {
|
|
51080
51299
|
return __awaiter$7(this, void 0, void 0, function* () {
|
|
51081
|
-
if (!screenLeft) return;
|
|
51300
|
+
if (!screenLeft) return proxy.updateDeltaX(x), proxy.table.scenegraph.setBodyAndColHeaderX(-x + proxy.deltaX), void proxy.table.scenegraph.updateNextFrame();
|
|
51082
51301
|
const screenLeftCol = screenLeft.col,
|
|
51083
51302
|
screenLeftX = screenLeft.left;
|
|
51084
51303
|
let deltaCol;
|
|
@@ -51254,7 +51473,7 @@
|
|
|
51254
51473
|
};
|
|
51255
51474
|
function dynamicSetY(y, screenTop, isEnd, proxy) {
|
|
51256
51475
|
return __awaiter$6(this, void 0, void 0, function* () {
|
|
51257
|
-
if (!screenTop) return;
|
|
51476
|
+
if (!screenTop) return proxy.updateDeltaY(y), proxy.updateBody(y - proxy.deltaY), void proxy.table.scenegraph.updateNextFrame();
|
|
51258
51477
|
const screenTopRow = screenTop.row,
|
|
51259
51478
|
screenTopY = screenTop.top;
|
|
51260
51479
|
let deltaRow;
|
|
@@ -51859,7 +52078,7 @@
|
|
|
51859
52078
|
return __awaiter$3(this, void 0, void 0, function* () {
|
|
51860
52079
|
const yLimitTop = this.table.getRowsHeight(this.bodyTopRow, this.bodyTopRow + (this.rowEnd - this.rowStart + 1)) / 2,
|
|
51861
52080
|
yLimitBottom = this.table.getAllRowsHeight() - yLimitTop,
|
|
51862
|
-
screenTop = this.
|
|
52081
|
+
screenTop = this.resolveTargetRowInfo(y + this.table.scenegraph.colHeaderGroup.attribute.height);
|
|
51863
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));
|
|
51864
52083
|
});
|
|
51865
52084
|
}
|
|
@@ -51868,7 +52087,7 @@
|
|
|
51868
52087
|
return __awaiter$3(this, void 0, void 0, function* () {
|
|
51869
52088
|
const xLimitLeft = this.table.getColsWidth(this.bodyLeftCol, this.bodyLeftCol + (this.colEnd - this.colStart + 1)) / 2,
|
|
51870
52089
|
xLimitRight = this.table.getAllColsWidth() - xLimitLeft,
|
|
51871
|
-
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));
|
|
51872
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);
|
|
51873
52092
|
});
|
|
51874
52093
|
}
|
|
@@ -51882,6 +52101,22 @@
|
|
|
51882
52101
|
dynamicSetX(x, screenLeft, isEnd, this);
|
|
51883
52102
|
});
|
|
51884
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
|
+
}
|
|
51885
52120
|
updateBody(y) {
|
|
51886
52121
|
this.table.scenegraph.setBodyAndRowHeaderY(-y);
|
|
51887
52122
|
}
|
|
@@ -54202,15 +54437,17 @@
|
|
|
54202
54437
|
this.table.scenegraph.proxy.setY(-y, isEnd);
|
|
54203
54438
|
}
|
|
54204
54439
|
setBodyAndRowHeaderY(y) {
|
|
54205
|
-
var _a, _b
|
|
54206
|
-
const
|
|
54207
|
-
|
|
54208
|
-
|
|
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());
|
|
54209
54446
|
}
|
|
54210
54447
|
setBodyAndColHeaderX(x) {
|
|
54211
|
-
const firstBodyCol = this.bodyGroup.firstChild
|
|
54212
|
-
|
|
54213
|
-
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());
|
|
54214
54451
|
}
|
|
54215
54452
|
afterScenegraphCreated() {
|
|
54216
54453
|
var _a, _b;
|
|
@@ -57647,6 +57884,7 @@
|
|
|
57647
57884
|
}
|
|
57648
57885
|
function dblclickHandler(e, table) {
|
|
57649
57886
|
var _a, _b, _c, _d, _e, _f;
|
|
57887
|
+
if ("number" == typeof e.button && 0 !== e.button) return;
|
|
57650
57888
|
const eventArgsSet = getCellEventArgsSetWithTable(e, table);
|
|
57651
57889
|
let col = -1,
|
|
57652
57890
|
row = -1;
|
|
@@ -57842,7 +58080,13 @@
|
|
|
57842
58080
|
function bindContainerDomListener(eventManager) {
|
|
57843
58081
|
const table = eventManager.table,
|
|
57844
58082
|
stateManager = table.stateManager,
|
|
57845
|
-
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
|
+
};
|
|
57846
58090
|
function handleKeydownListener(e) {
|
|
57847
58091
|
var _a;
|
|
57848
58092
|
if (table.hasListeners(TABLE_EVENT_TYPE.KEYDOWN)) {
|
|
@@ -57865,7 +58109,7 @@
|
|
|
57865
58109
|
}
|
|
57866
58110
|
eventManager.dealTableHover();
|
|
57867
58111
|
}), handler.on(table.getElement(), "keydown", e => {
|
|
57868
|
-
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;
|
|
57869
58113
|
const beforeKeydownEvent = {
|
|
57870
58114
|
keyCode: null !== (_a = e.keyCode) && void 0 !== _a ? _a : e.which,
|
|
57871
58115
|
code: e.code,
|
|
@@ -57875,48 +58119,60 @@
|
|
|
57875
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;
|
|
57876
58120
|
let targetCol, targetRow;
|
|
57877
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;
|
|
57878
|
-
const isEditingCell = !!(null === (_g = table.editorManager) || void 0 === _g ? void 0 : _g.editingEditor)
|
|
57879
|
-
|
|
57880
|
-
|
|
57881
|
-
|
|
57882
|
-
|
|
57883
|
-
|
|
57884
|
-
|
|
57885
|
-
|
|
57886
|
-
|
|
57887
|
-
|
|
57888
|
-
|
|
57889
|
-
|
|
57890
|
-
|
|
57891
|
-
|
|
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
|
+
});
|
|
57892
58144
|
}
|
|
57893
|
-
if (!0 === (null === (
|
|
58145
|
+
if (!0 === (null === (_m = table.options.keyboardOptions) || void 0 === _m ? void 0 : _m.moveFocusCellOnEnter)) {
|
|
57894
58146
|
const targetCol = stateManager.select.cellPos.col,
|
|
57895
58147
|
targetRow = Math.min(table.rowCount - 1, Math.max(0, stateManager.select.cellPos.row + 1));
|
|
57896
58148
|
if (isCellDisableSelect(table, targetCol, targetRow)) return;
|
|
57897
|
-
const enableShiftSelectMode = null === (
|
|
58149
|
+
const enableShiftSelectMode = null === (_p = null === (_o = table.options.keyboardOptions) || void 0 === _o ? void 0 : _o.shiftMultiSelect) || void 0 === _p || _p;
|
|
57898
58150
|
table.selectCell(targetCol, targetRow, e.shiftKey && enableShiftSelectMode);
|
|
57899
|
-
} 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)) {
|
|
57900
58152
|
const startCol = table.stateManager.select.ranges[0].start.col,
|
|
57901
58153
|
startRow = table.stateManager.select.ranges[0].start.row,
|
|
57902
58154
|
endCol = table.stateManager.select.ranges[0].end.col,
|
|
57903
58155
|
endRow = table.stateManager.select.ranges[0].end.row;
|
|
57904
|
-
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));
|
|
57905
58157
|
}
|
|
57906
58158
|
} else if ("Tab" === e.key) {
|
|
57907
|
-
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) {
|
|
57908
58160
|
if (stateManager.select.cellPos.col === table.colCount - 1 && stateManager.select.cellPos.row === table.rowCount - 1) return;
|
|
57909
58161
|
let targetCol, targetRow;
|
|
57910
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;
|
|
57911
|
-
const isEditingCell = !!(null === (
|
|
57912
|
-
|
|
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
|
+
});
|
|
57913
58169
|
}
|
|
57914
58170
|
} else if (!e.ctrlKey && !e.metaKey) {
|
|
57915
58171
|
const editCellTrigger = table.options.editCellTrigger,
|
|
57916
58172
|
selectedRanges = table.stateManager.select.ranges;
|
|
57917
|
-
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)) {
|
|
57918
58174
|
const allowedKeys = /^[a-zA-Z0-9+\-*\/%=.,\s]$/;
|
|
57919
|
-
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, ""));
|
|
57920
58176
|
}
|
|
57921
58177
|
}
|
|
57922
58178
|
handleKeydownListener(e);
|
|
@@ -61178,7 +61434,7 @@
|
|
|
61178
61434
|
}
|
|
61179
61435
|
constructor(container, options = {}) {
|
|
61180
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;
|
|
61181
|
-
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.
|
|
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) {
|
|
61182
61438
|
const g = window;
|
|
61183
61439
|
g[this.id] = this;
|
|
61184
61440
|
const registry = g.__vtable__ || (g.__vtable__ = {
|
|
@@ -71222,11 +71478,6 @@
|
|
|
71222
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);
|
|
71223
71479
|
}
|
|
71224
71480
|
|
|
71225
|
-
const MENU_CONTAINER_CLASS = "vtable-context-menu-container";
|
|
71226
|
-
const MENU_ITEM_CLASS = "vtable-context-menu-item";
|
|
71227
|
-
const MENU_ITEM_DISABLED_CLASS = "vtable-context-menu-item-disabled";
|
|
71228
|
-
const MENU_ITEM_SEPARATOR_CLASS = "vtable-context-menu-item-separator";
|
|
71229
|
-
const MENU_ITEM_SUBMENU_CLASS = "vtable-context-menu-item-submenu";
|
|
71230
71481
|
const MENU_STYLES = {
|
|
71231
71482
|
menuContainer: {
|
|
71232
71483
|
position: "absolute",
|
|
@@ -71234,7 +71485,7 @@
|
|
|
71234
71485
|
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.2)",
|
|
71235
71486
|
borderRadius: "4px",
|
|
71236
71487
|
padding: "5px 0",
|
|
71237
|
-
zIndex:
|
|
71488
|
+
zIndex: "1000",
|
|
71238
71489
|
minWidth: "180px",
|
|
71239
71490
|
maxHeight: "300px",
|
|
71240
71491
|
overflowY: "auto",
|
|
@@ -71253,7 +71504,7 @@
|
|
|
71253
71504
|
backgroundColor: "#f5f5f5"
|
|
71254
71505
|
},
|
|
71255
71506
|
menuItemDisabled: {
|
|
71256
|
-
opacity: .5,
|
|
71507
|
+
opacity: "0.5",
|
|
71257
71508
|
cursor: "not-allowed"
|
|
71258
71509
|
},
|
|
71259
71510
|
menuItemSeparator: {
|
|
@@ -71270,7 +71521,7 @@
|
|
|
71270
71521
|
justifyContent: "center"
|
|
71271
71522
|
},
|
|
71272
71523
|
menuItemText: {
|
|
71273
|
-
flex: 1
|
|
71524
|
+
flex: "1"
|
|
71274
71525
|
},
|
|
71275
71526
|
menuItemShortcut: {
|
|
71276
71527
|
marginLeft: "20px",
|
|
@@ -71290,7 +71541,7 @@
|
|
|
71290
71541
|
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.2)",
|
|
71291
71542
|
borderRadius: "4px",
|
|
71292
71543
|
padding: "5px 0",
|
|
71293
|
-
zIndex: 1001,
|
|
71544
|
+
zIndex: "1001",
|
|
71294
71545
|
minWidth: "180px",
|
|
71295
71546
|
fontSize: "12px"
|
|
71296
71547
|
},
|
|
@@ -71324,17 +71575,83 @@
|
|
|
71324
71575
|
fontSize: "12px"
|
|
71325
71576
|
}
|
|
71326
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
|
+
}
|
|
71327
71627
|
function createElement$1(tag, className, styles) {
|
|
71328
71628
|
const element = document.createElement(tag);
|
|
71329
71629
|
return className && (element.className = className), styles && applyStyles$1(element, styles), element;
|
|
71330
71630
|
}
|
|
71331
71631
|
function applyStyles$1(element, styles) {
|
|
71332
|
-
|
|
71333
|
-
|
|
71334
|
-
|
|
71632
|
+
for (const key in styles) {
|
|
71633
|
+
const value = styles[key];
|
|
71634
|
+
void 0 !== value && (element.style[key] = value);
|
|
71635
|
+
}
|
|
71335
71636
|
}
|
|
71336
|
-
function createIcon(
|
|
71337
|
-
|
|
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");
|
|
71338
71655
|
switch (iconName) {
|
|
71339
71656
|
case "copy":
|
|
71340
71657
|
iconElement.innerHTML = "📋";
|
|
@@ -71378,20 +71695,30 @@
|
|
|
71378
71695
|
default:
|
|
71379
71696
|
iconElement.innerHTML = "•";
|
|
71380
71697
|
}
|
|
71381
|
-
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) : [];
|
|
71382
71709
|
}
|
|
71383
71710
|
|
|
71384
71711
|
let MenuManager$1 = class MenuManager {
|
|
71385
|
-
constructor() {
|
|
71712
|
+
constructor(styles, classes) {
|
|
71386
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 => {
|
|
71387
71714
|
if (!this.menuContainer || event.target !== this.menuContainer && !this.menuContainer.contains(event.target)) {
|
|
71388
71715
|
for (const submenu of this.activeSubmenus) if (event.target === submenu || submenu.contains(event.target)) return;
|
|
71389
71716
|
this.release();
|
|
71390
71717
|
}
|
|
71391
|
-
};
|
|
71718
|
+
}, this.styles = null != styles ? styles : MENU_STYLES, this.classes = null != classes ? classes : MENU_CLASSES;
|
|
71392
71719
|
}
|
|
71393
71720
|
showMenu(menuItems, x, y, context, table) {
|
|
71394
|
-
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 => {
|
|
71395
71722
|
e.preventDefault();
|
|
71396
71723
|
}), this.createMenuItems(menuItems, this.menuContainer), this.positionMenu(this.menuContainer, x, y), this.menuContainer.style.pointerEvents = "none", setTimeout(() => {
|
|
71397
71724
|
this.menuContainer && (this.menuContainer.style.pointerEvents = "auto");
|
|
@@ -71404,25 +71731,29 @@
|
|
|
71404
71731
|
}
|
|
71405
71732
|
createMenuItems(items, container, parentItem) {
|
|
71406
71733
|
items.forEach(item => {
|
|
71734
|
+
var _a;
|
|
71407
71735
|
if ("string" == typeof item && "---" === item) {
|
|
71408
|
-
const separator = createElement$1("div"
|
|
71409
|
-
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);
|
|
71410
71738
|
} else if ("object" == typeof item) {
|
|
71411
71739
|
const menuItem = item,
|
|
71412
|
-
|
|
71413
|
-
|
|
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);
|
|
71414
71743
|
const leftContainer = createElement$1("div");
|
|
71415
|
-
|
|
71416
|
-
|
|
71417
|
-
|
|
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);
|
|
71418
71749
|
} else if (menuItem.iconPlaceholder) {
|
|
71419
71750
|
const placeholder = createElement$1("span");
|
|
71420
|
-
applyStyles$1(placeholder,
|
|
71751
|
+
applyStyles$1(placeholder, this.styles.menuItemIcon), leftContainer.appendChild(placeholder);
|
|
71421
71752
|
}
|
|
71422
71753
|
const text = createElement$1("span");
|
|
71423
|
-
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) {
|
|
71424
71755
|
const input = createElement$1("input");
|
|
71425
|
-
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 => {
|
|
71426
71757
|
"Enter" === e.key && this.handleMenuItemClick(Object.assign({
|
|
71427
71758
|
menuKey: menuItem.menuKey,
|
|
71428
71759
|
menuText: menuItem.text,
|
|
@@ -71432,26 +71763,26 @@
|
|
|
71432
71763
|
}
|
|
71433
71764
|
menuItemElement.appendChild(leftContainer);
|
|
71434
71765
|
const rightContainer = createElement$1("div");
|
|
71435
|
-
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) {
|
|
71436
71767
|
const shortcut = createElement$1("span");
|
|
71437
|
-
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);
|
|
71438
71769
|
}
|
|
71439
71770
|
if (menuItem.children && menuItem.children.length > 0) {
|
|
71440
|
-
menuItemElement.classList.add(
|
|
71771
|
+
menuItemElement.classList.add(...normalizeClassName(this.classes.menuItemSubmenu));
|
|
71441
71772
|
const arrow = createElement$1("span");
|
|
71442
|
-
arrow.textContent = "▶", applyStyles$1(arrow,
|
|
71773
|
+
customClassName.arrow && arrow.classList.add(...customClassName.arrow), arrow.textContent = "▶", applyStyles$1(arrow, this.styles.submenuArrow), rightContainer.appendChild(arrow);
|
|
71443
71774
|
}
|
|
71444
|
-
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 => {
|
|
71445
71776
|
e.target instanceof HTMLInputElement || this.handleMenuItemClick(Object.assign({
|
|
71446
71777
|
menuKey: menuItem.menuKey,
|
|
71447
71778
|
menuText: menuItem.text
|
|
71448
71779
|
}, this.context));
|
|
71449
71780
|
}), menuItemElement.addEventListener("mouseenter", () => {
|
|
71450
|
-
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(() => {
|
|
71451
71782
|
document.body.contains(menuItemElement) && this.showSubmenu(menuItem.children, menuItemElement, menuItem);
|
|
71452
71783
|
}, this.submenuShowDelay)) : parentItem || this.closeAllSubmenus();
|
|
71453
71784
|
}), menuItemElement.addEventListener("mouseleave", () => {
|
|
71454
|
-
Object.keys(
|
|
71785
|
+
Object.keys(this.styles.menuItemHover).forEach(key => {
|
|
71455
71786
|
menuItemElement.style[key] = "";
|
|
71456
71787
|
}), menuItem.children && menuItem.children.length > 0 && (this.hideTimeout = setTimeout(() => {
|
|
71457
71788
|
this.closeAllSubmenus();
|
|
@@ -71462,8 +71793,8 @@
|
|
|
71462
71793
|
}
|
|
71463
71794
|
showSubmenu(items, parentElement, parentItem) {
|
|
71464
71795
|
const parentRect = parentElement.getBoundingClientRect(),
|
|
71465
|
-
submenu = createElement$1("div"
|
|
71466
|
-
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);
|
|
71467
71798
|
const submenuRect = submenu.getBoundingClientRect();
|
|
71468
71799
|
let left = parentRect.right,
|
|
71469
71800
|
top = parentRect.top;
|
|
@@ -72935,7 +73266,7 @@
|
|
|
72935
73266
|
|
|
72936
73267
|
class ContextMenuPlugin {
|
|
72937
73268
|
constructor(pluginOptions = {}) {
|
|
72938
|
-
var _a;
|
|
73269
|
+
var _a, _b, _c;
|
|
72939
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) => {
|
|
72940
73271
|
const {
|
|
72941
73272
|
col: col,
|
|
@@ -72965,7 +73296,7 @@
|
|
|
72965
73296
|
}
|
|
72966
73297
|
}, this.handleMenuClickCallback = (args, table) => {
|
|
72967
73298
|
"function" == typeof this.pluginOptions.menuClickCallback ? this.pluginOptions.menuClickCallback(args, table) : this.handleMenuClick(args, table);
|
|
72968
|
-
}, 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();
|
|
72969
73300
|
}
|
|
72970
73301
|
initDefaultMenuItems() {
|
|
72971
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);
|
|
@@ -83720,7 +84051,7 @@
|
|
|
83720
84051
|
function getCellMatrix(table) {
|
|
83721
84052
|
return {
|
|
83722
84053
|
getValue: (row, col) => {
|
|
83723
|
-
const value = table.
|
|
84054
|
+
const value = table.getCellOriginValue(col, row);
|
|
83724
84055
|
return "number" != typeof value && isNaN(Number(value)) ? {
|
|
83725
84056
|
v: value || "",
|
|
83726
84057
|
t: CellValueType.STRING
|
|
@@ -90990,6 +91321,7 @@
|
|
|
90990
91321
|
_initializeTable() {
|
|
90991
91322
|
const tableOptions = this._generateTableOptions();
|
|
90992
91323
|
this.tableInstance = new ListTableAll(tableOptions);
|
|
91324
|
+
this._bindKeyboardSelectionVisibility();
|
|
90993
91325
|
this.element.classList.add('vtable-excel-cursor');
|
|
90994
91326
|
this.eventBus = this.vtableSheet.getEventBus();
|
|
90995
91327
|
this.eventManager = new WorkSheetEventManager(this);
|
|
@@ -90999,6 +91331,45 @@
|
|
|
90999
91331
|
this.eventManager.emitDataLoaded(this.rowCount, this.colCount);
|
|
91000
91332
|
}
|
|
91001
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
|
+
}
|
|
91002
91373
|
_generateTableOptions() {
|
|
91003
91374
|
let isShowTableHeader = this.options.showHeader;
|
|
91004
91375
|
if (!this.options.columns) {
|
|
@@ -95772,7 +96143,7 @@
|
|
|
95772
96143
|
importStyle();
|
|
95773
96144
|
}
|
|
95774
96145
|
|
|
95775
|
-
const version = "1.26.
|
|
96146
|
+
const version = "1.26.1";
|
|
95776
96147
|
importStyles();
|
|
95777
96148
|
|
|
95778
96149
|
exports.TYPES = index;
|