@@ -12,18 +12,14 @@ function isString(str: any): str is string {
1212export interface StepProps {
1313 // style
1414 prefixCls ?: string ;
15- className ?: string ;
16- style ?: React . CSSProperties ;
1715 classNames : StepsProps [ 'classNames' ] ;
1816 styles : StepsProps [ 'styles' ] ;
1917
2018 // data
2119 data : StepItem ;
22- status : Status ;
2320 prevStatus ?: Status ;
2421
2522 active ?: boolean ;
26- disabled ?: boolean ;
2723 index : number ;
2824
2925 // stepIndex?: number;
@@ -36,7 +32,7 @@ export interface StepProps {
3632 iconRender ?: StepsProps [ 'iconRender' ] ;
3733 icon ?: React . ReactNode ;
3834 progressDot ?: ProgressDotRender | boolean ;
39- render ?: ( stepItem : React . ReactElement ) => React . ReactNode ;
35+ itemRender ?: ( stepItem : React . ReactElement ) => React . ReactNode ;
4036
4137 // Event
4238 onClick ?: ( index : number ) => void ;
@@ -46,33 +42,40 @@ export default function Step(props: StepProps) {
4642 const {
4743 // style
4844 prefixCls,
49- className,
50- style,
5145 classNames,
5246 styles,
5347
5448 // data
5549 data,
56- status,
5750 prevStatus,
5851
5952 active,
60- disabled,
6153 index,
6254
6355 // render
64- icon,
6556 progressDot,
66- render,
57+ itemRender,
58+ iconRender,
6759
6860 // events
6961 onClick,
70-
71- ...restProps
7262 } = props ;
7363
7464 // ========================== Data ==========================
75- const { onClick : onItemClick , title, subTitle, content, description } = data ;
65+ const {
66+ onClick : onItemClick ,
67+ title,
68+ subTitle,
69+ content,
70+ description,
71+ disabled,
72+ icon,
73+ status,
74+
75+ className,
76+ style,
77+ ...restItemProps
78+ } = data ;
7679 const mergedContent = content ?? description ;
7780
7881 // ========================= Click ==========================
@@ -102,74 +105,37 @@ export default function Step(props: StepProps) {
102105 }
103106
104107 // ========================= Render =========================
105- const renderIconNode = ( ) => {
106- let iconNode : React . ReactNode ;
107- const iconClassName = cls ( `${ prefixCls } -icon` , `${ iconPrefix } icon` , {
108- [ `${ iconPrefix } icon-${ icon } ` ] : icon && isString ( icon ) ,
109- [ `${ iconPrefix } icon-check` ] :
110- ! icon && status === 'finish' && ( ( icons && ! icons . finish ) || ! icons ) ,
111- [ `${ iconPrefix } icon-cross` ] :
112- ! icon && status === 'error' && ( ( icons && ! icons . error ) || ! icons ) ,
113- } ) ;
114- const iconDot = < span className = { `${ prefixCls } -icon-dot` } /> ;
115- // `progressDot` enjoy the highest priority
116- if ( progressDot ) {
117- if ( typeof progressDot === 'function' ) {
118- iconNode = (
119- < span className = { `${ prefixCls } -icon` } >
120- { progressDot ( iconDot , {
121- index : stepNumber - 1 ,
122- status,
123- title,
124- description,
125- content : mergedContent ,
126- } ) }
127- </ span >
128- ) ;
129- } else {
130- iconNode = < span className = { `${ prefixCls } -icon` } > { iconDot } </ span > ;
131- }
132- } else if ( icon && ! isString ( icon ) ) {
133- iconNode = < span className = { `${ prefixCls } -icon` } > { icon } </ span > ;
134- } else if ( icons && icons . finish && status === 'finish' ) {
135- iconNode = < span className = { `${ prefixCls } -icon` } > { icons . finish } </ span > ;
136- } else if ( icons && icons . error && status === 'error' ) {
137- iconNode = < span className = { `${ prefixCls } -icon` } > { icons . error } </ span > ;
138- } else if ( icon || status === 'finish' || status === 'error' ) {
139- iconNode = < span className = { iconClassName } /> ;
140- } else {
141- iconNode = < span className = { `${ prefixCls } -icon` } > { stepNumber } </ span > ;
142- }
143-
144- if ( stepIcon ) {
145- iconNode = stepIcon ( {
146- index,
147- status,
148- title,
149- description,
150- content : mergedContent ,
151- node : iconNode ,
152- } ) ;
153- }
154-
155- return iconNode ;
156- } ;
157-
158108 const mergedStatus = status || 'wait' ;
159109
160- const classString = cls ( `${ prefixCls } -item` , `${ prefixCls } -item-${ mergedStatus } ` , className , {
161- [ `${ prefixCls } -item-custom` ] : icon ,
162- [ `${ prefixCls } -item-active` ] : active ,
163- [ `${ prefixCls } -item-disabled` ] : disabled === true ,
164- } ) ;
165-
166- const stepItemStyle : React . CSSProperties = { ...style } ;
110+ const classString = cls (
111+ `${ prefixCls } -item` ,
112+ `${ prefixCls } -item-${ mergedStatus } ` ,
113+ {
114+ [ `${ prefixCls } -item-custom` ] : icon ,
115+ [ `${ prefixCls } -item-active` ] : active ,
116+ [ `${ prefixCls } -item-disabled` ] : disabled === true ,
117+ } ,
118+ className ,
119+ classNames . item ,
120+ ) ;
167121
168122 let stepNode : React . ReactNode = (
169- < div { ...restProps } className = { classString } style = { stepItemStyle } >
170- < div onClick = { onClick } { ...accessibilityProps } className = { `${ prefixCls } -item-container` } >
123+ < div
124+ { ...restItemProps }
125+ className = { classString }
126+ style = { {
127+ ...styles . item ,
128+ ...style ,
129+ } }
130+ >
131+ < div { ...accessibilityProps } className = { `${ prefixCls } -item-container` } >
171132 < div className = { `${ prefixCls } -item-tail` } />
172- < div className = { `${ prefixCls } -item-icon` } > { renderIconNode ( ) } </ div >
133+ < div className = { `${ prefixCls } -item-icon` } >
134+ { iconRender ( data , {
135+ index,
136+ active,
137+ } ) }
138+ </ div >
173139 < div className = { `${ prefixCls } -item-content` } >
174140 < div className = { `${ prefixCls } -item-title` } >
175141 { title }
@@ -188,8 +154,8 @@ export default function Step(props: StepProps) {
188154 </ div >
189155 ) ;
190156
191- if ( render ) {
192- stepNode = ( render ( stepNode ) || null ) as React . ReactElement ;
157+ if ( itemRender ) {
158+ stepNode = ( itemRender ( stepNode ) || null ) as React . ReactElement ;
193159 }
194160
195161 return stepNode ;
0 commit comments