@@ -4,6 +4,7 @@ import { useCallback, useEffect } from "react";
44import { useFormContext } from "react-hook-form" ;
55import { FormControl , FormField , FormItem , FormLabel , FormMessage } from "../../../../../../../components/ui/Form" ;
66import { Input } from "../../../../../../../components/ui/Input" ;
7+ import { Textarea } from "../../../../../../../components/ui/Textarea" ;
78import { useEnsAddress } from "./useEnsAddress" ;
89
910type Props = {
@@ -23,6 +24,21 @@ const getInputPlaceholder = (input: AbiParameter): string => {
2324 return `[${ componentsString } ]` ;
2425} ;
2526
27+ type TextFieldProps = {
28+ fieldType : string ;
29+ className ?: string ;
30+ placeholder ?: string ;
31+ value ?: string ;
32+ onChange ?: ( evt : React . ChangeEvent < HTMLInputElement | HTMLTextAreaElement > ) => void ;
33+ } ;
34+
35+ function TextField ( { fieldType, ...props } : TextFieldProps ) {
36+ if ( fieldType === "string" ) {
37+ return < Textarea { ...props } /> ;
38+ }
39+ return < Input { ...props } /> ;
40+ }
41+
2642export function FunctionInput ( { input, index } : Props ) {
2743 const form = useFormContext ( ) ;
2844 const currentValue = form . watch ( `inputs.${ index } ` ) ;
@@ -60,15 +76,18 @@ export function FunctionInput({ input, index }: Props) {
6076 name = { `inputs.${ index } ` }
6177 render = { ( { field } ) => (
6278 < FormItem className = "flex flex-col gap-2" >
63- < div className = "flex items-start gap-4" >
64- { input . name && < FormLabel className = "shrink-0 pt-2 font-mono text-sm opacity-70" > { input . name } </ FormLabel > }
79+ < div className = "flex items-center gap-4" >
80+ { input . name && < FormLabel className = "shrink-0 font-mono text-sm opacity-70" > { input . name } </ FormLabel > }
6581 < div className = "flex-1" >
6682 < FormControl >
67- < Input
83+ < TextField
84+ className = "font-mono text-sm"
6885 placeholder = { getInputPlaceholder ( input ) }
86+ fieldType = { input . type }
6987 value = { field . value }
70- onChange = { ( evt ) => handleChange ( evt . target . value ) }
71- className = "font-mono text-sm"
88+ onChange = { ( evt : React . ChangeEvent < HTMLInputElement | HTMLTextAreaElement > ) =>
89+ handleChange ( evt . target . value )
90+ }
7291 />
7392 </ FormControl >
7493 < FormMessage />
0 commit comments