@odoo/o-spreadsheet 17.2.5 → 17.2.6

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.
@@ -3,9 +3,9 @@
3
3
  /**
4
4
  * This file is generated by o-spreadsheet build tools. Do not edit it.
5
5
  * @see https://github.com/odoo/o-spreadsheet
6
- * @version 17.2.5
7
- * @date 2024-04-26T07:41:13.193Z
8
- * @hash a730f5c
6
+ * @version 17.2.6
7
+ * @date 2024-05-07T10:41:20.332Z
8
+ * @hash a4f800c
9
9
  */
10
10
 
11
11
  (function (exports, owl) {
@@ -553,7 +553,7 @@
553
553
  /**
554
554
  * Compares two objects.
555
555
  */
556
- function deepEquals(o1, o2) {
556
+ function deepEquals(o1, o2, ignoreFunctions) {
557
557
  if (o1 === o2)
558
558
  return true;
559
559
  if ((o1 && !o2) || (o2 && !o1))
@@ -569,13 +569,16 @@
569
569
  }
570
570
  }
571
571
  for (const key in o1) {
572
- if (typeof o1[key] !== typeof o2[key])
572
+ const typeOfO1Key = typeof o1[key];
573
+ if (typeOfO1Key !== typeof o2[key])
573
574
  return false;
574
- if (typeof o1[key] === "object") {
575
- if (!deepEquals(o1[key], o2[key]))
575
+ if (typeOfO1Key === "object") {
576
+ if (!deepEquals(o1[key], o2[key], ignoreFunctions))
576
577
  return false;
577
578
  }
578
579
  else {
580
+ if (ignoreFunctions && typeOfO1Key === "function")
581
+ return true;
579
582
  if (o1[key] !== o2[key])
580
583
  return false;
581
584
  }
@@ -3683,21 +3686,22 @@
3683
3686
  xc = xc.split("!").at(-1);
3684
3687
  }
3685
3688
  if (xc.includes("$")) {
3686
- xc = xc.replace(/\$/g, "");
3689
+ xc = xc.replaceAll("$", "");
3687
3690
  }
3688
- let ranges;
3691
+ let firstRangePart = "";
3692
+ let secondRangePart;
3689
3693
  if (xc.includes(":")) {
3690
- ranges = xc.split(":").map((x) => x.trim());
3694
+ [firstRangePart, secondRangePart] = xc.split(":");
3695
+ firstRangePart = firstRangePart.trim();
3696
+ secondRangePart = secondRangePart.trim();
3691
3697
  }
3692
3698
  else {
3693
- ranges = [xc.trim()];
3699
+ firstRangePart = xc.trim();
3694
3700
  }
3695
3701
  let top, bottom, left, right;
3696
3702
  let fullCol = false;
3697
3703
  let fullRow = false;
3698
3704
  let hasHeader = false;
3699
- const firstRangePart = ranges[0];
3700
- const secondRangePart = ranges[1] && ranges[1];
3701
3705
  if (isColReference(firstRangePart)) {
3702
3706
  left = right = lettersToNumber(firstRangePart);
3703
3707
  top = bottom = 0;
@@ -3714,7 +3718,7 @@
3714
3718
  top = bottom = c.row;
3715
3719
  hasHeader = true;
3716
3720
  }
3717
- if (ranges.length === 2) {
3721
+ if (secondRangePart) {
3718
3722
  if (isColReference(secondRangePart)) {
3719
3723
  right = lettersToNumber(secondRangePart);
3720
3724
  fullCol = true;
@@ -8905,8 +8909,7 @@ stores.inject(MyMetaStore, storeInstance);
8905
8909
  const exactMatch = proposals?.find((p) => p.text === tokenAtCursor.value);
8906
8910
  // remove tokens that are likely to be other parts of the formula that slipped in the token if it's a string
8907
8911
  const searchTerm = tokenAtCursor.value.replace(/[ ,\(\)]/g, "");
8908
- const initialContent = this.initialContent;
8909
- if (exactMatch && exactMatch.text !== initialContent) {
8912
+ if (exactMatch && this._currentContent !== this.initialContent) {
8910
8913
  // this means the user has chosen a proposal
8911
8914
  return;
8912
8915
  }
@@ -8914,7 +8917,7 @@ stores.inject(MyMetaStore, storeInstance);
8914
8917
  proposals &&
8915
8918
  !["ARG_SEPARATOR", "LEFT_PAREN"].includes(tokenAtCursor.type)) {
8916
8919
  const filteredProposals = fuzzyLookup(searchTerm, proposals, (p) => p.fuzzySearchKey || p.text);
8917
- if (!exactMatch) {
8920
+ if (!exactMatch || filteredProposals.length > 1) {
8918
8921
  proposals = filteredProposals;
8919
8922
  }
8920
8923
  }
@@ -9049,6 +9052,7 @@ stores.inject(MyMetaStore, storeInstance);
9049
9052
  };
9050
9053
  canvas = owl.useRef("graphContainer");
9051
9054
  chart;
9055
+ currentRuntime;
9052
9056
  get background() {
9053
9057
  return this.chartRuntime.background;
9054
9058
  }
@@ -9065,9 +9069,18 @@ stores.inject(MyMetaStore, storeInstance);
9065
9069
  setup() {
9066
9070
  owl.onMounted(() => {
9067
9071
  const runtime = this.chartRuntime;
9068
- this.createChart(runtime.chartJsConfig);
9072
+ this.currentRuntime = runtime;
9073
+ // Note: chartJS modify the runtime in place, so it's important to give it a copy
9074
+ this.createChart(deepCopy(runtime.chartJsConfig));
9075
+ });
9076
+ owl.onWillUnmount(() => this.chart?.destroy());
9077
+ owl.useEffect(() => {
9078
+ const runtime = this.chartRuntime;
9079
+ if (!deepEquals(runtime, this.currentRuntime, "ignoreFunctions")) {
9080
+ this.currentRuntime = runtime;
9081
+ this.updateChartJs(deepCopy(runtime));
9082
+ }
9069
9083
  });
9070
- owl.useEffect(() => this.updateChartJs(this.chartRuntime), () => [this.chartRuntime]);
9071
9084
  }
9072
9085
  createChart(chartData) {
9073
9086
  const canvas = this.canvas.el;
@@ -9089,8 +9102,7 @@ stores.inject(MyMetaStore, storeInstance);
9089
9102
  this.chart.config.options.plugins.tooltip = chartData.options.plugins.tooltip;
9090
9103
  this.chart.config.options.plugins.legend = chartData.options.plugins.legend;
9091
9104
  this.chart.config.options.scales = chartData.options?.scales;
9092
- // ?
9093
- this.chart.update("active");
9105
+ this.chart.update();
9094
9106
  }
9095
9107
  }
9096
9108
 
@@ -19453,7 +19465,7 @@ stores.inject(MyMetaStore, storeInstance);
19453
19465
  /**
19454
19466
  * Get a default chart js configuration
19455
19467
  */
19456
- function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale }) {
19468
+ function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale, truncateLabels }) {
19457
19469
  const options = {
19458
19470
  // https://www.chartjs.org/docs/latest/general/responsive.html
19459
19471
  responsive: true,
@@ -19500,7 +19512,7 @@ stores.inject(MyMetaStore, storeInstance);
19500
19512
  type: chart.type,
19501
19513
  options,
19502
19514
  data: {
19503
- labels: labels.map(truncateLabel),
19515
+ labels: truncateLabels ? labels.map(truncateLabel) : labels,
19504
19516
  datasets: [],
19505
19517
  },
19506
19518
  platform: undefined,
@@ -20266,9 +20278,9 @@ stores.inject(MyMetaStore, storeInstance);
20266
20278
  }
20267
20279
  return isInstalled;
20268
20280
  }
20269
- function getLineOrScatterConfiguration(chart, labels, localeFormat) {
20281
+ function getLineOrScatterConfiguration(chart, labels, options) {
20270
20282
  const fontColor = chartFontColor(chart.background);
20271
- const config = getDefaultChartJsRuntime(chart, labels, fontColor, localeFormat);
20283
+ const config = getDefaultChartJsRuntime(chart, labels, fontColor, options);
20272
20284
  const legend = {
20273
20285
  labels: {
20274
20286
  color: fontColor,
@@ -20311,7 +20323,7 @@ stores.inject(MyMetaStore, storeInstance);
20311
20323
  value = Number(value);
20312
20324
  if (isNaN(value))
20313
20325
  return value;
20314
- const { locale, format } = localeFormat;
20326
+ const { locale, format } = options;
20315
20327
  return formatValue(value, {
20316
20328
  locale,
20317
20329
  format: !format && Math.abs(value) >= 1000 ? "#,##" : format,
@@ -20344,9 +20356,10 @@ stores.inject(MyMetaStore, storeInstance);
20344
20356
  ({ labels, dataSetsValues } = aggregateDataForLabels(labels, dataSetsValues));
20345
20357
  }
20346
20358
  const locale = getters.getLocale();
20359
+ const truncateLabels = axisType === "category";
20347
20360
  const dataSetFormat = getChartDatasetFormat(getters, chart.dataSets);
20348
- const localeFormat = { format: dataSetFormat, locale };
20349
- const config = getLineOrScatterConfiguration(chart, labels, localeFormat);
20361
+ const options = { format: dataSetFormat, locale, truncateLabels };
20362
+ const config = getLineOrScatterConfiguration(chart, labels, options);
20350
20363
  const labelFormat = getChartLabelFormat(getters, chart.labelRange);
20351
20364
  if (axisType === "time") {
20352
20365
  const axis = {
@@ -32900,7 +32913,8 @@ stores.inject(MyMetaStore, storeInstance);
32900
32913
  get checkBoxCellPositions() {
32901
32914
  return this.env.model.getters
32902
32915
  .getVisibleCellPositions()
32903
- .filter(this.env.model.getters.isCellValidCheckbox);
32916
+ .filter((position) => this.env.model.getters.isCellValidCheckbox(position) &&
32917
+ !this.env.model.getters.isFilterHeader(position));
32904
32918
  }
32905
32919
  get listIconsCellPositions() {
32906
32920
  if (this.env.model.getters.isReadonly()) {
@@ -32908,7 +32922,8 @@ stores.inject(MyMetaStore, storeInstance);
32908
32922
  }
32909
32923
  return this.env.model.getters
32910
32924
  .getVisibleCellPositions()
32911
- .filter(this.env.model.getters.cellHasListDataValidationIcon);
32925
+ .filter((position) => this.env.model.getters.cellHasListDataValidationIcon(position) &&
32926
+ !this.env.model.getters.isFilterHeader(position));
32912
32927
  }
32913
32928
  }
32914
32929
 
@@ -47928,7 +47943,7 @@ stores.inject(MyMetaStore, storeInstance);
47928
47943
  ? getItemId(newFormat, data.formats)
47929
47944
  : exportedCellData.format;
47930
47945
  let content;
47931
- if (isFormula && formulaCell instanceof FormulaCellWithDependencies) {
47946
+ if (isExported && isFormula && formulaCell instanceof FormulaCellWithDependencies) {
47932
47947
  content = formulaCell.contentWithFixedReferences;
47933
47948
  }
47934
47949
  else {
@@ -60599,9 +60614,9 @@ stores.inject(MyMetaStore, storeInstance);
60599
60614
  exports.tokenize = tokenize;
60600
60615
 
60601
60616
 
60602
- __info__.version = "17.2.5";
60603
- __info__.date = "2024-04-26T07:41:13.193Z";
60604
- __info__.hash = "a730f5c";
60617
+ __info__.version = "17.2.6";
60618
+ __info__.date = "2024-05-07T10:41:20.332Z";
60619
+ __info__.hash = "a4f800c";
60605
60620
 
60606
60621
 
60607
60622
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);