1
1
import { flattenChildren , getPropsSlot , isValidElement } from '../../_util/props-util' ;
2
2
import PropTypes from '../../_util/vue-types' ;
3
- import type { ExtractPropTypes } from 'vue' ;
3
+ import type { ExtractPropTypes , PropType } from 'vue' ;
4
4
import { computed , defineComponent , getCurrentInstance , onBeforeUnmount , ref , watch } from 'vue' ;
5
5
import { useInjectKeyPath , useMeasure } from './hooks/useKeyPath' ;
6
6
import { useInjectFirstLevel , useInjectMenu } from './hooks/useMenuContext' ;
@@ -11,24 +11,30 @@ import KeyCode from '../../_util/KeyCode';
11
11
import useDirectionStyle from './hooks/useDirectionStyle' ;
12
12
import Overflow from '../../vc-overflow' ;
13
13
import devWarning from '../../vc-util/devWarning' ;
14
+ import type { MouseEventHandler } from '../../_util/EventInterface' ;
14
15
15
16
let indexGuid = 0 ;
16
- export const menuItemProps = {
17
+ export const menuItemProps = ( ) => ( {
17
18
id : String ,
18
19
role : String ,
19
20
disabled : Boolean ,
20
21
danger : Boolean ,
21
22
title : { type : [ String , Boolean ] , default : undefined } ,
22
23
icon : PropTypes . any ,
23
- } ;
24
+ onMouseenter : Function as PropType < MouseEventHandler > ,
25
+ onMouseleave : Function as PropType < MouseEventHandler > ,
26
+ onClick : Function as PropType < MouseEventHandler > ,
27
+ onKeydown : Function as PropType < MouseEventHandler > ,
28
+ onFocus : Function as PropType < MouseEventHandler > ,
29
+ } ) ;
24
30
25
- export type MenuItemProps = Partial < ExtractPropTypes < typeof menuItemProps > > ;
31
+ export type MenuItemProps = Partial < ExtractPropTypes < ReturnType < typeof menuItemProps > > > ;
26
32
27
33
export default defineComponent ( {
28
34
name : 'AMenuItem' ,
29
35
inheritAttrs : false ,
30
- props : menuItemProps ,
31
- emits : [ 'mouseenter' , 'mouseleave' , 'click' , 'keydown' , 'focus' ] ,
36
+ props : menuItemProps ( ) ,
37
+ // emits: ['mouseenter', 'mouseleave', 'click', 'keydown', 'focus'],
32
38
slots : [ 'icon' , 'title' ] ,
33
39
setup ( props , { slots, emit, attrs } ) {
34
40
const instance = getCurrentInstance ( ) ;
0 commit comments