import { Field } from "formik"; import { classNames } from "../../utils"; import { EyeIcon, EyeOffIcon } from "@heroicons/react/solid"; import { useToggle } from "../../hooks/hooks"; type COL_WIDTHS = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; interface TextFieldProps { name: string; label?: string; placeholder?: string; columns?: COL_WIDTHS; autoComplete?: string; } export const TextField = ({ name, label, placeholder, columns, autoComplete }: TextFieldProps) => (
{label && ( )} {({ field, meta, }: any) => (
{meta.touched && meta.error && (
{meta.error}
)}
)}
) interface PasswordFieldProps { name: string; label?: string; placeholder?: string; columns?: COL_WIDTHS; autoComplete?: string; defaultValue?: string; help?: string; required?: boolean; } export const PasswordField = ({ name, label, placeholder, defaultValue, columns, autoComplete, help, required }: PasswordFieldProps) => { const [isVisible, toggleVisibility] = useToggle(false) return (
{label && ( )} {({ field, meta, }: any) => (
{!isVisible ?
{help && (

{help}

)} {meta.touched && meta.error && (
{meta.error}
)}
)}
) } interface NumberFieldProps { name: string; label?: string; placeholder?: string; } export const NumberField = ({ name, label, placeholder }: NumberFieldProps) => (
{({ field, meta, }: any) => (
{meta.touched && meta.error && (
{meta.error}
)}
)}
);