ant-design-vue/components/float-button/context.ts
2023-03-03 16:58:47 +08:00

20 lines
580 B
TypeScript

import type { Ref, InjectionKey } from 'vue';
import { inject, provide, ref } from 'vue';
import type { FloatButtonShape } from './interface';
interface FloatButtonGroupContext {
shape: Ref<FloatButtonShape>;
}
const contextKey: InjectionKey<FloatButtonGroupContext> = Symbol('floatButtonGroupContext');
export const useProvideFloatButtonGroupContext = (props: FloatButtonGroupContext) => {
provide(contextKey, props);
return props;
};
export const useInjectFloatButtonGroupContext = () => {
return inject(contextKey, { shape: ref() } as FloatButtonGroupContext);
};