'use client'; import { UNSTABLE_ToastRegion as ToastRegion, UNSTABLE_Toast as Toast, UNSTABLE_ToastQueue as ToastQueue, UNSTABLE_ToastContent as ToastContent, type ToastProps, Text } from 'react-aria-components/Toast'; import {Button} from './Button'; import {X} from 'lucide-react'; import './Toast.css'; import {flushSync} from 'react-dom'; import {type CSSProperties} from 'react'; // Define the type for your toast content. This interface defines the properties of your toast content, affecting what you // pass to the queue calls as arguments. interface MyToastContent { title: string; description?: string; } // This is a global toast queue, to be imported and called where ever you want to queue a toast via queue.add(). export const queue = new ToastQueue({ // Wrap state updates in a CSS view transition. wrapUpdate(fn) { if ('startViewTransition' in document) { document.startViewTransition(() => { flushSync(fn); }); } else { fn(); } } }); export function MyToastRegion() { return ( // The ToastRegion should be rendered at the root of your app. {({toast}) => ( {toast.content.title} {toast.content.description && ( {toast.content.description} )} )} ); } export function MyToast(props: ToastProps) { return ; }