@scalar/use-toasts
Version:
display toasts in Vue
29 lines (28 loc) • 803 B
JavaScript
import { defineComponent as c, ref as i, onMounted as u, createBlock as f, createCommentVNode as m, openBlock as l, unref as p } from "vue";
import { toast as t, Toaster as d } from "vue-sonner";
import { useToasts as _ } from "../hooks/useToasts.js";
const v = /* @__PURE__ */ c({
__name: "ScalarToasts",
setup(T) {
const o = i(!1);
u(() => o.value = !0);
const e = {
success: t.success,
error: t.error,
warn: t.warning,
info: t
}, { initializeToasts: a } = _();
return a((s, r = "info", n = {}) => {
(e[r] || e.info)(s, {
duration: n.timeout || 3e3,
description: n.description
});
}), (s, r) => o.value ? (l(), f(p(d), {
key: 0,
class: "scalar-toaster"
})) : m("", !0);
}
});
export {
v as default
};