{"version":3,"file":"dropdown-menu.js","sources":["../../../../../../packages/components/dropdown/src/dropdown-menu.vue"],"sourcesContent":["<template>\n  <ul\n    :ref=\"dropdownListWrapperRef\"\n    :class=\"dropdownKls\"\n    :style=\"rovingFocusGroupRootStyle\"\n    :tabindex=\"-1\"\n    :role=\"role\"\n    :aria-labelledby=\"triggerId\"\n    @blur=\"onBlur\"\n    @focus=\"onFocus\"\n    @keydown.self=\"handleKeydown\"\n    @mousedown.self=\"onMousedown\"\n  >\n    <slot />\n  </ul>\n</template>\n<script lang=\"ts\">\n// @ts-nocheck\nimport { computed, defineComponent, inject, unref } from 'vue'\nimport { composeEventHandlers, composeRefs } from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { FOCUS_TRAP_INJECTION_KEY } from '@element-plus/components/focus-trap'\nimport {\n  ROVING_FOCUS_COLLECTION_INJECTION_KEY,\n  ROVING_FOCUS_GROUP_INJECTION_KEY,\n  focusFirst,\n} from '@element-plus/components/roving-focus-group'\nimport { useNamespace } from '@element-plus/hooks'\nimport { DROPDOWN_INJECTION_KEY } from './tokens'\nimport {\n  DROPDOWN_COLLECTION_INJECTION_KEY,\n  FIRST_LAST_KEYS,\n  LAST_KEYS,\n  dropdownMenuProps,\n} from './dropdown'\nimport { useDropdown } from './useDropdown'\n\nexport default defineComponent({\n  name: 'ElDropdownMenu',\n  props: dropdownMenuProps,\n  setup(props) {\n    const ns = useNamespace('dropdown')\n    const { _elDropdownSize } = useDropdown()\n    const size = _elDropdownSize.value\n\n    const { focusTrapRef, onKeydown } = inject(\n      FOCUS_TRAP_INJECTION_KEY,\n      undefined\n    )!\n\n    const { contentRef, role, triggerId } = inject(\n      DROPDOWN_INJECTION_KEY,\n      undefined\n    )!\n\n    const { collectionRef: dropdownCollectionRef, getItems } = inject(\n      DROPDOWN_COLLECTION_INJECTION_KEY,\n      undefined\n    )!\n\n    const {\n      rovingFocusGroupRef,\n      rovingFocusGroupRootStyle,\n      tabIndex,\n      onBlur,\n      onFocus,\n      onMousedown,\n    } = inject(ROVING_FOCUS_GROUP_INJECTION_KEY, undefined)!\n\n    const { collectionRef: rovingFocusGroupCollectionRef } = inject(\n      ROVING_FOCUS_COLLECTION_INJECTION_KEY,\n      undefined\n    )!\n\n    const dropdownKls = computed(() => {\n      return [ns.b('menu'), ns.bm('menu', size?.value)]\n    })\n\n    const dropdownListWrapperRef = composeRefs(\n      contentRef,\n      dropdownCollectionRef,\n      focusTrapRef,\n      rovingFocusGroupRef,\n      rovingFocusGroupCollectionRef\n    )\n\n    const composedKeydown = composeEventHandlers(\n      (e: KeyboardEvent) => {\n        props.onKeydown?.(e)\n      },\n      (e) => {\n        const { currentTarget, code, target } = e\n        const isKeydownContained = (currentTarget as Node).contains(\n          target as Node\n        )\n\n        if (isKeydownContained) {\n          // TODO: implement typeahead search\n        }\n\n        if (EVENT_CODE.tab === code) {\n          e.stopImmediatePropagation()\n        }\n\n        e.preventDefault()\n\n        if (target !== unref(contentRef) || !FIRST_LAST_KEYS.includes(code))\n          return\n        const items = getItems<{ disabled: boolean }>().filter(\n          (item) => !item.disabled\n        )\n        const targets = items.map((item) => item.ref!)\n        if (LAST_KEYS.includes(code)) {\n          targets.reverse()\n        }\n        focusFirst(targets)\n      }\n    )\n\n    const handleKeydown = (e: KeyboardEvent) => {\n      composedKeydown(e)\n      onKeydown(e)\n    }\n\n    return {\n      size,\n      rovingFocusGroupRootStyle,\n      tabIndex,\n      dropdownKls,\n      role,\n      triggerId,\n      dropdownListWrapperRef,\n      handleKeydown,\n      onBlur,\n      onFocus,\n      onMousedown,\n    }\n  },\n})\n</script>\n"],"names":["defineComponent","dropdownMenuProps","useNamespace","useDropdown","inject","FOCUS_TRAP_INJECTION_KEY","DROPDOWN_INJECTION_KEY","DROPDOWN_COLLECTION_INJECTION_KEY","ROVING_FOCUS_GROUP_INJECTION_KEY","ROVING_FOCUS_COLLECTION_INJECTION_KEY","computed","composeRefs","composeEventHandlers","EVENT_CODE","unref","FIRST_LAST_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