@datorama/core 22.12.3-rc.2 → 22.12.3-rc.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.
@@ -1649,6 +1649,30 @@
1649
1649
  function isNaN$1(number) {
1650
1650
  return typeof number === 'number' && number !== number;
1651
1651
  }
1652
+ function shortNumber(value, decimalPlaces) {
1653
+ if (decimalPlaces === void 0) { decimalPlaces = 0; }
1654
+ if (!isNumber(value)) {
1655
+ return '';
1656
+ }
1657
+ if (value < 1000) {
1658
+ return value.toString();
1659
+ }
1660
+ var suffixes = [
1661
+ { suffix: 'Q', minValue: Math.pow(10, 15) },
1662
+ { suffix: 'T', minValue: Math.pow(10, 12) },
1663
+ { suffix: 'B', minValue: Math.pow(10, 9) },
1664
+ { suffix: 'M', minValue: Math.pow(10, 6) },
1665
+ { suffix: 'K', minValue: 1000 }
1666
+ ];
1667
+ var round = function (num) { return Number(num.toFixed(decimalPlaces)); };
1668
+ for (var i = 0; i < suffixes.length; i++) {
1669
+ var _a = suffixes[i], minValue = _a.minValue, suffix = _a.suffix;
1670
+ if (value >= minValue) {
1671
+ return "" + round(value / minValue) + suffix;
1672
+ }
1673
+ }
1674
+ return "" + round(value);
1675
+ }
1652
1676
 
1653
1677
  /**
1654
1678
  *
@@ -4877,6 +4901,21 @@
4877
4901
  return DatoTreePipe;
4878
4902
  }());
4879
4903
 
4904
+ var DatoShortNumberPipe = /** @class */ (function () {
4905
+ function DatoShortNumberPipe() {
4906
+ }
4907
+ DatoShortNumberPipe.prototype.transform = function (value, decimalPlaces) {
4908
+ if (decimalPlaces === void 0) { decimalPlaces = 0; }
4909
+ return shortNumber(value, decimalPlaces);
4910
+ };
4911
+ DatoShortNumberPipe = __decorate([
4912
+ core.Pipe({
4913
+ name: 'shortNumber'
4914
+ })
4915
+ ], DatoShortNumberPipe);
4916
+ return DatoShortNumberPipe;
4917
+ }());
4918
+
4880
4919
  /**
4881
4920
  * @license
4882
4921
  * Copyright Datorama. All Rights Reserved.
@@ -4892,7 +4931,8 @@
4892
4931
  DatoSearchResultsGroupSortPipe,
4893
4932
  DatoSearchResultsSortPipe,
4894
4933
  DatoTrackByPropPipe,
4895
- DatoTreePipe
4934
+ DatoTreePipe,
4935
+ DatoShortNumberPipe
4896
4936
  ];
4897
4937
  var DatoPipesModule = /** @class */ (function () {
4898
4938
  function DatoPipesModule() {
@@ -25858,6 +25898,7 @@
25858
25898
  exports.DatoSelectComponent = DatoSelectComponent;
25859
25899
  exports.DatoSelectEmptyComponent = DatoSelectEmptyComponent;
25860
25900
  exports.DatoSelectModule = DatoSelectModule;
25901
+ exports.DatoShortNumberPipe = DatoShortNumberPipe;
25861
25902
  exports.DatoSliderComponent = DatoSliderComponent;
25862
25903
  exports.DatoSliderModule = DatoSliderModule;
25863
25904
  exports.DatoSnackbar = DatoSnackbar;
@@ -26065,6 +26106,7 @@
26065
26106
  exports.setMinDimensions = setMinDimensions;
26066
26107
  exports.setStyle = setStyle;
26067
26108
  exports.setStyles = setStyles;
26109
+ exports.shortNumber = shortNumber;
26068
26110
  exports.size = size;
26069
26111
  exports.sortBy = sortBy;
26070
26112
  exports.stubs = stubs;