import { Trash2 } from "lucide-react"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Button } from "../../components/ui/button"; import { useFieldContext } from "."; import { FieldErrors } from "./Errors.Field"; type DynamicInputField = { name?: string; label: string; inputType: "text" | "email" | "password" | "number" | "username"; required?: boolean; description?: string; addLabel?: string; placeholder?: string; disabled?: boolean; }; const autoCompleteMap: Record = { email: "email", password: "current-password", text: "off", username: "username", }; export const DynamicInputField = ({ label, inputType = "text", required = false, description, addLabel, }: DynamicInputField) => { const field = useFieldContext(); const values = Array.isArray(field.state.value) ? field.state.value : []; return (
{description ? (

{description}

) : null}
{values.map((_: string, index: number) => (
field.replaceValue(index, e.target.value)} onBlur={field.handleBlur} type={inputType} required={required} /> {values.length > 1 ? ( ) : null}
))}
); };