@@ -5,6 +5,10 @@ import KeyCode from '@rc-component/util/lib/KeyCode';
5
5
import type { Status , StepItem , StepsProps } from './Steps' ;
6
6
import Rail from './Rail' ;
7
7
8
+ function hasContent < T > ( value : T ) {
9
+ return value !== undefined && value !== null ;
10
+ }
11
+
8
12
export interface StepProps {
9
13
// style
10
14
prefixCls ?: string ;
@@ -18,12 +22,6 @@ export interface StepProps {
18
22
index : number ;
19
23
last : boolean ;
20
24
21
- // stepIndex?: number;
22
- // stepNumber?: number;
23
- // title?: React.ReactNode;
24
- // subTitle?: React.ReactNode;
25
- // description?: React.ReactNode;
26
-
27
25
// render
28
26
iconRender ?: StepsProps [ 'iconRender' ] ;
29
27
icon ?: React . ReactNode ;
@@ -115,29 +113,37 @@ export default function Step(props: StepProps) {
115
113
// ========================= Render =========================
116
114
const mergedStatus = status || 'wait' ;
117
115
116
+ const hasTitle = hasContent ( title ) ;
117
+ const hasSubTitle = hasContent ( subTitle ) ;
118
+
118
119
const classString = cls (
119
120
itemCls ,
120
121
`${ itemCls } -${ mergedStatus } ` ,
121
122
{
122
123
[ `${ itemCls } -custom` ] : icon ,
123
124
[ `${ itemCls } -active` ] : active ,
124
125
[ `${ itemCls } -disabled` ] : disabled === true ,
126
+ [ `${ itemCls } -empty-header` ] : ! hasTitle && ! hasSubTitle ,
125
127
} ,
126
128
className ,
127
129
classNames . item ,
128
130
) ;
129
131
132
+ // !hasContent(title) && !hasContent(subTitle) && `${itemCls}-header-empty`
133
+
130
134
const wrapperNode = (
131
135
< div className = { cls ( `${ itemCls } -wrapper` , classNames . itemWrapper ) } style = { styles . itemWrapper } >
132
136
< div className = { cls ( `${ itemCls } -icon` , classNames . itemIcon ) } style = { styles . itemIcon } >
133
137
{ iconRender ?.( renderInfo ) }
134
138
</ div >
135
139
< div className = { cls ( `${ itemCls } -section` , classNames . itemSection ) } style = { styles . itemSection } >
136
140
< div className = { cls ( `${ itemCls } -header` , classNames . itemHeader ) } style = { styles . itemHeader } >
137
- < div className = { cls ( `${ itemCls } -title` , classNames . itemTitle ) } style = { styles . itemTitle } >
138
- { title }
139
- </ div >
140
- { subTitle && (
141
+ { hasTitle && (
142
+ < div className = { cls ( `${ itemCls } -title` , classNames . itemTitle ) } style = { styles . itemTitle } >
143
+ { title }
144
+ </ div >
145
+ ) }
146
+ { hasSubTitle && (
141
147
< div
142
148
title = { typeof subTitle === 'string' ? subTitle : undefined }
143
149
className = { cls ( `${ itemCls } -subtitle` , classNames . itemSubtitle ) }
@@ -151,7 +157,7 @@ export default function Step(props: StepProps) {
151
157
< Rail prefixCls = { itemCls } classNames = { classNames } styles = { styles } status = { nextStatus } />
152
158
) }
153
159
</ div >
154
- { mergedContent && (
160
+ { hasContent ( mergedContent ) && (
155
161
< div
156
162
className = { cls ( `${ itemCls } -content` , classNames . itemContent ) }
157
163
style = { styles . itemContent }
0 commit comments