import type { InjectionKey, Ref } from 'vue'; import { computed, inject, ref, provide } from 'vue'; export type DisabledType = boolean | undefined; const DisabledContextKey: InjectionKey> = Symbol('DisabledContextKey'); export const useInjectDisabled = () => { return inject(DisabledContextKey, ref(undefined)); }; export const useProviderDisabled = (disabled: Ref) => { const parentDisabled = useInjectDisabled(); provide( DisabledContextKey, computed(() => disabled.value ?? parentDisabled.value), ); return disabled; };