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