1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import { createVNode as _createVNode } from "vue";
|
3 |
|
4 | var __rest = this && this.__rest || function (s, e) {
|
5 | var t = {};
|
6 |
|
7 | for (var p in s) {
|
8 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
9 | }
|
10 |
|
11 | if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
12 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
13 | }
|
14 | return t;
|
15 | };
|
16 |
|
17 | import classNames from '../_util/classNames';
|
18 | import PropTypes from '../_util/vue-types';
|
19 | import { cloneElement } from '../_util/vnode';
|
20 | import { defineComponent } from 'vue';
|
21 | import useConfigInject from '../_util/hooks/useConfigInject';
|
22 | import SingleNumber from './SingleNumber';
|
23 | import { filterEmpty } from '../_util/props-util';
|
24 | export var scrollNumberProps = {
|
25 | prefixCls: PropTypes.string,
|
26 | count: PropTypes.any,
|
27 | component: PropTypes.string,
|
28 | title: PropTypes.oneOfType([PropTypes.number, PropTypes.string, null]),
|
29 | show: Boolean
|
30 | };
|
31 | export default defineComponent({
|
32 | name: 'ScrollNumber',
|
33 | inheritAttrs: false,
|
34 | props: scrollNumberProps,
|
35 | setup: function setup(props, _ref) {
|
36 | var attrs = _ref.attrs,
|
37 | slots = _ref.slots;
|
38 |
|
39 | var _useConfigInject = useConfigInject('scroll-number', props),
|
40 | prefixCls = _useConfigInject.prefixCls;
|
41 |
|
42 | return function () {
|
43 | var _a;
|
44 |
|
45 | var _b = _extends(_extends({}, props), attrs),
|
46 | customizePrefixCls = _b.prefixCls,
|
47 | count = _b.count,
|
48 | title = _b.title,
|
49 | show = _b.show,
|
50 | _b$component = _b.component,
|
51 | Tag = _b$component === void 0 ? 'sup' : _b$component,
|
52 | className = _b.class,
|
53 | style = _b.style,
|
54 | restProps = __rest(_b, ["prefixCls", "count", "title", "show", "component", "class", "style"]);
|
55 |
|
56 |
|
57 | var newProps = _extends(_extends({}, restProps), {
|
58 | style: style,
|
59 | 'data-show': props.show,
|
60 | class: classNames(prefixCls.value, className),
|
61 | title: title
|
62 | });
|
63 |
|
64 |
|
65 | var numberNodes = count;
|
66 |
|
67 | if (count && Number(count) % 1 === 0) {
|
68 | var numberList = String(count).split('');
|
69 | numberNodes = numberList.map(function (num, i) {
|
70 | return _createVNode(SingleNumber, {
|
71 | "prefixCls": prefixCls.value,
|
72 | "count": Number(count),
|
73 | "value": num,
|
74 | "key": numberList.length - i
|
75 | }, null);
|
76 | });
|
77 | }
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | if (style && style.borderColor) {
|
83 | newProps.style = _extends(_extends({}, style), {
|
84 | boxShadow: "0 0 0 1px ".concat(style.borderColor, " inset")
|
85 | });
|
86 | }
|
87 |
|
88 | var children = filterEmpty((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots));
|
89 |
|
90 | if (children && children.length) {
|
91 | return cloneElement(children, {
|
92 | class: classNames("".concat(prefixCls.value, "-custom-component"))
|
93 | }, false);
|
94 | }
|
95 |
|
96 | return _createVNode(Tag, newProps, {
|
97 | default: function _default() {
|
98 | return [numberNodes];
|
99 | }
|
100 | });
|
101 | };
|
102 | }
|
103 | }); |
\ | No newline at end of file |