/** * Global toast store - allows direct toast access without hooks * Similar to Sonner's approach */ import { ToastProps } from '../types'; type ToastStore = { addToast: (toast: Omit) => string; removeToast: (id: string) => void; updateToast: (id: string, updates: Partial>) => void; clearAllToasts: () => void; }; let toastStore: ToastStore | null = null; /** * Register the toast store (called by ToastProvider) */ export const registerToastStore = (store: ToastStore) => { toastStore = store; }; /** * Unregister the toast store (called when ToastProvider unmounts) */ export const unregisterToastStore = () => { toastStore = null; }; /** * Get the current toast store */ export const getToastStore = (): ToastStore => { if (!toastStore) { throw new Error( 'Toast store not initialized. Make sure you have or in your app.' ); } return toastStore; }; /** * Check if toast store is available */ export const isToastStoreAvailable = (): boolean => { return toastStore !== null; };