@opensig/opendesign
Version:
73 lines (72 loc) • 2.52 kB
JavaScript
;
const vue = require("vue");
const styleClass = require("../_utils/style-class.js");
const types = require("./types.js");
const icons = require("../_utils/icons.js");
const is = require("../_utils/is.js");
const _hoisted_1 = {
key: 0,
class: "o-tag-icon"
};
const _hoisted_2 = { class: "o-tag-label" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "OTag",
props: types.tagProps,
emits: ["update:visible", "close"],
setup(__props, { emit: __emit }) {
const props = __props;
const emits = __emit;
const round = styleClass.getRoundClass(props, "tag");
const innerIsVisible = vue.ref(props.visible ?? props.defaultVisible);
const isVisible = vue.computed(() => props.visible ?? innerIsVisible.value);
const onClose = async (ev) => {
ev.stopPropagation();
if (is.isFunction(props.beforeClose)) {
const rlt = await props.beforeClose();
if (rlt) {
innerIsVisible.value = false;
emits("update:visible", innerIsVisible.value);
emits("close", ev);
return;
}
}
innerIsVisible.value = false;
emits("update:visible", innerIsVisible.value);
emits("close", ev);
};
return (_ctx, _cache) => {
return isVisible.value ? (vue.openBlock(), vue.createElementBlock(
"span",
{
key: 0,
class: vue.normalizeClass(["o-tag", [
`o-tag-${props.variant}`,
`o-tag-${props.color}`,
`o-tag-${props.size}`,
vue.unref(round).class.value,
{ "o-tag-closable": props.closable, "o-tag-interactive": props.interactive || props.closable }
]]),
style: vue.normalizeStyle(vue.unref(round).style.value)
},
[
_ctx.$slots.icon ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_1, [
vue.renderSlot(_ctx.$slots, "icon")
])) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("span", _hoisted_2, [
vue.renderSlot(_ctx.$slots, "default")
]),
props.closable ? (vue.openBlock(), vue.createElementBlock("span", {
key: 1,
class: "o-tag-close",
onClick: onClose
}, [
vue.createVNode(vue.unref(icons.IconClose))
])) : vue.createCommentVNode("v-if", true)
],
6
/* CLASS, STYLE */
)) : vue.createCommentVNode("v-if", true);
};
}
});
module.exports = _sfc_main;