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.
1 lines
9.3 KiB
1 lines
9.3 KiB
{"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","resolveComponent","openBlock","createElementBlock","class","normalizeClass","_ctx","b","is","role","tabindex","onClick","type","collapse","$slots","title","createBlock","key","effect","popperEffect","placement","persistent","content","withCtx","default","createElementVNode","be","MenuItem","_export_sfc","_sfc_render"],"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"],"mappings":";;;;;;;AAwDA,MAAMA,cAAiB;AACvB,MAAKC,SAAA,GAAaC,eAAa;EAC7BC,IAAM,EAAAH,cAAA;EACNI,UAAY;IACVC;EAAA,CACF;EAEAC,KAAO,EAAAC,aAAA;EACPC,KAAO,EAAAC,aAAA;EAEPC,KAAMA,CAAAJ,KAAA,EAAO;IAAEK;EAAA,CAAQ;IACrB,MAAMC,QAAA,GAAWC,kBAAmB;IAC9B,MAAAC,QAAA,GAAWC,MAAA,CAAqB,UAAU;IAC1C,MAAAC,MAAA,GAASC,YAAA,CAAa,MAAM;IAC5B,MAAAC,UAAA,GAAaD,YAAA,CAAa,WAAW;IAC3C,IAAI,CAACH,QAAA,EAECK,UAAA,CAAAnB,cAAwB,4BAAsB;IAEpD,MAAM;MAAAoB,UAAkC;MAAAC;IAAA,IAAWC,OAAW,CAAAV,QAAA,EAAAW,KAAW,CAAAjB,KAAA;IACzE,MAAKkB,OAAS,GAAWT,MAAA,YAAAK,UAAyC,CAAAK,KAAA,CAAAC,GAAA;IAElE,KAAAF,OAAA,EACAL,UAAA,CAAiCnB,cAAS;IAAA,MAAA2B,MAC3B,GAAAC,QAAA,OAAAtB,KAAA,CAAAuB,KAAA,KAAAf,QAAA,CAAAgB,WAAA;IACb,MAAAC,IAAA,GAAAC,QAAA;MACAH,KAAA,EAAAvB,KAAA,CA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