@odoo/o-spreadsheet 17.0.8 → 17.0.9

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.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 17.0.8
6
- * @date 2024-01-17T10:27:32.736Z
7
- * @hash 0f2d46e
5
+ * @version 17.0.9
6
+ * @date 2024-01-29T13:53:22.963Z
7
+ * @hash 3c1209a
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -2121,6 +2121,7 @@
2121
2121
  CommandResult["BlockingValidationRule"] = "BlockingValidationRule";
2122
2122
  CommandResult["InvalidCopyPasteSelection"] = "InvalidCopyPasteSelection";
2123
2123
  CommandResult["NoChanges"] = "NoChanges";
2124
+ CommandResult["InvalidInputId"] = "InvalidInputId";
2124
2125
  })(exports.CommandResult || (exports.CommandResult = {}));
2125
2126
 
2126
2127
  const DEFAULT_LOCALES = [
@@ -3265,27 +3266,30 @@
3265
3266
  }
3266
3267
  function createLargeNumberFormat(format, magnitude, postFix, locale) {
3267
3268
  const internalFormat = parseFormat(format || "#,##0");
3268
- const largeNumberFormat = internalFormat
3269
- .map((formatPart) => {
3270
- if (formatPart.type === "NUMBER") {
3271
- return [
3272
- {
3273
- ...formatPart,
3274
- format: {
3275
- ...formatPart.format,
3276
- magnitude,
3277
- decimalPart: undefined,
3278
- },
3279
- },
3280
- {
3281
- type: "STRING",
3282
- format: postFix,
3283
- },
3284
- ];
3269
+ const largeNumberFormat = [];
3270
+ for (let i = 0; i < internalFormat.length; i++) {
3271
+ const formatPart = internalFormat[i];
3272
+ if (formatPart.type !== "NUMBER") {
3273
+ largeNumberFormat.push(formatPart);
3274
+ continue;
3285
3275
  }
3286
- return formatPart;
3287
- })
3288
- .flat();
3276
+ largeNumberFormat.push({
3277
+ ...formatPart,
3278
+ format: {
3279
+ ...formatPart.format,
3280
+ magnitude,
3281
+ decimalPart: undefined,
3282
+ },
3283
+ });
3284
+ largeNumberFormat.push({
3285
+ type: "STRING",
3286
+ format: postFix,
3287
+ });
3288
+ const nextFormatPart = internalFormat[i + 1];
3289
+ if (nextFormatPart?.type === "STRING" && ["k", "m", "b"].includes(nextFormatPart.format)) {
3290
+ i++;
3291
+ }
3292
+ }
3289
3293
  return convertInternalFormatToFormat(largeNumberFormat);
3290
3294
  }
3291
3295
  function changeDecimalPlaces(format, step, locale) {
@@ -26807,6 +26811,9 @@
26807
26811
  const token = tokens.filter((token) => token.value.includes(currentSelectedText) &&
26808
26812
  token.start <= currentSelection.start &&
26809
26813
  token.end >= currentSelection.end)[0];
26814
+ if (!token) {
26815
+ return;
26816
+ }
26810
26817
  if (token.type === "REFERENCE") {
26811
26818
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", {
26812
26819
  start: token.start,
@@ -39837,22 +39844,17 @@
39837
39844
  * The `compute` of the formula's function must process it completely
39838
39845
  */
39839
39846
  refFn(range, isMeta, functionName, paramNumber) {
39847
+ this.assertRangeValid(range);
39840
39848
  if (isMeta) {
39841
39849
  // Use zoneToXc of zone instead of getRangeString to avoid sending unbounded ranges
39842
39850
  return { value: zoneToXc(range.zone) };
39843
39851
  }
39844
- if (!isZoneValid(range.zone)) {
39845
- throw new InvalidReferenceError();
39846
- }
39847
39852
  // if the formula definition could have accepted a range, we would pass through the _range function and not here
39848
39853
  if (range.zone.bottom !== range.zone.top || range.zone.left !== range.zone.right) {
39849
39854
  throw new Error(paramNumber
39850
39855
  ? _t("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.", functionName.toString(), paramNumber.toString())
39851
39856
  : _t("Function %s expects its parameters to be single values or single cell references, not ranges.", functionName.toString()));
39852
39857
  }
39853
- if (range.invalidSheetName) {
39854
- throw new Error(_t("Invalid sheet name: %s", range.invalidSheetName));
39855
- }
39856
39858
  const position = { sheetId: range.sheetId, col: range.zone.left, row: range.zone.top };
39857
39859
  return this.readCell(position);
39858
39860
  }
@@ -39887,10 +39889,10 @@
39887
39889
  * Note that each col is possibly sparse: it only contain the values of cells
39888
39890
  * that are actually present in the grid.
39889
39891
  */
39890
- range({ sheetId, zone }) {
39891
- if (!isZoneValid(zone)) {
39892
- throw new InvalidReferenceError();
39893
- }
39892
+ range(range) {
39893
+ this.assertRangeValid(range);
39894
+ const sheetId = range.sheetId;
39895
+ const zone = range.zone;
39894
39896
  // Performance issue: Avoid fetching data on positions that are out of the spreadsheet
39895
39897
  // e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
39896
39898
  const sheetZone = this.getters.getSheetZone(sheetId);
@@ -39927,6 +39929,14 @@
39927
39929
  this.rangeCache[cacheKey] = matrix;
39928
39930
  return matrix;
39929
39931
  }
39932
+ assertRangeValid(range) {
39933
+ if (!isZoneValid(range.zone)) {
39934
+ throw new InvalidReferenceError();
39935
+ }
39936
+ if (range.invalidSheetName) {
39937
+ throw new Error(_t("Invalid sheet name: %s", range.invalidSheetName));
39938
+ }
39939
+ }
39930
39940
  }
39931
39941
 
39932
39942
  function quickselect(arr, k, left, right, compare) {
@@ -45999,27 +46009,6 @@
45999
46009
  // ---------------------------------------------------------------------------
46000
46010
  // Command Handling
46001
46011
  // ---------------------------------------------------------------------------
46002
- allowDispatch(cmd) {
46003
- switch (cmd.type) {
46004
- case "ADD_RANGE":
46005
- case "ADD_EMPTY_RANGE":
46006
- if (this.inputHasSingleRange && this.ranges.length === 1) {
46007
- return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46008
- }
46009
- break;
46010
- case "REMOVE_RANGE":
46011
- if (this.ranges.length === 1) {
46012
- return "MinimumRangesReached" /* CommandResult.MinimumRangesReached */;
46013
- }
46014
- break;
46015
- case "CHANGE_RANGE":
46016
- if (this.inputHasSingleRange && cmd.value.split(",").length > 1) {
46017
- return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46018
- }
46019
- break;
46020
- }
46021
- return "Success" /* CommandResult.Success */;
46022
- }
46023
46012
  handleEvent(event) {
46024
46013
  if (this.focusedRangeIndex === null) {
46025
46014
  return;
@@ -46257,6 +46246,15 @@
46257
46246
  // Command Handling
46258
46247
  // ---------------------------------------------------------------------------
46259
46248
  allowDispatch(cmd) {
46249
+ switch (cmd.type) {
46250
+ case "FOCUS_RANGE":
46251
+ case "CHANGE_RANGE":
46252
+ case "ADD_EMPTY_RANGE":
46253
+ case "REMOVE_RANGE":
46254
+ if (!this.inputs[cmd.id]) {
46255
+ return "InvalidInputId" /* CommandResult.InvalidInputId */;
46256
+ }
46257
+ }
46260
46258
  switch (cmd.type) {
46261
46259
  case "FOCUS_RANGE":
46262
46260
  const index = this.currentInput?.getIndex(cmd.rangeId);
@@ -46264,9 +46262,25 @@
46264
46262
  return "InputAlreadyFocused" /* CommandResult.InputAlreadyFocused */;
46265
46263
  }
46266
46264
  break;
46267
- }
46268
- if (this.currentInput) {
46269
- return this.currentInput.allowDispatch(cmd);
46265
+ case "ADD_RANGE":
46266
+ case "ADD_EMPTY_RANGE":
46267
+ const input = this.inputs[cmd.id];
46268
+ if (input.inputHasSingleRange && input.ranges.length === 1) {
46269
+ return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46270
+ }
46271
+ break;
46272
+ case "REMOVE_RANGE":
46273
+ if (this.inputs[cmd.id].ranges.length === 1) {
46274
+ return "MinimumRangesReached" /* CommandResult.MinimumRangesReached */;
46275
+ }
46276
+ break;
46277
+ case "CHANGE_RANGE": {
46278
+ const input = this.inputs[cmd.id];
46279
+ if (input.inputHasSingleRange && cmd.value.split(",").length > 1) {
46280
+ return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46281
+ }
46282
+ break;
46283
+ }
46270
46284
  }
46271
46285
  return "Success" /* CommandResult.Success */;
46272
46286
  }
@@ -48575,9 +48589,10 @@
48575
48589
  */
48576
48590
  getReferencedRanges() {
48577
48591
  const editionSheetId = this.getters.getCurrentEditedCell().sheetId;
48578
- return this.currentTokens
48592
+ const referenceRanges = this.currentTokens
48579
48593
  .filter((token) => token.type === "REFERENCE")
48580
48594
  .map((token) => this.getters.getRangeFromSheetXC(editionSheetId, token.value));
48595
+ return referenceRanges.filter((range) => !range.invalidSheetName && !range.invalidXc);
48581
48596
  }
48582
48597
  getAutoCompleteDataValidationValues() {
48583
48598
  if (this.mode === "inactive") {
@@ -56769,9 +56784,9 @@
56769
56784
  exports.tokenize = tokenize;
56770
56785
 
56771
56786
 
56772
- __info__.version = "17.0.8";
56773
- __info__.date = "2024-01-17T10:27:32.736Z";
56774
- __info__.hash = "0f2d46e";
56787
+ __info__.version = "17.0.9";
56788
+ __info__.date = "2024-01-29T13:53:22.963Z";
56789
+ __info__.hash = "3c1209a";
56775
56790
 
56776
56791
 
56777
56792
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);