({
fullWidth = true,
title,
description,
children,
startAdornment,
avatar,
className,
onClose,
...rest
}: AlertProps)
| 38 | } |
| 39 | |
| 40 | export function Alert({ |
| 41 | fullWidth = true, |
| 42 | title, |
| 43 | description, |
| 44 | children, |
| 45 | startAdornment, |
| 46 | avatar, |
| 47 | className, |
| 48 | onClose, |
| 49 | ...rest |
| 50 | }: AlertProps) { |
| 51 | const labelId = useId(); |
| 52 | const contentId = useId(); |
| 53 | |
| 54 | return ( |
| 55 | <div |
| 56 | role='alert' |
| 57 | aria-describedby={description ? contentId : undefined} |
| 58 | aria-labelledby={title ? labelId : undefined} |
| 59 | className={clsxMerge(alertVariants({ fullWidth }), className)} |
| 60 | {...rest} |
| 61 | > |
| 62 | {(startAdornment ?? avatar) && ( |
| 63 | <div className='inline-flex items-start justify-start'> |
| 64 | {!avatar && startAdornment} |
| 65 | {!startAdornment && avatar && <Avatar {...avatar} />} |
| 66 | </div> |
| 67 | )} |
| 68 | <div className='flex flex-1 flex-col items-start justify-center gap-3 overflow-hidden'> |
| 69 | {title && ( |
| 70 | <p id={labelId} className='text-sm font-medium text-black'> |
| 71 | {title} |
| 72 | </p> |
| 73 | )} |
| 74 | {description && ( |
| 75 | <p id={contentId} className='text-xs font-normal leading-none text-slate-600'> |
| 76 | {description} |
| 77 | </p> |
| 78 | )} |
| 79 | <div>{children}</div> |
| 80 | </div> |
| 81 | {onClose && ( |
| 82 | <Button |
| 83 | variant='text' |
| 84 | size='small' |
| 85 | className='h-auto min-w-0 text-slate-600' |
| 86 | aria-label='Close' |
| 87 | title='Close' |
| 88 | iconOnly |
| 89 | > |
| 90 | <CloseIcon className='size-4' onClick={onClose} /> |
| 91 | </Button> |
| 92 | )} |
| 93 | </div> |
| 94 | ); |
| 95 | } |
| 96 | |
| 97 | Alert.displayName = 'Alert'; |
nothing calls this directly
no test coverage detected