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