53fd959b0b00cd5fdf388a6f3ad97b154611cdbcdbf2dd39c046fd9e5705dfc302617b659e8023597580563afdd43bf77e7fa6999ff2eddbe68264dd50b737 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createElementVNode, renderSlot, createBlock, withModifiers, withCtx, createVNode, createCommentVNode, Transition } from 'vue';
  2. import { ElIcon } from '../../icon/index.mjs';
  3. import { Close } from '@element-plus/icons-vue';
  4. import { tagProps, tagEmits } from './tag.mjs';
  5. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  6. import { useFormSize } from '../../form/src/hooks/use-form-common-props.mjs';
  7. import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
  8. const __default__ = defineComponent({
  9. name: "ElTag"
  10. });
  11. const _sfc_main = /* @__PURE__ */ defineComponent({
  12. ...__default__,
  13. props: tagProps,
  14. emits: tagEmits,
  15. setup(__props, { emit }) {
  16. const props = __props;
  17. const tagSize = useFormSize();
  18. const ns = useNamespace("tag");
  19. const containerKls = computed(() => {
  20. const { type, hit, effect, closable, round } = props;
  21. return [
  22. ns.b(),
  23. ns.is("closable", closable),
  24. ns.m(type || "primary"),
  25. ns.m(tagSize.value),
  26. ns.m(effect),
  27. ns.is("hit", hit),
  28. ns.is("round", round)
  29. ];
  30. });
  31. const handleClose = (event) => {
  32. emit("close", event);
  33. };
  34. const handleClick = (event) => {
  35. emit("click", event);
  36. };
  37. const handleVNodeMounted = (vnode) => {
  38. var _a, _b, _c;
  39. if ((_c = (_b = (_a = vnode == null ? void 0 : vnode.component) == null ? void 0 : _a.subTree) == null ? void 0 : _b.component) == null ? void 0 : _c.bum) {
  40. vnode.component.subTree.component.bum = null;
  41. }
  42. };
  43. return (_ctx, _cache) => {
  44. return _ctx.disableTransitions ? (openBlock(), createElementBlock("span", {
  45. key: 0,
  46. class: normalizeClass(unref(containerKls)),
  47. style: normalizeStyle({ backgroundColor: _ctx.color }),
  48. onClick: handleClick
  49. }, [
  50. createElementVNode("span", {
  51. class: normalizeClass(unref(ns).e("content"))
  52. }, [
  53. renderSlot(_ctx.$slots, "default")
  54. ], 2),
  55. _ctx.closable ? (openBlock(), createBlock(unref(ElIcon), {
  56. key: 0,
  57. class: normalizeClass(unref(ns).e("close")),
  58. onClick: withModifiers(handleClose, ["stop"])
  59. }, {
  60. default: withCtx(() => [
  61. createVNode(unref(Close))
  62. ]),
  63. _: 1
  64. }, 8, ["class", "onClick"])) : createCommentVNode("v-if", true)
  65. ], 6)) : (openBlock(), createBlock(Transition, {
  66. key: 1,
  67. name: `${unref(ns).namespace.value}-zoom-in-center`,
  68. appear: "",
  69. onVnodeMounted: handleVNodeMounted
  70. }, {
  71. default: withCtx(() => [
  72. createElementVNode("span", {
  73. class: normalizeClass(unref(containerKls)),
  74. style: normalizeStyle({ backgroundColor: _ctx.color }),
  75. onClick: handleClick
  76. }, [
  77. createElementVNode("span", {
  78. class: normalizeClass(unref(ns).e("content"))
  79. }, [
  80. renderSlot(_ctx.$slots, "default")
  81. ], 2),
  82. _ctx.closable ? (openBlock(), createBlock(unref(ElIcon), {
  83. key: 0,
  84. class: normalizeClass(unref(ns).e("close")),
  85. onClick: withModifiers(handleClose, ["stop"])
  86. }, {
  87. default: withCtx(() => [
  88. createVNode(unref(Close))
  89. ]),
  90. _: 1
  91. }, 8, ["class", "onClick"])) : createCommentVNode("v-if", true)
  92. ], 6)
  93. ]),
  94. _: 3
  95. }, 8, ["name"]));
  96. };
  97. }
  98. });
  99. var Tag = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "tag.vue"]]);
  100. export { Tag as default };
  101. //# sourceMappingURL=tag2.mjs.map