push
31 of 39 branches covered (79.49%)
Branch coverage included in aggregate %.
13 of 17 new or added lines in 4 files covered. (76.47%)
664 of 747 relevant lines covered (88.89%)
4.85 hits per line
1 |
import { forwardRef, LegacyRef } from 'react'; |
1✔ |
2 |
import { FieldError } from 'react-hook-form'; |
1✔ |
3 |
|
1✔ |
4 |
interface InputProps { |
1✔ |
5 |
type: string; |
1✔ |
6 |
width?: string;
|
1✔ |
7 |
placeholder: string; |
1✔ |
8 |
otherStyles?: string;
|
1✔ |
9 |
error?: FieldError | undefined; |
1✔ |
10 |
} |
1✔ |
11 |
|
1✔ |
12 |
const FormInput = forwardRef(
|
1✔ |
13 |
( |
|
14 |
{ type, width, placeholder, otherStyles, error, ...props }: InputProps, |
51✔ |
15 |
ref: LegacyRef<HTMLInputElement> | undefined, |
51✔ |
16 |
) => { |
51✔ |
17 |
return (
|
51✔ |
18 |
<> |
51✔ |
19 |
<div className={`${width ? `${width}` : 'flex-1'}`}> |
|
20 |
<input |
51✔ |
21 |
type={type} |
51✔ |
22 |
placeholder={placeholder} |
51✔ |
23 |
className={`w-full bg-[#D9D9D9] ${otherStyles} outline-none text-black/75`} |
51✔ |
24 |
{...props} |
51✔ |
25 |
ref={ref} |
51✔ |
26 |
/> |
51✔ |
27 |
{error && ( |
|
NEW
|
<p className="text-[0.5rem] text-action-error text-end px-2">
|
× |
29 |
{error.message} |
× |
30 |
</p> |
× |
31 |
)} |
51✔ |
32 |
</div> |
51✔ |
33 |
</> |
51✔ |
34 |
); |
51✔ |
35 |
}, |
51✔ |
36 |
); |
1✔ |
37 |
|
1✔ |
38 |
export default FormInput; |
1✔ |