tg-core-components 6.1.3-crypto.1 → 6.1.3-crypto.12

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.
@@ -4,13 +4,25 @@ import React from 'react';
4
4
  import { FormattedNumber } from 'react-intl';
5
5
  import PropTypes from 'prop-types';
6
6
 
7
+ /**
8
+ * For crypto we want more decimals.
9
+ */
10
+ var fractionDigits = {
11
+ BTC: { min: 5, max: 5 },
12
+ LTC: { min: 5, max: 5 },
13
+ XBC: { min: 5, max: 5 },
14
+ XRP: { min: 5, max: 5 },
15
+ ETC: { min: 5, max: 5 },
16
+ BCH: { min: 5, max: 5 }
17
+ };
18
+
7
19
  /**
8
20
  * FormattedNumber component to display currency
9
21
  */
10
22
  var Money = function Money(props) {
11
23
  return React.createElement(FormattedNumber, _extends({
12
- minimumFractionDigits: props.decimals ? 2 : 0,
13
- maximumFractionDigits: props.decimals ? 2 : 0
24
+ minimumFractionDigits: props.decimals ? fractionDigits[props.currency] || 2 : 0,
25
+ maximumFractionDigits: props.decimals ? fractionDigits[props.currency] || 2 : 0
14
26
  }, props, {
15
27
  style: 'currency'
16
28
  }));
@@ -34,4 +46,11 @@ Money.defaultProps = {
34
46
  decimals: true
35
47
  };
36
48
 
49
+ export var format = function format(currency) {
50
+ return new Intl.NumberFormat('en-US', {
51
+ minimumFractionDigits: fractionDigits[currency] ? fractionDigits[currency].min : null,
52
+ maximumFractionDigits: fractionDigits[currency] ? fractionDigits[currency].max : null
53
+ });
54
+ };
55
+
37
56
  export default Money;
@@ -137,7 +137,10 @@ var HistoryWidgetList = function (_React$Component) {
137
137
  'div',
138
138
  null,
139
139
  getMessage(item.Settled ? 'settled' : 'pendling')
140
- )], [React.createElement(Money, { value: item.TotalWin - item.TotalWager, currency: item.Currency }), React.createElement(FormattedRelativeTime, selectUnit(new Date(item.Created + '+00:00')))]];
140
+ )], [React.createElement(Money, {
141
+ value: item.TotalWin - item.TotalWager,
142
+ currency: item.Currency
143
+ }), React.createElement(FormattedRelativeTime, selectUnit(new Date(item.Created + '+00:00')))]];
141
144
  } else if (product === 'bingo') {
142
145
  return [[React.createElement(Translate, {
143
146
  tag: 'div'
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.format = undefined;
6
7
 
7
8
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8
9
 
@@ -18,13 +19,25 @@ var _propTypes2 = _interopRequireDefault(_propTypes);
18
19
 
19
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
21
 
22
+ /**
23
+ * For crypto we want more decimals.
24
+ */
25
+ var fractionDigits = {
26
+ BTC: { min: 5, max: 5 },
27
+ LTC: { min: 5, max: 5 },
28
+ XBC: { min: 5, max: 5 },
29
+ XRP: { min: 5, max: 5 },
30
+ ETC: { min: 5, max: 5 },
31
+ BCH: { min: 5, max: 5 }
32
+ };
33
+
21
34
  /**
22
35
  * FormattedNumber component to display currency
23
36
  */
24
37
  var Money = function Money(props) {
25
38
  return _react2.default.createElement(_reactIntl.FormattedNumber, _extends({
26
- minimumFractionDigits: props.decimals ? 2 : 0,
27
- maximumFractionDigits: props.decimals ? 2 : 0
39
+ minimumFractionDigits: props.decimals ? fractionDigits[props.currency] || 2 : 0,
40
+ maximumFractionDigits: props.decimals ? fractionDigits[props.currency] || 2 : 0
28
41
  }, props, {
29
42
  style: 'currency'
30
43
  }));
@@ -48,4 +61,11 @@ Money.defaultProps = {
48
61
  decimals: true
49
62
  };
50
63
 
64
+ var format = exports.format = function format(currency) {
65
+ return new Intl.NumberFormat('en-US', {
66
+ minimumFractionDigits: fractionDigits[currency] ? fractionDigits[currency].min : null,
67
+ maximumFractionDigits: fractionDigits[currency] ? fractionDigits[currency].max : null
68
+ });
69
+ };
70
+
51
71
  exports.default = Money;
@@ -171,7 +171,10 @@ var HistoryWidgetList = function (_React$Component) {
171
171
  'div',
172
172
  null,
173
173
  (0, _message.getMessage)(item.Settled ? 'settled' : 'pendling')
174
- )], [_react2.default.createElement(_Money2.default, { value: item.TotalWin - item.TotalWager, currency: item.Currency }), _react2.default.createElement(_reactIntl.FormattedRelativeTime, selectUnit(new Date(item.Created + '+00:00')))]];
174
+ )], [_react2.default.createElement(_Money2.default, {
175
+ value: item.TotalWin - item.TotalWager,
176
+ currency: item.Currency
177
+ }), _react2.default.createElement(_reactIntl.FormattedRelativeTime, selectUnit(new Date(item.Created + '+00:00')))]];
175
178
  } else if (product === 'bingo') {
176
179
  return [[_react2.default.createElement(_Translate2.default, {
177
180
  tag: 'div'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tg-core-components",
3
- "version": "6.1.3-crypto.1",
3
+ "version": "6.1.3-crypto.12",
4
4
  "description": "tg-core-components",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",