import { jsx } from 'react/jsx-runtime';
import { useField, useFormikContext, getIn } from 'formik';
import { dissoc } from 'ramda';
import { R as RadioGroup } from '../RadioGroup-BTemSonO.js';
import 'react';
import '../utils-BJnb9o5c.js';
import '../primitives/RadioGroup.js';
import '../index-DNzunGHb.js';
import '../index-BtkPdosV.js';
import '../index-CiyxEyB0.js';
import '../index-DhnfW8wQ.js';
import 'react-dom';
import '../index-DT56XkyA.js';
import '../index-Dd1i1d2M.js';
import '../index-zW4GjM5L.js';
import '../index-DOzu5J1s.js';
import '../index-CSUSJzOJ.js';
import '../index-Cor698lu.js';
import '../index-d0BBQf5t.js';
import '../index-BYZaLNq1.js';
import '../index-30QpKM0j.js';
import '../index-yFgkK_AM.js';
import '../primitives/Label.js';
import '../label-BgLSVt4u.js';
import '../primitives/Field.js';
import '../index-Bo3AAQJp.js';
import '../separator-ByRsc-y-.js';

const FormikRadioGroup = ({
  name,
  onValueChange: onValueChangeProp,
  onChange: onChangeProp,
  ...props
}) => {
  const [field, meta] = useField(name);
  const {
    setFieldValue,
    status = {},
    setStatus
  } = useFormikContext();
  const fieldStatus = getIn(status, name);
  return /* @__PURE__ */ jsx(
    RadioGroup,
    {
      error: meta.touched ? meta.error || fieldStatus : "",
      name: field.name,
      value: field.value,
      onValueChange: (value) => {
        setStatus(dissoc(name, status));
        setFieldValue(name, value);
        onValueChangeProp?.(value);
        onChangeProp?.(value);
      },
      ...props
    }
  );
};
FormikRadioGroup.displayName = "FormikRadioGroup";
FormikRadioGroup.Item = RadioGroup.Item;

export { FormikRadioGroup };
//# sourceMappingURL=RadioGroup.js.map
