/** * Toast notification types * @enum {string} */ export const ToastType = { error: "error", success: "success", warning: "warning", }; export class Dom { /** * Create a `
` * @param {Object} [o] * @param {Partial} [o.styles] * @param {string} [o.id] * @param {string[]} [o.classes] * @param {HTMLElement[]} [o.children] * @param {Record} [o.attributes] * @returns {HTMLDivElement} */ static div(o = {}) { const div = document.createElement("div"); if (o.styles) Object.assign(div.style, o.styles); if (o.id) div.id = o.id; if (o.classes) for (const cls of o.classes) div.classList.add(cls); if (o.attributes) for (const [k, v] of Object.entries(o.attributes)) div.setAttribute(k, v); if (o.children) div.append(...o.children); return div; } /** * Create a `` * @param {Object} o * @param {string} o.text * @param {Partial} [o.styles] * @param {string} [o.id] * @param {string[]} [o.classes] * @param {HTMLElement[]} [o.children] * @param {Record} [o.attributes] * @returns {HTMLSpanElement} */ static span(o) { const span = document.createElement("span"); if (o.styles) Object.assign(span.style, o.styles); if (o.id) span.id = o.id; if (o.classes) for (const cls of o.classes) span.classList.add(cls); span.textContent = o.text; if (o.attributes) for (const [k, v] of Object.entries(o.attributes)) span.setAttribute(k, v); if (o.children) span.append(...o.children); return span; } /** * Create a `