2023-12-15 17:34:50 +03:00
|
|
|
import clsx from 'clsx';
|
2023-08-10 14:13:34 +03:00
|
|
|
|
2023-12-18 19:42:27 +03:00
|
|
|
import { CProps } from '../props';
|
2023-07-15 17:46:19 +03:00
|
|
|
import Label from './Label';
|
|
|
|
|
2023-12-28 14:04:44 +03:00
|
|
|
export interface TextAreaProps extends CProps.Editor, CProps.Colors, CProps.TextArea {
|
|
|
|
dense?: boolean;
|
2024-05-12 13:58:28 +03:00
|
|
|
noResize?: boolean;
|
2023-07-15 17:46:19 +03:00
|
|
|
}
|
|
|
|
|
2023-07-20 17:11:03 +03:00
|
|
|
function TextArea({
|
2023-12-28 14:04:44 +03:00
|
|
|
id,
|
|
|
|
label,
|
|
|
|
required,
|
|
|
|
rows,
|
|
|
|
dense,
|
|
|
|
noBorder,
|
|
|
|
noOutline,
|
2024-05-12 13:58:28 +03:00
|
|
|
noResize,
|
2023-12-18 12:25:39 +03:00
|
|
|
className,
|
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-28 14:04:44 +03:00
|
|
|
<div
|
2023-12-15 17:34:50 +03:00
|
|
|
className={clsx(
|
|
|
|
{
|
2023-12-28 14:04:44 +03:00
|
|
|
'flex flex-col gap-2': !dense,
|
|
|
|
'flex items-center gap-3': dense
|
2023-12-15 17:34:50 +03:00
|
|
|
},
|
2023-12-28 14:04:44 +03:00
|
|
|
dense && className
|
2023-12-15 17:34:50 +03:00
|
|
|
)}
|
2023-12-28 14:04:44 +03:00
|
|
|
>
|
|
|
|
<Label text={label} htmlFor={id} />
|
|
|
|
<textarea
|
|
|
|
id={id}
|
|
|
|
className={clsx(
|
|
|
|
'px-3 py-2',
|
|
|
|
'leading-tight',
|
2024-05-12 13:58:28 +03:00
|
|
|
'overflow-x-hidden overflow-y-auto',
|
2023-12-28 14:04:44 +03:00
|
|
|
{
|
2024-05-12 13:58:28 +03:00
|
|
|
'resize-none': noResize,
|
2023-12-28 14:04:44 +03:00
|
|
|
'border': !noBorder,
|
2024-05-11 20:53:36 +03:00
|
|
|
'flex-grow max-w-full': dense,
|
2023-12-28 14:04:44 +03:00
|
|
|
'clr-outline': !noOutline
|
|
|
|
},
|
|
|
|
colors,
|
|
|
|
!dense && className
|
|
|
|
)}
|
|
|
|
rows={rows}
|
|
|
|
required={required}
|
|
|
|
{...restProps}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
2023-07-15 17:46:19 +03:00
|
|
|
}
|
|
|
|
|
2023-12-28 14:04:44 +03:00
|
|
|
export default TextArea;
|