@odoo/o-spreadsheet 18.1.0-alpha.5 → 18.1.0-alpha.6

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.0-alpha.5
6
- * @date 2024-11-22T14:22:50.899Z
7
- * @hash e13bd67
5
+ * @version 18.1.0-alpha.6
6
+ * @date 2024-11-28T09:06:59.527Z
7
+ * @hash 875c901
8
8
  */
9
9
 
10
10
  'use strict';
@@ -3498,7 +3498,9 @@ exports.CommandResult = void 0;
3498
3498
  CommandResult["MaxInvalidFormula"] = "MaxInvalidFormula";
3499
3499
  CommandResult["ValueUpperInvalidFormula"] = "ValueUpperInvalidFormula";
3500
3500
  CommandResult["ValueLowerInvalidFormula"] = "ValueLowerInvalidFormula";
3501
+ CommandResult["InvalidSortAnchor"] = "InvalidSortAnchor";
3501
3502
  CommandResult["InvalidSortZone"] = "InvalidSortZone";
3503
+ CommandResult["SortZoneWithArrayFormulas"] = "SortZoneWithArrayFormulas";
3502
3504
  CommandResult["WaitingSessionConfirmation"] = "WaitingSessionConfirmation";
3503
3505
  CommandResult["MergeOverlap"] = "MergeOverlap";
3504
3506
  CommandResult["TooManyHiddenElements"] = "TooManyHiddenElements";
@@ -3554,7 +3556,6 @@ exports.CommandResult = void 0;
3554
3556
  CommandResult["ValueCellIsInvalidFormula"] = "ValueCellIsInvalidFormula";
3555
3557
  CommandResult["InvalidDefinition"] = "InvalidDefinition";
3556
3558
  CommandResult["InvalidColor"] = "InvalidColor";
3557
- CommandResult["DataBarRangeValuesMismatch"] = "DataBarRangeValuesMismatch";
3558
3559
  })(exports.CommandResult || (exports.CommandResult = {}));
3559
3560
 
3560
3561
  const DEFAULT_LOCALES = [
@@ -14671,7 +14672,6 @@ function sortCells(cells, sortDirection, emptyCellAsZero) {
14671
14672
  return cellsToSort.sort(cellsSortingCriterion(sortDirection));
14672
14673
  }
14673
14674
  function interactiveSortSelection(env, sheetId, anchor, zone, sortDirection) {
14674
- let result = DispatchResult.Success;
14675
14675
  //several columns => bypass the contiguity check
14676
14676
  let multiColumns = zone.right > zone.left;
14677
14677
  if (env.model.getters.doesIntersectMerge(sheetId, zone)) {
@@ -14691,49 +14691,37 @@ function interactiveSortSelection(env, sheetId, anchor, zone, sortDirection) {
14691
14691
  }
14692
14692
  }
14693
14693
  }
14694
- const { col, row } = anchor;
14695
14694
  if (multiColumns) {
14696
- result = env.model.dispatch("SORT_CELLS", { sheetId, col, row, zone, sortDirection });
14695
+ interactiveSort(env, sheetId, anchor, zone, sortDirection);
14696
+ return;
14697
+ }
14698
+ const contiguousZone = env.model.getters.getContiguousZone(sheetId, zone);
14699
+ if (isEqual(contiguousZone, zone)) {
14700
+ interactiveSort(env, sheetId, anchor, zone, sortDirection);
14697
14701
  }
14698
14702
  else {
14699
- // check contiguity
14700
- const contiguousZone = env.model.getters.getContiguousZone(sheetId, zone);
14701
- if (isEqual(contiguousZone, zone)) {
14702
- // merge as it is
14703
- result = env.model.dispatch("SORT_CELLS", {
14704
- sheetId,
14705
- col,
14706
- row,
14707
- zone,
14708
- sortDirection,
14709
- });
14710
- }
14711
- else {
14712
- env.askConfirmation(_t("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"), () => {
14713
- zone = contiguousZone;
14714
- result = env.model.dispatch("SORT_CELLS", {
14715
- sheetId,
14716
- col,
14717
- row,
14718
- zone,
14719
- sortDirection,
14720
- });
14721
- }, () => {
14722
- result = env.model.dispatch("SORT_CELLS", {
14723
- sheetId,
14724
- col,
14725
- row,
14726
- zone,
14727
- sortDirection,
14728
- });
14729
- });
14730
- }
14703
+ env.askConfirmation(_t("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"), () => interactiveSort(env, sheetId, anchor, contiguousZone, sortDirection), () => interactiveSort(env, sheetId, anchor, zone, sortDirection));
14731
14704
  }
14705
+ }
14706
+ function interactiveSort(env, sheetId, anchor, zone, sortDirection, sortOptions) {
14707
+ const result = env.model.dispatch("SORT_CELLS", {
14708
+ sheetId,
14709
+ col: anchor.col,
14710
+ row: anchor.row,
14711
+ zone,
14712
+ sortDirection,
14713
+ sortOptions,
14714
+ });
14732
14715
  if (result.isCancelledBecause("InvalidSortZone" /* CommandResult.InvalidSortZone */)) {
14733
14716
  const { col, row } = anchor;
14734
14717
  env.model.selection.selectZone({ cell: { col, row }, zone });
14735
14718
  env.raiseError(_t("Cannot sort. To sort, select only cells or only merges that have the same size."));
14736
14719
  }
14720
+ if (result.isCancelledBecause("SortZoneWithArrayFormulas" /* CommandResult.SortZoneWithArrayFormulas */)) {
14721
+ const { col, row } = anchor;
14722
+ env.model.selection.selectZone({ cell: { col, row }, zone });
14723
+ env.raiseError(_t("Cannot sort a zone with array formulas."));
14724
+ }
14737
14725
  }
14738
14726
 
14739
14727
  function sortMatrix(matrix, locale, ...criteria) {
@@ -27721,7 +27709,6 @@ const CfTerms = {
27721
27709
  ["ValueLowerInvalidFormula" /* CommandResult.ValueLowerInvalidFormula */]: _t("Invalid lower inflection point formula"),
27722
27710
  ["EmptyRange" /* CommandResult.EmptyRange */]: _t("A range needs to be defined"),
27723
27711
  ["ValueCellIsInvalidFormula" /* CommandResult.ValueCellIsInvalidFormula */]: _t("At least one of the provided values is an invalid formula"),
27724
- ["DataBarRangeValuesMismatch" /* CommandResult.DataBarRangeValuesMismatch */]: _t("All the ranges and the range values must have the same size"),
27725
27712
  Unexpected: _t("The rule is invalid for an unknown reason"),
27726
27713
  },
27727
27714
  ColorScale: _t("Color scale"),
@@ -29095,20 +29082,27 @@ function getWaterfallChartScales(definition, args) {
29095
29082
  return scales;
29096
29083
  }
29097
29084
  function getPyramidChartScales(definition, args) {
29085
+ const { dataSetsValues } = args;
29098
29086
  const scales = getBarChartScales(definition, args);
29099
29087
  const scalesXCallback = scales.x.ticks.callback;
29100
29088
  scales.x.ticks.callback = (value) => scalesXCallback(Math.abs(value));
29089
+ const maxValue = Math.max(...dataSetsValues.map((dataSet) => Math.max(...dataSet.data.map(Math.abs))));
29090
+ scales.x.suggestedMin = -maxValue;
29091
+ scales.x.suggestedMax = maxValue;
29101
29092
  return scales;
29102
29093
  }
29103
29094
  function getRadarChartScales(definition, args) {
29104
- const { locale, axisFormats } = args;
29095
+ const { locale, axisFormats, dataSetsValues } = args;
29096
+ const minValue = Math.min(...dataSetsValues.map((ds) => Math.min(...ds.data.filter((x) => !isNaN(x)))));
29105
29097
  return {
29106
29098
  r: {
29099
+ beginAtZero: true,
29107
29100
  ticks: {
29108
29101
  callback: formatTickValue({ format: axisFormats?.r, locale }),
29109
29102
  backdropColor: definition.background || "#FFFFFF",
29110
29103
  },
29111
29104
  pointLabels: { color: chartFontColor(definition.background) },
29105
+ suggestedMin: minValue < 0 ? minValue - 1 : 0,
29112
29106
  },
29113
29107
  };
29114
29108
  }
@@ -32209,14 +32203,9 @@ class FilterMenu extends owl.Component {
32209
32203
  }
32210
32204
  const sheetId = this.env.model.getters.getActiveSheetId();
32211
32205
  const contentZone = { ...tableZone, top: tableZone.top + 1 };
32212
- this.env.model.dispatch("SORT_CELLS", {
32213
- sheetId,
32214
- col: filterPosition.col,
32215
- row: contentZone.top,
32216
- zone: contentZone,
32217
- sortDirection,
32218
- sortOptions: { emptyCellAsZero: true, sortHeaders: true },
32219
- });
32206
+ const sortAnchor = { col: filterPosition.col, row: contentZone.top };
32207
+ const sortOptions = { emptyCellAsZero: true, sortHeaders: true };
32208
+ interactiveSort(this.env, sheetId, sortAnchor, contentZone, sortDirection, sortOptions);
32220
32209
  this.props.onClosed?.();
32221
32210
  }
32222
32211
  }
@@ -34232,6 +34221,7 @@ const pivotProperties = {
34232
34221
  const pivotId = env.model.getters.getPivotIdFromPosition(position);
34233
34222
  return (pivotId && env.model.getters.isExistingPivot(pivotId)) || false;
34234
34223
  },
34224
+ isReadonlyAllowed: true,
34235
34225
  icon: "o-spreadsheet-Icon.PIVOT",
34236
34226
  };
34237
34227
  const FIX_FORMULAS = {
@@ -35949,6 +35939,7 @@ topbarMenuRegistry
35949
35939
  id: `item_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`,
35950
35940
  name: env.model.getters.getPivotDisplayName(pivotId),
35951
35941
  sequence: sequence + index,
35942
+ isReadonlyAllowed: true,
35952
35943
  execute: (env) => env.openSidePanel("PivotSidePanel", { pivotId }),
35953
35944
  onStartHover: (env) => env.getStore(HighlightStore).register(highlightProvider),
35954
35945
  onStopHover: (env) => env.getStore(HighlightStore).unRegister(highlightProvider),
@@ -52904,8 +52895,6 @@ class ConditionalFormatPlugin extends CorePlugin {
52904
52895
  case "IconSetRule": {
52905
52896
  return this.checkValidations(rule, this.chainValidations(this.checkInflectionPoints(this.checkNaN), this.checkLowerBiggerThanUpper), this.chainValidations(this.checkInflectionPoints(this.checkFormulaCompilation)));
52906
52897
  }
52907
- case "DataBarRule":
52908
- return this.checkDataBarRangeValues(rule, cmd.ranges, cmd.sheetId);
52909
52898
  }
52910
52899
  return "Success" /* CommandResult.Success */;
52911
52900
  }
@@ -53036,18 +53025,6 @@ class ConditionalFormatPlugin extends CorePlugin {
53036
53025
  }
53037
53026
  return "Success" /* CommandResult.Success */;
53038
53027
  }
53039
- checkDataBarRangeValues(rule, ranges, sheetId) {
53040
- if (rule.rangeValues) {
53041
- const { numberOfCols, numberOfRows } = zoneToDimension(this.getters.getRangeFromSheetXC(sheetId, rule.rangeValues).zone);
53042
- for (const range of ranges) {
53043
- const dimensions = zoneToDimension(this.getters.getRangeFromRangeData(range).zone);
53044
- if (numberOfCols !== dimensions.numberOfCols || numberOfRows !== dimensions.numberOfRows) {
53045
- return "DataBarRangeValuesMismatch" /* CommandResult.DataBarRangeValuesMismatch */;
53046
- }
53047
- }
53048
- }
53049
- return "Success" /* CommandResult.Success */;
53050
- }
53051
53028
  removeConditionalFormatting(id, sheet) {
53052
53029
  const cfIndex = this.cfRules[sheet].findIndex((s) => s.id === id);
53053
53030
  if (cfIndex !== -1) {
@@ -59452,8 +59429,12 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
59452
59429
  const zoneOfValues = rangeValues.zone;
59453
59430
  for (let row = zone.top; row <= zone.bottom; row++) {
59454
59431
  for (let col = zone.left; col <= zone.right; col++) {
59455
- const cell = this.getEvaluatedCellInZone(sheetId, zone, col, row, zoneOfValues);
59456
- if (cell.type !== CellValueType.number || cell.value <= 0) {
59432
+ const targetCol = col - zone.left + zoneOfValues.left;
59433
+ const targetRow = row - zone.top + zoneOfValues.top;
59434
+ const cell = this.getters.getEvaluatedCell({ sheetId, col: targetCol, row: targetRow });
59435
+ if (!isInside(targetCol, targetRow, zoneOfValues) ||
59436
+ cell.type !== CellValueType.number ||
59437
+ cell.value <= 0) {
59457
59438
  // values negatives or 0 are ignored
59458
59439
  continue;
59459
59440
  }
@@ -59466,11 +59447,6 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
59466
59447
  }
59467
59448
  }
59468
59449
  }
59469
- getEvaluatedCellInZone(sheetId, zone, col, row, targetZone) {
59470
- const targetCol = col - zone.left + targetZone.left;
59471
- const targetRow = row - zone.top + targetZone.top;
59472
- return this.getters.getEvaluatedCell({ sheetId, col: targetCol, row: targetRow });
59473
- }
59474
59450
  /** Compute the color scale for the given range and CF rule, and apply in in the given computedStyle object */
59475
59451
  applyColorScale(sheetId, range, rule, computedStyle) {
59476
59452
  const minValue = this.parsePoint(sheetId, range, rule.minimum, "min");
@@ -63048,9 +63024,9 @@ class SortPlugin extends UIPlugin {
63048
63024
  switch (cmd.type) {
63049
63025
  case "SORT_CELLS":
63050
63026
  if (!isInside(cmd.col, cmd.row, cmd.zone)) {
63051
- throw new Error(_t("The anchor must be part of the provided zone"));
63027
+ return "InvalidSortAnchor" /* CommandResult.InvalidSortAnchor */;
63052
63028
  }
63053
- return this.checkValidations(cmd, this.checkMerge, this.checkMergeSizes);
63029
+ return this.checkValidations(cmd, this.checkMerge, this.checkMergeSizes, this.checkArrayFormulaInSortZone);
63054
63030
  }
63055
63031
  return "Success" /* CommandResult.Success */;
63056
63032
  }
@@ -63091,6 +63067,10 @@ class SortPlugin extends UIPlugin {
63091
63067
  }
63092
63068
  return "Success" /* CommandResult.Success */;
63093
63069
  }
63070
+ checkArrayFormulaInSortZone({ sheetId, zone }) {
63071
+ const arrayFormulaInZone = positions(zone).some(({ col, row }) => this.getters.getArrayFormulaSpreadingOn({ sheetId, col, row }));
63072
+ return arrayFormulaInZone ? "SortZoneWithArrayFormulas" /* CommandResult.SortZoneWithArrayFormulas */ : "Success" /* CommandResult.Success */;
63073
+ }
63094
63074
  /**
63095
63075
  * This function evaluates if the top row of a provided zone can be considered as a `header`
63096
63076
  * by checking the following criteria:
@@ -73692,6 +73672,9 @@ const components = {
73692
73672
  GaugeChartDesignPanel,
73693
73673
  ScorecardChartConfigPanel,
73694
73674
  ScorecardChartDesignPanel,
73675
+ RadarChartDesignPanel,
73676
+ WaterfallChartDesignPanel,
73677
+ ComboChartDesignPanel,
73695
73678
  ChartTypePicker,
73696
73679
  FigureComponent,
73697
73680
  Menu,
@@ -73745,6 +73728,7 @@ const constants = {
73745
73728
  DEFAULT_LOCALE,
73746
73729
  HIGHLIGHT_COLOR,
73747
73730
  PIVOT_TABLE_CONFIG,
73731
+ ChartTerms,
73748
73732
  };
73749
73733
  const chartHelpers = { ...CHART_HELPERS, ...CHART_RUNTIME_HELPERS };
73750
73734
 
@@ -73795,6 +73779,6 @@ exports.tokenColors = tokenColors;
73795
73779
  exports.tokenize = tokenize;
73796
73780
 
73797
73781
 
73798
- __info__.version = "18.1.0-alpha.5";
73799
- __info__.date = "2024-11-22T14:22:50.899Z";
73800
- __info__.hash = "e13bd67";
73782
+ __info__.version = "18.1.0-alpha.6";
73783
+ __info__.date = "2024-11-28T09:06:59.527Z";
73784
+ __info__.hash = "875c901";