@odoo/o-spreadsheet 18.1.16 → 18.1.18

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.16
6
- * @date 2025-04-18T16:24:16.854Z
7
- * @hash 19f6de2
5
+ * @version 18.1.18
6
+ * @date 2025-05-02T12:30:47.822Z
7
+ * @hash 29c21c6
8
8
  */
9
9
 
10
10
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, useState, onPatched, onWillPatch, onWillUpdateProps, useExternalListener, onWillStart, xml, useChildSubEnv, markRaw, toRaw } from '@odoo/owl';
@@ -3760,6 +3760,7 @@ var CommandResult;
3760
3760
  CommandResult["ValueCellIsInvalidFormula"] = "ValueCellIsInvalidFormula";
3761
3761
  CommandResult["InvalidDefinition"] = "InvalidDefinition";
3762
3762
  CommandResult["InvalidColor"] = "InvalidColor";
3763
+ CommandResult["InvalidPivotDataSet"] = "InvalidPivotDataSet";
3763
3764
  })(CommandResult || (CommandResult = {}));
3764
3765
 
3765
3766
  const DEFAULT_LOCALES = [
@@ -3832,11 +3833,13 @@ const CellErrorType = {
3832
3833
  NullError: "#NULL!",
3833
3834
  };
3834
3835
  const errorTypes = new Set(Object.values(CellErrorType));
3835
- class EvaluationError extends Error {
3836
+ class EvaluationError {
3837
+ message;
3836
3838
  value;
3837
3839
  constructor(message = _t("Error"), value = CellErrorType.GenericError) {
3838
- super(message);
3840
+ this.message = message;
3839
3841
  this.value = value;
3842
+ this.message = message.toString();
3840
3843
  }
3841
3844
  }
3842
3845
  class BadExpressionError extends EvaluationError {
@@ -10005,7 +10008,7 @@ function drawLineOrBarOrRadarChartValues(chart, options, ctx) {
10005
10008
  const yMin = chart.chartArea.top;
10006
10009
  const textsPositions = {};
10007
10010
  for (const dataset of chart._metasets) {
10008
- if (isTrendLineAxis(dataset.axisID) || dataset.hidden) {
10011
+ if (isTrendLineAxis(dataset.xAxisID) || dataset.hidden) {
10009
10012
  continue;
10010
10013
  }
10011
10014
  for (let i = 0; i < dataset._parsed.length; i++) {
@@ -10048,7 +10051,7 @@ function drawHorizontalBarChartValues(chart, options, ctx) {
10048
10051
  const xMin = chart.chartArea.left;
10049
10052
  const textsPositions = {};
10050
10053
  for (const dataset of chart._metasets) {
10051
- if (isTrendLineAxis(dataset.axisID)) {
10054
+ if (isTrendLineAxis(dataset.xAxisID)) {
10052
10055
  return; // ignore trend lines
10053
10056
  }
10054
10057
  for (let i = 0; i < dataset._parsed.length; i++) {
@@ -10164,6 +10167,7 @@ class ChartJsComponent extends Component {
10164
10167
  canvas = useRef("graphContainer");
10165
10168
  chart;
10166
10169
  currentRuntime;
10170
+ currentDevicePixelRatio = window.devicePixelRatio;
10167
10171
  get background() {
10168
10172
  return this.chartRuntime.background;
10169
10173
  }
@@ -10197,6 +10201,10 @@ class ChartJsComponent extends Component {
10197
10201
  }
10198
10202
  this.currentRuntime = runtime;
10199
10203
  }
10204
+ else if (this.currentDevicePixelRatio !== window.devicePixelRatio) {
10205
+ this.currentDevicePixelRatio = window.devicePixelRatio;
10206
+ this.updateChartJs(deepCopy(this.currentRuntime.chartJsConfig));
10207
+ }
10200
10208
  });
10201
10209
  }
10202
10210
  createChart(chartData) {
@@ -10452,9 +10460,11 @@ let ScorecardChart$1 = class ScorecardChart extends AbstractChart {
10452
10460
  };
10453
10461
  function drawScoreChart(structure, canvas) {
10454
10462
  const ctx = canvas.getContext("2d");
10455
- canvas.width = structure.canvas.width;
10456
- const availableWidth = canvas.width - CHART_PADDING$1 * 2;
10457
- canvas.height = structure.canvas.height;
10463
+ const dpr = window.devicePixelRatio || 1;
10464
+ canvas.width = dpr * structure.canvas.width;
10465
+ canvas.height = dpr * structure.canvas.height;
10466
+ ctx.scale(dpr, dpr);
10467
+ const availableWidth = structure.canvas.width - CHART_PADDING$1 * 2;
10458
10468
  ctx.fillStyle = structure.canvas.backgroundColor;
10459
10469
  ctx.fillRect(0, 0, structure.canvas.width, structure.canvas.height);
10460
10470
  if (structure.title) {
@@ -10817,7 +10827,7 @@ class ScorecardChart extends Component {
10817
10827
  useEffect(this.createChart.bind(this), () => {
10818
10828
  const canvas = this.canvas.el;
10819
10829
  const rect = canvas.getBoundingClientRect();
10820
- return [rect.width, rect.height, this.runtime, this.canvas.el];
10830
+ return [rect.width, rect.height, this.runtime, this.canvas.el, window.devicePixelRatio];
10821
10831
  });
10822
10832
  }
10823
10833
  createChart() {
@@ -13577,7 +13587,7 @@ const RANK = {
13577
13587
  }
13578
13588
  }
13579
13589
  if (!found) {
13580
- throw new NotAvailableError(_t("Value not found in the given data."));
13590
+ return new NotAvailableError(_t("Value not found in the given data."));
13581
13591
  }
13582
13592
  return rank;
13583
13593
  },
@@ -15317,7 +15327,7 @@ const UNIQUE = {
15317
15327
  result.push(row.data);
15318
15328
  }
15319
15329
  if (!result.length)
15320
- throw new EvaluationError(_t("No unique values found"));
15330
+ return new EvaluationError(_t("No unique values found"));
15321
15331
  return _byColumn ? result : transposeMatrix(result);
15322
15332
  },
15323
15333
  isExported: true,
@@ -19096,7 +19106,7 @@ const OFFSET = {
19096
19106
  }
19097
19107
  const _cellReference = cellReference?.value;
19098
19108
  if (!_cellReference) {
19099
- throw new Error("In this context, the function OFFSET needs to have a cell or range in parameter.");
19109
+ return new EvaluationError("In this context, the function OFFSET needs to have a cell or range in parameter.");
19100
19110
  }
19101
19111
  const zone = toZone(_cellReference);
19102
19112
  let offsetHeight = zone.bottom - zone.top + 1;
@@ -22406,9 +22416,11 @@ const GAUGE_INFLECTION_LABEL_BOTTOM_MARGIN = 6;
22406
22416
  const GAUGE_TITLE_SECTION_HEIGHT = 25;
22407
22417
  function drawGaugeChart(canvas, runtime) {
22408
22418
  const canvasBoundingRect = canvas.getBoundingClientRect();
22409
- canvas.width = canvasBoundingRect.width;
22410
- canvas.height = canvasBoundingRect.height;
22419
+ const dpr = window.devicePixelRatio || 1;
22420
+ canvas.width = dpr * canvasBoundingRect.width;
22421
+ canvas.height = dpr * canvasBoundingRect.height;
22411
22422
  const ctx = canvas.getContext("2d");
22423
+ ctx.scale(dpr, dpr);
22412
22424
  const config = getGaugeRenderingConfig(canvasBoundingRect, runtime, ctx);
22413
22425
  drawBackground(ctx, config);
22414
22426
  drawGauge(ctx, config);
@@ -22743,7 +22755,7 @@ class GaugeChartComponent extends Component {
22743
22755
  useEffect(() => drawGaugeChart(this.canvas.el, this.runtime), () => {
22744
22756
  const canvas = this.canvas.el;
22745
22757
  const rect = canvas.getBoundingClientRect();
22746
- return [rect.width, rect.height, this.runtime, this.canvas.el];
22758
+ return [rect.width, rect.height, this.runtime, this.canvas.el, window.devicePixelRatio];
22747
22759
  });
22748
22760
  }
22749
22761
  }
@@ -29555,7 +29567,7 @@ function getBarChartScales(definition, args) {
29555
29567
  };
29556
29568
  scales[MOVING_AVERAGE_TREND_LINE_XAXIS_ID] = {
29557
29569
  ...scales.x,
29558
- offset: false,
29570
+ offset: true,
29559
29571
  display: false,
29560
29572
  };
29561
29573
  }
@@ -30152,9 +30164,6 @@ class BarChart extends AbstractChart {
30152
30164
  };
30153
30165
  }
30154
30166
  getDefinitionForExcel() {
30155
- // Excel does not support aggregating labels
30156
- if (this.aggregated)
30157
- return undefined;
30158
30167
  const dataSets = this.dataSets
30159
30168
  .map((ds) => toExcelDataset(this.getters, ds))
30160
30169
  .filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference);
@@ -30835,9 +30844,6 @@ class LineChart extends AbstractChart {
30835
30844
  return new LineChart(definition, this.sheetId, this.getters);
30836
30845
  }
30837
30846
  getDefinitionForExcel() {
30838
- // Excel does not support aggregating labels
30839
- if (this.aggregated)
30840
- return undefined;
30841
30847
  const dataSets = this.dataSets
30842
30848
  .map((ds) => toExcelDataset(this.getters, ds))
30843
30849
  .filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference);
@@ -30974,9 +30980,6 @@ class PieChart extends AbstractChart {
30974
30980
  return new PieChart(definition, sheetId, this.getters);
30975
30981
  }
30976
30982
  getDefinitionForExcel() {
30977
- // Excel does not support aggregating labels
30978
- if (this.aggregated)
30979
- return undefined;
30980
30983
  const dataSets = this.dataSets
30981
30984
  .map((ds) => toExcelDataset(this.getters, ds))
30982
30985
  .filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference);
@@ -33452,18 +33455,28 @@ function isCtrlKey(ev) {
33452
33455
  function useInterval(callback, delay) {
33453
33456
  let intervalId;
33454
33457
  const { setInterval, clearInterval } = window;
33458
+ const pause = () => {
33459
+ clearInterval(intervalId);
33460
+ intervalId = undefined;
33461
+ };
33462
+ const safeCallback = () => {
33463
+ try {
33464
+ callback();
33465
+ }
33466
+ catch (e) {
33467
+ pause();
33468
+ throw e;
33469
+ }
33470
+ };
33455
33471
  useEffect(() => {
33456
- intervalId = setInterval(callback, delay);
33472
+ intervalId = setInterval(safeCallback, delay);
33457
33473
  return () => clearInterval(intervalId);
33458
33474
  }, () => [delay]);
33459
33475
  return {
33460
- pause: () => {
33461
- clearInterval(intervalId);
33462
- intervalId = undefined;
33463
- },
33476
+ pause,
33464
33477
  resume: () => {
33465
33478
  if (intervalId === undefined) {
33466
- intervalId = setInterval(callback, delay);
33479
+ intervalId = setInterval(safeCallback, delay);
33467
33480
  }
33468
33481
  },
33469
33482
  };
@@ -38559,7 +38572,7 @@ class ColorPicker extends Component {
38559
38572
  }
38560
38573
  setHexColor(ev) {
38561
38574
  // only support HEX code input
38562
- const val = ev.target.value.slice(0, 7);
38575
+ const val = ev.target.value.replace("##", "#").slice(0, 7);
38563
38576
  this.state.customHexColor = val;
38564
38577
  if (!isColorValid(val)) ;
38565
38578
  else {
@@ -50452,7 +50465,7 @@ css /* scss */ `
50452
50465
  position: absolute;
50453
50466
  top: 0;
50454
50467
  left: ${HEADER_WIDTH}px;
50455
- right: 0;
50468
+ right: ${SCROLLBAR_WIDTH}px;
50456
50469
  height: ${HEADER_HEIGHT}px;
50457
50470
  &.o-dragging {
50458
50471
  cursor: grabbing;
@@ -50618,9 +50631,8 @@ css /* scss */ `
50618
50631
  position: absolute;
50619
50632
  top: ${HEADER_HEIGHT}px;
50620
50633
  left: 0;
50621
- right: 0;
50634
+ bottom: ${SCROLLBAR_WIDTH}px;
50622
50635
  width: ${HEADER_WIDTH}px;
50623
- height: calc(100% - ${HEADER_HEIGHT + SCROLLBAR_WIDTH}px);
50624
50636
  &.o-dragging {
50625
50637
  cursor: grabbing;
50626
50638
  }
@@ -58621,6 +58633,15 @@ function adaptPivotRange(range, applyChange) {
58621
58633
  }
58622
58634
  }
58623
58635
  class SpreadsheetPivotCorePlugin extends CorePlugin {
58636
+ allowDispatch(cmd) {
58637
+ switch (cmd.type) {
58638
+ case "ADD_PIVOT":
58639
+ case "UPDATE_PIVOT":
58640
+ const definition = cmd.pivot;
58641
+ return this.checkDataSetValidity(definition);
58642
+ }
58643
+ return "Success" /* CommandResult.Success */;
58644
+ }
58624
58645
  adaptRanges(applyChange) {
58625
58646
  for (const pivotId of this.getters.getPivotIds()) {
58626
58647
  const definition = this.getters.getPivotCoreDefinition(pivotId);
@@ -58639,6 +58660,16 @@ class SpreadsheetPivotCorePlugin extends CorePlugin {
58639
58660
  }
58640
58661
  }
58641
58662
  }
58663
+ checkDataSetValidity(definition) {
58664
+ if (definition.type === "SPREADSHEET" && definition.dataSet) {
58665
+ const { zone, sheetId } = definition.dataSet;
58666
+ if (!sheetId || !this.getters.tryGetSheet(sheetId) || !zone || !isZoneValid(zone)) {
58667
+ return "InvalidDataSet" /* CommandResult.InvalidDataSet */;
58668
+ }
58669
+ return this.getters.checkZonesExistInSheet(sheetId, [zone]);
58670
+ }
58671
+ return "Success" /* CommandResult.Success */;
58672
+ }
58642
58673
  }
58643
58674
 
58644
58675
  class TableStylePlugin extends CorePlugin {
@@ -61438,7 +61469,7 @@ class DynamicTablesPlugin extends UIPlugin {
61438
61469
  tables = {};
61439
61470
  handle(cmd) {
61440
61471
  if (invalidateEvaluationCommands.has(cmd.type) ||
61441
- (cmd.type === "UPDATE_CELL" && "content" in cmd) ||
61472
+ (cmd.type === "UPDATE_CELL" && ("content" in cmd || "format" in cmd)) ||
61442
61473
  cmd.type === "EVALUATE_CELLS") {
61443
61474
  this.tables = {};
61444
61475
  return;
@@ -61871,6 +61902,16 @@ function withPivotPresentationLayer (PivotClass) {
61871
61902
  }
61872
61903
  return values;
61873
61904
  }
61905
+ else if (rowDomain.length === this.definition.rows.length &&
61906
+ colDomain.length &&
61907
+ colDomain.length < this.definition.columns.length) {
61908
+ const colSubTree = this.getSubTreeMatchingDomain(table.getColTree(), colDomain);
61909
+ const domains = this.treeToLeafDomains(colSubTree, colDomain);
61910
+ for (const domain of domains) {
61911
+ values.push(this._getPivotCellValueAndFormat(measure.id, rowDomain.concat(domain)));
61912
+ }
61913
+ return values;
61914
+ }
61874
61915
  else {
61875
61916
  const tree = table.getRowTree();
61876
61917
  const subTree = this.getSubTreeMatchingDomain(tree, rowDomain);
@@ -65285,7 +65326,7 @@ class TableComputedStylePlugin extends UIPlugin {
65285
65326
  tableStyles = {};
65286
65327
  handle(cmd) {
65287
65328
  if (invalidateEvaluationCommands.has(cmd.type) ||
65288
- (cmd.type === "UPDATE_CELL" && "content" in cmd) ||
65329
+ (cmd.type === "UPDATE_CELL" && ("content" in cmd || "format" in cmd)) ||
65289
65330
  cmd.type === "EVALUATE_CELLS") {
65290
65331
  this.tableStyles = {};
65291
65332
  return;
@@ -67249,6 +67290,8 @@ class GridSelectionPlugin extends UIPlugin {
67249
67290
  });
67250
67291
  this.selectCell(col, row);
67251
67292
  }
67293
+ const { col, row } = this.gridSelection.anchor.cell;
67294
+ this.moveClient({ sheetId: this.activeSheet.id, col, row });
67252
67295
  }
67253
67296
  /**
67254
67297
  * Ensure selections are not outside sheet boundaries.
@@ -67988,8 +68031,11 @@ class SheetViewPlugin extends UIPlugin {
67988
68031
  case "REMOVE_TABLE":
67989
68032
  case "UPDATE_TABLE":
67990
68033
  case "UPDATE_FILTER":
67991
- this.sheetsWithDirtyViewports.add(cmd.sheetId);
67992
- break;
68034
+ case "UNFREEZE_ROWS":
68035
+ case "UNFREEZE_COLUMNS":
68036
+ case "FREEZE_COLUMNS":
68037
+ case "FREEZE_ROWS":
68038
+ case "UNFREEZE_COLUMNS_ROWS":
67993
68039
  case "REMOVE_COLUMNS_ROWS":
67994
68040
  case "RESIZE_COLUMNS_ROWS":
67995
68041
  case "HIDE_COLUMNS_ROWS":
@@ -68002,11 +68048,9 @@ class SheetViewPlugin extends UIPlugin {
68002
68048
  case "FOLD_HEADER_GROUPS_IN_ZONE":
68003
68049
  case "UNFOLD_HEADER_GROUPS_IN_ZONE":
68004
68050
  case "UNFOLD_ALL_HEADER_GROUPS":
68005
- case "FOLD_ALL_HEADER_GROUPS": {
68006
- const sheetId = "sheetId" in cmd ? cmd.sheetId : this.getters.getActiveSheetId();
68007
- this.sheetsWithDirtyViewports.add(sheetId);
68051
+ case "FOLD_ALL_HEADER_GROUPS":
68052
+ this.sheetsWithDirtyViewports.add(cmd.sheetId);
68008
68053
  break;
68009
- }
68010
68054
  case "UPDATE_CELL":
68011
68055
  // update cell content or format can change hidden rows because of data filters
68012
68056
  if ("content" in cmd || "format" in cmd || cmd.style?.fontSize !== undefined) {
@@ -68022,13 +68066,6 @@ class SheetViewPlugin extends UIPlugin {
68022
68066
  case "ACTIVATE_SHEET":
68023
68067
  this.sheetsWithDirtyViewports.add(cmd.sheetIdTo);
68024
68068
  break;
68025
- case "UNFREEZE_ROWS":
68026
- case "UNFREEZE_COLUMNS":
68027
- case "FREEZE_COLUMNS":
68028
- case "FREEZE_ROWS":
68029
- case "UNFREEZE_COLUMNS_ROWS":
68030
- this.resetViewports(this.getters.getActiveSheetId());
68031
- break;
68032
68069
  case "SCROLL_TO_CELL":
68033
68070
  this.refreshViewport(this.getters.getActiveSheetId(), { col: cmd.col, row: cmd.row });
68034
68071
  break;
@@ -69206,7 +69243,7 @@ class AggregateStatisticsStore extends SpreadsheetStore {
69206
69243
  }
69207
69244
  handle(cmd) {
69208
69245
  if (invalidateEvaluationCommands.has(cmd.type) ||
69209
- (cmd.type === "UPDATE_CELL" && "content" in cmd)) {
69246
+ (cmd.type === "UPDATE_CELL" && ("content" in cmd || "format" in cmd))) {
69210
69247
  this.isDirty = true;
69211
69248
  }
69212
69249
  switch (cmd.type) {
@@ -75723,6 +75760,6 @@ const chartHelpers = { ...CHART_HELPERS, ...CHART_RUNTIME_HELPERS };
75723
75760
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, 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 };
75724
75761
 
75725
75762
 
75726
- __info__.version = "18.1.16";
75727
- __info__.date = "2025-04-18T16:24:16.854Z";
75728
- __info__.hash = "19f6de2";
75763
+ __info__.version = "18.1.18";
75764
+ __info__.date = "2025-05-02T12:30:47.822Z";
75765
+ __info__.hash = "29c21c6";