@odoo/o-spreadsheet 16.3.0-alpha.8 → 16.3.1

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.
@@ -4397,6 +4397,7 @@
4397
4397
  CommandResult[CommandResult["EmptySplitSeparator"] = 89] = "EmptySplitSeparator";
4398
4398
  CommandResult[CommandResult["SplitWillOverwriteContent"] = 90] = "SplitWillOverwriteContent";
4399
4399
  CommandResult[CommandResult["NoSplitSeparatorInSelection"] = 91] = "NoSplitSeparatorInSelection";
4400
+ CommandResult[CommandResult["NoActiveSheet"] = 92] = "NoActiveSheet";
4400
4401
  })(exports.CommandResult || (exports.CommandResult = {}));
4401
4402
 
4402
4403
  const borderStyles = ["thin", "medium", "thick", "dashed", "dotted"];
@@ -16869,6 +16870,7 @@
16869
16870
  execute: (env) => env.model.dispatch("UNFREEZE_COLUMNS_ROWS", {
16870
16871
  sheetId: env.model.getters.getActiveSheetId(),
16871
16872
  }),
16873
+ icon: "o-spreadsheet-Icon.UNFREEZE",
16872
16874
  };
16873
16875
  const freezePane = {
16874
16876
  name: _lt("Freeze"),
@@ -17546,7 +17548,7 @@
17546
17548
  })
17547
17549
  .addChild("sort_range", ["data"], {
17548
17550
  ...sortRange,
17549
- sequence: 20,
17551
+ sequence: 10,
17550
17552
  separator: true,
17551
17553
  })
17552
17554
  .addChild("sort_ascending", ["data", "sort_range"], {
@@ -17559,16 +17561,16 @@
17559
17561
  })
17560
17562
  .addChild("split_to_columns", ["data"], {
17561
17563
  ...splitToColumns,
17562
- sequence: 10,
17564
+ sequence: 20,
17563
17565
  separator: true,
17564
17566
  })
17565
17567
  .addChild("add_data_filter", ["data"], {
17566
17568
  ...addDataFilter,
17567
- sequence: 10,
17569
+ sequence: 30,
17568
17570
  })
17569
17571
  .addChild("remove_data_filter", ["data"], {
17570
17572
  ...removeDataFilter,
17571
- sequence: 10,
17573
+ sequence: 30,
17572
17574
  });
17573
17575
 
17574
17576
  class OTRegistry extends Registry {
@@ -17940,6 +17942,18 @@
17940
17942
  grid-template-columns: repeat(${ITEMS_PER_LINE}, 1fr);
17941
17943
  grid-gap: ${ITEM_HORIZONTAL_MARGIN * 2}px;
17942
17944
  }
17945
+ .o-color-picker-toggler-button {
17946
+ display: flex;
17947
+ .o-color-picker-toggler-sign {
17948
+ margin: auto auto;
17949
+ width: 55%;
17950
+ height: 55%;
17951
+ .o-icon {
17952
+ width: 100%;
17953
+ height: 100%;
17954
+ }
17955
+ }
17956
+ }
17943
17957
  .o-color-picker-line-item {
17944
17958
  width: ${ITEM_EDGE_LENGTH}px;
17945
17959
  height: ${ITEM_EDGE_LENGTH}px;
@@ -18675,6 +18689,18 @@
18675
18689
  onCloseSidePanel: Function,
18676
18690
  };
18677
18691
 
18692
+ css /* scss */ `
18693
+ .o-spreadsheet {
18694
+ .o-icon {
18695
+ .small-text {
18696
+ font: bold 9px sans-serif;
18697
+ }
18698
+ .heavy-text {
18699
+ font: bold 16px sans-serif;
18700
+ }
18701
+ }
18702
+ }
18703
+ `;
18678
18704
  // -----------------------------------------------------------------------------
18679
18705
  // We need here the svg of the icons that we need to convert to images for the renderer
18680
18706
  // -----------------------------------------------------------------------------
@@ -20600,7 +20626,14 @@
20600
20626
  current = it.next();
20601
20627
  }
20602
20628
  if (current.value !== nodeToFind) {
20603
- throw new Error("Cannot find the node in the children of the element");
20629
+ /** This situation can happen if the code is called while the selection is not currently on the ContentEditableHelper.
20630
+ * In this case, we return 0 because we don't know the size of the text before the selection.
20631
+ *
20632
+ * A known occurence is triggered since the introduction of commit d4663158 (PR #2038).
20633
+ *
20634
+ * FIXME: find a way to test eventhough the selection API is not available in jsDOM.
20635
+ */
20636
+ return 0;
20604
20637
  }
20605
20638
  else {
20606
20639
  if (!current.value.hasChildNodes()) {
@@ -32191,6 +32224,8 @@
32191
32224
  "getSheetSize",
32192
32225
  "getSheetZone",
32193
32226
  "getPaneDivisions",
32227
+ "checkZonesExistInSheet",
32228
+ "getCommandZones",
32194
32229
  ];
32195
32230
  sheetIdsMapName = {};
32196
32231
  orderedSheetIds = [];
@@ -32200,7 +32235,7 @@
32200
32235
  // Command Handling
32201
32236
  // ---------------------------------------------------------------------------
32202
32237
  allowDispatch(cmd) {
32203
- const genericChecks = this.chainValidations(this.checkSheetExists, this.checkZones)(cmd);
32238
+ const genericChecks = this.chainValidations(this.checkSheetExists, this.checkZonesAreInSheet)(cmd);
32204
32239
  if (genericChecks !== 0 /* CommandResult.Success */) {
32205
32240
  return genericChecks;
32206
32241
  }
@@ -32540,6 +32575,37 @@
32540
32575
  .map(({ col, row }) => this.getCell({ sheetId, col, row }))
32541
32576
  .every((cell) => !cell || cell.content === "");
32542
32577
  }
32578
+ getCommandZones(cmd) {
32579
+ const zones = [];
32580
+ if ("zone" in cmd) {
32581
+ zones.push(cmd.zone);
32582
+ }
32583
+ if ("target" in cmd) {
32584
+ zones.push(...cmd.target);
32585
+ }
32586
+ if ("ranges" in cmd) {
32587
+ zones.push(...cmd.ranges.map((rangeData) => this.getters.getRangeFromRangeData(rangeData).zone));
32588
+ }
32589
+ if ("col" in cmd && "row" in cmd) {
32590
+ zones.push({ top: cmd.row, left: cmd.col, bottom: cmd.row, right: cmd.col });
32591
+ }
32592
+ return zones;
32593
+ }
32594
+ /**
32595
+ * Check if zones in the command are well formed and
32596
+ * not outside the sheet.
32597
+ */
32598
+ checkZonesExistInSheet(sheetId, zones) {
32599
+ if (!zones.every(isZoneValid))
32600
+ return 25 /* CommandResult.InvalidRange */;
32601
+ if (zones.length) {
32602
+ const sheetZone = this.getSheetZone(sheetId);
32603
+ return zones.every((zone) => isZoneInside(zone, sheetZone))
32604
+ ? 0 /* CommandResult.Success */
32605
+ : 18 /* CommandResult.TargetOutOfSheet */;
32606
+ }
32607
+ return 0 /* CommandResult.Success */;
32608
+ }
32543
32609
  updateCellPosition(cmd) {
32544
32610
  const { sheetId, cellId, col, row } = cmd;
32545
32611
  if (cellId) {
@@ -32988,9 +33054,6 @@
32988
33054
  }
32989
33055
  return { rowNumber, colNumber };
32990
33056
  }
32991
- // ----------------------------------------------------
32992
- // HIDE / SHOW
32993
- // ----------------------------------------------------
32994
33057
  /**
32995
33058
  * Check that any "sheetId" in the command matches an existing
32996
33059
  * sheet.
@@ -33008,27 +33071,10 @@
33008
33071
  * Check if zones in the command are well formed and
33009
33072
  * not outside the sheet.
33010
33073
  */
33011
- checkZones(cmd) {
33012
- const zones = [];
33013
- if ("zone" in cmd) {
33014
- zones.push(cmd.zone);
33015
- }
33016
- if ("target" in cmd && Array.isArray(cmd.target)) {
33017
- zones.push(...cmd.target);
33018
- }
33019
- if ("ranges" in cmd && Array.isArray(cmd.ranges)) {
33020
- zones.push(...cmd.ranges.map((rangeData) => this.getters.getRangeFromRangeData(rangeData).zone));
33021
- }
33022
- if (!zones.every(isZoneValid)) {
33023
- return 25 /* CommandResult.InvalidRange */;
33024
- }
33025
- else if (zones.length && "sheetId" in cmd) {
33026
- const sheetZone = this.getSheetZone(cmd.sheetId);
33027
- return zones.every((zone) => isZoneInside(zone, sheetZone))
33028
- ? 0 /* CommandResult.Success */
33029
- : 18 /* CommandResult.TargetOutOfSheet */;
33030
- }
33031
- return 0 /* CommandResult.Success */;
33074
+ checkZonesAreInSheet(cmd) {
33075
+ if (!("sheetId" in cmd))
33076
+ return 0 /* CommandResult.Success */;
33077
+ return this.checkZonesExistInSheet(cmd.sheetId, this.getCommandZones(cmd));
33032
33078
  }
33033
33079
  }
33034
33080
 
@@ -33619,7 +33665,7 @@
33619
33665
  }
33620
33666
  break;
33621
33667
  case "PASTE_CONDITIONAL_FORMAT":
33622
- this.pasteCf(cmd.origin, cmd.target, cmd.operation);
33668
+ this.pasteCf(cmd.originPosition, cmd.targetPosition, cmd.operation);
33623
33669
  break;
33624
33670
  }
33625
33671
  }
@@ -38604,18 +38650,7 @@
38604
38650
  // Command Handling
38605
38651
  // ---------------------------------------------------------------------------
38606
38652
  allowDispatch(cmd) {
38607
- switch (cmd.type) {
38608
- case "AUTORESIZE_ROWS":
38609
- case "AUTORESIZE_COLUMNS":
38610
- try {
38611
- this.getters.getSheet(cmd.sheetId);
38612
- break;
38613
- }
38614
- catch (error) {
38615
- return 27 /* CommandResult.InvalidSheetId */;
38616
- }
38617
- }
38618
- return 0 /* CommandResult.Success */;
38653
+ return this.chainValidations(this.checkSheetExists, this.checkZonesAreInSheet)(cmd);
38619
38654
  }
38620
38655
  handle(cmd) {
38621
38656
  switch (cmd.type) {
@@ -38650,7 +38685,8 @@
38650
38685
  getCellWidth(position) {
38651
38686
  const text = this.getCellText(position);
38652
38687
  const style = this.getters.getCellComputedStyle(position);
38653
- let contentWidth = this.getTextWidth(text, style);
38688
+ const multiLineText = text.split(NEWLINE);
38689
+ let contentWidth = Math.max(...multiLineText.map((line) => this.getTextWidth(line, style)));
38654
38690
  const icon = this.getters.getConditionalIcon(position);
38655
38691
  if (icon) {
38656
38692
  contentWidth += computeIconWidth(this.getters.getCellStyle(position));
@@ -38815,6 +38851,31 @@
38815
38851
  splitWord.push(wordPart);
38816
38852
  return splitWord;
38817
38853
  }
38854
+ /**
38855
+ * Check that any "sheetId" in the command matches an existing
38856
+ * sheet.
38857
+ */
38858
+ checkSheetExists(cmd) {
38859
+ if ("sheetId" in cmd && this.getters.tryGetSheet(cmd.sheetId) === undefined) {
38860
+ return 27 /* CommandResult.InvalidSheetId */;
38861
+ }
38862
+ return 0 /* CommandResult.Success */;
38863
+ }
38864
+ /**
38865
+ * Check if zones in the command are well formed and
38866
+ * not outside the sheet.
38867
+ */
38868
+ checkZonesAreInSheet(cmd) {
38869
+ const sheetId = "sheetId" in cmd ? cmd.sheetId : this.getters.tryGetActiveSheetId();
38870
+ const zones = this.getters.getCommandZones(cmd);
38871
+ if (!sheetId && zones.length > 0) {
38872
+ return 92 /* CommandResult.NoActiveSheet */;
38873
+ }
38874
+ if (sheetId && zones.length > 0) {
38875
+ return this.getters.checkZonesExistInSheet(sheetId, zones);
38876
+ }
38877
+ return 0 /* CommandResult.Success */;
38878
+ }
38818
38879
  }
38819
38880
 
38820
38881
  const genericRepeatsTransforms = [
@@ -39639,8 +39700,8 @@
39639
39700
  this.pasteCell(origin, position, this.operation, clipboardOptions);
39640
39701
  if (shouldPasteCF) {
39641
39702
  this.dispatch("PASTE_CONDITIONAL_FORMAT", {
39642
- origin: origin.position,
39643
- target: position,
39703
+ originPosition: origin.position,
39704
+ targetPosition: position,
39644
39705
  operation: this.operation,
39645
39706
  });
39646
39707
  }
@@ -40031,7 +40092,7 @@
40031
40092
  allowDispatch(cmd) {
40032
40093
  switch (cmd.type) {
40033
40094
  case "CUT":
40034
- const zones = cmd.target || this.getters.getSelectedZones();
40095
+ const zones = cmd.cutTarget || this.getters.getSelectedZones();
40035
40096
  const state = this.getClipboardState(zones, cmd.type);
40036
40097
  return state.isCutAllowed(zones);
40037
40098
  case "PASTE":
@@ -40061,7 +40122,7 @@
40061
40122
  switch (cmd.type) {
40062
40123
  case "COPY":
40063
40124
  case "CUT":
40064
- const zones = ("target" in cmd && cmd.target) || this.getters.getSelectedZones();
40125
+ const zones = ("cutTarget" in cmd && cmd.cutTarget) || this.getters.getSelectedZones();
40065
40126
  this.state = this.getClipboardState(zones, cmd.type);
40066
40127
  this.status = "visible";
40067
40128
  break;
@@ -41017,6 +41078,7 @@
41017
41078
  "isSelected",
41018
41079
  "isSingleColSelected",
41019
41080
  "getElementsFromSelection",
41081
+ "tryGetActiveSheetId",
41020
41082
  ];
41021
41083
  gridSelection = {
41022
41084
  anchor: {
@@ -41232,6 +41294,9 @@
41232
41294
  getActiveSheetId() {
41233
41295
  return this.activeSheet.id;
41234
41296
  }
41297
+ tryGetActiveSheetId() {
41298
+ return this.activeSheet?.id;
41299
+ }
41235
41300
  getActiveCell() {
41236
41301
  return this.getters.getEvaluatedCell(this.getActivePosition());
41237
41302
  }
@@ -41478,7 +41543,7 @@
41478
41543
  const deltaCol = isBasedBefore && isCol ? thickness : 0;
41479
41544
  const deltaRow = isBasedBefore && !isCol ? thickness : 0;
41480
41545
  this.dispatch("CUT", {
41481
- target: [
41546
+ cutTarget: [
41482
41547
  {
41483
41548
  left: isCol ? start + deltaCol : 0,
41484
41549
  right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
@@ -43750,6 +43815,10 @@
43750
43815
  }
43751
43816
  checkViewportSize() {
43752
43817
  const { xRatio, yRatio } = this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());
43818
+ if (!isFinite(xRatio) || !isFinite(yRatio)) {
43819
+ // before mounting, the ratios can be NaN or Infinity if the viewport size is 0
43820
+ return;
43821
+ }
43753
43822
  if (yRatio > MAXIMAL_FREEZABLE_RATIO || xRatio > MAXIMAL_FREEZABLE_RATIO) {
43754
43823
  if (this.isViewportTooSmall) {
43755
43824
  return;
@@ -46972,6 +47041,7 @@
46972
47041
  coreGetters;
46973
47042
  uuidGenerator;
46974
47043
  handlers = [];
47044
+ uiHandlers = [];
46975
47045
  coreHandlers = [];
46976
47046
  constructor(data = {}, config = {}, stateUpdateMessages = [], uuidGenerator = new UuidGenerator(), verboseImport = true) {
46977
47047
  super();
@@ -47011,17 +47081,20 @@
47011
47081
  const plugin = this.setupUiPlugin(Plugin);
47012
47082
  this.statefulUIPlugins.push(plugin);
47013
47083
  this.handlers.push(plugin);
47084
+ this.uiHandlers.push(plugin);
47014
47085
  }
47015
47086
  for (let Plugin of coreViewsPluginRegistry.getAll()) {
47016
47087
  const plugin = this.setupUiPlugin(Plugin);
47017
47088
  this.coreViewsPlugins.push(plugin);
47018
47089
  this.handlers.push(plugin);
47090
+ this.uiHandlers.push(plugin);
47019
47091
  this.coreHandlers.push(plugin);
47020
47092
  }
47021
47093
  for (let Plugin of featurePluginRegistry.getAll()) {
47022
47094
  const plugin = this.setupUiPlugin(Plugin);
47023
47095
  this.featurePlugins.push(plugin);
47024
47096
  this.handlers.push(plugin);
47097
+ this.uiHandlers.push(plugin);
47025
47098
  }
47026
47099
  this.uuidGenerator.setIsFastStrategy(false);
47027
47100
  // starting plugins
@@ -47190,7 +47263,7 @@
47190
47263
  return new DispatchResult(results.flat());
47191
47264
  }
47192
47265
  checkDispatchAllowedLocalCommand(command) {
47193
- const results = this.handlers.map((handler) => handler.allowDispatch(command));
47266
+ const results = this.uiHandlers.map((handler) => handler.allowDispatch(command));
47194
47267
  return new DispatchResult(results.flat());
47195
47268
  }
47196
47269
  finalize() {
@@ -47509,9 +47582,9 @@
47509
47582
  Object.defineProperty(exports, '__esModule', { value: true });
47510
47583
 
47511
47584
 
47512
- __info__.version = '16.3.0-alpha.8';
47513
- __info__.date = '2023-05-12T10:59:42.550Z';
47514
- __info__.hash = 'afee7d5';
47585
+ __info__.version = '16.3.1';
47586
+ __info__.date = '2023-05-25T13:00:27.320Z';
47587
+ __info__.hash = 'b3cfd2c';
47515
47588
 
47516
47589
 
47517
47590
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);