/** * Simple toast notification component. * * @package GetMD * @since 1.0.2 */ import * as React from 'react'; import { Alert, AlertDescription } from './alert'; export interface ToastProps { message: string; variant?: 'default' | 'destructive'; onClose?: () => void; duration?: number; } /** * Toast notification component that auto-dismisses after a duration. * * @param props Toast properties including message, variant, onClose callback, and duration * @returns Toast notification as JSX element */ export function Toast({ message, variant = 'default', onClose, duration = 3000 }: ToastProps) { // Auto-dismiss timer React.useEffect(() => { if (duration > 0) { const timer = setTimeout(() => { onClose?.(); }, duration); return () => clearTimeout(timer); } }, [duration, onClose]); // Keyboard escape handler React.useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === 'Escape' && onClose) { onClose(); } }; document.addEventListener('keydown', handleEscape); return () => document.removeEventListener('keydown', handleEscape); }, [onClose]); return (