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