@@ -122,43 +122,68 @@ export const BaseDialog: FunctionComponent<Partial<DialogBasicProps>> & {
122
122
const btnClass =
123
123
hideCancelButton || hideConfirmButton ? `${ classPrefix } -footer-block` : ''
124
124
125
+ const renderCancelOfVertical = ( ) => {
126
+ return (
127
+ ! hideCancelButton && (
128
+ < View
129
+ className = { `${ classPrefix } -footer-cancel ${ btnClass } ` }
130
+ onClick = { ( e : ITouchEvent ) => handleCancel ( e ) }
131
+ >
132
+ { cancelText || locale . cancel }
133
+ </ View >
134
+ )
135
+ )
136
+ }
137
+
138
+ const renderCancel = ( ) => {
139
+ return (
140
+ ! hideCancelButton && (
141
+ < Button
142
+ type = "default"
143
+ size = "large"
144
+ className = { `${ classPrefix } -footer-cancel ${ btnClass } ` }
145
+ onClick = { ( e : React . MouseEvent < HTMLButtonElement > ) =>
146
+ handleCancel ( e )
147
+ }
148
+ >
149
+ { cancelText || locale . cancel }
150
+ </ Button >
151
+ )
152
+ )
153
+ }
154
+
155
+ const renderConfirm = ( ) => {
156
+ return (
157
+ ! hideConfirmButton && (
158
+ < Button
159
+ size = "large"
160
+ type = "primary"
161
+ className = { classNames ( `${ classPrefix } -footer-ok ${ btnClass } ` , {
162
+ disabled : disableConfirmButton ,
163
+ } ) }
164
+ disabled = { disableConfirmButton }
165
+ onClick = { ( e : React . MouseEvent < HTMLButtonElement > ) => handleOk ( e ) }
166
+ loading = { loading }
167
+ >
168
+ { confirmText || locale . confirm }
169
+ </ Button >
170
+ )
171
+ )
172
+ }
173
+
125
174
return (
126
175
footer || (
127
176
< >
128
- { ! hideCancelButton &&
129
- ( footerDirection === 'vertical' ? (
130
- < View
131
- className = { `${ classPrefix } -footer-cancel ${ btnClass } ` }
132
- onClick = { ( e : ITouchEvent ) => handleCancel ( e ) }
133
- >
134
- { cancelText || locale . cancel }
135
- </ View >
136
- ) : (
137
- < Button
138
- type = "default"
139
- size = "large"
140
- className = { `${ classPrefix } -footer-cancel ${ btnClass } ` }
141
- onClick = { ( e : React . MouseEvent < HTMLButtonElement > ) =>
142
- handleCancel ( e )
143
- }
144
- >
145
- { cancelText || locale . cancel }
146
- </ Button >
147
- ) ) }
148
-
149
- { ! hideConfirmButton && (
150
- < Button
151
- size = "large"
152
- type = "primary"
153
- className = { classNames ( `${ classPrefix } -footer-ok ${ btnClass } ` , {
154
- disabled : disableConfirmButton ,
155
- } ) }
156
- disabled = { disableConfirmButton }
157
- onClick = { ( e : React . MouseEvent < HTMLButtonElement > ) => handleOk ( e ) }
158
- loading = { loading }
159
- >
160
- { confirmText || locale . confirm }
161
- </ Button >
177
+ { footerDirection === 'vertical' ? (
178
+ < >
179
+ { renderConfirm ( ) }
180
+ { renderCancelOfVertical ( ) }
181
+ </ >
182
+ ) : (
183
+ < >
184
+ { renderCancel ( ) }
185
+ { renderConfirm ( ) }
186
+ </ >
162
187
) }
163
188
</ >
164
189
)
@@ -193,46 +218,52 @@ export const BaseDialog: FunctionComponent<Partial<DialogBasicProps>> & {
193
218
}
194
219
}
195
220
221
+ const renderContent = ( ) => {
222
+ return (
223
+ < CSSTransition
224
+ in = { visible }
225
+ timeout = { 300 }
226
+ classNames = "fadeDialog"
227
+ unmountOnExit
228
+ appear
229
+ >
230
+ < Content
231
+ className = { className }
232
+ style = { style }
233
+ title = { title }
234
+ header = { header }
235
+ close = { renderCloseIcon ( ) }
236
+ footer = { renderFooter ( ) }
237
+ footerDirection = { footerDirection }
238
+ visible = { visible }
239
+ >
240
+ { content || children }
241
+ </ Content >
242
+ </ CSSTransition >
243
+ )
244
+ }
245
+
196
246
return (
197
247
< View
198
248
style = { { display : visible ? 'block' : 'none' } }
199
249
ref = { refObject }
200
250
catchMove = { lockScroll }
201
251
>
202
- < >
203
- { overlay && (
204
- < Overlay
205
- zIndex = { zIndex }
206
- visible = { visible }
207
- style = { overlayStyle }
208
- className = { overlayClassName }
209
- closeOnOverlayClick = { closeOnOverlayClick }
210
- lockScroll = { lockScroll }
211
- onClick = { onHandleClickOverlay }
212
- />
213
- ) }
214
-
215
- < CSSTransition
216
- in = { visible }
217
- timeout = { 300 }
218
- classNames = "fadeDialog"
219
- unmountOnExit
220
- appear
252
+ { overlay ? (
253
+ < Overlay
254
+ zIndex = { zIndex }
255
+ visible = { visible }
256
+ style = { overlayStyle }
257
+ className = { overlayClassName }
258
+ closeOnOverlayClick = { closeOnOverlayClick }
259
+ lockScroll = { lockScroll }
260
+ onClick = { onHandleClickOverlay }
221
261
>
222
- < Content
223
- className = { className }
224
- style = { style }
225
- title = { title }
226
- header = { header }
227
- close = { renderCloseIcon ( ) }
228
- footer = { renderFooter ( ) }
229
- footerDirection = { footerDirection }
230
- visible = { visible }
231
- >
232
- { content || children }
233
- </ Content >
234
- </ CSSTransition >
235
- </ >
262
+ { renderContent ( ) }
263
+ </ Overlay >
264
+ ) : (
265
+ renderContent ( )
266
+ ) }
236
267
</ View >
237
268
)
238
269
}
0 commit comments