@pinuts/bsr-uikit-relaunch 0.0.16 → 0.0.18
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/shared/Modal/Modal.jsx"],"names":[],"mappings":";AASA;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/shared/Modal/Modal.jsx"],"names":[],"mappings":";AASA;;;;;;;;;;gBAyIC"}
|
|
@@ -46,7 +46,7 @@ const Modal = _ref => {
|
|
|
46
46
|
// Set focus on the close button
|
|
47
47
|
(closeButtonRef.current || null)?.focus();
|
|
48
48
|
const handleTabKeyPress = event => {
|
|
49
|
-
if (event.key === 'Tab') {
|
|
49
|
+
if (event.key === 'Tab' && (0, _isWindowAvailable.isWindowAvailable)()) {
|
|
50
50
|
if (event.shiftKey && document.activeElement === firstElement) {
|
|
51
51
|
event.preventDefault();
|
|
52
52
|
lastElement.focus();
|
|
@@ -61,13 +61,17 @@ const Modal = _ref => {
|
|
|
61
61
|
toggleModal();
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
if ((0, _isWindowAvailable.isWindowAvailable)()) {
|
|
65
|
+
modalElement.addEventListener('keydown', handleTabKeyPress);
|
|
66
|
+
modalElement.addEventListener('keydown', handleEscapeKeyPress);
|
|
67
|
+
document.body.classList.add(_ModalModule.default.modalOpen || '');
|
|
68
|
+
}
|
|
67
69
|
return () => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
if ((0, _isWindowAvailable.isWindowAvailable)()) {
|
|
71
|
+
modalElement.removeEventListener('keydown', handleTabKeyPress);
|
|
72
|
+
modalElement.removeEventListener('keydown', handleEscapeKeyPress);
|
|
73
|
+
document.body.classList.remove(_ModalModule.default.modalOpen || '');
|
|
74
|
+
}
|
|
71
75
|
};
|
|
72
76
|
}
|
|
73
77
|
(0, _isWindowAvailable.isWindowAvailable)() && document.body.classList.remove(_ModalModule.default.modalOpen || '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmallModal.d.ts","sourceRoot":"","sources":["../../../src/shared/Modal/SmallModal.jsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"SmallModal.d.ts","sourceRoot":"","sources":["../../../src/shared/Modal/SmallModal.jsx"],"names":[],"mappings":";AASA;;;;;;;;;gBAiFC"}
|
|
@@ -10,6 +10,7 @@ var _reactI18next = require("react-i18next");
|
|
|
10
10
|
var _uuid = require("uuid");
|
|
11
11
|
var _ModalModule = _interopRequireDefault(require("./Modal.module.scss"));
|
|
12
12
|
var _Close = _interopRequireDefault(require("../../icons/Close.jsx"));
|
|
13
|
+
var _isWindowAvailable = require("../../utils/isWindowAvailable.js");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -44,16 +45,20 @@ const SmallModal = _ref => {
|
|
|
44
45
|
onClose();
|
|
45
46
|
}
|
|
46
47
|
};
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
if ((0, _isWindowAvailable.isWindowAvailable)()) {
|
|
49
|
+
document.addEventListener('keydown', handleEscapeKeyPress);
|
|
50
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
51
|
+
}
|
|
49
52
|
|
|
50
53
|
// Set focus to the modal content when it opens
|
|
51
54
|
if (contentRef.current) {
|
|
52
55
|
contentRef.current.focus();
|
|
53
56
|
}
|
|
54
57
|
return () => {
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
if ((0, _isWindowAvailable.isWindowAvailable)()) {
|
|
59
|
+
document.removeEventListener('keydown', handleEscapeKeyPress);
|
|
60
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
61
|
+
}
|
|
57
62
|
};
|
|
58
63
|
}
|
|
59
64
|
}, [show, onClose]);
|