UNPKG

hongluan-ui

Version:
66 lines (61 loc) 2.06 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); require('../../../hooks/index.js'); require('../../../tokens/index.js'); var breadcrumbItem = require('./breadcrumb-item2.js'); var index = require('../../../hooks/use-namespace/index.js'); var breadcrumb = require('../../../tokens/breadcrumb.js'); const _sfc_main = vue.defineComponent({ name: "BreadcrumbItem", props: breadcrumbItem.breadcrumbItemProps, setup(props) { const { namespace } = index.useNamespace("breadcrumb-item"); const link = vue.ref(); const instance = vue.getCurrentInstance(); const router = instance.appContext.config.globalProperties.$router; vue.onMounted(() => { var _a, _b; (_a = link.value) == null ? void 0 : _a.setAttribute("role", "link"); (_b = link.value) == null ? void 0 : _b.addEventListener("click", () => { if (!props.to || !router) return; props.replace ? router.replace(props.to) : router.push(props.to); }); }); return { namespace, link }; }, render() { var _a; const { $slots, namespace, to } = this; const parent = vue.inject(breadcrumb.BreadcrumbKey); const separator = parent == null ? void 0 : parent.separator; return vue.h("span", { class: [namespace] }, [ ((_a = parent == null ? void 0 : parent.slots) == null ? void 0 : _a.icon) || $slots.icon ? vue.h("span", { class: "breadcrumb-separator" }, [ $slots.icon ? vue.renderSlot($slots, "icon", {}) : vue.renderSlot(parent == null ? void 0 : parent.slots, "icon", {}) ]) : vue.h("span", { class: "breadcrumb-separator", role: "presentation", innerHTML: separator }, []), vue.h("span", { ref: "link", class: ["breadcrumb-inner", to ? "is-link" : ""], role: "link" }, [vue.renderSlot($slots, "default", {})]) ]); } }); exports["default"] = _sfc_main; //# sourceMappingURL=breadcrumb-item.js.map