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
40 KiB

1 month ago
  1. {"ast":null,"code":"import { defineComponent, getCurrentInstance, ref, computed, watch, watchEffect, provide, reactive, onMounted, h, withDirectives, nextTick } from 'vue';\nimport { useResizeObserver } from '@vueuse/core';\nimport { isNil } from 'lodash-unified';\nimport { ElIcon } from '../../icon/index.mjs';\nimport { More } from '@element-plus/icons-vue';\nimport Menu$1 from './utils/menu-bar.mjs';\nimport ElMenuCollapseTransition from './menu-collapse-transition.mjs';\nimport SubMenu from './sub-menu.mjs';\nimport { useMenuCssVar } from './use-menu-css-var.mjs';\nimport ClickOutside from '../../../directives/click-outside/index.mjs';\nimport { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';\nimport { mutable } from '../../../utils/typescript.mjs';\nimport { iconPropType } from '../../../utils/vue/icon.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nimport { flattedChildren } from '../../../utils/vue/vnode.mjs';\nimport { isString, isArray, isObject } from '@vue/shared';\nconst menuProps = buildProps({\n mode: {\n type: String,\n values: [\"horizontal\", \"vertical\"],\n default: \"vertical\"\n },\n defaultActive: {\n type: String,\n default: \"\"\n },\n defaultOpeneds: {\n type: definePropType(Array),\n default: () => mutable([])\n },\n uniqueOpened: Boolean,\n router: Boolean,\n menuTrigger: {\n type: String,\n values: [\"hover\", \"click\"],\n default: \"hover\"\n },\n collapse: Boolean,\n backgroundColor: String,\n textColor: String,\n activeTextColor: String,\n closeOnClickOutside: Boolean,\n collapseTransition: {\n type: Boolean,\n default: true\n },\n ellipsis: {\n type: Boolean,\n default: true\n },\n popperOffset: {\n type: Number,\n default: 6\n },\n ellipsisIcon: {\n type: iconPropType,\n default: () => More\n },\n popperEffect: {\n type: definePropType(String),\n default: \"dark\"\n },\n popperClass: String,\n showTimeout: {\n type: Number,\n default: 300\n },\n hideTimeout: {\n type: Number,\n default: 300\n }\n});\nconst checkIndexPath = indexPath => isArray(indexPath) && indexPath.every(path => isString(path));\nconst menuEmits = {\n close: (index, indexPath) => isString(index) && checkIndexPath(indexPath),\n open: (index, indexPath) => isString(index) && checkIndexPath(indexPath),\n select: (index, indexPath, item, routerResult) => isString(index) && checkIndexPath(indexPath) && isObject(item) && (routerResult === void 0 || routerResult instanceof Promise)\n};\nvar Menu = defineComponent({\n name: \"ElMenu\",\n props: menuProps,\n emits: menuEmits,\n setup(props, {\n emit,\n slots,\n expose\n }) {\n const instance = getCurrentInstance();\n const router = instance.appContext.config.globalProperties.$router;\n const menu = ref();\n const nsMenu = useNamespace(\"menu\");\n const nsSubMenu = useNamespace(\"sub-menu\");\n const sliceIndex = ref(-1);\n const openedMenus = ref(props.defaultOpeneds && !props.collapse ? props.defaultOpeneds.slice(0) : []);\n const activeIndex = ref(props.defaultActive);\n const items = ref({});\n const subMenus = ref({});\n const isMenuPopup = computed(() => {\n return props.mode === \"horizontal\" || props.mode === \"vertical\" && props.collapse;\n });\n const initMenu = () => {\n const activeItem = activeIndex.value && items.value[activeIndex.value];\n if (!activeItem || props.mode === \"horizontal\" || props.collapse) return;\n const indexPath = activeItem.indexPath;\n indexPath.forEach(index => {\n const subMenu = subMenus.value[index];\n subMenu && openMenu(index, subMenu.indexPath);\n });\n };\n const openMenu = (index, indexPath) => {\n if (openedMenus.value.includes(index)) return;\n if (props.uniqueOpened) {\n openedMenus.value = openedMenus.value.filter(index2 => indexPath.includes(index2));\n }\n openedMenus.value.push(index);\n emit(\"open\", index, indexPath);\n };\n