From c711c39aa9ce330c581794f6e03875b562177a08 Mon Sep 17 00:00:00 2001 From: Tilen Komel Date: Sat, 24 Aug 2024 12:21:15 +0200 Subject: [PATCH] Add inputChange to FormInpit --- src/components/Form/FormInput.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/Form/FormInput.tsx b/src/components/Form/FormInput.tsx index 33ba8ccd..13f77260 100644 --- a/src/components/Form/FormInput.tsx +++ b/src/components/Form/FormInput.tsx @@ -4,10 +4,12 @@ import type { } from "@components/Form/DynamicForm.js"; import { Input } from "@components/UI/Input.js"; import type { LucideIcon } from "lucide-react"; +import type { ChangeEventHandler } 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; @@ -34,13 +36,14 @@ export function GenericInput({ type={field.type} step={field.properties?.step} value={field.type === "number" ? Number.parseFloat(value) : value} - onChange={(e) => + onChange={(e) => { + if (field.inputChange) field.inputChange(e); onChange( field.type === "number" ? Number.parseFloat(e.target.value) : e.target.value, - ) - } + ); + }} {...field.properties} {...rest} disabled={disabled}