10 lines
459 B
TypeScript
10 lines
459 B
TypeScript
import { computed, inject, type ComputedRef, type InjectionKey } from "vue";
|
|
|
|
/** Semantic disabled scope, including controls with no native disabled attribute. */
|
|
export const disabledContextKey: InjectionKey<ComputedRef<boolean>> =
|
|
Symbol("HeroUIVue.Disabled");
|
|
export function useInheritedDisabled(local: () => unknown = () => false) {
|
|
const parent = inject(disabledContextKey, undefined);
|
|
return computed(() => Boolean(local() || parent?.value));
|
|
}
|