@alfalab/core-components-bottom-sheet 6.1.0 → 6.2.1

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
@@ -1,11 +1,286 @@
1
- import 'react';
2
- import 'react-div-100vh';
3
- import 'react-merge-refs';
4
- import 'react-swipeable';
5
- import 'classnames';
6
- import '@alfalab/core-components-base-modal/modern';
7
- export { B as BottomSheet, C as CLOSE_OFFSET, H as HEADER_OFFSET } from './component-1cd1bc34.js';
8
- import './components/footer/Component.js';
9
- import './components/swipeable-backdrop/Component.js';
1
+ import React, { forwardRef, useMemo, useState, useRef, useEffect, useImperativeHandle } from 'react';
2
+ import { use100vh } from 'react-div-100vh';
3
+ import mergeRefs from 'react-merge-refs';
4
+ import { useSwipeable } from 'react-swipeable';
5
+ import cn from 'classnames';
6
+ import { BaseModal } from '@alfalab/core-components-base-modal/modern';
7
+ import { Footer } from './components/footer/Component.js';
8
+ import { Header } from './components/header/Component.js';
9
+ import { SwipeableBackdrop } from './components/swipeable-backdrop/Component.js';
10
+ import { convertPercentToNumber, HEADER_OFFSET, TIMEOUT, MARKER_HEIGHT, SCROLL_OFFSET, SWIPE_VELOCITY, CLOSE_OFFSET } from './utils.js';
10
11
  import '@alfalab/core-components-navigation-bar/modern';
11
12
  import '@alfalab/core-components-backdrop/modern';
13
+
14
+ const getDataTestId = (dataTestId, element) => {
15
+ const elementPart = element ? `-${element.toLowerCase()}` : '';
16
+ return dataTestId ? `${dataTestId}${elementPart}` : undefined;
17
+ };
18
+
19
+ const isClient = () => typeof window !== 'undefined';
20
+
21
+ const styles = {"modal":"bottom-sheet__modal_7jq8y","wrapper":"bottom-sheet__wrapper_7jq8y","component":"bottom-sheet__component_7jq8y","withTransition":"bottom-sheet__withTransition_7jq8y","scrollableContainer":"bottom-sheet__scrollableContainer_7jq8y","marker":"bottom-sheet__marker_7jq8y","content":"bottom-sheet__content_7jq8y","noHeader":"bottom-sheet__noHeader_7jq8y","noFooter":"bottom-sheet__noFooter_7jq8y","scrollLocked":"bottom-sheet__scrollLocked_7jq8y","hiddenScrollbar":"bottom-sheet__hiddenScrollbar_7jq8y","disabledPointerEvents":"bottom-sheet__disabledPointerEvents_7jq8y","appear":"bottom-sheet__appear_7jq8y","enter":"bottom-sheet__enter_7jq8y","appearActive":"bottom-sheet__appearActive_7jq8y","enterActive":"bottom-sheet__enterActive_7jq8y","enterDone":"bottom-sheet__enterDone_7jq8y","appearDone":"bottom-sheet__appearDone_7jq8y","exit":"bottom-sheet__exit_7jq8y","exitActive":"bottom-sheet__exitActive_7jq8y","background-accent":"bottom-sheet__background-accent_7jq8y","background-info":"bottom-sheet__background-info_7jq8y","background-attention-muted":"bottom-sheet__background-attention-muted_7jq8y","background-positive-muted":"bottom-sheet__background-positive-muted_7jq8y","background-negative-muted":"bottom-sheet__background-negative-muted_7jq8y","background-primary":"bottom-sheet__background-primary_7jq8y","background-primary-inverted":"bottom-sheet__background-primary-inverted_7jq8y","background-secondary":"bottom-sheet__background-secondary_7jq8y","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_7jq8y","background-tertiary":"bottom-sheet__background-tertiary_7jq8y","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_7jq8y","background-quaternary":"bottom-sheet__background-quaternary_7jq8y","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_7jq8y","background-specialbg-component":"bottom-sheet__background-specialbg-component_7jq8y","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_7jq8y","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_7jq8y","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_7jq8y","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_7jq8y","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_7jq8y","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_7jq8y","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_7jq8y","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_7jq8y"};
22
+ require('./index.css')
23
+
24
+ const BottomSheet = forwardRef(({ open, title, container, backgroundColor, titleSize = 'default', subtitle, actionButton, contentClassName, containerClassName, containerProps, headerClassName, footerClassName, addonClassName, closerClassName, backerClassName, modalClassName, modalWrapperClassName, className, leftAddons, rightAddons, bottomAddons, hasCloser, hasBacker, titleAlign = 'left', trimTitle, stickyHeader, stickyFooter = true, initialHeight = 'default', hideOverlay, hideScrollbar, hideHeader, disableOverlayClick, disableBlockingScroll, children, zIndex, transitionProps = {}, magneticAreas: magneticAreasProp, initialActiveAreaIndex, dataTestId, swipeable = true, scrollLocked: scrollLockedProp, backdropProps, scrollableContainerRef = () => null, bottomSheetInstanceRef, sheetContainerRef = () => null, onClose, onBack, onMagnetize, }, ref) => {
25
+ const hasInitialIdx = initialActiveAreaIndex !== undefined;
26
+ const fullHeight = use100vh() || isClient() ? window.innerHeight : 0;
27
+ const magneticAreas = useMemo(() => {
28
+ if (magneticAreasProp) {
29
+ return magneticAreasProp.map((area) => convertPercentToNumber(area, fullHeight));
30
+ }
31
+ return [0, fullHeight - HEADER_OFFSET];
32
+ }, [fullHeight, magneticAreasProp]);
33
+ const lastMagneticArea = magneticAreas[magneticAreas.length - 1];
34
+ const [sheetOffset, setSheetOffset] = useState(hasInitialIdx
35
+ ? lastMagneticArea - magneticAreas[initialActiveAreaIndex]
36
+ : magneticAreas[0]);
37
+ const [backdropOpacity, setBackdropOpacity] = useState(1);
38
+ const [activeArea, setActiveArea] = useState(hasInitialIdx ? magneticAreas[initialActiveAreaIndex] : lastMagneticArea);
39
+ const swipingInProgress = useRef(false);
40
+ const headerRef = useRef(null);
41
+ const sheetHeight = useRef(0);
42
+ const sheetRef = useRef(null);
43
+ const scrollableContainer = useRef(null);
44
+ const emptyHeader = !hasCloser && !leftAddons && !title && !hasBacker && !rightAddons;
45
+ const titleIsReactElement = React.isValidElement(title);
46
+ const headerProps = {
47
+ ...(titleIsReactElement
48
+ ? { children: title }
49
+ : { title: title ? title?.toString() : undefined }),
50
+ scrollableParentRef: scrollableContainer,
51
+ headerRef,
52
+ className: headerClassName,
53
+ addonClassName,
54
+ closerClassName,
55
+ backButtonClassName: backerClassName,
56
+ leftAddons,
57
+ rightAddons,
58
+ bottomAddons,
59
+ hasCloser,
60
+ hasBackButton: hasBacker,
61
+ align: titleAlign,
62
+ trim: trimTitle,
63
+ sticky: stickyHeader,
64
+ dataTestId: getDataTestId(dataTestId, 'header'),
65
+ onBack,
66
+ titleSize,
67
+ subtitle,
68
+ onClose,
69
+ };
70
+ const getBackdropOpacity = (offset) => {
71
+ const canClose = magneticAreas[0] === 0;
72
+ const secondArea = magneticAreas[1];
73
+ const isSecondArea = secondArea === activeArea;
74
+ if (canClose && isSecondArea && sheetOffset > lastMagneticArea - secondArea) {
75
+ const opacity = 1 - (offset - (lastMagneticArea - secondArea)) / secondArea;
76
+ return Math.max(0, Number(opacity.toFixed(2)));
77
+ }
78
+ return 1;
79
+ };
80
+ const getSheetOffset = (deltaY) => {
81
+ let offset = lastMagneticArea - activeArea + deltaY;
82
+ const maxOffset = magneticAreas[0] === 0 ? 0 : lastMagneticArea - magneticAreas[0];
83
+ if (maxOffset) {
84
+ offset = Math.min(maxOffset, offset);
85
+ }
86
+ return Math.max(0, Math.round(offset));
87
+ };
88
+ const getActiveAreaIndex = (area) => magneticAreas.findIndex((a) => a === area);
89
+ const setSheetHeight = () => {
90
+ if (sheetRef.current) {
91
+ sheetHeight.current = sheetRef.current.getBoundingClientRect().height - sheetOffset;
92
+ }
93
+ };
94
+ const scrollToArea = (idx) => {
95
+ const nextArea = magneticAreas[idx];
96
+ if (nextArea === 0) {
97
+ onClose();
98
+ return;
99
+ }
100
+ if (nextArea) {
101
+ setActiveArea(nextArea);
102
+ setSheetOffset(lastMagneticArea - nextArea);
103
+ }
104
+ };
105
+ const magnetize = (dir, velocity, deltaY) => {
106
+ const shouldMagnetizeDownByVelocity = dir === 'Down' && velocity >= SWIPE_VELOCITY;
107
+ const shouldMagnetizeUpByVelocity = dir === 'Up' && velocity >= SWIPE_VELOCITY;
108
+ if (shouldMagnetizeDownByVelocity) {
109
+ const nextArea = magneticAreas
110
+ .slice()
111
+ .reverse()
112
+ .find((area) => area < activeArea);
113
+ if (nextArea === 0) {
114
+ onClose();
115
+ return;
116
+ }
117
+ const offset = nextArea
118
+ ? lastMagneticArea - nextArea
119
+ : lastMagneticArea - activeArea;
120
+ setSheetOffset(offset);
121
+ setActiveArea((prevState) => nextArea ?? prevState);
122
+ return;
123
+ }
124
+ if (shouldMagnetizeUpByVelocity) {
125
+ const nextArea = magneticAreas.find((area) => area > activeArea);
126
+ const offset = nextArea ? lastMagneticArea - nextArea : 0;
127
+ setSheetOffset(offset);
128
+ setActiveArea((prevState) => nextArea ?? prevState);
129
+ return;
130
+ }
131
+ const offset = getSheetOffset(deltaY);
132
+ const currentSheetHeight = lastMagneticArea - offset;
133
+ const secondArea = magneticAreas[1];
134
+ const isSecondArea = activeArea === secondArea;
135
+ const canClose = magneticAreas[0] === 0 && dir === 'Down';
136
+ const shouldCloseByOffset = isSecondArea && canClose && 1 - currentSheetHeight / activeArea > CLOSE_OFFSET;
137
+ if (shouldCloseByOffset) {
138
+ onClose();
139
+ return;
140
+ }
141
+ const { nearestArea } = magneticAreas.reduceRight((res, area) => {
142
+ if (Math.abs(area - currentSheetHeight) < res.minOffset) {
143
+ res.minOffset = area - currentSheetHeight;
144
+ res.nearestArea = area;
145
+ }
146
+ return res;
147
+ }, {
148
+ nearestArea: lastMagneticArea,
149
+ minOffset: lastMagneticArea,
150
+ });
151
+ if (nearestArea === 0) {
152
+ onClose();
153
+ }
154
+ else {
155
+ setSheetOffset(lastMagneticArea - nearestArea);
156
+ setActiveArea(nearestArea);
157
+ setBackdropOpacity(1);
158
+ }
159
+ };
160
+ /**
161
+ * Если контент внутри шторки скроллится - то шторка не должна свайпаться
162
+ * Если шапка внутри шторки зафиксирована - то шторка должна свайпаться только в области шапки
163
+ */
164
+ const shouldSkipSwiping = (dir, startY) => {
165
+ if (!swipeable)
166
+ return true;
167
+ if (scrollLockedProp || swipingInProgress.current)
168
+ return false;
169
+ const scrollableNode = scrollableContainer.current;
170
+ // Точка верхней границы (y координата)
171
+ const bottomSheetTopY = fullHeight - sheetHeight.current;
172
+ if (!scrollableNode ||
173
+ (!stickyHeader && Math.abs(bottomSheetTopY - startY) <= MARKER_HEIGHT) ||
174
+ (stickyHeader &&
175
+ headerRef.current &&
176
+ Math.abs(bottomSheetTopY - startY) <= headerRef.current.clientHeight)) {
177
+ return false;
178
+ }
179
+ return dir === 'Down'
180
+ ? scrollableNode.scrollTop > 0
181
+ : scrollableNode.scrollHeight -
182
+ scrollableNode.scrollTop -
183
+ scrollableNode.clientHeight >
184
+ SCROLL_OFFSET;
185
+ };
186
+ const handleSheetSwipe = ({ dir, initial, velocity, deltaY }) => {
187
+ if (shouldSkipSwiping(dir, initial[1])) {
188
+ return;
189
+ }
190
+ magnetize(dir, velocity, deltaY);
191
+ };
192
+ const handleSheetSwipeStart = ({ dir, initial }) => {
193
+ if (shouldSkipSwiping(dir, initial[1])) {
194
+ return;
195
+ }
196
+ swipingInProgress.current = true;
197
+ };
198
+ const handleSheetSwiped = () => {
199
+ swipingInProgress.current = false;
200
+ };
201
+ const handleSheetSwiping = ({ initial, deltaY, dir }) => {
202
+ if (shouldSkipSwiping(dir, initial[1])) {
203
+ return;
204
+ }
205
+ const offset = getSheetOffset(deltaY);
206
+ const opacity = getBackdropOpacity(offset);
207
+ setSheetOffset(offset);
208
+ setBackdropOpacity(opacity);
209
+ };
210
+ const sheetSwipeableHandlers = useSwipeable({
211
+ onSwipeStart: handleSheetSwipeStart,
212
+ onSwiping: handleSheetSwiping,
213
+ onSwipedDown: handleSheetSwipe,
214
+ onSwipedUp: handleSheetSwipe,
215
+ onSwiped: handleSheetSwiped,
216
+ trackMouse: swipeable,
217
+ delta: 5,
218
+ });
219
+ const handleExited = (node) => {
220
+ const idx = initialActiveAreaIndex;
221
+ setBackdropOpacity(1);
222
+ setSheetOffset(hasInitialIdx ? lastMagneticArea - magneticAreas[idx] : magneticAreas[0]);
223
+ setActiveArea(hasInitialIdx ? magneticAreas[idx] : lastMagneticArea);
224
+ if (transitionProps.onExited) {
225
+ transitionProps.onExited(node);
226
+ }
227
+ };
228
+ const handleEntered = (node, isAppearing) => {
229
+ setBackdropOpacity(1);
230
+ setSheetHeight();
231
+ if (transitionProps.onEntered) {
232
+ transitionProps.onEntered(node, isAppearing);
233
+ }
234
+ };
235
+ useEffect(() => {
236
+ onMagnetize?.(open ? getActiveAreaIndex(activeArea) : 0);
237
+ // eslint-disable-next-line react-hooks/exhaustive-deps
238
+ }, [activeArea, open]);
239
+ useImperativeHandle(bottomSheetInstanceRef, () => ({
240
+ scrollToArea,
241
+ }));
242
+ const getSwipeStyles = () => ({
243
+ transform: sheetOffset ? `translateY(${sheetOffset}px)` : '',
244
+ });
245
+ const getHeightStyles = () => ({
246
+ height: initialHeight === 'full' ? `${lastMagneticArea}px` : 'unset',
247
+ maxHeight: `${lastMagneticArea}px`,
248
+ });
249
+ const bgClassName = backgroundColor && styles[`background-${backgroundColor}`];
250
+ return (React.createElement(BaseModal, { open: open, ref: ref, container: container, dataTestId: dataTestId, zIndex: zIndex, onClose: onClose, scrollHandler: scrollableContainer, Backdrop: SwipeableBackdrop, backdropProps: {
251
+ ...backdropProps,
252
+ className: styles.disabledPointerEvents,
253
+ opacity: backdropOpacity,
254
+ opacityTimeout: TIMEOUT,
255
+ invisible: hideOverlay,
256
+ }, disableBackdropClick: hideOverlay ? true : disableOverlayClick, className: cn(styles.modal, modalClassName), wrapperClassName: cn(modalWrapperClassName, {
257
+ [styles.disabledPointerEvents]: hideOverlay,
258
+ }), disableBlockingScroll: disableBlockingScroll, transitionProps: {
259
+ appear: true,
260
+ timeout: TIMEOUT,
261
+ classNames: styles,
262
+ ...transitionProps,
263
+ onExited: handleExited,
264
+ onEntered: handleEntered,
265
+ } },
266
+ React.createElement("div", { style: { ...getHeightStyles() }, className: styles.wrapper, onTransitionEnd: setSheetHeight },
267
+ React.createElement("div", { className: cn(styles.component, bgClassName, className, {
268
+ [styles.withTransition]: !swipingInProgress.current,
269
+ }), style: {
270
+ ...getSwipeStyles(),
271
+ ...getHeightStyles(),
272
+ }, ...sheetSwipeableHandlers, ref: mergeRefs([sheetRef, sheetContainerRef, sheetSwipeableHandlers.ref]), onTransitionEnd: setSheetHeight },
273
+ React.createElement("div", { ...containerProps, className: cn(styles.scrollableContainer, containerProps?.className, containerClassName, {
274
+ [styles.scrollLocked]: scrollLockedProp || swipingInProgress.current,
275
+ [styles.hiddenScrollbar]: hideScrollbar,
276
+ }), ref: mergeRefs([scrollableContainer, scrollableContainerRef]) },
277
+ swipeable && React.createElement("div", { className: cn(styles.marker) }),
278
+ !hideHeader && !emptyHeader && React.createElement(Header, { ...headerProps }),
279
+ React.createElement("div", { className: cn(styles.content, contentClassName, {
280
+ [styles.noHeader]: hideHeader || emptyHeader,
281
+ [styles.noFooter]: !actionButton,
282
+ }) }, children),
283
+ actionButton && (React.createElement(Footer, { sticky: stickyFooter, className: cn(bgClassName, footerClassName) }, actionButton)))))));
284
+ });
285
+
286
+ export { BottomSheet };
@@ -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/modern';
4
4
 
5
- const 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"};
5
+ const styles = {"footer":"bottom-sheet__footer_156iw","sticky":"bottom-sheet__sticky_156iw","highlighted":"bottom-sheet__highlighted_156iw","background-accent":"bottom-sheet__background-accent_156iw","background-info":"bottom-sheet__background-info_156iw","background-attention-muted":"bottom-sheet__background-attention-muted_156iw","background-positive-muted":"bottom-sheet__background-positive-muted_156iw","background-negative-muted":"bottom-sheet__background-negative-muted_156iw","background-primary":"bottom-sheet__background-primary_156iw","background-primary-inverted":"bottom-sheet__background-primary-inverted_156iw","background-secondary":"bottom-sheet__background-secondary_156iw","background-secondary-inverted":"bottom-sheet__background-secondary-inverted_156iw","background-tertiary":"bottom-sheet__background-tertiary_156iw","background-tertiary-inverted":"bottom-sheet__background-tertiary-inverted_156iw","background-quaternary":"bottom-sheet__background-quaternary_156iw","background-quaternary-inverted":"bottom-sheet__background-quaternary-inverted_156iw","background-specialbg-component":"bottom-sheet__background-specialbg-component_156iw","background-specialbg-component-inverted":"bottom-sheet__background-specialbg-component-inverted_156iw","background-specialbg-primary-grouped":"bottom-sheet__background-specialbg-primary-grouped_156iw","background-specialbg-secondary-grouped":"bottom-sheet__background-specialbg-secondary-grouped_156iw","background-specialbg-tertiary-grouped":"bottom-sheet__background-specialbg-tertiary-grouped_156iw","background-specialbg-secondary-transparent":"bottom-sheet__background-specialbg-secondary-transparent_156iw","background-specialbg-secondary-transparent-inverted":"bottom-sheet__background-specialbg-secondary-transparent-inverted_156iw","background-specialbg-tertiary-transparent":"bottom-sheet__background-specialbg-tertiary-transparent_156iw","background-specialbg-tertiary-transparent-inverted":"bottom-sheet__background-specialbg-tertiary-transparent-inverted_156iw"};
6
6
  require('./index.css')
7
7
 
8
8
  const Footer = ({ children, className, sticky }) => {
@@ -1,4 +1,4 @@
1
- /* hash: 1nw41 */
1
+ /* hash: 13uyg */
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_156iw {
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_156iw {
48
48
  position: sticky;
49
49
  bottom: 0;
50
50
  z-index: 1;
51
- } .bottom-sheet__highlighted_7gxws {
51
+ } .bottom-sheet__highlighted_156iw {
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_156iw {
55
55
  background-color: var(--color-light-bg-accent);
56
- } .bottom-sheet__background-info_7gxws {
56
+ } .bottom-sheet__background-info_156iw {
57
57
  background-color: var(--color-light-bg-info);
58
- } .bottom-sheet__background-attention-muted_7gxws {
58
+ } .bottom-sheet__background-attention-muted_156iw {
59
59
  background-color: var(--color-light-bg-attention-muted);
60
- } .bottom-sheet__background-positive-muted_7gxws {
60
+ } .bottom-sheet__background-positive-muted_156iw {
61
61
  background-color: var(--color-light-bg-positive-muted);
62
- } .bottom-sheet__background-negative-muted_7gxws {
62
+ } .bottom-sheet__background-negative-muted_156iw {
63
63
  background-color: var(--color-light-bg-negative-muted);
64
- } .bottom-sheet__background-primary_7gxws {
64
+ } .bottom-sheet__background-primary_156iw {
65
65
  background-color: var(--color-light-bg-primary);
66
- } .bottom-sheet__background-primary-inverted_7gxws {
66
+ } .bottom-sheet__background-primary-inverted_156iw {
67
67
  background-color: var(--color-light-bg-primary-inverted);
68
- } .bottom-sheet__background-secondary_7gxws {
68
+ } .bottom-sheet__background-secondary_156iw {
69
69
  background-color: var(--color-light-bg-secondary);
70
- } .bottom-sheet__background-secondary-inverted_7gxws {
70
+ } .bottom-sheet__background-secondary-inverted_156iw {
71
71
  background-color: var(--color-light-bg-secondary-inverted);
72
- } .bottom-sheet__background-tertiary_7gxws {
72
+ } .bottom-sheet__background-tertiary_156iw {
73
73
  background-color: var(--color-light-bg-tertiary);
74
- } .bottom-sheet__background-tertiary-inverted_7gxws {
74
+ } .bottom-sheet__background-tertiary-inverted_156iw {
75
75
  background-color: var(--color-light-bg-tertiary-inverted);
76
- } .bottom-sheet__background-quaternary_7gxws {
76
+ } .bottom-sheet__background-quaternary_156iw {
77
77
  background-color: var(--color-light-bg-quaternary);
78
- } .bottom-sheet__background-quaternary-inverted_7gxws {
78
+ } .bottom-sheet__background-quaternary-inverted_156iw {
79
79
  background-color: var(--color-light-bg-quaternary-inverted);
80
- } .bottom-sheet__background-specialbg-component_7gxws {
80
+ } .bottom-sheet__background-specialbg-component_156iw {
81
81
  background-color: var(--color-light-specialbg-component);
82
- } .bottom-sheet__background-specialbg-component-inverted_7gxws {
82
+ } .bottom-sheet__background-specialbg-component-inverted_156iw {
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_156iw {
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_156iw {
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_156iw {
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_156iw {
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_156iw {
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_156iw {
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_156iw {
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 };
@@ -1,11 +1,26 @@
1
- import 'react';
2
- import 'classnames';
3
- import '@alfalab/core-components-base-modal/modern';
4
- import '@alfalab/core-components-navigation-bar/modern';
5
- export { a as Header } from '../../component-1cd1bc34.js';
6
- import 'react-div-100vh';
7
- import 'react-merge-refs';
8
- import 'react-swipeable';
9
- import '../footer/Component.js';
10
- import '../swipeable-backdrop/Component.js';
11
- import '@alfalab/core-components-backdrop/modern';
1
+ import React, { useContext, useEffect } from 'react';
2
+ import cn from 'classnames';
3
+ import { BaseModalContext } from '@alfalab/core-components-base-modal/modern';
4
+ import { NavigationBar } from '@alfalab/core-components-navigation-bar/modern';
5
+ import { HEADER_OFFSET } from '../../utils.js';
6
+
7
+ const styles = {"headerWrapper":"bottom-sheet__headerWrapper_1xspb","hasContent":"bottom-sheet__hasContent_1xspb","header":"bottom-sheet__header_1xspb","sticky":"bottom-sheet__sticky_1xspb","highlighted":"bottom-sheet__highlighted_1xspb","justifyEnd":"bottom-sheet__justifyEnd_1xspb","addon":"bottom-sheet__addon_1xspb","addonFixed":"bottom-sheet__addonFixed_1xspb","title":"bottom-sheet__title_1xspb","titleCenter":"bottom-sheet__titleCenter_1xspb","titleLeft":"bottom-sheet__titleLeft_1xspb","trimTitle":"bottom-sheet__trimTitle_1xspb"};
8
+ require('./index.css')
9
+
10
+ const Header = ({ className, sticky, headerRef, title, children, ...restProps }) => {
11
+ const { setHeaderOffset, setHasHeader, headerHighlighted, onClose } = useContext(BaseModalContext);
12
+ useEffect(() => {
13
+ setHeaderOffset(HEADER_OFFSET);
14
+ }, [setHeaderOffset]);
15
+ useEffect(() => {
16
+ setHasHeader(true);
17
+ }, [setHasHeader]);
18
+ const hasContent = Boolean(title || children);
19
+ return (React.createElement(NavigationBar, { ...restProps, ref: headerRef, title: title, onClose: onClose, sticky: sticky, view: 'mobile', className: cn(styles.headerWrapper, className, {
20
+ [styles.highlighted]: hasContent && headerHighlighted && sticky,
21
+ [styles.sticky]: sticky,
22
+ [styles.hasContent]: hasContent,
23
+ }), contentClassName: cn(styles.title) }, children));
24
+ };
25
+
26
+ export { Header };
@@ -1,4 +1,4 @@
1
- /* hash: 16nrz */
1
+ /* hash: 6qb4a */
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_1xspb {
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_1xspb {
36
36
  background-color: inherit;
37
- } .bottom-sheet__header_1034c {
37
+ } .bottom-sheet__header_1xspb {
38
38
  display: flex;
39
- } .bottom-sheet__sticky_1034c {
39
+ } .bottom-sheet__sticky_1xspb {
40
40
  position: sticky;
41
41
  top: 0;
42
- } .bottom-sheet__highlighted_1034c {
42
+ } .bottom-sheet__highlighted_1xspb {
43
43
  border-bottom: var(--bottom-sheet-header-border-bottom);
44
- } .bottom-sheet__justifyEnd_1034c {
44
+ } .bottom-sheet__justifyEnd_1xspb {
45
45
  justify-content: flex-end;
46
- } .bottom-sheet__addon_1034c {
46
+ } .bottom-sheet__addon_1xspb {
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_1xspb {
53
53
  position: fixed;
54
- } .bottom-sheet__title_1034c {
54
+ } .bottom-sheet__title_1xspb {
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_1xspb {
62
62
  text-align: center;
63
- } .bottom-sheet__titleLeft_1034c {
63
+ } .bottom-sheet__titleLeft_1xspb {
64
64
  text-align: left;
65
- } .bottom-sheet__trimTitle_1034c {
65
+ } .bottom-sheet__trimTitle_1xspb {
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
  /**