buefy
Version:
Lightweight UI components for Vue.js (v3) based on Bulma
168 lines (163 loc) • 5.36 kB
JavaScript
;
var vue = require('vue');
var Icon = require('./Icon-lsDKE2wQ.js');
var _pluginVue_exportHelper = require('./_plugin-vue_export-helper-Die8u8yB.js');
var _sfc_main = vue.defineComponent({
name: "BTag",
components: { BIcon: Icon.BIcon },
props: {
attached: Boolean,
closable: Boolean,
type: [String, Object],
size: String,
rounded: Boolean,
disabled: Boolean,
ellipsis: Boolean,
tabstop: {
type: Boolean,
default: true
},
ariaCloseLabel: String,
icon: String,
iconType: String,
iconPack: String,
closeType: String,
closeIcon: String,
closeIconPack: String,
closeIconType: String
},
emits: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
click: (_) => true,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
close: (_) => true
},
computed: {
// setting a boolean attribute `false` does not remove it on Vue 3.
// `null` or `undefined` has to be given to remove it.
disabledOrUndefined() {
return this.disabled || void 0;
}
},
methods: {
/*
* Emit close event when delete button is clicked
* or delete key is pressed.
*/
close(event) {
if (this.disabled) return;
this.$emit("close", event);
},
/*
* Emit click event when tag is clicked.
*/
click(event) {
if (this.disabled) return;
this.$emit("click", event);
}
}
});
const _hoisted_1 = {
key: 0,
class: "tags has-addons inline-tags"
};
const _hoisted_2 = ["aria-label", "tabindex", "disabled"];
const _hoisted_3 = ["aria-label", "disabled", "tabindex"];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_b_icon = vue.resolveComponent("b-icon");
return _ctx.attached && _ctx.closable ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
vue.createElementVNode(
"span",
{
class: vue.normalizeClass(["tag", [_ctx.type, _ctx.size, { "is-rounded": _ctx.rounded }]])
},
[
_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_b_icon, {
key: 0,
icon: _ctx.icon,
size: _ctx.size,
type: _ctx.iconType,
pack: _ctx.iconPack
}, null, 8, ["icon", "size", "type", "pack"])) : vue.createCommentVNode("v-if", true),
vue.createElementVNode(
"span",
{
class: vue.normalizeClass({ "has-ellipsis": _ctx.ellipsis }),
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.click && _ctx.click(...args))
},
[
vue.renderSlot(_ctx.$slots, "default")
],
2
/* CLASS */
)
],
2
/* CLASS */
),
vue.createElementVNode("a", {
class: vue.normalizeClass(["tag", [
_ctx.size,
_ctx.closeType,
{ "is-rounded": _ctx.rounded },
_ctx.closeIcon ? "has-delete-icon" : "is-delete"
]]),
role: "button",
"aria-label": _ctx.ariaCloseLabel,
tabindex: _ctx.tabstop ? 0 : void 0,
disabled: _ctx.disabledOrUndefined,
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.close && _ctx.close(...args)),
onKeyup: _cache[2] || (_cache[2] = vue.withKeys(vue.withModifiers((...args) => _ctx.close && _ctx.close(...args), ["prevent"]), ["delete"]))
}, [
_ctx.closeIcon ? (vue.openBlock(), vue.createBlock(_component_b_icon, {
key: 0,
"custom-class": "",
icon: _ctx.closeIcon,
size: _ctx.size,
type: _ctx.closeIconType,
pack: _ctx.closeIconPack
}, null, 8, ["icon", "size", "type", "pack"])) : vue.createCommentVNode("v-if", true)
], 42, _hoisted_2)
])) : (vue.openBlock(), vue.createElementBlock(
"span",
{
key: 1,
class: vue.normalizeClass(["tag", [_ctx.type, _ctx.size, { "is-rounded": _ctx.rounded }]])
},
[
_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_b_icon, {
key: 0,
icon: _ctx.icon,
size: _ctx.size,
type: _ctx.iconType,
pack: _ctx.iconPack
}, null, 8, ["icon", "size", "type", "pack"])) : vue.createCommentVNode("v-if", true),
vue.createElementVNode(
"span",
{
class: vue.normalizeClass({ "has-ellipsis": _ctx.ellipsis }),
onClick: _cache[3] || (_cache[3] = (...args) => _ctx.click && _ctx.click(...args))
},
[
vue.renderSlot(_ctx.$slots, "default")
],
2
/* CLASS */
),
_ctx.closable ? (vue.openBlock(), vue.createElementBlock("a", {
key: 1,
role: "button",
"aria-label": _ctx.ariaCloseLabel,
class: vue.normalizeClass(["delete is-small", _ctx.closeType]),
disabled: _ctx.disabledOrUndefined,
tabindex: _ctx.tabstop ? 0 : void 0,
onClick: _cache[4] || (_cache[4] = (...args) => _ctx.close && _ctx.close(...args)),
onKeyup: _cache[5] || (_cache[5] = vue.withKeys(vue.withModifiers((...args) => _ctx.close && _ctx.close(...args), ["prevent"]), ["delete"]))
}, null, 42, _hoisted_3)) : vue.createCommentVNode("v-if", true)
],
2
/* CLASS */
));
}
var BTag = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["render", _sfc_render]]);
exports.BTag = BTag;