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