import type { Ref } from 'vue' import type { ToastManager, ToastObject } from './createToastManager' import { injectToastProviderContext } from './ToastProvider.vue' export interface UseToastManagerReturn extends ToastManager { /** The toasts of the nearest `ToastProvider`, newest first. */ toasts: Readonly[]>> } /** * Returns the toasts of the nearest `ToastProvider` and methods to manage them. */ export function useToastManager(): UseToastManagerReturn { const { toastStore } = injectToastProviderContext() return { toasts: toastStore.toasts as Readonly[]>>, add: toastStore.add, close: toastStore.close, update: toastStore.update, promise: toastStore.promise, } }