2023-07-23 15:23:01 +03:00
|
|
|
import { InputHTMLAttributes } from 'react';
|
2023-07-15 17:46:19 +03:00
|
|
|
import Label from './Label';
|
|
|
|
|
2023-07-23 15:23:01 +03:00
|
|
|
interface TextInputProps
|
|
|
|
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'className'> {
|
2023-07-15 17:46:19 +03:00
|
|
|
id: string
|
|
|
|
label: string
|
|
|
|
widthClass?: string
|
|
|
|
}
|
|
|
|
|
2023-07-20 17:11:03 +03:00
|
|
|
function TextInput({
|
2023-07-23 15:23:01 +03:00
|
|
|
id, required, label, widthClass='w-full',
|
|
|
|
...props
|
2023-07-20 17:11:03 +03:00
|
|
|
}: TextInputProps) {
|
2023-07-15 17:46:19 +03:00
|
|
|
return (
|
|
|
|
<div className='flex flex-col items-start [&:not(:first-child)]:mt-3'>
|
|
|
|
<Label
|
|
|
|
text={label}
|
|
|
|
required={required}
|
|
|
|
htmlFor={id}
|
|
|
|
/>
|
|
|
|
<input id={id}
|
2023-07-16 20:25:55 +03:00
|
|
|
className={'px-3 py-2 mt-2 leading-tight border shadow dark:bg-gray-800 truncate hover:text-clip '+ widthClass}
|
2023-07-15 17:46:19 +03:00
|
|
|
required={required}
|
2023-07-23 15:23:01 +03:00
|
|
|
{...props}
|
2023-07-15 17:46:19 +03:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TextInput;
|