1
1
import type { Key } from '../../../_util/type' ;
2
- import type { ComputedRef , CSSProperties , InjectionKey , Ref , UnwrapRef } from 'vue' ;
2
+ import type { ComputedRef , CSSProperties , InjectionKey , PropType , Ref , UnwrapRef } from 'vue' ;
3
+ import { toRef } from 'vue' ;
4
+ import { watchEffect } from 'vue' ;
3
5
import { defineComponent , inject , provide } from 'vue' ;
4
6
import type {
5
7
BuiltinPlacements ,
@@ -31,8 +33,6 @@ export interface MenuContextProps {
31
33
selectedSubMenuEventKeys : Ref < string [ ] > ;
32
34
rtl ?: ComputedRef < boolean > ;
33
35
34
- locked ?: Ref < boolean > ;
35
-
36
36
inlineCollapsed : Ref < boolean > ;
37
37
antdMenuTheme ?: ComputedRef < MenuTheme > ;
38
38
@@ -44,7 +44,7 @@ export interface MenuContextProps {
44
44
// // Disabled
45
45
disabled ?: ComputedRef < boolean > ;
46
46
// // Used for overflow only. Prevent hidden node trigger open
47
- overflowDisabled ?: ComputedRef < boolean > ;
47
+ overflowDisabled ?: Ref < boolean > ;
48
48
49
49
// // Active
50
50
activeKeys : Ref < Key [ ] > ;
@@ -108,10 +108,25 @@ const MenuContextProvider = defineComponent({
108
108
name : 'MenuContextProvider' ,
109
109
inheritAttrs : false ,
110
110
props : {
111
- props : Object ,
111
+ mode : { type : String as PropType < MenuMode > , default : undefined } ,
112
+ overflowDisabled : { type : Boolean , default : undefined } ,
113
+ isRootMenu : { type : Boolean , default : undefined } ,
112
114
} ,
113
115
setup ( props , { slots } ) {
114
- useProvideMenu ( { ...useInjectMenu ( ) , ...props . props } ) ;
116
+ const menuContext = useInjectMenu ( ) ;
117
+ const newContext = { ...menuContext } ;
118
+ watchEffect ( ( ) => {
119
+ if ( props . mode !== undefined ) {
120
+ newContext . mode = toRef ( props , 'mode' ) ;
121
+ }
122
+ if ( props . isRootMenu !== undefined ) {
123
+ newContext . isRootMenu = props . isRootMenu ;
124
+ }
125
+ if ( props . overflowDisabled !== undefined ) {
126
+ newContext . overflowDisabled = toRef ( props , 'overflowDisabled' ) ;
127
+ }
128
+ } ) ;
129
+ useProvideMenu ( newContext ) ;
115
130
return ( ) => slots . default ?.( ) ;
116
131
} ,
117
132
} ) ;
0 commit comments