'use client'; import s from './input.module.scss'; import React, { InputHTMLAttributes, useState } from 'react'; import clsx from 'clsx'; type InputPropsType = { className?: string; placeholder: string; errorMessage?: string | boolean; } & InputHTMLAttributes; const Input = ({ placeholder, errorMessage, disabled, className, onChange, ...props }: InputPropsType) => { const [onFocus, setOnFocus] = useState(false); const hasValue = typeof props.value === 'string' ? props.value.length > 0 : props.value !== undefined && props.value !== null; return (
{ if (typeof props.onFocus !== 'undefined') { props.onFocus(event); } setOnFocus(true); }} onBlur={(event) => { if (typeof props.onBlur !== 'undefined') { props.onBlur(event); } setOnFocus(false); }} disabled={disabled} className={clsx(s.input__self, { [s['input--disabled']]: disabled })} />
{errorMessage && ( {errorMessage} )}
); }; export default Input;