@odoo/o-spreadsheet 18.5.0-alpha.1 → 18.5.0-alpha.2

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.5.0-alpha.1
6
- * @date 2025-06-27T09:12:49.245Z
7
- * @hash 756e75b
5
+ * @version 18.5.0-alpha.2
6
+ * @date 2025-07-11T11:13:53.317Z
7
+ * @hash 6d42178
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -853,6 +853,7 @@
853
853
  ];
854
854
  const specialWhiteSpaceRegexp = new RegExp(specialWhiteSpaceSpecialCharacters.join("|"), "g");
855
855
  const newLineRegexp = /(\r\n|\r)/g;
856
+ const whiteSpaceCharacters = specialWhiteSpaceSpecialCharacters.concat([" "]);
856
857
  /**
857
858
  * Replace all different newlines characters by \n
858
859
  */
@@ -1989,8 +1990,9 @@
1989
1990
  const DATE_JS_1900_OFFSET = INITIAL_JS_DAY.getTime() - INITIAL_1900_DAY.getTime();
1990
1991
  const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
1991
1992
  const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
1992
- const dateSeparatorsRegex = /\/|-|\s/;
1993
- const dateRegexp = /^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/;
1993
+ const whiteSpaceChars = whiteSpaceCharacters.join("");
1994
+ const dateSeparatorsRegex = new RegExp(`\/|-|${whiteSpaceCharacters.join("|")}`);
1995
+ const dateRegexp = new RegExp(`^(\\d{1,4})[\/${whiteSpaceChars}\-](\\d{1,4})([\/${whiteSpaceChars}\-](\\d{1,4}))?$`);
1994
1996
  const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
1995
1997
  /** Convert a value number representing a date, or return undefined if it isn't possible */
1996
1998
  function valueToDateNumber(value, locale) {
@@ -6925,6 +6927,8 @@
6925
6927
  function splitTextToWidth(ctx, text, style, width) {
6926
6928
  if (!style)
6927
6929
  style = {};
6930
+ if (isMarkdownLink(text))
6931
+ text = parseMarkdownLink(text).label;
6928
6932
  const brokenText = [];
6929
6933
  // Checking if text contains NEWLINE before split makes it very slightly slower if text contains it,
6930
6934
  // but 5-10x faster if it doesn't
@@ -8765,6 +8769,10 @@
8765
8769
  if (groupValue === null || groupValue === "null") {
8766
8770
  return null;
8767
8771
  }
8772
+ const extractedGroupValue = typeof groupValue === "object" ? groupValue.value : groupValue;
8773
+ if (isEvaluationError(extractedGroupValue)) {
8774
+ return extractedGroupValue;
8775
+ }
8768
8776
  const groupValueString = typeof groupValue === "boolean"
8769
8777
  ? toString(groupValue).toLocaleLowerCase()
8770
8778
  : toString(groupValue);
@@ -27447,7 +27455,9 @@ stores.inject(MyMetaStore, storeInstance);
27447
27455
  }
27448
27456
  function getFormulaNumberValue(sheetId, formula, getters) {
27449
27457
  const value = getters.evaluateFormula(sheetId, formula);
27450
- return isMatrix(value) ? undefined : tryToNumber(value, getters.getLocale());
27458
+ return isMultipleElementMatrix(value)
27459
+ ? undefined
27460
+ : tryToNumber(toScalar(value), getters.getLocale());
27451
27461
  }
27452
27462
  function getInvalidGaugeRuntime(chart, getters) {
27453
27463
  return {
@@ -31072,6 +31082,9 @@ stores.inject(MyMetaStore, storeInstance);
31072
31082
  return undefined;
31073
31083
  }
31074
31084
  get errorOriginPositionString() {
31085
+ if (this.env.model.getters.isDashboard()) {
31086
+ return "";
31087
+ }
31075
31088
  const evaluationError = this.evaluationError;
31076
31089
  const position = evaluationError?.errorOriginPosition;
31077
31090
  if (!position || deepEquals(position, this.props.cellPosition)) {
@@ -39220,40 +39233,112 @@ stores.inject(MyMetaStore, storeInstance);
39220
39233
  * In all the sheets, replace the table-only references in the formula cells with standard references.
39221
39234
  */
39222
39235
  function convertTableFormulaReferences(convertedSheets, xlsxSheets) {
39236
+ let deconstructedSheets = null;
39223
39237
  for (const tableSheet of convertedSheets) {
39224
39238
  const tables = xlsxSheets.find((s) => isSheetNameEqual(s.sheetName, tableSheet.name)).tables;
39239
+ if (!tables || tables.length === 0) {
39240
+ continue;
39241
+ }
39242
+ // Only deconstruct sheets if we are sure there are tables to process
39243
+ if (!deconstructedSheets) {
39244
+ deconstructedSheets = deconstructSheets(convertedSheets);
39245
+ }
39225
39246
  for (const table of tables) {
39226
- const tabRef = table.name + "[";
39227
- for (const sheet of convertedSheets) {
39228
- for (const xc in sheet.cells) {
39229
- const cell = sheet.cells[xc];
39230
- let cellContent = sheet.cells[xc];
39231
- if (cell && cellContent && cellContent.startsWith("=")) {
39232
- let refIndex;
39233
- while ((refIndex = cellContent.indexOf(tabRef)) !== -1) {
39234
- let endIndex = refIndex + tabRef.length;
39235
- let openBrackets = 1;
39236
- while (openBrackets > 0 && endIndex < cellContent.length) {
39237
- if (cellContent[endIndex] === "[") {
39238
- openBrackets++;
39239
- }
39240
- else if (cellContent[endIndex] === "]") {
39241
- openBrackets--;
39242
- }
39243
- endIndex++;
39244
- }
39245
- const reference = cellContent.slice(refIndex + tabRef.length, endIndex - 1);
39246
- const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
39247
- const convertedRef = convertTableReference(sheetPrefix, reference, table, xc);
39248
- cellContent =
39249
- cellContent.slice(0, refIndex) + convertedRef + cellContent.slice(endIndex);
39247
+ for (const sheetId in deconstructedSheets) {
39248
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
39249
+ for (const xc in deconstructedSheets[sheetId]) {
39250
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
39251
+ for (let i = deconstructedCell.length - 3; i >= 0; i -= 2) {
39252
+ const possibleTable = deconstructedSheets[sheetId][xc][i];
39253
+ if (!possibleTable.endsWith(table.name)) {
39254
+ continue;
39250
39255
  }
39256
+ const possibleRef = deconstructedSheets[sheetId][xc][i + 1];
39257
+ const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
39258
+ const convertedRef = convertTableReference(sheetPrefix, possibleRef, table, xc);
39259
+ deconstructedSheets[sheetId][xc][i + 2] =
39260
+ possibleTable.slice(0, possibleTable.indexOf(table.name)) +
39261
+ convertedRef +
39262
+ deconstructedSheets[sheetId][xc][i + 2];
39263
+ deconstructedSheets[sheetId][xc].splice(i, 2);
39251
39264
  }
39252
- sheet.cells[xc] = cellContent;
39265
+ // sheet.cells[xc] = cellContent;
39253
39266
  }
39254
39267
  }
39255
39268
  }
39256
39269
  }
39270
+ if (!deconstructedSheets) {
39271
+ return;
39272
+ }
39273
+ for (const sheetId in deconstructedSheets) {
39274
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
39275
+ for (const xc in deconstructedSheets[sheetId]) {
39276
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
39277
+ if (deconstructedCell.length === 1) {
39278
+ sheet.cells[xc] = deconstructedCell[0];
39279
+ continue;
39280
+ }
39281
+ let newContent = "";
39282
+ for (let i = 0; i < deconstructedCell.length; i += 2) {
39283
+ newContent += deconstructedCell[i] + "[" + deconstructedCell[i + 1] + "]";
39284
+ }
39285
+ newContent += deconstructedCell[deconstructedCell.length - 1];
39286
+ sheet.cells[xc] = newContent;
39287
+ }
39288
+ }
39289
+ }
39290
+ /**
39291
+ * Deconstruct the content of the cells in the sheets to extract possible table references.
39292
+ * Example from "=AVERAGE(Table1[colName1])-AVERAGE(Table2[colName2])":
39293
+ * return --> ["=AVERAGE(Table1", "colName1", ")-AVERAGE(Table2", "colName2", ")"]
39294
+ */
39295
+ function deconstructSheets(convertedSheets) {
39296
+ const deconstructedSheets = {};
39297
+ for (const sheet of convertedSheets) {
39298
+ for (const xc in sheet.cells) {
39299
+ const cellContent = sheet.cells[xc];
39300
+ if (!cellContent || !cellContent.startsWith("=")) {
39301
+ continue;
39302
+ }
39303
+ const startIndex = cellContent.indexOf("[");
39304
+ if (startIndex === -1) {
39305
+ continue;
39306
+ }
39307
+ const deconstructedCell = [];
39308
+ let possibleTable = cellContent.slice(0, startIndex);
39309
+ let possibleRef = "";
39310
+ let openBrackets = 1;
39311
+ let mainPossibleTableIndex = 0;
39312
+ let mainOpenBracketIndex = startIndex;
39313
+ for (let index = startIndex + 1; index < cellContent.length; index++) {
39314
+ if (cellContent[index] === "[") {
39315
+ if (openBrackets === 0) {
39316
+ possibleTable = cellContent.slice(mainPossibleTableIndex, index);
39317
+ mainOpenBracketIndex = index;
39318
+ }
39319
+ openBrackets++;
39320
+ continue;
39321
+ }
39322
+ if (cellContent[index] === "]") {
39323
+ openBrackets--;
39324
+ if (openBrackets === 0) {
39325
+ possibleRef = cellContent.slice(mainOpenBracketIndex + 1, index);
39326
+ deconstructedCell.push(possibleTable);
39327
+ deconstructedCell.push(possibleRef);
39328
+ mainPossibleTableIndex = index + 1;
39329
+ }
39330
+ }
39331
+ }
39332
+ if (deconstructedCell.length) {
39333
+ if (!deconstructedSheets[sheet.id]) {
39334
+ deconstructedSheets[sheet.id] = {};
39335
+ }
39336
+ deconstructedCell.push(cellContent.slice(mainPossibleTableIndex));
39337
+ deconstructedSheets[sheet.id][xc] = [...deconstructedCell];
39338
+ }
39339
+ }
39340
+ }
39341
+ return deconstructedSheets;
39257
39342
  }
39258
39343
  /**
39259
39344
  * Convert table-specific references in formulas into standard references. A table reference is composed of columns names,
@@ -45565,10 +45650,10 @@ stores.inject(MyMetaStore, storeInstance);
45565
45650
  const cellValue = isFormula(content)
45566
45651
  ? this.getters.evaluateFormula(this.sheetId, content)
45567
45652
  : parseLiteral(content, this.getters.getLocale());
45568
- if (isMatrix(cellValue)) {
45653
+ if (isMultipleElementMatrix(cellValue)) {
45569
45654
  return true;
45570
45655
  }
45571
- const validationResult = this.getters.getValidationResultForCellValue(cellValue, cellPosition);
45656
+ const validationResult = this.getters.getValidationResultForCellValue(toScalar(cellValue), cellPosition);
45572
45657
  if (!validationResult.isValid && validationResult.rule.isBlocking) {
45573
45658
  return false;
45574
45659
  }
@@ -50680,10 +50765,10 @@ stores.inject(MyMetaStore, storeInstance);
50680
50765
  return tryToNumber(value, locale) !== undefined;
50681
50766
  }
50682
50767
  const evaluatedValue = this.env.model.getters.evaluateFormula(this.sheetId, value);
50683
- if (isMatrix(evaluatedValue)) {
50768
+ if (isMultipleElementMatrix(evaluatedValue)) {
50684
50769
  return false;
50685
50770
  }
50686
- return tryToNumber(evaluatedValue, locale) !== undefined;
50771
+ return tryToNumber(toScalar(evaluatedValue), locale) !== undefined;
50687
50772
  }
50688
50773
  get sheetId() {
50689
50774
  const chart = this.env.model.getters.getChart(this.props.figureId);
@@ -51537,12 +51622,32 @@ stores.inject(MyMetaStore, storeInstance);
51537
51622
  static template = "o-spreadsheet-ChartPanel";
51538
51623
  static components = { Section, ChartTypePicker };
51539
51624
  static props = { onCloseSidePanel: Function, figureId: String };
51625
+ panelContentRef;
51626
+ scrollPositions = {
51627
+ configuration: 0,
51628
+ design: 0,
51629
+ };
51540
51630
  store;
51541
51631
  get figureId() {
51542
51632
  return this.props.figureId;
51543
51633
  }
51544
51634
  setup() {
51545
51635
  this.store = useLocalStore(MainChartPanelStore);
51636
+ this.panelContentRef = owl.useRef("panelContent");
51637
+ owl.useEffect(() => {
51638
+ const el = this.panelContentRef.el;
51639
+ const activePanel = this.store.panel;
51640
+ if (el) {
51641
+ el.scrollTop = this.scrollPositions[activePanel];
51642
+ }
51643
+ }, () => [this.store.panel]);
51644
+ }
51645
+ switchPanel(panel) {
51646
+ const el = this.panelContentRef.el;
51647
+ if (el) {
51648
+ this.scrollPositions[this.store.panel] = el.scrollTop;
51649
+ }
51650
+ this.store.activatePanel(panel);
51546
51651
  }
51547
51652
  updateChart(figureId, updateDefinition) {
51548
51653
  if (figureId !== this.figureId) {
@@ -55494,10 +55599,7 @@ stores.inject(MyMetaStore, storeInstance);
55494
55599
  if (finalCell.value === null) {
55495
55600
  return { value: _t("(Undefined)") };
55496
55601
  }
55497
- return {
55498
- value: finalCell.value,
55499
- format: finalCell.format,
55500
- };
55602
+ return finalCell;
55501
55603
  }
55502
55604
  getPivotCellValueAndFormat(measureId, domain) {
55503
55605
  const dataEntries = this.filterDataEntriesFromDomain(this.dataEntries, domain);
@@ -55735,7 +55837,6 @@ stores.inject(MyMetaStore, storeInstance);
55735
55837
  ui: SpreadsheetPivot,
55736
55838
  definition: SpreadsheetPivotRuntimeDefinition,
55737
55839
  externalData: false,
55738
- onIterationEndEvaluation: (pivot) => pivot.markAsDirtyForEvaluation(),
55739
55840
  dateGranularities: [...dateGranularities],
55740
55841
  datetimeGranularities: [...dateGranularities, "hour_number", "minute_number", "second_number"],
55741
55842
  isMeasureCandidate: (field) => field.type !== "boolean",
@@ -64386,7 +64487,7 @@ stores.inject(MyMetaStore, storeInstance);
64386
64487
  onIterationEndEvaluationRegistry.add("pivots", (getters) => {
64387
64488
  for (const pivotId of getters.getPivotIds()) {
64388
64489
  const pivot = getters.getPivot(pivotId);
64389
- pivotRegistry.get(pivot.type).onIterationEndEvaluation(pivot);
64490
+ pivot.markAsDirtyForEvaluation?.();
64390
64491
  }
64391
64492
  });
64392
64493
 
@@ -66850,12 +66951,12 @@ stores.inject(MyMetaStore, storeInstance);
66850
66951
  }
66851
66952
  return this.getters.evaluateFormula(sheetId, value) ?? "";
66852
66953
  });
66853
- if (evaluatedCriterionValues.some(isMatrix)) {
66954
+ if (evaluatedCriterionValues.some(isMultipleElementMatrix)) {
66854
66955
  return false;
66855
66956
  }
66856
66957
  const evaluatedCriterion = {
66857
66958
  type: rule.operator,
66858
- values: evaluatedCriterionValues,
66959
+ values: evaluatedCriterionValues.map(toScalar),
66859
66960
  };
66860
66961
  return evaluator.isValueValid(cell.value ?? "", evaluatedCriterion, this.getters, sheetId);
66861
66962
  }
@@ -67015,10 +67116,10 @@ stores.inject(MyMetaStore, storeInstance);
67015
67116
  const evaluator = criterionEvaluatorRegistry.get(criterion.type);
67016
67117
  const offset = this.getCellOffsetInRule(cellPosition, rule);
67017
67118
  const evaluatedCriterionValues = this.getEvaluatedCriterionValues(sheetId, offset, criterion);
67018
- if (evaluatedCriterionValues.some(isMatrix)) {
67119
+ if (evaluatedCriterionValues.some(isMultipleElementMatrix)) {
67019
67120
  return undefined;
67020
67121
  }
67021
- const evaluatedCriterion = { ...criterion, values: evaluatedCriterionValues };
67122
+ const evaluatedCriterion = { ...criterion, values: evaluatedCriterionValues.map(toScalar) };
67022
67123
  if (evaluator.isValueValid(cellValue, evaluatedCriterion, this.getters, sheetId)) {
67023
67124
  return undefined;
67024
67125
  }
@@ -67661,13 +67762,13 @@ stores.inject(MyMetaStore, storeInstance);
67661
67762
  super(custom, params);
67662
67763
  this.getters = params.getters;
67663
67764
  }
67664
- init(params) {
67765
+ markAsDirtyForEvaluation() {
67665
67766
  this.cache = {};
67666
67767
  this.rankAsc = {};
67667
67768
  this.rankDesc = {};
67668
67769
  this.runningTotal = {};
67669
67770
  this.runningTotalInPercent = {};
67670
- super.init(params);
67771
+ super.markAsDirtyForEvaluation?.();
67671
67772
  }
67672
67773
  getPivotCellValueAndFormat(measureName, domain) {
67673
67774
  return this.getMeasureDisplayValue(measureName, domain);
@@ -67792,7 +67893,7 @@ stores.inject(MyMetaStore, storeInstance);
67792
67893
  return this.getSubTreeMatchingDomain(node.children, domain, domainLevel + 1);
67793
67894
  }
67794
67895
  }
67795
- return tree;
67896
+ return [];
67796
67897
  }
67797
67898
  treeToLeafDomains(tree, parentDomain = []) {
67798
67899
  const domains = [];
@@ -73531,12 +73632,12 @@ stores.inject(MyMetaStore, storeInstance);
73531
73632
  }
73532
73633
  return this.getters.evaluateFormula(sheetId, value) ?? "";
73533
73634
  });
73534
- if (evaluatedCriterionValues.some(isMatrix)) {
73635
+ if (evaluatedCriterionValues.some(isMultipleElementMatrix)) {
73535
73636
  continue;
73536
73637
  }
73537
73638
  const evaluatedCriterion = {
73538
73639
  type: filterValue.type,
73539
- values: evaluatedCriterionValues,
73640
+ values: evaluatedCriterionValues.map(toScalar),
73540
73641
  dateValue: filterValue.dateValue,
73541
73642
  };
73542
73643
  for (let row = filteredZone.top; row <= filteredZone.bottom; row++) {
@@ -84464,6 +84565,7 @@ stores.inject(MyMetaStore, storeInstance);
84464
84565
  PivotSidePanelStore,
84465
84566
  PivotMeasureDisplayPanelStore,
84466
84567
  ClientFocusStore,
84568
+ GridRenderer,
84467
84569
  };
84468
84570
  function addFunction(functionName, functionDescription) {
84469
84571
  functionRegistry.add(functionName, functionDescription);
@@ -84530,9 +84632,9 @@ stores.inject(MyMetaStore, storeInstance);
84530
84632
  exports.tokenize = tokenize;
84531
84633
 
84532
84634
 
84533
- __info__.version = "18.5.0-alpha.1";
84534
- __info__.date = "2025-06-27T09:12:49.245Z";
84535
- __info__.hash = "756e75b";
84635
+ __info__.version = "18.5.0-alpha.2";
84636
+ __info__.date = "2025-07-11T11:13:53.317Z";
84637
+ __info__.hash = "6d42178";
84536
84638
 
84537
84639
 
84538
84640
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);