{"version":3,"file":"menu-item2.js","sources":["../../../../../../packages/components/menu/src/menu-item.vue"],"sourcesContent":["<template>\n <li\n :class=\"[\n nsMenuItem.b(),\n nsMenuItem.is('active', active),\n nsMenuItem.is('disabled', disabled),\n ]\"\n role=\"menuitem\"\n tabindex=\"-1\"\n @click=\"handleClick\"\n >\n <el-tooltip\n v-if=\"\n parentMenu.type.name === 'ElMenu' &&\n rootMenu.props.collapse &&\n $slots.title\n \"\n :effect=\"rootMenu.props.popperEffect\"\n placement=\"right\"\n :fallback-placements=\"['left']\"\n persistent\n >\n <template #content>\n <slot name=\"title\" />\n </template>\n <div :class=\"nsMenu.be('tooltip', 'trigger')\">\n <slot />\n </div>\n </el-tooltip>\n <template v-else>\n <slot />\n <slot name=\"title\" />\n </template>\n </li>\n</template>\n\n<script lang=\"ts\">\n// @ts-nocheck\nimport {\n computed,\n defineComponent,\n getCurrentInstance,\n inject,\n onBeforeUnmount,\n onMounted,\n reactive,\n toRef,\n} from 'vue'\nimport ElTooltip from '@element-plus/components/tooltip'\nimport { throwError } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport useMenu from './use-menu'\nimport { menuItemEmits, menuItemProps } from './menu-item'\n\nimport type { MenuItemRegistered, MenuProvider, SubMenuProvider } from './types'\n\nconst COMPONENT_NAME = 'ElMenuItem'\nexport default defineComponent({\n name: COMPONENT_NAME,\n components: {\n ElTooltip,\n },\n\n props: menuItemProps,\n emits: menuItemEmits,\n\n setup(props, { emit }) {\n const instance = getCurrentInstance()!\n const rootMenu = inject<MenuProvider>('rootMenu')\n const nsMenu = useNamespace('menu')\n const nsMenuItem = useNamespace('menu-item')\n if (!rootMenu) throwError(COMPONENT_NAME, 'can not inject root menu')\n\n const { parentMenu, indexPath } = useMenu(instance, toRef(props, 'index'))\n\n const subMenu = inject<SubMenuProvider>(`subMenu:${parentMenu.value.uid}`)\n if (!subMenu) throwError(COMPONENT_NAME, 'can not inject sub menu')\n\n const active = computed(() => props.index === rootMenu.activeIndex)\n const item: MenuItemRegistered = reactive({\n index: props.index,\n indexPath,\n active,\n })\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\n onMounted(() => {\n subMenu.addSubMenu(item)\n rootMenu.addMenuItem(item)\n })\n\n onBeforeUnmount(() => {\n subMenu.removeSubMenu(item)\n rootMenu.removeMenuItem(item)\n })\n\n return {\n parentMenu,\n rootMenu,\n active,\n nsMenu,\n nsMenuItem,\n handleClick,\n }\n },\n})\n</script>\n"],"names":["defineComponent","ElTooltip","menuItemProps","menuItemEmits","getCurrentInstance","inject","useNamespace","throwError","useMenu","toRef","computed","reactive","onMounted","onBeforeUnmount","_createElementBlock","_normalizeClass","_createBlock","_withCtx","_renderSlot","_createElementVNode","_Fragment"],"mappings":";;;;;;;;;;;;;;AAwDA,MAAM,cAAiB,GAAA,YAAA,CAAA;AACvB,MAAK,YAAaA,mBAAa,CAAA;AAAA,EAC7B,IAAM,EAAA,cAAA;AAAA,EACN,UAAY,EAAA;AAAA,eACVC,eAAA;AAAA,GACF;AAAA,EAEA,KAAO,EAAAC,sBAAA;AAAA,EACP,KAAO,EAAAC,sBAAA;AAAA,EAEP,KAAA,CAAM,KAAO,EAAA,EAAE,IAAQ,EAAA,EAAA;AACrB,IAAA,MAAM,WAAWC,sBAAmB,EAAA,CAAA;AACpC,IAAM,MAAA,QAAA,GAAWC,WAAqB,UAAU,CAAA,CAAA;AAChD,IAAM,MAAA,MAAA,GAASC,qBAAa,MAAM,CAAA,CAAA;AAClC,IAAM,MAAA,UAAA,GAAaA,qBAAa,WAAW,CAAA,CAAA;AAC3C,IAAA,IAAI,CAAC,QAAA;AAAU,MAAAC,gBAAA,CAAW,gBAAgB,0BAA0B,CAAA,CAAA;AAEpE,IAAM,MAAA,EAAE,YAAY,SAAc,EAAA,GAAAC,kBAAA,CAAQ,UAAUC,SAAM,CAAA,KAAA,EAAO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