@nextcloud/vue
Version:
Nextcloud vue components
149 lines (148 loc) • 4.79 kB
JavaScript
require('../assets/NcDashboardWidgetItem-B8_6-_k8.css');
;
const NcAvatar = require("./NcAvatar-CQtsmbBW.cjs");
const NcActions = require("./NcActions-DTICeoTz.cjs");
const NcActionButton = require("./NcActionButton-DcpUnqA7.cjs");
const _pluginVue2_normalizer = require("./_plugin-vue2_normalizer-V0q-tHlQ.cjs");
const _sfc_main = {
name: "NcDashboardWidgetItem",
components: {
NcAvatar: NcAvatar.NcAvatar,
NcActions: NcActions.NcActions,
NcActionButton: NcActionButton.NcActionButton
},
props: {
/**
* The item id (optional)
*/
id: {
type: [String, Number],
default: void 0
},
/**
* The item element is a link to this URL (optional)
*/
targetUrl: {
type: String,
default: void 0
},
/**
* Where to get the avatar image. (optional) Used if avatarUsername is not defined.
*/
avatarUrl: {
type: String,
default: void 0
},
/**
* Name to provide to the Avatar. (optional) Used if avatarUrl is not defined.
*/
avatarUsername: {
type: String,
default: void 0
},
/**
* Is the avatarUsername not a user's name? (optional, false by default)
*/
avatarIsNoUser: {
type: Boolean,
default: false
},
/**
* Small icon to display on the bottom-right corner of the avatar (optional)
*/
overlayIconUrl: {
type: String,
default: void 0
},
/**
* Item main text (mandatory)
*/
mainText: {
type: String,
required: true
},
/**
* Item subline text (optional)
*/
subText: {
type: String,
default: ""
},
/**
* An object containing context menu entries that will be displayed for each items (optional)
*/
itemMenu: {
type: Object,
default: () => {
return {};
}
},
/**
* Specify whether the 3 dot menu is forced when only one action is present
*/
forceMenu: {
type: Boolean,
default: true
}
},
data() {
return {
hovered: false
};
},
computed: {
item() {
return {
id: this.id,
targetUrl: this.targetUrl,
avatarUrl: this.avatarUrl,
avatarUsername: this.avatarUsername,
overlayIconUrl: this.overlayIconUrl,
mainText: this.mainText,
subText: this.subText
};
},
gotMenu() {
return Object.keys(this.itemMenu).length !== 0 || !!this.$slots.actions;
},
gotOverlayIcon() {
return this.overlayIconUrl && this.overlayIconUrl !== "";
}
},
methods: {
onLinkClick(event) {
if (event.target.closest(".action-item")) {
event.preventDefault();
}
}
}
};
var _sfc_render = function render() {
var _vm = this, _c = _vm._self._c;
return _c("div", { on: { "mouseover": function($event) {
_vm.hovered = true;
}, "mouseleave": function($event) {
_vm.hovered = false;
} } }, [_c(_vm.targetUrl ? "a" : "div", { tag: "component", class: { "item-list__entry": true, "item-list__entry--has-actions-menu": _vm.gotMenu }, attrs: { "href": _vm.targetUrl || void 0, "target": _vm.targetUrl ? "_blank" : void 0 }, on: { "click": _vm.onLinkClick } }, [_vm._t("avatar", function() {
return [_c("NcAvatar", { staticClass: "item-avatar", attrs: { "size": 44, "url": _vm.avatarUrl, "user": _vm.avatarUsername, "is-no-user": _vm.avatarIsNoUser, "show-user-status": !_vm.gotOverlayIcon } })];
}, { "avatarUrl": _vm.avatarUrl, "avatarUsername": _vm.avatarUsername }), _vm.overlayIconUrl ? _c("img", { staticClass: "item-icon", attrs: { "alt": "", "src": _vm.overlayIconUrl } }) : _vm._e(), _c("div", { staticClass: "item__details" }, [_c("h3", { attrs: { "title": _vm.mainText } }, [_vm._v(" " + _vm._s(_vm.mainText) + " ")]), _vm.subText !== "" ? _c("span", { staticClass: "message", attrs: { "title": _vm.subText } }, [_vm._v(" " + _vm._s(_vm.subText) + " ")]) : _vm._e()]), _vm.gotMenu ? _c("NcActions", { attrs: { "force-menu": _vm.forceMenu } }, [_vm._t("actions", function() {
return _vm._l(_vm.itemMenu, function(m, menuItemId) {
return _c("NcActionButton", { key: menuItemId, attrs: { "icon": m.icon, "close-after-click": true }, on: { "click": function($event) {
$event.preventDefault();
$event.stopPropagation();
return _vm.$emit(menuItemId, _vm.item);
} } }, [_vm._v(" " + _vm._s(m.text) + " ")]);
});
})], 2) : _vm._e()], 2)], 1);
};
var _sfc_staticRenderFns = [];
var __component__ = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent(
_sfc_main,
_sfc_render,
_sfc_staticRenderFns,
false,
null,
"db766935"
);
const NcDashboardWidgetItem = __component__.exports;
exports.NcDashboardWidgetItem = NcDashboardWidgetItem;