-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathtypes.ts
More file actions
82 lines (78 loc) · 2.55 KB
/
types.ts
File metadata and controls
82 lines (78 loc) · 2.55 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
export type Handler = (() => Promise<void>) | (() => void) | null;
export type WizardProps = {
/** Optional header that is shown above the active step */
header?: React.ReactNode;
/** Optional sidebar that is shown before the active step */
sidebar?: React.ReactNode;
/** Optional footer that is shown below the active step */
footer?: React.ReactNode;
/** Optional start index @default 0 */
startIndex?: number;
/**
* Optional wrapper that is exclusively wrapped around the active step component. It is not wrapped around the `header`, `sidebar` and `footer`
* @example With `framer-motion` - `<AnimatePresence />`
* ```jsx
* <Wizard wrapper={<AnimatePresence exitBeforeEnter />}>
* ...
* </Wizard>
* ```
*/
wrapper?: React.ReactElement;
/**
* Optional wrapper that is exclusively wrapped around the sidebar and active step component. It is not wrapped around the `header` and `footer`
* @example With `framer-motion` - `<AnimatePresence />`
* ```jsx
* <Wizard wrapper={<AnimatePresence exitBeforeEnter />}>
* ...
* </Wizard>
* ```
*/
sidebarAndStepWrapper?: React.ReactElement;
/** Callback that will be invoked with the new step index when the wizard changes steps */
onStepChange?: (stepIndex: number) => void;
};
export interface BaseWizardStep {
/** The step number */
number?: number;
/** The step name */
name?: string;
}
export type WizardValues = {
/**
* Go to the next step
*/
nextStep: () => Promise<void>;
/**
* Go to the previous step
*/
previousStep: () => void;
/**
* Go to the given step index
* @param stepIndex The step index, starts at 0
*/
goToStep: (stepIndex: number) => void;
/**
* Attach a callback that will be called when calling `nextStep()`
* @param handler Can be either sync or async
*/
handleStep: (handler: Handler) => void;
/**
* Indicate the current state of the handler
*
* Will reflect the handler promise state: will be `true` if the handler promise is pending and
* `false` when the handler is either fulfilled or rejected
*/
isLoading: boolean;
/** The current active step of the wizard */
activeStep: number;
/** The total number of steps of the wizard */
stepCount: number;
/** Indicate if the current step is the first step (aka no previous step) */
isFirstStep: boolean;
/** Indicate if the current step is the last step (aka no next step) */
isLastStep: boolean;
/** The labels of each step */
steps: BaseWizardStep[];
};
/** Console log levels */
export type LogLevel = 'info' | 'error' | 'warn';