1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
3 | import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
4 | var __rest = this && this.__rest || function (s, e) {
|
5 | var t = {};
|
6 | for (var p in s) {
|
7 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
8 | }
|
9 | if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
10 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
11 | }
|
12 | return t;
|
13 | };
|
14 | import CheckOutlined from "@ant-design/icons/es/icons/CheckOutlined";
|
15 | import CloseOutlined from "@ant-design/icons/es/icons/CloseOutlined";
|
16 | import classNames from 'classnames';
|
17 | import RcSteps from 'rc-steps';
|
18 | import * as React from 'react';
|
19 | import Tooltip from '../tooltip';
|
20 | import { ConfigContext } from '../config-provider';
|
21 | import useBreakpoint from '../grid/hooks/useBreakpoint';
|
22 | import Progress from '../progress';
|
23 | import useLegacyItems from './useLegacyItems';
|
24 | import useStyle from './style';
|
25 | var Steps = function Steps(props) {
|
26 | var _classNames;
|
27 | var percent = props.percent,
|
28 | size = props.size,
|
29 | className = props.className,
|
30 | direction = props.direction,
|
31 | items = props.items,
|
32 | _props$responsive = props.responsive,
|
33 | responsive = _props$responsive === void 0 ? true : _props$responsive,
|
34 | _props$current = props.current,
|
35 | current = _props$current === void 0 ? 0 : _props$current,
|
36 | children = props.children,
|
37 | restProps = __rest(props, ["percent", "size", "className", "direction", "items", "responsive", "current", "children"]);
|
38 | var _useBreakpoint = useBreakpoint(responsive),
|
39 | xs = _useBreakpoint.xs;
|
40 | var _React$useContext = React.useContext(ConfigContext),
|
41 | getPrefixCls = _React$useContext.getPrefixCls,
|
42 | rtlDirection = _React$useContext.direction;
|
43 | var realDirectionValue = React.useMemo(function () {
|
44 | return responsive && xs ? 'vertical' : direction;
|
45 | }, [xs, direction]);
|
46 | var prefixCls = getPrefixCls('steps', props.prefixCls);
|
47 | var _useStyle = useStyle(prefixCls),
|
48 | _useStyle2 = _slicedToArray(_useStyle, 2),
|
49 | wrapSSR = _useStyle2[0],
|
50 | hashId = _useStyle2[1];
|
51 | var isInline = props.type === 'inline';
|
52 | var iconPrefix = getPrefixCls('', props.iconPrefix);
|
53 | var mergedItems = useLegacyItems(items, children);
|
54 | var mergedPercent = isInline ? undefined : percent;
|
55 | var stepsClassName = classNames((_classNames = {}, _defineProperty(_classNames, prefixCls + "-rtl", rtlDirection === 'rtl'), _defineProperty(_classNames, prefixCls + "-with-progress", mergedPercent !== undefined), _classNames), className, hashId);
|
56 | var icons = {
|
57 | finish: React.createElement(CheckOutlined, {
|
58 | className: prefixCls + "-finish-icon"
|
59 | }),
|
60 | error: React.createElement(CloseOutlined, {
|
61 | className: prefixCls + "-error-icon"
|
62 | })
|
63 | };
|
64 | var stepIconRender = function stepIconRender(_ref) {
|
65 | var node = _ref.node,
|
66 | status = _ref.status;
|
67 | if (status === 'process' && mergedPercent !== undefined) {
|
68 |
|
69 | var progressWidth = size === 'small' ? 32 : 40;
|
70 |
|
71 | return React.createElement("div", {
|
72 | className: prefixCls + "-progress-icon"
|
73 | }, React.createElement(Progress, {
|
74 | type: "circle",
|
75 | percent: mergedPercent,
|
76 | width: progressWidth,
|
77 | strokeWidth: 4,
|
78 | format: function format() {
|
79 | return null;
|
80 | }
|
81 | }), node);
|
82 | }
|
83 | return node;
|
84 | };
|
85 | var itemRender = function itemRender(item, stepItem) {
|
86 | return item.description ? React.createElement(Tooltip, {
|
87 | title: item.description
|
88 | }, stepItem) : stepItem;
|
89 | };
|
90 | return wrapSSR( React.createElement(RcSteps, _extends({
|
91 | icons: icons
|
92 | }, restProps, {
|
93 | current: current,
|
94 | size: size,
|
95 | items: mergedItems,
|
96 | itemRender: isInline ? itemRender : undefined,
|
97 | stepIcon: stepIconRender,
|
98 | direction: realDirectionValue,
|
99 | prefixCls: prefixCls,
|
100 | iconPrefix: iconPrefix,
|
101 | className: stepsClassName
|
102 | })));
|
103 | };
|
104 | Steps.Step = RcSteps.Step;
|
105 | export default Steps; |
\ | No newline at end of file |