@odoo/o-spreadsheet 18.2.8 → 18.2.10

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.8
6
- * @date 2025-04-18T16:26:20.673Z
7
- * @hash 5da9ddc
5
+ * @version 18.2.10
6
+ * @date 2025-05-02T12:34:39.632Z
7
+ * @hash e8ff3fc
8
8
  */
9
9
 
10
10
  'use strict';
@@ -3771,6 +3771,7 @@ exports.CommandResult = void 0;
3771
3771
  CommandResult["ValueCellIsInvalidFormula"] = "ValueCellIsInvalidFormula";
3772
3772
  CommandResult["InvalidDefinition"] = "InvalidDefinition";
3773
3773
  CommandResult["InvalidColor"] = "InvalidColor";
3774
+ CommandResult["InvalidPivotDataSet"] = "InvalidPivotDataSet";
3774
3775
  })(exports.CommandResult || (exports.CommandResult = {}));
3775
3776
 
3776
3777
  const DEFAULT_LOCALES = [
@@ -3843,11 +3844,13 @@ const CellErrorType = {
3843
3844
  NullError: "#NULL!",
3844
3845
  };
3845
3846
  const errorTypes = new Set(Object.values(CellErrorType));
3846
- class EvaluationError extends Error {
3847
+ class EvaluationError {
3848
+ message;
3847
3849
  value;
3848
3850
  constructor(message = _t("Error"), value = CellErrorType.GenericError) {
3849
- super(message);
3851
+ this.message = message;
3850
3852
  this.value = value;
3853
+ this.message = message.toString();
3851
3854
  }
3852
3855
  }
3853
3856
  class BadExpressionError extends EvaluationError {
@@ -10171,7 +10174,7 @@ function drawLineOrBarOrRadarChartValues(chart, options, ctx) {
10171
10174
  const yMin = chart.chartArea.top;
10172
10175
  const textsPositions = {};
10173
10176
  for (const dataset of chart._metasets) {
10174
- if (isTrendLineAxis(dataset.axisID) || dataset.hidden) {
10177
+ if (isTrendLineAxis(dataset.xAxisID) || dataset.hidden) {
10175
10178
  continue;
10176
10179
  }
10177
10180
  for (let i = 0; i < dataset._parsed.length; i++) {
@@ -10214,7 +10217,7 @@ function drawHorizontalBarChartValues(chart, options, ctx) {
10214
10217
  const xMin = chart.chartArea.left;
10215
10218
  const textsPositions = {};
10216
10219
  for (const dataset of chart._metasets) {
10217
- if (isTrendLineAxis(dataset.axisID)) {
10220
+ if (isTrendLineAxis(dataset.xAxisID)) {
10218
10221
  return; // ignore trend lines
10219
10222
  }
10220
10223
  for (let i = 0; i < dataset._parsed.length; i++) {
@@ -10339,6 +10342,7 @@ class ChartJsComponent extends owl.Component {
10339
10342
  canvas = owl.useRef("graphContainer");
10340
10343
  chart;
10341
10344
  currentRuntime;
10345
+ currentDevicePixelRatio = window.devicePixelRatio;
10342
10346
  get background() {
10343
10347
  return this.chartRuntime.background;
10344
10348
  }
@@ -10372,6 +10376,10 @@ class ChartJsComponent extends owl.Component {
10372
10376
  }
10373
10377
  this.currentRuntime = runtime;
10374
10378
  }
10379
+ else if (this.currentDevicePixelRatio !== window.devicePixelRatio) {
10380
+ this.currentDevicePixelRatio = window.devicePixelRatio;
10381
+ this.updateChartJs(deepCopy(this.currentRuntime.chartJsConfig));
10382
+ }
10375
10383
  });
10376
10384
  }
10377
10385
  createChart(chartData) {
@@ -10627,9 +10635,11 @@ let ScorecardChart$1 = class ScorecardChart extends AbstractChart {
10627
10635
  };
10628
10636
  function drawScoreChart(structure, canvas) {
10629
10637
  const ctx = canvas.getContext("2d");
10630
- canvas.width = structure.canvas.width;
10631
- const availableWidth = canvas.width - CHART_PADDING$1 * 2;
10632
- canvas.height = structure.canvas.height;
10638
+ const dpr = window.devicePixelRatio || 1;
10639
+ canvas.width = dpr * structure.canvas.width;
10640
+ canvas.height = dpr * structure.canvas.height;
10641
+ ctx.scale(dpr, dpr);
10642
+ const availableWidth = structure.canvas.width - CHART_PADDING$1 * 2;
10633
10643
  ctx.fillStyle = structure.canvas.backgroundColor;
10634
10644
  ctx.fillRect(0, 0, structure.canvas.width, structure.canvas.height);
10635
10645
  if (structure.title) {
@@ -10992,7 +11002,7 @@ class ScorecardChart extends owl.Component {
10992
11002
  owl.useEffect(this.createChart.bind(this), () => {
10993
11003
  const canvas = this.canvas.el;
10994
11004
  const rect = canvas.getBoundingClientRect();
10995
- return [rect.width, rect.height, this.runtime, this.canvas.el];
11005
+ return [rect.width, rect.height, this.runtime, this.canvas.el, window.devicePixelRatio];
10996
11006
  });
10997
11007
  }
10998
11008
  createChart() {
@@ -13752,7 +13762,7 @@ const RANK = {
13752
13762
  }
13753
13763
  }
13754
13764
  if (!found) {
13755
- throw new NotAvailableError(_t("Value not found in the given data."));
13765
+ return new NotAvailableError(_t("Value not found in the given data."));
13756
13766
  }
13757
13767
  return rank;
13758
13768
  },
@@ -15492,7 +15502,7 @@ const UNIQUE = {
15492
15502
  result.push(row.data);
15493
15503
  }
15494
15504
  if (!result.length)
15495
- throw new EvaluationError(_t("No unique values found"));
15505
+ return new EvaluationError(_t("No unique values found"));
15496
15506
  return _byColumn ? result : transposeMatrix(result);
15497
15507
  },
15498
15508
  isExported: true,
@@ -19271,7 +19281,7 @@ const OFFSET = {
19271
19281
  }
19272
19282
  const _cellReference = cellReference?.value;
19273
19283
  if (!_cellReference) {
19274
- throw new Error("In this context, the function OFFSET needs to have a cell or range in parameter.");
19284
+ return new EvaluationError("In this context, the function OFFSET needs to have a cell or range in parameter.");
19275
19285
  }
19276
19286
  const zone = toZone(_cellReference);
19277
19287
  let offsetHeight = zone.bottom - zone.top + 1;
@@ -22581,9 +22591,11 @@ const GAUGE_INFLECTION_LABEL_BOTTOM_MARGIN = 6;
22581
22591
  const GAUGE_TITLE_SECTION_HEIGHT = 25;
22582
22592
  function drawGaugeChart(canvas, runtime) {
22583
22593
  const canvasBoundingRect = canvas.getBoundingClientRect();
22584
- canvas.width = canvasBoundingRect.width;
22585
- canvas.height = canvasBoundingRect.height;
22594
+ const dpr = window.devicePixelRatio || 1;
22595
+ canvas.width = dpr * canvasBoundingRect.width;
22596
+ canvas.height = dpr * canvasBoundingRect.height;
22586
22597
  const ctx = canvas.getContext("2d");
22598
+ ctx.scale(dpr, dpr);
22587
22599
  const config = getGaugeRenderingConfig(canvasBoundingRect, runtime, ctx);
22588
22600
  drawBackground(ctx, config);
22589
22601
  drawGauge(ctx, config);
@@ -22918,7 +22930,7 @@ class GaugeChartComponent extends owl.Component {
22918
22930
  owl.useEffect(() => drawGaugeChart(this.canvas.el, this.runtime), () => {
22919
22931
  const canvas = this.canvas.el;
22920
22932
  const rect = canvas.getBoundingClientRect();
22921
- return [rect.width, rect.height, this.runtime, this.canvas.el];
22933
+ return [rect.width, rect.height, this.runtime, this.canvas.el, window.devicePixelRatio];
22922
22934
  });
22923
22935
  }
22924
22936
  }
@@ -29581,7 +29593,7 @@ function getBarChartScales(definition, args) {
29581
29593
  };
29582
29594
  scales[MOVING_AVERAGE_TREND_LINE_XAXIS_ID] = {
29583
29595
  ...scales.x,
29584
- offset: false,
29596
+ offset: true,
29585
29597
  display: false,
29586
29598
  };
29587
29599
  }
@@ -30301,9 +30313,6 @@ class BarChart extends AbstractChart {
30301
30313
  };
30302
30314
  }
30303
30315
  getDefinitionForExcel() {
30304
- // Excel does not support aggregating labels
30305
- if (this.aggregated)
30306
- return undefined;
30307
30316
  const dataSets = this.dataSets
30308
30317
  .map((ds) => toExcelDataset(this.getters, ds))
30309
30318
  .filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference);
@@ -31018,9 +31027,6 @@ class LineChart extends AbstractChart {
31018
31027
  return new LineChart(definition, this.sheetId, this.getters);
31019
31028
  }
31020
31029
  getDefinitionForExcel() {
31021
- // Excel does not support aggregating labels
31022
- if (this.aggregated)
31023
- return undefined;
31024
31030
  const dataSets = this.dataSets
31025
31031
  .map((ds) => toExcelDataset(this.getters, ds))
31026
31032
  .filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference);
@@ -31157,9 +31163,6 @@ class PieChart extends AbstractChart {
31157
31163
  return new PieChart(definition, sheetId, this.getters);
31158
31164
  }
31159
31165
  getDefinitionForExcel() {
31160
- // Excel does not support aggregating labels
31161
- if (this.aggregated)
31162
- return undefined;
31163
31166
  const dataSets = this.dataSets
31164
31167
  .map((ds) => toExcelDataset(this.getters, ds))
31165
31168
  .filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference);
@@ -33658,18 +33661,28 @@ function isBrowserFirefox() {
33658
33661
  function useInterval(callback, delay) {
33659
33662
  let intervalId;
33660
33663
  const { setInterval, clearInterval } = window;
33664
+ const pause = () => {
33665
+ clearInterval(intervalId);
33666
+ intervalId = undefined;
33667
+ };
33668
+ const safeCallback = () => {
33669
+ try {
33670
+ callback();
33671
+ }
33672
+ catch (e) {
33673
+ pause();
33674
+ throw e;
33675
+ }
33676
+ };
33661
33677
  owl.useEffect(() => {
33662
- intervalId = setInterval(callback, delay);
33678
+ intervalId = setInterval(safeCallback, delay);
33663
33679
  return () => clearInterval(intervalId);
33664
33680
  }, () => [delay]);
33665
33681
  return {
33666
- pause: () => {
33667
- clearInterval(intervalId);
33668
- intervalId = undefined;
33669
- },
33682
+ pause,
33670
33683
  resume: () => {
33671
33684
  if (intervalId === undefined) {
33672
- intervalId = setInterval(callback, delay);
33685
+ intervalId = setInterval(safeCallback, delay);
33673
33686
  }
33674
33687
  },
33675
33688
  };
@@ -38450,8 +38463,11 @@ class SelectionInput extends owl.Component {
38450
38463
  }
38451
38464
  removeInput(rangeId) {
38452
38465
  const index = this.store.selectionInputs.findIndex((range) => range.id === rangeId);
38453
- this.props.onSelectionRemoved?.(index);
38454
- this.props.onSelectionConfirmed?.();
38466
+ if (this.ranges.find((range) => range.id === rangeId)?.xc) {
38467
+ this.props.onSelectionRemoved?.(index);
38468
+ this.props.onSelectionConfirmed?.();
38469
+ }
38470
+ this.store.removeRange(rangeId);
38455
38471
  }
38456
38472
  onInputChanged(rangeId, ev) {
38457
38473
  const target = ev.target;
@@ -39117,7 +39133,7 @@ class ColorPicker extends owl.Component {
39117
39133
  }
39118
39134
  setHexColor(ev) {
39119
39135
  // only support HEX code input
39120
- const val = ev.target.value.slice(0, 7);
39136
+ const val = ev.target.value.replace("##", "#").slice(0, 7);
39121
39137
  this.state.customHexColor = val;
39122
39138
  if (!isColorValid(val)) ;
39123
39139
  else {
@@ -50851,7 +50867,7 @@ css /* scss */ `
50851
50867
  position: absolute;
50852
50868
  top: 0;
50853
50869
  left: ${HEADER_WIDTH}px;
50854
- right: 0;
50870
+ right: ${SCROLLBAR_WIDTH}px;
50855
50871
  height: ${HEADER_HEIGHT}px;
50856
50872
  width: calc(100% - ${HEADER_WIDTH + SCROLLBAR_WIDTH}px);
50857
50873
  &.o-dragging {
@@ -51044,9 +51060,8 @@ css /* scss */ `
51044
51060
  position: absolute;
51045
51061
  top: ${HEADER_HEIGHT}px;
51046
51062
  left: 0;
51047
- right: 0;
51063
+ bottom: ${SCROLLBAR_WIDTH}px;
51048
51064
  width: ${HEADER_WIDTH}px;
51049
- height: calc(100% - ${HEADER_HEIGHT + SCROLLBAR_WIDTH}px);
51050
51065
  &.o-dragging {
51051
51066
  cursor: grabbing;
51052
51067
  }
@@ -59094,6 +59109,15 @@ function adaptPivotRange(range, applyChange) {
59094
59109
  }
59095
59110
  }
59096
59111
  class SpreadsheetPivotCorePlugin extends CorePlugin {
59112
+ allowDispatch(cmd) {
59113
+ switch (cmd.type) {
59114
+ case "ADD_PIVOT":
59115
+ case "UPDATE_PIVOT":
59116
+ const definition = cmd.pivot;
59117
+ return this.checkDataSetValidity(definition);
59118
+ }
59119
+ return "Success" /* CommandResult.Success */;
59120
+ }
59097
59121
  adaptRanges(applyChange) {
59098
59122
  for (const pivotId of this.getters.getPivotIds()) {
59099
59123
  const definition = this.getters.getPivotCoreDefinition(pivotId);
@@ -59112,6 +59136,16 @@ class SpreadsheetPivotCorePlugin extends CorePlugin {
59112
59136
  }
59113
59137
  }
59114
59138
  }
59139
+ checkDataSetValidity(definition) {
59140
+ if (definition.type === "SPREADSHEET" && definition.dataSet) {
59141
+ const { zone, sheetId } = definition.dataSet;
59142
+ if (!sheetId || !this.getters.tryGetSheet(sheetId) || !zone || !isZoneValid(zone)) {
59143
+ return "InvalidDataSet" /* CommandResult.InvalidDataSet */;
59144
+ }
59145
+ return this.getters.checkZonesExistInSheet(sheetId, [zone]);
59146
+ }
59147
+ return "Success" /* CommandResult.Success */;
59148
+ }
59115
59149
  }
59116
59150
 
59117
59151
  class TableStylePlugin extends CorePlugin {
@@ -61902,7 +61936,7 @@ class DynamicTablesPlugin extends CoreViewPlugin {
61902
61936
  tables = {};
61903
61937
  handle(cmd) {
61904
61938
  if (invalidateEvaluationCommands.has(cmd.type) ||
61905
- (cmd.type === "UPDATE_CELL" && "content" in cmd) ||
61939
+ (cmd.type === "UPDATE_CELL" && ("content" in cmd || "format" in cmd)) ||
61906
61940
  cmd.type === "EVALUATE_CELLS") {
61907
61941
  this.tables = {};
61908
61942
  return;
@@ -62335,6 +62369,16 @@ function withPivotPresentationLayer (PivotClass) {
62335
62369
  }
62336
62370
  return values;
62337
62371
  }
62372
+ else if (rowDomain.length === this.definition.rows.length &&
62373
+ colDomain.length &&
62374
+ colDomain.length < this.definition.columns.length) {
62375
+ const colSubTree = this.getSubTreeMatchingDomain(table.getColTree(), colDomain);
62376
+ const domains = this.treeToLeafDomains(colSubTree, colDomain);
62377
+ for (const domain of domains) {
62378
+ values.push(this._getPivotCellValueAndFormat(measure.id, rowDomain.concat(domain)));
62379
+ }
62380
+ return values;
62381
+ }
62338
62382
  else {
62339
62383
  const tree = table.getRowTree();
62340
62384
  const subTree = this.getSubTreeMatchingDomain(tree, rowDomain);
@@ -65764,7 +65808,7 @@ class TableComputedStylePlugin extends UIPlugin {
65764
65808
  tableStyles = {};
65765
65809
  handle(cmd) {
65766
65810
  if (invalidateEvaluationCommands.has(cmd.type) ||
65767
- (cmd.type === "UPDATE_CELL" && "content" in cmd) ||
65811
+ (cmd.type === "UPDATE_CELL" && ("content" in cmd || "format" in cmd)) ||
65768
65812
  cmd.type === "EVALUATE_CELLS") {
65769
65813
  this.tableStyles = {};
65770
65814
  return;
@@ -67725,6 +67769,8 @@ class GridSelectionPlugin extends UIPlugin {
67725
67769
  });
67726
67770
  this.selectCell(col, row);
67727
67771
  }
67772
+ const { col, row } = this.gridSelection.anchor.cell;
67773
+ this.moveClient({ sheetId: this.activeSheet.id, col, row });
67728
67774
  }
67729
67775
  /**
67730
67776
  * Ensure selections are not outside sheet boundaries.
@@ -68440,8 +68486,11 @@ class SheetViewPlugin extends UIPlugin {
68440
68486
  case "REMOVE_TABLE":
68441
68487
  case "UPDATE_TABLE":
68442
68488
  case "UPDATE_FILTER":
68443
- this.sheetsWithDirtyViewports.add(cmd.sheetId);
68444
- break;
68489
+ case "UNFREEZE_ROWS":
68490
+ case "UNFREEZE_COLUMNS":
68491
+ case "FREEZE_COLUMNS":
68492
+ case "FREEZE_ROWS":
68493
+ case "UNFREEZE_COLUMNS_ROWS":
68445
68494
  case "REMOVE_COLUMNS_ROWS":
68446
68495
  case "RESIZE_COLUMNS_ROWS":
68447
68496
  case "HIDE_COLUMNS_ROWS":
@@ -68454,11 +68503,9 @@ class SheetViewPlugin extends UIPlugin {
68454
68503
  case "FOLD_HEADER_GROUPS_IN_ZONE":
68455
68504
  case "UNFOLD_HEADER_GROUPS_IN_ZONE":
68456
68505
  case "UNFOLD_ALL_HEADER_GROUPS":
68457
- case "FOLD_ALL_HEADER_GROUPS": {
68458
- const sheetId = "sheetId" in cmd ? cmd.sheetId : this.getters.getActiveSheetId();
68459
- this.sheetsWithDirtyViewports.add(sheetId);
68506
+ case "FOLD_ALL_HEADER_GROUPS":
68507
+ this.sheetsWithDirtyViewports.add(cmd.sheetId);
68460
68508
  break;
68461
- }
68462
68509
  case "UPDATE_CELL":
68463
68510
  // update cell content or format can change hidden rows because of data filters
68464
68511
  if ("content" in cmd || "format" in cmd || cmd.style?.fontSize !== undefined) {
@@ -68474,13 +68521,6 @@ class SheetViewPlugin extends UIPlugin {
68474
68521
  case "ACTIVATE_SHEET":
68475
68522
  this.sheetsWithDirtyViewports.add(cmd.sheetIdTo);
68476
68523
  break;
68477
- case "UNFREEZE_ROWS":
68478
- case "UNFREEZE_COLUMNS":
68479
- case "FREEZE_COLUMNS":
68480
- case "FREEZE_ROWS":
68481
- case "UNFREEZE_COLUMNS_ROWS":
68482
- this.resetViewports(this.getters.getActiveSheetId());
68483
- break;
68484
68524
  case "SCROLL_TO_CELL":
68485
68525
  this.refreshViewport(this.getters.getActiveSheetId(), { col: cmd.col, row: cmd.row });
68486
68526
  break;
@@ -69648,7 +69688,7 @@ class AggregateStatisticsStore extends SpreadsheetStore {
69648
69688
  }
69649
69689
  handle(cmd) {
69650
69690
  if (invalidateEvaluationCommands.has(cmd.type) ||
69651
- (cmd.type === "UPDATE_CELL" && "content" in cmd)) {
69691
+ (cmd.type === "UPDATE_CELL" && ("content" in cmd || "format" in cmd))) {
69652
69692
  this.isDirty = true;
69653
69693
  }
69654
69694
  switch (cmd.type) {
@@ -76230,6 +76270,6 @@ exports.tokenColors = tokenColors;
76230
76270
  exports.tokenize = tokenize;
76231
76271
 
76232
76272
 
76233
- __info__.version = "18.2.8";
76234
- __info__.date = "2025-04-18T16:26:20.673Z";
76235
- __info__.hash = "5da9ddc";
76273
+ __info__.version = "18.2.10";
76274
+ __info__.date = "2025-05-02T12:34:39.632Z";
76275
+ __info__.hash = "e8ff3fc";
@@ -3150,7 +3150,8 @@ declare const enum CommandResult {
3150
3150
  EmptyName = "EmptyName",
3151
3151
  ValueCellIsInvalidFormula = "ValueCellIsInvalidFormula",
3152
3152
  InvalidDefinition = "InvalidDefinition",
3153
- InvalidColor = "InvalidColor"
3153
+ InvalidColor = "InvalidColor",
3154
+ InvalidPivotDataSet = "InvalidPivotDataSet"
3154
3155
  }
3155
3156
  interface CommandHandler<T> {
3156
3157
  allowDispatch(command: T): CommandResult | CommandResult[];
@@ -8686,6 +8687,7 @@ declare class ChartJsComponent extends Component<Props$O, SpreadsheetChildEnv> {
8686
8687
  private canvas;
8687
8688
  private chart?;
8688
8689
  private currentRuntime;
8690
+ private currentDevicePixelRatio;
8689
8691
  get background(): string;
8690
8692
  get canvasStyle(): string;
8691
8693
  get chartRuntime(): ChartJSRuntime;
@@ -11676,7 +11678,8 @@ declare const CellErrorType: {
11676
11678
  readonly GenericError: "#ERROR";
11677
11679
  readonly NullError: "#NULL!";
11678
11680
  };
11679
- declare class EvaluationError extends Error {
11681
+ declare class EvaluationError {
11682
+ readonly message: string;
11680
11683
  readonly value: string;
11681
11684
  constructor(message?: string, value?: string);
11682
11685
  }