@odoo/o-spreadsheet 18.1.23 → 18.1.24

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.1.23
6
- * @date 2025-05-30T08:45:44.408Z
7
- * @hash a21fa01
5
+ * @version 18.1.24
6
+ * @date 2025-06-06T09:31:57.011Z
7
+ * @hash 0e386b2
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -10207,8 +10207,6 @@ stores.inject(MyMetaStore, storeInstance);
10207
10207
  if (isNaN(value)) {
10208
10208
  continue;
10209
10209
  }
10210
- const axisId = chart.config.type === "radar" ? dataset.rAxisID : dataset.yAxisID;
10211
- const displayValue = options.callback(Number(value), axisId);
10212
10210
  const point = dataset.data[i];
10213
10211
  const xPosition = point.x;
10214
10212
  let yPosition = 0;
@@ -10232,7 +10230,8 @@ stores.inject(MyMetaStore, storeInstance);
10232
10230
  textsPositions[xPosition].push(yPosition);
10233
10231
  ctx.fillStyle = point.options.backgroundColor;
10234
10232
  ctx.strokeStyle = options.background || "#ffffff";
10235
- drawTextWithBackground(displayValue, xPosition, yPosition, ctx);
10233
+ const valueToDisplay = options.callback(Number(value), dataset, i);
10234
+ drawTextWithBackground(valueToDisplay, xPosition, yPosition, ctx);
10236
10235
  }
10237
10236
  }
10238
10237
  }
@@ -10249,7 +10248,7 @@ stores.inject(MyMetaStore, storeInstance);
10249
10248
  if (isNaN(value)) {
10250
10249
  continue;
10251
10250
  }
10252
- const displayValue = options.callback(value, dataset.xAxisID);
10251
+ const displayValue = options.callback(value, dataset, i);
10253
10252
  const point = dataset.data[i];
10254
10253
  const yPosition = point.y;
10255
10254
  let xPosition = value < 0 ? point.x + point.width / 2 : point.x - point.width / 2;
@@ -10287,7 +10286,7 @@ stores.inject(MyMetaStore, storeInstance);
10287
10286
  const y = bar.y + midRadius * Math.sin(midAngle) + 7;
10288
10287
  ctx.fillStyle = chartFontColor(options.background);
10289
10288
  ctx.strokeStyle = options.background || "#ffffff";
10290
- const displayValue = options.callback(value, "y");
10289
+ const displayValue = options.callback(value, dataset, i);
10291
10290
  drawTextWithBackground(displayValue, x, y, ctx);
10292
10291
  }
10293
10292
  }
@@ -30052,9 +30051,51 @@ stores.inject(MyMetaStore, storeInstance);
30052
30051
  horizontal: "horizontal" in definition && definition.horizontal,
30053
30052
  showValues: "showValues" in definition ? !!definition.showValues : false,
30054
30053
  background: definition.background,
30055
- callback: formatChartDatasetValue(axisFormats, locale),
30054
+ callback: (value, dataset) => {
30055
+ const axisId = getDatasetAxisId(definition, dataset);
30056
+ return formatChartDatasetValue(axisFormats, locale)(value, axisId);
30057
+ },
30056
30058
  };
30057
30059
  }
30060
+ function getPyramidChartShowValues(definition, args) {
30061
+ const { axisFormats, locale } = args;
30062
+ return {
30063
+ horizontal: true,
30064
+ showValues: "showValues" in definition ? !!definition.showValues : false,
30065
+ background: definition.background,
30066
+ callback: (value, dataset) => {
30067
+ value = Math.abs(Number(value));
30068
+ return formatChartDatasetValue(axisFormats, locale)(value, dataset.xAxisID || "x");
30069
+ },
30070
+ };
30071
+ }
30072
+ function getWaterfallChartShowValues(definition, args) {
30073
+ const { axisFormats, locale, dataSetsValues } = args;
30074
+ const subtotalIndexes = dataSetsValues.reduce((subtotalIndexes, ds) => {
30075
+ subtotalIndexes.push((subtotalIndexes.at(-1) || -1) + ds.data.length + 1);
30076
+ return subtotalIndexes;
30077
+ }, []);
30078
+ return {
30079
+ showValues: "showValues" in definition ? !!definition.showValues : false,
30080
+ background: definition.background,
30081
+ callback: (value, dataset, index) => {
30082
+ const raw = dataset._dataset.data[index];
30083
+ const delta = raw[1] - raw[0];
30084
+ let sign = delta >= 0 ? "+" : "";
30085
+ if (definition.showSubTotals && subtotalIndexes.includes(index) && sign === "+") {
30086
+ sign = "";
30087
+ }
30088
+ return `${sign}${formatChartDatasetValue(axisFormats, locale)(delta, dataset.yAxisID)}`;
30089
+ },
30090
+ };
30091
+ }
30092
+ function getDatasetAxisId(definition, dataset) {
30093
+ if (dataset.rAxisID) {
30094
+ return dataset.rAxisID;
30095
+ }
30096
+ const axisId = "horizontal" in definition && definition.horizontal ? dataset.xAxisID : dataset.yAxisID;
30097
+ return axisId || "y";
30098
+ }
30058
30099
 
30059
30100
  function getChartTitle(definition) {
30060
30101
  const chartTitle = definition.title;
@@ -30263,6 +30304,7 @@ stores.inject(MyMetaStore, storeInstance);
30263
30304
  getPieChartTooltip: getPieChartTooltip,
30264
30305
  getPyramidChartData: getPyramidChartData,
30265
30306
  getPyramidChartScales: getPyramidChartScales,
30307
+ getPyramidChartShowValues: getPyramidChartShowValues,
30266
30308
  getPyramidChartTooltip: getPyramidChartTooltip,
30267
30309
  getRadarChartData: getRadarChartData,
30268
30310
  getRadarChartDatasets: getRadarChartDatasets,
@@ -30276,6 +30318,7 @@ stores.inject(MyMetaStore, storeInstance);
30276
30318
  getTrendDatasetForLineChart: getTrendDatasetForLineChart,
30277
30319
  getWaterfallChartLegend: getWaterfallChartLegend,
30278
30320
  getWaterfallChartScales: getWaterfallChartScales,
30321
+ getWaterfallChartShowValues: getWaterfallChartShowValues,
30279
30322
  getWaterfallChartTooltip: getWaterfallChartTooltip,
30280
30323
  getWaterfallDatasetAndLabels: getWaterfallDatasetAndLabels
30281
30324
  });
@@ -31374,7 +31417,7 @@ stores.inject(MyMetaStore, storeInstance);
31374
31417
  title: getChartTitle(definition),
31375
31418
  legend: getBarChartLegend(definition),
31376
31419
  tooltip: getPyramidChartTooltip(definition, chartData),
31377
- chartShowValuesPlugin: getChartShowValues(definition, chartData),
31420
+ chartShowValuesPlugin: getPyramidChartShowValues(definition, chartData),
31378
31421
  },
31379
31422
  },
31380
31423
  };
@@ -31837,7 +31880,7 @@ stores.inject(MyMetaStore, storeInstance);
31837
31880
  title: getChartTitle(definition),
31838
31881
  legend: getWaterfallChartLegend(definition),
31839
31882
  tooltip: getWaterfallChartTooltip(definition, chartData),
31840
- chartShowValuesPlugin: getChartShowValues(definition, chartData),
31883
+ chartShowValuesPlugin: getWaterfallChartShowValues(definition, chartData),
31841
31884
  waterfallLinesPlugin: { showConnectorLines: definition.showConnectorLines },
31842
31885
  },
31843
31886
  },
@@ -44320,13 +44363,15 @@ stores.inject(MyMetaStore, storeInstance);
44320
44363
  if (this.selectedMatchIndex === null) {
44321
44364
  return;
44322
44365
  }
44366
+ this.preserveSelectedMatchIndex = true;
44367
+ this.shouldFinalizeUpdateSelection = true;
44323
44368
  this.model.dispatch("REPLACE_SEARCH", {
44324
44369
  searchString: this.toSearch,
44325
44370
  replaceWith: this.toReplace,
44326
44371
  matches: [this.searchMatches[this.selectedMatchIndex]],
44327
44372
  searchOptions: this.searchOptions,
44328
44373
  });
44329
- this.selectNextCell(Direction.next, { jumpToMatchSheet: true, updateSelection: true });
44374
+ this.preserveSelectedMatchIndex = false;
44330
44375
  }
44331
44376
  /**
44332
44377
  * Apply the replace function to all the matches one time.
@@ -51822,6 +51867,9 @@ stores.inject(MyMetaStore, storeInstance);
51822
51867
  let deltaX = lastX - clientX;
51823
51868
  let deltaY = lastY - clientY;
51824
51869
  const elapsedTime = currentTime - lastTime;
51870
+ if (!elapsedTime) {
51871
+ return;
51872
+ }
51825
51873
  velocityX = deltaX / elapsedTime;
51826
51874
  velocityY = deltaY / elapsedTime;
51827
51875
  lastX = clientX;
@@ -51842,6 +51890,11 @@ stores.inject(MyMetaStore, storeInstance);
51842
51890
  function onTouchEnd(ev) {
51843
51891
  isMouseDown = false;
51844
51892
  lastX = lastY = 0;
51893
+ if (resetTimeout) {
51894
+ clearTimeout(resetTimeout);
51895
+ }
51896
+ velocityX *= 1.2;
51897
+ velocityY *= 1.2;
51845
51898
  requestAnimationFrame(scroll);
51846
51899
  }
51847
51900
  function scroll() {
@@ -58943,7 +58996,7 @@ stores.inject(MyMetaStore, storeInstance);
58943
58996
  break;
58944
58997
  }
58945
58998
  case "UPDATE_PIVOT": {
58946
- this.history.update("pivots", cmd.pivotId, "definition", deepCopy(cmd.pivot));
58999
+ this.history.update("pivots", cmd.pivotId, "definition", this.repairSortedColumn(deepCopy(cmd.pivot)));
58947
59000
  this.compileCalculatedMeasures(cmd.pivot.measures);
58948
59001
  break;
58949
59002
  }
@@ -59014,7 +59067,10 @@ stores.inject(MyMetaStore, storeInstance);
59014
59067
  // Private
59015
59068
  // -------------------------------------------------------------------------
59016
59069
  addPivot(pivotId, pivot, formulaId = this.nextFormulaId.toString()) {
59017
- this.history.update("pivots", pivotId, { definition: deepCopy(pivot), formulaId });
59070
+ this.history.update("pivots", pivotId, {
59071
+ definition: this.repairSortedColumn(deepCopy(pivot)),
59072
+ formulaId,
59073
+ });
59018
59074
  this.compileCalculatedMeasures(pivot.measures);
59019
59075
  this.history.update("formulaIds", formulaId, pivotId);
59020
59076
  this.history.update("nextFormulaId", this.nextFormulaId + 1);
@@ -59107,6 +59163,26 @@ stores.inject(MyMetaStore, storeInstance);
59107
59163
  }
59108
59164
  return "Success" /* CommandResult.Success */;
59109
59165
  }
59166
+ repairSortedColumn(definition) {
59167
+ if (definition.sortedColumn) {
59168
+ // Fix for an upgrade issue: the sortedColumn measure was not updated
59169
+ // from using fieldName to using id. If the sortedColumn measure matches
59170
+ // a measure fieldName in the definition, update it to use the measure's id instead
59171
+ // of its fieldName.
59172
+ // TODO: add an upgrade step to fix this in master and remove this code
59173
+ const sortedMeasure = definition.measures.find((measure) => measure.fieldName === definition.sortedColumn?.measure);
59174
+ if (sortedMeasure) {
59175
+ return {
59176
+ ...definition,
59177
+ sortedColumn: {
59178
+ ...definition.sortedColumn,
59179
+ measure: sortedMeasure.id,
59180
+ },
59181
+ };
59182
+ }
59183
+ }
59184
+ return definition;
59185
+ }
59110
59186
  // ---------------------------------------------------------------------
59111
59187
  // Import/Export
59112
59188
  // ---------------------------------------------------------------------
@@ -68015,11 +68091,6 @@ stores.inject(MyMetaStore, storeInstance);
68015
68091
  },
68016
68092
  ];
68017
68093
  const sheetId = this.getActiveSheetId();
68018
- const handler = new CellClipboardHandler(this.getters, this.dispatch);
68019
- const data = handler.copy(getClipboardDataPositions(sheetId, target));
68020
- if (!data) {
68021
- return;
68022
- }
68023
68094
  const base = isBasedBefore ? cmd.base : cmd.base + 1;
68024
68095
  const pasteTarget = [
68025
68096
  {
@@ -68029,7 +68100,14 @@ stores.inject(MyMetaStore, storeInstance);
68029
68100
  bottom: !isCol ? base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
68030
68101
  },
68031
68102
  ];
68032
- handler.paste({ zones: pasteTarget, sheetId }, data, { isCutOperation: true });
68103
+ for (const Handler of clipboardHandlersRegistries.cellHandlers.getAll()) {
68104
+ const handler = new Handler(this.getters, this.dispatch);
68105
+ const data = handler.copy(getClipboardDataPositions(sheetId, target));
68106
+ if (!data) {
68107
+ continue;
68108
+ }
68109
+ handler.paste({ zones: pasteTarget, sheetId }, data, { isCutOperation: true });
68110
+ }
68033
68111
  const selection = pasteTarget[0];
68034
68112
  const col = selection.left;
68035
68113
  const row = selection.top;
@@ -76432,9 +76510,9 @@ stores.inject(MyMetaStore, storeInstance);
76432
76510
  exports.tokenize = tokenize;
76433
76511
 
76434
76512
 
76435
- __info__.version = "18.1.23";
76436
- __info__.date = "2025-05-30T08:45:44.408Z";
76437
- __info__.hash = "a21fa01";
76513
+ __info__.version = "18.1.24";
76514
+ __info__.date = "2025-06-06T09:31:57.011Z";
76515
+ __info__.hash = "0e386b2";
76438
76516
 
76439
76517
 
76440
76518
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);