@nextcloud/vue
Version:
Nextcloud vue components
105 lines (104 loc) • 3.99 kB
JavaScript
require('../assets/NcChip-CEKw1zaK.css');
;
const Vue = require("vue");
const _l10n = require("../chunks/_l10n-Ci9_UR5q.cjs");
const NcActions = require("../chunks/NcActions-gOMT5VzC.cjs");
const Components_NcActionButton = require("./NcActionButton.cjs");
const NcIconSvgWrapper = require("../chunks/NcIconSvgWrapper-Cb4bAwV6.cjs");
const _pluginVue2_normalizer = require("../chunks/_plugin-vue2_normalizer-V0q-tHlQ.cjs");
var mdiClose = "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z";
_l10n.register(_l10n.t18);
const _sfc_main = {
__name: "NcChip",
props: {
/**
* aria label to set on the close button
* @default 'Close'
*/
ariaLabelClose: {
type: String,
default: _l10n.t("Close")
},
/**
* Main text of the chip
*/
text: {
type: String,
default: ""
},
/**
* Chip style
* This sets the background style of the chip, similar to NcButton's `type`
*/
type: {
type: String,
default: "secondary",
validator: (value) => ["primary", "secondary", "tertiary"].includes(value)
},
/**
* SVG path of the icon to use, this takes precedence over `iconSVG`.
* For example icon paths from `@mdi/js` can be used.
*/
iconPath: {
type: String,
default: null
},
/**
* Inline SVG to use as the icon
*/
iconSvg: {
type: String,
default: null
},
/**
* Set to true to prevent the close button to be shown
*/
noClose: {
type: Boolean,
default: false
}
},
emits: ["close"],
setup(__props, { emit }) {
const props = __props;
const slots = Vue.useSlots();
const canClose = Vue.computed(() => !props.noClose);
const hasActions = () => {
var _a;
return Boolean((_a = slots.actions) == null ? void 0 : _a.call(slots));
};
const hasIcon = () => {
var _a;
return Boolean(props.iconPath || props.iconSvg || !!((_a = slots.icon) == null ? void 0 : _a.call(slots)));
};
const onClose = () => {
emit("close");
};
return { __sfc: true, props, emit, slots, canClose, hasActions, hasIcon, onClose, mdiClose, NcActions: NcActions.NcActions, NcActionButton: Components_NcActionButton, NcIconSvgWrapper: NcIconSvgWrapper.NcIconSvgWrapper };
}
};
var _sfc_render = function render() {
var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy;
return _c("div", { staticClass: "nc-chip", class: {
["nc-chip--".concat(_vm.type)]: true,
"nc-chip--no-actions": _vm.noClose && !_setup.hasActions(),
"nc-chip--no-icon": !_setup.hasIcon()
} }, [_setup.hasIcon() ? _c("span", { staticClass: "nc-chip__icon" }, [_vm._t("icon", function() {
return [_vm.iconPath || _vm.iconSvg ? _c(_setup.NcIconSvgWrapper, { attrs: { "inline": "", "path": _vm.iconPath, "svg": _vm.iconPath ? void 0 : _vm.iconSvg, "size": 18 } }) : _vm._e()];
})], 2) : _vm._e(), _c("span", { staticClass: "nc-chip__text" }, [_vm._t("default", function() {
return [_vm._v(_vm._s(_vm.text))];
})], 2), _setup.canClose || _setup.hasActions() ? _c(_setup.NcActions, { staticClass: "nc-chip__actions", attrs: { "force-menu": !_setup.canClose, "type": "tertiary-no-background" } }, [_setup.canClose ? _c(_setup.NcActionButton, { attrs: { "close-after-click": "" }, on: { "click": _setup.onClose }, scopedSlots: _vm._u([{ key: "icon", fn: function() {
return [_c(_setup.NcIconSvgWrapper, { attrs: { "path": _setup.mdiClose, "size": 20 } })];
}, proxy: true }], null, false, 2547223506) }, [_vm._v(" " + _vm._s(_vm.ariaLabelClose) + " ")]) : _vm._e(), _vm._t("actions")], 2) : _vm._e()], 1);
};
var _sfc_staticRenderFns = [];
var __component__ = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent(
_sfc_main,
_sfc_render,
_sfc_staticRenderFns,
false,
null,
"470fc02d"
);
const NcChip = __component__.exports;
module.exports = NcChip;