tyh-ui2
Version:
The next generation ui component library of tyh-ui is based on vue3 Version, fully embrace vue3.
80 lines (79 loc) • 2.31 kB
JavaScript
import { defineComponent as m, ref as _, computed as r, getCurrentInstance as k, openBlock as n, createBlock as g, Transition as C, withCtx as w, withDirectives as b, createElementVNode as e, normalizeClass as l, createElementBlock as h, unref as T, createCommentVNode as u, toDisplayString as f, vShow as B } from "vue";
import { Props as E } from "./index2.js";
const N = { class: "tyh-notification-body" }, S = { class: "tyh-notification-content" }, D = { class: "tyh-notification-title" }, I = { class: "tyh-notification-message" }, V = m({
name: "TyhNotification"
}), L = /* @__PURE__ */ m({
...V,
props: E,
setup(y) {
const i = y, o = _(!0);
let s;
(function() {
i.time > 0 && (s = setTimeout(() => {
c();
}, i.time));
})();
const c = () => {
clearTimeout(s), o.value = !1;
}, p = r(() => {
let t = "";
switch (i.type) {
case "primary":
t = "tyh-ui-smile";
break;
case "success":
t = "tyh-ui-success-filling";
break;
case "danger":
t = "tyh-ui-error";
break;
case "warning":
t = "tyh-ui-warning-filling";
break;
}
return t;
}), d = r(() => [
"tyh-icon",
"tyh-notification-icon",
p.value,
`tyh-notification-icon-${i.type}`
]), a = k(), v = () => {
a.vnode.el.parentElement.removeChild(a.vnode.el);
};
return (t, $) => (n(), g(C, {
name: "tyh-notification-fade",
appear: "",
onAfterLeave: v
}, {
default: w(() => [
b(e("div", {
class: l(["tyh-notification", `tyh-notification-${t.position}`])
}, [
e("div", N, [
t.type ? (n(), h("i", {
key: 0,
class: l(T(d))
}, null, 2)) : u("", !0),
e("div", S, [
e("h3", D, f(t.title), 1),
e("div", I, [
e("p", null, f(t.message), 1)
])
]),
t.close ? (n(), h("i", {
key: 1,
class: "tyh-icon tyh-ui-close",
onClick: c
})) : u("", !0)
])
], 2), [
[B, o.value]
])
]),
_: 1
}));
}
});
export {
L as default
};