UNPKG

1.44 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3import React from 'react';
4import PropTypes from 'prop-types';
5import classNames from 'classnames';
6import { mapToCssModules, tagPropType } from './utils';
7var propTypes = {
8 children: PropTypes.node,
9 row: PropTypes.bool,
10 check: PropTypes.bool,
11 inline: PropTypes.bool,
12 disabled: PropTypes.bool,
13 tag: tagPropType,
14 className: PropTypes.string,
15 cssModule: PropTypes.object
16};
17var defaultProps = {
18 tag: 'div'
19};
20
21var FormGroup = function FormGroup(props) {
22 var className = props.className,
23 cssModule = props.cssModule,
24 row = props.row,
25 disabled = props.disabled,
26 check = props.check,
27 inline = props.inline,
28 Tag = props.tag,
29 attributes = _objectWithoutPropertiesLoose(props, ["className", "cssModule", "row", "disabled", "check", "inline", "tag"]);
30
31 var classes = mapToCssModules(classNames(className, row ? 'row' : false, check ? 'form-check' : 'form-group', check && inline ? 'form-check-inline' : false, check && disabled ? 'disabled' : false), cssModule);
32
33 if (Tag === 'fieldset') {
34 attributes.disabled = disabled;
35 }
36
37 return React.createElement(Tag, _extends({}, attributes, {
38 className: classes
39 }));
40};
41
42FormGroup.propTypes = propTypes;
43FormGroup.defaultProps = defaultProps;
44export default FormGroup;
\No newline at end of file