@ttoss/react-wizard 0.4.7 → 0.4.9
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 +12 -12
- package/dist/esm/index.js +0 -483
- package/dist/index.d.ts +0 -158
- package/dist/index.js +0 -517
package/dist/esm/index.js
DELETED
|
@@ -1,483 +0,0 @@
|
|
|
1
|
-
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", {
|
|
5
|
-
value,
|
|
6
|
-
configurable: true
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
// src/Wizard.tsx
|
|
10
|
-
import { defineMessages, useI18n } from "@ttoss/react-i18n";
|
|
11
|
-
import { Box as Box2, Button, Flex as Flex2 } from "@ttoss/ui";
|
|
12
|
-
import * as React3 from "react";
|
|
13
|
-
|
|
14
|
-
// src/Wizard.styles.ts
|
|
15
|
-
import { keyframes } from "@ttoss/ui";
|
|
16
|
-
var gradientFlow = keyframes({
|
|
17
|
-
"0%": {
|
|
18
|
-
backgroundPosition: "0% 50%"
|
|
19
|
-
},
|
|
20
|
-
"50%": {
|
|
21
|
-
backgroundPosition: "100% 50%"
|
|
22
|
-
},
|
|
23
|
-
"100%": {
|
|
24
|
-
backgroundPosition: "0% 50%"
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
var getAccentGradientBackground = /* @__PURE__ */__name(t => {
|
|
28
|
-
const theme = t;
|
|
29
|
-
const start = theme.colors?.action?.background?.accent?.default || theme.colors?.input?.background?.accent?.default;
|
|
30
|
-
if (!start) return void 0;
|
|
31
|
-
const middle = theme.colors?.action?.background?.accent?.active || theme.colors?.input?.background?.accent?.active || start;
|
|
32
|
-
return `linear-gradient(270deg, ${start}, ${middle}, ${start})`;
|
|
33
|
-
}, "getAccentGradientBackground");
|
|
34
|
-
var getPrimaryGradientBackground = /* @__PURE__ */__name(t => {
|
|
35
|
-
const theme = t;
|
|
36
|
-
const start = theme.colors?.action?.background?.primary?.default;
|
|
37
|
-
if (!start) return void 0;
|
|
38
|
-
const middle = theme.colors?.action?.background?.secondary?.default || start;
|
|
39
|
-
return `linear-gradient(270deg, ${start}, ${middle}, ${start})`;
|
|
40
|
-
}, "getPrimaryGradientBackground");
|
|
41
|
-
var getVariantStyles = /* @__PURE__ */__name((variantType = "spotlight-accent") => {
|
|
42
|
-
const variants = {
|
|
43
|
-
"spotlight-accent": {
|
|
44
|
-
accentColor: "action.background.accent.default",
|
|
45
|
-
accentTextColor: "action.text.accent.default",
|
|
46
|
-
borderColor: "display.border.muted.default",
|
|
47
|
-
primaryButtonVariant: "accent",
|
|
48
|
-
gradientBackground: getAccentGradientBackground
|
|
49
|
-
},
|
|
50
|
-
"spotlight-primary": {
|
|
51
|
-
accentColor: "action.background.primary.default",
|
|
52
|
-
accentTextColor: "display.text.accent.default",
|
|
53
|
-
borderColor: "display.border.muted.default",
|
|
54
|
-
primaryButtonVariant: "primary",
|
|
55
|
-
gradientBackground: getPrimaryGradientBackground
|
|
56
|
-
},
|
|
57
|
-
primary: {
|
|
58
|
-
accentColor: "action.background.primary.default",
|
|
59
|
-
accentTextColor: "action.text.primary.default",
|
|
60
|
-
borderColor: "display.border.muted.default",
|
|
61
|
-
primaryButtonVariant: "primary"
|
|
62
|
-
},
|
|
63
|
-
secondary: {
|
|
64
|
-
accentColor: "action.background.secondary.default",
|
|
65
|
-
accentTextColor: "action.text.primary.default",
|
|
66
|
-
borderColor: "display.border.muted.default",
|
|
67
|
-
primaryButtonVariant: "secondary"
|
|
68
|
-
},
|
|
69
|
-
accent: {
|
|
70
|
-
accentColor: "action.background.accent.default",
|
|
71
|
-
accentTextColor: "action.text.accent.default",
|
|
72
|
-
borderColor: "display.border.muted.default",
|
|
73
|
-
primaryButtonVariant: "accent"
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
return variants[variantType] ?? variants["spotlight-accent"];
|
|
77
|
-
}, "getVariantStyles");
|
|
78
|
-
var getWizardShellSx = /* @__PURE__ */__name((variant = "spotlight-accent") => {
|
|
79
|
-
const variantStyles = getVariantStyles(variant);
|
|
80
|
-
return {
|
|
81
|
-
width: "100%",
|
|
82
|
-
minHeight: "300px",
|
|
83
|
-
border: "1px solid",
|
|
84
|
-
borderColor: variantStyles.borderColor,
|
|
85
|
-
borderRadius: "8px",
|
|
86
|
-
overflow: "hidden"
|
|
87
|
-
};
|
|
88
|
-
}, "getWizardShellSx");
|
|
89
|
-
var getWizardStepListSx = /* @__PURE__ */__name(({
|
|
90
|
-
layout,
|
|
91
|
-
variant = "spotlight-accent"
|
|
92
|
-
}) => {
|
|
93
|
-
const isHorizontal = layout === "top" || layout === "bottom";
|
|
94
|
-
const isSpotlight = variant.startsWith("spotlight-");
|
|
95
|
-
const variantStyles = getVariantStyles(variant);
|
|
96
|
-
return {
|
|
97
|
-
position: "relative",
|
|
98
|
-
padding: "6",
|
|
99
|
-
backgroundColor: variantStyles.accentColor,
|
|
100
|
-
...(isSpotlight ? {
|
|
101
|
-
background: variantStyles.gradientBackground,
|
|
102
|
-
backgroundSize: "400% 400%",
|
|
103
|
-
animation: `${gradientFlow} 6s ease infinite`
|
|
104
|
-
} : {}),
|
|
105
|
-
...(isHorizontal ? {
|
|
106
|
-
width: "100%"
|
|
107
|
-
} : {
|
|
108
|
-
minWidth: "200px"
|
|
109
|
-
})
|
|
110
|
-
};
|
|
111
|
-
}, "getWizardStepListSx");
|
|
112
|
-
var getWizardStepIndicatorSx = /* @__PURE__ */__name(({
|
|
113
|
-
status,
|
|
114
|
-
variant = "spotlight-accent",
|
|
115
|
-
isClickable
|
|
116
|
-
}) => {
|
|
117
|
-
const variantStyles = getVariantStyles(variant);
|
|
118
|
-
const isCompleted = status === "completed";
|
|
119
|
-
const isUpcoming = status === "upcoming";
|
|
120
|
-
return {
|
|
121
|
-
borderColor: variantStyles.accentTextColor,
|
|
122
|
-
backgroundColor: isCompleted ? variantStyles.accentTextColor : "transparent",
|
|
123
|
-
color: isCompleted ? variantStyles.accentColor : variantStyles.accentTextColor,
|
|
124
|
-
opacity: isUpcoming ? 0.4 : 1,
|
|
125
|
-
transition: "all 0.2s ease",
|
|
126
|
-
...(isClickable ? {
|
|
127
|
-
_hover: {
|
|
128
|
-
opacity: 1
|
|
129
|
-
}
|
|
130
|
-
} : {})
|
|
131
|
-
};
|
|
132
|
-
}, "getWizardStepIndicatorSx");
|
|
133
|
-
var getWizardStepSeparatorSx = /* @__PURE__ */__name(({
|
|
134
|
-
isCompleted,
|
|
135
|
-
variant = "spotlight-accent"
|
|
136
|
-
}) => {
|
|
137
|
-
const variantStyles = getVariantStyles(variant);
|
|
138
|
-
return {
|
|
139
|
-
backgroundColor: variantStyles.accentTextColor,
|
|
140
|
-
opacity: isCompleted ? 1 : 0.4
|
|
141
|
-
};
|
|
142
|
-
}, "getWizardStepSeparatorSx");
|
|
143
|
-
var getWizardStepTitleSx = /* @__PURE__ */__name(({
|
|
144
|
-
status,
|
|
145
|
-
variant = "spotlight-accent"
|
|
146
|
-
}) => {
|
|
147
|
-
const variantStyles = getVariantStyles(variant);
|
|
148
|
-
return {
|
|
149
|
-
color: variantStyles.accentTextColor,
|
|
150
|
-
textAlign: "center",
|
|
151
|
-
fontWeight: status === "active" ? "bold" : "normal",
|
|
152
|
-
opacity: status === "upcoming" ? 0.4 : 1
|
|
153
|
-
};
|
|
154
|
-
}, "getWizardStepTitleSx");
|
|
155
|
-
var getWizardStepDescriptionSx = /* @__PURE__ */__name(({
|
|
156
|
-
status,
|
|
157
|
-
variant = "spotlight-accent"
|
|
158
|
-
}) => {
|
|
159
|
-
const variantStyles = getVariantStyles(variant);
|
|
160
|
-
return {
|
|
161
|
-
color: variantStyles.accentTextColor,
|
|
162
|
-
textAlign: "center",
|
|
163
|
-
opacity: status === "upcoming" ? 0.4 : 1
|
|
164
|
-
};
|
|
165
|
-
}, "getWizardStepDescriptionSx");
|
|
166
|
-
var WizardStepDescriptionFlexSx = {
|
|
167
|
-
flexDirection: "row",
|
|
168
|
-
alignItems: "center",
|
|
169
|
-
justifyContent: "center"
|
|
170
|
-
};
|
|
171
|
-
var WizardStepTextWrapperSx = {
|
|
172
|
-
textAlign: "center"
|
|
173
|
-
};
|
|
174
|
-
var getWizardPrimaryButtonVariant = /* @__PURE__ */__name((variant = "spotlight-accent") => {
|
|
175
|
-
return getVariantStyles(variant).primaryButtonVariant;
|
|
176
|
-
}, "getWizardPrimaryButtonVariant");
|
|
177
|
-
|
|
178
|
-
// src/WizardContext.ts
|
|
179
|
-
import * as React2 from "react";
|
|
180
|
-
var WizardContext = React2.createContext(null);
|
|
181
|
-
var useWizard = /* @__PURE__ */__name(() => {
|
|
182
|
-
const context = React2.useContext(WizardContext);
|
|
183
|
-
if (!context) {
|
|
184
|
-
throw new Error("useWizard must be used within a Wizard component.");
|
|
185
|
-
}
|
|
186
|
-
return context;
|
|
187
|
-
}, "useWizard");
|
|
188
|
-
|
|
189
|
-
// src/WizardStepList.tsx
|
|
190
|
-
import { Steps } from "@chakra-ui/react";
|
|
191
|
-
import { Box, Flex } from "@ttoss/ui";
|
|
192
|
-
var WizardStepList = /* @__PURE__ */__name(({
|
|
193
|
-
steps,
|
|
194
|
-
currentStep,
|
|
195
|
-
layout,
|
|
196
|
-
variant,
|
|
197
|
-
allowStepClick,
|
|
198
|
-
getStepStatus,
|
|
199
|
-
onStepClick
|
|
200
|
-
}) => {
|
|
201
|
-
const isHorizontal = layout === "top" || layout === "bottom";
|
|
202
|
-
const orientation = isHorizontal ? "horizontal" : "vertical";
|
|
203
|
-
return /* @__PURE__ */React.createElement(Flex, {
|
|
204
|
-
role: "navigation",
|
|
205
|
-
"aria-label": "Wizard steps",
|
|
206
|
-
"data-variant": variant,
|
|
207
|
-
sx: getWizardStepListSx({
|
|
208
|
-
layout,
|
|
209
|
-
variant
|
|
210
|
-
})
|
|
211
|
-
}, /* @__PURE__ */React.createElement(Steps.Root, {
|
|
212
|
-
step: currentStep,
|
|
213
|
-
count: steps.length,
|
|
214
|
-
orientation
|
|
215
|
-
}, /* @__PURE__ */React.createElement(Steps.List, null, steps.map((step, index) => {
|
|
216
|
-
const status = getStepStatus({
|
|
217
|
-
stepIndex: index
|
|
218
|
-
});
|
|
219
|
-
const isClickable = allowStepClick && status === "completed" && index !== currentStep;
|
|
220
|
-
return /* @__PURE__ */React.createElement(Steps.Item, {
|
|
221
|
-
key: index,
|
|
222
|
-
index
|
|
223
|
-
}, /* @__PURE__ */React.createElement(Flex, {
|
|
224
|
-
sx: {
|
|
225
|
-
flexDirection: isHorizontal ? "column" : "row",
|
|
226
|
-
alignItems: "center",
|
|
227
|
-
gap: "2"
|
|
228
|
-
}
|
|
229
|
-
}, /* @__PURE__ */React.createElement(Box, {
|
|
230
|
-
role: "button",
|
|
231
|
-
tabIndex: isClickable ? 0 : -1,
|
|
232
|
-
onClick: /* @__PURE__ */__name(() => {
|
|
233
|
-
if (isClickable) {
|
|
234
|
-
onStepClick({
|
|
235
|
-
stepIndex: index
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
}, "onClick"),
|
|
239
|
-
onKeyDown: /* @__PURE__ */__name(e => {
|
|
240
|
-
if (isClickable && (e.key === "Enter" || e.key === " ")) {
|
|
241
|
-
e.preventDefault();
|
|
242
|
-
onStepClick({
|
|
243
|
-
stepIndex: index
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
}, "onKeyDown"),
|
|
247
|
-
"aria-current": status === "active" ? "step" : void 0,
|
|
248
|
-
sx: {
|
|
249
|
-
cursor: isClickable ? "pointer" : "default"
|
|
250
|
-
}
|
|
251
|
-
}, /* @__PURE__ */React.createElement(Steps.Indicator, {
|
|
252
|
-
css: getWizardStepIndicatorSx({
|
|
253
|
-
status,
|
|
254
|
-
variant,
|
|
255
|
-
isClickable
|
|
256
|
-
})
|
|
257
|
-
}, /* @__PURE__ */React.createElement(Steps.Status, {
|
|
258
|
-
complete: "\u2713",
|
|
259
|
-
incomplete: /* @__PURE__ */React.createElement(Steps.Number, null)
|
|
260
|
-
}))), (step.title || step.description) && /* @__PURE__ */React.createElement(Box, {
|
|
261
|
-
sx: WizardStepTextWrapperSx
|
|
262
|
-
}, step.title && /* @__PURE__ */React.createElement(Steps.Title, {
|
|
263
|
-
css: getWizardStepTitleSx({
|
|
264
|
-
status,
|
|
265
|
-
variant
|
|
266
|
-
})
|
|
267
|
-
}, step.title), step.description && /* @__PURE__ */React.createElement(Flex, {
|
|
268
|
-
sx: WizardStepDescriptionFlexSx
|
|
269
|
-
}, /* @__PURE__ */React.createElement(Steps.Description, {
|
|
270
|
-
css: getWizardStepDescriptionSx({
|
|
271
|
-
status,
|
|
272
|
-
variant
|
|
273
|
-
})
|
|
274
|
-
}, step.description)))), index < steps.length - 1 && /* @__PURE__ */React.createElement(Steps.Separator, {
|
|
275
|
-
css: getWizardStepSeparatorSx({
|
|
276
|
-
isCompleted: index < currentStep,
|
|
277
|
-
variant
|
|
278
|
-
})
|
|
279
|
-
}));
|
|
280
|
-
}))));
|
|
281
|
-
}, "WizardStepList");
|
|
282
|
-
|
|
283
|
-
// src/Wizard.tsx
|
|
284
|
-
var messages = defineMessages({
|
|
285
|
-
previous: {
|
|
286
|
-
id: "60eH0J",
|
|
287
|
-
defaultMessage: [{
|
|
288
|
-
"type": 0,
|
|
289
|
-
"value": "Previous"
|
|
290
|
-
}]
|
|
291
|
-
},
|
|
292
|
-
next: {
|
|
293
|
-
id: "FmaVut",
|
|
294
|
-
defaultMessage: [{
|
|
295
|
-
"type": 0,
|
|
296
|
-
"value": "Next"
|
|
297
|
-
}]
|
|
298
|
-
},
|
|
299
|
-
finish: {
|
|
300
|
-
id: "5lZ8VT",
|
|
301
|
-
defaultMessage: [{
|
|
302
|
-
"type": 0,
|
|
303
|
-
"value": "Finish"
|
|
304
|
-
}]
|
|
305
|
-
},
|
|
306
|
-
cancel: {
|
|
307
|
-
id: "6I9gjk",
|
|
308
|
-
defaultMessage: [{
|
|
309
|
-
"type": 0,
|
|
310
|
-
"value": "Cancel"
|
|
311
|
-
}]
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
var getFlexDirection = /* @__PURE__ */__name(layout => {
|
|
315
|
-
switch (layout) {
|
|
316
|
-
case "top":
|
|
317
|
-
return "column";
|
|
318
|
-
case "bottom":
|
|
319
|
-
return "column-reverse";
|
|
320
|
-
case "left":
|
|
321
|
-
return "row";
|
|
322
|
-
case "right":
|
|
323
|
-
return "row-reverse";
|
|
324
|
-
}
|
|
325
|
-
}, "getFlexDirection");
|
|
326
|
-
var Wizard = /* @__PURE__ */__name(({
|
|
327
|
-
steps,
|
|
328
|
-
layout = "top",
|
|
329
|
-
variant = "spotlight-accent",
|
|
330
|
-
onComplete,
|
|
331
|
-
onCancel,
|
|
332
|
-
onStepChange,
|
|
333
|
-
initialStep = 0,
|
|
334
|
-
allowStepClick = true,
|
|
335
|
-
labels
|
|
336
|
-
}) => {
|
|
337
|
-
const {
|
|
338
|
-
intl
|
|
339
|
-
} = useI18n();
|
|
340
|
-
const [currentStep, setCurrentStep] = React3.useState(initialStep);
|
|
341
|
-
const stepValidationRef = React3.useRef(null);
|
|
342
|
-
const totalSteps = steps.length;
|
|
343
|
-
const isFirstStep = currentStep === 0;
|
|
344
|
-
const isLastStep = currentStep === totalSteps - 1;
|
|
345
|
-
const buttonLabels = React3.useMemo(() => {
|
|
346
|
-
return {
|
|
347
|
-
previous: labels?.previous ?? intl.formatMessage(messages.previous),
|
|
348
|
-
next: labels?.next ?? intl.formatMessage(messages.next),
|
|
349
|
-
finish: labels?.finish ?? intl.formatMessage(messages.finish),
|
|
350
|
-
cancel: labels?.cancel ?? intl.formatMessage(messages.cancel)
|
|
351
|
-
};
|
|
352
|
-
}, [intl, labels]);
|
|
353
|
-
const getStepStatus = React3.useCallback(({
|
|
354
|
-
stepIndex
|
|
355
|
-
}) => {
|
|
356
|
-
if (stepIndex < currentStep) {
|
|
357
|
-
return "completed";
|
|
358
|
-
}
|
|
359
|
-
if (stepIndex === currentStep) {
|
|
360
|
-
return "active";
|
|
361
|
-
}
|
|
362
|
-
return "upcoming";
|
|
363
|
-
}, [currentStep]);
|
|
364
|
-
const goToNext = React3.useCallback(async () => {
|
|
365
|
-
const step = steps[currentStep];
|
|
366
|
-
if (stepValidationRef.current) {
|
|
367
|
-
const canProceed = await stepValidationRef.current();
|
|
368
|
-
if (!canProceed) {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
if (step.onNext) {
|
|
373
|
-
const canProceed = await step.onNext();
|
|
374
|
-
if (!canProceed) {
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
if (isLastStep) {
|
|
379
|
-
onComplete?.();
|
|
380
|
-
} else {
|
|
381
|
-
const nextStep = currentStep + 1;
|
|
382
|
-
stepValidationRef.current = null;
|
|
383
|
-
setCurrentStep(nextStep);
|
|
384
|
-
onStepChange?.({
|
|
385
|
-
stepIndex: nextStep
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
}, [currentStep, steps, isLastStep, onComplete, onStepChange]);
|
|
389
|
-
const goToPrevious = React3.useCallback(() => {
|
|
390
|
-
if (!isFirstStep) {
|
|
391
|
-
const prevStep = currentStep - 1;
|
|
392
|
-
stepValidationRef.current = null;
|
|
393
|
-
setCurrentStep(prevStep);
|
|
394
|
-
onStepChange?.({
|
|
395
|
-
stepIndex: prevStep
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
}, [currentStep, isFirstStep, onStepChange]);
|
|
399
|
-
const goToStep = React3.useCallback(({
|
|
400
|
-
stepIndex
|
|
401
|
-
}) => {
|
|
402
|
-
if (stepIndex >= 0 && stepIndex < totalSteps && stepIndex <= currentStep) {
|
|
403
|
-
stepValidationRef.current = null;
|
|
404
|
-
setCurrentStep(stepIndex);
|
|
405
|
-
onStepChange?.({
|
|
406
|
-
stepIndex
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
}, [currentStep, totalSteps, onStepChange]);
|
|
410
|
-
const setStepValidation = React3.useCallback(validate => {
|
|
411
|
-
stepValidationRef.current = validate;
|
|
412
|
-
}, []);
|
|
413
|
-
const contextValue = React3.useMemo(() => {
|
|
414
|
-
return {
|
|
415
|
-
currentStep,
|
|
416
|
-
totalSteps,
|
|
417
|
-
goToNext,
|
|
418
|
-
goToPrevious,
|
|
419
|
-
goToStep,
|
|
420
|
-
isFirstStep,
|
|
421
|
-
isLastStep,
|
|
422
|
-
getStepStatus,
|
|
423
|
-
setStepValidation
|
|
424
|
-
};
|
|
425
|
-
}, [currentStep, totalSteps, goToNext, goToPrevious, goToStep, isFirstStep, isLastStep, getStepStatus, setStepValidation]);
|
|
426
|
-
return /* @__PURE__ */React3.createElement(WizardContext.Provider, {
|
|
427
|
-
value: contextValue
|
|
428
|
-
}, /* @__PURE__ */React3.createElement(Flex2, {
|
|
429
|
-
"data-variant": variant,
|
|
430
|
-
sx: {
|
|
431
|
-
flexDirection: getFlexDirection(layout),
|
|
432
|
-
...getWizardShellSx(variant)
|
|
433
|
-
}
|
|
434
|
-
}, /* @__PURE__ */React3.createElement(WizardStepList, {
|
|
435
|
-
steps,
|
|
436
|
-
currentStep,
|
|
437
|
-
layout,
|
|
438
|
-
variant,
|
|
439
|
-
allowStepClick,
|
|
440
|
-
getStepStatus,
|
|
441
|
-
onStepClick: goToStep
|
|
442
|
-
}), /* @__PURE__ */React3.createElement(Flex2, {
|
|
443
|
-
sx: {
|
|
444
|
-
flexDirection: "column",
|
|
445
|
-
flex: 1,
|
|
446
|
-
padding: "6"
|
|
447
|
-
}
|
|
448
|
-
}, /* @__PURE__ */React3.createElement(Box2, {
|
|
449
|
-
sx: {
|
|
450
|
-
flex: 1,
|
|
451
|
-
marginBottom: "4"
|
|
452
|
-
}
|
|
453
|
-
}, steps[currentStep].content), /* @__PURE__ */React3.createElement(Flex2, {
|
|
454
|
-
sx: {
|
|
455
|
-
justifyContent: "space-between",
|
|
456
|
-
alignItems: "center",
|
|
457
|
-
gap: "3"
|
|
458
|
-
}
|
|
459
|
-
}, /* @__PURE__ */React3.createElement(Flex2, {
|
|
460
|
-
sx: {
|
|
461
|
-
gap: "3"
|
|
462
|
-
}
|
|
463
|
-
}, onCancel && /* @__PURE__ */React3.createElement(Button, {
|
|
464
|
-
variant: "secondary",
|
|
465
|
-
onClick: onCancel,
|
|
466
|
-
"aria-label": buttonLabels.cancel
|
|
467
|
-
}, buttonLabels.cancel)), /* @__PURE__ */React3.createElement(Flex2, {
|
|
468
|
-
sx: {
|
|
469
|
-
gap: "3"
|
|
470
|
-
}
|
|
471
|
-
}, /* @__PURE__ */React3.createElement(Button, {
|
|
472
|
-
variant: "secondary",
|
|
473
|
-
onClick: goToPrevious,
|
|
474
|
-
disabled: isFirstStep,
|
|
475
|
-
"aria-label": buttonLabels.previous
|
|
476
|
-
}, buttonLabels.previous), /* @__PURE__ */React3.createElement(Button, {
|
|
477
|
-
variant: getWizardPrimaryButtonVariant(variant),
|
|
478
|
-
onClick: goToNext,
|
|
479
|
-
"aria-label": isLastStep ? buttonLabels.finish : buttonLabels.next
|
|
480
|
-
}, isLastStep ? buttonLabels.finish : buttonLabels.next))))));
|
|
481
|
-
}, "Wizard");
|
|
482
|
-
Wizard.displayName = "Wizard";
|
|
483
|
-
export { Wizard, useWizard };
|
package/dist/index.d.ts
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
|
|
4
|
-
type WizardVariant = 'spotlight-accent' | 'spotlight-primary' | 'primary' | 'secondary' | 'accent';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Position of the step list relative to the wizard content.
|
|
8
|
-
*/
|
|
9
|
-
type WizardLayout = 'top' | 'right' | 'bottom' | 'left';
|
|
10
|
-
/**
|
|
11
|
-
* Status of a wizard step.
|
|
12
|
-
*/
|
|
13
|
-
type WizardStepStatus = 'completed' | 'active' | 'upcoming';
|
|
14
|
-
/**
|
|
15
|
-
* Definition of a single wizard step.
|
|
16
|
-
*/
|
|
17
|
-
interface WizardStep {
|
|
18
|
-
/**
|
|
19
|
-
* Title displayed in the step list.
|
|
20
|
-
*/
|
|
21
|
-
title: string;
|
|
22
|
-
/**
|
|
23
|
-
* Optional description displayed below the title in the step list.
|
|
24
|
-
*/
|
|
25
|
-
description?: string;
|
|
26
|
-
/**
|
|
27
|
-
* The content rendered when this step is active.
|
|
28
|
-
*/
|
|
29
|
-
content: React.ReactNode;
|
|
30
|
-
/**
|
|
31
|
-
* Called when the user clicks "Next". If it returns false or
|
|
32
|
-
* a Promise that resolves to false, the wizard will not advance.
|
|
33
|
-
*/
|
|
34
|
-
onNext?: () => boolean | Promise<boolean>;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Props for the Wizard component.
|
|
38
|
-
*/
|
|
39
|
-
interface WizardProps {
|
|
40
|
-
/**
|
|
41
|
-
* Array of steps to display in the wizard.
|
|
42
|
-
*/
|
|
43
|
-
steps: WizardStep[];
|
|
44
|
-
/**
|
|
45
|
-
* Position of the step list. Defaults to 'top'.
|
|
46
|
-
*/
|
|
47
|
-
layout?: WizardLayout;
|
|
48
|
-
/**
|
|
49
|
-
* Visual variant for the wizard shell, step accents, and primary action.
|
|
50
|
-
* @default 'spotlight-accent'
|
|
51
|
-
*/
|
|
52
|
-
variant?: WizardVariant;
|
|
53
|
-
/**
|
|
54
|
-
* Called when the wizard completes (user clicks "Finish" on the last step).
|
|
55
|
-
*/
|
|
56
|
-
onComplete?: () => void;
|
|
57
|
-
/**
|
|
58
|
-
* Called when the user clicks "Cancel".
|
|
59
|
-
* If not provided, the Cancel button is not rendered.
|
|
60
|
-
*/
|
|
61
|
-
onCancel?: () => void;
|
|
62
|
-
/**
|
|
63
|
-
* Called whenever the active step changes.
|
|
64
|
-
*/
|
|
65
|
-
onStepChange?: (params: {
|
|
66
|
-
stepIndex: number;
|
|
67
|
-
}) => void;
|
|
68
|
-
/**
|
|
69
|
-
* The initially active step index. Defaults to 0.
|
|
70
|
-
*/
|
|
71
|
-
initialStep?: number;
|
|
72
|
-
/**
|
|
73
|
-
* Allow clicking on completed steps to navigate back.
|
|
74
|
-
* Defaults to true.
|
|
75
|
-
*/
|
|
76
|
-
allowStepClick?: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Optional custom labels for the navigation buttons.
|
|
79
|
-
*/
|
|
80
|
-
labels?: Partial<WizardLabels>;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Customizable labels used by the wizard navigation buttons.
|
|
84
|
-
*/
|
|
85
|
-
interface WizardLabels {
|
|
86
|
-
previous: string;
|
|
87
|
-
next: string;
|
|
88
|
-
finish: string;
|
|
89
|
-
cancel: string;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Context value exposed by WizardProvider.
|
|
93
|
-
*/
|
|
94
|
-
interface WizardContextValue {
|
|
95
|
-
/**
|
|
96
|
-
* Current active step index.
|
|
97
|
-
*/
|
|
98
|
-
currentStep: number;
|
|
99
|
-
/**
|
|
100
|
-
* Total number of steps.
|
|
101
|
-
*/
|
|
102
|
-
totalSteps: number;
|
|
103
|
-
/**
|
|
104
|
-
* Navigate to the next step.
|
|
105
|
-
*/
|
|
106
|
-
goToNext: () => Promise<void>;
|
|
107
|
-
/**
|
|
108
|
-
* Navigate to the previous step.
|
|
109
|
-
*/
|
|
110
|
-
goToPrevious: () => void;
|
|
111
|
-
/**
|
|
112
|
-
* Navigate to a specific step (only if it's completed or active).
|
|
113
|
-
*/
|
|
114
|
-
goToStep: (params: {
|
|
115
|
-
stepIndex: number;
|
|
116
|
-
}) => void;
|
|
117
|
-
/**
|
|
118
|
-
* Whether the wizard is on the first step.
|
|
119
|
-
*/
|
|
120
|
-
isFirstStep: boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Whether the wizard is on the last step.
|
|
123
|
-
*/
|
|
124
|
-
isLastStep: boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Get the status of a step by index.
|
|
127
|
-
*/
|
|
128
|
-
getStepStatus: (params: {
|
|
129
|
-
stepIndex: number;
|
|
130
|
-
}) => WizardStepStatus;
|
|
131
|
-
/**
|
|
132
|
-
* Register a validation function for the current step.
|
|
133
|
-
* This allows step content components to provide their own validation logic.
|
|
134
|
-
*/
|
|
135
|
-
setStepValidation: (validate: () => boolean | Promise<boolean>) => void;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Renders a multi-step wizard with step navigation, localized action labels,
|
|
140
|
-
* and support for completion, cancellation, and step changes.
|
|
141
|
-
*
|
|
142
|
-
* @param props - Wizard configuration and step content.
|
|
143
|
-
* @param props.steps - The ordered steps displayed in the wizard.
|
|
144
|
-
* @param props.onComplete - Called when the user finishes the last step.
|
|
145
|
-
* @param props.onCancel - Called when the user cancels the wizard.
|
|
146
|
-
* @param props.onStepChange - Called when the current step changes.
|
|
147
|
-
*/
|
|
148
|
-
declare const Wizard: {
|
|
149
|
-
({ steps, layout, variant, onComplete, onCancel, onStepChange, initialStep, allowStepClick, labels, }: WizardProps): react_jsx_runtime.JSX.Element;
|
|
150
|
-
displayName: string;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Hook to access the wizard context from within step content.
|
|
155
|
-
*/
|
|
156
|
-
declare const useWizard: () => WizardContextValue;
|
|
157
|
-
|
|
158
|
-
export { Wizard, type WizardContextValue, type WizardLabels, type WizardLayout, type WizardProps, type WizardStep, type WizardStepStatus, type WizardVariant, useWizard };
|