init
This commit is contained in:
84
es/menuItem/index.js
Normal file
84
es/menuItem/index.js
Normal file
@@ -0,0 +1,84 @@
|
||||
import { w as withInstall } from "../badge/index2.js";
|
||||
import { defineComponent, useSlots, inject, computed, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createBlock, withCtx, renderSlot, createCommentVNode, createElementVNode } from "vue";
|
||||
import { d as dropdownInjectionKey } from "../dropdown/index2.js";
|
||||
import { u as useLevel } from "../useLevel/index.js";
|
||||
import { i as indentHandle } from "../utils/index.js";
|
||||
import { _ as _sfc_main$1 } from "../tooltip/index2.js";
|
||||
import "../_chunks/@vueuse/index.js";
|
||||
const _hoisted_1 = { href: "javascript:void(0)" };
|
||||
const _hoisted_2 = { key: 0 };
|
||||
const _hoisted_3 = { key: 0 };
|
||||
const _hoisted_4 = {
|
||||
key: 1,
|
||||
href: "javascript:void(0)"
|
||||
};
|
||||
const _hoisted_5 = {
|
||||
key: 0,
|
||||
class: "layui-sub-menu-icon"
|
||||
};
|
||||
const _hoisted_6 = { key: 1 };
|
||||
const _hoisted_7 = { key: 2 };
|
||||
const __default__ = {
|
||||
name: "LayMenuItem"
|
||||
};
|
||||
const _sfc_main = defineComponent({
|
||||
...__default__,
|
||||
props: {
|
||||
id: null,
|
||||
title: null
|
||||
},
|
||||
setup(__props) {
|
||||
const props = __props;
|
||||
const slots = useSlots();
|
||||
const { level } = useLevel();
|
||||
const selectedKey = inject("selectedKey");
|
||||
const isTree = inject("isTree");
|
||||
const isCollapse = inject("isCollapse");
|
||||
const theme = inject("menuTheme");
|
||||
const indent = inject("indent");
|
||||
const dropdownCtx = inject(dropdownInjectionKey, void 0);
|
||||
const selectHandle = function() {
|
||||
selectedKey.value = props.id;
|
||||
dropdownCtx == null ? void 0 : dropdownCtx.hide();
|
||||
};
|
||||
const needTooltip = computed(() => isTree.value && (isCollapse.value === true || isCollapse.value === "true") && level.value === 1);
|
||||
return (_ctx, _cache) => {
|
||||
return openBlock(), createElementBlock("li", {
|
||||
class: normalizeClass(["layui-nav-item", { "layui-this": unref(selectedKey) === __props.id }]),
|
||||
style: normalizeStyle(unref(indentHandle)({ indent: unref(indent), level: unref(level), isTree: unref(isTree) })),
|
||||
onClick: _cache[0] || (_cache[0] = ($event) => selectHandle())
|
||||
}, [
|
||||
unref(needTooltip) ? (openBlock(), createBlock(_sfc_main$1, {
|
||||
key: 0,
|
||||
position: "right",
|
||||
isDark: unref(theme) !== "light"
|
||||
}, {
|
||||
content: withCtx(() => [
|
||||
unref(slots).title ? (openBlock(), createElementBlock("span", _hoisted_3, [
|
||||
renderSlot(_ctx.$slots, "title")
|
||||
])) : createCommentVNode("", true)
|
||||
]),
|
||||
default: withCtx(() => [
|
||||
createElementVNode("a", _hoisted_1, [
|
||||
unref(slots).icon ? (openBlock(), createElementBlock("i", _hoisted_2, [
|
||||
renderSlot(_ctx.$slots, "icon")
|
||||
])) : createCommentVNode("", true)
|
||||
])
|
||||
]),
|
||||
_: 3
|
||||
}, 8, ["isDark"])) : (openBlock(), createElementBlock("a", _hoisted_4, [
|
||||
unref(slots).icon ? (openBlock(), createElementBlock("i", _hoisted_5, [
|
||||
renderSlot(_ctx.$slots, "icon")
|
||||
])) : createCommentVNode("", true),
|
||||
unref(slots).title ? (openBlock(), createElementBlock("span", _hoisted_6, [
|
||||
renderSlot(_ctx.$slots, "title")
|
||||
])) : (openBlock(), createElementBlock("span", _hoisted_7, [
|
||||
renderSlot(_ctx.$slots, "default")
|
||||
]))
|
||||
]))
|
||||
], 6);
|
||||
};
|
||||
}
|
||||
});
|
||||
const component = withInstall(_sfc_main);
|
||||
export { component as default };
|
||||
Reference in New Issue
Block a user