@odoo/o-spreadsheet 18.3.6 → 18.3.7

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.3.6
6
- * @date 2025-05-30T08:46:25.817Z
7
- * @hash afa4379
5
+ * @version 18.3.7
6
+ * @date 2025-06-06T09:31:27.123Z
7
+ * @hash 05333f1
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -20956,8 +20956,6 @@ stores.inject(MyMetaStore, storeInstance);
20956
20956
  if (isNaN(value)) {
20957
20957
  continue;
20958
20958
  }
20959
- const axisId = chart.config.type === "radar" ? dataset.rAxisID : dataset.yAxisID;
20960
- const displayValue = options.callback(Number(value), axisId);
20961
20959
  const point = dataset.data[i];
20962
20960
  const xPosition = point.x;
20963
20961
  let yPosition = 0;
@@ -20981,7 +20979,8 @@ stores.inject(MyMetaStore, storeInstance);
20981
20979
  textsPositions[xPosition].push(yPosition);
20982
20980
  ctx.fillStyle = point.options.backgroundColor;
20983
20981
  ctx.strokeStyle = options.background || "#ffffff";
20984
- drawTextWithBackground(displayValue, xPosition, yPosition, ctx);
20982
+ const valueToDisplay = options.callback(Number(value), dataset, i);
20983
+ drawTextWithBackground(valueToDisplay, xPosition, yPosition, ctx);
20985
20984
  }
20986
20985
  }
20987
20986
  }
@@ -20998,7 +20997,7 @@ stores.inject(MyMetaStore, storeInstance);
20998
20997
  if (isNaN(value)) {
20999
20998
  continue;
21000
20999
  }
21001
- const displayValue = options.callback(value, dataset.xAxisID);
21000
+ const displayValue = options.callback(value, dataset, i);
21002
21001
  const point = dataset.data[i];
21003
21002
  const yPosition = point.y;
21004
21003
  let xPosition = value < 0 ? point.x + point.width / 2 : point.x - point.width / 2;
@@ -21036,7 +21035,7 @@ stores.inject(MyMetaStore, storeInstance);
21036
21035
  const y = bar.y + midRadius * Math.sin(midAngle) + 7;
21037
21036
  ctx.fillStyle = chartFontColor(options.background);
21038
21037
  ctx.strokeStyle = options.background || "#ffffff";
21039
- const displayValue = options.callback(value, "y");
21038
+ const displayValue = options.callback(value, dataset, i);
21040
21039
  drawTextWithBackground(displayValue, x, y, ctx);
21041
21040
  }
21042
21041
  }
@@ -26357,7 +26356,10 @@ stores.inject(MyMetaStore, storeInstance);
26357
26356
  horizontal: "horizontal" in definition && definition.horizontal,
26358
26357
  showValues: "showValues" in definition ? !!definition.showValues : false,
26359
26358
  background: definition.background,
26360
- callback: formatChartDatasetValue(axisFormats, locale),
26359
+ callback: (value, dataset) => {
26360
+ const axisId = getDatasetAxisId(definition, dataset);
26361
+ return formatChartDatasetValue(axisFormats, locale)(value, axisId);
26362
+ },
26361
26363
  };
26362
26364
  }
26363
26365
  function getSunburstShowValues(definition, args) {
@@ -26375,6 +26377,45 @@ stores.inject(MyMetaStore, storeInstance);
26375
26377
  },
26376
26378
  };
26377
26379
  }
26380
+ function getPyramidChartShowValues(definition, args) {
26381
+ const { axisFormats, locale } = args;
26382
+ return {
26383
+ horizontal: true,
26384
+ showValues: "showValues" in definition ? !!definition.showValues : false,
26385
+ background: definition.background,
26386
+ callback: (value, dataset) => {
26387
+ value = Math.abs(Number(value));
26388
+ return formatChartDatasetValue(axisFormats, locale)(value, dataset.xAxisID || "x");
26389
+ },
26390
+ };
26391
+ }
26392
+ function getWaterfallChartShowValues(definition, args) {
26393
+ const { axisFormats, locale, dataSetsValues } = args;
26394
+ const subtotalIndexes = dataSetsValues.reduce((subtotalIndexes, ds) => {
26395
+ subtotalIndexes.push((subtotalIndexes.at(-1) || -1) + ds.data.length + 1);
26396
+ return subtotalIndexes;
26397
+ }, []);
26398
+ return {
26399
+ showValues: "showValues" in definition ? !!definition.showValues : false,
26400
+ background: definition.background,
26401
+ callback: (value, dataset, index) => {
26402
+ const raw = dataset._dataset.data[index];
26403
+ const delta = raw[1] - raw[0];
26404
+ let sign = delta >= 0 ? "+" : "";
26405
+ if (definition.showSubTotals && subtotalIndexes.includes(index) && sign === "+") {
26406
+ sign = "";
26407
+ }
26408
+ return `${sign}${formatChartDatasetValue(axisFormats, locale)(delta, dataset.yAxisID)}`;
26409
+ },
26410
+ };
26411
+ }
26412
+ function getDatasetAxisId(definition, dataset) {
26413
+ if (dataset.rAxisID) {
26414
+ return dataset.rAxisID;
26415
+ }
26416
+ const axisId = "horizontal" in definition && definition.horizontal ? dataset.xAxisID : dataset.yAxisID;
26417
+ return axisId || "y";
26418
+ }
26378
26419
 
26379
26420
  function getChartTitle(definition) {
26380
26421
  const chartTitle = definition.title;
@@ -26777,6 +26818,7 @@ stores.inject(MyMetaStore, storeInstance);
26777
26818
  getPieChartTooltip: getPieChartTooltip,
26778
26819
  getPyramidChartData: getPyramidChartData,
26779
26820
  getPyramidChartScales: getPyramidChartScales,
26821
+ getPyramidChartShowValues: getPyramidChartShowValues,
26780
26822
  getPyramidChartTooltip: getPyramidChartTooltip,
26781
26823
  getRadarChartData: getRadarChartData,
26782
26824
  getRadarChartDatasets: getRadarChartDatasets,
@@ -26796,6 +26838,7 @@ stores.inject(MyMetaStore, storeInstance);
26796
26838
  getTrendDatasetForLineChart: getTrendDatasetForLineChart,
26797
26839
  getWaterfallChartLegend: getWaterfallChartLegend,
26798
26840
  getWaterfallChartScales: getWaterfallChartScales,
26841
+ getWaterfallChartShowValues: getWaterfallChartShowValues,
26799
26842
  getWaterfallChartTooltip: getWaterfallChartTooltip,
26800
26843
  getWaterfallDatasetAndLabels: getWaterfallDatasetAndLabels,
26801
26844
  makeDatasetsCumulative: makeDatasetsCumulative
@@ -28075,7 +28118,7 @@ stores.inject(MyMetaStore, storeInstance);
28075
28118
  title: getChartTitle(definition),
28076
28119
  legend: getBarChartLegend(definition),
28077
28120
  tooltip: getPyramidChartTooltip(definition, chartData),
28078
- chartShowValuesPlugin: getChartShowValues(definition, chartData),
28121
+ chartShowValuesPlugin: getPyramidChartShowValues(definition, chartData),
28079
28122
  },
28080
28123
  },
28081
28124
  };
@@ -28816,7 +28859,7 @@ stores.inject(MyMetaStore, storeInstance);
28816
28859
  title: getChartTitle(definition),
28817
28860
  legend: getWaterfallChartLegend(definition),
28818
28861
  tooltip: getWaterfallChartTooltip(definition, chartData),
28819
- chartShowValuesPlugin: getChartShowValues(definition, chartData),
28862
+ chartShowValuesPlugin: getWaterfallChartShowValues(definition, chartData),
28820
28863
  waterfallLinesPlugin: { showConnectorLines: definition.showConnectorLines },
28821
28864
  },
28822
28865
  },
@@ -47368,13 +47411,15 @@ stores.inject(MyMetaStore, storeInstance);
47368
47411
  if (this.selectedMatchIndex === null) {
47369
47412
  return;
47370
47413
  }
47414
+ this.preserveSelectedMatchIndex = true;
47415
+ this.shouldFinalizeUpdateSelection = true;
47371
47416
  this.model.dispatch("REPLACE_SEARCH", {
47372
47417
  searchString: this.toSearch,
47373
47418
  replaceWith: this.toReplace,
47374
47419
  matches: [this.searchMatches[this.selectedMatchIndex]],
47375
47420
  searchOptions: this.searchOptions,
47376
47421
  });
47377
- this.selectNextCell(Direction.next, { jumpToMatchSheet: true, updateSelection: true });
47422
+ this.preserveSelectedMatchIndex = false;
47378
47423
  }
47379
47424
  /**
47380
47425
  * Apply the replace function to all the matches one time.
@@ -53530,7 +53575,7 @@ stores.inject(MyMetaStore, storeInstance);
53530
53575
  }
53531
53576
  }
53532
53577
  hover(position) {
53533
- if (position.col === this.col && position.row === this.row) {
53578
+ if (!this.getters.isDashboard() || (position.col === this.col && position.row === this.row)) {
53534
53579
  return "noStateChange";
53535
53580
  }
53536
53581
  this.col = position.col;
@@ -55206,6 +55251,9 @@ stores.inject(MyMetaStore, storeInstance);
55206
55251
  let deltaX = lastX - clientX;
55207
55252
  let deltaY = lastY - clientY;
55208
55253
  const elapsedTime = currentTime - lastTime;
55254
+ if (!elapsedTime) {
55255
+ return;
55256
+ }
55209
55257
  velocityX = deltaX / elapsedTime;
55210
55258
  velocityY = deltaY / elapsedTime;
55211
55259
  lastX = clientX;
@@ -55226,6 +55274,11 @@ stores.inject(MyMetaStore, storeInstance);
55226
55274
  function onTouchEnd(ev) {
55227
55275
  isMouseDown = false;
55228
55276
  lastX = lastY = 0;
55277
+ if (resetTimeout) {
55278
+ clearTimeout(resetTimeout);
55279
+ }
55280
+ velocityX *= 1.2;
55281
+ velocityY *= 1.2;
55229
55282
  requestAnimationFrame(scroll);
55230
55283
  }
55231
55284
  function scroll() {
@@ -62316,7 +62369,7 @@ stores.inject(MyMetaStore, storeInstance);
62316
62369
  break;
62317
62370
  }
62318
62371
  case "UPDATE_PIVOT": {
62319
- this.history.update("pivots", cmd.pivotId, "definition", deepCopy(cmd.pivot));
62372
+ this.history.update("pivots", cmd.pivotId, "definition", this.repairSortedColumn(deepCopy(cmd.pivot)));
62320
62373
  this.compileCalculatedMeasures(cmd.pivot.measures);
62321
62374
  break;
62322
62375
  }
@@ -62387,7 +62440,10 @@ stores.inject(MyMetaStore, storeInstance);
62387
62440
  // Private
62388
62441
  // -------------------------------------------------------------------------
62389
62442
  addPivot(pivotId, pivot, formulaId = this.nextFormulaId.toString()) {
62390
- this.history.update("pivots", pivotId, { definition: deepCopy(pivot), formulaId });
62443
+ this.history.update("pivots", pivotId, {
62444
+ definition: this.repairSortedColumn(deepCopy(pivot)),
62445
+ formulaId,
62446
+ });
62391
62447
  this.compileCalculatedMeasures(pivot.measures);
62392
62448
  this.history.update("formulaIds", formulaId, pivotId);
62393
62449
  this.history.update("nextFormulaId", this.nextFormulaId + 1);
@@ -62476,6 +62532,7 @@ stores.inject(MyMetaStore, storeInstance);
62476
62532
  }
62477
62533
  }
62478
62534
  checkSortedColumnInMeasures(definition) {
62535
+ definition = this.repairSortedColumn(definition);
62479
62536
  const measures = definition.measures.map((measure) => measure.id);
62480
62537
  if (definition.sortedColumn && !measures.includes(definition.sortedColumn.measure)) {
62481
62538
  return "InvalidDefinition" /* CommandResult.InvalidDefinition */;
@@ -62489,6 +62546,26 @@ stores.inject(MyMetaStore, storeInstance);
62489
62546
  }
62490
62547
  return "Success" /* CommandResult.Success */;
62491
62548
  }
62549
+ repairSortedColumn(definition) {
62550
+ if (definition.sortedColumn) {
62551
+ // Fix for an upgrade issue: the sortedColumn measure was not updated
62552
+ // from using fieldName to using id. If the sortedColumn measure matches
62553
+ // a measure fieldName in the definition, update it to use the measure's id instead
62554
+ // of its fieldName.
62555
+ // TODO: add an upgrade step to fix this in master and remove this code
62556
+ const sortedMeasure = definition.measures.find((measure) => measure.fieldName === definition.sortedColumn?.measure);
62557
+ if (sortedMeasure) {
62558
+ return {
62559
+ ...definition,
62560
+ sortedColumn: {
62561
+ ...definition.sortedColumn,
62562
+ measure: sortedMeasure.id,
62563
+ },
62564
+ };
62565
+ }
62566
+ }
62567
+ return definition;
62568
+ }
62492
62569
  // ---------------------------------------------------------------------
62493
62570
  // Import/Export
62494
62571
  // ---------------------------------------------------------------------
@@ -71648,11 +71725,6 @@ stores.inject(MyMetaStore, storeInstance);
71648
71725
  },
71649
71726
  ];
71650
71727
  const sheetId = this.getActiveSheetId();
71651
- const handler = new CellClipboardHandler(this.getters, this.dispatch);
71652
- const data = handler.copy(getClipboardDataPositions(sheetId, target));
71653
- if (!data) {
71654
- return;
71655
- }
71656
71728
  const base = isBasedBefore ? cmd.base : cmd.base + 1;
71657
71729
  const pasteTarget = [
71658
71730
  {
@@ -71662,7 +71734,14 @@ stores.inject(MyMetaStore, storeInstance);
71662
71734
  bottom: !isCol ? base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
71663
71735
  },
71664
71736
  ];
71665
- handler.paste({ zones: pasteTarget, sheetId }, data, { isCutOperation: true });
71737
+ for (const Handler of clipboardHandlersRegistries.cellHandlers.getAll()) {
71738
+ const handler = new Handler(this.getters, this.dispatch);
71739
+ const data = handler.copy(getClipboardDataPositions(sheetId, target));
71740
+ if (!data) {
71741
+ continue;
71742
+ }
71743
+ handler.paste({ zones: pasteTarget, sheetId }, data, { isCutOperation: true });
71744
+ }
71666
71745
  const selection = pasteTarget[0];
71667
71746
  const col = selection.left;
71668
71747
  const row = selection.top;
@@ -80562,9 +80641,9 @@ stores.inject(MyMetaStore, storeInstance);
80562
80641
  exports.tokenize = tokenize;
80563
80642
 
80564
80643
 
80565
- __info__.version = "18.3.6";
80566
- __info__.date = "2025-05-30T08:46:25.817Z";
80567
- __info__.hash = "afa4379";
80644
+ __info__.version = "18.3.7";
80645
+ __info__.date = "2025-06-06T09:31:27.123Z";
80646
+ __info__.hash = "05333f1";
80568
80647
 
80569
80648
 
80570
80649
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);