@cloud-ru/ds-bottom-sheet 1.2.1 → 1.2.2-preview-3ffb7c01.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,5 +1,4 @@
1
1
  import { FooterActions, PopupMedia } from '@cloud-ru/ds-popup-private';
2
- import cn from 'classnames';
3
2
  import { isValidElement, ReactNode, useId } from 'react';
4
3
 
5
4
  import { TEST_IDS } from '../../constants';
@@ -11,7 +10,7 @@ function isMediaProps(value: BottomSheetMediaProps | ReactNode): value is Bottom
11
10
  return typeof value === 'object' && value !== null && !isValidElement(value) && 'src' in value && 'alt' in value;
12
11
  }
13
12
 
14
- /** Обёртка `@cloud-ru/ds-bottom-sheet` с готовой анатомией: media + header + body + footer + safeArea + dividers. */
13
+ /** Обёртка `@cloud-ru/ds-bottom-sheet` с готовой анатомией: media + header + body + footer + safe-area + dividers. */
15
14
  export function BottomSheet({
16
15
  title,
17
16
  slotAfterTitle,
@@ -30,7 +29,7 @@ export function BottomSheet({
30
29
  footerTestIds,
31
30
  withDividers = true,
32
31
  swipeEnabled = true,
33
- // safeArea уходит в `...rest` → BottomSheetCustom (env-паддинг на `.content`).
32
+ // safeAreaTop/safeAreaBottom уходят в `...rest` → BottomSheetCustom (env-паддинг на `.content`).
34
33
  className,
35
34
  ...rest
36
35
  }: BottomSheetProps) {
@@ -38,7 +37,6 @@ export function BottomSheet({
38
37
  title || onBackButtonClick || actionButton || slotAfterTitle || subtitle || slotSecondTitle,
39
38
  );
40
39
  const hasMedia = media != null;
41
- const hasFullWidthMediaImage = hasMedia && isMediaProps(media) && (media.kind ?? 'image') === 'image';
42
40
 
43
41
  // aria-labelledby связывает заголовок с dialog'ом; без title имя задаёт потребитель через aria-label.
44
42
  const titleId = useId();
@@ -85,7 +83,7 @@ export function BottomSheet({
85
83
  </div>
86
84
  ))}
87
85
 
88
- <div className={cn(styles.contentBlock, hasFullWidthMediaImage && styles.contentBlockNoTopPadding)}>
86
+ <div className={styles.contentBlock}>
89
87
  {hasHeader && (
90
88
  <BottomSheetCustom.Header
91
89
  title={title}
@@ -1,5 +1,4 @@
1
1
  @use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
2
- @use '@cloud-ru/ds-figma-variables/build/scss/components/bottomSheet.module' as bottomSheet;
3
2
 
4
3
  .root {
5
4
  display: flex;
@@ -26,13 +25,5 @@
26
25
 
27
26
  box-sizing: border-box;
28
27
  min-height: 0;
29
- // Верхний зазор контента: коллекция bottomSheet больше не несёт `content.padding-top`
30
- // (chrome уехал в popupPrivate). Верхний отступ шапки теперь owns PopupHeader
31
- // (popupPrivate `bottomSheet.header.padding-top`); здесь остаётся frame-паддинг `container.padding-top`.
32
- padding-top: base.simple-var(bottomSheet.$bottomSheet, 'anatomy', 'container', 'padding-top');
33
- }
34
-
35
- .contentBlockNoTopPadding {
36
- padding-top: 0;
37
28
  }
38
29
 
@@ -52,7 +52,8 @@ export function BottomSheetCustom(props: BottomSheetCustomProps) {
52
52
  showBackdrop = true,
53
53
  lockScroll = true,
54
54
  swipeEnabled = true,
55
- safeArea = true,
55
+ safeAreaTop = true,
56
+ safeAreaBottom = true,
56
57
  snapPoints,
57
58
  defaultSnapIndex,
58
59
  snapIndex,
@@ -188,7 +189,8 @@ export function BottomSheetCustom(props: BottomSheetCustomProps) {
188
189
  // aria-modal только для модального sheet'а: non-modal оставляет фон доступным AT.
189
190
  aria-modal={isModal ? 'true' : undefined}
190
191
  data-test-id={TEST_IDS.root}
191
- data-safe-area={safeArea || undefined}
192
+ data-safe-area-top={(safeAreaTop && isFullHeight) || undefined}
193
+ data-safe-area-bottom={safeAreaBottom || undefined}
192
194
  data-snap-index={activeSnapIndex}
193
195
  // Пустой массив ведёт себя как single fit-content — атрибут не выставляем.
194
196
  data-snap-points={snapPoints && snapPoints.length > 0 ? snapPoints.length : undefined}
@@ -45,10 +45,10 @@
45
45
  display: flex;
46
46
  flex-direction: column;
47
47
 
48
- // Верхний зазор для не-full snap'ов: видна подложка (tap-to-dismiss) + уважение notch (min 32px).
48
+ // Верхний зазор для не-full snap'ов: видна подложка (tap-to-dismiss) + уважение notch.
49
49
  max-height: calc(
50
50
  100% - max(
51
- #{base.simple-var(bottomSheet.$bottomSheet, 'anatomy', 'safeArea', 'padding-top')},
51
+ #{base.simple-var(bottomSheet.$bottomSheet, 'anatomy', 'safeArea', 'overlay', 'padding')},
52
52
  env(safe-area-inset-top)
53
53
  )
54
54
  );
@@ -83,7 +83,6 @@
83
83
  width: 100%;
84
84
  min-height: 0;
85
85
  max-height: 100%;
86
- padding-top: base.simple-var(bottomSheet.$bottomSheet, 'anatomy', 'container', 'padding-top');
87
86
  border-top-left-radius: base.simple-var(bottomSheet.$bottomSheet, 'anatomy', 'container', 'border-top-left-radius');
88
87
  border-top-right-radius: base.simple-var(bottomSheet.$bottomSheet, 'anatomy', 'container', 'border-top-right-radius');
89
88
 
@@ -116,14 +115,20 @@
116
115
  border-top-right-radius: 0;
117
116
  }
118
117
 
119
- // Safe-area: env-паддинг прямо на `.content`. Нижний — всегда (home-indicator), верхний —
120
- // только при full-height (верх уходит под notch). Без выреза `env(...)` = 0.
121
- &[data-safe-area] {
122
- padding-bottom: env(safe-area-inset-bottom);
118
+ // Safe-area: токен из макета как минимум, на устройстве с вырезом — env, если он больше.
119
+ // Верхний выставляется только при full-height (верх уходит под notch), см. `data-safe-area-top`.
120
+ &[data-safe-area-bottom] {
121
+ padding-bottom: max(
122
+ #{base.simple-var(bottomSheet.$bottomSheet, 'anatomy', 'safeArea', 'bottom', 'min-height')},
123
+ env(safe-area-inset-bottom)
124
+ );
123
125
  }
124
126
 
125
- &[data-safe-area][data-full-height] {
126
- padding-top: env(safe-area-inset-top);
127
+ &[data-safe-area-top] {
128
+ padding-top: max(
129
+ #{base.simple-var(bottomSheet.$bottomSheet, 'anatomy', 'safeArea', 'top', 'min-height')},
130
+ env(safe-area-inset-top)
131
+ );
127
132
  }
128
133
  }
129
134
 
package/src/types.ts CHANGED
@@ -89,13 +89,18 @@ export type BottomSheetCustomProps = WithSupportProps<
89
89
  */
90
90
  closeOnPopstate?: boolean;
91
91
  /**
92
- * Резервировать ли место под iOS notch / home-indicator и Android nav-bar. Реализовано паддингом
93
- * на `.content` через `env(safe-area-inset-*)`: на устройстве без выреза/индикатора (и на desktop)
94
- * inset = 0, поэтому никакого «лишнего» отступа не появляется; на notched-устройстве — ровно нужный.
95
- * Верхний отступ добавляется только когда sheet раскрыт на полный вьюпорт (его верх под notch).
92
+ * Верхний safe-area отступ под iOS notch / status-bar. Размер — токен `safeArea.top.minHeight`,
93
+ * на устройстве с большим `env(safe-area-inset-top)` — значение inset. Применяется, только когда
94
+ * sheet раскрыт на полный вьюпорт: у неполного sheet'а верх и так не заходит под notch.
96
95
  * @default true
97
96
  */
98
- safeArea?: boolean;
97
+ safeAreaTop?: boolean;
98
+ /**
99
+ * Нижний safe-area отступ под iOS home-indicator и Android nav-bar. Размер — токен
100
+ * `safeArea.bottom.minHeight`, на устройстве с большим `env(safe-area-inset-bottom)` — значение inset.
101
+ * @default true
102
+ */
103
+ safeAreaBottom?: boolean;
99
104
  /**
100
105
  * Отключить анимации открытия / закрытия и перехода между snap-точками.
101
106
  * @default false