1 | import _extends from "@babel/runtime-corejs2/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime-corejs2/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import _inheritsLoose from "@babel/runtime-corejs2/helpers/esm/inheritsLoose";
|
4 | import classNames from 'classnames';
|
5 | import React from 'react';
|
6 | import PropTypes from 'prop-types';
|
7 | import warning from 'warning';
|
8 | import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
|
9 | var propTypes = {
|
10 | |
11 |
|
12 |
|
13 | htmlFor: PropTypes.string,
|
14 | srOnly: PropTypes.bool
|
15 | };
|
16 | var defaultProps = {
|
17 | srOnly: false
|
18 | };
|
19 | var contextTypes = {
|
20 | $bs_formGroup: PropTypes.object
|
21 | };
|
22 |
|
23 | var ControlLabel =
|
24 |
|
25 | function (_React$Component) {
|
26 | _inheritsLoose(ControlLabel, _React$Component);
|
27 |
|
28 | function ControlLabel() {
|
29 | return _React$Component.apply(this, arguments) || this;
|
30 | }
|
31 |
|
32 | var _proto = ControlLabel.prototype;
|
33 |
|
34 | _proto.render = function render() {
|
35 | var formGroup = this.context.$bs_formGroup;
|
36 | var controlId = formGroup && formGroup.controlId;
|
37 |
|
38 | var _this$props = this.props,
|
39 | _this$props$htmlFor = _this$props.htmlFor,
|
40 | htmlFor = _this$props$htmlFor === void 0 ? controlId : _this$props$htmlFor,
|
41 | srOnly = _this$props.srOnly,
|
42 | className = _this$props.className,
|
43 | props = _objectWithoutPropertiesLoose(_this$props, ["htmlFor", "srOnly", "className"]);
|
44 |
|
45 | var _splitBsProps = splitBsProps(props),
|
46 | bsProps = _splitBsProps[0],
|
47 | elementProps = _splitBsProps[1];
|
48 |
|
49 | process.env.NODE_ENV !== "production" ? warning(controlId == null || htmlFor === controlId, '`controlId` is ignored on `<ControlLabel>` when `htmlFor` is specified.') : void 0;
|
50 |
|
51 | var classes = _extends({}, getClassSet(bsProps), {
|
52 | 'sr-only': srOnly
|
53 | });
|
54 |
|
55 | return React.createElement("label", _extends({}, elementProps, {
|
56 | htmlFor: htmlFor,
|
57 | className: classNames(className, classes)
|
58 | }));
|
59 | };
|
60 |
|
61 | return ControlLabel;
|
62 | }(React.Component);
|
63 |
|
64 | ControlLabel.propTypes = propTypes;
|
65 | ControlLabel.defaultProps = defaultProps;
|
66 | ControlLabel.contextTypes = contextTypes;
|
67 | export default bsClass('control-label', ControlLabel); |
\ | No newline at end of file |