@univerjs/sheets-table 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/lib/cjs/index.js +274 -151
  2. package/lib/cjs/locale/ar-SA.js +10 -0
  3. package/lib/cjs/locale/ca-ES.js +10 -0
  4. package/lib/cjs/locale/de-DE.js +10 -0
  5. package/lib/cjs/locale/en-US.js +25 -0
  6. package/lib/cjs/locale/es-ES.js +10 -0
  7. package/lib/cjs/locale/fa-IR.js +10 -0
  8. package/lib/cjs/locale/fr-FR.js +10 -0
  9. package/lib/cjs/locale/id-ID.js +10 -0
  10. package/lib/cjs/locale/it-IT.js +10 -0
  11. package/lib/cjs/locale/ja-JP.js +10 -0
  12. package/lib/cjs/locale/ko-KR.js +10 -0
  13. package/lib/cjs/locale/pl-PL.js +10 -0
  14. package/lib/cjs/locale/pt-BR.js +10 -0
  15. package/lib/cjs/locale/ru-RU.js +10 -0
  16. package/lib/cjs/locale/sk-SK.js +10 -0
  17. package/lib/cjs/locale/vi-VN.js +10 -0
  18. package/lib/cjs/locale/zh-CN.js +10 -0
  19. package/lib/cjs/locale/zh-HK.js +10 -0
  20. package/lib/cjs/locale/zh-TW.js +10 -0
  21. package/lib/es/index.js +274 -152
  22. package/lib/es/locale/ar-SA.js +9 -0
  23. package/lib/es/locale/ca-ES.js +9 -0
  24. package/lib/es/locale/de-DE.js +9 -0
  25. package/lib/es/locale/en-US.js +24 -0
  26. package/lib/es/locale/es-ES.js +9 -0
  27. package/lib/es/locale/fa-IR.js +9 -0
  28. package/lib/es/locale/fr-FR.js +9 -0
  29. package/lib/es/locale/id-ID.js +9 -0
  30. package/lib/es/locale/it-IT.js +9 -0
  31. package/lib/es/locale/ja-JP.js +9 -0
  32. package/lib/es/locale/ko-KR.js +9 -0
  33. package/lib/es/locale/pl-PL.js +9 -0
  34. package/lib/es/locale/pt-BR.js +9 -0
  35. package/lib/es/locale/ru-RU.js +9 -0
  36. package/lib/es/locale/sk-SK.js +9 -0
  37. package/lib/es/locale/vi-VN.js +9 -0
  38. package/lib/es/locale/zh-CN.js +9 -0
  39. package/lib/es/locale/zh-HK.js +9 -0
  40. package/lib/es/locale/zh-TW.js +9 -0
  41. package/lib/index.js +274 -152
  42. package/lib/locale/ar-SA.js +9 -0
  43. package/lib/locale/ca-ES.js +9 -0
  44. package/lib/locale/de-DE.js +9 -0
  45. package/lib/locale/en-US.js +24 -0
  46. package/lib/locale/es-ES.js +9 -0
  47. package/lib/locale/fa-IR.js +9 -0
  48. package/lib/locale/fr-FR.js +9 -0
  49. package/lib/locale/id-ID.js +9 -0
  50. package/lib/locale/it-IT.js +9 -0
  51. package/lib/locale/ja-JP.js +9 -0
  52. package/lib/locale/ko-KR.js +9 -0
  53. package/lib/locale/pl-PL.js +9 -0
  54. package/lib/locale/pt-BR.js +9 -0
  55. package/lib/locale/ru-RU.js +9 -0
  56. package/lib/locale/sk-SK.js +9 -0
  57. package/lib/locale/vi-VN.js +9 -0
  58. package/lib/locale/zh-CN.js +9 -0
  59. package/lib/locale/zh-HK.js +9 -0
  60. package/lib/locale/zh-TW.js +9 -0
  61. package/lib/types/commands/commands/set-sheet-table.command.d.ts +1 -0
  62. package/lib/types/const.d.ts +1 -0
  63. package/lib/types/controllers/sheet-table-ref-range.controller.d.ts +3 -0
  64. package/lib/types/controllers/table-filter.controller.d.ts +4 -4
  65. package/lib/types/facade/f-workbook.d.ts +8 -4
  66. package/lib/types/facade/f-worksheet.d.ts +18 -9
  67. package/lib/types/index.d.ts +1 -1
  68. package/lib/types/locale/ar-SA.d.ts +18 -0
  69. package/lib/types/locale/ca-ES.d.ts +18 -0
  70. package/lib/types/locale/de-DE.d.ts +18 -0
  71. package/lib/types/locale/en-US.d.ts +23 -0
  72. package/lib/types/locale/es-ES.d.ts +18 -0
  73. package/lib/types/locale/fa-IR.d.ts +18 -0
  74. package/lib/types/locale/fr-FR.d.ts +18 -0
  75. package/lib/types/locale/id-ID.d.ts +18 -0
  76. package/lib/types/locale/it-IT.d.ts +18 -0
  77. package/lib/types/locale/ja-JP.d.ts +18 -0
  78. package/lib/types/locale/ko-KR.d.ts +18 -0
  79. package/lib/types/locale/pl-PL.d.ts +18 -0
  80. package/lib/types/locale/pt-BR.d.ts +18 -0
  81. package/lib/types/locale/ru-RU.d.ts +18 -0
  82. package/lib/types/locale/sk-SK.d.ts +18 -0
  83. package/lib/types/locale/vi-VN.d.ts +18 -0
  84. package/lib/types/locale/zh-CN.d.ts +18 -0
  85. package/lib/types/locale/zh-HK.d.ts +18 -0
  86. package/lib/types/locale/zh-TW.d.ts +18 -0
  87. package/lib/umd/facade.js +1 -1
  88. package/lib/umd/index.js +1 -1
  89. package/lib/umd/locale/ar-SA.js +1 -0
  90. package/lib/umd/locale/ca-ES.js +1 -0
  91. package/lib/umd/locale/de-DE.js +1 -0
  92. package/lib/umd/locale/en-US.js +1 -0
  93. package/lib/umd/locale/es-ES.js +1 -0
  94. package/lib/umd/locale/fa-IR.js +1 -0
  95. package/lib/umd/locale/fr-FR.js +1 -0
  96. package/lib/umd/locale/id-ID.js +1 -0
  97. package/lib/umd/locale/it-IT.js +1 -0
  98. package/lib/umd/locale/ja-JP.js +1 -0
  99. package/lib/umd/locale/ko-KR.js +1 -0
  100. package/lib/umd/locale/pl-PL.js +1 -0
  101. package/lib/umd/locale/pt-BR.js +1 -0
  102. package/lib/umd/locale/ru-RU.js +1 -0
  103. package/lib/umd/locale/sk-SK.js +1 -0
  104. package/lib/umd/locale/vi-VN.js +1 -0
  105. package/lib/umd/locale/zh-CN.js +1 -0
  106. package/lib/umd/locale/zh-HK.js +1 -0
  107. package/lib/umd/locale/zh-TW.js +1 -0
  108. package/package.json +13 -6
package/lib/cjs/index.js CHANGED
@@ -307,7 +307,7 @@ const tableThemeConfig = tableDefaultThemeStyleArr.map((item, index) => {
307
307
  });
308
308
 
309
309
  //#endregion
310
- //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
310
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
311
311
  function _typeof(o) {
312
312
  "@babel/helpers - typeof";
313
313
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -318,7 +318,7 @@ function _typeof(o) {
318
318
  }
319
319
 
320
320
  //#endregion
321
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
321
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
322
322
  function toPrimitive(t, r) {
323
323
  if ("object" != _typeof(t) || !t) return t;
324
324
  var e = t[Symbol.toPrimitive];
@@ -331,14 +331,14 @@ function toPrimitive(t, r) {
331
331
  }
332
332
 
333
333
  //#endregion
334
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
334
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
335
335
  function toPropertyKey(t) {
336
336
  var i = toPrimitive(t, "string");
337
337
  return "symbol" == _typeof(i) ? i : i + "";
338
338
  }
339
339
 
340
340
  //#endregion
341
- //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
341
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
342
342
  function _defineProperty(e, r, t) {
343
343
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
344
344
  value: t,
@@ -394,6 +394,28 @@ var TableColumn = class {
394
394
  }
395
395
  };
396
396
 
397
+ //#endregion
398
+ //#region src/const.ts
399
+ /**
400
+ * Copyright 2023-present DreamNum Co., Ltd.
401
+ *
402
+ * Licensed under the Apache License, Version 2.0 (the "License");
403
+ * you may not use this file except in compliance with the License.
404
+ * You may obtain a copy of the License at
405
+ *
406
+ * http://www.apache.org/licenses/LICENSE-2.0
407
+ *
408
+ * Unless required by applicable law or agreed to in writing, software
409
+ * distributed under the License is distributed on an "AS IS" BASIS,
410
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
411
+ * See the License for the specific language governing permissions and
412
+ * limitations under the License.
413
+ */
414
+ const PLUGIN_NAME = "SHEET_TABLE_PLUGIN";
415
+ const FEATURE_TABLE_ID = "SHEET_TABLE";
416
+ const SHEET_TABLE_CUSTOM_THEME_PREFIX = "table-custom";
417
+ const TABLE_FILTER_EMPTY_VALUE = "__UNIVER_TABLE_FILTER_EMPTY__";
418
+
397
419
  //#endregion
398
420
  //#region src/model/filter-util/date-filter-util.ts
399
421
  /**
@@ -601,7 +623,7 @@ const nextWeek = (date, anchorTime = /* @__PURE__ */ new Date()) => {
601
623
  */
602
624
  const lastWeek = (date, anchorTime = /* @__PURE__ */ new Date()) => {
603
625
  const weekStart = getWeekStart(date);
604
- const anchorTimeLastWeekStart = new Date(getWeekStart(anchorTime).getTime() - perWeek);
626
+ const anchorTimeLastWeekStart = /* @__PURE__ */ new Date(getWeekStart(anchorTime).getTime() - perWeek);
605
627
  return weekStart.toDateString() === anchorTimeLastWeekStart.toDateString();
606
628
  };
607
629
  /**
@@ -1298,7 +1320,8 @@ var TableFilters = class {
1298
1320
  const executeFunc = this.getExecuteFunc(sheet, range, columnIndex, filter);
1299
1321
  for (let row = startRow; row <= endRow; row++) {
1300
1322
  const conditionType = isConditionFilter(filter) ? filter.filterInfo.conditionType : "string";
1301
- if (getCellValueWithConditionType(sheet, row, column, conditionType) === null) filterOutRows.add(row);
1323
+ const cellValue = getCellValueWithConditionType(sheet, row, column, conditionType);
1324
+ if (cellValue === null && !executeFunc(cellValue)) filterOutRows.add(row);
1302
1325
  else if (!executeFunc(getCellValueWithConditionType(sheet, row, column, conditionType))) filterOutRows.add(row);
1303
1326
  }
1304
1327
  }
@@ -1326,6 +1349,7 @@ var TableFilters = class {
1326
1349
  if (filter.filterType === "manual") {
1327
1350
  const valuesSet = new Set(filter.values);
1328
1351
  return (value) => {
1352
+ if (value == null) return valuesSet.has(TABLE_FILTER_EMPTY_VALUE);
1329
1353
  return valuesSet.has(value);
1330
1354
  };
1331
1355
  } else if (filter.filterType === "condition") return getConditionExecuteFunc(filter, isNumberDynamicFilter(filter.filterInfo.compareType) ? this._getNumberCalculatedOptions(sheet, range, columnIndex) : void 0);
@@ -1577,7 +1601,7 @@ var Table = class {
1577
1601
  };
1578
1602
 
1579
1603
  //#endregion
1580
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
1604
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
1581
1605
  function __decorateParam(paramIndex, decorator) {
1582
1606
  return function(target, key) {
1583
1607
  decorator(target, key, paramIndex);
@@ -1585,7 +1609,7 @@ function __decorateParam(paramIndex, decorator) {
1585
1609
  }
1586
1610
 
1587
1611
  //#endregion
1588
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
1612
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
1589
1613
  function __decorate(decorators, target, key, desc) {
1590
1614
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1591
1615
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2178,6 +2202,7 @@ const DeleteSheetTableCommand = {
2178
2202
  id: "sheet.command.delete-table",
2179
2203
  type: _univerjs_core.CommandType.COMMAND,
2180
2204
  handler: (accessor, params) => {
2205
+ var _interceptorCommands$, _interceptorCommands$2;
2181
2206
  if (!params) return false;
2182
2207
  const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
2183
2208
  const commandService = accessor.get(_univerjs_core.ICommandService);
@@ -2191,10 +2216,20 @@ const DeleteSheetTableCommand = {
2191
2216
  logService.error("[TableManager]: Table not found");
2192
2217
  return false;
2193
2218
  }
2219
+ const interceptorCommands = accessor.get(_univerjs_sheets.SheetInterceptorService).onCommandExecute({
2220
+ id: DeleteSheetTableCommand.id,
2221
+ params: {
2222
+ ...params,
2223
+ tableName: tableConfig.name
2224
+ }
2225
+ });
2226
+ redos.push(...(_interceptorCommands$ = interceptorCommands.preRedos) !== null && _interceptorCommands$ !== void 0 ? _interceptorCommands$ : []);
2194
2227
  redos.push({
2195
2228
  id: DeleteSheetTableMutation.id,
2196
2229
  params: { ...params }
2197
2230
  });
2231
+ redos.push(...interceptorCommands.redos);
2232
+ undos.push(...(_interceptorCommands$2 = interceptorCommands.preUndos) !== null && _interceptorCommands$2 !== void 0 ? _interceptorCommands$2 : []);
2198
2233
  undos.push({
2199
2234
  id: AddSheetTableMutation.id,
2200
2235
  params: {
@@ -2206,6 +2241,7 @@ const DeleteSheetTableCommand = {
2206
2241
  options: tableConfig.options
2207
2242
  }
2208
2243
  });
2244
+ undos.push(...interceptorCommands.undos);
2209
2245
  if ((0, _univerjs_core.sequenceExecute)(redos, commandService).result) {
2210
2246
  undoRedoService.pushUndoRedo({
2211
2247
  unitID: params.unitId,
@@ -2218,27 +2254,6 @@ const DeleteSheetTableCommand = {
2218
2254
  }
2219
2255
  };
2220
2256
 
2221
- //#endregion
2222
- //#region src/const.ts
2223
- /**
2224
- * Copyright 2023-present DreamNum Co., Ltd.
2225
- *
2226
- * Licensed under the Apache License, Version 2.0 (the "License");
2227
- * you may not use this file except in compliance with the License.
2228
- * You may obtain a copy of the License at
2229
- *
2230
- * http://www.apache.org/licenses/LICENSE-2.0
2231
- *
2232
- * Unless required by applicable law or agreed to in writing, software
2233
- * distributed under the License is distributed on an "AS IS" BASIS,
2234
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2235
- * See the License for the specific language governing permissions and
2236
- * limitations under the License.
2237
- */
2238
- const PLUGIN_NAME = "SHEET_TABLE_PLUGIN";
2239
- const FEATURE_TABLE_ID = "SHEET_TABLE";
2240
- const SHEET_TABLE_CUSTOM_THEME_PREFIX = "table-custom";
2241
-
2242
2257
  //#endregion
2243
2258
  //#region src/commands/commands/remove-table-theme.command.ts
2244
2259
  const RemoveTableThemeCommand = {
@@ -2343,6 +2358,7 @@ const SetSheetTableCommand = {
2343
2358
  id: "sheet.command.set-table-config",
2344
2359
  type: _univerjs_core.CommandType.COMMAND,
2345
2360
  handler: (accessor, params) => {
2361
+ var _interceptorCommands$, _interceptorCommands$2;
2346
2362
  if (!params) return false;
2347
2363
  const { unitId, tableId, name, updateRange, rowColOperation, theme } = params;
2348
2364
  const tableManager = accessor.get(TableManager);
@@ -2387,22 +2403,43 @@ const SetSheetTableCommand = {
2387
2403
  tableId,
2388
2404
  config: newTableConfig
2389
2405
  };
2390
- accessor.get(_univerjs_core.ICommandService).executeCommand(SetSheetTableMutation.id, redoParams);
2391
- accessor.get(_univerjs_core.IUndoRedoService).pushUndoRedo({
2392
- unitID: unitId,
2393
- undoMutations: [{
2394
- id: SetSheetTableMutation.id,
2395
- params: {
2396
- unitId,
2397
- subUnitId: table.getSubunitId(),
2398
- tableId,
2399
- config: oldTableConfig
2400
- }
2401
- }],
2402
- redoMutations: [{
2406
+ const undoParams = {
2407
+ unitId,
2408
+ subUnitId: table.getSubunitId(),
2409
+ tableId,
2410
+ config: oldTableConfig
2411
+ };
2412
+ const interceptorCommands = accessor.get(_univerjs_sheets.SheetInterceptorService).onCommandExecute({
2413
+ id: SetSheetTableCommand.id,
2414
+ params: {
2415
+ ...params,
2416
+ oldTableName: oldTableConfig.name
2417
+ }
2418
+ });
2419
+ const redos = [
2420
+ ...(_interceptorCommands$ = interceptorCommands.preRedos) !== null && _interceptorCommands$ !== void 0 ? _interceptorCommands$ : [],
2421
+ {
2403
2422
  id: SetSheetTableMutation.id,
2404
2423
  params: redoParams
2405
- }]
2424
+ },
2425
+ ...interceptorCommands.redos
2426
+ ];
2427
+ const undos = [
2428
+ ...(_interceptorCommands$2 = interceptorCommands.preUndos) !== null && _interceptorCommands$2 !== void 0 ? _interceptorCommands$2 : [],
2429
+ {
2430
+ id: SetSheetTableMutation.id,
2431
+ params: undoParams
2432
+ },
2433
+ ...interceptorCommands.undos
2434
+ ];
2435
+ const commandService = accessor.get(_univerjs_core.ICommandService);
2436
+ redos.forEach((mutation) => {
2437
+ commandService.executeCommand(mutation.id, mutation.params);
2438
+ });
2439
+ accessor.get(_univerjs_core.IUndoRedoService).pushUndoRedo({
2440
+ unitID: unitId,
2441
+ undoMutations: undos,
2442
+ redoMutations: redos
2406
2443
  });
2407
2444
  return true;
2408
2445
  }
@@ -3103,6 +3140,7 @@ const SheetTableRemoveColumnAtCommand = {
3103
3140
  id: "sheet.command.table-remove-column-at",
3104
3141
  type: _univerjs_core.CommandType.COMMAND,
3105
3142
  handler: (accessor, params) => {
3143
+ var _interceptorCommands$, _interceptorCommands$2;
3106
3144
  if (!params) return false;
3107
3145
  const { unitId, subUnitId, tableId, index, count = 1 } = params;
3108
3146
  if (count <= 0) return false;
@@ -3115,41 +3153,58 @@ const SheetTableRemoveColumnAtCommand = {
3115
3153
  if (!table || table.getSubunitId() !== subUnitId) return false;
3116
3154
  const oldRange = table.getRange();
3117
3155
  if (index < oldRange.startColumn || index + count - 1 > oldRange.endColumn || count >= oldRange.endColumn - oldRange.startColumn + 1) return false;
3156
+ const tableInfo = table.getTableInfo();
3118
3157
  const columns = [];
3119
3158
  const gap = index - oldRange.startColumn;
3120
3159
  for (let i = 0; i < count; i++) {
3121
- const column = table.getTableInfo().columns[gap + i];
3160
+ const column = tableInfo.columns[gap + i];
3122
3161
  if (column) columns.push(column);
3123
3162
  }
3124
- const redos = [{
3125
- id: SetSheetTableMutation.id,
3126
- params: {
3127
- unitId,
3128
- subUnitId,
3129
- tableId,
3130
- config: { rowColOperation: {
3131
- operationType: "delete",
3132
- rowColType: "column",
3133
- index,
3134
- count
3135
- } }
3136
- }
3137
- }];
3138
- const undos = [{
3139
- id: SetSheetTableMutation.id,
3163
+ const interceptorCommands = accessor.get(_univerjs_sheets.SheetInterceptorService).onCommandExecute({
3164
+ id: SheetTableRemoveColumnAtCommand.id,
3140
3165
  params: {
3141
- unitId,
3142
- subUnitId,
3143
- tableId,
3144
- config: { rowColOperation: {
3145
- operationType: "insert",
3146
- rowColType: "column",
3147
- index,
3148
- count,
3149
- columnsJson: columns
3150
- } }
3166
+ ...params,
3167
+ tableName: tableInfo.name,
3168
+ removedColumnNames: columns.map((column) => column.displayName)
3151
3169
  }
3152
- }];
3170
+ });
3171
+ const redos = [
3172
+ ...(_interceptorCommands$ = interceptorCommands.preRedos) !== null && _interceptorCommands$ !== void 0 ? _interceptorCommands$ : [],
3173
+ {
3174
+ id: SetSheetTableMutation.id,
3175
+ params: {
3176
+ unitId,
3177
+ subUnitId,
3178
+ tableId,
3179
+ config: { rowColOperation: {
3180
+ operationType: "delete",
3181
+ rowColType: "column",
3182
+ index,
3183
+ count
3184
+ } }
3185
+ }
3186
+ },
3187
+ ...interceptorCommands.redos
3188
+ ];
3189
+ const undos = [
3190
+ ...(_interceptorCommands$2 = interceptorCommands.preUndos) !== null && _interceptorCommands$2 !== void 0 ? _interceptorCommands$2 : [],
3191
+ {
3192
+ id: SetSheetTableMutation.id,
3193
+ params: {
3194
+ unitId,
3195
+ subUnitId,
3196
+ tableId,
3197
+ config: { rowColOperation: {
3198
+ operationType: "insert",
3199
+ rowColType: "column",
3200
+ index,
3201
+ count,
3202
+ columnsJson: columns
3203
+ } }
3204
+ }
3205
+ },
3206
+ ...interceptorCommands.undos
3207
+ ];
3153
3208
  const colContentIndex = target.worksheet.getCellMatrix().getDataRange().endColumn;
3154
3209
  if (index + count <= colContentIndex) {
3155
3210
  const moveRangeMutations = (0, _univerjs_sheets.getMoveRangeUndoRedoMutations)(accessor, {
@@ -3256,6 +3311,7 @@ const SheetTableRemoveColCommand = {
3256
3311
  id: "sheet.command.table-remove-col",
3257
3312
  type: _univerjs_core.CommandType.COMMAND,
3258
3313
  handler: (accessor, params) => {
3314
+ var _interceptorCommands$3, _interceptorCommands$4;
3259
3315
  if (!params) return false;
3260
3316
  const target = (0, _univerjs_sheets.getSheetCommandTarget)(accessor.get(_univerjs_core.IUniverInstanceService), params);
3261
3317
  if (!target) return false;
@@ -3284,12 +3340,24 @@ const SheetTableRemoveColCommand = {
3284
3340
  } }
3285
3341
  }
3286
3342
  });
3343
+ const tableInfo = table.getTableInfo();
3287
3344
  const columns = [];
3288
3345
  const gap = range.startColumn - oldRange.startColumn;
3289
3346
  for (let i = 0; i < removeColCount; i++) {
3290
- const column = table.getTableInfo().columns[gap + i];
3347
+ const column = tableInfo.columns[gap + i];
3291
3348
  if (column) columns.push(column);
3292
3349
  }
3350
+ const interceptorCommands = accessor.get(_univerjs_sheets.SheetInterceptorService).onCommandExecute({
3351
+ id: SheetTableRemoveColCommand.id,
3352
+ params: {
3353
+ ...params,
3354
+ tableName: tableInfo.name,
3355
+ removedColumnNames: columns.map((column) => column.displayName)
3356
+ }
3357
+ });
3358
+ redos.unshift(...(_interceptorCommands$3 = interceptorCommands.preRedos) !== null && _interceptorCommands$3 !== void 0 ? _interceptorCommands$3 : []);
3359
+ redos.push(...interceptorCommands.redos);
3360
+ undos.unshift(...(_interceptorCommands$4 = interceptorCommands.preUndos) !== null && _interceptorCommands$4 !== void 0 ? _interceptorCommands$4 : []);
3293
3361
  undos.push({
3294
3362
  id: SetSheetTableMutation.id,
3295
3363
  params: {
@@ -3305,6 +3373,7 @@ const SheetTableRemoveColCommand = {
3305
3373
  } }
3306
3374
  }
3307
3375
  });
3376
+ undos.push(...interceptorCommands.undos);
3308
3377
  const colContentIndex = target.worksheet.getCellMatrix().getDataRange().endColumn;
3309
3378
  const moveRangeMutations = (0, _univerjs_sheets.getMoveRangeUndoRedoMutations)(accessor, {
3310
3379
  unitId,
@@ -3344,7 +3413,7 @@ const SheetTableRemoveColCommand = {
3344
3413
  //#endregion
3345
3414
  //#region package.json
3346
3415
  var name = "@univerjs/sheets-table";
3347
- var version = "0.24.0";
3416
+ var version = "0.25.0";
3348
3417
 
3349
3418
  //#endregion
3350
3419
  //#region src/controllers/sheet-table-formula.controller.ts
@@ -3383,10 +3452,10 @@ let SheetTableFormulaController = class SheetTableFormulaController extends _uni
3383
3452
  });
3384
3453
  const table = this._tableManager.getTableById(unitId, tableId);
3385
3454
  if (!table) return;
3386
- this._updateSuperTable(unitId, table);
3455
+ this._updateSuperTable(unitId, table, oldTableName);
3387
3456
  }));
3388
3457
  }
3389
- _updateSuperTable(unitId, table) {
3458
+ _updateSuperTable(unitId, table, oldTableName) {
3390
3459
  const tableInfo = table.getTableInfo();
3391
3460
  const name = tableInfo.name;
3392
3461
  const columns = tableInfo.columns;
@@ -3397,6 +3466,7 @@ let SheetTableFormulaController = class SheetTableFormulaController extends _uni
3397
3466
  this._commandService.executeCommand(_univerjs_engine_formula.SetSuperTableMutation.id, {
3398
3467
  unitId,
3399
3468
  tableName: name,
3469
+ oldTableName,
3400
3470
  reference: {
3401
3471
  range: tableInfo.range,
3402
3472
  sheetId: tableInfo.subUnitId,
@@ -3457,6 +3527,8 @@ SheetTableRangeController = __decorate([__decorateParam(0, (0, _univerjs_core.In
3457
3527
 
3458
3528
  //#endregion
3459
3529
  //#region src/controllers/sheet-table-ref-range.controller.ts
3530
+ const SHEET_TABLE_REMOVE_COL_COMMAND_ID = "sheet.command.table-remove-col";
3531
+ const DELETE_SHEET_TABLE_COMMAND_ID = "sheet.command.delete-table";
3460
3532
  let SheetTableRefRangeController = class SheetTableRefRangeController extends _univerjs_core.Disposable {
3461
3533
  constructor(_commandService, _refRangeService, _univerInstanceService, _injector, _sheetInterceptorService, _tableManager, _localeService) {
3462
3534
  super();
@@ -3472,20 +3544,23 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
3472
3544
  }
3473
3545
  _initCommandInterceptor() {
3474
3546
  const self = this;
3475
- this._sheetInterceptorService.interceptCommand({ getMutations(commandInfo) {
3476
- const defaultReturn = {
3477
- redos: [],
3478
- undos: []
3479
- };
3480
- const { id, params } = commandInfo;
3481
- switch (id) {
3482
- case _univerjs_sheets.InsertRowCommand.id: return self._generateTableMutationWithInsertRow(params);
3483
- case _univerjs_sheets.InsertColCommand.id: return self._generateTableMutationWithInsertCol(params);
3484
- case _univerjs_sheets.RemoveRowCommand.id: return self._generateTableMutationWithRemoveRow(params);
3485
- case _univerjs_sheets.RemoveColCommand.id: return self._generateTableMutationWithRemoveCol(params);
3547
+ this._sheetInterceptorService.interceptCommand({
3548
+ priority: -1,
3549
+ getMutations(commandInfo) {
3550
+ const defaultReturn = {
3551
+ redos: [],
3552
+ undos: []
3553
+ };
3554
+ const { id, params } = commandInfo;
3555
+ switch (id) {
3556
+ case _univerjs_sheets.InsertRowCommand.id: return self._generateTableMutationWithInsertRow(params);
3557
+ case _univerjs_sheets.InsertColCommand.id: return self._generateTableMutationWithInsertCol(params);
3558
+ case _univerjs_sheets.RemoveRowCommand.id: return self._generateTableMutationWithRemoveRow(params);
3559
+ case _univerjs_sheets.RemoveColCommand.id: return self._generateTableMutationWithRemoveCol(params);
3560
+ }
3561
+ return defaultReturn;
3486
3562
  }
3487
- return defaultReturn;
3488
- } });
3563
+ });
3489
3564
  }
3490
3565
  _generateTableMutationWithInsertRow(insertParams) {
3491
3566
  const undos = [];
@@ -3714,6 +3789,18 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
3714
3789
  const tableRange = table.getRange();
3715
3790
  if (_univerjs_core.Rectangle.intersects(tableRange, range)) {
3716
3791
  if (range.startColumn <= tableRange.startColumn && range.endColumn >= tableRange.endColumn) {
3792
+ var _formulaMutations$pre, _formulaMutations$pre2;
3793
+ const tableInfo = table.getTableInfo();
3794
+ const formulaMutations = this._sheetInterceptorService.onCommandExecute({
3795
+ id: DELETE_SHEET_TABLE_COMMAND_ID,
3796
+ params: {
3797
+ unitId,
3798
+ subUnitId,
3799
+ tableId: table.getId(),
3800
+ tableName: tableInfo.name
3801
+ }
3802
+ });
3803
+ preRedos.push(...(_formulaMutations$pre = formulaMutations.preRedos) !== null && _formulaMutations$pre !== void 0 ? _formulaMutations$pre : [], ...formulaMutations.redos);
3717
3804
  preRedos.push({
3718
3805
  id: DeleteSheetTableMutation.id,
3719
3806
  params: {
@@ -3746,7 +3833,9 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
3746
3833
  options: tableJson.options
3747
3834
  }
3748
3835
  });
3836
+ undos.push(...(_formulaMutations$pre2 = formulaMutations.preUndos) !== null && _formulaMutations$pre2 !== void 0 ? _formulaMutations$pre2 : [], ...formulaMutations.undos);
3749
3837
  } else if (range.startColumn <= tableRange.startColumn && range.endColumn >= tableRange.startColumn) {
3838
+ const tableJson = table.toJSON();
3750
3839
  const removeColumnCount = range.endColumn - tableRange.startColumn + 1;
3751
3840
  redos.push({
3752
3841
  id: SetSheetTableMutation.id,
@@ -3767,22 +3856,18 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
3767
3856
  const column = table.getTableColumnByIndex(i);
3768
3857
  if (column) columns.push(column.toJSON());
3769
3858
  }
3770
- undos.push({
3771
- id: SetSheetTableMutation.id,
3772
- params: {
3773
- unitId,
3774
- subUnitId,
3775
- tableId: table.getId(),
3776
- config: { rowColOperation: {
3777
- operationType: "insert",
3778
- rowColType: "column",
3779
- index: tableRange.startColumn,
3780
- count: removeColumnCount,
3781
- columnsJson: columns
3782
- } }
3783
- }
3859
+ preUndos.push(this._getDeleteTableMutation(unitId, subUnitId, table.getId()));
3860
+ undos.push(this._getAddTableMutation(unitId, subUnitId, tableJson));
3861
+ this._appendTableColumnFormulaMutations(redos, undos, {
3862
+ unitId,
3863
+ subUnitId,
3864
+ tableId: table.getId(),
3865
+ tableName: table.getTableInfo().name,
3866
+ range,
3867
+ columns
3784
3868
  });
3785
3869
  } else if (range.startColumn > tableRange.startColumn && range.endColumn > tableRange.endColumn) {
3870
+ const tableJson = table.toJSON();
3786
3871
  const removeColumnCount = tableRange.endColumn - range.startColumn + 1;
3787
3872
  redos.push({
3788
3873
  id: SetSheetTableMutation.id,
@@ -3804,22 +3889,18 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
3804
3889
  const column = table.getTableColumnByIndex(i + gap);
3805
3890
  if (column) columns.push(column.toJSON());
3806
3891
  }
3807
- undos.push({
3808
- id: SetSheetTableMutation.id,
3809
- params: {
3810
- unitId,
3811
- subUnitId,
3812
- tableId: table.getId(),
3813
- config: { rowColOperation: {
3814
- operationType: "insert",
3815
- rowColType: "column",
3816
- index: range.startColumn,
3817
- count: removeColCount,
3818
- columnsJson: columns
3819
- } }
3820
- }
3892
+ preUndos.push(this._getDeleteTableMutation(unitId, subUnitId, table.getId()));
3893
+ undos.push(this._getAddTableMutation(unitId, subUnitId, tableJson));
3894
+ this._appendTableColumnFormulaMutations(redos, undos, {
3895
+ unitId,
3896
+ subUnitId,
3897
+ tableId: table.getId(),
3898
+ tableName: table.getTableInfo().name,
3899
+ range,
3900
+ columns
3821
3901
  });
3822
3902
  } else if (range.startColumn > tableRange.startColumn && range.endColumn <= tableRange.endColumn) {
3903
+ const tableJson = table.toJSON();
3823
3904
  redos.push({
3824
3905
  id: SetSheetTableMutation.id,
3825
3906
  params: {
@@ -3840,20 +3921,15 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
3840
3921
  const column = table.getTableColumnByIndex(i + gap);
3841
3922
  if (column) columns.push(column.toJSON());
3842
3923
  }
3843
- undos.push({
3844
- id: SetSheetTableMutation.id,
3845
- params: {
3846
- unitId,
3847
- subUnitId,
3848
- tableId: table.getId(),
3849
- config: { rowColOperation: {
3850
- operationType: "insert",
3851
- rowColType: "column",
3852
- index: range.startColumn,
3853
- count: removeColCount,
3854
- columnsJson: columns
3855
- } }
3856
- }
3924
+ preUndos.push(this._getDeleteTableMutation(unitId, subUnitId, table.getId()));
3925
+ undos.push(this._getAddTableMutation(unitId, subUnitId, tableJson));
3926
+ this._appendTableColumnFormulaMutations(redos, undos, {
3927
+ unitId,
3928
+ subUnitId,
3929
+ tableId: table.getId(),
3930
+ tableName: table.getTableInfo().name,
3931
+ range,
3932
+ columns
3857
3933
  });
3858
3934
  }
3859
3935
  }
@@ -3865,6 +3941,53 @@ let SheetTableRefRangeController = class SheetTableRefRangeController extends _u
3865
3941
  preUndos
3866
3942
  };
3867
3943
  }
3944
+ _getDeleteTableMutation(unitId, subUnitId, tableId) {
3945
+ return {
3946
+ id: DeleteSheetTableMutation.id,
3947
+ params: {
3948
+ unitId,
3949
+ subUnitId,
3950
+ tableId
3951
+ }
3952
+ };
3953
+ }
3954
+ _getAddTableMutation(unitId, subUnitId, tableJson) {
3955
+ const header = tableJson.columns.map((column) => column.displayName);
3956
+ return {
3957
+ id: AddSheetTableMutation.id,
3958
+ params: {
3959
+ unitId,
3960
+ subUnitId,
3961
+ tableId: tableJson.id,
3962
+ name: tableJson.name,
3963
+ header,
3964
+ range: tableJson.range,
3965
+ options: {
3966
+ ...tableJson.options,
3967
+ columns: tableJson.columns,
3968
+ filters: tableJson.filters.tableColumnFilterList
3969
+ }
3970
+ }
3971
+ };
3972
+ }
3973
+ _appendTableColumnFormulaMutations(redos, undos, info) {
3974
+ var _formulaMutations$pre3, _formulaMutations$pre4;
3975
+ const removedColumnNames = info.columns.map((column) => column.displayName);
3976
+ if (!removedColumnNames.length) return;
3977
+ const formulaMutations = this._sheetInterceptorService.onCommandExecute({
3978
+ id: SHEET_TABLE_REMOVE_COL_COMMAND_ID,
3979
+ params: {
3980
+ unitId: info.unitId,
3981
+ subUnitId: info.subUnitId,
3982
+ tableId: info.tableId,
3983
+ tableName: info.tableName,
3984
+ range: info.range,
3985
+ removedColumnNames
3986
+ }
3987
+ });
3988
+ redos.splice(Math.max(redos.length - 1, 0), 0, ...(_formulaMutations$pre3 = formulaMutations.preRedos) !== null && _formulaMutations$pre3 !== void 0 ? _formulaMutations$pre3 : [], ...formulaMutations.redos);
3989
+ undos.push(...(_formulaMutations$pre4 = formulaMutations.preUndos) !== null && _formulaMutations$pre4 !== void 0 ? _formulaMutations$pre4 : [], ...formulaMutations.undos);
3990
+ }
3868
3991
  _initCommandListener() {
3869
3992
  this._commandService.onCommandExecuted((commandInfo) => {
3870
3993
  if (commandInfo.id === _univerjs_sheets.InsertRowMutation.id) {
@@ -4030,25 +4153,18 @@ let TableFilterController = class TableFilterController extends _univerjs_core.D
4030
4153
  this._sheetInterceptorService = _sheetInterceptorService;
4031
4154
  this._univerInstanceService = _univerInstanceService;
4032
4155
  this._zebraCrossingCacheController = _zebraCrossingCacheController;
4033
- _defineProperty(this, "_tableFilteredOutRows$", new rxjs.BehaviorSubject(/* @__PURE__ */ new Set()));
4034
- _defineProperty(this, "tableFilteredOutRows$", this._tableFilteredOutRows$.asObservable());
4156
+ _defineProperty(this, "_tableFilteredOutRows", /* @__PURE__ */ new Map());
4035
4157
  _defineProperty(this, "_subscription", null);
4036
4158
  this.registerFilterChangeEvent();
4037
4159
  this.initTableHiddenRowIntercept();
4038
4160
  this._initFilteredOutRows();
4039
4161
  }
4040
- get tableFilteredOutRows() {
4041
- return this._tableFilteredOutRows$.value;
4042
- }
4043
- set tableFilteredOutRows(value) {
4044
- this._tableFilteredOutRows$.next(value);
4045
- }
4046
4162
  initTableHiddenRowIntercept() {
4047
4163
  this.disposeWithMe(this._sheetInterceptorService.intercept(_univerjs_sheets.INTERCEPTOR_POINT.ROW_FILTERED, {
4048
4164
  priority: 100,
4049
4165
  handler: (filtered, rowLocation, next) => {
4050
4166
  if (filtered) return true;
4051
- const isTableFiltered = this.tableFilteredOutRows.has(rowLocation.row);
4167
+ const isTableFiltered = this._getTableFilteredOutRows(rowLocation.unitId, rowLocation.subUnitId).has(rowLocation.row);
4052
4168
  return isTableFiltered ? true : next(isTableFiltered);
4053
4169
  }
4054
4170
  }));
@@ -4060,12 +4176,7 @@ let TableFilterController = class TableFilterController extends _univerjs_core.D
4060
4176
  const target = (0, _univerjs_sheets.getSheetCommandTarget)(this._univerInstanceService);
4061
4177
  if (!target) return;
4062
4178
  const { unitId, subUnitId } = target;
4063
- this.tableFilteredOutRows.clear();
4064
- this._tableManager.getTablesBySubunitId(unitId, subUnitId).forEach((table) => {
4065
- const tableFilteredRows = table.getTableFilters().getFilterOutRows();
4066
- if (!tableFilteredRows) return;
4067
- for (const row of tableFilteredRows) this.tableFilteredOutRows.add(row);
4068
- });
4179
+ this._refreshTableFilteredOutRows(unitId, subUnitId);
4069
4180
  });
4070
4181
  }
4071
4182
  registerFilterChangeEvent() {
@@ -4075,16 +4186,27 @@ let TableFilterController = class TableFilterController extends _univerjs_core.D
4075
4186
  const worksheet = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(subUnitId);
4076
4187
  const table = this._tableManager.getTable(unitId, tableId);
4077
4188
  if (!worksheet || !table) return;
4078
- this.tableFilteredOutRows.clear();
4079
4189
  table.getTableFilters().doFilter(worksheet, table.getTableFilterRange());
4080
- this._tableManager.getTablesBySubunitId(unitId, subUnitId).forEach((table) => {
4081
- const tableFilteredRows = table.getTableFilters().getFilterOutRows();
4082
- if (!tableFilteredRows) return;
4083
- for (const row of tableFilteredRows) this.tableFilteredOutRows.add(row);
4084
- });
4190
+ this._refreshTableFilteredOutRows(unitId, subUnitId);
4085
4191
  this._zebraCrossingCacheController.updateZebraCrossingCache(unitId, subUnitId);
4086
4192
  }));
4087
4193
  }
4194
+ _refreshTableFilteredOutRows(unitId, subUnitId) {
4195
+ const filteredOutRows = /* @__PURE__ */ new Set();
4196
+ this._tableManager.getTablesBySubunitId(unitId, subUnitId).forEach((table) => {
4197
+ const tableFilteredRows = table.getTableFilters().getFilterOutRows();
4198
+ if (!tableFilteredRows) return;
4199
+ for (const row of tableFilteredRows) filteredOutRows.add(row);
4200
+ });
4201
+ this._tableFilteredOutRows.set(this._getSheetKey(unitId, subUnitId), filteredOutRows);
4202
+ }
4203
+ _getTableFilteredOutRows(unitId, subUnitId) {
4204
+ var _this$_tableFilteredO;
4205
+ return (_this$_tableFilteredO = this._tableFilteredOutRows.get(this._getSheetKey(unitId, subUnitId))) !== null && _this$_tableFilteredO !== void 0 ? _this$_tableFilteredO : /* @__PURE__ */ new Set();
4206
+ }
4207
+ _getSheetKey(unitId, subUnitId) {
4208
+ return `${unitId}|${subUnitId}`;
4209
+ }
4088
4210
  dispose() {
4089
4211
  var _this$_subscription;
4090
4212
  super.dispose();
@@ -4200,6 +4322,7 @@ Object.defineProperty(exports, 'SheetsTableController', {
4200
4322
  }
4201
4323
  });
4202
4324
  exports.SheetsTableSortStateEnum = SheetsTableSortStateEnum;
4325
+ exports.TABLE_FILTER_EMPTY_VALUE = TABLE_FILTER_EMPTY_VALUE;
4203
4326
  exports.TableColumnDataTypeEnum = TableColumnDataTypeEnum;
4204
4327
  exports.TableColumnFilterTypeEnum = TableColumnFilterTypeEnum;
4205
4328
  exports.TableConditionTypeEnum = TableConditionTypeEnum;