-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathcontext.ts
23 lines (19 loc) · 852 Bytes
/
context.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type { InjectionKey } from 'vue';
import { inject, provide } from 'vue';
import type { RadioGroupContext, RadioOptionTypeContextProps } from './interface';
const radioGroupContextKey: InjectionKey<RadioGroupContext> = Symbol('radioGroupContextKey');
export const useProvideRadioGroupContext = (props: RadioGroupContext) => {
provide(radioGroupContextKey, props);
};
export const useInjectRadioGroupContext = () => {
return inject(radioGroupContextKey, undefined);
};
const radioOptionTypeContextKey: InjectionKey<RadioOptionTypeContextProps> = Symbol(
'radioOptionTypeContextKey',
);
export const useProvideRadioOptionTypeContext = (props: RadioOptionTypeContextProps) => {
provide(radioOptionTypeContextKey, props);
};
export const useInjectRadioOptionTypeContext = () => {
return inject(radioOptionTypeContextKey, undefined);
};