/* eslint-disable */ // @ts-nocheck import { FileUpload, ValidatedOptions, FileUploadProps, } from "../../@patternfly/react-core"; import { ReactNode, useState } from "react"; import { FieldPath, FieldValues, PathValue, UseControllerProps, useController, } from "react-hook-form"; import { getRuleValue } from "../utils/getRuleValue"; import { FormLabel } from "./FormLabel"; import { useTranslation } from "react-i18next"; export type FileUploadControlProps< T extends FieldValues, P extends FieldPath = FieldPath, > = UseControllerProps & Omit & { label: string; labelIcon?: string | ReactNode; isDisabled?: boolean; "data-testid"?: string; type?: string; }; export const FileUploadControl = < T extends FieldValues, P extends FieldPath = FieldPath, >( props: FileUploadControlProps, ) => { const { labelIcon, ...rest } = props; const required = !!getRuleValue(props.rules?.required); const defaultValue = props.defaultValue ?? ("" as PathValue); const { t } = useTranslation(); const [filename, setFilename] = useState(""); const { field, fieldState } = useController({ ...props, defaultValue, }); return ( { field.onChange(file); setFilename(file.name); }} onClearClick={() => { field.onChange(null); setFilename(""); }} {...rest} {...field} /> ); };