UNPKG

element-plus

Version:
109 lines (103 loc) 3.2 kB
import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, normalizeStyle, renderSlot, createCommentVNode, createBlock, Transition, withCtx, createElementVNode } from 'vue'; import { useGlobalConfig } from '../../utils/util'; import { isValidComponentSize } from '../../utils/validators'; var script = defineComponent({ name: "ElTag", props: { closable: Boolean, type: { type: String, default: "" }, hit: Boolean, disableTransitions: Boolean, color: { type: String, default: "" }, size: { type: String, validator: isValidComponentSize }, effect: { type: String, default: "light", validator: (val) => { return ["dark", "light", "plain"].indexOf(val) !== -1; } } }, emits: ["close", "click"], setup(props, ctx) { const ELEMENT = useGlobalConfig(); const tagSize = computed(() => { return props.size || ELEMENT.size; }); const classes = computed(() => { const { type, hit, effect } = props; return [ "el-tag", type ? `el-tag--${type}` : "", tagSize.value ? `el-tag--${tagSize.value}` : "", effect ? `el-tag--${effect}` : "", hit && "is-hit" ]; }); const handleClose = (event) => { event.stopPropagation(); ctx.emit("close", event); }; const handleClick = (event) => { ctx.emit("click", event); }; return { tagSize, classes, handleClose, handleClick }; } }); function render(_ctx, _cache, $props, $setup, $data, $options) { return !_ctx.disableTransitions ? (openBlock(), createElementBlock("span", { key: 0, class: normalizeClass(_ctx.classes), style: normalizeStyle({ backgroundColor: _ctx.color }), onClick: _cache[1] || (_cache[1] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)) }, [ renderSlot(_ctx.$slots, "default"), _ctx.closable ? (openBlock(), createElementBlock("i", { key: 0, class: "el-tag__close el-icon-close", onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClose && _ctx.handleClose(...args)) })) : createCommentVNode("v-if", true) ], 6)) : (openBlock(), createBlock(Transition, { key: 1, name: "el-zoom-in-center" }, { default: withCtx(() => [ createElementVNode("span", { class: normalizeClass(_ctx.classes), style: normalizeStyle({ backgroundColor: _ctx.color }), onClick: _cache[3] || (_cache[3] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)) }, [ renderSlot(_ctx.$slots, "default"), _ctx.closable ? (openBlock(), createElementBlock("i", { key: 0, class: "el-tag__close el-icon-close", onClick: _cache[2] || (_cache[2] = (...args) => _ctx.handleClose && _ctx.handleClose(...args)) })) : createCommentVNode("v-if", true) ], 6) ]), _: 3 })); } script.render = render; script.__file = "packages/components/tag/src/index.vue"; script.install = (app) => { app.component(script.name, script); }; const _Tag = script; const ElTag = _Tag; export default _Tag; export { ElTag };