/* eslint-disable */ // @ts-nocheck import { FormHelperText, HelperText, HelperTextItem, TextInput, TextInputProps, ValidatedOptions, } from "../../@patternfly/react-core"; import { ReactNode } from "react"; import { FieldPath, FieldValues, PathValue, UseControllerProps, useController, } from "react-hook-form"; import { getRuleValue } from "../utils/getRuleValue"; import { FormLabel } from "./FormLabel"; export type TextControlProps< T extends FieldValues, P extends FieldPath = FieldPath, > = UseControllerProps & Omit & { label: string; labelIcon?: string | ReactNode; isDisabled?: boolean; helperText?: string; "data-testid"?: string; type?: string; }; export const TextControl = < T extends FieldValues, P extends FieldPath = FieldPath, >( props: TextControlProps, ) => { const { labelIcon, helperText, ...rest } = props; const required = !!getRuleValue(props.rules?.required); const defaultValue = props.defaultValue ?? ("" as PathValue); const { field, fieldState } = useController({ ...props, defaultValue, }); return ( {helperText && ( {helperText} )} ); };