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