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

1 month ago
  1. {"ast":null,"code":"import { defineComponent, getCurrentInstance, computed, inject, ref, reactive, watch, provide, onMounted, onBeforeUnmount, h, Fragment, withDirectives, vShow } from 'vue';\nimport { useTimeoutFn } from '@vueuse/core';\nimport { ElCollapseTransition } from '../../collapse-transition/index.mjs';\nimport { ElTooltip } from '../../tooltip/index.mjs';\nimport { ArrowDown, ArrowRight } from '@element-plus/icons-vue';\nimport { ElIcon } from '../../icon/index.mjs';\nimport useMenu from './use-menu.mjs';\nimport { useMenuCssVar } from './use-menu-css-var.mjs';\nimport { buildProps } from '../../../utils/vue/props/runtime.mjs';\nimport { iconPropType } from '../../../utils/vue/icon.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nimport { throwError } from '../../../utils/error.mjs';\nimport { isString } from '@vue/shared';\nconst subMenuProps = buildProps({\n index: {\n type: String,\n required: true\n },\n showTimeout: Number,\n hideTimeout: Number,\n popperClass: String,\n disabled: Boolean,\n teleported: {\n type: Boolean,\n default: void 0\n },\n popperOffset: Number,\n expandCloseIcon: {\n type: iconPropType\n },\n expandOpenIcon: {\n type: iconPropType\n },\n collapseCloseIcon: {\n type: iconPropType\n },\n collapseOpenIcon: {\n type: iconPropType\n }\n});\nconst COMPONENT_NAME = \"ElSubMenu\";\nvar SubMenu = defineComponent({\n name: COMPONENT_NAME,\n props: subMenuProps,\n setup(props, {\n slots,\n expose\n }) {\n const instance = getCurrentInstance();\n const {\n indexPath,\n parentMenu\n } = useMenu(instance, computed(() => props.index));\n const nsMenu = useNamespace(\"menu\");\n const nsSubMenu = useNamespace(\"sub-menu\");\n const rootMenu = inject(\"rootMenu\");\n if (!rootMenu) throwError(COMPONENT_NAME, \"can not inject root menu\");\n const subMenu = inject(`subMenu:${parentMenu.value.uid}`);\n if (!subMenu) throwError(COMPONENT_NAME, \"can not inject sub menu\");\n const items = ref({});\n const subMenus = ref({});\n let timeout;\n const mouseInChild = ref(false);\n const verticalTitleRef = ref();\n const vPopper = ref(null);\n const currentPlacement = computed(() => mode.value === \"horizontal\" && isFirstLevel.value ? \"bottom-start\" : \"right-start\");\n const subMenuTitleIcon = computed(() => {\n return mode.value === \"horizontal\" && isFirstLevel.value || mode.value === \"vertical\" && !rootMenu.props.collapse ? props.expandCloseIcon && props.expandOpenIcon ? opened.value ? props.expandOpenIcon : props.expandCloseIcon : ArrowDown : props.collapseCloseIcon && props.collapseOpenIcon ? opened.value ? props.collapseOpenIcon : props.collapseCloseIcon : ArrowRight;\n });\n const isFirstLevel = computed(() => {\n return subMenu.level === 0;\n });\n const appendToBody = computed(() => {\n const value = props.teleported;\n return value === void 0 ? isFirstLevel.value : value;\n });\n const menuTransitionName = computed(() => rootMenu.props.collapse ? `${nsMenu.namespace.value}-zoom-in-left` : `${nsMenu.namespace.value}-zoom-in-top`);\n const fallbackPlacements = computed(() => mode.value === \"horizontal\" && isFirstLevel.value ? [\"bottom-start\", \"bottom-end\", \"top-start\", \"top-end\", \"right-start\", \"left-start\"] : [\"right-start\", \"right\", \"right-end\", \"left-start\", \"bottom-start\", \"bottom-end\", \"top-start\", \"top-end\"]);\n const opened = computed(() => rootMenu.openedMenus.includes(props.index));\n const active = computed(() => {\n let isActive = false;\n Object.values(items.value).forEach(item2 => {\n if (item2.active) {\n isActive = true;\n }\n });\n Object.values(subMenus.value).forEach(subItem => {\n if (subItem.active) {\n isActive = true;\n }\n });\n return isActive;\n });\n const mode = computed(() => rootMenu.props.mode);\n const item = reactive({\n index: props.index,\n indexPat