@odoo/o-spreadsheet 16.1.9 → 16.1.11

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.
@@ -3625,6 +3625,8 @@
3625
3625
  CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
3626
3626
  CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
3627
3627
  CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
3628
+ CommandResult[CommandResult["InvalidHeaderIndex"] = 86] = "InvalidHeaderIndex";
3629
+ CommandResult[CommandResult["InvalidQuantity"] = 87] = "InvalidQuantity";
3628
3630
  })(exports.CommandResult || (exports.CommandResult = {}));
3629
3631
 
3630
3632
  var DIRECTION;
@@ -14112,7 +14114,11 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
14112
14114
  : getNormalizedValueFromRowRange;
14113
14115
  const rangeLength = verticalSearch ? nbRow : nbCol;
14114
14116
  const index = dichotomicSearch(searchArray, _searchKey, "nextSmaller", "asc", rangeLength, getElement);
14115
- assertAvailable(searchArray[0][index], searchKey);
14117
+ if (index === -1)
14118
+ assertAvailable(undefined, searchKey);
14119
+ verticalSearch
14120
+ ? assertAvailable(searchArray[0][index], searchKey)
14121
+ : assertAvailable(searchArray[index][nbRow - 1], searchKey);
14116
14122
  if (resultRange === undefined) {
14117
14123
  return (verticalSearch ? searchArray[nbCol - 1][index] : searchArray[index][nbRow - 1]);
14118
14124
  }
@@ -14494,7 +14500,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
14494
14500
  base (number) ${_lt("The number to raise to the exponent power.")}
14495
14501
  exponent (number) ${_lt("The exponent to raise base to.")}
14496
14502
  `),
14497
- returns: ["BOOLEAN"],
14503
+ returns: ["NUMBER"],
14498
14504
  compute: function (base, exponent) {
14499
14505
  return POWER.compute(base, exponent);
14500
14506
  },
@@ -19748,6 +19754,12 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
19748
19754
  height: 25px;
19749
19755
  }
19750
19756
  }
19757
+ /** Make the character a bit bigger
19758
+ compared to its neighbor INPUT box */
19759
+ .o-remove-selection {
19760
+ font-weight: bold;
19761
+ font-size: calc(100% + 4px);
19762
+ }
19751
19763
  }
19752
19764
  `;
19753
19765
  /**
@@ -19839,6 +19851,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
19839
19851
  }
19840
19852
  }
19841
19853
  }
19854
+ extractRanges(value) {
19855
+ return this.props.hasSingleRange ? value.split(",")[0] : value;
19856
+ }
19842
19857
  focus(rangeId) {
19843
19858
  this.state.isMissing = false;
19844
19859
  this.state.mode = "select-range";
@@ -19858,15 +19873,16 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
19858
19873
  }
19859
19874
  onInputChanged(rangeId, ev) {
19860
19875
  const target = ev.target;
19876
+ const value = this.extractRanges(target.value);
19861
19877
  this.env.model.dispatch("CHANGE_RANGE", {
19862
19878
  id: this.id,
19863
19879
  rangeId,
19864
- value: target.value,
19880
+ value,
19865
19881
  });
19866
19882
  target.blur();
19867
19883
  this.triggerChange();
19868
19884
  }
19869
- disable() {
19885
+ confirm() {
19870
19886
  var _a, _b;
19871
19887
  this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");
19872
19888
  const ranges = this.env.model.getters.getSelectionInputValue(this.id);
@@ -25188,7 +25204,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
25188
25204
  if (cell.style) {
25189
25205
  style = data.styles[cell.style];
25190
25206
  }
25191
- const format = cell.format ? data.formats[cell.format] : undefined;
25207
+ const format = extractFormat(cell, data);
25192
25208
  const exportedBorder = {};
25193
25209
  if (cell.border) {
25194
25210
  const border = data.borders[cell.border];
@@ -25222,6 +25238,22 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
25222
25238
  styles.font["italic"] = !!(style === null || style === void 0 ? void 0 : style.italic) || undefined;
25223
25239
  return styles;
25224
25240
  }
25241
+ function extractFormat(cell, data) {
25242
+ if (cell.format) {
25243
+ return data.formats[cell.format];
25244
+ }
25245
+ if (cell.isFormula) {
25246
+ const tokens = tokenize(cell.content || "");
25247
+ const functions = functionRegistry.content;
25248
+ const isExported = tokens
25249
+ .filter((tk) => tk.type === "FUNCTION")
25250
+ .every((tk) => functions[tk.value.toUpperCase()].isExported);
25251
+ if (!isExported) {
25252
+ return cell.computedFormat;
25253
+ }
25254
+ }
25255
+ return undefined;
25256
+ }
25225
25257
  function normalizeStyle(construct, styles) {
25226
25258
  const { id: fontId } = pushElement(styles["font"], construct.fonts);
25227
25259
  const { id: fillId } = pushElement(styles["fill"], construct.fills);
@@ -29972,9 +30004,16 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29972
30004
  const elements = cmd.dimension === "COL"
29973
30005
  ? this.getters.getNumberCols(cmd.sheetId)
29974
30006
  : this.getters.getNumberRows(cmd.sheetId);
29975
- return (hiddenGroup || []).flat().concat(cmd.elements).length < elements
29976
- ? 0 /* CommandResult.Success */
29977
- : 66 /* CommandResult.TooManyHiddenElements */;
30007
+ const hiddenElements = new Set((hiddenGroup || []).flat().concat(cmd.elements));
30008
+ if (hiddenElements.size >= elements) {
30009
+ return 66 /* CommandResult.TooManyHiddenElements */;
30010
+ }
30011
+ else if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
30012
+ return 86 /* CommandResult.InvalidHeaderIndex */;
30013
+ }
30014
+ else {
30015
+ return 0 /* CommandResult.Success */;
30016
+ }
29978
30017
  }
29979
30018
  case "REMOVE_COLUMNS_ROWS":
29980
30019
  if (!this.getters.tryGetSheet(cmd.sheetId)) {
@@ -31138,6 +31177,28 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
31138
31177
  return this.orderedSheetIds.length > 1
31139
31178
  ? 0 /* CommandResult.Success */
31140
31179
  : 9 /* CommandResult.NotEnoughSheets */;
31180
+ case "ADD_COLUMNS_ROWS":
31181
+ const elements = cmd.dimension === "COL"
31182
+ ? this.getNumberCols(cmd.sheetId)
31183
+ : this.getNumberRows(cmd.sheetId);
31184
+ if (cmd.base < 0 || cmd.base > elements) {
31185
+ return 86 /* CommandResult.InvalidHeaderIndex */;
31186
+ }
31187
+ else if (cmd.quantity <= 0) {
31188
+ return 87 /* CommandResult.InvalidQuantity */;
31189
+ }
31190
+ return 0 /* CommandResult.Success */;
31191
+ case "REMOVE_COLUMNS_ROWS": {
31192
+ const elements = cmd.dimension === "COL"
31193
+ ? this.getNumberCols(cmd.sheetId)
31194
+ : this.getNumberRows(cmd.sheetId);
31195
+ if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
31196
+ return 86 /* CommandResult.InvalidHeaderIndex */;
31197
+ }
31198
+ else {
31199
+ return 0 /* CommandResult.Success */;
31200
+ }
31201
+ }
31141
31202
  case "FREEZE_ROWS": {
31142
31203
  return this.checkValidations(cmd, this.checkRowFreezeQuantity, this.checkRowFreezeOverlapMerge);
31143
31204
  }
@@ -32303,7 +32364,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32303
32364
  // magic "empty" value
32304
32365
  // Returning {value: null} instead of undefined will ensure that we don't
32305
32366
  // fall back on the default value of the argument provided to the formula's compute function
32306
- return { value: null };
32367
+ return { value: null, format: cell === null || cell === void 0 ? void 0 : cell.format };
32307
32368
  }
32308
32369
  return getEvaluatedCell(cell);
32309
32370
  }
@@ -32386,8 +32447,12 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32386
32447
  const cell = this.getters.getCell(position);
32387
32448
  if (cell) {
32388
32449
  const exportedCellData = sheet.cells[xc];
32389
- exportedCellData.value = this.getEvaluatedCell(position).value;
32450
+ const evaluatedCell = this.getEvaluatedCell(position);
32451
+ exportedCellData.value = evaluatedCell.value;
32390
32452
  exportedCellData.isFormula = cell.isFormula && !this.isBadExpression(cell.content);
32453
+ if (cell.format !== evaluatedCell.format) {
32454
+ exportedCellData.computedFormat = evaluatedCell.format;
32455
+ }
32391
32456
  }
32392
32457
  }
32393
32458
  }
@@ -35850,6 +35915,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
35850
35915
  */
35851
35916
  class SelectionInputPlugin extends UIPlugin {
35852
35917
  constructor(config, initialRanges, inputHasSingleRange) {
35918
+ if (inputHasSingleRange && initialRanges.length > 1) {
35919
+ throw new Error("Input with a single range cannot be instantiated with several range references.");
35920
+ }
35853
35921
  super(config);
35854
35922
  this.inputHasSingleRange = inputHasSingleRange;
35855
35923
  this.ranges = [];
@@ -35872,6 +35940,11 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
35872
35940
  return 30 /* CommandResult.MaximumRangesReached */;
35873
35941
  }
35874
35942
  break;
35943
+ case "CHANGE_RANGE":
35944
+ if (this.inputHasSingleRange && cmd.value.split(",").length > 1) {
35945
+ return 30 /* CommandResult.MaximumRangesReached */;
35946
+ }
35947
+ break;
35875
35948
  }
35876
35949
  return 0 /* CommandResult.Success */;
35877
35950
  }
@@ -36696,13 +36769,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
36696
36769
  }
36697
36770
  loadInitialMessages(messages) {
36698
36771
  this.isReplayingInitialRevisions = true;
36699
- this.on("unexpected-revision-id", this, ({ revisionId }) => {
36700
- throw new Error(`The spreadsheet could not be loaded. Revision ${revisionId} is corrupted.`);
36701
- });
36702
36772
  for (const message of messages) {
36703
36773
  this.onMessageReceived(message);
36704
36774
  }
36705
- this.off("unexpected-revision-id", this);
36706
36775
  this.isReplayingInitialRevisions = false;
36707
36776
  }
36708
36777
  /**
@@ -36774,6 +36843,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
36774
36843
  onMessageReceived(message) {
36775
36844
  if (this.isAlreadyProcessed(message))
36776
36845
  return;
36846
+ if (this.isWrongServerRevisionId(message)) {
36847
+ this.trigger("unexpected-revision-id");
36848
+ return;
36849
+ }
36777
36850
  switch (message.type) {
36778
36851
  case "CLIENT_MOVED":
36779
36852
  this.onClientMoved(message);
@@ -36800,10 +36873,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
36800
36873
  });
36801
36874
  break;
36802
36875
  case "REMOTE_REVISION":
36803
- if (message.serverRevisionId !== this.serverRevisionId) {
36804
- this.trigger("unexpected-revision-id", { revisionId: message.serverRevisionId });
36805
- return;
36806
- }
36807
36876
  const { clientId, commands } = message;
36808
36877
  const revision = new Revision(message.nextRevisionId, clientId, commands);
36809
36878
  if (revision.clientId !== this.clientId) {
@@ -36935,6 +37004,17 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
36935
37004
  return false;
36936
37005
  }
36937
37006
  }
37007
+ isWrongServerRevisionId(message) {
37008
+ switch (message.type) {
37009
+ case "REMOTE_REVISION":
37010
+ case "REVISION_REDONE":
37011
+ case "REVISION_UNDONE":
37012
+ case "SNAPSHOT_CREATED":
37013
+ return message.serverRevisionId !== this.serverRevisionId;
37014
+ default:
37015
+ return false;
37016
+ }
37017
+ }
36938
37018
  dropPendingHistoryMessages() {
36939
37019
  this.waitingUndoRedoAck = false;
36940
37020
  this.pendingMessages = this.pendingMessages.filter(({ type }) => type !== "REVISION_REDONE" && type !== "REVISION_UNDONE");
@@ -39565,7 +39645,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
39565
39645
  color: dimgrey;
39566
39646
  }
39567
39647
  .o-sidePanelClose {
39568
- font-size: 1.5rem;
39569
39648
  padding: 5px 10px;
39570
39649
  cursor: pointer;
39571
39650
  &:hover {
@@ -42565,12 +42644,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
42565
42644
  else {
42566
42645
  // Shouldn't we always output the value then ?
42567
42646
  const value = cell.value;
42568
- // what if value = 0? Is this condition correct?
42569
- if (value) {
42570
- const type = getCellType(value);
42571
- attrs.push(["t", type]);
42572
- node = escapeXml /*xml*/ `<v>${value}</v>`;
42573
- }
42647
+ const type = getCellType(value);
42648
+ attrs.push(["t", type]);
42649
+ node = escapeXml /*xml*/ `<v>${value}</v>`;
42574
42650
  return { attrs, node };
42575
42651
  }
42576
42652
  }
@@ -44182,9 +44258,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
44182
44258
  Object.defineProperty(exports, '__esModule', { value: true });
44183
44259
 
44184
44260
 
44185
- __info__.version = '16.1.9';
44186
- __info__.date = '2023-04-21T07:29:41.080Z';
44187
- __info__.hash = '686bffa';
44261
+ __info__.version = '16.1.11';
44262
+ __info__.date = '2023-05-12T10:58:24.113Z';
44263
+ __info__.hash = 'd9a2cce';
44188
44264
 
44189
44265
 
44190
44266
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);