@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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 1.2.0 (2026-09-10)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **FF-8978:** expose truncate prop on Drawer header ([f2de71d](https://github.com/cloud-ru-tech/snack-v2/commit/f2de71d976205a9b78d7a93f60a16592801ff26e))
|
|
11
|
+
|
|
6
12
|
## 1.1.1 (2026-09-01)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @ds/drawer
|
package/README.md
CHANGED
|
@@ -252,7 +252,7 @@ export function NestedDrawer() {
|
|
|
252
252
|
| `data-test-id` | `string` | — | |
|
|
253
253
|
| `disableMotions` | `boolean` | `false` | Отключить анимации |
|
|
254
254
|
| `footer` | `(ReactElement<any, string \| JSXElementConstructor<any>> & (string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<...> \| ReactPortal \| null))` | — | Футер <br/> Произвольный футер. Приоритетнее `approveButton` / `cancelButton` / `additionalButton`. |
|
|
255
|
-
| `footerActionsOrientation` | `"horizontal"` \| `"vertical"` | `'horizontal'` | Ориентация кнопок футера.
|
|
255
|
+
| `footerActionsOrientation` | `"horizontal"` \| `"vertical"` | `'horizontal'` | Ориентация кнопок футера. Применяется только при двух кнопках; игнорируется при заданном `footer`. |
|
|
256
256
|
| `heightAuto` | `boolean` | `false` | Высота панели по контенту (только при `position: "top" \| "bottom"`). |
|
|
257
257
|
| `media` | `ReactNode` | — | Медиа-контент |
|
|
258
258
|
| `nestedDrawer` | `DrawerProps` | — | Вложенный Drawer |
|
|
@@ -272,8 +272,9 @@ export function NestedDrawer() {
|
|
|
272
272
|
| `subtitle` | `ReactNode` | — | Текстовая строка-подзаголовок под title. |
|
|
273
273
|
| `swipeEnabled` | `boolean` | `true` | Включает swipe-down для закрытия / swipe-up для раскрытия на следующий snap-point. <br/> При `swipeEnabled=false` snap-point по-прежнему можно переключить через controlled `snapIndex` prop'ом. |
|
|
274
274
|
| `title` | `ReactNode` | — | Заголовок. Типографика зависит от поверхности: `title-l` на sheet, `headline-s` на window (modal/drawer). |
|
|
275
|
+
| `truncate` | `{ title?: number; subtitle?: number; } \| undefined` | — | Усечение строковых `title`/`subtitle` через `TruncateString` (число строк). Применяется только <br/> когда задано — по умолчанию текст не усекается. Актуально для window-поверхности (modal/drawer), <br/> где длинный заголовок иначе переносится на несколько строк. |
|
|
275
276
|
| `width` | `Width` | `'s'` | Ширина (только при position: "left" \| "right") |
|
|
276
|
-
| `withDividers` | `boolean` | `
|
|
277
|
+
| `withDividers` | `boolean` | `false` | Только mobile: разделители между шапкой/контентом/футером sheet'а. |
|
|
277
278
|
|
|
278
279
|
##### Related types
|
|
279
280
|
|
|
@@ -293,7 +294,7 @@ export function NestedDrawer() {
|
|
|
293
294
|
| `data-test-id` | `string \| undefined` | — | |
|
|
294
295
|
| `disableMotions` | `boolean \| undefined` | — | Отключить анимации |
|
|
295
296
|
| `footer` | `(ReactElement<any, string \| JSXElementConstructor<any>> & (string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| null)) \| undefined` | — | Футер <br/> Произвольный футер. Приоритетнее `approveButton` / `cancelButton` / `additionalButton`. |
|
|
296
|
-
| `footerActionsOrientation` | `"horizontal"` \| `"vertical"` | — | Ориентация кнопок футера.
|
|
297
|
+
| `footerActionsOrientation` | `"horizontal"` \| `"vertical"` | — | Ориентация кнопок футера. Применяется только при двух кнопках; игнорируется при заданном `footer`. |
|
|
297
298
|
| `heightAuto` | `boolean \| undefined` | — | Высота панели по контенту (только при `position: "top" \| "bottom"`). |
|
|
298
299
|
| `media` | `string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| null \| undefined` | — | Медиа-контент |
|
|
299
300
|
| `nestedDrawer` | `DrawerProps` | — | Вложенный Drawer |
|
|
@@ -313,6 +314,7 @@ export function NestedDrawer() {
|
|
|
313
314
|
| `subtitle` | `string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| null \| undefined` | — | Текстовая строка-подзаголовок под title. |
|
|
314
315
|
| `swipeEnabled` | `boolean \| undefined` | — | Включает swipe-down для закрытия / swipe-up для раскрытия на следующий snap-point. <br/> При `swipeEnabled=false` snap-point по-прежнему можно переключить через controlled `snapIndex` prop'ом. |
|
|
315
316
|
| `title` | `string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| null \| undefined` | — | Заголовок. Типографика зависит от поверхности: `title-l` на sheet, `headline-s` на window (modal/drawer). |
|
|
317
|
+
| `truncate` | `{ title?: number; subtitle?: number; } \| undefined` | — | Усечение строковых `title`/`subtitle` через `TruncateString` (число строк). Применяется только <br/> когда задано — по умолчанию текст не усекается. Актуально для window-поверхности (modal/drawer), <br/> где длинный заголовок иначе переносится на несколько строк. |
|
|
316
318
|
| `width` | `Width` | — | Ширина (только при position: "left" \| "right") |
|
|
317
319
|
| `withDividers` | `boolean \| undefined` | — | Только mobile: разделители между шапкой/контентом/футером sheet'а. |
|
|
318
320
|
|
|
@@ -325,7 +327,7 @@ export function NestedDrawer() {
|
|
|
325
327
|
`Drawer` — адаптивный компонент с переключением поверхности (surface-swap). Раскладку он берёт из `AdaptiveProvider` (контекст `@cloud-ru/ds-adaptive`); публичный API единый для обеих платформ:
|
|
326
328
|
|
|
327
329
|
- **desktop** (по умолчанию) — панель, выезжающая со стороны экрана (`left`/`right`/`top`/`bottom`).
|
|
328
|
-
- **mobile** — контент рендерится в `BottomSheet` из `@cloud-ru/ds-bottom-sheet` (панель снизу со свайпом для закрытия).
|
|
330
|
+
- **mobile** — контент рендерится в `BottomSheet` из `@cloud-ru/ds-bottom-sheet` (панель снизу со свайпом для закрытия).
|
|
329
331
|
|
|
330
332
|
Верстайте под desktop и поставьте один `<AdaptiveProvider>` в корне приложения — mobile-поверхность включается автоматически (desktop-first). Пропа `layoutType` у компонента нет: источник раскладки — только контекст.
|
|
331
333
|
|
|
@@ -358,7 +360,6 @@ export function NestedDrawer() {
|
|
|
358
360
|
| `position`, `width`, `heightAuto`, `nestedDrawer` | используется | игнорируется |
|
|
359
361
|
| `title`, `subtitle`, `slotAfterTitle`, `onBackButtonClick`, `media`, `content`, `footer` | используется | используется |
|
|
360
362
|
| `open`, `onClose`, `showBlackout`, `container`, `closeOnPopstate`, `className`, `rootClassName` | используется | используется |
|
|
361
|
-
| `swipeEnabled`, `snapPoints`, `snapIndex`, `onSnapIndexChange`, `safeArea`, `withDividers` | игнорируется | используется |
|
|
362
363
|
|
|
363
364
|
Подробнее о модели адаптивности — **Adaptive**.
|
|
364
365
|
|
|
@@ -6,15 +6,14 @@ import { DrawerCustomProps } from '../DrawerCustom';
|
|
|
6
6
|
/**
|
|
7
7
|
* Адаптивный Drawer: desktop — боковая/верхняя/нижняя панель, `mobile` — `BottomSheet`.
|
|
8
8
|
*
|
|
9
|
-
* Только desktop: `position`, `width`, `heightAuto`, `nestedDrawer` (на mobile игнорируются).
|
|
9
|
+
* Только desktop: `position`, `width`, `heightAuto`, `nestedDrawer`, `truncate` (на mobile игнорируются).
|
|
10
10
|
* Только mobile: `swipeEnabled`, `snapPoints`, `snapIndex`, `onSnapIndexChange`, `safeArea`, `withDividers`
|
|
11
|
-
* (на desktop-панели игнорируются — это анатомия `BottomSheet`).
|
|
12
|
-
* `MOBILE_SNAP_POINTS_DEFAULT` (`[1]`): sheet открывается на весь вьюпорт.
|
|
11
|
+
* (на desktop-панели игнорируются — это анатомия `BottomSheet`).
|
|
13
12
|
*/
|
|
14
|
-
export type DrawerProps = WithSupportProps<Omit<DrawerCustomProps, 'nestedDrawer' | 'push' | 'resizable'> & Pick<BottomSheetProps, 'swipeEnabled' | 'snapPoints' | 'snapIndex' | 'onSnapIndexChange' | 'safeArea'> & Pick<DialogHeaderProps, 'title' | 'slotAfterTitle' | 'slotSecondTitle' | 'onBackButtonClick'> & Pick<DialogBodyProps, 'content'> & {
|
|
13
|
+
export type DrawerProps = WithSupportProps<Omit<DrawerCustomProps, 'nestedDrawer' | 'push' | 'resizable'> & Pick<BottomSheetProps, 'swipeEnabled' | 'snapPoints' | 'snapIndex' | 'onSnapIndexChange' | 'safeArea'> & Pick<DialogHeaderProps, 'title' | 'slotAfterTitle' | 'slotSecondTitle' | 'onBackButtonClick' | 'truncate'> & Pick<DialogBodyProps, 'content'> & {
|
|
15
14
|
/** Ссылка на скроллируемый контейнер контента (например, для дозагрузки по скроллу). */
|
|
16
15
|
contentRef?: Ref<HTMLElement>;
|
|
17
|
-
/** Только mobile: разделители между шапкой/контентом/футером sheet'а. @default
|
|
16
|
+
/** Только mobile: разделители между шапкой/контентом/футером sheet'а. @default false */
|
|
18
17
|
withDividers?: boolean;
|
|
19
18
|
/** Текстовая строка-подзаголовок под title. */
|
|
20
19
|
subtitle?: ReactNode;
|
|
@@ -29,8 +28,7 @@ export type DrawerProps = WithSupportProps<Omit<DrawerCustomProps, 'nestedDrawer
|
|
|
29
28
|
/** Дополнительная (третья) кнопка — пропсы `Button` (дефолт `view='simple'`, `appearance='neutral'`). */
|
|
30
29
|
additionalButton?: BottomSheetActionButton;
|
|
31
30
|
/**
|
|
32
|
-
* Ориентация кнопок футера.
|
|
33
|
-
* выбирает поверхность: два действия — в строку, три — стопкой.
|
|
31
|
+
* Ориентация кнопок футера. Применяется только при двух кнопках; игнорируется при заданном `footer`.
|
|
34
32
|
* @default 'horizontal'
|
|
35
33
|
*/
|
|
36
34
|
footerActionsOrientation?: FooterActionsOrientation;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { DialogBody, DialogBodyProps, DialogFooter, DialogFooterProps, DialogHeader, DialogHeaderProps } from '../../helperComponents';
|
|
2
2
|
import { DrawerCustomProps } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* Адаптивный low-level `DrawerCustom`: на `mobile` — `BottomSheetCustom
|
|
5
|
-
*
|
|
6
|
-
* (surface-aware слоты `.Header/.Body/.Footer`). Форс — `withLayoutType`.
|
|
4
|
+
* Адаптивный low-level `DrawerCustom`: на `mobile` — `BottomSheetCustom`, иначе — `DrawerFrame`.
|
|
5
|
+
* Композиция одна (surface-aware слоты `.Header/.Body/.Footer`). Форс — `withLayoutType`.
|
|
7
6
|
*/
|
|
8
7
|
export declare function DrawerCustom(props: DrawerCustomProps): import("react/jsx-runtime").JSX.Element;
|
|
9
8
|
export declare namespace DrawerCustom {
|
|
@@ -62,14 +62,13 @@ function DrawerFrame(props) {
|
|
|
62
62
|
}, size: isPredefinedWidth ? 'null' : width, ...(0, utils_1.extractSupportProps)(rest), "data-content-wrapper": true, "data-position": position, "data-width": isPredefinedWidth ? width : undefined, "data-height-auto": heightAutoVertical ? true : undefined, "data-acrylic-appearance": 'neutral', "data-acrylic-level": '1Level', prefixCls: styles_module_scss_1.default.prefixCls, ...(disableMotions ? {} : constants_2.motionProps), children: (0, jsx_runtime_1.jsxs)(react_remove_scroll_1.RemoveScroll, { enabled: showBlackout || outerScrollLock, removeScrollBar: false, ref: focusTrapRef, className: styles_module_scss_1.default.scrollLock, children: [showButtonClosed && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.showButtonClosedWrapper, children: (0, jsx_runtime_1.jsx)(popup_private_1.PopupCloseButton, { className: styles_module_scss_1.default.showButtonClosed, "aria-label": 'close drawer', "data-test-id": constants_1.TEST_IDS.closeButton, onClick: onClose }) })), (0, jsx_runtime_1.jsx)(bottom_sheet_1.OverlaySurfaceProvider, { surface: bottom_sheet_1.OVERLAY_SURFACE.Drawer, bodyHeightAuto: heightAutoVertical, children: children }), tooltip, nestedDrawer] }) }));
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
* Адаптивный low-level `DrawerCustom`: на `mobile` — `BottomSheetCustom
|
|
66
|
-
*
|
|
67
|
-
* (surface-aware слоты `.Header/.Body/.Footer`). Форс — `withLayoutType`.
|
|
65
|
+
* Адаптивный low-level `DrawerCustom`: на `mobile` — `BottomSheetCustom`, иначе — `DrawerFrame`.
|
|
66
|
+
* Композиция одна (surface-aware слоты `.Header/.Body/.Footer`). Форс — `withLayoutType`.
|
|
68
67
|
*/
|
|
69
68
|
function DrawerCustom(props) {
|
|
70
69
|
const { layoutType } = (0, adaptive_1.useAdaptiveLayout)();
|
|
71
70
|
if ((0, adaptive_1.isMobileLayout)(layoutType)) {
|
|
72
|
-
const { open, onClose, children, className, rootClassName, container, closeOnPopstate, showBlackout, snapPoints
|
|
71
|
+
const { open, onClose, children, className, rootClassName, container, closeOnPopstate, showBlackout, snapPoints, swipeEnabled, safeArea, disableMotions, ...rest } = props;
|
|
73
72
|
return ((0, jsx_runtime_1.jsx)(bottom_sheet_1.BottomSheetCustom, { open: open, onClose: onClose, container: container, className: className, rootClassName: rootClassName, closeOnPopstate: closeOnPopstate, showBackdrop: showBlackout, snapPoints: snapPoints, swipeEnabled: swipeEnabled, safeArea: safeArea, disableMotions: disableMotions, ...(0, utils_1.extractSupportProps)(rest), children: children }));
|
|
74
73
|
}
|
|
75
74
|
return (0, jsx_runtime_1.jsx)(DrawerFrame, { ...props });
|
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SnapPoint } from '@cloud-ru/ds-bottom-sheet';
|
|
2
1
|
export declare const TEST_IDS: {
|
|
3
2
|
readonly closeButton: "drawer__close-button";
|
|
4
3
|
readonly header: "drawer__header";
|
|
@@ -27,8 +26,3 @@ export declare const POSITION: {
|
|
|
27
26
|
readonly Top: "top";
|
|
28
27
|
readonly Bottom: "bottom";
|
|
29
28
|
};
|
|
30
|
-
/**
|
|
31
|
-
* Snap-точки мобильной поверхности дровера по умолчанию: одна позиция на весь вьюпорт.
|
|
32
|
-
* Дровер на mobile открывается сразу full-screen; swipe-down закрывает его.
|
|
33
|
-
*/
|
|
34
|
-
export declare const MOBILE_SNAP_POINTS_DEFAULT: SnapPoint[];
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.POSITION = exports.WIDTH_AS_VALUES = exports.WIDTH = exports.TEST_IDS = void 0;
|
|
4
4
|
exports.TEST_IDS = {
|
|
5
5
|
closeButton: 'drawer__close-button',
|
|
6
6
|
header: 'drawer__header',
|
|
@@ -29,8 +29,3 @@ exports.POSITION = {
|
|
|
29
29
|
Top: 'top',
|
|
30
30
|
Bottom: 'bottom',
|
|
31
31
|
};
|
|
32
|
-
/**
|
|
33
|
-
* Snap-точки мобильной поверхности дровера по умолчанию: одна позиция на весь вьюпорт.
|
|
34
|
-
* Дровер на mobile открывается сразу full-screen; swipe-down закрывает его.
|
|
35
|
-
*/
|
|
36
|
-
exports.MOBILE_SNAP_POINTS_DEFAULT = [1];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DrawerProps } from '../../components/Drawer/types';
|
|
2
2
|
/** Desktop-поверхность Drawer'а: панель (`DrawerCustom`) с пресетной разметкой. Internal. */
|
|
3
|
-
export declare function DesktopDrawer({ content, media, title, slotAfterTitle, slotSecondTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, nestedDrawer, contentRef, className, ...rest }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function DesktopDrawer({ content, media, title, truncate, slotAfterTitle, slotSecondTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, nestedDrawer, contentRef, className, ...rest }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,13 +11,13 @@ const styles_module_scss_1 = __importDefault(require('../../components/Drawer/st
|
|
|
11
11
|
const DrawerCustom_1 = require("../../components/DrawerCustom");
|
|
12
12
|
const constants_2 = require("../../constants");
|
|
13
13
|
/** Desktop-поверхность Drawer'а: панель (`DrawerCustom`) с пресетной разметкой. Internal. */
|
|
14
|
-
function DesktopDrawer({ content, media, title, slotAfterTitle, slotSecondTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, nestedDrawer, contentRef,
|
|
14
|
+
function DesktopDrawer({ content, media, title, truncate, slotAfterTitle, slotSecondTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, nestedDrawer, contentRef,
|
|
15
15
|
// `withDividers` — mobile-only (мастер bottomSheet): молча уходит в `rest` и отбрасывается фреймом.
|
|
16
16
|
className, ...rest }) {
|
|
17
17
|
const showHeader = Boolean(title || subtitle || slotAfterTitle || slotSecondTitle);
|
|
18
18
|
// Произвольный `footer` приоритетнее кнопок-слотов; раскладку слотов делает сам `DrawerCustom.Footer`.
|
|
19
19
|
const hasFooter = Boolean(footer || approveButton || cancelButton || additionalButton);
|
|
20
|
-
return ((0, jsx_runtime_1.jsxs)(DrawerCustom_1.DrawerCustom, { ...rest, resizable: undefined, className: (0, classnames_1.default)(styles_module_scss_1.default.drawer, className), push: Boolean(nestedDrawer) && { distance: constants_1.NESTED_DRAWER_PUSH_DISTANCE }, children: [media, showHeader && ((0, jsx_runtime_1.jsx)(DrawerCustom_1.DrawerCustom.Header, { title: title, slotAfterTitle: slotAfterTitle, slotSecondTitle: slotSecondTitle, subtitle: subtitle, onBackButtonClick: onBackButtonClick,
|
|
20
|
+
return ((0, jsx_runtime_1.jsxs)(DrawerCustom_1.DrawerCustom, { ...rest, resizable: undefined, className: (0, classnames_1.default)(styles_module_scss_1.default.drawer, className), push: Boolean(nestedDrawer) && { distance: constants_1.NESTED_DRAWER_PUSH_DISTANCE }, children: [media, showHeader && ((0, jsx_runtime_1.jsx)(DrawerCustom_1.DrawerCustom.Header, { title: title, truncate: truncate, slotAfterTitle: slotAfterTitle, slotSecondTitle: slotSecondTitle, subtitle: subtitle, onBackButtonClick: onBackButtonClick,
|
|
21
21
|
// Сохраняем публичный контракт test-id'ов drawer'а поверх общего `PopupHeader`.
|
|
22
22
|
// slotAfterTitle НЕ переопределяем: id тултипа ставит сам потребитель на своём span.
|
|
23
23
|
testIds: {
|
|
@@ -9,7 +9,7 @@ export type DialogFooterProps = SheetFooterProps & {
|
|
|
9
9
|
cancelButton?: BottomSheetActionButton;
|
|
10
10
|
/** Дополнительная (третья) кнопка. */
|
|
11
11
|
additionalButton?: BottomSheetActionButton;
|
|
12
|
-
/** Ориентация
|
|
12
|
+
/** Ориентация кнопок при ровно двух действиях. */
|
|
13
13
|
footerActionsOrientation?: FooterActionsOrientation;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
@@ -10,9 +10,13 @@ const constants_1 = require("../../constants");
|
|
|
10
10
|
* (`subtitle` 1:1, `showBlackout→showBackdrop`, остальное 1:1). Internal. Desktop-only пропы
|
|
11
11
|
* уходят в `...rest`.
|
|
12
12
|
*/
|
|
13
|
-
function MobileDrawer({ content, media, title, slotAfterTitle, slotSecondTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, className, rootClassName, open, onClose, showBlackout, container, closeOnPopstate, swipeEnabled, snapPoints
|
|
13
|
+
function MobileDrawer({ content, media, title, slotAfterTitle, slotSecondTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, className, rootClassName, open, onClose, showBlackout, container, closeOnPopstate, swipeEnabled, snapPoints, snapIndex, onSnapIndexChange, safeArea, withDividers = false, ...rest }) {
|
|
14
14
|
// Футер собирает сам `BottomSheet`.
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)(bottom_sheet_1.BottomSheet
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(bottom_sheet_1.BottomSheet
|
|
16
|
+
// Дефолт `withDividers` в sheet'е — `true`; у Drawer'а вид исторически без разделителей.
|
|
17
|
+
, {
|
|
18
|
+
// Дефолт `withDividers` в sheet'е — `true`; у Drawer'а вид исторически без разделителей.
|
|
19
|
+
withDividers: withDividers, open: open, onClose: onClose, showBackdrop: showBlackout, title: title, subtitle: subtitle, slotAfterTitle: slotAfterTitle, slotSecondTitle: slotSecondTitle, onBackButtonClick: onBackButtonClick, media: media, content: content, approveButton: approveButton, cancelButton: cancelButton, additionalButton: additionalButton, footerActionsOrientation: footerActionsOrientation, footer: footer,
|
|
16
20
|
// Те же id футера, что у desktop-поверхности — стабильный селектор при свапе surface.
|
|
17
21
|
footerTestIds: {
|
|
18
22
|
approve: constants_1.TEST_IDS.footerApprove,
|
|
@@ -6,15 +6,14 @@ import { DrawerCustomProps } from '../DrawerCustom/index.js';
|
|
|
6
6
|
/**
|
|
7
7
|
* Адаптивный Drawer: desktop — боковая/верхняя/нижняя панель, `mobile` — `BottomSheet`.
|
|
8
8
|
*
|
|
9
|
-
* Только desktop: `position`, `width`, `heightAuto`, `nestedDrawer` (на mobile игнорируются).
|
|
9
|
+
* Только desktop: `position`, `width`, `heightAuto`, `nestedDrawer`, `truncate` (на mobile игнорируются).
|
|
10
10
|
* Только mobile: `swipeEnabled`, `snapPoints`, `snapIndex`, `onSnapIndexChange`, `safeArea`, `withDividers`
|
|
11
|
-
* (на desktop-панели игнорируются — это анатомия `BottomSheet`).
|
|
12
|
-
* `MOBILE_SNAP_POINTS_DEFAULT` (`[1]`): sheet открывается на весь вьюпорт.
|
|
11
|
+
* (на desktop-панели игнорируются — это анатомия `BottomSheet`).
|
|
13
12
|
*/
|
|
14
|
-
export type DrawerProps = WithSupportProps<Omit<DrawerCustomProps, 'nestedDrawer' | 'push' | 'resizable'> & Pick<BottomSheetProps, 'swipeEnabled' | 'snapPoints' | 'snapIndex' | 'onSnapIndexChange' | 'safeArea'> & Pick<DialogHeaderProps, 'title' | 'slotAfterTitle' | 'slotSecondTitle' | 'onBackButtonClick'> & Pick<DialogBodyProps, 'content'> & {
|
|
13
|
+
export type DrawerProps = WithSupportProps<Omit<DrawerCustomProps, 'nestedDrawer' | 'push' | 'resizable'> & Pick<BottomSheetProps, 'swipeEnabled' | 'snapPoints' | 'snapIndex' | 'onSnapIndexChange' | 'safeArea'> & Pick<DialogHeaderProps, 'title' | 'slotAfterTitle' | 'slotSecondTitle' | 'onBackButtonClick' | 'truncate'> & Pick<DialogBodyProps, 'content'> & {
|
|
15
14
|
/** Ссылка на скроллируемый контейнер контента (например, для дозагрузки по скроллу). */
|
|
16
15
|
contentRef?: Ref<HTMLElement>;
|
|
17
|
-
/** Только mobile: разделители между шапкой/контентом/футером sheet'а. @default
|
|
16
|
+
/** Только mobile: разделители между шапкой/контентом/футером sheet'а. @default false */
|
|
18
17
|
withDividers?: boolean;
|
|
19
18
|
/** Текстовая строка-подзаголовок под title. */
|
|
20
19
|
subtitle?: ReactNode;
|
|
@@ -29,8 +28,7 @@ export type DrawerProps = WithSupportProps<Omit<DrawerCustomProps, 'nestedDrawer
|
|
|
29
28
|
/** Дополнительная (третья) кнопка — пропсы `Button` (дефолт `view='simple'`, `appearance='neutral'`). */
|
|
30
29
|
additionalButton?: BottomSheetActionButton;
|
|
31
30
|
/**
|
|
32
|
-
* Ориентация кнопок футера.
|
|
33
|
-
* выбирает поверхность: два действия — в строку, три — стопкой.
|
|
31
|
+
* Ориентация кнопок футера. Применяется только при двух кнопках; игнорируется при заданном `footer`.
|
|
34
32
|
* @default 'horizontal'
|
|
35
33
|
*/
|
|
36
34
|
footerActionsOrientation?: FooterActionsOrientation;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { DialogBody, DialogBodyProps, DialogFooter, DialogFooterProps, DialogHeader, DialogHeaderProps } from '../../helperComponents/index.js';
|
|
2
2
|
import { DrawerCustomProps } from './types.js';
|
|
3
3
|
/**
|
|
4
|
-
* Адаптивный low-level `DrawerCustom`: на `mobile` — `BottomSheetCustom
|
|
5
|
-
*
|
|
6
|
-
* (surface-aware слоты `.Header/.Body/.Footer`). Форс — `withLayoutType`.
|
|
4
|
+
* Адаптивный low-level `DrawerCustom`: на `mobile` — `BottomSheetCustom`, иначе — `DrawerFrame`.
|
|
5
|
+
* Композиция одна (surface-aware слоты `.Header/.Body/.Footer`). Форс — `withLayoutType`.
|
|
7
6
|
*/
|
|
8
7
|
export declare function DrawerCustom(props: DrawerCustomProps): import("react/jsx-runtime").JSX.Element;
|
|
9
8
|
export declare namespace DrawerCustom {
|
|
@@ -8,7 +8,7 @@ import RcDrawerImport from '@rc-component/drawer';
|
|
|
8
8
|
import cn from 'classnames';
|
|
9
9
|
import { useMemo } from 'react';
|
|
10
10
|
import { RemoveScroll } from 'react-remove-scroll';
|
|
11
|
-
import {
|
|
11
|
+
import { TEST_IDS, WIDTH_AS_VALUES } from '../../constants.js';
|
|
12
12
|
import { DialogBody, DialogFooter, DialogHeader, } from '../../helperComponents/index.js';
|
|
13
13
|
import { interopDefault } from '../../utils/interopDefault.js';
|
|
14
14
|
import { motionProps } from './constants.js';
|
|
@@ -56,14 +56,13 @@ function DrawerFrame(props) {
|
|
|
56
56
|
}, size: isPredefinedWidth ? 'null' : width, ...extractSupportProps(rest), "data-content-wrapper": true, "data-position": position, "data-width": isPredefinedWidth ? width : undefined, "data-height-auto": heightAutoVertical ? true : undefined, "data-acrylic-appearance": 'neutral', "data-acrylic-level": '1Level', prefixCls: styles.prefixCls, ...(disableMotions ? {} : motionProps), children: _jsxs(RemoveScroll, { enabled: showBlackout || outerScrollLock, removeScrollBar: false, ref: focusTrapRef, className: styles.scrollLock, children: [showButtonClosed && (_jsx("div", { className: styles.showButtonClosedWrapper, children: _jsx(PopupCloseButton, { className: styles.showButtonClosed, "aria-label": 'close drawer', "data-test-id": TEST_IDS.closeButton, onClick: onClose }) })), _jsx(OverlaySurfaceProvider, { surface: OVERLAY_SURFACE.Drawer, bodyHeightAuto: heightAutoVertical, children: children }), tooltip, nestedDrawer] }) }));
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
* Адаптивный low-level `DrawerCustom`: на `mobile` — `BottomSheetCustom
|
|
60
|
-
*
|
|
61
|
-
* (surface-aware слоты `.Header/.Body/.Footer`). Форс — `withLayoutType`.
|
|
59
|
+
* Адаптивный low-level `DrawerCustom`: на `mobile` — `BottomSheetCustom`, иначе — `DrawerFrame`.
|
|
60
|
+
* Композиция одна (surface-aware слоты `.Header/.Body/.Footer`). Форс — `withLayoutType`.
|
|
62
61
|
*/
|
|
63
62
|
export function DrawerCustom(props) {
|
|
64
63
|
const { layoutType } = useAdaptiveLayout();
|
|
65
64
|
if (isMobileLayout(layoutType)) {
|
|
66
|
-
const { open, onClose, children, className, rootClassName, container, closeOnPopstate, showBlackout, snapPoints
|
|
65
|
+
const { open, onClose, children, className, rootClassName, container, closeOnPopstate, showBlackout, snapPoints, swipeEnabled, safeArea, disableMotions, ...rest } = props;
|
|
67
66
|
return (_jsx(BottomSheetCustom, { open: open, onClose: onClose, container: container, className: className, rootClassName: rootClassName, closeOnPopstate: closeOnPopstate, showBackdrop: showBlackout, snapPoints: snapPoints, swipeEnabled: swipeEnabled, safeArea: safeArea, disableMotions: disableMotions, ...extractSupportProps(rest), children: children }));
|
|
68
67
|
}
|
|
69
68
|
return _jsx(DrawerFrame, { ...props });
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SnapPoint } from '@cloud-ru/ds-bottom-sheet';
|
|
2
1
|
export declare const TEST_IDS: {
|
|
3
2
|
readonly closeButton: "drawer__close-button";
|
|
4
3
|
readonly header: "drawer__header";
|
|
@@ -27,8 +26,3 @@ export declare const POSITION: {
|
|
|
27
26
|
readonly Top: "top";
|
|
28
27
|
readonly Bottom: "bottom";
|
|
29
28
|
};
|
|
30
|
-
/**
|
|
31
|
-
* Snap-точки мобильной поверхности дровера по умолчанию: одна позиция на весь вьюпорт.
|
|
32
|
-
* Дровер на mobile открывается сразу full-screen; swipe-down закрывает его.
|
|
33
|
-
*/
|
|
34
|
-
export declare const MOBILE_SNAP_POINTS_DEFAULT: SnapPoint[];
|
package/dist/esm/constants.js
CHANGED
|
@@ -26,8 +26,3 @@ export const POSITION = {
|
|
|
26
26
|
Top: 'top',
|
|
27
27
|
Bottom: 'bottom',
|
|
28
28
|
};
|
|
29
|
-
/**
|
|
30
|
-
* Snap-точки мобильной поверхности дровера по умолчанию: одна позиция на весь вьюпорт.
|
|
31
|
-
* Дровер на mobile открывается сразу full-screen; swipe-down закрывает его.
|
|
32
|
-
*/
|
|
33
|
-
export const MOBILE_SNAP_POINTS_DEFAULT = [1];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DrawerProps } from '../../components/Drawer/types.js';
|
|
2
2
|
/** Desktop-поверхность Drawer'а: панель (`DrawerCustom`) с пресетной разметкой. Internal. */
|
|
3
|
-
export declare function DesktopDrawer({ content, media, title, slotAfterTitle, slotSecondTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, nestedDrawer, contentRef, className, ...rest }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function DesktopDrawer({ content, media, title, truncate, slotAfterTitle, slotSecondTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, nestedDrawer, contentRef, className, ...rest }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,13 +5,13 @@ import styles from '../../components/Drawer/styles.module.css';
|
|
|
5
5
|
import { DrawerCustom } from '../../components/DrawerCustom/index.js';
|
|
6
6
|
import { TEST_IDS } from '../../constants.js';
|
|
7
7
|
/** Desktop-поверхность Drawer'а: панель (`DrawerCustom`) с пресетной разметкой. Internal. */
|
|
8
|
-
export function DesktopDrawer({ content, media, title, slotAfterTitle, slotSecondTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, nestedDrawer, contentRef,
|
|
8
|
+
export function DesktopDrawer({ content, media, title, truncate, slotAfterTitle, slotSecondTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, nestedDrawer, contentRef,
|
|
9
9
|
// `withDividers` — mobile-only (мастер bottomSheet): молча уходит в `rest` и отбрасывается фреймом.
|
|
10
10
|
className, ...rest }) {
|
|
11
11
|
const showHeader = Boolean(title || subtitle || slotAfterTitle || slotSecondTitle);
|
|
12
12
|
// Произвольный `footer` приоритетнее кнопок-слотов; раскладку слотов делает сам `DrawerCustom.Footer`.
|
|
13
13
|
const hasFooter = Boolean(footer || approveButton || cancelButton || additionalButton);
|
|
14
|
-
return (_jsxs(DrawerCustom, { ...rest, resizable: undefined, className: cn(styles.drawer, className), push: Boolean(nestedDrawer) && { distance: NESTED_DRAWER_PUSH_DISTANCE }, children: [media, showHeader && (_jsx(DrawerCustom.Header, { title: title, slotAfterTitle: slotAfterTitle, slotSecondTitle: slotSecondTitle, subtitle: subtitle, onBackButtonClick: onBackButtonClick,
|
|
14
|
+
return (_jsxs(DrawerCustom, { ...rest, resizable: undefined, className: cn(styles.drawer, className), push: Boolean(nestedDrawer) && { distance: NESTED_DRAWER_PUSH_DISTANCE }, children: [media, showHeader && (_jsx(DrawerCustom.Header, { title: title, truncate: truncate, slotAfterTitle: slotAfterTitle, slotSecondTitle: slotSecondTitle, subtitle: subtitle, onBackButtonClick: onBackButtonClick,
|
|
15
15
|
// Сохраняем публичный контракт test-id'ов drawer'а поверх общего `PopupHeader`.
|
|
16
16
|
// slotAfterTitle НЕ переопределяем: id тултипа ставит сам потребитель на своём span.
|
|
17
17
|
testIds: {
|
|
@@ -9,7 +9,7 @@ export type DialogFooterProps = SheetFooterProps & {
|
|
|
9
9
|
cancelButton?: BottomSheetActionButton;
|
|
10
10
|
/** Дополнительная (третья) кнопка. */
|
|
11
11
|
additionalButton?: BottomSheetActionButton;
|
|
12
|
-
/** Ориентация
|
|
12
|
+
/** Ориентация кнопок при ровно двух действиях. */
|
|
13
13
|
footerActionsOrientation?: FooterActionsOrientation;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { BottomSheet } from '@cloud-ru/ds-bottom-sheet';
|
|
3
3
|
import { extractSupportProps } from '@cloud-ru/ds-utils';
|
|
4
|
-
import {
|
|
4
|
+
import { TEST_IDS } from '../../constants.js';
|
|
5
5
|
/**
|
|
6
6
|
* Mobile-поверхность Drawer'а: контент в `BottomSheet`, слоты маппятся на API sheet'а
|
|
7
7
|
* (`subtitle` 1:1, `showBlackout→showBackdrop`, остальное 1:1). Internal. Desktop-only пропы
|
|
8
8
|
* уходят в `...rest`.
|
|
9
9
|
*/
|
|
10
|
-
export function MobileDrawer({ content, media, title, slotAfterTitle, slotSecondTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, className, rootClassName, open, onClose, showBlackout, container, closeOnPopstate, swipeEnabled, snapPoints
|
|
10
|
+
export function MobileDrawer({ content, media, title, slotAfterTitle, slotSecondTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, className, rootClassName, open, onClose, showBlackout, container, closeOnPopstate, swipeEnabled, snapPoints, snapIndex, onSnapIndexChange, safeArea, withDividers = false, ...rest }) {
|
|
11
11
|
// Футер собирает сам `BottomSheet`.
|
|
12
|
-
return (_jsx(BottomSheet
|
|
12
|
+
return (_jsx(BottomSheet
|
|
13
|
+
// Дефолт `withDividers` в sheet'е — `true`; у Drawer'а вид исторически без разделителей.
|
|
14
|
+
, {
|
|
15
|
+
// Дефолт `withDividers` в sheet'е — `true`; у Drawer'а вид исторически без разделителей.
|
|
16
|
+
withDividers: withDividers, open: open, onClose: onClose, showBackdrop: showBlackout, title: title, subtitle: subtitle, slotAfterTitle: slotAfterTitle, slotSecondTitle: slotSecondTitle, onBackButtonClick: onBackButtonClick, media: media, content: content, approveButton: approveButton, cancelButton: cancelButton, additionalButton: additionalButton, footerActionsOrientation: footerActionsOrientation, footer: footer,
|
|
13
17
|
// Те же id футера, что у desktop-поверхности — стабильный селектор при свапе surface.
|
|
14
18
|
footerTestIds: {
|
|
15
19
|
approve: TEST_IDS.footerApprove,
|