You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
9.3 KiB

1 month ago
  1. {"ast":null,"code":"import { defineComponent, getCurrentInstance, inject, toRef, computed, reactive, onMounted, onBeforeUnmount, resolveComponent, openBlock, createElementBlock, normalizeClass, createBlock, withCtx, renderSlot, createElementVNode, Fragment } from 'vue';\nimport { ElTooltip } from '../../tooltip/index.mjs';\nimport useMenu from './use-menu.mjs';\nimport { menuItemProps, menuItemEmits } from './menu-item.mjs';\nimport _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nimport { throwError } from '../../../utils/error.mjs';\nconst COMPONENT_NAME = \"ElMenuItem\";\nconst _sfc_main = defineComponent({\n name: COMPONENT_NAME,\n components: {\n ElTooltip\n },\n props: menuItemProps,\n emits: menuItemEmits,\n setup(props, {\n emit\n }) {\n const instance = getCurrentInstance();\n const rootMenu = inject(\"rootMenu\");\n const nsMenu = useNamespace(\"menu\");\n const nsMenuItem = useNamespace(\"menu-item\");\n if (!rootMenu) throwError(COMPONENT_NAME, \"can not inject root menu\");\n const {\n parentMenu,\n indexPath\n } = useMenu(instance, toRef(props, \"index\"));\n const subMenu = inject(`subMenu:${parentMenu.value.uid}`);\n if (!subMenu) throwError(COMPONENT_NAME, \"can not inject sub menu\");\n const active = computed(() => props.index === rootMenu.activeIndex);\n const item = reactive({\n index: props.index,\n indexPath,\n active\n });\n const handleClick = () => {\n if (!props.disabled) {\n rootMenu.handleMenuItemClick({\n index: props.index,\n indexPath: indexPath.value,\n route: props.route\n });\n emit(\"click\", item);\n }\n };\n onMounted(() => {\n subMenu.addSubMenu(item);\n rootMenu.addMenuItem(item);\n });\n onBeforeUnmount(() => {\n subMenu.removeSubMenu(item);\n rootMenu.removeMenuItem(item);\n });\n return {\n parentMenu,\n rootMenu,\n active,\n nsMenu,\n nsMenuItem,\n handleClick\n };\n }\n});\nfunction _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {\n const _component_el_tooltip = resolveComponent(\"el-tooltip\");\n return openBlock(), createElementBlock(\"li\", {\n class: normalizeClass([_ctx.nsMenuItem.b(), _ctx.nsMenuItem.is(\"active\", _ctx.active), _ctx.nsMenuItem.is(\"disabled\", _ctx.disabled)]),\n role: \"menuitem\",\n tabindex: \"-1\",\n onClick: _ctx.handleClick\n }, [_ctx.parentMenu.type.name === \"ElMenu\" && _ctx.rootMenu.props.collapse && _ctx.$slots.title ? (openBlock(), createBlock(_component_el_tooltip, {\n key: 0,\n effect: _ctx.rootMenu.props.popperEffect,\n placement: \"right\",\n \"fallback-placements\": [\"left\"],\n persistent: \"\"\n }, {\n content: withCtx(() => [renderSlot(_ctx.$slots, \"title\")]),\n default: withCtx(() => [createElementVNode(\"div\", {\n class: normalizeClass(_ctx.nsMenu.be(\"tooltip\", \"trigger\"))\n }, [renderSlot(_ctx.$slots, \"default\")], 2)]),\n _: 3\n }, 8, [\"effect\"])) : (openBlock(), createElementBlock(Fragment, {\n key: 1\n }, [renderSlot(_ctx.$slots, \"default\"), renderSlot(_ctx.$slots, \"title\")], 64))], 10, [\"onClick\"]);\n}\nvar MenuItem = /* @__PURE__ */_export_sfc(_sfc_main, [[\"render\", _sfc_render], [\"__file\", \"menu-item.vue\"]]);\nexport { MenuItem as default };","map":{"version":3,"names":["COMPONENT_NAME","_sfc_main","defineComponent","name","components","ElTooltip","props","menuItemProps","emits","menuItemEmits","setup","emit","instance","getCurrentInstance","rootMenu","inject","nsMenu","useNamespace","nsMenuItem","throwError","parentMenu","indexPath","useMenu","toRef","subMenu","value","uid","active","computed","index","activeIndex","item","reactive","handleClick","disabled","handleMenuItemClick","route","onMounted","addSubMenu","addMenuItem","onBeforeUnmount","removeSubMenu","removeMenuItem","_cache","$props","$setup","$data","$options","_component_el_tooltip",