1 | import classnames from 'classnames';
|
2 | import React, { PropTypes} from 'react';
|
3 |
|
4 | const propTypes = {
|
5 | validationState: PropTypes.oneOf(['success', 'warning', 'error'])
|
6 | };
|
7 | const defaultProps = {
|
8 | clsPrefix: 'u-form-group'
|
9 | }
|
10 |
|
11 | class FormGroup extends React.Component {
|
12 | constructor(props) {
|
13 | super(props);
|
14 | }
|
15 | render() {
|
16 | const { validationState, className, children,clsPrefix, ...others } = this.props;
|
17 |
|
18 | let classes = {};
|
19 |
|
20 | if(validationState){
|
21 | classes[`has-${validationState}`] = true;
|
22 | }
|
23 |
|
24 | let classNames = classnames(clsPrefix,classes);
|
25 |
|
26 | return (
|
27 | <div
|
28 | {...others}
|
29 | className={classnames(className,classNames)}
|
30 | >
|
31 | {children}
|
32 | </div>
|
33 | );
|
34 | }
|
35 | }
|
36 |
|
37 | FormGroup.propTypes = propTypes;
|
38 | FormGroup.defaultProps = defaultProps;
|
39 |
|
40 | export default FormGroup
|