UNPKG

hongluan-ui

Version:
65 lines (60 loc) 2 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); require('../../../hooks/index.js'); var types = require('./types.js'); var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js'); var index = require('../../../hooks/use-namespace/index.js'); const _sfc_main = vue.defineComponent({ name: "AnchorLink", props: { title: String, href: String }, setup(props) { const { namespace } = index.useNamespace("anchor-link"); const linkRef = vue.ref(); const context = vue.inject(types.anchorInjectionKey, void 0); const cls = vue.computed(() => [ namespace.value, { [`is-active`]: (context == null ? void 0 : context.currentLink) === props.href } ]); const handleClick = (e) => context == null ? void 0 : context.handleClick(e, props.href); vue.onMounted(() => { if (props.href && linkRef.value) { context == null ? void 0 : context.addLink(props.href, linkRef.value); } }); return { cls, linkRef, handleClick }; } }); function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return vue.openBlock(), vue.createElementBlock("div", { ref: "linkRef", class: vue.normalizeClass(_ctx.cls) }, [ vue.createElementVNode("a", { href: _ctx.href, onClick: _ctx.handleClick }, [ vue.renderSlot(_ctx.$slots, "default", {}, () => [ vue.createTextVNode(vue.toDisplayString(_ctx.title), 1) ]) ], 8, ["href", "onClick"]), _ctx.$slots.sublist ? (vue.openBlock(), vue.createElementBlock("div", { key: 0, class: vue.normalizeClass(`anchor-sublist`) }, [ vue.renderSlot(_ctx.$slots, "sublist") ])) : vue.createCommentVNode("v-if", true) ], 2); } var AnchorLink = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render]]); exports["default"] = AnchorLink; //# sourceMappingURL=anchor-link.js.map