@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
|
@@ -1,19 +1,3 @@
|
|
|
1
1
|
.drawer{
|
|
2
2
|
box-sizing:border-box;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.safeAreaTop{
|
|
6
|
-
display:flex;
|
|
7
|
-
flex-direction:column;
|
|
8
|
-
align-items:flex-start;
|
|
9
|
-
align-self:stretch;
|
|
10
|
-
padding-top:var(--sn-drawer-anatomy-container-safeArea-paddingTop, var(--sn-density-spacing-interval-l, var(--sn-primitive-dimension-24, 24px)));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.safeAreaBottom{
|
|
14
|
-
display:flex;
|
|
15
|
-
flex-direction:column;
|
|
16
|
-
align-items:flex-start;
|
|
17
|
-
align-self:stretch;
|
|
18
|
-
padding-bottom:var(--sn-drawer-anatomy-container-safeArea-paddingBottom, var(--sn-density-spacing-interval-s, var(--sn-primitive-dimension-8, 8px)));
|
|
19
3
|
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { BottomSheetActionButton, BottomSheetProps, FooterActionsOrientation } from '@cloud-ru/ds-bottom-sheet';
|
|
2
2
|
import { WithSupportProps } from '@cloud-ru/ds-utils';
|
|
3
|
-
import { ReactElement, ReactNode } from 'react';
|
|
3
|
+
import { ReactElement, ReactNode, Ref } from 'react';
|
|
4
4
|
import { DialogBodyProps, DialogHeaderProps } from '../../helperComponents/index.js';
|
|
5
5
|
import { DrawerCustomProps } from '../DrawerCustom/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* Адаптивный Drawer: desktop — боковая/верхняя/нижняя панель, `mobile` — `BottomSheet`.
|
|
8
8
|
*
|
|
9
9
|
* Только desktop: `position`, `width`, `heightAuto`, `nestedDrawer` (на mobile игнорируются).
|
|
10
|
-
* Только mobile: `swipeEnabled`, `snapPoints`, `snapIndex`, `onSnapIndexChange`, `safeArea`
|
|
10
|
+
* Только mobile: `swipeEnabled`, `snapPoints`, `snapIndex`, `onSnapIndexChange`, `safeArea`, `withDividers`
|
|
11
11
|
* (на desktop-панели игнорируются — это анатомия `BottomSheet`).
|
|
12
12
|
*/
|
|
13
|
-
export type DrawerProps = WithSupportProps<Omit<DrawerCustomProps, 'nestedDrawer' | 'push' | 'resizable'> & Pick<BottomSheetProps, 'swipeEnabled' | 'snapPoints' | 'snapIndex' | 'onSnapIndexChange' | 'safeArea'> & Pick<DialogHeaderProps, 'title' | 'slotAfterTitle' | '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'> & Pick<DialogBodyProps, 'content'> & {
|
|
14
|
+
/** Ссылка на скроллируемый контейнер контента (например, для дозагрузки по скроллу). */
|
|
15
|
+
contentRef?: Ref<HTMLElement>;
|
|
16
|
+
/** Только mobile: разделители между шапкой/контентом/футером sheet'а. @default false */
|
|
17
|
+
withDividers?: boolean;
|
|
14
18
|
/** Текстовая строка-подзаголовок под title. */
|
|
15
19
|
subtitle?: ReactNode;
|
|
16
20
|
/** CSS-класс */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DialogBody, DialogBodyProps, DialogFooterProps, DialogHeaderProps } from '../../helperComponents/index.js';
|
|
1
|
+
import { DialogBody, DialogBodyProps, DialogFooter, DialogFooterProps, DialogHeader, DialogHeaderProps } from '../../helperComponents/index.js';
|
|
2
2
|
import { DrawerCustomProps } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Адаптивный low-level `DrawerCustom`: на `mobile` — `BottomSheetCustom`, иначе — `DrawerFrame`.
|
|
@@ -9,7 +9,7 @@ export declare namespace DrawerCustom {
|
|
|
9
9
|
type HeaderProps = DialogHeaderProps;
|
|
10
10
|
type BodyProps = DialogBodyProps;
|
|
11
11
|
type FooterProps = DialogFooterProps;
|
|
12
|
-
const Header: typeof
|
|
12
|
+
const Header: typeof DialogHeader;
|
|
13
13
|
const Body: typeof DialogBody;
|
|
14
|
-
const Footer: typeof
|
|
14
|
+
const Footer: typeof DialogFooter;
|
|
15
15
|
}
|
|
@@ -53,7 +53,7 @@ function DrawerFrame(props) {
|
|
|
53
53
|
const resolvedContainer = container ?? (portalContextRef.current ? () => portalContextRef.current : undefined);
|
|
54
54
|
return (_jsx(RcDrawer, { resizable: drawerResizable, panelRef: checkElement, mask: showBlackout, maskClosable: showBlackout, keyboard: showBlackout, "data-showblackout": showBlackout, open: open, onClose: onClose, push: push, getContainer: resolvedContainer, placement: position, destroyOnHidden: true, rootClassName: cn(styles.drawerRoot, rootClassName), style: drawerPanelStyle, classNames: {
|
|
55
55
|
section: cn(styles.drawer, className),
|
|
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:
|
|
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: 'snack-rc-drawer', ...(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
59
|
* Адаптивный low-level `DrawerCustom`: на `mobile` — `BottomSheetCustom`, иначе — `DrawerFrame`.
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import styles from './styles.module.css';
|
|
2
1
|
export const maskMotion = {
|
|
3
2
|
motionAppear: true,
|
|
4
|
-
motionName:
|
|
3
|
+
motionName: 'maskMotion',
|
|
5
4
|
};
|
|
6
5
|
export const motion = placement => ({
|
|
7
6
|
motionAppear: true,
|
|
8
7
|
motionDeadline: 300,
|
|
9
|
-
motionName:
|
|
8
|
+
motionName: `panelMotion-${placement}`,
|
|
10
9
|
});
|
|
11
10
|
export const motionProps = {
|
|
12
11
|
maskMotion,
|
|
@@ -2,8 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Tooltip } from '@cloud-ru/ds-tooltip';
|
|
3
3
|
import { isBrowser } from '@cloud-ru/ds-utils';
|
|
4
4
|
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
5
|
-
|
|
6
|
-
const DRAGGER_SELECTOR = `.${styles.prefixCls}-resizable-dragger`;
|
|
5
|
+
const DRAGGER_SELECTOR = '.snack-rc-drawer-resizable-dragger';
|
|
7
6
|
export function useDrawerResize({ position, resizable: resizableProp }) {
|
|
8
7
|
const targetRef = useRef(null);
|
|
9
8
|
const targetRefCallbackRef = useRef();
|