@odoo/o-spreadsheet 17.1.13 → 17.1.15

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.1.13
6
- * @date 2024-04-26T07:39:54.100Z
7
- * @hash f2ea8c7
5
+ * @version 17.1.15
6
+ * @date 2024-05-15T09:22:23.258Z
7
+ * @hash fc959fe
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -542,7 +542,7 @@
542
542
  /**
543
543
  * Compares two objects.
544
544
  */
545
- function deepEquals(o1, o2) {
545
+ function deepEquals(o1, o2, ignoreFunctions) {
546
546
  if (o1 === o2)
547
547
  return true;
548
548
  if ((o1 && !o2) || (o2 && !o1))
@@ -558,13 +558,16 @@
558
558
  }
559
559
  }
560
560
  for (const key in o1) {
561
- if (typeof o1[key] !== typeof o2[key])
561
+ const typeOfO1Key = typeof o1[key];
562
+ if (typeOfO1Key !== typeof o2[key])
562
563
  return false;
563
- if (typeof o1[key] === "object") {
564
- if (!deepEquals(o1[key], o2[key]))
564
+ if (typeOfO1Key === "object") {
565
+ if (!deepEquals(o1[key], o2[key], ignoreFunctions))
565
566
  return false;
566
567
  }
567
568
  else {
569
+ if (ignoreFunctions && typeOfO1Key === "function")
570
+ return true;
568
571
  if (o1[key] !== o2[key])
569
572
  return false;
570
573
  }
@@ -3624,21 +3627,22 @@
3624
3627
  xc = xc.split("!").at(-1);
3625
3628
  }
3626
3629
  if (xc.includes("$")) {
3627
- xc = xc.replace(/\$/g, "");
3630
+ xc = xc.replaceAll("$", "");
3628
3631
  }
3629
- let ranges;
3632
+ let firstRangePart = "";
3633
+ let secondRangePart;
3630
3634
  if (xc.includes(":")) {
3631
- ranges = xc.split(":").map((x) => x.trim());
3635
+ [firstRangePart, secondRangePart] = xc.split(":");
3636
+ firstRangePart = firstRangePart.trim();
3637
+ secondRangePart = secondRangePart.trim();
3632
3638
  }
3633
3639
  else {
3634
- ranges = [xc.trim()];
3640
+ firstRangePart = xc.trim();
3635
3641
  }
3636
3642
  let top, bottom, left, right;
3637
3643
  let fullCol = false;
3638
3644
  let fullRow = false;
3639
3645
  let hasHeader = false;
3640
- const firstRangePart = ranges[0];
3641
- const secondRangePart = ranges[1] && ranges[1];
3642
3646
  if (isColReference(firstRangePart)) {
3643
3647
  left = right = lettersToNumber(firstRangePart);
3644
3648
  top = bottom = 0;
@@ -3655,7 +3659,7 @@
3655
3659
  top = bottom = c.row;
3656
3660
  hasHeader = true;
3657
3661
  }
3658
- if (ranges.length === 2) {
3662
+ if (secondRangePart) {
3659
3663
  if (isColReference(secondRangePart)) {
3660
3664
  right = lettersToNumber(secondRangePart);
3661
3665
  fullCol = true;
@@ -4829,6 +4833,7 @@
4829
4833
  };
4830
4834
  canvas = owl.useRef("graphContainer");
4831
4835
  chart;
4836
+ currentRuntime;
4832
4837
  get background() {
4833
4838
  return this.chartRuntime.background;
4834
4839
  }
@@ -4845,9 +4850,18 @@
4845
4850
  setup() {
4846
4851
  owl.onMounted(() => {
4847
4852
  const runtime = this.chartRuntime;
4848
- this.createChart(runtime.chartJsConfig);
4853
+ this.currentRuntime = runtime;
4854
+ // Note: chartJS modify the runtime in place, so it's important to give it a copy
4855
+ this.createChart(deepCopy(runtime.chartJsConfig));
4856
+ });
4857
+ owl.onWillUnmount(() => this.chart?.destroy());
4858
+ owl.useEffect(() => {
4859
+ const runtime = this.chartRuntime;
4860
+ if (!deepEquals(runtime, this.currentRuntime, "ignoreFunctions")) {
4861
+ this.currentRuntime = runtime;
4862
+ this.updateChartJs(deepCopy(runtime));
4863
+ }
4849
4864
  });
4850
- owl.useEffect(() => this.updateChartJs(this.chartRuntime), () => [this.chartRuntime]);
4851
4865
  }
4852
4866
  createChart(chartData) {
4853
4867
  const canvas = this.canvas.el;
@@ -4875,8 +4889,7 @@
4875
4889
  this.chart.config.options.plugins.tooltip = chartData.options.plugins.tooltip;
4876
4890
  this.chart.config.options.plugins.legend = chartData.options.plugins.legend;
4877
4891
  this.chart.config.options.scales = chartData.options?.scales;
4878
- // ?
4879
- this.chart.update("active");
4892
+ this.chart.update();
4880
4893
  }
4881
4894
  }
4882
4895
 
@@ -7564,7 +7577,7 @@
7564
7577
  }
7565
7578
  return null;
7566
7579
  }
7567
- const separatorRegexp = /^[\w\.!\$]+/;
7580
+ const SYMBOL_CHARS = new Set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.!$");
7568
7581
  /**
7569
7582
  * A "Symbol" is just basically any word-like element that can appear in a
7570
7583
  * formula, which is not a string. So:
@@ -7604,11 +7617,8 @@
7604
7617
  };
7605
7618
  }
7606
7619
  }
7607
- const match = chars.remaining().match(separatorRegexp);
7608
- if (match) {
7609
- const value = match[0];
7610
- result += value;
7611
- chars.advanceBy(value.length);
7620
+ while (chars.current && SYMBOL_CHARS.has(chars.current)) {
7621
+ result += chars.shift();
7612
7622
  }
7613
7623
  if (result.length) {
7614
7624
  const value = result;
@@ -8439,7 +8449,7 @@
8439
8449
  /**
8440
8450
  * Get a default chart js configuration
8441
8451
  */
8442
- function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale }) {
8452
+ function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale, truncateLabels }) {
8443
8453
  const options = {
8444
8454
  // https://www.chartjs.org/docs/latest/general/responsive.html
8445
8455
  responsive: true,
@@ -8486,7 +8496,7 @@
8486
8496
  type: chart.type,
8487
8497
  options,
8488
8498
  data: {
8489
- labels: labels.map(truncateLabel),
8499
+ labels: truncateLabels ? labels.map(truncateLabel) : labels,
8490
8500
  datasets: [],
8491
8501
  },
8492
8502
  platform: undefined,
@@ -9369,9 +9379,9 @@
9369
9379
  }
9370
9380
  return true;
9371
9381
  }
9372
- function getLineConfiguration(chart, labels, localeFormat) {
9382
+ function getLineConfiguration(chart, labels, options) {
9373
9383
  const fontColor = chartFontColor(chart.background);
9374
- const config = getDefaultChartJsRuntime(chart, labels, fontColor, localeFormat);
9384
+ const config = getDefaultChartJsRuntime(chart, labels, fontColor, options);
9375
9385
  const legend = {
9376
9386
  labels: {
9377
9387
  color: fontColor,
@@ -9414,7 +9424,7 @@
9414
9424
  value = Number(value);
9415
9425
  if (isNaN(value))
9416
9426
  return value;
9417
- const { locale, format } = localeFormat;
9427
+ const { locale, format } = options;
9418
9428
  return formatValue(value, {
9419
9429
  locale,
9420
9430
  format: !format && Math.abs(value) >= 1000 ? "#,##" : format,
@@ -9447,9 +9457,10 @@
9447
9457
  ({ labels, dataSetsValues } = aggregateDataForLabels(labels, dataSetsValues));
9448
9458
  }
9449
9459
  const locale = getters.getLocale();
9460
+ const truncateLabels = axisType === "category";
9450
9461
  const dataSetFormat = getChartDatasetFormat(getters, chart.dataSets);
9451
- const localeFormat = { format: dataSetFormat, locale };
9452
- const config = getLineConfiguration(chart, labels, localeFormat);
9462
+ const options = { format: dataSetFormat, locale, truncateLabels };
9463
+ const config = getLineConfiguration(chart, labels, options);
9453
9464
  const labelFormat = getChartLabelFormat(getters, chart.labelRange);
9454
9465
  if (axisType === "time") {
9455
9466
  const axis = {
@@ -28053,7 +28064,8 @@
28053
28064
  get checkBoxCellPositions() {
28054
28065
  return this.env.model.getters
28055
28066
  .getVisibleCellPositions()
28056
- .filter(this.env.model.getters.isCellValidCheckbox);
28067
+ .filter((position) => this.env.model.getters.isCellValidCheckbox(position) &&
28068
+ !this.env.model.getters.isFilterHeader(position));
28057
28069
  }
28058
28070
  get listIconsCellPositions() {
28059
28071
  if (this.env.model.getters.isReadonly()) {
@@ -28061,7 +28073,8 @@
28061
28073
  }
28062
28074
  return this.env.model.getters
28063
28075
  .getVisibleCellPositions()
28064
- .filter(this.env.model.getters.cellHasListDataValidationIcon);
28076
+ .filter((position) => this.env.model.getters.cellHasListDataValidationIcon(position) &&
28077
+ !this.env.model.getters.isFilterHeader(position));
28065
28078
  }
28066
28079
  }
28067
28080
 
@@ -34068,7 +34081,7 @@
34068
34081
  function matchReference(tokens) {
34069
34082
  let head = 0;
34070
34083
  let transitions = machine[State.LeftRef];
34071
- const matchedTokens = [];
34084
+ let matchedTokens = "";
34072
34085
  while (transitions !== undefined) {
34073
34086
  const token = tokens[head++];
34074
34087
  if (!token) {
@@ -34080,15 +34093,15 @@
34080
34093
  case undefined:
34081
34094
  return null;
34082
34095
  case State.Found:
34083
- matchedTokens.push(token);
34096
+ matchedTokens += token.value;
34084
34097
  tokens.splice(0, head);
34085
34098
  return {
34086
34099
  type: "REFERENCE",
34087
- value: concat(matchedTokens.map((token) => token.value)),
34100
+ value: matchedTokens,
34088
34101
  };
34089
34102
  default:
34090
34103
  transitions = machine[nextState];
34091
- matchedTokens.push(token);
34104
+ matchedTokens += token.value;
34092
34105
  break;
34093
34106
  }
34094
34107
  }
@@ -42503,7 +42516,7 @@
42503
42516
  ? getItemId(newFormat, data.formats)
42504
42517
  : exportedCellData.format;
42505
42518
  let content;
42506
- if (isFormula && formulaCell instanceof FormulaCellWithDependencies) {
42519
+ if (isExported && isFormula && formulaCell instanceof FormulaCellWithDependencies) {
42507
42520
  content = formulaCell.contentWithFixedReferences;
42508
42521
  }
42509
42522
  else {
@@ -57717,9 +57730,9 @@
57717
57730
  exports.tokenize = tokenize;
57718
57731
 
57719
57732
 
57720
- __info__.version = "17.1.13";
57721
- __info__.date = "2024-04-26T07:39:54.100Z";
57722
- __info__.hash = "f2ea8c7";
57733
+ __info__.version = "17.1.15";
57734
+ __info__.date = "2024-05-15T09:22:23.258Z";
57735
+ __info__.hash = "fc959fe";
57723
57736
 
57724
57737
 
57725
57738
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);