@mailstep/design-system 0.6.62 → 0.6.63-beta.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailstep/design-system",
3
- "version": "0.6.62",
3
+ "version": "0.6.63-beta.0",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useMemo } from 'react';
2
+ import { useEffect, useMemo } from 'react';
3
3
  import { StepItem } from './components/StepItem';
4
4
  import { Container, ItemsWrapper } from './styles';
5
5
  export var Stepper = function (_a) {
@@ -7,6 +7,12 @@ export var Stepper = function (_a) {
7
7
  if (!(items === null || items === void 0 ? void 0 : items.length))
8
8
  return null;
9
9
  var Component = useMemo(function () { return items[activeStep].component; }, [items, activeStep]);
10
+ useEffect(function () {
11
+ var _a;
12
+ if (!((_a = items[activeStep]) === null || _a === void 0 ? void 0 : _a.completed)) {
13
+ handleChangeStep(0);
14
+ }
15
+ }, [activeStep]);
10
16
  return (_jsxs(Container, { children: [_jsx(ItemsWrapper, { children: items.map(function (_a, index) {
11
17
  var title = _a.title, disabled = _a.disabled, completed = _a.completed;
12
18
  return (_jsx(StepItem, { onClick: handleChangeStep(index), title: title, index: index, activeStep: activeStep, disabled: disabled, completed: completed }, title));
@@ -1,6 +1,5 @@
1
1
  type Props = {
2
2
  totalSteps: number;
3
- handleFinish?: () => Promise<void>;
4
3
  };
5
4
  type HookType = (props: Props) => {
6
5
  activeStep: number;
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useState } from 'react';
2
2
  export var useStepper = function (_a) {
3
- var totalSteps = _a.totalSteps, handleFinish = _a.handleFinish;
3
+ var totalSteps = _a.totalSteps;
4
4
  var _b = useState(0), activeStep = _b[0], setActiveStep = _b[1];
5
5
  var _c = useState(false), isSuccess = _c[0], setSuccess = _c[1];
6
6
  var handleReset = useCallback(function () {
@@ -9,13 +9,6 @@ export var useStepper = function (_a) {
9
9
  }, []);
10
10
  var handleGoToNextStep = useCallback(function () {
11
11
  if (activeStep + 1 === totalSteps) {
12
- if (handleFinish) {
13
- handleFinish().then(function () {
14
- handleReset();
15
- setSuccess(true);
16
- });
17
- return;
18
- }
19
12
  handleReset();
20
13
  setSuccess(true);
21
14
  return;