@odoo/o-spreadsheet 18.2.15 → 18.2.16

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.15
6
- * @date 2025-05-30T08:45:53.952Z
7
- * @hash 607492d
5
+ * @version 18.2.16
6
+ * @date 2025-06-06T09:32:04.909Z
7
+ * @hash 7ee118c
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -10371,8 +10371,6 @@ stores.inject(MyMetaStore, storeInstance);
10371
10371
  if (isNaN(value)) {
10372
10372
  continue;
10373
10373
  }
10374
- const axisId = chart.config.type === "radar" ? dataset.rAxisID : dataset.yAxisID;
10375
- const displayValue = options.callback(Number(value), axisId);
10376
10374
  const point = dataset.data[i];
10377
10375
  const xPosition = point.x;
10378
10376
  let yPosition = 0;
@@ -10396,7 +10394,8 @@ stores.inject(MyMetaStore, storeInstance);
10396
10394
  textsPositions[xPosition].push(yPosition);
10397
10395
  ctx.fillStyle = point.options.backgroundColor;
10398
10396
  ctx.strokeStyle = options.background || "#ffffff";
10399
- drawTextWithBackground(displayValue, xPosition, yPosition, ctx);
10397
+ const valueToDisplay = options.callback(Number(value), dataset, i);
10398
+ drawTextWithBackground(valueToDisplay, xPosition, yPosition, ctx);
10400
10399
  }
10401
10400
  }
10402
10401
  }
@@ -10413,7 +10412,7 @@ stores.inject(MyMetaStore, storeInstance);
10413
10412
  if (isNaN(value)) {
10414
10413
  continue;
10415
10414
  }
10416
- const displayValue = options.callback(value, dataset.xAxisID);
10415
+ const displayValue = options.callback(value, dataset, i);
10417
10416
  const point = dataset.data[i];
10418
10417
  const yPosition = point.y;
10419
10418
  let xPosition = value < 0 ? point.x + point.width / 2 : point.x - point.width / 2;
@@ -10451,7 +10450,7 @@ stores.inject(MyMetaStore, storeInstance);
10451
10450
  const y = bar.y + midRadius * Math.sin(midAngle) + 7;
10452
10451
  ctx.fillStyle = chartFontColor(options.background);
10453
10452
  ctx.strokeStyle = options.background || "#ffffff";
10454
- const displayValue = options.callback(value, "y");
10453
+ const displayValue = options.callback(value, dataset, i);
10455
10454
  drawTextWithBackground(displayValue, x, y, ctx);
10456
10455
  }
10457
10456
  }
@@ -30084,9 +30083,51 @@ stores.inject(MyMetaStore, storeInstance);
30084
30083
  horizontal: "horizontal" in definition && definition.horizontal,
30085
30084
  showValues: "showValues" in definition ? !!definition.showValues : false,
30086
30085
  background: definition.background,
30087
- callback: formatChartDatasetValue(axisFormats, locale),
30086
+ callback: (value, dataset) => {
30087
+ const axisId = getDatasetAxisId(definition, dataset);
30088
+ return formatChartDatasetValue(axisFormats, locale)(value, axisId);
30089
+ },
30088
30090
  };
30089
30091
  }
30092
+ function getPyramidChartShowValues(definition, args) {
30093
+ const { axisFormats, locale } = args;
30094
+ return {
30095
+ horizontal: true,
30096
+ showValues: "showValues" in definition ? !!definition.showValues : false,
30097
+ background: definition.background,
30098
+ callback: (value, dataset) => {
30099
+ value = Math.abs(Number(value));
30100
+ return formatChartDatasetValue(axisFormats, locale)(value, dataset.xAxisID || "x");
30101
+ },
30102
+ };
30103
+ }
30104
+ function getWaterfallChartShowValues(definition, args) {
30105
+ const { axisFormats, locale, dataSetsValues } = args;
30106
+ const subtotalIndexes = dataSetsValues.reduce((subtotalIndexes, ds) => {
30107
+ subtotalIndexes.push((subtotalIndexes.at(-1) || -1) + ds.data.length + 1);
30108
+ return subtotalIndexes;
30109
+ }, []);
30110
+ return {
30111
+ showValues: "showValues" in definition ? !!definition.showValues : false,
30112
+ background: definition.background,
30113
+ callback: (value, dataset, index) => {
30114
+ const raw = dataset._dataset.data[index];
30115
+ const delta = raw[1] - raw[0];
30116
+ let sign = delta >= 0 ? "+" : "";
30117
+ if (definition.showSubTotals && subtotalIndexes.includes(index) && sign === "+") {
30118
+ sign = "";
30119
+ }
30120
+ return `${sign}${formatChartDatasetValue(axisFormats, locale)(delta, dataset.yAxisID)}`;
30121
+ },
30122
+ };
30123
+ }
30124
+ function getDatasetAxisId(definition, dataset) {
30125
+ if (dataset.rAxisID) {
30126
+ return dataset.rAxisID;
30127
+ }
30128
+ const axisId = "horizontal" in definition && definition.horizontal ? dataset.xAxisID : dataset.yAxisID;
30129
+ return axisId || "y";
30130
+ }
30090
30131
 
30091
30132
  function getChartTitle(definition) {
30092
30133
  const chartTitle = definition.title;
@@ -30410,6 +30451,7 @@ stores.inject(MyMetaStore, storeInstance);
30410
30451
  getPieChartTooltip: getPieChartTooltip,
30411
30452
  getPyramidChartData: getPyramidChartData,
30412
30453
  getPyramidChartScales: getPyramidChartScales,
30454
+ getPyramidChartShowValues: getPyramidChartShowValues,
30413
30455
  getPyramidChartTooltip: getPyramidChartTooltip,
30414
30456
  getRadarChartData: getRadarChartData,
30415
30457
  getRadarChartDatasets: getRadarChartDatasets,
@@ -30423,6 +30465,7 @@ stores.inject(MyMetaStore, storeInstance);
30423
30465
  getTrendDatasetForLineChart: getTrendDatasetForLineChart,
30424
30466
  getWaterfallChartLegend: getWaterfallChartLegend,
30425
30467
  getWaterfallChartScales: getWaterfallChartScales,
30468
+ getWaterfallChartShowValues: getWaterfallChartShowValues,
30426
30469
  getWaterfallChartTooltip: getWaterfallChartTooltip,
30427
30470
  getWaterfallDatasetAndLabels: getWaterfallDatasetAndLabels
30428
30471
  });
@@ -31555,7 +31598,7 @@ stores.inject(MyMetaStore, storeInstance);
31555
31598
  title: getChartTitle(definition),
31556
31599
  legend: getBarChartLegend(definition),
31557
31600
  tooltip: getPyramidChartTooltip(definition, chartData),
31558
- chartShowValuesPlugin: getChartShowValues(definition, chartData),
31601
+ chartShowValuesPlugin: getPyramidChartShowValues(definition, chartData),
31559
31602
  },
31560
31603
  },
31561
31604
  };
@@ -32018,7 +32061,7 @@ stores.inject(MyMetaStore, storeInstance);
32018
32061
  title: getChartTitle(definition),
32019
32062
  legend: getWaterfallChartLegend(definition),
32020
32063
  tooltip: getWaterfallChartTooltip(definition, chartData),
32021
- chartShowValuesPlugin: getChartShowValues(definition, chartData),
32064
+ chartShowValuesPlugin: getWaterfallChartShowValues(definition, chartData),
32022
32065
  waterfallLinesPlugin: { showConnectorLines: definition.showConnectorLines },
32023
32066
  },
32024
32067
  },
@@ -44664,13 +44707,15 @@ stores.inject(MyMetaStore, storeInstance);
44664
44707
  if (this.selectedMatchIndex === null) {
44665
44708
  return;
44666
44709
  }
44710
+ this.preserveSelectedMatchIndex = true;
44711
+ this.shouldFinalizeUpdateSelection = true;
44667
44712
  this.model.dispatch("REPLACE_SEARCH", {
44668
44713
  searchString: this.toSearch,
44669
44714
  replaceWith: this.toReplace,
44670
44715
  matches: [this.searchMatches[this.selectedMatchIndex]],
44671
44716
  searchOptions: this.searchOptions,
44672
44717
  });
44673
- this.selectNextCell(Direction.next, { jumpToMatchSheet: true, updateSelection: true });
44718
+ this.preserveSelectedMatchIndex = false;
44674
44719
  }
44675
44720
  /**
44676
44721
  * Apply the replace function to all the matches one time.
@@ -52271,6 +52316,9 @@ stores.inject(MyMetaStore, storeInstance);
52271
52316
  let deltaX = lastX - clientX;
52272
52317
  let deltaY = lastY - clientY;
52273
52318
  const elapsedTime = currentTime - lastTime;
52319
+ if (!elapsedTime) {
52320
+ return;
52321
+ }
52274
52322
  velocityX = deltaX / elapsedTime;
52275
52323
  velocityY = deltaY / elapsedTime;
52276
52324
  lastX = clientX;
@@ -52291,6 +52339,11 @@ stores.inject(MyMetaStore, storeInstance);
52291
52339
  function onTouchEnd(ev) {
52292
52340
  isMouseDown = false;
52293
52341
  lastX = lastY = 0;
52342
+ if (resetTimeout) {
52343
+ clearTimeout(resetTimeout);
52344
+ }
52345
+ velocityX *= 1.2;
52346
+ velocityY *= 1.2;
52294
52347
  requestAnimationFrame(scroll);
52295
52348
  }
52296
52349
  function scroll() {
@@ -59431,7 +59484,7 @@ stores.inject(MyMetaStore, storeInstance);
59431
59484
  break;
59432
59485
  }
59433
59486
  case "UPDATE_PIVOT": {
59434
- this.history.update("pivots", cmd.pivotId, "definition", deepCopy(cmd.pivot));
59487
+ this.history.update("pivots", cmd.pivotId, "definition", this.repairSortedColumn(deepCopy(cmd.pivot)));
59435
59488
  this.compileCalculatedMeasures(cmd.pivot.measures);
59436
59489
  break;
59437
59490
  }
@@ -59502,7 +59555,10 @@ stores.inject(MyMetaStore, storeInstance);
59502
59555
  // Private
59503
59556
  // -------------------------------------------------------------------------
59504
59557
  addPivot(pivotId, pivot, formulaId = this.nextFormulaId.toString()) {
59505
- this.history.update("pivots", pivotId, { definition: deepCopy(pivot), formulaId });
59558
+ this.history.update("pivots", pivotId, {
59559
+ definition: this.repairSortedColumn(deepCopy(pivot)),
59560
+ formulaId,
59561
+ });
59506
59562
  this.compileCalculatedMeasures(pivot.measures);
59507
59563
  this.history.update("formulaIds", formulaId, pivotId);
59508
59564
  this.history.update("nextFormulaId", this.nextFormulaId + 1);
@@ -59595,6 +59651,26 @@ stores.inject(MyMetaStore, storeInstance);
59595
59651
  }
59596
59652
  return "Success" /* CommandResult.Success */;
59597
59653
  }
59654
+ repairSortedColumn(definition) {
59655
+ if (definition.sortedColumn) {
59656
+ // Fix for an upgrade issue: the sortedColumn measure was not updated
59657
+ // from using fieldName to using id. If the sortedColumn measure matches
59658
+ // a measure fieldName in the definition, update it to use the measure's id instead
59659
+ // of its fieldName.
59660
+ // TODO: add an upgrade step to fix this in master and remove this code
59661
+ const sortedMeasure = definition.measures.find((measure) => measure.fieldName === definition.sortedColumn?.measure);
59662
+ if (sortedMeasure) {
59663
+ return {
59664
+ ...definition,
59665
+ sortedColumn: {
59666
+ ...definition.sortedColumn,
59667
+ measure: sortedMeasure.id,
59668
+ },
59669
+ };
59670
+ }
59671
+ }
59672
+ return definition;
59673
+ }
59598
59674
  // ---------------------------------------------------------------------
59599
59675
  // Import/Export
59600
59676
  // ---------------------------------------------------------------------
@@ -68506,11 +68582,6 @@ stores.inject(MyMetaStore, storeInstance);
68506
68582
  },
68507
68583
  ];
68508
68584
  const sheetId = this.getActiveSheetId();
68509
- const handler = new CellClipboardHandler(this.getters, this.dispatch);
68510
- const data = handler.copy(getClipboardDataPositions(sheetId, target));
68511
- if (!data) {
68512
- return;
68513
- }
68514
68585
  const base = isBasedBefore ? cmd.base : cmd.base + 1;
68515
68586
  const pasteTarget = [
68516
68587
  {
@@ -68520,7 +68591,14 @@ stores.inject(MyMetaStore, storeInstance);
68520
68591
  bottom: !isCol ? base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
68521
68592
  },
68522
68593
  ];
68523
- handler.paste({ zones: pasteTarget, sheetId }, data, { isCutOperation: true });
68594
+ for (const Handler of clipboardHandlersRegistries.cellHandlers.getAll()) {
68595
+ const handler = new Handler(this.getters, this.dispatch);
68596
+ const data = handler.copy(getClipboardDataPositions(sheetId, target));
68597
+ if (!data) {
68598
+ continue;
68599
+ }
68600
+ handler.paste({ zones: pasteTarget, sheetId }, data, { isCutOperation: true });
68601
+ }
68524
68602
  const selection = pasteTarget[0];
68525
68603
  const col = selection.left;
68526
68604
  const row = selection.top;
@@ -76910,9 +76988,9 @@ stores.inject(MyMetaStore, storeInstance);
76910
76988
  exports.tokenize = tokenize;
76911
76989
 
76912
76990
 
76913
- __info__.version = "18.2.15";
76914
- __info__.date = "2025-05-30T08:45:53.952Z";
76915
- __info__.hash = "607492d";
76991
+ __info__.version = "18.2.16";
76992
+ __info__.date = "2025-06-06T09:32:04.909Z";
76993
+ __info__.hash = "7ee118c";
76916
76994
 
76917
76995
 
76918
76996
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);