@extclp/vexip-ui
Version:
A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good
125 lines (124 loc) • 4.53 kB
JavaScript
import { defineComponent as $, computed as b, ref as p, reactive as B, createBlock as i, openBlock as r, unref as o, normalizeClass as t, withCtx as I, createElementVNode as k, normalizeStyle as y, createElementBlock as s, createCommentVNode as g, mergeProps as _, Fragment as M, toDisplayString as V, createVNode as z } from "vue";
import "../icon/index.mjs";
import "../renderer/index.mjs";
import "../popup/index.mjs";
import { useNameHelper as E, useIcons as G } from "@vexip-ui/config";
import { assertiveTypes as L, effectiveTypes as C } from "./symbol.mjs";
import O from "../popup/popup.vue2.mjs";
import f from "../icon/icon.mjs";
import S from "../renderer/renderer.mjs";
const D = ["aria-live"], F = ["innerHTML"], P = ["onClick"], ee = /* @__PURE__ */ $({
name: "Message",
__name: "message",
setup(R, { expose: h }) {
const n = E("message"), c = G(), w = b(() => ({
primary: c.value.info,
info: c.value.info,
success: c.value.success,
warning: c.value.warning,
error: c.value.error
})), u = p("top"), v = p(30), d = p(16), a = p(), N = b(() => `${u.value}-center`);
async function x(l) {
a.value && await a.value.add(l);
}
async function m(l) {
return !!a.value && await a.value.remove(l);
}
function H(l) {
u.value = l.placement || u.value, v.value = l.startOffset || v.value, d.value = l.itemGap || d.value;
}
function T() {
a.value && a.value.clear();
}
return h(
B({
popup: a,
add: x,
remove: m,
clear: T,
config: H
})
), (l, j) => (r(), i(o(O), {
ref_key: "popup",
ref: a,
class: t(o(n).b()),
"transition-name": o(n).ns(`popup-${u.value}`),
placement: N.value,
"start-offset": v.value,
"item-gap": d.value
}, {
item: I(({ item: e }) => [
k("div", {
class: t([
{
[o(n).be("item")]: !0,
[o(n).bs("vars")]: !0,
[o(n).bem("item", e.type)]: e.type && o(C).includes(e.type),
[o(n).bem("item", "background")]: e.background,
[o(n).bem("item", "color")]: e.background && e.color,
[o(n).bem("item", "color-only")]: !e.background && e.color,
[o(n).bem("item", "has-icon")]: e.icon,
[o(n).bem("item", "closable")]: e.closable
},
e.className
]),
role: "alert",
style: y([
{
color: typeof e.color == "string" ? e.color : void 0,
backgroundColor: typeof e.background == "string" ? e.background : void 0
},
e.style || {}
]),
"aria-atomic": "true",
"aria-live": e.type && o(L).includes(e.type) ? "assertive" : "polite"
}, [
k("div", {
class: t(o(n).be("wrapper"))
}, [
e.icon || e.type && o(C).includes(e.type) ? (r(), s("div", {
key: 0,
class: t(o(n).be("icon")),
style: y({ color: e.iconColor })
}, [
e.icon ? (r(), i(o(f), {
key: 0,
icon: e.icon,
style: y([{ color: e.iconColor }, e.icon.style])
}, null, 8, ["icon", "style"])) : (r(), i(o(f), _({ key: 1 }, w.value[e.type], {
style: { color: e.iconColor }
}), null, 16, ["style"]))
], 6)) : g("", !0),
typeof e.renderer == "function" ? (r(), i(o(S), {
key: 1,
renderer: e.renderer,
data: e
}, null, 8, ["renderer", "data"])) : (r(), s(M, { key: 2 }, [
e.parseHtml ? (r(), s("div", {
key: 0,
class: t(o(n).be("content")),
innerHTML: e.content
}, null, 10, F)) : (r(), s("div", {
key: 1,
class: t(o(n).be("content"))
}, V(e.content || ""), 3))
], 64))
], 2),
e.closable ? (r(), s("button", {
key: 0,
type: "button",
class: t(o(n).be("close")),
onClick: (q) => m(e.key)
}, [
z(o(f), _(o(c).close, { label: "close" }), null, 16)
], 10, P)) : g("", !0)
], 14, D)
]),
_: 1
}, 8, ["class", "transition-name", "placement", "start-offset", "item-gap"]));
}
});
export {
ee as default
};
//# sourceMappingURL=message.vue2.mjs.map