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