Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions dist/index.es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.es.js.map

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions dist/lib/ReactForm.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
/// <reference types="react" />
import { RowSchema, IFormActionProps, BuilderSettingsProps } from './ml-form-builder';
import { FormikValues } from 'formik';
import { FormikConfig, FormikValues } from 'formik';
export * from './ml-form-builder';
export * from './ml-form-builder/lib';
export * from './ml-form-builder/Utils';
Expand Down Expand Up @@ -30,13 +30,14 @@ export * from './ml-form-builder/Utils';
* }]
* }
*/
export interface IReactFormProps extends FormikValues {
export interface IReactFormProps<T = any> extends FormikValues {
config: Array<RowSchema>;
formId: string;
innerRef?: FormikConfig<T>['innerRef'];
actionConfig: IFormActionProps;
formSettings?: BuilderSettingsProps;
isInProgress?: boolean;
isReadOnly?: boolean;
}
export declare const ReactForm: React.FC<IReactFormProps>;
export declare function ReactForm<T>(props: IReactFormProps<T>): JSX.Element;
export default ReactForm;
12 changes: 7 additions & 5 deletions src/lib/ReactForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { MLFormBuilder, RowSchema, IFormActionProps, BuilderSettingsProps } from './ml-form-builder';
import { Formik, FormikValues } from 'formik';
import { Formik, FormikConfig, FormikValues } from 'formik';
export * from './ml-form-builder';
export * from './ml-form-builder/lib';
export * from './ml-form-builder/Utils'
Expand Down Expand Up @@ -36,19 +36,21 @@ export * from './ml-form-builder/Utils'
*/


export interface IReactFormProps extends FormikValues {
export interface IReactFormProps<T = any> extends FormikValues {
config: Array<RowSchema>,
formId: string,
innerRef?: FormikConfig<T>['innerRef']
actionConfig: IFormActionProps
formSettings?: BuilderSettingsProps
isInProgress?: boolean
isReadOnly?: boolean
}
export const ReactForm: React.FC<IReactFormProps> = (props) => {
const { config, formId, initialValues = {}, onSubmit, actionConfig, formSettings, isInProgress = false, isReadOnly = false, ...formikProps } = props;
export function ReactForm<T>(props: IReactFormProps<T>) {
const { config, innerRef, formId, initialValues = {}, onSubmit, actionConfig, formSettings, isInProgress = false, isReadOnly = false, ...formikProps } = props;

return (
<Formik
<Formik<T>
innerRef={innerRef}
initialValues={initialValues}
onSubmit={onSubmit}
{...formikProps}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ml-form-builder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export const attachField = (type: Array<string> | string, component: JSX.Element
export const setDefaultProps = (type: Array<string> | string, props: object) => {
if (isArray(type)) {
map(type, item => ComponentMapConfig[item].props = { ...ComponentMapConfig[item].props, ...props })
} else
ComponentMapConfig[type]?.props = { ...ComponentMapConfig[type]?.props, ...props }
} else if (ComponentMapConfig[type]?.props)
ComponentMapConfig[type].props = { ...ComponentMapConfig[type]?.props, ...props }
}


Expand Down