import { TextInputProps, ValidatedOptions } from "@patternfly/react-core"; import { FieldPath, FieldValues, PathValue, useController, UseControllerProps, } from "react-hook-form"; import { KeycloakTextInput } from "../keycloak-text-input/KeycloakTextInput"; import { FormLabel } from "./FormLabel"; export type TextControlProps< T extends FieldValues, P extends FieldPath = FieldPath, > = UseControllerProps & Omit & { label: string; labelIcon?: string; isDisabled?: boolean; helperText?: string; }; export const TextControl = < T extends FieldValues, P extends FieldPath = FieldPath, >( props: TextControlProps, ) => { const { labelIcon, ...rest } = props; const required = !!props.rules?.required; const defaultValue = props.defaultValue ?? ("" as PathValue); const { field, fieldState } = useController({ ...props, defaultValue, }); return ( ); };