import type { BaseFieldControlProps } from "../types"
import { Input } from "@/shared/components/ui/input"

export type TextInputFieldProps = BaseFieldControlProps<string> & {
  placeholder?: string
  type?: React.HTMLInputTypeAttribute
  step?: React.InputHTMLAttributes<HTMLInputElement>["step"]
}

export function TextInputField({
  value,
  onChange,
  onBlur,
  name,
  disabled,
  invalid,
  placeholder,
  type = "text",
  step,
}: TextInputFieldProps) {
  return (
    <Input
      value={value}
      onChange={(e) => onChange(e.target.value)}
      onBlur={onBlur}
      name={name}
      disabled={disabled}
      aria-invalid={invalid || undefined}
      placeholder={placeholder}
      type={type}
      step={step}
    />
  )
}
