@alfalab/core-components-bottom-sheet 6.15.6 → 6.16.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/component.js +16 -9
- package/components/footer/Component.js +1 -1
- package/components/footer/index.css +26 -26
- package/components/header/Component.js +1 -1
- package/components/header/index.css +13 -13
- package/cssm/component.js +15 -8
- package/cssm/hooks/index.d.ts +1 -0
- package/cssm/hooks/index.js +9 -0
- package/cssm/hooks/use-visualviewport-size.d.ts +3 -0
- package/cssm/hooks/use-visualviewport-size.js +36 -0
- package/cssm/types.d.ts +4 -0
- package/esm/component.js +16 -9
- package/esm/components/footer/Component.js +1 -1
- package/esm/components/footer/index.css +26 -26
- package/esm/components/header/Component.js +1 -1
- package/esm/components/header/index.css +13 -13
- package/esm/hooks/index.d.ts +1 -0
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/use-visualviewport-size.d.ts +3 -0
- package/esm/hooks/use-visualviewport-size.js +32 -0
- package/esm/index.css +45 -45
- package/esm/types.d.ts +4 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +9 -0
- package/hooks/use-visualviewport-size.d.ts +3 -0
- package/hooks/use-visualviewport-size.js +36 -0
- package/index.css +45 -45
- package/modern/component.js +11 -5
- package/modern/components/footer/Component.js +1 -1
- package/modern/components/footer/index.css +26 -26
- package/modern/components/header/Component.js +1 -1
- package/modern/components/header/index.css +13 -13
- package/modern/hooks/index.d.ts +1 -0
- package/modern/hooks/index.js +1 -0
- package/modern/hooks/use-visualviewport-size.d.ts +3 -0
- package/modern/hooks/use-visualviewport-size.js +27 -0
- package/modern/index.css +45 -45
- package/modern/types.d.ts +4 -0
- package/package.json +2 -2
- package/src/component.tsx +12 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-visualviewport-size.ts +39 -0
- package/src/types.ts +5 -0
- package/types.d.ts +4 -0
package/component.js
CHANGED
|
@@ -14,6 +14,7 @@ var components_footer_Component = require('./components/footer/Component.js');
|
|
|
14
14
|
var components_header_Component = require('./components/header/Component.js');
|
|
15
15
|
var components_swipeableBackdrop_Component = require('./components/swipeable-backdrop/Component.js');
|
|
16
16
|
var consts_swipeConsts = require('./consts/swipeConsts.js');
|
|
17
|
+
var hooks_useVisualviewportSize = require('./hooks/use-visualviewport-size.js');
|
|
17
18
|
var utils = require('./utils.js');
|
|
18
19
|
|
|
19
20
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -22,14 +23,17 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
|
22
23
|
var mergeRefs__default = /*#__PURE__*/_interopDefaultCompat(mergeRefs);
|
|
23
24
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
24
25
|
|
|
25
|
-
var styles = {"modal":"bottom-
|
|
26
|
+
var styles = {"modal":"bottom-sheet__modal_90r42","wrapper":"bottom-sheet__wrapper_90r42","fullscreen":"bottom-sheet__fullscreen_90r42","component":"bottom-sheet__component_90r42","withTransition":"bottom-sheet__withTransition_90r42","scrollableContainer":"bottom-sheet__scrollableContainer_90r42","marker":"bottom-sheet__marker_90r42","defaultMarker":"bottom-sheet__defaultMarker_90r42","content":"bottom-sheet__content_90r42","noHeader":"bottom-sheet__noHeader_90r42","noFooter":"bottom-sheet__noFooter_90r42","scrollLocked":"bottom-sheet__scrollLocked_90r42","hiddenScrollbar":"bottom-sheet__hiddenScrollbar_90r42","disabledPointerEvents":"bottom-sheet__disabledPointerEvents_90r42","appear":"bottom-sheet__appear_90r42","enter":"bottom-sheet__enter_90r42","appearActive":"bottom-sheet__appearActive_90r42","enterActive":"bottom-sheet__enterActive_90r42","enterDone":"bottom-sheet__enterDone_90r42","appearDone":"bottom-sheet__appearDone_90r42","exit":"bottom-sheet__exit_90r42","exitActive":"bottom-sheet__exitActive_90r42","safeAreaBottom":"bottom-sheet__safeAreaBottom_90r42","background-accent":"bottom-sheet__background-accent_90r42","background-info":"bottom-sheet__background-info_90r42","background-attention-muted":"bottom-sheet__background-attention-muted_90r42","background-positive-muted":"bottom-sheet__background-positive-muted_90r42","background-negative-muted":"bottom-sheet__background-negative-muted_90r42","background-primary":"bottom-sheet__background-primary_90r42","background-primary-inverted":"bottom-sheet__background-primary-inverted_90r42","background-secondary":"bottom-sheet__background-secondary_90r42","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_90r42","background-tertiary":"bottom-sheet__background-tertiary_90r42","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_90r42","background-quaternary":"bottom-sheet__background-quaternary_90r42","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_90r42","background-specialbg-component":"bottom-sheet__background-specialbg-component_90r42","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_90r42","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_90r42","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_90r42","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_90r42","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_90r42","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_90r42","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_90r42","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_90r42"};
|
|
26
27
|
require('./index.css')
|
|
27
28
|
|
|
28
29
|
var isNil = coreComponentsShared.fnUtils.isNil;
|
|
29
30
|
var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
30
31
|
var _b, _c, _d, _e, _f;
|
|
31
|
-
var
|
|
32
|
-
var
|
|
32
|
+
var _g, _h;
|
|
33
|
+
var open = _a.open, title = _a.title, container = _a.container, usePortal = _a.usePortal, backgroundColor = _a.backgroundColor, _j = _a.titleSize, titleSize = _j === void 0 ? 'default' : _j, subtitle = _a.subtitle, actionButton = _a.actionButton, contentClassName = _a.contentClassName, containerClassName = _a.containerClassName, containerProps = _a.containerProps, headerClassName = _a.headerClassName, footerClassName = _a.footerClassName, addonClassName = _a.addonClassName, closerClassName = _a.closerClassName, backerClassName = _a.backerClassName, modalClassName = _a.modalClassName, modalWrapperClassName = _a.modalWrapperClassName, className = _a.className, leftAddons = _a.leftAddons, rightAddons = _a.rightAddons, bottomAddons = _a.bottomAddons, hasCloser = _a.hasCloser, hasBacker = _a.hasBacker, _k = _a.titleAlign, titleAlign = _k === void 0 ? 'left' : _k, trimTitle = _a.trimTitle, stickyHeader = _a.stickyHeader, _l = _a.stickyFooter, stickyFooter = _l === void 0 ? true : _l, _m = _a.initialHeight, initialHeight = _m === void 0 ? 'default' : _m, hideOverlay = _a.hideOverlay, hideScrollbar = _a.hideScrollbar, hideHeader = _a.hideHeader, disableOverlayClick = _a.disableOverlayClick, disableBlockingScroll = _a.disableBlockingScroll, disableFocusLock = _a.disableFocusLock, children = _a.children, zIndex = _a.zIndex, _o = _a.transitionProps, transitionProps = _o === void 0 ? {} : _o, magneticAreasProp = _a.magneticAreas, initialActiveAreaIndex = _a.initialActiveAreaIndex, dataTestId = _a.dataTestId, _p = _a.swipeable, swipeable = _p === void 0 ? true : _p, _q = _a.swipeableContent, swipeableContent = _q === void 0 ? true : _q, _r = _a.swipeThreshold, swipeThreshold = _r === void 0 ? 5 : _r, scrollLockedProp = _a.scrollLocked, backdropProps = _a.backdropProps, _s = _a.scrollableContainerRef, scrollableContainerRef = _s === void 0 ? function () { return null; } : _s, bottomSheetInstanceRef = _a.bottomSheetInstanceRef, _t = _a.sheetContainerRef, sheetContainerRef = _t === void 0 ? function () { return null; } : _t, _u = _a.headerOffset, headerOffset = _u === void 0 ? 24 : _u, onClose = _a.onClose, onBack = _a.onBack, onMagnetize = _a.onMagnetize, onSwipeStart = _a.onSwipeStart, onSwipeEnd = _a.onSwipeEnd, disableRestoreFocus = _a.disableRestoreFocus, disableAutoFocus = _a.disableAutoFocus, disableEscapeKeyDown = _a.disableEscapeKeyDown, keepMounted = _a.keepMounted, onMagnetizeEnd = _a.onMagnetizeEnd, onOffsetChange = _a.onOffsetChange, swipeableMarker = _a.swipeableMarker, swipeableMarkerClassName = _a.swipeableMarkerClassName, backButtonProps = _a.backButtonProps, _v = _a.iOSLock, iOSLock = _v === void 0 ? false : _v, _w = _a.virtualKeyboard, virtualKeyboard = _w === void 0 ? false : _w;
|
|
34
|
+
var windowHeight = (_g = reactDiv100vh.use100vh()) !== null && _g !== void 0 ? _g : 0;
|
|
35
|
+
var visibleViewportSize = hooks_useVisualviewportSize.useVisibleViewportSize(virtualKeyboard);
|
|
36
|
+
var fullHeight = virtualKeyboard ? (_h = visibleViewportSize === null || visibleViewportSize === void 0 ? void 0 : visibleViewportSize.height) !== null && _h !== void 0 ? _h : 0 : windowHeight;
|
|
33
37
|
// Хук use100vh рассчитывает высоту вьюпорта в useEffect, поэтому на первый рендер всегда возвращает null.
|
|
34
38
|
var isFirstRender = fullHeight === 0;
|
|
35
39
|
var initialIndexRef = React.useRef(initialActiveAreaIndex);
|
|
@@ -43,14 +47,14 @@ var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
|
43
47
|
var iOSViewHeight = coreComponentsShared.isClient()
|
|
44
48
|
? ((_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.clientHeight) || (window === null || window === void 0 ? void 0 : window.innerHeight)
|
|
45
49
|
: 0;
|
|
46
|
-
var viewHeight = coreComponentsShared.os.isIOS() ? iOSViewHeight : fullHeight;
|
|
50
|
+
var viewHeight = coreComponentsShared.os.isIOS() && !virtualKeyboard ? iOSViewHeight : fullHeight;
|
|
47
51
|
return [0, viewHeight - headerOffset];
|
|
48
|
-
}, [fullHeight, headerOffset, magneticAreasProp]);
|
|
52
|
+
}, [fullHeight, headerOffset, magneticAreasProp, virtualKeyboard]);
|
|
49
53
|
var lastMagneticArea = magneticAreas[magneticAreas.length - 1];
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
+
var _x = React.useState(0), sheetOffset = _x[0], setSheetOffset = _x[1];
|
|
55
|
+
var _y = React.useState(1), backdropOpacity = _y[0], setBackdropOpacity = _y[1];
|
|
56
|
+
var _z = React.useState(-1), activeAreaIdx = _z[0], setActiveAreaIdx = _z[1];
|
|
57
|
+
var _0 = React.useState(null), swipingInProgress = _0[0], setSwipingInProgress = _0[1];
|
|
54
58
|
var scrollOccurred = React.useRef(false);
|
|
55
59
|
var headerRef = React.useRef(null);
|
|
56
60
|
var contentRef = React.useRef(null);
|
|
@@ -353,6 +357,9 @@ var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
|
353
357
|
? "".concat(lastMagneticArea, "px")
|
|
354
358
|
: 'unset',
|
|
355
359
|
maxHeight: isFirstRender ? 0 : "".concat(lastMagneticArea, "px"),
|
|
360
|
+
marginBottom: virtualKeyboard && visibleViewportSize && windowHeight > visibleViewportSize.height
|
|
361
|
+
? windowHeight - visibleViewportSize.height - visibleViewportSize.offsetTop
|
|
362
|
+
: undefined,
|
|
356
363
|
}); };
|
|
357
364
|
var renderMarker = function () {
|
|
358
365
|
if (swipeable) {
|
|
@@ -11,7 +11,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
11
11
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
12
12
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
13
13
|
|
|
14
|
-
var styles = {"footer":"bottom-
|
|
14
|
+
var styles = {"footer":"bottom-sheet__footer_10j16","sticky":"bottom-sheet__sticky_10j16","highlighted":"bottom-sheet__highlighted_10j16","background-accent":"bottom-sheet__background-accent_10j16","background-info":"bottom-sheet__background-info_10j16","background-attention-muted":"bottom-sheet__background-attention-muted_10j16","background-positive-muted":"bottom-sheet__background-positive-muted_10j16","background-negative-muted":"bottom-sheet__background-negative-muted_10j16","background-primary":"bottom-sheet__background-primary_10j16","background-primary-inverted":"bottom-sheet__background-primary-inverted_10j16","background-secondary":"bottom-sheet__background-secondary_10j16","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_10j16","background-tertiary":"bottom-sheet__background-tertiary_10j16","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_10j16","background-quaternary":"bottom-sheet__background-quaternary_10j16","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_10j16","background-specialbg-component":"bottom-sheet__background-specialbg-component_10j16","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_10j16","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_10j16","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_10j16","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_10j16","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_10j16","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_10j16","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_10j16","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_10j16"};
|
|
15
15
|
require('./index.css')
|
|
16
16
|
|
|
17
17
|
var Footer = function (_a) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1pai5 */
|
|
2
2
|
:root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-modal-bg-primary: #fff;
|
|
@@ -46,58 +46,58 @@
|
|
|
46
46
|
/* footer */
|
|
47
47
|
--bottom-sheet-footer-border-top: 1px solid var(--color-light-neutral-300);
|
|
48
48
|
--bottom-sheet-footer-background-color: var(--color-light-modal-bg-primary);
|
|
49
|
-
} .bottom-
|
|
49
|
+
} .bottom-sheet__footer_10j16 {
|
|
50
50
|
padding: var(--gap-m) var(--gap-m);
|
|
51
51
|
background-color: var(--color-light-modal-bg-primary);
|
|
52
|
-
} .bottom-
|
|
52
|
+
} .bottom-sheet__sticky_10j16 {
|
|
53
53
|
position: sticky;
|
|
54
54
|
bottom: 0;
|
|
55
55
|
z-index: 1;
|
|
56
|
-
} .bottom-
|
|
56
|
+
} .bottom-sheet__highlighted_10j16 {
|
|
57
57
|
border-top: var(--bottom-sheet-footer-border-top);
|
|
58
58
|
background-color: var(--bottom-sheet-footer-background-color);
|
|
59
|
-
} .bottom-sheet__background-
|
|
59
|
+
} .bottom-sheet__background-accent_10j16 {
|
|
60
60
|
background-color: var(--color-light-bg-accent);
|
|
61
|
-
} .bottom-sheet__background-
|
|
61
|
+
} .bottom-sheet__background-info_10j16 {
|
|
62
62
|
background-color: var(--color-light-bg-info);
|
|
63
|
-
} .bottom-sheet__background-attention-
|
|
63
|
+
} .bottom-sheet__background-attention-muted_10j16 {
|
|
64
64
|
background-color: var(--color-light-bg-attention-muted);
|
|
65
|
-
} .bottom-sheet__background-positive-
|
|
65
|
+
} .bottom-sheet__background-positive-muted_10j16 {
|
|
66
66
|
background-color: var(--color-light-bg-positive-muted);
|
|
67
|
-
} .bottom-sheet__background-negative-
|
|
67
|
+
} .bottom-sheet__background-negative-muted_10j16 {
|
|
68
68
|
background-color: var(--color-light-bg-negative-muted);
|
|
69
|
-
} .bottom-sheet__background-
|
|
69
|
+
} .bottom-sheet__background-primary_10j16 {
|
|
70
70
|
background-color: var(--color-light-bg-primary);
|
|
71
|
-
} .bottom-sheet__background-primary-
|
|
71
|
+
} .bottom-sheet__background-primary-inverted_10j16 {
|
|
72
72
|
background-color: var(--color-light-bg-primary-inverted);
|
|
73
|
-
} .bottom-sheet__background-
|
|
73
|
+
} .bottom-sheet__background-secondary_10j16 {
|
|
74
74
|
background-color: var(--color-light-bg-secondary);
|
|
75
|
-
} .bottom-sheet__background-secondary-
|
|
75
|
+
} .bottom-sheet__background-secondary-inverted_10j16 {
|
|
76
76
|
background-color: var(--color-light-bg-secondary-inverted);
|
|
77
|
-
} .bottom-sheet__background-
|
|
77
|
+
} .bottom-sheet__background-tertiary_10j16 {
|
|
78
78
|
background-color: var(--color-light-bg-tertiary);
|
|
79
|
-
} .bottom-sheet__background-tertiary-
|
|
79
|
+
} .bottom-sheet__background-tertiary-inverted_10j16 {
|
|
80
80
|
background-color: var(--color-light-bg-tertiary-inverted);
|
|
81
|
-
} .bottom-sheet__background-
|
|
81
|
+
} .bottom-sheet__background-quaternary_10j16 {
|
|
82
82
|
background-color: var(--color-light-bg-quaternary);
|
|
83
|
-
} .bottom-sheet__background-quaternary-
|
|
83
|
+
} .bottom-sheet__background-quaternary-inverted_10j16 {
|
|
84
84
|
background-color: var(--color-light-bg-quaternary-inverted);
|
|
85
|
-
} .bottom-sheet__background-specialbg-
|
|
85
|
+
} .bottom-sheet__background-specialbg-component_10j16 {
|
|
86
86
|
background-color: var(--color-light-specialbg-component);
|
|
87
|
-
} .bottom-sheet__background-specialbg-component-
|
|
87
|
+
} .bottom-sheet__background-specialbg-component-inverted_10j16 {
|
|
88
88
|
background-color: var(--color-light-specialbg-component-inverted);
|
|
89
|
-
} .bottom-sheet__background-specialbg-primary-
|
|
89
|
+
} .bottom-sheet__background-specialbg-primary-grouped_10j16 {
|
|
90
90
|
background-color: var(--color-light-specialbg-primary-grouped);
|
|
91
|
-
} .bottom-sheet__background-specialbg-secondary-
|
|
91
|
+
} .bottom-sheet__background-specialbg-secondary-grouped_10j16 {
|
|
92
92
|
background-color: var(--color-light-specialbg-secondary-grouped);
|
|
93
|
-
} .bottom-sheet__background-specialbg-tertiary-
|
|
93
|
+
} .bottom-sheet__background-specialbg-tertiary-grouped_10j16 {
|
|
94
94
|
background-color: var(--color-light-specialbg-tertiary-grouped);
|
|
95
|
-
} .bottom-sheet__background-specialbg-secondary-
|
|
95
|
+
} .bottom-sheet__background-specialbg-secondary-transparent_10j16 {
|
|
96
96
|
background-color: var(--color-light-specialbg-secondary-transparent);
|
|
97
|
-
} .bottom-sheet__background-specialbg-secondary-transparent-
|
|
97
|
+
} .bottom-sheet__background-specialbg-secondary-transparent-inverted_10j16 {
|
|
98
98
|
background-color: var(--color-light-specialbg-secondary-transparent-inverted);
|
|
99
|
-
} .bottom-sheet__background-specialbg-tertiary-
|
|
99
|
+
} .bottom-sheet__background-specialbg-tertiary-transparent_10j16 {
|
|
100
100
|
background-color: var(--color-light-specialbg-tertiary-transparent);
|
|
101
|
-
} .bottom-sheet__background-specialbg-tertiary-transparent-
|
|
101
|
+
} .bottom-sheet__background-specialbg-tertiary-transparent-inverted_10j16 {
|
|
102
102
|
background-color: var(--color-light-specialbg-tertiary-transparent-inverted);
|
|
103
103
|
}
|
|
@@ -13,7 +13,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
13
13
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
14
14
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
15
15
|
|
|
16
|
-
var styles = {"headerWrapper":"bottom-
|
|
16
|
+
var styles = {"headerWrapper":"bottom-sheet__headerWrapper_16ikx","hasContent":"bottom-sheet__hasContent_16ikx","header":"bottom-sheet__header_16ikx","sticky":"bottom-sheet__sticky_16ikx","highlighted":"bottom-sheet__highlighted_16ikx","justifyEnd":"bottom-sheet__justifyEnd_16ikx","addon":"bottom-sheet__addon_16ikx","addonFixed":"bottom-sheet__addonFixed_16ikx","title":"bottom-sheet__title_16ikx","titleCenter":"bottom-sheet__titleCenter_16ikx","titleLeft":"bottom-sheet__titleLeft_16ikx","trimTitle":"bottom-sheet__trimTitle_16ikx"};
|
|
17
17
|
require('./index.css')
|
|
18
18
|
|
|
19
19
|
var Header = function (_a) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1l0li */
|
|
2
2
|
:root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-neutral-300: #e7e8eb; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
@@ -30,42 +30,42 @@
|
|
|
30
30
|
--bottom-sheet-title-font-family: var(--font-family-system);
|
|
31
31
|
|
|
32
32
|
/* footer */
|
|
33
|
-
} .bottom-
|
|
33
|
+
} .bottom-sheet__headerWrapper_16ikx {
|
|
34
34
|
padding: var(--gap-s) var(--gap-xs) var(--gap-2xs);
|
|
35
35
|
border-top-left-radius: inherit;
|
|
36
36
|
border-top-right-radius: inherit;
|
|
37
37
|
z-index: 1;
|
|
38
|
-
} .bottom-
|
|
38
|
+
} .bottom-sheet__hasContent_16ikx {
|
|
39
39
|
background-color: inherit;
|
|
40
|
-
} .bottom-
|
|
40
|
+
} .bottom-sheet__header_16ikx {
|
|
41
41
|
display: flex;
|
|
42
|
-
} .bottom-
|
|
42
|
+
} .bottom-sheet__sticky_16ikx {
|
|
43
43
|
position: sticky;
|
|
44
44
|
top: 0;
|
|
45
|
-
} .bottom-
|
|
45
|
+
} .bottom-sheet__highlighted_16ikx {
|
|
46
46
|
border-bottom: var(--bottom-sheet-header-border-bottom);
|
|
47
|
-
} .bottom-
|
|
47
|
+
} .bottom-sheet__justifyEnd_16ikx {
|
|
48
48
|
justify-content: flex-end;
|
|
49
|
-
} .bottom-
|
|
49
|
+
} .bottom-sheet__addon_16ikx {
|
|
50
50
|
display: flex;
|
|
51
51
|
justify-content: center;
|
|
52
52
|
align-items: center;
|
|
53
53
|
min-width: 48px;
|
|
54
54
|
height: 48px;
|
|
55
|
-
} .bottom-
|
|
55
|
+
} .bottom-sheet__addonFixed_16ikx {
|
|
56
56
|
position: fixed;
|
|
57
|
-
} .bottom-
|
|
57
|
+
} .bottom-sheet__title_16ikx {
|
|
58
58
|
padding: var(--gap-s) var(--gap-xs);
|
|
59
59
|
width: 100%;
|
|
60
60
|
font-size: var(--bottom-sheet-title-font-size);
|
|
61
61
|
font-weight: var(--bottom-sheet-title-font-weight);
|
|
62
62
|
line-height: var(--bottom-sheet-title-line-height);
|
|
63
63
|
font-family: var(--bottom-sheet-title-font-family);
|
|
64
|
-
} .bottom-
|
|
64
|
+
} .bottom-sheet__titleCenter_16ikx {
|
|
65
65
|
text-align: center;
|
|
66
|
-
} .bottom-
|
|
66
|
+
} .bottom-sheet__titleLeft_16ikx {
|
|
67
67
|
text-align: left;
|
|
68
|
-
} .bottom-
|
|
68
|
+
} .bottom-sheet__trimTitle_16ikx {
|
|
69
69
|
white-space: nowrap;
|
|
70
70
|
overflow: hidden;
|
|
71
71
|
text-overflow: ellipsis;
|
package/cssm/component.js
CHANGED
|
@@ -14,6 +14,7 @@ var components_footer_Component = require('./components/footer/Component.js');
|
|
|
14
14
|
var components_header_Component = require('./components/header/Component.js');
|
|
15
15
|
var components_swipeableBackdrop_Component = require('./components/swipeable-backdrop/Component.js');
|
|
16
16
|
var consts_swipeConsts = require('./consts/swipeConsts.js');
|
|
17
|
+
var hooks_useVisualviewportSize = require('./hooks/use-visualviewport-size.js');
|
|
17
18
|
var utils = require('./utils.js');
|
|
18
19
|
var styles = require('./index.module.css');
|
|
19
20
|
|
|
@@ -27,8 +28,11 @@ var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
|
27
28
|
var isNil = coreComponentsShared.fnUtils.isNil;
|
|
28
29
|
var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
29
30
|
var _b, _c, _d, _e, _f;
|
|
30
|
-
var
|
|
31
|
-
var
|
|
31
|
+
var _g, _h;
|
|
32
|
+
var open = _a.open, title = _a.title, container = _a.container, usePortal = _a.usePortal, backgroundColor = _a.backgroundColor, _j = _a.titleSize, titleSize = _j === void 0 ? 'default' : _j, subtitle = _a.subtitle, actionButton = _a.actionButton, contentClassName = _a.contentClassName, containerClassName = _a.containerClassName, containerProps = _a.containerProps, headerClassName = _a.headerClassName, footerClassName = _a.footerClassName, addonClassName = _a.addonClassName, closerClassName = _a.closerClassName, backerClassName = _a.backerClassName, modalClassName = _a.modalClassName, modalWrapperClassName = _a.modalWrapperClassName, className = _a.className, leftAddons = _a.leftAddons, rightAddons = _a.rightAddons, bottomAddons = _a.bottomAddons, hasCloser = _a.hasCloser, hasBacker = _a.hasBacker, _k = _a.titleAlign, titleAlign = _k === void 0 ? 'left' : _k, trimTitle = _a.trimTitle, stickyHeader = _a.stickyHeader, _l = _a.stickyFooter, stickyFooter = _l === void 0 ? true : _l, _m = _a.initialHeight, initialHeight = _m === void 0 ? 'default' : _m, hideOverlay = _a.hideOverlay, hideScrollbar = _a.hideScrollbar, hideHeader = _a.hideHeader, disableOverlayClick = _a.disableOverlayClick, disableBlockingScroll = _a.disableBlockingScroll, disableFocusLock = _a.disableFocusLock, children = _a.children, zIndex = _a.zIndex, _o = _a.transitionProps, transitionProps = _o === void 0 ? {} : _o, magneticAreasProp = _a.magneticAreas, initialActiveAreaIndex = _a.initialActiveAreaIndex, dataTestId = _a.dataTestId, _p = _a.swipeable, swipeable = _p === void 0 ? true : _p, _q = _a.swipeableContent, swipeableContent = _q === void 0 ? true : _q, _r = _a.swipeThreshold, swipeThreshold = _r === void 0 ? 5 : _r, scrollLockedProp = _a.scrollLocked, backdropProps = _a.backdropProps, _s = _a.scrollableContainerRef, scrollableContainerRef = _s === void 0 ? function () { return null; } : _s, bottomSheetInstanceRef = _a.bottomSheetInstanceRef, _t = _a.sheetContainerRef, sheetContainerRef = _t === void 0 ? function () { return null; } : _t, _u = _a.headerOffset, headerOffset = _u === void 0 ? 24 : _u, onClose = _a.onClose, onBack = _a.onBack, onMagnetize = _a.onMagnetize, onSwipeStart = _a.onSwipeStart, onSwipeEnd = _a.onSwipeEnd, disableRestoreFocus = _a.disableRestoreFocus, disableAutoFocus = _a.disableAutoFocus, disableEscapeKeyDown = _a.disableEscapeKeyDown, keepMounted = _a.keepMounted, onMagnetizeEnd = _a.onMagnetizeEnd, onOffsetChange = _a.onOffsetChange, swipeableMarker = _a.swipeableMarker, swipeableMarkerClassName = _a.swipeableMarkerClassName, backButtonProps = _a.backButtonProps, _v = _a.iOSLock, iOSLock = _v === void 0 ? false : _v, _w = _a.virtualKeyboard, virtualKeyboard = _w === void 0 ? false : _w;
|
|
33
|
+
var windowHeight = (_g = reactDiv100vh.use100vh()) !== null && _g !== void 0 ? _g : 0;
|
|
34
|
+
var visibleViewportSize = hooks_useVisualviewportSize.useVisibleViewportSize(virtualKeyboard);
|
|
35
|
+
var fullHeight = virtualKeyboard ? (_h = visibleViewportSize === null || visibleViewportSize === void 0 ? void 0 : visibleViewportSize.height) !== null && _h !== void 0 ? _h : 0 : windowHeight;
|
|
32
36
|
// Хук use100vh рассчитывает высоту вьюпорта в useEffect, поэтому на первый рендер всегда возвращает null.
|
|
33
37
|
var isFirstRender = fullHeight === 0;
|
|
34
38
|
var initialIndexRef = React.useRef(initialActiveAreaIndex);
|
|
@@ -42,14 +46,14 @@ var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
|
42
46
|
var iOSViewHeight = coreComponentsShared.isClient()
|
|
43
47
|
? ((_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.clientHeight) || (window === null || window === void 0 ? void 0 : window.innerHeight)
|
|
44
48
|
: 0;
|
|
45
|
-
var viewHeight = coreComponentsShared.os.isIOS() ? iOSViewHeight : fullHeight;
|
|
49
|
+
var viewHeight = coreComponentsShared.os.isIOS() && !virtualKeyboard ? iOSViewHeight : fullHeight;
|
|
46
50
|
return [0, viewHeight - headerOffset];
|
|
47
|
-
}, [fullHeight, headerOffset, magneticAreasProp]);
|
|
51
|
+
}, [fullHeight, headerOffset, magneticAreasProp, virtualKeyboard]);
|
|
48
52
|
var lastMagneticArea = magneticAreas[magneticAreas.length - 1];
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
+
var _x = React.useState(0), sheetOffset = _x[0], setSheetOffset = _x[1];
|
|
54
|
+
var _y = React.useState(1), backdropOpacity = _y[0], setBackdropOpacity = _y[1];
|
|
55
|
+
var _z = React.useState(-1), activeAreaIdx = _z[0], setActiveAreaIdx = _z[1];
|
|
56
|
+
var _0 = React.useState(null), swipingInProgress = _0[0], setSwipingInProgress = _0[1];
|
|
53
57
|
var scrollOccurred = React.useRef(false);
|
|
54
58
|
var headerRef = React.useRef(null);
|
|
55
59
|
var contentRef = React.useRef(null);
|
|
@@ -352,6 +356,9 @@ var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
|
352
356
|
? "".concat(lastMagneticArea, "px")
|
|
353
357
|
: 'unset',
|
|
354
358
|
maxHeight: isFirstRender ? 0 : "".concat(lastMagneticArea, "px"),
|
|
359
|
+
marginBottom: virtualKeyboard && visibleViewportSize && windowHeight > visibleViewportSize.height
|
|
360
|
+
? windowHeight - visibleViewportSize.height - visibleViewportSize.offsetTop
|
|
361
|
+
: undefined,
|
|
355
362
|
}); };
|
|
356
363
|
var renderMarker = function () {
|
|
357
364
|
if (swipeable) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useVisibleViewportSize } from "./use-visualviewport-size";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var coreComponentsShared = require('@alfalab/core-components-shared/cssm');
|
|
7
|
+
|
|
8
|
+
var measureVisualViewport = function (visualViewport) {
|
|
9
|
+
if (!visualViewport)
|
|
10
|
+
return null;
|
|
11
|
+
var height = visualViewport.height, offsetTop = visualViewport.offsetTop;
|
|
12
|
+
return { height: height, offsetTop: offsetTop };
|
|
13
|
+
};
|
|
14
|
+
function useVisibleViewportSize(enabled) {
|
|
15
|
+
if (enabled === void 0) { enabled = false; }
|
|
16
|
+
var _a = React.useState(function () {
|
|
17
|
+
return coreComponentsShared.isClient() ? measureVisualViewport(window.visualViewport) : null;
|
|
18
|
+
}), size = _a[0], setSize = _a[1];
|
|
19
|
+
React.useEffect(function () {
|
|
20
|
+
var visualViewport = window.visualViewport;
|
|
21
|
+
if (!coreComponentsShared.isClient() || !enabled || !visualViewport)
|
|
22
|
+
return coreComponentsShared.fnUtils.noop;
|
|
23
|
+
var listener = function (event) {
|
|
24
|
+
return setSize(measureVisualViewport(event.target));
|
|
25
|
+
};
|
|
26
|
+
visualViewport.addEventListener('resize', listener);
|
|
27
|
+
visualViewport.addEventListener('scroll', listener);
|
|
28
|
+
return function () {
|
|
29
|
+
visualViewport.removeEventListener('resize', listener);
|
|
30
|
+
visualViewport.removeEventListener('scroll', listener);
|
|
31
|
+
};
|
|
32
|
+
}, [enabled]);
|
|
33
|
+
return size;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.useVisibleViewportSize = useVisibleViewportSize;
|
package/cssm/types.d.ts
CHANGED
|
@@ -281,5 +281,9 @@ type BottomSheetProps = {
|
|
|
281
281
|
* Блокирует скролл когда модальное окно открыто. Работает только на iOS
|
|
282
282
|
*/
|
|
283
283
|
iOSLock?: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Учитывать высоту виртуальной клавиатуры
|
|
286
|
+
*/
|
|
287
|
+
virtualKeyboard?: boolean;
|
|
284
288
|
};
|
|
285
289
|
export { BottomSheetTitleAlign, BottomSheetProps };
|
package/esm/component.js
CHANGED
|
@@ -10,16 +10,20 @@ import { Footer } from './components/footer/Component.js';
|
|
|
10
10
|
import { Header } from './components/header/Component.js';
|
|
11
11
|
import { SwipeableBackdrop } from './components/swipeable-backdrop/Component.js';
|
|
12
12
|
import { horizontalDirections } from './consts/swipeConsts.js';
|
|
13
|
+
import { useVisibleViewportSize } from './hooks/use-visualviewport-size.js';
|
|
13
14
|
import { convertPercentToNumber, TIMEOUT, MARKER_HEIGHT, SCROLL_OFFSET, SWIPE_VELOCITY, CLOSE_OFFSET } from './utils.js';
|
|
14
15
|
|
|
15
|
-
var styles = {"modal":"bottom-
|
|
16
|
+
var styles = {"modal":"bottom-sheet__modal_90r42","wrapper":"bottom-sheet__wrapper_90r42","fullscreen":"bottom-sheet__fullscreen_90r42","component":"bottom-sheet__component_90r42","withTransition":"bottom-sheet__withTransition_90r42","scrollableContainer":"bottom-sheet__scrollableContainer_90r42","marker":"bottom-sheet__marker_90r42","defaultMarker":"bottom-sheet__defaultMarker_90r42","content":"bottom-sheet__content_90r42","noHeader":"bottom-sheet__noHeader_90r42","noFooter":"bottom-sheet__noFooter_90r42","scrollLocked":"bottom-sheet__scrollLocked_90r42","hiddenScrollbar":"bottom-sheet__hiddenScrollbar_90r42","disabledPointerEvents":"bottom-sheet__disabledPointerEvents_90r42","appear":"bottom-sheet__appear_90r42","enter":"bottom-sheet__enter_90r42","appearActive":"bottom-sheet__appearActive_90r42","enterActive":"bottom-sheet__enterActive_90r42","enterDone":"bottom-sheet__enterDone_90r42","appearDone":"bottom-sheet__appearDone_90r42","exit":"bottom-sheet__exit_90r42","exitActive":"bottom-sheet__exitActive_90r42","safeAreaBottom":"bottom-sheet__safeAreaBottom_90r42","background-accent":"bottom-sheet__background-accent_90r42","background-info":"bottom-sheet__background-info_90r42","background-attention-muted":"bottom-sheet__background-attention-muted_90r42","background-positive-muted":"bottom-sheet__background-positive-muted_90r42","background-negative-muted":"bottom-sheet__background-negative-muted_90r42","background-primary":"bottom-sheet__background-primary_90r42","background-primary-inverted":"bottom-sheet__background-primary-inverted_90r42","background-secondary":"bottom-sheet__background-secondary_90r42","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_90r42","background-tertiary":"bottom-sheet__background-tertiary_90r42","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_90r42","background-quaternary":"bottom-sheet__background-quaternary_90r42","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_90r42","background-specialbg-component":"bottom-sheet__background-specialbg-component_90r42","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_90r42","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_90r42","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_90r42","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_90r42","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_90r42","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_90r42","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_90r42","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_90r42"};
|
|
16
17
|
require('./index.css')
|
|
17
18
|
|
|
18
19
|
var isNil = fnUtils.isNil;
|
|
19
20
|
var BottomSheet = forwardRef(function (_a, ref) {
|
|
20
21
|
var _b, _c, _d, _e, _f;
|
|
21
|
-
var
|
|
22
|
-
var
|
|
22
|
+
var _g, _h;
|
|
23
|
+
var open = _a.open, title = _a.title, container = _a.container, usePortal = _a.usePortal, backgroundColor = _a.backgroundColor, _j = _a.titleSize, titleSize = _j === void 0 ? 'default' : _j, subtitle = _a.subtitle, actionButton = _a.actionButton, contentClassName = _a.contentClassName, containerClassName = _a.containerClassName, containerProps = _a.containerProps, headerClassName = _a.headerClassName, footerClassName = _a.footerClassName, addonClassName = _a.addonClassName, closerClassName = _a.closerClassName, backerClassName = _a.backerClassName, modalClassName = _a.modalClassName, modalWrapperClassName = _a.modalWrapperClassName, className = _a.className, leftAddons = _a.leftAddons, rightAddons = _a.rightAddons, bottomAddons = _a.bottomAddons, hasCloser = _a.hasCloser, hasBacker = _a.hasBacker, _k = _a.titleAlign, titleAlign = _k === void 0 ? 'left' : _k, trimTitle = _a.trimTitle, stickyHeader = _a.stickyHeader, _l = _a.stickyFooter, stickyFooter = _l === void 0 ? true : _l, _m = _a.initialHeight, initialHeight = _m === void 0 ? 'default' : _m, hideOverlay = _a.hideOverlay, hideScrollbar = _a.hideScrollbar, hideHeader = _a.hideHeader, disableOverlayClick = _a.disableOverlayClick, disableBlockingScroll = _a.disableBlockingScroll, disableFocusLock = _a.disableFocusLock, children = _a.children, zIndex = _a.zIndex, _o = _a.transitionProps, transitionProps = _o === void 0 ? {} : _o, magneticAreasProp = _a.magneticAreas, initialActiveAreaIndex = _a.initialActiveAreaIndex, dataTestId = _a.dataTestId, _p = _a.swipeable, swipeable = _p === void 0 ? true : _p, _q = _a.swipeableContent, swipeableContent = _q === void 0 ? true : _q, _r = _a.swipeThreshold, swipeThreshold = _r === void 0 ? 5 : _r, scrollLockedProp = _a.scrollLocked, backdropProps = _a.backdropProps, _s = _a.scrollableContainerRef, scrollableContainerRef = _s === void 0 ? function () { return null; } : _s, bottomSheetInstanceRef = _a.bottomSheetInstanceRef, _t = _a.sheetContainerRef, sheetContainerRef = _t === void 0 ? function () { return null; } : _t, _u = _a.headerOffset, headerOffset = _u === void 0 ? 24 : _u, onClose = _a.onClose, onBack = _a.onBack, onMagnetize = _a.onMagnetize, onSwipeStart = _a.onSwipeStart, onSwipeEnd = _a.onSwipeEnd, disableRestoreFocus = _a.disableRestoreFocus, disableAutoFocus = _a.disableAutoFocus, disableEscapeKeyDown = _a.disableEscapeKeyDown, keepMounted = _a.keepMounted, onMagnetizeEnd = _a.onMagnetizeEnd, onOffsetChange = _a.onOffsetChange, swipeableMarker = _a.swipeableMarker, swipeableMarkerClassName = _a.swipeableMarkerClassName, backButtonProps = _a.backButtonProps, _v = _a.iOSLock, iOSLock = _v === void 0 ? false : _v, _w = _a.virtualKeyboard, virtualKeyboard = _w === void 0 ? false : _w;
|
|
24
|
+
var windowHeight = (_g = use100vh()) !== null && _g !== void 0 ? _g : 0;
|
|
25
|
+
var visibleViewportSize = useVisibleViewportSize(virtualKeyboard);
|
|
26
|
+
var fullHeight = virtualKeyboard ? (_h = visibleViewportSize === null || visibleViewportSize === void 0 ? void 0 : visibleViewportSize.height) !== null && _h !== void 0 ? _h : 0 : windowHeight;
|
|
23
27
|
// Хук use100vh рассчитывает высоту вьюпорта в useEffect, поэтому на первый рендер всегда возвращает null.
|
|
24
28
|
var isFirstRender = fullHeight === 0;
|
|
25
29
|
var initialIndexRef = useRef(initialActiveAreaIndex);
|
|
@@ -33,14 +37,14 @@ var BottomSheet = forwardRef(function (_a, ref) {
|
|
|
33
37
|
var iOSViewHeight = isClient()
|
|
34
38
|
? ((_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.clientHeight) || (window === null || window === void 0 ? void 0 : window.innerHeight)
|
|
35
39
|
: 0;
|
|
36
|
-
var viewHeight = os.isIOS() ? iOSViewHeight : fullHeight;
|
|
40
|
+
var viewHeight = os.isIOS() && !virtualKeyboard ? iOSViewHeight : fullHeight;
|
|
37
41
|
return [0, viewHeight - headerOffset];
|
|
38
|
-
}, [fullHeight, headerOffset, magneticAreasProp]);
|
|
42
|
+
}, [fullHeight, headerOffset, magneticAreasProp, virtualKeyboard]);
|
|
39
43
|
var lastMagneticArea = magneticAreas[magneticAreas.length - 1];
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
+
var _x = useState(0), sheetOffset = _x[0], setSheetOffset = _x[1];
|
|
45
|
+
var _y = useState(1), backdropOpacity = _y[0], setBackdropOpacity = _y[1];
|
|
46
|
+
var _z = useState(-1), activeAreaIdx = _z[0], setActiveAreaIdx = _z[1];
|
|
47
|
+
var _0 = useState(null), swipingInProgress = _0[0], setSwipingInProgress = _0[1];
|
|
44
48
|
var scrollOccurred = useRef(false);
|
|
45
49
|
var headerRef = useRef(null);
|
|
46
50
|
var contentRef = useRef(null);
|
|
@@ -343,6 +347,9 @@ var BottomSheet = forwardRef(function (_a, ref) {
|
|
|
343
347
|
? "".concat(lastMagneticArea, "px")
|
|
344
348
|
: 'unset',
|
|
345
349
|
maxHeight: isFirstRender ? 0 : "".concat(lastMagneticArea, "px"),
|
|
350
|
+
marginBottom: virtualKeyboard && visibleViewportSize && windowHeight > visibleViewportSize.height
|
|
351
|
+
? windowHeight - visibleViewportSize.height - visibleViewportSize.offsetTop
|
|
352
|
+
: undefined,
|
|
346
353
|
}); };
|
|
347
354
|
var renderMarker = function () {
|
|
348
355
|
if (swipeable) {
|
|
@@ -2,7 +2,7 @@ import React, { useContext, useEffect } from 'react';
|
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { BaseModalContext } from '@alfalab/core-components-base-modal/esm';
|
|
4
4
|
|
|
5
|
-
var styles = {"footer":"bottom-
|
|
5
|
+
var styles = {"footer":"bottom-sheet__footer_10j16","sticky":"bottom-sheet__sticky_10j16","highlighted":"bottom-sheet__highlighted_10j16","background-accent":"bottom-sheet__background-accent_10j16","background-info":"bottom-sheet__background-info_10j16","background-attention-muted":"bottom-sheet__background-attention-muted_10j16","background-positive-muted":"bottom-sheet__background-positive-muted_10j16","background-negative-muted":"bottom-sheet__background-negative-muted_10j16","background-primary":"bottom-sheet__background-primary_10j16","background-primary-inverted":"bottom-sheet__background-primary-inverted_10j16","background-secondary":"bottom-sheet__background-secondary_10j16","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_10j16","background-tertiary":"bottom-sheet__background-tertiary_10j16","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_10j16","background-quaternary":"bottom-sheet__background-quaternary_10j16","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_10j16","background-specialbg-component":"bottom-sheet__background-specialbg-component_10j16","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_10j16","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_10j16","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_10j16","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_10j16","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_10j16","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_10j16","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_10j16","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_10j16"};
|
|
6
6
|
require('./index.css')
|
|
7
7
|
|
|
8
8
|
var Footer = function (_a) {
|