1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | var _vue = require("vue");
|
9 |
|
10 | var _padEnd = _interopRequireDefault(require("lodash-es/padEnd"));
|
11 |
|
12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13 |
|
14 | function _isSlot(s) {
|
15 | return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !(0, _vue.isVNode)(s);
|
16 | }
|
17 |
|
18 | var StatisticNumber = function StatisticNumber(props) {
|
19 | var value = props.value,
|
20 | formatter = props.formatter,
|
21 | precision = props.precision,
|
22 | decimalSeparator = props.decimalSeparator,
|
23 | _props$groupSeparator = props.groupSeparator,
|
24 | groupSeparator = _props$groupSeparator === void 0 ? '' : _props$groupSeparator,
|
25 | prefixCls = props.prefixCls;
|
26 | var valueNode;
|
27 |
|
28 | if (typeof formatter === 'function') {
|
29 |
|
30 | valueNode = formatter({
|
31 | value: value
|
32 | });
|
33 | } else {
|
34 |
|
35 | var val = String(value);
|
36 | var cells = val.match(/^(-?)(\d*)(\.(\d+))?$/);
|
37 |
|
38 | if (!cells) {
|
39 | valueNode = val;
|
40 | } else {
|
41 | var negative = cells[1];
|
42 |
|
43 | var _int = cells[2] || '0';
|
44 |
|
45 | var decimal = cells[4] || '';
|
46 | _int = _int.replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator);
|
47 |
|
48 | if (typeof precision === 'number') {
|
49 | decimal = (0, _padEnd.default)(decimal, precision, '0').slice(0, precision);
|
50 | }
|
51 |
|
52 | if (decimal) {
|
53 | decimal = "".concat(decimalSeparator).concat(decimal);
|
54 | }
|
55 |
|
56 | valueNode = [(0, _vue.createVNode)("span", {
|
57 | "key": "int",
|
58 | "class": "".concat(prefixCls, "-content-value-int")
|
59 | }, [negative, _int]), decimal && (0, _vue.createVNode)("span", {
|
60 | "key": "decimal",
|
61 | "class": "".concat(prefixCls, "-content-value-decimal")
|
62 | }, _isSlot(decimal) ? decimal : {
|
63 | default: function _default() {
|
64 | return [decimal];
|
65 | }
|
66 | })];
|
67 | }
|
68 | }
|
69 |
|
70 | return (0, _vue.createVNode)("span", {
|
71 | "class": "".concat(prefixCls, "-content-value")
|
72 | }, _isSlot(valueNode) ? valueNode : {
|
73 | default: function _default() {
|
74 | return [valueNode];
|
75 | }
|
76 | });
|
77 | };
|
78 |
|
79 | StatisticNumber.displayName = 'StatisticNumber';
|
80 | var _default2 = StatisticNumber;
|
81 | exports.default = _default2; |
\ | No newline at end of file |