@univerjs/sheets-table 1.0.0-rc.0 → 1.0.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/lib/cjs/facade.js +23 -1
- package/lib/cjs/index.js +484 -74
- package/lib/cjs/locale/ar-SA.js +0 -1
- package/lib/cjs/locale/ca-ES.js +0 -1
- package/lib/cjs/locale/de-DE.js +0 -1
- package/lib/cjs/locale/en-US.js +0 -1
- package/lib/cjs/locale/es-ES.js +0 -1
- package/lib/cjs/locale/fa-IR.js +0 -1
- package/lib/cjs/locale/fr-FR.js +0 -1
- package/lib/cjs/locale/id-ID.js +0 -1
- package/lib/cjs/locale/it-IT.js +0 -1
- package/lib/cjs/locale/ja-JP.js +0 -1
- package/lib/cjs/locale/ko-KR.js +0 -1
- package/lib/cjs/locale/pl-PL.js +0 -1
- package/lib/cjs/locale/pt-BR.js +0 -1
- package/lib/cjs/locale/ru-RU.js +0 -1
- package/lib/cjs/locale/sk-SK.js +0 -1
- package/lib/cjs/locale/vi-VN.js +0 -1
- package/lib/cjs/locale/zh-CN.js +0 -1
- package/lib/cjs/locale/zh-HK.js +0 -1
- package/lib/cjs/locale/zh-TW.js +0 -1
- package/lib/es/facade.js +25 -3
- package/lib/es/index.js +484 -78
- package/lib/facade.js +25 -3
- package/lib/index.js +484 -78
- package/lib/types/commands/mutations/set-table-filter.mutation.d.ts +3 -0
- package/lib/types/commands/utils/calculated-column.d.ts +20 -0
- package/lib/types/controllers/sheet-table-formula.controller.d.ts +4 -1
- package/lib/types/controllers/table-filter.controller.d.ts +4 -1
- package/lib/types/facade/f-enum.d.ts +5 -0
- package/lib/types/facade/f-workbook.d.ts +6 -6
- package/lib/types/facade/f-worksheet.d.ts +22 -3
- package/lib/types/index.d.ts +3 -2
- package/lib/types/models/filter-util/record-filter.d.ts +24 -0
- package/lib/types/models/table-column.d.ts +11 -0
- package/lib/types/models/table-filter.d.ts +1 -0
- package/lib/types/models/table.d.ts +4 -0
- package/lib/types/types/enum.d.ts +2 -1
- package/lib/types/types/type.d.ts +55 -2
- package/lib/types/util.d.ts +2 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BorderStyleTypes, CellValueType, ColorKit, CommandType, DEFAULT_STYLES, DateSystem, DependentOn, Disposable, ICommandService, IConfigService, ILogService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Plugin, RTree, Rectangle, UniverInstanceType, customNameCharacterCheck, excelSerialToDateTime, generateRandomId, getColorStyle, merge, regexp, registerDependencies, sequenceExecute, touchDependencies } from "@univerjs/core";
|
|
2
|
-
import { IDefinedNamesService, RemoveSuperTableMutation, SetSuperTableMutation } from "@univerjs/engine-formula";
|
|
3
|
-
import { AddRangeThemeMutation, CopySheetCommand, IExclusiveRangeService, INTERCEPTOR_POINT, InsertColCommand, InsertColMutation, InsertRowCommand, InsertRowMutation, RangeThemeStyle, RefRangeService, RemoveColCommand, RemoveColMutation, RemoveRangeThemeMutation, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, SheetInterceptorService, SheetRangeThemeModel, SheetRangeThemeService, SheetsSelectionsService, UniverSheetsPlugin, ZebraCrossingCacheController, getMoveRangeUndoRedoMutations, getSheetCommandTarget } from "@univerjs/sheets";
|
|
1
|
+
import { BooleanNumber, BorderStyleTypes, CellValueType, ColorKit, CommandType, DEFAULT_STYLES, DateSystem, DependentOn, Disposable, FilterSelectionMode, FormulaType, ICommandService, IConfigService, ILogService, IPermissionService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Plugin, RTree, RecordValueType, Rectangle, UniverInstanceType, customNameCharacterCheck, excelSerialToDateTime, generateRandomId, getColorStyle, merge, numfmt, regexp, registerDependencies, sequenceExecute, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
|
+
import { IActiveDirtyManagerService, IDefinedNamesService, ISheetRowFilteredService, LexerTreeBuilder, RemoveSuperTableMutation, SetSuperTableMutation, extractFormulaError, serializeRange } from "@univerjs/engine-formula";
|
|
3
|
+
import { AddRangeThemeMutation, CopySheetCommand, IExclusiveRangeService, INTERCEPTOR_POINT, InsertColCommand, InsertColMutation, InsertRowCommand, InsertRowMutation, RangeThemeStyle, RefRangeService, RemoveColCommand, RemoveColMutation, RemoveRangeThemeMutation, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SheetInterceptorService, SheetRangeThemeModel, SheetRangeThemeService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, ZebraCrossingCacheController, checkRangesEditablePermission, getMoveRangeCommandMutations, getMoveRangeUndoRedoMutations, getSheetCommandTarget } from "@univerjs/sheets";
|
|
4
4
|
import { BehaviorSubject, Subject, filter, switchMap } from "rxjs";
|
|
5
5
|
|
|
6
6
|
//#region src/types/enum.ts
|
|
@@ -33,6 +33,7 @@ let TableColumnFilterTypeEnum = /* @__PURE__ */ function(TableColumnFilterTypeEn
|
|
|
33
33
|
TableColumnFilterTypeEnum["manual"] = "manual";
|
|
34
34
|
TableColumnFilterTypeEnum["condition"] = "condition";
|
|
35
35
|
TableColumnFilterTypeEnum["color"] = "color";
|
|
36
|
+
TableColumnFilterTypeEnum["record"] = "record";
|
|
36
37
|
return TableColumnFilterTypeEnum;
|
|
37
38
|
}({});
|
|
38
39
|
let TableConditionTypeEnum = /* @__PURE__ */ function(TableConditionTypeEnum) {
|
|
@@ -185,6 +186,10 @@ function isColorTableFilter(filter) {
|
|
|
185
186
|
if (!filter) return false;
|
|
186
187
|
return filter.filterType === "color";
|
|
187
188
|
}
|
|
189
|
+
function isRecordTableFilter(filter) {
|
|
190
|
+
if (!filter) return false;
|
|
191
|
+
return filter.filterType === "record";
|
|
192
|
+
}
|
|
188
193
|
/**
|
|
189
194
|
* Get existing names including sheet names, table names and defined names to check for duplicates table name.
|
|
190
195
|
*/
|
|
@@ -311,7 +316,7 @@ const tableThemeConfig = tableDefaultThemeStyleArr.map((item, index) => {
|
|
|
311
316
|
});
|
|
312
317
|
|
|
313
318
|
//#endregion
|
|
314
|
-
//#region \0@oxc-project+runtime@0.
|
|
319
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
315
320
|
function _typeof(o) {
|
|
316
321
|
"@babel/helpers - typeof";
|
|
317
322
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -322,7 +327,7 @@ function _typeof(o) {
|
|
|
322
327
|
}
|
|
323
328
|
|
|
324
329
|
//#endregion
|
|
325
|
-
//#region \0@oxc-project+runtime@0.
|
|
330
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
326
331
|
function toPrimitive(t, r) {
|
|
327
332
|
if ("object" != _typeof(t) || !t) return t;
|
|
328
333
|
var e = t[Symbol.toPrimitive];
|
|
@@ -335,14 +340,14 @@ function toPrimitive(t, r) {
|
|
|
335
340
|
}
|
|
336
341
|
|
|
337
342
|
//#endregion
|
|
338
|
-
//#region \0@oxc-project+runtime@0.
|
|
343
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
339
344
|
function toPropertyKey(t) {
|
|
340
345
|
var i = toPrimitive(t, "string");
|
|
341
346
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
342
347
|
}
|
|
343
348
|
|
|
344
349
|
//#endregion
|
|
345
|
-
//#region \0@oxc-project+runtime@0.
|
|
350
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
346
351
|
function _defineProperty(e, r, t) {
|
|
347
352
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
348
353
|
value: t,
|
|
@@ -360,12 +365,18 @@ var TableColumn = class {
|
|
|
360
365
|
_defineProperty(this, "id", void 0);
|
|
361
366
|
_defineProperty(this, "displayName", void 0);
|
|
362
367
|
_defineProperty(this, "formula", void 0);
|
|
368
|
+
_defineProperty(this, "formulaIsArray", void 0);
|
|
369
|
+
_defineProperty(this, "totalsRowLabel", void 0);
|
|
370
|
+
_defineProperty(this, "totalsRowFunction", void 0);
|
|
371
|
+
_defineProperty(this, "totalsRowFormula", void 0);
|
|
372
|
+
_defineProperty(this, "showFilterButton", void 0);
|
|
363
373
|
_defineProperty(this, "meta", void 0);
|
|
364
374
|
_defineProperty(this, "style", void 0);
|
|
365
375
|
this.id = id;
|
|
366
376
|
this.displayName = name;
|
|
367
377
|
this.dataType = "string";
|
|
368
378
|
this.formula = "";
|
|
379
|
+
this.showFilterButton = true;
|
|
369
380
|
this.meta = {};
|
|
370
381
|
this.style = {};
|
|
371
382
|
}
|
|
@@ -384,6 +395,11 @@ var TableColumn = class {
|
|
|
384
395
|
displayName: this.displayName,
|
|
385
396
|
dataType: this.dataType,
|
|
386
397
|
formula: this.formula,
|
|
398
|
+
formulaIsArray: this.formulaIsArray,
|
|
399
|
+
totalsRowLabel: this.totalsRowLabel,
|
|
400
|
+
totalsRowFunction: this.totalsRowFunction,
|
|
401
|
+
totalsRowFormula: this.totalsRowFormula,
|
|
402
|
+
showFilterButton: this.showFilterButton,
|
|
387
403
|
meta: this.meta,
|
|
388
404
|
style: this.style
|
|
389
405
|
};
|
|
@@ -393,9 +409,17 @@ var TableColumn = class {
|
|
|
393
409
|
this.displayName = json.displayName;
|
|
394
410
|
this.dataType = json.dataType;
|
|
395
411
|
this.formula = json.formula;
|
|
412
|
+
this.formulaIsArray = json.formulaIsArray;
|
|
413
|
+
this.totalsRowLabel = json.totalsRowLabel;
|
|
414
|
+
this.totalsRowFunction = json.totalsRowFunction;
|
|
415
|
+
this.totalsRowFormula = json.totalsRowFormula;
|
|
416
|
+
this.showFilterButton = json.showFilterButton ?? true;
|
|
396
417
|
this.meta = json.meta;
|
|
397
418
|
this.style = json.style;
|
|
398
419
|
}
|
|
420
|
+
isShowFilterButton() {
|
|
421
|
+
return this.showFilterButton;
|
|
422
|
+
}
|
|
399
423
|
};
|
|
400
424
|
|
|
401
425
|
//#endregion
|
|
@@ -596,7 +620,7 @@ const getWeekStart = (date) => {
|
|
|
596
620
|
weekStart.setDate(diff);
|
|
597
621
|
return weekStart;
|
|
598
622
|
};
|
|
599
|
-
const perWeek =
|
|
623
|
+
const perWeek = 6048e5;
|
|
600
624
|
/**
|
|
601
625
|
* The provided date is in the current week.
|
|
602
626
|
* @param {Date} date - The date to compare.
|
|
@@ -1223,10 +1247,10 @@ function getConditionExecuteFunc(filter, calculatedOptions) {
|
|
|
1223
1247
|
function getCellValueWithConditionType(sheet, row, col, conditionType, dateSystem = DateSystem.Date1900) {
|
|
1224
1248
|
switch (conditionType) {
|
|
1225
1249
|
case "date": {
|
|
1226
|
-
const dateNumber = getNumberCellValue(sheet, row, col);
|
|
1250
|
+
const dateNumber = getNumberCellValue$1(sheet, row, col);
|
|
1227
1251
|
return dateNumber == null ? null : excelSerialToDateTimeLocal(dateNumber, dateSystem);
|
|
1228
1252
|
}
|
|
1229
|
-
case "number": return getNumberCellValue(sheet, row, col);
|
|
1253
|
+
case "number": return getNumberCellValue$1(sheet, row, col);
|
|
1230
1254
|
case "string":
|
|
1231
1255
|
default: return getStringCellValue(sheet, row, col);
|
|
1232
1256
|
}
|
|
@@ -1252,7 +1276,7 @@ function getStringCellValue(sheet, row, col) {
|
|
|
1252
1276
|
if (v === void 0) return;
|
|
1253
1277
|
return String(v);
|
|
1254
1278
|
}
|
|
1255
|
-
function getNumberCellValue(sheet, row, col) {
|
|
1279
|
+
function getNumberCellValue$1(sheet, row, col) {
|
|
1256
1280
|
const cellData = sheet.getCell(row, col);
|
|
1257
1281
|
if (!cellData) return null;
|
|
1258
1282
|
const { v, t, p } = cellData;
|
|
@@ -1266,17 +1290,124 @@ function excelSerialToDateTimeLocal(serial, dateSystem = DateSystem.Date1900) {
|
|
|
1266
1290
|
return new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate(), utcDate.getUTCHours(), utcDate.getUTCMinutes(), utcDate.getUTCSeconds(), utcDate.getUTCMilliseconds());
|
|
1267
1291
|
}
|
|
1268
1292
|
|
|
1293
|
+
//#endregion
|
|
1294
|
+
//#region src/models/filter-util/record-filter.ts
|
|
1295
|
+
/**
|
|
1296
|
+
* Formula errors are recognized when the cell retains formula, shared-formula, or intercepted array-formula context.
|
|
1297
|
+
*/
|
|
1298
|
+
function getTableRecordValue(sheet, row, column) {
|
|
1299
|
+
const cell = sheet.getCell(row, column);
|
|
1300
|
+
const error = extractFormulaError(cell, (cell === null || cell === void 0 ? void 0 : cell.isInArrayFormulaRange) === true);
|
|
1301
|
+
if (error !== null) return {
|
|
1302
|
+
type: RecordValueType.Error,
|
|
1303
|
+
value: error
|
|
1304
|
+
};
|
|
1305
|
+
if (!cell) return { type: RecordValueType.Blank };
|
|
1306
|
+
if (cell.p) return {
|
|
1307
|
+
type: RecordValueType.String,
|
|
1308
|
+
value: convertCellDataToString(cell)
|
|
1309
|
+
};
|
|
1310
|
+
const value = cell.v;
|
|
1311
|
+
if (value === null || value === void 0) return { type: RecordValueType.Blank };
|
|
1312
|
+
if (cell.t === CellValueType.STRING || cell.t === CellValueType.FORCE_STRING) return {
|
|
1313
|
+
type: RecordValueType.String,
|
|
1314
|
+
value: String(value)
|
|
1315
|
+
};
|
|
1316
|
+
if (cell.t === CellValueType.BOOLEAN) return {
|
|
1317
|
+
type: RecordValueType.Boolean,
|
|
1318
|
+
value: getBooleanValue(value)
|
|
1319
|
+
};
|
|
1320
|
+
if (cell.t === CellValueType.NUMBER || typeof value === "number") {
|
|
1321
|
+
var _sheet$getComposedCel;
|
|
1322
|
+
const numberValue = getFiniteNumberValue(getNumberCellValue(sheet, row, column, value, cell.t === CellValueType.NUMBER, cell.isInArrayFormulaRange === true));
|
|
1323
|
+
const pattern = (_sheet$getComposedCel = sheet.getComposedCellStyleByCellData(row, column, cell).n) === null || _sheet$getComposedCel === void 0 ? void 0 : _sheet$getComposedCel.pattern;
|
|
1324
|
+
return pattern && numfmt.getFormatInfo(pattern).isDate ? {
|
|
1325
|
+
type: RecordValueType.Date,
|
|
1326
|
+
value: numberValue
|
|
1327
|
+
} : {
|
|
1328
|
+
type: RecordValueType.Number,
|
|
1329
|
+
value: numberValue
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
if (typeof value === "boolean") return {
|
|
1333
|
+
type: RecordValueType.Boolean,
|
|
1334
|
+
value
|
|
1335
|
+
};
|
|
1336
|
+
if (typeof value === "string") return {
|
|
1337
|
+
type: RecordValueType.String,
|
|
1338
|
+
value
|
|
1339
|
+
};
|
|
1340
|
+
throw new TypeError("Invalid table record cell value.");
|
|
1341
|
+
}
|
|
1342
|
+
function getTableRecordValueKey(_value) {
|
|
1343
|
+
const value = _value;
|
|
1344
|
+
if (!isRecord(value) || typeof value.type !== "string") throw new TypeError("Invalid table record value.");
|
|
1345
|
+
switch (value.type) {
|
|
1346
|
+
case RecordValueType.Blank:
|
|
1347
|
+
if ("value" in value) throw new TypeError("Blank table record values cannot have a value.");
|
|
1348
|
+
return "[\"blank\"]";
|
|
1349
|
+
case RecordValueType.String:
|
|
1350
|
+
case RecordValueType.Error:
|
|
1351
|
+
if (typeof value.value !== "string") throw new TypeError("Invalid table record value.");
|
|
1352
|
+
return JSON.stringify([value.type, value.value]);
|
|
1353
|
+
case RecordValueType.Boolean:
|
|
1354
|
+
if (typeof value.value !== "boolean") throw new TypeError("Invalid table record value.");
|
|
1355
|
+
return JSON.stringify([value.type, value.value]);
|
|
1356
|
+
case RecordValueType.Number:
|
|
1357
|
+
case RecordValueType.Date:
|
|
1358
|
+
if (typeof value.value !== "number") throw new TypeError("Invalid table record value.");
|
|
1359
|
+
if (!Number.isFinite(value.value)) throw new RangeError("Table record numeric values must be finite.");
|
|
1360
|
+
return JSON.stringify([value.type, value.value === 0 ? 0 : value.value]);
|
|
1361
|
+
default: throw new TypeError("Unknown table record value type.");
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
function compileTableRecordFilter(_filter) {
|
|
1365
|
+
const filter = _filter;
|
|
1366
|
+
if (!isRecord(filter) || filter.filterType !== "record") throw new TypeError("Invalid table record filter.");
|
|
1367
|
+
if (filter.mode !== FilterSelectionMode.Include && filter.mode !== FilterSelectionMode.Exclude || !Array.isArray(filter.values)) throw new TypeError("Invalid table record filter.");
|
|
1368
|
+
const keys = new Set(filter.values.map((value) => getTableRecordValueKey(value)));
|
|
1369
|
+
if (filter.mode === FilterSelectionMode.Include) return (value) => keys.has(getTableRecordValueKey(value));
|
|
1370
|
+
return (value) => !keys.has(getTableRecordValueKey(value));
|
|
1371
|
+
}
|
|
1372
|
+
function cloneTableRecordFilter(filter) {
|
|
1373
|
+
compileTableRecordFilter(filter);
|
|
1374
|
+
return {
|
|
1375
|
+
filterType: "record",
|
|
1376
|
+
mode: filter.mode,
|
|
1377
|
+
values: filter.values.map((value) => value.type === RecordValueType.Blank ? { type: RecordValueType.Blank } : { ...value })
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
function getBooleanValue(value) {
|
|
1381
|
+
if (value === true || value === 1 || typeof value === "string" && value.toUpperCase() === "TRUE") return true;
|
|
1382
|
+
if (value === false || value === 0 || typeof value === "string" && value.toUpperCase() === "FALSE") return false;
|
|
1383
|
+
throw new TypeError("Invalid table record boolean value.");
|
|
1384
|
+
}
|
|
1385
|
+
function getFiniteNumberValue(value) {
|
|
1386
|
+
const numberValue = typeof value === "number" ? value : Number(value);
|
|
1387
|
+
if (!Number.isFinite(numberValue)) throw new RangeError("Table record numeric values must be finite.");
|
|
1388
|
+
return numberValue;
|
|
1389
|
+
}
|
|
1390
|
+
function getNumberCellValue(sheet, row, column, value, isNumberCell, isArrayFormulaCell) {
|
|
1391
|
+
var _sheet$getCellRaw;
|
|
1392
|
+
if (!isNumberCell || isArrayFormulaCell) return value;
|
|
1393
|
+
return ((_sheet$getCellRaw = sheet.getCellRaw(row, column)) === null || _sheet$getCellRaw === void 0 ? void 0 : _sheet$getCellRaw.v) ?? value;
|
|
1394
|
+
}
|
|
1395
|
+
function isRecord(value) {
|
|
1396
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1269
1399
|
//#endregion
|
|
1270
1400
|
//#region src/models/table-filter.ts
|
|
1271
1401
|
var TableFilters = class {
|
|
1272
1402
|
constructor() {
|
|
1273
1403
|
_defineProperty(this, "_tableColumnFilterList", void 0);
|
|
1274
1404
|
_defineProperty(this, "_tableSortInfo", void 0);
|
|
1275
|
-
_defineProperty(this, "_filterOutRows",
|
|
1405
|
+
_defineProperty(this, "_filterOutRows", /* @__PURE__ */ new Set());
|
|
1276
1406
|
this._tableColumnFilterList = [];
|
|
1277
1407
|
}
|
|
1278
1408
|
setColumnFilter(columnIndex, filter) {
|
|
1279
1409
|
if (!filter) this._tableColumnFilterList[columnIndex] = void 0;
|
|
1410
|
+
else if (filter.filterType === "record") this._tableColumnFilterList[columnIndex] = cloneTableRecordFilter(filter);
|
|
1280
1411
|
else this._tableColumnFilterList[columnIndex] = filter;
|
|
1281
1412
|
}
|
|
1282
1413
|
setSortState(columnIndex, sortState) {
|
|
@@ -1289,7 +1420,8 @@ var TableFilters = class {
|
|
|
1289
1420
|
this._tableSortInfo = sortInfo;
|
|
1290
1421
|
}
|
|
1291
1422
|
getColumnFilter(columnIndex) {
|
|
1292
|
-
|
|
1423
|
+
const filter = this._tableColumnFilterList[columnIndex];
|
|
1424
|
+
return (filter === null || filter === void 0 ? void 0 : filter.filterType) === "record" ? cloneTableRecordFilter(filter) : filter;
|
|
1293
1425
|
}
|
|
1294
1426
|
getFilterState(columnIndex) {
|
|
1295
1427
|
var _this$_tableSortInfo;
|
|
@@ -1308,6 +1440,9 @@ var TableFilters = class {
|
|
|
1308
1440
|
getFilterOutRows() {
|
|
1309
1441
|
return this._filterOutRows;
|
|
1310
1442
|
}
|
|
1443
|
+
setFilterOutRows(rows) {
|
|
1444
|
+
this._filterOutRows = new Set(rows);
|
|
1445
|
+
}
|
|
1311
1446
|
doFilter(sheet, range, dateSystem = DateSystem.Date1900) {
|
|
1312
1447
|
const filterOutRows = /* @__PURE__ */ new Set();
|
|
1313
1448
|
const tableColumnFilterList = this._tableColumnFilterList;
|
|
@@ -1320,6 +1455,11 @@ var TableFilters = class {
|
|
|
1320
1455
|
if (filter && sheet) {
|
|
1321
1456
|
const { startRow, endRow, startColumn } = range;
|
|
1322
1457
|
const column = startColumn + columnIndex;
|
|
1458
|
+
if (filter.filterType === "record") {
|
|
1459
|
+
const executeRecordFilter = compileTableRecordFilter(filter);
|
|
1460
|
+
for (let row = startRow; row <= endRow; row++) if (!executeRecordFilter(getTableRecordValue(sheet, row, column))) filterOutRows.add(row);
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1323
1463
|
const executeFunc = this.getExecuteFunc(sheet, range, columnIndex, filter);
|
|
1324
1464
|
for (let row = startRow; row <= endRow; row++) {
|
|
1325
1465
|
if (isColorTableFilter(filter)) {
|
|
@@ -1358,10 +1498,13 @@ var TableFilters = class {
|
|
|
1358
1498
|
const valuesSet = new Set(filter.values);
|
|
1359
1499
|
return (value) => {
|
|
1360
1500
|
if (value == null) return valuesSet.has(TABLE_FILTER_EMPTY_VALUE);
|
|
1361
|
-
return valuesSet.has(value);
|
|
1501
|
+
return valuesSet.has(String(value));
|
|
1362
1502
|
};
|
|
1363
|
-
} else if (filter.filterType === "
|
|
1364
|
-
else if (filter.filterType === "
|
|
1503
|
+
} else if (filter.filterType === "record") return compileTableRecordFilter(filter);
|
|
1504
|
+
else if (filter.filterType === "condition") {
|
|
1505
|
+
const calculatedOptions = isNumberDynamicFilter(filter.filterInfo.compareType) ? this._getNumberCalculatedOptions(sheet, range, columnIndex) : void 0;
|
|
1506
|
+
return getConditionExecuteFunc(filter, calculatedOptions);
|
|
1507
|
+
} else if (filter.filterType === "color") {
|
|
1365
1508
|
const normalizeColor = (color) => color ? new ColorKit(color).toRgbString() : null;
|
|
1366
1509
|
if (filter.cellFillColors) {
|
|
1367
1510
|
const colors = new Set(filter.cellFillColors.map(normalizeColor));
|
|
@@ -1378,16 +1521,21 @@ var TableFilters = class {
|
|
|
1378
1521
|
}
|
|
1379
1522
|
toJSON() {
|
|
1380
1523
|
return {
|
|
1381
|
-
tableColumnFilterList: this._tableColumnFilterList,
|
|
1524
|
+
tableColumnFilterList: this._tableColumnFilterList.some((filter) => (filter === null || filter === void 0 ? void 0 : filter.filterType) === "record") ? this._tableColumnFilterList.map((filter) => (filter === null || filter === void 0 ? void 0 : filter.filterType) === "record" ? cloneTableRecordFilter(filter) : filter) : this._tableColumnFilterList,
|
|
1382
1525
|
tableSortInfo: this._tableSortInfo
|
|
1383
1526
|
};
|
|
1384
1527
|
}
|
|
1385
1528
|
fromJSON(json) {
|
|
1386
|
-
|
|
1529
|
+
const filters = json.tableColumnFilterList ?? [];
|
|
1530
|
+
if (filters.some((filter) => (filter === null || filter === void 0 ? void 0 : filter.filterType) === "record")) {
|
|
1531
|
+
this._tableColumnFilterList = [];
|
|
1532
|
+
filters.forEach((filter, index) => this.setColumnFilter(index, filter));
|
|
1533
|
+
} else this._tableColumnFilterList = filters;
|
|
1387
1534
|
if (json.tableSortInfo) this._tableSortInfo = json.tableSortInfo;
|
|
1388
1535
|
}
|
|
1389
1536
|
dispose() {
|
|
1390
1537
|
this._tableColumnFilterList = [];
|
|
1538
|
+
this._filterOutRows = /* @__PURE__ */ new Set();
|
|
1391
1539
|
}
|
|
1392
1540
|
};
|
|
1393
1541
|
|
|
@@ -1400,6 +1548,7 @@ var Table = class {
|
|
|
1400
1548
|
_defineProperty(this, "_tableStyleId", void 0);
|
|
1401
1549
|
_defineProperty(this, "_showHeader", void 0);
|
|
1402
1550
|
_defineProperty(this, "_showFooter", void 0);
|
|
1551
|
+
_defineProperty(this, "_showAutoFilter", void 0);
|
|
1403
1552
|
_defineProperty(this, "_range", void 0);
|
|
1404
1553
|
_defineProperty(this, "_columns", /* @__PURE__ */ new Map());
|
|
1405
1554
|
_defineProperty(this, "_columnOrder", []);
|
|
@@ -1415,7 +1564,8 @@ var Table = class {
|
|
|
1415
1564
|
_init(header, options) {
|
|
1416
1565
|
this._tableStyleId = options === null || options === void 0 ? void 0 : options.tableStyleId;
|
|
1417
1566
|
this._showHeader = (options === null || options === void 0 ? void 0 : options.showHeader) ?? true;
|
|
1418
|
-
this._showFooter = false;
|
|
1567
|
+
this._showFooter = (options === null || options === void 0 ? void 0 : options.showFooter) ?? false;
|
|
1568
|
+
this._showAutoFilter = (options === null || options === void 0 ? void 0 : options.showAutoFilter) ?? true;
|
|
1419
1569
|
const range = this.getRange();
|
|
1420
1570
|
const startColumn = range.startColumn;
|
|
1421
1571
|
const endColumn = range.endColumn;
|
|
@@ -1540,6 +1690,12 @@ var Table = class {
|
|
|
1540
1690
|
isShowFooter() {
|
|
1541
1691
|
return this._showFooter ?? false;
|
|
1542
1692
|
}
|
|
1693
|
+
isShowAutoFilter() {
|
|
1694
|
+
return this._showAutoFilter ?? true;
|
|
1695
|
+
}
|
|
1696
|
+
setShowAutoFilter(showAutoFilter) {
|
|
1697
|
+
this._showAutoFilter = showAutoFilter;
|
|
1698
|
+
}
|
|
1543
1699
|
getTableInfo() {
|
|
1544
1700
|
return {
|
|
1545
1701
|
id: this._id,
|
|
@@ -1548,6 +1704,7 @@ var Table = class {
|
|
|
1548
1704
|
range: this.getRangeInfo(),
|
|
1549
1705
|
meta: this.tableMeta,
|
|
1550
1706
|
showHeader: this._showHeader,
|
|
1707
|
+
showAutoFilter: this._showAutoFilter,
|
|
1551
1708
|
columns: this._columnOrder.map((columnId) => this._columns.get(columnId).toJSON())
|
|
1552
1709
|
};
|
|
1553
1710
|
}
|
|
@@ -1557,7 +1714,8 @@ var Table = class {
|
|
|
1557
1714
|
range: this.getRangeInfo(),
|
|
1558
1715
|
options: {
|
|
1559
1716
|
showHeader: this._showHeader,
|
|
1560
|
-
showFooter: this._showFooter
|
|
1717
|
+
showFooter: this._showFooter,
|
|
1718
|
+
showAutoFilter: this._showAutoFilter
|
|
1561
1719
|
},
|
|
1562
1720
|
tableStyleId: this._tableStyleId
|
|
1563
1721
|
};
|
|
@@ -1577,6 +1735,7 @@ var Table = class {
|
|
|
1577
1735
|
options: {
|
|
1578
1736
|
showHeader: this._showHeader,
|
|
1579
1737
|
showFooter: this._showFooter,
|
|
1738
|
+
showAutoFilter: this._showAutoFilter,
|
|
1580
1739
|
tableStyleId: this._tableStyleId
|
|
1581
1740
|
},
|
|
1582
1741
|
filters: this._tableFilters.toJSON(),
|
|
@@ -1592,6 +1751,9 @@ var Table = class {
|
|
|
1592
1751
|
this._tableStyleId = json.options.tableStyleId || "";
|
|
1593
1752
|
this._showHeader = json.options.showHeader ?? true;
|
|
1594
1753
|
this._showFooter = json.options.showFooter ?? true;
|
|
1754
|
+
this._showAutoFilter = json.options.showAutoFilter ?? true;
|
|
1755
|
+
this._columns.clear();
|
|
1756
|
+
this._columnOrder = [];
|
|
1595
1757
|
json.columns.forEach((column) => {
|
|
1596
1758
|
const tableColumn = new TableColumn(column.id, column.displayName);
|
|
1597
1759
|
tableColumn.fromJSON(column);
|
|
@@ -1607,6 +1769,7 @@ var Table = class {
|
|
|
1607
1769
|
this._tableStyleId = "";
|
|
1608
1770
|
this._showHeader = true;
|
|
1609
1771
|
this._showFooter = true;
|
|
1772
|
+
this._showAutoFilter = true;
|
|
1610
1773
|
delete this._range;
|
|
1611
1774
|
this._columns.clear();
|
|
1612
1775
|
this._columnOrder = [];
|
|
@@ -1614,7 +1777,7 @@ var Table = class {
|
|
|
1614
1777
|
};
|
|
1615
1778
|
|
|
1616
1779
|
//#endregion
|
|
1617
|
-
//#region \0@oxc-project+runtime@0.
|
|
1780
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
1618
1781
|
function __decorateParam(paramIndex, decorator) {
|
|
1619
1782
|
return function(target, key) {
|
|
1620
1783
|
decorator(target, key, paramIndex);
|
|
@@ -1622,7 +1785,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
1622
1785
|
}
|
|
1623
1786
|
|
|
1624
1787
|
//#endregion
|
|
1625
|
-
//#region \0@oxc-project+runtime@0.
|
|
1788
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
1626
1789
|
function __decorate(decorators, target, key, desc) {
|
|
1627
1790
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1628
1791
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1680,7 +1843,8 @@ let TableManager = class TableManager extends Disposable {
|
|
|
1680
1843
|
*/
|
|
1681
1844
|
addTable(unitId, subUnitId, name, range, header, initId, options) {
|
|
1682
1845
|
const id = initId ?? generateRandomId();
|
|
1683
|
-
const
|
|
1846
|
+
const tableHeader = header || this.getColumnHeader(unitId, subUnitId, range);
|
|
1847
|
+
const table = new Table(id, name, range, tableHeader, options);
|
|
1684
1848
|
table.setSubunitId(subUnitId);
|
|
1685
1849
|
this._ensureUnit(unitId).set(id, table);
|
|
1686
1850
|
this._tableAdd$.next({
|
|
@@ -1729,7 +1893,7 @@ let TableManager = class TableManager extends Disposable {
|
|
|
1729
1893
|
if (!unitMap) return [];
|
|
1730
1894
|
const filterRanges = [];
|
|
1731
1895
|
unitMap.forEach((table) => {
|
|
1732
|
-
if (table.getSubunitId() === subUnitId && table.isShowHeader()) filterRanges.push({
|
|
1896
|
+
if (table.getSubunitId() === subUnitId && table.isShowHeader() && table.isShowAutoFilter()) filterRanges.push({
|
|
1733
1897
|
tableId: table.getId(),
|
|
1734
1898
|
range: table.getRange(),
|
|
1735
1899
|
states: table.getFilterStates(table.getRange())
|
|
@@ -1893,7 +2057,21 @@ let TableManager = class TableManager extends Disposable {
|
|
|
1893
2057
|
const table = unitMap === null || unitMap === void 0 ? void 0 : unitMap.get(tableId);
|
|
1894
2058
|
if (!table) return;
|
|
1895
2059
|
const subUnitId = table.getSubunitId();
|
|
1896
|
-
const { name, updateRange, rowColOperation, theme, sortInfo, options } = config;
|
|
2060
|
+
const { name, updateRange, rowColOperation, theme, sortInfo, options, filterButtons } = config;
|
|
2061
|
+
if (config.calculatedColumn) {
|
|
2062
|
+
const column = table.getColumn(config.calculatedColumn.columnId);
|
|
2063
|
+
if (column) {
|
|
2064
|
+
column.formula = config.calculatedColumn.formula;
|
|
2065
|
+
column.formulaIsArray = config.calculatedColumn.formulaIsArray;
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
if (filterButtons) {
|
|
2069
|
+
if (filterButtons.showAutoFilter !== void 0) table.setShowAutoFilter(filterButtons.showAutoFilter);
|
|
2070
|
+
for (const [columnId, visible] of Object.entries(filterButtons.columns ?? {})) {
|
|
2071
|
+
const column = table.getColumn(columnId);
|
|
2072
|
+
if (column) column.showFilterButton = visible;
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
1897
2075
|
if (name) {
|
|
1898
2076
|
const oldTableName = table.getDisplayName();
|
|
1899
2077
|
table.setDisplayName(name);
|
|
@@ -1957,6 +2135,7 @@ let TableManager = class TableManager extends Disposable {
|
|
|
1957
2135
|
if (data[subUnitId].tables) tables = data[subUnitId].tables;
|
|
1958
2136
|
else if (Array.isArray(data[subUnitId])) tables = data[subUnitId];
|
|
1959
2137
|
if (!tables) return;
|
|
2138
|
+
const cachedFilteredOutRows = data[subUnitId].tableFilteredOutRows;
|
|
1960
2139
|
tables.forEach((table) => {
|
|
1961
2140
|
var _table$options;
|
|
1962
2141
|
const header = this.getColumnHeader(unitId, subUnitId, table.range);
|
|
@@ -1966,7 +2145,10 @@ let TableManager = class TableManager extends Disposable {
|
|
|
1966
2145
|
if (table.filters) {
|
|
1967
2146
|
const tableFilter = tableInstance.getTableFilters();
|
|
1968
2147
|
tableFilter.fromJSON(table.filters);
|
|
1969
|
-
|
|
2148
|
+
if (Array.isArray(cachedFilteredOutRows)) {
|
|
2149
|
+
const { startRow, endRow } = tableInstance.getTableFilterRange();
|
|
2150
|
+
tableFilter.setFilterOutRows(cachedFilteredOutRows.filter((row) => row >= startRow && row <= endRow));
|
|
2151
|
+
} else tableFilter.doFilter(sheet, tableInstance.getTableFilterRange(), target.workbook.getDateSystem());
|
|
1970
2152
|
}
|
|
1971
2153
|
tableInstance.setSubunitId(subUnitId);
|
|
1972
2154
|
unitMap.set(table.id, tableInstance);
|
|
@@ -2198,7 +2380,8 @@ const AddTableThemeCommand = {
|
|
|
2198
2380
|
styleName: themeStyle.getName()
|
|
2199
2381
|
}
|
|
2200
2382
|
});
|
|
2201
|
-
|
|
2383
|
+
const commandService = accessor.get(ICommandService);
|
|
2384
|
+
if (sequenceExecute(redos, commandService).result) {
|
|
2202
2385
|
accessor.get(IUndoRedoService).pushUndoRedo({
|
|
2203
2386
|
unitID: unitId,
|
|
2204
2387
|
undoMutations: undos,
|
|
@@ -2322,7 +2505,8 @@ const RemoveTableThemeCommand = {
|
|
|
2322
2505
|
}
|
|
2323
2506
|
});
|
|
2324
2507
|
}
|
|
2325
|
-
|
|
2508
|
+
const commandService = accessor.get(ICommandService);
|
|
2509
|
+
if (sequenceExecute(redos, commandService).result) {
|
|
2326
2510
|
accessor.get(IUndoRedoService).pushUndoRedo({
|
|
2327
2511
|
unitID: unitId,
|
|
2328
2512
|
redoMutations: redos,
|
|
@@ -2365,6 +2549,91 @@ function validateSheetTableName(name, existingNamesSet) {
|
|
|
2365
2549
|
return { valid: true };
|
|
2366
2550
|
}
|
|
2367
2551
|
|
|
2552
|
+
//#endregion
|
|
2553
|
+
//#region src/commands/utils/calculated-column.ts
|
|
2554
|
+
function getCalculatedColumnFillMutation(table, unitId, subUnitId, startRow, endRow, getLexerTreeBuilder, config) {
|
|
2555
|
+
var _table$getTableInfo;
|
|
2556
|
+
const tableInfo = (_table$getTableInfo = table.getTableInfo) === null || _table$getTableInfo === void 0 ? void 0 : _table$getTableInfo.call(table);
|
|
2557
|
+
if (!tableInfo) return;
|
|
2558
|
+
const firstDataRow = tableInfo.range.startRow + (tableInfo.showHeader ? 1 : 0);
|
|
2559
|
+
const cellValue = {};
|
|
2560
|
+
let lexerTreeBuilder;
|
|
2561
|
+
tableInfo.columns.forEach((column, columnIndex) => {
|
|
2562
|
+
var _ref;
|
|
2563
|
+
if (config && column.id !== config.columnId) return;
|
|
2564
|
+
const formula = (_ref = (config === null || config === void 0 ? void 0 : config.formula) ?? column.formula) === null || _ref === void 0 ? void 0 : _ref.trim();
|
|
2565
|
+
const formulaIsArray = (config === null || config === void 0 ? void 0 : config.formulaIsArray) ?? column.formulaIsArray;
|
|
2566
|
+
if (!formula) return;
|
|
2567
|
+
const baseFormula = normalizeCalculatedColumnFormula(formula.startsWith("=") ? formula : `=${formula}`, tableInfo.name);
|
|
2568
|
+
const sheetColumn = tableInfo.range.startColumn + columnIndex;
|
|
2569
|
+
lexerTreeBuilder ??= getLexerTreeBuilder();
|
|
2570
|
+
for (let row = startRow; row <= endRow; row++) {
|
|
2571
|
+
cellValue[row] ??= {};
|
|
2572
|
+
const cell = {
|
|
2573
|
+
f: lexerTreeBuilder.moveFormulaRefOffset(baseFormula, 0, row - firstDataRow),
|
|
2574
|
+
si: null,
|
|
2575
|
+
ref: null,
|
|
2576
|
+
ft: formulaIsArray ? FormulaType.ARRAY : null,
|
|
2577
|
+
fd: formulaIsArray ? BooleanNumber.FALSE : null,
|
|
2578
|
+
v: null,
|
|
2579
|
+
p: null,
|
|
2580
|
+
t: null
|
|
2581
|
+
};
|
|
2582
|
+
if (formulaIsArray) cell.ref = serializeRange({
|
|
2583
|
+
startRow: row,
|
|
2584
|
+
endRow: row,
|
|
2585
|
+
startColumn: sheetColumn,
|
|
2586
|
+
endColumn: sheetColumn
|
|
2587
|
+
});
|
|
2588
|
+
cellValue[row][sheetColumn] = cell;
|
|
2589
|
+
}
|
|
2590
|
+
});
|
|
2591
|
+
if (!Object.keys(cellValue).length) return;
|
|
2592
|
+
return {
|
|
2593
|
+
id: SetRangeValuesMutation.id,
|
|
2594
|
+
params: {
|
|
2595
|
+
unitId,
|
|
2596
|
+
subUnitId,
|
|
2597
|
+
cellValue
|
|
2598
|
+
}
|
|
2599
|
+
};
|
|
2600
|
+
}
|
|
2601
|
+
function normalizeCalculatedColumnFormula(formula, tableName) {
|
|
2602
|
+
let result = "";
|
|
2603
|
+
for (let index = 0; index < formula.length; index++) {
|
|
2604
|
+
const start = index;
|
|
2605
|
+
const char = formula[index];
|
|
2606
|
+
if (char === "\"" || char === "'") {
|
|
2607
|
+
while (++index < formula.length) if (formula[index] === char) {
|
|
2608
|
+
if (formula[index + 1] !== char) break;
|
|
2609
|
+
index++;
|
|
2610
|
+
}
|
|
2611
|
+
} else if (char === "[") {
|
|
2612
|
+
let depth = 1;
|
|
2613
|
+
while (++index < formula.length && depth > 0) {
|
|
2614
|
+
if (formula[index] === "'") index++;
|
|
2615
|
+
else if (formula[index] === "[") depth++;
|
|
2616
|
+
else if (formula[index] === "]") depth--;
|
|
2617
|
+
if (depth === 0) break;
|
|
2618
|
+
}
|
|
2619
|
+
if (depth === 0) {
|
|
2620
|
+
const body = formula.slice(start + 1, index);
|
|
2621
|
+
const previous = formula.slice(0, start).trimEnd().slice(-1);
|
|
2622
|
+
const unqualified = !previous || /[=+\-*/^&(<>,;:{]/.test(previous);
|
|
2623
|
+
const next = formula.slice(index + 1).trimStart();
|
|
2624
|
+
if (!/^[^+\-*/^&=<>%),;}:\s]/.test(next)) {
|
|
2625
|
+
const prefix = unqualified ? tableName : "";
|
|
2626
|
+
const columns = body.slice(1);
|
|
2627
|
+
result += body.startsWith("@") ? `${prefix}[[#This Row],${columns.startsWith("[") ? columns : `[${columns}]`}]` : `${prefix}[${body}]`;
|
|
2628
|
+
continue;
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
result += formula.slice(start, index + 1);
|
|
2633
|
+
}
|
|
2634
|
+
return result;
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2368
2637
|
//#endregion
|
|
2369
2638
|
//#region src/commands/commands/set-sheet-table.command.ts
|
|
2370
2639
|
const SetSheetTableCommand = {
|
|
@@ -2372,12 +2641,65 @@ const SetSheetTableCommand = {
|
|
|
2372
2641
|
type: CommandType.COMMAND,
|
|
2373
2642
|
handler: (accessor, params) => {
|
|
2374
2643
|
if (!params) return false;
|
|
2375
|
-
const { unitId, tableId, name, updateRange, rowColOperation, theme } = params;
|
|
2644
|
+
const { unitId, tableId, name, updateRange, rowColOperation, theme, filterButtons } = params;
|
|
2376
2645
|
const tableManager = accessor.get(TableManager);
|
|
2377
2646
|
const table = tableManager.getTableById(unitId, tableId);
|
|
2378
2647
|
if (!table) return false;
|
|
2648
|
+
const cellRedos = [];
|
|
2649
|
+
const cellUndos = [];
|
|
2379
2650
|
const oldTableConfig = {};
|
|
2380
2651
|
const newTableConfig = {};
|
|
2652
|
+
if (params.calculatedColumn) {
|
|
2653
|
+
const { columnId, formula, formulaIsArray } = params.calculatedColumn;
|
|
2654
|
+
const column = table.getColumn(columnId);
|
|
2655
|
+
if (!column || typeof formula !== "string" || formulaIsArray !== void 0 && typeof formulaIsArray !== "boolean") return false;
|
|
2656
|
+
if (updateRange || rowColOperation) return false;
|
|
2657
|
+
const range = table.getTableFilterRange();
|
|
2658
|
+
const columnIndex = table.getTableInfo().columns.findIndex((item) => item.id === columnId);
|
|
2659
|
+
const sheetColumn = range.startColumn + columnIndex;
|
|
2660
|
+
const editRange = {
|
|
2661
|
+
...range,
|
|
2662
|
+
startColumn: sheetColumn,
|
|
2663
|
+
endColumn: sheetColumn
|
|
2664
|
+
};
|
|
2665
|
+
if (!checkRangesEditablePermission(accessor, unitId, table.getSubunitId(), [editRange])) return false;
|
|
2666
|
+
const normalized = formula.trim();
|
|
2667
|
+
if (normalized === "=") return false;
|
|
2668
|
+
oldTableConfig.calculatedColumn = {
|
|
2669
|
+
columnId,
|
|
2670
|
+
formula: column.formula,
|
|
2671
|
+
formulaIsArray: column.formulaIsArray
|
|
2672
|
+
};
|
|
2673
|
+
newTableConfig.calculatedColumn = {
|
|
2674
|
+
columnId,
|
|
2675
|
+
formula: normalized && !normalized.startsWith("=") ? `=${normalized}` : normalized,
|
|
2676
|
+
formulaIsArray: normalized ? formulaIsArray ?? column.formulaIsArray : void 0
|
|
2677
|
+
};
|
|
2678
|
+
const fill = getCalculatedColumnFillMutation(table, unitId, table.getSubunitId(), range.startRow, range.endRow, () => accessor.get(LexerTreeBuilder), newTableConfig.calculatedColumn);
|
|
2679
|
+
if (fill) {
|
|
2680
|
+
cellRedos.push(fill);
|
|
2681
|
+
cellUndos.push({
|
|
2682
|
+
id: SetRangeValuesMutation.id,
|
|
2683
|
+
params: SetRangeValuesUndoMutationFactory(accessor, fill.params)
|
|
2684
|
+
});
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
if (filterButtons) {
|
|
2688
|
+
var _accessor$get$getPerm;
|
|
2689
|
+
if (((_accessor$get$getPerm = accessor.get(IPermissionService).getPermissionPoint(new WorkbookEditablePermission(unitId).id)) === null || _accessor$get$getPerm === void 0 ? void 0 : _accessor$get$getPerm.value) === false) return false;
|
|
2690
|
+
const { showAutoFilter, columns } = filterButtons;
|
|
2691
|
+
if (showAutoFilter !== void 0 && typeof showAutoFilter !== "boolean") return false;
|
|
2692
|
+
const entries = Object.entries(columns ?? {});
|
|
2693
|
+
if (entries.some(([id, visible]) => !table.getColumn(id) || typeof visible !== "boolean")) return false;
|
|
2694
|
+
oldTableConfig.filterButtons = {
|
|
2695
|
+
...showAutoFilter === void 0 ? {} : { showAutoFilter: table.isShowAutoFilter() },
|
|
2696
|
+
columns: Object.fromEntries(entries.map(([id]) => [id, table.getColumn(id).isShowFilterButton()]))
|
|
2697
|
+
};
|
|
2698
|
+
newTableConfig.filterButtons = {
|
|
2699
|
+
...showAutoFilter === void 0 ? {} : { showAutoFilter },
|
|
2700
|
+
columns: Object.fromEntries(entries)
|
|
2701
|
+
};
|
|
2702
|
+
}
|
|
2381
2703
|
const localeService = accessor.get(LocaleService);
|
|
2382
2704
|
const existingNamesSet = getExistingNamesSet(unitId, {
|
|
2383
2705
|
univerInstanceService: accessor.get(IUniverInstanceService),
|
|
@@ -2434,6 +2756,7 @@ const SetSheetTableCommand = {
|
|
|
2434
2756
|
id: SetSheetTableMutation.id,
|
|
2435
2757
|
params: redoParams
|
|
2436
2758
|
},
|
|
2759
|
+
...cellRedos,
|
|
2437
2760
|
...interceptorCommands.redos
|
|
2438
2761
|
];
|
|
2439
2762
|
const undos = [
|
|
@@ -2442,12 +2765,11 @@ const SetSheetTableCommand = {
|
|
|
2442
2765
|
id: SetSheetTableMutation.id,
|
|
2443
2766
|
params: undoParams
|
|
2444
2767
|
},
|
|
2768
|
+
...cellUndos,
|
|
2445
2769
|
...interceptorCommands.undos
|
|
2446
2770
|
];
|
|
2447
2771
|
const commandService = accessor.get(ICommandService);
|
|
2448
|
-
|
|
2449
|
-
commandService.executeCommand(mutation.id, mutation.params);
|
|
2450
|
-
});
|
|
2772
|
+
if (!sequenceExecute(redos, commandService).result) return false;
|
|
2451
2773
|
accessor.get(IUndoRedoService).pushUndoRedo({
|
|
2452
2774
|
unitID: unitId,
|
|
2453
2775
|
undoMutations: undos,
|
|
@@ -2464,7 +2786,17 @@ const SetSheetTableFilterMutation = {
|
|
|
2464
2786
|
type: CommandType.MUTATION,
|
|
2465
2787
|
handler: (accessor, params) => {
|
|
2466
2788
|
const { tableId, unitId, column, tableFilter } = params;
|
|
2467
|
-
accessor.get(TableManager)
|
|
2789
|
+
const tableManager = accessor.get(TableManager);
|
|
2790
|
+
const table = tableManager.getTable(unitId, tableId);
|
|
2791
|
+
tableManager.addFilter(unitId, tableId, column, tableFilter);
|
|
2792
|
+
if (table) {
|
|
2793
|
+
var _tableManager$toJSON$;
|
|
2794
|
+
const tableFilters = table.getTableFilters();
|
|
2795
|
+
if (params.filterOutRows) tableFilters.setFilterOutRows(params.filterOutRows);
|
|
2796
|
+
else params.filterOutRows = [...tableFilters.getFilterOutRows()];
|
|
2797
|
+
params.subUnitId = table.getSubunitId();
|
|
2798
|
+
params.tableFilteredOutRows = ((_tableManager$toJSON$ = tableManager.toJSON(unitId)[params.subUnitId]) === null || _tableManager$toJSON$ === void 0 ? void 0 : _tableManager$toJSON$.tableFilteredOutRows) ?? [];
|
|
2799
|
+
}
|
|
2468
2800
|
return true;
|
|
2469
2801
|
}
|
|
2470
2802
|
};
|
|
@@ -2475,20 +2807,24 @@ const SetSheetTableFilterCommand = {
|
|
|
2475
2807
|
id: "sheet.command.set-table-filter",
|
|
2476
2808
|
type: CommandType.COMMAND,
|
|
2477
2809
|
handler: (accessor, params) => {
|
|
2478
|
-
var _tableManager$getTabl;
|
|
2810
|
+
var _tableManager$getTabl, _params$tableFilter;
|
|
2479
2811
|
if (!params) return false;
|
|
2480
2812
|
const undoRedoService = accessor.get(IUndoRedoService);
|
|
2481
2813
|
const commandService = accessor.get(ICommandService);
|
|
2482
2814
|
const tableManager = accessor.get(TableManager);
|
|
2483
2815
|
const tableId = params.tableId || generateRandomId();
|
|
2484
|
-
const
|
|
2816
|
+
const tableFilters = (_tableManager$getTabl = tableManager.getTable(params.unitId, tableId)) === null || _tableManager$getTabl === void 0 ? void 0 : _tableManager$getTabl.getTableFilters();
|
|
2817
|
+
const previousFilter = tableFilters === null || tableFilters === void 0 ? void 0 : tableFilters.getColumnFilter(params.column);
|
|
2818
|
+
const previousFilterOutRows = [...(tableFilters === null || tableFilters === void 0 ? void 0 : tableFilters.getFilterOutRows()) ?? []];
|
|
2819
|
+
const tableFilter = ((_params$tableFilter = params.tableFilter) === null || _params$tableFilter === void 0 ? void 0 : _params$tableFilter.filterType) === "record" ? cloneTableRecordFilter(params.tableFilter) : params.tableFilter;
|
|
2485
2820
|
const redos = [];
|
|
2486
2821
|
const undos = [];
|
|
2487
2822
|
redos.push({
|
|
2488
2823
|
id: SetSheetTableFilterMutation.id,
|
|
2489
2824
|
params: {
|
|
2490
2825
|
...params,
|
|
2491
|
-
tableId
|
|
2826
|
+
tableId,
|
|
2827
|
+
tableFilter
|
|
2492
2828
|
}
|
|
2493
2829
|
});
|
|
2494
2830
|
undos.push({
|
|
@@ -2496,7 +2832,8 @@ const SetSheetTableFilterCommand = {
|
|
|
2496
2832
|
params: {
|
|
2497
2833
|
...params,
|
|
2498
2834
|
tableId,
|
|
2499
|
-
tableFilter: previousFilter
|
|
2835
|
+
tableFilter: previousFilter,
|
|
2836
|
+
filterOutRows: previousFilterOutRows
|
|
2500
2837
|
}
|
|
2501
2838
|
});
|
|
2502
2839
|
if (sequenceExecute(redos, commandService).result) {
|
|
@@ -2557,9 +2894,9 @@ let SheetsTableController = class SheetsTableController extends Disposable {
|
|
|
2557
2894
|
this._tableManager = _tableManager;
|
|
2558
2895
|
this._resourceManagerService = _resourceManagerService;
|
|
2559
2896
|
_defineProperty(this, "_tableRangeRTree", /* @__PURE__ */ new Map());
|
|
2897
|
+
this.registerTableChangeEvent();
|
|
2560
2898
|
this._initSnapshot();
|
|
2561
2899
|
this._initSheetChange();
|
|
2562
|
-
this.registerTableChangeEvent();
|
|
2563
2900
|
this.registerTableHeaderInterceptor();
|
|
2564
2901
|
}
|
|
2565
2902
|
getContainerTableWithRange(unitId, subUnitId, range) {
|
|
@@ -2799,7 +3136,8 @@ SheetsTableController = __decorate([
|
|
|
2799
3136
|
//#endregion
|
|
2800
3137
|
//#region src/commands/commands/sheet-table-row-col.command.ts
|
|
2801
3138
|
function executeTableMutationSequence(accessor, unitId, redos, undos) {
|
|
2802
|
-
|
|
3139
|
+
const commandService = accessor.get(ICommandService);
|
|
3140
|
+
if (sequenceExecute(redos, commandService).result) {
|
|
2803
3141
|
accessor.get(IUndoRedoService).pushUndoRedo({
|
|
2804
3142
|
unitID: unitId,
|
|
2805
3143
|
undoMutations: undos,
|
|
@@ -2813,12 +3151,12 @@ const SheetTableInsertRowCommand = {
|
|
|
2813
3151
|
id: "sheet.command.table-insert-row",
|
|
2814
3152
|
type: CommandType.COMMAND,
|
|
2815
3153
|
handler: (accessor) => {
|
|
2816
|
-
const
|
|
3154
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
3155
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
2817
3156
|
if (!target) return false;
|
|
2818
|
-
const {
|
|
3157
|
+
const { worksheet, unitId, subUnitId } = target;
|
|
2819
3158
|
const selections = accessor.get(SheetsSelectionsService).getCurrentSelections();
|
|
2820
3159
|
if (!selections.length || selections.length > 1) return false;
|
|
2821
|
-
accessor.get(TableManager);
|
|
2822
3160
|
const range = selections[0].range;
|
|
2823
3161
|
const table = accessor.get(SheetsTableController).getContainerTableWithRange(unitId, subUnitId, range);
|
|
2824
3162
|
if (!table) return false;
|
|
@@ -2888,31 +3226,41 @@ const SheetTableInsertRowCommand = {
|
|
|
2888
3226
|
config: { updateRange: { newRange: { ...oldRange } } }
|
|
2889
3227
|
}
|
|
2890
3228
|
});
|
|
2891
|
-
const moveRangeMutations =
|
|
2892
|
-
unitId,
|
|
2893
|
-
subUnitId,
|
|
2894
|
-
|
|
3229
|
+
const moveRangeMutations = getMoveRangeCommandMutations(accessor, {
|
|
3230
|
+
fromUnitId: unitId,
|
|
3231
|
+
fromSubUnitId: subUnitId,
|
|
3232
|
+
toSubUnitId: subUnitId,
|
|
3233
|
+
fromRange: {
|
|
2895
3234
|
startRow: range.startRow,
|
|
2896
3235
|
endRow: rowContentIndex,
|
|
2897
3236
|
startColumn: oldRange.startColumn,
|
|
2898
3237
|
endColumn: oldRange.endColumn
|
|
2899
|
-
}
|
|
2900
|
-
|
|
2901
|
-
unitId,
|
|
2902
|
-
subUnitId,
|
|
2903
|
-
range: {
|
|
3238
|
+
},
|
|
3239
|
+
toRange: {
|
|
2904
3240
|
startRow: range.startRow + insertRowCount,
|
|
2905
3241
|
endRow: rowContentIndex + insertRowCount,
|
|
2906
3242
|
startColumn: oldRange.startColumn,
|
|
2907
3243
|
endColumn: oldRange.endColumn
|
|
2908
3244
|
}
|
|
3245
|
+
}, {
|
|
3246
|
+
includeSelection: false,
|
|
3247
|
+
includeAutoHeight: false
|
|
2909
3248
|
});
|
|
2910
3249
|
if (moveRangeMutations) {
|
|
2911
3250
|
redos.push(...moveRangeMutations.redos);
|
|
2912
3251
|
undos.push(...moveRangeMutations.undos);
|
|
2913
3252
|
}
|
|
2914
3253
|
}
|
|
2915
|
-
|
|
3254
|
+
const formulaMutation = getCalculatedColumnFillMutation(table, unitId, subUnitId, range.startRow, range.endRow, () => accessor.get(LexerTreeBuilder));
|
|
3255
|
+
if (formulaMutation) {
|
|
3256
|
+
redos.push(formulaMutation);
|
|
3257
|
+
undos.push({
|
|
3258
|
+
id: SetRangeValuesMutation.id,
|
|
3259
|
+
params: SetRangeValuesUndoMutationFactory(accessor, formulaMutation.params)
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
3262
|
+
const commandService = accessor.get(ICommandService);
|
|
3263
|
+
if (sequenceExecute(redos, commandService).result) {
|
|
2916
3264
|
accessor.get(IUndoRedoService).pushUndoRedo({
|
|
2917
3265
|
unitID: unitId,
|
|
2918
3266
|
undoMutations: undos,
|
|
@@ -2930,7 +3278,8 @@ const SheetTableInsertRowAtCommand = {
|
|
|
2930
3278
|
if (!params) return false;
|
|
2931
3279
|
const { unitId, subUnitId, tableId, index, count = 1 } = params;
|
|
2932
3280
|
if (count <= 0) return false;
|
|
2933
|
-
const
|
|
3281
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
3282
|
+
const target = getSheetCommandTarget(univerInstanceService, {
|
|
2934
3283
|
unitId,
|
|
2935
3284
|
subUnitId
|
|
2936
3285
|
});
|
|
@@ -2961,29 +3310,38 @@ const SheetTableInsertRowAtCommand = {
|
|
|
2961
3310
|
}
|
|
2962
3311
|
}];
|
|
2963
3312
|
const rowContentIndex = target.worksheet.getCellMatrix().getDataRange().endRow;
|
|
2964
|
-
const moveRangeMutations =
|
|
2965
|
-
unitId,
|
|
2966
|
-
subUnitId,
|
|
2967
|
-
|
|
3313
|
+
const moveRangeMutations = index <= rowContentIndex ? getMoveRangeCommandMutations(accessor, {
|
|
3314
|
+
fromUnitId: unitId,
|
|
3315
|
+
fromSubUnitId: subUnitId,
|
|
3316
|
+
toSubUnitId: subUnitId,
|
|
3317
|
+
fromRange: {
|
|
2968
3318
|
startRow: index,
|
|
2969
3319
|
endRow: rowContentIndex,
|
|
2970
3320
|
startColumn: oldRange.startColumn,
|
|
2971
3321
|
endColumn: oldRange.endColumn
|
|
2972
|
-
}
|
|
2973
|
-
|
|
2974
|
-
unitId,
|
|
2975
|
-
subUnitId,
|
|
2976
|
-
range: {
|
|
3322
|
+
},
|
|
3323
|
+
toRange: {
|
|
2977
3324
|
startRow: index + count,
|
|
2978
3325
|
endRow: rowContentIndex + count,
|
|
2979
3326
|
startColumn: oldRange.startColumn,
|
|
2980
3327
|
endColumn: oldRange.endColumn
|
|
2981
3328
|
}
|
|
2982
|
-
}
|
|
3329
|
+
}, {
|
|
3330
|
+
includeSelection: false,
|
|
3331
|
+
includeAutoHeight: false
|
|
3332
|
+
}) : null;
|
|
2983
3333
|
if (moveRangeMutations) {
|
|
2984
3334
|
redos.push(...moveRangeMutations.redos);
|
|
2985
3335
|
undos.push(...moveRangeMutations.undos);
|
|
2986
3336
|
}
|
|
3337
|
+
const formulaMutation = getCalculatedColumnFillMutation(table, unitId, subUnitId, index, index + count - 1, () => accessor.get(LexerTreeBuilder));
|
|
3338
|
+
if (formulaMutation) {
|
|
3339
|
+
redos.push(formulaMutation);
|
|
3340
|
+
undos.push({
|
|
3341
|
+
id: SetRangeValuesMutation.id,
|
|
3342
|
+
params: SetRangeValuesUndoMutationFactory(accessor, formulaMutation.params)
|
|
3343
|
+
});
|
|
3344
|
+
}
|
|
2987
3345
|
return executeTableMutationSequence(accessor, unitId, redos, undos);
|
|
2988
3346
|
}
|
|
2989
3347
|
};
|
|
@@ -2991,7 +3349,8 @@ const SheetTableInsertColCommand = {
|
|
|
2991
3349
|
id: "sheet.command.table-insert-col",
|
|
2992
3350
|
type: CommandType.COMMAND,
|
|
2993
3351
|
handler: (accessor) => {
|
|
2994
|
-
const
|
|
3352
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
3353
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
2995
3354
|
if (!target) return false;
|
|
2996
3355
|
const { worksheet, unitId, subUnitId } = target;
|
|
2997
3356
|
const selections = accessor.get(SheetsSelectionsService).getCurrentSelections();
|
|
@@ -3103,7 +3462,8 @@ const SheetTableInsertColCommand = {
|
|
|
3103
3462
|
undos.push(...moveRangeMutations.undos);
|
|
3104
3463
|
}
|
|
3105
3464
|
}
|
|
3106
|
-
|
|
3465
|
+
const commandService = accessor.get(ICommandService);
|
|
3466
|
+
if (sequenceExecute(redos, commandService).result) {
|
|
3107
3467
|
accessor.get(IUndoRedoService).pushUndoRedo({
|
|
3108
3468
|
unitID: unitId,
|
|
3109
3469
|
undoMutations: undos,
|
|
@@ -3121,7 +3481,8 @@ const SheetTableInsertColumnAtCommand = {
|
|
|
3121
3481
|
if (!params) return false;
|
|
3122
3482
|
const { unitId, subUnitId, tableId, index, count = 1 } = params;
|
|
3123
3483
|
if (count <= 0) return false;
|
|
3124
|
-
const
|
|
3484
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
3485
|
+
const target = getSheetCommandTarget(univerInstanceService, {
|
|
3125
3486
|
unitId,
|
|
3126
3487
|
subUnitId
|
|
3127
3488
|
});
|
|
@@ -3194,7 +3555,8 @@ const SheetTableRemoveColumnAtCommand = {
|
|
|
3194
3555
|
if (!params) return false;
|
|
3195
3556
|
const { unitId, subUnitId, tableId, index, count = 1 } = params;
|
|
3196
3557
|
if (count <= 0) return false;
|
|
3197
|
-
const
|
|
3558
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
3559
|
+
const target = getSheetCommandTarget(univerInstanceService, {
|
|
3198
3560
|
unitId,
|
|
3199
3561
|
subUnitId
|
|
3200
3562
|
});
|
|
@@ -3289,7 +3651,8 @@ const SheetTableRemoveRowCommand = {
|
|
|
3289
3651
|
type: CommandType.COMMAND,
|
|
3290
3652
|
handler: (accessor, params) => {
|
|
3291
3653
|
if (!params) return false;
|
|
3292
|
-
const
|
|
3654
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
3655
|
+
const target = getSheetCommandTarget(univerInstanceService, params);
|
|
3293
3656
|
if (!target) return false;
|
|
3294
3657
|
const { unitId, subUnitId } = target;
|
|
3295
3658
|
const selections = accessor.get(SheetsSelectionsService).getCurrentSelections();
|
|
@@ -3346,7 +3709,8 @@ const SheetTableRemoveRowCommand = {
|
|
|
3346
3709
|
redos.push(...moveRangeMutations.redos);
|
|
3347
3710
|
undos.push(...moveRangeMutations.undos);
|
|
3348
3711
|
}
|
|
3349
|
-
|
|
3712
|
+
const commandService = accessor.get(ICommandService);
|
|
3713
|
+
if (sequenceExecute(redos, commandService).result) {
|
|
3350
3714
|
accessor.get(IUndoRedoService).pushUndoRedo({
|
|
3351
3715
|
unitID: unitId,
|
|
3352
3716
|
undoMutations: undos,
|
|
@@ -3362,7 +3726,8 @@ const SheetTableRemoveColCommand = {
|
|
|
3362
3726
|
type: CommandType.COMMAND,
|
|
3363
3727
|
handler: (accessor, params) => {
|
|
3364
3728
|
if (!params) return false;
|
|
3365
|
-
const
|
|
3729
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
3730
|
+
const target = getSheetCommandTarget(univerInstanceService, params);
|
|
3366
3731
|
if (!target) return false;
|
|
3367
3732
|
const { workbook, unitId, subUnitId } = target;
|
|
3368
3733
|
accessor.get(TableManager);
|
|
@@ -3447,7 +3812,8 @@ const SheetTableRemoveColCommand = {
|
|
|
3447
3812
|
redos.push(...moveRangeMutations.redos);
|
|
3448
3813
|
undos.push(...moveRangeMutations.undos);
|
|
3449
3814
|
}
|
|
3450
|
-
|
|
3815
|
+
const commandService = accessor.get(ICommandService);
|
|
3816
|
+
if (sequenceExecute(redos, commandService).result) {
|
|
3451
3817
|
accessor.get(IUndoRedoService).pushUndoRedo({
|
|
3452
3818
|
unitID: unitId,
|
|
3453
3819
|
undoMutations: undos,
|
|
@@ -3558,16 +3924,40 @@ SheetsTableThemeController = __decorate([
|
|
|
3558
3924
|
//#endregion
|
|
3559
3925
|
//#region package.json
|
|
3560
3926
|
var name = "@univerjs/sheets-table";
|
|
3561
|
-
var version = "1.0.
|
|
3927
|
+
var version = "1.0.1";
|
|
3562
3928
|
|
|
3563
3929
|
//#endregion
|
|
3564
3930
|
//#region src/controllers/sheet-table-formula.controller.ts
|
|
3565
3931
|
let SheetTableFormulaController = class SheetTableFormulaController extends Disposable {
|
|
3566
|
-
constructor(_tableManager, _commandService) {
|
|
3932
|
+
constructor(_tableManager, _commandService, _activeDirtyManagerService) {
|
|
3567
3933
|
super();
|
|
3568
3934
|
this._tableManager = _tableManager;
|
|
3569
3935
|
this._commandService = _commandService;
|
|
3936
|
+
this._activeDirtyManagerService = _activeDirtyManagerService;
|
|
3570
3937
|
this._initRangeListener();
|
|
3938
|
+
this._initFilterDirtyRange();
|
|
3939
|
+
}
|
|
3940
|
+
_initFilterDirtyRange() {
|
|
3941
|
+
this._activeDirtyManagerService.register(SetSheetTableFilterMutation.id, {
|
|
3942
|
+
commandId: SetSheetTableFilterMutation.id,
|
|
3943
|
+
getDirtyData: (command) => {
|
|
3944
|
+
const params = command.params;
|
|
3945
|
+
const table = this._tableManager.getTableById(params.unitId, params.tableId);
|
|
3946
|
+
if (!table) return {};
|
|
3947
|
+
const { subUnitId, range } = table.getTableInfo();
|
|
3948
|
+
return {
|
|
3949
|
+
dirtyRanges: [{
|
|
3950
|
+
unitId: params.unitId,
|
|
3951
|
+
sheetId: subUnitId,
|
|
3952
|
+
range
|
|
3953
|
+
}],
|
|
3954
|
+
clearDependencyTreeCache: { [params.unitId]: { [subUnitId]: "1" } }
|
|
3955
|
+
};
|
|
3956
|
+
}
|
|
3957
|
+
});
|
|
3958
|
+
this.disposeWithMe(toDisposable(() => {
|
|
3959
|
+
this._activeDirtyManagerService.remove(SetSheetTableFilterMutation.id);
|
|
3960
|
+
}));
|
|
3571
3961
|
}
|
|
3572
3962
|
_initRangeListener() {
|
|
3573
3963
|
this.disposeWithMe(this._tableManager.tableRangeChanged$.subscribe((event) => {
|
|
@@ -3624,7 +4014,11 @@ let SheetTableFormulaController = class SheetTableFormulaController extends Disp
|
|
|
3624
4014
|
}, { onlyLocal: true });
|
|
3625
4015
|
}
|
|
3626
4016
|
};
|
|
3627
|
-
SheetTableFormulaController = __decorate([
|
|
4017
|
+
SheetTableFormulaController = __decorate([
|
|
4018
|
+
__decorateParam(0, Inject(TableManager)),
|
|
4019
|
+
__decorateParam(1, ICommandService),
|
|
4020
|
+
__decorateParam(2, IActiveDirtyManagerService)
|
|
4021
|
+
], SheetTableFormulaController);
|
|
3628
4022
|
|
|
3629
4023
|
//#endregion
|
|
3630
4024
|
//#region src/controllers/sheet-table-range.controller.ts
|
|
@@ -3742,6 +4136,8 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends Di
|
|
|
3742
4136
|
} } }
|
|
3743
4137
|
}
|
|
3744
4138
|
});
|
|
4139
|
+
const formulaMutation = getCalculatedColumnFillMutation(table, unitId, subUnitId, range.startRow, range.endRow, () => this._injector.get(LexerTreeBuilder));
|
|
4140
|
+
if (formulaMutation) redos.push(formulaMutation);
|
|
3745
4141
|
undos.push({
|
|
3746
4142
|
id: SetSheetTableMutation.id,
|
|
3747
4143
|
params: {
|
|
@@ -4198,18 +4594,25 @@ SheetTableRefRangeController = __decorate([
|
|
|
4198
4594
|
//#endregion
|
|
4199
4595
|
//#region src/controllers/table-filter.controller.ts
|
|
4200
4596
|
let TableFilterController = class TableFilterController extends Disposable {
|
|
4201
|
-
constructor(_tableManager, _sheetInterceptorService, _univerInstanceService, _zebraCrossingCacheController) {
|
|
4597
|
+
constructor(_tableManager, _sheetInterceptorService, _univerInstanceService, _sheetRowFilteredService, _zebraCrossingCacheController) {
|
|
4202
4598
|
super();
|
|
4203
4599
|
this._tableManager = _tableManager;
|
|
4204
4600
|
this._sheetInterceptorService = _sheetInterceptorService;
|
|
4205
4601
|
this._univerInstanceService = _univerInstanceService;
|
|
4602
|
+
this._sheetRowFilteredService = _sheetRowFilteredService;
|
|
4206
4603
|
this._zebraCrossingCacheController = _zebraCrossingCacheController;
|
|
4207
4604
|
_defineProperty(this, "_tableFilteredOutRows", /* @__PURE__ */ new Map());
|
|
4208
4605
|
_defineProperty(this, "_subscription", null);
|
|
4209
4606
|
this.registerFilterChangeEvent();
|
|
4210
4607
|
this.initTableHiddenRowIntercept();
|
|
4608
|
+
this._registerFormulaRowFiltered();
|
|
4211
4609
|
this._initFilteredOutRows();
|
|
4212
4610
|
}
|
|
4611
|
+
_registerFormulaRowFiltered() {
|
|
4612
|
+
this.disposeWithMe(this._sheetRowFilteredService.register((unitId, subUnitId, row) => {
|
|
4613
|
+
return this._getTableFilteredOutRows(unitId, subUnitId).has(row);
|
|
4614
|
+
}));
|
|
4615
|
+
}
|
|
4213
4616
|
initTableHiddenRowIntercept() {
|
|
4214
4617
|
this.disposeWithMe(this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.ROW_FILTERED, {
|
|
4215
4618
|
priority: 100,
|
|
@@ -4252,7 +4655,9 @@ let TableFilterController = class TableFilterController extends Disposable {
|
|
|
4252
4655
|
this._tableFilteredOutRows.set(this._getSheetKey(unitId, subUnitId), filteredOutRows);
|
|
4253
4656
|
}
|
|
4254
4657
|
_getTableFilteredOutRows(unitId, subUnitId) {
|
|
4255
|
-
|
|
4658
|
+
const key = this._getSheetKey(unitId, subUnitId);
|
|
4659
|
+
if (!this._tableFilteredOutRows.has(key)) this._refreshTableFilteredOutRows(unitId, subUnitId);
|
|
4660
|
+
return this._tableFilteredOutRows.get(key) ?? /* @__PURE__ */ new Set();
|
|
4256
4661
|
}
|
|
4257
4662
|
_getSheetKey(unitId, subUnitId) {
|
|
4258
4663
|
return `${unitId}|${subUnitId}`;
|
|
@@ -4267,7 +4672,8 @@ TableFilterController = __decorate([
|
|
|
4267
4672
|
__decorateParam(0, Inject(TableManager)),
|
|
4268
4673
|
__decorateParam(1, Inject(SheetInterceptorService)),
|
|
4269
4674
|
__decorateParam(2, Inject(IUniverInstanceService)),
|
|
4270
|
-
__decorateParam(3, Inject(
|
|
4675
|
+
__decorateParam(3, Inject(ISheetRowFilteredService)),
|
|
4676
|
+
__decorateParam(4, Inject(ZebraCrossingCacheController))
|
|
4271
4677
|
], TableFilterController);
|
|
4272
4678
|
|
|
4273
4679
|
//#endregion
|
|
@@ -4342,4 +4748,4 @@ UniverSheetsTablePlugin = __decorate([
|
|
|
4342
4748
|
], UniverSheetsTablePlugin);
|
|
4343
4749
|
|
|
4344
4750
|
//#endregion
|
|
4345
|
-
export { AddSheetTableCommand, AddSheetTableMutation, AddTableThemeCommand, DeleteSheetTableCommand, DeleteSheetTableMutation, RemoveTableThemeCommand, SHEET_TABLE_CUSTOM_THEME_PREFIX, SetSheetTableCommand, SetSheetTableFilterCommand, SetSheetTableFilterMutation, SetSheetTableMutation, SetSheetTableSortStateCommand, SheetTableInsertColCommand, SheetTableInsertColumnAtCommand, SheetTableInsertRowAtCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveColumnAtCommand, SheetTableRemoveRowCommand, SheetTableService, SheetsTableButtonStateEnum, SheetsTableController, SheetsTableSortStateEnum, SheetsTableThemeController, TABLE_FILTER_EMPTY_VALUE, TableColumnDataTypeEnum, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableManager, TableNumberCompareTypeEnum, TableStringCompareTypeEnum, UniverSheetsTablePlugin, customEmptyThemeWithBorderStyle, getExistingNamesSet, isColorTableFilter, isConditionFilter, isManualTableFilter, processStyleWithBorderStyle, validateSheetTableName };
|
|
4751
|
+
export { AddSheetTableCommand, AddSheetTableMutation, AddTableThemeCommand, DeleteSheetTableCommand, DeleteSheetTableMutation, RemoveTableThemeCommand, SHEET_TABLE_CUSTOM_THEME_PREFIX, SetSheetTableCommand, SetSheetTableFilterCommand, SetSheetTableFilterMutation, SetSheetTableMutation, SetSheetTableSortStateCommand, SheetTableInsertColCommand, SheetTableInsertColumnAtCommand, SheetTableInsertRowAtCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveColumnAtCommand, SheetTableRemoveRowCommand, SheetTableService, SheetsTableButtonStateEnum, SheetsTableController, SheetsTableSortStateEnum, SheetsTableThemeController, TABLE_FILTER_EMPTY_VALUE, TableColumnDataTypeEnum, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableManager, TableNumberCompareTypeEnum, TableStringCompareTypeEnum, UniverSheetsTablePlugin, compileTableRecordFilter, customEmptyThemeWithBorderStyle, getExistingNamesSet, getTableRecordValue, getTableRecordValueKey, isColorTableFilter, isConditionFilter, isManualTableFilter, isRecordTableFilter, processStyleWithBorderStyle, validateSheetTableName };
|