@snack-uikit/modal 0.16.6 → 0.17.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 +11 -0
- package/dist/cjs/components/ModalCustom/ModalCustom.d.ts +3 -1
- package/dist/cjs/components/ModalCustom/ModalCustom.js +4 -2
- package/dist/esm/components/ModalCustom/ModalCustom.d.ts +3 -1
- package/dist/esm/components/ModalCustom/ModalCustom.js +3 -2
- package/package.json +11 -11
- package/src/components/ModalCustom/ModalCustom.tsx +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
# 0.17.0 (2025-07-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **PDS-2556:** add closeOnPopstate prop ([7f56996](https://github.com/cloud-ru-tech/snack-uikit/commit/7f5699646fd3c3eee2c00bd0c0d4dc94ccc019f8))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.16.6 (2025-06-27)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
|
@@ -24,8 +24,10 @@ export type ModalCustomProps = WithSupportProps<{
|
|
|
24
24
|
className?: string;
|
|
25
25
|
/** Контент */
|
|
26
26
|
children: ReactNode;
|
|
27
|
+
/** Закрывать при переходе по истории браузера */
|
|
28
|
+
closeOnPopstate?: boolean;
|
|
27
29
|
}>;
|
|
28
|
-
export declare function ModalCustom({ open, onClose, size, mode, children, className, ...rest }: ModalCustomProps): import("react/jsx-runtime").JSX.Element | null;
|
|
30
|
+
export declare function ModalCustom({ open, onClose, size, mode, children, className, closeOnPopstate, ...rest }: ModalCustomProps): import("react/jsx-runtime").JSX.Element | null;
|
|
29
31
|
export declare namespace ModalCustom {
|
|
30
32
|
type HeaderProps = ModalHeaderProps;
|
|
31
33
|
type BodyProps = ModalBodyProps;
|
|
@@ -32,9 +32,10 @@ function ModalCustom(_a) {
|
|
|
32
32
|
size = constants_1.SIZE.S,
|
|
33
33
|
mode = constants_1.MODE.Regular,
|
|
34
34
|
children,
|
|
35
|
-
className
|
|
35
|
+
className,
|
|
36
|
+
closeOnPopstate
|
|
36
37
|
} = _a,
|
|
37
|
-
rest = __rest(_a, ["open", "onClose", "size", "mode", "children", "className"]);
|
|
38
|
+
rest = __rest(_a, ["open", "onClose", "size", "mode", "children", "className", "closeOnPopstate"]);
|
|
38
39
|
const handleCloseButtonClick = () => {
|
|
39
40
|
onClose();
|
|
40
41
|
};
|
|
@@ -43,6 +44,7 @@ function ModalCustom(_a) {
|
|
|
43
44
|
onClose();
|
|
44
45
|
}
|
|
45
46
|
};
|
|
47
|
+
(0, utils_1.usePopstateSubscription)(() => open && onClose(), Boolean(closeOnPopstate));
|
|
46
48
|
if (!open) {
|
|
47
49
|
return null;
|
|
48
50
|
}
|
|
@@ -24,8 +24,10 @@ export type ModalCustomProps = WithSupportProps<{
|
|
|
24
24
|
className?: string;
|
|
25
25
|
/** Контент */
|
|
26
26
|
children: ReactNode;
|
|
27
|
+
/** Закрывать при переходе по истории браузера */
|
|
28
|
+
closeOnPopstate?: boolean;
|
|
27
29
|
}>;
|
|
28
|
-
export declare function ModalCustom({ open, onClose, size, mode, children, className, ...rest }: ModalCustomProps): import("react/jsx-runtime").JSX.Element | null;
|
|
30
|
+
export declare function ModalCustom({ open, onClose, size, mode, children, className, closeOnPopstate, ...rest }: ModalCustomProps): import("react/jsx-runtime").JSX.Element | null;
|
|
29
31
|
export declare namespace ModalCustom {
|
|
30
32
|
type HeaderProps = ModalHeaderProps;
|
|
31
33
|
type BodyProps = ModalBodyProps;
|
|
@@ -12,13 +12,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import cn from 'classnames';
|
|
14
14
|
import RCModal from 'react-modal';
|
|
15
|
-
import { isBrowser } from '@snack-uikit/utils';
|
|
15
|
+
import { isBrowser, usePopstateSubscription } from '@snack-uikit/utils';
|
|
16
16
|
import { MODE, SIZE } from '../../constants';
|
|
17
17
|
import { ButtonClose, ModalBody, ModalFooter, ModalHeader, OverlayElement, } from '../../helperComponents';
|
|
18
18
|
import styles from './styles.module.css';
|
|
19
19
|
import { getDataTestAttributes } from './utils';
|
|
20
20
|
export function ModalCustom(_a) {
|
|
21
|
-
var { open, onClose, size = SIZE.S, mode = MODE.Regular, children, className } = _a, rest = __rest(_a, ["open", "onClose", "size", "mode", "children", "className"]);
|
|
21
|
+
var { open, onClose, size = SIZE.S, mode = MODE.Regular, children, className, closeOnPopstate } = _a, rest = __rest(_a, ["open", "onClose", "size", "mode", "children", "className", "closeOnPopstate"]);
|
|
22
22
|
const handleCloseButtonClick = () => {
|
|
23
23
|
onClose();
|
|
24
24
|
};
|
|
@@ -27,6 +27,7 @@ export function ModalCustom(_a) {
|
|
|
27
27
|
onClose();
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
+
usePopstateSubscription(() => open && onClose(), Boolean(closeOnPopstate));
|
|
30
31
|
if (!open) {
|
|
31
32
|
return null;
|
|
32
33
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Modal",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.17.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -36,20 +36,20 @@
|
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@snack-uikit/button": "0.19.
|
|
40
|
-
"@snack-uikit/icon-predefined": "0.7.
|
|
41
|
-
"@snack-uikit/icons": "0.27.
|
|
42
|
-
"@snack-uikit/link": "0.17.
|
|
43
|
-
"@snack-uikit/scroll": "0.10.
|
|
44
|
-
"@snack-uikit/tooltip": "0.
|
|
45
|
-
"@snack-uikit/truncate-string": "0.6.
|
|
46
|
-
"@snack-uikit/typography": "0.8.
|
|
47
|
-
"@snack-uikit/utils": "3.
|
|
39
|
+
"@snack-uikit/button": "0.19.12",
|
|
40
|
+
"@snack-uikit/icon-predefined": "0.7.7",
|
|
41
|
+
"@snack-uikit/icons": "0.27.1",
|
|
42
|
+
"@snack-uikit/link": "0.17.5",
|
|
43
|
+
"@snack-uikit/scroll": "0.10.2",
|
|
44
|
+
"@snack-uikit/tooltip": "0.18.0",
|
|
45
|
+
"@snack-uikit/truncate-string": "0.6.23",
|
|
46
|
+
"@snack-uikit/typography": "0.8.8",
|
|
47
|
+
"@snack-uikit/utils": "3.9.0",
|
|
48
48
|
"classnames": "2.5.1",
|
|
49
49
|
"react-modal": "3.16.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/react-modal": "3.16.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "9e08a5c61a90e739f44ba128242a95d866452dc0"
|
|
55
55
|
}
|
|
@@ -2,7 +2,7 @@ import cn from 'classnames';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import RCModal from 'react-modal';
|
|
4
4
|
|
|
5
|
-
import { isBrowser, WithSupportProps } from '@snack-uikit/utils';
|
|
5
|
+
import { isBrowser, usePopstateSubscription, WithSupportProps } from '@snack-uikit/utils';
|
|
6
6
|
|
|
7
7
|
import { MODE, SIZE } from '../../constants';
|
|
8
8
|
import {
|
|
@@ -41,6 +41,8 @@ export type ModalCustomProps = WithSupportProps<{
|
|
|
41
41
|
className?: string;
|
|
42
42
|
/** Контент */
|
|
43
43
|
children: ReactNode;
|
|
44
|
+
/** Закрывать при переходе по истории браузера */
|
|
45
|
+
closeOnPopstate?: boolean;
|
|
44
46
|
}>;
|
|
45
47
|
|
|
46
48
|
export function ModalCustom({
|
|
@@ -50,6 +52,7 @@ export function ModalCustom({
|
|
|
50
52
|
mode = MODE.Regular,
|
|
51
53
|
children,
|
|
52
54
|
className,
|
|
55
|
+
closeOnPopstate,
|
|
53
56
|
...rest
|
|
54
57
|
}: ModalCustomProps) {
|
|
55
58
|
const handleCloseButtonClick = () => {
|
|
@@ -62,6 +65,8 @@ export function ModalCustom({
|
|
|
62
65
|
}
|
|
63
66
|
};
|
|
64
67
|
|
|
68
|
+
usePopstateSubscription(() => open && onClose(), Boolean(closeOnPopstate));
|
|
69
|
+
|
|
65
70
|
if (!open) {
|
|
66
71
|
return null;
|
|
67
72
|
}
|