@univerjs/engine-formula 0.1.3 → 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.
Files changed (39) hide show
  1. package/lib/cjs/index.js +1 -1
  2. package/lib/es/index.js +4219 -3167
  3. package/lib/types/basics/common.d.ts +5 -0
  4. package/lib/types/basics/date.d.ts +1 -1
  5. package/lib/types/basics/format.d.ts +24 -0
  6. package/lib/types/basics/inverted-index-cache.d.ts +2 -2
  7. package/lib/types/basics/object-class-type.d.ts +4 -0
  8. package/lib/types/engine/dependency/dependency-tree.d.ts +20 -4
  9. package/lib/types/engine/dependency/formula-dependency.d.ts +0 -6
  10. package/lib/types/engine/reference-object/base-reference-object.d.ts +8 -6
  11. package/lib/types/engine/utils/char-kit.d.ts +25 -0
  12. package/lib/types/engine/utils/object-compare.d.ts +0 -1
  13. package/lib/types/engine/utils/reference.d.ts +1 -1
  14. package/lib/types/engine/value-object/__tests__/array-value-divided.spec.d.ts +16 -0
  15. package/lib/types/engine/value-object/__tests__/array-value-minus.spec.d.ts +16 -0
  16. package/lib/types/engine/value-object/__tests__/array-value-multiply.spec.d.ts +16 -0
  17. package/lib/types/engine/value-object/__tests__/array-value-plus.spec.d.ts +16 -0
  18. package/lib/types/engine/value-object/array-value-object.d.ts +7 -7
  19. package/lib/types/engine/value-object/base-value-object.d.ts +8 -4
  20. package/lib/types/engine/value-object/cube-value-object.d.ts +1 -0
  21. package/lib/types/engine/value-object/lambda-value-object.d.ts +1 -0
  22. package/lib/types/engine/value-object/primitive-object.d.ts +25 -4
  23. package/lib/types/functions/base-function.d.ts +4 -9
  24. package/lib/types/functions/logical/or/__tests__/index.spec.d.ts +16 -0
  25. package/lib/types/functions/logical/or/index.d.ts +20 -0
  26. package/lib/types/functions/lookup/function-map.d.ts +1 -4
  27. package/lib/types/functions/lookup/index/index.d.ts +11 -2
  28. package/lib/types/functions/lookup/offset/index.d.ts +2 -2
  29. package/lib/types/functions/text/len/__test__/index.spec.d.ts +16 -0
  30. package/lib/types/functions/text/len/index.d.ts +21 -0
  31. package/lib/types/functions/text/lenb/__test__/index.spec.d.ts +16 -0
  32. package/lib/types/functions/text/lenb/index.d.ts +21 -0
  33. package/lib/types/functions/text/text/__test__/index.spec.d.ts +16 -0
  34. package/lib/types/functions/text/text/index.d.ts +20 -0
  35. package/lib/types/index.d.ts +3 -0
  36. package/lib/types/plugin.d.ts +1 -1
  37. package/lib/types/services/current-data.service.d.ts +3 -0
  38. package/lib/umd/index.js +1 -1
  39. package/package.json +10 -8
@@ -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 { ArrayValueObject } from '../../../engine/value-object/array-value-object';
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
- calculate(reference: BaseValueObject, rowNum: BaseValueObject, columnNum?: BaseValueObject, areaNum?: BaseValueObject): BaseValueObject | ArrayValueObject;
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
- calculate(reference: BaseValueObject, rows: BaseValueObject, columns: BaseValueObject, height?: BaseValueObject, width?: BaseValueObject): BaseValueObject | BaseReferenceObject;
21
- private _setDefault;
20
+ needsReferenceObject: boolean;
21
+ calculate(referenceObject: BaseValueObject, rows: BaseValueObject, columns: BaseValueObject, height?: BaseValueObject, width?: BaseValueObject): BaseValueObject | BaseReferenceObject;
22
22
  }
@@ -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
+ }
@@ -89,3 +89,6 @@ export { SetNumfmtFormulaDataMutation } from './commands/mutations/set-numfmt-fo
89
89
  export type { ISetNumfmtFormulaDataMutationParams } from './commands/mutations/set-numfmt-formula-data.mutation';
90
90
  export { isReferenceString } from './basics/regex';
91
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';
@@ -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: Array<[Ctor<BaseFunction>, IFunctionNames]>;
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;