2023-12-15 17:34:50 +03:00
|
|
|
import clsx from 'clsx';
|
2023-08-10 14:13:34 +03:00
|
|
|
import { TextareaHTMLAttributes } from 'react';
|
|
|
|
|
2023-12-13 14:32:57 +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-11-27 13:50:56 +03:00
|
|
|
...restProps
|
2023-07-20 17:11:03 +03:00
|
|
|
}: TextAreaProps) {
|
2023-07-15 17:46:19 +03:00
|
|
|
return (
|
2023-12-15 17:34:50 +03:00
|
|
|
<div className={clsx(
|
|
|
|
{
|
|
|
|
'flex items-center gap-3': dense,
|
|
|
|
'flex flex-col items-start gap-2': !dense
|
|
|
|
},
|
|
|
|
dense && dimensions,
|
|
|
|
)}>
|
|
|
|
<Label text={label} htmlFor={id} />
|
2023-12-05 01:22:44 +03:00
|
|
|
<textarea id={id}
|
|
|
|
title={tooltip}
|
2023-12-15 17:34:50 +03:00
|
|
|
className={clsx(
|
|
|
|
'px-3 py-2',
|
|
|
|
'leading-tight',
|
|
|
|
{
|
|
|
|
'w-full': dense,
|
|
|
|
'border': !noBorder,
|
|
|
|
'clr-outline': !noOutline
|
|
|
|
},
|
|
|
|
colors,
|
|
|
|
!dense && dimensions
|
|
|
|
)}
|
2023-12-05 01:22:44 +03:00
|
|
|
rows={rows}
|
|
|
|
required={required}
|
|
|
|
{...restProps}
|
|
|
|
/>
|
|
|
|
</div>);
|
2023-07-15 17:46:19 +03:00
|
|
|
}
|
|
|
|
|
2023-12-13 14:32:57 +03:00
|
|
|
export default TextArea;
|