@megafon/ui-core 7.8.0 → 7.9.0
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.
- package/dist/es/components/Modal/Modal.d.ts +4 -1
- package/dist/es/components/Modal/Modal.js +29 -3
- package/dist/es/components/Modal/_ModalContent/ModalContent.css +1 -1
- package/dist/es/components/Modal/_ModalContent/ModalContent.js +1 -1
- package/dist/es/components/Modal/_ModalMobileBottom/ModalMobileBottom.js +9 -4
- package/dist/es/components/Modal/mocks.js +4 -0
- package/dist/es/components/Modal/types.d.ts +1 -0
- package/dist/es/components/ScrollBar/ScrollBar.d.ts +2 -0
- package/dist/es/components/ScrollBar/ScrollBar.js +12 -3
- package/dist/lib/components/Modal/Modal.d.ts +4 -1
- package/dist/lib/components/Modal/Modal.js +29 -3
- package/dist/lib/components/Modal/_ModalContent/ModalContent.css +1 -1
- package/dist/lib/components/Modal/_ModalContent/ModalContent.js +1 -1
- package/dist/lib/components/Modal/_ModalMobileBottom/ModalMobileBottom.js +9 -4
- package/dist/lib/components/Modal/mocks.js +4 -0
- package/dist/lib/components/Modal/types.d.ts +1 -0
- package/dist/lib/components/ScrollBar/ScrollBar.d.ts +2 -0
- package/dist/lib/components/ScrollBar/ScrollBar.js +12 -3
- package/package.json +4 -4
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import type { IScrollBarProps } from '../ScrollBar/ScrollBar';
|
|
3
3
|
import './Modal.scss';
|
|
4
4
|
export declare enum MODAL_MOBILE_VIEWS_ENUM {
|
|
5
|
-
FULL_SCREEN = "
|
|
5
|
+
FULL_SCREEN = "fullScreen",// use camelCase for simple using in props from backend
|
|
6
6
|
BOTTOM = "bottom"
|
|
7
7
|
}
|
|
8
8
|
export declare enum MODAL_TRANSITIONS_STEPS_ENUM {
|
|
@@ -20,6 +20,7 @@ export type ModalClassesType = {
|
|
|
20
20
|
containerInner?: string;
|
|
21
21
|
containerBody?: string;
|
|
22
22
|
header?: string;
|
|
23
|
+
headerBackButton?: string;
|
|
23
24
|
headerCloseButton?: string;
|
|
24
25
|
titleArea?: string;
|
|
25
26
|
title?: string;
|
|
@@ -88,6 +89,8 @@ export interface IModalProps {
|
|
|
88
89
|
isDisabledBackgroundClick?: boolean;
|
|
89
90
|
/** Восстанавливает фокус на элементе, который был сфокусирован до открытия модального окна */
|
|
90
91
|
isReturnFocusAfterClose?: boolean;
|
|
92
|
+
/** Пересчитывать максимальную высоту скролла */
|
|
93
|
+
isRecalculateHeight?: boolean;
|
|
91
94
|
/** Должен ли root-элемент приложения быть скрыт */
|
|
92
95
|
hideAriaApp?: boolean;
|
|
93
96
|
/** Устанавливает aria-label */
|
|
@@ -5,6 +5,7 @@ import { cnCreate, breakpoints } from '@megafon/ui-helpers';
|
|
|
5
5
|
import throttle from 'lodash.throttle';
|
|
6
6
|
import ReactModal from 'react-modal';
|
|
7
7
|
import THROTTLE_TIME from "../../constants/throttleTime";
|
|
8
|
+
import usePrevious from "../../hooks/usePrevious";
|
|
8
9
|
import useResolution from "../../hooks/useResolution";
|
|
9
10
|
import ModalDesktop from "./_ModalDesktop/ModalDesktop";
|
|
10
11
|
import ModalMobileBottom from "./_ModalMobileBottom/ModalMobileBottom";
|
|
@@ -15,7 +16,7 @@ var MOBILE_BIG_START = breakpoints.MOBILE_BIG_START;
|
|
|
15
16
|
var HEIGHT_TRANSITION_PROPERTY = 'height';
|
|
16
17
|
export var MODAL_MOBILE_VIEWS_ENUM;
|
|
17
18
|
(function (MODAL_MOBILE_VIEWS_ENUM) {
|
|
18
|
-
MODAL_MOBILE_VIEWS_ENUM["FULL_SCREEN"] = "
|
|
19
|
+
MODAL_MOBILE_VIEWS_ENUM["FULL_SCREEN"] = "fullScreen";
|
|
19
20
|
MODAL_MOBILE_VIEWS_ENUM["BOTTOM"] = "bottom";
|
|
20
21
|
})(MODAL_MOBILE_VIEWS_ENUM || (MODAL_MOBILE_VIEWS_ENUM = {}));
|
|
21
22
|
export var MODAL_TRANSITIONS_STEPS_ENUM;
|
|
@@ -40,6 +41,7 @@ var Modal = function Modal(_ref) {
|
|
|
40
41
|
isEnabledNativeScroll = _ref.isEnabledNativeScroll,
|
|
41
42
|
isSwipeDisabled = _ref.isSwipeDisabled,
|
|
42
43
|
isDisabledBackgroundClick = _ref.isDisabledBackgroundClick,
|
|
44
|
+
isRecalculateHeight = _ref.isRecalculateHeight,
|
|
43
45
|
_ref$hideAriaApp = _ref.hideAriaApp,
|
|
44
46
|
hideAriaApp = _ref$hideAriaApp === void 0 ? false : _ref$hideAriaApp,
|
|
45
47
|
contentLabel = _ref.contentLabel,
|
|
@@ -85,6 +87,7 @@ var Modal = function Modal(_ref) {
|
|
|
85
87
|
var containerWrapRef = React.useRef(null);
|
|
86
88
|
var containerInnerRef = React.useRef(null);
|
|
87
89
|
var containerBodyRef = React.useRef(null);
|
|
90
|
+
var scrollBarScrollableRef = React.useRef(null);
|
|
88
91
|
var resizeObserver = React.useRef(null);
|
|
89
92
|
var _useResolution = useResolution(),
|
|
90
93
|
isMobile = _useResolution.isMobile;
|
|
@@ -93,6 +96,15 @@ var Modal = function Modal(_ref) {
|
|
|
93
96
|
var isBottomTransitionIn = transitionStep !== MODAL_TRANSITIONS_STEPS_ENUM.END_STEP && transitionStep !== MODAL_TRANSITIONS_STEPS_ENUM.MOVE_END_STEP;
|
|
94
97
|
var isTransitionMoveStep = transitionStep === MODAL_TRANSITIONS_STEPS_ENUM.MOVE_STEP;
|
|
95
98
|
var isTransitionEndStep = transitionStep === MODAL_TRANSITIONS_STEPS_ENUM.END_STEP;
|
|
99
|
+
var prevMobileView = usePrevious(mobileView);
|
|
100
|
+
var isChangeMobileView = mobileView !== prevMobileView;
|
|
101
|
+
var prevHeaderProps = usePrevious(headerProps);
|
|
102
|
+
var prevFooterProps = usePrevious(footerProps);
|
|
103
|
+
var isHeaderPropsDiff = headerProps !== prevHeaderProps;
|
|
104
|
+
var isFooterPropsDiff = footerProps !== prevFooterProps;
|
|
105
|
+
var handleGetScrollBarScrollableRef = function handleGetScrollBarScrollableRef(node) {
|
|
106
|
+
scrollBarScrollableRef.current = node;
|
|
107
|
+
};
|
|
96
108
|
var handleChangeTransitionStep = function handleChangeTransitionStep(value) {
|
|
97
109
|
setTransitionStep(value);
|
|
98
110
|
};
|
|
@@ -201,6 +213,18 @@ var Modal = function Modal(_ref) {
|
|
|
201
213
|
window.removeEventListener('resize', handleThrottleResize);
|
|
202
214
|
};
|
|
203
215
|
}, [isEnabledNativeScroll, handleSetScrollContentMaxHeight]);
|
|
216
|
+
React.useEffect(function () {
|
|
217
|
+
if (!isMobile || !isChangeMobileView) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
handleSetScrollContentMaxHeight();
|
|
221
|
+
}, [isMobile, isChangeMobileView, handleSetScrollContentMaxHeight]);
|
|
222
|
+
React.useEffect(function () {
|
|
223
|
+
if (isEnabledNativeScroll || !(isRecalculateHeight && (isHeaderPropsDiff || isFooterPropsDiff))) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
handleSetScrollContentMaxHeight();
|
|
227
|
+
}, [isEnabledNativeScroll, isFooterPropsDiff, isRecalculateHeight, isHeaderPropsDiff, handleSetScrollContentMaxHeight]);
|
|
204
228
|
React.useEffect(function () {
|
|
205
229
|
return function () {
|
|
206
230
|
setIsPopupOpened(false);
|
|
@@ -215,7 +239,8 @@ var Modal = function Modal(_ref) {
|
|
|
215
239
|
classes: classes,
|
|
216
240
|
dataAttrs: dataAttrs,
|
|
217
241
|
scrollBarParams: _extends(_extends({}, scrollBarParams), {
|
|
218
|
-
maxHeight: scrollMaxHeight
|
|
242
|
+
maxHeight: scrollMaxHeight,
|
|
243
|
+
getScrollable: handleGetScrollBarScrollableRef
|
|
219
244
|
}),
|
|
220
245
|
headerProps: headerProps,
|
|
221
246
|
footerProps: footerProps,
|
|
@@ -225,7 +250,8 @@ var Modal = function Modal(_ref) {
|
|
|
225
250
|
footerRef: footerRef,
|
|
226
251
|
containerWrapRef: containerWrapRef,
|
|
227
252
|
containerInnerRef: containerInnerRef,
|
|
228
|
-
containerBodyRef: containerBodyRef
|
|
253
|
+
containerBodyRef: containerBodyRef,
|
|
254
|
+
scrollBarScrollableRef: scrollBarScrollableRef
|
|
229
255
|
},
|
|
230
256
|
isEnabledNativeScroll: isEnabledNativeScroll,
|
|
231
257
|
isDisabledBackgroundClick: isDisabledBackgroundClick,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
h1,h2,h3,h4,h5{margin:0}.mfui-modal-content__background{background-color:rgba(0,0,0,.8);bottom:0;left:0;position:fixed;right:0;top:0}.mfui-modal-content__container-wrap{-webkit-animation:show-popup .3s ease-out;animation:show-popup .3s ease-out;position:relative;width:100%}@media screen and (min-width:768px){.mfui-modal-content__container-wrap{-webkit-transition:height .1s;transition:height .1s;width:740px}}.mfui-modal-content__container-inner{background-color:var(--background);font-family:inherit;width:100%}.mfui-modal-content__header{position:relative}.mfui-modal-content__header_shadow{-webkit-box-shadow:0 2px 12px rgba(0,0,0,.1);box-shadow:0 2px 12px rgba(0,0,0,.1)}.mfui-modal-content__header-main{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;min-height:52px}@media screen and (min-width:768px){.mfui-modal-content__header-main{min-height:64px}}.mfui-modal-content__header-button{display:-webkit-box;display:-ms-flexbox;display:flex;position:absolute;top:12px;z-index:2;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;background:transparent;border:none;cursor:pointer;height:32px;justify-content:center;outline:none;width:32px}@media screen and (min-width:768px){.mfui-modal-content__header-button{height:40px;width:40px}}.mfui-modal-content__header-button_back{left:16px}.mfui-modal-content__header-button_close{right:16px}.mfui-modal-content__header-button_shadow{background:var(--base);border-radius:50%;-webkit-box-shadow:0 2px 12px rgba(0,0,0,.1);box-shadow:0 2px 12px rgba(0,0,0,.1)}.mfui-modal-content__header-button svg{fill:var(--content)}.mfui-modal-content__title-area{-webkit-box-sizing:border-box;box-sizing:border-box;margin:0 48px;padding:12px}@media screen and (min-width:768px){.mfui-modal-content__title-area{margin:0 56px;padding:16px}}.mfui-modal-content__title{font-size:18px;font-weight:500;letter-spacing:.5px;line-height:24px;text-align:center}@media screen and (min-width:1280px){.mfui-modal-content__title{font-size:20px;line-height:28px}}@media screen and (min-width:768px){.mfui-modal-content__title{font-size:20px;font-weight:500;letter-spacing:.5px;line-height:28px}}.mfui-modal-content__header-additional{-webkit-box-sizing:border-box;box-sizing:border-box;padding:8px 16px;text-align:center}@media screen and (min-width:768px){.mfui-modal-content__header-additional{padding-left:32px;padding-right:32px}}.mfui-modal-content__container-body{-webkit-box-sizing:border-box;box-sizing:border-box;padding-bottom:24px;padding-right:6px}@media screen and (min-width:768px){.mfui-modal-content__container-body{padding-bottom:32px;padding-right:12px}}.mfui-modal-content__children{-webkit-box-sizing:border-box;box-sizing:border-box;padding-left:16px;padding-right:4px;padding-top:24px}@media screen and (min-width:768px){.mfui-modal-content__children{padding-left:32px;padding-right:14px}}.mfui-modal-
|
|
1
|
+
h1,h2,h3,h4,h5{margin:0}.mfui-modal-content__background{background-color:rgba(0,0,0,.8);bottom:0;left:0;position:fixed;right:0;top:0}.mfui-modal-content__container-wrap{-webkit-animation:show-popup .3s ease-out;animation:show-popup .3s ease-out;position:relative;width:100%}@media screen and (min-width:768px){.mfui-modal-content__container-wrap{-webkit-transition:height .1s;transition:height .1s;width:740px}}.mfui-modal-content__container-inner{background-color:var(--background);font-family:inherit;width:100%}.mfui-modal-content__header{position:relative}.mfui-modal-content__header_shadow{-webkit-box-shadow:0 2px 12px rgba(0,0,0,.1);box-shadow:0 2px 12px rgba(0,0,0,.1)}.mfui-modal-content__header-main{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;min-height:52px}@media screen and (min-width:768px){.mfui-modal-content__header-main{min-height:64px}}.mfui-modal-content__header-button{display:-webkit-box;display:-ms-flexbox;display:flex;position:absolute;top:12px;z-index:2;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;background:transparent;border:none;cursor:pointer;height:32px;justify-content:center;outline:none;width:32px}@media screen and (min-width:768px){.mfui-modal-content__header-button{height:40px;width:40px}}.mfui-modal-content__header-button_back{left:16px}.mfui-modal-content__header-button_close{right:16px}.mfui-modal-content__header-button_shadow{background:var(--base);border-radius:50%;-webkit-box-shadow:0 2px 12px rgba(0,0,0,.1);box-shadow:0 2px 12px rgba(0,0,0,.1)}.mfui-modal-content__header-button svg{fill:var(--content)}.mfui-modal-content__title-area{-webkit-box-sizing:border-box;box-sizing:border-box;margin:0 48px;padding:12px}@media screen and (min-width:768px){.mfui-modal-content__title-area{margin:0 56px;padding:16px}}.mfui-modal-content__title{font-size:18px;font-weight:500;letter-spacing:.5px;line-height:24px;text-align:center}@media screen and (min-width:1280px){.mfui-modal-content__title{font-size:20px;line-height:28px}}@media screen and (min-width:768px){.mfui-modal-content__title{font-size:20px;font-weight:500;letter-spacing:.5px;line-height:28px}}.mfui-modal-content__header-additional{-webkit-box-sizing:border-box;box-sizing:border-box;padding:8px 16px;text-align:center}@media screen and (min-width:768px){.mfui-modal-content__header-additional{padding-left:32px;padding-right:32px}}.mfui-modal-content__container-body{-webkit-box-sizing:border-box;box-sizing:border-box;padding-bottom:24px;padding-right:6px}@media screen and (min-width:768px){.mfui-modal-content__container-body{padding-bottom:32px;padding-right:12px}}.mfui-modal-content__children{-webkit-box-sizing:border-box;box-sizing:border-box;padding-left:16px;padding-right:4px;padding-top:24px}@media screen and (min-width:768px){.mfui-modal-content__children{padding-left:32px;padding-right:14px}}.mfui-modal-content__container-wrap_static-header .mfui-modal-content__container-body{padding-top:24px}.mfui-modal-content__container-wrap_static-header .mfui-modal-content__children{padding-top:0}.mfui-modal-content__container-wrap_static-header .mfui-modal-content__header{margin-bottom:24px;margin-left:-16px;margin-right:-16px}@media screen and (min-width:768px){.mfui-modal-content__container-wrap_static-header .mfui-modal-content__header{margin-left:-32px;margin-right:-32px}}.mfui-modal-content__container-wrap_static-header .mfui-modal-content__header-main{min-height:40px}.mfui-modal-content__container-wrap_static-header .mfui-modal-content__header-button{top:0}.mfui-modal-content__container-wrap_static-header .mfui-modal-content__title-area{padding-bottom:4px;padding-top:4px}.mfui-modal-content__container-wrap_hide-header .mfui-modal-content__container-body{padding-top:24px}.mfui-modal-content__container-wrap_hide-header .mfui-modal-content__children{padding-top:0}.mfui-modal-content__container-wrap_sticky-footer .mfui-modal-content__container-body{padding-bottom:0}.mfui-modal-content__container-wrap_sticky-footer .mfui-modal-content__footer{padding-left:16px;padding-right:16px}@media screen and (min-width:768px){.mfui-modal-content__container-wrap_sticky-footer .mfui-modal-content__footer{padding-left:32px;padding-right:32px}}.mfui-modal-content__container-wrap_sticky-footer .mfui-modal-content__footer_shadow{-webkit-box-shadow:0 2px 12px rgba(0,0,0,.1);box-shadow:0 2px 12px rgba(0,0,0,.1)}.mfui-modal-content__container-wrap_out-side-buttons .mfui-modal-content__container-body{padding-top:24px}.mfui-modal-content__container-wrap_native-scroll .mfui-modal-content__children,.mfui-modal-content__container-wrap_native-scroll .mfui-modal-content__container-body{padding:0}.mfui-modal-content__container-wrap_transition-end{-webkit-animation:hide-popup .2s ease-in;animation:hide-popup .2s ease-in}@-webkit-keyframes show-popup{0%{-webkit-transform:scale(95%);transform:scale(95%);-webkit-transform-origin:top;transform-origin:top}to{-webkit-transform:scale(100%);transform:scale(100%)}}@keyframes show-popup{0%{-webkit-transform:scale(95%);transform:scale(95%);-webkit-transform-origin:top;transform-origin:top}to{-webkit-transform:scale(100%);transform:scale(100%)}}@-webkit-keyframes hide-popup{0%{-webkit-transform:scale(100%);transform:scale(100%)}to{-webkit-transform:scale(95%);transform:scale(95%)}}@keyframes hide-popup{0%{-webkit-transform:scale(100%);transform:scale(100%)}to{-webkit-transform:scale(95%);transform:scale(95%)}}
|
|
@@ -94,7 +94,7 @@ var ModalContent = function ModalContent(_ref) {
|
|
|
94
94
|
className: cn('header-button', {
|
|
95
95
|
back: true,
|
|
96
96
|
shadow: hasHeaderButtonsShadow
|
|
97
|
-
}),
|
|
97
|
+
}, classes === null || classes === void 0 ? void 0 : classes.headerBackButton),
|
|
98
98
|
type: "button",
|
|
99
99
|
onClick: onBackButtonClick
|
|
100
100
|
}), isSmallIcon ? /*#__PURE__*/React.createElement(ArrowLeft24, null) : /*#__PURE__*/React.createElement(ArrowLeft32, null));
|
|
@@ -31,6 +31,7 @@ var ModalMobileBottom = function ModalMobileBottom(_a) {
|
|
|
31
31
|
var _restProps$refs = restProps.refs,
|
|
32
32
|
containerWrapRef = _restProps$refs.containerWrapRef,
|
|
33
33
|
containerInnerRef = _restProps$refs.containerInnerRef,
|
|
34
|
+
scrollBarScrollableRef = _restProps$refs.scrollBarScrollableRef,
|
|
34
35
|
isTransitionMoveStep = restProps.isTransitionMoveStep,
|
|
35
36
|
isTransitionEndStep = restProps.isTransitionEndStep;
|
|
36
37
|
var _React$useState = React.useState(null),
|
|
@@ -51,9 +52,11 @@ var ModalMobileBottom = function ModalMobileBottom(_a) {
|
|
|
51
52
|
window.cancelAnimationFrame(animationFrameId.current);
|
|
52
53
|
}
|
|
53
54
|
var containerWrapNode = containerWrapRef.current;
|
|
55
|
+
var scrollableNode = scrollBarScrollableRef.current;
|
|
54
56
|
animationFrameId.current = window.requestAnimationFrame(function () {
|
|
55
57
|
onChangeTransitionStep(MODAL_TRANSITIONS_STEPS_ENUM.MOVE_STEP);
|
|
56
|
-
|
|
58
|
+
var isScrollTop = ((scrollableNode === null || scrollableNode === void 0 ? void 0 : scrollableNode.scrollTop) || 0) === 0;
|
|
59
|
+
if (!containerWrapNode || !isScrollTop) {
|
|
57
60
|
return;
|
|
58
61
|
}
|
|
59
62
|
if (!initialContainerWrapHeight) {
|
|
@@ -74,11 +77,13 @@ var ModalMobileBottom = function ModalMobileBottom(_a) {
|
|
|
74
77
|
onChangeContainerWrapTransform("translateY(".concat(positionsDiffAbs, "px)"));
|
|
75
78
|
animationFrameId.current = 0;
|
|
76
79
|
});
|
|
77
|
-
}, [containerWrapRef, initialContainerWrapHeight, initialTouchPosition, onChangeContainerWrapTransform, onChangeTransitionStep]);
|
|
80
|
+
}, [containerWrapRef, scrollBarScrollableRef, initialContainerWrapHeight, initialTouchPosition, onChangeContainerWrapTransform, onChangeTransitionStep]);
|
|
78
81
|
var handleWindowTouchEnd = React.useCallback(function (e) {
|
|
79
82
|
var _a;
|
|
80
83
|
var containerWrapNode = containerWrapRef.current;
|
|
81
|
-
|
|
84
|
+
var scrollableNode = scrollBarScrollableRef.current;
|
|
85
|
+
var isScrollTop = ((scrollableNode === null || scrollableNode === void 0 ? void 0 : scrollableNode.scrollTop) || 0) === 0;
|
|
86
|
+
if (!containerWrapNode || !isTransitionMoveStep || !isScrollTop) {
|
|
82
87
|
return;
|
|
83
88
|
}
|
|
84
89
|
window.cancelAnimationFrame(animationFrameId.current);
|
|
@@ -87,7 +92,7 @@ var ModalMobileBottom = function ModalMobileBottom(_a) {
|
|
|
87
92
|
setInitialTouchPosition(null);
|
|
88
93
|
onChangeContainerWrapTransform(isMoreHalfClosed ? 'translateY(100%)' : 'none');
|
|
89
94
|
onChangeTransitionStep(isMoreHalfClosed ? MODAL_TRANSITIONS_STEPS_ENUM.MOVE_END_STEP : MODAL_TRANSITIONS_STEPS_ENUM.INITIAL_STEP);
|
|
90
|
-
}, [containerWrapRef, isTransitionMoveStep, offsetHeightCenter, onChangeContainerWrapTransform, onChangeTransitionStep]);
|
|
95
|
+
}, [containerWrapRef, scrollBarScrollableRef, isTransitionMoveStep, offsetHeightCenter, onChangeContainerWrapTransform, onChangeTransitionStep]);
|
|
91
96
|
React.useEffect(function () {
|
|
92
97
|
if (isSwipeDisabled) {
|
|
93
98
|
return undefined;
|
|
@@ -8,6 +8,7 @@ var mockModalContextProps = {
|
|
|
8
8
|
containerInner: 'containerInner-class',
|
|
9
9
|
containerBody: 'containerBody-class',
|
|
10
10
|
header: 'header-class',
|
|
11
|
+
headerBackButton: 'headerBackButton-class',
|
|
11
12
|
headerCloseButton: 'headerCloseButton-class',
|
|
12
13
|
titleArea: 'titleArea-class',
|
|
13
14
|
title: 'title-class',
|
|
@@ -62,6 +63,9 @@ var mockModalContextProps = {
|
|
|
62
63
|
},
|
|
63
64
|
containerBodyRef: {
|
|
64
65
|
current: null
|
|
66
|
+
},
|
|
67
|
+
scrollBarScrollableRef: {
|
|
68
|
+
current: null
|
|
65
69
|
}
|
|
66
70
|
},
|
|
67
71
|
isMobile: false,
|
|
@@ -11,6 +11,7 @@ type ModalContextPropsType = ModalComponentPropsType & {
|
|
|
11
11
|
containerWrapRef: RefType;
|
|
12
12
|
containerInnerRef: RefType;
|
|
13
13
|
containerBodyRef: RefType;
|
|
14
|
+
scrollBarScrollableRef: React.MutableRefObject<HTMLElement | null>;
|
|
14
15
|
};
|
|
15
16
|
isMobile: boolean;
|
|
16
17
|
isTransitionMoveStep: boolean;
|
|
@@ -30,6 +30,8 @@ export interface IScrollBarProps {
|
|
|
30
30
|
showAlways?: boolean;
|
|
31
31
|
/** Ref обработчик */
|
|
32
32
|
getScrollBar?: (node: HTMLElement) => void;
|
|
33
|
+
/** Ref обработчик для Scrollable element */
|
|
34
|
+
getScrollable?: (node: HTMLElement) => void;
|
|
33
35
|
children?: React.ReactNode;
|
|
34
36
|
}
|
|
35
37
|
declare const ScrollBar: React.FC<IScrollBarProps>;
|
|
@@ -17,12 +17,14 @@ var ScrollBar = function ScrollBar(_ref) {
|
|
|
17
17
|
hideMobile = _ref.hideMobile,
|
|
18
18
|
showAlways = _ref.showAlways,
|
|
19
19
|
getScrollBar = _ref.getScrollBar,
|
|
20
|
+
getScrollable = _ref.getScrollable,
|
|
20
21
|
children = _ref.children;
|
|
21
22
|
var _React$useState = React.useState(false),
|
|
22
23
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
23
24
|
isInitialHide = _React$useState2[0],
|
|
24
25
|
setIsInitialHide = _React$useState2[1];
|
|
25
26
|
var scrollBarInitNode = React.useRef(null);
|
|
27
|
+
var scrollableNode = React.useRef(null);
|
|
26
28
|
var resizeObserver = React.useRef(null);
|
|
27
29
|
function handleGetScrollBarRef(node) {
|
|
28
30
|
if (!node) {
|
|
@@ -32,6 +34,10 @@ var ScrollBar = function ScrollBar(_ref) {
|
|
|
32
34
|
scrollBarInitNode.current = scrollInitEl;
|
|
33
35
|
getScrollBar === null || getScrollBar === void 0 ? void 0 : getScrollBar(scrollInitEl);
|
|
34
36
|
}
|
|
37
|
+
function handleGetScrollableRef(node) {
|
|
38
|
+
scrollableNode.current = node;
|
|
39
|
+
getScrollable === null || getScrollable === void 0 ? void 0 : getScrollable(node);
|
|
40
|
+
}
|
|
35
41
|
var handleSetInitialHide = React.useCallback(function () {
|
|
36
42
|
if (!scrollBarInitNode.current || !maxHeight) {
|
|
37
43
|
setIsInitialHide(false);
|
|
@@ -57,7 +63,7 @@ var ScrollBar = function ScrollBar(_ref) {
|
|
|
57
63
|
}
|
|
58
64
|
};
|
|
59
65
|
}, [handleSetInitialHide, maxHeight]);
|
|
60
|
-
return /*#__PURE__*/React.createElement("div", _extends({
|
|
66
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
61
67
|
className: cn({
|
|
62
68
|
'initial-hide': isInitialHide,
|
|
63
69
|
'hide-all': hideAll,
|
|
@@ -67,7 +73,7 @@ var ScrollBar = function ScrollBar(_ref) {
|
|
|
67
73
|
'hide-mobile': hideMobile,
|
|
68
74
|
'show-always': showAlways
|
|
69
75
|
}, [classes === null || classes === void 0 ? void 0 : classes.root])
|
|
70
|
-
}
|
|
76
|
+
}), /*#__PURE__*/React.createElement(SimpleBar, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.init), {
|
|
71
77
|
className: cn('init', [classes === null || classes === void 0 ? void 0 : classes.init]),
|
|
72
78
|
classNames: {
|
|
73
79
|
track: cn('scroll-track'),
|
|
@@ -80,7 +86,10 @@ var ScrollBar = function ScrollBar(_ref) {
|
|
|
80
86
|
maxHeight: "".concat(maxHeight, "px")
|
|
81
87
|
},
|
|
82
88
|
forceVisible: "y",
|
|
83
|
-
ref: handleGetScrollBarRef
|
|
89
|
+
ref: handleGetScrollBarRef,
|
|
90
|
+
scrollableNodeProps: {
|
|
91
|
+
ref: handleGetScrollableRef
|
|
92
|
+
}
|
|
84
93
|
}), /*#__PURE__*/React.createElement("div", {
|
|
85
94
|
className: cn('children-wrap', [classes === null || classes === void 0 ? void 0 : classes.childrenWrap])
|
|
86
95
|
}, children)));
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import type { IScrollBarProps } from '../ScrollBar/ScrollBar';
|
|
3
3
|
import './Modal.scss';
|
|
4
4
|
export declare enum MODAL_MOBILE_VIEWS_ENUM {
|
|
5
|
-
FULL_SCREEN = "
|
|
5
|
+
FULL_SCREEN = "fullScreen",// use camelCase for simple using in props from backend
|
|
6
6
|
BOTTOM = "bottom"
|
|
7
7
|
}
|
|
8
8
|
export declare enum MODAL_TRANSITIONS_STEPS_ENUM {
|
|
@@ -20,6 +20,7 @@ export type ModalClassesType = {
|
|
|
20
20
|
containerInner?: string;
|
|
21
21
|
containerBody?: string;
|
|
22
22
|
header?: string;
|
|
23
|
+
headerBackButton?: string;
|
|
23
24
|
headerCloseButton?: string;
|
|
24
25
|
titleArea?: string;
|
|
25
26
|
title?: string;
|
|
@@ -88,6 +89,8 @@ export interface IModalProps {
|
|
|
88
89
|
isDisabledBackgroundClick?: boolean;
|
|
89
90
|
/** Восстанавливает фокус на элементе, который был сфокусирован до открытия модального окна */
|
|
90
91
|
isReturnFocusAfterClose?: boolean;
|
|
92
|
+
/** Пересчитывать максимальную высоту скролла */
|
|
93
|
+
isRecalculateHeight?: boolean;
|
|
91
94
|
/** Должен ли root-элемент приложения быть скрыт */
|
|
92
95
|
hideAriaApp?: boolean;
|
|
93
96
|
/** Устанавливает aria-label */
|
|
@@ -12,6 +12,7 @@ var _uiHelpers = require("@megafon/ui-helpers");
|
|
|
12
12
|
var _lodash = _interopRequireDefault(require("lodash.throttle"));
|
|
13
13
|
var _reactModal = _interopRequireDefault(require("react-modal"));
|
|
14
14
|
var _throttleTime = _interopRequireDefault(require("../../constants/throttleTime"));
|
|
15
|
+
var _usePrevious = _interopRequireDefault(require("../../hooks/usePrevious"));
|
|
15
16
|
var _useResolution2 = _interopRequireDefault(require("../../hooks/useResolution"));
|
|
16
17
|
var _ModalDesktop = _interopRequireDefault(require("./_ModalDesktop/ModalDesktop"));
|
|
17
18
|
var _ModalMobileBottom = _interopRequireDefault(require("./_ModalMobileBottom/ModalMobileBottom"));
|
|
@@ -24,7 +25,7 @@ var MOBILE_BIG_START = _uiHelpers.breakpoints.MOBILE_BIG_START;
|
|
|
24
25
|
var HEIGHT_TRANSITION_PROPERTY = 'height';
|
|
25
26
|
var MODAL_MOBILE_VIEWS_ENUM;
|
|
26
27
|
(function (MODAL_MOBILE_VIEWS_ENUM) {
|
|
27
|
-
MODAL_MOBILE_VIEWS_ENUM["FULL_SCREEN"] = "
|
|
28
|
+
MODAL_MOBILE_VIEWS_ENUM["FULL_SCREEN"] = "fullScreen";
|
|
28
29
|
MODAL_MOBILE_VIEWS_ENUM["BOTTOM"] = "bottom";
|
|
29
30
|
})(MODAL_MOBILE_VIEWS_ENUM || (exports.MODAL_MOBILE_VIEWS_ENUM = MODAL_MOBILE_VIEWS_ENUM = {}));
|
|
30
31
|
var MODAL_TRANSITIONS_STEPS_ENUM;
|
|
@@ -49,6 +50,7 @@ var Modal = function Modal(_ref) {
|
|
|
49
50
|
isEnabledNativeScroll = _ref.isEnabledNativeScroll,
|
|
50
51
|
isSwipeDisabled = _ref.isSwipeDisabled,
|
|
51
52
|
isDisabledBackgroundClick = _ref.isDisabledBackgroundClick,
|
|
53
|
+
isRecalculateHeight = _ref.isRecalculateHeight,
|
|
52
54
|
_ref$hideAriaApp = _ref.hideAriaApp,
|
|
53
55
|
hideAriaApp = _ref$hideAriaApp === void 0 ? false : _ref$hideAriaApp,
|
|
54
56
|
contentLabel = _ref.contentLabel,
|
|
@@ -94,6 +96,7 @@ var Modal = function Modal(_ref) {
|
|
|
94
96
|
var containerWrapRef = React.useRef(null);
|
|
95
97
|
var containerInnerRef = React.useRef(null);
|
|
96
98
|
var containerBodyRef = React.useRef(null);
|
|
99
|
+
var scrollBarScrollableRef = React.useRef(null);
|
|
97
100
|
var resizeObserver = React.useRef(null);
|
|
98
101
|
var _useResolution = (0, _useResolution2["default"])(),
|
|
99
102
|
isMobile = _useResolution.isMobile;
|
|
@@ -102,6 +105,15 @@ var Modal = function Modal(_ref) {
|
|
|
102
105
|
var isBottomTransitionIn = transitionStep !== MODAL_TRANSITIONS_STEPS_ENUM.END_STEP && transitionStep !== MODAL_TRANSITIONS_STEPS_ENUM.MOVE_END_STEP;
|
|
103
106
|
var isTransitionMoveStep = transitionStep === MODAL_TRANSITIONS_STEPS_ENUM.MOVE_STEP;
|
|
104
107
|
var isTransitionEndStep = transitionStep === MODAL_TRANSITIONS_STEPS_ENUM.END_STEP;
|
|
108
|
+
var prevMobileView = (0, _usePrevious["default"])(mobileView);
|
|
109
|
+
var isChangeMobileView = mobileView !== prevMobileView;
|
|
110
|
+
var prevHeaderProps = (0, _usePrevious["default"])(headerProps);
|
|
111
|
+
var prevFooterProps = (0, _usePrevious["default"])(footerProps);
|
|
112
|
+
var isHeaderPropsDiff = headerProps !== prevHeaderProps;
|
|
113
|
+
var isFooterPropsDiff = footerProps !== prevFooterProps;
|
|
114
|
+
var handleGetScrollBarScrollableRef = function handleGetScrollBarScrollableRef(node) {
|
|
115
|
+
scrollBarScrollableRef.current = node;
|
|
116
|
+
};
|
|
105
117
|
var handleChangeTransitionStep = function handleChangeTransitionStep(value) {
|
|
106
118
|
setTransitionStep(value);
|
|
107
119
|
};
|
|
@@ -210,6 +222,18 @@ var Modal = function Modal(_ref) {
|
|
|
210
222
|
window.removeEventListener('resize', handleThrottleResize);
|
|
211
223
|
};
|
|
212
224
|
}, [isEnabledNativeScroll, handleSetScrollContentMaxHeight]);
|
|
225
|
+
React.useEffect(function () {
|
|
226
|
+
if (!isMobile || !isChangeMobileView) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
handleSetScrollContentMaxHeight();
|
|
230
|
+
}, [isMobile, isChangeMobileView, handleSetScrollContentMaxHeight]);
|
|
231
|
+
React.useEffect(function () {
|
|
232
|
+
if (isEnabledNativeScroll || !(isRecalculateHeight && (isHeaderPropsDiff || isFooterPropsDiff))) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
handleSetScrollContentMaxHeight();
|
|
236
|
+
}, [isEnabledNativeScroll, isFooterPropsDiff, isRecalculateHeight, isHeaderPropsDiff, handleSetScrollContentMaxHeight]);
|
|
213
237
|
React.useEffect(function () {
|
|
214
238
|
return function () {
|
|
215
239
|
setIsPopupOpened(false);
|
|
@@ -224,7 +248,8 @@ var Modal = function Modal(_ref) {
|
|
|
224
248
|
classes: classes,
|
|
225
249
|
dataAttrs: dataAttrs,
|
|
226
250
|
scrollBarParams: (0, _extends2["default"])((0, _extends2["default"])({}, scrollBarParams), {
|
|
227
|
-
maxHeight: scrollMaxHeight
|
|
251
|
+
maxHeight: scrollMaxHeight,
|
|
252
|
+
getScrollable: handleGetScrollBarScrollableRef
|
|
228
253
|
}),
|
|
229
254
|
headerProps: headerProps,
|
|
230
255
|
footerProps: footerProps,
|
|
@@ -234,7 +259,8 @@ var Modal = function Modal(_ref) {
|
|
|
234
259
|
footerRef: footerRef,
|
|
235
260
|
containerWrapRef: containerWrapRef,
|
|
236
261
|
containerInnerRef: containerInnerRef,
|
|
237
|
-
containerBodyRef: containerBodyRef
|
|
262
|
+
containerBodyRef: containerBodyRef,
|
|
263
|
+
scrollBarScrollableRef: scrollBarScrollableRef
|
|
238
264
|
},
|
|
239
265
|
isEnabledNativeScroll: isEnabledNativeScroll,
|
|
240
266
|
isDisabledBackgroundClick: isDisabledBackgroundClick,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
h1,h2,h3,h4,h5{margin:0}.mfui-modal-content__background{background-color:rgba(0,0,0,.8);bottom:0;left:0;position:fixed;right:0;top:0}.mfui-modal-content__container-wrap{-webkit-animation:show-popup .3s ease-out;animation:show-popup .3s ease-out;position:relative;width:100%}@media screen and (min-width:768px){.mfui-modal-content__container-wrap{-webkit-transition:height .1s;transition:height .1s;width:740px}}.mfui-modal-content__container-inner{background-color:var(--background);font-family:inherit;width:100%}.mfui-modal-content__header{position:relative}.mfui-modal-content__header_shadow{-webkit-box-shadow:0 2px 12px rgba(0,0,0,.1);box-shadow:0 2px 12px rgba(0,0,0,.1)}.mfui-modal-content__header-main{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;min-height:52px}@media screen and (min-width:768px){.mfui-modal-content__header-main{min-height:64px}}.mfui-modal-content__header-button{display:-webkit-box;display:-ms-flexbox;display:flex;position:absolute;top:12px;z-index:2;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;background:transparent;border:none;cursor:pointer;height:32px;justify-content:center;outline:none;width:32px}@media screen and (min-width:768px){.mfui-modal-content__header-button{height:40px;width:40px}}.mfui-modal-content__header-button_back{left:16px}.mfui-modal-content__header-button_close{right:16px}.mfui-modal-content__header-button_shadow{background:var(--base);border-radius:50%;-webkit-box-shadow:0 2px 12px rgba(0,0,0,.1);box-shadow:0 2px 12px rgba(0,0,0,.1)}.mfui-modal-content__header-button svg{fill:var(--content)}.mfui-modal-content__title-area{-webkit-box-sizing:border-box;box-sizing:border-box;margin:0 48px;padding:12px}@media screen and (min-width:768px){.mfui-modal-content__title-area{margin:0 56px;padding:16px}}.mfui-modal-content__title{font-size:18px;font-weight:500;letter-spacing:.5px;line-height:24px;text-align:center}@media screen and (min-width:1280px){.mfui-modal-content__title{font-size:20px;line-height:28px}}@media screen and (min-width:768px){.mfui-modal-content__title{font-size:20px;font-weight:500;letter-spacing:.5px;line-height:28px}}.mfui-modal-content__header-additional{-webkit-box-sizing:border-box;box-sizing:border-box;padding:8px 16px;text-align:center}@media screen and (min-width:768px){.mfui-modal-content__header-additional{padding-left:32px;padding-right:32px}}.mfui-modal-content__container-body{-webkit-box-sizing:border-box;box-sizing:border-box;padding-bottom:24px;padding-right:6px}@media screen and (min-width:768px){.mfui-modal-content__container-body{padding-bottom:32px;padding-right:12px}}.mfui-modal-content__children{-webkit-box-sizing:border-box;box-sizing:border-box;padding-left:16px;padding-right:4px;padding-top:24px}@media screen and (min-width:768px){.mfui-modal-content__children{padding-left:32px;padding-right:14px}}.mfui-modal-
|
|
1
|
+
h1,h2,h3,h4,h5{margin:0}.mfui-modal-content__background{background-color:rgba(0,0,0,.8);bottom:0;left:0;position:fixed;right:0;top:0}.mfui-modal-content__container-wrap{-webkit-animation:show-popup .3s ease-out;animation:show-popup .3s ease-out;position:relative;width:100%}@media screen and (min-width:768px){.mfui-modal-content__container-wrap{-webkit-transition:height .1s;transition:height .1s;width:740px}}.mfui-modal-content__container-inner{background-color:var(--background);font-family:inherit;width:100%}.mfui-modal-content__header{position:relative}.mfui-modal-content__header_shadow{-webkit-box-shadow:0 2px 12px rgba(0,0,0,.1);box-shadow:0 2px 12px rgba(0,0,0,.1)}.mfui-modal-content__header-main{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;min-height:52px}@media screen and (min-width:768px){.mfui-modal-content__header-main{min-height:64px}}.mfui-modal-content__header-button{display:-webkit-box;display:-ms-flexbox;display:flex;position:absolute;top:12px;z-index:2;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;background:transparent;border:none;cursor:pointer;height:32px;justify-content:center;outline:none;width:32px}@media screen and (min-width:768px){.mfui-modal-content__header-button{height:40px;width:40px}}.mfui-modal-content__header-button_back{left:16px}.mfui-modal-content__header-button_close{right:16px}.mfui-modal-content__header-button_shadow{background:var(--base);border-radius:50%;-webkit-box-shadow:0 2px 12px rgba(0,0,0,.1);box-shadow:0 2px 12px rgba(0,0,0,.1)}.mfui-modal-content__header-button svg{fill:var(--content)}.mfui-modal-content__title-area{-webkit-box-sizing:border-box;box-sizing:border-box;margin:0 48px;padding:12px}@media screen and (min-width:768px){.mfui-modal-content__title-area{margin:0 56px;padding:16px}}.mfui-modal-content__title{font-size:18px;font-weight:500;letter-spacing:.5px;line-height:24px;text-align:center}@media screen and (min-width:1280px){.mfui-modal-content__title{font-size:20px;line-height:28px}}@media screen and (min-width:768px){.mfui-modal-content__title{font-size:20px;font-weight:500;letter-spacing:.5px;line-height:28px}}.mfui-modal-content__header-additional{-webkit-box-sizing:border-box;box-sizing:border-box;padding:8px 16px;text-align:center}@media screen and (min-width:768px){.mfui-modal-content__header-additional{padding-left:32px;padding-right:32px}}.mfui-modal-content__container-body{-webkit-box-sizing:border-box;box-sizing:border-box;padding-bottom:24px;padding-right:6px}@media screen and (min-width:768px){.mfui-modal-content__container-body{padding-bottom:32px;padding-right:12px}}.mfui-modal-content__children{-webkit-box-sizing:border-box;box-sizing:border-box;padding-left:16px;padding-right:4px;padding-top:24px}@media screen and (min-width:768px){.mfui-modal-content__children{padding-left:32px;padding-right:14px}}.mfui-modal-content__container-wrap_static-header .mfui-modal-content__container-body{padding-top:24px}.mfui-modal-content__container-wrap_static-header .mfui-modal-content__children{padding-top:0}.mfui-modal-content__container-wrap_static-header .mfui-modal-content__header{margin-bottom:24px;margin-left:-16px;margin-right:-16px}@media screen and (min-width:768px){.mfui-modal-content__container-wrap_static-header .mfui-modal-content__header{margin-left:-32px;margin-right:-32px}}.mfui-modal-content__container-wrap_static-header .mfui-modal-content__header-main{min-height:40px}.mfui-modal-content__container-wrap_static-header .mfui-modal-content__header-button{top:0}.mfui-modal-content__container-wrap_static-header .mfui-modal-content__title-area{padding-bottom:4px;padding-top:4px}.mfui-modal-content__container-wrap_hide-header .mfui-modal-content__container-body{padding-top:24px}.mfui-modal-content__container-wrap_hide-header .mfui-modal-content__children{padding-top:0}.mfui-modal-content__container-wrap_sticky-footer .mfui-modal-content__container-body{padding-bottom:0}.mfui-modal-content__container-wrap_sticky-footer .mfui-modal-content__footer{padding-left:16px;padding-right:16px}@media screen and (min-width:768px){.mfui-modal-content__container-wrap_sticky-footer .mfui-modal-content__footer{padding-left:32px;padding-right:32px}}.mfui-modal-content__container-wrap_sticky-footer .mfui-modal-content__footer_shadow{-webkit-box-shadow:0 2px 12px rgba(0,0,0,.1);box-shadow:0 2px 12px rgba(0,0,0,.1)}.mfui-modal-content__container-wrap_out-side-buttons .mfui-modal-content__container-body{padding-top:24px}.mfui-modal-content__container-wrap_native-scroll .mfui-modal-content__children,.mfui-modal-content__container-wrap_native-scroll .mfui-modal-content__container-body{padding:0}.mfui-modal-content__container-wrap_transition-end{-webkit-animation:hide-popup .2s ease-in;animation:hide-popup .2s ease-in}@-webkit-keyframes show-popup{0%{-webkit-transform:scale(95%);transform:scale(95%);-webkit-transform-origin:top;transform-origin:top}to{-webkit-transform:scale(100%);transform:scale(100%)}}@keyframes show-popup{0%{-webkit-transform:scale(95%);transform:scale(95%);-webkit-transform-origin:top;transform-origin:top}to{-webkit-transform:scale(100%);transform:scale(100%)}}@-webkit-keyframes hide-popup{0%{-webkit-transform:scale(100%);transform:scale(100%)}to{-webkit-transform:scale(95%);transform:scale(95%)}}@keyframes hide-popup{0%{-webkit-transform:scale(100%);transform:scale(100%)}to{-webkit-transform:scale(95%);transform:scale(95%)}}
|
|
@@ -103,7 +103,7 @@ var ModalContent = function ModalContent(_ref) {
|
|
|
103
103
|
className: cn('header-button', {
|
|
104
104
|
back: true,
|
|
105
105
|
shadow: hasHeaderButtonsShadow
|
|
106
|
-
}),
|
|
106
|
+
}, classes === null || classes === void 0 ? void 0 : classes.headerBackButton),
|
|
107
107
|
type: "button",
|
|
108
108
|
onClick: onBackButtonClick
|
|
109
109
|
}), isSmallIcon ? /*#__PURE__*/React.createElement(ArrowLeft24, null) : /*#__PURE__*/React.createElement(ArrowLeft32, null));
|
|
@@ -40,6 +40,7 @@ var ModalMobileBottom = function ModalMobileBottom(_a) {
|
|
|
40
40
|
var _restProps$refs = restProps.refs,
|
|
41
41
|
containerWrapRef = _restProps$refs.containerWrapRef,
|
|
42
42
|
containerInnerRef = _restProps$refs.containerInnerRef,
|
|
43
|
+
scrollBarScrollableRef = _restProps$refs.scrollBarScrollableRef,
|
|
43
44
|
isTransitionMoveStep = restProps.isTransitionMoveStep,
|
|
44
45
|
isTransitionEndStep = restProps.isTransitionEndStep;
|
|
45
46
|
var _React$useState = React.useState(null),
|
|
@@ -60,9 +61,11 @@ var ModalMobileBottom = function ModalMobileBottom(_a) {
|
|
|
60
61
|
window.cancelAnimationFrame(animationFrameId.current);
|
|
61
62
|
}
|
|
62
63
|
var containerWrapNode = containerWrapRef.current;
|
|
64
|
+
var scrollableNode = scrollBarScrollableRef.current;
|
|
63
65
|
animationFrameId.current = window.requestAnimationFrame(function () {
|
|
64
66
|
onChangeTransitionStep(_Modal.MODAL_TRANSITIONS_STEPS_ENUM.MOVE_STEP);
|
|
65
|
-
|
|
67
|
+
var isScrollTop = ((scrollableNode === null || scrollableNode === void 0 ? void 0 : scrollableNode.scrollTop) || 0) === 0;
|
|
68
|
+
if (!containerWrapNode || !isScrollTop) {
|
|
66
69
|
return;
|
|
67
70
|
}
|
|
68
71
|
if (!initialContainerWrapHeight) {
|
|
@@ -83,11 +86,13 @@ var ModalMobileBottom = function ModalMobileBottom(_a) {
|
|
|
83
86
|
onChangeContainerWrapTransform("translateY(".concat(positionsDiffAbs, "px)"));
|
|
84
87
|
animationFrameId.current = 0;
|
|
85
88
|
});
|
|
86
|
-
}, [containerWrapRef, initialContainerWrapHeight, initialTouchPosition, onChangeContainerWrapTransform, onChangeTransitionStep]);
|
|
89
|
+
}, [containerWrapRef, scrollBarScrollableRef, initialContainerWrapHeight, initialTouchPosition, onChangeContainerWrapTransform, onChangeTransitionStep]);
|
|
87
90
|
var handleWindowTouchEnd = React.useCallback(function (e) {
|
|
88
91
|
var _a;
|
|
89
92
|
var containerWrapNode = containerWrapRef.current;
|
|
90
|
-
|
|
93
|
+
var scrollableNode = scrollBarScrollableRef.current;
|
|
94
|
+
var isScrollTop = ((scrollableNode === null || scrollableNode === void 0 ? void 0 : scrollableNode.scrollTop) || 0) === 0;
|
|
95
|
+
if (!containerWrapNode || !isTransitionMoveStep || !isScrollTop) {
|
|
91
96
|
return;
|
|
92
97
|
}
|
|
93
98
|
window.cancelAnimationFrame(animationFrameId.current);
|
|
@@ -96,7 +101,7 @@ var ModalMobileBottom = function ModalMobileBottom(_a) {
|
|
|
96
101
|
setInitialTouchPosition(null);
|
|
97
102
|
onChangeContainerWrapTransform(isMoreHalfClosed ? 'translateY(100%)' : 'none');
|
|
98
103
|
onChangeTransitionStep(isMoreHalfClosed ? _Modal.MODAL_TRANSITIONS_STEPS_ENUM.MOVE_END_STEP : _Modal.MODAL_TRANSITIONS_STEPS_ENUM.INITIAL_STEP);
|
|
99
|
-
}, [containerWrapRef, isTransitionMoveStep, offsetHeightCenter, onChangeContainerWrapTransform, onChangeTransitionStep]);
|
|
104
|
+
}, [containerWrapRef, scrollBarScrollableRef, isTransitionMoveStep, offsetHeightCenter, onChangeContainerWrapTransform, onChangeTransitionStep]);
|
|
100
105
|
React.useEffect(function () {
|
|
101
106
|
if (isSwipeDisabled) {
|
|
102
107
|
return undefined;
|
|
@@ -14,6 +14,7 @@ var mockModalContextProps = {
|
|
|
14
14
|
containerInner: 'containerInner-class',
|
|
15
15
|
containerBody: 'containerBody-class',
|
|
16
16
|
header: 'header-class',
|
|
17
|
+
headerBackButton: 'headerBackButton-class',
|
|
17
18
|
headerCloseButton: 'headerCloseButton-class',
|
|
18
19
|
titleArea: 'titleArea-class',
|
|
19
20
|
title: 'title-class',
|
|
@@ -68,6 +69,9 @@ var mockModalContextProps = {
|
|
|
68
69
|
},
|
|
69
70
|
containerBodyRef: {
|
|
70
71
|
current: null
|
|
72
|
+
},
|
|
73
|
+
scrollBarScrollableRef: {
|
|
74
|
+
current: null
|
|
71
75
|
}
|
|
72
76
|
},
|
|
73
77
|
isMobile: false,
|
|
@@ -11,6 +11,7 @@ type ModalContextPropsType = ModalComponentPropsType & {
|
|
|
11
11
|
containerWrapRef: RefType;
|
|
12
12
|
containerInnerRef: RefType;
|
|
13
13
|
containerBodyRef: RefType;
|
|
14
|
+
scrollBarScrollableRef: React.MutableRefObject<HTMLElement | null>;
|
|
14
15
|
};
|
|
15
16
|
isMobile: boolean;
|
|
16
17
|
isTransitionMoveStep: boolean;
|
|
@@ -30,6 +30,8 @@ export interface IScrollBarProps {
|
|
|
30
30
|
showAlways?: boolean;
|
|
31
31
|
/** Ref обработчик */
|
|
32
32
|
getScrollBar?: (node: HTMLElement) => void;
|
|
33
|
+
/** Ref обработчик для Scrollable element */
|
|
34
|
+
getScrollable?: (node: HTMLElement) => void;
|
|
33
35
|
children?: React.ReactNode;
|
|
34
36
|
}
|
|
35
37
|
declare const ScrollBar: React.FC<IScrollBarProps>;
|
|
@@ -25,12 +25,14 @@ var ScrollBar = function ScrollBar(_ref) {
|
|
|
25
25
|
hideMobile = _ref.hideMobile,
|
|
26
26
|
showAlways = _ref.showAlways,
|
|
27
27
|
getScrollBar = _ref.getScrollBar,
|
|
28
|
+
getScrollable = _ref.getScrollable,
|
|
28
29
|
children = _ref.children;
|
|
29
30
|
var _React$useState = React.useState(false),
|
|
30
31
|
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
31
32
|
isInitialHide = _React$useState2[0],
|
|
32
33
|
setIsInitialHide = _React$useState2[1];
|
|
33
34
|
var scrollBarInitNode = React.useRef(null);
|
|
35
|
+
var scrollableNode = React.useRef(null);
|
|
34
36
|
var resizeObserver = React.useRef(null);
|
|
35
37
|
function handleGetScrollBarRef(node) {
|
|
36
38
|
if (!node) {
|
|
@@ -40,6 +42,10 @@ var ScrollBar = function ScrollBar(_ref) {
|
|
|
40
42
|
scrollBarInitNode.current = scrollInitEl;
|
|
41
43
|
getScrollBar === null || getScrollBar === void 0 ? void 0 : getScrollBar(scrollInitEl);
|
|
42
44
|
}
|
|
45
|
+
function handleGetScrollableRef(node) {
|
|
46
|
+
scrollableNode.current = node;
|
|
47
|
+
getScrollable === null || getScrollable === void 0 ? void 0 : getScrollable(node);
|
|
48
|
+
}
|
|
43
49
|
var handleSetInitialHide = React.useCallback(function () {
|
|
44
50
|
if (!scrollBarInitNode.current || !maxHeight) {
|
|
45
51
|
setIsInitialHide(false);
|
|
@@ -65,7 +71,7 @@ var ScrollBar = function ScrollBar(_ref) {
|
|
|
65
71
|
}
|
|
66
72
|
};
|
|
67
73
|
}, [handleSetInitialHide, maxHeight]);
|
|
68
|
-
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
|
|
74
|
+
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
69
75
|
className: cn({
|
|
70
76
|
'initial-hide': isInitialHide,
|
|
71
77
|
'hide-all': hideAll,
|
|
@@ -75,7 +81,7 @@ var ScrollBar = function ScrollBar(_ref) {
|
|
|
75
81
|
'hide-mobile': hideMobile,
|
|
76
82
|
'show-always': showAlways
|
|
77
83
|
}, [classes === null || classes === void 0 ? void 0 : classes.root])
|
|
78
|
-
}
|
|
84
|
+
}), /*#__PURE__*/React.createElement(_simplebarReact["default"], (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.init), {
|
|
79
85
|
className: cn('init', [classes === null || classes === void 0 ? void 0 : classes.init]),
|
|
80
86
|
classNames: {
|
|
81
87
|
track: cn('scroll-track'),
|
|
@@ -88,7 +94,10 @@ var ScrollBar = function ScrollBar(_ref) {
|
|
|
88
94
|
maxHeight: "".concat(maxHeight, "px")
|
|
89
95
|
},
|
|
90
96
|
forceVisible: "y",
|
|
91
|
-
ref: handleGetScrollBarRef
|
|
97
|
+
ref: handleGetScrollBarRef,
|
|
98
|
+
scrollableNodeProps: {
|
|
99
|
+
ref: handleGetScrollableRef
|
|
100
|
+
}
|
|
92
101
|
}), /*#__PURE__*/React.createElement("div", {
|
|
93
102
|
className: cn('children-wrap', [classes === null || classes === void 0 ? void 0 : classes.childrenWrap])
|
|
94
103
|
}, children)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@megafon/ui-core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.9.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"styles"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@babel/preset-env": "^7.8.6",
|
|
51
51
|
"@babel/preset-react": "^7.8.3",
|
|
52
52
|
"@babel/preset-typescript": "^7.8.3",
|
|
53
|
-
"@megafon/ui-icons": "^3.5.
|
|
53
|
+
"@megafon/ui-icons": "^3.5.1",
|
|
54
54
|
"@svgr/core": "^2.4.1",
|
|
55
55
|
"@testing-library/jest-dom": "^6.5.0",
|
|
56
56
|
"@testing-library/react": "^16.0.1",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@datepicker-react/hooks": "^2.7.0",
|
|
90
90
|
"@dnd-kit/core": "^6.1.0",
|
|
91
91
|
"@dnd-kit/sortable": "^8.0.0",
|
|
92
|
-
"@megafon/ui-helpers": "^3.1.
|
|
92
|
+
"@megafon/ui-helpers": "^3.1.2",
|
|
93
93
|
"@mona-health/react-input-mask": "^3.0.3",
|
|
94
94
|
"@popperjs/core": "^2.11.8",
|
|
95
95
|
"core-js": "^3.6.4",
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
"simplebar-react": "^3.2.5",
|
|
105
105
|
"swiper": "^11.1.1"
|
|
106
106
|
},
|
|
107
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "a981889514af3bc91afd05caf40ffe989995abcf"
|
|
108
108
|
}
|