@odoo/o-spreadsheet 18.0.35 → 18.0.37

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 18.0.35
6
- * @date 2025-06-23T15:06:32.032Z
7
- * @hash a38db25
5
+ * @version 18.0.37
6
+ * @date 2025-07-11T11:11:13.394Z
7
+ * @hash bc6f00d
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -818,6 +818,7 @@
818
818
  ];
819
819
  const specialWhiteSpaceRegexp = new RegExp(specialWhiteSpaceSpecialCharacters.join("|"), "g");
820
820
  const newLineRegexp = /(\r\n|\r)/g;
821
+ const whiteSpaceCharacters = specialWhiteSpaceSpecialCharacters.concat([" "]);
821
822
  /**
822
823
  * Replace all different newlines characters by \n
823
824
  */
@@ -2661,8 +2662,9 @@
2661
2662
  const DATE_JS_1900_OFFSET = INITIAL_JS_DAY.getTime() - INITIAL_1900_DAY.getTime();
2662
2663
  const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
2663
2664
  const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
2664
- const dateSeparatorsRegex = /\/|-|\s/;
2665
- const dateRegexp = /^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/;
2665
+ const whiteSpaceChars = whiteSpaceCharacters.join("");
2666
+ const dateSeparatorsRegex = new RegExp(`\/|-|${whiteSpaceCharacters.join("|")}`);
2667
+ const dateRegexp = new RegExp(`^(\\d{1,4})[\/${whiteSpaceChars}\-](\\d{1,4})([\/${whiteSpaceChars}\-](\\d{1,4}))?$`);
2666
2668
  const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
2667
2669
  /** Convert a value number representing a date, or return undefined if it isn't possible */
2668
2670
  function valueToDateNumber(value, locale) {
@@ -6365,6 +6367,8 @@
6365
6367
  function splitTextToWidth(ctx, text, style, width) {
6366
6368
  if (!style)
6367
6369
  style = {};
6370
+ if (isMarkdownLink(text))
6371
+ text = parseMarkdownLink(text).label;
6368
6372
  const brokenText = [];
6369
6373
  // Checking if text contains NEWLINE before split makes it very slightly slower if text contains it,
6370
6374
  // but 5-10x faster if it doesn't
@@ -8318,6 +8322,10 @@
8318
8322
  if (groupValue === null || groupValue === "null") {
8319
8323
  return null;
8320
8324
  }
8325
+ const extractedGroupValue = typeof groupValue === "object" ? groupValue.value : groupValue;
8326
+ if (isEvaluationError(extractedGroupValue)) {
8327
+ return extractedGroupValue;
8328
+ }
8321
8329
  const groupValueString = typeof groupValue === "boolean"
8322
8330
  ? toString(groupValue).toLocaleLowerCase()
8323
8331
  : toString(groupValue);
@@ -12965,38 +12973,111 @@ stores.inject(MyMetaStore, storeInstance);
12965
12973
  * In all the sheets, replace the table-only references in the formula cells with standard references.
12966
12974
  */
12967
12975
  function convertTableFormulaReferences(convertedSheets, xlsxSheets) {
12976
+ let deconstructedSheets = null;
12968
12977
  for (let tableSheet of convertedSheets) {
12969
12978
  const tables = xlsxSheets.find((s) => isSheetNameEqual(s.sheetName, tableSheet.name)).tables;
12979
+ if (!tables || tables.length === 0) {
12980
+ continue;
12981
+ }
12982
+ // Only deconstruct sheets if we are sure there are tables to process
12983
+ if (!deconstructedSheets) {
12984
+ deconstructedSheets = deconstructSheets(convertedSheets);
12985
+ }
12970
12986
  for (let table of tables) {
12971
- const tabRef = table.name + "[";
12972
- for (let sheet of convertedSheets) {
12973
- for (let xc in sheet.cells) {
12974
- const cell = sheet.cells[xc];
12975
- if (cell && cell.content && cell.content.startsWith("=")) {
12976
- let refIndex;
12977
- while ((refIndex = cell.content.indexOf(tabRef)) !== -1) {
12978
- let endIndex = refIndex + tabRef.length;
12979
- let openBrackets = 1;
12980
- while (openBrackets > 0 && endIndex < cell.content.length) {
12981
- if (cell.content[endIndex] === "[") {
12982
- openBrackets++;
12983
- }
12984
- else if (cell.content[endIndex] === "]") {
12985
- openBrackets--;
12986
- }
12987
- endIndex++;
12988
- }
12989
- let reference = cell.content.slice(refIndex + tabRef.length, endIndex - 1);
12990
- const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
12991
- const convertedRef = convertTableReference(sheetPrefix, reference, table, xc);
12992
- cell.content =
12993
- cell.content.slice(0, refIndex) + convertedRef + cell.content.slice(endIndex);
12987
+ for (let sheetId in deconstructedSheets) {
12988
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
12989
+ for (let xc in deconstructedSheets[sheetId]) {
12990
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
12991
+ for (let i = deconstructedCell.length - 3; i >= 0; i -= 2) {
12992
+ const possibleTable = deconstructedSheets[sheetId][xc][i];
12993
+ if (!possibleTable.endsWith(table.name)) {
12994
+ continue;
12994
12995
  }
12996
+ const possibleRef = deconstructedSheets[sheetId][xc][i + 1];
12997
+ const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
12998
+ const convertedRef = convertTableReference(sheetPrefix, possibleRef, table, xc);
12999
+ deconstructedSheets[sheetId][xc][i + 2] =
13000
+ possibleTable.slice(0, possibleTable.indexOf(table.name)) +
13001
+ convertedRef +
13002
+ deconstructedSheets[sheetId][xc][i + 2];
13003
+ deconstructedSheets[sheetId][xc].splice(i, 2);
13004
+ }
13005
+ }
13006
+ }
13007
+ }
13008
+ }
13009
+ if (!deconstructedSheets) {
13010
+ return;
13011
+ }
13012
+ for (let sheetId in deconstructedSheets) {
13013
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
13014
+ for (let xc in deconstructedSheets[sheetId]) {
13015
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
13016
+ if (deconstructedCell.length === 1) {
13017
+ sheet.cells[xc].content = deconstructedCell[0];
13018
+ continue;
13019
+ }
13020
+ let newContent = "";
13021
+ for (let i = 0; i < deconstructedCell.length; i += 2) {
13022
+ newContent += deconstructedCell[i] + "[" + deconstructedCell[i + 1] + "]";
13023
+ }
13024
+ newContent += deconstructedCell[deconstructedCell.length - 1];
13025
+ sheet.cells[xc].content = newContent;
13026
+ }
13027
+ }
13028
+ }
13029
+ /**
13030
+ * Deconstruct the content of the cells in the sheets to extract possible table references.
13031
+ * Example from "=AVERAGE(Table1[colName1])-AVERAGE(Table2[colName2])":
13032
+ * return --> ["=AVERAGE(Table1", "colName1", ")-AVERAGE(Table2", "colName2", ")"]
13033
+ */
13034
+ function deconstructSheets(convertedSheets) {
13035
+ const deconstructedSheets = {};
13036
+ for (let sheet of convertedSheets) {
13037
+ for (let xc in sheet.cells) {
13038
+ const cellContent = sheet.cells[xc]?.content;
13039
+ if (!cellContent || !cellContent.startsWith("=")) {
13040
+ continue;
13041
+ }
13042
+ const startIndex = cellContent.indexOf("[");
13043
+ if (startIndex === -1) {
13044
+ continue;
13045
+ }
13046
+ const deconstructedCell = [];
13047
+ let possibleTable = cellContent.slice(0, startIndex);
13048
+ let possibleRef = "";
13049
+ let openBrackets = 1;
13050
+ let mainPossibleTableIndex = 0;
13051
+ let mainOpenBracketIndex = startIndex;
13052
+ for (let index = startIndex + 1; index < cellContent.length; index++) {
13053
+ if (cellContent[index] === "[") {
13054
+ if (openBrackets === 0) {
13055
+ possibleTable = cellContent.slice(mainPossibleTableIndex, index);
13056
+ mainOpenBracketIndex = index;
13057
+ }
13058
+ openBrackets++;
13059
+ continue;
13060
+ }
13061
+ if (cellContent[index] === "]") {
13062
+ openBrackets--;
13063
+ if (openBrackets === 0) {
13064
+ possibleRef = cellContent.slice(mainOpenBracketIndex + 1, index);
13065
+ deconstructedCell.push(possibleTable);
13066
+ deconstructedCell.push(possibleRef);
13067
+ mainPossibleTableIndex = index + 1;
12995
13068
  }
12996
13069
  }
12997
13070
  }
13071
+ if (deconstructedCell.length) {
13072
+ if (!deconstructedSheets[sheet.id]) {
13073
+ deconstructedSheets[sheet.id] = {};
13074
+ }
13075
+ deconstructedCell.push(cellContent.slice(mainPossibleTableIndex));
13076
+ deconstructedSheets[sheet.id][xc] = [...deconstructedCell];
13077
+ }
12998
13078
  }
12999
13079
  }
13080
+ return deconstructedSheets;
13000
13081
  }
13001
13082
  /**
13002
13083
  * Convert table-specific references in formulas into standard references. A table reference is composed of columns names,
@@ -44567,10 +44648,7 @@ stores.inject(MyMetaStore, storeInstance);
44567
44648
  if (finalCell.value === null) {
44568
44649
  return { value: _t("(Undefined)") };
44569
44650
  }
44570
- return {
44571
- value: finalCell.value,
44572
- format: finalCell.format,
44573
- };
44651
+ return finalCell;
44574
44652
  }
44575
44653
  getPivotCellValueAndFormat(measureId, domain) {
44576
44654
  const dataEntries = this.filterDataEntriesFromDomain(this.dataEntries, domain);
@@ -44801,7 +44879,6 @@ stores.inject(MyMetaStore, storeInstance);
44801
44879
  ui: SpreadsheetPivot,
44802
44880
  definition: SpreadsheetPivotRuntimeDefinition,
44803
44881
  externalData: false,
44804
- onIterationEndEvaluation: (pivot) => pivot.markAsDirtyForEvaluation(),
44805
44882
  dateGranularities: [...dateGranularities],
44806
44883
  datetimeGranularities: [...dateGranularities, "hour_number", "minute_number", "second_number"],
44807
44884
  isMeasureCandidate: (field) => !["datetime", "boolean"].includes(field.type),
@@ -57472,7 +57549,7 @@ stores.inject(MyMetaStore, storeInstance);
57472
57549
  onIterationEndEvaluationRegistry.add("pivots", (getters) => {
57473
57550
  for (const pivotId of getters.getPivotIds()) {
57474
57551
  const pivot = getters.getPivot(pivotId);
57475
- pivotRegistry.get(pivot.type).onIterationEndEvaluation(pivot);
57552
+ pivot.markAsDirtyForEvaluation?.();
57476
57553
  }
57477
57554
  });
57478
57555
 
@@ -60509,13 +60586,13 @@ stores.inject(MyMetaStore, storeInstance);
60509
60586
  super(custom, params);
60510
60587
  this.getters = params.getters;
60511
60588
  }
60512
- init(params) {
60589
+ markAsDirtyForEvaluation() {
60513
60590
  this.cache = {};
60514
60591
  this.rankAsc = {};
60515
60592
  this.rankDesc = {};
60516
60593
  this.runningTotal = {};
60517
60594
  this.runningTotalInPercent = {};
60518
- super.init(params);
60595
+ super.markAsDirtyForEvaluation?.();
60519
60596
  }
60520
60597
  getPivotCellValueAndFormat(measureName, domain) {
60521
60598
  return this.getMeasureDisplayValue(measureName, domain);
@@ -60640,7 +60717,7 @@ stores.inject(MyMetaStore, storeInstance);
60640
60717
  return this.getSubTreeMatchingDomain(node.children, domain, domainLevel + 1);
60641
60718
  }
60642
60719
  }
60643
- return tree;
60720
+ return [];
60644
60721
  }
60645
60722
  treeToLeafDomains(tree, parentDomain = []) {
60646
60723
  const domains = [];
@@ -71195,26 +71272,28 @@ stores.inject(MyMetaStore, storeInstance);
71195
71272
  bottom: Math.min(this.getters.getNumberRows(sheetId) - 1, bottom),
71196
71273
  };
71197
71274
  };
71198
- const { col: refCol, row: refRow } = this.getReferencePosition();
71275
+ const { cell: refCell, zone: refZone } = this.getReferenceAnchor();
71276
+ const { col: refCol, row: refRow } = refCell;
71199
71277
  // check if we can shrink selection
71200
71278
  let n = 0;
71201
71279
  while (result !== null) {
71202
71280
  n++;
71203
71281
  if (deltaCol < 0) {
71204
71282
  const newRight = this.getNextAvailableCol(deltaCol, right - (n - 1), refRow);
71205
- result = refCol <= right - n ? expand({ top, left, bottom, right: newRight }) : null;
71283
+ result = refZone.right <= right - n ? expand({ top, left, bottom, right: newRight }) : null;
71206
71284
  }
71207
71285
  if (deltaCol > 0) {
71208
71286
  const newLeft = this.getNextAvailableCol(deltaCol, left + (n - 1), refRow);
71209
- result = left + n <= refCol ? expand({ top, left: newLeft, bottom, right }) : null;
71287
+ result = left + n <= refZone.left ? expand({ top, left: newLeft, bottom, right }) : null;
71210
71288
  }
71211
71289
  if (deltaRow < 0) {
71212
71290
  const newBottom = this.getNextAvailableRow(deltaRow, refCol, bottom - (n - 1));
71213
- result = refRow <= bottom - n ? expand({ top, left, bottom: newBottom, right }) : null;
71291
+ result =
71292
+ refZone.bottom <= bottom - n ? expand({ top, left, bottom: newBottom, right }) : null;
71214
71293
  }
71215
71294
  if (deltaRow > 0) {
71216
71295
  const newTop = this.getNextAvailableRow(deltaRow, refCol, top + (n - 1));
71217
- result = top + n <= refRow ? expand({ top: newTop, left, bottom, right }) : null;
71296
+ result = top + n <= refZone.top ? expand({ top: newTop, left, bottom, right }) : null;
71218
71297
  }
71219
71298
  result = result ? reorderZone(result) : result;
71220
71299
  if (result && !isEqual(result, anchor.zone)) {
@@ -71444,18 +71523,26 @@ stores.inject(MyMetaStore, storeInstance);
71444
71523
  * If the anchor is hidden, browses from left to right and top to bottom to
71445
71524
  * find a visible cell.
71446
71525
  */
71447
- getReferencePosition() {
71526
+ getReferenceAnchor() {
71448
71527
  const sheetId = this.getters.getActiveSheetId();
71449
71528
  const anchor = this.anchor;
71450
71529
  const { left, right, top, bottom } = anchor.zone;
71451
71530
  const { col: anchorCol, row: anchorRow } = anchor.cell;
71531
+ const col = this.getters.isColHidden(sheetId, anchorCol)
71532
+ ? this.getters.findVisibleHeader(sheetId, "COL", left, right) || anchorCol
71533
+ : anchorCol;
71534
+ const row = this.getters.isRowHidden(sheetId, anchorRow)
71535
+ ? this.getters.findVisibleHeader(sheetId, "ROW", top, bottom) || anchorRow
71536
+ : anchorRow;
71537
+ const zone = this.getters.expandZone(sheetId, {
71538
+ left: col,
71539
+ right: col,
71540
+ top: row,
71541
+ bottom: row,
71542
+ });
71452
71543
  return {
71453
- col: this.getters.isColHidden(sheetId, anchorCol)
71454
- ? this.getters.findVisibleHeader(sheetId, "COL", left, right) || anchorCol
71455
- : anchorCol,
71456
- row: this.getters.isRowHidden(sheetId, anchorRow)
71457
- ? this.getters.findVisibleHeader(sheetId, "ROW", top, bottom) || anchorRow
71458
- : anchorRow,
71544
+ cell: { col, row },
71545
+ zone,
71459
71546
  };
71460
71547
  }
71461
71548
  deltaToTarget(position, direction, step) {
@@ -74503,9 +74590,9 @@ stores.inject(MyMetaStore, storeInstance);
74503
74590
  exports.tokenize = tokenize;
74504
74591
 
74505
74592
 
74506
- __info__.version = "18.0.35";
74507
- __info__.date = "2025-06-23T15:06:32.032Z";
74508
- __info__.hash = "a38db25";
74593
+ __info__.version = "18.0.37";
74594
+ __info__.date = "2025-07-11T11:11:13.394Z";
74595
+ __info__.hash = "bc6f00d";
74509
74596
 
74510
74597
 
74511
74598
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);