1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| (function () { "use strict";
const CONFIG = { duration: 5000, maxCount: 5, };
const ICONS = { success: '<svg viewBox="0 0 24 24"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>', error: '<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>', warning: '<svg viewBox="0 0 24 24"><path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"/></svg>', info: '<svg viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>', close: '<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>', };
let toastContainer = null; const activeToasts = new Map();
function getContainer() { if (!toastContainer) { toastContainer = document.createElement("div"); toastContainer.id = "toast-container"; document.body.appendChild(toastContainer); } return toastContainer; }
function show(options) { const config = { type: "info", title: "", message: "", duration: CONFIG.duration, ...options, };
}
function success(message, title, options = {}) { return show({ type: "success", message, title, ...options }); }
function error(message, title, options = {}) { return show({ type: "error", message, title, ...options }); }
function warning(message, title, options = {}) { return show({ type: "warning", message, title, ...options }); }
function info(message, title, options = {}) { return show({ type: "info", message, title, ...options }); }
window.Toast = { show, success, error, warning, info, }; })();
|