2023-07-15 17:46:19 +03:00
|
|
|
import Label from './Label';
|
|
|
|
|
|
|
|
interface TextInputProps {
|
|
|
|
id: string
|
|
|
|
type: string
|
|
|
|
label: string
|
|
|
|
required?: boolean
|
|
|
|
disabled?: boolean
|
|
|
|
placeholder?: string
|
|
|
|
widthClass?: string
|
|
|
|
value?: any
|
|
|
|
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void
|
|
|
|
}
|
|
|
|
|
|
|
|
function TextInput({id, type, required, label, disabled, placeholder, widthClass='w-full', value, onChange}: TextInputProps) {
|
|
|
|
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}
|
|
|
|
type={type}
|
|
|
|
placeholder={placeholder}
|
|
|
|
value={value}
|
|
|
|
onChange={onChange}
|
|
|
|
disabled={disabled}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TextInput;
|