diff --git a/packages/components/select-v2/src/defaults.ts b/packages/components/select-v2/src/defaults.ts index b5f6c3baa2..c8d320031b 100644 --- a/packages/components/select-v2/src/defaults.ts +++ b/packages/components/select-v2/src/defaults.ts @@ -4,7 +4,13 @@ import { useEmptyValuesProps, useSizeProp, } from '@element-plus/hooks' -import { buildProps, definePropType, iconPropType } from '@element-plus/utils' +import { + buildProps, + definePropType, + iconPropType, + isNumber, +} from '@element-plus/utils' +import { CHANGE_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants' import { useTooltipContentProps } from '@element-plus/components/tooltip' import { CircleClose } from '@element-plus/icons-vue' import { tagProps } from '../../tag' @@ -12,6 +18,8 @@ import { defaultProps } from './useProps' import type { Option, OptionType } from './select.types' import type { Props } from './useProps' +import type { EmitFn } from '@element-plus/utils/vue/typescript' +import type { ExtractPropTypes } from 'vue' import type { Options, Placement, @@ -269,3 +277,24 @@ export const OptionProps = buildProps({ selected: Boolean, created: Boolean, } as const) + +/* eslint-disable @typescript-eslint/no-unused-vars */ +export const selectEmits = { + [UPDATE_MODEL_EVENT]: (val: ISelectV2Props['modelValue']) => true, + [CHANGE_EVENT]: (val: ISelectV2Props['modelValue']) => true, + 'remove-tag': (val: unknown) => true, + 'visible-change': (visible: boolean) => true, + focus: (evt: FocusEvent) => evt instanceof FocusEvent, + blur: (evt: FocusEvent) => evt instanceof FocusEvent, + clear: () => true, +} +export const optionEmits = { + hover: (index?: number) => isNumber(index), + select: (val: Option, index?: number) => true, +} +/* eslint-enable @typescript-eslint/no-unused-vars */ + +export type ISelectV2Props = ExtractPropTypes +export type IOptionV2Props = ExtractPropTypes +export type SelectEmitFn = EmitFn +export type OptionEmitFn = EmitFn diff --git a/packages/components/select-v2/src/group-item.vue b/packages/components/select-v2/src/group-item.vue index cd1cdb6cdf..594fa64071 100644 --- a/packages/components/select-v2/src/group-item.vue +++ b/packages/components/select-v2/src/group-item.vue @@ -1,16 +1,16 @@