@univerjs/engine-formula 0.1.0-beta.4 → 0.1.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +3800 -3309
- package/lib/types/basics/__tests__/date.spec.d.ts +16 -0
- package/lib/types/basics/common.d.ts +6 -0
- package/lib/types/basics/date.d.ts +30 -0
- package/lib/types/basics/object-class-type.d.ts +3 -0
- package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +2 -1
- package/lib/types/commands/mutations/set-numfmt-formula-data.mutation.d.ts +21 -0
- package/lib/types/engine/ast-node/function-node.d.ts +12 -0
- package/lib/types/engine/reference-object/base-reference-object.d.ts +4 -1
- package/lib/types/engine/utils/__tests__/cell.spec.d.ts +16 -0
- package/lib/types/engine/utils/cell.d.ts +17 -0
- package/lib/types/engine/value-object/array-value-object.d.ts +8 -0
- package/lib/types/functions/__tests__/nested-functions.spec.d.ts +16 -0
- package/lib/types/functions/base-function.d.ts +7 -0
- package/lib/types/functions/date/date/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/date/date/index.d.ts +20 -0
- package/lib/types/functions/date/day/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/date/day/index.d.ts +20 -0
- package/lib/types/functions/date/edate/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/date/edate/index.d.ts +23 -0
- package/lib/types/functions/date/function-map.d.ts +3 -1
- package/lib/types/functions/date/month/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/date/month/index.d.ts +20 -0
- package/lib/types/functions/date/today/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/date/today/index.d.ts +22 -0
- package/lib/types/functions/date/year/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/date/year/index.d.ts +20 -0
- package/lib/types/functions/information/isblank/index.d.ts +1 -1
- package/lib/types/functions/logical/iferror/index.d.ts +1 -1
- package/lib/types/functions/lookup/address/index.d.ts +2 -3
- package/lib/types/functions/lookup/function-map.d.ts +1 -4
- package/lib/types/functions/lookup/lookup/index.d.ts +1 -1
- package/lib/types/functions/lookup/match/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/lookup/match/index.d.ts +23 -0
- package/lib/types/functions/lookup/offset/index.d.ts +1 -2
- package/lib/types/functions/lookup/xmatch/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/lookup/xmatch/index.d.ts +23 -0
- package/lib/types/functions/math/abs/index.d.ts +1 -2
- package/lib/types/functions/math/acos/index.d.ts +1 -2
- package/lib/types/functions/math/acosh/index.d.ts +1 -2
- package/lib/types/functions/math/acot/index.d.ts +1 -2
- package/lib/types/functions/meta/compare/index.d.ts +1 -1
- package/lib/types/functions/meta/multiply/index.d.ts +1 -1
- package/lib/types/functions/statistical/average/index.d.ts +1 -1
- package/lib/types/functions/statistical/count/index.d.ts +1 -1
- package/lib/types/functions/statistical/counta/index.d.ts +1 -1
- package/lib/types/functions/statistical/max/index.d.ts +1 -1
- package/lib/types/index.d.ts +3 -1
- package/lib/types/models/formula-data.model.d.ts +9 -3
- package/lib/types/services/current-data.service.d.ts +3 -1
- package/lib/types/services/runtime.service.d.ts +5 -2
- package/lib/umd/index.js +1 -1
- package/package.json +22 -9
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
|
|
17
|
+
import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
18
|
+
import { BaseFunction } from '../../base-function';
|
|
19
|
+
export declare class Xmatch extends BaseFunction {
|
|
20
|
+
calculate(lookupValue: BaseValueObject, lookupArray: ArrayValueObject, matchMode?: BaseValueObject, searchMode?: BaseValueObject): BaseValueObject;
|
|
21
|
+
private _handleSingleObject;
|
|
22
|
+
private _getSearchModeValue;
|
|
23
|
+
}
|
|
@@ -13,9 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
|
|
17
16
|
import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
18
17
|
import { BaseFunction } from '../../base-function';
|
|
19
18
|
export declare class Abs extends BaseFunction {
|
|
20
|
-
calculate(variant:
|
|
19
|
+
calculate(variant: BaseValueObject): BaseValueObject;
|
|
21
20
|
}
|
|
@@ -13,9 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
|
|
17
16
|
import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
18
17
|
import { BaseFunction } from '../../base-function';
|
|
19
18
|
export declare class Acos extends BaseFunction {
|
|
20
|
-
calculate(variant:
|
|
19
|
+
calculate(variant: BaseValueObject): BaseValueObject;
|
|
21
20
|
}
|
|
@@ -13,9 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
|
|
17
16
|
import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
18
17
|
import { BaseFunction } from '../../base-function';
|
|
19
18
|
export declare class Acosh extends BaseFunction {
|
|
20
|
-
calculate(variant:
|
|
19
|
+
calculate(variant: BaseValueObject): BaseValueObject;
|
|
21
20
|
}
|
|
@@ -13,9 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
|
|
17
16
|
import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
18
17
|
import { BaseFunction } from '../../base-function';
|
|
19
18
|
export declare class Acot extends BaseFunction {
|
|
20
|
-
calculate(variant:
|
|
19
|
+
calculate(variant: BaseValueObject): BaseValueObject;
|
|
21
20
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { compareToken } from '../../../basics/token';
|
|
17
|
-
import {
|
|
17
|
+
import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
18
18
|
import { BaseFunction } from '../../base-function';
|
|
19
19
|
export declare class Compare extends BaseFunction {
|
|
20
20
|
private _compareType;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
17
17
|
import { BaseFunction } from '../../base-function';
|
|
18
18
|
export declare class Multiply extends BaseFunction {
|
|
19
19
|
calculate(variant1: BaseValueObject, variant2: BaseValueObject): BaseValueObject;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type
|
|
16
|
+
import { type BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
17
17
|
import { BaseFunction } from '../../base-function';
|
|
18
18
|
export declare class Average extends BaseFunction {
|
|
19
19
|
calculate(...variants: BaseValueObject[]): BaseValueObject;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type
|
|
16
|
+
import { type BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
17
17
|
import { BaseFunction } from '../../base-function';
|
|
18
18
|
export declare class Count extends BaseFunction {
|
|
19
19
|
calculate(...variants: BaseValueObject[]): BaseValueObject;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type
|
|
16
|
+
import { type BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
17
17
|
import { BaseFunction } from '../../base-function';
|
|
18
18
|
export declare class CountA extends BaseFunction {
|
|
19
19
|
calculate(...variants: BaseValueObject[]): BaseValueObject;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type
|
|
16
|
+
import { type BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
17
17
|
import { BaseFunction } from '../../base-function';
|
|
18
18
|
export declare class Max extends BaseFunction {
|
|
19
19
|
calculate(...variants: BaseValueObject[]): BaseValueObject;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export type { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IDirtyUnitFeatureMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDataItem, IFormulaDatasetConfig, IRuntimeUnitDataType, ISheetData, IUnitData, IUnitSheetNameMap, } from './basics/common';
|
|
16
|
+
export type { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IDirtyUnitFeatureMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDataItem, IFormulaDatasetConfig, IRuntimeUnitDataType, ISheetData, IUnitData, IUnitSheetNameMap, INumfmtItemMap, } from './basics/common';
|
|
17
17
|
export { isInDirtyRange } from './basics/dirty';
|
|
18
18
|
export { ErrorType } from './basics/error-type';
|
|
19
19
|
export { FunctionType, type IFunctionInfo, type IFunctionParam } from './basics/function';
|
|
@@ -86,3 +86,5 @@ export { IFunctionService } from './services/function.service';
|
|
|
86
86
|
export { type IOtherFormulaManagerService, OtherFormulaManagerService } from './services/other-formula-manager.service';
|
|
87
87
|
export { FormulaExecuteStageType, type IExecutionInProgressParams } from './services/runtime.service';
|
|
88
88
|
export { FormulaExecutedStateType, type IAllRuntimeData } from './services/runtime.service';
|
|
89
|
+
export { SetNumfmtFormulaDataMutation } from './commands/mutations/set-numfmt-formula-data.mutation';
|
|
90
|
+
export type { ISetNumfmtFormulaDataMutationParams } from './commands/mutations/set-numfmt-formula-data.mutation';
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { ICellData, IObjectMatrixPrimitiveType, Nullable } from '@univerjs/core';
|
|
17
17
|
import { Disposable, IUniverInstanceService, ObjectMatrix } from '@univerjs/core';
|
|
18
|
-
import type { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IFormulaData, IFormulaDataItem, IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap } from '../basics/common';
|
|
18
|
+
import type { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IFormulaData, IFormulaDataItem, INumfmtItemMap, IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap } from '../basics/common';
|
|
19
19
|
import { LexerTreeBuilder } from '../engine/analysis/lexer-tree-builder';
|
|
20
20
|
export interface IFormulaIdMap {
|
|
21
21
|
f: string;
|
|
@@ -28,15 +28,20 @@ export declare class FormulaDataModel extends Disposable {
|
|
|
28
28
|
private _formulaData;
|
|
29
29
|
private _arrayFormulaRange;
|
|
30
30
|
private _arrayFormulaCellData;
|
|
31
|
+
private _numfmtItemMap;
|
|
31
32
|
constructor(_currentUniverService: IUniverInstanceService, _lexerTreeBuilder: LexerTreeBuilder);
|
|
32
33
|
clearPreviousArrayFormulaCellData(clearArrayFormulaCellData: IRuntimeUnitDataType): void;
|
|
33
34
|
mergeArrayFormulaCellData(unitData: IRuntimeUnitDataType): void;
|
|
34
35
|
getFormulaData(): IFormulaData;
|
|
35
36
|
setFormulaData(value: IFormulaData): void;
|
|
36
|
-
setArrayFormulaRange(value: IArrayFormulaRangeType): void;
|
|
37
37
|
getArrayFormulaRange(): IArrayFormulaRangeType;
|
|
38
|
-
|
|
38
|
+
setArrayFormulaRange(value: IArrayFormulaRangeType): void;
|
|
39
39
|
getArrayFormulaCellData(): IArrayFormulaUnitCellType;
|
|
40
|
+
setArrayFormulaCellData(value: IArrayFormulaUnitCellType): void;
|
|
41
|
+
getNumfmtItemMap(): INumfmtItemMap;
|
|
42
|
+
getNumfmtValue(unitId: string, sheetId: string, row: number, column: number): Nullable<string>;
|
|
43
|
+
setNumfmtItemMap(value: INumfmtItemMap): void;
|
|
44
|
+
updateNumfmtItemMap(value: INumfmtItemMap): void;
|
|
40
45
|
mergeArrayFormulaRange(formulaData: IArrayFormulaRangeType): void;
|
|
41
46
|
deleteArrayFormulaRange(unitId: string, sheetId: string, row: number, column: number): void;
|
|
42
47
|
initFormulaData(): void;
|
|
@@ -47,6 +52,7 @@ export declare class FormulaDataModel extends Disposable {
|
|
|
47
52
|
updateFormulaData(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): void;
|
|
48
53
|
updateArrayFormulaRange(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): void;
|
|
49
54
|
updateArrayFormulaCellData(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): void;
|
|
55
|
+
updateNumfmtData(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): void;
|
|
50
56
|
getFormulaItemBySId(sId: string, sheetId: string, unitId: string): Nullable<IFormulaDataItem>;
|
|
51
57
|
getFormulaDataItem(row: number, column: number, sheetId: string, unitId: string): IFormulaDataItem | undefined;
|
|
52
58
|
getFormulaIdMap(unitId: string, sheetId: string): Map<string, IFormulaIdMap>;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { IUnitRange, Nullable } from '@univerjs/core';
|
|
17
17
|
import { Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
18
|
-
import type { IDirtyUnitFeatureMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitSheetNameMap } from '../basics/common';
|
|
18
|
+
import type { IDirtyUnitFeatureMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig, INumfmtItemMap, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitSheetNameMap } from '../basics/common';
|
|
19
19
|
export declare const DEFAULT_DOCUMENT_SUB_COMPONENT_ID = "__default_document_sub_component_id20231101__";
|
|
20
20
|
export interface IFormulaCurrentConfigService {
|
|
21
21
|
load(config: IFormulaDatasetConfig): void;
|
|
@@ -42,6 +42,7 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
|
|
|
42
42
|
private _forceCalculate;
|
|
43
43
|
private _dirtyRanges;
|
|
44
44
|
private _dirtyNameMap;
|
|
45
|
+
private _numfmtItemMap;
|
|
45
46
|
private _dirtyUnitFeatureMap;
|
|
46
47
|
private _excludedCell;
|
|
47
48
|
constructor(_currentUniverService: IUniverInstanceService);
|
|
@@ -54,6 +55,7 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
|
|
|
54
55
|
isForceCalculate(): boolean;
|
|
55
56
|
getDirtyRanges(): IUnitRange[];
|
|
56
57
|
getDirtyNameMap(): IDirtyUnitSheetNameMap;
|
|
58
|
+
getNumfmtItemMap(): INumfmtItemMap;
|
|
57
59
|
getDirtyUnitFeatureMap(): IDirtyUnitFeatureMap;
|
|
58
60
|
load(config: IFormulaDatasetConfig): void;
|
|
59
61
|
loadDirtyRangesAndExcludedCell(dirtyRanges: IUnitRange[], excludedCell?: IUnitExcludedCell): void;
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { Nullable } from '@univerjs/core';
|
|
17
17
|
import { Disposable } from '@univerjs/core';
|
|
18
|
-
import type { IArrayFormulaRangeType, IFeatureDirtyRangeType, IRuntimeOtherUnitDataType, IRuntimeUnitDataType } from '../basics/common';
|
|
18
|
+
import type { IArrayFormulaRangeType, IFeatureDirtyRangeType, INumfmtItemMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataType } from '../basics/common';
|
|
19
19
|
import type { BaseAstNode } from '../engine/ast-node/base-ast-node';
|
|
20
|
-
import {
|
|
20
|
+
import type { FunctionVariantType } from '../engine/reference-object/base-reference-object';
|
|
21
21
|
import { IFormulaCurrentConfigService } from './current-data.service';
|
|
22
22
|
/**
|
|
23
23
|
* IDLE: Idle phase of the formula engine.
|
|
@@ -51,6 +51,7 @@ export interface IAllRuntimeData {
|
|
|
51
51
|
functionsExecutedState: FormulaExecutedStateType;
|
|
52
52
|
arrayFormulaCellData: IRuntimeUnitDataType;
|
|
53
53
|
clearArrayFormulaCellData: IRuntimeUnitDataType;
|
|
54
|
+
numfmtItemMap: INumfmtItemMap;
|
|
54
55
|
runtimeFeatureRange: {
|
|
55
56
|
[featureId: string]: IFeatureDirtyRangeType;
|
|
56
57
|
};
|
|
@@ -126,6 +127,7 @@ export declare class FormulaRuntimeService extends Disposable implements IFormul
|
|
|
126
127
|
private _unitArrayFormulaRange;
|
|
127
128
|
private _runtimeArrayFormulaCellData;
|
|
128
129
|
private _runtimeClearArrayFormulaCellData;
|
|
130
|
+
private _numfmtItemMap;
|
|
129
131
|
private _runtimeFeatureRange;
|
|
130
132
|
private _runtimeFeatureCellData;
|
|
131
133
|
private _functionsExecutedState;
|
|
@@ -171,6 +173,7 @@ export declare class FormulaRuntimeService extends Disposable implements IFormul
|
|
|
171
173
|
setRuntimeData(functionVariant: FunctionVariantType): void;
|
|
172
174
|
getUnitData(): IRuntimeUnitDataType;
|
|
173
175
|
getUnitArrayFormula(): IArrayFormulaRangeType;
|
|
176
|
+
getNumfmtItemMap(): INumfmtItemMap;
|
|
174
177
|
getRuntimeOtherData(): IRuntimeOtherUnitDataType;
|
|
175
178
|
getRuntimeArrayFormulaCellData(): IRuntimeUnitDataType;
|
|
176
179
|
getRuntimeClearArrayFormulaCellData(): IRuntimeUnitDataType;
|