Files
element-plus/packages/components/select-v2/src/useOption.ts
dopamine cd517d6743 chore(components): [select-v2] remove ts-nocheck comments in select-v2 (#16746)
* chore: remove ts-nocheck comments in select-v2

* take the review comments

* improve emits type

* the keys of emits use camelCase instead of kebab-case

* apply suggestions from code review

Co-authored-by: btea <2356281422@qq.com>

* reduce duplicate ESLint comments

* use more succinct syntax to define props

* revert emits to kebab-case

* fix: type checking failed

* chore: illustrate why return early in validateIcon

* fix: signature with duplicate parameter names

Co-authored-by: qiang <qw13131wang@gmail.com>

---------

Co-authored-by: btea <2356281422@qq.com>
Co-authored-by: qiang <qw13131wang@gmail.com>
2024-09-23 13:45:35 +08:00

21 lines
427 B
TypeScript

import type { IOptionV2Props } from './token'
import type { OptionEmitFn } from './defaults'
export function useOption(
props: IOptionV2Props,
{ emit }: { emit: OptionEmitFn }
) {
return {
hoverItem: () => {
if (!props.disabled) {
emit('hover', props.index)
}
},
selectOptionClick: () => {
if (!props.disabled) {
emit('select', props.item, props.index)
}
},
}
}