UNPKG

vuestic-ui

Version:
33 lines (32 loc) 930 B
import { c as createToastInstance, a as closeById, b as closeAllNotifications } from "../toast.js"; import { u as useAppContext } from "../../../composables/useAppContext.js"; const useToast = () => { const appContext = useAppContext(); const createdInThisSetupContext = []; const notify = (options) => { const id = createToastInstance(options, appContext.value); if (id) { createdInThisSetupContext.push(id); } return id; }; const init = (options) => { return notify(options); }; const close = (id) => closeById(id); const closeAll = (allApps = false) => closeAllNotifications(allApps ? void 0 : appContext.value); const closeAllCreatedInThisHook = () => { createdInThisSetupContext.forEach((id) => closeById(id)); }; return { init, notify, close, closeAll, closeAllCreatedInThisHook }; }; export { useToast as u }; //# sourceMappingURL=useToast.js.map