2023-08-10 14:13:34 +03:00
|
|
|
import { TextareaHTMLAttributes } from 'react';
|
|
|
|
|
2023-11-05 16:31:49 +03:00
|
|
|
import { IColorsProps, IEditorProps } from '../commonInterfaces';
|
2023-07-15 17:46:19 +03:00
|
|
|
import Label from './Label';
|
|
|
|
|
2023-08-23 22:57:25 +03:00
|
|
|
export interface TextAreaProps
|
2023-11-05 16:31:49 +03:00
|
|
|
extends IEditorProps, IColorsProps, Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'className' | 'title'> {
|
2023-10-23 18:22:55 +03:00
|
|
|
dense?: boolean
|
2023-07-15 17:46:19 +03:00
|
|
|
}
|
|
|
|
|
2023-07-20 17:11:03 +03:00
|
|
|
function TextArea({
|
2023-11-10 15:34:59 +03:00
|
|
|
id, label, required, tooltip, rows,
|
|
|
|
dense, noBorder, noOutline,
|
2023-09-15 23:29:52 +03:00
|
|
|
dimensions = 'w-full',
|
2023-11-05 16:31:49 +03:00
|
|
|
colors = 'clr-input',
|
2023-08-10 14:13:34 +03:00
|
|
|
...props
|
2023-07-20 17:11:03 +03:00
|
|
|
}: TextAreaProps) {
|
2023-11-05 16:31:49 +03:00
|
|
|
const borderClass = noBorder ? '': 'border';
|
|
|
|
const outlineClass = noOutline ? '': 'clr-outline';
|
2023-07-15 17:46:19 +03:00
|
|
|
return (
|
2023-10-23 18:22:55 +03:00
|
|
|
<div className={`flex ${dense ? 'items-center gap-4 ' + dimensions : 'flex-col items-start gap-2'}`}>
|
2023-10-14 23:46:36 +03:00
|
|
|
{label &&
|
|
|
|
<Label
|
2023-07-15 17:46:19 +03:00
|
|
|
text={label}
|
|
|
|
htmlFor={id}
|
2023-09-15 23:29:52 +03:00
|
|
|
/>}
|
2023-07-20 17:11:03 +03:00
|
|
|
<textarea id={id}
|
2023-08-26 17:26:49 +03:00
|
|
|
title={tooltip}
|
2023-11-05 16:31:49 +03:00
|
|
|
className={`px-3 py-2 leading-tight ${outlineClass} ${borderClass} ${colors} ${dense ? 'w-full' : dimensions}`}
|
2023-08-26 17:26:49 +03:00
|
|
|
rows={rows}
|
|
|
|
required={required}
|
|
|
|
{...props}
|
2023-07-15 17:46:19 +03:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-07-25 20:27:29 +03:00
|
|
|
export default TextArea;
|