import { EyeIcon, EyeOffIcon } from '@heroicons/react/solid'; import { Field } from 'formik'; import React, { useState } from 'react'; interface CustomInputProps extends React.ComponentProps<'input'> { as?: 'input'; } interface CustomFieldProps extends React.ComponentProps { as?: 'field'; } type SensitiveInputProps = CustomInputProps | CustomFieldProps; const SensitiveInput: React.FC = ({ as = 'input', ...props }) => { const [isHidden, setHidden] = useState(true); const Component = as === 'input' ? 'input' : Field; const componentProps = as === 'input' ? props : { ...props, as: props.type === 'textarea' && !isHidden ? 'textarea' : undefined, }; return ( <> ); }; export default SensitiveInput;