@odoo/o-spreadsheet 17.1.0-alpha.2 → 17.1.0-alpha.3

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.
@@ -17,6 +17,7 @@ declare const functionCache: {
17
17
  [key: string]: Omit<CompiledFormula, "dependencies" | "tokens">;
18
18
  };
19
19
  declare function compile(formula: string): CompiledFormula;
20
+ declare function compileTokens(tokens: Token[]): CompiledFormula;
20
21
 
21
22
  interface FunctionContext {
22
23
  parent: string;
@@ -93,6 +94,7 @@ type AST = ASTOperation | ASTUnaryOperation | ASTFuncall | ASTNumber | ASTBoolea
93
94
  * Parse an expression (as a string) into an AST.
94
95
  */
95
96
  declare function parse(str: string): AST;
97
+ declare function parseTokens(tokens: Token[]): AST;
96
98
  /**
97
99
  * Allows to visit all nodes of an AST and apply a mapping function
98
100
  * to nodes of a specific type.
@@ -2652,6 +2654,9 @@ interface CompiledFormula {
2652
2654
  tokens: Token[];
2653
2655
  dependencies: string[];
2654
2656
  }
2657
+ interface RangeCompiledFormula extends Omit<CompiledFormula, "dependencies"> {
2658
+ dependencies: Range[];
2659
+ }
2655
2660
  type Matrix<T = unknown> = T[][];
2656
2661
  type ValueAndFormat = {
2657
2662
  value: CellValue;
@@ -2803,8 +2808,7 @@ interface LiteralCell extends CellAttributes {
2803
2808
  }
2804
2809
  interface FormulaCell extends CellAttributes {
2805
2810
  readonly isFormula: true;
2806
- readonly compiledFormula: CompiledFormula;
2807
- readonly dependencies: Range[];
2811
+ readonly compiledFormula: RangeCompiledFormula;
2808
2812
  }
2809
2813
  type Cell = LiteralCell | FormulaCell;
2810
2814
  interface EvaluatedCellProperties {
@@ -3378,8 +3382,8 @@ declare class CellPlugin extends CorePlugin<CoreState> implements CoreState {
3378
3382
  * starting an async evaluation even if it has been moved or re-allocated
3379
3383
  */
3380
3384
  getCellById(cellId: UID): Cell | undefined;
3381
- getFormulaCellContent(sheetId: UID, cell: Pick<FormulaCell, "dependencies" | "compiledFormula">, dependencies?: Range[]): string;
3382
- getTranslatedCellFormula(sheetId: UID, offsetX: number, offsetY: number, compiledFormula: CompiledFormula, dependencies: Range[]): string;
3385
+ getFormulaCellContent(sheetId: UID, compiledFormula: RangeCompiledFormula, dependencies?: Range[]): string;
3386
+ getTranslatedCellFormula(sheetId: UID, offsetX: number, offsetY: number, compiledFormula: RangeCompiledFormula): string;
3383
3387
  getCellStyle(position: CellPosition): Style;
3384
3388
  /**
3385
3389
  * Converts a zone to a XC coordinate system
@@ -4084,7 +4088,7 @@ declare class SheetPlugin extends CorePlugin<SheetState> implements SheetState {
4084
4088
 
4085
4089
  declare class EvaluationPlugin extends UIPlugin {
4086
4090
  private config;
4087
- static getters: readonly ["evaluateFormula", "getCorrespondingFormulaCell", "getRangeFormattedValues", "getRangeValues", "getRangeFormats", "getEvaluatedCell", "getEvaluatedCells", "getEvaluatedCellsInZone"];
4091
+ static getters: readonly ["evaluateFormula", "getCorrespondingFormulaCell", "getRangeFormattedValues", "getRangeValues", "getRangeFormats", "getEvaluatedCell", "getEvaluatedCells", "getEvaluatedCellsInZone", "getSpreadPositionsOf"];
4088
4092
  private shouldRebuildDependenciesGraph;
4089
4093
  private evaluator;
4090
4094
  private compilationParams;
@@ -4109,6 +4113,7 @@ declare class EvaluationPlugin extends UIPlugin {
4109
4113
  getEvaluatedCell(position: CellPosition): EvaluatedCell;
4110
4114
  getEvaluatedCells(sheetId: UID): Record<UID, EvaluatedCell>;
4111
4115
  getEvaluatedCellsInZone(sheetId: UID, zone: Zone): EvaluatedCell[];
4116
+ getSpreadPositionsOf(position: CellPosition): CellPosition[];
4112
4117
  exportForExcel(data: ExcelWorkbookData): void;
4113
4118
  /**
4114
4119
  * Returns the corresponding formula cell of a given cell
@@ -4142,11 +4147,11 @@ declare class CustomColorsPlugin extends UIPlugin<CustomColorState> {
4142
4147
  }
4143
4148
 
4144
4149
  interface EvaluationChartState {
4145
- readonly charts: Immutable<Record<UID, ChartRuntime | undefined>>;
4150
+ charts: Record<UID, ChartRuntime | undefined>;
4146
4151
  }
4147
4152
  declare class EvaluationChartPlugin extends UIPlugin<EvaluationChartState> {
4148
4153
  static getters: readonly ["getChartRuntime", "getBackgroundOfSingleCellChart"];
4149
- readonly charts: Immutable<Record<UID, ChartRuntime | undefined>>;
4154
+ charts: Record<UID, ChartRuntime | undefined>;
4150
4155
  private createRuntimeChart;
4151
4156
  handle(cmd: CoreViewCommand): void;
4152
4157
  getChartRuntime(figureId: UID): ChartRuntime;
@@ -4659,56 +4664,10 @@ declare class SelectionInputsManagerPlugin extends UIPlugin {
4659
4664
  }
4660
4665
 
4661
4666
  declare class SortPlugin extends UIPlugin {
4662
- static getters: readonly ["getContiguousZone"];
4663
4667
  allowDispatch(cmd: LocalCommand): CommandResult | CommandResult[];
4664
4668
  handle(cmd: Command): void;
4665
4669
  private checkMerge;
4666
4670
  private checkMergeSizes;
4667
- /**
4668
- * safe-version of expandZone to make sure we don't get out of the grid
4669
- */
4670
- private expand;
4671
- /**
4672
- * verifies the presence of at least one non-empty cell in the given zone
4673
- */
4674
- private checkExpandedValues;
4675
- /**
4676
- * This function will expand the provided zone in directions (top, bottom, left, right) for which there
4677
- * are non-null cells on the external boundary of the zone in the given direction.
4678
- *
4679
- * Example:
4680
- * A B C D E
4681
- * ___ ___ ___ ___ ___
4682
- * 1 | | D | | | |
4683
- * ___ ___ ___ ___ ___
4684
- * 2 | 5 | | 1 | D | |
4685
- * ___ ___ ___ ___ ___
4686
- * 3 | | | A | X | |
4687
- * ___ ___ ___ ___ ___
4688
- * 4 | | | | | |
4689
- * ___ ___ ___ ___ ___
4690
- *
4691
- * Let's consider a provided zone corresponding to (C2:D3) - (left:2, right: 3, top:1, bottom:2)
4692
- * - the top external boundary is (B1:E1)
4693
- * Since we have B1='D' != "", we expand to the top: => (C1:D3)
4694
- * The top boundary having reached the top of the grid, we cannot expand in that direction anymore
4695
- *
4696
- * - the left boundary is (B1:B4)
4697
- * since we have B1 again, we expand to the left => (B1:D3)
4698
- *
4699
- * - the right and bottom boundaries are a dead end for now as (E1:E4) and (A4:E4) are empty.
4700
- *
4701
- * - the left boundary is now (A1:A4)
4702
- * Since we have A2=5 != "", we can therefore expand to the left => (A1:D3)
4703
- *
4704
- * This will be the final zone as left and top have reached the boundaries of the grid and
4705
- * the other boundaries (E1:E4) and (A4:E4) are empty.
4706
- *
4707
- * @param sheetId UID of concerned sheet
4708
- * @param zone Zone
4709
- *
4710
- */
4711
- getContiguousZone(sheetId: UID, zone: Zone): Zone;
4712
4671
  /**
4713
4672
  * This function evaluates if the top row of a provided zone can be considered as a `header`
4714
4673
  * by checking the following criteria:
@@ -4760,7 +4719,7 @@ declare class UIOptionsPlugin extends UIPlugin {
4760
4719
  }
4761
4720
 
4762
4721
  declare class SheetUIPlugin extends UIPlugin {
4763
- static getters: readonly ["doesCellHaveGridIcon", "getCellWidth", "getTextWidth", "getCellText", "getCellMultiLineText"];
4722
+ static getters: readonly ["doesCellHaveGridIcon", "getCellWidth", "getTextWidth", "getCellText", "getCellMultiLineText", "getContiguousZone", "isCellEmpty"];
4764
4723
  private ctx;
4765
4724
  allowDispatch(cmd: LocalCommand): CommandResult | CommandResult[];
4766
4725
  handle(cmd: Command): void;
@@ -4773,6 +4732,15 @@ declare class SheetUIPlugin extends UIPlugin {
4773
4732
  */
4774
4733
  getCellMultiLineText(position: CellPosition, width: number | undefined): string[];
4775
4734
  doesCellHaveGridIcon(position: CellPosition): boolean;
4735
+ /**
4736
+ * Expands the given zone until bordered by empty cells or reached the sheet boundaries.
4737
+ */
4738
+ getContiguousZone(sheetId: UID, zoneToExpand: Zone): Zone;
4739
+ /**
4740
+ * Check if a cell is empty. If the cell is part of a merge,
4741
+ * check if the merge containing the cell is empty.
4742
+ */
4743
+ isCellEmpty(position: CellPosition): boolean;
4776
4744
  private getColMaxWidth;
4777
4745
  /**
4778
4746
  * Check that any "sheetId" in the command matches an existing
@@ -7909,4 +7877,4 @@ declare const constants: {
7909
7877
  DEFAULT_LOCALE: Locale;
7910
7878
  };
7911
7879
 
7912
- export { AbstractChart, CancelledReason, Client, ClientJoinedMessage, ClientLeftMessage, ClientMovedMessage, CollaborationMessage, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, RemoteRevisionMessage, Revision, RevisionRedoneMessage, RevisionUndoneMessage, SPREADSHEET_DIMENSIONS, Spreadsheet, TransportService, UIPlugin, __info__, addFunction, astToFormula, compile, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
7880
+ export { AbstractChart, CancelledReason, Client, ClientJoinedMessage, ClientLeftMessage, ClientMovedMessage, CollaborationMessage, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, RemoteRevisionMessage, Revision, RevisionRedoneMessage, RevisionUndoneMessage, SPREADSHEET_DIMENSIONS, Spreadsheet, TransportService, UIPlugin, __info__, addFunction, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };