ant-design-vue/components/vc-overflow/context.ts
Garret MH a2f7d6d062
feat: Vue 3 Migration Build support (#5973), close #5765
closes vueComponent/ant-design-vue#5765

Add `compatConfig: { MODE: 3 }` to all component definitions to signal to `@vue/compat` not to use any Vue 2 compatibility features.
2022-09-26 21:33:41 +08:00

49 lines
1.2 KiB
TypeScript

import type { ComputedRef, InjectionKey, PropType } from 'vue';
import { computed, defineComponent, inject, provide } from 'vue';
import type { Key } from '../_util/type';
export interface OverflowContextProviderValueType {
prefixCls: string;
responsive: boolean;
order: number;
registerSize: (key: Key, width: number | null) => void;
display: boolean;
invalidate: boolean;
// Item Usage
item?: any;
itemKey?: Key;
// Rest Usage
className?: string;
}
const OverflowContextProviderKey: InjectionKey<
ComputedRef<OverflowContextProviderValueType | null>
> = Symbol('OverflowContextProviderKey');
export const OverflowContextProvider = defineComponent({
compatConfig: { MODE: 3 },
name: 'OverflowContextProvider',
inheritAttrs: false,
props: {
value: { type: Object as PropType<OverflowContextProviderValueType> },
},
setup(props, { slots }) {
provide(
OverflowContextProviderKey,
computed(() => props.value),
);
return () => slots.default?.();
},
});
export const useInjectOverflowContext =
(): ComputedRef<OverflowContextProviderValueType | null> => {
return inject(
OverflowContextProviderKey,
computed(() => null),
);
};