@ttoss/react-wizard 0.11.2 → 0.11.4
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 +110 -58
- package/dist/index.mjs +111 -59
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -256,14 +256,27 @@ var messages$1 = (0, _ttoss_react_i18n.defineMessages)({
|
|
|
256
256
|
description: "Wizard: accessible name of the list of steps."
|
|
257
257
|
}
|
|
258
258
|
});
|
|
259
|
+
/**
|
|
260
|
+
* Below the `md` breakpoint a horizontal list has no room for every step's
|
|
261
|
+
* text: each item shows only its indicator and the active step's text is
|
|
262
|
+
* rendered once, full width, under the list (`WizardActiveStepSummary`).
|
|
263
|
+
*/
|
|
264
|
+
var HORIZONTAL_TEXT_DISPLAY = ["none", "none", "block"];
|
|
265
|
+
var HORIZONTAL_SUMMARY_DISPLAY = ["block", "block", "none"];
|
|
259
266
|
var WizardStepText = ({
|
|
260
267
|
step,
|
|
261
268
|
status,
|
|
262
|
-
variant
|
|
269
|
+
variant,
|
|
270
|
+
isHorizontal
|
|
263
271
|
}) => {
|
|
264
272
|
if (!step.title && !step.description) return null;
|
|
265
273
|
return /* @__PURE__ */(0, react_jsx_runtime.jsxs)(_ttoss_ui.Box, {
|
|
266
|
-
sx:
|
|
274
|
+
sx: {
|
|
275
|
+
...WizardStepTextWrapperSx,
|
|
276
|
+
...(isHorizontal ? {
|
|
277
|
+
display: HORIZONTAL_TEXT_DISPLAY
|
|
278
|
+
} : {})
|
|
279
|
+
},
|
|
267
280
|
children: [step.title && /* @__PURE__ */(0, react_jsx_runtime.jsx)(_chakra_ui_react.Steps.Title, {
|
|
268
281
|
css: getWizardStepTitleSx({
|
|
269
282
|
status,
|
|
@@ -282,6 +295,35 @@ var WizardStepText = ({
|
|
|
282
295
|
})]
|
|
283
296
|
});
|
|
284
297
|
};
|
|
298
|
+
var WizardActiveStepSummary = ({
|
|
299
|
+
step,
|
|
300
|
+
variant
|
|
301
|
+
}) => {
|
|
302
|
+
if (!step || !step.title && !step.description) return null;
|
|
303
|
+
return /* @__PURE__ */(0, react_jsx_runtime.jsxs)(_ttoss_ui.Box, {
|
|
304
|
+
"data-testid": "wizard-active-step-summary",
|
|
305
|
+
sx: {
|
|
306
|
+
display: HORIZONTAL_SUMMARY_DISPLAY,
|
|
307
|
+
marginTop: "4",
|
|
308
|
+
textAlign: "center"
|
|
309
|
+
},
|
|
310
|
+
children: [step.title && /* @__PURE__ */(0, react_jsx_runtime.jsx)(_ttoss_ui.Text, {
|
|
311
|
+
as: "div",
|
|
312
|
+
sx: getWizardStepTitleSx({
|
|
313
|
+
status: "active",
|
|
314
|
+
variant
|
|
315
|
+
}),
|
|
316
|
+
children: step.title
|
|
317
|
+
}), step.description && /* @__PURE__ */(0, react_jsx_runtime.jsx)(_ttoss_ui.Text, {
|
|
318
|
+
as: "div",
|
|
319
|
+
sx: getWizardStepDescriptionSx({
|
|
320
|
+
status: "active",
|
|
321
|
+
variant
|
|
322
|
+
}),
|
|
323
|
+
children: step.description
|
|
324
|
+
})]
|
|
325
|
+
});
|
|
326
|
+
};
|
|
285
327
|
var WizardStepList = ({
|
|
286
328
|
steps,
|
|
287
329
|
currentStep,
|
|
@@ -304,69 +346,79 @@ var WizardStepList = ({
|
|
|
304
346
|
layout,
|
|
305
347
|
variant
|
|
306
348
|
}),
|
|
307
|
-
children: /* @__PURE__ */(0, react_jsx_runtime.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
if (isClickable) onStepClick({
|
|
330
|
-
stepIndex: index
|
|
331
|
-
});
|
|
349
|
+
children: /* @__PURE__ */(0, react_jsx_runtime.jsxs)(_ttoss_ui.Box, {
|
|
350
|
+
sx: {
|
|
351
|
+
width: "100%",
|
|
352
|
+
minWidth: 0
|
|
353
|
+
},
|
|
354
|
+
children: [/* @__PURE__ */(0, react_jsx_runtime.jsx)(_chakra_ui_react.Steps.Root, {
|
|
355
|
+
step: currentStep,
|
|
356
|
+
count: steps.length,
|
|
357
|
+
orientation,
|
|
358
|
+
children: /* @__PURE__ */(0, react_jsx_runtime.jsx)(_chakra_ui_react.Steps.List, {
|
|
359
|
+
children: steps.map((step, index) => {
|
|
360
|
+
const status = getStepStatus({
|
|
361
|
+
stepIndex: index
|
|
362
|
+
});
|
|
363
|
+
const isClickable = allowStepClick && status === "completed" && index !== currentStep;
|
|
364
|
+
return /* @__PURE__ */(0, react_jsx_runtime.jsxs)(_chakra_ui_react.Steps.Item, {
|
|
365
|
+
index,
|
|
366
|
+
children: [/* @__PURE__ */(0, react_jsx_runtime.jsxs)(_ttoss_ui.Flex, {
|
|
367
|
+
sx: {
|
|
368
|
+
flexDirection: isHorizontal ? "column" : "row",
|
|
369
|
+
alignItems: "center",
|
|
370
|
+
gap: "2"
|
|
332
371
|
},
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
372
|
+
children: [/* @__PURE__ */(0, react_jsx_runtime.jsx)(_ttoss_ui.Box, {
|
|
373
|
+
role: "button",
|
|
374
|
+
tabIndex: isClickable ? 0 : -1,
|
|
375
|
+
onClick: () => {
|
|
376
|
+
if (isClickable) onStepClick({
|
|
337
377
|
stepIndex: index
|
|
338
378
|
});
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
379
|
+
},
|
|
380
|
+
onKeyDown: e => {
|
|
381
|
+
if (isClickable && (e.key === "Enter" || e.key === " ")) {
|
|
382
|
+
e.preventDefault();
|
|
383
|
+
onStepClick({
|
|
384
|
+
stepIndex: index
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
"aria-current": status === "active" ? "step" : void 0,
|
|
389
|
+
sx: {
|
|
390
|
+
cursor: isClickable ? "pointer" : "default"
|
|
391
|
+
},
|
|
392
|
+
children: /* @__PURE__ */(0, react_jsx_runtime.jsx)(_chakra_ui_react.Steps.Indicator, {
|
|
393
|
+
css: getWizardStepIndicatorSx({
|
|
394
|
+
status,
|
|
395
|
+
variant,
|
|
396
|
+
isClickable
|
|
397
|
+
}),
|
|
398
|
+
children: /* @__PURE__ */(0, react_jsx_runtime.jsx)(_chakra_ui_react.Steps.Status, {
|
|
399
|
+
complete: "✓",
|
|
400
|
+
incomplete: /* @__PURE__ */(0, react_jsx_runtime.jsx)(_chakra_ui_react.Steps.Number, {})
|
|
401
|
+
})
|
|
354
402
|
})
|
|
403
|
+
}), /* @__PURE__ */(0, react_jsx_runtime.jsx)(WizardStepText, {
|
|
404
|
+
step,
|
|
405
|
+
status,
|
|
406
|
+
variant,
|
|
407
|
+
isHorizontal
|
|
408
|
+
})]
|
|
409
|
+
}), index < steps.length - 1 && /* @__PURE__ */(0, react_jsx_runtime.jsx)(_chakra_ui_react.Steps.Separator, {
|
|
410
|
+
css: getWizardStepSeparatorSx({
|
|
411
|
+
isCompleted: index < currentStep,
|
|
412
|
+
variant
|
|
355
413
|
})
|
|
356
|
-
}), /* @__PURE__ */(0, react_jsx_runtime.jsx)(WizardStepText, {
|
|
357
|
-
step,
|
|
358
|
-
status,
|
|
359
|
-
variant
|
|
360
414
|
})]
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
isCompleted: index < currentStep,
|
|
364
|
-
variant
|
|
365
|
-
})
|
|
366
|
-
})]
|
|
367
|
-
}, index);
|
|
415
|
+
}, index);
|
|
416
|
+
})
|
|
368
417
|
})
|
|
369
|
-
})
|
|
418
|
+
}), isHorizontal && /* @__PURE__ */(0, react_jsx_runtime.jsx)(WizardActiveStepSummary, {
|
|
419
|
+
step: steps[currentStep],
|
|
420
|
+
variant
|
|
421
|
+
})]
|
|
370
422
|
})
|
|
371
423
|
});
|
|
372
424
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
2
|
import { defineMessages, useI18n } from "@ttoss/react-i18n";
|
|
3
|
-
import { Box, Button, Flex, keyframes } from "@ttoss/ui";
|
|
3
|
+
import { Box, Button, Flex, Text, keyframes } from "@ttoss/ui";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { Steps } from "@chakra-ui/react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -228,14 +228,27 @@ var messages$1 = defineMessages({
|
|
|
228
228
|
}]
|
|
229
229
|
}
|
|
230
230
|
});
|
|
231
|
+
/**
|
|
232
|
+
* Below the `md` breakpoint a horizontal list has no room for every step's
|
|
233
|
+
* text: each item shows only its indicator and the active step's text is
|
|
234
|
+
* rendered once, full width, under the list (`WizardActiveStepSummary`).
|
|
235
|
+
*/
|
|
236
|
+
var HORIZONTAL_TEXT_DISPLAY = ["none", "none", "block"];
|
|
237
|
+
var HORIZONTAL_SUMMARY_DISPLAY = ["block", "block", "none"];
|
|
231
238
|
var WizardStepText = ({
|
|
232
239
|
step,
|
|
233
240
|
status,
|
|
234
|
-
variant
|
|
241
|
+
variant,
|
|
242
|
+
isHorizontal
|
|
235
243
|
}) => {
|
|
236
244
|
if (!step.title && !step.description) return null;
|
|
237
245
|
return /* @__PURE__ */jsxs(Box, {
|
|
238
|
-
sx:
|
|
246
|
+
sx: {
|
|
247
|
+
...WizardStepTextWrapperSx,
|
|
248
|
+
...(isHorizontal ? {
|
|
249
|
+
display: HORIZONTAL_TEXT_DISPLAY
|
|
250
|
+
} : {})
|
|
251
|
+
},
|
|
239
252
|
children: [step.title && /* @__PURE__ */jsx(Steps.Title, {
|
|
240
253
|
css: getWizardStepTitleSx({
|
|
241
254
|
status,
|
|
@@ -254,6 +267,35 @@ var WizardStepText = ({
|
|
|
254
267
|
})]
|
|
255
268
|
});
|
|
256
269
|
};
|
|
270
|
+
var WizardActiveStepSummary = ({
|
|
271
|
+
step,
|
|
272
|
+
variant
|
|
273
|
+
}) => {
|
|
274
|
+
if (!step || !step.title && !step.description) return null;
|
|
275
|
+
return /* @__PURE__ */jsxs(Box, {
|
|
276
|
+
"data-testid": "wizard-active-step-summary",
|
|
277
|
+
sx: {
|
|
278
|
+
display: HORIZONTAL_SUMMARY_DISPLAY,
|
|
279
|
+
marginTop: "4",
|
|
280
|
+
textAlign: "center"
|
|
281
|
+
},
|
|
282
|
+
children: [step.title && /* @__PURE__ */jsx(Text, {
|
|
283
|
+
as: "div",
|
|
284
|
+
sx: getWizardStepTitleSx({
|
|
285
|
+
status: "active",
|
|
286
|
+
variant
|
|
287
|
+
}),
|
|
288
|
+
children: step.title
|
|
289
|
+
}), step.description && /* @__PURE__ */jsx(Text, {
|
|
290
|
+
as: "div",
|
|
291
|
+
sx: getWizardStepDescriptionSx({
|
|
292
|
+
status: "active",
|
|
293
|
+
variant
|
|
294
|
+
}),
|
|
295
|
+
children: step.description
|
|
296
|
+
})]
|
|
297
|
+
});
|
|
298
|
+
};
|
|
257
299
|
var WizardStepList = ({
|
|
258
300
|
steps,
|
|
259
301
|
currentStep,
|
|
@@ -276,69 +318,79 @@ var WizardStepList = ({
|
|
|
276
318
|
layout,
|
|
277
319
|
variant
|
|
278
320
|
}),
|
|
279
|
-
children: /* @__PURE__ */
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (isClickable) onStepClick({
|
|
302
|
-
stepIndex: index
|
|
303
|
-
});
|
|
321
|
+
children: /* @__PURE__ */jsxs(Box, {
|
|
322
|
+
sx: {
|
|
323
|
+
width: "100%",
|
|
324
|
+
minWidth: 0
|
|
325
|
+
},
|
|
326
|
+
children: [/* @__PURE__ */jsx(Steps.Root, {
|
|
327
|
+
step: currentStep,
|
|
328
|
+
count: steps.length,
|
|
329
|
+
orientation,
|
|
330
|
+
children: /* @__PURE__ */jsx(Steps.List, {
|
|
331
|
+
children: steps.map((step, index) => {
|
|
332
|
+
const status = getStepStatus({
|
|
333
|
+
stepIndex: index
|
|
334
|
+
});
|
|
335
|
+
const isClickable = allowStepClick && status === "completed" && index !== currentStep;
|
|
336
|
+
return /* @__PURE__ */jsxs(Steps.Item, {
|
|
337
|
+
index,
|
|
338
|
+
children: [/* @__PURE__ */jsxs(Flex, {
|
|
339
|
+
sx: {
|
|
340
|
+
flexDirection: isHorizontal ? "column" : "row",
|
|
341
|
+
alignItems: "center",
|
|
342
|
+
gap: "2"
|
|
304
343
|
},
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
344
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
345
|
+
role: "button",
|
|
346
|
+
tabIndex: isClickable ? 0 : -1,
|
|
347
|
+
onClick: () => {
|
|
348
|
+
if (isClickable) onStepClick({
|
|
309
349
|
stepIndex: index
|
|
310
350
|
});
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
351
|
+
},
|
|
352
|
+
onKeyDown: e => {
|
|
353
|
+
if (isClickable && (e.key === "Enter" || e.key === " ")) {
|
|
354
|
+
e.preventDefault();
|
|
355
|
+
onStepClick({
|
|
356
|
+
stepIndex: index
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
"aria-current": status === "active" ? "step" : void 0,
|
|
361
|
+
sx: {
|
|
362
|
+
cursor: isClickable ? "pointer" : "default"
|
|
363
|
+
},
|
|
364
|
+
children: /* @__PURE__ */jsx(Steps.Indicator, {
|
|
365
|
+
css: getWizardStepIndicatorSx({
|
|
366
|
+
status,
|
|
367
|
+
variant,
|
|
368
|
+
isClickable
|
|
369
|
+
}),
|
|
370
|
+
children: /* @__PURE__ */jsx(Steps.Status, {
|
|
371
|
+
complete: "✓",
|
|
372
|
+
incomplete: /* @__PURE__ */jsx(Steps.Number, {})
|
|
373
|
+
})
|
|
326
374
|
})
|
|
375
|
+
}), /* @__PURE__ */jsx(WizardStepText, {
|
|
376
|
+
step,
|
|
377
|
+
status,
|
|
378
|
+
variant,
|
|
379
|
+
isHorizontal
|
|
380
|
+
})]
|
|
381
|
+
}), index < steps.length - 1 && /* @__PURE__ */jsx(Steps.Separator, {
|
|
382
|
+
css: getWizardStepSeparatorSx({
|
|
383
|
+
isCompleted: index < currentStep,
|
|
384
|
+
variant
|
|
327
385
|
})
|
|
328
|
-
}), /* @__PURE__ */jsx(WizardStepText, {
|
|
329
|
-
step,
|
|
330
|
-
status,
|
|
331
|
-
variant
|
|
332
386
|
})]
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
isCompleted: index < currentStep,
|
|
336
|
-
variant
|
|
337
|
-
})
|
|
338
|
-
})]
|
|
339
|
-
}, index);
|
|
387
|
+
}, index);
|
|
388
|
+
})
|
|
340
389
|
})
|
|
341
|
-
})
|
|
390
|
+
}), isHorizontal && /* @__PURE__ */jsx(WizardActiveStepSummary, {
|
|
391
|
+
step: steps[currentStep],
|
|
392
|
+
variant
|
|
393
|
+
})]
|
|
342
394
|
})
|
|
343
395
|
});
|
|
344
396
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/react-wizard",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"description": "A React wizard component for guiding users through multi-step flows with configurable step list layouts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"React",
|
|
@@ -40,19 +40,19 @@
|
|
|
40
40
|
"jest": "^30.5.2",
|
|
41
41
|
"react": "^19.3.0",
|
|
42
42
|
"tsdown": "^0.23.1",
|
|
43
|
-
"@ttoss/config": "^4.0.
|
|
44
|
-
"@ttoss/forms": "^0.53.
|
|
45
|
-
"@ttoss/
|
|
46
|
-
"@ttoss/i18n-cli": "^0.16.
|
|
47
|
-
"@ttoss/
|
|
48
|
-
"@ttoss/
|
|
43
|
+
"@ttoss/config": "^4.0.1",
|
|
44
|
+
"@ttoss/forms": "^0.53.3",
|
|
45
|
+
"@ttoss/react-i18n": "^4.0.2",
|
|
46
|
+
"@ttoss/i18n-cli": "^0.16.1",
|
|
47
|
+
"@ttoss/test-utils": "^7.1.1",
|
|
48
|
+
"@ttoss/ui": "^9.0.2"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@chakra-ui/react": "^3",
|
|
52
52
|
"react": ">=16.8.0",
|
|
53
53
|
"react-icons": "^5",
|
|
54
|
-
"@ttoss/react-i18n": "^4.0.
|
|
55
|
-
"@ttoss/ui": "^9.0.
|
|
54
|
+
"@ttoss/react-i18n": "^4.0.2",
|
|
55
|
+
"@ttoss/ui": "^9.0.2"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public",
|