@cloud-ru/ds-drawer 1.0.7-preview-5f569f3c.0 → 1.1.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 +7 -0
- package/README.md +6 -0
- package/dist/cjs/components/Drawer/styles.module.css +0 -16
- package/dist/cjs/components/Drawer/types.d.ts +7 -3
- package/dist/cjs/components/DrawerCustom/DrawerCustom.d.ts +3 -3
- package/dist/cjs/components/DrawerCustom/DrawerCustom.js +1 -1
- package/dist/cjs/components/DrawerCustom/constants.js +2 -6
- package/dist/cjs/components/DrawerCustom/hooks/useDrawerResize.js +1 -5
- package/dist/cjs/components/DrawerCustom/styles.module.css +117 -123
- package/dist/cjs/constants.d.ts +1 -1
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/helperComponents/DesktopDrawer/DesktopDrawer.d.ts +1 -1
- package/dist/cjs/helperComponents/DesktopDrawer/DesktopDrawer.js +8 -12
- package/dist/cjs/helperComponents/DialogSlots.d.ts +25 -4
- package/dist/cjs/helperComponents/DialogSlots.js +32 -3
- package/dist/cjs/helperComponents/DrawerBody/DrawerBody.d.ts +1 -1
- package/dist/cjs/helperComponents/DrawerBody/DrawerBody.js +3 -2
- package/dist/cjs/helperComponents/MobileDrawer/MobileDrawer.d.ts +1 -1
- package/dist/cjs/helperComponents/MobileDrawer/MobileDrawer.js +4 -4
- package/dist/cjs/helperComponents/styles.module.css +15 -0
- package/dist/cjs/style.css +132 -139
- package/dist/esm/components/Drawer/styles.module.css +0 -16
- package/dist/esm/components/Drawer/types.d.ts +7 -3
- package/dist/esm/components/DrawerCustom/DrawerCustom.d.ts +3 -3
- package/dist/esm/components/DrawerCustom/DrawerCustom.js +1 -1
- package/dist/esm/components/DrawerCustom/constants.js +2 -3
- package/dist/esm/components/DrawerCustom/hooks/useDrawerResize.js +1 -2
- package/dist/esm/components/DrawerCustom/styles.module.css +117 -123
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/helperComponents/DesktopDrawer/DesktopDrawer.d.ts +1 -1
- package/dist/esm/helperComponents/DesktopDrawer/DesktopDrawer.js +8 -12
- package/dist/esm/helperComponents/DialogSlots.d.ts +25 -4
- package/dist/esm/helperComponents/DialogSlots.js +29 -4
- package/dist/esm/helperComponents/DrawerBody/DrawerBody.d.ts +1 -1
- package/dist/esm/helperComponents/DrawerBody/DrawerBody.js +4 -3
- package/dist/esm/helperComponents/MobileDrawer/MobileDrawer.d.ts +1 -1
- package/dist/esm/helperComponents/MobileDrawer/MobileDrawer.js +4 -4
- package/dist/esm/helperComponents/styles.module.css +15 -0
- package/dist/esm/style.css +132 -139
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/components/Drawer/styles.module.scss +0 -19
- package/src/components/Drawer/types.ts +7 -3
- package/src/components/DrawerCustom/DrawerCustom.tsx +1 -1
- package/src/components/DrawerCustom/constants.ts +2 -4
- package/src/components/DrawerCustom/hooks/useDrawerResize.tsx +1 -2
- package/src/components/DrawerCustom/styles.module.scss +42 -60
- package/src/constants.ts +1 -1
- package/src/helperComponents/DesktopDrawer/DesktopDrawer.tsx +18 -27
- package/src/helperComponents/DialogSlots.tsx +74 -3
- package/src/helperComponents/DrawerBody/DrawerBody.tsx +5 -2
- package/src/helperComponents/MobileDrawer/MobileDrawer.tsx +5 -2
- package/src/helperComponents/styles.module.scss +22 -0
package/dist/esm/constants.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export declare const TEST_IDS: {
|
|
|
11
11
|
readonly footerCancel: "drawer__footer-cancel";
|
|
12
12
|
readonly footerAdditional: "drawer__footer-additional";
|
|
13
13
|
readonly nestedDrawer: "drawer__nested";
|
|
14
|
-
/** Зарезервирован: rc-drawer отдаёт для маски только `classNames`/`styles`, атрибут навесить нечем. */
|
|
15
14
|
readonly overlay: "drawer__overlay";
|
|
15
|
+
readonly contentWrapper: "drawer__content-wrapper";
|
|
16
16
|
};
|
|
17
17
|
export declare const WIDTH: {
|
|
18
18
|
readonly S: "s";
|
package/dist/esm/constants.js
CHANGED
|
@@ -11,8 +11,8 @@ export const TEST_IDS = {
|
|
|
11
11
|
footerCancel: 'drawer__footer-cancel',
|
|
12
12
|
footerAdditional: 'drawer__footer-additional',
|
|
13
13
|
nestedDrawer: 'drawer__nested',
|
|
14
|
-
/** Зарезервирован: rc-drawer отдаёт для маски только `classNames`/`styles`, атрибут навесить нечем. */
|
|
15
14
|
overlay: 'drawer__overlay',
|
|
15
|
+
contentWrapper: 'drawer__content-wrapper',
|
|
16
16
|
};
|
|
17
17
|
export const WIDTH = {
|
|
18
18
|
S: 's',
|
|
@@ -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, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, nestedDrawer, className, ...rest }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
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;
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { FooterActions } from '@cloud-ru/ds-bottom-sheet';
|
|
3
2
|
import cn from 'classnames';
|
|
4
3
|
import { NESTED_DRAWER_PUSH_DISTANCE } from '../../components/Drawer/constants.js';
|
|
5
4
|
import styles from '../../components/Drawer/styles.module.css';
|
|
6
5
|
import { DrawerCustom } from '../../components/DrawerCustom/index.js';
|
|
7
6
|
import { TEST_IDS } from '../../constants.js';
|
|
8
7
|
/** Desktop-поверхность Drawer'а: панель (`DrawerCustom`) с пресетной разметкой. Internal. */
|
|
9
|
-
export function DesktopDrawer({ content, media, title, slotAfterTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, nestedDrawer,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
additional: TEST_IDS.footerAdditional,
|
|
17
|
-
} })) : null);
|
|
18
|
-
return (_jsxs(DrawerCustom, { ...rest, resizable: undefined, className: cn(styles.drawer, className), push: Boolean(nestedDrawer) && { distance: NESTED_DRAWER_PUSH_DISTANCE }, children: [media, _jsx("div", { className: styles.safeAreaTop }), showHeader && (_jsx(DrawerCustom.Header, { title: title, slotAfterTitle: slotAfterTitle, subtitle: subtitle, onBackButtonClick: onBackButtonClick,
|
|
8
|
+
export function DesktopDrawer({ content, media, title, slotAfterTitle, slotSecondTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, nestedDrawer, contentRef,
|
|
9
|
+
// `withDividers` — mobile-only (мастер bottomSheet): молча уходит в `rest` и отбрасывается фреймом.
|
|
10
|
+
className, ...rest }) {
|
|
11
|
+
const showHeader = Boolean(title || subtitle || slotAfterTitle || slotSecondTitle);
|
|
12
|
+
// Произвольный `footer` приоритетнее кнопок-слотов; раскладку слотов делает сам `DrawerCustom.Footer`.
|
|
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,
|
|
19
15
|
// Сохраняем публичный контракт test-id'ов drawer'а поверх общего `PopupHeader`.
|
|
20
16
|
// slotAfterTitle НЕ переопределяем: id тултипа ставит сам потребитель на своём span.
|
|
21
17
|
testIds: {
|
|
22
18
|
header: TEST_IDS.header,
|
|
23
19
|
title: TEST_IDS.title,
|
|
24
20
|
subtitle: TEST_IDS.subtitle,
|
|
25
|
-
} })), _jsx(DrawerCustom.Body, { "data-test-id": TEST_IDS.body,
|
|
21
|
+
} })), _jsx(DrawerCustom.Body, { "data-test-id": TEST_IDS.body, innerRef: contentRef, content: content }), hasFooter && (_jsx(DrawerCustom.Footer, { "data-test-id": TEST_IDS.footer, approveButton: footer ? undefined : approveButton, cancelButton: footer ? undefined : cancelButton, additionalButton: footer ? undefined : additionalButton, footerActionsOrientation: footerActionsOrientation, children: footer })), nestedDrawer] }));
|
|
26
22
|
}
|
|
@@ -1,8 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BottomSheetActionButton, FooterActionsOrientation, SheetFooterProps, SheetHeaderProps } from '@cloud-ru/ds-bottom-sheet';
|
|
2
2
|
import { DrawerBodyProps } from './DrawerBody/index.js';
|
|
3
3
|
export type DialogHeaderProps = SheetHeaderProps;
|
|
4
4
|
export type DialogBodyProps = DrawerBodyProps;
|
|
5
|
-
export type DialogFooterProps = SheetFooterProps
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export type DialogFooterProps = SheetFooterProps & {
|
|
6
|
+
/** Основная кнопка. Задаёт штатную раскладку футера — вместо `children`. */
|
|
7
|
+
approveButton?: BottomSheetActionButton;
|
|
8
|
+
/** Кнопка отмены. */
|
|
9
|
+
cancelButton?: BottomSheetActionButton;
|
|
10
|
+
/** Дополнительная (третья) кнопка. */
|
|
11
|
+
additionalButton?: BottomSheetActionButton;
|
|
12
|
+
/** Ориентация кнопок при ровно двух действиях. */
|
|
13
|
+
footerActionsOrientation?: FooterActionsOrientation;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Шапка панели вместе с верхней safe-area.
|
|
17
|
+
*
|
|
18
|
+
* Отступ лежит здесь, а не во фрейме: иначе его теряет ручная композиция из
|
|
19
|
+
* `DrawerCustom.Header/Body/Footer`. На `sheet` не нужен — там свой `padding-top` в токенах.
|
|
20
|
+
*/
|
|
21
|
+
export declare function DialogHeader(props: DialogHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* Футер панели вместе с зазором от `Body` (нижняя safe-area; на `sheet` его даёт сам мастер).
|
|
24
|
+
*
|
|
25
|
+
* Кнопки-слоты раскладывает `FooterActions`. `children` — для нестандартного содержимого:
|
|
26
|
+
* раскладку в этом случае обеспечивает потребитель.
|
|
27
|
+
*/
|
|
28
|
+
export declare function DialogFooter({ approveButton, cancelButton, additionalButton, footerActionsOrientation, children, ...rest }: DialogFooterProps): import("react/jsx-runtime").JSX.Element;
|
|
8
29
|
export declare function DialogBody(props: DialogBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,33 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { OVERLAY_SURFACE, SheetBody, SheetFooter, SheetHeader, useOverlaySurface, } from '@cloud-ru/ds-bottom-sheet';
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FooterActions, OVERLAY_SURFACE, SheetBody, SheetFooter, SheetHeader, useOverlaySurface, } from '@cloud-ru/ds-bottom-sheet';
|
|
3
|
+
import { TEST_IDS } from '../constants.js';
|
|
3
4
|
import { DrawerBody } from './DrawerBody/index.js';
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
import styles from './styles.module.css';
|
|
6
|
+
/**
|
|
7
|
+
* Шапка панели вместе с верхней safe-area.
|
|
8
|
+
*
|
|
9
|
+
* Отступ лежит здесь, а не во фрейме: иначе его теряет ручная композиция из
|
|
10
|
+
* `DrawerCustom.Header/Body/Footer`. На `sheet` не нужен — там свой `padding-top` в токенах.
|
|
11
|
+
*/
|
|
12
|
+
export function DialogHeader(props) {
|
|
13
|
+
const isSheet = useOverlaySurface() === OVERLAY_SURFACE.Sheet;
|
|
14
|
+
return (_jsxs(_Fragment, { children: [!isSheet && _jsx("div", { className: styles.safeAreaTop }), _jsx(SheetHeader, { ...props })] }));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Футер панели вместе с зазором от `Body` (нижняя safe-area; на `sheet` его даёт сам мастер).
|
|
18
|
+
*
|
|
19
|
+
* Кнопки-слоты раскладывает `FooterActions`. `children` — для нестандартного содержимого:
|
|
20
|
+
* раскладку в этом случае обеспечивает потребитель.
|
|
21
|
+
*/
|
|
22
|
+
export function DialogFooter({ approveButton, cancelButton, additionalButton, footerActionsOrientation, children, ...rest }) {
|
|
23
|
+
const isSheet = useOverlaySurface() === OVERLAY_SURFACE.Sheet;
|
|
24
|
+
const hasActions = Boolean(approveButton || cancelButton || additionalButton);
|
|
25
|
+
return (_jsxs(_Fragment, { children: [!isSheet && _jsx("div", { className: styles.safeAreaBottom }), _jsx(SheetFooter, { ...rest, children: hasActions ? (_jsx(FooterActions, { surface: isSheet ? 'bottomSheet' : 'window', size: 'l', approveButton: approveButton, cancelButton: cancelButton, additionalButton: additionalButton, footerActionsOrientation: footerActionsOrientation, testIds: {
|
|
26
|
+
approve: TEST_IDS.footerApprove,
|
|
27
|
+
cancel: TEST_IDS.footerCancel,
|
|
28
|
+
additional: TEST_IDS.footerAdditional,
|
|
29
|
+
} })) : (children) })] }));
|
|
30
|
+
}
|
|
6
31
|
export function DialogBody(props) {
|
|
7
32
|
return useOverlaySurface() === OVERLAY_SURFACE.Sheet ? _jsx(SheetBody, { ...props }) : _jsx(DrawerBody, { ...props });
|
|
8
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { SheetBodyProps } from '@cloud-ru/ds-bottom-sheet';
|
|
2
2
|
export type DrawerBodyProps = SheetBodyProps;
|
|
3
3
|
/** Body дровера (desktop): `Scroll`; высота-по-контенту — из overlay-контекста. */
|
|
4
|
-
export declare function DrawerBody({ content, children, bodyPadding, className, ...rest }: DrawerBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function DrawerBody({ content, children, bodyPadding, innerRef, className, ...rest }: DrawerBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useOverlayBodyHeightAuto } from '@cloud-ru/ds-bottom-sheet';
|
|
3
3
|
import { Scroll } from '@cloud-ru/ds-scroll';
|
|
4
|
-
import { extractSupportProps } from '@cloud-ru/ds-utils';
|
|
4
|
+
import { extractSupportProps, withInnerRefSupport } from '@cloud-ru/ds-utils';
|
|
5
5
|
import cn from 'classnames';
|
|
6
6
|
import styles from './styles.module.css';
|
|
7
7
|
/** Body дровера (desktop): `Scroll`; высота-по-контенту — из overlay-контекста. */
|
|
8
|
-
export function DrawerBody({ content, children, bodyPadding = true, className, ...rest }) {
|
|
8
|
+
export function DrawerBody({ content, children, bodyPadding = true, innerRef, className, ...rest }) {
|
|
9
9
|
const heightAutoVertical = useOverlayBodyHeightAuto();
|
|
10
|
-
return (_jsx(Scroll, { size: 'm', barHideStrategy: 'never', className: cn(styles.body, heightAutoVertical && styles.bodyHeightAuto, className), "data-no-padding": bodyPadding === false || undefined, ...extractSupportProps(rest), children: children ?? content }));
|
|
10
|
+
return (_jsx(Scroll, { ref: innerRef, size: 'm', barHideStrategy: 'never', className: cn(styles.body, heightAutoVertical && styles.bodyHeightAuto, className), "data-no-padding": bodyPadding === false || undefined, ...extractSupportProps(rest), children: children ?? content }));
|
|
11
11
|
}
|
|
12
|
+
withInnerRefSupport(DrawerBody);
|
|
@@ -4,4 +4,4 @@ import { DrawerProps } from '../../components/Drawer/types.js';
|
|
|
4
4
|
* (`subtitle` 1:1, `showBlackout→showBackdrop`, остальное 1:1). Internal. Desktop-only пропы
|
|
5
5
|
* уходят в `...rest`.
|
|
6
6
|
*/
|
|
7
|
-
export declare function MobileDrawer({ content, media, title, slotAfterTitle, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, className, rootClassName, open, onClose, showBlackout, container, closeOnPopstate, swipeEnabled, snapPoints, snapIndex, onSnapIndexChange, safeArea, ...rest }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare 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, ...rest }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,13 +7,13 @@ import { TEST_IDS } from '../../constants.js';
|
|
|
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, subtitle, onBackButtonClick, approveButton, cancelButton, additionalButton, footerActionsOrientation, footer, className, rootClassName, open, onClose, showBlackout, container, closeOnPopstate, swipeEnabled, snapPoints, snapIndex, onSnapIndexChange, safeArea, ...rest }) {
|
|
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
12
|
return (_jsx(BottomSheet
|
|
13
|
-
// Дефолт `withDividers`
|
|
13
|
+
// Дефолт `withDividers` в sheet'е — `true`; у Drawer'а вид исторически без разделителей.
|
|
14
14
|
, {
|
|
15
|
-
// Дефолт `withDividers`
|
|
16
|
-
withDividers:
|
|
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,
|
|
17
17
|
// Те же id футера, что у desktop-поверхности — стабильный селектор при свапе surface.
|
|
18
18
|
footerTestIds: {
|
|
19
19
|
approve: TEST_IDS.footerApprove,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.safeAreaTop{
|
|
2
|
+
display:flex;
|
|
3
|
+
flex-direction:column;
|
|
4
|
+
align-items:flex-start;
|
|
5
|
+
align-self:stretch;
|
|
6
|
+
padding-top:var(--sn-drawer-anatomy-container-safeArea-paddingTop, var(--sn-density-spacing-interval-l, var(--sn-primitive-dimension-24, 24px)));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.safeAreaBottom{
|
|
10
|
+
display:flex;
|
|
11
|
+
flex-direction:column;
|
|
12
|
+
align-items:flex-start;
|
|
13
|
+
align-self:stretch;
|
|
14
|
+
padding-bottom:var(--sn-drawer-anatomy-container-safeArea-paddingBottom, var(--sn-density-spacing-interval-s, var(--sn-primitive-dimension-8, 8px)));
|
|
15
|
+
}
|