forked from zaguiini/formik-wizard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
53 lines (48 loc) · 1.53 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { FormikProps, FormikErrors } from 'formik'
import { WizardContext, WizardProps } from 'react-albus'
import { Schema } from 'yup'
export type FormikWizardBaseValues = any
export interface FormikWizardContextValue<V = any, S = any, F = any> {
forward: F
setForward: React.Dispatch<React.SetStateAction<F>>
status: S
setStatus: React.Dispatch<React.SetStateAction<S>>
values: V
setValues: React.Dispatch<React.SetStateAction<V>>
}
export interface FormikWizardStepType {
id: string
component: React.SFC<{}>
validationSchema?: Schema<any>
validate?: (values: any) => void | object | Promise<FormikErrors<any>>
initialValues?: FormikWizardBaseValues
actionLabel?: string
onAction?: (
sectionValues: FormikWizardBaseValues,
formValues: FormikWizardBaseValues
) => Promise<any>
keepValuesOnPrevious?: boolean
}
export interface FormikWizardWrapperProps<Values, Status = any, Forward = any>
extends FormikWizardContextValue<Values, Status, Forward> {
canGoBack: boolean
goToPreviousStep: () => void
currentStep: string
actionLabel?: string
isLastStep: boolean
steps: string[]
wizard: WizardContext
children: React.ReactNode
isSubmitting: boolean
}
export interface FormikWizardProps<Values, Status = any> {
steps: FormikWizardStepType[]
render: React.SFC<FormikWizardWrapperProps<Values, Status>>
onSubmit: (values: Values) => void | Promise<void>
formikProps?: Partial<FormikProps<Values>>
albusProps?: Partial<WizardProps>
Form?: any
}
export interface History<any> {
index: number
}