|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
import type { Key } from '../../../_util/type'; |
|
|
|
|
import type { ComputedRef, CSSProperties, InjectionKey, Ref, UnwrapRef } from 'vue'; |
|
|
|
|
import type { ComputedRef, CSSProperties, InjectionKey, PropType, Ref, UnwrapRef } from 'vue'; |
|
|
|
|
import { toRef } from 'vue'; |
|
|
|
|
import { watchEffect } from 'vue'; |
|
|
|
|
import { defineComponent, inject, provide } from 'vue'; |
|
|
|
|
import type { |
|
|
|
|
BuiltinPlacements, |
|
|
|
@ -31,8 +33,6 @@ export interface MenuContextProps {
|
|
|
|
|
selectedSubMenuEventKeys: Ref<string[]>; |
|
|
|
|
rtl?: ComputedRef<boolean>; |
|
|
|
|
|
|
|
|
|
locked?: Ref<boolean>; |
|
|
|
|
|
|
|
|
|
inlineCollapsed: Ref<boolean>; |
|
|
|
|
antdMenuTheme?: ComputedRef<MenuTheme>; |
|
|
|
|
|
|
|
|
@ -44,7 +44,7 @@ export interface MenuContextProps {
|
|
|
|
|
// // Disabled
|
|
|
|
|
disabled?: ComputedRef<boolean>; |
|
|
|
|
// // Used for overflow only. Prevent hidden node trigger open
|
|
|
|
|
overflowDisabled?: ComputedRef<boolean>; |
|
|
|
|
overflowDisabled?: Ref<boolean>; |
|
|
|
|
|
|
|
|
|
// // Active
|
|
|
|
|
activeKeys: Ref<Key[]>; |
|
|
|
@ -108,10 +108,25 @@ const MenuContextProvider = defineComponent({
|
|
|
|
|
name: 'MenuContextProvider', |
|
|
|
|
inheritAttrs: false, |
|
|
|
|
props: { |
|
|
|
|
props: Object, |
|
|
|
|
mode: { type: String as PropType<MenuMode>, default: undefined }, |
|
|
|
|
overflowDisabled: { type: Boolean, default: undefined }, |
|
|
|
|
isRootMenu: { type: Boolean, default: undefined }, |
|
|
|
|
}, |
|
|
|
|
setup(props, { slots }) { |
|
|
|
|
useProvideMenu({ ...useInjectMenu(), ...props.props }); |
|
|
|
|
const menuContext = useInjectMenu(); |
|
|
|
|
const newContext = { ...menuContext }; |
|
|
|
|
watchEffect(() => { |
|
|
|
|
if (props.mode !== undefined) { |
|
|
|
|
newContext.mode = toRef(props, 'mode'); |
|
|
|
|
} |
|
|
|
|
if (props.isRootMenu !== undefined) { |
|
|
|
|
newContext.isRootMenu = props.isRootMenu; |
|
|
|
|
} |
|
|
|
|
if (props.overflowDisabled !== undefined) { |
|
|
|
|
newContext.overflowDisabled = toRef(props, 'overflowDisabled'); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
useProvideMenu(newContext); |
|
|
|
|
return () => slots.default?.(); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|