import { jsx as _jsx } from "react/jsx-runtime";
import { Controller } from "react-hook-form";
import { TextField } from "./TextField.native.js";
import { useFormContext } from "./context.native.js";
function FormInput(param) {
  var {
      id,
      helperText,
      error: defaultError,
      required,
      ...props
    } = param,
    _errors_id,
    {
      control,
      formState: {
        errors
      },
      disabled
    } = useFormContext(),
    error = !!errors[id] || defaultError,
    supportingText = (errors == null || (_errors_id = errors[id]) === null || _errors_id === void 0 ? void 0 : _errors_id.message) || helperText,
    label = required ? `${props.label} *` : props.label;
  return /* @__PURE__ */_jsx(Controller, {
    control,
    name: id,
    render: function (param2) {
      var {
          field
        } = param2,
        _field_value,
        _field_value1;
      return /* @__PURE__ */_jsx(TextField, {
        ...props,
        fg: 1,
        label,
        disabled: disabled || props?.disabled,
        error,
        onBlur: field?.onBlur,
        onChangeText: field?.onChange,
        value: field == null || (_field_value = field.value) === null || _field_value === void 0 ? void 0 : _field_value.toString(),
        placeholder: field == null || (_field_value1 = field.value) === null || _field_value1 === void 0 ? void 0 : _field_value1.toString(),
        id,
        supportingText
      });
    }
  });
}
export { FormInput };
//# sourceMappingURL=FormInput.native.js.map
