UNPKG

vant

Version:

Mobile UI Components built on Vue

98 lines (97 loc) 2.79 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name2 in all) __defProp(target, name2, { get: all[name2], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var stdin_exports = {}; __export(stdin_exports, { default: () => stdin_default, tagProps: () => tagProps }); module.exports = __toCommonJS(stdin_exports); var import_vue = require("vue"); var import_utils = require("../utils"); var import_icon = require("../icon"); const [name, bem] = (0, import_utils.createNamespace)("tag"); const tagProps = { size: String, mark: Boolean, show: import_utils.truthProp, type: (0, import_utils.makeStringProp)("default"), color: String, plain: Boolean, round: Boolean, textColor: String, closeable: Boolean }; var stdin_default = (0, import_vue.defineComponent)({ name, props: tagProps, emits: ["close"], setup(props, { slots, emit }) { const onClose = (event) => { event.stopPropagation(); emit("close", event); }; const getStyle = () => { if (props.plain) { return { color: props.textColor || props.color, borderColor: props.color }; } return { color: props.textColor, background: props.color }; }; const renderTag = () => { var _a; const { type, mark, plain, round, size, closeable } = props; const classes = { mark, plain, round }; if (size) { classes[size] = size; } const CloseIcon = closeable && (0, import_vue.createVNode)(import_icon.Icon, { "name": "cross", "class": [bem("close"), import_utils.HAPTICS_FEEDBACK], "onClick": onClose }, null); return (0, import_vue.createVNode)("span", { "style": getStyle(), "class": bem([classes, type]) }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]); }; return () => (0, import_vue.createVNode)(import_vue.Transition, { "name": props.closeable ? "van-fade" : void 0 }, { default: () => [props.show ? renderTag() : null] }); } });