1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-09 11:14:29 +02:00
unleash.unleash/frontend/src/component/common/Input/Input.tsx
2022-02-11 00:43:23 +01:00

57 lines
1.4 KiB
TypeScript

import { TextField } from '@material-ui/core';
import { INPUT_ERROR_TEXT } from '../../../testIds';
import { useStyles } from './Input.styles.ts';
interface IInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
label: string;
error?: boolean;
errorText?: string;
style?: Object;
className?: string;
value: string;
onChange: (e: any) => any;
onFocus?: (e: any) => any;
onBlur?: (e: any) => any;
multiline?: boolean;
rows?: number;
}
const Input = ({
label,
placeholder,
error,
errorText,
style,
className,
value,
onChange,
...rest
}: IInputProps) => {
const styles = useStyles();
return (
<div className={styles.inputContainer} data-loading>
<TextField
size="small"
variant="outlined"
label={label}
placeholder={placeholder}
error={error}
helperText={errorText}
style={style}
className={className ? className : ''}
value={value}
onChange={onChange}
FormHelperTextProps={{
['data-test']: INPUT_ERROR_TEXT,
classes: {
root: styles.helperText,
},
}}
{...rest}
/>
</div>
);
};
export default Input;