UNPKG

hongluan-ui

Version:
70 lines (65 loc) 2.13 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); require('../../../hooks/index.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: "ListItem", props: { type: String, to: { type: [String, Object], default: "" }, replace: { type: Boolean, default: false } }, emits: ["select-item"], setup(props) { const { namespace } = index.useNamespace("list-item"); const instance = vue.getCurrentInstance(); const router = instance.appContext.config.globalProperties.$router; const listItemRef = vue.ref(null); const { selectItem } = vue.inject("ListComponnetContext"); vue.onMounted(() => { listItemRef.value.addEventListener("click", (evt) => { selectItem(evt); if (!props.to || !router) return; props.replace ? router.replace(props.to) : router.push(props.to); }); }); return { namespace, listItemRef }; } }); function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return vue.openBlock(), vue.createElementBlock("div", { ref: "listItemRef", class: vue.normalizeClass([_ctx.namespace, _ctx.type ? _ctx.type : ""]) }, [ _ctx.$slots.prefix ? (vue.openBlock(), vue.createElementBlock("span", { key: 0, class: "item-prefix" }, [ vue.renderSlot(_ctx.$slots, "prefix") ])) : vue.createCommentVNode("v-if", true), vue.createElementVNode("span", { class: "item-content" }, [ vue.renderSlot(_ctx.$slots, "default") ]), _ctx.$slots.suffix ? (vue.openBlock(), vue.createElementBlock("span", { key: 1, class: "item-suffix" }, [ vue.renderSlot(_ctx.$slots, "suffix") ])) : vue.createCommentVNode("v-if", true) ], 2); } var ListItem = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render]]); exports["default"] = ListItem; //# sourceMappingURL=list-item.js.map