You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
5.3 KiB
1 lines
5.3 KiB
{"ast":null,"code":"import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, unref, renderSlot, createVNode, Transition, withCtx, withDirectives, createElementVNode, normalizeStyle, createTextVNode, toDisplayString, vShow } from 'vue';\nimport { badgeProps } from './badge2.mjs';\nimport _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nimport { isNumber } from '../../../utils/types.mjs';\nimport { addUnit } from '../../../utils/dom/style.mjs';\nconst __default__ = defineComponent({\n name: \"ElBadge\"\n});\nconst _sfc_main = /* @__PURE__ */defineComponent({\n ...__default__,\n props: badgeProps,\n setup(__props, {\n expose\n }) {\n const props = __props;\n const ns = useNamespace(\"badge\");\n const content = computed(() => {\n if (props.isDot) return \"\";\n if (isNumber(props.value) && isNumber(props.max)) {\n return props.max < props.value ? `${props.max}+` : `${props.value}`;\n }\n return `${props.value}`;\n });\n const style = computed(() => {\n var _a, _b, _c, _d, _e;\n return [{\n backgroundColor: props.color,\n marginRight: addUnit(-((_b = (_a = props.offset) == null ? void 0 : _a[0]) != null ? _b : 0)),\n marginTop: addUnit((_d = (_c = props.offset) == null ? void 0 : _c[1]) != null ? _d : 0)\n }, (_e = props.badgeStyle) != null ? _e : {}];\n });\n expose({\n content\n });\n return (_ctx, _cache) => {\n return openBlock(), createElementBlock(\"div\", {\n class: normalizeClass(unref(ns).b())\n }, [renderSlot(_ctx.$slots, \"default\"), createVNode(Transition, {\n name: `${unref(ns).namespace.value}-zoom-in-center`,\n persisted: \"\"\n }, {\n default: withCtx(() => [withDirectives(createElementVNode(\"sup\", {\n class: normalizeClass([unref(ns).e(\"content\"), unref(ns).em(\"content\", _ctx.type), unref(ns).is(\"fixed\", !!_ctx.$slots.default), unref(ns).is(\"dot\", _ctx.isDot), unref(ns).is(\"hide-zero\", !_ctx.showZero && props.value === 0), _ctx.badgeClass]),\n style: normalizeStyle(unref(style))\n }, [renderSlot(_ctx.$slots, \"content\", {\n value: unref(content)\n }, () => [createTextVNode(toDisplayString(unref(content)), 1)])], 6), [[vShow, !_ctx.hidden && (unref(content) || _ctx.isDot || _ctx.$slots.content)]])]),\n _: 3\n }, 8, [\"name\"])], 2);\n };\n }\n});\nvar Badge = /* @__PURE__ */_export_sfc(_sfc_main, [[\"__file\", \"badge.vue\"]]);\nexport { Badge as default };","map":{"version":3,"names":["name","ns","useNamespace","content","computed","props","isDot","isNumber","value","max","style","_a","_b","_c","_d","_e","backgroundColor","color","marginRight","addUnit","offset","marginTop","badgeStyle","expose"],"sources":["../../../../../../packages/components/badge/src/badge.vue"],"sourcesContent":["<template>\n <div :class=\"ns.b()\">\n <slot />\n <transition :name=\"`${ns.namespace.value}-zoom-in-center`\">\n <sup\n v-show=\"!hidden && (content || isDot || $slots.content)\"\n :class=\"[\n ns.e('content'),\n ns.em('content', type),\n ns.is('fixed', !!$slots.default),\n ns.is('dot', isDot),\n ns.is('hide-zero', !showZero && props.value === 0),\n badgeClass,\n ]\"\n :style=\"style\"\n >\n <slot name=\"content\" :value=\"content\">\n {{ content }}\n </slot>\n </sup>\n </transition>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { addUnit, isNumber } from '@element-plus/utils'\nimport { badgeProps } from './badge'\nimport type { StyleValue } from 'vue'\n\ndefineOptions({\n name: 'ElBadge',\n})\n\nconst props = defineProps(badgeProps)\n\nconst ns = useNamespace('badge')\n\nconst content = computed<string>(() => {\n if (props.isDot) return ''\n if (isNumber(props.value) && isNumber(props.max)) {\n return props.max < props.value ? `${props.max}+` : `${props.value}`\n }\n return `${props.value}`\n})\n\nconst style = computed<StyleValue>(() => {\n return [\n {\n backgroundColor: props.color,\n marginRight: addUnit(-(props.offset?.[0] ?? 0)),\n marginTop: addUnit(props.offset?.[1] ?? 0),\n },\n props.badgeStyle ?? {},\n ]\n})\n\ndefineExpose({\n /** @description badge content */\n content,\n})\n</script>\n"],"mappings":";;;;;;mCA+Bc;EACZA,IAAM;AACR;;;;;;;;IAIM,MAAAC,EAAA,GAAKC,YAAA,CAAa,OAAO;IAEzB,MAAAC,OAAA,GAAUC,QAAA,CAAiB,MAAM;MACjC,IAAAC,KAAA,CAAMC,KAAA,EACV;MACS,IAAAC,QAAA,CAAAF,KAAY,CAAAG,KAAA,KAAcD,QAAA,CAAGF,KAAA,CAAMI,GAAG;QAC/C,OAAAJ,KAAA,CAAAI,GAAA,GAAAJ,KAAA,CAAAG,KAAA,MAAAH,KAAA,CAAAI,GAAA,SAAAJ,KAAA,CAAAG,KAAA;MACA;MACD,UAAAH,KAAA,CAAAG,KAAA;IAED,CAAM;IACG,MAAAE,KAAA,GAAAN,QAAA;MACL,IAAAO,EAAA,EAAAC,EAAA,EAAAC,EAAA,EAAAC,EAAA,EAAAC,EAAA;MAAA,QACyB;QAEvBC,eAAmB,EAAAX,KAAA,CAAAY,KAAe;QACpCC,WAAA,EAAAC,OAAA,IAAAP,EAAA,IAAAD,EAAA,GAAAN,KAAA,CAAAe,MAAA,qBAAAT,EAAA,eAAAC,EAAA;QACAS,SAAA,EAAAF,OAAoB,CAAC,CAAAL,EAAA,IAAAD,EAAA,GAAAR,KAAA,CAAAe,MAAA,qBAAAP,EAAA,eAAAC,EAAA;MAAA,CACvB,EACD,CAAAC,EAAA,GAAAV,KAAA,CAAAiB,UAAA,YAAAP,EAAA,MAEY;IAAA;IAEXQ,MAAA;MACDpB","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}
|