2023-05-06 15:49:37 +08:00
|
|
|
import * as React from 'react';
|
2022-05-07 14:31:54 +08:00
|
|
|
import type { AbstractCheckboxProps } from '../checkbox/Checkbox';
|
2020-05-27 10:21:17 +08:00
|
|
|
import { ConfigContext } from '../config-provider';
|
2022-04-08 15:23:52 +08:00
|
|
|
import { RadioOptionTypeContextProvider } from './context';
|
2022-06-22 14:57:09 +08:00
|
|
|
import type { RadioChangeEvent } from './interface';
|
|
|
|
import Radio from './radio';
|
2015-11-06 22:03:09 +08:00
|
|
|
|
2018-03-08 20:34:40 +08:00
|
|
|
export type RadioButtonProps = AbstractCheckboxProps<RadioChangeEvent>;
|
2016-08-10 10:26:42 +08:00
|
|
|
|
2020-03-05 16:25:47 +08:00
|
|
|
const RadioButton = (props: RadioButtonProps, ref: React.Ref<any>) => {
|
2020-05-27 10:21:17 +08:00
|
|
|
const { getPrefixCls } = React.useContext(ConfigContext);
|
2017-03-23 17:19:50 +08:00
|
|
|
|
2020-05-27 10:21:17 +08:00
|
|
|
const { prefixCls: customizePrefixCls, ...radioProps } = props;
|
2022-04-08 15:23:52 +08:00
|
|
|
const prefixCls = getPrefixCls('radio', customizePrefixCls);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<RadioOptionTypeContextProvider value="button">
|
|
|
|
<Radio prefixCls={prefixCls} {...radioProps} type="radio" ref={ref} />
|
|
|
|
</RadioOptionTypeContextProvider>
|
|
|
|
);
|
2020-02-26 16:09:22 +08:00
|
|
|
};
|
2018-11-09 17:38:19 +08:00
|
|
|
|
2020-03-05 16:25:47 +08:00
|
|
|
export default React.forwardRef(RadioButton);
|