ConceptPortal-public/rsconcept/frontend/src/components/Common/TextInput.tsx

41 lines
1.0 KiB
TypeScript
Raw Normal View History

2023-07-15 17:46:19 +03:00
import Label from './Label';
2023-07-25 20:27:29 +03:00
interface TextInputProps
2023-09-07 16:30:43 +03:00
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'className' | 'title'> {
2023-09-14 16:53:38 +03:00
id?: string
label?: string
2023-08-26 17:26:49 +03:00
tooltip?: string
dimensions?: string
2023-08-10 14:13:34 +03:00
colorClass?: string
2023-10-23 18:22:55 +03:00
dense?: boolean
2023-09-29 15:33:32 +03:00
noBorder?: boolean
2023-11-04 01:29:21 +03:00
noOutline?: boolean
2023-07-15 17:46:19 +03:00
}
2023-07-20 17:11:03 +03:00
function TextInput({
2023-11-04 01:29:21 +03:00
id, required, label, dense, tooltip, noBorder, noOutline,
dimensions = 'w-full',
2023-08-10 14:13:34 +03:00
colorClass = 'clr-input',
...props
2023-07-20 17:11:03 +03:00
}: TextInputProps) {
2023-10-23 18:22:55 +03:00
const borderClass = noBorder ? '': 'border';
2023-11-04 01:29:21 +03:00
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-09-29 15:33:32 +03:00
{label &&
<Label
2023-07-15 17:46:19 +03:00
text={label}
htmlFor={id}
2023-09-14 16:53:38 +03:00
/>}
2023-07-15 17:46:19 +03:00
<input id={id}
2023-08-26 17:26:49 +03:00
title={tooltip}
2023-11-04 01:29:21 +03:00
className={`px-3 py-2 leading-tight truncate hover:text-clip ${outlineClass} ${borderClass} ${colorClass} ${dense ? 'w-full' : dimensions}`}
2023-07-15 17:46:19 +03:00
required={required}
{...props}
2023-07-15 17:46:19 +03:00
/>
</div>
);
}
2023-07-25 20:27:29 +03:00
export default TextInput;