UNPKG

hongluan-ui

Version:
64 lines (61 loc) 2.04 kB
import { defineComponent, computed, withDirectives, openBlock, createElementBlock, normalizeClass, normalizeStyle, toDisplayString, vShow } from 'vue'; import '../../../hooks/index.mjs'; import '../../../utils/index.mjs'; import { badgeProps } from './badge2.mjs'; import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs'; import { useNamespace } from '../../../hooks/use-namespace/index.mjs'; import { isNumber } from '../../../utils/types.mjs'; const _sfc_main = defineComponent({ name: "Badge", props: badgeProps, setup(props) { const { namespace } = useNamespace("badge"); const content = computed(() => { if (props.dot) { return ""; } if (isNumber(props.value) && isNumber(props.max)) { if (props.max < props.value) { return `${props.max}+`; } return props.value === 0 && !props.showZero ? "" : `${props.value}`; } return `${props.value}`; }); const style = computed(() => { return props.offset ? ` top: ${props.offset[0]}; right: ${props.offset[1]}; bottom: ${props.offset[2]}; left: ${props.offset[3]}; ` : ""; }); return { namespace, content, style }; } }); function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { var _a; return withDirectives((openBlock(), createElementBlock("em", { class: normalizeClass([ _ctx.namespace, { "dot": _ctx.dot, "round": _ctx.round }, _ctx.type ? _ctx.type : "", _ctx.position, _ctx.badgeClass ]), style: normalizeStyle([_ctx.style, { backgroundColor: _ctx.color }, (_a = _ctx.badgeStyle) != null ? _a : {}]), textContent: toDisplayString(_ctx.content) }, null, 14, ["textContent"])), [ [vShow, !_ctx.hidden && (_ctx.content || _ctx.content === "0" || _ctx.dot)] ]); } var Badge = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { Badge as default }; //# sourceMappingURL=badge.mjs.map