1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
| import { defineComponent, getCurrentInstance, inject, toRef, computed, reactive, onMounted, onBeforeUnmount, resolveComponent, openBlock, createElementBlock, normalizeClass, createBlock, withCtx, renderSlot, createElementVNode, Fragment } from 'vue';
| import { ElTooltip } from '../../tooltip/index.mjs';
| import '../../../utils/index.mjs';
| import '../../../hooks/index.mjs';
| import useMenu from './use-menu.mjs';
| import { menuItemProps, menuItemEmits } from './menu-item.mjs';
| import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
| import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
| import { throwError } from '../../../utils/error.mjs';
|
| const COMPONENT_NAME = "ElMenuItem";
| const _sfc_main = defineComponent({
| name: COMPONENT_NAME,
| components: {
| ElTooltip
| },
| props: menuItemProps,
| emits: menuItemEmits,
| setup(props, { emit }) {
| const instance = getCurrentInstance();
| const rootMenu = inject("rootMenu");
| const nsMenu = useNamespace("menu");
| const nsMenuItem = useNamespace("menu-item");
| if (!rootMenu)
| throwError(COMPONENT_NAME, "can not inject root menu");
| const { parentMenu, indexPath } = useMenu(instance, toRef(props, "index"));
| const subMenu = inject(`subMenu:${parentMenu.value.uid}`);
| if (!subMenu)
| throwError(COMPONENT_NAME, "can not inject sub menu");
| const active = computed(() => props.index === rootMenu.activeIndex);
| const item = reactive({
| index: props.index,
| indexPath,
| active
| });
| const handleClick = () => {
| if (!props.disabled) {
| rootMenu.handleMenuItemClick({
| index: props.index,
| indexPath: indexPath.value,
| route: props.route
| });
| emit("click", item);
| }
| };
| onMounted(() => {
| subMenu.addSubMenu(item);
| rootMenu.addMenuItem(item);
| });
| onBeforeUnmount(() => {
| subMenu.removeSubMenu(item);
| rootMenu.removeMenuItem(item);
| });
| return {
| parentMenu,
| rootMenu,
| active,
| nsMenu,
| nsMenuItem,
| handleClick
| };
| }
| });
| function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
| const _component_el_tooltip = resolveComponent("el-tooltip");
| return openBlock(), createElementBlock("li", {
| class: normalizeClass([
| _ctx.nsMenuItem.b(),
| _ctx.nsMenuItem.is("active", _ctx.active),
| _ctx.nsMenuItem.is("disabled", _ctx.disabled)
| ]),
| role: "menuitem",
| tabindex: "-1",
| onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
| }, [
| _ctx.parentMenu.type.name === "ElMenu" && _ctx.rootMenu.props.collapse && _ctx.$slots.title ? (openBlock(), createBlock(_component_el_tooltip, {
| key: 0,
| effect: _ctx.rootMenu.props.popperEffect,
| placement: "right",
| "fallback-placements": ["left"],
| persistent: ""
| }, {
| content: withCtx(() => [
| renderSlot(_ctx.$slots, "title")
| ]),
| default: withCtx(() => [
| createElementVNode("div", {
| class: normalizeClass(_ctx.nsMenu.be("tooltip", "trigger"))
| }, [
| renderSlot(_ctx.$slots, "default")
| ], 2)
| ]),
| _: 3
| }, 8, ["effect"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
| renderSlot(_ctx.$slots, "default"),
| renderSlot(_ctx.$slots, "title")
| ], 64))
| ], 2);
| }
| var MenuItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/element-plus/element-plus/packages/components/menu/src/menu-item.vue"]]);
|
| export { MenuItem as default };
| //# sourceMappingURL=menu-item2.mjs.map
|
|