UNPKG

@opensig/opendesign

Version:

65 lines (64 loc) 1.82 kB
"use strict"; const vue = require("vue"); const types = require("./types.js"); const is = require("../_utils/is.js"); const _hoisted_1 = { class: "o-badge-label" }; const _sfc_main = /* @__PURE__ */ vue.defineComponent({ __name: "OBadge", props: types.badgeProps, setup(__props) { const props = __props; const content = vue.computed(() => { if (props.dot) { return ""; } if (is.isNumber(props.value) && is.isNumber(props.max)) { return props.value < props.max ? `${props.value}` : `${props.max}+`; } return props.value; }); const style = vue.computed(() => { const [x, y] = props.offset; const right = is.isNumber(x) ? `${x * -1}px` : `calc(${x} * -1)`; const top = is.isNumber(y) ? `${y}px` : `${y}`; return { right, top }; }); return (_ctx, _cache) => { return vue.openBlock(), vue.createElementBlock( "div", { class: vue.normalizeClass(["o-badge", [`o-badge-${props.color}`, { "o-badge-dot": props.dot, "o-badge-only": !_ctx.$slots.default }]]) }, [ vue.renderSlot(_ctx.$slots, "default"), vue.createElementVNode( "sup", { class: "o-badge-content", style: vue.normalizeStyle(style.value) }, [ vue.renderSlot(_ctx.$slots, "content", {}, () => [ vue.createElementVNode( "div", _hoisted_1, vue.toDisplayString(content.value), 1 /* TEXT */ ) ]) ], 4 /* STYLE */ ) ], 2 /* CLASS */ ); }; } }); module.exports = _sfc_main;