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