@alfalab/core-components-bottom-sheet 6.2.2 → 6.2.4
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 +26 -17
- 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 +25 -16
- package/cssm/types.d.ts +4 -0
- package/esm/component.js +26 -17
- 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/index.css +41 -41
- package/esm/types.d.ts +4 -0
- package/index.css +41 -41
- package/modern/component.js +24 -17
- 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/index.css +41 -41
- package/modern/types.d.ts +4 -0
- package/package.json +2 -4
- package/types.d.ts +4 -0
package/component.js
CHANGED
|
@@ -27,16 +27,16 @@ var getDataTestId = function (dataTestId, element) {
|
|
|
27
27
|
return dataTestId ? "".concat(dataTestId).concat(elementPart) : undefined;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
var styles = {"modal":"bottom-sheet__modal_8udi2","wrapper":"bottom-sheet__wrapper_8udi2","component":"bottom-sheet__component_8udi2","withTransition":"bottom-sheet__withTransition_8udi2","scrollableContainer":"bottom-sheet__scrollableContainer_8udi2","marker":"bottom-sheet__marker_8udi2","content":"bottom-sheet__content_8udi2","noHeader":"bottom-sheet__noHeader_8udi2","noFooter":"bottom-sheet__noFooter_8udi2","scrollLocked":"bottom-sheet__scrollLocked_8udi2","hiddenScrollbar":"bottom-sheet__hiddenScrollbar_8udi2","disabledPointerEvents":"bottom-sheet__disabledPointerEvents_8udi2","appear":"bottom-sheet__appear_8udi2","enter":"bottom-sheet__enter_8udi2","appearActive":"bottom-sheet__appearActive_8udi2","enterActive":"bottom-sheet__enterActive_8udi2","enterDone":"bottom-sheet__enterDone_8udi2","appearDone":"bottom-sheet__appearDone_8udi2","exit":"bottom-sheet__exit_8udi2","exitActive":"bottom-sheet__exitActive_8udi2","background-accent":"bottom-sheet__background-accent_8udi2","background-info":"bottom-sheet__background-info_8udi2","background-attention-muted":"bottom-sheet__background-attention-muted_8udi2","background-positive-muted":"bottom-sheet__background-positive-muted_8udi2","background-negative-muted":"bottom-sheet__background-negative-muted_8udi2","background-primary":"bottom-sheet__background-primary_8udi2","background-primary-inverted":"bottom-sheet__background-primary-inverted_8udi2","background-secondary":"bottom-sheet__background-secondary_8udi2","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_8udi2","background-tertiary":"bottom-sheet__background-tertiary_8udi2","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_8udi2","background-quaternary":"bottom-sheet__background-quaternary_8udi2","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_8udi2","background-specialbg-component":"bottom-sheet__background-specialbg-component_8udi2","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_8udi2","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_8udi2","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_8udi2","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_8udi2","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_8udi2","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_8udi2","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_8udi2","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_8udi2"};
|
|
30
|
+
var styles = {"modal":"bottom-sheet__modal_1gfwj","wrapper":"bottom-sheet__wrapper_1gfwj","component":"bottom-sheet__component_1gfwj","withTransition":"bottom-sheet__withTransition_1gfwj","scrollableContainer":"bottom-sheet__scrollableContainer_1gfwj","marker":"bottom-sheet__marker_1gfwj","content":"bottom-sheet__content_1gfwj","noHeader":"bottom-sheet__noHeader_1gfwj","noFooter":"bottom-sheet__noFooter_1gfwj","scrollLocked":"bottom-sheet__scrollLocked_1gfwj","hiddenScrollbar":"bottom-sheet__hiddenScrollbar_1gfwj","disabledPointerEvents":"bottom-sheet__disabledPointerEvents_1gfwj","appear":"bottom-sheet__appear_1gfwj","enter":"bottom-sheet__enter_1gfwj","appearActive":"bottom-sheet__appearActive_1gfwj","enterActive":"bottom-sheet__enterActive_1gfwj","enterDone":"bottom-sheet__enterDone_1gfwj","appearDone":"bottom-sheet__appearDone_1gfwj","exit":"bottom-sheet__exit_1gfwj","exitActive":"bottom-sheet__exitActive_1gfwj","background-accent":"bottom-sheet__background-accent_1gfwj","background-info":"bottom-sheet__background-info_1gfwj","background-attention-muted":"bottom-sheet__background-attention-muted_1gfwj","background-positive-muted":"bottom-sheet__background-positive-muted_1gfwj","background-negative-muted":"bottom-sheet__background-negative-muted_1gfwj","background-primary":"bottom-sheet__background-primary_1gfwj","background-primary-inverted":"bottom-sheet__background-primary-inverted_1gfwj","background-secondary":"bottom-sheet__background-secondary_1gfwj","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_1gfwj","background-tertiary":"bottom-sheet__background-tertiary_1gfwj","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_1gfwj","background-quaternary":"bottom-sheet__background-quaternary_1gfwj","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_1gfwj","background-specialbg-component":"bottom-sheet__background-specialbg-component_1gfwj","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_1gfwj","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_1gfwj","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_1gfwj","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_1gfwj","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_1gfwj","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_1gfwj","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_1gfwj","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_1gfwj"};
|
|
33
31
|
require('./index.css')
|
|
34
32
|
|
|
35
33
|
var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
36
34
|
var _b, _c, _d, _e;
|
|
37
|
-
var open = _a.open, title = _a.title, container = _a.container, backgroundColor = _a.backgroundColor, _f = _a.titleSize, titleSize = _f === void 0 ? 'default' : _f, 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, _g = _a.titleAlign, titleAlign = _g === void 0 ? 'left' : _g, trimTitle = _a.trimTitle, stickyHeader = _a.stickyHeader, _h = _a.stickyFooter, stickyFooter = _h === void 0 ? true : _h, _j = _a.initialHeight, initialHeight = _j === void 0 ? 'default' : _j, hideOverlay = _a.hideOverlay, hideScrollbar = _a.hideScrollbar, hideHeader = _a.hideHeader, disableOverlayClick = _a.disableOverlayClick, disableBlockingScroll = _a.disableBlockingScroll, children = _a.children, zIndex = _a.zIndex, _k = _a.transitionProps, transitionProps = _k === void 0 ? {} : _k, magneticAreasProp = _a.magneticAreas, initialActiveAreaIndex = _a.initialActiveAreaIndex, dataTestId = _a.dataTestId, _l = _a.swipeable, swipeable = _l === void 0 ? true : _l, scrollLockedProp = _a.scrollLocked, backdropProps = _a.backdropProps, _m = _a.scrollableContainerRef, scrollableContainerRef = _m === void 0 ? function () { return null; } : _m, bottomSheetInstanceRef = _a.bottomSheetInstanceRef, _o = _a.sheetContainerRef, sheetContainerRef = _o === void 0 ? function () { return null; } : _o, onClose = _a.onClose, onBack = _a.onBack, onMagnetize = _a.onMagnetize;
|
|
35
|
+
var open = _a.open, title = _a.title, container = _a.container, usePortal = _a.usePortal, backgroundColor = _a.backgroundColor, _f = _a.titleSize, titleSize = _f === void 0 ? 'default' : _f, 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, _g = _a.titleAlign, titleAlign = _g === void 0 ? 'left' : _g, trimTitle = _a.trimTitle, stickyHeader = _a.stickyHeader, _h = _a.stickyFooter, stickyFooter = _h === void 0 ? true : _h, _j = _a.initialHeight, initialHeight = _j === void 0 ? 'default' : _j, hideOverlay = _a.hideOverlay, hideScrollbar = _a.hideScrollbar, hideHeader = _a.hideHeader, disableOverlayClick = _a.disableOverlayClick, disableBlockingScroll = _a.disableBlockingScroll, children = _a.children, zIndex = _a.zIndex, _k = _a.transitionProps, transitionProps = _k === void 0 ? {} : _k, magneticAreasProp = _a.magneticAreas, initialActiveAreaIndex = _a.initialActiveAreaIndex, dataTestId = _a.dataTestId, _l = _a.swipeable, swipeable = _l === void 0 ? true : _l, scrollLockedProp = _a.scrollLocked, backdropProps = _a.backdropProps, _m = _a.scrollableContainerRef, scrollableContainerRef = _m === void 0 ? function () { return null; } : _m, bottomSheetInstanceRef = _a.bottomSheetInstanceRef, _o = _a.sheetContainerRef, sheetContainerRef = _o === void 0 ? function () { return null; } : _o, onClose = _a.onClose, onBack = _a.onBack, onMagnetize = _a.onMagnetize;
|
|
38
36
|
var hasInitialIdx = initialActiveAreaIndex !== undefined;
|
|
39
|
-
var fullHeight = reactDiv100vh.use100vh() ||
|
|
37
|
+
var fullHeight = reactDiv100vh.use100vh() || 0;
|
|
38
|
+
// Хук use100vh рассчитывает высоту вьюпорта в useEffect, поэтому на первый рендер всегда возвращает null.
|
|
39
|
+
var isFirstRender = fullHeight === 0;
|
|
40
40
|
var magneticAreas = React.useMemo(function () {
|
|
41
41
|
if (magneticAreasProp) {
|
|
42
42
|
return magneticAreasProp.map(function (area) { return utils.convertPercentToNumber(area, fullHeight); });
|
|
@@ -44,12 +44,10 @@ var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
|
44
44
|
return [0, fullHeight - utils.HEADER_OFFSET];
|
|
45
45
|
}, [fullHeight, magneticAreasProp]);
|
|
46
46
|
var lastMagneticArea = magneticAreas[magneticAreas.length - 1];
|
|
47
|
-
var _p = React.useState(
|
|
48
|
-
? lastMagneticArea - magneticAreas[initialActiveAreaIndex]
|
|
49
|
-
: magneticAreas[0]), sheetOffset = _p[0], setSheetOffset = _p[1];
|
|
47
|
+
var _p = React.useState(0), sheetOffset = _p[0], setSheetOffset = _p[1];
|
|
50
48
|
var _q = React.useState(1), backdropOpacity = _q[0], setBackdropOpacity = _q[1];
|
|
51
|
-
var _r = React.useState(
|
|
52
|
-
var swipingInProgress = React.useRef(
|
|
49
|
+
var _r = React.useState(0), activeArea = _r[0], setActiveArea = _r[1];
|
|
50
|
+
var swipingInProgress = React.useRef(null);
|
|
53
51
|
var headerRef = React.useRef(null);
|
|
54
52
|
var sheetHeight = React.useRef(0);
|
|
55
53
|
var sheetRef = React.useRef(null);
|
|
@@ -84,6 +82,7 @@ var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
|
84
82
|
}
|
|
85
83
|
};
|
|
86
84
|
var scrollToArea = function (idx) {
|
|
85
|
+
swipingInProgress.current = false;
|
|
87
86
|
var nextArea = magneticAreas[idx];
|
|
88
87
|
if (nextArea === 0) {
|
|
89
88
|
onClose();
|
|
@@ -223,10 +222,20 @@ var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
|
223
222
|
var handleEntered = function (node, isAppearing) {
|
|
224
223
|
setBackdropOpacity(1);
|
|
225
224
|
setSheetHeight();
|
|
225
|
+
// Ready for swiping
|
|
226
|
+
swipingInProgress.current = false;
|
|
226
227
|
if (transitionProps.onEntered) {
|
|
227
228
|
transitionProps.onEntered(node, isAppearing);
|
|
228
229
|
}
|
|
229
230
|
};
|
|
231
|
+
React.useEffect(function () {
|
|
232
|
+
// Инициализируем стейт только после того, как была рассчитана высота вьюпорта.
|
|
233
|
+
if (!isFirstRender) {
|
|
234
|
+
setSheetOffset(hasInitialIdx ? lastMagneticArea - magneticAreas[initialActiveAreaIndex] : 0);
|
|
235
|
+
setActiveArea(hasInitialIdx ? magneticAreas[initialActiveAreaIndex] : lastMagneticArea);
|
|
236
|
+
}
|
|
237
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
238
|
+
}, [isFirstRender]);
|
|
230
239
|
React.useEffect(function () {
|
|
231
240
|
onMagnetize === null || onMagnetize === void 0 ? void 0 : onMagnetize(open ? getActiveAreaIndex(activeArea) : 0);
|
|
232
241
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -234,20 +243,20 @@ var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
|
234
243
|
React.useImperativeHandle(bottomSheetInstanceRef, function () { return ({
|
|
235
244
|
scrollToArea: scrollToArea,
|
|
236
245
|
}); });
|
|
237
|
-
var getSwipeStyles = function () {
|
|
238
|
-
|
|
239
|
-
}
|
|
246
|
+
var getSwipeStyles = function () {
|
|
247
|
+
return sheetOffset ? { transform: "translateY(".concat(sheetOffset, "px)") } : {};
|
|
248
|
+
};
|
|
240
249
|
var getHeightStyles = function () { return ({
|
|
241
|
-
height: initialHeight === 'full' ? "".concat(lastMagneticArea, "px") : 'unset',
|
|
242
|
-
maxHeight: "".concat(lastMagneticArea, "px"),
|
|
250
|
+
height: !isFirstRender && initialHeight === 'full' ? "".concat(lastMagneticArea, "px") : 'unset',
|
|
251
|
+
maxHeight: isFirstRender ? 0 : "".concat(lastMagneticArea, "px"),
|
|
243
252
|
}); };
|
|
244
253
|
var bgClassName = backgroundColor && styles["background-".concat(backgroundColor)];
|
|
245
|
-
return (React__default.default.createElement(coreComponentsBaseModal.BaseModal, { open: open, ref: ref, container: container, dataTestId: dataTestId, zIndex: zIndex, onClose: onClose, scrollHandler: scrollableContainer, Backdrop: components_swipeableBackdrop_Component.SwipeableBackdrop, backdropProps: tslib.__assign(tslib.__assign({}, backdropProps), { className: styles.disabledPointerEvents, opacity: backdropOpacity, opacityTimeout: utils.TIMEOUT, invisible: hideOverlay }), disableBackdropClick: hideOverlay ? true : disableOverlayClick, className: cn__default.default(styles.modal, modalClassName), wrapperClassName: cn__default.default(modalWrapperClassName, (_b = {},
|
|
254
|
+
return (React__default.default.createElement(coreComponentsBaseModal.BaseModal, { open: open, ref: ref, container: container, dataTestId: dataTestId, zIndex: zIndex, onClose: onClose, usePortal: usePortal, scrollHandler: scrollableContainer, Backdrop: components_swipeableBackdrop_Component.SwipeableBackdrop, backdropProps: tslib.__assign(tslib.__assign({}, backdropProps), { className: styles.disabledPointerEvents, opacity: backdropOpacity, opacityTimeout: utils.TIMEOUT, invisible: hideOverlay }), disableBackdropClick: hideOverlay ? true : disableOverlayClick, className: cn__default.default(styles.modal, modalClassName), wrapperClassName: cn__default.default(modalWrapperClassName, (_b = {},
|
|
246
255
|
_b[styles.disabledPointerEvents] = hideOverlay,
|
|
247
256
|
_b)), disableBlockingScroll: disableBlockingScroll, transitionProps: tslib.__assign(tslib.__assign({ appear: true, timeout: utils.TIMEOUT, classNames: styles }, transitionProps), { onExited: handleExited, onEntered: handleEntered }) },
|
|
248
257
|
React__default.default.createElement("div", { style: tslib.__assign({}, getHeightStyles()), className: styles.wrapper, onTransitionEnd: setSheetHeight },
|
|
249
258
|
React__default.default.createElement("div", tslib.__assign({ className: cn__default.default(styles.component, bgClassName, className, (_c = {},
|
|
250
|
-
_c[styles.withTransition] =
|
|
259
|
+
_c[styles.withTransition] = swipingInProgress.current === false,
|
|
251
260
|
_c)), style: tslib.__assign(tslib.__assign({}, getSwipeStyles()), getHeightStyles()) }, sheetSwipeableHandlers, { ref: mergeRefs__default.default([sheetRef, sheetContainerRef, sheetSwipeableHandlers.ref]), onTransitionEnd: setSheetHeight }),
|
|
252
261
|
React__default.default.createElement("div", tslib.__assign({}, containerProps, { className: cn__default.default(styles.scrollableContainer, containerProps === null || containerProps === void 0 ? void 0 : containerProps.className, containerClassName, (_d = {},
|
|
253
262
|
_d[styles.scrollLocked] = scrollLockedProp || swipingInProgress.current,
|
|
@@ -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_ykuo8","sticky":"bottom-sheet__sticky_ykuo8","highlighted":"bottom-sheet__highlighted_ykuo8","background-accent":"bottom-sheet__background-accent_ykuo8","background-info":"bottom-sheet__background-info_ykuo8","background-attention-muted":"bottom-sheet__background-attention-muted_ykuo8","background-positive-muted":"bottom-sheet__background-positive-muted_ykuo8","background-negative-muted":"bottom-sheet__background-negative-muted_ykuo8","background-primary":"bottom-sheet__background-primary_ykuo8","background-primary-inverted":"bottom-sheet__background-primary-inverted_ykuo8","background-secondary":"bottom-sheet__background-secondary_ykuo8","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_ykuo8","background-tertiary":"bottom-sheet__background-tertiary_ykuo8","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_ykuo8","background-quaternary":"bottom-sheet__background-quaternary_ykuo8","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_ykuo8","background-specialbg-component":"bottom-sheet__background-specialbg-component_ykuo8","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_ykuo8","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_ykuo8","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_ykuo8","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_ykuo8","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_ykuo8","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_ykuo8","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_ykuo8","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_ykuo8"};
|
|
15
15
|
require('./index.css')
|
|
16
16
|
|
|
17
17
|
var Footer = function (_a) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1wk86 */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-bg-accent: #ef3124;
|
|
@@ -41,58 +41,58 @@
|
|
|
41
41
|
} :root {
|
|
42
42
|
--bottom-sheet-footer-border-top: 1px solid var(--color-light-border-secondary);
|
|
43
43
|
--bottom-sheet-footer-background-color: var(--color-light-bg-primary);
|
|
44
|
-
} .bottom-
|
|
44
|
+
} .bottom-sheet__footer_ykuo8 {
|
|
45
45
|
padding: var(--gap-m) var(--gap-m);
|
|
46
46
|
background-color: var(--color-light-bg-primary);
|
|
47
|
-
} .bottom-
|
|
47
|
+
} .bottom-sheet__sticky_ykuo8 {
|
|
48
48
|
position: sticky;
|
|
49
49
|
bottom: 0;
|
|
50
50
|
z-index: 1;
|
|
51
|
-
} .bottom-
|
|
51
|
+
} .bottom-sheet__highlighted_ykuo8 {
|
|
52
52
|
border-top: var(--bottom-sheet-footer-border-top);
|
|
53
53
|
background-color: var(--bottom-sheet-footer-background-color);
|
|
54
|
-
} .bottom-sheet__background-
|
|
54
|
+
} .bottom-sheet__background-accent_ykuo8 {
|
|
55
55
|
background-color: var(--color-light-bg-accent);
|
|
56
|
-
} .bottom-sheet__background-
|
|
56
|
+
} .bottom-sheet__background-info_ykuo8 {
|
|
57
57
|
background-color: var(--color-light-bg-info);
|
|
58
|
-
} .bottom-sheet__background-attention-
|
|
58
|
+
} .bottom-sheet__background-attention-muted_ykuo8 {
|
|
59
59
|
background-color: var(--color-light-bg-attention-muted);
|
|
60
|
-
} .bottom-sheet__background-positive-
|
|
60
|
+
} .bottom-sheet__background-positive-muted_ykuo8 {
|
|
61
61
|
background-color: var(--color-light-bg-positive-muted);
|
|
62
|
-
} .bottom-sheet__background-negative-
|
|
62
|
+
} .bottom-sheet__background-negative-muted_ykuo8 {
|
|
63
63
|
background-color: var(--color-light-bg-negative-muted);
|
|
64
|
-
} .bottom-sheet__background-
|
|
64
|
+
} .bottom-sheet__background-primary_ykuo8 {
|
|
65
65
|
background-color: var(--color-light-bg-primary);
|
|
66
|
-
} .bottom-sheet__background-primary-
|
|
66
|
+
} .bottom-sheet__background-primary-inverted_ykuo8 {
|
|
67
67
|
background-color: var(--color-light-bg-primary-inverted);
|
|
68
|
-
} .bottom-sheet__background-
|
|
68
|
+
} .bottom-sheet__background-secondary_ykuo8 {
|
|
69
69
|
background-color: var(--color-light-bg-secondary);
|
|
70
|
-
} .bottom-sheet__background-secondary-
|
|
70
|
+
} .bottom-sheet__background-secondary-inverted_ykuo8 {
|
|
71
71
|
background-color: var(--color-light-bg-secondary-inverted);
|
|
72
|
-
} .bottom-sheet__background-
|
|
72
|
+
} .bottom-sheet__background-tertiary_ykuo8 {
|
|
73
73
|
background-color: var(--color-light-bg-tertiary);
|
|
74
|
-
} .bottom-sheet__background-tertiary-
|
|
74
|
+
} .bottom-sheet__background-tertiary-inverted_ykuo8 {
|
|
75
75
|
background-color: var(--color-light-bg-tertiary-inverted);
|
|
76
|
-
} .bottom-sheet__background-
|
|
76
|
+
} .bottom-sheet__background-quaternary_ykuo8 {
|
|
77
77
|
background-color: var(--color-light-bg-quaternary);
|
|
78
|
-
} .bottom-sheet__background-quaternary-
|
|
78
|
+
} .bottom-sheet__background-quaternary-inverted_ykuo8 {
|
|
79
79
|
background-color: var(--color-light-bg-quaternary-inverted);
|
|
80
|
-
} .bottom-sheet__background-specialbg-
|
|
80
|
+
} .bottom-sheet__background-specialbg-component_ykuo8 {
|
|
81
81
|
background-color: var(--color-light-specialbg-component);
|
|
82
|
-
} .bottom-sheet__background-specialbg-component-
|
|
82
|
+
} .bottom-sheet__background-specialbg-component-inverted_ykuo8 {
|
|
83
83
|
background-color: var(--color-light-specialbg-component-inverted);
|
|
84
|
-
} .bottom-sheet__background-specialbg-primary-
|
|
84
|
+
} .bottom-sheet__background-specialbg-primary-grouped_ykuo8 {
|
|
85
85
|
background-color: var(--color-light-specialbg-primary-grouped);
|
|
86
|
-
} .bottom-sheet__background-specialbg-secondary-
|
|
86
|
+
} .bottom-sheet__background-specialbg-secondary-grouped_ykuo8 {
|
|
87
87
|
background-color: var(--color-light-specialbg-secondary-grouped);
|
|
88
|
-
} .bottom-sheet__background-specialbg-tertiary-
|
|
88
|
+
} .bottom-sheet__background-specialbg-tertiary-grouped_ykuo8 {
|
|
89
89
|
background-color: var(--color-light-specialbg-tertiary-grouped);
|
|
90
|
-
} .bottom-sheet__background-specialbg-secondary-
|
|
90
|
+
} .bottom-sheet__background-specialbg-secondary-transparent_ykuo8 {
|
|
91
91
|
background-color: var(--color-light-specialbg-secondary-transparent);
|
|
92
|
-
} .bottom-sheet__background-specialbg-secondary-transparent-
|
|
92
|
+
} .bottom-sheet__background-specialbg-secondary-transparent-inverted_ykuo8 {
|
|
93
93
|
background-color: var(--color-light-specialbg-secondary-transparent-inverted);
|
|
94
|
-
} .bottom-sheet__background-specialbg-tertiary-
|
|
94
|
+
} .bottom-sheet__background-specialbg-tertiary-transparent_ykuo8 {
|
|
95
95
|
background-color: var(--color-light-specialbg-tertiary-transparent);
|
|
96
|
-
} .bottom-sheet__background-specialbg-tertiary-transparent-
|
|
96
|
+
} .bottom-sheet__background-specialbg-tertiary-transparent-inverted_ykuo8 {
|
|
97
97
|
background-color: var(--color-light-specialbg-tertiary-transparent-inverted);
|
|
98
98
|
}
|
|
@@ -14,7 +14,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
14
14
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
15
15
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
16
16
|
|
|
17
|
-
var styles = {"headerWrapper":"bottom-
|
|
17
|
+
var styles = {"headerWrapper":"bottom-sheet__headerWrapper_1r713","hasContent":"bottom-sheet__hasContent_1r713","header":"bottom-sheet__header_1r713","sticky":"bottom-sheet__sticky_1r713","highlighted":"bottom-sheet__highlighted_1r713","justifyEnd":"bottom-sheet__justifyEnd_1r713","addon":"bottom-sheet__addon_1r713","addonFixed":"bottom-sheet__addonFixed_1r713","title":"bottom-sheet__title_1r713","titleCenter":"bottom-sheet__titleCenter_1r713","titleLeft":"bottom-sheet__titleLeft_1r713","trimTitle":"bottom-sheet__trimTitle_1r713"};
|
|
18
18
|
require('./index.css')
|
|
19
19
|
|
|
20
20
|
var Header = function (_a) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: gqfc1 */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-border-secondary: #e9e9eb; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
@@ -27,42 +27,42 @@
|
|
|
27
27
|
--bottom-sheet-title-font-weight: 700;
|
|
28
28
|
--bottom-sheet-title-line-height: 24px;
|
|
29
29
|
--bottom-sheet-title-font-family: var(--font-family-system);
|
|
30
|
-
} .bottom-
|
|
30
|
+
} .bottom-sheet__headerWrapper_1r713 {
|
|
31
31
|
padding: var(--gap-s) var(--gap-xs) var(--gap-2xs);
|
|
32
32
|
border-top-right-radius: var(--border-radius-xl);
|
|
33
33
|
border-top-left-radius: var(--border-radius-xl);
|
|
34
34
|
z-index: 1;
|
|
35
|
-
} .bottom-
|
|
35
|
+
} .bottom-sheet__hasContent_1r713 {
|
|
36
36
|
background-color: inherit;
|
|
37
|
-
} .bottom-
|
|
37
|
+
} .bottom-sheet__header_1r713 {
|
|
38
38
|
display: flex;
|
|
39
|
-
} .bottom-
|
|
39
|
+
} .bottom-sheet__sticky_1r713 {
|
|
40
40
|
position: sticky;
|
|
41
41
|
top: 0;
|
|
42
|
-
} .bottom-
|
|
42
|
+
} .bottom-sheet__highlighted_1r713 {
|
|
43
43
|
border-bottom: var(--bottom-sheet-header-border-bottom);
|
|
44
|
-
} .bottom-
|
|
44
|
+
} .bottom-sheet__justifyEnd_1r713 {
|
|
45
45
|
justify-content: flex-end;
|
|
46
|
-
} .bottom-
|
|
46
|
+
} .bottom-sheet__addon_1r713 {
|
|
47
47
|
display: flex;
|
|
48
48
|
justify-content: center;
|
|
49
49
|
align-items: center;
|
|
50
50
|
min-width: 48px;
|
|
51
51
|
height: 48px;
|
|
52
|
-
} .bottom-
|
|
52
|
+
} .bottom-sheet__addonFixed_1r713 {
|
|
53
53
|
position: fixed;
|
|
54
|
-
} .bottom-
|
|
54
|
+
} .bottom-sheet__title_1r713 {
|
|
55
55
|
padding: var(--gap-s) var(--gap-xs);
|
|
56
56
|
width: 100%;
|
|
57
57
|
font-size: var(--bottom-sheet-title-font-size);
|
|
58
58
|
font-weight: var(--bottom-sheet-title-font-weight);
|
|
59
59
|
line-height: var(--bottom-sheet-title-line-height);
|
|
60
60
|
font-family: var(--bottom-sheet-title-font-family);
|
|
61
|
-
} .bottom-
|
|
61
|
+
} .bottom-sheet__titleCenter_1r713 {
|
|
62
62
|
text-align: center;
|
|
63
|
-
} .bottom-
|
|
63
|
+
} .bottom-sheet__titleLeft_1r713 {
|
|
64
64
|
text-align: left;
|
|
65
|
-
} .bottom-
|
|
65
|
+
} .bottom-sheet__trimTitle_1r713 {
|
|
66
66
|
white-space: nowrap;
|
|
67
67
|
overflow: hidden;
|
|
68
68
|
text-overflow: ellipsis;
|
package/cssm/component.js
CHANGED
|
@@ -31,13 +31,13 @@ var getDataTestId = function (dataTestId, element) {
|
|
|
31
31
|
return dataTestId ? "".concat(dataTestId).concat(elementPart) : undefined;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
var isClient = function () { return typeof window !== 'undefined'; };
|
|
35
|
-
|
|
36
34
|
var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
37
35
|
var _b, _c, _d, _e;
|
|
38
|
-
var open = _a.open, title = _a.title, container = _a.container, backgroundColor = _a.backgroundColor, _f = _a.titleSize, titleSize = _f === void 0 ? 'default' : _f, 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, _g = _a.titleAlign, titleAlign = _g === void 0 ? 'left' : _g, trimTitle = _a.trimTitle, stickyHeader = _a.stickyHeader, _h = _a.stickyFooter, stickyFooter = _h === void 0 ? true : _h, _j = _a.initialHeight, initialHeight = _j === void 0 ? 'default' : _j, hideOverlay = _a.hideOverlay, hideScrollbar = _a.hideScrollbar, hideHeader = _a.hideHeader, disableOverlayClick = _a.disableOverlayClick, disableBlockingScroll = _a.disableBlockingScroll, children = _a.children, zIndex = _a.zIndex, _k = _a.transitionProps, transitionProps = _k === void 0 ? {} : _k, magneticAreasProp = _a.magneticAreas, initialActiveAreaIndex = _a.initialActiveAreaIndex, dataTestId = _a.dataTestId, _l = _a.swipeable, swipeable = _l === void 0 ? true : _l, scrollLockedProp = _a.scrollLocked, backdropProps = _a.backdropProps, _m = _a.scrollableContainerRef, scrollableContainerRef = _m === void 0 ? function () { return null; } : _m, bottomSheetInstanceRef = _a.bottomSheetInstanceRef, _o = _a.sheetContainerRef, sheetContainerRef = _o === void 0 ? function () { return null; } : _o, onClose = _a.onClose, onBack = _a.onBack, onMagnetize = _a.onMagnetize;
|
|
36
|
+
var open = _a.open, title = _a.title, container = _a.container, usePortal = _a.usePortal, backgroundColor = _a.backgroundColor, _f = _a.titleSize, titleSize = _f === void 0 ? 'default' : _f, 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, _g = _a.titleAlign, titleAlign = _g === void 0 ? 'left' : _g, trimTitle = _a.trimTitle, stickyHeader = _a.stickyHeader, _h = _a.stickyFooter, stickyFooter = _h === void 0 ? true : _h, _j = _a.initialHeight, initialHeight = _j === void 0 ? 'default' : _j, hideOverlay = _a.hideOverlay, hideScrollbar = _a.hideScrollbar, hideHeader = _a.hideHeader, disableOverlayClick = _a.disableOverlayClick, disableBlockingScroll = _a.disableBlockingScroll, children = _a.children, zIndex = _a.zIndex, _k = _a.transitionProps, transitionProps = _k === void 0 ? {} : _k, magneticAreasProp = _a.magneticAreas, initialActiveAreaIndex = _a.initialActiveAreaIndex, dataTestId = _a.dataTestId, _l = _a.swipeable, swipeable = _l === void 0 ? true : _l, scrollLockedProp = _a.scrollLocked, backdropProps = _a.backdropProps, _m = _a.scrollableContainerRef, scrollableContainerRef = _m === void 0 ? function () { return null; } : _m, bottomSheetInstanceRef = _a.bottomSheetInstanceRef, _o = _a.sheetContainerRef, sheetContainerRef = _o === void 0 ? function () { return null; } : _o, onClose = _a.onClose, onBack = _a.onBack, onMagnetize = _a.onMagnetize;
|
|
39
37
|
var hasInitialIdx = initialActiveAreaIndex !== undefined;
|
|
40
|
-
var fullHeight = reactDiv100vh.use100vh() ||
|
|
38
|
+
var fullHeight = reactDiv100vh.use100vh() || 0;
|
|
39
|
+
// Хук use100vh рассчитывает высоту вьюпорта в useEffect, поэтому на первый рендер всегда возвращает null.
|
|
40
|
+
var isFirstRender = fullHeight === 0;
|
|
41
41
|
var magneticAreas = React.useMemo(function () {
|
|
42
42
|
if (magneticAreasProp) {
|
|
43
43
|
return magneticAreasProp.map(function (area) { return utils.convertPercentToNumber(area, fullHeight); });
|
|
@@ -45,12 +45,10 @@ var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
|
45
45
|
return [0, fullHeight - utils.HEADER_OFFSET];
|
|
46
46
|
}, [fullHeight, magneticAreasProp]);
|
|
47
47
|
var lastMagneticArea = magneticAreas[magneticAreas.length - 1];
|
|
48
|
-
var _p = React.useState(
|
|
49
|
-
? lastMagneticArea - magneticAreas[initialActiveAreaIndex]
|
|
50
|
-
: magneticAreas[0]), sheetOffset = _p[0], setSheetOffset = _p[1];
|
|
48
|
+
var _p = React.useState(0), sheetOffset = _p[0], setSheetOffset = _p[1];
|
|
51
49
|
var _q = React.useState(1), backdropOpacity = _q[0], setBackdropOpacity = _q[1];
|
|
52
|
-
var _r = React.useState(
|
|
53
|
-
var swipingInProgress = React.useRef(
|
|
50
|
+
var _r = React.useState(0), activeArea = _r[0], setActiveArea = _r[1];
|
|
51
|
+
var swipingInProgress = React.useRef(null);
|
|
54
52
|
var headerRef = React.useRef(null);
|
|
55
53
|
var sheetHeight = React.useRef(0);
|
|
56
54
|
var sheetRef = React.useRef(null);
|
|
@@ -85,6 +83,7 @@ var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
|
85
83
|
}
|
|
86
84
|
};
|
|
87
85
|
var scrollToArea = function (idx) {
|
|
86
|
+
swipingInProgress.current = false;
|
|
88
87
|
var nextArea = magneticAreas[idx];
|
|
89
88
|
if (nextArea === 0) {
|
|
90
89
|
onClose();
|
|
@@ -224,10 +223,20 @@ var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
|
224
223
|
var handleEntered = function (node, isAppearing) {
|
|
225
224
|
setBackdropOpacity(1);
|
|
226
225
|
setSheetHeight();
|
|
226
|
+
// Ready for swiping
|
|
227
|
+
swipingInProgress.current = false;
|
|
227
228
|
if (transitionProps.onEntered) {
|
|
228
229
|
transitionProps.onEntered(node, isAppearing);
|
|
229
230
|
}
|
|
230
231
|
};
|
|
232
|
+
React.useEffect(function () {
|
|
233
|
+
// Инициализируем стейт только после того, как была рассчитана высота вьюпорта.
|
|
234
|
+
if (!isFirstRender) {
|
|
235
|
+
setSheetOffset(hasInitialIdx ? lastMagneticArea - magneticAreas[initialActiveAreaIndex] : 0);
|
|
236
|
+
setActiveArea(hasInitialIdx ? magneticAreas[initialActiveAreaIndex] : lastMagneticArea);
|
|
237
|
+
}
|
|
238
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
239
|
+
}, [isFirstRender]);
|
|
231
240
|
React.useEffect(function () {
|
|
232
241
|
onMagnetize === null || onMagnetize === void 0 ? void 0 : onMagnetize(open ? getActiveAreaIndex(activeArea) : 0);
|
|
233
242
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -235,20 +244,20 @@ var BottomSheet = React.forwardRef(function (_a, ref) {
|
|
|
235
244
|
React.useImperativeHandle(bottomSheetInstanceRef, function () { return ({
|
|
236
245
|
scrollToArea: scrollToArea,
|
|
237
246
|
}); });
|
|
238
|
-
var getSwipeStyles = function () {
|
|
239
|
-
|
|
240
|
-
}
|
|
247
|
+
var getSwipeStyles = function () {
|
|
248
|
+
return sheetOffset ? { transform: "translateY(".concat(sheetOffset, "px)") } : {};
|
|
249
|
+
};
|
|
241
250
|
var getHeightStyles = function () { return ({
|
|
242
|
-
height: initialHeight === 'full' ? "".concat(lastMagneticArea, "px") : 'unset',
|
|
243
|
-
maxHeight: "".concat(lastMagneticArea, "px"),
|
|
251
|
+
height: !isFirstRender && initialHeight === 'full' ? "".concat(lastMagneticArea, "px") : 'unset',
|
|
252
|
+
maxHeight: isFirstRender ? 0 : "".concat(lastMagneticArea, "px"),
|
|
244
253
|
}); };
|
|
245
254
|
var bgClassName = backgroundColor && styles__default.default["background-".concat(backgroundColor)];
|
|
246
|
-
return (React__default.default.createElement(coreComponentsBaseModal.BaseModal, { open: open, ref: ref, container: container, dataTestId: dataTestId, zIndex: zIndex, onClose: onClose, scrollHandler: scrollableContainer, Backdrop: components_swipeableBackdrop_Component.SwipeableBackdrop, backdropProps: tslib.__assign(tslib.__assign({}, backdropProps), { className: styles__default.default.disabledPointerEvents, opacity: backdropOpacity, opacityTimeout: utils.TIMEOUT, invisible: hideOverlay }), disableBackdropClick: hideOverlay ? true : disableOverlayClick, className: cn__default.default(styles__default.default.modal, modalClassName), wrapperClassName: cn__default.default(modalWrapperClassName, (_b = {},
|
|
255
|
+
return (React__default.default.createElement(coreComponentsBaseModal.BaseModal, { open: open, ref: ref, container: container, dataTestId: dataTestId, zIndex: zIndex, onClose: onClose, usePortal: usePortal, scrollHandler: scrollableContainer, Backdrop: components_swipeableBackdrop_Component.SwipeableBackdrop, backdropProps: tslib.__assign(tslib.__assign({}, backdropProps), { className: styles__default.default.disabledPointerEvents, opacity: backdropOpacity, opacityTimeout: utils.TIMEOUT, invisible: hideOverlay }), disableBackdropClick: hideOverlay ? true : disableOverlayClick, className: cn__default.default(styles__default.default.modal, modalClassName), wrapperClassName: cn__default.default(modalWrapperClassName, (_b = {},
|
|
247
256
|
_b[styles__default.default.disabledPointerEvents] = hideOverlay,
|
|
248
257
|
_b)), disableBlockingScroll: disableBlockingScroll, transitionProps: tslib.__assign(tslib.__assign({ appear: true, timeout: utils.TIMEOUT, classNames: styles__default.default }, transitionProps), { onExited: handleExited, onEntered: handleEntered }) },
|
|
249
258
|
React__default.default.createElement("div", { style: tslib.__assign({}, getHeightStyles()), className: styles__default.default.wrapper, onTransitionEnd: setSheetHeight },
|
|
250
259
|
React__default.default.createElement("div", tslib.__assign({ className: cn__default.default(styles__default.default.component, bgClassName, className, (_c = {},
|
|
251
|
-
_c[styles__default.default.withTransition] =
|
|
260
|
+
_c[styles__default.default.withTransition] = swipingInProgress.current === false,
|
|
252
261
|
_c)), style: tslib.__assign(tslib.__assign({}, getSwipeStyles()), getHeightStyles()) }, sheetSwipeableHandlers, { ref: mergeRefs__default.default([sheetRef, sheetContainerRef, sheetSwipeableHandlers.ref]), onTransitionEnd: setSheetHeight }),
|
|
253
262
|
React__default.default.createElement("div", tslib.__assign({}, containerProps, { className: cn__default.default(styles__default.default.scrollableContainer, containerProps === null || containerProps === void 0 ? void 0 : containerProps.className, containerClassName, (_d = {},
|
|
254
263
|
_d[styles__default.default.scrollLocked] = scrollLockedProp || swipingInProgress.current,
|
package/cssm/types.d.ts
CHANGED
|
@@ -36,6 +36,10 @@ type BottomSheetProps = {
|
|
|
36
36
|
* Контейнер к которому будут добавляться порталы
|
|
37
37
|
*/
|
|
38
38
|
container?: BaseModalProps['container'];
|
|
39
|
+
/**
|
|
40
|
+
* Рендерить ли в контейнер через портал.
|
|
41
|
+
*/
|
|
42
|
+
usePortal?: BaseModalProps['usePortal'];
|
|
39
43
|
/**
|
|
40
44
|
* Дополнительный класс
|
|
41
45
|
*/
|
package/esm/component.js
CHANGED
|
@@ -17,16 +17,16 @@ var getDataTestId = function (dataTestId, element) {
|
|
|
17
17
|
return dataTestId ? "".concat(dataTestId).concat(elementPart) : undefined;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
var styles = {"modal":"bottom-sheet__modal_8udi2","wrapper":"bottom-sheet__wrapper_8udi2","component":"bottom-sheet__component_8udi2","withTransition":"bottom-sheet__withTransition_8udi2","scrollableContainer":"bottom-sheet__scrollableContainer_8udi2","marker":"bottom-sheet__marker_8udi2","content":"bottom-sheet__content_8udi2","noHeader":"bottom-sheet__noHeader_8udi2","noFooter":"bottom-sheet__noFooter_8udi2","scrollLocked":"bottom-sheet__scrollLocked_8udi2","hiddenScrollbar":"bottom-sheet__hiddenScrollbar_8udi2","disabledPointerEvents":"bottom-sheet__disabledPointerEvents_8udi2","appear":"bottom-sheet__appear_8udi2","enter":"bottom-sheet__enter_8udi2","appearActive":"bottom-sheet__appearActive_8udi2","enterActive":"bottom-sheet__enterActive_8udi2","enterDone":"bottom-sheet__enterDone_8udi2","appearDone":"bottom-sheet__appearDone_8udi2","exit":"bottom-sheet__exit_8udi2","exitActive":"bottom-sheet__exitActive_8udi2","background-accent":"bottom-sheet__background-accent_8udi2","background-info":"bottom-sheet__background-info_8udi2","background-attention-muted":"bottom-sheet__background-attention-muted_8udi2","background-positive-muted":"bottom-sheet__background-positive-muted_8udi2","background-negative-muted":"bottom-sheet__background-negative-muted_8udi2","background-primary":"bottom-sheet__background-primary_8udi2","background-primary-inverted":"bottom-sheet__background-primary-inverted_8udi2","background-secondary":"bottom-sheet__background-secondary_8udi2","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_8udi2","background-tertiary":"bottom-sheet__background-tertiary_8udi2","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_8udi2","background-quaternary":"bottom-sheet__background-quaternary_8udi2","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_8udi2","background-specialbg-component":"bottom-sheet__background-specialbg-component_8udi2","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_8udi2","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_8udi2","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_8udi2","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_8udi2","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_8udi2","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_8udi2","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_8udi2","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_8udi2"};
|
|
20
|
+
var styles = {"modal":"bottom-sheet__modal_1gfwj","wrapper":"bottom-sheet__wrapper_1gfwj","component":"bottom-sheet__component_1gfwj","withTransition":"bottom-sheet__withTransition_1gfwj","scrollableContainer":"bottom-sheet__scrollableContainer_1gfwj","marker":"bottom-sheet__marker_1gfwj","content":"bottom-sheet__content_1gfwj","noHeader":"bottom-sheet__noHeader_1gfwj","noFooter":"bottom-sheet__noFooter_1gfwj","scrollLocked":"bottom-sheet__scrollLocked_1gfwj","hiddenScrollbar":"bottom-sheet__hiddenScrollbar_1gfwj","disabledPointerEvents":"bottom-sheet__disabledPointerEvents_1gfwj","appear":"bottom-sheet__appear_1gfwj","enter":"bottom-sheet__enter_1gfwj","appearActive":"bottom-sheet__appearActive_1gfwj","enterActive":"bottom-sheet__enterActive_1gfwj","enterDone":"bottom-sheet__enterDone_1gfwj","appearDone":"bottom-sheet__appearDone_1gfwj","exit":"bottom-sheet__exit_1gfwj","exitActive":"bottom-sheet__exitActive_1gfwj","background-accent":"bottom-sheet__background-accent_1gfwj","background-info":"bottom-sheet__background-info_1gfwj","background-attention-muted":"bottom-sheet__background-attention-muted_1gfwj","background-positive-muted":"bottom-sheet__background-positive-muted_1gfwj","background-negative-muted":"bottom-sheet__background-negative-muted_1gfwj","background-primary":"bottom-sheet__background-primary_1gfwj","background-primary-inverted":"bottom-sheet__background-primary-inverted_1gfwj","background-secondary":"bottom-sheet__background-secondary_1gfwj","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_1gfwj","background-tertiary":"bottom-sheet__background-tertiary_1gfwj","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_1gfwj","background-quaternary":"bottom-sheet__background-quaternary_1gfwj","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_1gfwj","background-specialbg-component":"bottom-sheet__background-specialbg-component_1gfwj","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_1gfwj","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_1gfwj","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_1gfwj","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_1gfwj","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_1gfwj","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_1gfwj","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_1gfwj","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_1gfwj"};
|
|
23
21
|
require('./index.css')
|
|
24
22
|
|
|
25
23
|
var BottomSheet = forwardRef(function (_a, ref) {
|
|
26
24
|
var _b, _c, _d, _e;
|
|
27
|
-
var open = _a.open, title = _a.title, container = _a.container, backgroundColor = _a.backgroundColor, _f = _a.titleSize, titleSize = _f === void 0 ? 'default' : _f, 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, _g = _a.titleAlign, titleAlign = _g === void 0 ? 'left' : _g, trimTitle = _a.trimTitle, stickyHeader = _a.stickyHeader, _h = _a.stickyFooter, stickyFooter = _h === void 0 ? true : _h, _j = _a.initialHeight, initialHeight = _j === void 0 ? 'default' : _j, hideOverlay = _a.hideOverlay, hideScrollbar = _a.hideScrollbar, hideHeader = _a.hideHeader, disableOverlayClick = _a.disableOverlayClick, disableBlockingScroll = _a.disableBlockingScroll, children = _a.children, zIndex = _a.zIndex, _k = _a.transitionProps, transitionProps = _k === void 0 ? {} : _k, magneticAreasProp = _a.magneticAreas, initialActiveAreaIndex = _a.initialActiveAreaIndex, dataTestId = _a.dataTestId, _l = _a.swipeable, swipeable = _l === void 0 ? true : _l, scrollLockedProp = _a.scrollLocked, backdropProps = _a.backdropProps, _m = _a.scrollableContainerRef, scrollableContainerRef = _m === void 0 ? function () { return null; } : _m, bottomSheetInstanceRef = _a.bottomSheetInstanceRef, _o = _a.sheetContainerRef, sheetContainerRef = _o === void 0 ? function () { return null; } : _o, onClose = _a.onClose, onBack = _a.onBack, onMagnetize = _a.onMagnetize;
|
|
25
|
+
var open = _a.open, title = _a.title, container = _a.container, usePortal = _a.usePortal, backgroundColor = _a.backgroundColor, _f = _a.titleSize, titleSize = _f === void 0 ? 'default' : _f, 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, _g = _a.titleAlign, titleAlign = _g === void 0 ? 'left' : _g, trimTitle = _a.trimTitle, stickyHeader = _a.stickyHeader, _h = _a.stickyFooter, stickyFooter = _h === void 0 ? true : _h, _j = _a.initialHeight, initialHeight = _j === void 0 ? 'default' : _j, hideOverlay = _a.hideOverlay, hideScrollbar = _a.hideScrollbar, hideHeader = _a.hideHeader, disableOverlayClick = _a.disableOverlayClick, disableBlockingScroll = _a.disableBlockingScroll, children = _a.children, zIndex = _a.zIndex, _k = _a.transitionProps, transitionProps = _k === void 0 ? {} : _k, magneticAreasProp = _a.magneticAreas, initialActiveAreaIndex = _a.initialActiveAreaIndex, dataTestId = _a.dataTestId, _l = _a.swipeable, swipeable = _l === void 0 ? true : _l, scrollLockedProp = _a.scrollLocked, backdropProps = _a.backdropProps, _m = _a.scrollableContainerRef, scrollableContainerRef = _m === void 0 ? function () { return null; } : _m, bottomSheetInstanceRef = _a.bottomSheetInstanceRef, _o = _a.sheetContainerRef, sheetContainerRef = _o === void 0 ? function () { return null; } : _o, onClose = _a.onClose, onBack = _a.onBack, onMagnetize = _a.onMagnetize;
|
|
28
26
|
var hasInitialIdx = initialActiveAreaIndex !== undefined;
|
|
29
|
-
var fullHeight = use100vh() ||
|
|
27
|
+
var fullHeight = use100vh() || 0;
|
|
28
|
+
// Хук use100vh рассчитывает высоту вьюпорта в useEffect, поэтому на первый рендер всегда возвращает null.
|
|
29
|
+
var isFirstRender = fullHeight === 0;
|
|
30
30
|
var magneticAreas = useMemo(function () {
|
|
31
31
|
if (magneticAreasProp) {
|
|
32
32
|
return magneticAreasProp.map(function (area) { return convertPercentToNumber(area, fullHeight); });
|
|
@@ -34,12 +34,10 @@ var BottomSheet = forwardRef(function (_a, ref) {
|
|
|
34
34
|
return [0, fullHeight - HEADER_OFFSET];
|
|
35
35
|
}, [fullHeight, magneticAreasProp]);
|
|
36
36
|
var lastMagneticArea = magneticAreas[magneticAreas.length - 1];
|
|
37
|
-
var _p = useState(
|
|
38
|
-
? lastMagneticArea - magneticAreas[initialActiveAreaIndex]
|
|
39
|
-
: magneticAreas[0]), sheetOffset = _p[0], setSheetOffset = _p[1];
|
|
37
|
+
var _p = useState(0), sheetOffset = _p[0], setSheetOffset = _p[1];
|
|
40
38
|
var _q = useState(1), backdropOpacity = _q[0], setBackdropOpacity = _q[1];
|
|
41
|
-
var _r = useState(
|
|
42
|
-
var swipingInProgress = useRef(
|
|
39
|
+
var _r = useState(0), activeArea = _r[0], setActiveArea = _r[1];
|
|
40
|
+
var swipingInProgress = useRef(null);
|
|
43
41
|
var headerRef = useRef(null);
|
|
44
42
|
var sheetHeight = useRef(0);
|
|
45
43
|
var sheetRef = useRef(null);
|
|
@@ -74,6 +72,7 @@ var BottomSheet = forwardRef(function (_a, ref) {
|
|
|
74
72
|
}
|
|
75
73
|
};
|
|
76
74
|
var scrollToArea = function (idx) {
|
|
75
|
+
swipingInProgress.current = false;
|
|
77
76
|
var nextArea = magneticAreas[idx];
|
|
78
77
|
if (nextArea === 0) {
|
|
79
78
|
onClose();
|
|
@@ -213,10 +212,20 @@ var BottomSheet = forwardRef(function (_a, ref) {
|
|
|
213
212
|
var handleEntered = function (node, isAppearing) {
|
|
214
213
|
setBackdropOpacity(1);
|
|
215
214
|
setSheetHeight();
|
|
215
|
+
// Ready for swiping
|
|
216
|
+
swipingInProgress.current = false;
|
|
216
217
|
if (transitionProps.onEntered) {
|
|
217
218
|
transitionProps.onEntered(node, isAppearing);
|
|
218
219
|
}
|
|
219
220
|
};
|
|
221
|
+
useEffect(function () {
|
|
222
|
+
// Инициализируем стейт только после того, как была рассчитана высота вьюпорта.
|
|
223
|
+
if (!isFirstRender) {
|
|
224
|
+
setSheetOffset(hasInitialIdx ? lastMagneticArea - magneticAreas[initialActiveAreaIndex] : 0);
|
|
225
|
+
setActiveArea(hasInitialIdx ? magneticAreas[initialActiveAreaIndex] : lastMagneticArea);
|
|
226
|
+
}
|
|
227
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
228
|
+
}, [isFirstRender]);
|
|
220
229
|
useEffect(function () {
|
|
221
230
|
onMagnetize === null || onMagnetize === void 0 ? void 0 : onMagnetize(open ? getActiveAreaIndex(activeArea) : 0);
|
|
222
231
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -224,20 +233,20 @@ var BottomSheet = forwardRef(function (_a, ref) {
|
|
|
224
233
|
useImperativeHandle(bottomSheetInstanceRef, function () { return ({
|
|
225
234
|
scrollToArea: scrollToArea,
|
|
226
235
|
}); });
|
|
227
|
-
var getSwipeStyles = function () {
|
|
228
|
-
|
|
229
|
-
}
|
|
236
|
+
var getSwipeStyles = function () {
|
|
237
|
+
return sheetOffset ? { transform: "translateY(".concat(sheetOffset, "px)") } : {};
|
|
238
|
+
};
|
|
230
239
|
var getHeightStyles = function () { return ({
|
|
231
|
-
height: initialHeight === 'full' ? "".concat(lastMagneticArea, "px") : 'unset',
|
|
232
|
-
maxHeight: "".concat(lastMagneticArea, "px"),
|
|
240
|
+
height: !isFirstRender && initialHeight === 'full' ? "".concat(lastMagneticArea, "px") : 'unset',
|
|
241
|
+
maxHeight: isFirstRender ? 0 : "".concat(lastMagneticArea, "px"),
|
|
233
242
|
}); };
|
|
234
243
|
var bgClassName = backgroundColor && styles["background-".concat(backgroundColor)];
|
|
235
|
-
return (React.createElement(BaseModal, { open: open, ref: ref, container: container, dataTestId: dataTestId, zIndex: zIndex, onClose: onClose, scrollHandler: scrollableContainer, Backdrop: SwipeableBackdrop, backdropProps: __assign(__assign({}, backdropProps), { className: styles.disabledPointerEvents, opacity: backdropOpacity, opacityTimeout: TIMEOUT, invisible: hideOverlay }), disableBackdropClick: hideOverlay ? true : disableOverlayClick, className: cn(styles.modal, modalClassName), wrapperClassName: cn(modalWrapperClassName, (_b = {},
|
|
244
|
+
return (React.createElement(BaseModal, { open: open, ref: ref, container: container, dataTestId: dataTestId, zIndex: zIndex, onClose: onClose, usePortal: usePortal, scrollHandler: scrollableContainer, Backdrop: SwipeableBackdrop, backdropProps: __assign(__assign({}, backdropProps), { className: styles.disabledPointerEvents, opacity: backdropOpacity, opacityTimeout: TIMEOUT, invisible: hideOverlay }), disableBackdropClick: hideOverlay ? true : disableOverlayClick, className: cn(styles.modal, modalClassName), wrapperClassName: cn(modalWrapperClassName, (_b = {},
|
|
236
245
|
_b[styles.disabledPointerEvents] = hideOverlay,
|
|
237
246
|
_b)), disableBlockingScroll: disableBlockingScroll, transitionProps: __assign(__assign({ appear: true, timeout: TIMEOUT, classNames: styles }, transitionProps), { onExited: handleExited, onEntered: handleEntered }) },
|
|
238
247
|
React.createElement("div", { style: __assign({}, getHeightStyles()), className: styles.wrapper, onTransitionEnd: setSheetHeight },
|
|
239
248
|
React.createElement("div", __assign({ className: cn(styles.component, bgClassName, className, (_c = {},
|
|
240
|
-
_c[styles.withTransition] =
|
|
249
|
+
_c[styles.withTransition] = swipingInProgress.current === false,
|
|
241
250
|
_c)), style: __assign(__assign({}, getSwipeStyles()), getHeightStyles()) }, sheetSwipeableHandlers, { ref: mergeRefs([sheetRef, sheetContainerRef, sheetSwipeableHandlers.ref]), onTransitionEnd: setSheetHeight }),
|
|
242
251
|
React.createElement("div", __assign({}, containerProps, { className: cn(styles.scrollableContainer, containerProps === null || containerProps === void 0 ? void 0 : containerProps.className, containerClassName, (_d = {},
|
|
243
252
|
_d[styles.scrollLocked] = scrollLockedProp || swipingInProgress.current,
|
|
@@ -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_ykuo8","sticky":"bottom-sheet__sticky_ykuo8","highlighted":"bottom-sheet__highlighted_ykuo8","background-accent":"bottom-sheet__background-accent_ykuo8","background-info":"bottom-sheet__background-info_ykuo8","background-attention-muted":"bottom-sheet__background-attention-muted_ykuo8","background-positive-muted":"bottom-sheet__background-positive-muted_ykuo8","background-negative-muted":"bottom-sheet__background-negative-muted_ykuo8","background-primary":"bottom-sheet__background-primary_ykuo8","background-primary-inverted":"bottom-sheet__background-primary-inverted_ykuo8","background-secondary":"bottom-sheet__background-secondary_ykuo8","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_ykuo8","background-tertiary":"bottom-sheet__background-tertiary_ykuo8","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_ykuo8","background-quaternary":"bottom-sheet__background-quaternary_ykuo8","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_ykuo8","background-specialbg-component":"bottom-sheet__background-specialbg-component_ykuo8","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_ykuo8","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_ykuo8","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_ykuo8","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_ykuo8","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_ykuo8","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_ykuo8","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_ykuo8","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_ykuo8"};
|
|
6
6
|
require('./index.css')
|
|
7
7
|
|
|
8
8
|
var Footer = function (_a) {
|