2022-02-07 23:22:35 +01:00
|
|
|
export interface TextInputControlPropsNoLabel {
|
|
|
|
onChange?: (data: string) => void;
|
|
|
|
value?: string;
|
2022-02-10 23:45:17 +01:00
|
|
|
placeholder?: string;
|
|
|
|
className?: string;
|
2022-02-07 23:22:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface TextInputControlProps extends TextInputControlPropsNoLabel {
|
|
|
|
label?: string;
|
|
|
|
}
|
|
|
|
|
2022-02-10 23:45:17 +01:00
|
|
|
export function TextInputControl({
|
|
|
|
onChange,
|
|
|
|
value,
|
|
|
|
label,
|
|
|
|
className,
|
|
|
|
placeholder,
|
|
|
|
}: TextInputControlProps) {
|
|
|
|
const input = (
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
className={className}
|
|
|
|
placeholder={placeholder}
|
|
|
|
onChange={(e) => onChange && onChange(e.target.value)}
|
|
|
|
value={value}
|
|
|
|
/>
|
|
|
|
);
|
2022-02-07 23:22:35 +01:00
|
|
|
|
|
|
|
if (label) {
|
|
|
|
return (
|
|
|
|
<label>
|
|
|
|
<span>{label}</span>
|
|
|
|
{input}
|
|
|
|
</label>
|
2022-02-10 23:45:17 +01:00
|
|
|
);
|
2022-02-07 23:22:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return input;
|
|
|
|
}
|