UNPKG

2.47 kBJavaScriptView Raw
1"use strict";
2"use client";
3
4var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5exports.__esModule = true;
6exports.default = void 0;
7var _classnames = _interopRequireDefault(require("classnames"));
8var React = _interopRequireWildcard(require("react"));
9var _FormContext = _interopRequireDefault(require("./FormContext"));
10var _ThemeProvider = require("./ThemeProvider");
11var _jsxRuntime = require("react/jsx-runtime");
12function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14const FormCheckInput = /*#__PURE__*/React.forwardRef(({
15 id,
16 bsPrefix,
17 className,
18 type = 'checkbox',
19 isValid = false,
20 isInvalid = false,
21 // Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
22 as: Component = 'input',
23 ...props
24}, ref) => {
25 const {
26 controlId
27 } = (0, React.useContext)(_FormContext.default);
28 bsPrefix = (0, _ThemeProvider.useBootstrapPrefix)(bsPrefix, 'form-check-input');
29 return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
30 ...props,
31 ref: ref,
32 type: type,
33 id: id || controlId,
34 className: (0, _classnames.default)(className, bsPrefix, isValid && 'is-valid', isInvalid && 'is-invalid')
35 });
36});
37FormCheckInput.displayName = 'FormCheckInput';
38var _default = FormCheckInput;
39exports.default = _default;
40module.exports = exports.default;
\No newline at end of file