@odoo/o-spreadsheet 17.2.0-alpha.0 → 17.2.0-alpha.2

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.
@@ -2,17 +2,6 @@ import * as _odoo_owl from '@odoo/owl';
2
2
  import { ComponentConstructor, Component } from '@odoo/owl';
3
3
  import { ChartConfiguration, ChartData, ChartDataset, ChartOptions } from 'chart.js';
4
4
 
5
- declare enum CellErrorLevel {
6
- silent = 0,
7
- error = 1
8
- }
9
- declare class EvaluationError extends Error {
10
- readonly errorType: string;
11
- readonly logLevel: number;
12
- constructor(errorType: string, message: string, logLevel?: number);
13
- get isVerbose(): boolean;
14
- }
15
-
16
5
  declare const functionCache: {
17
6
  [key: string]: Omit<CompiledFormula, "dependencies" | "tokens">;
18
7
  };
@@ -457,6 +446,11 @@ type PieChartRuntime = {
457
446
  background: Color;
458
447
  };
459
448
 
449
+ interface ScatterChartDefinition extends Omit<LineChartDefinition, "type" | "stacked" | "cumulative"> {
450
+ readonly type: "scatter";
451
+ }
452
+ type ScatterChartRuntime = LineChartRuntime;
453
+
460
454
  interface ScorecardChartDefinition {
461
455
  readonly type: "scorecard";
462
456
  readonly title: string;
@@ -483,9 +477,9 @@ interface ScorecardChartRuntime {
483
477
  readonly baselineStyle?: Style;
484
478
  }
485
479
 
486
- type ChartType = "line" | "bar" | "pie" | "scorecard" | "gauge";
487
- type ChartDefinition = LineChartDefinition | PieChartDefinition | BarChartDefinition | ScorecardChartDefinition | GaugeChartDefinition;
488
- type ChartJSRuntime = LineChartRuntime | PieChartRuntime | BarChartRuntime | GaugeChartRuntime;
480
+ type ChartType = "line" | "bar" | "pie" | "scorecard" | "gauge" | "scatter";
481
+ type ChartDefinition = LineChartDefinition | PieChartDefinition | BarChartDefinition | ScorecardChartDefinition | GaugeChartDefinition | ScatterChartDefinition;
482
+ type ChartJSRuntime = LineChartRuntime | PieChartRuntime | BarChartRuntime | GaugeChartRuntime | ScatterChartRuntime;
489
483
  type ChartRuntime = ChartJSRuntime | ScorecardChartRuntime;
490
484
  interface ExcelChartDataset {
491
485
  readonly label?: string;
@@ -664,13 +658,23 @@ interface ExcelCellData extends CellData {
664
658
  isFormula: Boolean;
665
659
  computedFormat?: Format;
666
660
  }
667
- interface ExcelSheetData extends Omit<SheetData, "figureTables"> {
661
+ interface ExcelSheetData extends Omit<SheetData, "figureTables" | "cols" | "rows"> {
668
662
  cells: {
669
663
  [key: string]: ExcelCellData | undefined;
670
664
  };
671
665
  charts: FigureData<ExcelChartDefinition>[];
672
666
  images: FigureData<Image>[];
673
667
  filterTables: ExcelFilterTableData[];
668
+ cols: {
669
+ [key: number]: ExcelHeaderData;
670
+ };
671
+ rows: {
672
+ [key: number]: ExcelHeaderData;
673
+ };
674
+ }
675
+ interface ExcelHeaderData extends HeaderData {
676
+ outlineLevel?: number;
677
+ collapsed?: boolean;
674
678
  }
675
679
  interface FilterTableData {
676
680
  range: string;
@@ -2459,7 +2463,8 @@ declare const enum CommandResult {
2459
2463
  InvalidNumberOfCriterionValues = "InvalidNumberOfCriterionValues",
2460
2464
  BlockingValidationRule = "BlockingValidationRule",
2461
2465
  InvalidCopyPasteSelection = "InvalidCopyPasteSelection",
2462
- NoChanges = "NoChanges"
2466
+ NoChanges = "NoChanges",
2467
+ InvalidInputId = "InvalidInputId"
2463
2468
  }
2464
2469
  interface CommandHandler<T> {
2465
2470
  allowDispatch(command: T): CommandResult | CommandResult[];
@@ -2606,9 +2611,9 @@ interface Border$1 {
2606
2611
  bottom?: BorderDescr;
2607
2612
  right?: BorderDescr;
2608
2613
  }
2609
- type ReferenceDenormalizer = (range: Range, isMeta: boolean, functionName: string, paramNumber: number) => any | any[][];
2610
- type EnsureRange = (range: Range) => Matrix<ValueAndFormat>;
2611
- type _CompiledFormula = (deps: Range[], refFn: ReferenceDenormalizer, range: EnsureRange, ctx: {}) => Matrix<ValueAndFormat> | ValueAndFormat;
2614
+ type ReferenceDenormalizer = (range: Range, isMeta: boolean, functionName: string, paramNumber: number) => FPayload;
2615
+ type EnsureRange = (range: Range) => Matrix<FPayload>;
2616
+ type _CompiledFormula = (deps: Range[], refFn: ReferenceDenormalizer, range: EnsureRange, ctx: {}) => Matrix<FPayload> | FPayload;
2612
2617
  interface CompiledFormula {
2613
2618
  execute: _CompiledFormula;
2614
2619
  tokens: Token[];
@@ -2618,12 +2623,12 @@ interface RangeCompiledFormula extends Omit<CompiledFormula, "dependencies"> {
2618
2623
  dependencies: Range[];
2619
2624
  }
2620
2625
  type Matrix<T = unknown> = T[][];
2621
- type ValueAndFormat = {
2626
+ type FPayload = {
2622
2627
  value: CellValue;
2623
2628
  format?: Format;
2629
+ message?: string;
2624
2630
  };
2625
- type Arg = Maybe<ValueAndFormat> | Matrix<ValueAndFormat>;
2626
- type ArgValue = Maybe<CellValue> | Matrix<CellValue>;
2631
+ type Arg = Maybe<FPayload> | Matrix<FPayload>;
2627
2632
  declare function isMatrix(x: any): x is Matrix<any>;
2628
2633
  interface HeaderDimensions {
2629
2634
  start: Pixel;
@@ -2806,7 +2811,7 @@ interface EmptyCell extends EvaluatedCellProperties {
2806
2811
  interface ErrorCell extends EvaluatedCellProperties {
2807
2812
  readonly type: CellValueType.error;
2808
2813
  readonly value: string;
2809
- readonly error: EvaluationError;
2814
+ readonly message?: string;
2810
2815
  }
2811
2816
  declare enum CellValueType {
2812
2817
  boolean = "boolean",
@@ -3274,6 +3279,7 @@ declare class CellPlugin extends CorePlugin<CoreState> implements CoreState {
3274
3279
  adaptRanges(applyChange: ApplyRangeChange, sheetId?: UID): void;
3275
3280
  allowDispatch(cmd: CoreCommand): CommandResult | CommandResult[];
3276
3281
  handle(cmd: CoreCommand): void;
3282
+ private clearZones;
3277
3283
  /**
3278
3284
  * Set a format to all the cells in a zone
3279
3285
  */
@@ -3684,6 +3690,7 @@ declare class HeaderGroupingPlugin extends CorePlugin<State$7> {
3684
3690
  private getGroupIndex;
3685
3691
  import(data: WorkbookData): void;
3686
3692
  export(data: WorkbookData): void;
3693
+ exportForExcel(data: ExcelWorkbookData): void;
3687
3694
  }
3688
3695
 
3689
3696
  interface HeaderSizeState$1 {
@@ -3920,7 +3927,6 @@ declare class SheetPlugin extends CorePlugin<SheetState> implements SheetState {
3920
3927
  */
3921
3928
  private clearPosition;
3922
3929
  private setGridLinesVisibility;
3923
- private clearZones;
3924
3930
  private createSheet;
3925
3931
  private moveSheet;
3926
3932
  private findIndexOfTargetSheet;
@@ -4126,6 +4132,7 @@ declare class EvaluationDataValidationPlugin extends UIPlugin {
4126
4132
  static getters: readonly ["getDataValidationInvalidCriterionValueMessage", "getDataValidationCheckBoxCellPositions", "getDataValidationListCellsPositions", "getInvalidDataValidationMessage", "getValidationResultForCellValue", "isCellValidCheckbox", "isDataValidationInvalid"];
4127
4133
  validationResults: Record<UID, SheetValidationResult>;
4128
4134
  handle(cmd: CoreViewCommand): void;
4135
+ private setContentToBooleanCells;
4129
4136
  isDataValidationInvalid(cellPosition: CellPosition): boolean;
4130
4137
  getInvalidDataValidationMessage(cellPosition: CellPosition): string | undefined;
4131
4138
  /**
@@ -4559,14 +4566,13 @@ interface RangeInputValue {
4559
4566
  * This plugin handles this internal state.
4560
4567
  */
4561
4568
  declare class SelectionInputPlugin extends UIPlugin implements StreamCallbacks<SelectionEvent> {
4562
- private readonly inputHasSingleRange;
4569
+ readonly inputHasSingleRange: boolean;
4563
4570
  static layers: LAYERS[];
4564
4571
  static getters: never[];
4565
4572
  ranges: RangeInputValue[];
4566
4573
  focusedRangeIndex: number | null;
4567
4574
  private inputSheetId;
4568
4575
  constructor(config: UIPluginConfig, initialRanges: string[], inputHasSingleRange: boolean);
4569
- allowDispatch(cmd: LocalCommand): CommandResult;
4570
4576
  handleEvent(event: SelectionEvent): void;
4571
4577
  handle(cmd: Command): void;
4572
4578
  getSelectionInputValue(): string[];
@@ -5192,33 +5198,22 @@ type ArgType = "ANY" | "BOOLEAN" | "NUMBER" | "STRING" | "DATE" | "RANGE" | "RAN
5192
5198
  interface ArgDefinition {
5193
5199
  repeating?: boolean;
5194
5200
  optional?: boolean;
5195
- lazy?: boolean;
5196
5201
  description: string;
5197
5202
  name: string;
5198
5203
  type: ArgType[];
5199
5204
  default?: boolean;
5200
5205
  defaultValue?: any;
5201
5206
  }
5202
- type ComputeFunctionArg<T> = T | (() => T);
5203
- type ComputeFunction<T, R> = (this: EvalContext, ...args: ComputeFunctionArg<T>[]) => R;
5204
- interface AddFunctionDescriptionBase {
5207
+ type ComputeFunction<R> = (this: EvalContext, ...args: Arg[]) => R;
5208
+ interface AddFunctionDescription {
5209
+ compute: ComputeFunction<FPayload | Matrix<FPayload> | CellValue | Matrix<CellValue>>;
5205
5210
  description: string;
5206
5211
  category?: string;
5207
5212
  args: ArgDefinition[];
5208
- returns: [ArgType];
5213
+ returns: ArgType[];
5209
5214
  isExported?: boolean;
5210
5215
  hidden?: boolean;
5211
5216
  }
5212
- interface ComputeValue {
5213
- compute: ComputeFunction<ArgValue, CellValue | Matrix<CellValue>>;
5214
- }
5215
- interface ComputeFormat {
5216
- computeFormat: ComputeFunction<Arg, Format | undefined | Matrix<Format | undefined>>;
5217
- }
5218
- interface ComputeValueAndFormat {
5219
- computeValueAndFormat: ComputeFunction<Arg, Matrix<ValueAndFormat> | ValueAndFormat>;
5220
- }
5221
- type AddFunctionDescription = (AddFunctionDescriptionBase & ComputeValue & Partial<ComputeFormat>) | (AddFunctionDescriptionBase & ComputeValueAndFormat);
5222
5217
  type FunctionDescription = AddFunctionDescription & {
5223
5218
  minArgRequired: number;
5224
5219
  maxArgPossible: number;
@@ -5226,7 +5221,6 @@ type FunctionDescription = AddFunctionDescription & {
5226
5221
  getArgToFocus: (argPosition: number) => number;
5227
5222
  };
5228
5223
  type EvalContext = {
5229
- __lastFnCalled?: string;
5230
5224
  __originSheetId: UID;
5231
5225
  __originCellXC: () => string | undefined;
5232
5226
  locale: Locale;
@@ -5601,7 +5595,7 @@ interface Props$L {
5601
5595
  name: string;
5602
5596
  label: string;
5603
5597
  value: boolean;
5604
- update: (value: boolean) => void;
5598
+ onChange: (value: boolean) => void;
5605
5599
  }>;
5606
5600
  }
5607
5601
  declare class ChartLabelRange extends Component<Props$L, SpreadsheetChildEnv> {
@@ -5917,7 +5911,6 @@ interface Props$H {
5917
5911
  declare class ChartTitle extends Component<Props$H, SpreadsheetChildEnv> {
5918
5912
  static template: string;
5919
5913
  static components: {
5920
- ColorPickerWidget: typeof ColorPickerWidget;
5921
5914
  Section: typeof Section;
5922
5915
  };
5923
5916
  static props: {
@@ -5937,7 +5930,6 @@ declare class LineBarPieDesignPanel extends Component<Props$G, SpreadsheetChildE
5937
5930
  static template: string;
5938
5931
  static components: {
5939
5932
  ChartColor: typeof ChartColor;
5940
- ColorPickerWidget: typeof ColorPickerWidget;
5941
5933
  ChartTitle: typeof ChartTitle;
5942
5934
  Section: typeof Section;
5943
5935
  };
@@ -5962,7 +5954,6 @@ interface Props$F {
5962
5954
  declare class GaugeChartConfigPanel extends Component<Props$F, SpreadsheetChildEnv> {
5963
5955
  static template: string;
5964
5956
  static components: {
5965
- SelectionInput: typeof SelectionInput;
5966
5957
  ChartErrorSection: typeof ChartErrorSection;
5967
5958
  ChartDataSeries: typeof ChartDataSeries;
5968
5959
  };
@@ -6047,7 +6038,6 @@ declare class ScorecardChartConfigPanel extends Component<Props$D, SpreadsheetCh
6047
6038
  static template: string;
6048
6039
  static components: {
6049
6040
  SelectionInput: typeof SelectionInput;
6050
- ValidationMessages: typeof ValidationMessages;
6051
6041
  ChartErrorSection: typeof ChartErrorSection;
6052
6042
  Section: typeof Section;
6053
6043
  };
@@ -8494,13 +8484,27 @@ declare class ChartPanel extends Component<Props, SpreadsheetChildEnv> {
8494
8484
  activatePanel(panel: "configuration" | "design"): void;
8495
8485
  }
8496
8486
 
8497
- declare function toNumber(value: string | number | boolean | null | undefined, locale: Locale): number;
8498
- declare function toString(value: string | number | boolean | null | undefined): string;
8499
- declare function toBoolean(value: string | number | boolean | null | undefined): boolean;
8500
- declare function toJsDate(value: string | number | boolean | null | undefined, locale: Locale): DateTime;
8487
+ declare function isEvaluationError(error: Maybe<CellValue>): boolean;
8488
+ declare function toNumber(data: FPayload | CellValue | undefined, locale: Locale): number;
8489
+ declare function toString(data: FPayload | CellValue | undefined): string;
8490
+ declare function toBoolean(data: FPayload | CellValue | undefined): boolean;
8491
+ declare function toJsDate(data: FPayload | CellValue | undefined, locale: Locale): DateTime;
8501
8492
 
8502
8493
  declare function arg(definition: string, description?: string): ArgDefinition;
8503
8494
 
8495
+ interface FunctionRegistry extends Registry<FunctionDescription> {
8496
+ add(functionName: string, addDescr: AddFunctionDescription): FunctionRegistry;
8497
+ get(functionName: string): FunctionDescription;
8498
+ mapping: {
8499
+ [functionName: string]: ComputeFunction<Matrix<FPayload> | FPayload>;
8500
+ };
8501
+ }
8502
+ declare class FunctionRegistry extends Registry<FunctionDescription> {
8503
+ mapping: {
8504
+ [key: string]: ComputeFunction<Matrix<FPayload> | FPayload>;
8505
+ };
8506
+ }
8507
+
8504
8508
  declare class ChartColors {
8505
8509
  private graphColorIndex;
8506
8510
  next(): string;
@@ -8543,6 +8547,19 @@ type TranslationFunction = (string: string, ...values: SprintfValues) => string;
8543
8547
  */
8544
8548
  declare function setTranslationMethod(tfn: TranslationFunction, loaded?: () => boolean): void;
8545
8549
 
8550
+ declare const CellErrorType: {
8551
+ readonly NotAvailable: "#N/A";
8552
+ readonly InvalidReference: "#REF";
8553
+ readonly BadExpression: "#BAD_EXPR";
8554
+ readonly CircularDependency: "#CYCLE";
8555
+ readonly UnknownFunction: "#NAME?";
8556
+ readonly GenericError: "#ERROR";
8557
+ };
8558
+ declare class EvaluationError extends Error {
8559
+ readonly value: string;
8560
+ constructor(message?: string, value?: string);
8561
+ }
8562
+
8546
8563
  /**
8547
8564
  * We export here all entities that needs to be accessed publicly by Odoo.
8548
8565
  *
@@ -8567,21 +8584,9 @@ declare const registries: {
8567
8584
  autofillRulesRegistry: Registry<AutofillRule>;
8568
8585
  cellMenuRegistry: MenuItemRegistry;
8569
8586
  colMenuRegistry: MenuItemRegistry;
8587
+ errorTypes: Set<string>;
8570
8588
  linkMenuRegistry: MenuItemRegistry;
8571
- functionRegistry: {
8572
- mapping: {
8573
- [key: string]: ComputeFunction<Arg, ValueAndFormat | Matrix<ValueAndFormat>>;
8574
- };
8575
- add(name: string, addDescr: AddFunctionDescription): any;
8576
- content: {
8577
- [key: string]: FunctionDescription;
8578
- };
8579
- get(key: string): FunctionDescription;
8580
- contains(key: string): boolean;
8581
- getAll(): FunctionDescription[];
8582
- getKeys(): string[];
8583
- remove(key: string): void;
8584
- };
8589
+ functionRegistry: FunctionRegistry;
8585
8590
  featurePluginRegistry: Registry<UIPluginConstructor>;
8586
8591
  statefulUIPluginRegistry: Registry<UIPluginConstructor>;
8587
8592
  coreViewsPluginRegistry: Registry<UIPluginConstructor>;
@@ -8619,6 +8624,7 @@ declare const registries: {
8619
8624
  };
8620
8625
  declare const helpers: {
8621
8626
  arg: typeof arg;
8627
+ isEvaluationError: typeof isEvaluationError;
8622
8628
  toBoolean: typeof toBoolean;
8623
8629
  toJsDate: typeof toJsDate;
8624
8630
  toNumber: typeof toNumber;
@@ -8639,8 +8645,6 @@ declare const helpers: {
8639
8645
  getDefaultChartJsRuntime: typeof getDefaultChartJsRuntime;
8640
8646
  chartFontColor: typeof chartFontColor;
8641
8647
  ChartColors: typeof ChartColors;
8642
- EvaluationError: typeof EvaluationError;
8643
- CellErrorLevel: typeof CellErrorLevel;
8644
8648
  getFillingMode: typeof getFillingMode;
8645
8649
  rgbaToHex: typeof rgbaToHex;
8646
8650
  colorToRGBA: typeof colorToRGBA;
@@ -8661,6 +8665,13 @@ declare const links: {
8661
8665
  urlRepresentation: typeof urlRepresentation;
8662
8666
  };
8663
8667
  declare const components: {
8668
+ Checkbox: typeof Checkbox;
8669
+ Section: typeof Section;
8670
+ ChartColor: typeof ChartColor;
8671
+ ChartDataSeries: typeof ChartDataSeries;
8672
+ ChartErrorSection: typeof ChartErrorSection;
8673
+ ChartLabelRange: typeof ChartLabelRange;
8674
+ ChartTitle: typeof ChartTitle;
8664
8675
  ChartPanel: typeof ChartPanel;
8665
8676
  ChartFigure: typeof ChartFigure;
8666
8677
  ChartJsComponent: typeof ChartJsComponent;
@@ -8690,4 +8701,4 @@ declare const constants: {
8690
8701
  DEFAULT_LOCALE: Locale;
8691
8702
  };
8692
8703
 
8693
- 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 };
8704
+ export { AST, ASTFuncall, AbstractChart, AddFunctionDescription, Arg, CancelledReason, Cell, CellErrorType, CellPosition, Client, ClientJoinedMessage, ClientLeftMessage, ClientMovedMessage, CollaborationMessage, CommandResult, CorePlugin, DispatchResult, EnrichedToken, EvalContext, EvaluationError, FPayload, FunctionRegistry, Model, Registry, RemoteRevisionMessage, Revision, RevisionRedoneMessage, RevisionUndoneMessage, SPREADSHEET_DIMENSIONS, Spreadsheet, Token, 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 };