intelicoreact 1.2.30 → 1.2.32
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.
|
@@ -178,7 +178,7 @@ var Modal = function Modal(_ref2) {
|
|
|
178
178
|
'modal__footer--sticky': !MODALS_LOGIC.IS_FOOTER_HIDDEN && MODALS_LOGIC.IS_FOOTER_STICKY,
|
|
179
179
|
'modal__footer_with-left-content': leftContentOfFooter
|
|
180
180
|
})
|
|
181
|
-
}, customFooter || /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, leftContentOfFooter, !noCloseBtn
|
|
181
|
+
}, customFooter || /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, leftContentOfFooter, (!noCloseBtn || !noConfirmBtn) && /*#__PURE__*/_react.default.createElement("div", {
|
|
182
182
|
className: "modal__buttons-block"
|
|
183
183
|
}, !noCloseBtn && /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
184
184
|
testId: "modal",
|
|
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports.default = useMobileModal;
|
|
11
11
|
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
12
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
15
|
|
|
14
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -17,58 +19,82 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
17
19
|
|
|
18
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
21
|
|
|
22
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
+
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
+
|
|
20
26
|
var SCROLL_DIRECTION = {
|
|
21
27
|
UP: 'up',
|
|
22
28
|
DOWN: 'down'
|
|
23
29
|
};
|
|
24
30
|
|
|
25
31
|
function useMobileModal(_ref) {
|
|
26
|
-
var
|
|
32
|
+
var _modalMobileContainer7, _modalMobileContainer8, _modalMobileHeaderRef3, _modalMobileHeaderRef4, _modalMobileBodyRef$c3, _modalMobileBodyRef$c4, _modalMobileFooterRef3, _modalMobileFooterRef4, _modalMobileFooterRef7, _modalMobileFooterRef8;
|
|
27
33
|
|
|
28
34
|
var _ref$modalRef = _ref.modalRef,
|
|
29
35
|
modalRef = _ref$modalRef === void 0 ? null : _ref$modalRef,
|
|
30
36
|
_ref$noMobileModalLog = _ref.noMobileModalLogic,
|
|
31
37
|
noMobileModalLogic = _ref$noMobileModalLog === void 0 ? false : _ref$noMobileModalLog,
|
|
32
38
|
isOpen = _ref.isOpen;
|
|
39
|
+
var modalMobileContainerRef = (0, _react.useRef)(null);
|
|
40
|
+
var modalMobileHeaderRef = (0, _react.useRef)(null);
|
|
41
|
+
var modalMobileFooterRef = (0, _react.useRef)(null);
|
|
42
|
+
var modalMobileBodyRef = (0, _react.useRef)(null);
|
|
33
43
|
|
|
34
44
|
var _useState = (0, _react.useState)(false),
|
|
35
45
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
36
46
|
isMobile = _useState2[0],
|
|
37
47
|
setIsMobile = _useState2[1];
|
|
38
48
|
|
|
39
|
-
var modalMobileContainerRef = (0, _react.useRef)(null);
|
|
40
|
-
var modalMobileHeaderRef = (0, _react.useRef)(null);
|
|
41
|
-
var modalMobileFooterRef = (0, _react.useRef)(null);
|
|
42
|
-
var modalMobileBodyRef = (0, _react.useRef)(null);
|
|
43
|
-
|
|
44
49
|
var _useState3 = (0, _react.useState)(0),
|
|
45
50
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var _useState5 = (0, _react.useState)(
|
|
51
|
+
modalHeight = _useState4[0],
|
|
52
|
+
setModalHeight = _useState4[1];
|
|
53
|
+
|
|
54
|
+
var _useState5 = (0, _react.useState)({
|
|
55
|
+
IS_HEADER_HIDDEN: false,
|
|
56
|
+
IS_HEADER_STICKY: false,
|
|
57
|
+
IS_FOOTER_HIDDEN: false,
|
|
58
|
+
IS_FOOTER_STICKY: false
|
|
59
|
+
}),
|
|
50
60
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var _useState7 = (0, _react.useState)(
|
|
61
|
+
modalsLogic = _useState6[0],
|
|
62
|
+
setModalsLogic = _useState6[1];
|
|
63
|
+
|
|
64
|
+
var _useState7 = (0, _react.useState)({
|
|
65
|
+
modalMobileContainerHeight: 0,
|
|
66
|
+
headerTop: 0,
|
|
67
|
+
bodyTop: 0,
|
|
68
|
+
footerBottom: 0,
|
|
69
|
+
footerHeight: 0
|
|
70
|
+
}),
|
|
55
71
|
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
modalsLogicProps = _useState8[0],
|
|
73
|
+
setModalsLogicProps = _useState8[1];
|
|
74
|
+
|
|
75
|
+
var _useState9 = (0, _react.useState)(SCROLL_DIRECTION.UP),
|
|
76
|
+
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
77
|
+
scrollDirection = _useState10[0],
|
|
78
|
+
setScrollDirection = _useState10[1];
|
|
79
|
+
|
|
80
|
+
var _useState11 = (0, _react.useState)(0),
|
|
81
|
+
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
82
|
+
scrollTopPrev = _useState12[0],
|
|
83
|
+
setScrollTopPrev = _useState12[1];
|
|
84
|
+
|
|
85
|
+
var _useState13 = (0, _react.useState)(0),
|
|
86
|
+
_useState14 = (0, _slicedToArray2.default)(_useState13, 2),
|
|
87
|
+
scrollTop = _useState14[0],
|
|
88
|
+
setScrollTop = _useState14[1];
|
|
64
89
|
/* MODALS LOGIC | BEGIN */
|
|
65
90
|
// Detect Mobile
|
|
66
91
|
|
|
67
|
-
|
|
92
|
+
|
|
93
|
+
(0, _react.useLayoutEffect)(function () {
|
|
68
94
|
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) setIsMobile(true);
|
|
69
95
|
}, [navigator.userAgent]); // Count ScrollTop
|
|
70
96
|
|
|
71
|
-
(0, _react.
|
|
97
|
+
(0, _react.useLayoutEffect)(function () {
|
|
72
98
|
var el = modalMobileContainerRef === null || modalMobileContainerRef === void 0 ? void 0 : modalMobileContainerRef.current;
|
|
73
99
|
|
|
74
100
|
if (el) {
|
|
@@ -81,37 +107,103 @@ function useMobileModal(_ref) {
|
|
|
81
107
|
}
|
|
82
108
|
}, [modalMobileContainerRef === null || modalMobileContainerRef === void 0 ? void 0 : modalMobileContainerRef.current]); // Count ScrollDirection
|
|
83
109
|
|
|
84
|
-
(0, _react.
|
|
110
|
+
(0, _react.useLayoutEffect)(function () {
|
|
85
111
|
setScrollDirection(scrollTop < scrollTopPrev ? SCROLL_DIRECTION.UP : SCROLL_DIRECTION.DOWN);
|
|
86
112
|
}, [scrollTop, scrollTopPrev]); // Dynamic Modal Positioning
|
|
87
113
|
|
|
88
|
-
(0, _react.
|
|
114
|
+
(0, _react.useLayoutEffect)(function () {
|
|
89
115
|
if (isOpen) {
|
|
90
|
-
var _modalRef$current, _modalRef$current$get;
|
|
91
|
-
|
|
92
116
|
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
|
-
|
|
117
|
+
|
|
118
|
+
var _modalHeight = modalRef !== null && modalRef !== void 0 && modalRef.current ? _modalHeight + parseFloat((modalStyle === null || modalStyle === void 0 ? void 0 : modalStyle.marginTop) || 0) : 0;
|
|
119
|
+
|
|
94
120
|
var windowHeight = document.documentElement.clientHeight || window.screen.availHeight || window.screen.height;
|
|
95
121
|
|
|
96
|
-
if (
|
|
97
|
-
if (
|
|
122
|
+
if (modalMobileContainerRef !== null && modalMobileContainerRef !== void 0 && modalMobileContainerRef.current) {
|
|
123
|
+
if (_modalHeight <= windowHeight) {
|
|
98
124
|
modalMobileContainerRef.current.style.display = 'flex';
|
|
99
125
|
modalMobileContainerRef.current.style.alignItems = 'flex-end';
|
|
100
126
|
} else {
|
|
101
|
-
var
|
|
127
|
+
var _modalMobileContainer, _modalMobileContainer2, _modalMobileContainer3, _modalMobileContainer4;
|
|
102
128
|
|
|
103
|
-
(
|
|
104
|
-
(
|
|
129
|
+
(_modalMobileContainer = modalMobileContainerRef.current) === null || _modalMobileContainer === void 0 ? void 0 : (_modalMobileContainer2 = _modalMobileContainer.style) === null || _modalMobileContainer2 === void 0 ? void 0 : _modalMobileContainer2.removeProperty('display');
|
|
130
|
+
(_modalMobileContainer3 = modalMobileContainerRef.current) === null || _modalMobileContainer3 === void 0 ? void 0 : (_modalMobileContainer4 = _modalMobileContainer3.style) === null || _modalMobileContainer4 === void 0 ? void 0 : _modalMobileContainer4.removeProperty('align-items');
|
|
105
131
|
}
|
|
106
132
|
}
|
|
107
133
|
}
|
|
108
|
-
}, [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
134
|
+
}, [modalsLogicProps, isOpen, isMobile, modalHeight]); // Calculating
|
|
135
|
+
|
|
136
|
+
(0, _react.useLayoutEffect)(function () {
|
|
137
|
+
if (isMobile && isOpen) {
|
|
138
|
+
var _modalRef$current, _modalRef$current$get;
|
|
139
|
+
|
|
140
|
+
var newModalHeight = 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;
|
|
141
|
+
|
|
142
|
+
if (modalHeight !== newModalHeight) {
|
|
143
|
+
setModalHeight(newModalHeight);
|
|
144
|
+
console.log({
|
|
145
|
+
modalHeight: modalHeight
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
(0, _react.useLayoutEffect)(function () {
|
|
151
|
+
var footerBottom = modalsLogicProps.footerBottom,
|
|
152
|
+
footerHeight = modalsLogicProps.footerHeight,
|
|
153
|
+
headerTop = modalsLogicProps.headerTop,
|
|
154
|
+
bodyTop = modalsLogicProps.bodyTop;
|
|
155
|
+
setModalsLogic({
|
|
156
|
+
IS_HEADER_HIDDEN: !isMobile || noMobileModalLogic ? false : footerBottom * -1 <= footerHeight || scrollDirection === SCROLL_DIRECTION.DOWN,
|
|
157
|
+
IS_HEADER_STICKY: !isMobile || noMobileModalLogic ? false : headerTop <= 0,
|
|
158
|
+
IS_FOOTER_HIDDEN: !isMobile || noMobileModalLogic ? false : bodyTop > 0 || scrollDirection === SCROLL_DIRECTION.UP,
|
|
159
|
+
IS_FOOTER_STICKY: !isMobile || noMobileModalLogic ? false : footerBottom <= 0
|
|
160
|
+
});
|
|
161
|
+
}, [isMobile, noMobileModalLogic, scrollDirection, modalsLogicProps, modalHeight]);
|
|
162
|
+
(0, _react.useLayoutEffect)(function () {
|
|
163
|
+
setModalsLogicProps(function (state) {
|
|
164
|
+
var _modalMobileContainer5, _modalMobileContainer6;
|
|
165
|
+
|
|
166
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
167
|
+
modalMobileContainerHeight: modalMobileContainerRef === null || modalMobileContainerRef === void 0 ? void 0 : (_modalMobileContainer5 = modalMobileContainerRef.current) === null || _modalMobileContainer5 === void 0 ? void 0 : (_modalMobileContainer6 = _modalMobileContainer5.getBoundingClientRect()) === null || _modalMobileContainer6 === void 0 ? void 0 : _modalMobileContainer6.height
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
}, [modalMobileContainerRef === null || modalMobileContainerRef === void 0 ? void 0 : (_modalMobileContainer7 = modalMobileContainerRef.current) === null || _modalMobileContainer7 === void 0 ? void 0 : (_modalMobileContainer8 = _modalMobileContainer7.getBoundingClientRect()) === null || _modalMobileContainer8 === void 0 ? void 0 : _modalMobileContainer8.height]);
|
|
171
|
+
(0, _react.useLayoutEffect)(function () {
|
|
172
|
+
setModalsLogicProps(function (state) {
|
|
173
|
+
var _modalMobileHeaderRef, _modalMobileHeaderRef2;
|
|
174
|
+
|
|
175
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
176
|
+
headerTop: modalMobileHeaderRef === null || modalMobileHeaderRef === void 0 ? void 0 : (_modalMobileHeaderRef = modalMobileHeaderRef.current) === null || _modalMobileHeaderRef === void 0 ? void 0 : (_modalMobileHeaderRef2 = _modalMobileHeaderRef.getBoundingClientRect()) === null || _modalMobileHeaderRef2 === void 0 ? void 0 : _modalMobileHeaderRef2.top
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
}, [modalMobileHeaderRef === null || modalMobileHeaderRef === void 0 ? void 0 : (_modalMobileHeaderRef3 = modalMobileHeaderRef.current) === null || _modalMobileHeaderRef3 === void 0 ? void 0 : (_modalMobileHeaderRef4 = _modalMobileHeaderRef3.getBoundingClientRect()) === null || _modalMobileHeaderRef4 === void 0 ? void 0 : _modalMobileHeaderRef4.top]);
|
|
180
|
+
(0, _react.useLayoutEffect)(function () {
|
|
181
|
+
setModalsLogicProps(function (state) {
|
|
182
|
+
var _modalMobileBodyRef$c, _modalMobileBodyRef$c2;
|
|
183
|
+
|
|
184
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
185
|
+
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
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}, [modalMobileBodyRef === null || modalMobileBodyRef === void 0 ? void 0 : (_modalMobileBodyRef$c3 = modalMobileBodyRef.current) === null || _modalMobileBodyRef$c3 === void 0 ? void 0 : (_modalMobileBodyRef$c4 = _modalMobileBodyRef$c3.getBoundingClientRect()) === null || _modalMobileBodyRef$c4 === void 0 ? void 0 : _modalMobileBodyRef$c4.top]);
|
|
189
|
+
(0, _react.useLayoutEffect)(function () {
|
|
190
|
+
setModalsLogicProps(function (state) {
|
|
191
|
+
var _modalMobileFooterRef, _modalMobileFooterRef2;
|
|
192
|
+
|
|
193
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
194
|
+
footerBottom: modalsLogicProps.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)
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
}, [modalsLogicProps.modalMobileContainerHeight, 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.bottom]);
|
|
198
|
+
(0, _react.useLayoutEffect)(function () {
|
|
199
|
+
setModalsLogicProps(function (state) {
|
|
200
|
+
var _modalMobileFooterRef5, _modalMobileFooterRef6;
|
|
201
|
+
|
|
202
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
203
|
+
footerHeight: modalMobileFooterRef === null || modalMobileFooterRef === void 0 ? void 0 : (_modalMobileFooterRef5 = modalMobileFooterRef.current) === null || _modalMobileFooterRef5 === void 0 ? void 0 : (_modalMobileFooterRef6 = _modalMobileFooterRef5.getBoundingClientRect()) === null || _modalMobileFooterRef6 === void 0 ? void 0 : _modalMobileFooterRef6.height
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
}, [modalMobileFooterRef === null || modalMobileFooterRef === void 0 ? void 0 : (_modalMobileFooterRef7 = modalMobileFooterRef.current) === null || _modalMobileFooterRef7 === void 0 ? void 0 : (_modalMobileFooterRef8 = _modalMobileFooterRef7.getBoundingClientRect()) === null || _modalMobileFooterRef8 === void 0 ? void 0 : _modalMobileFooterRef8.height]);
|
|
115
207
|
/* MODALS LOGIC | END */
|
|
116
208
|
|
|
117
209
|
var renderMobileModal = function renderMobileModal(modal) {
|
|
@@ -130,7 +222,7 @@ function useMobileModal(_ref) {
|
|
|
130
222
|
modalMobileHeaderRef: modalMobileHeaderRef,
|
|
131
223
|
modalMobileBodyRef: modalMobileBodyRef,
|
|
132
224
|
modalMobileFooterRef: modalMobileFooterRef,
|
|
133
|
-
MODALS_LOGIC:
|
|
225
|
+
MODALS_LOGIC: modalsLogic,
|
|
134
226
|
SCROLL_DIRECTION: SCROLL_DIRECTION,
|
|
135
227
|
renderModal: renderModal,
|
|
136
228
|
isMobile: isMobile
|