vuux
Version:
Vue3 Nuxt3 Nuxt4 组件库
39 lines (38 loc) • 1.06 kB
JavaScript
import { computed as a, ref as v, onMounted as p, getCurrentInstance as x } from "vue";
const m = (n, s) => {
const o = a(() => n.max == 0 ? n.data : n.data.slice(0, n.max)), e = a(() => {
const { src: t, size: r, shape: d } = n.options || {};
return {
src: t || "src",
size: r || "42",
shape: d || "circle"
};
}), c = a(() => `width: ${e.value.size}px; height: ${e.value.size}px`), l = a(() => ({
display: "inline-flex",
objectFit: "cover",
width: e.value.size + "px",
height: e.value.size + "px",
minWidth: e.value.size + "px",
minHeight: e.value.size + "px",
borderRadius: e.value.shape == "circle" ? "50%" : "4px"
})), i = v(!1), h = (t) => {
s("change", t);
}, u = () => {
s("more");
};
return p(() => {
const t = x();
t && t.vnode.props && "onChange" in t.vnode.props && (i.value = !0);
}), {
list: o,
mergedFields: e,
styles: c,
avatarStyles: l,
isChange: i,
handleGetData: h,
handleMore: u
};
};
export {
m as useAvatarGroup
};