@univerjs/engine-formula 0.1.2 → 0.1.4
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 +5872 -4638
- package/lib/types/basics/common.d.ts +11 -4
- package/lib/types/basics/date.d.ts +1 -1
- package/lib/types/basics/format.d.ts +24 -0
- package/lib/types/basics/inverted-index-cache.d.ts +2 -2
- package/lib/types/basics/match-token.d.ts +5 -0
- package/lib/types/basics/object-class-type.d.ts +4 -0
- package/lib/types/basics/runtime.d.ts +2 -1
- package/lib/types/basics/token-type.d.ts +1 -0
- package/lib/types/basics/token.d.ts +1 -0
- package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +2 -2
- package/lib/types/engine/analysis/lexer-tree-builder.d.ts +5 -1
- package/lib/types/engine/analysis/parser.d.ts +0 -1
- package/lib/types/engine/ast-node/reference-node.d.ts +3 -3
- package/lib/types/engine/dependency/dependency-tree.d.ts +20 -4
- package/lib/types/engine/dependency/formula-dependency.d.ts +0 -6
- package/lib/types/engine/reference-object/base-reference-object.d.ts +8 -6
- package/lib/types/engine/utils/ast-node-tool.d.ts +18 -0
- package/lib/types/engine/utils/char-kit.d.ts +25 -0
- package/lib/types/engine/utils/compare.d.ts +1 -0
- package/lib/types/engine/utils/object-compare.d.ts +0 -1
- package/lib/types/engine/utils/prefixHandler.d.ts +24 -0
- package/lib/types/engine/utils/r1c1-reference.d.ts +2 -3
- package/lib/types/engine/utils/reference.d.ts +4 -9
- package/lib/types/engine/value-object/__tests__/array-value-divided.spec.d.ts +16 -0
- package/lib/types/engine/value-object/__tests__/array-value-minus.spec.d.ts +16 -0
- package/lib/types/engine/value-object/__tests__/array-value-multiply.spec.d.ts +16 -0
- package/lib/types/engine/value-object/__tests__/array-value-plus.spec.d.ts +16 -0
- package/lib/types/engine/value-object/array-value-object.d.ts +7 -7
- package/lib/types/engine/value-object/base-value-object.d.ts +9 -4
- package/lib/types/engine/value-object/cube-value-object.d.ts +30 -0
- package/lib/types/engine/value-object/lambda-value-object.d.ts +1 -0
- package/lib/types/engine/value-object/primitive-object.d.ts +25 -4
- package/lib/types/functions/base-function.d.ts +4 -9
- package/lib/types/functions/logical/or/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/logical/or/index.d.ts +20 -0
- package/lib/types/functions/lookup/function-map.d.ts +1 -4
- package/lib/types/functions/lookup/index/index.d.ts +11 -2
- package/lib/types/functions/lookup/offset/index.d.ts +2 -2
- package/lib/types/functions/meta/cube/index.d.ts +20 -0
- package/lib/types/functions/meta/function-map.d.ts +2 -2
- package/lib/types/functions/meta/function-names.d.ts +2 -1
- package/lib/types/functions/text/len/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/len/index.d.ts +21 -0
- package/lib/types/functions/text/lenb/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/lenb/index.d.ts +21 -0
- package/lib/types/functions/text/text/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/text/index.d.ts +20 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/plugin.d.ts +1 -1
- package/lib/types/services/current-data.service.d.ts +3 -0
- package/lib/umd/index.js +1 -1
- package/package.json +13 -11
|
@@ -13,14 +13,15 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import type { Nullable } from '@univerjs/core';
|
|
17
|
+
import { FormulaAstLRU } from '../../basics/cache-lru';
|
|
16
18
|
import { ConcatenateType } from '../../basics/common';
|
|
17
19
|
import { ErrorType } from '../../basics/error-type';
|
|
18
20
|
import { ObjectClassType } from '../../basics/object-class-type';
|
|
19
21
|
import { compareToken } from '../../basics/token';
|
|
20
22
|
export type callbackMapFnType = (currentValue: BaseValueObject, row: number, column: number) => BaseValueObject;
|
|
21
|
-
export type callbackProductFnType = (currentValue: BaseValueObject, operationValue: BaseValueObject) => BaseValueObject;
|
|
22
23
|
export interface IArrayValueObject {
|
|
23
|
-
calculateValueList: BaseValueObject[][];
|
|
24
|
+
calculateValueList: Nullable<BaseValueObject>[][];
|
|
24
25
|
rowCount: number;
|
|
25
26
|
columnCount: number;
|
|
26
27
|
unitId: string;
|
|
@@ -43,9 +44,10 @@ export declare class BaseValueObject extends ObjectClassType {
|
|
|
43
44
|
unitId: string;
|
|
44
45
|
};
|
|
45
46
|
getValue(): string | number | boolean;
|
|
46
|
-
getArrayValue(): BaseValueObject[][];
|
|
47
|
+
getArrayValue(): Nullable<BaseValueObject>[][];
|
|
47
48
|
setValue(value: string | number | boolean): void;
|
|
48
49
|
setArrayValue(value: BaseValueObject[][]): void;
|
|
50
|
+
isCube(): boolean;
|
|
49
51
|
isArray(): boolean;
|
|
50
52
|
isString(): boolean;
|
|
51
53
|
isNumber(): boolean;
|
|
@@ -78,7 +80,6 @@ export declare class BaseValueObject extends ObjectClassType {
|
|
|
78
80
|
* @returns
|
|
79
81
|
*/
|
|
80
82
|
mapValue(callbackFn: callbackMapFnType): BaseValueObject;
|
|
81
|
-
product(valueObject: BaseValueObject, callbackFn: callbackProductFnType): BaseValueObject;
|
|
82
83
|
compare(valueObject: BaseValueObject, operator: compareToken): BaseValueObject;
|
|
83
84
|
isEqual(valueObject: BaseValueObject): BaseValueObject;
|
|
84
85
|
isNotEqual(valueObject: BaseValueObject): BaseValueObject;
|
|
@@ -147,10 +148,14 @@ export declare class BaseValueObject extends ObjectClassType {
|
|
|
147
148
|
floorInverse(valueObject: BaseValueObject): BaseValueObject;
|
|
148
149
|
ceil(valueObject: BaseValueObject): BaseValueObject;
|
|
149
150
|
ceilInverse(valueObject: BaseValueObject): BaseValueObject;
|
|
151
|
+
convertToNumberObjectValue(): BaseValueObject;
|
|
152
|
+
convertToBooleanObjectValue(): BaseValueObject;
|
|
150
153
|
}
|
|
154
|
+
export declare const ErrorValueObjectCache: FormulaAstLRU<ErrorValueObject>;
|
|
151
155
|
export declare class ErrorValueObject extends BaseValueObject {
|
|
152
156
|
private _errorType;
|
|
153
157
|
private _errorContent;
|
|
158
|
+
static create(errorType: ErrorType, errorContent?: string): ErrorValueObject;
|
|
154
159
|
constructor(_errorType: ErrorType, _errorContent?: string);
|
|
155
160
|
getValue(): ErrorType;
|
|
156
161
|
getErrorType(): ErrorType;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 './array-value-object';
|
|
17
|
+
import { BaseValueObject } from './base-value-object';
|
|
18
|
+
import { NumberValueObject } from './primitive-object';
|
|
19
|
+
export declare class CubeValueObject extends BaseValueObject {
|
|
20
|
+
static create(values: ArrayValueObject[]): CubeValueObject;
|
|
21
|
+
isCube(): boolean;
|
|
22
|
+
private _values;
|
|
23
|
+
constructor(values: ArrayValueObject[]);
|
|
24
|
+
sum(): NumberValueObject;
|
|
25
|
+
max(): NumberValueObject;
|
|
26
|
+
min(): NumberValueObject;
|
|
27
|
+
count(): NumberValueObject;
|
|
28
|
+
countA(): NumberValueObject;
|
|
29
|
+
countBlank(): NumberValueObject;
|
|
30
|
+
}
|
|
@@ -21,6 +21,7 @@ export declare class LambdaValueObjectObject extends BaseValueObject {
|
|
|
21
21
|
private _lambdaNode;
|
|
22
22
|
private _interpreter;
|
|
23
23
|
private _lambdaPrivacyVarKeys;
|
|
24
|
+
static create(lambdaNode: BaseAstNode, interpreter: Interpreter, lambdaPrivacyVarKeys: string[]): LambdaValueObjectObject;
|
|
24
25
|
private _lambdaPrivacyValueMap;
|
|
25
26
|
constructor(_lambdaNode: BaseAstNode, _interpreter: Interpreter, _lambdaPrivacyVarKeys: string[]);
|
|
26
27
|
isLambda(): boolean;
|
|
@@ -14,9 +14,12 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { compareToken } from '../../basics/token';
|
|
17
|
-
import {
|
|
17
|
+
import { FormulaAstLRU } from '../../basics/cache-lru';
|
|
18
|
+
import { BaseValueObject, ErrorValueObject } from './base-value-object';
|
|
18
19
|
export type PrimitiveValueType = string | boolean | number | null;
|
|
19
20
|
export declare class NullValueObject extends BaseValueObject {
|
|
21
|
+
private static _instance;
|
|
22
|
+
static create(): NullValueObject;
|
|
20
23
|
isNull(): boolean;
|
|
21
24
|
plus(valueObject: BaseValueObject): BaseValueObject;
|
|
22
25
|
minus(valueObject: BaseValueObject): BaseValueObject;
|
|
@@ -52,10 +55,15 @@ export declare class NullValueObject extends BaseValueObject {
|
|
|
52
55
|
round(valueObject: BaseValueObject): BaseValueObject;
|
|
53
56
|
floor(valueObject: BaseValueObject): BaseValueObject;
|
|
54
57
|
ceil(valueObject: BaseValueObject): BaseValueObject;
|
|
58
|
+
convertToNumberObjectValue(): NumberValueObject;
|
|
59
|
+
convertToBooleanObjectValue(): BooleanValueObject;
|
|
55
60
|
}
|
|
56
61
|
export declare class BooleanValueObject extends BaseValueObject {
|
|
57
62
|
private _value;
|
|
58
|
-
|
|
63
|
+
private static _instanceTrue;
|
|
64
|
+
private static _instanceFalse;
|
|
65
|
+
static create(value: boolean): BooleanValueObject;
|
|
66
|
+
constructor(rawValue: boolean);
|
|
59
67
|
getValue(): boolean;
|
|
60
68
|
isBoolean(): boolean;
|
|
61
69
|
getNegative(): BaseValueObject;
|
|
@@ -90,10 +98,14 @@ export declare class BooleanValueObject extends BaseValueObject {
|
|
|
90
98
|
round(valueObject: BaseValueObject): BaseValueObject;
|
|
91
99
|
floor(valueObject: BaseValueObject): BaseValueObject;
|
|
92
100
|
ceil(valueObject: BaseValueObject): BaseValueObject;
|
|
101
|
+
convertToNumberObjectValue(): ErrorValueObject | NumberValueObject;
|
|
102
|
+
convertToBooleanObjectValue(): this;
|
|
93
103
|
}
|
|
104
|
+
export declare const NumberValueObjectCache: FormulaAstLRU<NumberValueObject>;
|
|
94
105
|
export declare class NumberValueObject extends BaseValueObject {
|
|
95
106
|
private _value;
|
|
96
|
-
|
|
107
|
+
static create(value: number, pattern?: string): NumberValueObject;
|
|
108
|
+
constructor(rawValue: number);
|
|
97
109
|
getValue(): number;
|
|
98
110
|
setValue(value: number): void;
|
|
99
111
|
isNumber(): boolean;
|
|
@@ -134,16 +146,25 @@ export declare class NumberValueObject extends BaseValueObject {
|
|
|
134
146
|
round(valueObject: BaseValueObject): BaseValueObject;
|
|
135
147
|
floor(valueObject: BaseValueObject): BaseValueObject;
|
|
136
148
|
ceil(valueObject: BaseValueObject): BaseValueObject;
|
|
149
|
+
convertToNumberObjectValue(): this;
|
|
150
|
+
convertToBooleanObjectValue(): BooleanValueObject;
|
|
137
151
|
private _compareInfinity;
|
|
138
152
|
}
|
|
153
|
+
export declare const StringValueObjectCache: FormulaAstLRU<StringValueObject>;
|
|
139
154
|
export declare class StringValueObject extends BaseValueObject {
|
|
140
155
|
private _value;
|
|
141
|
-
|
|
156
|
+
static create(value: string): StringValueObject;
|
|
157
|
+
constructor(rawValue: string);
|
|
142
158
|
getValue(): string;
|
|
143
159
|
isString(): boolean;
|
|
144
160
|
concatenateFront(valueObject: BaseValueObject): BaseValueObject;
|
|
145
161
|
concatenateBack(valueObject: BaseValueObject): BaseValueObject;
|
|
146
162
|
compare(valueObject: BaseValueObject, operator: compareToken): BaseValueObject;
|
|
147
163
|
compareBy(value: string | number | boolean, operator: compareToken): BaseValueObject;
|
|
164
|
+
convertToNumberObjectValue(): ErrorValueObject | NumberValueObject;
|
|
165
|
+
convertToBooleanObjectValue(): BooleanValueObject;
|
|
148
166
|
private _checkWildcard;
|
|
149
167
|
}
|
|
168
|
+
export declare function createBooleanValueObjectByRawValue(rawValue: string | number | boolean): BooleanValueObject;
|
|
169
|
+
export declare function createStringValueObjectByRawValue(rawValue: string | number | boolean): StringValueObject;
|
|
170
|
+
export declare function createNumberValueObjectByRawValue(rawValue: string | number | boolean): ErrorValueObject | NumberValueObject;
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { Nullable } from '@univerjs/core';
|
|
16
|
+
import type { IRange, Nullable } from '@univerjs/core';
|
|
17
17
|
import { Disposable } from '@univerjs/core';
|
|
18
18
|
import type { IFunctionNames } from '../basics/function';
|
|
19
|
-
import type { FunctionVariantType, NodeValueType } from '../engine/reference-object/base-reference-object';
|
|
19
|
+
import type { BaseReferenceObject, FunctionVariantType, NodeValueType } from '../engine/reference-object/base-reference-object';
|
|
20
20
|
import type { ArrayBinarySearchType } from '../engine/utils/compare';
|
|
21
21
|
import { ArrayOrderSearchType } from '../engine/utils/compare';
|
|
22
22
|
import type { ArrayValueObject } from '../engine/value-object/array-value-object';
|
|
@@ -54,7 +54,6 @@ export declare class BaseFunction extends Disposable {
|
|
|
54
54
|
* For instance, The column number (starting with 1 for the left-most column of table_array) that contains the return value.
|
|
55
55
|
* https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1
|
|
56
56
|
* @param indexNum
|
|
57
|
-
* @returns
|
|
58
57
|
*/
|
|
59
58
|
getIndexNumValue(indexNum: BaseValueObject, defaultValue?: number): number | ErrorValueObject;
|
|
60
59
|
/**
|
|
@@ -68,28 +67,24 @@ export declare class BaseFunction extends Disposable {
|
|
|
68
67
|
* If a1 is FALSE, ref_text is interpreted as an R1C1-style reference.
|
|
69
68
|
* https://support.microsoft.com/zh-cn/office/indirect-%E5%87%BD%E6%95%B0-474b3a3a-8a26-4f44-b491-92b6306fa261
|
|
70
69
|
* @param logicValueObject
|
|
71
|
-
* @returns
|
|
72
70
|
*/
|
|
73
71
|
getZeroOrOneByOneDefault(logicValueObject?: BaseValueObject): number | undefined;
|
|
74
72
|
/**
|
|
75
73
|
* A logical value that specifies 1/TRUE , 0/FALSE, -1, default 1.
|
|
76
74
|
* The difference from getZeroOrOneByOneDefault is that we need to get -1
|
|
77
75
|
* @param logicValueObject
|
|
78
|
-
* @returns
|
|
79
76
|
*/
|
|
80
77
|
getMatchTypeValue(logicValueObject?: BaseValueObject): number | undefined;
|
|
81
78
|
binarySearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayBinarySearchType): BaseValueObject;
|
|
82
79
|
equalSearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean): BaseValueObject;
|
|
83
80
|
fuzzySearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean): BaseValueObject;
|
|
84
81
|
orderSearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayOrderSearchType, isDesc?: boolean): BaseValueObject;
|
|
85
|
-
/**
|
|
86
|
-
* @param axis 0 row, 1 column
|
|
87
|
-
* @returns
|
|
88
|
-
*/
|
|
89
82
|
binarySearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, axis?: number, searchType?: ArrayBinarySearchType): ErrorValueObject | ArrayValueObject | undefined;
|
|
90
83
|
equalSearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean, axis?: number): ErrorValueObject | ArrayValueObject | undefined;
|
|
91
84
|
fuzzySearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean, axis?: number): ErrorValueObject | ArrayValueObject | undefined;
|
|
92
85
|
orderSearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayOrderSearchType, isDesc?: boolean, axis?: number): ErrorValueObject | ArrayValueObject | undefined;
|
|
93
86
|
flattenArray(variants: BaseValueObject[], ignoreLogicalValuesAndText?: boolean): ArrayValueObject | BaseValueObject;
|
|
94
87
|
private _includingLogicalValuesAndText;
|
|
88
|
+
createReferenceObject(reference: BaseReferenceObject, range: IRange): ErrorValueObject | BaseReferenceObject;
|
|
89
|
+
private _setReferenceDefault;
|
|
95
90
|
}
|
|
@@ -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 {};
|
|
@@ -0,0 +1,20 @@
|
|
|
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 BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
17
|
+
import { BaseFunction } from '../../base-function';
|
|
18
|
+
export declare class Or extends BaseFunction {
|
|
19
|
+
calculate(...logicalValues: BaseValueObject[]): BaseValueObject;
|
|
20
|
+
}
|
|
@@ -13,14 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Address } from './address';
|
|
17
16
|
import { Column } from './column';
|
|
18
17
|
import { FUNCTION_NAMES_LOOKUP } from './function-names';
|
|
19
|
-
import { Indirect } from './indirect';
|
|
20
18
|
import { Lookup } from './lookup';
|
|
21
19
|
import { Match } from './match';
|
|
22
20
|
import { Offset } from './offset';
|
|
23
21
|
import { Xlookup } from './xlookup';
|
|
24
22
|
import { Xmatch } from './xmatch';
|
|
25
|
-
|
|
26
|
-
export declare const functionLookup: ((FUNCTION_NAMES_LOOKUP | typeof Address)[] | (FUNCTION_NAMES_LOOKUP | typeof Column)[] | (FUNCTION_NAMES_LOOKUP | typeof Index)[] | (FUNCTION_NAMES_LOOKUP | typeof Indirect)[] | (FUNCTION_NAMES_LOOKUP | typeof Offset)[] | (FUNCTION_NAMES_LOOKUP | typeof Lookup)[] | (FUNCTION_NAMES_LOOKUP | typeof Match)[] | (FUNCTION_NAMES_LOOKUP | typeof Xlookup)[] | (FUNCTION_NAMES_LOOKUP | typeof Xmatch)[])[];
|
|
23
|
+
export declare const functionLookup: ((FUNCTION_NAMES_LOOKUP | typeof Column)[] | (FUNCTION_NAMES_LOOKUP | typeof Offset)[] | (FUNCTION_NAMES_LOOKUP | typeof Lookup)[] | (FUNCTION_NAMES_LOOKUP | typeof Match)[] | (FUNCTION_NAMES_LOOKUP | typeof Xlookup)[] | (FUNCTION_NAMES_LOOKUP | typeof Xmatch)[])[];
|
|
@@ -13,12 +13,21 @@
|
|
|
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 { BaseReferenceObject } from '../../../engine/reference-object/base-reference-object';
|
|
17
17
|
import { type BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
18
18
|
import { BaseFunction } from '../../base-function';
|
|
19
|
+
/**
|
|
20
|
+
* The result of the INDEX function is a reference and is interpreted as such by other formulas. Depending on the formula, the return value of INDEX may be used as a reference or as a value.
|
|
21
|
+
*
|
|
22
|
+
* =INDEX(A2:A5,2,1):A1 same as =A1:A3
|
|
23
|
+
*
|
|
24
|
+
* OPTIMIZE: maybe we can remove some unknown type
|
|
25
|
+
*/
|
|
19
26
|
export declare class Index extends BaseFunction {
|
|
20
|
-
|
|
27
|
+
needsReferenceObject: boolean;
|
|
28
|
+
calculate(referenceObject: BaseValueObject, rowNum: BaseValueObject, columnNum?: BaseValueObject, areaNum?: BaseValueObject): BaseValueObject | BaseReferenceObject;
|
|
21
29
|
private _calculateSingleCell;
|
|
22
30
|
private _getNumberValue;
|
|
23
31
|
private _getAreaNumberValue;
|
|
32
|
+
private _getReferenceObject;
|
|
24
33
|
}
|
|
@@ -17,6 +17,6 @@ import type { BaseReferenceObject } from '../../../engine/reference-object/base-
|
|
|
17
17
|
import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
18
18
|
import { BaseFunction } from '../../base-function';
|
|
19
19
|
export declare class Offset extends BaseFunction {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
needsReferenceObject: boolean;
|
|
21
|
+
calculate(referenceObject: BaseValueObject, rows: BaseValueObject, columns: BaseValueObject, height?: BaseValueObject, width?: BaseValueObject): BaseValueObject | BaseReferenceObject;
|
|
22
22
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
17
|
+
import { BaseFunction } from '../../base-function';
|
|
18
|
+
export declare class Cube extends BaseFunction {
|
|
19
|
+
calculate(...variants: BaseValueObject[]): BaseValueObject;
|
|
20
|
+
}
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { Cube } from './cube';
|
|
17
17
|
import { FUNCTION_NAMES_META } from './function-names';
|
|
18
|
-
export declare const functionMeta: (FUNCTION_NAMES_META | typeof
|
|
18
|
+
export declare const functionMeta: (FUNCTION_NAMES_META | typeof Cube)[][];
|
|
@@ -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 {};
|
|
@@ -0,0 +1,21 @@
|
|
|
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 BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
17
|
+
import { BaseFunction } from '../../base-function';
|
|
18
|
+
export declare class Len extends BaseFunction {
|
|
19
|
+
calculate(text: BaseValueObject): BaseValueObject;
|
|
20
|
+
private _handleSingleText;
|
|
21
|
+
}
|
|
@@ -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 {};
|
|
@@ -0,0 +1,21 @@
|
|
|
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 BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
17
|
+
import { BaseFunction } from '../../base-function';
|
|
18
|
+
export declare class Lenb extends BaseFunction {
|
|
19
|
+
calculate(text: BaseValueObject): BaseValueObject;
|
|
20
|
+
private _handleSingleText;
|
|
21
|
+
}
|
|
@@ -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 {};
|
|
@@ -0,0 +1,20 @@
|
|
|
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 BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
17
|
+
import { BaseFunction } from '../../base-function';
|
|
18
|
+
export declare class Text extends BaseFunction {
|
|
19
|
+
calculate(text: BaseValueObject, formatText: BaseValueObject): BaseValueObject;
|
|
20
|
+
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -88,3 +88,7 @@ export { FormulaExecutedStateType, type IAllRuntimeData } from './services/runti
|
|
|
88
88
|
export { SetNumfmtFormulaDataMutation } from './commands/mutations/set-numfmt-formula-data.mutation';
|
|
89
89
|
export type { ISetNumfmtFormulaDataMutationParams } from './commands/mutations/set-numfmt-formula-data.mutation';
|
|
90
90
|
export { isReferenceString } from './basics/regex';
|
|
91
|
+
export { matchRefDrawToken } from './basics/match-token';
|
|
92
|
+
export { IDefinedNamesService, DefinedNamesService } from './services/defined-names.service';
|
|
93
|
+
export { IFormulaRuntimeService, FormulaRuntimeService } from './services/runtime.service';
|
|
94
|
+
export { IFormulaCurrentConfigService, FormulaCurrentConfigService } from './services/current-data.service';
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ import type { IFunctionNames } from './basics/function';
|
|
|
20
20
|
import type { BaseFunction } from './functions/base-function';
|
|
21
21
|
interface IUniverFormulaEngine {
|
|
22
22
|
notExecuteFormula?: boolean;
|
|
23
|
-
function
|
|
23
|
+
function?: Array<[Ctor<BaseFunction>, IFunctionNames]>;
|
|
24
24
|
}
|
|
25
25
|
export declare class UniverFormulaEnginePlugin extends Plugin {
|
|
26
26
|
private _config;
|
|
@@ -32,6 +32,7 @@ export interface IFormulaCurrentConfigService {
|
|
|
32
32
|
getExcludedRange(): Nullable<IUnitExcludedCell>;
|
|
33
33
|
loadDirtyRangesAndExcludedCell(dirtyRanges: IUnitRange[], excludedCell?: IUnitExcludedCell): void;
|
|
34
34
|
getArrayFormulaCellData(): IRuntimeUnitDataType;
|
|
35
|
+
getSheetName(unitId: string, sheetId: string): string;
|
|
35
36
|
}
|
|
36
37
|
export declare class FormulaCurrentConfigService extends Disposable implements IFormulaCurrentConfigService {
|
|
37
38
|
private readonly _currentUniverService;
|
|
@@ -45,6 +46,7 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
|
|
|
45
46
|
private _numfmtItemMap;
|
|
46
47
|
private _dirtyUnitFeatureMap;
|
|
47
48
|
private _excludedCell;
|
|
49
|
+
private _sheetIdToNameMap;
|
|
48
50
|
constructor(_currentUniverService: IUniverInstanceService);
|
|
49
51
|
dispose(): void;
|
|
50
52
|
getExcludedRange(): Nullable<IUnitExcludedCell>;
|
|
@@ -57,6 +59,7 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
|
|
|
57
59
|
getDirtyNameMap(): IDirtyUnitSheetNameMap;
|
|
58
60
|
getNumfmtItemMap(): INumfmtItemMap;
|
|
59
61
|
getDirtyUnitFeatureMap(): IDirtyUnitFeatureMap;
|
|
62
|
+
getSheetName(unitId: string, sheetId: string): string;
|
|
60
63
|
load(config: IFormulaDatasetConfig): void;
|
|
61
64
|
loadDirtyRangesAndExcludedCell(dirtyRanges: IUnitRange[], excludedCell?: IUnitExcludedCell): void;
|
|
62
65
|
registerUnitData(unitData: IUnitData): void;
|