@odoo/o-spreadsheet 18.0.2 → 18.0.4

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.0.2
6
- * @date 2024-10-24T08:54:21.934Z
7
- * @hash 788df92
5
+ * @version 18.0.4
6
+ * @date 2024-11-13T15:08:50.620Z
7
+ * @hash 88e1aee
8
8
  */
9
9
 
10
10
  'use strict';
@@ -9322,38 +9322,40 @@ function getFullTrendingLineDataSet(dataset, config, data) {
9322
9322
  const defaultBorderColor = colorToRGBA(dataset.backgroundColor);
9323
9323
  defaultBorderColor.a = 1;
9324
9324
  const borderColor = config.color || lightenColor(rgbaToHex(defaultBorderColor), 0.5);
9325
- const backgroundRGBA = colorToRGBA(borderColor);
9326
- // @ts-expect-error
9327
- if (dataset?.fill) {
9328
- backgroundRGBA.a = LINE_FILL_TRANSPARENCY; // to support area charts
9329
- }
9330
9325
  return {
9331
- ...dataset,
9332
9326
  type: "line",
9333
9327
  xAxisID: TREND_LINE_XAXIS_ID,
9328
+ yAxisID: dataset.yAxisID,
9334
9329
  label: dataset.label ? _t("Trend line for %s", dataset.label) : "",
9335
9330
  data,
9336
9331
  order: -1,
9337
9332
  showLine: true,
9338
9333
  pointRadius: 0,
9339
- backgroundColor: rgbaToHex(backgroundRGBA),
9334
+ backgroundColor: borderColor,
9340
9335
  borderColor,
9341
9336
  borderDash: [5, 5],
9342
9337
  borderWidth: undefined,
9338
+ fill: false,
9339
+ pointBackgroundColor: borderColor,
9343
9340
  };
9344
9341
  }
9345
9342
  function interpolateData(config, values, labels, newLabels) {
9346
9343
  if (values.length < 2 || labels.length < 2 || newLabels.length === 0) {
9347
9344
  return [];
9348
9345
  }
9346
+ const labelMin = Math.min(...labels);
9347
+ const labelMax = Math.max(...labels);
9348
+ const labelRange = labelMax - labelMin;
9349
+ const normalizedLabels = labels.map((v) => (v - labelMin) / labelRange);
9350
+ const normalizedNewLabels = newLabels.map((v) => (v - labelMin) / labelRange);
9349
9351
  switch (config.type) {
9350
9352
  case "polynomial": {
9351
9353
  const order = config.order ?? 2;
9352
9354
  if (order === 1) {
9353
- return predictLinearValues([values], [labels], [newLabels], true)[0];
9355
+ return predictLinearValues([values], [normalizedLabels], [normalizedNewLabels], true)[0];
9354
9356
  }
9355
- const coeffs = polynomialRegression(values, labels, order, true).flat();
9356
- return newLabels.map((v) => evaluatePolynomial(coeffs, v, order));
9357
+ const coeffs = polynomialRegression(values, normalizedLabels, order, true).flat();
9358
+ return normalizedNewLabels.map((v) => evaluatePolynomial(coeffs, v, order));
9357
9359
  }
9358
9360
  case "exponential": {
9359
9361
  const positiveLogValues = [];
@@ -9361,16 +9363,16 @@ function interpolateData(config, values, labels, newLabels) {
9361
9363
  for (let i = 0; i < values.length; i++) {
9362
9364
  if (values[i] > 0) {
9363
9365
  positiveLogValues.push(Math.log(values[i]));
9364
- filteredLabels.push(labels[i]);
9366
+ filteredLabels.push(normalizedLabels[i]);
9365
9367
  }
9366
9368
  }
9367
9369
  if (!filteredLabels.length) {
9368
9370
  return [];
9369
9371
  }
9370
- return expM(predictLinearValues([positiveLogValues], [filteredLabels], [newLabels], true))[0];
9372
+ return expM(predictLinearValues([positiveLogValues], [filteredLabels], [normalizedNewLabels], true))[0];
9371
9373
  }
9372
9374
  case "logarithmic": {
9373
- return predictLinearValues([values], logM([labels]), logM([newLabels]), true)[0];
9375
+ return predictLinearValues([values], logM([normalizedLabels]), logM([normalizedNewLabels]), true)[0];
9374
9376
  }
9375
9377
  default:
9376
9378
  return [];
@@ -9506,6 +9508,10 @@ function drawHorizontalBarChartValues(chart, options, ctx) {
9506
9508
  function drawPieChartValues(chart, options, ctx) {
9507
9509
  for (const dataset of chart._metasets) {
9508
9510
  for (let i = 0; i < dataset._parsed.length; i++) {
9511
+ const value = Number(dataset._parsed[i]);
9512
+ if (isNaN(value) || value === 0) {
9513
+ continue;
9514
+ }
9509
9515
  const bar = dataset.data[i];
9510
9516
  const { startAngle, endAngle, innerRadius, outerRadius } = bar;
9511
9517
  const midAngle = (startAngle + endAngle) / 2;
@@ -9514,8 +9520,8 @@ function drawPieChartValues(chart, options, ctx) {
9514
9520
  const y = bar.y + midRadius * Math.sin(midAngle) + 7;
9515
9521
  ctx.fillStyle = chartFontColor(options.background);
9516
9522
  ctx.strokeStyle = options.background || "#ffffff";
9517
- const value = options.callback(dataset._parsed[i]);
9518
- drawTextWithBackground(value, x, y, ctx);
9523
+ const displayValue = options.callback(value);
9524
+ drawTextWithBackground(displayValue, x, y, ctx);
9519
9525
  }
9520
9526
  }
9521
9527
  }
@@ -14594,7 +14600,7 @@ const FILTER = {
14594
14600
  const result = [];
14595
14601
  for (let i = 0; i < _array.length; i++) {
14596
14602
  const row = _array[i];
14597
- if (_conditions.every((c) => c[i])) {
14603
+ if (_conditions.every((c) => (typeof c[i] === "boolean" || typeof c[i] === "number") && c[i])) {
14598
14604
  result.push(row);
14599
14605
  }
14600
14606
  }
@@ -16989,7 +16995,10 @@ function parseOperand(tokens) {
16989
16995
  case "STRING":
16990
16996
  return { type: "STRING", value: removeStringQuotes(current.value) };
16991
16997
  case "INVALID_REFERENCE":
16992
- throw new InvalidReferenceError();
16998
+ return {
16999
+ type: "REFERENCE",
17000
+ value: CellErrorType.InvalidReference,
17001
+ };
16993
17002
  case "REFERENCE":
16994
17003
  if (tokens[0]?.value === ":" && tokens[1]?.type === "REFERENCE") {
16995
17004
  tokens.shift();
@@ -27873,6 +27882,7 @@ const ChartTerms = {
27873
27882
  StackedBarChart: _t("Stacked bar chart"),
27874
27883
  StackedLineChart: _t("Stacked line chart"),
27875
27884
  StackedAreaChart: _t("Stacked area chart"),
27885
+ StackedColumnChart: _t("Stacked column chart"),
27876
27886
  CumulativeData: _t("Cumulative data"),
27877
27887
  TreatLabelsAsText: _t("Treat labels as text"),
27878
27888
  AggregatedChart: _t("Aggregate"),
@@ -28159,11 +28169,14 @@ function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale, tr
28159
28169
  function getChartLabelFormat(getters, range) {
28160
28170
  if (!range)
28161
28171
  return undefined;
28162
- return getters.getEvaluatedCell({
28163
- sheetId: range.sheetId,
28164
- col: range.zone.left,
28165
- row: range.zone.top,
28166
- }).format;
28172
+ const { sheetId, zone: { left, top, bottom }, } = range;
28173
+ for (let row = top; row <= bottom; row++) {
28174
+ const format = getters.getEvaluatedCell({ sheetId, col: left, row }).format;
28175
+ if (format) {
28176
+ return format;
28177
+ }
28178
+ }
28179
+ return undefined;
28167
28180
  }
28168
28181
  function getChartLabelValues(getters, dataSets, labelRange) {
28169
28182
  let labels = { values: [], formattedValues: [] };
@@ -28744,11 +28757,7 @@ function canBeDateChart(labelRange, getters) {
28744
28757
  if (!labelRange || !canBeLinearChart(labelRange, getters)) {
28745
28758
  return false;
28746
28759
  }
28747
- const labelFormat = getters.getEvaluatedCell({
28748
- sheetId: labelRange.sheetId,
28749
- col: labelRange.zone.left,
28750
- row: labelRange.zone.top,
28751
- }).format;
28760
+ const labelFormat = getChartLabelFormat(getters, labelRange);
28752
28761
  return Boolean(labelFormat && timeFormatLuxonCompatible.test(labelFormat));
28753
28762
  }
28754
28763
  function canBeLinearChart(labelRange, getters) {
@@ -28811,8 +28820,8 @@ function getTrendDatasetForLineChart(config, dataset, axisType, locale) {
28811
28820
  break;
28812
28821
  case "time":
28813
28822
  for (const point of dataset.data) {
28814
- const date = toJsDate({ value: point.x }, locale).getTime();
28815
- if (typeof point.y === "number") {
28823
+ const date = toNumber({ value: point.x }, locale);
28824
+ if (point.y !== null) {
28816
28825
  filteredValues.push(point.y);
28817
28826
  filteredLabels.push(date);
28818
28827
  }
@@ -29044,10 +29053,6 @@ function createLineOrScatterChartRuntime(chart, getters) {
29044
29053
  return {
29045
29054
  chartJsConfig: config,
29046
29055
  background: chart.background || BACKGROUND_CHART_COLOR,
29047
- dataSetsValues,
29048
- labelValues,
29049
- dataSetFormat,
29050
- labelFormat,
29051
29056
  };
29052
29057
  }
29053
29058
 
@@ -36282,6 +36287,12 @@ class GenericChartConfigPanel extends owl.Component {
36282
36287
 
36283
36288
  class BarConfigPanel extends GenericChartConfigPanel {
36284
36289
  static template = "o-spreadsheet-BarConfigPanel";
36290
+ get stackedLabel() {
36291
+ const definition = this.props.definition;
36292
+ return definition.horizontal
36293
+ ? this.chartTerms.StackedBarChart
36294
+ : this.chartTerms.StackedColumnChart;
36295
+ }
36285
36296
  onUpdateStacked(stacked) {
36286
36297
  this.props.updateChart(this.props.figureId, {
36287
36298
  stacked,
@@ -36716,6 +36727,7 @@ class ColorPicker extends owl.Component {
36716
36727
  currentColor: { type: String, optional: true },
36717
36728
  maxHeight: { type: Number, optional: true },
36718
36729
  anchorRect: Object,
36730
+ disableNoColor: { type: Boolean, optional: true },
36719
36731
  };
36720
36732
  static defaultProps = { currentColor: "" };
36721
36733
  static components = { Popover };
@@ -36942,6 +36954,7 @@ class RoundColorPicker extends owl.Component {
36942
36954
  currentColor: { type: String, optional: true },
36943
36955
  title: { type: String, optional: true },
36944
36956
  onColorPicked: Function,
36957
+ disableNoColor: { type: Boolean, optional: true },
36945
36958
  };
36946
36959
  colorPickerButtonRef = owl.useRef("colorPickerButton");
36947
36960
  state;
@@ -37604,7 +37617,9 @@ class LineConfigPanel extends GenericChartConfigPanel {
37604
37617
  }
37605
37618
  get stackedLabel() {
37606
37619
  const definition = this.props.definition;
37607
- return definition.fillArea ? this.chartTerms.StackedAreaChart : this.chartTerms.StackedBarChart;
37620
+ return definition.fillArea
37621
+ ? this.chartTerms.StackedAreaChart
37622
+ : this.chartTerms.StackedLineChart;
37608
37623
  }
37609
37624
  getLabelRangeOptions() {
37610
37625
  const options = super.getLabelRangeOptions();
@@ -39718,6 +39733,9 @@ class ConditionalFormattingEditor extends owl.Component {
39718
39733
  }
39719
39734
  }
39720
39735
  setColorScaleColor(target, color) {
39736
+ if (!isColorValid(color)) {
39737
+ return;
39738
+ }
39721
39739
  const point = this.state.rules.colorScale[target];
39722
39740
  if (point) {
39723
39741
  point.color = Number.parseInt(color.substr(1), 16);
@@ -59618,6 +59636,10 @@ class PivotUIPlugin extends UIPlugin {
59618
59636
  if (!pivot.isValid()) {
59619
59637
  return EMPTY_PIVOT_CELL;
59620
59638
  }
59639
+ if (functionName === "PIVOT" &&
59640
+ !cell.content.replaceAll(" ", "").toUpperCase().startsWith("=PIVOT")) {
59641
+ return EMPTY_PIVOT_CELL;
59642
+ }
59621
59643
  if (functionName === "PIVOT") {
59622
59644
  const includeTotal = args[2] === false ? false : undefined;
59623
59645
  const includeColumnHeaders = args[3] === false ? false : undefined;
@@ -70391,7 +70413,8 @@ function addFormula(cell) {
70391
70413
  }
70392
70414
  const attrs = [["t", type]];
70393
70415
  const XlsxFormula = adaptFormulaToExcel(formula);
70394
- const node = escapeXml /*xml*/ `<f>${XlsxFormula}</f><v>${cell.value}</v>`;
70416
+ const exportedValue = adaptFormulaValueToExcel(cell.value);
70417
+ const node = escapeXml /*xml*/ `<f>${XlsxFormula}</f><v>${exportedValue}</v>`;
70395
70418
  return { attrs, node };
70396
70419
  }
70397
70420
  function addContent(content, sharedStrings, forceString = false) {
@@ -70426,8 +70449,14 @@ function adaptFormulaToExcel(formulaText) {
70426
70449
  ast = addMissingRequiredArgs(ast);
70427
70450
  return ast;
70428
70451
  });
70452
+ ast = convertAstNodes(ast, "REFERENCE", (ast) => {
70453
+ return ast.value === CellErrorType.InvalidReference ? { ...ast, value: "#REF!" } : ast;
70454
+ });
70429
70455
  return ast ? astToFormula(ast) : formulaText;
70430
70456
  }
70457
+ function adaptFormulaValueToExcel(formulaValue) {
70458
+ return formulaValue === CellErrorType.InvalidReference ? "#REF!" : formulaValue;
70459
+ }
70431
70460
  /**
70432
70461
  * Some Excel function need required args that might not be mandatory in o-spreadsheet.
70433
70462
  * This adds those missing args.
@@ -72402,6 +72431,7 @@ const constants = {
72402
72431
  PIVOT_TABLE_CONFIG,
72403
72432
  TREND_LINE_XAXIS_ID,
72404
72433
  CHART_AXIS_CHOICES,
72434
+ ChartTerms,
72405
72435
  };
72406
72436
 
72407
72437
  exports.AbstractCellClipboardHandler = AbstractCellClipboardHandler;
@@ -72450,6 +72480,6 @@ exports.tokenColors = tokenColors;
72450
72480
  exports.tokenize = tokenize;
72451
72481
 
72452
72482
 
72453
- __info__.version = "18.0.2";
72454
- __info__.date = "2024-10-24T08:54:21.934Z";
72455
- __info__.hash = "788df92";
72483
+ __info__.version = "18.0.4";
72484
+ __info__.date = "2024-11-13T15:08:50.620Z";
72485
+ __info__.hash = "88e1aee";