@synerise/ds-format-picker 0.5.2 → 0.5.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.
- package/CHANGELOG.md +11 -0
- package/dist/FormatPicker.js +49 -14
- package/dist/FormatSettings/FormatSettings.d.ts +1 -1
- package/dist/FormatSettings/FormatSettings.js +4 -15
- package/dist/FormatSettings/FormatSettings.types.d.ts +3 -1
- package/package.json +10 -11
- package/dist/utils/valueFormatter.d.ts +0 -9
- package/dist/utils/valueFormatter.js +0 -203
- package/dist/utils/valueFormatter.types.d.ts +0 -7
- package/dist/utils/valueFormatter.types.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.5.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-format-picker@0.5.2...@synerise/ds-format-picker@0.5.3) (2024-08-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **format-picker:** use ds-data-format to format value preview ([6926f1b](https://github.com/Synerise/synerise-design/commit/6926f1ba2eb9a2314365a5203e26f67777fc4fa1))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [0.5.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-format-picker@0.5.1...@synerise/ds-format-picker@0.5.2) (2024-08-19)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @synerise/ds-format-picker
|
package/dist/FormatPicker.js
CHANGED
|
@@ -4,13 +4,13 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
|
-
import React, { useEffect, useMemo } from 'react';
|
|
7
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
8
8
|
import { useIntl } from 'react-intl';
|
|
9
9
|
import Button from '@synerise/ds-button';
|
|
10
10
|
import Dropdown from '@synerise/ds-dropdown';
|
|
11
11
|
import Icon, { HashM } from '@synerise/ds-icon';
|
|
12
|
+
import { useDataFormat } from '@synerise/ds-data-format';
|
|
12
13
|
import FormatSettings from './FormatSettings/FormatSettings';
|
|
13
|
-
import { valueFormatter } from './utils/valueFormatter';
|
|
14
14
|
|
|
15
15
|
var FormatPicker = function FormatPicker(_ref) {
|
|
16
16
|
var onUseSeparatorChange = _ref.onUseSeparatorChange,
|
|
@@ -28,6 +28,10 @@ var FormatPicker = function FormatPicker(_ref) {
|
|
|
28
28
|
buttonType = _ref$buttonType === void 0 ? 'tertiary' : _ref$buttonType,
|
|
29
29
|
disabled = _ref.disabled;
|
|
30
30
|
var intl = useIntl();
|
|
31
|
+
|
|
32
|
+
var _useDataFormat = useDataFormat(),
|
|
33
|
+
formatValue = _useDataFormat.formatValue;
|
|
34
|
+
|
|
31
35
|
var texts = useMemo(function () {
|
|
32
36
|
return _objectSpread({
|
|
33
37
|
header: intl.formatMessage({
|
|
@@ -64,16 +68,47 @@ var FormatPicker = function FormatPicker(_ref) {
|
|
|
64
68
|
})
|
|
65
69
|
}, text);
|
|
66
70
|
}, [text, intl]);
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
var getFormattedValue = useCallback(function (overrideOptions) {
|
|
72
|
+
var useSeparator = format.useSeparator,
|
|
73
|
+
compactNumbers = format.compactNumbers,
|
|
74
|
+
currency = format.currency,
|
|
75
|
+
dataFormat = format.dataFormat,
|
|
76
|
+
fixedLength = format.fixedLength;
|
|
77
|
+
var options = {
|
|
78
|
+
useGrouping: useSeparator
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
if (compactNumbers) {
|
|
82
|
+
options = {
|
|
83
|
+
notation: 'compact'
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (dataFormat === 'cash' && currency) {
|
|
88
|
+
options = _objectSpread({}, options, {
|
|
89
|
+
currency: currency,
|
|
90
|
+
style: 'currency'
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (dataFormat === 'percent') {
|
|
95
|
+
options = _objectSpread({}, options, {
|
|
96
|
+
suffix: compactNumbers ? ' %' : '%'
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (typeof fixedLength === 'number') {
|
|
101
|
+
options = _objectSpread({}, options, {
|
|
102
|
+
minimumFractionDigits: fixedLength,
|
|
103
|
+
maximumFractionDigits: fixedLength
|
|
104
|
+
}, overrideOptions);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return formatValue(value, options);
|
|
108
|
+
}, [value, format, formatValue]);
|
|
74
109
|
useEffect(function () {
|
|
75
|
-
onFormattedValueChange && onFormattedValueChange(
|
|
76
|
-
}, [
|
|
110
|
+
onFormattedValueChange && onFormattedValueChange(getFormattedValue());
|
|
111
|
+
}, [getFormattedValue, onFormattedValueChange]);
|
|
77
112
|
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
78
113
|
trigger: ['click'],
|
|
79
114
|
disabled: disabled,
|
|
@@ -85,10 +120,10 @@ var FormatPicker = function FormatPicker(_ref) {
|
|
|
85
120
|
onUseSeparatorChange: onUseSeparatorChange,
|
|
86
121
|
onSetDefault: onSetDefault,
|
|
87
122
|
format: format,
|
|
88
|
-
value: value,
|
|
89
123
|
text: texts,
|
|
90
124
|
currenciesConfig: currenciesConfig,
|
|
91
|
-
disabled: disabled
|
|
125
|
+
disabled: disabled,
|
|
126
|
+
getFormattedValue: getFormattedValue
|
|
92
127
|
}),
|
|
93
128
|
placement: "topCenter"
|
|
94
129
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
@@ -97,7 +132,7 @@ var FormatPicker = function FormatPicker(_ref) {
|
|
|
97
132
|
disabled: disabled
|
|
98
133
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
99
134
|
component: /*#__PURE__*/React.createElement(HashM, null)
|
|
100
|
-
}), texts.format + " " +
|
|
135
|
+
}), texts.format + " " + getFormattedValue()));
|
|
101
136
|
};
|
|
102
137
|
|
|
103
138
|
export default FormatPicker;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FormatSettingsProps } from './FormatSettings.types';
|
|
3
|
-
declare const FormatSettings: ({ onCompactNumbersChange, onCurrencyChange, onDataFormatChange, onFixedLengthChange, onUseSeparatorChange, onSetDefault,
|
|
3
|
+
declare const FormatSettings: ({ onCompactNumbersChange, onCurrencyChange, onDataFormatChange, onFixedLengthChange, onUseSeparatorChange, onSetDefault, getFormattedValue, format, text, currenciesConfig, disabled, }: FormatSettingsProps) => React.JSX.Element;
|
|
4
4
|
export default FormatSettings;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
1
|
import React, { useCallback, useMemo } from 'react';
|
|
8
|
-
import Icon, { AngleDownS, Coin2M, CommaDecM, CommaIncM, HashM, PercentM } from '@synerise/ds-icon';
|
|
9
2
|
import { useIntl } from 'react-intl';
|
|
3
|
+
import Icon, { AngleDownS, Coin2M, CommaDecM, CommaIncM, HashM, PercentM } from '@synerise/ds-icon';
|
|
10
4
|
import { Title } from '@synerise/ds-typography';
|
|
11
5
|
import Tooltip from '@synerise/ds-tooltip';
|
|
12
6
|
import Radio from '@synerise/ds-radio';
|
|
@@ -15,7 +9,6 @@ import Button from '@synerise/ds-button';
|
|
|
15
9
|
import Checkbox from '@synerise/ds-checkbox';
|
|
16
10
|
import Dropdown from '@synerise/ds-dropdown';
|
|
17
11
|
import * as S from './FormatSettings.styles';
|
|
18
|
-
import { valueFormatter } from '../utils/valueFormatter';
|
|
19
12
|
var DEFAULT_CURRENCIES_CONFIG = [{
|
|
20
13
|
currency: 'USD',
|
|
21
14
|
label: 'Dollar (US)'
|
|
@@ -53,8 +46,8 @@ var FormatSettings = function FormatSettings(_ref) {
|
|
|
53
46
|
onFixedLengthChange = _ref.onFixedLengthChange,
|
|
54
47
|
onUseSeparatorChange = _ref.onUseSeparatorChange,
|
|
55
48
|
onSetDefault = _ref.onSetDefault,
|
|
49
|
+
getFormattedValue = _ref.getFormattedValue,
|
|
56
50
|
format = _ref.format,
|
|
57
|
-
value = _ref.value,
|
|
58
51
|
text = _ref.text,
|
|
59
52
|
_ref$currenciesConfig = _ref.currenciesConfig,
|
|
60
53
|
currenciesConfig = _ref$currenciesConfig === void 0 ? DEFAULT_CURRENCIES_CONFIG : _ref$currenciesConfig,
|
|
@@ -124,12 +117,8 @@ var FormatSettings = function FormatSettings(_ref) {
|
|
|
124
117
|
label = _ref2.label;
|
|
125
118
|
return /*#__PURE__*/React.createElement(S.ListItem, {
|
|
126
119
|
key: currency,
|
|
127
|
-
suffixel:
|
|
128
|
-
|
|
129
|
-
formatting: _objectSpread({}, format, {
|
|
130
|
-
currency: currency
|
|
131
|
-
}),
|
|
132
|
-
intl: intl
|
|
120
|
+
suffixel: getFormattedValue({
|
|
121
|
+
currency: currency
|
|
133
122
|
}),
|
|
134
123
|
onClick: function onClick() {
|
|
135
124
|
return onCurrencyChange(currency);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { NumberToFormatOptions } from '@synerise/ds-data-format';
|
|
1
2
|
import type { FormatPickerProps, FormatPickerTexts } from '../FomartPicker.types';
|
|
2
|
-
export type FormatSettingsProps = Omit<FormatPickerProps, 'text'> & {
|
|
3
|
+
export type FormatSettingsProps = Omit<FormatPickerProps, 'text' | 'value'> & {
|
|
4
|
+
getFormattedValue: (options: NumberToFormatOptions) => string;
|
|
3
5
|
text: FormatPickerTexts;
|
|
4
6
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-format-picker",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "FormatPicker UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -33,18 +33,17 @@
|
|
|
33
33
|
],
|
|
34
34
|
"types": "dist/index.d.ts",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@synerise/ds-button": "^0.21.
|
|
37
|
-
"@synerise/ds-button-group": "^0.7.
|
|
36
|
+
"@synerise/ds-button": "^0.21.6",
|
|
37
|
+
"@synerise/ds-button-group": "^0.7.10",
|
|
38
38
|
"@synerise/ds-checkbox": "^0.12.4",
|
|
39
|
-
"@synerise/ds-
|
|
40
|
-
"@synerise/ds-
|
|
41
|
-
"@synerise/ds-
|
|
39
|
+
"@synerise/ds-data-format": "^0.5.2",
|
|
40
|
+
"@synerise/ds-dropdown": "^0.18.10",
|
|
41
|
+
"@synerise/ds-icon": "^0.65.1",
|
|
42
|
+
"@synerise/ds-list-item": "^0.4.6",
|
|
42
43
|
"@synerise/ds-radio": "^0.12.0",
|
|
43
|
-
"@synerise/ds-tooltip": "^0.14.
|
|
44
|
+
"@synerise/ds-tooltip": "^0.14.36",
|
|
44
45
|
"@synerise/ds-typography": "^0.15.1",
|
|
45
|
-
"@
|
|
46
|
-
"lodash": "^4.17.19",
|
|
47
|
-
"numeral": "^2.0.6",
|
|
46
|
+
"@synerise/ds-utils": "^0.28.2",
|
|
48
47
|
"react-intl": "3.12.0"
|
|
49
48
|
},
|
|
50
49
|
"peerDependencies": {
|
|
@@ -52,5 +51,5 @@
|
|
|
52
51
|
"react": ">=16.9.0 <= 17.0.2",
|
|
53
52
|
"styled-components": "5.0.1"
|
|
54
53
|
},
|
|
55
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "a035aeea499cea00e72e20e3790c0ffcad4fe956"
|
|
56
55
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IntlShape } from 'react-intl';
|
|
2
|
-
import { CurrencyType, FormattingDataFormat, FormattingValue } from '../FomartPicker.types';
|
|
3
|
-
import { ValueFormatterProps } from './valueFormatter.types';
|
|
4
|
-
export declare const appendZeros: (fixedLength: number) => string;
|
|
5
|
-
export declare const chooseSuffix: (compactNumbers: boolean) => string;
|
|
6
|
-
export declare const choosePrefix: (useSeparator: boolean) => string;
|
|
7
|
-
export declare const getFormattingFormula: (formatting: FormattingValue) => string;
|
|
8
|
-
export declare const appendSign: (input: string, intl: IntlShape, format: FormattingDataFormat, currency: CurrencyType) => string;
|
|
9
|
-
export declare const valueFormatter: (props: ValueFormatterProps) => string;
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import numeral from 'numeral';
|
|
3
|
-
import { range } from 'lodash';
|
|
4
|
-
var CONTAINS_LETTERS = /[^0-9,.]/;
|
|
5
|
-
var DIGITS = /[0-9,.]+/;
|
|
6
|
-
var ptConfig = {
|
|
7
|
-
delimiters: {
|
|
8
|
-
thousands: ' ',
|
|
9
|
-
decimal: ','
|
|
10
|
-
},
|
|
11
|
-
abbreviations: {
|
|
12
|
-
thousand: 'k',
|
|
13
|
-
million: 'm',
|
|
14
|
-
billion: 'b',
|
|
15
|
-
trillion: 't'
|
|
16
|
-
},
|
|
17
|
-
ordinal: function ordinal() {
|
|
18
|
-
return 'º';
|
|
19
|
-
},
|
|
20
|
-
currency: {
|
|
21
|
-
symbol: '€'
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
if (numeral.locales.pl === undefined) {
|
|
26
|
-
numeral.register('locale', 'pl', {
|
|
27
|
-
delimiters: {
|
|
28
|
-
thousands: ',',
|
|
29
|
-
decimal: '.'
|
|
30
|
-
},
|
|
31
|
-
abbreviations: {
|
|
32
|
-
thousand: ' tys',
|
|
33
|
-
million: ' mln',
|
|
34
|
-
billion: ' mld',
|
|
35
|
-
trillion: ' bln'
|
|
36
|
-
},
|
|
37
|
-
ordinal: function ordinal(number) {
|
|
38
|
-
return number === 1 ? 'er' : 'ème';
|
|
39
|
-
},
|
|
40
|
-
currency: {
|
|
41
|
-
symbol: '$'
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (numeral.locales.es === undefined) {
|
|
47
|
-
numeral.register('locale', 'es', {
|
|
48
|
-
delimiters: {
|
|
49
|
-
thousands: '.',
|
|
50
|
-
decimal: ','
|
|
51
|
-
},
|
|
52
|
-
abbreviations: {
|
|
53
|
-
thousand: 'k',
|
|
54
|
-
million: 'mm',
|
|
55
|
-
billion: 'b',
|
|
56
|
-
trillion: 't'
|
|
57
|
-
},
|
|
58
|
-
ordinal: function ordinal(number) {
|
|
59
|
-
var b = number % 10;
|
|
60
|
-
var result = ['mo', 'er', 'do', 'er', 'to', 'to', 'to', 'mo', 'mo', 'no'];
|
|
61
|
-
return result[b];
|
|
62
|
-
},
|
|
63
|
-
currency: {
|
|
64
|
-
symbol: '$'
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (numeral.locales.fr === undefined) {
|
|
70
|
-
numeral.register('locale', 'fr', {
|
|
71
|
-
delimiters: {
|
|
72
|
-
thousands: '.',
|
|
73
|
-
decimal: ','
|
|
74
|
-
},
|
|
75
|
-
abbreviations: {
|
|
76
|
-
thousand: 'k',
|
|
77
|
-
million: 'mm',
|
|
78
|
-
billion: 'b',
|
|
79
|
-
trillion: 't'
|
|
80
|
-
},
|
|
81
|
-
ordinal: function ordinal(number) {
|
|
82
|
-
return number === 1 ? 'er' : 'e';
|
|
83
|
-
},
|
|
84
|
-
currency: {
|
|
85
|
-
symbol: '$'
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (numeral.locales.pt === undefined) {
|
|
91
|
-
numeral.register('locale', 'pt', ptConfig);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (numeral.locales['pt-pt'] === undefined) {
|
|
95
|
-
numeral.register('locale', 'pt-pt', ptConfig);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (numeral.locales['en-gb'] === undefined) {
|
|
99
|
-
numeral.register('locale', 'en-gb', {
|
|
100
|
-
delimiters: {
|
|
101
|
-
thousands: ',',
|
|
102
|
-
decimal: '.'
|
|
103
|
-
},
|
|
104
|
-
abbreviations: {
|
|
105
|
-
thousand: 'k',
|
|
106
|
-
million: 'm',
|
|
107
|
-
billion: 'b',
|
|
108
|
-
trillion: 't'
|
|
109
|
-
},
|
|
110
|
-
ordinal: function ordinal(number) {
|
|
111
|
-
var b = number % 10;
|
|
112
|
-
|
|
113
|
-
if (Math.floor(number % 100 / 10) === 1) {
|
|
114
|
-
return 'th';
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (b === 1) return 'st';
|
|
118
|
-
if (b === 2) return 'nd';
|
|
119
|
-
if (b === 3) return 'rd';
|
|
120
|
-
return 'th';
|
|
121
|
-
},
|
|
122
|
-
currency: {
|
|
123
|
-
symbol: '£'
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (numeral.locales['en-us'] === undefined) {
|
|
129
|
-
numeral.register('locale', 'en-us', {
|
|
130
|
-
delimiters: {
|
|
131
|
-
thousands: ',',
|
|
132
|
-
decimal: '.'
|
|
133
|
-
},
|
|
134
|
-
abbreviations: {
|
|
135
|
-
thousand: 'k',
|
|
136
|
-
million: 'm',
|
|
137
|
-
billion: 'b',
|
|
138
|
-
trillion: 't'
|
|
139
|
-
},
|
|
140
|
-
ordinal: function ordinal(number) {
|
|
141
|
-
var b = number % 10;
|
|
142
|
-
|
|
143
|
-
if (Math.floor(number % 100 / 10) === 1) {
|
|
144
|
-
return 'th';
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (b === 1) return 'st';
|
|
148
|
-
if (b === 2) return 'nd';
|
|
149
|
-
if (b === 3) return 'rd';
|
|
150
|
-
return 'th';
|
|
151
|
-
},
|
|
152
|
-
currency: {
|
|
153
|
-
symbol: '$'
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export var appendZeros = function appendZeros(fixedLength) {
|
|
159
|
-
if (!fixedLength) {
|
|
160
|
-
return '';
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return "." + range(0, fixedLength, 0).join('');
|
|
164
|
-
};
|
|
165
|
-
export var chooseSuffix = function chooseSuffix(compactNumbers) {
|
|
166
|
-
return compactNumbers ? 'a' : '';
|
|
167
|
-
};
|
|
168
|
-
export var choosePrefix = function choosePrefix(useSeparator) {
|
|
169
|
-
return useSeparator ? '0,0' : '0';
|
|
170
|
-
};
|
|
171
|
-
export var getFormattingFormula = function getFormattingFormula(formatting) {
|
|
172
|
-
return "" + choosePrefix(formatting.useSeparator) + appendZeros(formatting.fixedLength) + chooseSuffix(formatting.compactNumbers);
|
|
173
|
-
};
|
|
174
|
-
export var appendSign = function appendSign(input, intl, format, currency) {
|
|
175
|
-
switch (format) {
|
|
176
|
-
case 'cash':
|
|
177
|
-
{
|
|
178
|
-
if (!currency) {
|
|
179
|
-
return input;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
var currencyFormat = intl.formatNumber(1, {
|
|
183
|
-
style: 'currency',
|
|
184
|
-
currencyDisplay: 'symbol',
|
|
185
|
-
currency: currency
|
|
186
|
-
});
|
|
187
|
-
return CONTAINS_LETTERS.test(input) ? currencyFormat.replace(DIGITS, input + " ") : currencyFormat.replace(DIGITS, input);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
case 'percent':
|
|
191
|
-
return CONTAINS_LETTERS.test(input) ? input + " %" : input + "%";
|
|
192
|
-
|
|
193
|
-
case 'numeric':
|
|
194
|
-
default:
|
|
195
|
-
return input;
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
export var valueFormatter = function valueFormatter(props) {
|
|
199
|
-
numeral.locale(props.intl.locale.toLowerCase());
|
|
200
|
-
var formattedValue = numeral(props.value.toFixed(props.formatting.fixedLength)).format(getFormattingFormula(props.formatting));
|
|
201
|
-
var result = appendSign(formattedValue, props.intl, props.formatting.dataFormat, props.formatting.currency);
|
|
202
|
-
return result;
|
|
203
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|