UNPKG

yanzhen-design-vue

Version:

97 lines (96 loc) 4.18 kB
import { defineComponent, openBlock, createElementBlock, normalizeClass, unref, Fragment, renderList, createBlock, withCtx, mergeProps, withModifiers, createTextVNode, toDisplayString, withKeys, withDirectives, createVNode, vShow, createCommentVNode } from "vue"; import { Tooltip, Tag, Input } from "ant-design-vue"; import { PlusOutlined } from "@ant-design/icons-vue"; import { tagName, tagProps, tagEmits, tagOptions } from "./tag.mjs"; import { useTag } from "./use-tag.mjs"; const _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: tagName }, __name: "tag", props: tagProps, emits: tagEmits, setup(__props, { emit: __emit }) { const { ns } = tagOptions; const props = __props; const emit = __emit; const [{ tags, _ref, _inputRef, _props, editState, handleClose, handleInputConfirm, showInput }] = useTag(props, emit); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", { class: normalizeClass([unref(ns).b(), { [unref(ns).is("disabled")]: props.disabled }]) }, [ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(tags), (tag) => { return openBlock(), createElementBlock(Fragment, { key: tag }, [ tag.length > props.maxShowLength ? (openBlock(), createBlock(unref(Tooltip), { key: 0, title: tag }, { default: withCtx(() => [ (openBlock(), createBlock(unref(Tag), mergeProps({ ref_for: true, ref_key: "_ref", ref: _ref }, unref(_props), { key: tag, class: [unref(ns).e("item")], closable: props.closable && !props.disabled, onClose: withModifiers((e) => unref(handleClose)(e, tag), ["prevent"]) }), { default: withCtx(() => [ createTextVNode(toDisplayString(`${tag.slice(0, props.maxShowLength)}...`), 1) ]), _: 2 }, 1040, ["class", "closable", "onClose"])) ]), _: 2 }, 1032, ["title"])) : (openBlock(), createBlock(unref(Tag), mergeProps({ key: 1, ref_for: true, ref_key: "_ref", ref: _ref }, unref(_props), { key: tag, class: [unref(ns).e("item")], closable: props.closable && !props.disabled, onClose: withModifiers((e) => unref(handleClose)(e, tag), ["prevent"]) }), { default: withCtx(() => [ createTextVNode(toDisplayString(tag), 1) ]), _: 2 }, 1040, ["class", "closable", "onClose"])) ], 64); }), 128)), props.isEdit ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [ unref(editState).inputVisible ? (openBlock(), createBlock(unref(Input), { key: 0, ref_key: "_inputRef", ref: _inputRef, value: unref(editState).inputValue, "onUpdate:value": _cache[0] || (_cache[0] = ($event) => unref(editState).inputValue = $event), type: "text", size: "small", "max-length": 12, style: { width: "78px" }, onBlur: unref(handleInputConfirm), onKeyup: withKeys(unref(handleInputConfirm), ["enter"]) }, null, 8, ["value", "onBlur", "onKeyup"])) : withDirectives((openBlock(), createBlock(unref(Tag), { key: 1, class: normalizeClass([unref(ns).e("add")]), style: { "background": "#fff", "border-style": "dashed" }, onClick: unref(showInput) }, { default: withCtx(() => [ createVNode(unref(PlusOutlined)), createTextVNode(" " + toDisplayString(props.addName || "新标签"), 1) ]), _: 1 }, 8, ["class", "onClick"])), [ [vShow, !props.disabled] ]) ], 64)) : createCommentVNode("", true) ], 2); }; } }); export { _sfc_main as default };