1 | var _excluded = ["className", "cssModule", "row", "disabled", "check", "inline", "floating", "noMargin", "tag", "switch"];
|
2 | function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
3 | function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
4 | function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
5 | import React from 'react';
|
6 | import PropTypes from 'prop-types';
|
7 | import classNames from 'classnames';
|
8 | import { mapToCssModules, tagPropType } from './utils';
|
9 | var propTypes = {
|
10 | children: PropTypes.node,
|
11 | row: PropTypes.bool,
|
12 | check: PropTypes.bool,
|
13 | "switch": PropTypes.bool,
|
14 | inline: PropTypes.bool,
|
15 | floating: PropTypes.bool,
|
16 | noMargin: PropTypes.bool,
|
17 | disabled: PropTypes.bool,
|
18 | tag: tagPropType,
|
19 | className: PropTypes.string,
|
20 | cssModule: PropTypes.object
|
21 | };
|
22 | function FormGroup(props) {
|
23 | var className = props.className,
|
24 | cssModule = props.cssModule,
|
25 | row = props.row,
|
26 | disabled = props.disabled,
|
27 | check = props.check,
|
28 | inline = props.inline,
|
29 | floating = props.floating,
|
30 | noMargin = props.noMargin,
|
31 | _props$tag = props.tag,
|
32 | Tag = _props$tag === void 0 ? 'div' : _props$tag,
|
33 | switchProp = props["switch"],
|
34 | attributes = _objectWithoutProperties(props, _excluded);
|
35 | var formCheck = check || switchProp;
|
36 | var classes = mapToCssModules(classNames(className, row ? 'row' : false, formCheck ? 'form-check' : false, switchProp ? 'form-switch' : false, formCheck || noMargin ? false : 'mb-3', formCheck && inline ? 'form-check-inline' : false, formCheck && disabled ? 'disabled' : false, floating && 'form-floating'), cssModule);
|
37 | if (Tag === 'fieldset') {
|
38 | attributes.disabled = disabled;
|
39 | }
|
40 | return React.createElement(Tag, _extends({}, attributes, {
|
41 | className: classes
|
42 | }));
|
43 | }
|
44 | FormGroup.propTypes = propTypes;
|
45 | export default FormGroup; |
\ | No newline at end of file |