mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-21 13:18:04 +08:00
34 lines
850 B
TypeScript
34 lines
850 B
TypeScript
import React, { PropTypes } from 'react';
|
|
import Radio from './radio';
|
|
|
|
export interface RadioButtonProps {
|
|
value: string | number;
|
|
style?: React.CSSProperties;
|
|
disabled?: boolean;
|
|
checked?: boolean;
|
|
onChange?: (e: any) => any;
|
|
}
|
|
|
|
export default class RadioButton extends React.Component<RadioButtonProps, any> {
|
|
static defaultProps = {
|
|
prefixCls: 'ant-radio-button',
|
|
};
|
|
|
|
static contextTypes = {
|
|
radioGroup: PropTypes.any,
|
|
};
|
|
|
|
render() {
|
|
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;
|
|
}
|
|
|
|
return (
|
|
<Radio {...radioProps} />
|
|
);
|
|
}
|
|
}
|