badge2.mjs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, unref, renderSlot, createVNode, Transition, withCtx, withDirectives, createElementVNode, toDisplayString, vShow } from 'vue';
  2. import '../../../hooks/index.mjs';
  3. import '../../../utils/index.mjs';
  4. import { badgeProps } from './badge.mjs';
  5. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  6. import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
  7. import { isNumber } from '@vueuse/core';
  8. const _hoisted_1 = ["textContent"];
  9. const __default__ = defineComponent({
  10. name: "ElBadge"
  11. });
  12. const _sfc_main = /* @__PURE__ */ defineComponent({
  13. ...__default__,
  14. props: badgeProps,
  15. setup(__props, { expose }) {
  16. const props = __props;
  17. const ns = useNamespace("badge");
  18. const content = computed(() => {
  19. if (props.isDot)
  20. return "";
  21. if (isNumber(props.value) && isNumber(props.max)) {
  22. return props.max < props.value ? `${props.max}+` : `${props.value}`;
  23. }
  24. return `${props.value}`;
  25. });
  26. expose({
  27. content
  28. });
  29. return (_ctx, _cache) => {
  30. return openBlock(), createElementBlock("div", {
  31. class: normalizeClass(unref(ns).b())
  32. }, [
  33. renderSlot(_ctx.$slots, "default"),
  34. createVNode(Transition, {
  35. name: `${unref(ns).namespace.value}-zoom-in-center`,
  36. persisted: ""
  37. }, {
  38. default: withCtx(() => [
  39. withDirectives(createElementVNode("sup", {
  40. class: normalizeClass([
  41. unref(ns).e("content"),
  42. unref(ns).em("content", _ctx.type),
  43. unref(ns).is("fixed", !!_ctx.$slots.default),
  44. unref(ns).is("dot", _ctx.isDot)
  45. ]),
  46. textContent: toDisplayString(unref(content))
  47. }, null, 10, _hoisted_1), [
  48. [vShow, !_ctx.hidden && (unref(content) || _ctx.isDot)]
  49. ])
  50. ]),
  51. _: 1
  52. }, 8, ["name"])
  53. ], 2);
  54. };
  55. }
  56. });
  57. var Badge = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/badge/src/badge.vue"]]);
  58. export { Badge as default };
  59. //# sourceMappingURL=badge2.mjs.map