@vuesax-alpha/nightly
Version:
A Component Library for Vue 3
71 lines (66 loc) • 2.47 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../../utils/index.js');
require('../../../hooks/index.js');
var navbar = require('../../../tokens/navbar.js');
var navbarItem = require('./navbar-item.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var error = require('../../../utils/error.js');
var index = require('../../../hooks/use-namespace/index.js');
const __default__ = vue.defineComponent({
name: "VsNavbarItem"
});
const _sfc_main = vue.defineComponent({
...__default__,
props: navbarItem.navbarItemProps,
setup(__props) {
const props = __props;
const navbarRegister = vue.inject(navbar.navbarRegisterContextKey, void 0);
const navbarGroupRegister = vue.inject(navbar.navbarGroupRegisterContextKey, void 0);
if (!navbarRegister) {
error.throwError("navbar-item", "need to call inside navbar component");
}
const { unregister, onClick, isActive } = navbarRegister(props.id);
const navbarGroup = navbarGroupRegister == null ? void 0 : navbarGroupRegister(props.id);
const ns = index.useNamespace("navbar-item");
const handleClickItem = (router) => {
onClick();
if (props.to) {
router.push(props.to);
} else {
if (props.link) {
window.open(props.link.path, props.link.target);
}
}
};
vue.onBeforeUnmount(() => {
unregister();
navbarGroup == null ? void 0 : navbarGroup.unregister();
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock(
"button",
{
class: vue.normalizeClass([vue.unref(ns).b(), vue.unref(ns).is("active", _ctx.active || vue.unref(isActive))]),
onClick: _cache[0] || (_cache[0] = ($event) => handleClickItem(_ctx.$router))
},
[
vue.renderSlot(_ctx.$slots, "default", {}, () => {
var _a;
return [
vue.createTextVNode(
vue.toDisplayString((_a = _ctx.link) == null ? void 0 : _a.text),
1
)
];
})
],
2
);
};
}
});
var NavbarItem = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/home/runner/work/vuesax-alpha/vuesax-alpha/packages/components/navbar/src/navbar-item.vue"]]);
exports["default"] = NavbarItem;
//# sourceMappingURL=navbar-item2.js.map