@odoo/o-spreadsheet 16.3.2 → 16.3.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.
@@ -1777,6 +1777,7 @@ function removeTrailingZeroes(numberString) {
1777
1777
  }
1778
1778
  return numberString.slice(0, i + 1) || undefined;
1779
1779
  }
1780
+ const leadingZeroesRegexp = /^0+/;
1780
1781
  /**
1781
1782
  * Limit the size of the decimal part of a number to the given number of digits.
1782
1783
  */
@@ -1787,17 +1788,24 @@ function limitDecimalDigits(decimalDigits, maxDecimals) {
1787
1788
  // but it has very strange behaviour. Ex: 12.345.toFixed(2) => "12.35", but 1.345.toFixed(2) => "1.34"
1788
1789
  let slicedDecimalDigits = decimalDigits.slice(0, maxDecimals);
1789
1790
  const i = maxDecimals;
1790
- if (Number(Number(decimalDigits[i]) < 5)) {
1791
+ if (Number(decimalDigits[i]) < 5) {
1791
1792
  return { integerDigits, decimalDigits: slicedDecimalDigits };
1792
1793
  }
1793
1794
  // round up
1795
+ const leadingZeroes = slicedDecimalDigits.match(leadingZeroesRegexp)?.[0] || "";
1794
1796
  const slicedRoundedUp = (Number(slicedDecimalDigits) + 1).toString();
1795
- if (slicedRoundedUp.length > slicedDecimalDigits.length) {
1796
- integerDigits = (Number(integerDigits) + 1).toString();
1797
+ const withoutLeadingZeroes = slicedDecimalDigits.slice(leadingZeroes.length);
1798
+ // e.g. carry over from 99 to 100
1799
+ const carryOver = slicedRoundedUp.length > withoutLeadingZeroes.length;
1800
+ if (carryOver && !leadingZeroes) {
1801
+ integerDigits = "1";
1797
1802
  resultDecimalDigits = undefined;
1798
1803
  }
1804
+ else if (carryOver) {
1805
+ resultDecimalDigits = leadingZeroes.slice(0, -1) + slicedRoundedUp;
1806
+ }
1799
1807
  else {
1800
- resultDecimalDigits = slicedRoundedUp;
1808
+ resultDecimalDigits = leadingZeroes + slicedRoundedUp;
1801
1809
  }
1802
1810
  return { integerDigits, decimalDigits: resultDecimalDigits };
1803
1811
  }
@@ -17948,6 +17956,7 @@ css /* scss */ `
17948
17956
  .o-color-picker-toggler-button {
17949
17957
  display: flex;
17950
17958
  .o-color-picker-toggler-sign {
17959
+ display: flex;
17951
17960
  margin: auto auto;
17952
17961
  width: 55%;
17953
17962
  height: 55%;
@@ -47597,6 +47606,6 @@ exports.setTranslationMethod = setTranslationMethod;
47597
47606
  exports.tokenize = tokenize;
47598
47607
 
47599
47608
 
47600
- __info__.version = '16.3.2';
47601
- __info__.date = '2023-06-02T10:13:46.734Z';
47602
- __info__.hash = '69a4378';
47609
+ __info__.version = '16.3.3';
47610
+ __info__.date = '2023-06-12T13:50:01.114Z';
47611
+ __info__.hash = 'd3ab96f';
@@ -1773,6 +1773,7 @@ function removeTrailingZeroes(numberString) {
1773
1773
  }
1774
1774
  return numberString.slice(0, i + 1) || undefined;
1775
1775
  }
1776
+ const leadingZeroesRegexp = /^0+/;
1776
1777
  /**
1777
1778
  * Limit the size of the decimal part of a number to the given number of digits.
1778
1779
  */
@@ -1783,17 +1784,24 @@ function limitDecimalDigits(decimalDigits, maxDecimals) {
1783
1784
  // but it has very strange behaviour. Ex: 12.345.toFixed(2) => "12.35", but 1.345.toFixed(2) => "1.34"
1784
1785
  let slicedDecimalDigits = decimalDigits.slice(0, maxDecimals);
1785
1786
  const i = maxDecimals;
1786
- if (Number(Number(decimalDigits[i]) < 5)) {
1787
+ if (Number(decimalDigits[i]) < 5) {
1787
1788
  return { integerDigits, decimalDigits: slicedDecimalDigits };
1788
1789
  }
1789
1790
  // round up
1791
+ const leadingZeroes = slicedDecimalDigits.match(leadingZeroesRegexp)?.[0] || "";
1790
1792
  const slicedRoundedUp = (Number(slicedDecimalDigits) + 1).toString();
1791
- if (slicedRoundedUp.length > slicedDecimalDigits.length) {
1792
- integerDigits = (Number(integerDigits) + 1).toString();
1793
+ const withoutLeadingZeroes = slicedDecimalDigits.slice(leadingZeroes.length);
1794
+ // e.g. carry over from 99 to 100
1795
+ const carryOver = slicedRoundedUp.length > withoutLeadingZeroes.length;
1796
+ if (carryOver && !leadingZeroes) {
1797
+ integerDigits = "1";
1793
1798
  resultDecimalDigits = undefined;
1794
1799
  }
1800
+ else if (carryOver) {
1801
+ resultDecimalDigits = leadingZeroes.slice(0, -1) + slicedRoundedUp;
1802
+ }
1795
1803
  else {
1796
- resultDecimalDigits = slicedRoundedUp;
1804
+ resultDecimalDigits = leadingZeroes + slicedRoundedUp;
1797
1805
  }
1798
1806
  return { integerDigits, decimalDigits: resultDecimalDigits };
1799
1807
  }
@@ -17944,6 +17952,7 @@ css /* scss */ `
17944
17952
  .o-color-picker-toggler-button {
17945
17953
  display: flex;
17946
17954
  .o-color-picker-toggler-sign {
17955
+ display: flex;
17947
17956
  margin: auto auto;
17948
17957
  width: 55%;
17949
17958
  height: 55%;
@@ -47565,6 +47574,6 @@ function addFunction(functionName, functionDescription) {
47565
47574
  export { AbstractChart, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, links, load, parse, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
47566
47575
 
47567
47576
 
47568
- __info__.version = '16.3.2';
47569
- __info__.date = '2023-06-02T10:13:46.734Z';
47570
- __info__.hash = '69a4378';
47577
+ __info__.version = '16.3.3';
47578
+ __info__.date = '2023-06-12T13:50:01.114Z';
47579
+ __info__.hash = 'd3ab96f';
@@ -1774,6 +1774,7 @@
1774
1774
  }
1775
1775
  return numberString.slice(0, i + 1) || undefined;
1776
1776
  }
1777
+ const leadingZeroesRegexp = /^0+/;
1777
1778
  /**
1778
1779
  * Limit the size of the decimal part of a number to the given number of digits.
1779
1780
  */
@@ -1784,17 +1785,24 @@
1784
1785
  // but it has very strange behaviour. Ex: 12.345.toFixed(2) => "12.35", but 1.345.toFixed(2) => "1.34"
1785
1786
  let slicedDecimalDigits = decimalDigits.slice(0, maxDecimals);
1786
1787
  const i = maxDecimals;
1787
- if (Number(Number(decimalDigits[i]) < 5)) {
1788
+ if (Number(decimalDigits[i]) < 5) {
1788
1789
  return { integerDigits, decimalDigits: slicedDecimalDigits };
1789
1790
  }
1790
1791
  // round up
1792
+ const leadingZeroes = slicedDecimalDigits.match(leadingZeroesRegexp)?.[0] || "";
1791
1793
  const slicedRoundedUp = (Number(slicedDecimalDigits) + 1).toString();
1792
- if (slicedRoundedUp.length > slicedDecimalDigits.length) {
1793
- integerDigits = (Number(integerDigits) + 1).toString();
1794
+ const withoutLeadingZeroes = slicedDecimalDigits.slice(leadingZeroes.length);
1795
+ // e.g. carry over from 99 to 100
1796
+ const carryOver = slicedRoundedUp.length > withoutLeadingZeroes.length;
1797
+ if (carryOver && !leadingZeroes) {
1798
+ integerDigits = "1";
1794
1799
  resultDecimalDigits = undefined;
1795
1800
  }
1801
+ else if (carryOver) {
1802
+ resultDecimalDigits = leadingZeroes.slice(0, -1) + slicedRoundedUp;
1803
+ }
1796
1804
  else {
1797
- resultDecimalDigits = slicedRoundedUp;
1805
+ resultDecimalDigits = leadingZeroes + slicedRoundedUp;
1798
1806
  }
1799
1807
  return { integerDigits, decimalDigits: resultDecimalDigits };
1800
1808
  }
@@ -17945,6 +17953,7 @@
17945
17953
  .o-color-picker-toggler-button {
17946
17954
  display: flex;
17947
17955
  .o-color-picker-toggler-sign {
17956
+ display: flex;
17948
17957
  margin: auto auto;
17949
17958
  width: 55%;
17950
17959
  height: 55%;
@@ -47596,9 +47605,9 @@
47596
47605
  Object.defineProperty(exports, '__esModule', { value: true });
47597
47606
 
47598
47607
 
47599
- __info__.version = '16.3.2';
47600
- __info__.date = '2023-06-02T10:13:46.734Z';
47601
- __info__.hash = '69a4378';
47608
+ __info__.version = '16.3.3';
47609
+ __info__.date = '2023-06-12T13:50:01.114Z';
47610
+ __info__.hash = 'd3ab96f';
47602
47611
 
47603
47612
 
47604
47613
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);