1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 | var _react = _interopRequireDefault(require("react"));
|
8 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
9 | var _classnames = _interopRequireDefault(require("classnames"));
|
10 | var _utils = require("./utils");
|
11 | const _excluded = ["className", "cssModule", "row", "disabled", "check", "inline", "floating", "noMargin", "tag", "switch"];
|
12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13 | 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); }
|
14 | 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; }
|
15 | 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; }
|
16 | const propTypes = {
|
17 | children: _propTypes.default.node,
|
18 | row: _propTypes.default.bool,
|
19 | check: _propTypes.default.bool,
|
20 | switch: _propTypes.default.bool,
|
21 | inline: _propTypes.default.bool,
|
22 | floating: _propTypes.default.bool,
|
23 | noMargin: _propTypes.default.bool,
|
24 | disabled: _propTypes.default.bool,
|
25 | tag: _utils.tagPropType,
|
26 | className: _propTypes.default.string,
|
27 | cssModule: _propTypes.default.object
|
28 | };
|
29 | function FormGroup(props) {
|
30 | const {
|
31 | className,
|
32 | cssModule,
|
33 | row,
|
34 | disabled,
|
35 | check,
|
36 | inline,
|
37 | floating,
|
38 | noMargin,
|
39 | tag: Tag = 'div',
|
40 | switch: switchProp
|
41 | } = props,
|
42 | attributes = _objectWithoutProperties(props, _excluded);
|
43 | const formCheck = check || switchProp;
|
44 | const classes = (0, _utils.mapToCssModules)((0, _classnames.default)(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);
|
45 | if (Tag === 'fieldset') {
|
46 | attributes.disabled = disabled;
|
47 | }
|
48 | return _react.default.createElement(Tag, _extends({}, attributes, {
|
49 | className: classes
|
50 | }));
|
51 | }
|
52 | FormGroup.propTypes = propTypes;
|
53 | var _default = FormGroup;
|
54 | exports.default = _default; |
\ | No newline at end of file |