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 PropTypes from 'prop-types';
|
5 | import React from 'react';
|
6 | import Button from './Button';
|
7 | var propTypes = {
|
8 | |
9 |
|
10 |
|
11 |
|
12 | type: PropTypes.oneOf(['checkbox', 'radio']),
|
13 |
|
14 | |
15 |
|
16 |
|
17 |
|
18 | name: PropTypes.string,
|
19 |
|
20 | |
21 |
|
22 |
|
23 | checked: PropTypes.bool,
|
24 |
|
25 | |
26 |
|
27 |
|
28 | disabled: PropTypes.bool,
|
29 |
|
30 | |
31 |
|
32 |
|
33 | onChange: PropTypes.func,
|
34 |
|
35 | |
36 |
|
37 |
|
38 | value: PropTypes.any.isRequired
|
39 | };
|
40 |
|
41 | var ToggleButton =
|
42 |
|
43 | function (_React$Component) {
|
44 | _inheritsLoose(ToggleButton, _React$Component);
|
45 |
|
46 | function ToggleButton() {
|
47 | return _React$Component.apply(this, arguments) || this;
|
48 | }
|
49 |
|
50 | var _proto = ToggleButton.prototype;
|
51 |
|
52 | _proto.render = function render() {
|
53 | var _this$props = this.props,
|
54 | children = _this$props.children,
|
55 | name = _this$props.name,
|
56 | checked = _this$props.checked,
|
57 | type = _this$props.type,
|
58 | onChange = _this$props.onChange,
|
59 | value = _this$props.value,
|
60 | props = _objectWithoutPropertiesLoose(_this$props, ["children", "name", "checked", "type", "onChange", "value"]);
|
61 |
|
62 | var disabled = props.disabled;
|
63 | return React.createElement(Button, _extends({}, props, {
|
64 | active: !!checked,
|
65 | componentClass: "label"
|
66 | }), React.createElement("input", {
|
67 | name: name,
|
68 | type: type,
|
69 | autoComplete: "off",
|
70 | value: value,
|
71 | checked: !!checked,
|
72 | disabled: !!disabled,
|
73 | onChange: onChange
|
74 | }), children);
|
75 | };
|
76 |
|
77 | return ToggleButton;
|
78 | }(React.Component);
|
79 |
|
80 | ToggleButton.propTypes = propTypes;
|
81 | export default ToggleButton; |
\ | No newline at end of file |