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

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.
@@ -1430,80 +1430,6 @@ declare class UIPlugin<State = any> extends BasePlugin<State, Command> {
1430
1430
  drawGrid(ctx: GridRenderingContext, layer: LAYERS): void;
1431
1431
  }
1432
1432
 
1433
- interface SearchOptions {
1434
- matchCase: boolean;
1435
- exactMatch: boolean;
1436
- searchFormulas: boolean;
1437
- }
1438
- interface SearchMatch {
1439
- selected: boolean;
1440
- col: HeaderIndex;
1441
- row: HeaderIndex;
1442
- }
1443
- /**
1444
- * Find and Replace Plugin
1445
- *
1446
- * This plugin is used in combination with the find_and_replace sidePanel
1447
- * It is used to 'highlight' cells that match an input string according to
1448
- * the given searchOptions. The second part of this plugin makes it possible
1449
- * (again with the find_and_replace sidePanel), to replace the values that match
1450
- * the search with a new value.
1451
- */
1452
- declare class FindAndReplacePlugin extends UIPlugin {
1453
- static layers: LAYERS[];
1454
- static getters: readonly ["getSearchMatches", "getCurrentSelectedMatchIndex"];
1455
- private searchMatches;
1456
- private selectedMatchIndex;
1457
- private currentSearchRegex;
1458
- private searchOptions;
1459
- private toSearch;
1460
- private isSearchDirty;
1461
- handle(cmd: Command): void;
1462
- finalize(): void;
1463
- getSearchMatches(): SearchMatch[];
1464
- getCurrentSelectedMatchIndex(): number | null;
1465
- /**
1466
- * Will update the current searchOptions and accordingly update the regex.
1467
- * It will then search for matches using the regex and store them.
1468
- */
1469
- private updateSearch;
1470
- /**
1471
- * refresh the matches according to the current search options
1472
- */
1473
- private refreshSearch;
1474
- /**
1475
- * Updates the regex based on the current searchOptions and
1476
- * the value toSearch
1477
- */
1478
- private updateRegex;
1479
- /**
1480
- * Find matches using the current regex
1481
- */
1482
- private findMatches;
1483
- private sortByRowThenColumn;
1484
- /**
1485
- * Changes the selected search cell. Given a direction it will
1486
- * Change the selection to the previous, current or nextCell,
1487
- * if it exists otherwise it will set the selectedMatchIndex to null.
1488
- * It will also reset the index to 0 if the search has changed.
1489
- * It is also used to keep coherence between the selected searchMatch
1490
- * and selectedMatchIndex.
1491
- */
1492
- private selectNextCell;
1493
- private clearSearch;
1494
- private replaceMatch;
1495
- /**
1496
- * Replace the value of the currently selected match
1497
- */
1498
- private replace;
1499
- /**
1500
- * Apply the replace function to all the matches one time.
1501
- */
1502
- private replaceAll;
1503
- private getSearchableString;
1504
- drawGrid(renderingContext: GridRenderingContext): void;
1505
- }
1506
-
1507
1433
  type EditionMode = "editing" | "selecting" | "inactive";
1508
1434
  interface ComposerSelection {
1509
1435
  start: number;
@@ -1691,6 +1617,14 @@ type ClipboardContent = {
1691
1617
  };
1692
1618
  type ClipboardPasteOptions = "onlyFormat" | "onlyValue";
1693
1619
 
1620
+ interface SearchOptions {
1621
+ matchCase: boolean;
1622
+ exactMatch: boolean;
1623
+ searchFormulas: boolean;
1624
+ searchScope: "allSheets" | "activeSheet" | "specificRange";
1625
+ specificRange?: RangeData;
1626
+ }
1627
+
1694
1628
  /**
1695
1629
  * There are two kinds of commands: CoreCommands and LocalCommands
1696
1630
  *
@@ -2499,7 +2433,8 @@ declare const enum CommandResult {
2499
2433
  InvalidDataValidationCriterionValue = "InvalidDataValidationCriterionValue",
2500
2434
  InvalidNumberOfCriterionValues = "InvalidNumberOfCriterionValues",
2501
2435
  BlockingValidationRule = "BlockingValidationRule",
2502
- InvalidCopyPasteSelection = "InvalidCopyPasteSelection"
2436
+ InvalidCopyPasteSelection = "InvalidCopyPasteSelection",
2437
+ NoChanges = "NoChanges"
2503
2438
  }
2504
2439
  interface CommandHandler<T> {
2505
2440
  allowDispatch(command: T): CommandResult | CommandResult[];
@@ -3078,50 +3013,6 @@ interface SpreadsheetChildEnv extends SpreadsheetEnv {
3078
3013
  loadLocales: () => Promise<Locale[]>;
3079
3014
  }
3080
3015
 
3081
- type ArgType = "ANY" | "BOOLEAN" | "NUMBER" | "STRING" | "DATE" | "RANGE" | "RANGE<BOOLEAN>" | "RANGE<NUMBER>" | "RANGE<DATE>" | "RANGE<STRING>" | "RANGE<ANY>" | "META";
3082
- interface ArgDefinition {
3083
- repeating?: boolean;
3084
- optional?: boolean;
3085
- lazy?: boolean;
3086
- description: string;
3087
- name: string;
3088
- type: ArgType[];
3089
- default?: boolean;
3090
- defaultValue?: any;
3091
- }
3092
- type ComputeFunctionArg<T> = T | (() => T);
3093
- type ComputeFunction<T, R> = (this: EvalContext, ...args: ComputeFunctionArg<T>[]) => R;
3094
- interface AddFunctionDescriptionBase {
3095
- description: string;
3096
- category?: string;
3097
- args: ArgDefinition[];
3098
- returns: [ArgType];
3099
- isExported?: boolean;
3100
- hidden?: boolean;
3101
- }
3102
- interface ComputeValue {
3103
- compute: ComputeFunction<ArgValue, CellValue | Matrix<CellValue>>;
3104
- }
3105
- interface ComputeFormat {
3106
- computeFormat: ComputeFunction<Arg, Format | undefined | Matrix<Format | undefined>>;
3107
- }
3108
- interface ComputeValueAndFormat {
3109
- computeValueAndFormat: ComputeFunction<Arg, Matrix<ValueAndFormat> | ValueAndFormat>;
3110
- }
3111
- type AddFunctionDescription = (AddFunctionDescriptionBase & ComputeValue & Partial<ComputeFormat>) | (AddFunctionDescriptionBase & ComputeValueAndFormat);
3112
- type FunctionDescription = AddFunctionDescription & {
3113
- minArgRequired: number;
3114
- maxArgPossible: number;
3115
- nbrArgRepeating: number;
3116
- getArgToFocus: (argPosition: number) => number;
3117
- };
3118
- type EvalContext = {
3119
- __lastFnCalled?: string;
3120
- __originCellXC?: () => string;
3121
- locale: Locale;
3122
- [key: string]: any;
3123
- };
3124
-
3125
3016
  declare class RangeAdapter implements CommandHandler<CoreCommand> {
3126
3017
  private getters;
3127
3018
  private providers;
@@ -3231,7 +3122,8 @@ interface BordersPluginState {
3231
3122
  declare class BordersPlugin extends CorePlugin<BordersPluginState> implements BordersPluginState {
3232
3123
  static getters: readonly ["getCellBorder", "getBordersColors"];
3233
3124
  readonly borders: BordersPluginState["borders"];
3234
- handle(cmd: Command): void;
3125
+ allowDispatch(cmd: CoreCommand): CommandResult.Success | CommandResult.NoChanges;
3126
+ handle(cmd: CoreCommand): void;
3235
3127
  /**
3236
3128
  * Move borders according to the inserted columns.
3237
3129
  * Ensure borders continuity.
@@ -3329,6 +3221,7 @@ declare class BordersPlugin extends CorePlugin<BordersPluginState> implements Bo
3329
3221
  * Compute the borders to add to the given zone merged.
3330
3222
  */
3331
3223
  private addBordersToMerge;
3224
+ private checkBordersUnchanged;
3332
3225
  import(data: WorkbookData): void;
3333
3226
  export(data: WorkbookData): void;
3334
3227
  exportForExcel(data: ExcelWorkbookData): void;
@@ -3345,7 +3238,7 @@ interface CoreState {
3345
3238
  * cell and sheet content.
3346
3239
  */
3347
3240
  declare class CellPlugin extends CorePlugin<CoreState> implements CoreState {
3348
- static getters: readonly ["zoneToXC", "getCells", "getFormulaCellContent", "getTranslatedCellFormula", "getCellStyle", "getCellById"];
3241
+ static getters: readonly ["zoneToXC", "getCells", "getTranslatedCellFormula", "getCellStyle", "getCellById"];
3349
3242
  readonly nextId = 1;
3350
3243
  readonly cells: {
3351
3244
  [sheetId: string]: {
@@ -3353,7 +3246,7 @@ declare class CellPlugin extends CorePlugin<CoreState> implements CoreState {
3353
3246
  };
3354
3247
  };
3355
3248
  adaptRanges(applyChange: ApplyRangeChange, sheetId?: UID): void;
3356
- allowDispatch(cmd: CoreCommand): CommandResult;
3249
+ allowDispatch(cmd: CoreCommand): CommandResult | CommandResult[];
3357
3250
  handle(cmd: CoreCommand): void;
3358
3251
  /**
3359
3252
  * Set a format to all the cells in a zone
@@ -3382,7 +3275,7 @@ declare class CellPlugin extends CorePlugin<CoreState> implements CoreState {
3382
3275
  * starting an async evaluation even if it has been moved or re-allocated
3383
3276
  */
3384
3277
  getCellById(cellId: UID): Cell | undefined;
3385
- getFormulaCellContent(sheetId: UID, compiledFormula: RangeCompiledFormula, dependencies?: Range[]): string;
3278
+ private getFormulaCellContent;
3386
3279
  getTranslatedCellFormula(sheetId: UID, offsetX: number, offsetY: number, compiledFormula: RangeCompiledFormula): string;
3387
3280
  getCellStyle(position: CellPosition): Style;
3388
3281
  /**
@@ -3427,6 +3320,7 @@ declare class CellPlugin extends CorePlugin<CoreState> implements CoreState {
3427
3320
  private createFormulaCellWithDependencies;
3428
3321
  private createErrorFormula;
3429
3322
  private checkCellOutOfSheet;
3323
+ private checkUselessClearCell;
3430
3324
  }
3431
3325
 
3432
3326
  /**
@@ -4057,15 +3951,6 @@ declare class SheetPlugin extends CorePlugin<SheetState> implements SheetState {
4057
3951
  */
4058
3952
  private moveCellOnRowsDeletion;
4059
3953
  private updateRowsStructureOnDeletion;
4060
- /**
4061
- * Update the rows of the sheet after an addition:
4062
- * - Rename the rows
4063
- *
4064
- * @param sheet Sheet on which the deletion occurs
4065
- * @param addedRow Index of the added row
4066
- * @param rowsToAdd Number of the rows to add
4067
- */
4068
- private updateRowsStructureOnAddition;
4069
3954
  /**
4070
3955
  * Add empty rows at the end of the rows
4071
3956
  *
@@ -4087,11 +3972,9 @@ declare class SheetPlugin extends CorePlugin<SheetState> implements SheetState {
4087
3972
  }
4088
3973
 
4089
3974
  declare class EvaluationPlugin extends UIPlugin {
4090
- private config;
4091
- static getters: readonly ["evaluateFormula", "getCorrespondingFormulaCell", "getRangeFormattedValues", "getRangeValues", "getRangeFormats", "getEvaluatedCell", "getEvaluatedCells", "getEvaluatedCellsInZone", "getSpreadPositionsOf"];
3975
+ static getters: readonly ["evaluateFormula", "getCorrespondingFormulaCell", "getRangeFormattedValues", "getRangeValues", "getRangeFormats", "getEvaluatedCell", "getEvaluatedCells", "getEvaluatedCellsInZone", "getSpreadPositionsOf", "getArrayFormulaSpreadingOn"];
4092
3976
  private shouldRebuildDependenciesGraph;
4093
3977
  private evaluator;
4094
- private compilationParams;
4095
3978
  private positionsToUpdate;
4096
3979
  constructor(config: UIPluginConfig);
4097
3980
  beforeHandle(cmd: Command): void;
@@ -4114,6 +3997,7 @@ declare class EvaluationPlugin extends UIPlugin {
4114
3997
  getEvaluatedCells(sheetId: UID): Record<UID, EvaluatedCell>;
4115
3998
  getEvaluatedCellsInZone(sheetId: UID, zone: Zone): EvaluatedCell[];
4116
3999
  getSpreadPositionsOf(position: CellPosition): CellPosition[];
4000
+ getArrayFormulaSpreadingOn(position: CellPosition): CellPosition | undefined;
4117
4001
  exportForExcel(data: ExcelWorkbookData): void;
4118
4002
  /**
4119
4003
  * Returns the corresponding formula cell of a given cell
@@ -4121,7 +4005,6 @@ declare class EvaluationPlugin extends UIPlugin {
4121
4005
  * formula of the array formula that spreads to the cell
4122
4006
  */
4123
4007
  getCorrespondingFormulaCell(position: CellPosition): FormulaCell | undefined;
4124
- private getCompilationParameters;
4125
4008
  }
4126
4009
 
4127
4010
  interface CustomColorState {
@@ -4458,6 +4341,78 @@ declare class CollaborativePlugin extends UIPlugin {
4458
4341
  drawGrid(renderingContext: GridRenderingContext): void;
4459
4342
  }
4460
4343
 
4344
+ /**
4345
+ * Find and Replace Plugin
4346
+ *
4347
+ * This plugin is used in combination with the find_and_replace sidePanel
4348
+ * It is used to 'highlight' cells that match an input string according to
4349
+ * the given searchOptions. The second part of this plugin makes it possible
4350
+ * (again with the find_and_replace sidePanel), to replace the values that match
4351
+ * the search with a new value.
4352
+ */
4353
+ declare class FindAndReplacePlugin extends UIPlugin {
4354
+ static layers: LAYERS[];
4355
+ static getters: readonly ["getSearchMatches", "getCurrentSelectedMatchIndex", "getSearchOptions", "getAllSheetMatchesCount", "getActiveSheetMatchesCount", "getSpecificRangeMatchesCount"];
4356
+ private allSheetsMatches;
4357
+ private activeSheetMatches;
4358
+ private specificRangeMatches;
4359
+ private selectedMatchIndex;
4360
+ private currentSearchRegex;
4361
+ private searchOptions;
4362
+ private toSearch;
4363
+ private isSearchDirty;
4364
+ get searchMatches(): CellPosition[];
4365
+ handle(cmd: Command): void;
4366
+ finalize(): void;
4367
+ getSearchMatches(): CellPosition[];
4368
+ getCurrentSelectedMatchIndex(): number | null;
4369
+ getSearchOptions(): SearchOptions;
4370
+ getAllSheetMatchesCount(): number;
4371
+ getActiveSheetMatchesCount(): number;
4372
+ getSpecificRangeMatchesCount(): number;
4373
+ /**
4374
+ * Will update the current searchOptions and accordingly update the regex.
4375
+ * It will then search for matches using the regex and store them.
4376
+ */
4377
+ private updateSearch;
4378
+ /**
4379
+ * refresh the matches according to the current search options
4380
+ */
4381
+ private refreshSearch;
4382
+ /**
4383
+ * Updates the regex based on the current searchOptions and
4384
+ * the value toSearch
4385
+ */
4386
+ private updateRegex;
4387
+ private getSheetsInSearchOrder;
4388
+ /**
4389
+ * Find matches using the current regex
4390
+ */
4391
+ private findMatches;
4392
+ private findMatchesInSheet;
4393
+ /**
4394
+ * Changes the selected search cell. Given a direction it will
4395
+ * Change the selection to the previous, current or nextCell,
4396
+ * if it exists otherwise it will set the selectedMatchIndex to null.
4397
+ * It will also reset the index to 0 if the search has changed.
4398
+ * It is also used to keep coherence between the selected searchMatch
4399
+ * and selectedMatchIndex.
4400
+ */
4401
+ private selectNextCell;
4402
+ private clearSearch;
4403
+ private replaceMatch;
4404
+ /**
4405
+ * Replace the value of the currently selected match
4406
+ */
4407
+ private replace;
4408
+ /**
4409
+ * Apply the replace function to all the matches one time.
4410
+ */
4411
+ private replaceAll;
4412
+ private getSearchableString;
4413
+ drawGrid(renderingContext: GridRenderingContext): void;
4414
+ }
4415
+
4461
4416
  declare class HeaderVisibilityUIPlugin extends UIPlugin {
4462
4417
  static getters: readonly ["getNextVisibleCellPosition", "findVisibleHeader", "findLastVisibleColRowIndex", "findFirstVisibleColRowIndex", "isRowHidden", "isColHidden", "isHeaderHidden"];
4463
4418
  isRowHidden(sheetId: UID, index: number): boolean;
@@ -5216,6 +5171,52 @@ type Getters = {
5216
5171
  isDashboard: () => boolean;
5217
5172
  } & CoreGetters & PluginGetters<typeof AutofillPlugin> & PluginGetters<typeof AutomaticSumPlugin> & PluginGetters<typeof HistoryPlugin> & PluginGetters<typeof ClipboardPlugin> & PluginGetters<typeof EditionPlugin> & PluginGetters<typeof EvaluationPlugin> & PluginGetters<typeof EvaluationChartPlugin> & PluginGetters<typeof EvaluationConditionalFormatPlugin> & PluginGetters<typeof FindAndReplacePlugin> & PluginGetters<typeof HeaderVisibilityUIPlugin> & PluginGetters<typeof HighlightPlugin> & PluginGetters<typeof CustomColorsPlugin> & PluginGetters<typeof AutomaticSumPlugin> & PluginGetters<typeof RendererPlugin> & PluginGetters<typeof GridSelectionPlugin> & PluginGetters<typeof SelectionInputsManagerPlugin> & PluginGetters<typeof CollaborativePlugin> & PluginGetters<typeof SortPlugin> & PluginGetters<typeof UIOptionsPlugin> & PluginGetters<typeof SheetUIPlugin> & PluginGetters<typeof SheetViewPlugin> & PluginGetters<typeof CellPopoverPlugin> & PluginGetters<typeof FilterEvaluationPlugin> & PluginGetters<typeof SplitToColumnsPlugin> & PluginGetters<typeof HeaderSizeUIPlugin> & PluginGetters<typeof EvaluationDataValidationPlugin> & PluginGetters<typeof HeaderPositionsUIPlugin>;
5218
5173
 
5174
+ type ArgType = "ANY" | "BOOLEAN" | "NUMBER" | "STRING" | "DATE" | "RANGE" | "RANGE<BOOLEAN>" | "RANGE<NUMBER>" | "RANGE<DATE>" | "RANGE<STRING>" | "RANGE<ANY>" | "META";
5175
+ interface ArgDefinition {
5176
+ repeating?: boolean;
5177
+ optional?: boolean;
5178
+ lazy?: boolean;
5179
+ description: string;
5180
+ name: string;
5181
+ type: ArgType[];
5182
+ default?: boolean;
5183
+ defaultValue?: any;
5184
+ }
5185
+ type ComputeFunctionArg<T> = T | (() => T);
5186
+ type ComputeFunction<T, R> = (this: EvalContext, ...args: ComputeFunctionArg<T>[]) => R;
5187
+ interface AddFunctionDescriptionBase {
5188
+ description: string;
5189
+ category?: string;
5190
+ args: ArgDefinition[];
5191
+ returns: [ArgType];
5192
+ isExported?: boolean;
5193
+ hidden?: boolean;
5194
+ }
5195
+ interface ComputeValue {
5196
+ compute: ComputeFunction<ArgValue, CellValue | Matrix<CellValue>>;
5197
+ }
5198
+ interface ComputeFormat {
5199
+ computeFormat: ComputeFunction<Arg, Format | undefined | Matrix<Format | undefined>>;
5200
+ }
5201
+ interface ComputeValueAndFormat {
5202
+ computeValueAndFormat: ComputeFunction<Arg, Matrix<ValueAndFormat> | ValueAndFormat>;
5203
+ }
5204
+ type AddFunctionDescription = (AddFunctionDescriptionBase & ComputeValue & Partial<ComputeFormat>) | (AddFunctionDescriptionBase & ComputeValueAndFormat);
5205
+ type FunctionDescription = AddFunctionDescription & {
5206
+ minArgRequired: number;
5207
+ maxArgPossible: number;
5208
+ nbrArgRepeating: number;
5209
+ getArgToFocus: (argPosition: number) => number;
5210
+ };
5211
+ type EvalContext = {
5212
+ __lastFnCalled?: string;
5213
+ __originSheetId: UID;
5214
+ __originCellXC: () => string | undefined;
5215
+ locale: Locale;
5216
+ getters: Getters;
5217
+ [key: string]: any;
5218
+ };
5219
+
5219
5220
  interface HistoryChange {
5220
5221
  path: [any, ...(number | string)[]];
5221
5222
  before: any;
@@ -5774,6 +5775,10 @@ interface ActionSpec {
5774
5775
  * Can be defined to display an icon
5775
5776
  */
5776
5777
  icon?: string | ((env: SpreadsheetChildEnv) => string);
5778
+ /**
5779
+ * Can be defined to display another icon on the right of the item.
5780
+ */
5781
+ secondaryIcon?: string | ((env: SpreadsheetChildEnv) => string);
5777
5782
  /**
5778
5783
  * is the action allowed when running spreadsheet in readonly mode
5779
5784
  */
@@ -5804,6 +5809,7 @@ interface Action {
5804
5809
  isEnabled: (env: SpreadsheetChildEnv) => boolean;
5805
5810
  isActive?: (env: SpreadsheetChildEnv) => boolean;
5806
5811
  icon: (env: SpreadsheetChildEnv) => string;
5812
+ secondaryIcon: (env: SpreadsheetChildEnv) => string;
5807
5813
  isReadonlyAllowed: boolean;
5808
5814
  execute?: (env: SpreadsheetChildEnv) => unknown;
5809
5815
  children: (env: SpreadsheetChildEnv) => Action[];
@@ -7342,6 +7348,9 @@ declare class Spreadsheet extends Component<SpreadsheetProps, SpreadsheetChildEn
7342
7348
  };
7343
7349
  sidePanel: SidePanelState;
7344
7350
  composer: ComposerState;
7351
+ spreadsheetRef: {
7352
+ el: HTMLElement | null;
7353
+ };
7345
7354
  private _focusGrid?;
7346
7355
  private keyDownMapping;
7347
7356
  private isViewportTooSmall;
@@ -7474,7 +7483,7 @@ declare class ColResizer extends AbstractResizer {
7474
7483
  _getActiveElements(): Set<HeaderIndex>;
7475
7484
  _getPreviousVisibleElement(index: HeaderIndex): HeaderIndex;
7476
7485
  unhide(hiddenElements: HeaderIndex[]): void;
7477
- unhideStyleValue(hiddenIndex: HeaderIndex): Pixel;
7486
+ getUnhideButtonStyle(hiddenIndex: HeaderIndex): string;
7478
7487
  }
7479
7488
  declare class RowResizer extends AbstractResizer {
7480
7489
  static template: string;
@@ -7499,7 +7508,7 @@ declare class RowResizer extends AbstractResizer {
7499
7508
  _getActiveElements(): Set<HeaderIndex>;
7500
7509
  _getPreviousVisibleElement(index: HeaderIndex): HeaderIndex;
7501
7510
  unhide(hiddenElements: HeaderIndex[]): void;
7502
- unhideStyleValue(hiddenIndex: HeaderIndex): Pixel;
7511
+ getUnhideButtonStyle(hiddenIndex: HeaderIndex): string;
7503
7512
  }
7504
7513
  declare class HeadersOverlay extends Component<any, SpreadsheetChildEnv> {
7505
7514
  static template: string;
@@ -7866,6 +7875,7 @@ declare const components: {
7866
7875
  FigureComponent: typeof FigureComponent;
7867
7876
  Menu: typeof Menu;
7868
7877
  SelectionInput: typeof SelectionInput;
7878
+ ValidationMessages: typeof ValidationMessages;
7869
7879
  };
7870
7880
  declare const hooks: {
7871
7881
  useDragAndDropListItems: typeof useDragAndDropListItems;