@odoo/o-spreadsheet 18.0.2 → 18.0.3

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.3
6
+ * @date 2024-11-08T12:17:49.992Z
7
+ * @hash 5fa5fbb
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -9345,14 +9345,19 @@ stores.inject(MyMetaStore, storeInstance);
9345
9345
  if (values.length < 2 || labels.length < 2 || newLabels.length === 0) {
9346
9346
  return [];
9347
9347
  }
9348
+ const labelMin = Math.min(...labels);
9349
+ const labelMax = Math.max(...labels);
9350
+ const labelRange = labelMax - labelMin;
9351
+ const normalizedLabels = labels.map((v) => (v - labelMin) / labelRange);
9352
+ const normalizedNewLabels = newLabels.map((v) => (v - labelMin) / labelRange);
9348
9353
  switch (config.type) {
9349
9354
  case "polynomial": {
9350
9355
  const order = config.order ?? 2;
9351
9356
  if (order === 1) {
9352
- return predictLinearValues([values], [labels], [newLabels], true)[0];
9357
+ return predictLinearValues([values], [normalizedLabels], [normalizedNewLabels], true)[0];
9353
9358
  }
9354
- const coeffs = polynomialRegression(values, labels, order, true).flat();
9355
- return newLabels.map((v) => evaluatePolynomial(coeffs, v, order));
9359
+ const coeffs = polynomialRegression(values, normalizedLabels, order, true).flat();
9360
+ return normalizedNewLabels.map((v) => evaluatePolynomial(coeffs, v, order));
9356
9361
  }
9357
9362
  case "exponential": {
9358
9363
  const positiveLogValues = [];
@@ -9360,16 +9365,16 @@ stores.inject(MyMetaStore, storeInstance);
9360
9365
  for (let i = 0; i < values.length; i++) {
9361
9366
  if (values[i] > 0) {
9362
9367
  positiveLogValues.push(Math.log(values[i]));
9363
- filteredLabels.push(labels[i]);
9368
+ filteredLabels.push(normalizedLabels[i]);
9364
9369
  }
9365
9370
  }
9366
9371
  if (!filteredLabels.length) {
9367
9372
  return [];
9368
9373
  }
9369
- return expM(predictLinearValues([positiveLogValues], [filteredLabels], [newLabels], true))[0];
9374
+ return expM(predictLinearValues([positiveLogValues], [filteredLabels], [normalizedNewLabels], true))[0];
9370
9375
  }
9371
9376
  case "logarithmic": {
9372
- return predictLinearValues([values], logM([labels]), logM([newLabels]), true)[0];
9377
+ return predictLinearValues([values], logM([normalizedLabels]), logM([normalizedNewLabels]), true)[0];
9373
9378
  }
9374
9379
  default:
9375
9380
  return [];
@@ -9505,6 +9510,10 @@ stores.inject(MyMetaStore, storeInstance);
9505
9510
  function drawPieChartValues(chart, options, ctx) {
9506
9511
  for (const dataset of chart._metasets) {
9507
9512
  for (let i = 0; i < dataset._parsed.length; i++) {
9513
+ const value = Number(dataset._parsed[i]);
9514
+ if (isNaN(value) || value === 0) {
9515
+ continue;
9516
+ }
9508
9517
  const bar = dataset.data[i];
9509
9518
  const { startAngle, endAngle, innerRadius, outerRadius } = bar;
9510
9519
  const midAngle = (startAngle + endAngle) / 2;
@@ -9513,8 +9522,8 @@ stores.inject(MyMetaStore, storeInstance);
9513
9522
  const y = bar.y + midRadius * Math.sin(midAngle) + 7;
9514
9523
  ctx.fillStyle = chartFontColor(options.background);
9515
9524
  ctx.strokeStyle = options.background || "#ffffff";
9516
- const value = options.callback(dataset._parsed[i]);
9517
- drawTextWithBackground(value, x, y, ctx);
9525
+ const displayValue = options.callback(value);
9526
+ drawTextWithBackground(displayValue, x, y, ctx);
9518
9527
  }
9519
9528
  }
9520
9529
  }
@@ -14593,7 +14602,7 @@ stores.inject(MyMetaStore, storeInstance);
14593
14602
  const result = [];
14594
14603
  for (let i = 0; i < _array.length; i++) {
14595
14604
  const row = _array[i];
14596
- if (_conditions.every((c) => c[i])) {
14605
+ if (_conditions.every((c) => (typeof c[i] === "boolean" || typeof c[i] === "number") && c[i])) {
14597
14606
  result.push(row);
14598
14607
  }
14599
14608
  }
@@ -16988,7 +16997,10 @@ stores.inject(MyMetaStore, storeInstance);
16988
16997
  case "STRING":
16989
16998
  return { type: "STRING", value: removeStringQuotes(current.value) };
16990
16999
  case "INVALID_REFERENCE":
16991
- throw new InvalidReferenceError();
17000
+ return {
17001
+ type: "REFERENCE",
17002
+ value: CellErrorType.InvalidReference,
17003
+ };
16992
17004
  case "REFERENCE":
16993
17005
  if (tokens[0]?.value === ":" && tokens[1]?.type === "REFERENCE") {
16994
17006
  tokens.shift();
@@ -27872,6 +27884,7 @@ stores.inject(MyMetaStore, storeInstance);
27872
27884
  StackedBarChart: _t("Stacked bar chart"),
27873
27885
  StackedLineChart: _t("Stacked line chart"),
27874
27886
  StackedAreaChart: _t("Stacked area chart"),
27887
+ StackedColumnChart: _t("Stacked column chart"),
27875
27888
  CumulativeData: _t("Cumulative data"),
27876
27889
  TreatLabelsAsText: _t("Treat labels as text"),
27877
27890
  AggregatedChart: _t("Aggregate"),
@@ -28810,8 +28823,8 @@ stores.inject(MyMetaStore, storeInstance);
28810
28823
  break;
28811
28824
  case "time":
28812
28825
  for (const point of dataset.data) {
28813
- const date = toJsDate({ value: point.x }, locale).getTime();
28814
- if (typeof point.y === "number") {
28826
+ const date = toNumber({ value: point.x }, locale);
28827
+ if (point.y !== null) {
28815
28828
  filteredValues.push(point.y);
28816
28829
  filteredLabels.push(date);
28817
28830
  }
@@ -29043,10 +29056,6 @@ stores.inject(MyMetaStore, storeInstance);
29043
29056
  return {
29044
29057
  chartJsConfig: config,
29045
29058
  background: chart.background || BACKGROUND_CHART_COLOR,
29046
- dataSetsValues,
29047
- labelValues,
29048
- dataSetFormat,
29049
- labelFormat,
29050
29059
  };
29051
29060
  }
29052
29061
 
@@ -36281,6 +36290,12 @@ stores.inject(MyMetaStore, storeInstance);
36281
36290
 
36282
36291
  class BarConfigPanel extends GenericChartConfigPanel {
36283
36292
  static template = "o-spreadsheet-BarConfigPanel";
36293
+ get stackedLabel() {
36294
+ const definition = this.props.definition;
36295
+ return definition.horizontal
36296
+ ? this.chartTerms.StackedBarChart
36297
+ : this.chartTerms.StackedColumnChart;
36298
+ }
36284
36299
  onUpdateStacked(stacked) {
36285
36300
  this.props.updateChart(this.props.figureId, {
36286
36301
  stacked,
@@ -37603,7 +37618,9 @@ stores.inject(MyMetaStore, storeInstance);
37603
37618
  }
37604
37619
  get stackedLabel() {
37605
37620
  const definition = this.props.definition;
37606
- return definition.fillArea ? this.chartTerms.StackedAreaChart : this.chartTerms.StackedBarChart;
37621
+ return definition.fillArea
37622
+ ? this.chartTerms.StackedAreaChart
37623
+ : this.chartTerms.StackedLineChart;
37607
37624
  }
37608
37625
  getLabelRangeOptions() {
37609
37626
  const options = super.getLabelRangeOptions();
@@ -59617,6 +59634,10 @@ stores.inject(MyMetaStore, storeInstance);
59617
59634
  if (!pivot.isValid()) {
59618
59635
  return EMPTY_PIVOT_CELL;
59619
59636
  }
59637
+ if (functionName === "PIVOT" &&
59638
+ !cell.content.replaceAll(" ", "").toUpperCase().startsWith("=PIVOT")) {
59639
+ return EMPTY_PIVOT_CELL;
59640
+ }
59620
59641
  if (functionName === "PIVOT") {
59621
59642
  const includeTotal = args[2] === false ? false : undefined;
59622
59643
  const includeColumnHeaders = args[3] === false ? false : undefined;
@@ -70390,7 +70411,8 @@ stores.inject(MyMetaStore, storeInstance);
70390
70411
  }
70391
70412
  const attrs = [["t", type]];
70392
70413
  const XlsxFormula = adaptFormulaToExcel(formula);
70393
- const node = escapeXml /*xml*/ `<f>${XlsxFormula}</f><v>${cell.value}</v>`;
70414
+ const exportedValue = adaptFormulaValueToExcel(cell.value);
70415
+ const node = escapeXml /*xml*/ `<f>${XlsxFormula}</f><v>${exportedValue}</v>`;
70394
70416
  return { attrs, node };
70395
70417
  }
70396
70418
  function addContent(content, sharedStrings, forceString = false) {
@@ -70425,8 +70447,14 @@ stores.inject(MyMetaStore, storeInstance);
70425
70447
  ast = addMissingRequiredArgs(ast);
70426
70448
  return ast;
70427
70449
  });
70450
+ ast = convertAstNodes(ast, "REFERENCE", (ast) => {
70451
+ return ast.value === CellErrorType.InvalidReference ? { ...ast, value: "#REF!" } : ast;
70452
+ });
70428
70453
  return ast ? astToFormula(ast) : formulaText;
70429
70454
  }
70455
+ function adaptFormulaValueToExcel(formulaValue) {
70456
+ return formulaValue === CellErrorType.InvalidReference ? "#REF!" : formulaValue;
70457
+ }
70430
70458
  /**
70431
70459
  * Some Excel function need required args that might not be mandatory in o-spreadsheet.
70432
70460
  * This adds those missing args.
@@ -72401,6 +72429,7 @@ stores.inject(MyMetaStore, storeInstance);
72401
72429
  PIVOT_TABLE_CONFIG,
72402
72430
  TREND_LINE_XAXIS_ID,
72403
72431
  CHART_AXIS_CHOICES,
72432
+ ChartTerms,
72404
72433
  };
72405
72434
 
72406
72435
  exports.AbstractCellClipboardHandler = AbstractCellClipboardHandler;
@@ -72449,9 +72478,9 @@ stores.inject(MyMetaStore, storeInstance);
72449
72478
  exports.tokenize = tokenize;
72450
72479
 
72451
72480
 
72452
- __info__.version = "18.0.2";
72453
- __info__.date = "2024-10-24T08:54:21.934Z";
72454
- __info__.hash = "788df92";
72481
+ __info__.version = "18.0.3";
72482
+ __info__.date = "2024-11-08T12:17:49.992Z";
72483
+ __info__.hash = "5fa5fbb";
72455
72484
 
72456
72485
 
72457
72486
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);