UNPKG

@wikimedia/codex

Version:

Codex Design System for Wikimedia

22 lines (21 loc) 998 B
import { Ref, ComputedRef } from 'vue'; import { ValidationStatusType } from '../types'; /** * Compute data based on whether it's provided by a Field component or bound to the component. * * This function returns computed values for disabled, status, and id that take into account a * value provided by a parent Field component and a value bound directly to the component as a prop * or attribute. It makes decisions about which to prioritize based on the type of data. See inline * code comments for details. * * @param disabledProp The disabled prop ref * @param statusProp The status prop ref * @param idAttr The id attribute ref * * @return An object of computed data for disabled, status, and id */ export default function useFieldData(disabledProp: Ref<boolean>, statusProp?: Ref<ValidationStatusType>, idAttr?: string): { computedDisabled: ComputedRef<boolean>; computedStatus: ComputedRef<ValidationStatusType>; computedInputId: ComputedRef<string | undefined>; };