UNPKG

1.01 kBJavaScriptView Raw
1import classNames from 'classnames';
2import * as React from 'react';
3import { useContext } from 'react';
4import FormContext from './FormContext';
5import { useBootstrapPrefix } from './ThemeProvider';
6import { jsx as _jsx } from "react/jsx-runtime";
7const FormCheckInput = /*#__PURE__*/React.forwardRef(({
8 id,
9 bsPrefix,
10 className,
11 type = 'checkbox',
12 isValid = false,
13 isInvalid = false,
14 // Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
15 as: Component = 'input',
16 ...props
17}, ref) => {
18 const {
19 controlId
20 } = useContext(FormContext);
21 bsPrefix = useBootstrapPrefix(bsPrefix, 'form-check-input');
22 return /*#__PURE__*/_jsx(Component, { ...props,
23 ref: ref,
24 type: type,
25 id: id || controlId,
26 className: classNames(className, bsPrefix, isValid && 'is-valid', isInvalid && 'is-invalid')
27 });
28});
29FormCheckInput.displayName = 'FormCheckInput';
30export default FormCheckInput;
\No newline at end of file