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