@nextcloud/vue
Version:
Nextcloud vue components
87 lines (86 loc) • 2.44 kB
JavaScript
require('../assets/NcAppSidebarTab-Blv6UfuA.css');
;
const _pluginVue2_normalizer = require("../chunks/_plugin-vue2_normalizer-V0q-tHlQ.cjs");
const _sfc_main = {
name: "NcAppSidebarTab",
inject: ["registerTab", "unregisterTab", "getActiveTab", "isTablistShown"],
props: {
id: {
type: String,
required: true
},
/**
* Tab name in navigation
*/
name: {
type: String,
required: true
},
/**
* Tab icon's html class in navigation. Used if #icon slot is not provided
*/
icon: {
type: String,
default: ""
},
/**
* Tab order in navigation. If not provided, name is used.
*/
order: {
type: Number,
default: 0
}
},
emits: [
"bottom-reached",
"scroll"
],
expose: ["id", "name", "icon", "order", "renderIcon"],
computed: {
/**
* Is the current tab an active tab, that should be shown?
*
* @return {boolean}
*/
isActive() {
return this.getActiveTab() === this.id;
}
},
created() {
this.registerTab(this);
},
beforeDestroy() {
this.unregisterTab(this.id);
},
methods: {
onScroll(event) {
if (this.$el.scrollHeight - this.$el.scrollTop === this.$el.clientHeight) {
this.$emit("bottom-reached", event);
}
this.$emit("scroll", event);
},
/**
* Render tab's icon slot if any
*
* @return {import('vue').VNode[]}
*/
renderIcon() {
return this.$scopedSlots.icon?.();
}
}
};
var _sfc_render = function render() {
var _vm = this, _c = _vm._self._c;
return _c("section", { staticClass: "app-sidebar__tab", class: { "app-sidebar__tab--active": _vm.isActive }, attrs: { "id": `tab-${_vm.id}`, "aria-hidden": !_vm.isActive, "aria-label": _vm.isTablistShown() ? void 0 : _vm.name, "aria-labelledby": _vm.isTablistShown() ? `tab-button-${_vm.id}` : void 0, "tabindex": _vm.isTablistShown() ? 0 : -1, "role": _vm.isTablistShown() ? "tabpanel" : void 0 }, on: { "scroll": _vm.onScroll } }, [_c("h3", { staticClass: "hidden-visually" }, [_vm._v(" " + _vm._s(_vm.name) + " ")]), _vm._t("default")], 2);
};
var _sfc_staticRenderFns = [];
var __component__ = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent(
_sfc_main,
_sfc_render,
_sfc_staticRenderFns,
false,
null,
"095ea4ce"
);
const NcAppSidebarTab = __component__.exports;
module.exports = NcAppSidebarTab;