UNPKG

vue-toastify

Version:

<p align="center">Simple and dependency-free notification plugin.</p>

78 lines (77 loc) 1.97 kB
import d from "./useVtSettings.mjs"; import f from "./useVtEvents.mjs"; import { isVNode as y } from "vue"; /*! ================================ vue-toastify v2.1.0 (c) 2019-present Nandor Kraszlan Released under MIT License ================================== */ const b = (e) => typeof e == "boolean"; function l(e) { return e !== null && typeof e == "object" && !Array.isArray(e); } const w = (e, r, o) => e > r && e <= o, u = () => { const e = /[018]/g, r = (o) => (o ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> o / 4).toString(16); return "10000000-1000-4000-8000-100000000000".replace(e, r); }, t = (e) => typeof e == "string" || y(e); let n = {}; const i = (e, r) => (t(e) && (e = { body: e }), r && (e.title = r), e.type || (e.type = "success"), n.container.add(e)), s = { notify: i, success: (e, r) => i(e, r), info: (e, r) => (t(e) && (e = { body: e }), r && (e.title = r), e.type = "info", i(e)), warning: (e, r) => (t(e) && (e = { body: e }), r && (e.title = r), e.type = "warning", i(e)), error: (e, r) => { const o = {}; return t(e) && (o.body = e), r && (o.title = r), o.type = "error", i(o); }, loader: (e, r) => (t(e) && (e = { body: e }), r && (e.title = r), e.mode = "loader", i(e)), prompt: async (e) => { e.mode = "prompt"; const r = f(), o = n.container.add(e); return new Promise((p) => { r.once("vtPromptResponse", (c) => { c.id === o && p(c.response); }); }); }, stopLoader(e) { return n.container.stopLoader(e); }, findToast(e) { return n.container.get(e); }, getToasts() { return n.container.get(); }, updateToast(e, r) { return n.container.set(e, r); }, remove(e) { return n.container.remove(e); }, settings(e) { const r = d(); return e ? r.updateSettings(e) : r.settings; } }; function T() { return s; } export { b as a, w as b, n as c, t as d, T as e, l as i, s as t, u };