mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-05 05:29:01 +08:00
a2f7d6d062
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.
49 lines
1.2 KiB
TypeScript
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),
|
|
);
|
|
};
|