2017-03-23 17:19:50 +08:00
|
|
|
import React, { PropTypes } from 'react';
|
2017-05-08 13:12:34 +08:00
|
|
|
import { AbstractCheckboxProps } from '../checkbox/Checkbox';
|
2016-03-21 21:16:38 +08:00
|
|
|
import Radio from './radio';
|
2015-11-06 22:03:09 +08:00
|
|
|
|
2017-05-08 13:12:34 +08:00
|
|
|
export interface RadioButtonProps extends AbstractCheckboxProps {}
|
2016-08-10 10:26:42 +08:00
|
|
|
|
|
|
|
export default class RadioButton extends React.Component<RadioButtonProps, any> {
|
2016-03-28 23:21:47 +08:00
|
|
|
static defaultProps = {
|
|
|
|
prefixCls: 'ant-radio-button',
|
2016-07-13 11:14:24 +08:00
|
|
|
};
|
2017-03-23 17:19:50 +08:00
|
|
|
|
|
|
|
static contextTypes = {
|
|
|
|
radioGroup: PropTypes.any,
|
|
|
|
};
|
|
|
|
|
2015-11-06 22:03:09 +08:00
|
|
|
render() {
|
2017-03-23 17:19:50 +08:00
|
|
|
let radioProps: RadioButtonProps = { ...this.props };
|
|
|
|
if (this.context.radioGroup) {
|
|
|
|
radioProps.onChange = this.context.radioGroup.onChange;
|
|
|
|
radioProps.checked = this.props.value === this.context.radioGroup.value;
|
|
|
|
radioProps.disabled = this.props.disabled || this.context.radioGroup.disabled;
|
|
|
|
}
|
|
|
|
|
2015-11-06 22:03:09 +08:00
|
|
|
return (
|
2017-03-23 17:19:50 +08:00
|
|
|
<Radio {...radioProps} />
|
2015-11-06 22:03:09 +08:00
|
|
|
);
|
|
|
|
}
|
2016-03-28 23:21:47 +08:00
|
|
|
}
|