@alfalab/core-components-bottom-sheet 6.7.0 → 6.8.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.
@@ -1,4 +1,4 @@
1
- /* hash: 1yadn */
1
+ /* hash: 1x5qy */
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_1t48d {
30
+ } .bottom-sheet__headerWrapper_198ve {
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_1t48d {
35
+ } .bottom-sheet__hasContent_198ve {
36
36
  background-color: inherit;
37
- } .bottom-sheet__header_1t48d {
37
+ } .bottom-sheet__header_198ve {
38
38
  display: flex;
39
- } .bottom-sheet__sticky_1t48d {
39
+ } .bottom-sheet__sticky_198ve {
40
40
  position: sticky;
41
41
  top: 0;
42
- } .bottom-sheet__highlighted_1t48d {
42
+ } .bottom-sheet__highlighted_198ve {
43
43
  border-bottom: var(--bottom-sheet-header-border-bottom);
44
- } .bottom-sheet__justifyEnd_1t48d {
44
+ } .bottom-sheet__justifyEnd_198ve {
45
45
  justify-content: flex-end;
46
- } .bottom-sheet__addon_1t48d {
46
+ } .bottom-sheet__addon_198ve {
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_1t48d {
52
+ } .bottom-sheet__addonFixed_198ve {
53
53
  position: fixed;
54
- } .bottom-sheet__title_1t48d {
54
+ } .bottom-sheet__title_198ve {
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_1t48d {
61
+ } .bottom-sheet__titleCenter_198ve {
62
62
  text-align: center;
63
- } .bottom-sheet__titleLeft_1t48d {
63
+ } .bottom-sheet__titleLeft_198ve {
64
64
  text-align: left;
65
- } .bottom-sheet__trimTitle_1t48d {
65
+ } .bottom-sheet__trimTitle_198ve {
66
66
  white-space: nowrap;
67
67
  overflow: hidden;
68
68
  text-overflow: ellipsis;
package/modern/index.css CHANGED
@@ -1,4 +1,4 @@
1
- /* hash: ozuwp */
1
+ /* hash: okunf */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
4
  --color-light-bg-accent: #ef3124;
@@ -45,31 +45,31 @@
45
45
  } :root {
46
46
  --bottom-sheet-in-transition: transform 0.5s cubic-bezier(0.09, 0.91, 0.18, 0.99);
47
47
  --bottom-sheet-out-transition: transform 0.3s ease;
48
- } .bottom-sheet__modal_3cpay {
48
+ } .bottom-sheet__modal_88g3f {
49
49
  background-color: transparent;
50
50
  position: fixed;
51
51
  bottom: 0;
52
52
  width: 100%;
53
53
  max-width: 600px;
54
54
  pointer-events: none;
55
- } .bottom-sheet__wrapper_3cpay {
55
+ } .bottom-sheet__wrapper_88g3f {
56
56
  transform: translateY(100%);
57
57
  pointer-events: none;
58
58
  border-top-right-radius: var(--border-radius-xl);
59
59
  border-top-left-radius: var(--border-radius-xl);
60
60
  transition: border-radius 0.3s ease;
61
- } .bottom-sheet__fullscreen_3cpay {
61
+ } .bottom-sheet__fullscreen_88g3f {
62
62
  border-radius: 0;
63
- } .bottom-sheet__component_3cpay {
63
+ } .bottom-sheet__component_88g3f {
64
64
  position: relative;
65
65
  display: flex;
66
66
  flex-direction: column;
67
67
  border-radius: inherit;
68
68
  background-color: var(--color-light-bg-primary);
69
69
  pointer-events: all;
70
- } .bottom-sheet__withTransition_3cpay {
70
+ } .bottom-sheet__withTransition_88g3f {
71
71
  transition: var(--bottom-sheet-out-transition);
72
- } .bottom-sheet__scrollableContainer_3cpay {
72
+ } .bottom-sheet__scrollableContainer_88g3f {
73
73
  overflow: auto;
74
74
  display: flex;
75
75
  flex-direction: column;
@@ -77,7 +77,7 @@
77
77
  height: 100%;
78
78
  background-color: inherit;
79
79
  border-radius: inherit;
80
- } .bottom-sheet__marker_3cpay {
80
+ } .bottom-sheet__marker_88g3f {
81
81
  position: fixed;
82
82
  top: var(--gap-2xs);
83
83
  right: 0;
@@ -85,11 +85,11 @@
85
85
  z-index: 1000;
86
86
  width: 36px;
87
87
  margin: 0 auto;
88
- } .bottom-sheet__defaultMarker_3cpay {
88
+ } .bottom-sheet__defaultMarker_88g3f {
89
89
  height: 4px;
90
90
  border-radius: var(--border-radius-xxl);
91
91
  background-color: var(--color-light-graphic-quaternary);
92
- } .bottom-sheet__content_3cpay {
92
+ } .bottom-sheet__content_88g3f {
93
93
  position: relative;
94
94
  z-index: 0;
95
95
  display: flex;
@@ -98,73 +98,73 @@
98
98
  padding: 0 var(--gap-m);
99
99
  color: var(--color-light-text-primary);
100
100
  background-color: inherit;
101
- } .bottom-sheet__noHeader_3cpay {
101
+ } .bottom-sheet__noHeader_88g3f {
102
102
  padding-top: var(--gap-m);
103
- } .bottom-sheet__noFooter_3cpay {
103
+ } .bottom-sheet__noFooter_88g3f {
104
104
  padding-bottom: var(--gap-m);
105
- } .bottom-sheet__scrollLocked_3cpay {
105
+ } .bottom-sheet__scrollLocked_88g3f {
106
106
  overflow: hidden;
107
- } .bottom-sheet__hiddenScrollbar_3cpay {
107
+ } .bottom-sheet__hiddenScrollbar_88g3f {
108
108
  scrollbar-width: none
109
- } .bottom-sheet__hiddenScrollbar_3cpay::-webkit-scrollbar {
109
+ } .bottom-sheet__hiddenScrollbar_88g3f::-webkit-scrollbar {
110
110
  width: 0;
111
111
  height: 0;
112
- } .bottom-sheet__disabledPointerEvents_3cpay {
112
+ } .bottom-sheet__disabledPointerEvents_88g3f {
113
113
  pointer-events: none;
114
- } .bottom-sheet__appear_3cpay .bottom-sheet__wrapper_3cpay, .bottom-sheet__enter_3cpay .bottom-sheet__wrapper_3cpay {
114
+ } .bottom-sheet__appear_88g3f .bottom-sheet__wrapper_88g3f, .bottom-sheet__enter_88g3f .bottom-sheet__wrapper_88g3f {
115
115
  transition: none;
116
- } .bottom-sheet__appearActive_3cpay .bottom-sheet__wrapper_3cpay, .bottom-sheet__enterActive_3cpay .bottom-sheet__wrapper_3cpay {
116
+ } .bottom-sheet__appearActive_88g3f .bottom-sheet__wrapper_88g3f, .bottom-sheet__enterActive_88g3f .bottom-sheet__wrapper_88g3f {
117
117
  transition: var(--bottom-sheet-in-transition);
118
118
  transform: translateY(0);
119
- } .bottom-sheet__enterDone_3cpay .bottom-sheet__wrapper_3cpay, .bottom-sheet__appearDone_3cpay .bottom-sheet__wrapper_3cpay {
119
+ } .bottom-sheet__enterDone_88g3f .bottom-sheet__wrapper_88g3f, .bottom-sheet__appearDone_88g3f .bottom-sheet__wrapper_88g3f {
120
120
  transform: translateY(0);
121
- } .bottom-sheet__exit_3cpay .bottom-sheet__wrapper_3cpay {
121
+ } .bottom-sheet__exit_88g3f .bottom-sheet__wrapper_88g3f {
122
122
  transform: translateY(0);
123
- } .bottom-sheet__exitActive_3cpay .bottom-sheet__wrapper_3cpay {
123
+ } .bottom-sheet__exitActive_88g3f .bottom-sheet__wrapper_88g3f {
124
124
  transition: var(--bottom-sheet-out-transition);
125
125
  transform: translateY(100%);
126
- } .bottom-sheet__background-accent_3cpay {
126
+ } .bottom-sheet__background-accent_88g3f {
127
127
  background-color: var(--color-light-bg-accent);
128
- } .bottom-sheet__background-info_3cpay {
128
+ } .bottom-sheet__background-info_88g3f {
129
129
  background-color: var(--color-light-bg-info);
130
- } .bottom-sheet__background-attention-muted_3cpay {
130
+ } .bottom-sheet__background-attention-muted_88g3f {
131
131
  background-color: var(--color-light-bg-attention-muted);
132
- } .bottom-sheet__background-positive-muted_3cpay {
132
+ } .bottom-sheet__background-positive-muted_88g3f {
133
133
  background-color: var(--color-light-bg-positive-muted);
134
- } .bottom-sheet__background-negative-muted_3cpay {
134
+ } .bottom-sheet__background-negative-muted_88g3f {
135
135
  background-color: var(--color-light-bg-negative-muted);
136
- } .bottom-sheet__background-primary_3cpay {
136
+ } .bottom-sheet__background-primary_88g3f {
137
137
  background-color: var(--color-light-bg-primary);
138
- } .bottom-sheet__background-primary-inverted_3cpay {
138
+ } .bottom-sheet__background-primary-inverted_88g3f {
139
139
  background-color: var(--color-light-bg-primary-inverted);
140
- } .bottom-sheet__background-secondary_3cpay {
140
+ } .bottom-sheet__background-secondary_88g3f {
141
141
  background-color: var(--color-light-bg-secondary);
142
- } .bottom-sheet__background-secondary-inverted_3cpay {
142
+ } .bottom-sheet__background-secondary-inverted_88g3f {
143
143
  background-color: var(--color-light-bg-secondary-inverted);
144
- } .bottom-sheet__background-tertiary_3cpay {
144
+ } .bottom-sheet__background-tertiary_88g3f {
145
145
  background-color: var(--color-light-bg-tertiary);
146
- } .bottom-sheet__background-tertiary-inverted_3cpay {
146
+ } .bottom-sheet__background-tertiary-inverted_88g3f {
147
147
  background-color: var(--color-light-bg-tertiary-inverted);
148
- } .bottom-sheet__background-quaternary_3cpay {
148
+ } .bottom-sheet__background-quaternary_88g3f {
149
149
  background-color: var(--color-light-bg-quaternary);
150
- } .bottom-sheet__background-quaternary-inverted_3cpay {
150
+ } .bottom-sheet__background-quaternary-inverted_88g3f {
151
151
  background-color: var(--color-light-bg-quaternary-inverted);
152
- } .bottom-sheet__background-specialbg-component_3cpay {
152
+ } .bottom-sheet__background-specialbg-component_88g3f {
153
153
  background-color: var(--color-light-specialbg-component);
154
- } .bottom-sheet__background-specialbg-component-inverted_3cpay {
154
+ } .bottom-sheet__background-specialbg-component-inverted_88g3f {
155
155
  background-color: var(--color-light-specialbg-component-inverted);
156
- } .bottom-sheet__background-specialbg-primary-grouped_3cpay {
156
+ } .bottom-sheet__background-specialbg-primary-grouped_88g3f {
157
157
  background-color: var(--color-light-specialbg-primary-grouped);
158
- } .bottom-sheet__background-specialbg-secondary-grouped_3cpay {
158
+ } .bottom-sheet__background-specialbg-secondary-grouped_88g3f {
159
159
  background-color: var(--color-light-specialbg-secondary-grouped);
160
- } .bottom-sheet__background-specialbg-tertiary-grouped_3cpay {
160
+ } .bottom-sheet__background-specialbg-tertiary-grouped_88g3f {
161
161
  background-color: var(--color-light-specialbg-tertiary-grouped);
162
- } .bottom-sheet__background-specialbg-secondary-transparent_3cpay {
162
+ } .bottom-sheet__background-specialbg-secondary-transparent_88g3f {
163
163
  background-color: var(--color-light-specialbg-secondary-transparent);
164
- } .bottom-sheet__background-specialbg-secondary-transparent-inverted_3cpay {
164
+ } .bottom-sheet__background-specialbg-secondary-transparent-inverted_88g3f {
165
165
  background-color: var(--color-light-specialbg-secondary-transparent-inverted);
166
- } .bottom-sheet__background-specialbg-tertiary-transparent_3cpay {
166
+ } .bottom-sheet__background-specialbg-tertiary-transparent_88g3f {
167
167
  background-color: var(--color-light-specialbg-tertiary-transparent);
168
- } .bottom-sheet__background-specialbg-tertiary-transparent-inverted_3cpay {
168
+ } .bottom-sheet__background-specialbg-tertiary-transparent-inverted_88g3f {
169
169
  background-color: var(--color-light-specialbg-tertiary-transparent-inverted);
170
170
  }
package/modern/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react-transition-group" />
2
2
  import { HTMLAttributes, ReactElement, ReactNode, RefObject } from 'react';
3
+ import { HandledEvents } from 'react-swipeable/es/types';
3
4
  import { TransitionProps } from 'react-transition-group/Transition';
4
5
  import { BaseModalProps } from "@alfalab/core-components-base-modal";
5
6
  import { NavigationBarProps } from "@alfalab/core-components-navigation-bar";
@@ -263,5 +264,9 @@ type BottomSheetProps = {
263
264
  * Вызывается при изменении положения шторки
264
265
  */
265
266
  onOffsetChange?: (offset: number, percent: number) => void;
267
+ /**
268
+ * Вызывается для событий touchend and mouseup.
269
+ */
270
+ onTouchEnd?: (event: HandledEvents) => void;
266
271
  };
267
272
  export { BottomSheetTitleAlign, BottomSheetProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-bottom-sheet",
3
- "version": "6.7.0",
3
+ "version": "6.8.0",
4
4
  "description": "Bottom sheet mobile component",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -17,8 +17,8 @@
17
17
  "dependencies": {
18
18
  "@alfalab/core-components-backdrop": "^3.1.0",
19
19
  "@alfalab/core-components-base-modal": "^5.4.0",
20
- "@alfalab/core-components-navigation-bar": "^0.5.2",
21
- "@alfalab/core-components-shared": "^0.2.0",
20
+ "@alfalab/core-components-navigation-bar": "^0.5.4",
21
+ "@alfalab/core-components-shared": "^0.4.0",
22
22
  "classnames": "^2.3.1",
23
23
  "react-div-100vh": "^0.7.0",
24
24
  "react-merge-refs": "^1.1.0",
package/src/component.tsx CHANGED
@@ -14,7 +14,7 @@ import { HandledEvents } from 'react-swipeable/es/types';
14
14
  import cn from 'classnames';
15
15
 
16
16
  import { BaseModal } from '@alfalab/core-components-base-modal';
17
- import { getDataTestId } from '@alfalab/core-components-shared';
17
+ import { fnUtils, getDataTestId } from '@alfalab/core-components-shared';
18
18
 
19
19
  import { Footer } from './components/footer/Component';
20
20
  import { Header, HeaderProps } from './components/header/Component';
@@ -31,6 +31,8 @@ import {
31
31
 
32
32
  import styles from './index.module.css';
33
33
 
34
+ const { isNil } = fnUtils;
35
+
34
36
  export const BottomSheet = forwardRef<HTMLDivElement, BottomSheetProps>(
35
37
  (
36
38
  {
@@ -87,6 +89,7 @@ export const BottomSheet = forwardRef<HTMLDivElement, BottomSheetProps>(
87
89
  onClose,
88
90
  onBack,
89
91
  onMagnetize,
92
+ onTouchEnd,
90
93
  disableRestoreFocus,
91
94
  disableAutoFocus,
92
95
  disableEscapeKeyDown,
@@ -98,7 +101,6 @@ export const BottomSheet = forwardRef<HTMLDivElement, BottomSheetProps>(
98
101
  },
99
102
  ref,
100
103
  ) => {
101
- const hasInitialIdx = initialActiveAreaIndex !== undefined;
102
104
  const fullHeight = use100vh() || 0;
103
105
  // Хук use100vh рассчитывает высоту вьюпорта в useEffect, поэтому на первый рендер всегда возвращает null.
104
106
  const isFirstRender = fullHeight === 0;
@@ -357,7 +359,8 @@ export const BottomSheet = forwardRef<HTMLDivElement, BottomSheetProps>(
357
359
  setSwipingInProgress(true);
358
360
  };
359
361
 
360
- const handleTouchEnd: TapCallback = () => {
362
+ const handleTouchEnd: TapCallback = ({ event }) => {
363
+ onTouchEnd?.(event);
361
364
  setSwipingInProgress(false);
362
365
  scrollOccurred.current = false;
363
366
  };
@@ -389,12 +392,10 @@ export const BottomSheet = forwardRef<HTMLDivElement, BottomSheetProps>(
389
392
 
390
393
  const handleExited = (node: HTMLElement) => {
391
394
  const idx = initialActiveAreaIndex as number;
392
- const nextArea = hasInitialIdx ? magneticAreas[idx] : lastMagneticArea;
395
+ const nextArea = isNil(idx) ? lastMagneticArea : magneticAreas[idx];
393
396
 
394
397
  setBackdropOpacity(1);
395
- setSheetOffset(
396
- hasInitialIdx ? lastMagneticArea - magneticAreas[idx] : magneticAreas[0],
397
- );
398
+ setSheetOffset(isNil(idx) ? magneticAreas[0] : lastMagneticArea - magneticAreas[idx]);
398
399
  setActiveArea(nextArea);
399
400
  onMagnetizeEnd?.();
400
401
  if (transitionProps.onExited) {
@@ -431,19 +432,14 @@ export const BottomSheet = forwardRef<HTMLDivElement, BottomSheetProps>(
431
432
  };
432
433
 
433
434
  useEffect(() => {
434
- // Инициализируем стейт только после того, как была рассчитана высота вьюпорта.
435
+ // Инициализируем стейт только после того, как была рассчитана высота вьюпорта
435
436
  if (!isFirstRender) {
436
- setSheetOffset(
437
- hasInitialIdx ? lastMagneticArea - magneticAreas[initialActiveAreaIndex] : 0,
438
- );
437
+ const idx = initialActiveAreaIndex as number;
439
438
 
440
- setActiveArea(
441
- hasInitialIdx ? magneticAreas[initialActiveAreaIndex] : lastMagneticArea,
442
- );
439
+ setSheetOffset(isNil(idx) ? 0 : lastMagneticArea - magneticAreas[idx]);
440
+ setActiveArea(isNil(idx) ? lastMagneticArea : magneticAreas[idx]);
443
441
  }
444
-
445
- // eslint-disable-next-line react-hooks/exhaustive-deps
446
- }, [isFirstRender]);
442
+ }, [initialActiveAreaIndex, isFirstRender, lastMagneticArea, magneticAreas]);
447
443
 
448
444
  useEffect(() => {
449
445
  if (!sheetRef.current) return;
package/src/types.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { HTMLAttributes, ReactElement, ReactNode, RefObject } from 'react';
2
+ import type { HandledEvents } from 'react-swipeable/es/types';
2
3
  import type { TransitionProps } from 'react-transition-group/Transition';
3
4
 
4
5
  import type { BaseModalProps } from '@alfalab/core-components-base-modal';
@@ -325,4 +326,9 @@ export type BottomSheetProps = {
325
326
  * Вызывается при изменении положения шторки
326
327
  */
327
328
  onOffsetChange?: (offset: number, percent: number) => void;
329
+
330
+ /**
331
+ * Вызывается для событий touchend and mouseup.
332
+ */
333
+ onTouchEnd?: (event: HandledEvents) => void;
328
334
  };
package/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react-transition-group" />
2
2
  import { HTMLAttributes, ReactElement, ReactNode, RefObject } from 'react';
3
+ import { HandledEvents } from 'react-swipeable/es/types';
3
4
  import { TransitionProps } from 'react-transition-group/Transition';
4
5
  import { BaseModalProps } from "@alfalab/core-components-base-modal";
5
6
  import { NavigationBarProps } from "@alfalab/core-components-navigation-bar";
@@ -263,5 +264,9 @@ type BottomSheetProps = {
263
264
  * Вызывается при изменении положения шторки
264
265
  */
265
266
  onOffsetChange?: (offset: number, percent: number) => void;
267
+ /**
268
+ * Вызывается для событий touchend and mouseup.
269
+ */
270
+ onTouchEnd?: (event: HandledEvents) => void;
266
271
  };
267
272
  export { BottomSheetTitleAlign, BottomSheetProps };