@odoo/o-spreadsheet 17.0.7 → 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.7
6
- * @date 2024-01-12T13:42:04.654Z
7
- * @hash cadb817
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) {
@@ -480,7 +480,7 @@
480
480
  const upperCased = str.toUpperCase();
481
481
  return upperCased === "TRUE" || upperCased === "FALSE";
482
482
  }
483
- const MARKDOWN_LINK_REGEX = /^\[([^\[]+)\]\((.+)\)$/;
483
+ const MARKDOWN_LINK_REGEX = /^\[(.+)\]\((.+)\)$/;
484
484
  //link must start with http or https
485
485
  //https://stackoverflow.com/a/3809435/4760614
486
486
  const WEB_LINK_REGEX = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;
@@ -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,
@@ -27323,6 +27330,7 @@
27323
27330
  const MARGIN = (GRID_ICON_EDGE_LENGTH - CHECKBOX_WIDTH) / 2;
27324
27331
  css /* scss */ `
27325
27332
  .o-dv-checkbox {
27333
+ box-sizing: border-box !important;
27326
27334
  width: ${CHECKBOX_WIDTH}px;
27327
27335
  height: ${CHECKBOX_WIDTH}px;
27328
27336
  accent-color: #808080;
@@ -38402,9 +38410,9 @@
38402
38410
  * Get a Xc string that represent a part of a range
38403
38411
  */
38404
38412
  getRangePartString(range, part) {
38405
- const colFixed = range.parts && range.parts[part].colFixed ? "$" : "";
38413
+ const colFixed = range.parts && range.parts[part]?.colFixed ? "$" : "";
38406
38414
  const col = part === 0 ? numberToLetters(range.zone.left) : numberToLetters(range.zone.right);
38407
- const rowFixed = range.parts && range.parts[part].rowFixed ? "$" : "";
38415
+ const rowFixed = range.parts && range.parts[part]?.rowFixed ? "$" : "";
38408
38416
  const row = part === 0 ? String(range.zone.top + 1) : String(range.zone.bottom + 1);
38409
38417
  let str = "";
38410
38418
  if (range.isFullCol) {
@@ -39836,22 +39844,17 @@
39836
39844
  * The `compute` of the formula's function must process it completely
39837
39845
  */
39838
39846
  refFn(range, isMeta, functionName, paramNumber) {
39847
+ this.assertRangeValid(range);
39839
39848
  if (isMeta) {
39840
39849
  // Use zoneToXc of zone instead of getRangeString to avoid sending unbounded ranges
39841
39850
  return { value: zoneToXc(range.zone) };
39842
39851
  }
39843
- if (!isZoneValid(range.zone)) {
39844
- throw new InvalidReferenceError();
39845
- }
39846
39852
  // if the formula definition could have accepted a range, we would pass through the _range function and not here
39847
39853
  if (range.zone.bottom !== range.zone.top || range.zone.left !== range.zone.right) {
39848
39854
  throw new Error(paramNumber
39849
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())
39850
39856
  : _t("Function %s expects its parameters to be single values or single cell references, not ranges.", functionName.toString()));
39851
39857
  }
39852
- if (range.invalidSheetName) {
39853
- throw new Error(_t("Invalid sheet name: %s", range.invalidSheetName));
39854
- }
39855
39858
  const position = { sheetId: range.sheetId, col: range.zone.left, row: range.zone.top };
39856
39859
  return this.readCell(position);
39857
39860
  }
@@ -39886,10 +39889,10 @@
39886
39889
  * Note that each col is possibly sparse: it only contain the values of cells
39887
39890
  * that are actually present in the grid.
39888
39891
  */
39889
- range({ sheetId, zone }) {
39890
- if (!isZoneValid(zone)) {
39891
- throw new InvalidReferenceError();
39892
- }
39892
+ range(range) {
39893
+ this.assertRangeValid(range);
39894
+ const sheetId = range.sheetId;
39895
+ const zone = range.zone;
39893
39896
  // Performance issue: Avoid fetching data on positions that are out of the spreadsheet
39894
39897
  // e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
39895
39898
  const sheetZone = this.getters.getSheetZone(sheetId);
@@ -39926,6 +39929,14 @@
39926
39929
  this.rangeCache[cacheKey] = matrix;
39927
39930
  return matrix;
39928
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
+ }
39929
39940
  }
39930
39941
 
39931
39942
  function quickselect(arr, k, left, right, compare) {
@@ -45998,27 +46009,6 @@
45998
46009
  // ---------------------------------------------------------------------------
45999
46010
  // Command Handling
46000
46011
  // ---------------------------------------------------------------------------
46001
- allowDispatch(cmd) {
46002
- switch (cmd.type) {
46003
- case "ADD_RANGE":
46004
- case "ADD_EMPTY_RANGE":
46005
- if (this.inputHasSingleRange && this.ranges.length === 1) {
46006
- return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46007
- }
46008
- break;
46009
- case "REMOVE_RANGE":
46010
- if (this.ranges.length === 1) {
46011
- return "MinimumRangesReached" /* CommandResult.MinimumRangesReached */;
46012
- }
46013
- break;
46014
- case "CHANGE_RANGE":
46015
- if (this.inputHasSingleRange && cmd.value.split(",").length > 1) {
46016
- return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46017
- }
46018
- break;
46019
- }
46020
- return "Success" /* CommandResult.Success */;
46021
- }
46022
46012
  handleEvent(event) {
46023
46013
  if (this.focusedRangeIndex === null) {
46024
46014
  return;
@@ -46256,6 +46246,15 @@
46256
46246
  // Command Handling
46257
46247
  // ---------------------------------------------------------------------------
46258
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
+ }
46259
46258
  switch (cmd.type) {
46260
46259
  case "FOCUS_RANGE":
46261
46260
  const index = this.currentInput?.getIndex(cmd.rangeId);
@@ -46263,9 +46262,25 @@
46263
46262
  return "InputAlreadyFocused" /* CommandResult.InputAlreadyFocused */;
46264
46263
  }
46265
46264
  break;
46266
- }
46267
- if (this.currentInput) {
46268
- 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
+ }
46269
46284
  }
46270
46285
  return "Success" /* CommandResult.Success */;
46271
46286
  }
@@ -48574,9 +48589,10 @@
48574
48589
  */
48575
48590
  getReferencedRanges() {
48576
48591
  const editionSheetId = this.getters.getCurrentEditedCell().sheetId;
48577
- return this.currentTokens
48592
+ const referenceRanges = this.currentTokens
48578
48593
  .filter((token) => token.type === "REFERENCE")
48579
48594
  .map((token) => this.getters.getRangeFromSheetXC(editionSheetId, token.value));
48595
+ return referenceRanges.filter((range) => !range.invalidSheetName && !range.invalidXc);
48580
48596
  }
48581
48597
  getAutoCompleteDataValidationValues() {
48582
48598
  if (this.mode === "inactive") {
@@ -56768,9 +56784,9 @@
56768
56784
  exports.tokenize = tokenize;
56769
56785
 
56770
56786
 
56771
- __info__.version = "17.0.7";
56772
- __info__.date = "2024-01-12T13:42:04.654Z";
56773
- __info__.hash = "cadb817";
56787
+ __info__.version = "17.0.9";
56788
+ __info__.date = "2024-01-29T13:53:22.963Z";
56789
+ __info__.hash = "3c1209a";
56774
56790
 
56775
56791
 
56776
56792
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);