@snack-uikit/modal 0.17.1 → 0.18.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 CHANGED
@@ -3,6 +3,29 @@
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.18.0 (2025-07-15)
7
+
8
+
9
+ ### Features
10
+
11
+ * **PDS-2594:** add CloseWatcher using in modals and drawers ([7699e55](https://github.com/cloud-ru-tech/snack-uikit/commit/7699e55dc172f6082369b6fb83815c12d28b3f7a))
12
+
13
+
14
+
15
+
16
+
17
+ ## 0.17.2 (2025-07-10)
18
+
19
+ ### Only dependencies have been changed
20
+ * [@snack-uikit/icons@0.27.2](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/icons/CHANGELOG.md)
21
+ * [@snack-uikit/link@0.17.6](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/link/CHANGELOG.md)
22
+ * [@snack-uikit/tooltip@0.18.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/tooltip/CHANGELOG.md)
23
+ * [@snack-uikit/truncate-string@0.6.24](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/truncate-string/CHANGELOG.md)
24
+
25
+
26
+
27
+
28
+
6
29
  ## 0.17.1 (2025-07-10)
7
30
 
8
31
  ### Only dependencies have been changed
@@ -44,7 +44,11 @@ function ModalCustom(_a) {
44
44
  onClose();
45
45
  }
46
46
  };
47
- (0, utils_1.usePopstateSubscription)(() => open && onClose(), Boolean(closeOnPopstate));
47
+ const hasCloseButton = mode !== constants_1.MODE.Forced;
48
+ (0, utils_1.useModalOpenState)(open, onClose, {
49
+ closeOnPopstate,
50
+ onCloseRequest: () => hasCloseButton
51
+ });
48
52
  if (!open) {
49
53
  return null;
50
54
  }
@@ -61,7 +65,7 @@ function ModalCustom(_a) {
61
65
  onClose: handleClose
62
66
  }),
63
67
  className: (0, classnames_1.default)(styles_module_scss_1.default.modal, className),
64
- children: [mode !== constants_1.MODE.Forced && (0, jsx_runtime_1.jsx)("div", {
68
+ children: [hasCloseButton && (0, jsx_runtime_1.jsx)("div", {
65
69
  className: styles_module_scss_1.default.headerElements,
66
70
  children: (0, jsx_runtime_1.jsx)(helperComponents_1.ButtonClose, {
67
71
  onClick: handleCloseButtonClick
@@ -12,7 +12,7 @@ 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, usePopstateSubscription } from '@snack-uikit/utils';
15
+ import { isBrowser, useModalOpenState } 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';
@@ -27,11 +27,15 @@ export function ModalCustom(_a) {
27
27
  onClose();
28
28
  }
29
29
  };
30
- usePopstateSubscription(() => open && onClose(), Boolean(closeOnPopstate));
30
+ const hasCloseButton = mode !== MODE.Forced;
31
+ useModalOpenState(open, onClose, {
32
+ closeOnPopstate,
33
+ onCloseRequest: () => hasCloseButton,
34
+ });
31
35
  if (!open) {
32
36
  return null;
33
37
  }
34
- return (_jsxs(RCModal, { data: Object.assign(Object.assign({}, getDataTestAttributes(rest)), { size }), isOpen: true, onRequestClose: handleClose, appElement: isBrowser() ? document.body : undefined, overlayElement: (_, content) => (_jsx(OverlayElement, { blur: [MODE.Forced, MODE.Aggressive].includes(mode), content: content, onClose: handleClose })), className: cn(styles.modal, className), children: [mode !== MODE.Forced && (_jsx("div", { className: styles.headerElements, children: _jsx(ButtonClose, { onClick: handleCloseButtonClick }) })), children] }));
38
+ return (_jsxs(RCModal, { data: Object.assign(Object.assign({}, getDataTestAttributes(rest)), { size }), isOpen: true, onRequestClose: handleClose, appElement: isBrowser() ? document.body : undefined, overlayElement: (_, content) => (_jsx(OverlayElement, { blur: [MODE.Forced, MODE.Aggressive].includes(mode), content: content, onClose: handleClose })), className: cn(styles.modal, className), children: [hasCloseButton && (_jsx("div", { className: styles.headerElements, children: _jsx(ButtonClose, { onClick: handleCloseButtonClick }) })), children] }));
35
39
  }
36
40
  (function (ModalCustom) {
37
41
  ModalCustom.Header = ModalHeader;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Modal",
7
- "version": "0.17.1",
7
+ "version": "0.18.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.13",
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",
39
+ "@snack-uikit/button": "0.19.14",
40
+ "@snack-uikit/icon-predefined": "0.7.8",
41
+ "@snack-uikit/icons": "0.27.2",
42
+ "@snack-uikit/link": "0.17.7",
43
+ "@snack-uikit/scroll": "0.10.3",
44
+ "@snack-uikit/tooltip": "0.18.2",
45
+ "@snack-uikit/truncate-string": "0.6.25",
46
+ "@snack-uikit/typography": "0.8.9",
47
+ "@snack-uikit/utils": "3.10.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": "a52f1e048d51eb120078ce84b5cc497a8f35c133"
54
+ "gitHead": "60a306ca6f30a3dc7363ecc71b1584acc98dea58"
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, usePopstateSubscription, WithSupportProps } from '@snack-uikit/utils';
5
+ import { isBrowser, useModalOpenState, WithSupportProps } from '@snack-uikit/utils';
6
6
 
7
7
  import { MODE, SIZE } from '../../constants';
8
8
  import {
@@ -65,7 +65,12 @@ export function ModalCustom({
65
65
  }
66
66
  };
67
67
 
68
- usePopstateSubscription(() => open && onClose(), Boolean(closeOnPopstate));
68
+ const hasCloseButton = mode !== MODE.Forced;
69
+
70
+ useModalOpenState(open, onClose, {
71
+ closeOnPopstate,
72
+ onCloseRequest: () => hasCloseButton,
73
+ });
69
74
 
70
75
  if (!open) {
71
76
  return null;
@@ -86,7 +91,7 @@ export function ModalCustom({
86
91
  )}
87
92
  className={cn(styles.modal, className)}
88
93
  >
89
- {mode !== MODE.Forced && (
94
+ {hasCloseButton && (
90
95
  <div className={styles.headerElements}>
91
96
  <ButtonClose onClick={handleCloseButtonClick} />
92
97
  </div>