@ccos/webos-vue
Version:
A Web-Ui Framework for Skyworth/Coocaa TV
33 lines (32 loc) • 811 B
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const vue = require("vue");
const toast = require("./index32.js");
let toastDom = null;
let app = null;
const TvToast = (options) => {
const dom = document.body.querySelector(".my-toast");
if (!dom) {
toastDom = document.createElement("div");
toastDom.className = `my-toast`;
document.body.appendChild(toastDom);
} else {
app.unmount();
}
app = vue.createApp(toast.default, {
...options,
hide() {
if (app) {
app.unmount();
app = null;
}
if (toastDom) {
document.body.removeChild(toastDom);
toastDom = null;
}
}
});
return app.mount(toastDom);
};
TvToast.show = (options) => TvToast(options).show();
exports.TvToast = TvToast;