@cloud-ru/ds-drawer 1.1.1 → 1.1.2-preview-86f06def.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-ru/ds-drawer",
3
- "version": "1.1.1",
3
+ "version": "1.1.2-preview-86f06def.0",
4
4
  "description": "Пакет выезжающих панелей — компоненты Drawer и DrawerCustom с едиными токенами позиции и ширины.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,13 +40,13 @@
40
40
  "classnames": "^2.5.1",
41
41
  "react-remove-scroll": "^2.7.2",
42
42
  "tabbable": "^6.5.0",
43
- "@cloud-ru/ds-adaptive": "^1.0.1",
44
- "@cloud-ru/ds-bottom-sheet": "^1.1.1",
45
- "@cloud-ru/ds-materials": "^1.0.1",
46
- "@cloud-ru/ds-popup-private": "^1.1.1",
47
- "@cloud-ru/ds-portal-context": "^1.0.1",
48
- "@cloud-ru/ds-scroll": "^1.0.2",
49
- "@cloud-ru/ds-tooltip": "^1.0.4",
50
- "@cloud-ru/ds-utils": "^1.1.0"
43
+ "@cloud-ru/ds-adaptive": "1.0.1",
44
+ "@cloud-ru/ds-popup-private": "1.1.2-preview-86f06def.0",
45
+ "@cloud-ru/ds-scroll": "1.0.2",
46
+ "@cloud-ru/ds-bottom-sheet": "1.1.2-preview-86f06def.0",
47
+ "@cloud-ru/ds-portal-context": "1.0.1",
48
+ "@cloud-ru/ds-tooltip": "1.0.4",
49
+ "@cloud-ru/ds-utils": "1.1.0",
50
+ "@cloud-ru/ds-materials": "1.0.1"
51
51
  }
52
52
  }
@@ -10,7 +10,8 @@ import { DrawerCustomProps } from '../DrawerCustom';
10
10
  *
11
11
  * Только desktop: `position`, `width`, `heightAuto`, `nestedDrawer` (на mobile игнорируются).
12
12
  * Только mobile: `swipeEnabled`, `snapPoints`, `snapIndex`, `onSnapIndexChange`, `safeArea`, `withDividers`
13
- * (на desktop-панели игнорируются — это анатомия `BottomSheet`).
13
+ * (на desktop-панели игнорируются — это анатомия `BottomSheet`). `snapPoints` по умолчанию —
14
+ * `MOBILE_SNAP_POINTS_DEFAULT` (`[1]`): sheet открывается на весь вьюпорт.
14
15
  */
15
16
  export type DrawerProps = WithSupportProps<
16
17
  Omit<DrawerCustomProps, 'nestedDrawer' | 'push' | 'resizable'> &
@@ -19,7 +20,7 @@ export type DrawerProps = WithSupportProps<
19
20
  Pick<DialogBodyProps, 'content'> & {
20
21
  /** Ссылка на скроллируемый контейнер контента (например, для дозагрузки по скроллу). */
21
22
  contentRef?: Ref<HTMLElement>;
22
- /** Только mobile: разделители между шапкой/контентом/футером sheet'а. @default false */
23
+ /** Только mobile: разделители между шапкой/контентом/футером sheet'а. @default true */
23
24
  withDividers?: boolean;
24
25
  /** Текстовая строка-подзаголовок под title. */
25
26
  subtitle?: ReactNode;
@@ -34,7 +35,8 @@ export type DrawerProps = WithSupportProps<
34
35
  /** Дополнительная (третья) кнопка — пропсы `Button` (дефолт `view='simple'`, `appearance='neutral'`). */
35
36
  additionalButton?: BottomSheetActionButton;
36
37
  /**
37
- * Ориентация кнопок футера. Применяется только при двух кнопках; игнорируется при заданном `footer`.
38
+ * Ориентация кнопок футера. Игнорируется при заданном `footer`. Без значения раскладку
39
+ * выбирает поверхность: два действия — в строку, три — стопкой.
38
40
  * @default 'horizontal'
39
41
  */
40
42
  footerActionsOrientation?: FooterActionsOrientation;
@@ -8,7 +8,7 @@ import cn from 'classnames';
8
8
  import { ComponentType, CSSProperties, useMemo } from 'react';
9
9
  import { RemoveScroll } from 'react-remove-scroll';
10
10
 
11
- import { TEST_IDS, WIDTH_AS_VALUES } from '../../constants';
11
+ import { MOBILE_SNAP_POINTS_DEFAULT, TEST_IDS, WIDTH_AS_VALUES } from '../../constants';
12
12
  import {
13
13
  DialogBody,
14
14
  DialogBodyProps,
@@ -157,8 +157,9 @@ function DrawerFrame(props: DrawerCustomProps) {
157
157
  }
158
158
 
159
159
  /**
160
- * Адаптивный low-level `DrawerCustom`: на `mobile` — `BottomSheetCustom`, иначе — `DrawerFrame`.
161
- * Композиция одна (surface-aware слоты `.Header/.Body/.Footer`). Форс — `withLayoutType`.
160
+ * Адаптивный low-level `DrawerCustom`: на `mobile` — `BottomSheetCustom` (по умолчанию —
161
+ * full-screen, см. `MOBILE_SNAP_POINTS_DEFAULT`), иначе — `DrawerFrame`. Композиция одна
162
+ * (surface-aware слоты `.Header/.Body/.Footer`). Форс — `withLayoutType`.
162
163
  */
163
164
  export function DrawerCustom(props: DrawerCustomProps) {
164
165
  const { layoutType } = useAdaptiveLayout();
@@ -173,7 +174,7 @@ export function DrawerCustom(props: DrawerCustomProps) {
173
174
  container,
174
175
  closeOnPopstate,
175
176
  showBlackout,
176
- snapPoints,
177
+ snapPoints = MOBILE_SNAP_POINTS_DEFAULT,
177
178
  swipeEnabled,
178
179
  safeArea,
179
180
  disableMotions,
@@ -73,5 +73,6 @@ export type DrawerCustomProps = WithSupportProps<
73
73
  };
74
74
  }>
75
75
  > &
76
- // Только mobile: управляют sheet-поверхностью (на desktop игнорируются).
76
+ // Только mobile: управляют sheet-поверхностью (на desktop игнорируются). `snapPoints` по
77
+ // умолчанию — `MOBILE_SNAP_POINTS_DEFAULT` (`[1]`): sheet открывается на весь вьюпорт.
77
78
  Pick<BottomSheetCustomProps, 'snapPoints' | 'swipeEnabled' | 'safeArea'>;
package/src/constants.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { SnapPoint } from '@cloud-ru/ds-bottom-sheet';
2
+
1
3
  export const TEST_IDS = {
2
4
  closeButton: 'drawer__close-button',
3
5
  header: 'drawer__header',
@@ -29,3 +31,9 @@ export const POSITION = {
29
31
  Top: 'top',
30
32
  Bottom: 'bottom',
31
33
  } as const;
34
+
35
+ /**
36
+ * Snap-точки мобильной поверхности дровера по умолчанию: одна позиция на весь вьюпорт.
37
+ * Дровер на mobile открывается сразу full-screen; swipe-down закрывает его.
38
+ */
39
+ export const MOBILE_SNAP_POINTS_DEFAULT: SnapPoint[] = [1];
@@ -27,7 +27,7 @@ export type DialogFooterProps = SheetFooterProps & {
27
27
  cancelButton?: BottomSheetActionButton;
28
28
  /** Дополнительная (третья) кнопка. */
29
29
  additionalButton?: BottomSheetActionButton;
30
- /** Ориентация кнопок при ровно двух действиях. */
30
+ /** Ориентация кнопок; без значения — по числу действий (два в строку, три стопкой). */
31
31
  footerActionsOrientation?: FooterActionsOrientation;
32
32
  };
33
33
 
@@ -2,7 +2,7 @@ import { BottomSheet } from '@cloud-ru/ds-bottom-sheet';
2
2
  import { extractSupportProps } from '@cloud-ru/ds-utils';
3
3
 
4
4
  import { DrawerProps } from '../../components/Drawer/types';
5
- import { TEST_IDS } from '../../constants';
5
+ import { MOBILE_SNAP_POINTS_DEFAULT, TEST_IDS } from '../../constants';
6
6
 
7
7
  /**
8
8
  * Mobile-поверхность Drawer'а: контент в `BottomSheet`, слоты маппятся на API sheet'а
@@ -30,17 +30,16 @@ export function MobileDrawer({
30
30
  container,
31
31
  closeOnPopstate,
32
32
  swipeEnabled,
33
- snapPoints,
33
+ snapPoints = MOBILE_SNAP_POINTS_DEFAULT,
34
34
  snapIndex,
35
35
  onSnapIndexChange,
36
36
  safeArea,
37
- withDividers = false,
37
+ withDividers,
38
38
  ...rest
39
39
  }: DrawerProps) {
40
40
  // Футер собирает сам `BottomSheet`.
41
41
  return (
42
42
  <BottomSheet
43
- // Дефолт `withDividers` в sheet'е — `true`; у Drawer'а вид исторически без разделителей.
44
43
  withDividers={withDividers}
45
44
  open={open}
46
45
  onClose={onClose}