{"version":3,"file":"dropdown-item.js","sources":["../../../../../../packages/components/dropdown/src/dropdown-item.vue"],"sourcesContent":["<template>\n  <el-dropdown-collection-item\n    :disabled=\"disabled\"\n    :text-value=\"textValue ?? textContent\"\n  >\n    <el-roving-focus-item :focusable=\"!disabled\">\n      <el-dropdown-item-impl\n        v-bind=\"propsAndAttrs\"\n        @pointerleave=\"handlePointerLeave\"\n        @pointermove=\"handlePointerMove\"\n        @clickimpl=\"handleClick\"\n      >\n        <slot />\n      </el-dropdown-item-impl>\n    </el-roving-focus-item>\n  </el-dropdown-collection-item>\n</template>\n<script lang=\"ts\">\nimport {\n  computed,\n  defineComponent,\n  getCurrentInstance,\n  inject,\n  ref,\n  unref,\n} from 'vue'\nimport { ElRovingFocusItem } from '@element-plus/components/roving-focus-group'\nimport { composeEventHandlers, whenMouse } from '@element-plus/utils'\nimport ElDropdownItemImpl from './dropdown-item-impl.vue'\nimport { useDropdown } from './useDropdown'\nimport {\n  ElCollectionItem as ElDropdownCollectionItem,\n  dropdownItemProps,\n} from './dropdown'\nimport { DROPDOWN_INJECTION_KEY } from './tokens'\n\nexport default defineComponent({\n  name: 'ElDropdownItem',\n  components: {\n    ElDropdownCollectionItem,\n    ElRovingFocusItem,\n    ElDropdownItemImpl,\n  },\n  inheritAttrs: false,\n  props: dropdownItemProps,\n  emits: ['pointermove', 'pointerleave', 'click'],\n  setup(props, { emit, attrs }) {\n    const { elDropdown } = useDropdown()\n    const _instance = getCurrentInstance()\n    const itemRef = ref<HTMLElement | null>(null)\n    const textContent = computed(() => unref(itemRef)?.textContent ?? '')\n    const { onItemEnter, onItemLeave } = inject(\n      DROPDOWN_INJECTION_KEY,\n      undefined\n    )!\n\n    const handlePointerMove = composeEventHandlers(\n      (e: PointerEvent) => {\n        emit('pointermove', e)\n        return e.defaultPrevented\n      },\n      whenMouse((e) => {\n        if (props.disabled) {\n          onItemLeave(e)\n          return\n        }\n\n        const target = e.currentTarget as HTMLElement\n        /**\n         * This handles the following scenario:\n         *   when the item contains a form element such as input element\n         *   when the mouse is moving over the element itself which is contained by\n         *   the item, the default focusing logic should be prevented so that\n         *   it won't cause weird action.\n         */\n        if (\n          target === document.activeElement ||\n          target.contains(document.activeElement)\n        ) {\n          return\n        }\n\n        onItemEnter(e)\n        if (!e.defaultPrevented) {\n          target?.focus()\n        }\n      })\n    )\n\n    const handlePointerLeave = composeEventHandlers((e: PointerEvent) => {\n      emit('pointerleave', e)\n      return e.defaultPrevented\n    }, whenMouse(onItemLeave))\n\n    const handleClick = composeEventHandlers(\n      (e: PointerEvent) => {\n        if (props.disabled) {\n          return\n        }\n        emit('click', e)\n        return e.type !== 'keydown' && e.defaultPrevented\n      },\n      (e) => {\n        if (props.disabled) {\n          e.stopImmediatePropagation()\n          return\n        }\n        if (elDropdown?.hideOnClick?.value) {\n          elDropdown.handleClick?.()\n        }\n        elDropdown.commandHandler?.(props.command, _instance, e)\n      }\n    )\n\n    // direct usage of v-bind={ ...$props, ...$attrs } causes type errors\n    const propsAndAttrs = computed(() => ({ ...props, ...attrs }))\n\n    return {\n      handleClick,\n      handlePointerMove,\n      handlePointerLeave,\n      textContent,\n      propsAndAttrs,\n    }\n  },\n})\n</script>\n"],"names":["defineComponent","ElDropdownCollectionItem","ElRovingFocusItem","ElDropdownItemImpl","dropdownItemProps","useDropdown","getCurrentInstance","ref","computed","unref","inject","DROPDOWN_INJECTION_KEY","composeEventHandlers","whenMouse","_resolveComponent","_openBlock","_createBlock","_withCtx","_createVNode","_mergeProps"],"mappings":";;;;;;;;;;;;;;;AAoCA,MAAK,YAAaA,mBAAa,CAAA;AAAA,EAC7B,IAAM,EAAA,gBAAA;AAAA,EACN,UAAY,EAAA;AAAA,8BACVC,yBAAA;AAAA,uBACAC,0BAAA;AAAA,wBACAC,2BAAA;AAAA,GACF;AAAA,EACA,YAAc,EAAA,KAAA;AAAA,EACd,KAAO,EAAAC,0BAAA;AAAA,EACP,KAAO,EAAA,CAAC,aAAe,EAAA,cAAA,EAAgB,OAAO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