@nextcloud/vue
Version:
Nextcloud vue components
95 lines (94 loc) • 3.77 kB
JavaScript
import '../assets/NcChip-DZ8dUSFy.css';
import { defineComponent, useSlots, computed, createElementBlock, openBlock, normalizeClass, createCommentVNode, createElementVNode, createBlock, renderSlot, createTextVNode, toDisplayString, withCtx, createVNode, unref } from "vue";
import { b as mdiClose } from "./mdi-XFJRiRqJ.mjs";
import { N as NcActionButton } from "./NcActionButton-pKOSrlGE.mjs";
import { N as NcActions } from "./NcActions-DWmvh7-Y.mjs";
import { N as NcIconSvgWrapper } from "./NcIconSvgWrapper-BvLanNaW.mjs";
import { r as register, a as t } from "./_l10n-DrTiip5c.mjs";
import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.mjs";
register();
const _hoisted_1 = {
key: 0,
class: "nc-chip__icon"
};
const _hoisted_2 = { class: "nc-chip__text" };
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "NcChip",
props: {
ariaLabelClose: { default: t("Close") },
actionsContainer: { default: "body" },
text: { default: "" },
iconPath: { default: void 0 },
iconSvg: { default: void 0 },
noClose: { type: Boolean },
variant: { default: "secondary" }
},
emits: ["close"],
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const slots = useSlots();
const canClose = computed(() => !props.noClose);
const hasActions = () => !!slots.actions;
const hasIcon = () => Boolean(props.iconPath || props.iconSvg || !!slots.icon);
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", {
class: normalizeClass(["nc-chip", {
[`nc-chip--${_ctx.variant}`]: true,
"nc-chip--no-actions": _ctx.noClose && !hasActions(),
"nc-chip--no-icon": !hasIcon()
}])
}, [
hasIcon() ? (openBlock(), createElementBlock("span", _hoisted_1, [
renderSlot(_ctx.$slots, "icon", {}, () => [
_ctx.iconPath || _ctx.iconSvg ? (openBlock(), createBlock(NcIconSvgWrapper, {
key: 0,
inline: "",
path: _ctx.iconPath,
svg: _ctx.iconPath ? void 0 : _ctx.iconSvg,
size: 18
}, null, 8, ["path", "svg"])) : createCommentVNode("", true)
], true)
])) : createCommentVNode("", true),
createElementVNode("span", _hoisted_2, [
renderSlot(_ctx.$slots, "default", {}, () => [
createTextVNode(toDisplayString(_ctx.text), 1)
], true)
]),
canClose.value || hasActions() ? (openBlock(), createBlock(NcActions, {
key: 1,
class: "nc-chip__actions",
container: _ctx.actionsContainer,
"force-menu": !canClose.value,
variant: "tertiary-no-background"
}, {
default: withCtx(() => [
canClose.value ? (openBlock(), createBlock(NcActionButton, {
key: 0,
"close-after-click": "",
onClick: _cache[0] || (_cache[0] = ($event) => emit("close"))
}, {
icon: withCtx(() => [
createVNode(NcIconSvgWrapper, {
path: unref(mdiClose),
size: 20
}, null, 8, ["path"])
]),
default: withCtx(() => [
createTextVNode(" " + toDisplayString(_ctx.ariaLabelClose), 1)
]),
_: 1
})) : createCommentVNode("", true),
renderSlot(_ctx.$slots, "actions", {}, void 0, true)
]),
_: 3
}, 8, ["container", "force-menu"])) : createCommentVNode("", true)
], 2);
};
}
});
const NcChip = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2aa1d7ea"]]);
export {
NcChip as N
};
//# sourceMappingURL=NcChip-D8tGFzRl.mjs.map