@odoo/o-spreadsheet 18.2.20 → 18.2.21

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.2.20
6
- * @date 2025-06-27T09:11:55.800Z
7
- * @hash 16dfc38
5
+ * @version 18.2.21
6
+ * @date 2025-07-11T11:11:48.661Z
7
+ * @hash 1c32303
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -822,6 +822,7 @@
822
822
  ];
823
823
  const specialWhiteSpaceRegexp = new RegExp(specialWhiteSpaceSpecialCharacters.join("|"), "g");
824
824
  const newLineRegexp = /(\r\n|\r)/g;
825
+ const whiteSpaceCharacters = specialWhiteSpaceSpecialCharacters.concat([" "]);
825
826
  /**
826
827
  * Replace all different newlines characters by \n
827
828
  */
@@ -2838,8 +2839,9 @@
2838
2839
  const DATE_JS_1900_OFFSET = INITIAL_JS_DAY.getTime() - INITIAL_1900_DAY.getTime();
2839
2840
  const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
2840
2841
  const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
2841
- const dateSeparatorsRegex = /\/|-|\s/;
2842
- const dateRegexp = /^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/;
2842
+ const whiteSpaceChars = whiteSpaceCharacters.join("");
2843
+ const dateSeparatorsRegex = new RegExp(`\/|-|${whiteSpaceCharacters.join("|")}`);
2844
+ const dateRegexp = new RegExp(`^(\\d{1,4})[\/${whiteSpaceChars}\-](\\d{1,4})([\/${whiteSpaceChars}\-](\\d{1,4}))?$`);
2843
2845
  const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
2844
2846
  /** Convert a value number representing a date, or return undefined if it isn't possible */
2845
2847
  function valueToDateNumber(value, locale) {
@@ -6542,6 +6544,8 @@
6542
6544
  function splitTextToWidth(ctx, text, style, width) {
6543
6545
  if (!style)
6544
6546
  style = {};
6547
+ if (isMarkdownLink(text))
6548
+ text = parseMarkdownLink(text).label;
6545
6549
  const brokenText = [];
6546
6550
  // Checking if text contains NEWLINE before split makes it very slightly slower if text contains it,
6547
6551
  // but 5-10x faster if it doesn't
@@ -8506,6 +8510,10 @@
8506
8510
  if (groupValue === null || groupValue === "null") {
8507
8511
  return null;
8508
8512
  }
8513
+ const extractedGroupValue = typeof groupValue === "object" ? groupValue.value : groupValue;
8514
+ if (isEvaluationError(extractedGroupValue)) {
8515
+ return extractedGroupValue;
8516
+ }
8509
8517
  const groupValueString = typeof groupValue === "boolean"
8510
8518
  ? toString(groupValue).toLocaleLowerCase()
8511
8519
  : toString(groupValue);
@@ -25810,40 +25818,112 @@ stores.inject(MyMetaStore, storeInstance);
25810
25818
  * In all the sheets, replace the table-only references in the formula cells with standard references.
25811
25819
  */
25812
25820
  function convertTableFormulaReferences(convertedSheets, xlsxSheets) {
25821
+ let deconstructedSheets = null;
25813
25822
  for (let tableSheet of convertedSheets) {
25814
25823
  const tables = xlsxSheets.find((s) => isSheetNameEqual(s.sheetName, tableSheet.name)).tables;
25824
+ if (!tables || tables.length === 0) {
25825
+ continue;
25826
+ }
25827
+ // Only deconstruct sheets if we are sure there are tables to process
25828
+ if (!deconstructedSheets) {
25829
+ deconstructedSheets = deconstructSheets(convertedSheets);
25830
+ }
25815
25831
  for (let table of tables) {
25816
- const tabRef = table.name + "[";
25817
- for (let sheet of convertedSheets) {
25818
- for (let xc in sheet.cells) {
25819
- const cell = sheet.cells[xc];
25820
- let cellContent = sheet.cells[xc];
25821
- if (cell && cellContent && cellContent.startsWith("=")) {
25822
- let refIndex;
25823
- while ((refIndex = cellContent.indexOf(tabRef)) !== -1) {
25824
- let endIndex = refIndex + tabRef.length;
25825
- let openBrackets = 1;
25826
- while (openBrackets > 0 && endIndex < cellContent.length) {
25827
- if (cellContent[endIndex] === "[") {
25828
- openBrackets++;
25829
- }
25830
- else if (cellContent[endIndex] === "]") {
25831
- openBrackets--;
25832
- }
25833
- endIndex++;
25834
- }
25835
- let reference = cellContent.slice(refIndex + tabRef.length, endIndex - 1);
25836
- const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
25837
- const convertedRef = convertTableReference(sheetPrefix, reference, table, xc);
25838
- cellContent =
25839
- cellContent.slice(0, refIndex) + convertedRef + cellContent.slice(endIndex);
25832
+ for (let sheetId in deconstructedSheets) {
25833
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
25834
+ for (let xc in deconstructedSheets[sheetId]) {
25835
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
25836
+ for (let i = deconstructedCell.length - 3; i >= 0; i -= 2) {
25837
+ const possibleTable = deconstructedSheets[sheetId][xc][i];
25838
+ if (!possibleTable.endsWith(table.name)) {
25839
+ continue;
25840
25840
  }
25841
+ const possibleRef = deconstructedSheets[sheetId][xc][i + 1];
25842
+ const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
25843
+ const convertedRef = convertTableReference(sheetPrefix, possibleRef, table, xc);
25844
+ deconstructedSheets[sheetId][xc][i + 2] =
25845
+ possibleTable.slice(0, possibleTable.indexOf(table.name)) +
25846
+ convertedRef +
25847
+ deconstructedSheets[sheetId][xc][i + 2];
25848
+ deconstructedSheets[sheetId][xc].splice(i, 2);
25841
25849
  }
25842
- sheet.cells[xc] = cellContent;
25850
+ // sheet.cells[xc] = cellContent;
25843
25851
  }
25844
25852
  }
25845
25853
  }
25846
25854
  }
25855
+ if (!deconstructedSheets) {
25856
+ return;
25857
+ }
25858
+ for (let sheetId in deconstructedSheets) {
25859
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
25860
+ for (let xc in deconstructedSheets[sheetId]) {
25861
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
25862
+ if (deconstructedCell.length === 1) {
25863
+ sheet.cells[xc] = deconstructedCell[0];
25864
+ continue;
25865
+ }
25866
+ let newContent = "";
25867
+ for (let i = 0; i < deconstructedCell.length; i += 2) {
25868
+ newContent += deconstructedCell[i] + "[" + deconstructedCell[i + 1] + "]";
25869
+ }
25870
+ newContent += deconstructedCell[deconstructedCell.length - 1];
25871
+ sheet.cells[xc] = newContent;
25872
+ }
25873
+ }
25874
+ }
25875
+ /**
25876
+ * Deconstruct the content of the cells in the sheets to extract possible table references.
25877
+ * Example from "=AVERAGE(Table1[colName1])-AVERAGE(Table2[colName2])":
25878
+ * return --> ["=AVERAGE(Table1", "colName1", ")-AVERAGE(Table2", "colName2", ")"]
25879
+ */
25880
+ function deconstructSheets(convertedSheets) {
25881
+ const deconstructedSheets = {};
25882
+ for (let sheet of convertedSheets) {
25883
+ for (let xc in sheet.cells) {
25884
+ const cellContent = sheet.cells[xc];
25885
+ if (!cellContent || !cellContent.startsWith("=")) {
25886
+ continue;
25887
+ }
25888
+ const startIndex = cellContent.indexOf("[");
25889
+ if (startIndex === -1) {
25890
+ continue;
25891
+ }
25892
+ const deconstructedCell = [];
25893
+ let possibleTable = cellContent.slice(0, startIndex);
25894
+ let possibleRef = "";
25895
+ let openBrackets = 1;
25896
+ let mainPossibleTableIndex = 0;
25897
+ let mainOpenBracketIndex = startIndex;
25898
+ for (let index = startIndex + 1; index < cellContent.length; index++) {
25899
+ if (cellContent[index] === "[") {
25900
+ if (openBrackets === 0) {
25901
+ possibleTable = cellContent.slice(mainPossibleTableIndex, index);
25902
+ mainOpenBracketIndex = index;
25903
+ }
25904
+ openBrackets++;
25905
+ continue;
25906
+ }
25907
+ if (cellContent[index] === "]") {
25908
+ openBrackets--;
25909
+ if (openBrackets === 0) {
25910
+ possibleRef = cellContent.slice(mainOpenBracketIndex + 1, index);
25911
+ deconstructedCell.push(possibleTable);
25912
+ deconstructedCell.push(possibleRef);
25913
+ mainPossibleTableIndex = index + 1;
25914
+ }
25915
+ }
25916
+ }
25917
+ if (deconstructedCell.length) {
25918
+ if (!deconstructedSheets[sheet.id]) {
25919
+ deconstructedSheets[sheet.id] = {};
25920
+ }
25921
+ deconstructedCell.push(cellContent.slice(mainPossibleTableIndex));
25922
+ deconstructedSheets[sheet.id][xc] = [...deconstructedCell];
25923
+ }
25924
+ }
25925
+ }
25926
+ return deconstructedSheets;
25847
25927
  }
25848
25928
  /**
25849
25929
  * Convert table-specific references in formulas into standard references. A table reference is composed of columns names,
@@ -33287,6 +33367,9 @@ stores.inject(MyMetaStore, storeInstance);
33287
33367
  return undefined;
33288
33368
  }
33289
33369
  get errorOriginPositionString() {
33370
+ if (this.env.model.getters.isDashboard()) {
33371
+ return "";
33372
+ }
33290
33373
  const evaluationError = this.evaluationError;
33291
33374
  const position = evaluationError?.errorOriginPosition;
33292
33375
  if (!position || deepEquals(position, this.props.cellPosition)) {
@@ -47061,10 +47144,7 @@ stores.inject(MyMetaStore, storeInstance);
47061
47144
  if (finalCell.value === null) {
47062
47145
  return { value: _t("(Undefined)") };
47063
47146
  }
47064
- return {
47065
- value: finalCell.value,
47066
- format: finalCell.format,
47067
- };
47147
+ return finalCell;
47068
47148
  }
47069
47149
  getPivotCellValueAndFormat(measureId, domain) {
47070
47150
  const dataEntries = this.filterDataEntriesFromDomain(this.dataEntries, domain);
@@ -47293,7 +47373,6 @@ stores.inject(MyMetaStore, storeInstance);
47293
47373
  ui: SpreadsheetPivot,
47294
47374
  definition: SpreadsheetPivotRuntimeDefinition,
47295
47375
  externalData: false,
47296
- onIterationEndEvaluation: (pivot) => pivot.markAsDirtyForEvaluation(),
47297
47376
  dateGranularities: [...dateGranularities],
47298
47377
  datetimeGranularities: [...dateGranularities, "hour_number", "minute_number", "second_number"],
47299
47378
  isMeasureCandidate: (field) => field.type !== "boolean",
@@ -60059,7 +60138,7 @@ stores.inject(MyMetaStore, storeInstance);
60059
60138
  onIterationEndEvaluationRegistry.add("pivots", (getters) => {
60060
60139
  for (const pivotId of getters.getPivotIds()) {
60061
60140
  const pivot = getters.getPivot(pivotId);
60062
- pivotRegistry.get(pivot.type).onIterationEndEvaluation(pivot);
60141
+ pivot.markAsDirtyForEvaluation?.();
60063
60142
  }
60064
60143
  });
60065
60144
 
@@ -63065,13 +63144,13 @@ stores.inject(MyMetaStore, storeInstance);
63065
63144
  super(custom, params);
63066
63145
  this.getters = params.getters;
63067
63146
  }
63068
- init(params) {
63147
+ markAsDirtyForEvaluation() {
63069
63148
  this.cache = {};
63070
63149
  this.rankAsc = {};
63071
63150
  this.rankDesc = {};
63072
63151
  this.runningTotal = {};
63073
63152
  this.runningTotalInPercent = {};
63074
- super.init(params);
63153
+ super.markAsDirtyForEvaluation?.();
63075
63154
  }
63076
63155
  getPivotCellValueAndFormat(measureName, domain) {
63077
63156
  return this.getMeasureDisplayValue(measureName, domain);
@@ -63196,7 +63275,7 @@ stores.inject(MyMetaStore, storeInstance);
63196
63275
  return this.getSubTreeMatchingDomain(node.children, domain, domainLevel + 1);
63197
63276
  }
63198
63277
  }
63199
- return tree;
63278
+ return [];
63200
63279
  }
63201
63280
  treeToLeafDomains(tree, parentDomain = []) {
63202
63281
  const domains = [];
@@ -77107,9 +77186,9 @@ stores.inject(MyMetaStore, storeInstance);
77107
77186
  exports.tokenize = tokenize;
77108
77187
 
77109
77188
 
77110
- __info__.version = "18.2.20";
77111
- __info__.date = "2025-06-27T09:11:55.800Z";
77112
- __info__.hash = "16dfc38";
77189
+ __info__.version = "18.2.21";
77190
+ __info__.date = "2025-07-11T11:11:48.661Z";
77191
+ __info__.hash = "1c32303";
77113
77192
 
77114
77193
 
77115
77194
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);