import React from 'react'; import { Radio } from '@patternfly/react-core'; import { useField, useFormikContext, FormikValues } from 'formik'; import { FieldProps } from '../types'; import { getFieldId } from '../utils'; type RadioButtonFieldProps = Omit & { value: React.ReactText; description?: React.ReactNode; onChange?: (value: React.ReactText) => void; }; const RadioButtonField: React.FC = ({ name, label, value, onChange, ...props }) => { const [field, { touched, error }] = useField(name); const { setFieldValue, setFieldTouched } = useFormikContext(); const fieldId = getFieldId(`${name}-${value}`, 'radiobutton'); const isValid = !(touched && error); return ( { if (onChange) { onChange(value); } else { void setFieldValue(name, value); } void setFieldTouched(name, true, false); }} /> ); }; export default RadioButtonField;