mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-22 14:44:47 +08:00
9cf6ae6010
now support Button, Tag, Radio.Button and switch
34 lines
960 B
TypeScript
34 lines
960 B
TypeScript
import * as React from 'react';
|
|
import * as PropTypes from 'prop-types';
|
|
import { AbstractCheckboxProps } from '../checkbox/Checkbox';
|
|
import Radio from './radio';
|
|
import { RadioChangeEvent } from './interface';
|
|
import Wave from '../_util/wave';
|
|
|
|
export type RadioButtonProps = AbstractCheckboxProps<RadioChangeEvent>;
|
|
|
|
export default class RadioButton extends React.Component<RadioButtonProps, any> {
|
|
static defaultProps = {
|
|
prefixCls: 'ant-radio-button',
|
|
};
|
|
|
|
static contextTypes = {
|
|
radioGroup: PropTypes.any,
|
|
};
|
|
|
|
render() {
|
|
const 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 (
|
|
<Wave>
|
|
<Radio {...radioProps} />
|
|
</Wave>
|
|
);
|
|
}
|
|
}
|