yanzhen-design-vue
Version:
40 lines (39 loc) • 1.16 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const vue = require("vue");
const utils = require("@yanzhen-libs/utils");
const lodashEs = require("lodash-es");
function useContactsItem(props, emit) {
const { isSelf, errorImg } = vue.toRefs(props);
const _ref = vue.ref();
const _avatar = vue.computed(() => {
if (utils.isEmptyValue(props.avatar) || !lodashEs.isString(props.avatar)) {
return vue.unref(errorImg);
}
return props.avatar;
});
const _label = vue.computed(() => props.label);
const _tags = vue.computed(() => {
var _a;
const tags = (_a = props.tags) == null ? void 0 : _a.map(({ label }) => label).filter((v) => !utils.isEmptyValue(v));
if (!utils.isEmptyArray(tags)) return tags.join(";");
return false;
});
function handleClick() {
emit("item-click", props);
}
function handleSuffixClick() {
emit("suffix-click", props);
}
const ctx = {
_ref,
_tags,
_avatar,
_label,
isSelf,
errorImg
};
const methods = { handleClick, handleSuffixClick };
return { ctx, methods };
}
exports.useContactsItem = useContactsItem;