UNPKG

1.25 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3import classNames from 'classnames';
4import React, { useContext } from 'react';
5import FormContext from './FormContext';
6import { useBootstrapPrefix } from './ThemeProvider';
7var FormCheckLabel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
8 var bsPrefix = _ref.bsPrefix,
9 bsCustomPrefix = _ref.bsCustomPrefix,
10 className = _ref.className,
11 htmlFor = _ref.htmlFor,
12 props = _objectWithoutPropertiesLoose(_ref, ["bsPrefix", "bsCustomPrefix", "className", "htmlFor"]);
13
14 var _useContext = useContext(FormContext),
15 controlId = _useContext.controlId,
16 custom = _useContext.custom;
17
18 var _ref2 = custom ? [bsCustomPrefix, 'custom-control-label'] : [bsPrefix, 'form-check-label'],
19 prefix = _ref2[0],
20 defaultPrefix = _ref2[1];
21
22 bsPrefix = useBootstrapPrefix(prefix, defaultPrefix);
23 return /*#__PURE__*/React.createElement("label", _extends({}, props, {
24 ref: ref,
25 htmlFor: htmlFor || controlId,
26 className: classNames(className, bsPrefix)
27 }));
28});
29FormCheckLabel.displayName = 'FormCheckLabel';
30export default FormCheckLabel;
\No newline at end of file