UNPKG

3.9 kBJavaScriptView Raw
1var __defProp = Object.defineProperty;
2var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3var __getOwnPropNames = Object.getOwnPropertyNames;
4var __hasOwnProp = Object.prototype.hasOwnProperty;
5var __export = (target, all) => {
6 for (var name2 in all)
7 __defProp(target, name2, { get: all[name2], enumerable: true });
8};
9var __copyProps = (to, from, except, desc) => {
10 if (from && typeof from === "object" || typeof from === "function") {
11 for (let key of __getOwnPropNames(from))
12 if (!__hasOwnProp.call(to, key) && key !== except)
13 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14 }
15 return to;
16};
17var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18var stdin_exports = {};
19__export(stdin_exports, {
20 default: () => stdin_default
21});
22module.exports = __toCommonJS(stdin_exports);
23var import_vue = require("vue");
24var import_utils = require("../utils");
25var import_tag = require("../tag");
26var import_icon = require("../icon");
27var import_cell = require("../cell");
28var import_radio = require("../radio");
29var import_checkbox = require("../checkbox");
30const [name, bem] = (0, import_utils.createNamespace)("address-item");
31var stdin_default = (0, import_vue.defineComponent)({
32 name,
33 props: {
34 address: (0, import_utils.makeRequiredProp)(Object),
35 disabled: Boolean,
36 switchable: Boolean,
37 singleChoice: Boolean,
38 defaultTagText: String,
39 rightIcon: (0, import_utils.makeStringProp)("edit")
40 },
41 emits: ["edit", "click", "select"],
42 setup(props, {
43 slots,
44 emit
45 }) {
46 const onClick = (event) => {
47 if (props.switchable) {
48 emit("select");
49 }
50 emit("click", event);
51 };
52 const renderRightIcon = () => (0, import_vue.createVNode)(import_icon.Icon, {
53 "name": props.rightIcon,
54 "class": bem("edit"),
55 "onClick": (event) => {
56 event.stopPropagation();
57 emit("edit");
58 emit("click", event);
59 }
60 }, null);
61 const renderTag = () => {
62 if (slots.tag) {
63 return slots.tag(props.address);
64 }
65 if (props.address.isDefault && props.defaultTagText) {
66 return (0, import_vue.createVNode)(import_tag.Tag, {
67 "type": "primary",
68 "round": true,
69 "class": bem("tag")
70 }, {
71 default: () => [props.defaultTagText]
72 });
73 }
74 };
75 const renderContent = () => {
76 const {
77 address,
78 disabled,
79 switchable,
80 singleChoice
81 } = props;
82 const Info = [(0, import_vue.createVNode)("div", {
83 "class": bem("name")
84 }, [`${address.name} ${address.tel}`, renderTag()]), (0, import_vue.createVNode)("div", {
85 "class": bem("address")
86 }, [address.address])];
87 if (switchable && !disabled) {
88 if (singleChoice) {
89 return (0, import_vue.createVNode)(import_radio.Radio, {
90 "name": address.id,
91 "iconSize": 18
92 }, {
93 default: () => [Info]
94 });
95 } else {
96 return (0, import_vue.createVNode)(import_checkbox.Checkbox, {
97 "name": address.id,
98 "iconSize": 18
99 }, {
100 default: () => [Info]
101 });
102 }
103 }
104 return Info;
105 };
106 return () => {
107 var _a;
108 const {
109 disabled
110 } = props;
111 return (0, import_vue.createVNode)("div", {
112 "class": bem({
113 disabled
114 }),
115 "onClick": onClick
116 }, [(0, import_vue.createVNode)(import_cell.Cell, {
117 "border": false,
118 "titleClass": bem("title")
119 }, {
120 title: renderContent,
121 "right-icon": renderRightIcon
122 }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, (0, import_utils.extend)({}, props.address, {
123 disabled
124 }))]);
125 };
126 }
127});