@univerjs/sheets-table 0.21.1 → 0.22.0
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/README.md +30 -9
- package/lib/cjs/index.js +216 -202
- package/lib/es/index.js +216 -202
- package/lib/index.js +216 -202
- package/lib/umd/index.js +1 -1
- package/package.json +12 -10
- package/lib/types/model/filter-util/manual.d.ts +0 -22
package/lib/cjs/index.js
CHANGED
|
@@ -4,19 +4,6 @@ let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
|
4
4
|
let _univerjs_sheets = require("@univerjs/sheets");
|
|
5
5
|
let rxjs = require("rxjs");
|
|
6
6
|
|
|
7
|
-
//#region src/types/type.ts
|
|
8
|
-
let IRangeOperationTypeEnum = /* @__PURE__ */ function(IRangeOperationTypeEnum) {
|
|
9
|
-
IRangeOperationTypeEnum["Insert"] = "insert";
|
|
10
|
-
IRangeOperationTypeEnum["Delete"] = "delete";
|
|
11
|
-
return IRangeOperationTypeEnum;
|
|
12
|
-
}({});
|
|
13
|
-
let IRowColTypeEnum = /* @__PURE__ */ function(IRowColTypeEnum) {
|
|
14
|
-
IRowColTypeEnum["Row"] = "row";
|
|
15
|
-
IRowColTypeEnum["Col"] = "column";
|
|
16
|
-
return IRowColTypeEnum;
|
|
17
|
-
}({});
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
7
|
//#region src/types/enum.ts
|
|
21
8
|
/**
|
|
22
9
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
@@ -176,23 +163,23 @@ function convertCellDataToString(cellData) {
|
|
|
176
163
|
}
|
|
177
164
|
function getTableFilterState(tableFilter, sortState) {
|
|
178
165
|
if (tableFilter !== void 0 && tableFilter !== null) switch (sortState) {
|
|
179
|
-
case
|
|
180
|
-
case
|
|
181
|
-
default: return
|
|
166
|
+
case "asc": return 2;
|
|
167
|
+
case "desc": return 3;
|
|
168
|
+
default: return 1;
|
|
182
169
|
}
|
|
183
170
|
else switch (sortState) {
|
|
184
|
-
case
|
|
185
|
-
case
|
|
186
|
-
default: return
|
|
171
|
+
case "asc": return 5;
|
|
172
|
+
case "desc": return 6;
|
|
173
|
+
default: return 4;
|
|
187
174
|
}
|
|
188
175
|
}
|
|
189
176
|
function isConditionFilter(filter) {
|
|
190
177
|
if (!filter) return false;
|
|
191
|
-
return filter.filterType ===
|
|
178
|
+
return filter.filterType === "condition";
|
|
192
179
|
}
|
|
193
180
|
function isManualTableFilter(filter) {
|
|
194
181
|
if (!filter) return false;
|
|
195
|
-
return filter.filterType ===
|
|
182
|
+
return filter.filterType === "manual";
|
|
196
183
|
}
|
|
197
184
|
/**
|
|
198
185
|
* Get existing names including sheet names, table names and defined names to check for duplicates table name.
|
|
@@ -320,7 +307,7 @@ const tableThemeConfig = tableDefaultThemeStyleArr.map((item, index) => {
|
|
|
320
307
|
});
|
|
321
308
|
|
|
322
309
|
//#endregion
|
|
323
|
-
//#region \0@oxc-project+runtime@0.
|
|
310
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
|
|
324
311
|
function _typeof(o) {
|
|
325
312
|
"@babel/helpers - typeof";
|
|
326
313
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -331,7 +318,7 @@ function _typeof(o) {
|
|
|
331
318
|
}
|
|
332
319
|
|
|
333
320
|
//#endregion
|
|
334
|
-
//#region \0@oxc-project+runtime@0.
|
|
321
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
|
|
335
322
|
function toPrimitive(t, r) {
|
|
336
323
|
if ("object" != _typeof(t) || !t) return t;
|
|
337
324
|
var e = t[Symbol.toPrimitive];
|
|
@@ -344,14 +331,14 @@ function toPrimitive(t, r) {
|
|
|
344
331
|
}
|
|
345
332
|
|
|
346
333
|
//#endregion
|
|
347
|
-
//#region \0@oxc-project+runtime@0.
|
|
334
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
|
|
348
335
|
function toPropertyKey(t) {
|
|
349
336
|
var i = toPrimitive(t, "string");
|
|
350
337
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
351
338
|
}
|
|
352
339
|
|
|
353
340
|
//#endregion
|
|
354
|
-
//#region \0@oxc-project+runtime@0.
|
|
341
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
|
|
355
342
|
function _defineProperty(e, r, t) {
|
|
356
343
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
357
344
|
value: t,
|
|
@@ -373,7 +360,7 @@ var TableColumn = class {
|
|
|
373
360
|
_defineProperty(this, "style", void 0);
|
|
374
361
|
this.id = id;
|
|
375
362
|
this.displayName = name;
|
|
376
|
-
this.dataType =
|
|
363
|
+
this.dataType = "string";
|
|
377
364
|
this.formula = "";
|
|
378
365
|
this.meta = {};
|
|
379
366
|
this.style = {};
|
|
@@ -763,118 +750,118 @@ const yearToDate = (date, anchorTime = /* @__PURE__ */ new Date()) => {
|
|
|
763
750
|
};
|
|
764
751
|
function getDateFilterExecuteFunc(filterInfo) {
|
|
765
752
|
switch (filterInfo.compareType) {
|
|
766
|
-
case
|
|
753
|
+
case "equal": {
|
|
767
754
|
const expected = new Date(filterInfo.expectedValue);
|
|
768
755
|
return (date) => date.getTime() === expected.getTime();
|
|
769
756
|
}
|
|
770
|
-
case
|
|
757
|
+
case "notEqual": {
|
|
771
758
|
const expected = new Date(filterInfo.expectedValue);
|
|
772
759
|
return (date) => date.getTime() !== expected.getTime();
|
|
773
760
|
}
|
|
774
|
-
case
|
|
761
|
+
case "after": {
|
|
775
762
|
const expected = new Date(filterInfo.expectedValue);
|
|
776
763
|
return (date) => date.getTime() > expected.getTime();
|
|
777
764
|
}
|
|
778
|
-
case
|
|
765
|
+
case "before": {
|
|
779
766
|
const expected = new Date(filterInfo.expectedValue);
|
|
780
767
|
return (date) => date.getTime() < expected.getTime();
|
|
781
768
|
}
|
|
782
|
-
case
|
|
769
|
+
case "afterOrEqual": {
|
|
783
770
|
const expected = new Date(filterInfo.expectedValue);
|
|
784
771
|
return (date) => date.getTime() >= expected.getTime();
|
|
785
772
|
}
|
|
786
|
-
case
|
|
773
|
+
case "beforeOrEqual": {
|
|
787
774
|
const expected = new Date(filterInfo.expectedValue);
|
|
788
775
|
return (date) => date.getTime() <= expected.getTime();
|
|
789
776
|
}
|
|
790
|
-
case
|
|
777
|
+
case "between": return (date) => {
|
|
791
778
|
const [start, end] = filterInfo.expectedValue;
|
|
792
779
|
return date.getTime() >= new Date(start).getTime() && date.getTime() <= new Date(end).getTime();
|
|
793
780
|
};
|
|
794
|
-
case
|
|
781
|
+
case "notBetween": return (date) => {
|
|
795
782
|
const [start, end] = filterInfo.expectedValue;
|
|
796
783
|
return date.getTime() < new Date(start).getTime() || date.getTime() > new Date(end).getTime();
|
|
797
784
|
};
|
|
798
|
-
case
|
|
785
|
+
case "today": {
|
|
799
786
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
800
787
|
return (date) => today(date, anchorTime);
|
|
801
788
|
}
|
|
802
|
-
case
|
|
789
|
+
case "yesterday": {
|
|
803
790
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
804
791
|
return (date) => yesterday(date, anchorTime);
|
|
805
792
|
}
|
|
806
|
-
case
|
|
793
|
+
case "tomorrow": {
|
|
807
794
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
808
795
|
return (date) => tomorrow(date, anchorTime);
|
|
809
796
|
}
|
|
810
|
-
case
|
|
797
|
+
case "thisWeek": {
|
|
811
798
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
812
799
|
return (date) => thisWeek(date, anchorTime);
|
|
813
800
|
}
|
|
814
|
-
case
|
|
801
|
+
case "lastWeek": {
|
|
815
802
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
816
803
|
return (date) => lastWeek(date, anchorTime);
|
|
817
804
|
}
|
|
818
|
-
case
|
|
805
|
+
case "nextWeek": {
|
|
819
806
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
820
807
|
return (date) => nextWeek(date, anchorTime);
|
|
821
808
|
}
|
|
822
|
-
case
|
|
809
|
+
case "thisMonth": {
|
|
823
810
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
824
811
|
return (date) => thisMonth(date, anchorTime);
|
|
825
812
|
}
|
|
826
|
-
case
|
|
813
|
+
case "lastMonth": {
|
|
827
814
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
828
815
|
return (date) => lastMonth(date, anchorTime);
|
|
829
816
|
}
|
|
830
|
-
case
|
|
817
|
+
case "nextMonth": {
|
|
831
818
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
832
819
|
return (date) => nextMonth(date, anchorTime);
|
|
833
820
|
}
|
|
834
|
-
case
|
|
821
|
+
case "thisQuarter": {
|
|
835
822
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
836
823
|
return (date) => thisQuarter(date, anchorTime);
|
|
837
824
|
}
|
|
838
|
-
case
|
|
825
|
+
case "lastQuarter": {
|
|
839
826
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
840
827
|
return (date) => lastQuarter(date, anchorTime);
|
|
841
828
|
}
|
|
842
|
-
case
|
|
829
|
+
case "nextQuarter": {
|
|
843
830
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
844
831
|
return (date) => nextQuarter(date, anchorTime);
|
|
845
832
|
}
|
|
846
|
-
case
|
|
833
|
+
case "thisYear": {
|
|
847
834
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
848
835
|
return (date) => thisYear(date, anchorTime);
|
|
849
836
|
}
|
|
850
|
-
case
|
|
837
|
+
case "lastYear": {
|
|
851
838
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
852
839
|
return (date) => lastYear(date, anchorTime);
|
|
853
840
|
}
|
|
854
|
-
case
|
|
841
|
+
case "nextYear": {
|
|
855
842
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
856
843
|
return (date) => nextYear(date, anchorTime);
|
|
857
844
|
}
|
|
858
|
-
case
|
|
845
|
+
case "yearToDate": {
|
|
859
846
|
const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : /* @__PURE__ */ new Date();
|
|
860
847
|
return (date) => yearToDate(date, anchorTime);
|
|
861
848
|
}
|
|
862
|
-
case
|
|
863
|
-
case
|
|
864
|
-
case
|
|
865
|
-
case
|
|
866
|
-
case
|
|
867
|
-
case
|
|
868
|
-
case
|
|
869
|
-
case
|
|
870
|
-
case
|
|
871
|
-
case
|
|
872
|
-
case
|
|
873
|
-
case
|
|
874
|
-
case
|
|
875
|
-
case
|
|
876
|
-
case
|
|
877
|
-
case
|
|
849
|
+
case "m1": return dateM1;
|
|
850
|
+
case "m2": return dateM2;
|
|
851
|
+
case "m3": return dateM3;
|
|
852
|
+
case "m4": return dateM4;
|
|
853
|
+
case "m5": return dateM5;
|
|
854
|
+
case "m6": return dateM6;
|
|
855
|
+
case "m7": return dateM7;
|
|
856
|
+
case "m8": return dateM8;
|
|
857
|
+
case "m9": return dateM9;
|
|
858
|
+
case "m10": return dateM10;
|
|
859
|
+
case "m11": return dateM11;
|
|
860
|
+
case "m12": return dateM12;
|
|
861
|
+
case "q1": return dateQ1;
|
|
862
|
+
case "q2": return dateQ2;
|
|
863
|
+
case "q3": return dateQ3;
|
|
864
|
+
case "q4": return dateQ4;
|
|
878
865
|
default: throw new Error("Unsupported compare type");
|
|
879
866
|
}
|
|
880
867
|
}
|
|
@@ -1081,53 +1068,53 @@ const getTopN = (list, top, expectedValue) => {
|
|
|
1081
1068
|
};
|
|
1082
1069
|
function getNumberFilterExecuteFunc(filter, calculatedOptions) {
|
|
1083
1070
|
switch (filter.compareType) {
|
|
1084
|
-
case
|
|
1071
|
+
case "equal": {
|
|
1085
1072
|
const expectedValue = Number(filter.expectedValue);
|
|
1086
1073
|
return (value) => value === expectedValue;
|
|
1087
1074
|
}
|
|
1088
|
-
case
|
|
1075
|
+
case "notEqual": {
|
|
1089
1076
|
const expectedValue = Number(filter.expectedValue);
|
|
1090
1077
|
return (value) => value !== expectedValue;
|
|
1091
1078
|
}
|
|
1092
|
-
case
|
|
1079
|
+
case "greaterThan": {
|
|
1093
1080
|
const expectedValue = Number(filter.expectedValue);
|
|
1094
1081
|
return (value) => value > expectedValue;
|
|
1095
1082
|
}
|
|
1096
|
-
case
|
|
1083
|
+
case "greaterThanOrEqual": {
|
|
1097
1084
|
const expectedValue = Number(filter.expectedValue);
|
|
1098
1085
|
return (value) => value >= expectedValue;
|
|
1099
1086
|
}
|
|
1100
|
-
case
|
|
1087
|
+
case "lessThan": {
|
|
1101
1088
|
const expectedValue = Number(filter.expectedValue);
|
|
1102
1089
|
return (value) => value < expectedValue;
|
|
1103
1090
|
}
|
|
1104
|
-
case
|
|
1091
|
+
case "lessThanOrEqual": {
|
|
1105
1092
|
const expectedValue = Number(filter.expectedValue);
|
|
1106
1093
|
return (value) => value <= expectedValue;
|
|
1107
1094
|
}
|
|
1108
|
-
case
|
|
1095
|
+
case "between": {
|
|
1109
1096
|
const [min, max] = filter.expectedValue;
|
|
1110
1097
|
const minValue = Number(min);
|
|
1111
1098
|
const maxValue = Number(max);
|
|
1112
1099
|
if (minValue > maxValue) return (value) => value >= maxValue && value <= minValue;
|
|
1113
1100
|
return (value) => value >= minValue && value <= maxValue;
|
|
1114
1101
|
}
|
|
1115
|
-
case
|
|
1102
|
+
case "notBetween": {
|
|
1116
1103
|
const [min, max] = filter.expectedValue;
|
|
1117
1104
|
const minValue = Number(min);
|
|
1118
1105
|
const maxValue = Number(max);
|
|
1119
1106
|
if (minValue > maxValue) return (value) => value < maxValue || value > minValue;
|
|
1120
1107
|
return (value) => value < minValue || value > maxValue;
|
|
1121
1108
|
}
|
|
1122
|
-
case
|
|
1109
|
+
case "above": {
|
|
1123
1110
|
const average = calculatedOptions.average;
|
|
1124
1111
|
return (value) => above(value, average);
|
|
1125
1112
|
}
|
|
1126
|
-
case
|
|
1113
|
+
case "below": {
|
|
1127
1114
|
const average = calculatedOptions.average;
|
|
1128
1115
|
return (value) => below(value, average);
|
|
1129
1116
|
}
|
|
1130
|
-
case
|
|
1117
|
+
case "topN": {
|
|
1131
1118
|
const list = calculatedOptions.list;
|
|
1132
1119
|
const top = Number(filter.expectedValue);
|
|
1133
1120
|
return (value) => getTopN(list, top, value);
|
|
@@ -1157,12 +1144,12 @@ const textEndWith = (compareValue, expectedValue) => {
|
|
|
1157
1144
|
};
|
|
1158
1145
|
function getTextFilterExecuteFunc(filter) {
|
|
1159
1146
|
switch (filter.compareType) {
|
|
1160
|
-
case
|
|
1161
|
-
case
|
|
1162
|
-
case
|
|
1163
|
-
case
|
|
1164
|
-
case
|
|
1165
|
-
case
|
|
1147
|
+
case "equal": return (value) => textEqual(value, filter.expectedValue);
|
|
1148
|
+
case "notEqual": return (value) => textNotEqual(value, filter.expectedValue);
|
|
1149
|
+
case "contains": return (value) => textContain(value, filter.expectedValue);
|
|
1150
|
+
case "notContains": return (value) => textNotContain(value, filter.expectedValue);
|
|
1151
|
+
case "startsWith": return (value) => textStartWith(value, filter.expectedValue);
|
|
1152
|
+
case "endsWith": return (value) => textEndWith(value, filter.expectedValue);
|
|
1166
1153
|
default:
|
|
1167
1154
|
console.error(`Unknown filter operator: ${filter.compareType}`);
|
|
1168
1155
|
return (value) => true;
|
|
@@ -1172,27 +1159,27 @@ function getTextFilterExecuteFunc(filter) {
|
|
|
1172
1159
|
//#endregion
|
|
1173
1160
|
//#region src/model/filter-util/condition.ts
|
|
1174
1161
|
const NumberDynamicFilterCompareTypeSet = new Set([
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1162
|
+
"above",
|
|
1163
|
+
"below",
|
|
1164
|
+
"topN"
|
|
1178
1165
|
]);
|
|
1179
1166
|
const DateDynamicFilterCompareTypeSet = new Set([
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1167
|
+
"today",
|
|
1168
|
+
"yesterday",
|
|
1169
|
+
"tomorrow",
|
|
1170
|
+
"thisWeek",
|
|
1171
|
+
"lastWeek",
|
|
1172
|
+
"nextWeek",
|
|
1173
|
+
"thisMonth",
|
|
1174
|
+
"lastMonth",
|
|
1175
|
+
"nextMonth",
|
|
1176
|
+
"thisQuarter",
|
|
1177
|
+
"lastQuarter",
|
|
1178
|
+
"nextQuarter",
|
|
1179
|
+
"nextYear",
|
|
1180
|
+
"thisYear",
|
|
1181
|
+
"lastYear",
|
|
1182
|
+
"yearToDate"
|
|
1196
1183
|
]);
|
|
1197
1184
|
function isNumberDynamicFilter(compareType) {
|
|
1198
1185
|
return NumberDynamicFilterCompareTypeSet.has(compareType);
|
|
@@ -1200,21 +1187,21 @@ function isNumberDynamicFilter(compareType) {
|
|
|
1200
1187
|
function getConditionExecuteFunc(filter, calculatedOptions) {
|
|
1201
1188
|
if (isNumberDynamicFilter(filter.filterInfo.compareType)) return (value) => true;
|
|
1202
1189
|
else switch (filter.filterInfo.conditionType) {
|
|
1203
|
-
case
|
|
1204
|
-
case
|
|
1205
|
-
case
|
|
1206
|
-
case
|
|
1190
|
+
case "date": return getDateFilterExecuteFunc(filter.filterInfo);
|
|
1191
|
+
case "number": return getNumberFilterExecuteFunc(filter.filterInfo, calculatedOptions);
|
|
1192
|
+
case "string": return getTextFilterExecuteFunc(filter.filterInfo);
|
|
1193
|
+
case "logic":
|
|
1207
1194
|
default: return (value) => true;
|
|
1208
1195
|
}
|
|
1209
1196
|
}
|
|
1210
1197
|
function getCellValueWithConditionType(sheet, row, col, conditionType) {
|
|
1211
1198
|
switch (conditionType) {
|
|
1212
|
-
case
|
|
1199
|
+
case "date": {
|
|
1213
1200
|
const dateNumber = getNumberCellValue(sheet, row, col);
|
|
1214
1201
|
return dateNumber ? excelSerialToDateTime(dateNumber) : null;
|
|
1215
1202
|
}
|
|
1216
|
-
case
|
|
1217
|
-
case
|
|
1203
|
+
case "number": return getNumberCellValue(sheet, row, col);
|
|
1204
|
+
case "string":
|
|
1218
1205
|
default: return getStringCellValue(sheet, row, col);
|
|
1219
1206
|
}
|
|
1220
1207
|
}
|
|
@@ -1280,7 +1267,7 @@ var TableFilters = class {
|
|
|
1280
1267
|
}
|
|
1281
1268
|
getFilterState(columnIndex) {
|
|
1282
1269
|
var _this$_tableSortInfo;
|
|
1283
|
-
const sortState = ((_this$_tableSortInfo = this._tableSortInfo) === null || _this$_tableSortInfo === void 0 ? void 0 : _this$_tableSortInfo.columnIndex) === columnIndex ? this._tableSortInfo.sortState :
|
|
1270
|
+
const sortState = ((_this$_tableSortInfo = this._tableSortInfo) === null || _this$_tableSortInfo === void 0 ? void 0 : _this$_tableSortInfo.columnIndex) === columnIndex ? this._tableSortInfo.sortState : "none";
|
|
1284
1271
|
return getTableFilterState(this._tableColumnFilterList[columnIndex], sortState);
|
|
1285
1272
|
}
|
|
1286
1273
|
getSortState() {
|
|
@@ -1310,7 +1297,7 @@ var TableFilters = class {
|
|
|
1310
1297
|
const column = startColumn + columnIndex;
|
|
1311
1298
|
const executeFunc = this.getExecuteFunc(sheet, range, columnIndex, filter);
|
|
1312
1299
|
for (let row = startRow; row <= endRow; row++) {
|
|
1313
|
-
const conditionType = isConditionFilter(filter) ? filter.filterInfo.conditionType :
|
|
1300
|
+
const conditionType = isConditionFilter(filter) ? filter.filterInfo.conditionType : "string";
|
|
1314
1301
|
if (getCellValueWithConditionType(sheet, row, column, conditionType) === null) filterOutRows.add(row);
|
|
1315
1302
|
else if (!executeFunc(getCellValueWithConditionType(sheet, row, column, conditionType))) filterOutRows.add(row);
|
|
1316
1303
|
}
|
|
@@ -1323,7 +1310,7 @@ var TableFilters = class {
|
|
|
1323
1310
|
let count = 0;
|
|
1324
1311
|
let sum = 0;
|
|
1325
1312
|
for (let row = startRow; row <= endRow; row++) {
|
|
1326
|
-
const val = getCellValueWithConditionType(sheet, row, column,
|
|
1313
|
+
const val = getCellValueWithConditionType(sheet, row, column, "number");
|
|
1327
1314
|
if (val !== null) {
|
|
1328
1315
|
list.push(val);
|
|
1329
1316
|
count++;
|
|
@@ -1336,12 +1323,12 @@ var TableFilters = class {
|
|
|
1336
1323
|
};
|
|
1337
1324
|
}
|
|
1338
1325
|
getExecuteFunc(sheet, range, columnIndex, filter) {
|
|
1339
|
-
if (filter.filterType ===
|
|
1326
|
+
if (filter.filterType === "manual") {
|
|
1340
1327
|
const valuesSet = new Set(filter.values);
|
|
1341
1328
|
return (value) => {
|
|
1342
1329
|
return valuesSet.has(value);
|
|
1343
1330
|
};
|
|
1344
|
-
} else if (filter.filterType ===
|
|
1331
|
+
} else if (filter.filterType === "condition") return getConditionExecuteFunc(filter, isNumberDynamicFilter(filter.filterInfo.compareType) ? this._getNumberCalculatedOptions(sheet, range, columnIndex) : void 0);
|
|
1345
1332
|
else return (value) => {
|
|
1346
1333
|
return true;
|
|
1347
1334
|
};
|
|
@@ -1590,7 +1577,7 @@ var Table = class {
|
|
|
1590
1577
|
};
|
|
1591
1578
|
|
|
1592
1579
|
//#endregion
|
|
1593
|
-
//#region \0@oxc-project+runtime@0.
|
|
1580
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
|
|
1594
1581
|
function __decorateParam(paramIndex, decorator) {
|
|
1595
1582
|
return function(target, key) {
|
|
1596
1583
|
decorator(target, key, paramIndex);
|
|
@@ -1598,7 +1585,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
1598
1585
|
}
|
|
1599
1586
|
|
|
1600
1587
|
//#endregion
|
|
1601
|
-
//#region \0@oxc-project+runtime@0.
|
|
1588
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
|
|
1602
1589
|
function __decorate(decorators, target, key, desc) {
|
|
1603
1590
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1604
1591
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1799,7 +1786,7 @@ let TableManager = class TableManager extends _univerjs_core.Disposable {
|
|
|
1799
1786
|
const { operationType, rowColType, index, count, columnsJson } = config;
|
|
1800
1787
|
const oldRange = table.getRange();
|
|
1801
1788
|
const newRange = { ...oldRange };
|
|
1802
|
-
if (operationType ===
|
|
1789
|
+
if (operationType === "insert") {
|
|
1803
1790
|
if (rowColType === "row") newRange.endRow += count;
|
|
1804
1791
|
else if (rowColType === "column") {
|
|
1805
1792
|
newRange.endColumn += count;
|
|
@@ -2021,7 +2008,7 @@ let SheetTableService = class SheetTableService extends _univerjs_core.Disposabl
|
|
|
2021
2008
|
addFilter(unitId, tableId, column, filter) {
|
|
2022
2009
|
this._tableManager.addFilter(unitId, tableId, column, filter);
|
|
2023
2010
|
}
|
|
2024
|
-
getCellValueWithConditionType(sheet, row, col, conditionType =
|
|
2011
|
+
getCellValueWithConditionType(sheet, row, col, conditionType = "string") {
|
|
2025
2012
|
return getCellValueWithConditionType(sheet, row, col, conditionType);
|
|
2026
2013
|
}
|
|
2027
2014
|
};
|
|
@@ -2099,12 +2086,15 @@ const AddSheetTableCommand = {
|
|
|
2099
2086
|
unitId: params.unitId
|
|
2100
2087
|
}
|
|
2101
2088
|
});
|
|
2102
|
-
if ((0, _univerjs_core.sequenceExecute)(redos, commandService))
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2089
|
+
if ((0, _univerjs_core.sequenceExecute)(redos, commandService).result) {
|
|
2090
|
+
undoRedoService.pushUndoRedo({
|
|
2091
|
+
unitID: params.unitId,
|
|
2092
|
+
undoMutations: undos,
|
|
2093
|
+
redoMutations: redos
|
|
2094
|
+
});
|
|
2095
|
+
return true;
|
|
2096
|
+
}
|
|
2097
|
+
return false;
|
|
2108
2098
|
}
|
|
2109
2099
|
};
|
|
2110
2100
|
|
|
@@ -2169,12 +2159,15 @@ const AddTableThemeCommand = {
|
|
|
2169
2159
|
styleName: themeStyle.getName()
|
|
2170
2160
|
}
|
|
2171
2161
|
});
|
|
2172
|
-
if ((0, _univerjs_core.sequenceExecute)(redos, accessor.get(_univerjs_core.ICommandService)))
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2162
|
+
if ((0, _univerjs_core.sequenceExecute)(redos, accessor.get(_univerjs_core.ICommandService)).result) {
|
|
2163
|
+
accessor.get(_univerjs_core.IUndoRedoService).pushUndoRedo({
|
|
2164
|
+
unitID: unitId,
|
|
2165
|
+
undoMutations: undos,
|
|
2166
|
+
redoMutations: redos
|
|
2167
|
+
});
|
|
2168
|
+
return true;
|
|
2169
|
+
}
|
|
2170
|
+
return false;
|
|
2178
2171
|
}
|
|
2179
2172
|
};
|
|
2180
2173
|
|
|
@@ -2212,12 +2205,15 @@ const DeleteSheetTableCommand = {
|
|
|
2212
2205
|
options: tableConfig.options
|
|
2213
2206
|
}
|
|
2214
2207
|
});
|
|
2215
|
-
if ((0, _univerjs_core.sequenceExecute)(redos, commandService))
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2208
|
+
if ((0, _univerjs_core.sequenceExecute)(redos, commandService).result) {
|
|
2209
|
+
undoRedoService.pushUndoRedo({
|
|
2210
|
+
unitID: params.unitId,
|
|
2211
|
+
undoMutations: undos,
|
|
2212
|
+
redoMutations: redos
|
|
2213
|
+
});
|
|
2214
|
+
return true;
|
|
2215
|
+
}
|
|
2216
|
+
return false;
|
|
2221
2217
|
}
|
|
2222
2218
|
};
|
|
2223
2219
|
|
|
@@ -2297,12 +2293,15 @@ const RemoveTableThemeCommand = {
|
|
|
2297
2293
|
}
|
|
2298
2294
|
});
|
|
2299
2295
|
}
|
|
2300
|
-
if ((0, _univerjs_core.sequenceExecute)(redos, accessor.get(_univerjs_core.ICommandService)))
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2296
|
+
if ((0, _univerjs_core.sequenceExecute)(redos, accessor.get(_univerjs_core.ICommandService)).result) {
|
|
2297
|
+
accessor.get(_univerjs_core.IUndoRedoService).pushUndoRedo({
|
|
2298
|
+
unitID: unitId,
|
|
2299
|
+
redoMutations: redos,
|
|
2300
|
+
undoMutations: undos
|
|
2301
|
+
});
|
|
2302
|
+
return true;
|
|
2303
|
+
}
|
|
2304
|
+
return false;
|
|
2306
2305
|
}
|
|
2307
2306
|
};
|
|
2308
2307
|
|
|
@@ -2335,7 +2334,7 @@ const SetSheetTableCommand = {
|
|
|
2335
2334
|
}
|
|
2336
2335
|
if (rowColOperation) {
|
|
2337
2336
|
oldTableConfig.rowColOperation = {
|
|
2338
|
-
operationType: rowColOperation.operationType ===
|
|
2337
|
+
operationType: rowColOperation.operationType === "insert" ? "delete" : "insert",
|
|
2339
2338
|
rowColType: rowColOperation.rowColType,
|
|
2340
2339
|
index: rowColOperation.index,
|
|
2341
2340
|
count: rowColOperation.count
|
|
@@ -2416,12 +2415,15 @@ const SetSheetTableFilterCommand = {
|
|
|
2416
2415
|
tableFilter: void 0
|
|
2417
2416
|
}
|
|
2418
2417
|
});
|
|
2419
|
-
if ((0, _univerjs_core.sequenceExecute)(redos, commandService))
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2418
|
+
if ((0, _univerjs_core.sequenceExecute)(redos, commandService).result) {
|
|
2419
|
+
undoRedoService.pushUndoRedo({
|
|
2420
|
+
unitID: params.unitId,
|
|
2421
|
+
undoMutations: undos,
|
|
2422
|
+
redoMutations: redos
|
|
2423
|
+
});
|
|
2424
|
+
return true;
|
|
2425
|
+
}
|
|
2426
|
+
return false;
|
|
2425
2427
|
}
|
|
2426
2428
|
};
|
|
2427
2429
|
|
|
@@ -2779,12 +2781,15 @@ const SheetTableInsertRowCommand = {
|
|
|
2779
2781
|
undos.push(...moveRangeMutations.undos);
|
|
2780
2782
|
}
|
|
2781
2783
|
}
|
|
2782
|
-
if ((0, _univerjs_core.sequenceExecute)(redos, accessor.get(_univerjs_core.ICommandService)))
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2784
|
+
if ((0, _univerjs_core.sequenceExecute)(redos, accessor.get(_univerjs_core.ICommandService)).result) {
|
|
2785
|
+
accessor.get(_univerjs_core.IUndoRedoService).pushUndoRedo({
|
|
2786
|
+
unitID: unitId,
|
|
2787
|
+
undoMutations: undos,
|
|
2788
|
+
redoMutations: redos
|
|
2789
|
+
});
|
|
2790
|
+
return true;
|
|
2791
|
+
}
|
|
2792
|
+
return false;
|
|
2788
2793
|
}
|
|
2789
2794
|
};
|
|
2790
2795
|
const SheetTableInsertColCommand = {
|
|
@@ -2820,8 +2825,8 @@ const SheetTableInsertColCommand = {
|
|
|
2820
2825
|
subUnitId,
|
|
2821
2826
|
tableId: table.getId(),
|
|
2822
2827
|
config: { rowColOperation: {
|
|
2823
|
-
operationType:
|
|
2824
|
-
rowColType:
|
|
2828
|
+
operationType: "insert",
|
|
2829
|
+
rowColType: "column",
|
|
2825
2830
|
index: range.startColumn,
|
|
2826
2831
|
count: insertColCount
|
|
2827
2832
|
} }
|
|
@@ -2834,8 +2839,8 @@ const SheetTableInsertColCommand = {
|
|
|
2834
2839
|
subUnitId,
|
|
2835
2840
|
tableId: table.getId(),
|
|
2836
2841
|
config: { rowColOperation: {
|
|
2837
|
-
operationType:
|
|
2838
|
-
rowColType:
|
|
2842
|
+
operationType: "delete",
|
|
2843
|
+
rowColType: "column",
|
|
2839
2844
|
index: range.startColumn,
|
|
2840
2845
|
count: insertColCount
|
|
2841
2846
|
} }
|
|
@@ -2858,8 +2863,8 @@ const SheetTableInsertColCommand = {
|
|
|
2858
2863
|
subUnitId,
|
|
2859
2864
|
tableId: table.getId(),
|
|
2860
2865
|
config: { rowColOperation: {
|
|
2861
|
-
operationType:
|
|
2862
|
-
rowColType:
|
|
2866
|
+
operationType: "insert",
|
|
2867
|
+
rowColType: "column",
|
|
2863
2868
|
index: range.startColumn,
|
|
2864
2869
|
count: insertColCount
|
|
2865
2870
|
} }
|
|
@@ -2872,8 +2877,8 @@ const SheetTableInsertColCommand = {
|
|
|
2872
2877
|
subUnitId,
|
|
2873
2878
|
tableId: table.getId(),
|
|
2874
2879
|
config: { rowColOperation: {
|
|
2875
|
-
operationType:
|
|
2876
|
-
rowColType:
|
|
2880
|
+
operationType: "delete",
|
|
2881
|
+
rowColType: "column",
|
|
2877
2882
|
index: range.startColumn,
|
|
2878
2883
|
count: insertColCount
|
|
2879
2884
|
} }
|
|
@@ -2903,12 +2908,15 @@ const SheetTableInsertColCommand = {
|
|
|
2903
2908
|
undos.push(...moveRangeMutations.undos);
|
|
2904
2909
|
}
|
|
2905
2910
|
}
|
|
2906
|
-
if ((0, _univerjs_core.sequenceExecute)(redos, accessor.get(_univerjs_core.ICommandService)))
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2911
|
+
if ((0, _univerjs_core.sequenceExecute)(redos, accessor.get(_univerjs_core.ICommandService)).result) {
|
|
2912
|
+
accessor.get(_univerjs_core.IUndoRedoService).pushUndoRedo({
|
|
2913
|
+
unitID: unitId,
|
|
2914
|
+
undoMutations: undos,
|
|
2915
|
+
redoMutations: redos
|
|
2916
|
+
});
|
|
2917
|
+
return true;
|
|
2918
|
+
}
|
|
2919
|
+
return false;
|
|
2912
2920
|
}
|
|
2913
2921
|
};
|
|
2914
2922
|
const SheetTableRemoveRowCommand = {
|
|
@@ -2973,12 +2981,15 @@ const SheetTableRemoveRowCommand = {
|
|
|
2973
2981
|
redos.push(...moveRangeMutations.redos);
|
|
2974
2982
|
undos.push(...moveRangeMutations.undos);
|
|
2975
2983
|
}
|
|
2976
|
-
if ((0, _univerjs_core.sequenceExecute)(redos, accessor.get(_univerjs_core.ICommandService)))
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2984
|
+
if ((0, _univerjs_core.sequenceExecute)(redos, accessor.get(_univerjs_core.ICommandService)).result) {
|
|
2985
|
+
accessor.get(_univerjs_core.IUndoRedoService).pushUndoRedo({
|
|
2986
|
+
unitID: unitId,
|
|
2987
|
+
undoMutations: undos,
|
|
2988
|
+
redoMutations: redos
|
|
2989
|
+
});
|
|
2990
|
+
return true;
|
|
2991
|
+
}
|
|
2992
|
+
return false;
|
|
2982
2993
|
}
|
|
2983
2994
|
};
|
|
2984
2995
|
const SheetTableRemoveColCommand = {
|
|
@@ -3006,8 +3017,8 @@ const SheetTableRemoveColCommand = {
|
|
|
3006
3017
|
subUnitId,
|
|
3007
3018
|
tableId: table.getId(),
|
|
3008
3019
|
config: { rowColOperation: {
|
|
3009
|
-
operationType:
|
|
3010
|
-
rowColType:
|
|
3020
|
+
operationType: "delete",
|
|
3021
|
+
rowColType: "column",
|
|
3011
3022
|
index: range.startColumn,
|
|
3012
3023
|
count: removeColCount
|
|
3013
3024
|
} }
|
|
@@ -3026,8 +3037,8 @@ const SheetTableRemoveColCommand = {
|
|
|
3026
3037
|
subUnitId,
|
|
3027
3038
|
tableId: table.getId(),
|
|
3028
3039
|
config: { rowColOperation: {
|
|
3029
|
-
operationType:
|
|
3030
|
-
rowColType:
|
|
3040
|
+
operationType: "insert",
|
|
3041
|
+
rowColType: "column",
|
|
3031
3042
|
index: range.startColumn,
|
|
3032
3043
|
count: removeColCount,
|
|
3033
3044
|
columnsJson: columns
|
|
@@ -3058,19 +3069,22 @@ const SheetTableRemoveColCommand = {
|
|
|
3058
3069
|
redos.push(...moveRangeMutations.redos);
|
|
3059
3070
|
undos.push(...moveRangeMutations.undos);
|
|
3060
3071
|
}
|
|
3061
|
-
if ((0, _univerjs_core.sequenceExecute)(redos, accessor.get(_univerjs_core.ICommandService)))
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3072
|
+
if ((0, _univerjs_core.sequenceExecute)(redos, accessor.get(_univerjs_core.ICommandService)).result) {
|
|
3073
|
+
accessor.get(_univerjs_core.IUndoRedoService).pushUndoRedo({
|
|
3074
|
+
unitID: unitId,
|
|
3075
|
+
undoMutations: undos,
|
|
3076
|
+
redoMutations: redos
|
|
3077
|
+
});
|
|
3078
|
+
return true;
|
|
3079
|
+
}
|
|
3080
|
+
return false;
|
|
3067
3081
|
}
|
|
3068
3082
|
};
|
|
3069
3083
|
|
|
3070
3084
|
//#endregion
|
|
3071
3085
|
//#region package.json
|
|
3072
3086
|
var name = "@univerjs/sheets-table";
|
|
3073
|
-
var version = "0.
|
|
3087
|
+
var version = "0.22.0";
|
|
3074
3088
|
|
|
3075
3089
|
//#endregion
|
|
3076
3090
|
//#region src/controllers/sheet-table-formula.controller.ts
|
|
@@ -3286,8 +3300,8 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
|
|
|
3286
3300
|
subUnitId,
|
|
3287
3301
|
tableId: table.getId(),
|
|
3288
3302
|
config: { rowColOperation: {
|
|
3289
|
-
operationType:
|
|
3290
|
-
rowColType:
|
|
3303
|
+
operationType: "insert",
|
|
3304
|
+
rowColType: "column",
|
|
3291
3305
|
index: range.startColumn,
|
|
3292
3306
|
count: insertColCount
|
|
3293
3307
|
} }
|
|
@@ -3300,8 +3314,8 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
|
|
|
3300
3314
|
subUnitId,
|
|
3301
3315
|
tableId: table.getId(),
|
|
3302
3316
|
config: { rowColOperation: {
|
|
3303
|
-
operationType:
|
|
3304
|
-
rowColType:
|
|
3317
|
+
operationType: "delete",
|
|
3318
|
+
rowColType: "column",
|
|
3305
3319
|
index: range.startColumn,
|
|
3306
3320
|
count: insertColCount
|
|
3307
3321
|
} }
|
|
@@ -3481,8 +3495,8 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
|
|
|
3481
3495
|
subUnitId,
|
|
3482
3496
|
tableId: table.getId(),
|
|
3483
3497
|
config: { rowColOperation: {
|
|
3484
|
-
operationType:
|
|
3485
|
-
rowColType:
|
|
3498
|
+
operationType: "delete",
|
|
3499
|
+
rowColType: "column",
|
|
3486
3500
|
index: tableRange.startColumn,
|
|
3487
3501
|
count: removeColumnCount
|
|
3488
3502
|
} }
|
|
@@ -3500,8 +3514,8 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
|
|
|
3500
3514
|
subUnitId,
|
|
3501
3515
|
tableId: table.getId(),
|
|
3502
3516
|
config: { rowColOperation: {
|
|
3503
|
-
operationType:
|
|
3504
|
-
rowColType:
|
|
3517
|
+
operationType: "insert",
|
|
3518
|
+
rowColType: "column",
|
|
3505
3519
|
index: tableRange.startColumn,
|
|
3506
3520
|
count: removeColumnCount,
|
|
3507
3521
|
columnsJson: columns
|
|
@@ -3517,8 +3531,8 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
|
|
|
3517
3531
|
subUnitId,
|
|
3518
3532
|
tableId: table.getId(),
|
|
3519
3533
|
config: { rowColOperation: {
|
|
3520
|
-
operationType:
|
|
3521
|
-
rowColType:
|
|
3534
|
+
operationType: "delete",
|
|
3535
|
+
rowColType: "column",
|
|
3522
3536
|
index: range.startColumn,
|
|
3523
3537
|
count: removeColumnCount
|
|
3524
3538
|
} }
|
|
@@ -3537,8 +3551,8 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
|
|
|
3537
3551
|
subUnitId,
|
|
3538
3552
|
tableId: table.getId(),
|
|
3539
3553
|
config: { rowColOperation: {
|
|
3540
|
-
operationType:
|
|
3541
|
-
rowColType:
|
|
3554
|
+
operationType: "insert",
|
|
3555
|
+
rowColType: "column",
|
|
3542
3556
|
index: range.startColumn,
|
|
3543
3557
|
count: removeColCount,
|
|
3544
3558
|
columnsJson: columns
|
|
@@ -3553,8 +3567,8 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
|
|
|
3553
3567
|
subUnitId,
|
|
3554
3568
|
tableId: table.getId(),
|
|
3555
3569
|
config: { rowColOperation: {
|
|
3556
|
-
operationType:
|
|
3557
|
-
rowColType:
|
|
3570
|
+
operationType: "delete",
|
|
3571
|
+
rowColType: "column",
|
|
3558
3572
|
index: range.startColumn,
|
|
3559
3573
|
count: removeColCount
|
|
3560
3574
|
} }
|
|
@@ -3573,8 +3587,8 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
|
|
|
3573
3587
|
subUnitId,
|
|
3574
3588
|
tableId: table.getId(),
|
|
3575
3589
|
config: { rowColOperation: {
|
|
3576
|
-
operationType:
|
|
3577
|
-
rowColType:
|
|
3590
|
+
operationType: "insert",
|
|
3591
|
+
rowColType: "column",
|
|
3578
3592
|
index: range.startColumn,
|
|
3579
3593
|
count: removeColCount,
|
|
3580
3594
|
columnsJson: columns
|