UNPKG

2.79 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 tagProps: () => tagProps
22});
23module.exports = __toCommonJS(stdin_exports);
24var import_vue = require("vue");
25var import_utils = require("../utils");
26var import_icon = require("../icon");
27const [name, bem] = (0, import_utils.createNamespace)("tag");
28const tagProps = {
29 size: String,
30 mark: Boolean,
31 show: import_utils.truthProp,
32 type: (0, import_utils.makeStringProp)("default"),
33 color: String,
34 plain: Boolean,
35 round: Boolean,
36 textColor: String,
37 closeable: Boolean
38};
39var stdin_default = (0, import_vue.defineComponent)({
40 name,
41 props: tagProps,
42 emits: ["close"],
43 setup(props, {
44 slots,
45 emit
46 }) {
47 const onClose = (event) => {
48 event.stopPropagation();
49 emit("close", event);
50 };
51 const getStyle = () => {
52 if (props.plain) {
53 return {
54 color: props.textColor || props.color,
55 borderColor: props.color
56 };
57 }
58 return {
59 color: props.textColor,
60 background: props.color
61 };
62 };
63 const renderTag = () => {
64 var _a;
65 const {
66 type,
67 mark,
68 plain,
69 round,
70 size,
71 closeable
72 } = props;
73 const classes = {
74 mark,
75 plain,
76 round
77 };
78 if (size) {
79 classes[size] = size;
80 }
81 const CloseIcon = closeable && (0, import_vue.createVNode)(import_icon.Icon, {
82 "name": "cross",
83 "class": [bem("close"), import_utils.HAPTICS_FEEDBACK],
84 "onClick": onClose
85 }, null);
86 return (0, import_vue.createVNode)("span", {
87 "style": getStyle(),
88 "class": bem([classes, type])
89 }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
90 };
91 return () => (0, import_vue.createVNode)(import_vue.Transition, {
92 "name": props.closeable ? "van-fade" : void 0
93 }, {
94 default: () => [props.show ? renderTag() : null]
95 });
96 }
97});