import { ref } from 'vue' interface Toast { id: number message: string type: 'success' | 'error' | 'info' | 'warning' duration: number } /** * Toast Notification Composable * Displays glassmorphic toast notifications */ export function useToast() { const toasts = ref([]) let nextId = 0 function showToast( message: string, type: Toast['type'] = 'info', duration: number = 3000 ) { const toast: Toast = { id: nextId++, message, type, duration, } toasts.value.push(toast) if (duration > 0) { setTimeout(() => { removeToast(toast.id) }, duration) } return toast.id } function removeToast(id: number) { const index = toasts.value.findIndex((t) => t.id === id) if (index > -1) { toasts.value.splice(index, 1) } } function success(message: string, duration?: number) { return showToast(message, 'success', duration) } function error(message: string, duration?: number) { return showToast(message, 'error', duration) } function info(message: string, duration?: number) { return showToast(message, 'info', duration) } function warning(message: string, duration?: number) { return showToast(message, 'warning', duration) } return { toasts, showToast, removeToast, success, error, info, warning, } }