@ttoss/react-wizard 0.4.8 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +511 -0
- package/dist/index.d.cts +125 -112
- package/dist/index.d.mts +172 -0
- package/dist/index.mjs +490 -0
- package/package.json +14 -14
- package/dist/esm/index.js +0 -483
- package/dist/index.d.ts +0 -158
- package/dist/index.js +0 -517
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
1
|
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
//#region src/Wizard.styles.d.ts
|
|
4
4
|
type WizardVariant = 'spotlight-accent' | 'spotlight-primary' | 'primary' | 'secondary' | 'accent';
|
|
5
|
-
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/types.d.ts
|
|
6
7
|
/**
|
|
7
8
|
* Position of the step list relative to the wizard content.
|
|
8
9
|
*/
|
|
@@ -15,126 +16,127 @@ type WizardStepStatus = 'completed' | 'active' | 'upcoming';
|
|
|
15
16
|
* Definition of a single wizard step.
|
|
16
17
|
*/
|
|
17
18
|
interface WizardStep {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Title displayed in the step list.
|
|
21
|
+
*/
|
|
22
|
+
title: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional description displayed below the title in the step list.
|
|
25
|
+
*/
|
|
26
|
+
description?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The content rendered when this step is active.
|
|
29
|
+
*/
|
|
30
|
+
content: React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Called when the user clicks "Next". If it returns false or
|
|
33
|
+
* a Promise that resolves to false, the wizard will not advance.
|
|
34
|
+
*/
|
|
35
|
+
onNext?: () => boolean | Promise<boolean>;
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* Props for the Wizard component.
|
|
38
39
|
*/
|
|
39
40
|
interface WizardProps {
|
|
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
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Array of steps to display in the wizard.
|
|
43
|
+
*/
|
|
44
|
+
steps: WizardStep[];
|
|
45
|
+
/**
|
|
46
|
+
* Position of the step list. Defaults to 'top'.
|
|
47
|
+
*/
|
|
48
|
+
layout?: WizardLayout;
|
|
49
|
+
/**
|
|
50
|
+
* Visual variant for the wizard shell, step accents, and primary action.
|
|
51
|
+
* @default 'spotlight-accent'
|
|
52
|
+
*/
|
|
53
|
+
variant?: WizardVariant;
|
|
54
|
+
/**
|
|
55
|
+
* Called when the wizard completes (user clicks "Finish" on the last step).
|
|
56
|
+
*/
|
|
57
|
+
onComplete?: () => void;
|
|
58
|
+
/**
|
|
59
|
+
* Called when the user clicks "Cancel".
|
|
60
|
+
* If not provided, the Cancel button is not rendered.
|
|
61
|
+
*/
|
|
62
|
+
onCancel?: () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Called whenever the active step changes.
|
|
65
|
+
*/
|
|
66
|
+
onStepChange?: (params: {
|
|
67
|
+
stepIndex: number;
|
|
68
|
+
}) => void;
|
|
69
|
+
/**
|
|
70
|
+
* The initially active step index. Defaults to 0.
|
|
71
|
+
*/
|
|
72
|
+
initialStep?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Allow clicking on completed steps to navigate back.
|
|
75
|
+
* Defaults to true.
|
|
76
|
+
*/
|
|
77
|
+
allowStepClick?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Optional custom labels for the navigation buttons.
|
|
80
|
+
*/
|
|
81
|
+
labels?: Partial<WizardLabels>;
|
|
81
82
|
}
|
|
82
83
|
/**
|
|
83
84
|
* Customizable labels used by the wizard navigation buttons.
|
|
84
85
|
*/
|
|
85
86
|
interface WizardLabels {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
previous: string;
|
|
88
|
+
next: string;
|
|
89
|
+
finish: string;
|
|
90
|
+
cancel: string;
|
|
90
91
|
}
|
|
91
92
|
/**
|
|
92
93
|
* Context value exposed by WizardProvider.
|
|
93
94
|
*/
|
|
94
95
|
interface WizardContextValue {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Current active step index.
|
|
98
|
+
*/
|
|
99
|
+
currentStep: number;
|
|
100
|
+
/**
|
|
101
|
+
* Total number of steps.
|
|
102
|
+
*/
|
|
103
|
+
totalSteps: number;
|
|
104
|
+
/**
|
|
105
|
+
* Navigate to the next step.
|
|
106
|
+
*/
|
|
107
|
+
goToNext: () => Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Navigate to the previous step.
|
|
110
|
+
*/
|
|
111
|
+
goToPrevious: () => void;
|
|
112
|
+
/**
|
|
113
|
+
* Navigate to a specific step (only if it's completed or active).
|
|
114
|
+
*/
|
|
115
|
+
goToStep: (params: {
|
|
116
|
+
stepIndex: number;
|
|
117
|
+
}) => void;
|
|
118
|
+
/**
|
|
119
|
+
* Whether the wizard is on the first step.
|
|
120
|
+
*/
|
|
121
|
+
isFirstStep: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Whether the wizard is on the last step.
|
|
124
|
+
*/
|
|
125
|
+
isLastStep: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Get the status of a step by index.
|
|
128
|
+
*/
|
|
129
|
+
getStepStatus: (params: {
|
|
130
|
+
stepIndex: number;
|
|
131
|
+
}) => WizardStepStatus;
|
|
132
|
+
/**
|
|
133
|
+
* Register a validation function for the current step.
|
|
134
|
+
* This allows step content components to provide their own validation logic.
|
|
135
|
+
*/
|
|
136
|
+
setStepValidation: (validate: () => boolean | Promise<boolean>) => void;
|
|
136
137
|
}
|
|
137
|
-
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/Wizard.d.ts
|
|
138
140
|
/**
|
|
139
141
|
* Renders a multi-step wizard with step navigation, localized action labels,
|
|
140
142
|
* and support for completion, cancellation, and step changes.
|
|
@@ -146,13 +148,24 @@ interface WizardContextValue {
|
|
|
146
148
|
* @param props.onStepChange - Called when the current step changes.
|
|
147
149
|
*/
|
|
148
150
|
declare const Wizard: {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
+
({
|
|
152
|
+
steps,
|
|
153
|
+
layout,
|
|
154
|
+
variant,
|
|
155
|
+
onComplete,
|
|
156
|
+
onCancel,
|
|
157
|
+
onStepChange,
|
|
158
|
+
initialStep,
|
|
159
|
+
allowStepClick,
|
|
160
|
+
labels
|
|
161
|
+
}: WizardProps): import("react/jsx-runtime").JSX.Element;
|
|
162
|
+
displayName: string;
|
|
151
163
|
};
|
|
152
|
-
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/WizardContext.d.ts
|
|
153
166
|
/**
|
|
154
167
|
* Hook to access the wizard context from within step content.
|
|
155
168
|
*/
|
|
156
169
|
declare const useWizard: () => WizardContextValue;
|
|
157
|
-
|
|
158
|
-
export { Wizard, type WizardContextValue, type WizardLabels, type WizardLayout, type WizardProps, type WizardStep, type WizardStepStatus, type WizardVariant, useWizard };
|
|
170
|
+
//#endregion
|
|
171
|
+
export { Wizard, type WizardContextValue, type WizardLabels, type WizardLayout, type WizardProps, type WizardStep, type WizardStepStatus, type WizardVariant, useWizard };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/Wizard.styles.d.ts
|
|
5
|
+
type WizardVariant = 'spotlight-accent' | 'spotlight-primary' | 'primary' | 'secondary' | 'accent';
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/types.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Position of the step list relative to the wizard content.
|
|
10
|
+
*/
|
|
11
|
+
type WizardLayout = 'top' | 'right' | 'bottom' | 'left';
|
|
12
|
+
/**
|
|
13
|
+
* Status of a wizard step.
|
|
14
|
+
*/
|
|
15
|
+
type WizardStepStatus = 'completed' | 'active' | 'upcoming';
|
|
16
|
+
/**
|
|
17
|
+
* Definition of a single wizard step.
|
|
18
|
+
*/
|
|
19
|
+
interface WizardStep {
|
|
20
|
+
/**
|
|
21
|
+
* Title displayed in the step list.
|
|
22
|
+
*/
|
|
23
|
+
title: string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional description displayed below the title in the step list.
|
|
26
|
+
*/
|
|
27
|
+
description?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The content rendered when this step is active.
|
|
30
|
+
*/
|
|
31
|
+
content: React.ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Called when the user clicks "Next". If it returns false or
|
|
34
|
+
* a Promise that resolves to false, the wizard will not advance.
|
|
35
|
+
*/
|
|
36
|
+
onNext?: () => boolean | Promise<boolean>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Props for the Wizard component.
|
|
40
|
+
*/
|
|
41
|
+
interface WizardProps {
|
|
42
|
+
/**
|
|
43
|
+
* Array of steps to display in the wizard.
|
|
44
|
+
*/
|
|
45
|
+
steps: WizardStep[];
|
|
46
|
+
/**
|
|
47
|
+
* Position of the step list. Defaults to 'top'.
|
|
48
|
+
*/
|
|
49
|
+
layout?: WizardLayout;
|
|
50
|
+
/**
|
|
51
|
+
* Visual variant for the wizard shell, step accents, and primary action.
|
|
52
|
+
* @default 'spotlight-accent'
|
|
53
|
+
*/
|
|
54
|
+
variant?: WizardVariant;
|
|
55
|
+
/**
|
|
56
|
+
* Called when the wizard completes (user clicks "Finish" on the last step).
|
|
57
|
+
*/
|
|
58
|
+
onComplete?: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* Called when the user clicks "Cancel".
|
|
61
|
+
* If not provided, the Cancel button is not rendered.
|
|
62
|
+
*/
|
|
63
|
+
onCancel?: () => void;
|
|
64
|
+
/**
|
|
65
|
+
* Called whenever the active step changes.
|
|
66
|
+
*/
|
|
67
|
+
onStepChange?: (params: {
|
|
68
|
+
stepIndex: number;
|
|
69
|
+
}) => void;
|
|
70
|
+
/**
|
|
71
|
+
* The initially active step index. Defaults to 0.
|
|
72
|
+
*/
|
|
73
|
+
initialStep?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Allow clicking on completed steps to navigate back.
|
|
76
|
+
* Defaults to true.
|
|
77
|
+
*/
|
|
78
|
+
allowStepClick?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Optional custom labels for the navigation buttons.
|
|
81
|
+
*/
|
|
82
|
+
labels?: Partial<WizardLabels>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Customizable labels used by the wizard navigation buttons.
|
|
86
|
+
*/
|
|
87
|
+
interface WizardLabels {
|
|
88
|
+
previous: string;
|
|
89
|
+
next: string;
|
|
90
|
+
finish: string;
|
|
91
|
+
cancel: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Context value exposed by WizardProvider.
|
|
95
|
+
*/
|
|
96
|
+
interface WizardContextValue {
|
|
97
|
+
/**
|
|
98
|
+
* Current active step index.
|
|
99
|
+
*/
|
|
100
|
+
currentStep: number;
|
|
101
|
+
/**
|
|
102
|
+
* Total number of steps.
|
|
103
|
+
*/
|
|
104
|
+
totalSteps: number;
|
|
105
|
+
/**
|
|
106
|
+
* Navigate to the next step.
|
|
107
|
+
*/
|
|
108
|
+
goToNext: () => Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Navigate to the previous step.
|
|
111
|
+
*/
|
|
112
|
+
goToPrevious: () => void;
|
|
113
|
+
/**
|
|
114
|
+
* Navigate to a specific step (only if it's completed or active).
|
|
115
|
+
*/
|
|
116
|
+
goToStep: (params: {
|
|
117
|
+
stepIndex: number;
|
|
118
|
+
}) => void;
|
|
119
|
+
/**
|
|
120
|
+
* Whether the wizard is on the first step.
|
|
121
|
+
*/
|
|
122
|
+
isFirstStep: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Whether the wizard is on the last step.
|
|
125
|
+
*/
|
|
126
|
+
isLastStep: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Get the status of a step by index.
|
|
129
|
+
*/
|
|
130
|
+
getStepStatus: (params: {
|
|
131
|
+
stepIndex: number;
|
|
132
|
+
}) => WizardStepStatus;
|
|
133
|
+
/**
|
|
134
|
+
* Register a validation function for the current step.
|
|
135
|
+
* This allows step content components to provide their own validation logic.
|
|
136
|
+
*/
|
|
137
|
+
setStepValidation: (validate: () => boolean | Promise<boolean>) => void;
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/Wizard.d.ts
|
|
141
|
+
/**
|
|
142
|
+
* Renders a multi-step wizard with step navigation, localized action labels,
|
|
143
|
+
* and support for completion, cancellation, and step changes.
|
|
144
|
+
*
|
|
145
|
+
* @param props - Wizard configuration and step content.
|
|
146
|
+
* @param props.steps - The ordered steps displayed in the wizard.
|
|
147
|
+
* @param props.onComplete - Called when the user finishes the last step.
|
|
148
|
+
* @param props.onCancel - Called when the user cancels the wizard.
|
|
149
|
+
* @param props.onStepChange - Called when the current step changes.
|
|
150
|
+
*/
|
|
151
|
+
declare const Wizard: {
|
|
152
|
+
({
|
|
153
|
+
steps,
|
|
154
|
+
layout,
|
|
155
|
+
variant,
|
|
156
|
+
onComplete,
|
|
157
|
+
onCancel,
|
|
158
|
+
onStepChange,
|
|
159
|
+
initialStep,
|
|
160
|
+
allowStepClick,
|
|
161
|
+
labels
|
|
162
|
+
}: WizardProps): import("react/jsx-runtime").JSX.Element;
|
|
163
|
+
displayName: string;
|
|
164
|
+
};
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/WizardContext.d.ts
|
|
167
|
+
/**
|
|
168
|
+
* Hook to access the wizard context from within step content.
|
|
169
|
+
*/
|
|
170
|
+
declare const useWizard: () => WizardContextValue;
|
|
171
|
+
//#endregion
|
|
172
|
+
export { Wizard, type WizardContextValue, type WizardLabels, type WizardLayout, type WizardProps, type WizardStep, type WizardStepStatus, type WizardVariant, useWizard };
|