import RadioAntD, { RadioProps } from 'antd/lib/radio'; import React from 'react'; import { FieldProps, connectField, filterDOMProps } from 'uniforms'; import type { Option } from './types'; import wrapField from './wrapField'; const base64: (string: string) => string = typeof btoa === 'undefined' ? /* istanbul ignore next */ x => Buffer.from(x).toString('base64') : btoa; const escape = (x: string) => base64(encodeURIComponent(x)).replace(/=+$/, ''); export type RadioFieldProps = FieldProps< string, RadioProps, { options?: Option[] } >; const radioStyle = { display: 'block' }; function Radio(props: RadioFieldProps) { return wrapField( props, { if (!props.readOnly) { props.onChange(event.target.value as string | undefined); } }} value={props.value ?? ''} options={props.options?.map(option => ({ ...option, label: option.label ?? option.value, }))} > {props.options?.map(option => ( {option.label ?? option.value} ))} , ); } export default connectField(Radio, { kind: 'leaf' });