@odoo/o-spreadsheet 17.0.20 → 17.0.22

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 17.0.20
6
- * @date 2024-04-26T07:37:04.503Z
7
- * @hash 065ac98
5
+ * @version 17.0.22
6
+ * @date 2024-05-15T09:18:36.212Z
7
+ * @hash 1f90749
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -641,7 +641,7 @@
641
641
  /**
642
642
  * Compares two objects.
643
643
  */
644
- function deepEquals(o1, o2) {
644
+ function deepEquals(o1, o2, ignoreFunctions) {
645
645
  if (o1 === o2)
646
646
  return true;
647
647
  if ((o1 && !o2) || (o2 && !o1))
@@ -657,13 +657,16 @@
657
657
  }
658
658
  }
659
659
  for (const key in o1) {
660
- if (typeof o1[key] !== typeof o2[key])
660
+ const typeOfO1Key = typeof o1[key];
661
+ if (typeOfO1Key !== typeof o2[key])
661
662
  return false;
662
- if (typeof o1[key] === "object") {
663
- if (!deepEquals(o1[key], o2[key]))
663
+ if (typeOfO1Key === "object") {
664
+ if (!deepEquals(o1[key], o2[key], ignoreFunctions))
664
665
  return false;
665
666
  }
666
667
  else {
668
+ if (ignoreFunctions && typeOfO1Key === "function")
669
+ return true;
667
670
  if (o1[key] !== o2[key])
668
671
  return false;
669
672
  }
@@ -3558,21 +3561,22 @@
3558
3561
  xc = xc.split("!").at(-1);
3559
3562
  }
3560
3563
  if (xc.includes("$")) {
3561
- xc = xc.replace(/\$/g, "");
3564
+ xc = xc.replaceAll("$", "");
3562
3565
  }
3563
- let ranges;
3566
+ let firstRangePart = "";
3567
+ let secondRangePart;
3564
3568
  if (xc.includes(":")) {
3565
- ranges = xc.split(":").map((x) => x.trim());
3569
+ [firstRangePart, secondRangePart] = xc.split(":");
3570
+ firstRangePart = firstRangePart.trim();
3571
+ secondRangePart = secondRangePart.trim();
3566
3572
  }
3567
3573
  else {
3568
- ranges = [xc.trim()];
3574
+ firstRangePart = xc.trim();
3569
3575
  }
3570
3576
  let top, bottom, left, right;
3571
3577
  let fullCol = false;
3572
3578
  let fullRow = false;
3573
3579
  let hasHeader = false;
3574
- const firstRangePart = ranges[0];
3575
- const secondRangePart = ranges[1] && ranges[1];
3576
3580
  if (isColReference(firstRangePart)) {
3577
3581
  left = right = lettersToNumber(firstRangePart);
3578
3582
  top = bottom = 0;
@@ -3589,7 +3593,7 @@
3589
3593
  top = bottom = c.row;
3590
3594
  hasHeader = true;
3591
3595
  }
3592
- if (ranges.length === 2) {
3596
+ if (secondRangePart) {
3593
3597
  if (isColReference(secondRangePart)) {
3594
3598
  right = lettersToNumber(secondRangePart);
3595
3599
  fullCol = true;
@@ -4758,6 +4762,7 @@
4758
4762
  static template = "o-spreadsheet-ChartJsComponent";
4759
4763
  canvas = owl.useRef("graphContainer");
4760
4764
  chart;
4765
+ currentRuntime;
4761
4766
  get background() {
4762
4767
  return this.chartRuntime.background;
4763
4768
  }
@@ -4774,9 +4779,17 @@
4774
4779
  setup() {
4775
4780
  owl.onMounted(() => {
4776
4781
  const runtime = this.chartRuntime;
4777
- this.createChart(runtime.chartJsConfig);
4782
+ this.currentRuntime = runtime;
4783
+ // Note: chartJS modify the runtime in place, so it's important to give it a copy
4784
+ this.createChart(deepCopy(runtime.chartJsConfig));
4785
+ });
4786
+ owl.useEffect(() => {
4787
+ const runtime = this.chartRuntime;
4788
+ if (!deepEquals(runtime, this.currentRuntime, "ignoreFunctions")) {
4789
+ this.currentRuntime = runtime;
4790
+ this.updateChartJs(deepCopy(runtime));
4791
+ }
4778
4792
  });
4779
- owl.useEffect(() => this.updateChartJs(this.chartRuntime), () => [this.chartRuntime]);
4780
4793
  }
4781
4794
  createChart(chartData) {
4782
4795
  const canvas = this.canvas.el;
@@ -4804,8 +4817,7 @@
4804
4817
  this.chart.config.options.plugins.tooltip = chartData.options.plugins.tooltip;
4805
4818
  this.chart.config.options.plugins.legend = chartData.options.plugins.legend;
4806
4819
  this.chart.config.options.scales = chartData.options?.scales;
4807
- // ?
4808
- this.chart.update("active");
4820
+ this.chart.update();
4809
4821
  }
4810
4822
  }
4811
4823
  ChartJsComponent.props = {
@@ -7499,7 +7511,7 @@
7499
7511
  }
7500
7512
  return null;
7501
7513
  }
7502
- const separatorRegexp = /^[\w\.!\$]+/;
7514
+ const SYMBOL_CHARS = new Set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.!$");
7503
7515
  /**
7504
7516
  * A "Symbol" is just basically any word-like element that can appear in a
7505
7517
  * formula, which is not a string. So:
@@ -7539,11 +7551,8 @@
7539
7551
  };
7540
7552
  }
7541
7553
  }
7542
- const match = chars.remaining().match(separatorRegexp);
7543
- if (match) {
7544
- const value = match[0];
7545
- result += value;
7546
- chars.advanceBy(value.length);
7554
+ while (chars.current && SYMBOL_CHARS.has(chars.current)) {
7555
+ result += chars.shift();
7547
7556
  }
7548
7557
  if (result.length) {
7549
7558
  const value = result;
@@ -8374,7 +8383,7 @@
8374
8383
  /**
8375
8384
  * Get a default chart js configuration
8376
8385
  */
8377
- function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale }) {
8386
+ function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale, truncateLabels }) {
8378
8387
  const options = {
8379
8388
  // https://www.chartjs.org/docs/latest/general/responsive.html
8380
8389
  responsive: true,
@@ -8421,7 +8430,7 @@
8421
8430
  type: chart.type,
8422
8431
  options,
8423
8432
  data: {
8424
- labels: labels.map(truncateLabel),
8433
+ labels: truncateLabels ? labels.map(truncateLabel) : labels,
8425
8434
  datasets: [],
8426
8435
  },
8427
8436
  plugins: [],
@@ -9303,9 +9312,9 @@
9303
9312
  }
9304
9313
  return true;
9305
9314
  }
9306
- function getLineConfiguration(chart, labels, localeFormat) {
9315
+ function getLineConfiguration(chart, labels, options) {
9307
9316
  const fontColor = chartFontColor(chart.background);
9308
- const config = getDefaultChartJsRuntime(chart, labels, fontColor, localeFormat);
9317
+ const config = getDefaultChartJsRuntime(chart, labels, fontColor, options);
9309
9318
  const legend = {
9310
9319
  labels: {
9311
9320
  color: fontColor,
@@ -9348,7 +9357,7 @@
9348
9357
  value = Number(value);
9349
9358
  if (isNaN(value))
9350
9359
  return value;
9351
- const { locale, format } = localeFormat;
9360
+ const { locale, format } = options;
9352
9361
  return formatValue(value, {
9353
9362
  locale,
9354
9363
  format: !format && Math.abs(value) >= 1000 ? "#,##" : format,
@@ -9381,9 +9390,10 @@
9381
9390
  ({ labels, dataSetsValues } = aggregateDataForLabels(labels, dataSetsValues));
9382
9391
  }
9383
9392
  const locale = getters.getLocale();
9393
+ const truncateLabels = axisType === "category";
9384
9394
  const dataSetFormat = getChartDatasetFormat(getters, chart.dataSets);
9385
- const localeFormat = { format: dataSetFormat, locale };
9386
- const config = getLineConfiguration(chart, labels, localeFormat);
9395
+ const options = { format: dataSetFormat, locale, truncateLabels };
9396
+ const config = getLineConfiguration(chart, labels, options);
9387
9397
  const labelFormat = getChartLabelFormat(getters, chart.labelRange);
9388
9398
  if (axisType === "time") {
9389
9399
  const axis = {
@@ -27543,7 +27553,8 @@
27543
27553
  get checkBoxCellPositions() {
27544
27554
  return this.env.model.getters
27545
27555
  .getVisibleCellPositions()
27546
- .filter(this.env.model.getters.isCellValidCheckbox);
27556
+ .filter((position) => this.env.model.getters.isCellValidCheckbox(position) &&
27557
+ !this.env.model.getters.isFilterHeader(position));
27547
27558
  }
27548
27559
  get listIconsCellPositions() {
27549
27560
  if (this.env.model.getters.isReadonly()) {
@@ -27551,7 +27562,8 @@
27551
27562
  }
27552
27563
  return this.env.model.getters
27553
27564
  .getVisibleCellPositions()
27554
- .filter(this.env.model.getters.cellHasListDataValidationIcon);
27565
+ .filter((position) => this.env.model.getters.cellHasListDataValidationIcon(position) &&
27566
+ !this.env.model.getters.isFilterHeader(position));
27555
27567
  }
27556
27568
  }
27557
27569
  DataValidationOverlay.props = {};
@@ -33566,7 +33578,7 @@
33566
33578
  function matchReference(tokens) {
33567
33579
  let head = 0;
33568
33580
  let transitions = machine[State.LeftRef];
33569
- const matchedTokens = [];
33581
+ let matchedTokens = "";
33570
33582
  while (transitions !== undefined) {
33571
33583
  const token = tokens[head++];
33572
33584
  if (!token) {
@@ -33578,15 +33590,15 @@
33578
33590
  case undefined:
33579
33591
  return null;
33580
33592
  case State.Found:
33581
- matchedTokens.push(token);
33593
+ matchedTokens += token.value;
33582
33594
  tokens.splice(0, head);
33583
33595
  return {
33584
33596
  type: "REFERENCE",
33585
- value: concat(matchedTokens.map((token) => token.value)),
33597
+ value: matchedTokens,
33586
33598
  };
33587
33599
  default:
33588
33600
  transitions = machine[nextState];
33589
- matchedTokens.push(token);
33601
+ matchedTokens += token.value;
33590
33602
  break;
33591
33603
  }
33592
33604
  }
@@ -42018,7 +42030,7 @@
42018
42030
  ? getItemId(newFormat, data.formats)
42019
42031
  : exportedCellData.format;
42020
42032
  let content;
42021
- if (isFormula && formulaCell instanceof FormulaCellWithDependencies) {
42033
+ if (isExported && isFormula && formulaCell?.compiledFormula.dependencies.length) {
42022
42034
  content = this.getters.getFormulaCellContent(exportedSheetData.id, formulaCell.compiledFormula, formulaCell.compiledFormula.dependencies, true);
42023
42035
  }
42024
42036
  else {
@@ -57391,9 +57403,9 @@
57391
57403
  exports.tokenize = tokenize;
57392
57404
 
57393
57405
 
57394
- __info__.version = "17.0.20";
57395
- __info__.date = "2024-04-26T07:37:04.503Z";
57396
- __info__.hash = "065ac98";
57406
+ __info__.version = "17.0.22";
57407
+ __info__.date = "2024-05-15T09:18:36.212Z";
57408
+ __info__.hash = "1f90749";
57397
57409
 
57398
57410
 
57399
57411
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);