@univerjs/engine-formula 0.9.1-nightly.202507081607 → 0.9.1-nightly.202507101607
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 +42 -29
- package/lib/index.js +42 -29
- package/lib/types/engine/ast-node/function-node.d.ts +1 -0
- package/lib/types/engine/reference-object/base-reference-object.d.ts +7 -7
- package/lib/types/engine/value-object/array-value-object.d.ts +2 -3
- package/lib/types/functions/base-function.d.ts +1 -0
- package/lib/types/functions/text/text/index.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/es/index.js
CHANGED
|
@@ -6273,24 +6273,26 @@ class q extends $t {
|
|
|
6273
6273
|
}
|
|
6274
6274
|
}
|
|
6275
6275
|
class Vt {
|
|
6276
|
-
static create(a) {
|
|
6276
|
+
static create(a, e = !1) {
|
|
6277
6277
|
if (a == null)
|
|
6278
6278
|
return ue.create();
|
|
6279
6279
|
if (typeof a == "boolean")
|
|
6280
6280
|
return T.create(a);
|
|
6281
6281
|
if (typeof a == "string") {
|
|
6282
|
-
const
|
|
6283
|
-
if (yr.has(
|
|
6284
|
-
return g.create(
|
|
6285
|
-
if (
|
|
6282
|
+
const t = a.toLocaleUpperCase().trim();
|
|
6283
|
+
if (yr.has(t))
|
|
6284
|
+
return g.create(t);
|
|
6285
|
+
if (t === er.TRUE || t === er.FALSE)
|
|
6286
6286
|
return qn(a);
|
|
6287
6287
|
if (Q(a))
|
|
6288
6288
|
return y.create(Number(a));
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6289
|
+
if (!e) {
|
|
6290
|
+
const { isNumberPattern: n, value: s, pattern: o } = bl(a);
|
|
6291
|
+
if (n)
|
|
6292
|
+
return y.create(s, o);
|
|
6293
|
+
}
|
|
6294
|
+
const r = a.replace(/\n/g, "").replace(/\r/g, "");
|
|
6295
|
+
return !Tf(r) && jc(r) ? q.create(r) : jf(a);
|
|
6294
6296
|
}
|
|
6295
6297
|
return typeof a == "number" ? Kn(a) : g.create(m.VALUE);
|
|
6296
6298
|
}
|
|
@@ -7798,6 +7800,9 @@ class ah extends Qe {
|
|
|
7798
7800
|
const r = this._calculate(a);
|
|
7799
7801
|
this._setRefData(r), this.setValue(r);
|
|
7800
7802
|
}
|
|
7803
|
+
isFunctionExecutorArgumentsIgnoreNumberPattern() {
|
|
7804
|
+
return this._functionExecutor.isArgumentsIgnoreNumberPattern();
|
|
7805
|
+
}
|
|
7801
7806
|
/**
|
|
7802
7807
|
* Compatibility handling for special functions.
|
|
7803
7808
|
*/
|
|
@@ -8534,7 +8539,9 @@ class Sh extends Qe {
|
|
|
8534
8539
|
return ie.VALUE;
|
|
8535
8540
|
}
|
|
8536
8541
|
execute() {
|
|
8537
|
-
|
|
8542
|
+
var e;
|
|
8543
|
+
const a = ((e = this.getParent()) == null ? void 0 : e.nodeType) === ie.FUNCTION && this.getParent().isFunctionExecutorArgumentsIgnoreNumberPattern();
|
|
8544
|
+
this.setValue(Vt.create(this.getToken(), a));
|
|
8538
8545
|
}
|
|
8539
8546
|
}
|
|
8540
8547
|
class To extends bt {
|
|
@@ -10632,6 +10639,9 @@ class V {
|
|
|
10632
10639
|
isCustom() {
|
|
10633
10640
|
return !1;
|
|
10634
10641
|
}
|
|
10642
|
+
isArgumentsIgnoreNumberPattern() {
|
|
10643
|
+
return !1;
|
|
10644
|
+
}
|
|
10635
10645
|
setRefInfo(a, e, t, r) {
|
|
10636
10646
|
this._unitId = a, this._subUnitId = e, this._row = t, this._column = r;
|
|
10637
10647
|
}
|
|
@@ -30166,6 +30176,9 @@ class ib extends V {
|
|
|
30166
30176
|
A(this, "minParams", 2);
|
|
30167
30177
|
A(this, "maxParams", 2);
|
|
30168
30178
|
}
|
|
30179
|
+
isArgumentsIgnoreNumberPattern() {
|
|
30180
|
+
return !0;
|
|
30181
|
+
}
|
|
30169
30182
|
calculate(e, t) {
|
|
30170
30183
|
if (e.isError())
|
|
30171
30184
|
return e;
|
|
@@ -30177,27 +30190,27 @@ class ib extends V {
|
|
|
30177
30190
|
), n = Math.max(
|
|
30178
30191
|
e.isArray() ? e.getColumnCount() : 1,
|
|
30179
30192
|
t.isArray() ? t.getColumnCount() : 1
|
|
30180
|
-
), s = O(r, n, e), o = O(r, n, t)
|
|
30181
|
-
|
|
30182
|
-
|
|
30183
|
-
|
|
30184
|
-
|
|
30185
|
-
|
|
30186
|
-
|
|
30187
|
-
if (f.isBoolean())
|
|
30193
|
+
), s = O(r, n, e), o = O(r, n, t), u = s.map((c, l, f) => {
|
|
30194
|
+
if (c.isError())
|
|
30195
|
+
return c;
|
|
30196
|
+
let h = o.get(l, f) || j.create(" ");
|
|
30197
|
+
if (h.isError())
|
|
30198
|
+
return h;
|
|
30199
|
+
if (h.isBoolean())
|
|
30188
30200
|
return g.create(m.VALUE);
|
|
30189
|
-
if (
|
|
30190
|
-
return
|
|
30191
|
-
let
|
|
30192
|
-
if (
|
|
30193
|
-
if (!Q(
|
|
30194
|
-
return
|
|
30195
|
-
|
|
30201
|
+
if (c.isBoolean())
|
|
30202
|
+
return c;
|
|
30203
|
+
let d = c.getValue();
|
|
30204
|
+
if (c.isNull() && (d = 0), c.isString()) {
|
|
30205
|
+
if (!Q(d))
|
|
30206
|
+
return c;
|
|
30207
|
+
d = Number(d);
|
|
30196
30208
|
}
|
|
30197
|
-
|
|
30198
|
-
const
|
|
30199
|
-
return j.create(
|
|
30209
|
+
h.isNull() && (h = j.create(" "));
|
|
30210
|
+
const _ = `${h.getValue()}`, C = Wa(_, d);
|
|
30211
|
+
return j.create(_ === " " ? C.trimEnd() : C);
|
|
30200
30212
|
});
|
|
30213
|
+
return u.getRowCount() === 1 && u.getColumnCount() === 1 ? u.get(0, 0) : u;
|
|
30201
30214
|
}
|
|
30202
30215
|
}
|
|
30203
30216
|
class ob extends V {
|
package/lib/index.js
CHANGED
|
@@ -6273,24 +6273,26 @@ class q extends $t {
|
|
|
6273
6273
|
}
|
|
6274
6274
|
}
|
|
6275
6275
|
class Vt {
|
|
6276
|
-
static create(a) {
|
|
6276
|
+
static create(a, e = !1) {
|
|
6277
6277
|
if (a == null)
|
|
6278
6278
|
return ue.create();
|
|
6279
6279
|
if (typeof a == "boolean")
|
|
6280
6280
|
return T.create(a);
|
|
6281
6281
|
if (typeof a == "string") {
|
|
6282
|
-
const
|
|
6283
|
-
if (yr.has(
|
|
6284
|
-
return g.create(
|
|
6285
|
-
if (
|
|
6282
|
+
const t = a.toLocaleUpperCase().trim();
|
|
6283
|
+
if (yr.has(t))
|
|
6284
|
+
return g.create(t);
|
|
6285
|
+
if (t === er.TRUE || t === er.FALSE)
|
|
6286
6286
|
return qn(a);
|
|
6287
6287
|
if (Q(a))
|
|
6288
6288
|
return y.create(Number(a));
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6289
|
+
if (!e) {
|
|
6290
|
+
const { isNumberPattern: n, value: s, pattern: o } = bl(a);
|
|
6291
|
+
if (n)
|
|
6292
|
+
return y.create(s, o);
|
|
6293
|
+
}
|
|
6294
|
+
const r = a.replace(/\n/g, "").replace(/\r/g, "");
|
|
6295
|
+
return !Tf(r) && jc(r) ? q.create(r) : jf(a);
|
|
6294
6296
|
}
|
|
6295
6297
|
return typeof a == "number" ? Kn(a) : g.create(m.VALUE);
|
|
6296
6298
|
}
|
|
@@ -7798,6 +7800,9 @@ class ah extends Qe {
|
|
|
7798
7800
|
const r = this._calculate(a);
|
|
7799
7801
|
this._setRefData(r), this.setValue(r);
|
|
7800
7802
|
}
|
|
7803
|
+
isFunctionExecutorArgumentsIgnoreNumberPattern() {
|
|
7804
|
+
return this._functionExecutor.isArgumentsIgnoreNumberPattern();
|
|
7805
|
+
}
|
|
7801
7806
|
/**
|
|
7802
7807
|
* Compatibility handling for special functions.
|
|
7803
7808
|
*/
|
|
@@ -8534,7 +8539,9 @@ class Sh extends Qe {
|
|
|
8534
8539
|
return ie.VALUE;
|
|
8535
8540
|
}
|
|
8536
8541
|
execute() {
|
|
8537
|
-
|
|
8542
|
+
var e;
|
|
8543
|
+
const a = ((e = this.getParent()) == null ? void 0 : e.nodeType) === ie.FUNCTION && this.getParent().isFunctionExecutorArgumentsIgnoreNumberPattern();
|
|
8544
|
+
this.setValue(Vt.create(this.getToken(), a));
|
|
8538
8545
|
}
|
|
8539
8546
|
}
|
|
8540
8547
|
class To extends bt {
|
|
@@ -10632,6 +10639,9 @@ class V {
|
|
|
10632
10639
|
isCustom() {
|
|
10633
10640
|
return !1;
|
|
10634
10641
|
}
|
|
10642
|
+
isArgumentsIgnoreNumberPattern() {
|
|
10643
|
+
return !1;
|
|
10644
|
+
}
|
|
10635
10645
|
setRefInfo(a, e, t, r) {
|
|
10636
10646
|
this._unitId = a, this._subUnitId = e, this._row = t, this._column = r;
|
|
10637
10647
|
}
|
|
@@ -30166,6 +30176,9 @@ class ib extends V {
|
|
|
30166
30176
|
A(this, "minParams", 2);
|
|
30167
30177
|
A(this, "maxParams", 2);
|
|
30168
30178
|
}
|
|
30179
|
+
isArgumentsIgnoreNumberPattern() {
|
|
30180
|
+
return !0;
|
|
30181
|
+
}
|
|
30169
30182
|
calculate(e, t) {
|
|
30170
30183
|
if (e.isError())
|
|
30171
30184
|
return e;
|
|
@@ -30177,27 +30190,27 @@ class ib extends V {
|
|
|
30177
30190
|
), n = Math.max(
|
|
30178
30191
|
e.isArray() ? e.getColumnCount() : 1,
|
|
30179
30192
|
t.isArray() ? t.getColumnCount() : 1
|
|
30180
|
-
), s = O(r, n, e), o = O(r, n, t)
|
|
30181
|
-
|
|
30182
|
-
|
|
30183
|
-
|
|
30184
|
-
|
|
30185
|
-
|
|
30186
|
-
|
|
30187
|
-
if (f.isBoolean())
|
|
30193
|
+
), s = O(r, n, e), o = O(r, n, t), u = s.map((c, l, f) => {
|
|
30194
|
+
if (c.isError())
|
|
30195
|
+
return c;
|
|
30196
|
+
let h = o.get(l, f) || j.create(" ");
|
|
30197
|
+
if (h.isError())
|
|
30198
|
+
return h;
|
|
30199
|
+
if (h.isBoolean())
|
|
30188
30200
|
return g.create(m.VALUE);
|
|
30189
|
-
if (
|
|
30190
|
-
return
|
|
30191
|
-
let
|
|
30192
|
-
if (
|
|
30193
|
-
if (!Q(
|
|
30194
|
-
return
|
|
30195
|
-
|
|
30201
|
+
if (c.isBoolean())
|
|
30202
|
+
return c;
|
|
30203
|
+
let d = c.getValue();
|
|
30204
|
+
if (c.isNull() && (d = 0), c.isString()) {
|
|
30205
|
+
if (!Q(d))
|
|
30206
|
+
return c;
|
|
30207
|
+
d = Number(d);
|
|
30196
30208
|
}
|
|
30197
|
-
|
|
30198
|
-
const
|
|
30199
|
-
return j.create(
|
|
30209
|
+
h.isNull() && (h = j.create(" "));
|
|
30210
|
+
const _ = `${h.getValue()}`, C = Wa(_, d);
|
|
30211
|
+
return j.create(_ === " " ? C.trimEnd() : C);
|
|
30200
30212
|
});
|
|
30213
|
+
return u.getRowCount() === 1 && u.getColumnCount() === 1 ? u.get(0, 0) : u;
|
|
30201
30214
|
}
|
|
30202
30215
|
}
|
|
30203
30216
|
class ob extends V {
|
|
@@ -20,6 +20,7 @@ export declare class FunctionNode extends BaseAstNode {
|
|
|
20
20
|
get nodeType(): NodeType;
|
|
21
21
|
executeAsync(): Promise<AstNodePromiseType>;
|
|
22
22
|
execute(): void;
|
|
23
|
+
isFunctionExecutorArgumentsIgnoreNumberPattern(): boolean;
|
|
23
24
|
/**
|
|
24
25
|
* Compatibility handling for special functions.
|
|
25
26
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ICellData, IRange, Nullable } from '@univerjs/core';
|
|
2
2
|
import { IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap, IUnitStylesData } from '../../basics/common';
|
|
3
|
-
import { BaseValueObject
|
|
3
|
+
import { BaseValueObject } from '../value-object/base-value-object';
|
|
4
4
|
import { FormulaAstLRU } from '../../basics/cache-lru';
|
|
5
5
|
import { ObjectClassType } from '../../basics/object-class-type';
|
|
6
6
|
import { ArrayValueObject } from '../value-object/array-value-object';
|
|
7
|
-
import {
|
|
7
|
+
import { StringValueObject } from '../value-object/primitive-object';
|
|
8
8
|
export type NodeValueType = BaseValueObject | BaseReferenceObject | AsyncObject | AsyncArrayObject;
|
|
9
9
|
export type FunctionVariantType = BaseValueObject | BaseReferenceObject;
|
|
10
10
|
export declare const FORMULA_REF_TO_ARRAY_CACHE: FormulaAstLRU<ArrayValueObject>;
|
|
@@ -48,7 +48,7 @@ export declare class BaseReferenceObject extends ObjectClassType {
|
|
|
48
48
|
};
|
|
49
49
|
isReferenceObject(): boolean;
|
|
50
50
|
iterator(callback: (valueObject: Nullable<BaseValueObject>, rowIndex: number, columnIndex: number) => Nullable<boolean>): Nullable<boolean>;
|
|
51
|
-
getFirstCell():
|
|
51
|
+
getFirstCell(): BaseValueObject | StringValueObject;
|
|
52
52
|
getRangeData(): IRange;
|
|
53
53
|
setRangeData(range: IRange): void;
|
|
54
54
|
getUnitId(): string;
|
|
@@ -95,10 +95,10 @@ export declare class BaseReferenceObject extends ObjectClassType {
|
|
|
95
95
|
isTable(): boolean;
|
|
96
96
|
unionBy(referenceObject: BaseReferenceObject): NodeValueType;
|
|
97
97
|
unionRange(rangeData1: IRange, rangeData2: IRange): IRange;
|
|
98
|
-
getCellValueObject(cell: ICellData):
|
|
98
|
+
getCellValueObject(cell: ICellData): BaseValueObject | StringValueObject;
|
|
99
99
|
private _getPatternByCell;
|
|
100
|
-
getCellByRow(row: number):
|
|
101
|
-
getCellByColumn(column: number):
|
|
100
|
+
getCellByRow(row: number): BaseValueObject | StringValueObject;
|
|
101
|
+
getCellByColumn(column: number): BaseValueObject | StringValueObject;
|
|
102
102
|
getCurrentActiveSheetData(): import('../../basics/common').ISheetItem;
|
|
103
103
|
getCurrentStylesData(): import('@univerjs/core').Styles;
|
|
104
104
|
getCurrentRuntimeSheetData(): import('@univerjs/core').ObjectMatrix<Nullable<ICellData>> | undefined;
|
|
@@ -106,7 +106,7 @@ export declare class BaseReferenceObject extends ObjectClassType {
|
|
|
106
106
|
getCurrentRuntimeActiveArrayFormulaCellData(): import('@univerjs/core').ObjectMatrix<Nullable<ICellData>> | undefined;
|
|
107
107
|
getCellData(row: number, column: number): Nullable<ICellData>;
|
|
108
108
|
getRuntimeFeatureCellValue(row: number, column: number): ICellData | undefined;
|
|
109
|
-
getCellByPosition(rowRaw?: number, columnRaw?: number):
|
|
109
|
+
getCellByPosition(rowRaw?: number, columnRaw?: number): BaseValueObject | StringValueObject;
|
|
110
110
|
/**
|
|
111
111
|
* Get the pattern of the cell
|
|
112
112
|
* @param unitId
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Nullable } from '@univerjs/core';
|
|
2
|
-
import { callbackMapFnType, IArrayValueObject, BaseValueObject
|
|
2
|
+
import { callbackMapFnType, IArrayValueObject, BaseValueObject } from './base-value-object';
|
|
3
3
|
import { compareToken } from '../../basics/token';
|
|
4
4
|
import { ArrayBinarySearchType, ArrayOrderSearchType } from '../utils/compare';
|
|
5
|
-
import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from './primitive-object';
|
|
6
5
|
export declare function fromObjectToString(array: IArrayValueObject): string;
|
|
7
6
|
export declare function transformToValueObject(array?: Array<Array<number | string | boolean | null>>): BaseValueObject[][];
|
|
8
7
|
export declare function transformToValue(array?: Nullable<BaseValueObject>[][]): (string | number | boolean | null)[][];
|
|
@@ -226,5 +225,5 @@ export declare class ArrayValueObject extends BaseValueObject {
|
|
|
226
225
|
private _createNewArray;
|
|
227
226
|
}
|
|
228
227
|
export declare class ValueObjectFactory {
|
|
229
|
-
static create(rawValue: string | number | boolean | null):
|
|
228
|
+
static create(rawValue: string | number | boolean | null, isIgnoreNumberPattern?: boolean): BaseValueObject;
|
|
230
229
|
}
|
|
@@ -90,6 +90,7 @@ export declare class BaseFunction {
|
|
|
90
90
|
isAsync(): boolean;
|
|
91
91
|
isAddress(): boolean;
|
|
92
92
|
isCustom(): boolean;
|
|
93
|
+
isArgumentsIgnoreNumberPattern(): boolean;
|
|
93
94
|
setRefInfo(unitId: string, subUnitId: string, row: number, column: number): void;
|
|
94
95
|
calculateCustom(...arg: Array<FormulaFunctionValueType>): FormulaFunctionResultValueType | Promise<FormulaFunctionResultValueType>;
|
|
95
96
|
calculate(...arg: BaseValueObject[]): NodeValueType;
|
|
@@ -3,5 +3,6 @@ import { BaseFunction } from '../../base-function';
|
|
|
3
3
|
export declare class Text extends BaseFunction {
|
|
4
4
|
minParams: number;
|
|
5
5
|
maxParams: number;
|
|
6
|
+
isArgumentsIgnoreNumberPattern(): boolean;
|
|
6
7
|
calculate(text: BaseValueObject, formatText: BaseValueObject): BaseValueObject;
|
|
7
8
|
}
|