@odoo/o-spreadsheet 16.1.24 → 16.1.26

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.
@@ -4707,7 +4707,7 @@ function createGaugeChartRuntime(chart, getters) {
4707
4707
  });
4708
4708
  return {
4709
4709
  chartJsConfig: config,
4710
- background: getters.getBackgroundOfSingleCellChart(chart.background, dataRange),
4710
+ background: getters.getStyleOfSingleCellChart(chart.background, dataRange).background,
4711
4711
  };
4712
4712
  }
4713
4713
 
@@ -5384,7 +5384,7 @@ function createScorecardChartRuntime(chart, getters) {
5384
5384
  };
5385
5385
  baselineCell = getters.getEvaluatedCell(baselinePosition);
5386
5386
  }
5387
- const background = getters.getBackgroundOfSingleCellChart(chart.background, chart.keyValue);
5387
+ const { background, fontColor } = getters.getStyleOfSingleCellChart(chart.background, chart.keyValue);
5388
5388
  return {
5389
5389
  title: _t(chart.title),
5390
5390
  keyValue: formattedKeyValue || keyValue,
@@ -5392,7 +5392,7 @@ function createScorecardChartRuntime(chart, getters) {
5392
5392
  baselineArrow: getBaselineArrowDirection(baselineCell, keyValueCell, chart.baselineMode),
5393
5393
  baselineColor: getBaselineColor(baselineCell, chart.baselineMode, keyValueCell, chart.baselineColorUp, chart.baselineColorDown),
5394
5394
  baselineDescr: chart.baselineDescr ? _t(chart.baselineDescr) : "",
5395
- fontColor: chartFontColor(background),
5395
+ fontColor,
5396
5396
  background,
5397
5397
  baselineStyle: chart.baselineMode !== "percentage" && baseline
5398
5398
  ? getters.getCellStyle({
@@ -29929,7 +29929,11 @@ class HeaderSizePlugin extends CorePlugin {
29929
29929
  let sizes = [...this.sizes[cmd.sheetId][cmd.dimension]];
29930
29930
  const addIndex = getAddHeaderStartIndex(cmd.position, cmd.base);
29931
29931
  const baseSize = sizes[cmd.base];
29932
- sizes.splice(addIndex, 0, ...Array(cmd.quantity).fill(baseSize));
29932
+ const sizesToInsert = range(0, cmd.quantity).map(() => ({
29933
+ manualSize: baseSize.manualSize,
29934
+ computedSize: lazy(baseSize.computedSize()),
29935
+ }));
29936
+ sizes.splice(addIndex, 0, ...sizesToInsert);
29933
29937
  sizes = sizes.map((size, row) => {
29934
29938
  if (cmd.dimension === "ROW" && row > cmd.base + cmd.quantity) {
29935
29939
  // invalidate sizes
@@ -32662,28 +32666,29 @@ class EvaluationChartPlugin extends UIPlugin {
32662
32666
  return this.charts[figureId];
32663
32667
  }
32664
32668
  /**
32665
- * Get the background color of a chart based on the color of the first cell of the main range
32666
- * of the chart. In order of priority, it will return :
32667
- *
32668
- * - the chart background color if one is defined
32669
- * - the fill color of the cell if one is defined
32670
- * - the fill color of the cell from conditional formats if one is defined
32671
- * - the default chart color if no other color is defined
32669
+ * Get the background and textColor of a chart based on the color of the first cell of the main range of the chart.
32672
32670
  */
32673
- getBackgroundOfSingleCellChart(chartBackground, mainRange) {
32671
+ getStyleOfSingleCellChart(chartBackground, mainRange) {
32674
32672
  if (chartBackground)
32675
- return chartBackground;
32673
+ return { background: chartBackground, fontColor: chartFontColor(chartBackground) };
32676
32674
  if (!mainRange) {
32677
- return BACKGROUND_CHART_COLOR;
32675
+ return {
32676
+ background: BACKGROUND_CHART_COLOR,
32677
+ fontColor: chartFontColor(BACKGROUND_CHART_COLOR),
32678
+ };
32678
32679
  }
32679
32680
  const col = mainRange.zone.left;
32680
32681
  const row = mainRange.zone.top;
32681
32682
  const sheetId = mainRange.sheetId;
32682
32683
  const style = this.getters.getCellComputedStyle({ sheetId, col, row });
32683
- return style.fillColor || BACKGROUND_CHART_COLOR;
32684
+ const background = style.fillColor || BACKGROUND_CHART_COLOR;
32685
+ return {
32686
+ background,
32687
+ fontColor: style.textColor || chartFontColor(background),
32688
+ };
32684
32689
  }
32685
32690
  }
32686
- EvaluationChartPlugin.getters = ["getChartRuntime", "getBackgroundOfSingleCellChart"];
32691
+ EvaluationChartPlugin.getters = ["getChartRuntime", "getStyleOfSingleCellChart"];
32687
32692
 
32688
32693
  // -----------------------------------------------------------------------------
32689
32694
  // Constants
@@ -39044,11 +39049,19 @@ class GridSelectionPlugin extends UIPlugin {
39044
39049
  }
39045
39050
  }
39046
39051
  getStatisticFnResults() {
39047
- // get deduplicated cells in zones
39048
- const cells = new Set(this.gridSelection.zones
39049
- .map((zone) => this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(), zone))
39050
- .flat()
39051
- .filter((cell) => cell.type !== CellValueType.empty));
39052
+ const sheetId = this.getters.getActiveSheetId();
39053
+ const cells = new Set();
39054
+ for (const zone of this.gridSelection.zones) {
39055
+ for (const { col, row } of positions(zone)) {
39056
+ if (this.getters.isRowHidden(sheetId, row) || this.getters.isColHidden(sheetId, col)) {
39057
+ continue; // Skip hidden cells
39058
+ }
39059
+ const evaluatedCell = this.getters.getEvaluatedCell({ sheetId, col, row });
39060
+ if (evaluatedCell.type !== CellValueType.empty) {
39061
+ cells.add(evaluatedCell);
39062
+ }
39063
+ }
39064
+ }
39052
39065
  let cellsTypes = new Set();
39053
39066
  let cellsValues = [];
39054
39067
  for (let cell of cells) {
@@ -44427,6 +44440,6 @@ exports.setTranslationMethod = setTranslationMethod;
44427
44440
  exports.tokenize = tokenize;
44428
44441
 
44429
44442
 
44430
- __info__.version = '16.1.24';
44431
- __info__.date = '2023-10-19T14:21:55.097Z';
44432
- __info__.hash = '1b9e9d0';
44443
+ __info__.version = '16.1.26';
44444
+ __info__.date = '2023-11-02T09:31:23.420Z';
44445
+ __info__.hash = '1ddd8d0';
@@ -3831,22 +3831,20 @@ declare class EvaluationPlugin extends UIPlugin {
3831
3831
  private isBadExpression;
3832
3832
  }
3833
3833
 
3834
+ interface EvaluationChartStyle {
3835
+ background: Color;
3836
+ fontColor: Color;
3837
+ }
3834
3838
  declare class EvaluationChartPlugin extends UIPlugin {
3835
- static getters: readonly ["getChartRuntime", "getBackgroundOfSingleCellChart"];
3839
+ static getters: readonly ["getChartRuntime", "getStyleOfSingleCellChart"];
3836
3840
  readonly charts: Record<UID, ChartRuntime | undefined>;
3837
3841
  private createRuntimeChart;
3838
3842
  handle(cmd: Command): void;
3839
3843
  getChartRuntime(figureId: UID): ChartRuntime;
3840
3844
  /**
3841
- * Get the background color of a chart based on the color of the first cell of the main range
3842
- * of the chart. In order of priority, it will return :
3843
- *
3844
- * - the chart background color if one is defined
3845
- * - the fill color of the cell if one is defined
3846
- * - the fill color of the cell from conditional formats if one is defined
3847
- * - the default chart color if no other color is defined
3845
+ * Get the background and textColor of a chart based on the color of the first cell of the main range of the chart.
3848
3846
  */
3849
- getBackgroundOfSingleCellChart(chartBackground: Color | undefined, mainRange: Range | undefined): Color;
3847
+ getStyleOfSingleCellChart(chartBackground: Color | undefined, mainRange: Range | undefined): EvaluationChartStyle;
3850
3848
  }
3851
3849
 
3852
3850
  declare class EvaluationConditionalFormatPlugin extends UIPlugin {
@@ -4703,7 +4703,7 @@ function createGaugeChartRuntime(chart, getters) {
4703
4703
  });
4704
4704
  return {
4705
4705
  chartJsConfig: config,
4706
- background: getters.getBackgroundOfSingleCellChart(chart.background, dataRange),
4706
+ background: getters.getStyleOfSingleCellChart(chart.background, dataRange).background,
4707
4707
  };
4708
4708
  }
4709
4709
 
@@ -5380,7 +5380,7 @@ function createScorecardChartRuntime(chart, getters) {
5380
5380
  };
5381
5381
  baselineCell = getters.getEvaluatedCell(baselinePosition);
5382
5382
  }
5383
- const background = getters.getBackgroundOfSingleCellChart(chart.background, chart.keyValue);
5383
+ const { background, fontColor } = getters.getStyleOfSingleCellChart(chart.background, chart.keyValue);
5384
5384
  return {
5385
5385
  title: _t(chart.title),
5386
5386
  keyValue: formattedKeyValue || keyValue,
@@ -5388,7 +5388,7 @@ function createScorecardChartRuntime(chart, getters) {
5388
5388
  baselineArrow: getBaselineArrowDirection(baselineCell, keyValueCell, chart.baselineMode),
5389
5389
  baselineColor: getBaselineColor(baselineCell, chart.baselineMode, keyValueCell, chart.baselineColorUp, chart.baselineColorDown),
5390
5390
  baselineDescr: chart.baselineDescr ? _t(chart.baselineDescr) : "",
5391
- fontColor: chartFontColor(background),
5391
+ fontColor,
5392
5392
  background,
5393
5393
  baselineStyle: chart.baselineMode !== "percentage" && baseline
5394
5394
  ? getters.getCellStyle({
@@ -29925,7 +29925,11 @@ class HeaderSizePlugin extends CorePlugin {
29925
29925
  let sizes = [...this.sizes[cmd.sheetId][cmd.dimension]];
29926
29926
  const addIndex = getAddHeaderStartIndex(cmd.position, cmd.base);
29927
29927
  const baseSize = sizes[cmd.base];
29928
- sizes.splice(addIndex, 0, ...Array(cmd.quantity).fill(baseSize));
29928
+ const sizesToInsert = range(0, cmd.quantity).map(() => ({
29929
+ manualSize: baseSize.manualSize,
29930
+ computedSize: lazy(baseSize.computedSize()),
29931
+ }));
29932
+ sizes.splice(addIndex, 0, ...sizesToInsert);
29929
29933
  sizes = sizes.map((size, row) => {
29930
29934
  if (cmd.dimension === "ROW" && row > cmd.base + cmd.quantity) {
29931
29935
  // invalidate sizes
@@ -32658,28 +32662,29 @@ class EvaluationChartPlugin extends UIPlugin {
32658
32662
  return this.charts[figureId];
32659
32663
  }
32660
32664
  /**
32661
- * Get the background color of a chart based on the color of the first cell of the main range
32662
- * of the chart. In order of priority, it will return :
32663
- *
32664
- * - the chart background color if one is defined
32665
- * - the fill color of the cell if one is defined
32666
- * - the fill color of the cell from conditional formats if one is defined
32667
- * - the default chart color if no other color is defined
32665
+ * Get the background and textColor of a chart based on the color of the first cell of the main range of the chart.
32668
32666
  */
32669
- getBackgroundOfSingleCellChart(chartBackground, mainRange) {
32667
+ getStyleOfSingleCellChart(chartBackground, mainRange) {
32670
32668
  if (chartBackground)
32671
- return chartBackground;
32669
+ return { background: chartBackground, fontColor: chartFontColor(chartBackground) };
32672
32670
  if (!mainRange) {
32673
- return BACKGROUND_CHART_COLOR;
32671
+ return {
32672
+ background: BACKGROUND_CHART_COLOR,
32673
+ fontColor: chartFontColor(BACKGROUND_CHART_COLOR),
32674
+ };
32674
32675
  }
32675
32676
  const col = mainRange.zone.left;
32676
32677
  const row = mainRange.zone.top;
32677
32678
  const sheetId = mainRange.sheetId;
32678
32679
  const style = this.getters.getCellComputedStyle({ sheetId, col, row });
32679
- return style.fillColor || BACKGROUND_CHART_COLOR;
32680
+ const background = style.fillColor || BACKGROUND_CHART_COLOR;
32681
+ return {
32682
+ background,
32683
+ fontColor: style.textColor || chartFontColor(background),
32684
+ };
32680
32685
  }
32681
32686
  }
32682
- EvaluationChartPlugin.getters = ["getChartRuntime", "getBackgroundOfSingleCellChart"];
32687
+ EvaluationChartPlugin.getters = ["getChartRuntime", "getStyleOfSingleCellChart"];
32683
32688
 
32684
32689
  // -----------------------------------------------------------------------------
32685
32690
  // Constants
@@ -39040,11 +39045,19 @@ class GridSelectionPlugin extends UIPlugin {
39040
39045
  }
39041
39046
  }
39042
39047
  getStatisticFnResults() {
39043
- // get deduplicated cells in zones
39044
- const cells = new Set(this.gridSelection.zones
39045
- .map((zone) => this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(), zone))
39046
- .flat()
39047
- .filter((cell) => cell.type !== CellValueType.empty));
39048
+ const sheetId = this.getters.getActiveSheetId();
39049
+ const cells = new Set();
39050
+ for (const zone of this.gridSelection.zones) {
39051
+ for (const { col, row } of positions(zone)) {
39052
+ if (this.getters.isRowHidden(sheetId, row) || this.getters.isColHidden(sheetId, col)) {
39053
+ continue; // Skip hidden cells
39054
+ }
39055
+ const evaluatedCell = this.getters.getEvaluatedCell({ sheetId, col, row });
39056
+ if (evaluatedCell.type !== CellValueType.empty) {
39057
+ cells.add(evaluatedCell);
39058
+ }
39059
+ }
39060
+ }
39048
39061
  let cellsTypes = new Set();
39049
39062
  let cellsValues = [];
39050
39063
  for (let cell of cells) {
@@ -44395,6 +44408,6 @@ function addFunction(functionName, functionDescription) {
44395
44408
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, links, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
44396
44409
 
44397
44410
 
44398
- __info__.version = '16.1.24';
44399
- __info__.date = '2023-10-19T14:21:55.097Z';
44400
- __info__.hash = '1b9e9d0';
44411
+ __info__.version = '16.1.26';
44412
+ __info__.date = '2023-11-02T09:31:23.420Z';
44413
+ __info__.hash = '1ddd8d0';
@@ -4704,7 +4704,7 @@
4704
4704
  });
4705
4705
  return {
4706
4706
  chartJsConfig: config,
4707
- background: getters.getBackgroundOfSingleCellChart(chart.background, dataRange),
4707
+ background: getters.getStyleOfSingleCellChart(chart.background, dataRange).background,
4708
4708
  };
4709
4709
  }
4710
4710
 
@@ -5381,7 +5381,7 @@
5381
5381
  };
5382
5382
  baselineCell = getters.getEvaluatedCell(baselinePosition);
5383
5383
  }
5384
- const background = getters.getBackgroundOfSingleCellChart(chart.background, chart.keyValue);
5384
+ const { background, fontColor } = getters.getStyleOfSingleCellChart(chart.background, chart.keyValue);
5385
5385
  return {
5386
5386
  title: _t(chart.title),
5387
5387
  keyValue: formattedKeyValue || keyValue,
@@ -5389,7 +5389,7 @@
5389
5389
  baselineArrow: getBaselineArrowDirection(baselineCell, keyValueCell, chart.baselineMode),
5390
5390
  baselineColor: getBaselineColor(baselineCell, chart.baselineMode, keyValueCell, chart.baselineColorUp, chart.baselineColorDown),
5391
5391
  baselineDescr: chart.baselineDescr ? _t(chart.baselineDescr) : "",
5392
- fontColor: chartFontColor(background),
5392
+ fontColor,
5393
5393
  background,
5394
5394
  baselineStyle: chart.baselineMode !== "percentage" && baseline
5395
5395
  ? getters.getCellStyle({
@@ -29926,7 +29926,11 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29926
29926
  let sizes = [...this.sizes[cmd.sheetId][cmd.dimension]];
29927
29927
  const addIndex = getAddHeaderStartIndex(cmd.position, cmd.base);
29928
29928
  const baseSize = sizes[cmd.base];
29929
- sizes.splice(addIndex, 0, ...Array(cmd.quantity).fill(baseSize));
29929
+ const sizesToInsert = range(0, cmd.quantity).map(() => ({
29930
+ manualSize: baseSize.manualSize,
29931
+ computedSize: lazy(baseSize.computedSize()),
29932
+ }));
29933
+ sizes.splice(addIndex, 0, ...sizesToInsert);
29930
29934
  sizes = sizes.map((size, row) => {
29931
29935
  if (cmd.dimension === "ROW" && row > cmd.base + cmd.quantity) {
29932
29936
  // invalidate sizes
@@ -32659,28 +32663,29 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32659
32663
  return this.charts[figureId];
32660
32664
  }
32661
32665
  /**
32662
- * Get the background color of a chart based on the color of the first cell of the main range
32663
- * of the chart. In order of priority, it will return :
32664
- *
32665
- * - the chart background color if one is defined
32666
- * - the fill color of the cell if one is defined
32667
- * - the fill color of the cell from conditional formats if one is defined
32668
- * - the default chart color if no other color is defined
32666
+ * Get the background and textColor of a chart based on the color of the first cell of the main range of the chart.
32669
32667
  */
32670
- getBackgroundOfSingleCellChart(chartBackground, mainRange) {
32668
+ getStyleOfSingleCellChart(chartBackground, mainRange) {
32671
32669
  if (chartBackground)
32672
- return chartBackground;
32670
+ return { background: chartBackground, fontColor: chartFontColor(chartBackground) };
32673
32671
  if (!mainRange) {
32674
- return BACKGROUND_CHART_COLOR;
32672
+ return {
32673
+ background: BACKGROUND_CHART_COLOR,
32674
+ fontColor: chartFontColor(BACKGROUND_CHART_COLOR),
32675
+ };
32675
32676
  }
32676
32677
  const col = mainRange.zone.left;
32677
32678
  const row = mainRange.zone.top;
32678
32679
  const sheetId = mainRange.sheetId;
32679
32680
  const style = this.getters.getCellComputedStyle({ sheetId, col, row });
32680
- return style.fillColor || BACKGROUND_CHART_COLOR;
32681
+ const background = style.fillColor || BACKGROUND_CHART_COLOR;
32682
+ return {
32683
+ background,
32684
+ fontColor: style.textColor || chartFontColor(background),
32685
+ };
32681
32686
  }
32682
32687
  }
32683
- EvaluationChartPlugin.getters = ["getChartRuntime", "getBackgroundOfSingleCellChart"];
32688
+ EvaluationChartPlugin.getters = ["getChartRuntime", "getStyleOfSingleCellChart"];
32684
32689
 
32685
32690
  // -----------------------------------------------------------------------------
32686
32691
  // Constants
@@ -39041,11 +39046,19 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
39041
39046
  }
39042
39047
  }
39043
39048
  getStatisticFnResults() {
39044
- // get deduplicated cells in zones
39045
- const cells = new Set(this.gridSelection.zones
39046
- .map((zone) => this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(), zone))
39047
- .flat()
39048
- .filter((cell) => cell.type !== CellValueType.empty));
39049
+ const sheetId = this.getters.getActiveSheetId();
39050
+ const cells = new Set();
39051
+ for (const zone of this.gridSelection.zones) {
39052
+ for (const { col, row } of positions(zone)) {
39053
+ if (this.getters.isRowHidden(sheetId, row) || this.getters.isColHidden(sheetId, col)) {
39054
+ continue; // Skip hidden cells
39055
+ }
39056
+ const evaluatedCell = this.getters.getEvaluatedCell({ sheetId, col, row });
39057
+ if (evaluatedCell.type !== CellValueType.empty) {
39058
+ cells.add(evaluatedCell);
39059
+ }
39060
+ }
39061
+ }
39049
39062
  let cellsTypes = new Set();
39050
39063
  let cellsValues = [];
39051
39064
  for (let cell of cells) {
@@ -44426,9 +44439,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
44426
44439
  Object.defineProperty(exports, '__esModule', { value: true });
44427
44440
 
44428
44441
 
44429
- __info__.version = '16.1.24';
44430
- __info__.date = '2023-10-19T14:21:55.097Z';
44431
- __info__.hash = '1b9e9d0';
44442
+ __info__.version = '16.1.26';
44443
+ __info__.date = '2023-11-02T09:31:23.420Z';
44444
+ __info__.hash = '1ddd8d0';
44432
44445
 
44433
44446
 
44434
44447
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);