@odoo/o-spreadsheet 16.3.0-alpha.8 → 16.4.0-alpha.0

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.
@@ -4400,6 +4400,7 @@ exports.CommandResult = void 0;
4400
4400
  CommandResult[CommandResult["EmptySplitSeparator"] = 89] = "EmptySplitSeparator";
4401
4401
  CommandResult[CommandResult["SplitWillOverwriteContent"] = 90] = "SplitWillOverwriteContent";
4402
4402
  CommandResult[CommandResult["NoSplitSeparatorInSelection"] = 91] = "NoSplitSeparatorInSelection";
4403
+ CommandResult[CommandResult["NoActiveSheet"] = 92] = "NoActiveSheet";
4403
4404
  })(exports.CommandResult || (exports.CommandResult = {}));
4404
4405
 
4405
4406
  const borderStyles = ["thin", "medium", "thick", "dashed", "dotted"];
@@ -17549,7 +17550,7 @@ topbarMenuRegistry
17549
17550
  })
17550
17551
  .addChild("sort_range", ["data"], {
17551
17552
  ...sortRange,
17552
- sequence: 20,
17553
+ sequence: 10,
17553
17554
  separator: true,
17554
17555
  })
17555
17556
  .addChild("sort_ascending", ["data", "sort_range"], {
@@ -17562,16 +17563,16 @@ topbarMenuRegistry
17562
17563
  })
17563
17564
  .addChild("split_to_columns", ["data"], {
17564
17565
  ...splitToColumns,
17565
- sequence: 10,
17566
+ sequence: 20,
17566
17567
  separator: true,
17567
17568
  })
17568
17569
  .addChild("add_data_filter", ["data"], {
17569
17570
  ...addDataFilter,
17570
- sequence: 10,
17571
+ sequence: 30,
17571
17572
  })
17572
17573
  .addChild("remove_data_filter", ["data"], {
17573
17574
  ...removeDataFilter,
17574
- sequence: 10,
17575
+ sequence: 30,
17575
17576
  });
17576
17577
 
17577
17578
  class OTRegistry extends Registry {
@@ -18678,6 +18679,18 @@ ChartPanel.props = {
18678
18679
  onCloseSidePanel: Function,
18679
18680
  };
18680
18681
 
18682
+ css /* scss */ `
18683
+ .o-spreadsheet {
18684
+ .o-icon {
18685
+ .small-text {
18686
+ font: bold 9px sans-serif;
18687
+ }
18688
+ .heavy-text {
18689
+ font: bold 16px sans-serif;
18690
+ }
18691
+ }
18692
+ }
18693
+ `;
18681
18694
  // -----------------------------------------------------------------------------
18682
18695
  // We need here the svg of the icons that we need to convert to images for the renderer
18683
18696
  // -----------------------------------------------------------------------------
@@ -32194,6 +32207,8 @@ class SheetPlugin extends CorePlugin {
32194
32207
  "getSheetSize",
32195
32208
  "getSheetZone",
32196
32209
  "getPaneDivisions",
32210
+ "checkZonesExistInSheet",
32211
+ "getCommandZones",
32197
32212
  ];
32198
32213
  sheetIdsMapName = {};
32199
32214
  orderedSheetIds = [];
@@ -32203,7 +32218,7 @@ class SheetPlugin extends CorePlugin {
32203
32218
  // Command Handling
32204
32219
  // ---------------------------------------------------------------------------
32205
32220
  allowDispatch(cmd) {
32206
- const genericChecks = this.chainValidations(this.checkSheetExists, this.checkZones)(cmd);
32221
+ const genericChecks = this.chainValidations(this.checkSheetExists, this.checkZonesAreInSheet)(cmd);
32207
32222
  if (genericChecks !== 0 /* CommandResult.Success */) {
32208
32223
  return genericChecks;
32209
32224
  }
@@ -32543,6 +32558,37 @@ class SheetPlugin extends CorePlugin {
32543
32558
  .map(({ col, row }) => this.getCell({ sheetId, col, row }))
32544
32559
  .every((cell) => !cell || cell.content === "");
32545
32560
  }
32561
+ getCommandZones(cmd) {
32562
+ const zones = [];
32563
+ if ("zone" in cmd) {
32564
+ zones.push(cmd.zone);
32565
+ }
32566
+ if ("target" in cmd) {
32567
+ zones.push(...cmd.target);
32568
+ }
32569
+ if ("ranges" in cmd) {
32570
+ zones.push(...cmd.ranges.map((rangeData) => this.getters.getRangeFromRangeData(rangeData).zone));
32571
+ }
32572
+ if ("col" in cmd && "row" in cmd) {
32573
+ zones.push({ top: cmd.row, left: cmd.col, bottom: cmd.row, right: cmd.col });
32574
+ }
32575
+ return zones;
32576
+ }
32577
+ /**
32578
+ * Check if zones in the command are well formed and
32579
+ * not outside the sheet.
32580
+ */
32581
+ checkZonesExistInSheet(sheetId, zones) {
32582
+ if (!zones.every(isZoneValid))
32583
+ return 25 /* CommandResult.InvalidRange */;
32584
+ if (zones.length) {
32585
+ const sheetZone = this.getSheetZone(sheetId);
32586
+ return zones.every((zone) => isZoneInside(zone, sheetZone))
32587
+ ? 0 /* CommandResult.Success */
32588
+ : 18 /* CommandResult.TargetOutOfSheet */;
32589
+ }
32590
+ return 0 /* CommandResult.Success */;
32591
+ }
32546
32592
  updateCellPosition(cmd) {
32547
32593
  const { sheetId, cellId, col, row } = cmd;
32548
32594
  if (cellId) {
@@ -32991,9 +33037,6 @@ class SheetPlugin extends CorePlugin {
32991
33037
  }
32992
33038
  return { rowNumber, colNumber };
32993
33039
  }
32994
- // ----------------------------------------------------
32995
- // HIDE / SHOW
32996
- // ----------------------------------------------------
32997
33040
  /**
32998
33041
  * Check that any "sheetId" in the command matches an existing
32999
33042
  * sheet.
@@ -33011,27 +33054,10 @@ class SheetPlugin extends CorePlugin {
33011
33054
  * Check if zones in the command are well formed and
33012
33055
  * not outside the sheet.
33013
33056
  */
33014
- checkZones(cmd) {
33015
- const zones = [];
33016
- if ("zone" in cmd) {
33017
- zones.push(cmd.zone);
33018
- }
33019
- if ("target" in cmd && Array.isArray(cmd.target)) {
33020
- zones.push(...cmd.target);
33021
- }
33022
- if ("ranges" in cmd && Array.isArray(cmd.ranges)) {
33023
- zones.push(...cmd.ranges.map((rangeData) => this.getters.getRangeFromRangeData(rangeData).zone));
33024
- }
33025
- if (!zones.every(isZoneValid)) {
33026
- return 25 /* CommandResult.InvalidRange */;
33027
- }
33028
- else if (zones.length && "sheetId" in cmd) {
33029
- const sheetZone = this.getSheetZone(cmd.sheetId);
33030
- return zones.every((zone) => isZoneInside(zone, sheetZone))
33031
- ? 0 /* CommandResult.Success */
33032
- : 18 /* CommandResult.TargetOutOfSheet */;
33033
- }
33034
- return 0 /* CommandResult.Success */;
33057
+ checkZonesAreInSheet(cmd) {
33058
+ if (!("sheetId" in cmd))
33059
+ return 0 /* CommandResult.Success */;
33060
+ return this.checkZonesExistInSheet(cmd.sheetId, this.getCommandZones(cmd));
33035
33061
  }
33036
33062
  }
33037
33063
 
@@ -33622,7 +33648,7 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
33622
33648
  }
33623
33649
  break;
33624
33650
  case "PASTE_CONDITIONAL_FORMAT":
33625
- this.pasteCf(cmd.origin, cmd.target, cmd.operation);
33651
+ this.pasteCf(cmd.originPosition, cmd.targetPosition, cmd.operation);
33626
33652
  break;
33627
33653
  }
33628
33654
  }
@@ -38607,18 +38633,7 @@ class SheetUIPlugin extends UIPlugin {
38607
38633
  // Command Handling
38608
38634
  // ---------------------------------------------------------------------------
38609
38635
  allowDispatch(cmd) {
38610
- switch (cmd.type) {
38611
- case "AUTORESIZE_ROWS":
38612
- case "AUTORESIZE_COLUMNS":
38613
- try {
38614
- this.getters.getSheet(cmd.sheetId);
38615
- break;
38616
- }
38617
- catch (error) {
38618
- return 27 /* CommandResult.InvalidSheetId */;
38619
- }
38620
- }
38621
- return 0 /* CommandResult.Success */;
38636
+ return this.chainValidations(this.checkSheetExists, this.checkZonesAreInSheet)(cmd);
38622
38637
  }
38623
38638
  handle(cmd) {
38624
38639
  switch (cmd.type) {
@@ -38818,6 +38833,31 @@ class SheetUIPlugin extends UIPlugin {
38818
38833
  splitWord.push(wordPart);
38819
38834
  return splitWord;
38820
38835
  }
38836
+ /**
38837
+ * Check that any "sheetId" in the command matches an existing
38838
+ * sheet.
38839
+ */
38840
+ checkSheetExists(cmd) {
38841
+ if ("sheetId" in cmd && this.getters.tryGetSheet(cmd.sheetId) === undefined) {
38842
+ return 27 /* CommandResult.InvalidSheetId */;
38843
+ }
38844
+ return 0 /* CommandResult.Success */;
38845
+ }
38846
+ /**
38847
+ * Check if zones in the command are well formed and
38848
+ * not outside the sheet.
38849
+ */
38850
+ checkZonesAreInSheet(cmd) {
38851
+ const sheetId = "sheetId" in cmd ? cmd.sheetId : this.getters.tryGetActiveSheetId();
38852
+ const zones = this.getters.getCommandZones(cmd);
38853
+ if (!sheetId && zones.length > 0) {
38854
+ return 92 /* CommandResult.NoActiveSheet */;
38855
+ }
38856
+ if (sheetId && zones.length > 0) {
38857
+ return this.getters.checkZonesExistInSheet(sheetId, zones);
38858
+ }
38859
+ return 0 /* CommandResult.Success */;
38860
+ }
38821
38861
  }
38822
38862
 
38823
38863
  const genericRepeatsTransforms = [
@@ -39642,8 +39682,8 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
39642
39682
  this.pasteCell(origin, position, this.operation, clipboardOptions);
39643
39683
  if (shouldPasteCF) {
39644
39684
  this.dispatch("PASTE_CONDITIONAL_FORMAT", {
39645
- origin: origin.position,
39646
- target: position,
39685
+ originPosition: origin.position,
39686
+ targetPosition: position,
39647
39687
  operation: this.operation,
39648
39688
  });
39649
39689
  }
@@ -40034,7 +40074,7 @@ class ClipboardPlugin extends UIPlugin {
40034
40074
  allowDispatch(cmd) {
40035
40075
  switch (cmd.type) {
40036
40076
  case "CUT":
40037
- const zones = cmd.target || this.getters.getSelectedZones();
40077
+ const zones = cmd.cutTarget || this.getters.getSelectedZones();
40038
40078
  const state = this.getClipboardState(zones, cmd.type);
40039
40079
  return state.isCutAllowed(zones);
40040
40080
  case "PASTE":
@@ -40064,7 +40104,7 @@ class ClipboardPlugin extends UIPlugin {
40064
40104
  switch (cmd.type) {
40065
40105
  case "COPY":
40066
40106
  case "CUT":
40067
- const zones = ("target" in cmd && cmd.target) || this.getters.getSelectedZones();
40107
+ const zones = ("cutTarget" in cmd && cmd.cutTarget) || this.getters.getSelectedZones();
40068
40108
  this.state = this.getClipboardState(zones, cmd.type);
40069
40109
  this.status = "visible";
40070
40110
  break;
@@ -41020,6 +41060,7 @@ class GridSelectionPlugin extends UIPlugin {
41020
41060
  "isSelected",
41021
41061
  "isSingleColSelected",
41022
41062
  "getElementsFromSelection",
41063
+ "tryGetActiveSheetId",
41023
41064
  ];
41024
41065
  gridSelection = {
41025
41066
  anchor: {
@@ -41235,6 +41276,9 @@ class GridSelectionPlugin extends UIPlugin {
41235
41276
  getActiveSheetId() {
41236
41277
  return this.activeSheet.id;
41237
41278
  }
41279
+ tryGetActiveSheetId() {
41280
+ return this.activeSheet?.id;
41281
+ }
41238
41282
  getActiveCell() {
41239
41283
  return this.getters.getEvaluatedCell(this.getActivePosition());
41240
41284
  }
@@ -41481,7 +41525,7 @@ class GridSelectionPlugin extends UIPlugin {
41481
41525
  const deltaCol = isBasedBefore && isCol ? thickness : 0;
41482
41526
  const deltaRow = isBasedBefore && !isCol ? thickness : 0;
41483
41527
  this.dispatch("CUT", {
41484
- target: [
41528
+ cutTarget: [
41485
41529
  {
41486
41530
  left: isCol ? start + deltaCol : 0,
41487
41531
  right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
@@ -46975,6 +47019,7 @@ class Model extends EventBus {
46975
47019
  coreGetters;
46976
47020
  uuidGenerator;
46977
47021
  handlers = [];
47022
+ uiHandlers = [];
46978
47023
  coreHandlers = [];
46979
47024
  constructor(data = {}, config = {}, stateUpdateMessages = [], uuidGenerator = new UuidGenerator(), verboseImport = true) {
46980
47025
  super();
@@ -47014,17 +47059,20 @@ class Model extends EventBus {
47014
47059
  const plugin = this.setupUiPlugin(Plugin);
47015
47060
  this.statefulUIPlugins.push(plugin);
47016
47061
  this.handlers.push(plugin);
47062
+ this.uiHandlers.push(plugin);
47017
47063
  }
47018
47064
  for (let Plugin of coreViewsPluginRegistry.getAll()) {
47019
47065
  const plugin = this.setupUiPlugin(Plugin);
47020
47066
  this.coreViewsPlugins.push(plugin);
47021
47067
  this.handlers.push(plugin);
47068
+ this.uiHandlers.push(plugin);
47022
47069
  this.coreHandlers.push(plugin);
47023
47070
  }
47024
47071
  for (let Plugin of featurePluginRegistry.getAll()) {
47025
47072
  const plugin = this.setupUiPlugin(Plugin);
47026
47073
  this.featurePlugins.push(plugin);
47027
47074
  this.handlers.push(plugin);
47075
+ this.uiHandlers.push(plugin);
47028
47076
  }
47029
47077
  this.uuidGenerator.setIsFastStrategy(false);
47030
47078
  // starting plugins
@@ -47193,7 +47241,7 @@ class Model extends EventBus {
47193
47241
  return new DispatchResult(results.flat());
47194
47242
  }
47195
47243
  checkDispatchAllowedLocalCommand(command) {
47196
- const results = this.handlers.map((handler) => handler.allowDispatch(command));
47244
+ const results = this.uiHandlers.map((handler) => handler.allowDispatch(command));
47197
47245
  return new DispatchResult(results.flat());
47198
47246
  }
47199
47247
  finalize() {
@@ -47510,6 +47558,6 @@ exports.setTranslationMethod = setTranslationMethod;
47510
47558
  exports.tokenize = tokenize;
47511
47559
 
47512
47560
 
47513
- __info__.version = '16.3.0-alpha.8';
47514
- __info__.date = '2023-05-12T10:59:42.550Z';
47515
- __info__.hash = 'afee7d5';
47561
+ __info__.version = '16.4.0-alpha.0';
47562
+ __info__.date = '2023-05-17T15:49:04.448Z';
47563
+ __info__.hash = '3a3aab7';
@@ -1179,6 +1179,7 @@ declare class Model extends EventBus<any> implements CommandDispatcher {
1179
1179
  private coreGetters;
1180
1180
  uuidGenerator: UuidGenerator;
1181
1181
  private readonly handlers;
1182
+ private readonly uiHandlers;
1182
1183
  private readonly coreHandlers;
1183
1184
  constructor(data?: any, config?: Partial<ModelConfig>, stateUpdateMessages?: StateUpdateMessage[], uuidGenerator?: UuidGenerator, verboseImport?: boolean);
1184
1185
  joinSession(): void;
@@ -1880,7 +1881,7 @@ interface CopyCommand {
1880
1881
  interface CutCommand {
1881
1882
  type: "CUT";
1882
1883
  /** Zones to cut. If none were given, will copy the zones in the selection*/
1883
- target?: Zone[];
1884
+ cutTarget?: Zone[];
1884
1885
  }
1885
1886
  interface PasteCommand {
1886
1887
  type: "PASTE";
@@ -2191,8 +2192,8 @@ interface InsertCellCommand {
2191
2192
  }
2192
2193
  interface PasteCFCommand {
2193
2194
  type: "PASTE_CONDITIONAL_FORMAT";
2194
- origin: CellPosition;
2195
- target: CellPosition;
2195
+ originPosition: CellPosition;
2196
+ targetPosition: CellPosition;
2196
2197
  operation: "CUT" | "COPY";
2197
2198
  }
2198
2199
  interface ActivateNextSheetCommand {
@@ -2353,7 +2354,8 @@ declare const enum CommandResult {
2353
2354
  MoreThanOneColumnSelected = 88,
2354
2355
  EmptySplitSeparator = 89,
2355
2356
  SplitWillOverwriteContent = 90,
2356
- NoSplitSeparatorInSelection = 91
2357
+ NoSplitSeparatorInSelection = 91,
2358
+ NoActiveSheet = 92
2357
2359
  }
2358
2360
  interface CommandHandler<T> {
2359
2361
  allowDispatch(command: T): CommandResult | CommandResult[];
@@ -3543,7 +3545,7 @@ interface SheetState$1 {
3543
3545
  readonly cellPosition: Record<UID, CellPosition | undefined>;
3544
3546
  }
3545
3547
  declare class SheetPlugin extends CorePlugin<SheetState$1> implements SheetState$1 {
3546
- static getters: readonly ["getSheetName", "tryGetSheetName", "getSheet", "tryGetSheet", "getSheetIdByName", "getSheetIds", "getVisibleSheetIds", "isSheetVisible", "getEvaluationSheets", "doesHeaderExist", "getCell", "getCellPosition", "getColsZone", "getRowCells", "getRowsZone", "getNumberCols", "getNumberRows", "getNumberHeaders", "getGridLinesVisibility", "getNextSheetName", "isEmpty", "getSheetSize", "getSheetZone", "getPaneDivisions"];
3548
+ static getters: readonly ["getSheetName", "tryGetSheetName", "getSheet", "tryGetSheet", "getSheetIdByName", "getSheetIds", "getVisibleSheetIds", "isSheetVisible", "getEvaluationSheets", "doesHeaderExist", "getCell", "getCellPosition", "getColsZone", "getRowCells", "getRowsZone", "getNumberCols", "getNumberRows", "getNumberHeaders", "getGridLinesVisibility", "getNextSheetName", "isEmpty", "getSheetSize", "getSheetZone", "getPaneDivisions", "checkZonesExistInSheet", "getCommandZones"];
3547
3549
  readonly sheetIdsMapName: Record<string, UID | undefined>;
3548
3550
  readonly orderedSheetIds: UID[];
3549
3551
  readonly sheets: Record<UID, Sheet | undefined>;
@@ -3589,6 +3591,12 @@ declare class SheetPlugin extends CorePlugin<SheetState$1> implements SheetState
3589
3591
  * Check if a zone only contains empty cells
3590
3592
  */
3591
3593
  isEmpty(sheetId: UID, zone: Zone): boolean;
3594
+ getCommandZones(cmd: Command): Zone[];
3595
+ /**
3596
+ * Check if zones in the command are well formed and
3597
+ * not outside the sheet.
3598
+ */
3599
+ checkZonesExistInSheet(sheetId: UID, zones: Zone[]): CommandResult;
3592
3600
  private updateCellPosition;
3593
3601
  /**
3594
3602
  * Set the cell at a new position and clear its previous position.
@@ -3682,7 +3690,7 @@ declare class SheetPlugin extends CorePlugin<SheetState$1> implements SheetState
3682
3690
  * Check if zones in the command are well formed and
3683
3691
  * not outside the sheet.
3684
3692
  */
3685
- private checkZones;
3693
+ private checkZonesAreInSheet;
3686
3694
  }
3687
3695
 
3688
3696
  /**
@@ -4562,7 +4570,7 @@ declare class UIOptionsPlugin extends UIPlugin {
4562
4570
  declare class SheetUIPlugin extends UIPlugin {
4563
4571
  static getters: readonly ["getCellWidth", "getTextWidth", "getCellText", "getCellMultiLineText", "getColDimensions", "getRowDimensions", "getColRowOffset"];
4564
4572
  private ctx;
4565
- allowDispatch(cmd: LocalCommand): CommandResult;
4573
+ allowDispatch(cmd: LocalCommand): CommandResult | CommandResult[];
4566
4574
  handle(cmd: Command): void;
4567
4575
  getCellWidth(position: CellPosition): number;
4568
4576
  getTextWidth(text: string, style: Style): Pixel;
@@ -4590,6 +4598,16 @@ declare class SheetUIPlugin extends UIPlugin {
4590
4598
  getColRowOffset(dimension: Dimension, referenceIndex: HeaderIndex, index: HeaderIndex, sheetId?: UID): Pixel;
4591
4599
  private getColMaxWidth;
4592
4600
  private splitWordToSpecificWidth;
4601
+ /**
4602
+ * Check that any "sheetId" in the command matches an existing
4603
+ * sheet.
4604
+ */
4605
+ private checkSheetExists;
4606
+ /**
4607
+ * Check if zones in the command are well formed and
4608
+ * not outside the sheet.
4609
+ */
4610
+ private checkZonesAreInSheet;
4593
4611
  }
4594
4612
 
4595
4613
  /**
@@ -4637,7 +4655,7 @@ declare class ClipboardPlugin extends UIPlugin {
4637
4655
  */
4638
4656
  declare class GridSelectionPlugin extends UIPlugin {
4639
4657
  static layers: LAYERS[];
4640
- static getters: readonly ["getActiveSheet", "getActiveSheetId", "getActiveCell", "getActiveCols", "getActiveRows", "getCurrentStyle", "getSelectedZones", "getSelectedZone", "getSelectedCells", "getStatisticFnResults", "getAggregate", "getSelectedFigureId", "getSelection", "getActivePosition", "getSheetPosition", "isSelected", "isSingleColSelected", "getElementsFromSelection"];
4658
+ static getters: readonly ["getActiveSheet", "getActiveSheetId", "getActiveCell", "getActiveCols", "getActiveRows", "getCurrentStyle", "getSelectedZones", "getSelectedZone", "getSelectedCells", "getStatisticFnResults", "getAggregate", "getSelectedFigureId", "getSelection", "getActivePosition", "getSheetPosition", "isSelected", "isSingleColSelected", "getElementsFromSelection", "tryGetActiveSheetId"];
4641
4659
  private gridSelection;
4642
4660
  private selectedFigureId;
4643
4661
  private sheetsData;
@@ -4649,6 +4667,7 @@ declare class GridSelectionPlugin extends UIPlugin {
4649
4667
  handle(cmd: Command): void;
4650
4668
  getActiveSheet(): Readonly<Sheet>;
4651
4669
  getActiveSheetId(): UID;
4670
+ tryGetActiveSheetId(): UID | undefined;
4652
4671
  getActiveCell(): EvaluatedCell;
4653
4672
  getActiveCols(): Set<number>;
4654
4673
  getActiveRows(): Set<number>;