import { type SyntheticEvent } from 'react'; import { Snackbar as MuiSnackbar, Alert, type SnackbarProps } from '@mui/material'; export interface RdsSnackbarProps extends Omit { message?: string; type?: 'success' | 'error' | 'warning' | 'info'; showCloseButton?: boolean; onClose?: () => void; duration?: number; } const RdsSnackbar = ({ message, type = 'info', showCloseButton = true, onClose, duration = 6000, autoHideDuration, children, ...props }: RdsSnackbarProps) => { const handleClose = (event?: SyntheticEvent | Event, reason?: string) => { if (reason === 'clickaway') { return; } if (onClose) { onClose(); } }; const content = message || children; const alertTextColor = type ? `var(--rds-alert-${type}-text, var(--rds-text-primary))` : 'var(--rds-text-primary)'; return ( {type && message ? ( {content} ) : (
{content}
)}
); }; RdsSnackbar.displayName = 'RdsSnackbar'; export default RdsSnackbar;