UNPKG

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