You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
779 B
26 lines
779 B
import { a as useState } from './useLoading-D4zrSa2m.mjs';
|
|
|
|
let _counter = 0;
|
|
function useToast() {
|
|
const toasts = useState("app:toasts", () => []);
|
|
function toast(msg, type = "info", duration = 3e3) {
|
|
const id = ++_counter;
|
|
toasts.value.push({ id, type, msg });
|
|
if (duration > 0) {
|
|
setTimeout(() => {
|
|
toasts.value = toasts.value.filter((t) => t.id !== id);
|
|
}, duration);
|
|
}
|
|
}
|
|
return {
|
|
toasts,
|
|
toast,
|
|
success: (msg, duration) => toast(msg, "success", duration),
|
|
error: (msg, duration) => toast(msg, "error", duration),
|
|
info: (msg, duration) => toast(msg, "info", duration),
|
|
warn: (msg, duration) => toast(msg, "warning", duration)
|
|
};
|
|
}
|
|
|
|
export { useToast as u };
|
|
//# sourceMappingURL=useToast-CS21XT61.mjs.map
|
|
|