forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm.js
More file actions
51 lines (42 loc) · 1.03 KB
/
Form.js
File metadata and controls
51 lines (42 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import classNames from 'classnames';
import React from 'react';
import elementType from 'react-prop-types/lib/elementType';
import { bsClass, prefix, splitBsProps } from './utils/bootstrapUtils';
const propTypes = {
horizontal: React.PropTypes.bool,
inline: React.PropTypes.bool,
componentClass: elementType,
};
const defaultProps = {
horizontal: false,
inline: false,
componentClass: 'form',
};
class Form extends React.Component {
render() {
const {
horizontal,
inline,
componentClass: Component,
className,
...props
} = this.props;
const [bsProps, elementProps] = splitBsProps(props);
const classes = [];
if (horizontal) {
classes.push(prefix(bsProps, 'horizontal'));
}
if (inline) {
classes.push(prefix(bsProps, 'inline'));
}
return (
<Component
{...elementProps}
className={classNames(className, classes)}
/>
);
}
}
Form.propTypes = propTypes;
Form.defaultProps = defaultProps;
export default bsClass('form', Form);