@odoo/o-spreadsheet 18.2.19 → 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.19
6
- * @date 2025-06-23T15:07:13.023Z
7
- * @hash 430d931
5
+ * @version 18.2.21
6
+ * @date 2025-07-11T11:11:48.661Z
7
+ * @hash 1c32303
8
8
  */
9
9
 
10
10
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, App, blockDom, useState, onPatched, onWillPatch, onWillUpdateProps, useExternalListener, onWillStart, xml, useChildSubEnv, markRaw, toRaw } from '@odoo/owl';
@@ -821,6 +821,7 @@ const specialWhiteSpaceSpecialCharacters = [
821
821
  ];
822
822
  const specialWhiteSpaceRegexp = new RegExp(specialWhiteSpaceSpecialCharacters.join("|"), "g");
823
823
  const newLineRegexp = /(\r\n|\r)/g;
824
+ const whiteSpaceCharacters = specialWhiteSpaceSpecialCharacters.concat([" "]);
824
825
  /**
825
826
  * Replace all different newlines characters by \n
826
827
  */
@@ -2837,8 +2838,9 @@ const INITIAL_JS_DAY = DateTime.fromTimestamp(0);
2837
2838
  const DATE_JS_1900_OFFSET = INITIAL_JS_DAY.getTime() - INITIAL_1900_DAY.getTime();
2838
2839
  const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
2839
2840
  const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
2840
- const dateSeparatorsRegex = /\/|-|\s/;
2841
- const dateRegexp = /^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/;
2841
+ const whiteSpaceChars = whiteSpaceCharacters.join("");
2842
+ const dateSeparatorsRegex = new RegExp(`\/|-|${whiteSpaceCharacters.join("|")}`);
2843
+ const dateRegexp = new RegExp(`^(\\d{1,4})[\/${whiteSpaceChars}\-](\\d{1,4})([\/${whiteSpaceChars}\-](\\d{1,4}))?$`);
2842
2844
  const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
2843
2845
  /** Convert a value number representing a date, or return undefined if it isn't possible */
2844
2846
  function valueToDateNumber(value, locale) {
@@ -6541,6 +6543,8 @@ function splitWordToSpecificWidth(ctx, word, width, style) {
6541
6543
  function splitTextToWidth(ctx, text, style, width) {
6542
6544
  if (!style)
6543
6545
  style = {};
6546
+ if (isMarkdownLink(text))
6547
+ text = parseMarkdownLink(text).label;
6544
6548
  const brokenText = [];
6545
6549
  // Checking if text contains NEWLINE before split makes it very slightly slower if text contains it,
6546
6550
  // but 5-10x faster if it doesn't
@@ -8505,6 +8509,10 @@ function toNormalizedPivotValue(dimension, groupValue) {
8505
8509
  if (groupValue === null || groupValue === "null") {
8506
8510
  return null;
8507
8511
  }
8512
+ const extractedGroupValue = typeof groupValue === "object" ? groupValue.value : groupValue;
8513
+ if (isEvaluationError(extractedGroupValue)) {
8514
+ return extractedGroupValue;
8515
+ }
8508
8516
  const groupValueString = typeof groupValue === "boolean"
8509
8517
  ? toString(groupValue).toLocaleLowerCase()
8510
8518
  : toString(groupValue);
@@ -21198,7 +21206,7 @@ class AbstractComposerStore extends SpreadsheetStore {
21198
21206
  }
21199
21207
  captureSelection(zone, col, row) {
21200
21208
  this.model.selection.capture(this, {
21201
- cell: { col: col || zone.left, row: row || zone.right },
21209
+ cell: { col: col ?? zone.left, row: row ?? zone.right },
21202
21210
  zone,
21203
21211
  }, {
21204
21212
  handleEvent: this.handleEvent.bind(this),
@@ -25809,40 +25817,112 @@ function convertPivotTableConfig(pivotTable) {
25809
25817
  * In all the sheets, replace the table-only references in the formula cells with standard references.
25810
25818
  */
25811
25819
  function convertTableFormulaReferences(convertedSheets, xlsxSheets) {
25820
+ let deconstructedSheets = null;
25812
25821
  for (let tableSheet of convertedSheets) {
25813
25822
  const tables = xlsxSheets.find((s) => isSheetNameEqual(s.sheetName, tableSheet.name)).tables;
25823
+ if (!tables || tables.length === 0) {
25824
+ continue;
25825
+ }
25826
+ // Only deconstruct sheets if we are sure there are tables to process
25827
+ if (!deconstructedSheets) {
25828
+ deconstructedSheets = deconstructSheets(convertedSheets);
25829
+ }
25814
25830
  for (let table of tables) {
25815
- const tabRef = table.name + "[";
25816
- for (let sheet of convertedSheets) {
25817
- for (let xc in sheet.cells) {
25818
- const cell = sheet.cells[xc];
25819
- let cellContent = sheet.cells[xc];
25820
- if (cell && cellContent && cellContent.startsWith("=")) {
25821
- let refIndex;
25822
- while ((refIndex = cellContent.indexOf(tabRef)) !== -1) {
25823
- let endIndex = refIndex + tabRef.length;
25824
- let openBrackets = 1;
25825
- while (openBrackets > 0 && endIndex < cellContent.length) {
25826
- if (cellContent[endIndex] === "[") {
25827
- openBrackets++;
25828
- }
25829
- else if (cellContent[endIndex] === "]") {
25830
- openBrackets--;
25831
- }
25832
- endIndex++;
25833
- }
25834
- let reference = cellContent.slice(refIndex + tabRef.length, endIndex - 1);
25835
- const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
25836
- const convertedRef = convertTableReference(sheetPrefix, reference, table, xc);
25837
- cellContent =
25838
- cellContent.slice(0, refIndex) + convertedRef + cellContent.slice(endIndex);
25831
+ for (let sheetId in deconstructedSheets) {
25832
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
25833
+ for (let xc in deconstructedSheets[sheetId]) {
25834
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
25835
+ for (let i = deconstructedCell.length - 3; i >= 0; i -= 2) {
25836
+ const possibleTable = deconstructedSheets[sheetId][xc][i];
25837
+ if (!possibleTable.endsWith(table.name)) {
25838
+ continue;
25839
25839
  }
25840
+ const possibleRef = deconstructedSheets[sheetId][xc][i + 1];
25841
+ const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
25842
+ const convertedRef = convertTableReference(sheetPrefix, possibleRef, table, xc);
25843
+ deconstructedSheets[sheetId][xc][i + 2] =
25844
+ possibleTable.slice(0, possibleTable.indexOf(table.name)) +
25845
+ convertedRef +
25846
+ deconstructedSheets[sheetId][xc][i + 2];
25847
+ deconstructedSheets[sheetId][xc].splice(i, 2);
25840
25848
  }
25841
- sheet.cells[xc] = cellContent;
25849
+ // sheet.cells[xc] = cellContent;
25842
25850
  }
25843
25851
  }
25844
25852
  }
25845
25853
  }
25854
+ if (!deconstructedSheets) {
25855
+ return;
25856
+ }
25857
+ for (let sheetId in deconstructedSheets) {
25858
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
25859
+ for (let xc in deconstructedSheets[sheetId]) {
25860
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
25861
+ if (deconstructedCell.length === 1) {
25862
+ sheet.cells[xc] = deconstructedCell[0];
25863
+ continue;
25864
+ }
25865
+ let newContent = "";
25866
+ for (let i = 0; i < deconstructedCell.length; i += 2) {
25867
+ newContent += deconstructedCell[i] + "[" + deconstructedCell[i + 1] + "]";
25868
+ }
25869
+ newContent += deconstructedCell[deconstructedCell.length - 1];
25870
+ sheet.cells[xc] = newContent;
25871
+ }
25872
+ }
25873
+ }
25874
+ /**
25875
+ * Deconstruct the content of the cells in the sheets to extract possible table references.
25876
+ * Example from "=AVERAGE(Table1[colName1])-AVERAGE(Table2[colName2])":
25877
+ * return --> ["=AVERAGE(Table1", "colName1", ")-AVERAGE(Table2", "colName2", ")"]
25878
+ */
25879
+ function deconstructSheets(convertedSheets) {
25880
+ const deconstructedSheets = {};
25881
+ for (let sheet of convertedSheets) {
25882
+ for (let xc in sheet.cells) {
25883
+ const cellContent = sheet.cells[xc];
25884
+ if (!cellContent || !cellContent.startsWith("=")) {
25885
+ continue;
25886
+ }
25887
+ const startIndex = cellContent.indexOf("[");
25888
+ if (startIndex === -1) {
25889
+ continue;
25890
+ }
25891
+ const deconstructedCell = [];
25892
+ let possibleTable = cellContent.slice(0, startIndex);
25893
+ let possibleRef = "";
25894
+ let openBrackets = 1;
25895
+ let mainPossibleTableIndex = 0;
25896
+ let mainOpenBracketIndex = startIndex;
25897
+ for (let index = startIndex + 1; index < cellContent.length; index++) {
25898
+ if (cellContent[index] === "[") {
25899
+ if (openBrackets === 0) {
25900
+ possibleTable = cellContent.slice(mainPossibleTableIndex, index);
25901
+ mainOpenBracketIndex = index;
25902
+ }
25903
+ openBrackets++;
25904
+ continue;
25905
+ }
25906
+ if (cellContent[index] === "]") {
25907
+ openBrackets--;
25908
+ if (openBrackets === 0) {
25909
+ possibleRef = cellContent.slice(mainOpenBracketIndex + 1, index);
25910
+ deconstructedCell.push(possibleTable);
25911
+ deconstructedCell.push(possibleRef);
25912
+ mainPossibleTableIndex = index + 1;
25913
+ }
25914
+ }
25915
+ }
25916
+ if (deconstructedCell.length) {
25917
+ if (!deconstructedSheets[sheet.id]) {
25918
+ deconstructedSheets[sheet.id] = {};
25919
+ }
25920
+ deconstructedCell.push(cellContent.slice(mainPossibleTableIndex));
25921
+ deconstructedSheets[sheet.id][xc] = [...deconstructedCell];
25922
+ }
25923
+ }
25924
+ }
25925
+ return deconstructedSheets;
25846
25926
  }
25847
25927
  /**
25848
25928
  * Convert table-specific references in formulas into standard references. A table reference is composed of columns names,
@@ -33286,6 +33366,9 @@ class ErrorToolTip extends Component {
33286
33366
  return undefined;
33287
33367
  }
33288
33368
  get errorOriginPositionString() {
33369
+ if (this.env.model.getters.isDashboard()) {
33370
+ return "";
33371
+ }
33289
33372
  const evaluationError = this.evaluationError;
33290
33373
  const position = evaluationError?.errorOriginPosition;
33291
33374
  if (!position || deepEquals(position, this.props.cellPosition)) {
@@ -43142,6 +43225,9 @@ class ConditionalFormattingPanel extends Component {
43142
43225
  this.switchToList();
43143
43226
  }
43144
43227
  }
43228
+ else if (!this.editedCF) {
43229
+ this.switchToList();
43230
+ }
43145
43231
  });
43146
43232
  }
43147
43233
  get conditionalFormats() {
@@ -47057,10 +47143,7 @@ class SpreadsheetPivot {
47057
47143
  if (finalCell.value === null) {
47058
47144
  return { value: _t("(Undefined)") };
47059
47145
  }
47060
- return {
47061
- value: finalCell.value,
47062
- format: finalCell.format,
47063
- };
47146
+ return finalCell;
47064
47147
  }
47065
47148
  getPivotCellValueAndFormat(measureId, domain) {
47066
47149
  const dataEntries = this.filterDataEntriesFromDomain(this.dataEntries, domain);
@@ -47289,7 +47372,6 @@ pivotRegistry.add("SPREADSHEET", {
47289
47372
  ui: SpreadsheetPivot,
47290
47373
  definition: SpreadsheetPivotRuntimeDefinition,
47291
47374
  externalData: false,
47292
- onIterationEndEvaluation: (pivot) => pivot.markAsDirtyForEvaluation(),
47293
47375
  dateGranularities: [...dateGranularities],
47294
47376
  datetimeGranularities: [...dateGranularities, "hour_number", "minute_number", "second_number"],
47295
47377
  isMeasureCandidate: (field) => field.type !== "boolean",
@@ -60055,7 +60137,7 @@ const onIterationEndEvaluationRegistry = new Registry();
60055
60137
  onIterationEndEvaluationRegistry.add("pivots", (getters) => {
60056
60138
  for (const pivotId of getters.getPivotIds()) {
60057
60139
  const pivot = getters.getPivot(pivotId);
60058
- pivotRegistry.get(pivot.type).onIterationEndEvaluation(pivot);
60140
+ pivot.markAsDirtyForEvaluation?.();
60059
60141
  }
60060
60142
  });
60061
60143
 
@@ -63061,13 +63143,13 @@ function withPivotPresentationLayer (PivotClass) {
63061
63143
  super(custom, params);
63062
63144
  this.getters = params.getters;
63063
63145
  }
63064
- init(params) {
63146
+ markAsDirtyForEvaluation() {
63065
63147
  this.cache = {};
63066
63148
  this.rankAsc = {};
63067
63149
  this.rankDesc = {};
63068
63150
  this.runningTotal = {};
63069
63151
  this.runningTotalInPercent = {};
63070
- super.init(params);
63152
+ super.markAsDirtyForEvaluation?.();
63071
63153
  }
63072
63154
  getPivotCellValueAndFormat(measureName, domain) {
63073
63155
  return this.getMeasureDisplayValue(measureName, domain);
@@ -63192,7 +63274,7 @@ function withPivotPresentationLayer (PivotClass) {
63192
63274
  return this.getSubTreeMatchingDomain(node.children, domain, domainLevel + 1);
63193
63275
  }
63194
63276
  }
63195
- return tree;
63277
+ return [];
63196
63278
  }
63197
63279
  treeToLeafDomains(tree, parentDomain = []) {
63198
63280
  const domains = [];
@@ -73690,26 +73772,28 @@ class SelectionStreamProcessorImpl {
73690
73772
  bottom: Math.min(this.getters.getNumberRows(sheetId) - 1, bottom),
73691
73773
  };
73692
73774
  };
73693
- const { col: refCol, row: refRow } = this.getReferencePosition();
73775
+ const { cell: refCell, zone: refZone } = this.getReferenceAnchor();
73776
+ const { col: refCol, row: refRow } = refCell;
73694
73777
  // check if we can shrink selection
73695
73778
  let n = 0;
73696
73779
  while (result !== null) {
73697
73780
  n++;
73698
73781
  if (deltaCol < 0) {
73699
73782
  const newRight = this.getNextAvailableCol(deltaCol, right - (n - 1), refRow);
73700
- result = refCol <= right - n ? expand({ top, left, bottom, right: newRight }) : null;
73783
+ result = refZone.right <= right - n ? expand({ top, left, bottom, right: newRight }) : null;
73701
73784
  }
73702
73785
  if (deltaCol > 0) {
73703
73786
  const newLeft = this.getNextAvailableCol(deltaCol, left + (n - 1), refRow);
73704
- result = left + n <= refCol ? expand({ top, left: newLeft, bottom, right }) : null;
73787
+ result = left + n <= refZone.left ? expand({ top, left: newLeft, bottom, right }) : null;
73705
73788
  }
73706
73789
  if (deltaRow < 0) {
73707
73790
  const newBottom = this.getNextAvailableRow(deltaRow, refCol, bottom - (n - 1));
73708
- result = refRow <= bottom - n ? expand({ top, left, bottom: newBottom, right }) : null;
73791
+ result =
73792
+ refZone.bottom <= bottom - n ? expand({ top, left, bottom: newBottom, right }) : null;
73709
73793
  }
73710
73794
  if (deltaRow > 0) {
73711
73795
  const newTop = this.getNextAvailableRow(deltaRow, refCol, top + (n - 1));
73712
- result = top + n <= refRow ? expand({ top: newTop, left, bottom, right }) : null;
73796
+ result = top + n <= refZone.top ? expand({ top: newTop, left, bottom, right }) : null;
73713
73797
  }
73714
73798
  result = result ? reorderZone(result) : result;
73715
73799
  if (result && !isEqual(result, anchor.zone)) {
@@ -73939,18 +74023,26 @@ class SelectionStreamProcessorImpl {
73939
74023
  * If the anchor is hidden, browses from left to right and top to bottom to
73940
74024
  * find a visible cell.
73941
74025
  */
73942
- getReferencePosition() {
74026
+ getReferenceAnchor() {
73943
74027
  const sheetId = this.getters.getActiveSheetId();
73944
74028
  const anchor = this.anchor;
73945
74029
  const { left, right, top, bottom } = anchor.zone;
73946
74030
  const { col: anchorCol, row: anchorRow } = anchor.cell;
74031
+ const col = this.getters.isColHidden(sheetId, anchorCol)
74032
+ ? this.getters.findVisibleHeader(sheetId, "COL", left, right) || anchorCol
74033
+ : anchorCol;
74034
+ const row = this.getters.isRowHidden(sheetId, anchorRow)
74035
+ ? this.getters.findVisibleHeader(sheetId, "ROW", top, bottom) || anchorRow
74036
+ : anchorRow;
74037
+ const zone = this.getters.expandZone(sheetId, {
74038
+ left: col,
74039
+ right: col,
74040
+ top: row,
74041
+ bottom: row,
74042
+ });
73947
74043
  return {
73948
- col: this.getters.isColHidden(sheetId, anchorCol)
73949
- ? this.getters.findVisibleHeader(sheetId, "COL", left, right) || anchorCol
73950
- : anchorCol,
73951
- row: this.getters.isRowHidden(sheetId, anchorRow)
73952
- ? this.getters.findVisibleHeader(sheetId, "ROW", top, bottom) || anchorRow
73953
- : anchorRow,
74044
+ cell: { col, row },
74045
+ zone,
73954
74046
  };
73955
74047
  }
73956
74048
  deltaToTarget(position, direction, step) {
@@ -77048,6 +77140,6 @@ const chartHelpers = { ...CHART_HELPERS, ...CHART_RUNTIME_HELPERS };
77048
77140
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, CoreViewPlugin, DispatchResult, EvaluationError, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, chartHelpers, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, stores, tokenColors, tokenize };
77049
77141
 
77050
77142
 
77051
- __info__.version = "18.2.19";
77052
- __info__.date = "2025-06-23T15:07:13.023Z";
77053
- __info__.hash = "430d931";
77143
+ __info__.version = "18.2.21";
77144
+ __info__.date = "2025-07-11T11:11:48.661Z";
77145
+ __info__.hash = "1c32303";