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