import { Controller } from "react-hook-form";
import { Select } from "../Select.mjs";
import { useFormContext } from "./context.mjs";
import { jsx } from "react/jsx-runtime";
function FormSelect({
  id,
  label,
  supportingText,
  options,
  error: defaultError,
  ...props
}) {
  const {
      formState: {
        errors
      },
      control,
      disabled
    } = useFormContext(),
    error = !!errors[id] || defaultError,
    helperText = errors?.[id]?.message || supportingText;
  return /* @__PURE__ */jsx(Controller, {
    control,
    name: id,
    render: ({
      field
    }) => /* @__PURE__ */jsx(Select, {
      ...props,
      disabled: disabled || props?.disabled,
      options,
      label,
      value: field.value,
      onValueChange: value => field.onChange(value),
      id,
      error,
      supportingText: helperText
    })
  });
}
export { FormSelect };
//# sourceMappingURL=FormSelect.mjs.map
