{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport classNames from 'classnames';\nimport all from 'prop-types-extra/lib/all';\nimport React, { useContext, useMemo } from 'react';\nimport Feedback from './Feedback';\nimport FormCheckInput from './FormCheckInput';\nimport FormCheckLabel from './FormCheckLabel';\nimport FormContext from './FormContext';\nimport { useBootstrapPrefix } from './ThemeProvider';\nvar defaultProps = {\n type: 'checkbox',\n inline: false,\n disabled: false,\n isValid: false,\n isInvalid: false,\n title: ''\n};\nvar FormCheck = React.forwardRef(function (_ref, ref) {\n var id = _ref.id,\n bsPrefix = _ref.bsPrefix,\n bsCustomPrefix = _ref.bsCustomPrefix,\n inline = _ref.inline,\n disabled = _ref.disabled,\n isValid = _ref.isValid,\n isInvalid = _ref.isInvalid,\n feedback = _ref.feedback,\n className = _ref.className,\n style = _ref.style,\n title = _ref.title,\n type = _ref.type,\n label = _ref.label,\n children = _ref.children,\n propCustom = _ref.custom,\n _ref$as = _ref.as,\n as = _ref$as === void 0 ? 'input' : _ref$as,\n props = _objectWithoutPropertiesLoose(_ref, [\"id\", \"bsPrefix\", \"bsCustomPrefix\", \"inline\", \"disabled\", \"isValid\", \"isInvalid\", \"feedback\", \"className\", \"style\", \"title\", \"type\", \"label\", \"children\", \"custom\", \"as\"]);\n\n var custom = type === 'switch' ? true : propCustom;\n bsPrefix = custom ? useBootstrapPrefix(bsCustomPrefix, 'custom-control') : useBootstrapPrefix(bsPrefix, 'form-check');\n\n var _useContext = useContext(FormContext),\n controlId = _useContext.controlId;\n\n var innerFormContext = useMemo(function () {\n return {\n controlId: id || controlId,\n custom: custom\n };\n }, [controlId, custom, id]);\n var hasLabel = label != null && label !== false && !children;\n var input = React.createElement(FormCheckInput, _extends({}, props, {\n type: type === 'switch' ? 'checkbox' : type,\n ref: ref,\n isValid: isValid,\n isInvalid: isInvalid,\n isStatic: !hasLabel,\n disabled: disabled,\n as: as\n }));\n return React.createElement(FormContext.Provider, {\n value: innerFormContext\n }, React.createElement(\"div\", {\n style: style,\n className: classNames(className, bsPrefix, custom && \"custom-\" + type, inline && bsPrefix + \"-inline\")\n }, children || React.createElement(React.Fragment, null, input, hasLabel && React.createElement(FormCheckLabel, {\n title: title\n }, label), (isValid || isInvalid) && React.createElement(Feedback, {\n type: isValid ? 'valid' : 'invalid'\n }, feedback))));\n});\nFormCheck.displayName = 'FormCheck';\nFormCheck.defaultProps = defaultProps;\nFormCheck.Input = FormCheckInput;\nFormCheck.Label = FormCheckLabel;\nexport default FormCheck;","map":null,"metadata":{},"sourceType":"module"}