@univerjs/sheets-formula 0.1.6 → 0.1.7

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.
@@ -10,7 +10,7 @@ import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/c
10
10
  *
11
11
  2. Use refRange to offset the formula position and return undo/redo data to setRangeValues mutation
12
12
  - Redo data: Delete the old value at the old position on the match, and add the new value at the new position (the new value first checks whether the old position has offset content, if so, use the new offset content, if not, take the old value)
13
- - Undo data: the old position on the match saves the old value, and the new position is left blank
13
+ - Undo data: the old position on the match saves the old value, and the new position delete value. Using undos when undoing will operate the data after the offset position.
14
14
 
15
15
  3. onCommandExecuted, before formula calculation, use the setRangeValues information to delete the old formulaData, ArrayFormula and ArrayFormulaCellData, and send the worker (complementary setRangeValues after collaborative conflicts, normal operation triggers formula update, undo/redo are captured and processed here)
16
16
  */
@@ -25,7 +25,6 @@ export declare class UpdateFormulaController extends Disposable {
25
25
  constructor(_currentUniverService: IUniverInstanceService, _commandService: ICommandService, _lexerTreeBuilder: LexerTreeBuilder, _formulaDataModel: FormulaDataModel, _sheetInterceptorService: SheetInterceptorService, _selectionManagerService: SelectionManagerService, _injector: Injector);
26
26
  private _initialize;
27
27
  private _commandExecutedListener;
28
- private _handleRedoUndo;
29
28
  private _handleSetRangeValuesMutation;
30
29
  private _handleRemoveSheetMutation;
31
30
  private _handleInsertSheetMutation;
@@ -43,7 +42,6 @@ export declare class UpdateFormulaController extends Disposable {
43
42
  private _handleDeleteRangeMoveLeft;
44
43
  private _handleSetWorksheetName;
45
44
  private _handleRemoveWorksheet;
46
- private _getUpdateFormulaMutations;
47
45
  private _getFormulaReferenceMoveInfo;
48
46
  private _getNewRangeByMoveParam;
49
47
  private _checkIsSameUnitAndSheet;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
@@ -15,7 +15,11 @@ export interface IRefRangeWithPosition {
15
15
  export declare function offsetFormula<T>(formulaData: IFormulaDataGenerics<T>, command: ICommandInfo, unitId: string, sheetId: string, selections?: Readonly<Nullable<ISelectionWithStyle[]>>, formulaRangeData?: IFormulaDataGenerics<IRange>, refRanges?: IRefRangeWithPosition[]): IFormulaDataGenerics<T>;
16
16
  export declare function offsetArrayFormula(arrayFormulaRange: IArrayFormulaRangeType, command: ICommandInfo, unitId: string, sheetId: string): IArrayFormulaRangeType;
17
17
  export declare function checkFormulaDataNull<T>(formulaData: IFormulaDataGenerics<T>, unitId: string, sheetId: string): boolean;
18
- export declare function removeFormulaData<T>(formulaData: IFormulaDataGenerics<T>, unitId: string, sheetId: string): void;
18
+ export declare function removeFormulaData<T>(formulaData: IFormulaDataGenerics<T>, unitId: string, sheetId: string): {
19
+ [x: string]: {
20
+ [x: string]: null;
21
+ };
22
+ } | undefined;
19
23
  export declare function removeValueFormulaArray<T>(formulaRange: IRange, formulaMatrix: ObjectMatrix<T>): void;
20
24
  export declare function inFormulaRange(row: number, column: number, formulaMatrix?: ObjectMatrix<IRange>): boolean;
21
25
  export declare function moveRangeUpdateFormulaData<T>(fromRange: IRange, toRange: IRange, fromArrayFormulaCellDataMatrix: ObjectMatrix<T>, toArrayFormulaCellDataMatrix: ObjectMatrix<T>, arrayFormulaRangeMatrix?: ObjectMatrix<IRange>): void;
@@ -1,5 +1,5 @@
1
- import { IFormulaData } from '@univerjs/engine-formula';
2
- import { IMutationInfo, IRange } from '@univerjs/core';
1
+ import { IFormulaData, IFormulaDataItem } from '@univerjs/engine-formula';
2
+ import { ICellData, IMutationInfo, IObjectMatrixPrimitiveType, IRange, Nullable } from '@univerjs/core';
3
3
 
4
4
  export declare enum FormulaReferenceMoveType {
5
5
  MoveRange = 0,// range
@@ -25,6 +25,18 @@ export interface IFormulaReferenceMoveParam {
25
25
  to?: IRange;
26
26
  sheetName?: string;
27
27
  }
28
+ export declare function getFormulaReferenceMoveUndoRedo(oldFormulaData: IFormulaData, newFormulaData: IFormulaData, formulaReferenceMoveParam: IFormulaReferenceMoveParam): {
29
+ undos: IMutationInfo<object>[];
30
+ redos: IMutationInfo<object>[];
31
+ };
32
+ export declare function getFormulaReferenceSheet(oldFormulaData: IFormulaData, newFormulaData: IFormulaData): {
33
+ undos: IMutationInfo<object>[];
34
+ redos: IMutationInfo<object>[];
35
+ };
36
+ export declare function getFormulaReferenceRange(oldFormulaData: IFormulaData, newFormulaData: IFormulaData, formulaReferenceMoveParam: IFormulaReferenceMoveParam): {
37
+ undos: IMutationInfo<object>[];
38
+ redos: IMutationInfo<object>[];
39
+ };
28
40
  /**
29
41
  * For different Command operations, it may be necessary to perform traversal in reverse or in forward order, so first determine the type of Command and then perform traversal.
30
42
  * @param oldFormulaData
@@ -33,6 +45,22 @@ export interface IFormulaReferenceMoveParam {
33
45
  * @returns
34
46
  */
35
47
  export declare function refRangeFormula(oldFormulaData: IFormulaData, newFormulaData: IFormulaData, formulaReferenceMoveParam: IFormulaReferenceMoveParam): {
36
- redos: IMutationInfo<object>[];
37
- undos: IMutationInfo<object>[];
38
- } | undefined;
48
+ redoFormulaData: IObjectMatrixPrimitiveType<Nullable<ICellData>>;
49
+ undoFormulaData: IObjectMatrixPrimitiveType<Nullable<ICellData>>;
50
+ };
51
+ /**
52
+ * Transfer the formulaDataItem to the cellData
53
+ * ┌────────────────────────────────┬─────────────────┐
54
+ * │ IFormulaDataItem │ ICellData │
55
+ * ├──────────────────┬─────┬───┬───┼───────────┬─────┤
56
+ * │ f │ si │ x │ y │ f │ si │
57
+ * ├──────────────────┼─────┼───┼───┼───────────┼─────┤
58
+ * │ =SUM(1) │ │ │ │ =SUM(1) │ │
59
+ * │ │ id1 │ │ │ │ id1 │
60
+ * │ =SUM(1) │ id1 │ │ │ =SUM(1) │ id1 │
61
+ * │ =SUM(1) │ id1 │ 0 │ 0 │ =SUM(1) │ id1 │
62
+ * │ =SUM(1) │ id1 │ 0 │ 1 │ │ id1 │
63
+ * └──────────────────┴─────┴───┴───┴───────────┴─────┘
64
+ */
65
+ export declare function formulaDataItemToCellData(formulaDataItem: IFormulaDataItem): ICellData | null;
66
+ export declare function isFormulaDataItem(cell: IFormulaDataItem): boolean;
@@ -5425,11 +5425,23 @@ declare const _default: {
5425
5425
  url: string;
5426
5426
  }[];
5427
5427
  functionParameter: {
5428
- number1: {
5428
+ maxRange: {
5429
5429
  name: string;
5430
5430
  detail: string;
5431
5431
  };
5432
- number2: {
5432
+ criteriaRange1: {
5433
+ name: string;
5434
+ detail: string;
5435
+ };
5436
+ criteria1: {
5437
+ name: string;
5438
+ detail: string;
5439
+ };
5440
+ criteriaRange2: {
5441
+ name: string;
5442
+ detail: string;
5443
+ };
5444
+ criteria2: {
5433
5445
  name: string;
5434
5446
  detail: string;
5435
5447
  };
@@ -1102,11 +1102,23 @@ declare const _default: {
1102
1102
  url: string;
1103
1103
  }[];
1104
1104
  functionParameter: {
1105
- number1: {
1105
+ maxRange: {
1106
1106
  name: string;
1107
1107
  detail: string;
1108
1108
  };
1109
- number2: {
1109
+ criteriaRange1: {
1110
+ name: string;
1111
+ detail: string;
1112
+ };
1113
+ criteria1: {
1114
+ name: string;
1115
+ detail: string;
1116
+ };
1117
+ criteriaRange2: {
1118
+ name: string;
1119
+ detail: string;
1120
+ };
1121
+ criteria2: {
1110
1122
  name: string;
1111
1123
  detail: string;
1112
1124
  };
@@ -1102,11 +1102,23 @@ declare const _default: {
1102
1102
  url: string;
1103
1103
  }[];
1104
1104
  functionParameter: {
1105
- number1: {
1105
+ maxRange: {
1106
1106
  name: string;
1107
1107
  detail: string;
1108
1108
  };
1109
- number2: {
1109
+ criteriaRange1: {
1110
+ name: string;
1111
+ detail: string;
1112
+ };
1113
+ criteria1: {
1114
+ name: string;
1115
+ detail: string;
1116
+ };
1117
+ criteriaRange2: {
1118
+ name: string;
1119
+ detail: string;
1120
+ };
1121
+ criteria2: {
1110
1122
  name: string;
1111
1123
  detail: string;
1112
1124
  };
@@ -1102,11 +1102,23 @@ declare const _default: {
1102
1102
  url: string;
1103
1103
  }[];
1104
1104
  functionParameter: {
1105
- number1: {
1105
+ maxRange: {
1106
1106
  name: string;
1107
1107
  detail: string;
1108
1108
  };
1109
- number2: {
1109
+ criteriaRange1: {
1110
+ name: string;
1111
+ detail: string;
1112
+ };
1113
+ criteria1: {
1114
+ name: string;
1115
+ detail: string;
1116
+ };
1117
+ criteriaRange2: {
1118
+ name: string;
1119
+ detail: string;
1120
+ };
1121
+ criteria2: {
1110
1122
  name: string;
1111
1123
  detail: string;
1112
1124
  };
@@ -5425,11 +5425,23 @@ declare const _default: {
5425
5425
  url: string;
5426
5426
  }[];
5427
5427
  functionParameter: {
5428
- number1: {
5428
+ maxRange: {
5429
5429
  name: string;
5430
5430
  detail: string;
5431
5431
  };
5432
- number2: {
5432
+ criteriaRange1: {
5433
+ name: string;
5434
+ detail: string;
5435
+ };
5436
+ criteria1: {
5437
+ name: string;
5438
+ detail: string;
5439
+ };
5440
+ criteriaRange2: {
5441
+ name: string;
5442
+ detail: string;
5443
+ };
5444
+ criteria2: {
5433
5445
  name: string;
5434
5446
  detail: string;
5435
5447
  };