You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

39 lines
1.6 KiB

  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
  3. import classNames from 'classnames';
  4. import React, { useContext } from 'react';
  5. import FormContext from './FormContext';
  6. import { useBootstrapPrefix } from './ThemeProvider';
  7. var defaultProps = {
  8. type: 'checkbox'
  9. };
  10. var FormCheckInput = React.forwardRef(function (_ref, ref) {
  11. var id = _ref.id,
  12. bsPrefix = _ref.bsPrefix,
  13. bsCustomPrefix = _ref.bsCustomPrefix,
  14. className = _ref.className,
  15. isValid = _ref.isValid,
  16. isInvalid = _ref.isInvalid,
  17. isStatic = _ref.isStatic,
  18. _ref$as = _ref.as,
  19. Component = _ref$as === void 0 ? 'input' : _ref$as,
  20. props = _objectWithoutPropertiesLoose(_ref, ["id", "bsPrefix", "bsCustomPrefix", "className", "isValid", "isInvalid", "isStatic", "as"]);
  21. var _useContext = useContext(FormContext),
  22. controlId = _useContext.controlId,
  23. custom = _useContext.custom;
  24. var _ref2 = custom ? [bsCustomPrefix, 'custom-control-input'] : [bsPrefix, 'form-check-input'],
  25. prefix = _ref2[0],
  26. defaultPrefix = _ref2[1];
  27. bsPrefix = useBootstrapPrefix(prefix, defaultPrefix);
  28. return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
  29. ref: ref,
  30. id: id || controlId,
  31. className: classNames(className, bsPrefix, isValid && 'is-valid', isInvalid && 'is-invalid', isStatic && 'position-static')
  32. }));
  33. });
  34. FormCheckInput.displayName = 'FormCheckInput';
  35. FormCheckInput.defaultProps = defaultProps;
  36. export default FormCheckInput;