allaw-ui 0.1.14 → 0.1.16
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.
|
@@ -65,6 +65,16 @@
|
|
|
65
65
|
display: flex;
|
|
66
66
|
justify-content: center;
|
|
67
67
|
align-items: center;
|
|
68
|
+
opacity: 0;
|
|
69
|
+
visibility: hidden;
|
|
70
|
+
transition:
|
|
71
|
+
opacity 0.3s ease,
|
|
72
|
+
visibility 0.3s ease;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.stepper-overlay.visible {
|
|
76
|
+
opacity: 1;
|
|
77
|
+
visibility: visible;
|
|
68
78
|
}
|
|
69
79
|
|
|
70
80
|
.stepper-content {
|
|
@@ -9,13 +9,16 @@ import PrimaryButton from "../../atoms/buttons/PrimaryButton";
|
|
|
9
9
|
import SecondaryButton from "../../atoms/buttons/SecondaryButton";
|
|
10
10
|
var Stepper = function (_a) {
|
|
11
11
|
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;
|
|
12
|
-
var _g = useState(currentStep), step = _g[0], setStep = _g[1];
|
|
12
|
+
var _g = useState(currentStep || 1), step = _g[0], setStep = _g[1];
|
|
13
|
+
var _h = useState(false), isVisible = _h[0], setIsVisible = _h[1];
|
|
13
14
|
var portalContainerRef = useRef(null);
|
|
14
15
|
useEffect(function () {
|
|
15
16
|
var container = document.createElement("div");
|
|
16
17
|
document.body.appendChild(container);
|
|
17
18
|
portalContainerRef.current = container;
|
|
19
|
+
setIsVisible(true);
|
|
18
20
|
return function () {
|
|
21
|
+
setIsVisible(false);
|
|
19
22
|
if (portalContainerRef.current &&
|
|
20
23
|
document.body.contains(portalContainerRef.current)) {
|
|
21
24
|
document.body.removeChild(portalContainerRef.current);
|
|
@@ -23,7 +26,7 @@ var Stepper = function (_a) {
|
|
|
23
26
|
};
|
|
24
27
|
}, []);
|
|
25
28
|
useEffect(function () {
|
|
26
|
-
setStep(currentStep);
|
|
29
|
+
setStep(currentStep || 1);
|
|
27
30
|
}, [currentStep]);
|
|
28
31
|
var handleNext = useCallback(function () {
|
|
29
32
|
// console.log("Stepper: Validating current step");
|
|
@@ -52,20 +55,26 @@ var Stepper = function (_a) {
|
|
|
52
55
|
setStep(step - 1);
|
|
53
56
|
}
|
|
54
57
|
}, [step]);
|
|
55
|
-
var currentSecondaryButton = secondaryButton[step - 1];
|
|
56
|
-
var currentPrimaryButton = primaryButton[step - 1];
|
|
58
|
+
var currentSecondaryButton = secondaryButton[step - 1] || {};
|
|
59
|
+
var currentPrimaryButton = primaryButton[step - 1] || {};
|
|
57
60
|
var currentShowProgressBar = showProgressBar[step - 1] !== false;
|
|
58
61
|
var currentShowStartIcon = startIcon[step - 1];
|
|
59
|
-
var
|
|
62
|
+
var handleClose = useCallback(function () {
|
|
63
|
+
setIsVisible(false);
|
|
64
|
+
if (onClose) {
|
|
65
|
+
onClose();
|
|
66
|
+
}
|
|
67
|
+
}, [onClose]);
|
|
68
|
+
var stepperContent = (React.createElement("div", { className: "stepper-overlay ".concat(isVisible ? "visible" : ""), onClick: handleClose },
|
|
60
69
|
React.createElement("div", { className: "stepper-container", onClick: function (e) { return e.stopPropagation(); } },
|
|
61
|
-
React.createElement(ProgressBar, { steps: steps, currentStep: step, startIcon: currentShowStartIcon, endIcon: endIcon, onStartIconClick: handlePrevious, onEndIconClick:
|
|
70
|
+
React.createElement(ProgressBar, { steps: steps, currentStep: step, startIcon: currentShowStartIcon, endIcon: endIcon, onStartIconClick: handlePrevious, onEndIconClick: handleClose, showProgressBar: currentShowProgressBar }),
|
|
62
71
|
React.createElement("div", { className: "stepper-content" }, children[step - 1]),
|
|
63
72
|
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" : "") },
|
|
64
73
|
(currentSecondaryButton === null || currentSecondaryButton === void 0 ? void 0 : currentSecondaryButton.show) && (React.createElement("div", { className: "stepper-button-container secondary-button-container" },
|
|
65
74
|
React.createElement(SecondaryButton, { label: currentSecondaryButton.label, startIcon: currentSecondaryButton.icon, onClick: function () { var _a; return (_a = currentSecondaryButton.onSecondaryButtonClick) === null || _a === void 0 ? void 0 : _a.call(currentSecondaryButton, step); } }))),
|
|
66
75
|
(currentPrimaryButton === null || currentPrimaryButton === void 0 ? void 0 : currentPrimaryButton.show) && (React.createElement("div", { className: "stepper-button-container primary-button-container" },
|
|
67
76
|
React.createElement(PrimaryButton, { label: currentPrimaryButton.label, onClick: handleNext })))))));
|
|
68
|
-
return portalContainerRef.current
|
|
77
|
+
return portalContainerRef.current && isVisible
|
|
69
78
|
? ReactDOM.createPortal(stepperContent, portalContainerRef.current)
|
|
70
79
|
: null;
|
|
71
80
|
};
|