@@ -425,81 +425,69 @@ const Toast = (props: ToastProps) => {
425
425
</ button >
426
426
) : null }
427
427
{ /* TODO: This can be cleaner */ }
428
- { toast . jsx || isValidElement ( toast . title ) ? (
429
- toast . jsx ? (
430
- toast . jsx
431
- ) : typeof toast . title === 'function' ? (
432
- toast . title ( )
433
- ) : (
434
- toast . title
435
- )
436
- ) : (
437
- < >
438
- { toastType || toast . icon || toast . promise ? (
439
- < div data-icon = "" className = { cn ( classNames ?. icon , toast ?. classNames ?. icon ) } >
440
- { toast . promise || ( toast . type === 'loading' && ! toast . icon ) ? toast . icon || getLoadingIcon ( ) : null }
441
- { toast . type !== 'loading' ? toast . icon || icons ?. [ toastType ] || getAsset ( toastType ) : null }
442
- </ div >
443
- ) : null }
444
-
445
- < div data-content = "" className = { cn ( classNames ?. content , toast ?. classNames ?. content ) } >
446
- < div data-title = "" className = { cn ( classNames ?. title , toast ?. classNames ?. title ) } >
447
- { typeof toast . title === 'function' ? toast . title ( ) : toast . title }
448
- </ div >
449
- { toast . description ? (
450
- < div
451
- data-description = ""
452
- className = { cn (
453
- descriptionClassName ,
454
- toastDescriptionClassname ,
455
- classNames ?. description ,
456
- toast ?. classNames ?. description ,
457
- ) }
458
- >
459
- { typeof toast . description === 'function' ? toast . description ( ) : toast . description }
460
- </ div >
461
- ) : null }
428
+ { toastType || toast . icon || toast . promise ? (
429
+ < div data-icon = "" className = { cn ( classNames ?. icon , toast ?. classNames ?. icon ) } >
430
+ { toast . promise || ( toast . type === 'loading' && ! toast . icon ) ? toast . icon || getLoadingIcon ( ) : null }
431
+ { toast . type !== 'loading' ? toast . icon || icons ?. [ toastType ] || getAsset ( toastType ) : null }
432
+ </ div >
433
+ ) : null }
434
+
435
+ < div data-content = "" className = { cn ( classNames ?. content , toast ?. classNames ?. content ) } >
436
+ < div data-title = "" className = { cn ( classNames ?. title , toast ?. classNames ?. title ) } >
437
+ { toast . jsx ? toast . jsx : typeof toast . title === 'function' ? toast . title ( ) : toast . title }
438
+ </ div >
439
+ { toast . description ? (
440
+ < div
441
+ data-description = ""
442
+ className = { cn (
443
+ descriptionClassName ,
444
+ toastDescriptionClassname ,
445
+ classNames ?. description ,
446
+ toast ?. classNames ?. description ,
447
+ ) }
448
+ >
449
+ { typeof toast . description === 'function' ? toast . description ( ) : toast . description }
462
450
</ div >
463
- { isValidElement ( toast . cancel ) ? (
464
- toast . cancel
465
- ) : toast . cancel && isAction ( toast . cancel ) ? (
466
- < button
467
- data-button
468
- data-cancel
469
- style = { toast . cancelButtonStyle || cancelButtonStyle }
470
- onClick = { ( event ) => {
471
- // We need to check twice because typescript
472
- if ( ! isAction ( toast . cancel ) ) return ;
473
- if ( ! dismissible ) return ;
474
- toast . cancel . onClick ?. ( event ) ;
475
- deleteToast ( ) ;
476
- } }
477
- className = { cn ( classNames ?. cancelButton , toast ?. classNames ?. cancelButton ) }
478
- >
479
- { toast . cancel . label }
480
- </ button >
481
- ) : null }
482
- { isValidElement ( toast . action ) ? (
483
- toast . action
484
- ) : toast . action && isAction ( toast . action ) ? (
485
- < button
486
- data-button
487
- data-action
488
- style = { toast . actionButtonStyle || actionButtonStyle }
489
- onClick = { ( event ) => {
490
- // We need to check twice because typescript
491
- if ( ! isAction ( toast . action ) ) return ;
492
- toast . action . onClick ?. ( event ) ;
493
- if ( event . defaultPrevented ) return ;
494
- deleteToast ( ) ;
495
- } }
496
- className = { cn ( classNames ?. actionButton , toast ?. classNames ?. actionButton ) }
497
- >
498
- { toast . action . label }
499
- </ button >
500
- ) : null }
501
- </ >
502
- ) }
451
+ ) : null }
452
+ </ div >
453
+ { isValidElement ( toast . cancel ) ? (
454
+ toast . cancel
455
+ ) : toast . cancel && isAction ( toast . cancel ) ? (
456
+ < button
457
+ data-button
458
+ data-cancel
459
+ style = { toast . cancelButtonStyle || cancelButtonStyle }
460
+ onClick = { ( event ) => {
461
+ // We need to check twice because typescript
462
+ if ( ! isAction ( toast . cancel ) ) return ;
463
+ if ( ! dismissible ) return ;
464
+ toast . cancel . onClick ?. ( event ) ;
465
+ deleteToast ( ) ;
466
+ } }
467
+ className = { cn ( classNames ?. cancelButton , toast ?. classNames ?. cancelButton ) }
468
+ >
469
+ { toast . cancel . label }
470
+ </ button >
471
+ ) : null }
472
+ { isValidElement ( toast . action ) ? (
473
+ toast . action
474
+ ) : toast . action && isAction ( toast . action ) ? (
475
+ < button
476
+ data-button
477
+ data-action
478
+ style = { toast . actionButtonStyle || actionButtonStyle }
479
+ onClick = { ( event ) => {
480
+ // We need to check twice because typescript
481
+ if ( ! isAction ( toast . action ) ) return ;
482
+ toast . action . onClick ?. ( event ) ;
483
+ if ( event . defaultPrevented ) return ;
484
+ deleteToast ( ) ;
485
+ } }
486
+ className = { cn ( classNames ?. actionButton , toast ?. classNames ?. actionButton ) }
487
+ >
488
+ { toast . action . label }
489
+ </ button >
490
+ ) : null }
503
491
</ li >
504
492
) ;
505
493
} ;
0 commit comments