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 |
|
7 |
|
8 | import classNames from 'classnames';
|
9 | import React from 'react';
|
10 | import PropTypes from 'prop-types';
|
11 | import warning from 'warning';
|
12 |
|
13 | import { bsClass, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
|
14 |
|
15 | var propTypes = {
|
16 | inline: PropTypes.bool,
|
17 | disabled: PropTypes.bool,
|
18 | title: PropTypes.string,
|
19 | |
20 |
|
21 |
|
22 | validationState: PropTypes.oneOf(['success', 'warning', 'error', null]),
|
23 | |
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | inputRef: PropTypes.func
|
31 | };
|
32 |
|
33 | var defaultProps = {
|
34 | inline: false,
|
35 | disabled: false,
|
36 | title: ''
|
37 | };
|
38 |
|
39 | var Radio = function (_React$Component) {
|
40 | _inherits(Radio, _React$Component);
|
41 |
|
42 | function Radio() {
|
43 | _classCallCheck(this, Radio);
|
44 |
|
45 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
46 | }
|
47 |
|
48 | Radio.prototype.render = function render() {
|
49 | var _props = this.props,
|
50 | inline = _props.inline,
|
51 | disabled = _props.disabled,
|
52 | validationState = _props.validationState,
|
53 | inputRef = _props.inputRef,
|
54 | className = _props.className,
|
55 | style = _props.style,
|
56 | title = _props.title,
|
57 | children = _props.children,
|
58 | props = _objectWithoutProperties(_props, ['inline', 'disabled', 'validationState', 'inputRef', 'className', 'style', 'title', 'children']);
|
59 |
|
60 | var _splitBsProps = splitBsProps(props),
|
61 | bsProps = _splitBsProps[0],
|
62 | elementProps = _splitBsProps[1];
|
63 |
|
64 | var input = React.createElement('input', _extends({}, elementProps, {
|
65 | ref: inputRef,
|
66 | type: 'radio',
|
67 | disabled: disabled
|
68 | }));
|
69 |
|
70 | if (inline) {
|
71 | var _classes2;
|
72 |
|
73 | var _classes = (_classes2 = {}, _classes2[prefix(bsProps, 'inline')] = true, _classes2.disabled = disabled, _classes2);
|
74 |
|
75 |
|
76 |
|
77 | process.env.NODE_ENV !== 'production' ? warning(!validationState, '`validationState` is ignored on `<Radio inline>`. To display ' + 'validation state on an inline radio, set `validationState` on a ' + 'parent `<FormGroup>` or other element instead.') : void 0;
|
78 |
|
79 | return React.createElement(
|
80 | 'label',
|
81 | {
|
82 | className: classNames(className, _classes),
|
83 | style: style,
|
84 | title: title
|
85 | },
|
86 | input,
|
87 | children
|
88 | );
|
89 | }
|
90 |
|
91 | var classes = _extends({}, getClassSet(bsProps), {
|
92 | disabled: disabled
|
93 | });
|
94 | if (validationState) {
|
95 | classes['has-' + validationState] = true;
|
96 | }
|
97 |
|
98 | return React.createElement(
|
99 | 'div',
|
100 | { className: classNames(className, classes), style: style },
|
101 | React.createElement(
|
102 | 'label',
|
103 | { title: title },
|
104 | input,
|
105 | children
|
106 | )
|
107 | );
|
108 | };
|
109 |
|
110 | return Radio;
|
111 | }(React.Component);
|
112 |
|
113 | Radio.propTypes = propTypes;
|
114 | Radio.defaultProps = defaultProps;
|
115 |
|
116 | export default bsClass('radio', Radio); |
\ | No newline at end of file |