allaw-ui 1.0.46 → 1.0.47
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.
|
@@ -45,8 +45,7 @@ import PrimaryButton from "../../atoms/buttons/PrimaryButton";
|
|
|
45
45
|
import SecondaryButton from "../../atoms/buttons/SecondaryButton";
|
|
46
46
|
var Stepper = function (_a) {
|
|
47
47
|
var steps = _a.steps, currentStep = _a.currentStep, _b = _a.startIcon, startIcon = _b === void 0 ? [] : _b, _c = _a.endIcon, endIcon = _c === void 0 ? true : _c, children = _a.children, _d = _a.secondaryButton, secondaryButton = _d === void 0 ? [] : _d, _e = _a.primaryButton, primaryButton = _e === void 0 ? [] : _e, _f = _a.showProgressBar, showProgressBar = _f === void 0 ? [] : _f, onClose = _a.onClose, validateStep = _a.validateStep;
|
|
48
|
-
var _g = useState(
|
|
49
|
-
var _h = useState(false), isVisible = _h[0], setIsVisible = _h[1];
|
|
48
|
+
var _g = useState(false), isVisible = _g[0], setIsVisible = _g[1];
|
|
50
49
|
var portalContainerRef = useRef(null);
|
|
51
50
|
useEffect(function () {
|
|
52
51
|
var container = document.createElement("div");
|
|
@@ -61,71 +60,62 @@ var Stepper = function (_a) {
|
|
|
61
60
|
}
|
|
62
61
|
};
|
|
63
62
|
}, []);
|
|
64
|
-
useEffect(function () {
|
|
65
|
-
setStep(currentStep || 1);
|
|
66
|
-
}, [currentStep]);
|
|
67
63
|
var handleNext = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
64
|
var currentPrimaryButton, isValid;
|
|
69
65
|
return __generator(this, function (_a) {
|
|
70
66
|
switch (_a.label) {
|
|
71
67
|
case 0:
|
|
72
|
-
console.log("[Stepper.handleNext] Starting with step:",
|
|
73
|
-
currentPrimaryButton = primaryButton[
|
|
68
|
+
console.log("[Stepper.handleNext] Starting with step:", currentStep);
|
|
69
|
+
currentPrimaryButton = primaryButton[currentStep - 1];
|
|
74
70
|
if (!(currentPrimaryButton === null || currentPrimaryButton === void 0 ? void 0 : currentPrimaryButton.onPrimaryButtonClick)) return [3 /*break*/, 2];
|
|
75
71
|
console.log("[Stepper.handleNext] Calling onPrimaryButtonClick");
|
|
76
|
-
return [4 /*yield*/, currentPrimaryButton.onPrimaryButtonClick(
|
|
72
|
+
return [4 /*yield*/, currentPrimaryButton.onPrimaryButtonClick(currentStep)];
|
|
77
73
|
case 1:
|
|
78
74
|
_a.sent();
|
|
79
75
|
_a.label = 2;
|
|
80
76
|
case 2:
|
|
81
77
|
if (!validateStep) return [3 /*break*/, 4];
|
|
82
78
|
console.log("[Stepper.handleNext] Validating step");
|
|
83
|
-
return [4 /*yield*/, validateStep(
|
|
79
|
+
return [4 /*yield*/, validateStep(currentStep)];
|
|
84
80
|
case 3:
|
|
85
81
|
isValid = _a.sent();
|
|
86
82
|
console.log("[Stepper.handleNext] Validation result:", isValid);
|
|
87
83
|
if (!isValid) {
|
|
88
|
-
console.log("[Stepper.handleNext] Validation failed
|
|
84
|
+
console.log("[Stepper.handleNext] Validation failed");
|
|
89
85
|
return [2 /*return*/];
|
|
90
86
|
}
|
|
91
87
|
_a.label = 4;
|
|
92
|
-
case 4:
|
|
93
|
-
console.log("[Stepper.handleNext] Step validation successful");
|
|
94
|
-
return [2 /*return*/];
|
|
88
|
+
case 4: return [2 /*return*/];
|
|
95
89
|
}
|
|
96
90
|
});
|
|
97
|
-
}); }, [
|
|
98
|
-
var handlePrevious = useCallback(function () {
|
|
99
|
-
if (step > 1) {
|
|
100
|
-
setStep(step - 1);
|
|
101
|
-
}
|
|
102
|
-
}, [step]);
|
|
103
|
-
var currentSecondaryButton = secondaryButton[step - 1] || {};
|
|
104
|
-
var currentPrimaryButton = primaryButton[step - 1] || {};
|
|
105
|
-
var currentShowProgressBar = showProgressBar[step - 1] !== false;
|
|
106
|
-
var currentShowStartIcon = startIcon[step - 1];
|
|
91
|
+
}); }, [currentStep, validateStep, primaryButton]);
|
|
107
92
|
var handleClose = useCallback(function () {
|
|
108
|
-
setIsVisible(false);
|
|
109
93
|
if (onClose) {
|
|
110
94
|
onClose();
|
|
111
95
|
}
|
|
112
96
|
}, [onClose]);
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
97
|
+
var handlePrevious = useCallback(function () {
|
|
98
|
+
var currentSecondaryButton = secondaryButton[currentStep - 1];
|
|
99
|
+
if (currentSecondaryButton === null || currentSecondaryButton === void 0 ? void 0 : currentSecondaryButton.onSecondaryButtonClick) {
|
|
100
|
+
currentSecondaryButton.onSecondaryButtonClick(currentStep);
|
|
101
|
+
}
|
|
102
|
+
}, [currentStep, secondaryButton]);
|
|
103
|
+
var currentSecondaryButton = secondaryButton[currentStep - 1] || {};
|
|
104
|
+
var currentPrimaryButton = primaryButton[currentStep - 1] || {};
|
|
105
|
+
var currentShowProgressBar = showProgressBar[currentStep - 1] !== false;
|
|
106
|
+
var currentShowStartIcon = startIcon[currentStep - 1];
|
|
107
|
+
var stepperContent = (React.createElement("div", { className: "stepper-container" },
|
|
108
|
+
React.createElement("div", { className: "stepper-wrapper" },
|
|
109
|
+
React.createElement(ProgressBar, { steps: steps, currentStep: currentStep, startIcon: currentShowStartIcon, endIcon: endIcon, onStartIconClick: handlePrevious, onEndIconClick: handleClose, showProgressBar: currentShowProgressBar }),
|
|
110
|
+
React.createElement("div", { className: "stepper-content" }, children[currentStep - 1]),
|
|
117
111
|
React.createElement("div", { className: "stepper-buttons ".concat(!(currentSecondaryButton === null || currentSecondaryButton === void 0 ? void 0 : currentSecondaryButton.show) && !(currentPrimaryButton === null || currentPrimaryButton === void 0 ? void 0 : currentPrimaryButton.show) ? "no-buttons" : "") },
|
|
118
112
|
(currentSecondaryButton === null || currentSecondaryButton === void 0 ? void 0 : currentSecondaryButton.show) && (React.createElement("div", { className: "stepper-button-container secondary-button-container" },
|
|
119
|
-
React.createElement(SecondaryButton, { fullWidth: true, label: currentSecondaryButton.label, startIcon: currentSecondaryButton.startIconName ? true : undefined, endIcon: currentSecondaryButton.endIconName ? true : undefined, startIconName: currentSecondaryButton.startIconName, endIconName: currentSecondaryButton.endIconName, onClick: function () { var _a; return (_a = currentSecondaryButton.onSecondaryButtonClick) === null || _a === void 0 ? void 0 : _a.call(currentSecondaryButton,
|
|
113
|
+
React.createElement(SecondaryButton, { fullWidth: true, label: currentSecondaryButton.label, startIcon: currentSecondaryButton.startIconName ? true : undefined, endIcon: currentSecondaryButton.endIconName ? true : undefined, startIconName: currentSecondaryButton.startIconName, endIconName: currentSecondaryButton.endIconName, onClick: function () { var _a; return (_a = currentSecondaryButton.onSecondaryButtonClick) === null || _a === void 0 ? void 0 : _a.call(currentSecondaryButton, currentStep); } }))),
|
|
120
114
|
(currentPrimaryButton === null || currentPrimaryButton === void 0 ? void 0 : currentPrimaryButton.show) && (React.createElement("div", { className: "stepper-button-container primary-button-container" },
|
|
121
115
|
React.createElement(PrimaryButton, { fullWidth: true, label: currentPrimaryButton.label, startIcon: currentPrimaryButton.startIconName ? true : undefined, endIcon: currentPrimaryButton.endIconName ? true : undefined, startIconName: currentPrimaryButton.startIconName, endIconName: currentPrimaryButton.endIconName, disabled: currentPrimaryButton.disabled, onClick: handleNext })))))));
|
|
122
116
|
useEffect(function () {
|
|
123
|
-
console.log("[Stepper]
|
|
124
|
-
|
|
125
|
-
currentStep: currentStep,
|
|
126
|
-
totalSteps: steps,
|
|
127
|
-
});
|
|
128
|
-
}, [step, currentStep, steps]);
|
|
117
|
+
console.log("[Stepper] currentStep changed:", currentStep);
|
|
118
|
+
}, [currentStep]);
|
|
129
119
|
return portalContainerRef.current && isVisible
|
|
130
120
|
? ReactDOM.createPortal(stepperContent, portalContainerRef.current)
|
|
131
121
|
: null;
|