import { useCallback } from 'react'; import cx from 'classnames'; import { IRadioGroupProps, RadioGroup, IRadioEvent } from '../../radio'; import { IFormComponentProps, IFormFieldChildProps } from '../shared'; import { FormField } from '../Field'; import { useEventCallbackRef } from '../../utils/hooks/useEventCallbackRef'; export type IFormRadioGroupFieldProps = IFormComponentProps< T | null, Omit, 'value'> > & { children?: React.ReactNode; }; function RadioGroupField({ childProps, props, }: { childProps: IFormFieldChildProps; props: IFormRadioGroupFieldProps; }) { const onChangeRef = useEventCallbackRef(childProps.onChange); const onChange = useCallback( (e: IRadioEvent) => { onChangeRef.current?.(e.target.value); }, [onChangeRef] ); return ( {props.children} ); } export function FormRadioGroupField( props: IFormRadioGroupFieldProps ) { const { className, ...rest } = props; return ( {childProps => } ); }