1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | var __rest = this && this.__rest || function (s, e) {
|
3 | var t = {};
|
4 | for (var p in s) {
|
5 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
6 | }
|
7 | if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
8 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
9 | }
|
10 | return t;
|
11 | };
|
12 | import classNames from 'classnames';
|
13 | import * as React from 'react';
|
14 | import { ConfigContext } from '../config-provider';
|
15 | import { cloneElement } from '../_util/reactNode';
|
16 | import SingleNumber from './SingleNumber';
|
17 | var ScrollNumber = function ScrollNumber(_a) {
|
18 | var customizePrefixCls = _a.prefixCls,
|
19 | count = _a.count,
|
20 | className = _a.className,
|
21 | motionClassName = _a.motionClassName,
|
22 | style = _a.style,
|
23 | title = _a.title,
|
24 | show = _a.show,
|
25 | _a$component = _a.component,
|
26 | component = _a$component === void 0 ? 'sup' : _a$component,
|
27 | children = _a.children,
|
28 | restProps = __rest(_a, ["prefixCls", "count", "className", "motionClassName", "style", "title", "show", "component", "children"]);
|
29 | var _React$useContext = React.useContext(ConfigContext),
|
30 | getPrefixCls = _React$useContext.getPrefixCls;
|
31 | var prefixCls = getPrefixCls('scroll-number', customizePrefixCls);
|
32 |
|
33 | var newProps = _extends(_extends({}, restProps), {
|
34 | 'data-show': show,
|
35 | style: style,
|
36 | className: classNames(prefixCls, className, motionClassName),
|
37 | title: title
|
38 | });
|
39 |
|
40 | var numberNodes = count;
|
41 | if (count && Number(count) % 1 === 0) {
|
42 | var numberList = String(count).split('');
|
43 | numberNodes = numberList.map(function (num, i) {
|
44 | return React.createElement(SingleNumber, {
|
45 | prefixCls: prefixCls,
|
46 | count: Number(count),
|
47 | value: num,
|
48 |
|
49 | key: numberList.length - i
|
50 | });
|
51 | });
|
52 | }
|
53 |
|
54 |
|
55 |
|
56 | if (style && style.borderColor) {
|
57 | newProps.style = _extends(_extends({}, style), {
|
58 | boxShadow: "0 0 0 1px " + style.borderColor + " inset"
|
59 | });
|
60 | }
|
61 | if (children) {
|
62 | return cloneElement(children, function (oriProps) {
|
63 | return {
|
64 | className: classNames(prefixCls + "-custom-component", oriProps === null || oriProps === void 0 ? void 0 : oriProps.className, motionClassName)
|
65 | };
|
66 | });
|
67 | }
|
68 | return React.createElement(component, newProps, numberNodes);
|
69 | };
|
70 | export default ScrollNumber; |
\ | No newline at end of file |