@odoo/o-spreadsheet 16.0.8 → 16.0.10

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.
@@ -3270,6 +3270,8 @@
3270
3270
  CommandResult[CommandResult["InvalidSelectionStep"] = 82] = "InvalidSelectionStep";
3271
3271
  CommandResult[CommandResult["DuplicatedChartId"] = 83] = "DuplicatedChartId";
3272
3272
  CommandResult[CommandResult["ChartDoesNotExist"] = 84] = "ChartDoesNotExist";
3273
+ CommandResult[CommandResult["InvalidHeaderIndex"] = 85] = "InvalidHeaderIndex";
3274
+ CommandResult[CommandResult["InvalidQuantity"] = 86] = "InvalidQuantity";
3273
3275
  })(exports.CommandResult || (exports.CommandResult = {}));
3274
3276
 
3275
3277
  var DIRECTION;
@@ -6412,6 +6414,12 @@
6412
6414
  height: 25px;
6413
6415
  }
6414
6416
  }
6417
+ /** Make the character a bit bigger
6418
+ compared to its neighbor INPUT box */
6419
+ .o-remove-selection {
6420
+ font-weight: bold;
6421
+ font-size: calc(100% + 4px);
6422
+ }
6415
6423
  }
6416
6424
  `;
6417
6425
  /**
@@ -6488,6 +6496,9 @@
6488
6496
  (_b = (_a = this.props).onSelectionChanged) === null || _b === void 0 ? void 0 : _b.call(_a, ranges);
6489
6497
  this.previousRanges = ranges;
6490
6498
  }
6499
+ extractRanges(value) {
6500
+ return this.props.hasSingleRange ? value.split(",")[0] : value;
6501
+ }
6491
6502
  focus(rangeId) {
6492
6503
  this.state.isMissing = false;
6493
6504
  this.env.model.dispatch("FOCUS_RANGE", {
@@ -6506,15 +6517,16 @@
6506
6517
  }
6507
6518
  onInputChanged(rangeId, ev) {
6508
6519
  const target = ev.target;
6520
+ const value = this.extractRanges(target.value);
6509
6521
  this.env.model.dispatch("CHANGE_RANGE", {
6510
6522
  id: this.id,
6511
6523
  rangeId,
6512
- value: target.value,
6524
+ value,
6513
6525
  });
6514
6526
  target.blur();
6515
6527
  this.triggerChange();
6516
6528
  }
6517
- disable() {
6529
+ confirm() {
6518
6530
  var _a, _b;
6519
6531
  this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");
6520
6532
  const ranges = this.env.model.getters.getSelectionInputValue(this.id);
@@ -17408,7 +17420,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
17408
17420
  base (number) ${_lt("The number to raise to the exponent power.")}
17409
17421
  exponent (number) ${_lt("The exponent to raise base to.")}
17410
17422
  `),
17411
- returns: ["BOOLEAN"],
17423
+ returns: ["NUMBER"],
17412
17424
  compute: function (base, exponent) {
17413
17425
  return POWER.compute(base, exponent);
17414
17426
  },
@@ -24352,7 +24364,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
24352
24364
  if (cell.style) {
24353
24365
  style = data.styles[cell.style];
24354
24366
  }
24355
- const format = cell.format ? data.formats[cell.format] : undefined;
24367
+ const format = extractFormat(cell, data);
24356
24368
  const exportedBorder = {};
24357
24369
  if (cell.border) {
24358
24370
  const border = data.borders[cell.border];
@@ -24386,6 +24398,22 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
24386
24398
  styles.font["italic"] = !!(style === null || style === void 0 ? void 0 : style.italic) || undefined;
24387
24399
  return styles;
24388
24400
  }
24401
+ function extractFormat(cell, data) {
24402
+ if (cell.format) {
24403
+ return data.formats[cell.format];
24404
+ }
24405
+ if (cell.isFormula) {
24406
+ const tokens = tokenize(cell.content || "");
24407
+ const functions = functionRegistry.content;
24408
+ const isExported = tokens
24409
+ .filter((tk) => tk.type === "FUNCTION")
24410
+ .every((tk) => functions[tk.value.toUpperCase()].isExported);
24411
+ if (!isExported) {
24412
+ return cell.computedFormat;
24413
+ }
24414
+ }
24415
+ return undefined;
24416
+ }
24389
24417
  function normalizeStyle(construct, styles) {
24390
24418
  const { id: fontId } = pushElement(styles["font"], construct.fonts);
24391
24419
  const { id: fillId } = pushElement(styles["fill"], construct.fills);
@@ -27608,6 +27636,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27608
27636
  const exportedCellData = sheet.cells[xc];
27609
27637
  exportedCellData.value = cell.evaluated.value;
27610
27638
  exportedCellData.isFormula = cell.isFormula();
27639
+ if (cell.format !== cell.evaluated.format) {
27640
+ exportedCellData.computedFormat = cell.evaluated.format;
27641
+ }
27611
27642
  }
27612
27643
  }
27613
27644
  }
@@ -29060,9 +29091,16 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29060
29091
  const elements = cmd.dimension === "COL"
29061
29092
  ? this.getters.getNumberCols(cmd.sheetId)
29062
29093
  : this.getters.getNumberRows(cmd.sheetId);
29063
- return (hiddenGroup || []).flat().concat(cmd.elements).length < elements
29064
- ? 0 /* CommandResult.Success */
29065
- : 65 /* CommandResult.TooManyHiddenElements */;
29094
+ const hiddenElements = new Set((hiddenGroup || []).flat().concat(cmd.elements));
29095
+ if (hiddenElements.size >= elements) {
29096
+ return 65 /* CommandResult.TooManyHiddenElements */;
29097
+ }
29098
+ else if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
29099
+ return 85 /* CommandResult.InvalidHeaderIndex */;
29100
+ }
29101
+ else {
29102
+ return 0 /* CommandResult.Success */;
29103
+ }
29066
29104
  }
29067
29105
  case "REMOVE_COLUMNS_ROWS":
29068
29106
  if (!this.getters.tryGetSheet(cmd.sheetId)) {
@@ -29717,6 +29755,28 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29717
29755
  return this.orderedSheetIds.length > 1
29718
29756
  ? 0 /* CommandResult.Success */
29719
29757
  : 9 /* CommandResult.NotEnoughSheets */;
29758
+ case "ADD_COLUMNS_ROWS":
29759
+ const elements = cmd.dimension === "COL"
29760
+ ? this.getNumberCols(cmd.sheetId)
29761
+ : this.getNumberRows(cmd.sheetId);
29762
+ if (cmd.base < 0 || cmd.base > elements) {
29763
+ return 85 /* CommandResult.InvalidHeaderIndex */;
29764
+ }
29765
+ else if (cmd.quantity <= 0) {
29766
+ return 86 /* CommandResult.InvalidQuantity */;
29767
+ }
29768
+ return 0 /* CommandResult.Success */;
29769
+ case "REMOVE_COLUMNS_ROWS": {
29770
+ const elements = cmd.dimension === "COL"
29771
+ ? this.getNumberCols(cmd.sheetId)
29772
+ : this.getNumberRows(cmd.sheetId);
29773
+ if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
29774
+ return 85 /* CommandResult.InvalidHeaderIndex */;
29775
+ }
29776
+ else {
29777
+ return 0 /* CommandResult.Success */;
29778
+ }
29779
+ }
29720
29780
  case "FREEZE_ROWS": {
29721
29781
  return this.checkValidations(cmd, this.checkRowFreezeQuantity, this.checkRowFreezeOverlapMerge);
29722
29782
  }
@@ -32428,7 +32488,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32428
32488
  // magic "empty" value
32429
32489
  // Returning {value: null} instead of undefined will ensure that we don't
32430
32490
  // fall back on the default value of the argument provided to the formula's compute function
32431
- return { value: null };
32491
+ return { value: null, format: cell === null || cell === void 0 ? void 0 : cell.format };
32432
32492
  }
32433
32493
  return getEvaluatedCell(cell);
32434
32494
  }
@@ -34843,6 +34903,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
34843
34903
  */
34844
34904
  class SelectionInputPlugin extends UIPlugin {
34845
34905
  constructor(getters, state, dispatch, config, selection, initialRanges, inputHasSingleRange) {
34906
+ if (inputHasSingleRange && initialRanges.length > 1) {
34907
+ throw new Error("Input with a single range cannot be instantiated with several range references.");
34908
+ }
34846
34909
  super(getters, state, dispatch, config, selection);
34847
34910
  this.inputHasSingleRange = inputHasSingleRange;
34848
34911
  this.ranges = [];
@@ -34865,6 +34928,11 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
34865
34928
  return 29 /* CommandResult.MaximumRangesReached */;
34866
34929
  }
34867
34930
  break;
34931
+ case "CHANGE_RANGE":
34932
+ if (this.inputHasSingleRange && cmd.value.split(",").length > 1) {
34933
+ return 29 /* CommandResult.MaximumRangesReached */;
34934
+ }
34935
+ break;
34868
34936
  }
34869
34937
  return 0 /* CommandResult.Success */;
34870
34938
  }
@@ -35678,13 +35746,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
35678
35746
  }
35679
35747
  loadInitialMessages(messages) {
35680
35748
  this.isReplayingInitialRevisions = true;
35681
- this.on("unexpected-revision-id", this, ({ revisionId }) => {
35682
- throw new Error(`The spreadsheet could not be loaded. Revision ${revisionId} is corrupted.`);
35683
- });
35684
35749
  for (const message of messages) {
35685
35750
  this.onMessageReceived(message);
35686
35751
  }
35687
- this.off("unexpected-revision-id", this);
35688
35752
  this.isReplayingInitialRevisions = false;
35689
35753
  }
35690
35754
  /**
@@ -35756,6 +35820,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
35756
35820
  onMessageReceived(message) {
35757
35821
  if (this.isAlreadyProcessed(message))
35758
35822
  return;
35823
+ if (this.isWrongServerRevisionId(message)) {
35824
+ this.trigger("unexpected-revision-id");
35825
+ return;
35826
+ }
35759
35827
  switch (message.type) {
35760
35828
  case "CLIENT_MOVED":
35761
35829
  this.onClientMoved(message);
@@ -35782,10 +35850,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
35782
35850
  });
35783
35851
  break;
35784
35852
  case "REMOTE_REVISION":
35785
- if (message.serverRevisionId !== this.serverRevisionId) {
35786
- this.trigger("unexpected-revision-id", { revisionId: message.serverRevisionId });
35787
- return;
35788
- }
35789
35853
  const { clientId, commands } = message;
35790
35854
  const revision = new Revision(message.nextRevisionId, clientId, commands);
35791
35855
  if (revision.clientId !== this.clientId) {
@@ -35917,6 +35981,17 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
35917
35981
  return false;
35918
35982
  }
35919
35983
  }
35984
+ isWrongServerRevisionId(message) {
35985
+ switch (message.type) {
35986
+ case "REMOTE_REVISION":
35987
+ case "REVISION_REDONE":
35988
+ case "REVISION_UNDONE":
35989
+ case "SNAPSHOT_CREATED":
35990
+ return message.serverRevisionId !== this.serverRevisionId;
35991
+ default:
35992
+ return false;
35993
+ }
35994
+ }
35920
35995
  dropPendingHistoryMessages() {
35921
35996
  this.waitingUndoRedoAck = false;
35922
35997
  this.pendingMessages = this.pendingMessages.filter(({ type }) => type !== "REVISION_REDONE" && type !== "REVISION_UNDONE");
@@ -37880,7 +37955,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37880
37955
  color: dimgrey;
37881
37956
  }
37882
37957
  .o-sidePanelClose {
37883
- font-size: 1.5rem;
37884
37958
  padding: 5px 10px;
37885
37959
  cursor: pointer;
37886
37960
  &:hover {
@@ -41164,12 +41238,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
41164
41238
  else {
41165
41239
  // Shouldn't we always output the value then ?
41166
41240
  const value = cell.value;
41167
- // what if value = 0? Is this condition correct?
41168
- if (value) {
41169
- const type = getCellType(value);
41170
- attrs.push(["t", type]);
41171
- node = escapeXml /*xml*/ `<v>${value}</v>`;
41172
- }
41241
+ const type = getCellType(value);
41242
+ attrs.push(["t", type]);
41243
+ node = escapeXml /*xml*/ `<v>${value}</v>`;
41173
41244
  return { attrs, node };
41174
41245
  }
41175
41246
  }
@@ -42731,9 +42802,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
42731
42802
  Object.defineProperty(exports, '__esModule', { value: true });
42732
42803
 
42733
42804
 
42734
- __info__.version = '16.0.8';
42735
- __info__.date = '2023-04-21T07:29:33.894Z';
42736
- __info__.hash = 'dbd7aa4';
42805
+ __info__.version = '16.0.10';
42806
+ __info__.date = '2023-05-12T10:59:27.820Z';
42807
+ __info__.hash = '115eda7';
42737
42808
 
42738
42809
 
42739
42810
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);