UNPKG

2.92 kBJavaScriptView Raw
1import _extends from 'babel-runtime/helpers/extends';
2import _defineProperty from 'babel-runtime/helpers/defineProperty';
3import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
4import _createClass from 'babel-runtime/helpers/createClass';
5import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
6import _inherits from 'babel-runtime/helpers/inherits';
7var __rest = this && this.__rest || function (s, e) {
8 var t = {};
9 for (var p in s) {
10 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
11 }if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
12 if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
13 }return t;
14};
15import classnames from 'classnames';
16import React from 'react';
17import List from '../list';
18import Radio from './Radio';
19var ListItem = List.Item;
20function noop() {}
21
22var RadioItem = function (_React$Component) {
23 _inherits(RadioItem, _React$Component);
24
25 function RadioItem() {
26 _classCallCheck(this, RadioItem);
27
28 return _possibleConstructorReturn(this, (RadioItem.__proto__ || Object.getPrototypeOf(RadioItem)).apply(this, arguments));
29 }
30
31 _createClass(RadioItem, [{
32 key: 'render',
33 value: function render() {
34 var _this2 = this;
35
36 var _a = this.props,
37 listPrefixCls = _a.listPrefixCls,
38 onChange = _a.onChange,
39 disabled = _a.disabled,
40 radioProps = _a.radioProps,
41 onClick = _a.onClick,
42 otherProps = __rest(_a, ["listPrefixCls", "onChange", "disabled", "radioProps", "onClick"]);var prefixCls = otherProps.prefixCls,
43 className = otherProps.className,
44 children = otherProps.children;
45
46 var wrapCls = classnames(prefixCls + '-item', className, _defineProperty({}, prefixCls + '-item-disabled', disabled === true));
47 // Note: if not omit `onChange`, it will trigger twice on check listitem
48 if (!disabled) {
49 otherProps.onClick = onClick || noop;
50 }
51 var extraProps = {};
52 ['name', 'defaultChecked', 'checked', 'onChange', 'disabled'].forEach(function (i) {
53 if (i in _this2.props) {
54 extraProps[i] = _this2.props[i];
55 }
56 });
57 return React.createElement(
58 ListItem,
59 _extends({}, otherProps, { prefixCls: listPrefixCls, className: wrapCls, extra: React.createElement(Radio, _extends({}, radioProps, extraProps)) }),
60 children
61 );
62 }
63 }]);
64
65 return RadioItem;
66}(React.Component);
67
68export default RadioItem;
69
70RadioItem.defaultProps = {
71 prefixCls: 'am-radio',
72 listPrefixCls: 'am-list',
73 radioProps: {}
74};
\No newline at end of file