@snack-uikit/drawer 0.11.5 → 0.11.6-preview-92d6fde1.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/dist/cjs/components/DrawerCustom/DrawerCustom.d.ts +3 -1
- package/dist/cjs/components/DrawerCustom/DrawerCustom.js +4 -2
- package/dist/esm/components/DrawerCustom/DrawerCustom.d.ts +3 -1
- package/dist/esm/components/DrawerCustom/DrawerCustom.js +3 -2
- package/package.json +9 -9
- package/src/components/DrawerCustom/DrawerCustom.tsx +6 -1
|
@@ -25,8 +25,10 @@ export type DrawerCustomProps = WithSupportProps<PropsWithChildren<{
|
|
|
25
25
|
container?: string | HTMLElement;
|
|
26
26
|
/** Вложенный Drawer */
|
|
27
27
|
nestedDrawer?: ReactElement<DrawerCustomProps>;
|
|
28
|
+
/** Закрывать дровер при перемещении по истории браузера */
|
|
29
|
+
closeOnPopstate?: boolean;
|
|
28
30
|
}>>;
|
|
29
|
-
export declare function DrawerCustom({ open, mode, position, onClose, rootClassName, className, size, push, container, children, nestedDrawer, ...rest }: DrawerCustomProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare function DrawerCustom({ open, mode, position, onClose, rootClassName, className, size, push, container, children, nestedDrawer, closeOnPopstate, ...rest }: DrawerCustomProps): import("react/jsx-runtime").JSX.Element;
|
|
30
32
|
export declare namespace DrawerCustom {
|
|
31
33
|
type HeaderProps = DrawerHeaderProps;
|
|
32
34
|
type BodyProps = DrawerBodyProps;
|
|
@@ -38,11 +38,13 @@ function DrawerCustom(_a) {
|
|
|
38
38
|
push,
|
|
39
39
|
container,
|
|
40
40
|
children,
|
|
41
|
-
nestedDrawer
|
|
41
|
+
nestedDrawer,
|
|
42
|
+
closeOnPopstate
|
|
42
43
|
} = _a,
|
|
43
|
-
rest = __rest(_a, ["open", "mode", "position", "onClose", "rootClassName", "className", "size", "push", "container", "children", "nestedDrawer"]);
|
|
44
|
+
rest = __rest(_a, ["open", "mode", "position", "onClose", "rootClassName", "className", "size", "push", "container", "children", "nestedDrawer", "closeOnPopstate"]);
|
|
44
45
|
const isRegular = mode === constants_1.MODE.Regular;
|
|
45
46
|
const isPredefinedSize = typeof size === 'string' && constants_1.SIZE_AS_VALUES.includes(size);
|
|
47
|
+
(0, utils_1.usePopstateSubscription)(() => open && onClose(), Boolean(closeOnPopstate));
|
|
46
48
|
return (0, jsx_runtime_1.jsxs)(rc_drawer_1.default, Object.assign({
|
|
47
49
|
mask: isRegular,
|
|
48
50
|
maskClosable: isRegular,
|
|
@@ -25,8 +25,10 @@ export type DrawerCustomProps = WithSupportProps<PropsWithChildren<{
|
|
|
25
25
|
container?: string | HTMLElement;
|
|
26
26
|
/** Вложенный Drawer */
|
|
27
27
|
nestedDrawer?: ReactElement<DrawerCustomProps>;
|
|
28
|
+
/** Закрывать дровер при перемещении по истории браузера */
|
|
29
|
+
closeOnPopstate?: boolean;
|
|
28
30
|
}>>;
|
|
29
|
-
export declare function DrawerCustom({ open, mode, position, onClose, rootClassName, className, size, push, container, children, nestedDrawer, ...rest }: DrawerCustomProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare function DrawerCustom({ open, mode, position, onClose, rootClassName, className, size, push, container, children, nestedDrawer, closeOnPopstate, ...rest }: DrawerCustomProps): import("react/jsx-runtime").JSX.Element;
|
|
30
32
|
export declare namespace DrawerCustom {
|
|
31
33
|
type HeaderProps = DrawerHeaderProps;
|
|
32
34
|
type BodyProps = DrawerBodyProps;
|
|
@@ -13,15 +13,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import 'rc-drawer/assets/index.css';
|
|
14
14
|
import cn from 'classnames';
|
|
15
15
|
import RcDrawer from 'rc-drawer';
|
|
16
|
-
import { extractSupportProps } from '@snack-uikit/utils';
|
|
16
|
+
import { extractSupportProps, usePopstateSubscription } from '@snack-uikit/utils';
|
|
17
17
|
import { MODE, POSITION, SIZE, SIZE_AS_VALUES } from '../../constants';
|
|
18
18
|
import { ButtonClose, DrawerBody, DrawerFooter, DrawerHeader, } from '../../helperComponents';
|
|
19
19
|
import { motionProps } from './constants';
|
|
20
20
|
import styles from './styles.module.css';
|
|
21
21
|
export function DrawerCustom(_a) {
|
|
22
|
-
var { open, mode = MODE.Regular, position = POSITION.Right, onClose, rootClassName, className, size = SIZE.S, push, container, children, nestedDrawer } = _a, rest = __rest(_a, ["open", "mode", "position", "onClose", "rootClassName", "className", "size", "push", "container", "children", "nestedDrawer"]);
|
|
22
|
+
var { open, mode = MODE.Regular, position = POSITION.Right, onClose, rootClassName, className, size = SIZE.S, push, container, children, nestedDrawer, closeOnPopstate } = _a, rest = __rest(_a, ["open", "mode", "position", "onClose", "rootClassName", "className", "size", "push", "container", "children", "nestedDrawer", "closeOnPopstate"]);
|
|
23
23
|
const isRegular = mode === MODE.Regular;
|
|
24
24
|
const isPredefinedSize = typeof size === 'string' && SIZE_AS_VALUES.includes(size);
|
|
25
|
+
usePopstateSubscription(() => open && onClose(), Boolean(closeOnPopstate));
|
|
25
26
|
return (_jsxs(RcDrawer, Object.assign({ mask: isRegular, maskClosable: isRegular, maskClassName: styles.mask, keyboard: isRegular, width: isPredefinedSize ? 'null' : size, open: open, placement: position, destroyOnClose: true, push: push, onClose: onClose, getContainer: container, className: cn(styles.drawer, className), rootClassName: cn(styles.drawerRoot, rootClassName) }, extractSupportProps(rest), { "data-content-wrapper": true, "data-size": isPredefinedSize ? size : undefined, "data-mode": mode }, motionProps, { children: [_jsx("div", { className: styles.headerElements, children: _jsx(ButtonClose, { onClick: onClose }) }), children, nestedDrawer] })));
|
|
26
27
|
}
|
|
27
28
|
(function (DrawerCustom) {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Drawer",
|
|
7
|
-
"version": "0.11.
|
|
7
|
+
"version": "0.11.6-preview-92d6fde1.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@snack-uikit/button": "0.19.
|
|
40
|
-
"@snack-uikit/icons": "0.27.0",
|
|
41
|
-
"@snack-uikit/scroll": "0.10.
|
|
42
|
-
"@snack-uikit/tooltip": "0.17.
|
|
43
|
-
"@snack-uikit/truncate-string": "0.6.
|
|
44
|
-
"@snack-uikit/typography": "0.8.
|
|
45
|
-
"@snack-uikit/utils": "3.8.
|
|
39
|
+
"@snack-uikit/button": "0.19.12-preview-92d6fde1.0",
|
|
40
|
+
"@snack-uikit/icons": "0.27.1-preview-92d6fde1.0",
|
|
41
|
+
"@snack-uikit/scroll": "0.10.2-preview-92d6fde1.0",
|
|
42
|
+
"@snack-uikit/tooltip": "0.17.6-preview-92d6fde1.0",
|
|
43
|
+
"@snack-uikit/truncate-string": "0.6.23-preview-92d6fde1.0",
|
|
44
|
+
"@snack-uikit/typography": "0.8.8-preview-92d6fde1.0",
|
|
45
|
+
"@snack-uikit/utils": "3.8.3-preview-92d6fde1.0",
|
|
46
46
|
"classnames": "2.5.1",
|
|
47
47
|
"rc-drawer": "6.4.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "b69eea8eab30c5cf2d251a9985c6310aac3192b8"
|
|
50
50
|
}
|
|
@@ -4,7 +4,7 @@ import cn from 'classnames';
|
|
|
4
4
|
import RcDrawer, { DrawerProps as RcDrawerProps } from 'rc-drawer';
|
|
5
5
|
import { PropsWithChildren, ReactElement } from 'react';
|
|
6
6
|
|
|
7
|
-
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
7
|
+
import { extractSupportProps, usePopstateSubscription, WithSupportProps } from '@snack-uikit/utils';
|
|
8
8
|
|
|
9
9
|
import { MODE, POSITION, SIZE, SIZE_AS_VALUES } from '../../constants';
|
|
10
10
|
import {
|
|
@@ -42,6 +42,8 @@ export type DrawerCustomProps = WithSupportProps<
|
|
|
42
42
|
container?: string | HTMLElement;
|
|
43
43
|
/** Вложенный Drawer */
|
|
44
44
|
nestedDrawer?: ReactElement<DrawerCustomProps>;
|
|
45
|
+
/** Закрывать дровер при перемещении по истории браузера */
|
|
46
|
+
closeOnPopstate?: boolean;
|
|
45
47
|
}>
|
|
46
48
|
>;
|
|
47
49
|
|
|
@@ -57,11 +59,14 @@ export function DrawerCustom({
|
|
|
57
59
|
container,
|
|
58
60
|
children,
|
|
59
61
|
nestedDrawer,
|
|
62
|
+
closeOnPopstate,
|
|
60
63
|
...rest
|
|
61
64
|
}: DrawerCustomProps) {
|
|
62
65
|
const isRegular = mode === MODE.Regular;
|
|
63
66
|
const isPredefinedSize = typeof size === 'string' && SIZE_AS_VALUES.includes(size);
|
|
64
67
|
|
|
68
|
+
usePopstateSubscription(() => open && onClose(), Boolean(closeOnPopstate));
|
|
69
|
+
|
|
65
70
|
return (
|
|
66
71
|
<RcDrawer
|
|
67
72
|
mask={isRegular}
|