Skip to content

Commit ec8e009

Browse files
committed
fix(renderer): update wizard context types
1 parent 3629044 commit ec8e009

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/react-form-renderer/src/renderer-context/renderer-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface FormOptions<FormValues = Record<string, any>, InitialFormValues
1313
unRegisterInputFile?: (name: keyof FormValues) => void;
1414
onCancel?: (values: FormValues, ...args: any[]) => void;
1515
onReset?: () => void;
16-
onSubmit?: (...args: any[]) => void;
16+
onSubmit?: (...args: any[]) => void | any | Promise<any>;
1717
handleSubmit: () => Promise<FormValues | undefined> | undefined;
1818
onError?: (...args: any[]) => void;
1919
clearOnUnmount?: boolean;

packages/react-form-renderer/src/wizard-context/wizard-context.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@ import { createContext } from 'react';
22
import { Field } from '../common-types';
33
import { FormOptions } from '../renderer-context';
44

5+
export type NextStep =
6+
| string
7+
| ((context: { values: any }) => string)
8+
| ((context: { values: any }) => Promise<string>)
9+
| (any & {
10+
stepMapper: {
11+
[key: string]: string;
12+
[key: number]: string;
13+
};
14+
when: string[] | string;
15+
});
16+
517
export interface WizardContextValue {
618
formOptions: FormOptions;
719
crossroads: string[];
8-
currentStep: { fields: Field[]; name: string; title: string; nextStep?: string };
20+
currentStep: { fields?: Field[]; name: string; title?: string; nextStep?: NextStep } | undefined;
921
handlePrev: Function;
1022
onKeyDown: Function;
1123
jumpToStep: Function;
@@ -16,6 +28,7 @@ export interface WizardContextValue {
1628
maxStepIndex: number;
1729
isDynamic: boolean;
1830
prevSteps: string[];
31+
selectNext: Function;
1932
}
2033

2134
const WizardContext = createContext<WizardContextValue>({} as WizardContextValue);

0 commit comments

Comments
 (0)