import type { BaseFormBuilderProps, GenericFormElementProps, } from "@components/Form/DynamicForm.tsx"; import { Input } from "@components/UI/Input.tsx"; import type { LucideIcon } from "lucide-react"; import { Eye, EyeOff } from "lucide-react"; import type { ChangeEventHandler } from "react"; import { useState } from "react"; import { Controller, type FieldValues } from "react-hook-form"; export interface InputFieldProps extends BaseFormBuilderProps { type: "text" | "number" | "password"; inputChange?: ChangeEventHandler; properties?: { value?: string; prefix?: string; suffix?: string; step?: number; action?: { icon: LucideIcon; onClick: () => void; }; }; } export function GenericInput({ control, disabled, field, }: GenericFormElementProps>) { const [passwordShown, setPasswordShown] = useState(false); const togglePasswordVisiblity = () => { setPasswordShown(!passwordShown); }; return ( ( { if (field.inputChange) field.inputChange(e); onChange( field.type === "number" ? Number.parseFloat(e.target.value) : e.target.value, ); }} {...field.properties} {...rest} disabled={disabled} /> )} /> ); }