UNPKG

836 BJavaScriptView Raw
1import classnames from 'classnames';
2import React, { PropTypes} from 'react';
3
4const propTypes = {
5 validationState: PropTypes.oneOf(['success', 'warning', 'error'])
6};
7const defaultProps = {
8 clsPrefix: 'u-form-group'
9}
10
11class 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
37FormGroup.propTypes = propTypes;
38FormGroup.defaultProps = defaultProps;
39
40export default FormGroup