UNPKG

1.9 kBJavaScriptView Raw
1import _extends from 'babel-runtime/helpers/extends';
2import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
3import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
4import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
5import _inherits from 'babel-runtime/helpers/inherits';
6import classNames from 'classnames';
7import React from 'react';
8import PropTypes from 'prop-types';
9import elementType from 'prop-types-extra/lib/elementType';
10
11import { bsClass, prefix, splitBsProps } from './utils/bootstrapUtils';
12
13var propTypes = {
14 horizontal: PropTypes.bool,
15 inline: PropTypes.bool,
16 componentClass: elementType
17};
18
19var defaultProps = {
20 horizontal: false,
21 inline: false,
22 componentClass: 'form'
23};
24
25var Form = function (_React$Component) {
26 _inherits(Form, _React$Component);
27
28 function Form() {
29 _classCallCheck(this, Form);
30
31 return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
32 }
33
34 Form.prototype.render = function render() {
35 var _props = this.props,
36 horizontal = _props.horizontal,
37 inline = _props.inline,
38 Component = _props.componentClass,
39 className = _props.className,
40 props = _objectWithoutProperties(_props, ['horizontal', 'inline', 'componentClass', 'className']);
41
42 var _splitBsProps = splitBsProps(props),
43 bsProps = _splitBsProps[0],
44 elementProps = _splitBsProps[1];
45
46 var classes = [];
47 if (horizontal) {
48 classes.push(prefix(bsProps, 'horizontal'));
49 }
50 if (inline) {
51 classes.push(prefix(bsProps, 'inline'));
52 }
53
54 return React.createElement(Component, _extends({}, elementProps, { className: classNames(className, classes) }));
55 };
56
57 return Form;
58}(React.Component);
59
60Form.propTypes = propTypes;
61Form.defaultProps = defaultProps;
62
63export default bsClass('form', Form);
\No newline at end of file