@univerjs/sheets-formula 0.10.5 → 0.10.6-experimental.20250903-f52e3bf
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/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +93 -47
- package/lib/es/index.js +1254 -1246
- package/lib/facade.js +93 -47
- package/lib/index.js +1254 -1246
- package/lib/types/facade/f-range.d.ts +30 -0
- package/lib/types/facade/f-workbook.d.ts +25 -0
- package/lib/types/facade/index.d.ts +2 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +8 -7
- package/LICENSE +0 -176
package/lib/es/facade.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { debounce as
|
|
2
|
-
import { FUniver as
|
|
3
|
-
import { SetFormulaCalculationStartMutation as
|
|
4
|
-
import { IRegisterFunctionService as
|
|
5
|
-
import { FFormula as
|
|
6
|
-
|
|
1
|
+
import { debounce as y, LifecycleService as D, ILogService as R, IConfigService as U, LifecycleStages as A } from "@univerjs/core";
|
|
2
|
+
import { FUniver as b, FEnum as L } from "@univerjs/core/facade";
|
|
3
|
+
import { SetFormulaCalculationStartMutation as j, FormulaDataModel as k, extractFormulaError as I } from "@univerjs/engine-formula";
|
|
4
|
+
import { IRegisterFunctionService as s, RegisterFunctionService as S, PLUGIN_CONFIG_KEY_BASE as v, CalculationMode as N } from "@univerjs/sheets-formula";
|
|
5
|
+
import { FFormula as w } from "@univerjs/engine-formula/facade";
|
|
6
|
+
import { FWorkbook as M, FRange as p } from "@univerjs/sheets/facade";
|
|
7
|
+
class z extends b {
|
|
7
8
|
/**
|
|
8
9
|
* Initialize the FUniver instance.
|
|
9
10
|
* @ignore
|
|
10
11
|
*/
|
|
11
12
|
_initialize() {
|
|
12
|
-
this._debouncedFormulaCalculation =
|
|
13
|
+
this._debouncedFormulaCalculation = y(() => {
|
|
13
14
|
this._commandService.executeCommand(
|
|
14
|
-
|
|
15
|
+
j.id,
|
|
15
16
|
{
|
|
16
17
|
commands: [],
|
|
17
18
|
forceCalculation: !0
|
|
@@ -22,23 +23,23 @@ class y extends d {
|
|
|
22
23
|
);
|
|
23
24
|
}, 10);
|
|
24
25
|
}
|
|
25
|
-
registerFunction(
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
const e =
|
|
26
|
+
registerFunction(t) {
|
|
27
|
+
let r = this._injector.get(s);
|
|
28
|
+
r || (this._injector.add([s, { useClass: S }]), r = this._injector.get(s));
|
|
29
|
+
const e = r.registerFunctions(t);
|
|
29
30
|
return this._debouncedFormulaCalculation(), e;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
class
|
|
33
|
+
b.extend(z);
|
|
34
|
+
class B extends w {
|
|
34
35
|
/**
|
|
35
36
|
* Initialize the FUniver instance.
|
|
36
37
|
* @ignore
|
|
37
38
|
*/
|
|
38
39
|
_initialize() {
|
|
39
|
-
this._debouncedFormulaCalculation =
|
|
40
|
+
this._debouncedFormulaCalculation = y(() => {
|
|
40
41
|
this._commandService.executeCommand(
|
|
41
|
-
|
|
42
|
+
j.id,
|
|
42
43
|
{
|
|
43
44
|
commands: [],
|
|
44
45
|
forceCalculation: !0
|
|
@@ -49,45 +50,90 @@ class j extends f {
|
|
|
49
50
|
);
|
|
50
51
|
}, 10);
|
|
51
52
|
}
|
|
52
|
-
setInitialFormulaComputing(
|
|
53
|
-
const e = this._injector.get(
|
|
54
|
-
e >
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
57
|
-
|
|
53
|
+
setInitialFormulaComputing(t) {
|
|
54
|
+
const e = this._injector.get(D).stage, o = this._injector.get(R), n = this._injector.get(U);
|
|
55
|
+
e > A.Starting && o.warn("[FFormula]", "CalculationMode is called after the Starting lifecycle and will take effect the next time the Univer Sheet is constructed. If you want it to take effect when the Univer Sheet is initialized this time, consider calling it before the Ready lifecycle or using configuration.");
|
|
56
|
+
const i = n.getConfig(v);
|
|
57
|
+
if (!i) {
|
|
58
|
+
n.setConfig(v, { initialFormulaComputing: t });
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
+
i.initialFormulaComputing = t;
|
|
61
62
|
}
|
|
62
|
-
registerFunction(
|
|
63
|
-
var
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
name:
|
|
68
|
-
func:
|
|
69
|
-
description: typeof e == "string" ? e : (
|
|
63
|
+
registerFunction(t, r, e) {
|
|
64
|
+
var c;
|
|
65
|
+
let o = this._injector.get(s);
|
|
66
|
+
o || (this._injector.add([s, { useClass: S }]), o = this._injector.get(s));
|
|
67
|
+
const n = {
|
|
68
|
+
name: t,
|
|
69
|
+
func: r,
|
|
70
|
+
description: typeof e == "string" ? e : (c = e == null ? void 0 : e.description) != null ? c : "",
|
|
70
71
|
locales: typeof e == "object" ? e.locales : void 0
|
|
71
|
-
},
|
|
72
|
-
return this._debouncedFormulaCalculation(),
|
|
72
|
+
}, i = o.registerFunction(n);
|
|
73
|
+
return this._debouncedFormulaCalculation(), i;
|
|
73
74
|
}
|
|
74
|
-
registerAsyncFunction(
|
|
75
|
-
var
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
name:
|
|
80
|
-
func:
|
|
81
|
-
description: typeof e == "string" ? e : (
|
|
75
|
+
registerAsyncFunction(t, r, e) {
|
|
76
|
+
var c;
|
|
77
|
+
let o = this._injector.get(s);
|
|
78
|
+
o || (this._injector.add([s, { useClass: S }]), o = this._injector.get(s));
|
|
79
|
+
const n = {
|
|
80
|
+
name: t,
|
|
81
|
+
func: r,
|
|
82
|
+
description: typeof e == "string" ? e : (c = e == null ? void 0 : e.description) != null ? c : "",
|
|
82
83
|
locales: typeof e == "object" ? e.locales : void 0
|
|
83
|
-
},
|
|
84
|
-
return this._debouncedFormulaCalculation(),
|
|
84
|
+
}, i = o.registerAsyncFunction(n);
|
|
85
|
+
return this._debouncedFormulaCalculation(), i;
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
-
class
|
|
88
|
+
w.extend(B);
|
|
89
|
+
class G {
|
|
89
90
|
get CalculationMode() {
|
|
90
|
-
return
|
|
91
|
+
return N;
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
+
L.extend(G);
|
|
95
|
+
class T extends M {
|
|
96
|
+
getAllFormulaError() {
|
|
97
|
+
const t = [], r = this._workbook, e = r.getUnitId(), o = r.getSheets(), n = this._injector.get(k).getArrayFormulaCellData();
|
|
98
|
+
return o.forEach((i) => {
|
|
99
|
+
var h;
|
|
100
|
+
const c = i.getName(), _ = i.getSheetId(), C = i.getCellMatrix(), m = ((h = n == null ? void 0 : n[e]) == null ? void 0 : h[_]) || {};
|
|
101
|
+
C.forValue((F, d, u) => {
|
|
102
|
+
var g;
|
|
103
|
+
if (!u) return;
|
|
104
|
+
const l = (g = m == null ? void 0 : m[F]) == null ? void 0 : g[d], a = I(u, !!l);
|
|
105
|
+
a && t.push({
|
|
106
|
+
sheetName: c,
|
|
107
|
+
row: F,
|
|
108
|
+
column: d,
|
|
109
|
+
formula: u.f || "",
|
|
110
|
+
errorType: a
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}), t;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
M.extend(T);
|
|
117
|
+
class V extends p {
|
|
118
|
+
getFormulaError() {
|
|
119
|
+
var d, u;
|
|
120
|
+
const t = [], r = this._workbook.getUnitId(), e = this._worksheet.getSheetId(), o = this._worksheet.getName(), n = this._workbook.getSheetBySheetId(e);
|
|
121
|
+
if (!n) return t;
|
|
122
|
+
const i = this._injector.get(k).getArrayFormulaCellData(), c = ((d = i == null ? void 0 : i[r]) == null ? void 0 : d[e]) || {}, _ = n.getCellMatrix(), { startRow: C, endRow: m, startColumn: h, endColumn: F } = this._range;
|
|
123
|
+
for (let l = C; l <= m; l++)
|
|
124
|
+
for (let a = h; a <= F; a++) {
|
|
125
|
+
const g = _.getValue(l, a);
|
|
126
|
+
if (!g) continue;
|
|
127
|
+
const E = (u = c == null ? void 0 : c[l]) == null ? void 0 : u[a], x = I(g, !!E);
|
|
128
|
+
x && t.push({
|
|
129
|
+
sheetName: o,
|
|
130
|
+
row: l,
|
|
131
|
+
column: a,
|
|
132
|
+
formula: g.f || "",
|
|
133
|
+
errorType: x
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return t;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
p.extend(V);
|