@univerjs/sheets-table 1.0.3 → 1.1.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 (88) hide show
  1. package/lib/cjs/index.js +245 -62
  2. package/lib/cjs/locale/ar-SA.js +1 -0
  3. package/lib/cjs/locale/ca-ES.js +1 -0
  4. package/lib/cjs/locale/de-DE.js +1 -0
  5. package/lib/cjs/locale/en-US.js +1 -0
  6. package/lib/cjs/locale/es-ES.js +1 -0
  7. package/lib/cjs/locale/fa-IR.js +1 -0
  8. package/lib/cjs/locale/fr-FR.js +1 -0
  9. package/lib/cjs/locale/id-ID.js +1 -0
  10. package/lib/cjs/locale/it-IT.js +1 -0
  11. package/lib/cjs/locale/ja-JP.js +1 -0
  12. package/lib/cjs/locale/ko-KR.js +1 -0
  13. package/lib/cjs/locale/pl-PL.js +1 -0
  14. package/lib/cjs/locale/pt-BR.js +1 -0
  15. package/lib/cjs/locale/ru-RU.js +1 -0
  16. package/lib/cjs/locale/sk-SK.js +1 -0
  17. package/lib/cjs/locale/vi-VN.js +1 -0
  18. package/lib/cjs/locale/zh-CN.js +1 -0
  19. package/lib/cjs/locale/zh-HK.js +1 -0
  20. package/lib/cjs/locale/zh-TW.js +1 -0
  21. package/lib/es/index.js +242 -59
  22. package/lib/es/locale/ar-SA.js +1 -0
  23. package/lib/es/locale/ca-ES.js +1 -0
  24. package/lib/es/locale/de-DE.js +1 -0
  25. package/lib/es/locale/en-US.js +1 -0
  26. package/lib/es/locale/es-ES.js +1 -0
  27. package/lib/es/locale/fa-IR.js +1 -0
  28. package/lib/es/locale/fr-FR.js +1 -0
  29. package/lib/es/locale/id-ID.js +1 -0
  30. package/lib/es/locale/it-IT.js +1 -0
  31. package/lib/es/locale/ja-JP.js +1 -0
  32. package/lib/es/locale/ko-KR.js +1 -0
  33. package/lib/es/locale/pl-PL.js +1 -0
  34. package/lib/es/locale/pt-BR.js +1 -0
  35. package/lib/es/locale/ru-RU.js +1 -0
  36. package/lib/es/locale/sk-SK.js +1 -0
  37. package/lib/es/locale/vi-VN.js +1 -0
  38. package/lib/es/locale/zh-CN.js +1 -0
  39. package/lib/es/locale/zh-HK.js +1 -0
  40. package/lib/es/locale/zh-TW.js +1 -0
  41. package/lib/index.js +242 -59
  42. package/lib/locale/ar-SA.js +1 -0
  43. package/lib/locale/ca-ES.js +1 -0
  44. package/lib/locale/de-DE.js +1 -0
  45. package/lib/locale/en-US.js +1 -0
  46. package/lib/locale/es-ES.js +1 -0
  47. package/lib/locale/fa-IR.js +1 -0
  48. package/lib/locale/fr-FR.js +1 -0
  49. package/lib/locale/id-ID.js +1 -0
  50. package/lib/locale/it-IT.js +1 -0
  51. package/lib/locale/ja-JP.js +1 -0
  52. package/lib/locale/ko-KR.js +1 -0
  53. package/lib/locale/pl-PL.js +1 -0
  54. package/lib/locale/pt-BR.js +1 -0
  55. package/lib/locale/ru-RU.js +1 -0
  56. package/lib/locale/sk-SK.js +1 -0
  57. package/lib/locale/vi-VN.js +1 -0
  58. package/lib/locale/zh-CN.js +1 -0
  59. package/lib/locale/zh-HK.js +1 -0
  60. package/lib/locale/zh-TW.js +1 -0
  61. package/lib/types/commands/mutations/move-sheet-table.mutation.d.ts +25 -0
  62. package/lib/types/controllers/sheet-table-move.controller.d.ts +31 -0
  63. package/lib/types/controllers/table-filter.controller.d.ts +0 -1
  64. package/lib/types/locale/en-US.d.ts +1 -0
  65. package/lib/types/models/table-manager.d.ts +1 -0
  66. package/lib/types/types/type.d.ts +2 -7
  67. package/lib/umd/facade.js +1 -1
  68. package/lib/umd/index.js +1 -1
  69. package/lib/umd/locale/ar-SA.js +1 -1
  70. package/lib/umd/locale/ca-ES.js +1 -1
  71. package/lib/umd/locale/de-DE.js +1 -1
  72. package/lib/umd/locale/en-US.js +1 -1
  73. package/lib/umd/locale/es-ES.js +1 -1
  74. package/lib/umd/locale/fa-IR.js +1 -1
  75. package/lib/umd/locale/fr-FR.js +1 -1
  76. package/lib/umd/locale/id-ID.js +1 -1
  77. package/lib/umd/locale/it-IT.js +1 -1
  78. package/lib/umd/locale/ja-JP.js +1 -1
  79. package/lib/umd/locale/ko-KR.js +1 -1
  80. package/lib/umd/locale/pl-PL.js +1 -1
  81. package/lib/umd/locale/pt-BR.js +1 -1
  82. package/lib/umd/locale/ru-RU.js +1 -1
  83. package/lib/umd/locale/sk-SK.js +1 -1
  84. package/lib/umd/locale/vi-VN.js +1 -1
  85. package/lib/umd/locale/zh-CN.js +1 -1
  86. package/lib/umd/locale/zh-HK.js +1 -1
  87. package/lib/umd/locale/zh-TW.js +1 -1
  88. package/package.json +8 -8
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "Colonne",
4
4
  tablePrefix: "Tableau",
5
+ moveTableOverlapError: "La destination chevauche un autre tableau.",
5
6
  tableNameError: "Le nom du tableau ne peut pas contenir d'espaces, ne peut pas commencer par un chiffre et ne peut pas être identique à un nom de tableau existant"
6
7
  } };
7
8
 
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "Kolom",
4
4
  tablePrefix: "Tabel",
5
+ moveTableOverlapError: "Rentang tujuan tumpang tindih dengan tabel lain.",
5
6
  tableNameError: "Nama tabel tidak boleh mengandung spasi, tidak boleh diawali dengan angka, dan tidak boleh sama dengan nama tabel yang sudah ada"
6
7
  } };
7
8
 
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "Colonna",
4
4
  tablePrefix: "Tabella",
5
+ moveTableOverlapError: "La destinazione si sovrappone a un’altra tabella.",
5
6
  tableNameError: "Il nome della tabella non può contenere spazi, non può iniziare con un numero e non può essere identico a un nome di tabella esistente"
6
7
  } };
7
8
 
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "列",
4
4
  tablePrefix: "表",
5
+ moveTableOverlapError: "移動先が他のテーブルと重なっています。",
5
6
  tableNameError: "表の名前は空白を含めることはできず、数字で始めることはできず、既存の表名と重複できません"
6
7
  } };
7
8
 
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "열",
4
4
  tablePrefix: "표",
5
+ moveTableOverlapError: "대상 범위가 다른 표와 겹칩니다.",
5
6
  tableNameError: "표 이름은 공백을 포함할 수 없으며 숫자로 시작할 수 없고 기존 표 이름과 중복될 수 없습니다"
6
7
  } };
7
8
 
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "Kolumna",
4
4
  tablePrefix: "Tabela",
5
+ moveTableOverlapError: "Zakres docelowy nakłada się na inną tabelę.",
5
6
  tableNameError: "Nazwa tabeli nie może zawierać spacji, nie może zaczynać się od cyfry i nie może być identyczna z istniejącą nazwą tabeli"
6
7
  } };
7
8
 
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "Coluna",
4
4
  tablePrefix: "Tabela",
5
+ moveTableOverlapError: "O destino se sobrepõe a outra tabela.",
5
6
  tableNameError: "O nome da tabela não pode conter espaços, não pode começar com um número e não pode ser idêntico a um nome de tabela existente"
6
7
  } };
7
8
 
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "Столбец",
4
4
  tablePrefix: "Таблица",
5
+ moveTableOverlapError: "Диапазон назначения пересекается с другой таблицей.",
5
6
  tableNameError: "Имя таблицы не может содержать пробелы, не может начинаться с цифры и не может совпадать с именем существующей таблицы"
6
7
  } };
7
8
 
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "Stĺpec",
4
4
  tablePrefix: "Tabuľka",
5
+ moveTableOverlapError: "Cieľový rozsah sa prekrýva s inou tabuľkou.",
5
6
  tableNameError: "Názov tabuľky nesmie obsahovať medzery, nesmie začínať číslom a nesmie byť zhodný s existujúcim názvom tabuľky"
6
7
  } };
7
8
 
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "Cột",
4
4
  tablePrefix: "Bảng",
5
+ moveTableOverlapError: "Vùng đích chồng lấp với một bảng khác.",
5
6
  tableNameError: "Tên bảng không thể chứa khoảng trắng, không được bắt đầu bằng số và không được trùng với tên bảng đã có"
6
7
  } };
7
8
 
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "列",
4
4
  tablePrefix: "表格",
5
+ moveTableOverlapError: "目标区域与其他表格重叠。",
5
6
  tableNameError: "表格名称不能包含空格, 不能以数字开头,不能和已有表格名称重复"
6
7
  } };
7
8
 
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "列",
4
4
  tablePrefix: "表格",
5
+ moveTableOverlapError: "目標區域與其他表格重疊。",
5
6
  tableNameError: "表格名稱不能包含空格, 不能以數字開頭,不能和已有表格名稱重複"
6
7
  } };
7
8
 
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "列",
4
4
  tablePrefix: "表格",
5
+ moveTableOverlapError: "目標區域與其他表格重疊。",
5
6
  tableNameError: "表格名稱不能包含空格, 不能以數字開頭,不能和已有表格名稱重複"
6
7
  } };
7
8
 
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { BooleanNumber, BorderStyleTypes, CellValueType, ColorKit, CommandType, DEFAULT_STYLES, DateSystem, DependentOn, Disposable, FilterSelectionMode, FormulaType, ICommandService, IConfigService, ILogService, IPermissionService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Plugin, RTree, RecordValueType, Rectangle, UniverInstanceType, customNameCharacterCheck, excelSerialToDateTime, generateRandomId, getColorStyle, merge, numfmt, regexp, registerDependencies, sequenceExecute, toDisposable, touchDependencies } from "@univerjs/core";
1
+ import { BooleanNumber, BorderStyleTypes, CellValueType, ColorKit, CommandType, DEFAULT_STYLES, DateSystem, DependentOn, Disposable, ErrorService, FilterSelectionMode, FormulaType, ICommandService, IConfigService, ILogService, IPermissionService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Plugin, RTree, RecordValueType, Rectangle, UniverInstanceType, customNameCharacterCheck, excelSerialToDateTime, generateRandomId, getColorStyle, merge, numfmt, regexp, registerDependencies, sequenceExecute, toDisposable, touchDependencies } from "@univerjs/core";
2
2
  import { IActiveDirtyManagerService, IDefinedNamesService, ISheetRowFilteredService, LexerTreeBuilder, RemoveSuperTableMutation, SetSuperTableMutation, extractFormulaError, serializeRange } from "@univerjs/engine-formula";
3
- import { AddRangeThemeMutation, CopySheetCommand, IExclusiveRangeService, INTERCEPTOR_POINT, InsertColCommand, InsertColMutation, InsertRowCommand, InsertRowMutation, RangeThemeStyle, RefRangeService, RemoveColCommand, RemoveColMutation, RemoveRangeThemeMutation, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SheetInterceptorService, SheetRangeThemeModel, SheetRangeThemeService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, ZebraCrossingCacheController, checkRangesEditablePermission, getMoveRangeCommandMutations, getMoveRangeUndoRedoMutations, getSheetCommandTarget } from "@univerjs/sheets";
3
+ import { AddRangeThemeMutation, CopySheetCommand, IExclusiveRangeService, INTERCEPTOR_POINT, InsertColCommand, InsertColMutation, InsertRowCommand, InsertRowMutation, MoveRangeCommand, RangeThemeStyle, RefRangeService, RemoveColCommand, RemoveColMutation, RemoveRangeThemeMutation, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SheetInterceptorService, SheetRangeThemeModel, SheetRangeThemeService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, ZebraCrossingCacheController, checkRangesEditablePermission, getMoveRangeCommandMutations, getMoveRangeUndoRedoMutations, getSheetCommandTarget } from "@univerjs/sheets";
4
4
  import { BehaviorSubject, Subject, filter, switchMap } from "rxjs";
5
5
 
6
6
  //#region src/types/enum.ts
@@ -316,7 +316,7 @@ const tableThemeConfig = tableDefaultThemeStyleArr.map((item, index) => {
316
316
  });
317
317
 
318
318
  //#endregion
319
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
319
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
320
320
  function _typeof(o) {
321
321
  "@babel/helpers - typeof";
322
322
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -327,7 +327,7 @@ function _typeof(o) {
327
327
  }
328
328
 
329
329
  //#endregion
330
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
330
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
331
331
  function toPrimitive(t, r) {
332
332
  if ("object" != _typeof(t) || !t) return t;
333
333
  var e = t[Symbol.toPrimitive];
@@ -340,14 +340,14 @@ function toPrimitive(t, r) {
340
340
  }
341
341
 
342
342
  //#endregion
343
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
343
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
344
344
  function toPropertyKey(t) {
345
345
  var i = toPrimitive(t, "string");
346
346
  return "symbol" == _typeof(i) ? i : i + "";
347
347
  }
348
348
 
349
349
  //#endregion
350
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
350
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
351
351
  function _defineProperty(e, r, t) {
352
352
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
353
353
  value: t,
@@ -620,7 +620,6 @@ const getWeekStart = (date) => {
620
620
  weekStart.setDate(diff);
621
621
  return weekStart;
622
622
  };
623
- const perWeek = 6048e5;
624
623
  /**
625
624
  * The provided date is in the current week.
626
625
  * @param {Date} date - The date to compare.
@@ -640,7 +639,8 @@ const thisWeek = (date, anchorTime = /* @__PURE__ */ new Date()) => {
640
639
  */
641
640
  const nextWeek = (date, anchorTime = /* @__PURE__ */ new Date()) => {
642
641
  const weekStart = getWeekStart(date);
643
- const anchorTimeNextWeekStart = new Date(getWeekStart(anchorTime).getTime() + perWeek);
642
+ const anchorTimeNextWeekStart = getWeekStart(anchorTime);
643
+ anchorTimeNextWeekStart.setDate(anchorTimeNextWeekStart.getDate() + 7);
644
644
  return weekStart.toDateString() === anchorTimeNextWeekStart.toDateString();
645
645
  };
646
646
  /**
@@ -651,7 +651,8 @@ const nextWeek = (date, anchorTime = /* @__PURE__ */ new Date()) => {
651
651
  */
652
652
  const lastWeek = (date, anchorTime = /* @__PURE__ */ new Date()) => {
653
653
  const weekStart = getWeekStart(date);
654
- const anchorTimeLastWeekStart = /* @__PURE__ */ new Date(getWeekStart(anchorTime).getTime() - perWeek);
654
+ const anchorTimeLastWeekStart = getWeekStart(anchorTime);
655
+ anchorTimeLastWeekStart.setDate(anchorTimeLastWeekStart.getDate() - 7);
655
656
  return weekStart.toDateString() === anchorTimeLastWeekStart.toDateString();
656
657
  };
657
658
  /**
@@ -685,7 +686,7 @@ const nextMonth = (date, anchorTime = /* @__PURE__ */ new Date()) => {
685
686
  nextMonthStart.setHours(0, 0, 0, 0);
686
687
  nextMonthStart.setMonth(nextMonthStart.getMonth() + 1, 1);
687
688
  const monthEnd = new Date(nextMonthStart);
688
- monthEnd.setMonth(monthEnd.getMonth() + 1, 0);
689
+ monthEnd.setMonth(monthEnd.getMonth() + 1);
689
690
  const dateTime = date.getTime();
690
691
  return dateTime >= nextMonthStart.getTime() && dateTime < monthEnd.getTime();
691
692
  };
@@ -696,9 +697,9 @@ const nextMonth = (date, anchorTime = /* @__PURE__ */ new Date()) => {
696
697
  * @returns {boolean} return the date is match
697
698
  */
698
699
  const lastMonth = (date, anchorTime = /* @__PURE__ */ new Date()) => {
699
- const lastMonthStart = getMonthStart(anchorTime);
700
- const monthEnd = new Date(lastMonthStart);
701
- monthEnd.setMonth(monthEnd.getMonth() + 1, 0);
700
+ const monthEnd = getMonthStart(anchorTime);
701
+ const lastMonthStart = new Date(monthEnd);
702
+ lastMonthStart.setMonth(lastMonthStart.getMonth() - 1);
702
703
  const dateTime = date.getTime();
703
704
  return dateTime >= lastMonthStart.getTime() && dateTime < monthEnd.getTime();
704
705
  };
@@ -739,7 +740,7 @@ const nextQuarter = (date, anchorTime = /* @__PURE__ */ new Date()) => {
739
740
  const nextQuarterStart = new Date(quarterStart);
740
741
  nextQuarterStart.setMonth(nextQuarterStart.getMonth() + 3);
741
742
  const nextQuarterEnd = new Date(nextQuarterStart);
742
- nextQuarterEnd.setMonth(nextQuarterEnd.getMonth() + 3, 0);
743
+ nextQuarterEnd.setMonth(nextQuarterEnd.getMonth() + 3);
743
744
  const dateTime = date.getTime();
744
745
  return dateTime >= nextQuarterStart.getTime() && dateTime < nextQuarterEnd.getTime();
745
746
  };
@@ -753,10 +754,8 @@ const lastQuarter = (date, anchorTime = /* @__PURE__ */ new Date()) => {
753
754
  const quarterStart = getQuarterStart(anchorTime);
754
755
  const lastQuarterStart = new Date(quarterStart);
755
756
  lastQuarterStart.setMonth(lastQuarterStart.getMonth() - 3);
756
- const lastQuarterEnd = new Date(quarterStart);
757
- lastQuarterEnd.setDate(0);
758
757
  const dateTime = date.getTime();
759
- return dateTime >= lastQuarterStart.getTime() && dateTime < lastQuarterEnd.getTime();
758
+ return dateTime >= lastQuarterStart.getTime() && dateTime < quarterStart.getTime();
760
759
  };
761
760
  /**
762
761
  * The provided date is in the current year.
@@ -1495,7 +1494,7 @@ var TableFilters = class {
1495
1494
  }
1496
1495
  getExecuteFunc(sheet, range, columnIndex, filter) {
1497
1496
  if (filter.filterType === "manual") {
1498
- const valuesSet = new Set(filter.values);
1497
+ const valuesSet = new Set(filter.values.map(String));
1499
1498
  return (value) => {
1500
1499
  if (value == null) return valuesSet.has(TABLE_FILTER_EMPTY_VALUE);
1501
1500
  return valuesSet.has(String(value));
@@ -1724,10 +1723,7 @@ var Table = class {
1724
1723
  return this._tableFilters.getFilterStates(range);
1725
1724
  }
1726
1725
  toJSON() {
1727
- const columns = [];
1728
- this._columns.forEach((column) => {
1729
- columns.push(column.toJSON());
1730
- });
1726
+ const columns = this._columnOrder.map((columnId) => this._columns.get(columnId).toJSON());
1731
1727
  return {
1732
1728
  id: this._id,
1733
1729
  name: this._name,
@@ -1777,7 +1773,7 @@ var Table = class {
1777
1773
  };
1778
1774
 
1779
1775
  //#endregion
1780
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
1776
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
1781
1777
  function __decorateParam(paramIndex, decorator) {
1782
1778
  return function(target, key) {
1783
1779
  decorator(target, key, paramIndex);
@@ -1785,7 +1781,7 @@ function __decorateParam(paramIndex, decorator) {
1785
1781
  }
1786
1782
 
1787
1783
  //#endregion
1788
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
1784
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
1789
1785
  function __decorate(decorators, target, key, desc) {
1790
1786
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1791
1787
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2052,6 +2048,28 @@ let TableManager = class TableManager extends Disposable {
2052
2048
  oldRange
2053
2049
  });
2054
2050
  }
2051
+ moveTable(unitId, tableId, subUnitId, range) {
2052
+ const table = this.getTableById(unitId, tableId);
2053
+ if (!table) return;
2054
+ const oldRange = table.getRange();
2055
+ const oldSubUnitId = table.getSubunitId();
2056
+ table.setSubunitId(subUnitId);
2057
+ table.setRange({ ...range });
2058
+ this._tableRangeChanged$.next({
2059
+ unitId,
2060
+ subUnitId,
2061
+ oldSubUnitId,
2062
+ tableId,
2063
+ range: { ...range },
2064
+ oldRange
2065
+ });
2066
+ this._tableFilterChanged$.next({
2067
+ unitId,
2068
+ subUnitId,
2069
+ oldSubUnitId,
2070
+ tableId
2071
+ });
2072
+ }
2055
2073
  setTableByConfig(unitId, tableId, config) {
2056
2074
  const unitMap = this._tableMap.get(unitId);
2057
2075
  const table = unitMap === null || unitMap === void 0 ? void 0 : unitMap.get(tableId);
@@ -2393,12 +2411,35 @@ const AddTableThemeCommand = {
2393
2411
  }
2394
2412
  };
2395
2413
 
2414
+ //#endregion
2415
+ //#region src/commands/mutations/set-table-filter.mutation.ts
2416
+ const SetSheetTableFilterMutation = {
2417
+ id: "sheet.mutation.set-table-filter",
2418
+ type: CommandType.MUTATION,
2419
+ handler: (accessor, params) => {
2420
+ const { tableId, unitId, column, tableFilter } = params;
2421
+ const tableManager = accessor.get(TableManager);
2422
+ const table = tableManager.getTable(unitId, tableId);
2423
+ tableManager.addFilter(unitId, tableId, column, tableFilter);
2424
+ if (table) {
2425
+ var _tableManager$toJSON$;
2426
+ const tableFilters = table.getTableFilters();
2427
+ if (params.filterOutRows) tableFilters.setFilterOutRows(params.filterOutRows);
2428
+ else params.filterOutRows = [...tableFilters.getFilterOutRows()];
2429
+ params.subUnitId = table.getSubunitId();
2430
+ params.tableFilteredOutRows = ((_tableManager$toJSON$ = tableManager.toJSON(unitId)[params.subUnitId]) === null || _tableManager$toJSON$ === void 0 ? void 0 : _tableManager$toJSON$.tableFilteredOutRows) ?? [];
2431
+ }
2432
+ return true;
2433
+ }
2434
+ };
2435
+
2396
2436
  //#endregion
2397
2437
  //#region src/commands/commands/delete-sheet-table.command.ts
2398
2438
  const DeleteSheetTableCommand = {
2399
2439
  id: "sheet.command.delete-table",
2400
2440
  type: CommandType.COMMAND,
2401
2441
  handler: (accessor, params) => {
2442
+ var _tableConfig$filters$;
2402
2443
  if (!params) return false;
2403
2444
  const undoRedoService = accessor.get(IUndoRedoService);
2404
2445
  const commandService = accessor.get(ICommandService);
@@ -2437,6 +2478,17 @@ const DeleteSheetTableCommand = {
2437
2478
  options: tableConfig.options
2438
2479
  }
2439
2480
  });
2481
+ (_tableConfig$filters$ = tableConfig.filters.tableColumnFilterList) === null || _tableConfig$filters$ === void 0 || _tableConfig$filters$.forEach((tableFilter, column) => {
2482
+ if (tableFilter) undos.push({
2483
+ id: SetSheetTableFilterMutation.id,
2484
+ params: {
2485
+ unitId: params.unitId,
2486
+ tableId: params.tableId,
2487
+ column,
2488
+ tableFilter
2489
+ }
2490
+ });
2491
+ });
2440
2492
  undos.push(...interceptorCommands.undos);
2441
2493
  if (sequenceExecute(redos, commandService).result) {
2442
2494
  undoRedoService.pushUndoRedo({
@@ -2779,28 +2831,6 @@ const SetSheetTableCommand = {
2779
2831
  }
2780
2832
  };
2781
2833
 
2782
- //#endregion
2783
- //#region src/commands/mutations/set-table-filter.mutation.ts
2784
- const SetSheetTableFilterMutation = {
2785
- id: "sheet.mutation.set-table-filter",
2786
- type: CommandType.MUTATION,
2787
- handler: (accessor, params) => {
2788
- const { tableId, unitId, column, tableFilter } = params;
2789
- const tableManager = accessor.get(TableManager);
2790
- const table = tableManager.getTable(unitId, tableId);
2791
- tableManager.addFilter(unitId, tableId, column, tableFilter);
2792
- if (table) {
2793
- var _tableManager$toJSON$;
2794
- const tableFilters = table.getTableFilters();
2795
- if (params.filterOutRows) tableFilters.setFilterOutRows(params.filterOutRows);
2796
- else params.filterOutRows = [...tableFilters.getFilterOutRows()];
2797
- params.subUnitId = table.getSubunitId();
2798
- params.tableFilteredOutRows = ((_tableManager$toJSON$ = tableManager.toJSON(unitId)[params.subUnitId]) === null || _tableManager$toJSON$ === void 0 ? void 0 : _tableManager$toJSON$.tableFilteredOutRows) ?? [];
2799
- }
2800
- return true;
2801
- }
2802
- };
2803
-
2804
2834
  //#endregion
2805
2835
  //#region src/commands/commands/set-table-filter.command.ts
2806
2836
  const SetSheetTableFilterCommand = {
@@ -2927,11 +2957,11 @@ let SheetsTableController = class SheetsTableController extends Disposable {
2927
2957
  });
2928
2958
  }));
2929
2959
  this.disposeWithMe(this._tableManager.tableRangeChanged$.subscribe((event) => {
2930
- const { range, tableId, unitId, subUnitId, oldRange } = event;
2960
+ const { range, tableId, unitId, subUnitId, oldRange, oldSubUnitId = subUnitId } = event;
2931
2961
  const rTree = this._ensureTableRangeRTree(unitId);
2932
2962
  rTree.remove({
2933
2963
  unitId,
2934
- sheetId: subUnitId,
2964
+ sheetId: oldSubUnitId,
2935
2965
  id: tableId,
2936
2966
  range: { ...oldRange }
2937
2967
  });
@@ -3853,7 +3883,7 @@ let SheetsTableThemeController = class SheetsTableThemeController extends Dispos
3853
3883
  });
3854
3884
  }));
3855
3885
  this.disposeWithMe(this._tableManager.tableRangeChanged$.subscribe((event) => {
3856
- const { range, oldRange, tableId, unitId, subUnitId } = event;
3886
+ const { range, oldRange, tableId, unitId, subUnitId, oldSubUnitId = subUnitId } = event;
3857
3887
  const table = this._tableManager.getTable(unitId, tableId);
3858
3888
  let tableStyleId = table.getTableStyleId();
3859
3889
  if (!tableStyleId) {
@@ -3862,7 +3892,7 @@ let SheetsTableThemeController = class SheetsTableThemeController extends Dispos
3862
3892
  }
3863
3893
  this._sheetRangeThemeService.removeRangeThemeRule(tableStyleId, {
3864
3894
  unitId,
3865
- subUnitId,
3895
+ subUnitId: oldSubUnitId,
3866
3896
  range: { ...oldRange }
3867
3897
  });
3868
3898
  this._sheetRangeThemeService.registerRangeThemeStyle(tableStyleId, {
@@ -3924,7 +3954,43 @@ SheetsTableThemeController = __decorate([
3924
3954
  //#endregion
3925
3955
  //#region package.json
3926
3956
  var name = "@univerjs/sheets-table";
3927
- var version = "1.0.3";
3957
+ var version = "1.1.0";
3958
+
3959
+ //#endregion
3960
+ //#region src/commands/mutations/move-sheet-table.mutation.ts
3961
+ const MoveSheetTableMutation = {
3962
+ id: "sheet.mutation.move-table",
3963
+ type: CommandType.MUTATION,
3964
+ handler: (accessor, params) => {
3965
+ if (!params) return false;
3966
+ const { unitId, tableId, subUnitId, range, calculatedColumns } = params;
3967
+ const manager = accessor.get(TableManager);
3968
+ const table = manager.getTableById(unitId, tableId);
3969
+ const workbook = accessor.get(IUniverInstanceService).getUnit(unitId);
3970
+ const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(subUnitId);
3971
+ if (!table || !worksheet) return false;
3972
+ const columns = calculatedColumns ?? table.getTableInfo().columns.map((column, columnIndex) => {
3973
+ var _worksheet$getCellRaw;
3974
+ const row = range.startRow + (table.isShowHeader() ? 1 : 0);
3975
+ const endRow = range.endRow - (table.isShowFooter() ? 1 : 0);
3976
+ const formula = column.formula && row <= endRow ? (_worksheet$getCellRaw = worksheet.getCellRaw(row, range.startColumn + columnIndex)) === null || _worksheet$getCellRaw === void 0 ? void 0 : _worksheet$getCellRaw.f : void 0;
3977
+ return {
3978
+ columnId: column.id,
3979
+ formula: formula || column.formula,
3980
+ formulaIsArray: column.formulaIsArray
3981
+ };
3982
+ }).filter((column) => column.formula);
3983
+ for (const config of columns) {
3984
+ const column = table.getColumn(config.columnId);
3985
+ if (column) {
3986
+ column.formula = config.formula;
3987
+ column.formulaIsArray = config.formulaIsArray;
3988
+ }
3989
+ }
3990
+ manager.moveTable(unitId, tableId, subUnitId, range);
3991
+ return true;
3992
+ }
3993
+ };
3928
3994
 
3929
3995
  //#endregion
3930
3996
  //#region src/controllers/sheet-table-formula.controller.ts
@@ -4020,6 +4086,114 @@ SheetTableFormulaController = __decorate([
4020
4086
  __decorateParam(2, IActiveDirtyManagerService)
4021
4087
  ], SheetTableFormulaController);
4022
4088
 
4089
+ //#endregion
4090
+ //#region src/controllers/sheet-table-move.controller.ts
4091
+ let SheetTableMoveController = class SheetTableMoveController extends Disposable {
4092
+ constructor(_tableManager, _sheetInterceptorService, _univerInstanceService, _injector, _localeService, _errorService) {
4093
+ super();
4094
+ this._tableManager = _tableManager;
4095
+ this._sheetInterceptorService = _sheetInterceptorService;
4096
+ this._univerInstanceService = _univerInstanceService;
4097
+ this._injector = _injector;
4098
+ this._localeService = _localeService;
4099
+ this._errorService = _errorService;
4100
+ this.disposeWithMe(this._sheetInterceptorService.interceptBeforeCommand({ performCheck: async (command) => command.id !== MoveRangeCommand.id || this._checkMove(command.params) }));
4101
+ this.disposeWithMe(this._sheetInterceptorService.interceptAfterCommand({ getMutations: (command) => command.id === MoveRangeCommand.id ? this._getMoveMutations(command.params) : {
4102
+ redos: [],
4103
+ undos: []
4104
+ } }));
4105
+ }
4106
+ _getTargets(params) {
4107
+ const source = getSheetCommandTarget(this._univerInstanceService, {
4108
+ unitId: params.fromUnitId ?? params.toUnitId,
4109
+ subUnitId: params.fromSubUnitId
4110
+ });
4111
+ return {
4112
+ source,
4113
+ target: getSheetCommandTarget(this._univerInstanceService, {
4114
+ unitId: params.toUnitId ?? (source === null || source === void 0 ? void 0 : source.unitId),
4115
+ subUnitId: params.toSubUnitId ?? (source === null || source === void 0 ? void 0 : source.subUnitId)
4116
+ })
4117
+ };
4118
+ }
4119
+ _checkMove(params) {
4120
+ const { source, target } = this._getTargets(params);
4121
+ if (!source || !target || source.unitId !== target.unitId) return false;
4122
+ const movingTables = this._tableManager.getTablesBySubunitId(source.unitId, source.subUnitId).filter((table) => Rectangle.contains(params.fromRange, table.getRange()));
4123
+ if (!movingTables.length) return true;
4124
+ const targetTables = this._tableManager.getTablesBySubunitId(target.unitId, target.subUnitId);
4125
+ for (const table of targetTables) {
4126
+ if (movingTables.includes(table) || !Rectangle.intersects(params.toRange, table.getRange())) continue;
4127
+ this._errorService.emit(this._localeService.t("sheets-table.moveTableOverlapError"));
4128
+ return false;
4129
+ }
4130
+ const { fromRange, toRange } = params;
4131
+ if (!this._isValidMoveRange(params, target.worksheet)) return false;
4132
+ return checkRangesEditablePermission(this._injector, source.unitId, source.subUnitId, [fromRange]) && checkRangesEditablePermission(this._injector, target.unitId, target.subUnitId, [toRange]);
4133
+ }
4134
+ _isValidMoveRange(params, worksheet) {
4135
+ const { fromRange, toRange } = params;
4136
+ if (fromRange.endRow - fromRange.startRow !== toRange.endRow - toRange.startRow || fromRange.endColumn - fromRange.startColumn !== toRange.endColumn - toRange.startColumn || toRange.startRow < 0 || toRange.startColumn < 0 || toRange.endRow >= worksheet.getRowCount() || toRange.endColumn >= worksheet.getColumnCount()) return false;
4137
+ return true;
4138
+ }
4139
+ _getMoveMutations(params) {
4140
+ const redos = [];
4141
+ const undos = [];
4142
+ const { source, target } = this._getTargets(params);
4143
+ if (!source || !target || source.unitId !== target.unitId) return {
4144
+ redos,
4145
+ undos
4146
+ };
4147
+ const rowOffset = params.toRange.startRow - params.fromRange.startRow;
4148
+ const columnOffset = params.toRange.startColumn - params.fromRange.startColumn;
4149
+ const tables = this._tableManager.getTablesBySubunitId(source.unitId, source.subUnitId);
4150
+ for (const table of tables) {
4151
+ const range = table.getRange();
4152
+ if (!Rectangle.contains(params.fromRange, range)) continue;
4153
+ redos.push({
4154
+ id: MoveSheetTableMutation.id,
4155
+ params: {
4156
+ unitId: source.unitId,
4157
+ tableId: table.getId(),
4158
+ subUnitId: target.subUnitId,
4159
+ range: {
4160
+ startRow: range.startRow + rowOffset,
4161
+ endRow: range.endRow + rowOffset,
4162
+ startColumn: range.startColumn + columnOffset,
4163
+ endColumn: range.endColumn + columnOffset
4164
+ }
4165
+ }
4166
+ });
4167
+ undos.push({
4168
+ id: MoveSheetTableMutation.id,
4169
+ params: {
4170
+ unitId: source.unitId,
4171
+ tableId: table.getId(),
4172
+ subUnitId: source.subUnitId,
4173
+ range,
4174
+ calculatedColumns: table.getTableInfo().columns.filter((column) => column.formula).map((column) => ({
4175
+ columnId: column.id,
4176
+ formula: column.formula,
4177
+ formulaIsArray: column.formulaIsArray
4178
+ }))
4179
+ }
4180
+ });
4181
+ }
4182
+ return {
4183
+ redos,
4184
+ undos
4185
+ };
4186
+ }
4187
+ };
4188
+ SheetTableMoveController = __decorate([
4189
+ __decorateParam(0, Inject(TableManager)),
4190
+ __decorateParam(1, Inject(SheetInterceptorService)),
4191
+ __decorateParam(2, IUniverInstanceService),
4192
+ __decorateParam(3, Inject(Injector)),
4193
+ __decorateParam(4, Inject(LocaleService)),
4194
+ __decorateParam(5, Inject(ErrorService))
4195
+ ], SheetTableMoveController);
4196
+
4023
4197
  //#endregion
4024
4198
  //#region src/controllers/sheet-table-range.controller.ts
4025
4199
  /**
@@ -4046,8 +4220,8 @@ let SheetTableRangeController = class SheetTableRangeController extends Disposab
4046
4220
  }
4047
4221
  _initRangeListener() {
4048
4222
  this.disposeWithMe(this._tableManager.tableRangeChanged$.subscribe((event) => {
4049
- const { range, tableId, unitId, subUnitId } = event;
4050
- this._exclusiveRangeService.clearExclusiveRangesByGroupId(unitId, subUnitId, FEATURE_TABLE_ID, tableId);
4223
+ const { range, tableId, unitId, subUnitId, oldSubUnitId = subUnitId } = event;
4224
+ this._exclusiveRangeService.clearExclusiveRangesByGroupId(unitId, oldSubUnitId, FEATURE_TABLE_ID, tableId);
4051
4225
  this._exclusiveRangeService.addExclusiveRange(unitId, subUnitId, FEATURE_TABLE_ID, [{
4052
4226
  range: { ...range },
4053
4227
  groupId: tableId
@@ -4602,7 +4776,6 @@ let TableFilterController = class TableFilterController extends Disposable {
4602
4776
  this._sheetRowFilteredService = _sheetRowFilteredService;
4603
4777
  this._zebraCrossingCacheController = _zebraCrossingCacheController;
4604
4778
  _defineProperty(this, "_tableFilteredOutRows", /* @__PURE__ */ new Map());
4605
- _defineProperty(this, "_subscription", null);
4606
4779
  this.registerFilterChangeEvent();
4607
4780
  this.initTableHiddenRowIntercept();
4608
4781
  this._registerFormulaRowFiltered();
@@ -4624,18 +4797,22 @@ let TableFilterController = class TableFilterController extends Disposable {
4624
4797
  }));
4625
4798
  }
4626
4799
  _initFilteredOutRows() {
4627
- this._tableManager.tableInitStatus$.pipe(filter((initialized) => initialized), switchMap(() => {
4800
+ this.disposeWithMe(this._tableManager.tableInitStatus$.pipe(filter((initialized) => initialized), switchMap(() => {
4628
4801
  return this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
4629
4802
  }), filter((workbook) => workbook !== null && workbook !== void 0), switchMap((workbook) => workbook.activeSheet$), filter((sheet) => sheet !== null && sheet !== void 0)).subscribe(() => {
4630
4803
  const target = getSheetCommandTarget(this._univerInstanceService);
4631
4804
  if (!target) return;
4632
4805
  const { unitId, subUnitId } = target;
4633
4806
  this._refreshTableFilteredOutRows(unitId, subUnitId);
4634
- });
4807
+ }));
4635
4808
  }
4636
4809
  registerFilterChangeEvent() {
4810
+ this.disposeWithMe(this._tableManager.tableDelete$.subscribe(({ unitId, subUnitId }) => {
4811
+ this._refreshTableFilteredOutRows(unitId, subUnitId);
4812
+ this._zebraCrossingCacheController.updateZebraCrossingCache(unitId, subUnitId);
4813
+ }));
4637
4814
  this.disposeWithMe(this._tableManager.tableFilterChanged$.subscribe((event) => {
4638
- const { unitId, subUnitId, tableId } = event;
4815
+ const { unitId, subUnitId, tableId, oldSubUnitId } = event;
4639
4816
  const workbook = this._univerInstanceService.getUnit(unitId);
4640
4817
  const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(subUnitId);
4641
4818
  const table = this._tableManager.getTable(unitId, tableId);
@@ -4643,6 +4820,10 @@ let TableFilterController = class TableFilterController extends Disposable {
4643
4820
  table.getTableFilters().doFilter(worksheet, table.getTableFilterRange(), workbook === null || workbook === void 0 ? void 0 : workbook.getDateSystem());
4644
4821
  this._refreshTableFilteredOutRows(unitId, subUnitId);
4645
4822
  this._zebraCrossingCacheController.updateZebraCrossingCache(unitId, subUnitId);
4823
+ if (oldSubUnitId && oldSubUnitId !== subUnitId) {
4824
+ this._refreshTableFilteredOutRows(unitId, oldSubUnitId);
4825
+ this._zebraCrossingCacheController.updateZebraCrossingCache(unitId, oldSubUnitId);
4826
+ }
4646
4827
  }));
4647
4828
  }
4648
4829
  _refreshTableFilteredOutRows(unitId, subUnitId) {
@@ -4663,9 +4844,8 @@ let TableFilterController = class TableFilterController extends Disposable {
4663
4844
  return `${unitId}|${subUnitId}`;
4664
4845
  }
4665
4846
  dispose() {
4666
- var _this$_subscription;
4667
4847
  super.dispose();
4668
- (_this$_subscription = this._subscription) === null || _this$_subscription === void 0 || _this$_subscription.unsubscribe();
4848
+ this._tableFilteredOutRows.clear();
4669
4849
  }
4670
4850
  };
4671
4851
  TableFilterController = __decorate([
@@ -4698,6 +4878,7 @@ let UniverSheetsTablePlugin = class UniverSheetsTablePlugin extends Plugin {
4698
4878
  [TableFilterController],
4699
4879
  [SheetTableRangeController],
4700
4880
  [SheetTableRefRangeController],
4881
+ [SheetTableMoveController],
4701
4882
  [SheetTableFormulaController]
4702
4883
  ]);
4703
4884
  }
@@ -4706,6 +4887,7 @@ let UniverSheetsTablePlugin = class UniverSheetsTablePlugin extends Plugin {
4706
4887
  [SheetTableFormulaController],
4707
4888
  [SheetTableRangeController],
4708
4889
  [SheetTableRefRangeController],
4890
+ [SheetTableMoveController],
4709
4891
  [SheetsTableThemeController],
4710
4892
  [SheetsTableController],
4711
4893
  [SheetTableService],
@@ -4719,6 +4901,7 @@ let UniverSheetsTablePlugin = class UniverSheetsTablePlugin extends Plugin {
4719
4901
  AddSheetTableMutation,
4720
4902
  DeleteSheetTableCommand,
4721
4903
  DeleteSheetTableMutation,
4904
+ MoveSheetTableMutation,
4722
4905
  SetSheetTableFilterMutation,
4723
4906
  SetSheetTableFilterCommand,
4724
4907
  SetSheetTableSortStateCommand,
@@ -2,6 +2,7 @@
2
2
  const locale = { "sheets-table": {
3
3
  columnPrefix: "عمود",
4
4
  tablePrefix: "جدول",
5
+ moveTableOverlapError: "يتداخل نطاق الوجهة مع جدول آخر.",
5
6
  tableNameError: "لا يمكن أن يحتوي اسم الجدول على مسافات، ولا يمكن أن يبدأ برقم، ولا يمكن أن يكون مطابقًا لاسم جدول موجود"
6
7
  } };
7
8