d9f11f43322a5a9dcfe70e0e5a59692592c08c39
[arvados-workbench2.git] / src / components / text-field / text-field.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from 'react';
6 import { WrappedFieldProps } from 'redux-form';
7 import { ArvadosTheme } from '../../common/custom-theme';
8 import { TextField as MaterialTextField, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
9
10 type CssRules = 'textField';
11
12 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
13     textField: {
14         marginBottom: theme.spacing.unit * 3
15     },
16 });
17
18 export const TextField = withStyles(styles)((props: WrappedFieldProps & WithStyles<CssRules> & { label?: string }) =>
19     <MaterialTextField
20         helperText={props.meta.touched && props.meta.error}
21         className={props.classes.textField}
22         label={props.label}
23         disabled={props.meta.submitting}
24         error={props.meta.touched && !!props.meta.error}
25         autoComplete='off'
26         fullWidth={true}
27         {...props.input}
28     />);