@alfalab/core-components-bottom-sheet 6.1.0 → 6.2.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.
Files changed (62) hide show
  1. package/component.d.ts +5 -0
  2. package/component.js +256 -13
  3. package/components/footer/Component.js +1 -1
  4. package/components/footer/index.css +26 -26
  5. package/components/header/Component.d.ts +7 -0
  6. package/components/header/Component.js +31 -13
  7. package/components/header/index.css +13 -13
  8. package/components/swipeable-backdrop/Component.d.ts +1 -1
  9. package/cssm/component.d.ts +5 -0
  10. package/cssm/component.js +256 -15
  11. package/cssm/components/header/Component.d.ts +7 -0
  12. package/cssm/components/header/Component.js +30 -16
  13. package/cssm/components/swipeable-backdrop/Component.d.ts +1 -1
  14. package/cssm/index.d.ts +3 -1
  15. package/cssm/index.js +7 -5
  16. package/cssm/index.module.css +23 -10
  17. package/{component-b5d23e5e.d.ts → cssm/types.d.ts} +36 -15
  18. package/cssm/types.js +2 -0
  19. package/cssm/utils.d.ts +8 -0
  20. package/cssm/utils.js +33 -0
  21. package/esm/component.d.ts +5 -0
  22. package/esm/component.js +253 -10
  23. package/esm/components/footer/Component.js +1 -1
  24. package/esm/components/footer/index.css +26 -26
  25. package/esm/components/header/Component.d.ts +7 -0
  26. package/esm/components/header/Component.js +29 -12
  27. package/esm/components/header/index.css +13 -13
  28. package/esm/components/swipeable-backdrop/Component.d.ts +1 -1
  29. package/esm/index.css +55 -42
  30. package/esm/index.d.ts +3 -1
  31. package/esm/index.js +3 -1
  32. package/esm/{component-612e671f.d.ts → types.d.ts} +36 -15
  33. package/esm/types.js +1 -0
  34. package/esm/utils.d.ts +8 -0
  35. package/esm/utils.js +23 -0
  36. package/index.css +55 -42
  37. package/index.d.ts +3 -1
  38. package/index.js +6 -4
  39. package/modern/component.d.ts +5 -0
  40. package/modern/component.js +284 -9
  41. package/modern/components/footer/Component.js +1 -1
  42. package/modern/components/footer/index.css +26 -26
  43. package/modern/components/header/Component.d.ts +7 -0
  44. package/modern/components/header/Component.js +26 -11
  45. package/modern/components/header/index.css +13 -13
  46. package/modern/components/swipeable-backdrop/Component.d.ts +1 -1
  47. package/modern/index.css +55 -42
  48. package/modern/index.d.ts +3 -1
  49. package/modern/index.js +3 -1
  50. package/{cssm/component-517950e0.d.ts → modern/types.d.ts} +36 -15
  51. package/modern/types.js +1 -0
  52. package/modern/utils.d.ts +8 -0
  53. package/modern/utils.js +23 -0
  54. package/package.json +5 -5
  55. package/{modern/component-1cd1bc34.d.ts → types.d.ts} +36 -15
  56. package/types.js +2 -0
  57. package/utils.d.ts +8 -0
  58. package/utils.js +33 -0
  59. package/component-b5d23e5e.js +0 -204
  60. package/cssm/component-517950e0.js +0 -202
  61. package/esm/component-612e671f.js +0 -193
  62. package/modern/component-1cd1bc34.js +0 -221
package/component.d.ts CHANGED
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { BottomSheetProps } from "./types";
4
+ declare const BottomSheet: React.ForwardRefExoticComponent<BottomSheetProps & React.RefAttributes<HTMLDivElement>>;
5
+ export { BottomSheet };
package/component.js CHANGED
@@ -2,21 +2,264 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- require('tslib');
6
- require('react');
7
- require('react-div-100vh');
8
- require('react-merge-refs');
9
- require('react-swipeable');
10
- require('classnames');
11
- require('@alfalab/core-components-base-modal');
12
- var components_header_Component = require('./component-b5d23e5e.js');
13
- require('./components/footer/Component.js');
14
- require('./components/swipeable-backdrop/Component.js');
5
+ var tslib = require('tslib');
6
+ var React = require('react');
7
+ var reactDiv100vh = require('react-div-100vh');
8
+ var mergeRefs = require('react-merge-refs');
9
+ var reactSwipeable = require('react-swipeable');
10
+ var cn = require('classnames');
11
+ var coreComponentsBaseModal = require('@alfalab/core-components-base-modal');
12
+ var components_footer_Component = require('./components/footer/Component.js');
13
+ var components_header_Component = require('./components/header/Component.js');
14
+ var components_swipeableBackdrop_Component = require('./components/swipeable-backdrop/Component.js');
15
+ var utils = require('./utils.js');
15
16
  require('@alfalab/core-components-navigation-bar');
16
17
  require('@alfalab/core-components-backdrop');
17
18
 
19
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
18
20
 
21
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
22
+ var mergeRefs__default = /*#__PURE__*/_interopDefaultCompat(mergeRefs);
23
+ var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
19
24
 
20
- exports.BottomSheet = components_header_Component.BottomSheet;
21
- exports.CLOSE_OFFSET = components_header_Component.CLOSE_OFFSET;
22
- exports.HEADER_OFFSET = components_header_Component.HEADER_OFFSET;
25
+ var getDataTestId = function (dataTestId, element) {
26
+ var elementPart = element ? "-".concat(element.toLowerCase()) : '';
27
+ return dataTestId ? "".concat(dataTestId).concat(elementPart) : undefined;
28
+ };
29
+
30
+ var isClient = function () { return typeof window !== 'undefined'; };
31
+
32
+ var styles = {"modal":"bottom-sheet__modal_6ikry","wrapper":"bottom-sheet__wrapper_6ikry","component":"bottom-sheet__component_6ikry","withTransition":"bottom-sheet__withTransition_6ikry","scrollableContainer":"bottom-sheet__scrollableContainer_6ikry","marker":"bottom-sheet__marker_6ikry","content":"bottom-sheet__content_6ikry","noHeader":"bottom-sheet__noHeader_6ikry","noFooter":"bottom-sheet__noFooter_6ikry","scrollLocked":"bottom-sheet__scrollLocked_6ikry","hiddenScrollbar":"bottom-sheet__hiddenScrollbar_6ikry","disabledPointerEvents":"bottom-sheet__disabledPointerEvents_6ikry","appear":"bottom-sheet__appear_6ikry","enter":"bottom-sheet__enter_6ikry","appearActive":"bottom-sheet__appearActive_6ikry","enterActive":"bottom-sheet__enterActive_6ikry","enterDone":"bottom-sheet__enterDone_6ikry","appearDone":"bottom-sheet__appearDone_6ikry","exit":"bottom-sheet__exit_6ikry","exitActive":"bottom-sheet__exitActive_6ikry","background-accent":"bottom-sheet__background-accent_6ikry","background-info":"bottom-sheet__background-info_6ikry","background-attention-muted":"bottom-sheet__background-attention-muted_6ikry","background-positive-muted":"bottom-sheet__background-positive-muted_6ikry","background-negative-muted":"bottom-sheet__background-negative-muted_6ikry","background-primary":"bottom-sheet__background-primary_6ikry","background-primary-inverted":"bottom-sheet__background-primary-inverted_6ikry","background-secondary":"bottom-sheet__background-secondary_6ikry","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_6ikry","background-tertiary":"bottom-sheet__background-tertiary_6ikry","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_6ikry","background-quaternary":"bottom-sheet__background-quaternary_6ikry","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_6ikry","background-specialbg-component":"bottom-sheet__background-specialbg-component_6ikry","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_6ikry","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_6ikry","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_6ikry","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_6ikry","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_6ikry","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_6ikry","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_6ikry","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_6ikry"};
33
+ require('./index.css')
34
+
35
+ var BottomSheet = React.forwardRef(function (_a, ref) {
36
+ 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;
38
+ var hasInitialIdx = initialActiveAreaIndex !== undefined;
39
+ var fullHeight = reactDiv100vh.use100vh() || isClient() ? window.innerHeight : 0;
40
+ var magneticAreas = React.useMemo(function () {
41
+ if (magneticAreasProp) {
42
+ return magneticAreasProp.map(function (area) { return utils.convertPercentToNumber(area, fullHeight); });
43
+ }
44
+ return [0, fullHeight - utils.HEADER_OFFSET];
45
+ }, [fullHeight, magneticAreasProp]);
46
+ var lastMagneticArea = magneticAreas[magneticAreas.length - 1];
47
+ var _p = React.useState(hasInitialIdx
48
+ ? lastMagneticArea - magneticAreas[initialActiveAreaIndex]
49
+ : magneticAreas[0]), sheetOffset = _p[0], setSheetOffset = _p[1];
50
+ var _q = React.useState(1), backdropOpacity = _q[0], setBackdropOpacity = _q[1];
51
+ var _r = React.useState(hasInitialIdx ? magneticAreas[initialActiveAreaIndex] : lastMagneticArea), activeArea = _r[0], setActiveArea = _r[1];
52
+ var swipingInProgress = React.useRef(false);
53
+ var headerRef = React.useRef(null);
54
+ var sheetHeight = React.useRef(0);
55
+ var sheetRef = React.useRef(null);
56
+ var scrollableContainer = React.useRef(null);
57
+ var emptyHeader = !hasCloser && !leftAddons && !title && !hasBacker && !rightAddons;
58
+ var titleIsReactElement = React__default.default.isValidElement(title);
59
+ var headerProps = tslib.__assign(tslib.__assign({}, (titleIsReactElement
60
+ ? { children: title }
61
+ : { title: title ? title === null || title === void 0 ? void 0 : title.toString() : undefined })), { scrollableParentRef: scrollableContainer, headerRef: headerRef, className: headerClassName, addonClassName: addonClassName, closerClassName: closerClassName, backButtonClassName: backerClassName, leftAddons: leftAddons, rightAddons: rightAddons, bottomAddons: bottomAddons, hasCloser: hasCloser, hasBackButton: hasBacker, align: titleAlign, trim: trimTitle, sticky: stickyHeader, dataTestId: getDataTestId(dataTestId, 'header'), onBack: onBack, titleSize: titleSize, subtitle: subtitle, onClose: onClose });
62
+ var getBackdropOpacity = function (offset) {
63
+ var canClose = magneticAreas[0] === 0;
64
+ var secondArea = magneticAreas[1];
65
+ var isSecondArea = secondArea === activeArea;
66
+ if (canClose && isSecondArea && sheetOffset > lastMagneticArea - secondArea) {
67
+ var opacity = 1 - (offset - (lastMagneticArea - secondArea)) / secondArea;
68
+ return Math.max(0, Number(opacity.toFixed(2)));
69
+ }
70
+ return 1;
71
+ };
72
+ var getSheetOffset = function (deltaY) {
73
+ var offset = lastMagneticArea - activeArea + deltaY;
74
+ var maxOffset = magneticAreas[0] === 0 ? 0 : lastMagneticArea - magneticAreas[0];
75
+ if (maxOffset) {
76
+ offset = Math.min(maxOffset, offset);
77
+ }
78
+ return Math.max(0, Math.round(offset));
79
+ };
80
+ var getActiveAreaIndex = function (area) { return magneticAreas.findIndex(function (a) { return a === area; }); };
81
+ var setSheetHeight = function () {
82
+ if (sheetRef.current) {
83
+ sheetHeight.current = sheetRef.current.getBoundingClientRect().height - sheetOffset;
84
+ }
85
+ };
86
+ var scrollToArea = function (idx) {
87
+ var nextArea = magneticAreas[idx];
88
+ if (nextArea === 0) {
89
+ onClose();
90
+ return;
91
+ }
92
+ if (nextArea) {
93
+ setActiveArea(nextArea);
94
+ setSheetOffset(lastMagneticArea - nextArea);
95
+ }
96
+ };
97
+ var magnetize = function (dir, velocity, deltaY) {
98
+ var shouldMagnetizeDownByVelocity = dir === 'Down' && velocity >= utils.SWIPE_VELOCITY;
99
+ var shouldMagnetizeUpByVelocity = dir === 'Up' && velocity >= utils.SWIPE_VELOCITY;
100
+ if (shouldMagnetizeDownByVelocity) {
101
+ var nextArea_1 = magneticAreas
102
+ .slice()
103
+ .reverse()
104
+ .find(function (area) { return area < activeArea; });
105
+ if (nextArea_1 === 0) {
106
+ onClose();
107
+ return;
108
+ }
109
+ var offset_1 = nextArea_1
110
+ ? lastMagneticArea - nextArea_1
111
+ : lastMagneticArea - activeArea;
112
+ setSheetOffset(offset_1);
113
+ setActiveArea(function (prevState) { return nextArea_1 !== null && nextArea_1 !== void 0 ? nextArea_1 : prevState; });
114
+ return;
115
+ }
116
+ if (shouldMagnetizeUpByVelocity) {
117
+ var nextArea_2 = magneticAreas.find(function (area) { return area > activeArea; });
118
+ var offset_2 = nextArea_2 ? lastMagneticArea - nextArea_2 : 0;
119
+ setSheetOffset(offset_2);
120
+ setActiveArea(function (prevState) { return nextArea_2 !== null && nextArea_2 !== void 0 ? nextArea_2 : prevState; });
121
+ return;
122
+ }
123
+ var offset = getSheetOffset(deltaY);
124
+ var currentSheetHeight = lastMagneticArea - offset;
125
+ var secondArea = magneticAreas[1];
126
+ var isSecondArea = activeArea === secondArea;
127
+ var canClose = magneticAreas[0] === 0 && dir === 'Down';
128
+ var shouldCloseByOffset = isSecondArea && canClose && 1 - currentSheetHeight / activeArea > utils.CLOSE_OFFSET;
129
+ if (shouldCloseByOffset) {
130
+ onClose();
131
+ return;
132
+ }
133
+ var nearestArea = magneticAreas.reduceRight(function (res, area) {
134
+ if (Math.abs(area - currentSheetHeight) < res.minOffset) {
135
+ res.minOffset = area - currentSheetHeight;
136
+ res.nearestArea = area;
137
+ }
138
+ return res;
139
+ }, {
140
+ nearestArea: lastMagneticArea,
141
+ minOffset: lastMagneticArea,
142
+ }).nearestArea;
143
+ if (nearestArea === 0) {
144
+ onClose();
145
+ }
146
+ else {
147
+ setSheetOffset(lastMagneticArea - nearestArea);
148
+ setActiveArea(nearestArea);
149
+ setBackdropOpacity(1);
150
+ }
151
+ };
152
+ /**
153
+ * Если контент внутри шторки скроллится - то шторка не должна свайпаться
154
+ * Если шапка внутри шторки зафиксирована - то шторка должна свайпаться только в области шапки
155
+ */
156
+ var shouldSkipSwiping = function (dir, startY) {
157
+ if (!swipeable)
158
+ return true;
159
+ if (scrollLockedProp || swipingInProgress.current)
160
+ return false;
161
+ var scrollableNode = scrollableContainer.current;
162
+ // Точка верхней границы (y координата)
163
+ var bottomSheetTopY = fullHeight - sheetHeight.current;
164
+ if (!scrollableNode ||
165
+ (!stickyHeader && Math.abs(bottomSheetTopY - startY) <= utils.MARKER_HEIGHT) ||
166
+ (stickyHeader &&
167
+ headerRef.current &&
168
+ Math.abs(bottomSheetTopY - startY) <= headerRef.current.clientHeight)) {
169
+ return false;
170
+ }
171
+ return dir === 'Down'
172
+ ? scrollableNode.scrollTop > 0
173
+ : scrollableNode.scrollHeight -
174
+ scrollableNode.scrollTop -
175
+ scrollableNode.clientHeight >
176
+ utils.SCROLL_OFFSET;
177
+ };
178
+ var handleSheetSwipe = function (_a) {
179
+ var dir = _a.dir, initial = _a.initial, velocity = _a.velocity, deltaY = _a.deltaY;
180
+ if (shouldSkipSwiping(dir, initial[1])) {
181
+ return;
182
+ }
183
+ magnetize(dir, velocity, deltaY);
184
+ };
185
+ var handleSheetSwipeStart = function (_a) {
186
+ var dir = _a.dir, initial = _a.initial;
187
+ if (shouldSkipSwiping(dir, initial[1])) {
188
+ return;
189
+ }
190
+ swipingInProgress.current = true;
191
+ };
192
+ var handleSheetSwiped = function () {
193
+ swipingInProgress.current = false;
194
+ };
195
+ var handleSheetSwiping = function (_a) {
196
+ var initial = _a.initial, deltaY = _a.deltaY, dir = _a.dir;
197
+ if (shouldSkipSwiping(dir, initial[1])) {
198
+ return;
199
+ }
200
+ var offset = getSheetOffset(deltaY);
201
+ var opacity = getBackdropOpacity(offset);
202
+ setSheetOffset(offset);
203
+ setBackdropOpacity(opacity);
204
+ };
205
+ var sheetSwipeableHandlers = reactSwipeable.useSwipeable({
206
+ onSwipeStart: handleSheetSwipeStart,
207
+ onSwiping: handleSheetSwiping,
208
+ onSwipedDown: handleSheetSwipe,
209
+ onSwipedUp: handleSheetSwipe,
210
+ onSwiped: handleSheetSwiped,
211
+ trackMouse: swipeable,
212
+ delta: 5,
213
+ });
214
+ var handleExited = function (node) {
215
+ var idx = initialActiveAreaIndex;
216
+ setBackdropOpacity(1);
217
+ setSheetOffset(hasInitialIdx ? lastMagneticArea - magneticAreas[idx] : magneticAreas[0]);
218
+ setActiveArea(hasInitialIdx ? magneticAreas[idx] : lastMagneticArea);
219
+ if (transitionProps.onExited) {
220
+ transitionProps.onExited(node);
221
+ }
222
+ };
223
+ var handleEntered = function (node, isAppearing) {
224
+ setBackdropOpacity(1);
225
+ setSheetHeight();
226
+ if (transitionProps.onEntered) {
227
+ transitionProps.onEntered(node, isAppearing);
228
+ }
229
+ };
230
+ React.useEffect(function () {
231
+ onMagnetize === null || onMagnetize === void 0 ? void 0 : onMagnetize(open ? getActiveAreaIndex(activeArea) : 0);
232
+ // eslint-disable-next-line react-hooks/exhaustive-deps
233
+ }, [activeArea, open]);
234
+ React.useImperativeHandle(bottomSheetInstanceRef, function () { return ({
235
+ scrollToArea: scrollToArea,
236
+ }); });
237
+ var getSwipeStyles = function () { return ({
238
+ transform: sheetOffset ? "translateY(".concat(sheetOffset, "px)") : '',
239
+ }); };
240
+ var getHeightStyles = function () { return ({
241
+ height: initialHeight === 'full' ? "".concat(lastMagneticArea, "px") : 'unset',
242
+ maxHeight: "".concat(lastMagneticArea, "px"),
243
+ }); };
244
+ 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 = {},
246
+ _b[styles.disabledPointerEvents] = hideOverlay,
247
+ _b)), disableBlockingScroll: disableBlockingScroll, transitionProps: tslib.__assign(tslib.__assign({ appear: true, timeout: utils.TIMEOUT, classNames: styles }, transitionProps), { onExited: handleExited, onEntered: handleEntered }) },
248
+ React__default.default.createElement("div", { style: tslib.__assign({}, getHeightStyles()), className: styles.wrapper, onTransitionEnd: setSheetHeight },
249
+ React__default.default.createElement("div", tslib.__assign({ className: cn__default.default(styles.component, bgClassName, className, (_c = {},
250
+ _c[styles.withTransition] = !swipingInProgress.current,
251
+ _c)), style: tslib.__assign(tslib.__assign({}, getSwipeStyles()), getHeightStyles()) }, sheetSwipeableHandlers, { ref: mergeRefs__default.default([sheetRef, sheetContainerRef, sheetSwipeableHandlers.ref]), onTransitionEnd: setSheetHeight }),
252
+ 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
+ _d[styles.scrollLocked] = scrollLockedProp || swipingInProgress.current,
254
+ _d[styles.hiddenScrollbar] = hideScrollbar,
255
+ _d)), ref: mergeRefs__default.default([scrollableContainer, scrollableContainerRef]) }),
256
+ swipeable && React__default.default.createElement("div", { className: cn__default.default(styles.marker) }),
257
+ !hideHeader && !emptyHeader && React__default.default.createElement(components_header_Component.Header, tslib.__assign({}, headerProps)),
258
+ React__default.default.createElement("div", { className: cn__default.default(styles.content, contentClassName, (_e = {},
259
+ _e[styles.noHeader] = hideHeader || emptyHeader,
260
+ _e[styles.noFooter] = !actionButton,
261
+ _e)) }, children),
262
+ actionButton && (React__default.default.createElement(components_footer_Component.Footer, { sticky: stickyFooter, className: cn__default.default(bgClassName, footerClassName) }, actionButton)))))));
263
+ });
264
+
265
+ exports.BottomSheet = BottomSheet;
@@ -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-sheet__footer_7gxws","sticky":"bottom-sheet__sticky_7gxws","highlighted":"bottom-sheet__highlighted_7gxws","background-accent":"bottom-sheet__background-accent_7gxws","background-info":"bottom-sheet__background-info_7gxws","background-attention-muted":"bottom-sheet__background-attention-muted_7gxws","background-positive-muted":"bottom-sheet__background-positive-muted_7gxws","background-negative-muted":"bottom-sheet__background-negative-muted_7gxws","background-primary":"bottom-sheet__background-primary_7gxws","background-primary-inverted":"bottom-sheet__background-primary-inverted_7gxws","background-secondary":"bottom-sheet__background-secondary_7gxws","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_7gxws","background-tertiary":"bottom-sheet__background-tertiary_7gxws","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_7gxws","background-quaternary":"bottom-sheet__background-quaternary_7gxws","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_7gxws","background-specialbg-component":"bottom-sheet__background-specialbg-component_7gxws","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_7gxws","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_7gxws","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_7gxws","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_7gxws","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_7gxws","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_7gxws","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_7gxws","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_7gxws"};
14
+ var styles = {"footer":"bottom-sheet__footer_w482m","sticky":"bottom-sheet__sticky_w482m","highlighted":"bottom-sheet__highlighted_w482m","background-accent":"bottom-sheet__background-accent_w482m","background-info":"bottom-sheet__background-info_w482m","background-attention-muted":"bottom-sheet__background-attention-muted_w482m","background-positive-muted":"bottom-sheet__background-positive-muted_w482m","background-negative-muted":"bottom-sheet__background-negative-muted_w482m","background-primary":"bottom-sheet__background-primary_w482m","background-primary-inverted":"bottom-sheet__background-primary-inverted_w482m","background-secondary":"bottom-sheet__background-secondary_w482m","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_w482m","background-tertiary":"bottom-sheet__background-tertiary_w482m","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_w482m","background-quaternary":"bottom-sheet__background-quaternary_w482m","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_w482m","background-specialbg-component":"bottom-sheet__background-specialbg-component_w482m","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_w482m","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_w482m","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_w482m","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_w482m","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_w482m","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_w482m","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_w482m","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_w482m"};
15
15
  require('./index.css')
16
16
 
17
17
  var Footer = function (_a) {
@@ -1,4 +1,4 @@
1
- /* hash: 1nw41 */
1
+ /* hash: xwbh9 */
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-sheet__footer_7gxws {
44
+ } .bottom-sheet__footer_w482m {
45
45
  padding: var(--gap-m) var(--gap-m);
46
46
  background-color: var(--color-light-bg-primary);
47
- } .bottom-sheet__sticky_7gxws {
47
+ } .bottom-sheet__sticky_w482m {
48
48
  position: sticky;
49
49
  bottom: 0;
50
50
  z-index: 1;
51
- } .bottom-sheet__highlighted_7gxws {
51
+ } .bottom-sheet__highlighted_w482m {
52
52
  border-top: var(--bottom-sheet-footer-border-top);
53
53
  background-color: var(--bottom-sheet-footer-background-color);
54
- } .bottom-sheet__background-accent_7gxws {
54
+ } .bottom-sheet__background-accent_w482m {
55
55
  background-color: var(--color-light-bg-accent);
56
- } .bottom-sheet__background-info_7gxws {
56
+ } .bottom-sheet__background-info_w482m {
57
57
  background-color: var(--color-light-bg-info);
58
- } .bottom-sheet__background-attention-muted_7gxws {
58
+ } .bottom-sheet__background-attention-muted_w482m {
59
59
  background-color: var(--color-light-bg-attention-muted);
60
- } .bottom-sheet__background-positive-muted_7gxws {
60
+ } .bottom-sheet__background-positive-muted_w482m {
61
61
  background-color: var(--color-light-bg-positive-muted);
62
- } .bottom-sheet__background-negative-muted_7gxws {
62
+ } .bottom-sheet__background-negative-muted_w482m {
63
63
  background-color: var(--color-light-bg-negative-muted);
64
- } .bottom-sheet__background-primary_7gxws {
64
+ } .bottom-sheet__background-primary_w482m {
65
65
  background-color: var(--color-light-bg-primary);
66
- } .bottom-sheet__background-primary-inverted_7gxws {
66
+ } .bottom-sheet__background-primary-inverted_w482m {
67
67
  background-color: var(--color-light-bg-primary-inverted);
68
- } .bottom-sheet__background-secondary_7gxws {
68
+ } .bottom-sheet__background-secondary_w482m {
69
69
  background-color: var(--color-light-bg-secondary);
70
- } .bottom-sheet__background-secondary-inverted_7gxws {
70
+ } .bottom-sheet__background-secondary-inverted_w482m {
71
71
  background-color: var(--color-light-bg-secondary-inverted);
72
- } .bottom-sheet__background-tertiary_7gxws {
72
+ } .bottom-sheet__background-tertiary_w482m {
73
73
  background-color: var(--color-light-bg-tertiary);
74
- } .bottom-sheet__background-tertiary-inverted_7gxws {
74
+ } .bottom-sheet__background-tertiary-inverted_w482m {
75
75
  background-color: var(--color-light-bg-tertiary-inverted);
76
- } .bottom-sheet__background-quaternary_7gxws {
76
+ } .bottom-sheet__background-quaternary_w482m {
77
77
  background-color: var(--color-light-bg-quaternary);
78
- } .bottom-sheet__background-quaternary-inverted_7gxws {
78
+ } .bottom-sheet__background-quaternary-inverted_w482m {
79
79
  background-color: var(--color-light-bg-quaternary-inverted);
80
- } .bottom-sheet__background-specialbg-component_7gxws {
80
+ } .bottom-sheet__background-specialbg-component_w482m {
81
81
  background-color: var(--color-light-specialbg-component);
82
- } .bottom-sheet__background-specialbg-component-inverted_7gxws {
82
+ } .bottom-sheet__background-specialbg-component-inverted_w482m {
83
83
  background-color: var(--color-light-specialbg-component-inverted);
84
- } .bottom-sheet__background-specialbg-primary-grouped_7gxws {
84
+ } .bottom-sheet__background-specialbg-primary-grouped_w482m {
85
85
  background-color: var(--color-light-specialbg-primary-grouped);
86
- } .bottom-sheet__background-specialbg-secondary-grouped_7gxws {
86
+ } .bottom-sheet__background-specialbg-secondary-grouped_w482m {
87
87
  background-color: var(--color-light-specialbg-secondary-grouped);
88
- } .bottom-sheet__background-specialbg-tertiary-grouped_7gxws {
88
+ } .bottom-sheet__background-specialbg-tertiary-grouped_w482m {
89
89
  background-color: var(--color-light-specialbg-tertiary-grouped);
90
- } .bottom-sheet__background-specialbg-secondary-transparent_7gxws {
90
+ } .bottom-sheet__background-specialbg-secondary-transparent_w482m {
91
91
  background-color: var(--color-light-specialbg-secondary-transparent);
92
- } .bottom-sheet__background-specialbg-secondary-transparent-inverted_7gxws {
92
+ } .bottom-sheet__background-specialbg-secondary-transparent-inverted_w482m {
93
93
  background-color: var(--color-light-specialbg-secondary-transparent-inverted);
94
- } .bottom-sheet__background-specialbg-tertiary-transparent_7gxws {
94
+ } .bottom-sheet__background-specialbg-tertiary-transparent_w482m {
95
95
  background-color: var(--color-light-specialbg-tertiary-transparent);
96
- } .bottom-sheet__background-specialbg-tertiary-transparent-inverted_7gxws {
96
+ } .bottom-sheet__background-specialbg-tertiary-transparent-inverted_w482m {
97
97
  background-color: var(--color-light-specialbg-tertiary-transparent-inverted);
98
98
  }
@@ -0,0 +1,7 @@
1
+ import { FC, RefObject } from 'react';
2
+ import { NavigationBarProps } from "@alfalab/core-components-navigation-bar";
3
+ type HeaderProps = Omit<NavigationBarProps, 'view' | 'size'> & {
4
+ headerRef: RefObject<HTMLDivElement>;
5
+ };
6
+ declare const Header: FC<HeaderProps>;
7
+ export { HeaderProps, Header };
@@ -2,19 +2,37 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- require('tslib');
6
- require('react');
7
- require('classnames');
8
- require('@alfalab/core-components-base-modal');
9
- require('@alfalab/core-components-navigation-bar');
10
- var components_header_Component = require('../../component-b5d23e5e.js');
11
- require('react-div-100vh');
12
- require('react-merge-refs');
13
- require('react-swipeable');
14
- require('../footer/Component.js');
15
- require('../swipeable-backdrop/Component.js');
16
- require('@alfalab/core-components-backdrop');
5
+ var tslib = require('tslib');
6
+ var React = require('react');
7
+ var cn = require('classnames');
8
+ var coreComponentsBaseModal = require('@alfalab/core-components-base-modal');
9
+ var coreComponentsNavigationBar = require('@alfalab/core-components-navigation-bar');
10
+ var utils = require('../../utils.js');
17
11
 
12
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
18
13
 
14
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
15
+ var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
19
16
 
20
- exports.Header = components_header_Component.Header;
17
+ var styles = {"headerWrapper":"bottom-sheet__headerWrapper_tel2m","hasContent":"bottom-sheet__hasContent_tel2m","header":"bottom-sheet__header_tel2m","sticky":"bottom-sheet__sticky_tel2m","highlighted":"bottom-sheet__highlighted_tel2m","justifyEnd":"bottom-sheet__justifyEnd_tel2m","addon":"bottom-sheet__addon_tel2m","addonFixed":"bottom-sheet__addonFixed_tel2m","title":"bottom-sheet__title_tel2m","titleCenter":"bottom-sheet__titleCenter_tel2m","titleLeft":"bottom-sheet__titleLeft_tel2m","trimTitle":"bottom-sheet__trimTitle_tel2m"};
18
+ require('./index.css')
19
+
20
+ var Header = function (_a) {
21
+ var _b;
22
+ var className = _a.className, sticky = _a.sticky, headerRef = _a.headerRef, title = _a.title, children = _a.children, restProps = tslib.__rest(_a, ["className", "sticky", "headerRef", "title", "children"]);
23
+ var _c = React.useContext(coreComponentsBaseModal.BaseModalContext), setHeaderOffset = _c.setHeaderOffset, setHasHeader = _c.setHasHeader, headerHighlighted = _c.headerHighlighted, onClose = _c.onClose;
24
+ React.useEffect(function () {
25
+ setHeaderOffset(utils.HEADER_OFFSET);
26
+ }, [setHeaderOffset]);
27
+ React.useEffect(function () {
28
+ setHasHeader(true);
29
+ }, [setHasHeader]);
30
+ var hasContent = Boolean(title || children);
31
+ return (React__default.default.createElement(coreComponentsNavigationBar.NavigationBar, tslib.__assign({}, restProps, { ref: headerRef, title: title, onClose: onClose, sticky: sticky, view: 'mobile', className: cn__default.default(styles.headerWrapper, className, (_b = {},
32
+ _b[styles.highlighted] = hasContent && headerHighlighted && sticky,
33
+ _b[styles.sticky] = sticky,
34
+ _b[styles.hasContent] = hasContent,
35
+ _b)), contentClassName: cn__default.default(styles.title) }), children));
36
+ };
37
+
38
+ exports.Header = Header;
@@ -1,4 +1,4 @@
1
- /* hash: 16nrz */
1
+ /* hash: gnzfi */
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-sheet__headerWrapper_1034c {
30
+ } .bottom-sheet__headerWrapper_tel2m {
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-sheet__hasContent_1034c {
35
+ } .bottom-sheet__hasContent_tel2m {
36
36
  background-color: inherit;
37
- } .bottom-sheet__header_1034c {
37
+ } .bottom-sheet__header_tel2m {
38
38
  display: flex;
39
- } .bottom-sheet__sticky_1034c {
39
+ } .bottom-sheet__sticky_tel2m {
40
40
  position: sticky;
41
41
  top: 0;
42
- } .bottom-sheet__highlighted_1034c {
42
+ } .bottom-sheet__highlighted_tel2m {
43
43
  border-bottom: var(--bottom-sheet-header-border-bottom);
44
- } .bottom-sheet__justifyEnd_1034c {
44
+ } .bottom-sheet__justifyEnd_tel2m {
45
45
  justify-content: flex-end;
46
- } .bottom-sheet__addon_1034c {
46
+ } .bottom-sheet__addon_tel2m {
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-sheet__addonFixed_1034c {
52
+ } .bottom-sheet__addonFixed_tel2m {
53
53
  position: fixed;
54
- } .bottom-sheet__title_1034c {
54
+ } .bottom-sheet__title_tel2m {
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-sheet__titleCenter_1034c {
61
+ } .bottom-sheet__titleCenter_tel2m {
62
62
  text-align: center;
63
- } .bottom-sheet__titleLeft_1034c {
63
+ } .bottom-sheet__titleLeft_tel2m {
64
64
  text-align: left;
65
- } .bottom-sheet__trimTitle_1034c {
65
+ } .bottom-sheet__trimTitle_tel2m {
66
66
  white-space: nowrap;
67
67
  overflow: hidden;
68
68
  text-overflow: ellipsis;
@@ -1,5 +1,5 @@
1
1
  import { FC } from 'react';
2
- import { SwipeableHandlers } from 'react-swipeable/types';
2
+ import { SwipeableHandlers } from 'react-swipeable';
3
3
  import { BackdropProps } from "@alfalab/core-components-backdrop";
4
4
  type SwipeableBackdropProps = BackdropProps & {
5
5
  /**
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { BottomSheetProps } from "./types";
4
+ declare const BottomSheet: React.ForwardRefExoticComponent<BottomSheetProps & React.RefAttributes<HTMLDivElement>>;
5
+ export { BottomSheet };