import React from 'react'; import type { RadioProps, RadioGroupProps } from 'antd'; import { Radio } from 'antd'; import ProField from '@ant-design/pro-field'; import type { ProSchema } from '@ant-design/pro-utils'; import { runFunction } from '@ant-design/pro-utils'; import createField from '../../BaseForm/createField'; import type { ProFormItemProps } from '../../interface'; export type ProFormRadioGroupProps = ProFormItemProps & { layout?: 'horizontal' | 'vertical'; radioType?: 'button' | 'radio'; options?: RadioGroupProps['options']; valueEnum?: ProSchema['valueEnum']; request?: ProSchema['request']; }; const RadioGroup: React.FC = React.forwardRef( ({ fieldProps, options, radioType, layout, proFieldProps, valueEnum, ...rest }, ref: any) => { return ( (valueEnum, undefined)} {...rest} fieldProps={{ options, layout, ...fieldProps, }} {...proFieldProps} /> ); }, ); /** * Radio * * @param */ const ProFormRadioComponents: React.FC> = React.forwardRef( ({ fieldProps, children }, ref: any) => { return ( {children} ); }, ); const ProFormRadio = createField>(ProFormRadioComponents, { valuePropName: 'checked', ignoreWidth: true, }); const Group = createField(RadioGroup, { customLightMode: true, }); const WrappedProFormRadio: typeof ProFormRadio & { Group: typeof Group; Button: typeof Radio.Button; } = ProFormRadio as any; WrappedProFormRadio.Group = Group; WrappedProFormRadio.Button = Radio.Button; export default WrappedProFormRadio;