tg-core-components 6.1.3-crypto.10 → 6.1.3-crypto.13
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;
|
|
@@ -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;
|