import React, { forwardRef } from 'react'; import { Field as FormikField, FieldProps } from 'formik'; import Input from '@/components/elements/Input'; import Label from '@/components/elements/Label'; interface OwnProps { name: string; light?: boolean; label?: string; description?: string; validate?: (value: any) => undefined | string | Promise; } type Props = OwnProps & Omit, 'name'>; const Field = forwardRef(({ id, name, light = false, label, description, validate, ...props }, ref) => ( { ({ field, form: { errors, touched } }: FieldProps) => ( <> {label && } {touched[field.name] && errors[field.name] ?

{(errors[field.name] as string).charAt(0).toUpperCase() + (errors[field.name] as string).slice(1)}

: description ?

{description}

: null } ) }
)); Field.displayName = 'Field'; export default Field;