diff --git a/libs/core-components/src/lib/FieldWrapperFormik/FieldWrapperFormik.tsx b/libs/core-components/src/lib/FieldWrapperFormik/FieldWrapperFormik.tsx index 96a2dc6a9..b61ee766e 100644 --- a/libs/core-components/src/lib/FieldWrapperFormik/FieldWrapperFormik.tsx +++ b/libs/core-components/src/lib/FieldWrapperFormik/FieldWrapperFormik.tsx @@ -1,42 +1,42 @@ import React from 'react'; -import { ErrorMessage } from 'formik'; +import { FieldProps } from 'formik'; import { Badge } from 'reactstrap'; import './FieldWrapperFormik.global.css'; export type FieldWrapperProps = { - name: string; + id?: string; label: React.ReactNode; required?: boolean; className?: string; description?: React.ReactNode; + formik: FieldProps; }; + const FieldWrapper: React.FC> = ({ - name, + id, label, required, description, className, children, + formik: {field, form}, }) => { return (
-
); diff --git a/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikFileInput/FileDropzone.tsx b/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikFileInput/FileDropzone.tsx index f85d3b974..7ee0ea8c1 100644 --- a/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikFileInput/FileDropzone.tsx +++ b/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikFileInput/FileDropzone.tsx @@ -5,6 +5,7 @@ import { InlineMessage, Button } from '../../../..'; import styles from './FileDropzone.module.css'; interface FileInputDropzoneProps { + id: string; files: File[]; onDrop: (files: File[]) => void; onRemoveFile: (index: number) => void; @@ -18,6 +19,7 @@ interface FileInputDropzoneProps { * and user can manage (e.g. delete those files) directly in this component. */ const FileInputDropZone: React.FC = ({ + id, files, onDrop, maxSize, @@ -60,7 +62,7 @@ const FileInputDropZone: React.FC = ({ return ( // eslint-disable-next-line react/jsx-props-no-spreading
- + {!showFileList && (
diff --git a/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikFileInput/FormikFileInput.tsx b/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikFileInput/FormikFileInput.tsx index e44a5e506..5f71bc6bf 100644 --- a/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikFileInput/FormikFileInput.tsx +++ b/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikFileInput/FormikFileInput.tsx @@ -1,27 +1,32 @@ /* FP-993: Allow use by DataFilesUploadModal */ import React from 'react'; -import { useField } from 'formik'; +import { useField, FieldProps } from 'formik'; import FileInputDropZone from './FileDropzone'; import FieldWrapper from '../../FieldWrapperFormik'; -interface FormikFileInputProps { +interface FormikFileInputProps extends FieldProps { + id: string; name: string; label: string; required: boolean; description: string; maxSizeMessage: string; maxSize: number; -} +}; const FileInputDropZoneFormField: React.FC = ({ + id, name, label, description, maxSizeMessage, maxSize, required, + field, + form, + meta, }) => { - const [field, , helpers] = useField(name); + const [, , helpers] = useField(name); const onSetFiles = (acceptedFiles: File[]) => { const newAcceptedFiles = acceptedFiles.filter( @@ -35,12 +40,14 @@ const FileInputDropZoneFormField: React.FC = ({ }; return ( = ({ + id, name, label, required, description, + field, + form, + meta, ...props }: FormikInputProps) => { - const [field] = useField(name); return ( - + ); }; diff --git a/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikSelect.tsx b/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikSelect.tsx index 30ac325f2..101425671 100644 --- a/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikSelect.tsx +++ b/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikSelect.tsx @@ -1,25 +1,28 @@ import React from 'react'; import FieldWrapper from '../FieldWrapperFormik'; -import { useField } from 'formik'; import { FormikSelectProps } from '.'; const FormikTextarea: React.FC = ({ + id, name, label, required, description, children, + field, + form, + meta, ...props }: FormikSelectProps) => { - const [field] = useField(name); return ( - {children} diff --git a/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikTextarea.tsx b/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikTextarea.tsx index 0e1a5972c..2951ca8e7 100644 --- a/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikTextarea.tsx +++ b/libs/core-components/src/lib/FieldWrapperFormik/fields/FormikTextarea.tsx @@ -1,24 +1,27 @@ import React from 'react'; import FieldWrapper from '../FieldWrapperFormik'; -import { useField } from 'formik'; import { FormikTextareaProps } from '.'; const FormikTextarea: React.FC = ({ + id, name, label, required, description, + field, + form, + meta, ...props }: FormikTextareaProps) => { - const [field] = useField(name); return ( -