allaw-ui 1.0.48 → 1.0.50
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,46 +60,37 @@ 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
|
-
currentPrimaryButton = primaryButton[
|
|
68
|
+
currentPrimaryButton = primaryButton[currentStep - 1];
|
|
73
69
|
if (currentPrimaryButton === null || currentPrimaryButton === void 0 ? void 0 : currentPrimaryButton.onPrimaryButtonClick) {
|
|
74
|
-
currentPrimaryButton.onPrimaryButtonClick(
|
|
70
|
+
currentPrimaryButton.onPrimaryButtonClick(currentStep);
|
|
75
71
|
}
|
|
76
72
|
if (!validateStep) return [3 /*break*/, 2];
|
|
77
|
-
return [4 /*yield*/, validateStep(
|
|
73
|
+
return [4 /*yield*/, validateStep(currentStep)];
|
|
78
74
|
case 1:
|
|
79
75
|
isValid = _a.sent();
|
|
80
76
|
if (!isValid) {
|
|
81
77
|
return [2 /*return*/];
|
|
82
78
|
}
|
|
83
79
|
_a.label = 2;
|
|
84
|
-
case 2:
|
|
85
|
-
if (step < steps) {
|
|
86
|
-
setStep(step + 1);
|
|
87
|
-
}
|
|
88
|
-
else if (step === steps && onClose) {
|
|
89
|
-
onClose();
|
|
90
|
-
}
|
|
91
|
-
return [2 /*return*/];
|
|
80
|
+
case 2: return [2 /*return*/];
|
|
92
81
|
}
|
|
93
82
|
});
|
|
94
|
-
}); }, [
|
|
83
|
+
}); }, [currentStep, validateStep, primaryButton]);
|
|
95
84
|
var handlePrevious = useCallback(function () {
|
|
96
|
-
|
|
97
|
-
|
|
85
|
+
var currentSecondaryButton = secondaryButton[currentStep - 1];
|
|
86
|
+
if (currentSecondaryButton === null || currentSecondaryButton === void 0 ? void 0 : currentSecondaryButton.onSecondaryButtonClick) {
|
|
87
|
+
currentSecondaryButton.onSecondaryButtonClick(currentStep);
|
|
98
88
|
}
|
|
99
|
-
}, [
|
|
100
|
-
var currentSecondaryButton = secondaryButton[
|
|
101
|
-
var currentPrimaryButton = primaryButton[
|
|
102
|
-
var currentShowProgressBar = showProgressBar[
|
|
103
|
-
var currentShowStartIcon = startIcon[
|
|
89
|
+
}, [currentStep, secondaryButton]);
|
|
90
|
+
var currentSecondaryButton = secondaryButton[currentStep - 1] || {};
|
|
91
|
+
var currentPrimaryButton = primaryButton[currentStep - 1] || {};
|
|
92
|
+
var currentShowProgressBar = showProgressBar[currentStep - 1] !== false;
|
|
93
|
+
var currentShowStartIcon = startIcon[currentStep - 1];
|
|
104
94
|
var handleClose = useCallback(function () {
|
|
105
95
|
setIsVisible(false);
|
|
106
96
|
if (onClose) {
|
|
@@ -109,11 +99,11 @@ var Stepper = function (_a) {
|
|
|
109
99
|
}, [onClose]);
|
|
110
100
|
var stepperContent = (React.createElement("div", { className: "stepper-overlay ".concat(isVisible ? "visible" : ""), onClick: handleClose },
|
|
111
101
|
React.createElement("div", { className: "stepper-container", onClick: function (e) { return e.stopPropagation(); } },
|
|
112
|
-
React.createElement(ProgressBar, { steps: steps, currentStep:
|
|
113
|
-
React.createElement("div", { className: "stepper-content" }, children[
|
|
102
|
+
React.createElement(ProgressBar, { steps: steps, currentStep: currentStep, startIcon: currentShowStartIcon, endIcon: endIcon, onStartIconClick: handlePrevious, onEndIconClick: handleClose, showProgressBar: currentShowProgressBar }),
|
|
103
|
+
React.createElement("div", { className: "stepper-content" }, children[currentStep - 1]),
|
|
114
104
|
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" : "") },
|
|
115
105
|
(currentSecondaryButton === null || currentSecondaryButton === void 0 ? void 0 : currentSecondaryButton.show) && (React.createElement("div", { className: "stepper-button-container secondary-button-container" },
|
|
116
|
-
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,
|
|
106
|
+
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); } }))),
|
|
117
107
|
(currentPrimaryButton === null || currentPrimaryButton === void 0 ? void 0 : currentPrimaryButton.show) && (React.createElement("div", { className: "stepper-button-container primary-button-container" },
|
|
118
108
|
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 })))))));
|
|
119
109
|
return portalContainerRef.current && isVisible
|