You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
971 B
24 lines
971 B
import * as React from 'react';
|
|
import type { CheckboxRef } from '../checkbox';
|
|
import type { AbstractCheckboxProps } from '../checkbox/Checkbox';
|
|
import { ConfigContext } from '../config-provider';
|
|
import { RadioOptionTypeContextProvider } from './context';
|
|
import type { RadioChangeEvent } from './interface';
|
|
import Radio from './radio';
|
|
|
|
export type RadioButtonProps = AbstractCheckboxProps<RadioChangeEvent>;
|
|
|
|
const RadioButton: React.ForwardRefRenderFunction<CheckboxRef, RadioButtonProps> = (props, ref) => {
|
|
const { getPrefixCls } = React.useContext(ConfigContext);
|
|
|
|
const { prefixCls: customizePrefixCls, ...radioProps } = props;
|
|
const prefixCls = getPrefixCls('radio', customizePrefixCls);
|
|
|
|
return (
|
|
<RadioOptionTypeContextProvider value='button'>
|
|
<Radio prefixCls={prefixCls} {...radioProps} type='radio' ref={ref} />
|
|
</RadioOptionTypeContextProvider>
|
|
);
|
|
};
|
|
|
|
export default React.forwardRef<CheckboxRef, RadioButtonProps>(RadioButton);
|
|
|