|
@ -1,4 +1,5 @@ |
|
|
import * as React from 'react'; |
|
|
import * as React from 'react'; |
|
|
|
|
|
import type { CheckboxRef } from '../checkbox'; |
|
|
import type { AbstractCheckboxProps } from '../checkbox/Checkbox'; |
|
|
import type { AbstractCheckboxProps } from '../checkbox/Checkbox'; |
|
|
import { ConfigContext } from '../config-provider'; |
|
|
import { ConfigContext } from '../config-provider'; |
|
|
import { RadioOptionTypeContextProvider } from './context'; |
|
|
import { RadioOptionTypeContextProvider } from './context'; |
|
@ -7,17 +8,17 @@ import Radio from './radio'; |
|
|
|
|
|
|
|
|
export type RadioButtonProps = AbstractCheckboxProps<RadioChangeEvent>; |
|
|
export type RadioButtonProps = AbstractCheckboxProps<RadioChangeEvent>; |
|
|
|
|
|
|
|
|
const RadioButton = (props: RadioButtonProps, ref: React.Ref<any>) => { |
|
|
const RadioButton: React.ForwardRefRenderFunction<CheckboxRef, RadioButtonProps> = (props, ref) => { |
|
|
const { getPrefixCls } = React.useContext(ConfigContext); |
|
|
const { getPrefixCls } = React.useContext(ConfigContext); |
|
|
|
|
|
|
|
|
const { prefixCls: customizePrefixCls, ...radioProps } = props; |
|
|
const { prefixCls: customizePrefixCls, ...radioProps } = props; |
|
|
const prefixCls = getPrefixCls('radio', customizePrefixCls); |
|
|
const prefixCls = getPrefixCls('radio', customizePrefixCls); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<RadioOptionTypeContextProvider value="button"> |
|
|
<RadioOptionTypeContextProvider value='button'> |
|
|
<Radio prefixCls={prefixCls} {...radioProps} type="radio" ref={ref} /> |
|
|
<Radio prefixCls={prefixCls} {...radioProps} type='radio' ref={ref} /> |
|
|
</RadioOptionTypeContextProvider> |
|
|
</RadioOptionTypeContextProvider> |
|
|
); |
|
|
); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
export default React.forwardRef(RadioButton); |
|
|
export default React.forwardRef<CheckboxRef, RadioButtonProps>(RadioButton); |
|
|