2023-07-15 17:46:19 +03:00
|
|
|
import Label from './Label';
|
|
|
|
|
|
|
|
interface TextAreaProps {
|
|
|
|
id: string
|
|
|
|
label: string
|
|
|
|
required?: boolean
|
|
|
|
disabled?: boolean
|
2023-07-20 17:11:03 +03:00
|
|
|
spellCheck?: boolean
|
2023-07-15 17:46:19 +03:00
|
|
|
placeholder?: string
|
|
|
|
widthClass?: string
|
|
|
|
rows?: number
|
2023-07-26 23:11:00 +03:00
|
|
|
value?: string | ReadonlyArray<string> | number | undefined;
|
2023-07-15 17:46:19 +03:00
|
|
|
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void
|
2023-07-20 17:11:03 +03:00
|
|
|
onFocus?: () => void
|
2023-07-15 17:46:19 +03:00
|
|
|
}
|
|
|
|
|
2023-07-20 17:11:03 +03:00
|
|
|
function TextArea({
|
|
|
|
id, label, placeholder,
|
2023-07-25 20:27:29 +03:00
|
|
|
required, spellCheck, disabled,
|
|
|
|
widthClass = 'w-full', rows = 4, value,
|
2023-07-20 17:11:03 +03:00
|
|
|
onChange, onFocus
|
|
|
|
}: TextAreaProps) {
|
2023-07-15 17:46:19 +03:00
|
|
|
return (
|
|
|
|
<div className='flex flex-col items-start [&:not(:first-child)]:mt-3'>
|
2023-07-25 20:27:29 +03:00
|
|
|
<Label
|
2023-07-15 17:46:19 +03:00
|
|
|
text={label}
|
|
|
|
required={required}
|
|
|
|
htmlFor={id}
|
|
|
|
/>
|
2023-07-20 17:11:03 +03:00
|
|
|
<textarea id={id}
|
2023-08-08 23:04:21 +03:00
|
|
|
className={`px-3 py-2 mt-2 leading-tight border shadow clr-input ${widthClass}`}
|
2023-07-15 17:46:19 +03:00
|
|
|
rows={rows}
|
|
|
|
placeholder={placeholder}
|
|
|
|
required={required}
|
|
|
|
value={value}
|
|
|
|
onChange={onChange}
|
2023-07-20 17:11:03 +03:00
|
|
|
onFocus={onFocus}
|
2023-07-15 17:46:19 +03:00
|
|
|
disabled={disabled}
|
2023-07-20 17:11:03 +03:00
|
|
|
spellCheck={spellCheck}
|
2023-07-15 17:46:19 +03:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-07-25 20:27:29 +03:00
|
|
|
export default TextArea;
|