Files
heroui-vue/packages/vue/src/components/field/disabled.ts
T
2026-10-22 08:46:02 +08:00

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));
}