diff --git a/src/Field.tsx b/src/Field.tsx index ff034f9..e72448f 100644 --- a/src/Field.tsx +++ b/src/Field.tsx @@ -19,6 +19,7 @@ function FieldComponent< format, formatOnBlur, initialValue, + input, isEqual, multiple, name, @@ -52,17 +53,22 @@ function FieldComponent< value, }); + // Merge provided input prop with field.input + const mergedField = input + ? { ...field, input: { ...field.input, ...input } } + : field; + if (typeof children === "function") { return ( children as ( props: FieldRenderProps & typeof rest, ) => React.ReactNode - )({ ...field, ...rest }); + )({ ...mergedField, ...rest }); } if (typeof component === "string") { // ignore meta, combine input with any other props - const inputProps = { ...field.input }; + const inputProps = { ...mergedField.input }; // Ensure multiple select has array value if ( @@ -86,7 +92,7 @@ function FieldComponent< } return renderComponent( - { children, component, ...rest, ...field }, + { children, component, ...rest, ...mergedField }, {}, `Field(${name})`, ); diff --git a/src/types.ts b/src/types.ts index e09c96f..5cee6c8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -126,6 +126,7 @@ export interface FieldProps< Omit>, "children"> { name: string; children?: RenderableProps>["children"]; + input?: Partial>; // Allow overriding input props [key: string]: any; // Allow additional props for HTML elements } diff --git a/typescript/index.d.ts b/typescript/index.d.ts index fb81265..1f37ce5 100644 --- a/typescript/index.d.ts +++ b/typescript/index.d.ts @@ -125,6 +125,7 @@ export interface FieldProps< Omit>, "children"> { name: string; children?: RenderableProps>["children"]; + input?: Partial>; [key: string]: any; }