11/* eslint react/no-did-mount-set-state: 0, react/prop-types: 0 */
22import cls from 'classnames' ;
33import React from 'react' ;
4- import type { Icons , Status } from './interface' ;
5- import type { StepProps } from './Step' ;
64import Step from './Step' ;
5+ import Rail from './Rail' ;
6+
7+ export type Status = 'error' | 'process' | 'finish' | 'wait' ;
78
89export type SemanticName = 'root' | 'item' | 'itemTitle' | 'itemContent' | 'itemIcon' | 'itemRail' ;
910
@@ -28,18 +29,6 @@ export type StepIconRender = (info: {
2829 node : React . ReactNode ;
2930} ) => React . ReactNode ;
3031
31- export type ProgressDotRender = (
32- iconDot : React . ReactNode ,
33- info : {
34- index : number ;
35- status : Status ;
36- title : React . ReactNode ;
37- // @deprecated Please use `content` instead.
38- description : React . ReactNode ;
39- content : React . ReactNode ;
40- } ,
41- ) => React . ReactNode ;
42-
4332export type RenderInfo = {
4433 index : number ;
4534 active : boolean ;
@@ -58,7 +47,6 @@ export interface StepsProps {
5847 // layout
5948 orientation ?: 'horizontal' | 'vertical' ;
6049 labelPlacement ?: 'horizontal' | 'vertical' ;
61- progressDot ?: ProgressDotRender | boolean ;
6250
6351 // data
6452 status ?: Status ;
@@ -78,14 +66,13 @@ export default function Steps(props: StepsProps) {
7866 prefixCls = 'rc-steps' ,
7967 style,
8068 className,
81- classNames,
82- styles,
69+ classNames = { } ,
70+ styles = { } ,
8371 rootClassName,
8472
8573 // layout
8674 orientation = 'horizontal' ,
8775 labelPlacement = 'horizontal' ,
88- progressDot,
8976
9077 // data
9178 status = 'process' ,
@@ -102,21 +89,14 @@ export default function Steps(props: StepsProps) {
10289 } = props ;
10390
10491 // ============================= layout =============================
105- const [ mergedOrientation , mergeLabelPlacement ] = React . useMemo ( ( ) => {
106- const nextOrientation = orientation === 'vertical' ? 'vertical' : 'horizontal' ;
107- const nextLabelPlacement = progressDot ? 'vertical' : labelPlacement ;
108-
109- return [ nextOrientation , nextLabelPlacement ] as const ;
110- } , [ orientation , progressDot , labelPlacement ] ) ;
92+ const mergedOrientation = orientation === 'vertical' ? 'vertical' : 'horizontal' ;
93+ const mergeLabelPlacement = labelPlacement === 'vertical' ? 'vertical' : 'horizontal' ;
11194
11295 // ============================= styles =============================
11396 const classString = cls (
11497 prefixCls ,
11598 `${ prefixCls } -${ mergedOrientation } ` ,
116- {
117- [ `${ prefixCls } -label-${ mergeLabelPlacement } ` ] : mergedOrientation === 'horizontal' ,
118- [ `${ prefixCls } -dot` ] : ! ! progressDot ,
119- } ,
99+ `${ prefixCls } -label-${ mergeLabelPlacement } ` ,
120100 rootClassName ,
121101 className ,
122102 classNames . root ,
@@ -159,49 +139,33 @@ export default function Steps(props: StepsProps) {
159139 // data.className = `${prefixCls}-next-error`;
160140 // }
161141
162- // const { status: currentStatus = status } = item;
163- // const { status: prevStatus = currentStatus } = prevItem || {};
164-
165- // if (!data.status) {
166- // if (stepNumber === current) {
167- // data.status = status;
168- // } else if (stepNumber < current) {
169- // data.status = 'finish';
170- // } else {
171- // data.status = 'wait';
172- // }
173- // }
174-
175142 const itemStatus = statuses [ index ] ;
176- const nextStatus = statuses [ index + 1 ] ;
177143
178144 const data = {
179145 ...item ,
180146 status : itemStatus ,
181147 } ;
182148
183- // if (!data.render && itemRender) {
184- // data.render = (stepItem) => itemRender(data, stepItem);
185- // }
186-
187149 return (
188- < Step
189- // Style
190- prefixCls = { prefixCls }
191- classNames = { classNames }
192- styles = { styles }
193- // Data
194- data = { data }
195- nextStatus = { nextStatus }
196- active = { stepIndex === current }
197- index = { stepIndex }
198- // Render
199- key = { stepIndex }
200- progressDot = { progressDot }
201- iconRender = { iconRender }
202- itemRender = { itemRender }
203- onClick = { onChange && onStepClick }
204- />
150+ < React . Fragment key = { stepIndex } >
151+ { index !== 0 && (
152+ < Rail prefixCls = { prefixCls } classNames = { classNames } styles = { styles } status = { itemStatus } />
153+ ) }
154+ < Step
155+ // Style
156+ prefixCls = { prefixCls }
157+ classNames = { classNames }
158+ styles = { styles }
159+ // Data
160+ data = { data }
161+ active = { stepIndex === current }
162+ index = { stepIndex }
163+ // Render
164+ iconRender = { iconRender }
165+ itemRender = { itemRender }
166+ onClick = { onChange && onStepClick }
167+ />
168+ </ React . Fragment >
205169 ) ;
206170 } ;
207171
0 commit comments