y-design-ssr
Version:
SSR component library of YUI with Vue3
136 lines (135 loc) • 3.03 kB
JavaScript
import { ref as b, reactive as $, defineComponent as N, createVNode as o } from "vue";
const s = (e, t) => t ? typeof t == "string" ? ` ${e}--${t}` : Array.isArray(t) ? t.reduce((r, n) => r + s(e, n), "") : Object.keys(t).reduce(
(r, n) => r + (t[n] ? s(e, n) : ""),
""
) : "", S = (e) => (t, r) => {
let n = t, a = r;
return n && typeof n != "string" && (a = n, n = ""), n = n ? `${e}__${n}` : e, `${n}${s(n, a)}`;
}, C = () => (e, t) => t ? `${s(`y-${e}`, t)}` : `y-${e}`, h = {
"pull-refresh": {
pulling: "下拉刷新...",
loosing: "释放刷新...",
loading: "数据加载中...",
success: "数据已更新",
failed: "数据跟新失败,请稍后再试"
},
"form-item": {
validateMessage: "请输入正确内容"
}
};
b("zh-CN");
$({
"zh-CN": h
});
const k = (e) => {
const t = `y-${e}`;
return [t, S(t), C()];
}, x = (e) => isNaN(Number(e)) && typeof e == "string" ? e : `${e}px`, [z, l] = k("icon"), B = (e) => new RegExp(/\.(https|png|jpg|gif|jpeg|webp|apng)$/).test(e.toLowerCase()), I = /* @__PURE__ */ N({
name: z,
props: {
dot: {
type: Boolean,
default: !1
},
name: {
type: String,
default: ""
},
size: {
type: [Number, String],
default: ""
},
info: {
type: [Number, String],
default: ""
},
badge: {
type: [Number, String],
default: ""
},
color: {
type: String,
default: ""
},
subColor: {
type: String,
default: ""
},
subBg: {
type: String,
default: ""
},
classPrefix: {
type: String,
default: "y-icon"
},
/**
* @ignore
*/
tag: {
type: String,
default: "i"
}
},
emits: ["click"],
setup(e, {
slots: t,
emit: r
}) {
const n = B(e.name), a = () => ({
fontSize: x(e.size),
color: e.color
}), g = (c) => {
r("click", c);
};
return () => {
const {
name: c,
classPrefix: d,
badge: i,
dot: p,
subColor: y,
subBg: u,
tag: m
} = e;
return o(m, {
class: `${d}${n ? "" : ` y-icon--${c}`}`,
style: a(),
onClick: g
}, {
default: () => {
var f;
return [n ? o("em", {
class: l("node")
}, [o("img", {
class: l("image"),
src: c,
alt: "icon"
}, null)]) : null, p ? o("em", {
class: l("dot"),
style: {
backgroundColor: u
}
}, null) : null, i ? o("em", {
class: l("badge"),
style: {
color: y,
backgroundColor: u
}
}, [i]) : null, ((f = t.default) == null ? void 0 : f.call(t)) || null];
}
});
};
}
});
function _(e) {
const t = e;
return t.install = (r) => {
const { name: n } = e;
n && r.component(n, e);
}, t;
}
const j = _(I);
export {
j as default
};