@odoo/o-spreadsheet 16.1.13 → 16.1.14

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.
@@ -1707,27 +1707,36 @@ function removeTrailingZeroes(numberString) {
1707
1707
  }
1708
1708
  return numberString.slice(0, i + 1) || undefined;
1709
1709
  }
1710
+ const leadingZeroesRegexp = /^0+/;
1710
1711
  /**
1711
1712
  * Limit the size of the decimal part of a number to the given number of digits.
1712
1713
  */
1713
1714
  function limitDecimalDigits(decimalDigits, maxDecimals) {
1715
+ var _a;
1714
1716
  let integerDigits = "0";
1715
1717
  let resultDecimalDigits = decimalDigits;
1716
1718
  // Note : we'd want to simply use number.toFixed() to handle the max digits & rounding,
1717
1719
  // but it has very strange behaviour. Ex: 12.345.toFixed(2) => "12.35", but 1.345.toFixed(2) => "1.34"
1718
1720
  let slicedDecimalDigits = decimalDigits.slice(0, maxDecimals);
1719
1721
  const i = maxDecimals;
1720
- if (Number(Number(decimalDigits[i]) < 5)) {
1722
+ if (Number(decimalDigits[i]) < 5) {
1721
1723
  return { integerDigits, decimalDigits: slicedDecimalDigits };
1722
1724
  }
1723
1725
  // round up
1726
+ const leadingZeroes = ((_a = slicedDecimalDigits.match(leadingZeroesRegexp)) === null || _a === void 0 ? void 0 : _a[0]) || "";
1724
1727
  const slicedRoundedUp = (Number(slicedDecimalDigits) + 1).toString();
1725
- if (slicedRoundedUp.length > slicedDecimalDigits.length) {
1726
- integerDigits = (Number(integerDigits) + 1).toString();
1728
+ const withoutLeadingZeroes = slicedDecimalDigits.slice(leadingZeroes.length);
1729
+ // e.g. carry over from 99 to 100
1730
+ const carryOver = slicedRoundedUp.length > withoutLeadingZeroes.length;
1731
+ if (carryOver && !leadingZeroes) {
1732
+ integerDigits = "1";
1727
1733
  resultDecimalDigits = undefined;
1728
1734
  }
1735
+ else if (carryOver) {
1736
+ resultDecimalDigits = leadingZeroes.slice(0, -1) + slicedRoundedUp;
1737
+ }
1729
1738
  else {
1730
- resultDecimalDigits = slicedRoundedUp;
1739
+ resultDecimalDigits = leadingZeroes + slicedRoundedUp;
1731
1740
  }
1732
1741
  return { integerDigits, decimalDigits: resultDecimalDigits };
1733
1742
  }
@@ -17345,6 +17354,7 @@ class Composer extends owl.Component {
17345
17354
  (this.autoCompleteState.selectedIndex + 1) % this.autoCompleteState.values.length;
17346
17355
  }
17347
17356
  }
17357
+ this.updateCursorIfNeeded();
17348
17358
  }
17349
17359
  processTabKey(ev) {
17350
17360
  var _a;
@@ -17403,9 +17413,12 @@ class Composer extends owl.Component {
17403
17413
  }
17404
17414
  else {
17405
17415
  ev.stopPropagation();
17416
+ this.updateCursorIfNeeded();
17406
17417
  }
17407
- const { start, end } = this.contentHelper.getCurrentSelection();
17418
+ }
17419
+ updateCursorIfNeeded() {
17408
17420
  if (!this.env.model.getters.isSelectingForComposer()) {
17421
+ const { start, end } = this.contentHelper.getCurrentSelection();
17409
17422
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", { start, end });
17410
17423
  this.isKeyStillDown = true;
17411
17424
  }
@@ -20036,6 +20049,7 @@ css /* scss */ `
20036
20049
  .o-color-picker-toggler {
20037
20050
  display: flex;
20038
20051
  .o-color-picker-toggler-sign {
20052
+ display: flex;
20039
20053
  margin: auto auto;
20040
20054
  width: 55%;
20041
20055
  height: 55%;
@@ -44258,6 +44272,6 @@ exports.setTranslationMethod = setTranslationMethod;
44258
44272
  exports.tokenize = tokenize;
44259
44273
 
44260
44274
 
44261
- __info__.version = '16.1.13';
44262
- __info__.date = '2023-06-02T10:12:21.173Z';
44263
- __info__.hash = '5386a5b';
44275
+ __info__.version = '16.1.14';
44276
+ __info__.date = '2023-06-12T13:50:13.693Z';
44277
+ __info__.hash = 'a51d9fa';
@@ -5668,6 +5668,7 @@ declare class Composer extends Component<Props$j, SpreadsheetChildEnv> {
5668
5668
  onCompositionStart(): void;
5669
5669
  onCompositionEnd(): void;
5670
5670
  onKeydown(ev: KeyboardEvent): void;
5671
+ private updateCursorIfNeeded;
5671
5672
  onInput(): void;
5672
5673
  onKeyup(ev: KeyboardEvent): void;
5673
5674
  showAutocomplete(searchTerm: string): void;
@@ -1703,27 +1703,36 @@ function removeTrailingZeroes(numberString) {
1703
1703
  }
1704
1704
  return numberString.slice(0, i + 1) || undefined;
1705
1705
  }
1706
+ const leadingZeroesRegexp = /^0+/;
1706
1707
  /**
1707
1708
  * Limit the size of the decimal part of a number to the given number of digits.
1708
1709
  */
1709
1710
  function limitDecimalDigits(decimalDigits, maxDecimals) {
1711
+ var _a;
1710
1712
  let integerDigits = "0";
1711
1713
  let resultDecimalDigits = decimalDigits;
1712
1714
  // Note : we'd want to simply use number.toFixed() to handle the max digits & rounding,
1713
1715
  // but it has very strange behaviour. Ex: 12.345.toFixed(2) => "12.35", but 1.345.toFixed(2) => "1.34"
1714
1716
  let slicedDecimalDigits = decimalDigits.slice(0, maxDecimals);
1715
1717
  const i = maxDecimals;
1716
- if (Number(Number(decimalDigits[i]) < 5)) {
1718
+ if (Number(decimalDigits[i]) < 5) {
1717
1719
  return { integerDigits, decimalDigits: slicedDecimalDigits };
1718
1720
  }
1719
1721
  // round up
1722
+ const leadingZeroes = ((_a = slicedDecimalDigits.match(leadingZeroesRegexp)) === null || _a === void 0 ? void 0 : _a[0]) || "";
1720
1723
  const slicedRoundedUp = (Number(slicedDecimalDigits) + 1).toString();
1721
- if (slicedRoundedUp.length > slicedDecimalDigits.length) {
1722
- integerDigits = (Number(integerDigits) + 1).toString();
1724
+ const withoutLeadingZeroes = slicedDecimalDigits.slice(leadingZeroes.length);
1725
+ // e.g. carry over from 99 to 100
1726
+ const carryOver = slicedRoundedUp.length > withoutLeadingZeroes.length;
1727
+ if (carryOver && !leadingZeroes) {
1728
+ integerDigits = "1";
1723
1729
  resultDecimalDigits = undefined;
1724
1730
  }
1731
+ else if (carryOver) {
1732
+ resultDecimalDigits = leadingZeroes.slice(0, -1) + slicedRoundedUp;
1733
+ }
1725
1734
  else {
1726
- resultDecimalDigits = slicedRoundedUp;
1735
+ resultDecimalDigits = leadingZeroes + slicedRoundedUp;
1727
1736
  }
1728
1737
  return { integerDigits, decimalDigits: resultDecimalDigits };
1729
1738
  }
@@ -17341,6 +17350,7 @@ class Composer extends Component {
17341
17350
  (this.autoCompleteState.selectedIndex + 1) % this.autoCompleteState.values.length;
17342
17351
  }
17343
17352
  }
17353
+ this.updateCursorIfNeeded();
17344
17354
  }
17345
17355
  processTabKey(ev) {
17346
17356
  var _a;
@@ -17399,9 +17409,12 @@ class Composer extends Component {
17399
17409
  }
17400
17410
  else {
17401
17411
  ev.stopPropagation();
17412
+ this.updateCursorIfNeeded();
17402
17413
  }
17403
- const { start, end } = this.contentHelper.getCurrentSelection();
17414
+ }
17415
+ updateCursorIfNeeded() {
17404
17416
  if (!this.env.model.getters.isSelectingForComposer()) {
17417
+ const { start, end } = this.contentHelper.getCurrentSelection();
17405
17418
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", { start, end });
17406
17419
  this.isKeyStillDown = true;
17407
17420
  }
@@ -20032,6 +20045,7 @@ css /* scss */ `
20032
20045
  .o-color-picker-toggler {
20033
20046
  display: flex;
20034
20047
  .o-color-picker-toggler-sign {
20048
+ display: flex;
20035
20049
  margin: auto auto;
20036
20050
  width: 55%;
20037
20051
  height: 55%;
@@ -44226,6 +44240,6 @@ function addFunction(functionName, functionDescription) {
44226
44240
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, 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, setTranslationMethod, tokenize };
44227
44241
 
44228
44242
 
44229
- __info__.version = '16.1.13';
44230
- __info__.date = '2023-06-02T10:12:21.173Z';
44231
- __info__.hash = '5386a5b';
44243
+ __info__.version = '16.1.14';
44244
+ __info__.date = '2023-06-12T13:50:13.693Z';
44245
+ __info__.hash = 'a51d9fa';
@@ -1704,27 +1704,36 @@
1704
1704
  }
1705
1705
  return numberString.slice(0, i + 1) || undefined;
1706
1706
  }
1707
+ const leadingZeroesRegexp = /^0+/;
1707
1708
  /**
1708
1709
  * Limit the size of the decimal part of a number to the given number of digits.
1709
1710
  */
1710
1711
  function limitDecimalDigits(decimalDigits, maxDecimals) {
1712
+ var _a;
1711
1713
  let integerDigits = "0";
1712
1714
  let resultDecimalDigits = decimalDigits;
1713
1715
  // Note : we'd want to simply use number.toFixed() to handle the max digits & rounding,
1714
1716
  // but it has very strange behaviour. Ex: 12.345.toFixed(2) => "12.35", but 1.345.toFixed(2) => "1.34"
1715
1717
  let slicedDecimalDigits = decimalDigits.slice(0, maxDecimals);
1716
1718
  const i = maxDecimals;
1717
- if (Number(Number(decimalDigits[i]) < 5)) {
1719
+ if (Number(decimalDigits[i]) < 5) {
1718
1720
  return { integerDigits, decimalDigits: slicedDecimalDigits };
1719
1721
  }
1720
1722
  // round up
1723
+ const leadingZeroes = ((_a = slicedDecimalDigits.match(leadingZeroesRegexp)) === null || _a === void 0 ? void 0 : _a[0]) || "";
1721
1724
  const slicedRoundedUp = (Number(slicedDecimalDigits) + 1).toString();
1722
- if (slicedRoundedUp.length > slicedDecimalDigits.length) {
1723
- integerDigits = (Number(integerDigits) + 1).toString();
1725
+ const withoutLeadingZeroes = slicedDecimalDigits.slice(leadingZeroes.length);
1726
+ // e.g. carry over from 99 to 100
1727
+ const carryOver = slicedRoundedUp.length > withoutLeadingZeroes.length;
1728
+ if (carryOver && !leadingZeroes) {
1729
+ integerDigits = "1";
1724
1730
  resultDecimalDigits = undefined;
1725
1731
  }
1732
+ else if (carryOver) {
1733
+ resultDecimalDigits = leadingZeroes.slice(0, -1) + slicedRoundedUp;
1734
+ }
1726
1735
  else {
1727
- resultDecimalDigits = slicedRoundedUp;
1736
+ resultDecimalDigits = leadingZeroes + slicedRoundedUp;
1728
1737
  }
1729
1738
  return { integerDigits, decimalDigits: resultDecimalDigits };
1730
1739
  }
@@ -17342,6 +17351,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
17342
17351
  (this.autoCompleteState.selectedIndex + 1) % this.autoCompleteState.values.length;
17343
17352
  }
17344
17353
  }
17354
+ this.updateCursorIfNeeded();
17345
17355
  }
17346
17356
  processTabKey(ev) {
17347
17357
  var _a;
@@ -17400,9 +17410,12 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
17400
17410
  }
17401
17411
  else {
17402
17412
  ev.stopPropagation();
17413
+ this.updateCursorIfNeeded();
17403
17414
  }
17404
- const { start, end } = this.contentHelper.getCurrentSelection();
17415
+ }
17416
+ updateCursorIfNeeded() {
17405
17417
  if (!this.env.model.getters.isSelectingForComposer()) {
17418
+ const { start, end } = this.contentHelper.getCurrentSelection();
17406
17419
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", { start, end });
17407
17420
  this.isKeyStillDown = true;
17408
17421
  }
@@ -20033,6 +20046,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20033
20046
  .o-color-picker-toggler {
20034
20047
  display: flex;
20035
20048
  .o-color-picker-toggler-sign {
20049
+ display: flex;
20036
20050
  margin: auto auto;
20037
20051
  width: 55%;
20038
20052
  height: 55%;
@@ -44257,9 +44271,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
44257
44271
  Object.defineProperty(exports, '__esModule', { value: true });
44258
44272
 
44259
44273
 
44260
- __info__.version = '16.1.13';
44261
- __info__.date = '2023-06-02T10:12:21.173Z';
44262
- __info__.hash = '5386a5b';
44274
+ __info__.version = '16.1.14';
44275
+ __info__.date = '2023-06-12T13:50:13.693Z';
44276
+ __info__.hash = 'a51d9fa';
44263
44277
 
44264
44278
 
44265
44279
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);