@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
  'use strict';
@@ -3762,6 +3762,7 @@ exports.CommandResult = void 0;
3762
3762
  CommandResult["ValueCellIsInvalidFormula"] = "ValueCellIsInvalidFormula";
3763
3763
  CommandResult["InvalidDefinition"] = "InvalidDefinition";
3764
3764
  CommandResult["InvalidColor"] = "InvalidColor";
3765
+ CommandResult["InvalidPivotDataSet"] = "InvalidPivotDataSet";
3765
3766
  })(exports.CommandResult || (exports.CommandResult = {}));
3766
3767
 
3767
3768
  const DEFAULT_LOCALES = [
@@ -3834,11 +3835,13 @@ const CellErrorType = {
3834
3835
  NullError: "#NULL!",
3835
3836
  };
3836
3837
  const errorTypes = new Set(Object.values(CellErrorType));
3837
- class EvaluationError extends Error {
3838
+ class EvaluationError {
3839
+ message;
3838
3840
  value;
3839
3841
  constructor(message = _t("Error"), value = CellErrorType.GenericError) {
3840
- super(message);
3842
+ this.message = message;
3841
3843
  this.value = value;
3844
+ this.message = message.toString();
3842
3845
  }
3843
3846
  }
3844
3847
  class BadExpressionError extends EvaluationError {
@@ -10007,7 +10010,7 @@ function drawLineOrBarOrRadarChartValues(chart, options, ctx) {
10007
10010
  const yMin = chart.chartArea.top;
10008
10011
  const textsPositions = {};
10009
10012
  for (const dataset of chart._metasets) {
10010
- if (isTrendLineAxis(dataset.axisID) || dataset.hidden) {
10013
+ if (isTrendLineAxis(dataset.xAxisID) || dataset.hidden) {
10011
10014
  continue;
10012
10015
  }
10013
10016
  for (let i = 0; i < dataset._parsed.length; i++) {
@@ -10050,7 +10053,7 @@ function drawHorizontalBarChartValues(chart, options, ctx) {
10050
10053
  const xMin = chart.chartArea.left;
10051
10054
  const textsPositions = {};
10052
10055
  for (const dataset of chart._metasets) {
10053
- if (isTrendLineAxis(dataset.axisID)) {
10056
+ if (isTrendLineAxis(dataset.xAxisID)) {
10054
10057
  return; // ignore trend lines
10055
10058
  }
10056
10059
  for (let i = 0; i < dataset._parsed.length; i++) {
@@ -10166,6 +10169,7 @@ class ChartJsComponent extends owl.Component {
10166
10169
  canvas = owl.useRef("graphContainer");
10167
10170
  chart;
10168
10171
  currentRuntime;
10172
+ currentDevicePixelRatio = window.devicePixelRatio;
10169
10173
  get background() {
10170
10174
  return this.chartRuntime.background;
10171
10175
  }
@@ -10199,6 +10203,10 @@ class ChartJsComponent extends owl.Component {
10199
10203
  }
10200
10204
  this.currentRuntime = runtime;
10201
10205
  }
10206
+ else if (this.currentDevicePixelRatio !== window.devicePixelRatio) {
10207
+ this.currentDevicePixelRatio = window.devicePixelRatio;
10208
+ this.updateChartJs(deepCopy(this.currentRuntime.chartJsConfig));
10209
+ }
10202
10210
  });
10203
10211
  }
10204
10212
  createChart(chartData) {
@@ -10454,9 +10462,11 @@ let ScorecardChart$1 = class ScorecardChart extends AbstractChart {
10454
10462
  };
10455
10463
  function drawScoreChart(structure, canvas) {
10456
10464
  const ctx = canvas.getContext("2d");
10457
- canvas.width = structure.canvas.width;
10458
- const availableWidth = canvas.width - CHART_PADDING$1 * 2;
10459
- canvas.height = structure.canvas.height;
10465
+ const dpr = window.devicePixelRatio || 1;
10466
+ canvas.width = dpr * structure.canvas.width;
10467
+ canvas.height = dpr * structure.canvas.height;
10468
+ ctx.scale(dpr, dpr);
10469
+ const availableWidth = structure.canvas.width - CHART_PADDING$1 * 2;
10460
10470
  ctx.fillStyle = structure.canvas.backgroundColor;
10461
10471
  ctx.fillRect(0, 0, structure.canvas.width, structure.canvas.height);
10462
10472
  if (structure.title) {
@@ -10819,7 +10829,7 @@ class ScorecardChart extends owl.Component {
10819
10829
  owl.useEffect(this.createChart.bind(this), () => {
10820
10830
  const canvas = this.canvas.el;
10821
10831
  const rect = canvas.getBoundingClientRect();
10822
- return [rect.width, rect.height, this.runtime, this.canvas.el];
10832
+ return [rect.width, rect.height, this.runtime, this.canvas.el, window.devicePixelRatio];
10823
10833
  });
10824
10834
  }
10825
10835
  createChart() {
@@ -13579,7 +13589,7 @@ const RANK = {
13579
13589
  }
13580
13590
  }
13581
13591
  if (!found) {
13582
- throw new NotAvailableError(_t("Value not found in the given data."));
13592
+ return new NotAvailableError(_t("Value not found in the given data."));
13583
13593
  }
13584
13594
  return rank;
13585
13595
  },
@@ -15319,7 +15329,7 @@ const UNIQUE = {
15319
15329
  result.push(row.data);
15320
15330
  }
15321
15331
  if (!result.length)
15322
- throw new EvaluationError(_t("No unique values found"));
15332
+ return new EvaluationError(_t("No unique values found"));
15323
15333
  return _byColumn ? result : transposeMatrix(result);
15324
15334
  },
15325
15335
  isExported: true,
@@ -19098,7 +19108,7 @@ const OFFSET = {
19098
19108
  }
19099
19109
  const _cellReference = cellReference?.value;
19100
19110
  if (!_cellReference) {
19101
- throw new Error("In this context, the function OFFSET needs to have a cell or range in parameter.");
19111
+ return new EvaluationError("In this context, the function OFFSET needs to have a cell or range in parameter.");
19102
19112
  }
19103
19113
  const zone = toZone(_cellReference);
19104
19114
  let offsetHeight = zone.bottom - zone.top + 1;
@@ -22408,9 +22418,11 @@ const GAUGE_INFLECTION_LABEL_BOTTOM_MARGIN = 6;
22408
22418
  const GAUGE_TITLE_SECTION_HEIGHT = 25;
22409
22419
  function drawGaugeChart(canvas, runtime) {
22410
22420
  const canvasBoundingRect = canvas.getBoundingClientRect();
22411
- canvas.width = canvasBoundingRect.width;
22412
- canvas.height = canvasBoundingRect.height;
22421
+ const dpr = window.devicePixelRatio || 1;
22422
+ canvas.width = dpr * canvasBoundingRect.width;
22423
+ canvas.height = dpr * canvasBoundingRect.height;
22413
22424
  const ctx = canvas.getContext("2d");
22425
+ ctx.scale(dpr, dpr);
22414
22426
  const config = getGaugeRenderingConfig(canvasBoundingRect, runtime, ctx);
22415
22427
  drawBackground(ctx, config);
22416
22428
  drawGauge(ctx, config);
@@ -22745,7 +22757,7 @@ class GaugeChartComponent extends owl.Component {
22745
22757
  owl.useEffect(() => drawGaugeChart(this.canvas.el, this.runtime), () => {
22746
22758
  const canvas = this.canvas.el;
22747
22759
  const rect = canvas.getBoundingClientRect();
22748
- return [rect.width, rect.height, this.runtime, this.canvas.el];
22760
+ return [rect.width, rect.height, this.runtime, this.canvas.el, window.devicePixelRatio];
22749
22761
  });
22750
22762
  }
22751
22763
  }
@@ -29557,7 +29569,7 @@ function getBarChartScales(definition, args) {
29557
29569
  };
29558
29570
  scales[MOVING_AVERAGE_TREND_LINE_XAXIS_ID] = {
29559
29571
  ...scales.x,
29560
- offset: false,
29572
+ offset: true,
29561
29573
  display: false,
29562
29574
  };
29563
29575
  }
@@ -30154,9 +30166,6 @@ class BarChart extends AbstractChart {
30154
30166
  };
30155
30167
  }
30156
30168
  getDefinitionForExcel() {
30157
- // Excel does not support aggregating labels
30158
- if (this.aggregated)
30159
- return undefined;
30160
30169
  const dataSets = this.dataSets
30161
30170
  .map((ds) => toExcelDataset(this.getters, ds))
30162
30171
  .filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference);
@@ -30837,9 +30846,6 @@ class LineChart extends AbstractChart {
30837
30846
  return new LineChart(definition, this.sheetId, this.getters);
30838
30847
  }
30839
30848
  getDefinitionForExcel() {
30840
- // Excel does not support aggregating labels
30841
- if (this.aggregated)
30842
- return undefined;
30843
30849
  const dataSets = this.dataSets
30844
30850
  .map((ds) => toExcelDataset(this.getters, ds))
30845
30851
  .filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference);
@@ -30976,9 +30982,6 @@ class PieChart extends AbstractChart {
30976
30982
  return new PieChart(definition, sheetId, this.getters);
30977
30983
  }
30978
30984
  getDefinitionForExcel() {
30979
- // Excel does not support aggregating labels
30980
- if (this.aggregated)
30981
- return undefined;
30982
30985
  const dataSets = this.dataSets
30983
30986
  .map((ds) => toExcelDataset(this.getters, ds))
30984
30987
  .filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference);
@@ -33454,18 +33457,28 @@ function isCtrlKey(ev) {
33454
33457
  function useInterval(callback, delay) {
33455
33458
  let intervalId;
33456
33459
  const { setInterval, clearInterval } = window;
33460
+ const pause = () => {
33461
+ clearInterval(intervalId);
33462
+ intervalId = undefined;
33463
+ };
33464
+ const safeCallback = () => {
33465
+ try {
33466
+ callback();
33467
+ }
33468
+ catch (e) {
33469
+ pause();
33470
+ throw e;
33471
+ }
33472
+ };
33457
33473
  owl.useEffect(() => {
33458
- intervalId = setInterval(callback, delay);
33474
+ intervalId = setInterval(safeCallback, delay);
33459
33475
  return () => clearInterval(intervalId);
33460
33476
  }, () => [delay]);
33461
33477
  return {
33462
- pause: () => {
33463
- clearInterval(intervalId);
33464
- intervalId = undefined;
33465
- },
33478
+ pause,
33466
33479
  resume: () => {
33467
33480
  if (intervalId === undefined) {
33468
- intervalId = setInterval(callback, delay);
33481
+ intervalId = setInterval(safeCallback, delay);
33469
33482
  }
33470
33483
  },
33471
33484
  };
@@ -38561,7 +38574,7 @@ class ColorPicker extends owl.Component {
38561
38574
  }
38562
38575
  setHexColor(ev) {
38563
38576
  // only support HEX code input
38564
- const val = ev.target.value.slice(0, 7);
38577
+ const val = ev.target.value.replace("##", "#").slice(0, 7);
38565
38578
  this.state.customHexColor = val;
38566
38579
  if (!isColorValid(val)) ;
38567
38580
  else {
@@ -50454,7 +50467,7 @@ css /* scss */ `
50454
50467
  position: absolute;
50455
50468
  top: 0;
50456
50469
  left: ${HEADER_WIDTH}px;
50457
- right: 0;
50470
+ right: ${SCROLLBAR_WIDTH}px;
50458
50471
  height: ${HEADER_HEIGHT}px;
50459
50472
  &.o-dragging {
50460
50473
  cursor: grabbing;
@@ -50620,9 +50633,8 @@ css /* scss */ `
50620
50633
  position: absolute;
50621
50634
  top: ${HEADER_HEIGHT}px;
50622
50635
  left: 0;
50623
- right: 0;
50636
+ bottom: ${SCROLLBAR_WIDTH}px;
50624
50637
  width: ${HEADER_WIDTH}px;
50625
- height: calc(100% - ${HEADER_HEIGHT + SCROLLBAR_WIDTH}px);
50626
50638
  &.o-dragging {
50627
50639
  cursor: grabbing;
50628
50640
  }
@@ -58623,6 +58635,15 @@ function adaptPivotRange(range, applyChange) {
58623
58635
  }
58624
58636
  }
58625
58637
  class SpreadsheetPivotCorePlugin extends CorePlugin {
58638
+ allowDispatch(cmd) {
58639
+ switch (cmd.type) {
58640
+ case "ADD_PIVOT":
58641
+ case "UPDATE_PIVOT":
58642
+ const definition = cmd.pivot;
58643
+ return this.checkDataSetValidity(definition);
58644
+ }
58645
+ return "Success" /* CommandResult.Success */;
58646
+ }
58626
58647
  adaptRanges(applyChange) {
58627
58648
  for (const pivotId of this.getters.getPivotIds()) {
58628
58649
  const definition = this.getters.getPivotCoreDefinition(pivotId);
@@ -58641,6 +58662,16 @@ class SpreadsheetPivotCorePlugin extends CorePlugin {
58641
58662
  }
58642
58663
  }
58643
58664
  }
58665
+ checkDataSetValidity(definition) {
58666
+ if (definition.type === "SPREADSHEET" && definition.dataSet) {
58667
+ const { zone, sheetId } = definition.dataSet;
58668
+ if (!sheetId || !this.getters.tryGetSheet(sheetId) || !zone || !isZoneValid(zone)) {
58669
+ return "InvalidDataSet" /* CommandResult.InvalidDataSet */;
58670
+ }
58671
+ return this.getters.checkZonesExistInSheet(sheetId, [zone]);
58672
+ }
58673
+ return "Success" /* CommandResult.Success */;
58674
+ }
58644
58675
  }
58645
58676
 
58646
58677
  class TableStylePlugin extends CorePlugin {
@@ -61440,7 +61471,7 @@ class DynamicTablesPlugin extends UIPlugin {
61440
61471
  tables = {};
61441
61472
  handle(cmd) {
61442
61473
  if (invalidateEvaluationCommands.has(cmd.type) ||
61443
- (cmd.type === "UPDATE_CELL" && "content" in cmd) ||
61474
+ (cmd.type === "UPDATE_CELL" && ("content" in cmd || "format" in cmd)) ||
61444
61475
  cmd.type === "EVALUATE_CELLS") {
61445
61476
  this.tables = {};
61446
61477
  return;
@@ -61873,6 +61904,16 @@ function withPivotPresentationLayer (PivotClass) {
61873
61904
  }
61874
61905
  return values;
61875
61906
  }
61907
+ else if (rowDomain.length === this.definition.rows.length &&
61908
+ colDomain.length &&
61909
+ colDomain.length < this.definition.columns.length) {
61910
+ const colSubTree = this.getSubTreeMatchingDomain(table.getColTree(), colDomain);
61911
+ const domains = this.treeToLeafDomains(colSubTree, colDomain);
61912
+ for (const domain of domains) {
61913
+ values.push(this._getPivotCellValueAndFormat(measure.id, rowDomain.concat(domain)));
61914
+ }
61915
+ return values;
61916
+ }
61876
61917
  else {
61877
61918
  const tree = table.getRowTree();
61878
61919
  const subTree = this.getSubTreeMatchingDomain(tree, rowDomain);
@@ -65287,7 +65328,7 @@ class TableComputedStylePlugin extends UIPlugin {
65287
65328
  tableStyles = {};
65288
65329
  handle(cmd) {
65289
65330
  if (invalidateEvaluationCommands.has(cmd.type) ||
65290
- (cmd.type === "UPDATE_CELL" && "content" in cmd) ||
65331
+ (cmd.type === "UPDATE_CELL" && ("content" in cmd || "format" in cmd)) ||
65291
65332
  cmd.type === "EVALUATE_CELLS") {
65292
65333
  this.tableStyles = {};
65293
65334
  return;
@@ -67251,6 +67292,8 @@ class GridSelectionPlugin extends UIPlugin {
67251
67292
  });
67252
67293
  this.selectCell(col, row);
67253
67294
  }
67295
+ const { col, row } = this.gridSelection.anchor.cell;
67296
+ this.moveClient({ sheetId: this.activeSheet.id, col, row });
67254
67297
  }
67255
67298
  /**
67256
67299
  * Ensure selections are not outside sheet boundaries.
@@ -67990,8 +68033,11 @@ class SheetViewPlugin extends UIPlugin {
67990
68033
  case "REMOVE_TABLE":
67991
68034
  case "UPDATE_TABLE":
67992
68035
  case "UPDATE_FILTER":
67993
- this.sheetsWithDirtyViewports.add(cmd.sheetId);
67994
- break;
68036
+ case "UNFREEZE_ROWS":
68037
+ case "UNFREEZE_COLUMNS":
68038
+ case "FREEZE_COLUMNS":
68039
+ case "FREEZE_ROWS":
68040
+ case "UNFREEZE_COLUMNS_ROWS":
67995
68041
  case "REMOVE_COLUMNS_ROWS":
67996
68042
  case "RESIZE_COLUMNS_ROWS":
67997
68043
  case "HIDE_COLUMNS_ROWS":
@@ -68004,11 +68050,9 @@ class SheetViewPlugin extends UIPlugin {
68004
68050
  case "FOLD_HEADER_GROUPS_IN_ZONE":
68005
68051
  case "UNFOLD_HEADER_GROUPS_IN_ZONE":
68006
68052
  case "UNFOLD_ALL_HEADER_GROUPS":
68007
- case "FOLD_ALL_HEADER_GROUPS": {
68008
- const sheetId = "sheetId" in cmd ? cmd.sheetId : this.getters.getActiveSheetId();
68009
- this.sheetsWithDirtyViewports.add(sheetId);
68053
+ case "FOLD_ALL_HEADER_GROUPS":
68054
+ this.sheetsWithDirtyViewports.add(cmd.sheetId);
68010
68055
  break;
68011
- }
68012
68056
  case "UPDATE_CELL":
68013
68057
  // update cell content or format can change hidden rows because of data filters
68014
68058
  if ("content" in cmd || "format" in cmd || cmd.style?.fontSize !== undefined) {
@@ -68024,13 +68068,6 @@ class SheetViewPlugin extends UIPlugin {
68024
68068
  case "ACTIVATE_SHEET":
68025
68069
  this.sheetsWithDirtyViewports.add(cmd.sheetIdTo);
68026
68070
  break;
68027
- case "UNFREEZE_ROWS":
68028
- case "UNFREEZE_COLUMNS":
68029
- case "FREEZE_COLUMNS":
68030
- case "FREEZE_ROWS":
68031
- case "UNFREEZE_COLUMNS_ROWS":
68032
- this.resetViewports(this.getters.getActiveSheetId());
68033
- break;
68034
68071
  case "SCROLL_TO_CELL":
68035
68072
  this.refreshViewport(this.getters.getActiveSheetId(), { col: cmd.col, row: cmd.row });
68036
68073
  break;
@@ -69208,7 +69245,7 @@ class AggregateStatisticsStore extends SpreadsheetStore {
69208
69245
  }
69209
69246
  handle(cmd) {
69210
69247
  if (invalidateEvaluationCommands.has(cmd.type) ||
69211
- (cmd.type === "UPDATE_CELL" && "content" in cmd)) {
69248
+ (cmd.type === "UPDATE_CELL" && ("content" in cmd || "format" in cmd))) {
69212
69249
  this.isDirty = true;
69213
69250
  }
69214
69251
  switch (cmd.type) {
@@ -75769,6 +75806,6 @@ exports.tokenColors = tokenColors;
75769
75806
  exports.tokenize = tokenize;
75770
75807
 
75771
75808
 
75772
- __info__.version = "18.1.16";
75773
- __info__.date = "2025-04-18T16:24:16.854Z";
75774
- __info__.hash = "19f6de2";
75809
+ __info__.version = "18.1.18";
75810
+ __info__.date = "2025-05-02T12:30:47.822Z";
75811
+ __info__.hash = "29c21c6";
@@ -3147,7 +3147,8 @@ declare const enum CommandResult {
3147
3147
  EmptyName = "EmptyName",
3148
3148
  ValueCellIsInvalidFormula = "ValueCellIsInvalidFormula",
3149
3149
  InvalidDefinition = "InvalidDefinition",
3150
- InvalidColor = "InvalidColor"
3150
+ InvalidColor = "InvalidColor",
3151
+ InvalidPivotDataSet = "InvalidPivotDataSet"
3151
3152
  }
3152
3153
  interface CommandHandler<T> {
3153
3154
  allowDispatch(command: T): CommandResult | CommandResult[];
@@ -8558,6 +8559,7 @@ declare class ChartJsComponent extends Component<Props$O, SpreadsheetChildEnv> {
8558
8559
  private canvas;
8559
8560
  private chart?;
8560
8561
  private currentRuntime;
8562
+ private currentDevicePixelRatio;
8561
8563
  get background(): string;
8562
8564
  get canvasStyle(): string;
8563
8565
  get chartRuntime(): ChartJSRuntime;
@@ -11522,7 +11524,8 @@ declare const CellErrorType: {
11522
11524
  readonly GenericError: "#ERROR";
11523
11525
  readonly NullError: "#NULL!";
11524
11526
  };
11525
- declare class EvaluationError extends Error {
11527
+ declare class EvaluationError {
11528
+ readonly message: string;
11526
11529
  readonly value: string;
11527
11530
  constructor(message?: string, value?: string);
11528
11531
  }