@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/CHANGELOG.md +20 -0
- package/README.md +157 -23
- package/dist/index.d.mts +39 -22
- package/dist/index.d.ts +39 -22
- package/dist/index.js +463 -157
- package/dist/index.mjs +465 -158
- package/package.json +5 -4
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
|
-
|
|
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.
|
|
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
|
-
|
|
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:
|
|
60
|
-
|
|
125
|
+
gap: 4px;
|
|
126
|
+
max-width: ${STEP_CONTENT_MAX_WIDTH}px;
|
|
61
127
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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/
|
|
178
|
+
// src/components/StepContent/StepContent.tsx
|
|
70
179
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
|
|
180
|
+
var StepContent = ({
|
|
181
|
+
title,
|
|
182
|
+
description,
|
|
183
|
+
state,
|
|
184
|
+
isActive,
|
|
74
185
|
orientation
|
|
75
186
|
}) => {
|
|
76
|
-
const
|
|
77
|
-
|
|
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/
|
|
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/
|
|
87
|
-
var
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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/
|
|
308
|
+
// src/components/StepIndicator/StepIndicator.tsx
|
|
110
309
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
111
|
-
var
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
343
|
+
StepIndicatorStyled,
|
|
121
344
|
{
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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/
|
|
133
|
-
var
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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/
|
|
383
|
+
// src/components/TrailLine/TrailLine.tsx
|
|
147
384
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
148
|
-
var
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
|
|
169
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
404
|
+
variant = "number",
|
|
405
|
+
icon,
|
|
406
|
+
isLast = false,
|
|
407
|
+
orientation,
|
|
408
|
+
dataTestId
|
|
174
409
|
}) => {
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}) =>
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
469
|
+
orientation = "vertical",
|
|
470
|
+
variant = "number",
|
|
471
|
+
activeStep,
|
|
472
|
+
dataTestId
|
|
229
473
|
}) => {
|
|
230
|
-
const
|
|
231
|
-
|
|
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
|
-
|
|
497
|
+
Stepper.Step = Step;
|
|
234
498
|
|
|
235
499
|
// src/hooks/useStepper.ts
|
|
236
|
-
var
|
|
237
|
-
var useStepper = () => {
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
|
|
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
|
-
|
|
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
|