@univerjs/sheets-formula 0.10.5 → 0.10.6-experimental.20250904-44da50e

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.
@@ -0,0 +1,30 @@
1
+ import { ISheetFormulaError } from '@univerjs/engine-formula';
2
+ import { FRange } from '@univerjs/sheets/facade';
3
+ /**
4
+ * @ignore
5
+ */
6
+ export interface IFRangeEngineFormulaMixin {
7
+ /**
8
+ * Get formula errors in the current range
9
+ * @returns {ISheetFormulaError[]} Array of formula errors in the range
10
+ * @example
11
+ * ```typescript
12
+ * const range = univerAPI.getActiveWorkbook()
13
+ * .getActiveSheet()
14
+ * .getRange('A1:B10');
15
+ * const errors = range.getFormulaError();
16
+ * console.log('Formula errors in range:', errors);
17
+ * ```
18
+ */
19
+ getFormulaError(): ISheetFormulaError[];
20
+ }
21
+ /**
22
+ * @ignore
23
+ */
24
+ export declare class FRangeEngineFormulaMixin extends FRange implements IFRangeEngineFormulaMixin {
25
+ getFormulaError(): ISheetFormulaError[];
26
+ }
27
+ declare module '@univerjs/sheets/facade' {
28
+ interface FRange extends IFRangeEngineFormulaMixin {
29
+ }
30
+ }
@@ -0,0 +1,25 @@
1
+ import { ISheetFormulaError } from '@univerjs/engine-formula';
2
+ import { FWorkbook } from '@univerjs/sheets/facade';
3
+ /**
4
+ * @ignore
5
+ */
6
+ export interface IFWorkbookEngineFormulaMixin {
7
+ /**
8
+ * Get all formula errors in the workbook
9
+ * @returns {ISheetFormulaError[]} Array of formula errors
10
+ * @example
11
+ * ```typescript
12
+ * const fWorkbook = univerAPI.getActiveWorkbook();
13
+ * const errors = fWorkbook.getAllFormulaError();
14
+ * console.log('Formula errors:', errors);
15
+ * ```
16
+ */
17
+ getAllFormulaError(): ISheetFormulaError[];
18
+ }
19
+ export declare class FWorkbookEngineFormulaMixin extends FWorkbook implements IFWorkbookEngineFormulaMixin {
20
+ getAllFormulaError(): ISheetFormulaError[];
21
+ }
22
+ declare module '@univerjs/sheets/facade' {
23
+ interface FWorkbook extends IFWorkbookEngineFormulaMixin {
24
+ }
25
+ }
@@ -16,5 +16,7 @@
16
16
  import './f-univer';
17
17
  import './f-formula';
18
18
  import './f-enum';
19
+ import './f-workbook';
20
+ import './f-range';
19
21
  export type * from './f-formula';
20
22
  export type * from './f-univer';
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(t,o){typeof exports=="object"&&typeof module<"u"?o(require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula"),require("@univerjs/engine-formula/facade")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/core/facade","@univerjs/engine-formula","@univerjs/sheets-formula","@univerjs/engine-formula/facade"],o):(t=typeof globalThis<"u"?globalThis:t||self,o(t.UniverCore,t.UniverCoreFacade,t.UniverEngineFormula,t.UniverSheetsFormula,t.UniverEngineFormulaFacade))})(this,(function(t,o,l,i,d){"use strict";class f extends o.FUniver{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(l.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}registerFunction(r){let c=this._injector.get(i.IRegisterFunctionService);c||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),c=this._injector.get(i.IRegisterFunctionService));const e=c.registerFunctions(r);return this._debouncedFormulaCalculation(),e}}o.FUniver.extend(f);class v extends d.FFormula{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(l.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}setInitialFormulaComputing(r){const e=this._injector.get(t.LifecycleService).stage,n=this._injector.get(t.ILogService),u=this._injector.get(t.IConfigService);e>t.LifecycleStages.Starting&&n.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.");const a=u.getConfig(i.PLUGIN_CONFIG_KEY_BASE);if(!a){u.setConfig(i.PLUGIN_CONFIG_KEY_BASE,{initialFormulaComputing:r});return}a.initialFormulaComputing=r}registerFunction(r,c,e){var s;let n=this._injector.get(i.IRegisterFunctionService);n||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),n=this._injector.get(i.IRegisterFunctionService));const u={name:r,func:c,description:typeof e=="string"?e:(s=e==null?void 0:e.description)!=null?s:"",locales:typeof e=="object"?e.locales:void 0},a=n.registerFunction(u);return this._debouncedFormulaCalculation(),a}registerAsyncFunction(r,c,e){var s;let n=this._injector.get(i.IRegisterFunctionService);n||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),n=this._injector.get(i.IRegisterFunctionService));const u={name:r,func:c,description:typeof e=="string"?e:(s=e==null?void 0:e.description)!=null?s:"",locales:typeof e=="object"?e.locales:void 0},a=n.registerAsyncFunction(u);return this._debouncedFormulaCalculation(),a}}d.FFormula.extend(v);class S{get CalculationMode(){return i.CalculationMode}}o.FEnum.extend(S)}));
1
+ (function(t,l){typeof exports=="object"&&typeof module<"u"?l(require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula"),require("@univerjs/engine-formula/facade"),require("@univerjs/sheets/facade")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/core/facade","@univerjs/engine-formula","@univerjs/sheets-formula","@univerjs/engine-formula/facade","@univerjs/sheets/facade"],l):(t=typeof globalThis<"u"?globalThis:t||self,l(t.UniverCore,t.UniverCoreFacade,t.UniverEngineFormula,t.UniverSheetsFormula,t.UniverEngineFormulaFacade,t.UniverSheetsFacade))})(this,(function(t,l,g,i,x,m){"use strict";class k extends l.FUniver{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(g.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}registerFunction(n){let c=this._injector.get(i.IRegisterFunctionService);c||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),c=this._injector.get(i.IRegisterFunctionService));const e=c.registerFunctions(n);return this._debouncedFormulaCalculation(),e}}l.FUniver.extend(k);class R extends x.FFormula{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(g.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}setInitialFormulaComputing(n){const e=this._injector.get(t.LifecycleService).stage,o=this._injector.get(t.ILogService),s=this._injector.get(t.IConfigService);e>t.LifecycleStages.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.");const r=s.getConfig(i.PLUGIN_CONFIG_KEY_BASE);if(!r){s.setConfig(i.PLUGIN_CONFIG_KEY_BASE,{initialFormulaComputing:n});return}r.initialFormulaComputing=n}registerFunction(n,c,e){var a;let o=this._injector.get(i.IRegisterFunctionService);o||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),o=this._injector.get(i.IRegisterFunctionService));const s={name:n,func:c,description:typeof e=="string"?e:(a=e==null?void 0:e.description)!=null?a:"",locales:typeof e=="object"?e.locales:void 0},r=o.registerFunction(s);return this._debouncedFormulaCalculation(),r}registerAsyncFunction(n,c,e){var a;let o=this._injector.get(i.IRegisterFunctionService);o||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),o=this._injector.get(i.IRegisterFunctionService));const s={name:n,func:c,description:typeof e=="string"?e:(a=e==null?void 0:e.description)!=null?a:"",locales:typeof e=="object"?e.locales:void 0},r=o.registerAsyncFunction(s);return this._debouncedFormulaCalculation(),r}}x.FFormula.extend(R);class b{get CalculationMode(){return i.CalculationMode}}l.FEnum.extend(b);class E extends m.FWorkbook{getAllFormulaError(){const n=[],c=this._workbook,e=c.getUnitId(),o=c.getSheets(),s=this._injector.get(g.FormulaDataModel).getArrayFormulaCellData();return o.forEach(r=>{var C;const a=r.getName(),j=r.getSheetId(),I=r.getCellMatrix(),F=((C=s==null?void 0:s[e])==null?void 0:C[j])||{};I.forValue((_,h,f)=>{var v;if(!f)return;const d=(v=F==null?void 0:F[_])==null?void 0:v[h],u=g.extractFormulaError(f,!!d);u&&n.push({sheetName:a,row:_,column:h,formula:f.f||"",errorType:u})})}),n}}m.FWorkbook.extend(E);class U extends m.FRange{getFormulaError(){var h,f;const n=[],c=this._workbook.getUnitId(),e=this._worksheet.getSheetId(),o=this._worksheet.getName(),s=this._workbook.getSheetBySheetId(e);if(!s)return n;const r=this._injector.get(g.FormulaDataModel).getArrayFormulaCellData(),a=((h=r==null?void 0:r[c])==null?void 0:h[e])||{},j=s.getCellMatrix(),{startRow:I,endRow:F,startColumn:C,endColumn:_}=this._range;for(let d=I;d<=F;d++)for(let u=C;u<=_;u++){const v=j.getValue(d,u);if(!v)continue;const M=(f=a==null?void 0:a[d])==null?void 0:f[u],y=g.extractFormulaError(v,!!M);y&&n.push({sheetName:o,row:d,column:u,formula:v.f||"",errorType:y})}return n}}m.FRange.extend(U)}));