intelicoreact 1.2.29 → 1.2.30
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.
|
@@ -96,7 +96,8 @@ var Modal = function Modal(_ref2) {
|
|
|
96
96
|
|
|
97
97
|
var _useMobileModal = (0, _useMobileModal2.default)({
|
|
98
98
|
modalRef: modalRef,
|
|
99
|
-
noMobileModalLogic: noMobileModalLogic
|
|
99
|
+
noMobileModalLogic: noMobileModalLogic,
|
|
100
|
+
isOpen: isOpen
|
|
100
101
|
}),
|
|
101
102
|
modalMobileHeaderRef = _useMobileModal.modalMobileHeaderRef,
|
|
102
103
|
modalMobileBodyRef = _useMobileModal.modalMobileBodyRef,
|
|
@@ -131,7 +132,7 @@ var Modal = function Modal(_ref2) {
|
|
|
131
132
|
}, [submitOnEnter, closeOnEsc]);
|
|
132
133
|
|
|
133
134
|
var render = function render() {
|
|
134
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
135
|
+
return !isOpen ? null : /*#__PURE__*/_react.default.createElement("div", {
|
|
135
136
|
style: {
|
|
136
137
|
zIndex: zIndex
|
|
137
138
|
},
|
|
@@ -205,7 +206,6 @@ var Modal = function Modal(_ref2) {
|
|
|
205
206
|
})))))));
|
|
206
207
|
};
|
|
207
208
|
|
|
208
|
-
if (!isOpen) return null;
|
|
209
209
|
return render();
|
|
210
210
|
};
|
|
211
211
|
|
|
@@ -23,12 +23,13 @@ var SCROLL_DIRECTION = {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
function useMobileModal(_ref) {
|
|
26
|
-
var _modalMobileContainer, _modalMobileContainer2, _modalMobileHeaderRef, _modalMobileHeaderRef2, _modalMobileFooterRef, _modalMobileFooterRef2, _modalMobileFooterRef3, _modalMobileFooterRef4, _modalMobileBodyRef$c, _modalMobileBodyRef$c2
|
|
26
|
+
var _modalMobileContainer, _modalMobileContainer2, _modalMobileHeaderRef, _modalMobileHeaderRef2, _modalMobileFooterRef, _modalMobileFooterRef2, _modalMobileFooterRef3, _modalMobileFooterRef4, _modalMobileBodyRef$c, _modalMobileBodyRef$c2;
|
|
27
27
|
|
|
28
28
|
var _ref$modalRef = _ref.modalRef,
|
|
29
29
|
modalRef = _ref$modalRef === void 0 ? null : _ref$modalRef,
|
|
30
30
|
_ref$noMobileModalLog = _ref.noMobileModalLogic,
|
|
31
|
-
noMobileModalLogic = _ref$noMobileModalLog === void 0 ? false : _ref$noMobileModalLog
|
|
31
|
+
noMobileModalLogic = _ref$noMobileModalLog === void 0 ? false : _ref$noMobileModalLog,
|
|
32
|
+
isOpen = _ref.isOpen;
|
|
32
33
|
|
|
33
34
|
var _useState = (0, _react.useState)(false),
|
|
34
35
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -60,11 +61,6 @@ function useMobileModal(_ref) {
|
|
|
60
61
|
var footerBottom = modalMobileContainerHeight - (modalMobileFooterRef === null || modalMobileFooterRef === void 0 ? void 0 : (_modalMobileFooterRef = modalMobileFooterRef.current) === null || _modalMobileFooterRef === void 0 ? void 0 : (_modalMobileFooterRef2 = _modalMobileFooterRef.getBoundingClientRect()) === null || _modalMobileFooterRef2 === void 0 ? void 0 : _modalMobileFooterRef2.bottom);
|
|
61
62
|
var footerHeight = modalMobileFooterRef === null || modalMobileFooterRef === void 0 ? void 0 : (_modalMobileFooterRef3 = modalMobileFooterRef.current) === null || _modalMobileFooterRef3 === void 0 ? void 0 : (_modalMobileFooterRef4 = _modalMobileFooterRef3.getBoundingClientRect()) === null || _modalMobileFooterRef4 === void 0 ? void 0 : _modalMobileFooterRef4.height;
|
|
62
63
|
var bodyTop = modalMobileBodyRef === null || modalMobileBodyRef === void 0 ? void 0 : (_modalMobileBodyRef$c = modalMobileBodyRef.current) === null || _modalMobileBodyRef$c === void 0 ? void 0 : (_modalMobileBodyRef$c2 = _modalMobileBodyRef$c.getBoundingClientRect()) === null || _modalMobileBodyRef$c2 === void 0 ? void 0 : _modalMobileBodyRef$c2.top;
|
|
63
|
-
var modal = modalRef === null || modalRef === void 0 ? void 0 : modalRef.current;
|
|
64
|
-
var modalStyle = modal ? modal.currentStyle || window.getComputedStyle(modal) : {};
|
|
65
|
-
var modalHeight = modal ? (modal === null || modal === void 0 ? void 0 : (_modal$getBoundingCli = modal.getBoundingClientRect()) === null || _modal$getBoundingCli === void 0 ? void 0 : _modal$getBoundingCli.height) + parseFloat((modalStyle === null || modalStyle === void 0 ? void 0 : modalStyle.marginTop) || 0) : 0;
|
|
66
|
-
var windowHeight = document.documentElement.clientHeight || window.screen.availHeight || window.screen.height;
|
|
67
|
-
var modalContainer = modalMobileContainerRef === null || modalMobileContainerRef === void 0 ? void 0 : modalMobileContainerRef.current;
|
|
68
64
|
/* MODALS LOGIC | BEGIN */
|
|
69
65
|
// Detect Mobile
|
|
70
66
|
|
|
@@ -90,18 +86,26 @@ function useMobileModal(_ref) {
|
|
|
90
86
|
}, [scrollTop, scrollTopPrev]); // Dynamic Modal Positioning
|
|
91
87
|
|
|
92
88
|
(0, _react.useEffect)(function () {
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
if (isOpen) {
|
|
90
|
+
var _modalRef$current, _modalRef$current$get;
|
|
91
|
+
|
|
92
|
+
var modalStyle = modalRef !== null && modalRef !== void 0 && modalRef.current ? (modalRef === null || modalRef === void 0 ? void 0 : modalRef.current.currentStyle) || window.getComputedStyle(modalRef === null || modalRef === void 0 ? void 0 : modalRef.current) : {};
|
|
93
|
+
var modalHeight = modalRef !== null && modalRef !== void 0 && modalRef.current ? (modalRef === null || modalRef === void 0 ? void 0 : (_modalRef$current = modalRef.current) === null || _modalRef$current === void 0 ? void 0 : (_modalRef$current$get = _modalRef$current.getBoundingClientRect()) === null || _modalRef$current$get === void 0 ? void 0 : _modalRef$current$get.height) + parseFloat((modalStyle === null || modalStyle === void 0 ? void 0 : modalStyle.marginTop) || 0) : 0;
|
|
94
|
+
var windowHeight = document.documentElement.clientHeight || window.screen.availHeight || window.screen.height;
|
|
95
|
+
|
|
96
|
+
if (modalHeight && modalMobileContainerRef !== null && modalMobileContainerRef !== void 0 && modalMobileContainerRef.current) {
|
|
97
|
+
if (modalHeight <= windowHeight) {
|
|
98
|
+
modalMobileContainerRef.current.style.display = 'flex';
|
|
99
|
+
modalMobileContainerRef.current.style.alignItems = 'flex-end';
|
|
100
|
+
} else {
|
|
101
|
+
var _modalMobileContainer3, _modalMobileContainer4, _modalMobileContainer5, _modalMobileContainer6;
|
|
102
|
+
|
|
103
|
+
(_modalMobileContainer3 = modalMobileContainerRef.current) === null || _modalMobileContainer3 === void 0 ? void 0 : (_modalMobileContainer4 = _modalMobileContainer3.style) === null || _modalMobileContainer4 === void 0 ? void 0 : _modalMobileContainer4.removeProperty('display');
|
|
104
|
+
(_modalMobileContainer5 = modalMobileContainerRef.current) === null || _modalMobileContainer5 === void 0 ? void 0 : (_modalMobileContainer6 = _modalMobileContainer5.style) === null || _modalMobileContainer6 === void 0 ? void 0 : _modalMobileContainer6.removeProperty('align-items');
|
|
105
|
+
}
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
|
-
}, [
|
|
108
|
+
}, [modalRef, modalMobileContainerRef, isOpen]);
|
|
105
109
|
var MODALS_LOGIC = {
|
|
106
110
|
IS_HEADER_HIDDEN: !isMobile || noMobileModalLogic ? false : footerBottom * -1 <= footerHeight || scrollDirection === SCROLL_DIRECTION.DOWN,
|
|
107
111
|
IS_HEADER_STICKY: !isMobile || noMobileModalLogic ? false : headerTop <= 0,
|