badge2.js 2.2 KB

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