index.js
2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import * as React from 'react';
import omit from 'omit.js';
import RcSteps from 'rc-steps';
import CheckOutlined from '@ant-design/icons/CheckOutlined';
import CloseOutlined from '@ant-design/icons/CloseOutlined';
import classNames from 'classnames';
import { ConfigContext } from '../config-provider';
import Progress from '../progress';
import useBreakpoint from '../grid/hooks/useBreakpoint';
var Steps = function Steps(props) {
var _classNames;
var percent = props.percent,
size = props.size,
className = props.className,
direction = props.direction;
var _useBreakpoint = useBreakpoint(),
xs = _useBreakpoint.xs;
var _React$useContext = React.useContext(ConfigContext),
getPrefixCls = _React$useContext.getPrefixCls,
rtlDirection = _React$useContext.direction;
var getDirection = React.useCallback(function () {
return xs ? 'vertical' : direction;
}, [xs, direction]);
var prefixCls = getPrefixCls('steps', props.prefixCls);
var iconPrefix = getPrefixCls('', props.iconPrefix);
var stepsClassName = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-rtl"), rtlDirection === 'rtl'), _defineProperty(_classNames, "".concat(prefixCls, "-with-progress"), percent !== undefined), _classNames), className);
var icons = {
finish: /*#__PURE__*/React.createElement(CheckOutlined, {
className: "".concat(prefixCls, "-finish-icon")
}),
error: /*#__PURE__*/React.createElement(CloseOutlined, {
className: "".concat(prefixCls, "-error-icon")
})
};
var stepIconRender = function stepIconRender(_ref) {
var node = _ref.node,
status = _ref.status;
if (status === 'process' && percent !== undefined) {
// currently it's hard-coded, since we can't easily read the actually width of icon
var progressWidth = size === 'small' ? 32 : 40;
var iconWithProgress = /*#__PURE__*/React.createElement("div", {
className: "".concat(prefixCls, "-progress-icon")
}, /*#__PURE__*/React.createElement(Progress, {
type: "circle",
percent: percent,
width: progressWidth,
strokeWidth: 4,
format: function format() {
return null;
}
}), node);
return iconWithProgress;
}
return node;
};
return /*#__PURE__*/React.createElement(RcSteps, _extends({
icons: icons
}, omit(props, ['percent']), {
direction: getDirection(),
stepIcon: stepIconRender,
prefixCls: prefixCls,
iconPrefix: iconPrefix,
className: stepsClassName
}));
};
Steps.Step = RcSteps.Step;
Steps.defaultProps = {
current: 0
};
export default Steps;