'use strict';

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var formik = require('formik');
var ramda = require('ramda');
var Select = require('../Select-DbfPhEu0.js');
require('../SelectFieldWrapper-DKkizQNM.js');
require('../primitives/Field.js');
require('../index-vioSzJOw.js');
require('../utils-BhM0B89p.js');
require('../label-DJ7KkKYy.js');
require('../index-DMbj7vXd.js');
require('react-dom');
require('../index-D-iDn9RI.js');
require('../separator-DSL-aG1J.js');
require('../primitives/Combobox.js');
require('../button-CMl9rLXi.js');
require('../index-DuNgWCXZ.js');
require('../input-group-8TZFHzVl.js');
require('../input-BlyvDsZ5.js');
require('../textarea-Br-J3v7z.js');
require('../check-BQgcDXys.js');
require('../createLucideIcon-D0tRgV6l.js');
require('../x-Brw3FJst.js');
require('../chevron-down-CPsWSS51.js');
require('../floating-ui.react-dom-B4Aw6O7R.js');
require('../index-DnKJmaCq.js');
require('../index-BrpkRQoS.js');
require('../with-selector-DeKHbQY7.js');
require('../primitives/Spinner.js');
require('react-i18next');
require('../loader-circle-Bw7zP2Gn.js');

const FormikSelect = React.forwardRef(
  (props, ref) => {
    const { name, onOpenChange, onChange: onChangeProp, ...otherProps } = props;
    const [field, meta, { setValue, setTouched }] = formik.useField(name);
    const { status = {}, setStatus } = formik.useFormikContext();
    const fieldStatus = formik.getIn(status, name);
    const selectProps = {
      ...otherProps,
      ref,
      error: meta.touched ? meta.error || fieldStatus : "",
      name: field.name,
      value: field.value,
      onOpenChange: (open) => {
        if (!open) setTouched(true, false);
        onOpenChange?.(open);
      },
      onChange: (value) => {
        setStatus(ramda.dissoc(name, status));
        setValue(value);
        onChangeProp?.(value);
      }
    };
    return /* @__PURE__ */ jsxRuntime.jsx(Select.Select, { ...selectProps });
  }
);
FormikSelect.displayName = "FormikSelect";

exports.FormikSelect = FormikSelect;
//# sourceMappingURL=Select.js.map
