Files
superset2/superset/assets/javascripts/explorev2/components/TextField.jsx
Maxime Beauchemin 470a6e9d76 [explorev2] adding support for client side validators on controls (#1920)
* Adding support for client side validators on controls

* Applying validators to more fields

* Addressing comments
2017-01-12 09:21:17 -08:00

40 lines
883 B
JavaScript

import React, { PropTypes } from 'react';
import { FormGroup, FormControl } from 'react-bootstrap';
const propTypes = {
name: PropTypes.string.isRequired,
label: PropTypes.string,
description: PropTypes.string,
onChange: PropTypes.func,
value: PropTypes.string,
};
const defaultProps = {
label: null,
description: null,
onChange: () => {},
value: '',
};
export default class TextField extends React.Component {
onChange(event) {
this.props.onChange(event.target.value);
}
render() {
const value = this.props.value || '';
return (
<FormGroup controlId="formInlineName" bsSize="small">
<FormControl
type="text"
placeholder=""
onChange={this.onChange.bind(this)}
value={value}
/>
</FormGroup>
);
}
}
TextField.propTypes = propTypes;
TextField.defaultProps = defaultProps;