mautourco-components 0.2.20 → 0.2.21
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.
|
@@ -12,10 +12,10 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import Button from '@/src/components/atoms/Button/Button';
|
|
14
14
|
import { StepperTimeline, } from '@/src/components/molecules/StepperTimeline/StepperTimeline';
|
|
15
|
-
import { useState } from 'react';
|
|
15
|
+
import { useEffect, useState } from 'react';
|
|
16
16
|
import './BookingStep.css';
|
|
17
17
|
export var BookingStep = function (props) {
|
|
18
|
-
var steps = props.steps, className = props.className, nextDisabled = props.nextDisabled, onStepChange = props.onStepChange, onNextClick = props.onNextClick;
|
|
18
|
+
var steps = props.steps, className = props.className, nextDisabled = props.nextDisabled, currentStep = props.currentStep, onStepChange = props.onStepChange, onNextClick = props.onNextClick;
|
|
19
19
|
var _a = useState(0), currentIndex = _a[0], setCurrentIndex = _a[1];
|
|
20
20
|
var handleStepChange = function (step, index) {
|
|
21
21
|
setCurrentIndex(index);
|
|
@@ -26,5 +26,8 @@ export var BookingStep = function (props) {
|
|
|
26
26
|
setCurrentIndex(currentStep);
|
|
27
27
|
onNextClick === null || onNextClick === void 0 ? void 0 : onNextClick(steps[currentStep], currentStep);
|
|
28
28
|
};
|
|
29
|
+
useEffect(function () {
|
|
30
|
+
setCurrentIndex(currentStep ? currentStep - 1 : 0);
|
|
31
|
+
}, [currentStep]);
|
|
29
32
|
return (_jsxs("div", __assign({ className: "booking-step" }, { children: [_jsx(StepperTimeline, { steps: steps, className: className, currentIndex: currentIndex, onChange: handleStepChange }), _jsx(Button, __assign({ trailingIcon: "arrow-right-outline", variant: "secondary", className: "w-[189px]", disabled: nextDisabled, onClick: handleNextClick }, { children: currentIndex === steps.length - 1 ? 'Confirm' : 'Next' }))] })));
|
|
30
33
|
};
|
package/package.json
CHANGED
|
@@ -3,11 +3,12 @@ import {
|
|
|
3
3
|
StepperTimeline,
|
|
4
4
|
StepperTimelineItem,
|
|
5
5
|
} from '@/src/components/molecules/StepperTimeline/StepperTimeline';
|
|
6
|
-
import React, { useState } from 'react';
|
|
6
|
+
import React, { useEffect, useState } from 'react';
|
|
7
7
|
import './BookingStep.css';
|
|
8
8
|
|
|
9
9
|
export interface BookingStepProps {
|
|
10
10
|
steps: StepperTimelineItem[];
|
|
11
|
+
currentStep?: number;
|
|
11
12
|
className?: string;
|
|
12
13
|
nextDisabled?: boolean;
|
|
13
14
|
onStepChange?: (step: StepperTimelineItem, index: number) => void;
|
|
@@ -15,7 +16,8 @@ export interface BookingStepProps {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export const BookingStep: React.FC<BookingStepProps> = (props) => {
|
|
18
|
-
const { steps, className, nextDisabled, onStepChange, onNextClick } =
|
|
19
|
+
const { steps, className, nextDisabled, currentStep, onStepChange, onNextClick } =
|
|
20
|
+
props;
|
|
19
21
|
|
|
20
22
|
const [currentIndex, setCurrentIndex] = useState<number>(0);
|
|
21
23
|
|
|
@@ -30,6 +32,10 @@ export const BookingStep: React.FC<BookingStepProps> = (props) => {
|
|
|
30
32
|
onNextClick?.(steps[currentStep], currentStep);
|
|
31
33
|
};
|
|
32
34
|
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setCurrentIndex(currentStep ? currentStep - 1 : 0);
|
|
37
|
+
}, [currentStep]);
|
|
38
|
+
|
|
33
39
|
return (
|
|
34
40
|
<div className="booking-step">
|
|
35
41
|
<StepperTimeline
|