GamePortrait/node_modules/vant/es/address-list/AddressListItem.mjs

97 lines
2.4 KiB
JavaScript

import { createVNode as _createVNode } from "vue";
import { defineComponent } from "vue";
import { extend, createNamespace, makeRequiredProp } from "../utils/index.mjs";
import { Tag } from "../tag/index.mjs";
import { Icon } from "../icon/index.mjs";
import { Cell } from "../cell/index.mjs";
import { Radio } from "../radio/index.mjs";
const [name, bem] = createNamespace("address-item");
var stdin_default = defineComponent({
name,
props: {
address: makeRequiredProp(Object),
disabled: Boolean,
switchable: Boolean,
defaultTagText: String
},
emits: ["edit", "click", "select"],
setup(props, {
slots,
emit
}) {
const onClick = () => {
if (props.switchable) {
emit("select");
}
emit("click");
};
const renderRightIcon = () => _createVNode(Icon, {
"name": "edit",
"class": bem("edit"),
"onClick": (event) => {
event.stopPropagation();
emit("edit");
emit("click");
}
}, null);
const renderTag = () => {
if (slots.tag) {
return slots.tag(props.address);
}
if (props.address.isDefault && props.defaultTagText) {
return _createVNode(Tag, {
"type": "primary",
"round": true,
"class": bem("tag")
}, {
default: () => [props.defaultTagText]
});
}
};
const renderContent = () => {
const {
address,
disabled,
switchable
} = props;
const Info = [_createVNode("div", {
"class": bem("name")
}, [`${address.name} ${address.tel}`, renderTag()]), _createVNode("div", {
"class": bem("address")
}, [address.address])];
if (switchable && !disabled) {
return _createVNode(Radio, {
"name": address.id,
"iconSize": 18
}, {
default: () => [Info]
});
}
return Info;
};
return () => {
var _a;
const {
disabled
} = props;
return _createVNode("div", {
"class": bem({
disabled
}),
"onClick": onClick
}, [_createVNode(Cell, {
"border": false,
"titleClass": bem("title")
}, {
title: renderContent,
"right-icon": renderRightIcon
}), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props.address, {
disabled
}))]);
};
}
});
export {
stdin_default as default
};