@dt-dds/react-stepper 1.0.0-beta.46 → 1.0.0-beta.48

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.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
9
  var __getProtoOf = Object.getPrototypeOf;
@@ -19,6 +21,7 @@ var __spreadValues = (a, b) => {
19
21
  }
20
22
  return a;
21
23
  };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
25
  var __export = (target, all) => {
23
26
  for (var name in all)
24
27
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -44,217 +47,520 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
44
47
  // index.ts
45
48
  var index_exports = {};
46
49
  __export(index_exports, {
47
- Counter: () => Counter,
48
- Step: () => Step_default,
50
+ Step: () => Step,
49
51
  Stepper: () => Stepper,
50
52
  useStepper: () => useStepper
51
53
  });
52
54
  module.exports = __toCommonJS(index_exports);
53
55
 
54
- // src/Stepper.styled.ts
56
+ // src/Stepper.tsx
57
+ var import_react3 = require("react");
58
+
59
+ // src/components/Step/Step.styled.ts
55
60
  var import_styled = __toESM(require("@emotion/styled"));
56
- var StepperStyled = import_styled.default.ul`
61
+
62
+ // src/constants/index.ts
63
+ var VERTICAL_TRAIL_LINE_MIN_HEIGHT = 24;
64
+ var HORIZONTAL_TRAIL_LINE_MIN_WIDTH = 80;
65
+ var STEP_MIN_WIDTH = 120;
66
+ var STEP_CONTENT_MAX_WIDTH = 112;
67
+ var VERTICAL_LAST_STEP_INDICATOR_MIN_HEIGHT = 24;
68
+ var VERTICAL_STEP_INDICATOR_MIN_HEIGHT = 56;
69
+ var HORIZONTAL_TRAIL_LINE_START_OFFSET = 20;
70
+ var VERTICAL_TRAIL_LINE_TOP_OFFSET = 32;
71
+ var VERTICAL_TRAIL_LINE_LEFT_OFFSET = 12;
72
+
73
+ // src/components/Step/Step.styled.ts
74
+ var StepContainer = import_styled.default.div`
75
+ display: flex;
76
+ position: relative;
77
+ overflow: visible;
78
+ gap: 8px;
79
+
80
+ ${({ orientation, isLast, isDisabled }) => {
81
+ if (orientation === "horizontal") {
82
+ return `
83
+ flex-direction: column;
84
+ align-items: center;
85
+ flex: 1 1 0;
86
+ min-width: ${STEP_MIN_WIDTH}px;
87
+ `;
88
+ }
89
+ return `
90
+ flex-direction: row;
91
+ padding-bottom: ${isLast ? "0" : "8px"};
92
+ cursor: ${isDisabled ? "not-allowed" : "pointer"};
93
+ `;
94
+ }}
95
+ `;
96
+ var StepIndicatorWrapper = import_styled.default.div`
97
+ display: flex;
98
+ position: relative;
99
+
100
+ ${({ orientation, isLast }) => {
101
+ if (orientation === "horizontal") {
102
+ return `
103
+ width: 100%;
104
+ flex-direction: row;
105
+ justify-content: center;
106
+ `;
107
+ }
108
+ return `
109
+ flex-direction: column;
110
+ align-self: flex-start;
111
+ min-height: ${isLast ? `${VERTICAL_LAST_STEP_INDICATOR_MIN_HEIGHT}px` : `${VERTICAL_STEP_INDICATOR_MIN_HEIGHT}px`};
112
+ `;
113
+ }}
114
+ `;
115
+
116
+ // src/components/StepContent/StepContent.tsx
117
+ var import_react = require("react");
118
+ var import_react_tooltip = require("@dt-dds/react-tooltip");
119
+
120
+ // src/components/StepContent/StepContent.styled.ts
121
+ var import_styled2 = __toESM(require("@emotion/styled"));
122
+ var StepContentStyled = import_styled2.default.div`
57
123
  display: flex;
58
124
  flex-direction: column;
59
- gap: 32px;
60
- list-style: none;
125
+ gap: 4px;
126
+ max-width: ${STEP_CONTENT_MAX_WIDTH}px;
61
127
 
62
- ${({ theme, orientation = "vertical" }) => `
63
- @media only screen and (min-width: ${theme.breakpoints.mq3d}px) {
64
- flex-direction: ${orientation === "horizontal" ? "row" : "column"}
65
- }
66
- `}
128
+ & > * {
129
+ min-width: 0;
130
+ max-width: 100%;
131
+ }
132
+
133
+ ${({ orientation }) => orientation === "horizontal" ? `
134
+ align-items: center;
135
+ text-align: center;
136
+ ` : `
137
+ align-items: flex-start;
138
+ text-align: left;
139
+ padding-top: 4px;
140
+ `}
141
+ `;
142
+ var StepTitleStyled = import_styled2.default.span`
143
+ ${({ theme, state, isActive }) => {
144
+ const getColor = () => {
145
+ if (state === "disabled") return theme.palette.content.light;
146
+ if (state === "error") return theme.palette.error.default;
147
+ return theme.palette.content.dark;
148
+ };
149
+ return `
150
+ ${isActive ? theme.fontStyles.bodyMdBold : theme.fontStyles.bodyMdRegular}
151
+ color: ${getColor()};
152
+ white-space: nowrap;
153
+ overflow: hidden;
154
+ text-overflow: ellipsis;
155
+ `;
156
+ }}
157
+ `;
158
+ var StepDescriptionStyled = import_styled2.default.span`
159
+ ${({ theme, state }) => {
160
+ const getColor = () => {
161
+ if (state === "disabled") return theme.palette.content.light;
162
+ if (state === "error") return theme.palette.error.default;
163
+ if (state === "warning") return theme.palette.content.default;
164
+ return theme.palette.primary.medium;
165
+ };
166
+ return `
167
+ ${theme.fontStyles.bodySmRegular}
168
+ color: ${getColor()};
169
+ display: -webkit-box;
170
+ -webkit-line-clamp: 2;
171
+ -webkit-box-orient: vertical;
172
+ overflow: hidden;
173
+ text-overflow: ellipsis;
174
+ `;
175
+ }}
67
176
  `;
68
177
 
69
- // src/Stepper.tsx
178
+ // src/components/StepContent/StepContent.tsx
70
179
  var import_jsx_runtime = require("react/jsx-runtime");
71
- var Stepper = ({
72
- children,
73
- dataTestId,
180
+ var StepContent = ({
181
+ title,
182
+ description,
183
+ state,
184
+ isActive,
74
185
  orientation
75
186
  }) => {
76
- const testId = dataTestId != null ? dataTestId : "default";
77
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StepperStyled, { "data-testid": `${testId}-stepper`, orientation, children });
187
+ const titleRef = (0, import_react.useRef)(null);
188
+ const descRef = (0, import_react.useRef)(null);
189
+ const [showTitleTooltip, setShowTitleTooltip] = (0, import_react.useState)(false);
190
+ const [showDescTooltip, setShowDescTooltip] = (0, import_react.useState)(false);
191
+ (0, import_react.useEffect)(() => {
192
+ if (titleRef.current && title) {
193
+ const element = titleRef.current;
194
+ setShowTitleTooltip(element.scrollWidth > element.clientWidth);
195
+ }
196
+ if (descRef.current && description) {
197
+ const element = descRef.current;
198
+ setShowDescTooltip(element.scrollHeight > element.clientHeight);
199
+ }
200
+ }, [title, description, orientation]);
201
+ if (!title && !description) {
202
+ return null;
203
+ }
204
+ const renderContent = (content, ref, showTooltip, Component, componentProps) => {
205
+ if (!content) {
206
+ return null;
207
+ }
208
+ const element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, __spreadProps(__spreadValues({}, componentProps), { ref, children: content }));
209
+ if (showTooltip) {
210
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_tooltip.Tooltip, { children: [
211
+ element,
212
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_tooltip.Tooltip.Content, { direction: "right", children: content })
213
+ ] });
214
+ }
215
+ return element;
216
+ };
217
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StepContentStyled, { orientation, children: [
218
+ renderContent(title, titleRef, showTitleTooltip, StepTitleStyled, {
219
+ state,
220
+ isActive
221
+ }),
222
+ renderContent(
223
+ description,
224
+ descRef,
225
+ showDescTooltip,
226
+ StepDescriptionStyled,
227
+ { state }
228
+ )
229
+ ] });
78
230
  };
79
231
 
80
- // src/components/Step/Step.tsx
81
- var import_react = require("react");
232
+ // src/components/StepIndicator/StepIndicator.tsx
82
233
  var import_react2 = require("@emotion/react");
83
234
  var import_react_icon = require("@dt-dds/react-icon");
84
- var import_react_typography = require("@dt-dds/react-typography");
85
235
 
86
- // src/components/Counter/Counter.styled.ts
87
- var import_styled2 = __toESM(require("@emotion/styled"));
88
- var CounterStyled = import_styled2.default.span`
89
- ${({ theme, color, outlined, isLarge }) => `
90
- ${theme.fontStyles.bodySmRegular}
91
- color: ${theme.palette.content.contrast};
92
- border: ${theme.spacing.spacing_0};
93
- align-items: center;
94
- justify-content: center;
95
- display: flex;
96
- width: ${isLarge ? "24px" : "16px"};
97
- height: ${isLarge ? "24px" : "16px"};
98
- border-radius: 50%;
99
- background-color: ${color === "disabled" ? theme.palette.content.default : theme.palette[color].default};
236
+ // src/components/StepIndicator/StepIndicator.styled.ts
237
+ var import_styled3 = __toESM(require("@emotion/styled"));
238
+ var StepIndicatorStyled = import_styled3.default.div`
239
+ display: flex;
240
+ align-items: center;
241
+ justify-content: center;
242
+ width: 24px;
243
+ height: 24px;
244
+ border-radius: 50%;
245
+ flex-shrink: 0;
246
+ transition: transform 0.2s ease;
100
247
 
101
- ${outlined && `
102
- border: 2px solid ${color === "disabled" ? theme.palette.content.light : theme.palette[color].default};
103
- color: ${color === "disabled" ? theme.palette.content.light : theme.palette[color].default};
104
- background-color: ${theme.palette.surface.contrast}
105
- `};
106
- `}
248
+ ${({ theme, state, isActive, variant }) => {
249
+ const activeBgColor = isActive ? theme.palette.primary.light : theme.palette.content.contrast;
250
+ const colorMap = {
251
+ completed: {
252
+ bg: theme.palette.primary.default,
253
+ border: theme.palette.primary.default
254
+ },
255
+ warning: {
256
+ bg: theme.palette.warning.default,
257
+ border: "transparent"
258
+ },
259
+ error: {
260
+ bg: theme.palette.error.default,
261
+ border: "transparent"
262
+ },
263
+ disabled: {
264
+ bg: theme.palette.content.contrast,
265
+ border: theme.palette.border.medium,
266
+ text: theme.palette.content.light
267
+ },
268
+ incomplete: {
269
+ bg: activeBgColor,
270
+ border: theme.palette.primary.default,
271
+ text: theme.palette.primary.default
272
+ }
273
+ };
274
+ const colors = colorMap[state] || colorMap.incomplete;
275
+ const disabledBorderColor = state === "disabled" ? theme.palette.border.medium : theme.palette.primary.default;
276
+ if (variant === "bullet" && (state === "incomplete" || state === "disabled")) {
277
+ return `
278
+ background-color: ${activeBgColor};
279
+ border: 1px solid ${disabledBorderColor};
280
+
281
+ &::after {
282
+ content: '';
283
+ width: 10px;
284
+ height: 10px;
285
+ border-radius: 50%;
286
+ background-color: ${state === "disabled" ? theme.palette.content.light : theme.palette.primary.default};
287
+ }
288
+ `;
289
+ }
290
+ if (variant === "icon" && state === "disabled") {
291
+ return `
292
+ border: 1px solid ${disabledBorderColor};
293
+
294
+ > i {
295
+ color: ${theme.palette.content.light};
296
+ }
297
+ `;
298
+ }
299
+ return `
300
+ background-color: ${colors.bg};
301
+ border: 1px solid ${colors.border};
302
+ color: ${colors.text};
303
+ ${theme.fontStyles.bodySmBold}
304
+ `;
305
+ }}
107
306
  `;
108
307
 
109
- // src/components/Counter/Counter.tsx
308
+ // src/components/StepIndicator/StepIndicator.tsx
110
309
  var import_jsx_runtime2 = require("react/jsx-runtime");
111
- var Counter = ({
112
- children,
113
- color = "informative",
114
- dataTestId,
115
- style,
116
- outlined = false,
117
- isLarge = false
310
+ var StepIndicator = ({
311
+ index,
312
+ state,
313
+ variant,
314
+ isActive,
315
+ icon
118
316
  }) => {
317
+ const theme = (0, import_react2.useTheme)();
318
+ const getIndicatorContent = () => {
319
+ const iconMap = {
320
+ completed: "check",
321
+ warning: "warning",
322
+ error: "error"
323
+ };
324
+ if (iconMap[state]) {
325
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
326
+ import_react_icon.Icon,
327
+ {
328
+ code: iconMap[state],
329
+ color: theme.palette.content.contrast,
330
+ size: "small"
331
+ }
332
+ );
333
+ }
334
+ if (variant === "bullet") {
335
+ return null;
336
+ }
337
+ if (variant === "icon" && icon) {
338
+ return icon;
339
+ }
340
+ return index + 1;
341
+ };
119
342
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
120
- CounterStyled,
343
+ StepIndicatorStyled,
121
344
  {
122
- color,
123
- "data-testid": dataTestId != null ? dataTestId : "counter",
124
- isLarge,
125
- outlined,
126
- style,
127
- children
345
+ "data-testid": "step-indicator",
346
+ isActive,
347
+ state,
348
+ variant,
349
+ children: getIndicatorContent()
128
350
  }
129
351
  );
130
352
  };
131
353
 
132
- // src/components/Step/Step.styled.ts
133
- var import_styled3 = __toESM(require("@emotion/styled"));
134
- var StepStyled = import_styled3.default.li`
135
- display: flex;
136
- gap: 12px;
137
- align-items: center;
138
- `;
139
- var LabelStyled = import_styled3.default.span`
140
- ${({ theme, color }) => `
141
- ${theme.fontStyles.bodyMdRegularSmall};
142
- color: ${color === "disabled" ? theme.palette.content.light : theme.palette[color].default};
143
- `}
354
+ // src/components/TrailLine/TrailLine.styled.ts
355
+ var import_styled4 = __toESM(require("@emotion/styled"));
356
+ var TrailLineStyled = import_styled4.default.span`
357
+ position: absolute;
358
+ transition: background-color 0.3s ease;
359
+
360
+ ${({ state, orientation, theme }) => {
361
+ const color = state === "completed" ? `${theme.palette.primary.default}` : `${theme.palette.primary.light}`;
362
+ if (orientation === "horizontal") {
363
+ return `
364
+ top: 50%;
365
+ transform: translateY(-50%);
366
+ left: calc(50% + ${HORIZONTAL_TRAIL_LINE_START_OFFSET}px);
367
+ right: calc(-50% + ${HORIZONTAL_TRAIL_LINE_START_OFFSET}px);
368
+ min-width: ${HORIZONTAL_TRAIL_LINE_MIN_WIDTH}px;
369
+ height: ${state === "completed" ? "2px" : "1px"};
370
+ background-color: ${color};
371
+ `;
372
+ }
373
+ return `
374
+ top: ${VERTICAL_TRAIL_LINE_TOP_OFFSET}px;
375
+ left: ${VERTICAL_TRAIL_LINE_LEFT_OFFSET}px;
376
+ width: ${state === "completed" ? "2px" : "1px"};
377
+ min-height: ${VERTICAL_TRAIL_LINE_MIN_HEIGHT}px;
378
+ background-color: ${color};
379
+ `;
380
+ }}
144
381
  `;
145
382
 
146
- // src/components/Step/Step.tsx
383
+ // src/components/TrailLine/TrailLine.tsx
147
384
  var import_jsx_runtime3 = require("react/jsx-runtime");
148
- var Step = ({
149
- children,
150
- isActive = false,
151
- isCompleted = false,
152
- isDisabled = false,
153
- isError = false
154
- }) => {
155
- const clonedChildren = (0, import_react.useMemo)(
156
- () => import_react.Children.map(children, (child) => {
157
- return child && (0, import_react.cloneElement)(child, __spreadValues({
158
- isActive,
159
- isCompleted,
160
- isDisabled,
161
- isError
162
- }, child.props));
163
- }),
164
- [children, isActive, isCompleted, isDisabled, isError]
385
+ var TrailLine = ({ state, orientation }) => {
386
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
387
+ TrailLineStyled,
388
+ {
389
+ "data-testid": "trail-line",
390
+ orientation,
391
+ state
392
+ }
165
393
  );
166
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StepStyled, { children: clonedChildren });
167
394
  };
168
- var StepCounter = ({
169
- children,
395
+
396
+ // src/components/Step/Step.tsx
397
+ var import_jsx_runtime4 = require("react/jsx-runtime");
398
+ var Step = ({
399
+ index = 0,
400
+ title,
401
+ description,
402
+ state = "incomplete",
170
403
  isActive = false,
171
- isCompleted = false,
172
- isDisabled = false,
173
- isError = false
404
+ variant = "number",
405
+ icon,
406
+ isLast = false,
407
+ orientation,
408
+ dataTestId
174
409
  }) => {
175
- const theme = (0, import_react2.useTheme)();
176
- const color = isError ? "error" : isDisabled ? "disabled" : "primary";
177
- const bgColor = isError ? theme.palette.error.light : theme.palette.primary.light;
178
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
179
- Counter,
410
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
411
+ StepContainer,
180
412
  {
181
- color,
182
- isLarge: true,
183
- outlined: !isCompleted,
184
- style: __spreadValues({
185
- borderWidth: 1
186
- }, isActive && { backgroundColor: bgColor }),
187
- children: isCompleted ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_icon.Icon, { code: "check", color: theme.palette.surface.light, size: "small" }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
188
- import_react_typography.Typography,
189
- {
190
- color: color === "disabled" ? "content.light" : `${color}.default`,
191
- element: "span",
192
- fontStyles: "bodyXsBold",
193
- style: {
194
- width: 24,
195
- height: 24,
196
- display: "flex",
197
- alignItems: "center",
198
- justifyContent: "center"
199
- },
200
- children
201
- }
202
- )
413
+ isDisabled: state === "disabled",
414
+ isLast,
415
+ orientation,
416
+ children: [
417
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
418
+ StepIndicatorWrapper,
419
+ {
420
+ "data-testid": dataTestId != null ? dataTestId : `step-${index}`,
421
+ isLast,
422
+ orientation,
423
+ children: [
424
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
425
+ StepIndicator,
426
+ {
427
+ icon,
428
+ index,
429
+ isActive,
430
+ state,
431
+ variant
432
+ }
433
+ ),
434
+ !isLast && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TrailLine, { orientation, state })
435
+ ]
436
+ }
437
+ ),
438
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
439
+ StepContent,
440
+ {
441
+ description,
442
+ isActive,
443
+ orientation,
444
+ state,
445
+ title
446
+ }
447
+ )
448
+ ]
203
449
  }
204
450
  );
205
451
  };
206
- Step.Counter = StepCounter;
207
- var labelColor = ({
208
- isActive,
209
- isError,
210
- isDisabled,
211
- isCompleted
212
- }) => {
213
- if (isError) {
214
- return "error";
215
- } else if (isActive || isCompleted) {
216
- return "primary";
217
- } else if (isDisabled) {
218
- return "disabled";
219
- } else {
220
- return "secondary";
221
- }
222
- };
223
- Step.Label = ({
452
+
453
+ // src/Stepper.styled.ts
454
+ var import_styled5 = __toESM(require("@emotion/styled"));
455
+ var StepperStyled = import_styled5.default.div`
456
+ display: flex;
457
+
458
+ ${({ orientation = "vertical" }) => `
459
+ flex-direction: ${orientation === "horizontal" ? "row" : "column"};
460
+ width: ${orientation === "horizontal" ? "100%" : "fit-content"};
461
+ align-items: stretch;
462
+ `}
463
+ `;
464
+
465
+ // src/Stepper.tsx
466
+ var import_jsx_runtime5 = require("react/jsx-runtime");
467
+ var Stepper = ({
224
468
  children,
225
- isActive = false,
226
- isCompleted = false,
227
- isDisabled = false,
228
- isError = false
469
+ orientation = "vertical",
470
+ variant = "number",
471
+ activeStep,
472
+ dataTestId
229
473
  }) => {
230
- const color = labelColor({ isActive, isError, isDisabled, isCompleted });
231
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LabelStyled, { color, children });
474
+ const childrenArray = import_react3.Children.toArray(children);
475
+ const enhancedChildren = childrenArray.map((child, index) => {
476
+ var _a;
477
+ if (child.type !== Step) {
478
+ return child;
479
+ }
480
+ return (0, import_react3.cloneElement)(child, __spreadProps(__spreadValues({}, child.props), {
481
+ index,
482
+ variant,
483
+ orientation,
484
+ isLast: index === childrenArray.length - 1,
485
+ isActive: (_a = child.props.isActive) != null ? _a : activeStep === index
486
+ }));
487
+ });
488
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
489
+ StepperStyled,
490
+ {
491
+ "data-testid": dataTestId != null ? dataTestId : "stepper",
492
+ orientation,
493
+ children: enhancedChildren
494
+ }
495
+ );
232
496
  };
233
- var Step_default = Step;
497
+ Stepper.Step = Step;
234
498
 
235
499
  // src/hooks/useStepper.ts
236
- var import_react3 = require("react");
237
- var useStepper = () => {
238
- const [activeStep, setActiveStep] = (0, import_react3.useState)(0);
239
- const handleNext = () => {
240
- setActiveStep((activeStep2) => activeStep2 + 1);
241
- };
242
- const handleBack = () => {
243
- setActiveStep((activeStep2) => activeStep2 - 1);
244
- };
245
- const handleChangeStep = (0, import_react3.useCallback)((step) => {
246
- setActiveStep(step);
500
+ var import_react4 = require("react");
501
+ var useStepper = (options) => {
502
+ const { initialStep = 0, totalSteps } = options || {};
503
+ const [activeStep, setActiveStep] = (0, import_react4.useState)(initialStep);
504
+ const [completedSteps, setCompletedSteps] = (0, import_react4.useState)(/* @__PURE__ */ new Set());
505
+ const isFirstStep = activeStep === 0;
506
+ const isLastStep = totalSteps !== void 0 ? activeStep === totalSteps - 1 : false;
507
+ const canGoNext = totalSteps !== void 0 ? activeStep < totalSteps - 1 : true;
508
+ const canGoBack = activeStep > 0;
509
+ const handleNext = (0, import_react4.useCallback)(() => {
510
+ if (canGoNext) {
511
+ setActiveStep((prev) => prev + 1);
512
+ }
513
+ }, [canGoNext]);
514
+ const handleBack = (0, import_react4.useCallback)(() => {
515
+ if (canGoBack) {
516
+ setActiveStep((prev) => prev - 1);
517
+ }
518
+ }, [canGoBack]);
519
+ const handleChangeStep = (0, import_react4.useCallback)(
520
+ (step) => {
521
+ const isValidStep = step >= 0 && (totalSteps === void 0 || step < totalSteps);
522
+ if (isValidStep) {
523
+ setActiveStep(step);
524
+ }
525
+ },
526
+ [totalSteps]
527
+ );
528
+ const handleReset = (0, import_react4.useCallback)(() => {
529
+ setActiveStep(initialStep);
530
+ setCompletedSteps(/* @__PURE__ */ new Set());
531
+ }, [initialStep]);
532
+ const markStepComplete = (0, import_react4.useCallback)((step) => {
533
+ setCompletedSteps((prev) => new Set(prev).add(step));
534
+ }, []);
535
+ const markStepIncomplete = (0, import_react4.useCallback)((step) => {
536
+ setCompletedSteps((prev) => {
537
+ const newSet = new Set(prev);
538
+ newSet.delete(step);
539
+ return newSet;
540
+ });
247
541
  }, []);
542
+ const isStepComplete = (0, import_react4.useCallback)(
543
+ (step) => completedSteps.has(step),
544
+ [completedSteps]
545
+ );
248
546
  return {
249
547
  activeStep,
250
- handleChangeStep,
548
+ isFirstStep,
549
+ isLastStep,
550
+ canGoNext,
551
+ canGoBack,
552
+ completedSteps,
251
553
  handleNext,
252
- handleBack
554
+ handleBack,
555
+ handleChangeStep,
556
+ handleReset,
557
+ markStepComplete,
558
+ markStepIncomplete,
559
+ isStepComplete
253
560
  };
254
561
  };
255
562
  // Annotate the CommonJS export names for ESM import in node:
256
563
  0 && (module.exports = {
257
- Counter,
258
564
  Step,
259
565
  Stepper,
260
566
  useStepper