react-responsive-modal 6.4.1 → 7.0.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.
@@ -1,465 +0,0 @@
1
- import React, { useRef, useEffect, useState } from 'react';
2
- import ReactDom from 'react-dom';
3
- import cx from 'classnames';
4
- import { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';
5
- import useForwardedRef from '@bedrock-layout/use-forwarded-ref';
6
-
7
- function _extends() {
8
- _extends = Object.assign || function (target) {
9
- for (var i = 1; i < arguments.length; i++) {
10
- var source = arguments[i];
11
-
12
- for (var key in source) {
13
- if (Object.prototype.hasOwnProperty.call(source, key)) {
14
- target[key] = source[key];
15
- }
16
- }
17
- }
18
-
19
- return target;
20
- };
21
-
22
- return _extends.apply(this, arguments);
23
- }
24
-
25
- var CloseIcon = function CloseIcon(_ref) {
26
- var classes = _ref.classes,
27
- classNames = _ref.classNames,
28
- styles = _ref.styles,
29
- id = _ref.id,
30
- closeIcon = _ref.closeIcon,
31
- onClick = _ref.onClick;
32
- return React.createElement("button", {
33
- id: id,
34
- className: cx(classes.closeButton, classNames == null ? void 0 : classNames.closeButton),
35
- style: styles == null ? void 0 : styles.closeButton,
36
- onClick: onClick,
37
- "data-testid": "close-button"
38
- }, closeIcon ? closeIcon : React.createElement("svg", {
39
- className: classNames == null ? void 0 : classNames.closeIcon,
40
- style: styles == null ? void 0 : styles.closeIcon,
41
- width: 28,
42
- height: 28,
43
- viewBox: "0 0 36 36",
44
- "data-testid": "close-icon"
45
- }, React.createElement("path", {
46
- d: "M28.5 9.62L26.38 7.5 18 15.88 9.62 7.5 7.5 9.62 15.88 18 7.5 26.38l2.12 2.12L18 20.12l8.38 8.38 2.12-2.12L20.12 18z"
47
- })));
48
- };
49
-
50
- var isBrowser = typeof window !== 'undefined';
51
-
52
- // https://github.com/alexandrzavalii/focus-trap-js/blob/master/src/index.js v1.1.0
53
- var candidateSelectors = ['input', 'select', 'textarea', 'a[href]', 'button', '[tabindex]', 'audio[controls]', 'video[controls]', '[contenteditable]:not([contenteditable="false"])'];
54
-
55
- function isHidden(node) {
56
- // offsetParent being null will allow detecting cases where an element is invisible or inside an invisible element,
57
- // as long as the element does not use position: fixed. For them, their visibility has to be checked directly as well.
58
- return node.offsetParent === null || getComputedStyle(node).visibility === 'hidden';
59
- }
60
-
61
- function getCheckedRadio(nodes, form) {
62
- for (var i = 0; i < nodes.length; i++) {
63
- if (nodes[i].checked && nodes[i].form === form) {
64
- return nodes[i];
65
- }
66
- }
67
- }
68
-
69
- function isNotRadioOrTabbableRadio(node) {
70
- if (node.tagName !== 'INPUT' || node.type !== 'radio' || !node.name) {
71
- return true;
72
- }
73
-
74
- var radioScope = node.form || node.ownerDocument;
75
- var radioSet = radioScope.querySelectorAll('input[type="radio"][name="' + node.name + '"]');
76
- var checked = getCheckedRadio(radioSet, node.form);
77
- return checked === node || checked === undefined && radioSet[0] === node;
78
- }
79
-
80
- function getAllTabbingElements(parentElem) {
81
- var currentActiveElement = document.activeElement;
82
- var tabbableNodes = parentElem.querySelectorAll(candidateSelectors.join(','));
83
- var onlyTabbable = [];
84
-
85
- for (var i = 0; i < tabbableNodes.length; i++) {
86
- var node = tabbableNodes[i];
87
-
88
- if (currentActiveElement === node || !node.disabled && getTabindex(node) > -1 && !isHidden(node) && isNotRadioOrTabbableRadio(node)) {
89
- onlyTabbable.push(node);
90
- }
91
- }
92
-
93
- return onlyTabbable;
94
- }
95
- function tabTrappingKey(event, parentElem) {
96
- // check if current event keyCode is tab
97
- if (!event || event.key !== 'Tab') return;
98
-
99
- if (!parentElem || !parentElem.contains) {
100
- if (process && process.env.NODE_ENV === 'development') {
101
- console.warn('focus-trap-js: parent element is not defined');
102
- }
103
-
104
- return false;
105
- }
106
-
107
- if (!parentElem.contains(event.target)) {
108
- return false;
109
- }
110
-
111
- var allTabbingElements = getAllTabbingElements(parentElem);
112
- var firstFocusableElement = allTabbingElements[0];
113
- var lastFocusableElement = allTabbingElements[allTabbingElements.length - 1];
114
-
115
- if (event.shiftKey && event.target === firstFocusableElement) {
116
- lastFocusableElement.focus();
117
- event.preventDefault();
118
- return true;
119
- } else if (!event.shiftKey && event.target === lastFocusableElement) {
120
- firstFocusableElement.focus();
121
- event.preventDefault();
122
- return true;
123
- }
124
-
125
- return false;
126
- }
127
-
128
- function getTabindex(node) {
129
- var tabindexAttr = parseInt(node.getAttribute('tabindex'), 10);
130
- if (!isNaN(tabindexAttr)) return tabindexAttr; // Browsers do not return tabIndex correctly for contentEditable nodes;
131
- // so if they don't have a tabindex attribute specifically set, assume it's 0.
132
-
133
- if (isContentEditable(node)) return 0;
134
- return node.tabIndex;
135
- }
136
-
137
- function isContentEditable(node) {
138
- return node.getAttribute('contentEditable');
139
- }
140
-
141
- var FocusTrap = function FocusTrap(_ref) {
142
- var container = _ref.container,
143
- initialFocusRef = _ref.initialFocusRef;
144
- var refLastFocus = useRef();
145
- /**
146
- * Handle focus lock on the modal
147
- */
148
-
149
- useEffect(function () {
150
- var handleKeyEvent = function handleKeyEvent(event) {
151
- if (container == null ? void 0 : container.current) {
152
- tabTrappingKey(event, container.current);
153
- }
154
- };
155
-
156
- if (isBrowser) {
157
- document.addEventListener('keydown', handleKeyEvent);
158
- } // On mount we focus on the first focusable element in the modal if there is one
159
-
160
-
161
- if (isBrowser && (container == null ? void 0 : container.current)) {
162
- var savePreviousFocus = function savePreviousFocus() {
163
- // First we save the last focused element
164
- // only if it's a focusable element
165
- if (candidateSelectors.findIndex(function (selector) {
166
- var _document$activeEleme;
167
-
168
- return (_document$activeEleme = document.activeElement) == null ? void 0 : _document$activeEleme.matches(selector);
169
- }) !== -1) {
170
- refLastFocus.current = document.activeElement;
171
- }
172
- };
173
-
174
- if (initialFocusRef) {
175
- savePreviousFocus(); // We need to schedule focusing on a next frame - this allows to focus on the modal root
176
-
177
- requestAnimationFrame(function () {
178
- var _initialFocusRef$curr;
179
-
180
- (_initialFocusRef$curr = initialFocusRef.current) == null ? void 0 : _initialFocusRef$curr.focus();
181
- });
182
- } else {
183
- var allTabbingElements = getAllTabbingElements(container.current);
184
-
185
- if (allTabbingElements[0]) {
186
- savePreviousFocus();
187
- allTabbingElements[0].focus();
188
- }
189
- }
190
- }
191
-
192
- return function () {
193
- if (isBrowser) {
194
- var _refLastFocus$current;
195
-
196
- document.removeEventListener('keydown', handleKeyEvent); // On unmount we restore the focus to the last focused element
197
-
198
- (_refLastFocus$current = refLastFocus.current) == null ? void 0 : _refLastFocus$current.focus();
199
- }
200
- };
201
- }, [container, initialFocusRef]);
202
- return null;
203
- };
204
-
205
- var modals = [];
206
- /**
207
- * Handle the order of the modals.
208
- * Inspired by the material-ui implementation.
209
- */
210
-
211
- var modalManager = {
212
- /**
213
- * Register a new modal
214
- */
215
- add: function add(newModal) {
216
- modals.push(newModal);
217
- },
218
-
219
- /**
220
- * Remove a modal
221
- */
222
- remove: function remove(oldModal) {
223
- modals = modals.filter(function (modal) {
224
- return modal !== oldModal;
225
- });
226
- },
227
-
228
- /**
229
- * When multiple modals are rendered will return true if current modal is the last one
230
- */
231
- isTopModal: function isTopModal(modal) {
232
- return !!modals.length && modals[modals.length - 1] === modal;
233
- }
234
- };
235
- function useModalManager(ref, open) {
236
- useEffect(function () {
237
- if (open) {
238
- modalManager.add(ref);
239
- }
240
-
241
- return function () {
242
- modalManager.remove(ref);
243
- };
244
- }, [open, ref]);
245
- }
246
-
247
- var useScrollLock = function useScrollLock(refModal, open, showPortal, blockScroll, reserveScrollBarGap) {
248
- var oldRef = useRef(null);
249
- useEffect(function () {
250
- if (open && refModal.current && blockScroll) {
251
- oldRef.current = refModal.current;
252
- disableBodyScroll(refModal.current, {
253
- reserveScrollBarGap: reserveScrollBarGap
254
- });
255
- }
256
-
257
- return function () {
258
- if (oldRef.current) {
259
- enableBodyScroll(oldRef.current);
260
- oldRef.current = null;
261
- }
262
- };
263
- }, [open, showPortal, refModal, blockScroll, reserveScrollBarGap]);
264
- };
265
-
266
- var classes = {
267
- root: 'react-responsive-modal-root',
268
- overlay: 'react-responsive-modal-overlay',
269
- overlayAnimationIn: 'react-responsive-modal-overlay-in',
270
- overlayAnimationOut: 'react-responsive-modal-overlay-out',
271
- modalContainer: 'react-responsive-modal-container',
272
- modalContainerCenter: 'react-responsive-modal-containerCenter',
273
- modal: 'react-responsive-modal-modal',
274
- modalAnimationIn: 'react-responsive-modal-modal-in',
275
- modalAnimationOut: 'react-responsive-modal-modal-out',
276
- closeButton: 'react-responsive-modal-closeButton'
277
- };
278
- var Modal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
279
- var _classNames$overlayAn, _classNames$overlayAn2, _classNames$modalAnim, _classNames$modalAnim2;
280
-
281
- var open = _ref.open,
282
- center = _ref.center,
283
- _ref$blockScroll = _ref.blockScroll,
284
- blockScroll = _ref$blockScroll === void 0 ? true : _ref$blockScroll,
285
- _ref$closeOnEsc = _ref.closeOnEsc,
286
- closeOnEsc = _ref$closeOnEsc === void 0 ? true : _ref$closeOnEsc,
287
- _ref$closeOnOverlayCl = _ref.closeOnOverlayClick,
288
- closeOnOverlayClick = _ref$closeOnOverlayCl === void 0 ? true : _ref$closeOnOverlayCl,
289
- container = _ref.container,
290
- _ref$showCloseIcon = _ref.showCloseIcon,
291
- showCloseIcon = _ref$showCloseIcon === void 0 ? true : _ref$showCloseIcon,
292
- closeIconId = _ref.closeIconId,
293
- closeIcon = _ref.closeIcon,
294
- _ref$focusTrapped = _ref.focusTrapped,
295
- focusTrapped = _ref$focusTrapped === void 0 ? true : _ref$focusTrapped,
296
- _ref$initialFocusRef = _ref.initialFocusRef,
297
- initialFocusRef = _ref$initialFocusRef === void 0 ? undefined : _ref$initialFocusRef,
298
- _ref$animationDuratio = _ref.animationDuration,
299
- animationDuration = _ref$animationDuratio === void 0 ? 300 : _ref$animationDuratio,
300
- classNames = _ref.classNames,
301
- styles = _ref.styles,
302
- _ref$role = _ref.role,
303
- role = _ref$role === void 0 ? 'dialog' : _ref$role,
304
- ariaDescribedby = _ref.ariaDescribedby,
305
- ariaLabelledby = _ref.ariaLabelledby,
306
- containerId = _ref.containerId,
307
- modalId = _ref.modalId,
308
- onClose = _ref.onClose,
309
- onEscKeyDown = _ref.onEscKeyDown,
310
- onOverlayClick = _ref.onOverlayClick,
311
- onAnimationEnd = _ref.onAnimationEnd,
312
- children = _ref.children,
313
- reserveScrollBarGap = _ref.reserveScrollBarGap;
314
- var refDialog = useForwardedRef(ref);
315
- var refModal = useRef(null);
316
- var refShouldClose = useRef(null);
317
- var refContainer = useRef(null); // Lazily create the ref instance
318
- // https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily
319
-
320
- if (refContainer.current === null && isBrowser) {
321
- refContainer.current = document.createElement('div');
322
- } // The value should be false for srr, that way when the component is hydrated client side,
323
- // it will match the server rendered content
324
-
325
-
326
- var _useState = useState(false),
327
- showPortal = _useState[0],
328
- setShowPortal = _useState[1]; // Hook used to manage multiple modals opened at the same time
329
-
330
-
331
- useModalManager(refModal, open); // Hook used to manage the scroll
332
-
333
- useScrollLock(refModal, open, showPortal, blockScroll, reserveScrollBarGap);
334
-
335
- var handleOpen = function handleOpen() {
336
- if (refContainer.current && !container && !document.body.contains(refContainer.current)) {
337
- document.body.appendChild(refContainer.current);
338
- }
339
-
340
- document.addEventListener('keydown', handleKeydown);
341
- };
342
-
343
- var handleClose = function handleClose() {
344
- if (refContainer.current && !container && document.body.contains(refContainer.current)) {
345
- document.body.removeChild(refContainer.current);
346
- }
347
-
348
- document.removeEventListener('keydown', handleKeydown);
349
- };
350
-
351
- var handleKeydown = function handleKeydown(event) {
352
- // Only the last modal need to be escaped when pressing the esc key
353
- if (event.keyCode !== 27 || !modalManager.isTopModal(refModal)) {
354
- return;
355
- }
356
-
357
- onEscKeyDown == null ? void 0 : onEscKeyDown(event);
358
-
359
- if (closeOnEsc) {
360
- onClose();
361
- }
362
- };
363
-
364
- useEffect(function () {
365
- return function () {
366
- if (showPortal) {
367
- // When the modal is closed or removed directly, cleanup the listeners
368
- handleClose();
369
- }
370
- };
371
- }, [showPortal]);
372
- useEffect(function () {
373
- // If the open prop is changing, we need to open the modal
374
- // This is also called on the first render if the open prop is true when the modal is created
375
- if (open && !showPortal) {
376
- setShowPortal(true);
377
- handleOpen();
378
- }
379
- }, [open]);
380
-
381
- var handleClickOverlay = function handleClickOverlay(event) {
382
- if (refShouldClose.current === null) {
383
- refShouldClose.current = true;
384
- }
385
-
386
- if (!refShouldClose.current) {
387
- refShouldClose.current = null;
388
- return;
389
- }
390
-
391
- onOverlayClick == null ? void 0 : onOverlayClick(event);
392
-
393
- if (closeOnOverlayClick) {
394
- onClose();
395
- }
396
-
397
- refShouldClose.current = null;
398
- };
399
-
400
- var handleModalEvent = function handleModalEvent() {
401
- refShouldClose.current = false;
402
- };
403
-
404
- var handleAnimationEnd = function handleAnimationEnd() {
405
- if (!open) {
406
- setShowPortal(false);
407
- }
408
-
409
- onAnimationEnd == null ? void 0 : onAnimationEnd();
410
- };
411
-
412
- var containerModal = container || refContainer.current;
413
- var overlayAnimation = open ? (_classNames$overlayAn = classNames == null ? void 0 : classNames.overlayAnimationIn) != null ? _classNames$overlayAn : classes.overlayAnimationIn : (_classNames$overlayAn2 = classNames == null ? void 0 : classNames.overlayAnimationOut) != null ? _classNames$overlayAn2 : classes.overlayAnimationOut;
414
- var modalAnimation = open ? (_classNames$modalAnim = classNames == null ? void 0 : classNames.modalAnimationIn) != null ? _classNames$modalAnim : classes.modalAnimationIn : (_classNames$modalAnim2 = classNames == null ? void 0 : classNames.modalAnimationOut) != null ? _classNames$modalAnim2 : classes.modalAnimationOut;
415
- return showPortal && containerModal ? ReactDom.createPortal(React.createElement("div", {
416
- className: cx(classes.root, classNames == null ? void 0 : classNames.root),
417
- style: styles == null ? void 0 : styles.root,
418
- "data-testid": "root"
419
- }, React.createElement("div", {
420
- className: cx(classes.overlay, classNames == null ? void 0 : classNames.overlay),
421
- "data-testid": "overlay",
422
- "aria-hidden": true,
423
- style: _extends({
424
- animation: overlayAnimation + " " + animationDuration + "ms"
425
- }, styles == null ? void 0 : styles.overlay)
426
- }), React.createElement("div", {
427
- ref: refModal,
428
- id: containerId,
429
- className: cx(classes.modalContainer, center && classes.modalContainerCenter, classNames == null ? void 0 : classNames.modalContainer),
430
- style: styles == null ? void 0 : styles.modalContainer,
431
- "data-testid": "modal-container",
432
- onClick: handleClickOverlay
433
- }, React.createElement("div", {
434
- ref: refDialog,
435
- className: cx(classes.modal, classNames == null ? void 0 : classNames.modal),
436
- style: _extends({
437
- animation: modalAnimation + " " + animationDuration + "ms"
438
- }, styles == null ? void 0 : styles.modal),
439
- onMouseDown: handleModalEvent,
440
- onMouseUp: handleModalEvent,
441
- onClick: handleModalEvent,
442
- onAnimationEnd: handleAnimationEnd,
443
- id: modalId,
444
- role: role,
445
- "aria-modal": "true",
446
- "aria-labelledby": ariaLabelledby,
447
- "aria-describedby": ariaDescribedby,
448
- "data-testid": "modal",
449
- tabIndex: -1
450
- }, focusTrapped && React.createElement(FocusTrap, {
451
- container: refDialog,
452
- initialFocusRef: initialFocusRef
453
- }), children, showCloseIcon && React.createElement(CloseIcon, {
454
- classes: classes,
455
- classNames: classNames,
456
- styles: styles,
457
- closeIcon: closeIcon,
458
- onClick: onClose,
459
- id: closeIconId
460
- })))), containerModal) : null;
461
- });
462
-
463
- export default Modal;
464
- export { Modal };
465
- //# sourceMappingURL=react-responsive-modal.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-responsive-modal.esm.js","sources":["../src/CloseIcon.tsx","../src/utils.ts","../src/lib/focusTrapJs.ts","../src/FocusTrap.tsx","../src/modalManager.ts","../src/useScrollLock.ts","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport cx from 'classnames';\n\ninterface CloseIconProps {\n id?: string;\n closeIcon?: React.ReactNode;\n styles?: {\n closeButton?: React.CSSProperties;\n closeIcon?: React.CSSProperties;\n };\n classNames?: {\n closeButton?: string;\n closeIcon?: string;\n };\n classes: {\n closeButton?: string;\n };\n onClick: () => void;\n}\n\nconst CloseIcon = ({\n classes,\n classNames,\n styles,\n id,\n closeIcon,\n onClick,\n}: CloseIconProps) => (\n <button\n id={id}\n className={cx(classes.closeButton, classNames?.closeButton)}\n style={styles?.closeButton}\n onClick={onClick}\n data-testid=\"close-button\"\n >\n {closeIcon ? (\n closeIcon\n ) : (\n <svg\n className={classNames?.closeIcon}\n style={styles?.closeIcon}\n width={28}\n height={28}\n viewBox=\"0 0 36 36\"\n data-testid=\"close-icon\"\n >\n <path d=\"M28.5 9.62L26.38 7.5 18 15.88 9.62 7.5 7.5 9.62 15.88 18 7.5 26.38l2.12 2.12L18 20.12l8.38 8.38 2.12-2.12L20.12 18z\" />\n </svg>\n )}\n </button>\n);\n\nexport default CloseIcon;\n","export const isBrowser = typeof window !== 'undefined';\n","// https://github.com/alexandrzavalii/focus-trap-js/blob/master/src/index.js v1.1.0\n\nexport const candidateSelectors = [\n 'input',\n 'select',\n 'textarea',\n 'a[href]',\n 'button',\n '[tabindex]',\n 'audio[controls]',\n 'video[controls]',\n '[contenteditable]:not([contenteditable=\"false\"])',\n];\n\nfunction isHidden(node: any) {\n // offsetParent being null will allow detecting cases where an element is invisible or inside an invisible element,\n // as long as the element does not use position: fixed. For them, their visibility has to be checked directly as well.\n return (\n node.offsetParent === null || getComputedStyle(node).visibility === 'hidden'\n );\n}\n\nfunction getCheckedRadio(nodes: any, form: any) {\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i].checked && nodes[i].form === form) {\n return nodes[i];\n }\n }\n}\n\nfunction isNotRadioOrTabbableRadio(node: any) {\n if (node.tagName !== 'INPUT' || node.type !== 'radio' || !node.name) {\n return true;\n }\n var radioScope = node.form || node.ownerDocument;\n var radioSet = radioScope.querySelectorAll(\n 'input[type=\"radio\"][name=\"' + node.name + '\"]'\n );\n var checked = getCheckedRadio(radioSet, node.form);\n return checked === node || (checked === undefined && radioSet[0] === node);\n}\n\nexport function getAllTabbingElements(parentElem: any) {\n var currentActiveElement = document.activeElement;\n var tabbableNodes = parentElem.querySelectorAll(candidateSelectors.join(','));\n var onlyTabbable = [];\n for (var i = 0; i < tabbableNodes.length; i++) {\n var node = tabbableNodes[i];\n if (\n currentActiveElement === node ||\n (!node.disabled &&\n getTabindex(node) > -1 &&\n !isHidden(node) &&\n isNotRadioOrTabbableRadio(node))\n ) {\n onlyTabbable.push(node);\n }\n }\n return onlyTabbable;\n}\n\nexport function tabTrappingKey(event: any, parentElem: any) {\n // check if current event keyCode is tab\n if (!event || event.key !== 'Tab') return;\n\n if (!parentElem || !parentElem.contains) {\n if (process && process.env.NODE_ENV === 'development') {\n console.warn('focus-trap-js: parent element is not defined');\n }\n return false;\n }\n\n if (!parentElem.contains(event.target)) {\n return false;\n }\n\n var allTabbingElements = getAllTabbingElements(parentElem);\n var firstFocusableElement = allTabbingElements[0];\n var lastFocusableElement = allTabbingElements[allTabbingElements.length - 1];\n\n if (event.shiftKey && event.target === firstFocusableElement) {\n lastFocusableElement.focus();\n event.preventDefault();\n return true;\n } else if (!event.shiftKey && event.target === lastFocusableElement) {\n firstFocusableElement.focus();\n event.preventDefault();\n return true;\n }\n return false;\n}\n\nfunction getTabindex(node: any) {\n var tabindexAttr = parseInt(node.getAttribute('tabindex'), 10);\n\n if (!isNaN(tabindexAttr)) return tabindexAttr;\n // Browsers do not return tabIndex correctly for contentEditable nodes;\n // so if they don't have a tabindex attribute specifically set, assume it's 0.\n\n if (isContentEditable(node)) return 0;\n return node.tabIndex;\n}\n\nfunction isContentEditable(node: any) {\n return node.getAttribute('contentEditable');\n}\n","import { useEffect, useRef } from 'react';\nimport { isBrowser } from './utils';\nimport {\n tabTrappingKey,\n candidateSelectors,\n getAllTabbingElements,\n} from './lib/focusTrapJs';\n\ninterface FocusTrapProps {\n container?: React.RefObject<HTMLElement> | null;\n initialFocusRef?: React.RefObject<HTMLElement>;\n}\n\nexport const FocusTrap = ({ container, initialFocusRef }: FocusTrapProps) => {\n const refLastFocus = useRef<HTMLElement | null>();\n /**\n * Handle focus lock on the modal\n */\n useEffect(() => {\n const handleKeyEvent = (event: KeyboardEvent) => {\n if (container?.current) {\n tabTrappingKey(event, container.current);\n }\n };\n\n if (isBrowser) {\n document.addEventListener('keydown', handleKeyEvent);\n }\n // On mount we focus on the first focusable element in the modal if there is one\n if (isBrowser && container?.current) {\n const savePreviousFocus = () => {\n // First we save the last focused element\n // only if it's a focusable element\n if (\n candidateSelectors.findIndex((selector) =>\n document.activeElement?.matches(selector)\n ) !== -1\n ) {\n refLastFocus.current = document.activeElement as HTMLElement;\n }\n };\n\n if (initialFocusRef) {\n savePreviousFocus();\n // We need to schedule focusing on a next frame - this allows to focus on the modal root\n requestAnimationFrame(() => {\n initialFocusRef.current?.focus();\n });\n } else {\n const allTabbingElements = getAllTabbingElements(container.current);\n if (allTabbingElements[0]) {\n savePreviousFocus();\n allTabbingElements[0].focus();\n }\n }\n }\n return () => {\n if (isBrowser) {\n document.removeEventListener('keydown', handleKeyEvent);\n // On unmount we restore the focus to the last focused element\n refLastFocus.current?.focus();\n }\n };\n }, [container, initialFocusRef]);\n\n return null;\n};\n","import { Ref, useEffect } from 'react';\n\nlet modals: Ref<Element>[] = [];\n\n/**\n * Handle the order of the modals.\n * Inspired by the material-ui implementation.\n */\nexport const modalManager = {\n /**\n * Register a new modal\n */\n add: (newModal: Ref<Element>) => {\n modals.push(newModal);\n },\n\n /**\n * Remove a modal\n */\n remove: (oldModal: Ref<Element>) => {\n modals = modals.filter((modal) => modal !== oldModal);\n },\n\n /**\n * When multiple modals are rendered will return true if current modal is the last one\n */\n isTopModal: (modal: Ref<Element>) =>\n !!modals.length && modals[modals.length - 1] === modal,\n};\n\nexport function useModalManager(ref: Ref<Element>, open: boolean) {\n useEffect(() => {\n if (open) {\n modalManager.add(ref);\n }\n return () => {\n modalManager.remove(ref);\n };\n }, [open, ref]);\n}\n","import { useEffect, useRef } from 'react';\nimport { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';\n\nexport const useScrollLock = (\n refModal: React.RefObject<Element>,\n open: boolean,\n showPortal: boolean,\n blockScroll: boolean,\n reserveScrollBarGap?: boolean\n) => {\n const oldRef = useRef<Element | null>(null);\n\n useEffect(() => {\n if (open && refModal.current && blockScroll) {\n oldRef.current = refModal.current;\n disableBodyScroll(refModal.current, { reserveScrollBarGap });\n }\n return () => {\n if (oldRef.current) {\n enableBodyScroll(oldRef.current);\n oldRef.current = null;\n }\n };\n }, [open, showPortal, refModal, blockScroll, reserveScrollBarGap]);\n};\n","import React, { useEffect, useRef, useState } from 'react';\nimport ReactDom from 'react-dom';\nimport cx from 'classnames';\nimport CloseIcon from './CloseIcon';\nimport { FocusTrap } from './FocusTrap';\nimport { modalManager, useModalManager } from './modalManager';\nimport { useScrollLock } from './useScrollLock';\nimport { isBrowser } from './utils';\nimport useForwardedRef from '@bedrock-layout/use-forwarded-ref';\n\nconst classes = {\n root: 'react-responsive-modal-root',\n overlay: 'react-responsive-modal-overlay',\n overlayAnimationIn: 'react-responsive-modal-overlay-in',\n overlayAnimationOut: 'react-responsive-modal-overlay-out',\n modalContainer: 'react-responsive-modal-container',\n modalContainerCenter: 'react-responsive-modal-containerCenter',\n modal: 'react-responsive-modal-modal',\n modalAnimationIn: 'react-responsive-modal-modal-in',\n modalAnimationOut: 'react-responsive-modal-modal-out',\n closeButton: 'react-responsive-modal-closeButton',\n};\n\nexport interface ModalProps {\n /**\n * Control if the modal is open or not.\n */\n open: boolean;\n /**\n * Should the dialog be centered.\n *\n * Default to false.\n */\n center?: boolean;\n /**\n * Is the modal closable when user press esc key.\n *\n * Default to true.\n */\n closeOnEsc?: boolean;\n /**\n * Is the modal closable when user click on overlay.\n *\n * Default to true.\n */\n closeOnOverlayClick?: boolean;\n /**\n * Whether to block scrolling when dialog is open.\n *\n * Default to true.\n */\n blockScroll?: boolean;\n /**\n * Show the close icon.\n *\n * Default to true.\n */\n showCloseIcon?: boolean;\n /**\n * id attribute for the close icon button.\n */\n closeIconId?: string;\n /**\n * Custom icon to render (svg, img, etc...).\n */\n closeIcon?: React.ReactNode;\n /**\n * When the modal is open, trap focus within it.\n *\n * Default to true.\n */\n focusTrapped?: boolean;\n /**\n * Element to focus when focus trap is used.\n *\n * Default to undefined.\n */\n initialFocusRef?: React.RefObject<HTMLElement>;\n /**\n * You can specify a container prop which should be of type `Element`.\n * The portal will be rendered inside that element.\n * The default behavior will create a div node and render it at the at the end of document.body.\n */\n container?: Element | null;\n /**\n * An object containing classNames to style the modal.\n */\n classNames?: {\n root?: string;\n overlay?: string;\n overlayAnimationIn?: string;\n overlayAnimationOut?: string;\n modalContainer?: string;\n modal?: string;\n modalAnimationIn?: string;\n modalAnimationOut?: string;\n closeButton?: string;\n closeIcon?: string;\n };\n /**\n * An object containing the styles objects to style the modal.\n */\n styles?: {\n root?: React.CSSProperties;\n overlay?: React.CSSProperties;\n modalContainer?: React.CSSProperties;\n modal?: React.CSSProperties;\n closeButton?: React.CSSProperties;\n closeIcon?: React.CSSProperties;\n };\n /**\n * Animation duration in milliseconds.\n *\n * Default to 300.\n */\n animationDuration?: number;\n /**\n * ARIA role for modal\n *\n * Default to 'dialog'.\n */\n role?: string;\n /**\n * ARIA label for modal\n */\n ariaLabelledby?: string;\n /**\n * ARIA description for modal\n */\n ariaDescribedby?: string;\n /**\n * Avoid unpleasant flickering effect when body overflow is hidden. For more information see https://www.npmjs.com/package/body-scroll-lock\n */\n reserveScrollBarGap?: boolean;\n /**\n * id attribute for modal container\n */\n containerId?: string;\n /**\n * id attribute for modal\n */\n modalId?: string;\n /**\n * Callback fired when the Modal is requested to be closed by a click on the overlay or when user press esc key.\n */\n onClose: () => void;\n /**\n * Callback fired when the escape key is pressed.\n */\n onEscKeyDown?: (event: KeyboardEvent) => void;\n /**\n * Callback fired when the overlay is clicked.\n */\n onOverlayClick?: (\n event: React.MouseEvent<HTMLDivElement, MouseEvent>\n ) => void;\n /**\n * Callback fired when the Modal has exited and the animation is finished.\n */\n onAnimationEnd?: () => void;\n children?: React.ReactNode;\n}\n\nexport const Modal = React.forwardRef(\n (\n {\n open,\n center,\n blockScroll = true,\n closeOnEsc = true,\n closeOnOverlayClick = true,\n container,\n showCloseIcon = true,\n closeIconId,\n closeIcon,\n focusTrapped = true,\n initialFocusRef = undefined,\n animationDuration = 300,\n classNames,\n styles,\n role = 'dialog',\n ariaDescribedby,\n ariaLabelledby,\n containerId,\n modalId,\n onClose,\n onEscKeyDown,\n onOverlayClick,\n onAnimationEnd,\n children,\n reserveScrollBarGap,\n }: ModalProps,\n ref: React.ForwardedRef<HTMLDivElement>\n ) => {\n const refDialog = useForwardedRef(ref);\n const refModal = useRef<HTMLDivElement>(null);\n const refShouldClose = useRef<boolean | null>(null);\n const refContainer = useRef<HTMLDivElement | null>(null);\n // Lazily create the ref instance\n // https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily\n if (refContainer.current === null && isBrowser) {\n refContainer.current = document.createElement('div');\n }\n\n // The value should be false for srr, that way when the component is hydrated client side,\n // it will match the server rendered content\n const [showPortal, setShowPortal] = useState(false);\n\n // Hook used to manage multiple modals opened at the same time\n useModalManager(refModal, open);\n\n // Hook used to manage the scroll\n useScrollLock(refModal, open, showPortal, blockScroll, reserveScrollBarGap);\n\n const handleOpen = () => {\n if (\n refContainer.current &&\n !container &&\n !document.body.contains(refContainer.current)\n ) {\n document.body.appendChild(refContainer.current);\n }\n\n document.addEventListener('keydown', handleKeydown);\n };\n\n const handleClose = () => {\n if (\n refContainer.current &&\n !container &&\n document.body.contains(refContainer.current)\n ) {\n document.body.removeChild(refContainer.current);\n }\n document.removeEventListener('keydown', handleKeydown);\n };\n\n const handleKeydown = (event: KeyboardEvent) => {\n // Only the last modal need to be escaped when pressing the esc key\n if (event.keyCode !== 27 || !modalManager.isTopModal(refModal)) {\n return;\n }\n\n onEscKeyDown?.(event);\n\n if (closeOnEsc) {\n onClose();\n }\n };\n\n useEffect(() => {\n return () => {\n if (showPortal) {\n // When the modal is closed or removed directly, cleanup the listeners\n handleClose();\n }\n };\n }, [showPortal]);\n\n useEffect(() => {\n // If the open prop is changing, we need to open the modal\n // This is also called on the first render if the open prop is true when the modal is created\n if (open && !showPortal) {\n setShowPortal(true);\n handleOpen();\n }\n }, [open]);\n\n const handleClickOverlay = (\n event: React.MouseEvent<HTMLDivElement, MouseEvent>\n ) => {\n if (refShouldClose.current === null) {\n refShouldClose.current = true;\n }\n\n if (!refShouldClose.current) {\n refShouldClose.current = null;\n return;\n }\n\n onOverlayClick?.(event);\n\n if (closeOnOverlayClick) {\n onClose();\n }\n\n refShouldClose.current = null;\n };\n\n const handleModalEvent = () => {\n refShouldClose.current = false;\n };\n\n const handleAnimationEnd = () => {\n if (!open) {\n setShowPortal(false);\n }\n\n onAnimationEnd?.();\n };\n\n const containerModal = container || refContainer.current;\n\n const overlayAnimation = open\n ? classNames?.overlayAnimationIn ?? classes.overlayAnimationIn\n : classNames?.overlayAnimationOut ?? classes.overlayAnimationOut;\n\n const modalAnimation = open\n ? classNames?.modalAnimationIn ?? classes.modalAnimationIn\n : classNames?.modalAnimationOut ?? classes.modalAnimationOut;\n\n return showPortal && containerModal\n ? ReactDom.createPortal(\n <div\n className={cx(classes.root, classNames?.root)}\n style={styles?.root}\n data-testid=\"root\"\n >\n <div\n className={cx(classes.overlay, classNames?.overlay)}\n data-testid=\"overlay\"\n aria-hidden={true}\n style={{\n animation: `${overlayAnimation} ${animationDuration}ms`,\n ...styles?.overlay,\n }}\n />\n <div\n ref={refModal}\n id={containerId}\n className={cx(\n classes.modalContainer,\n center && classes.modalContainerCenter,\n classNames?.modalContainer\n )}\n style={styles?.modalContainer}\n data-testid=\"modal-container\"\n onClick={handleClickOverlay}\n >\n <div\n ref={refDialog}\n className={cx(classes.modal, classNames?.modal)}\n style={{\n animation: `${modalAnimation} ${animationDuration}ms`,\n ...styles?.modal,\n }}\n onMouseDown={handleModalEvent}\n onMouseUp={handleModalEvent}\n onClick={handleModalEvent}\n onAnimationEnd={handleAnimationEnd}\n id={modalId}\n role={role}\n aria-modal=\"true\"\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n data-testid=\"modal\"\n tabIndex={-1}\n >\n {focusTrapped && (\n <FocusTrap\n container={refDialog}\n initialFocusRef={initialFocusRef}\n />\n )}\n {children}\n {showCloseIcon && (\n <CloseIcon\n classes={classes}\n classNames={classNames}\n styles={styles}\n closeIcon={closeIcon}\n onClick={onClose}\n id={closeIconId}\n />\n )}\n </div>\n </div>\n </div>,\n containerModal\n )\n : null;\n }\n);\n\nexport default Modal;\n"],"names":["CloseIcon","classes","classNames","styles","id","closeIcon","onClick","React","className","cx","closeButton","style","width","height","viewBox","d","isBrowser","window","candidateSelectors","isHidden","node","offsetParent","getComputedStyle","visibility","getCheckedRadio","nodes","form","i","length","checked","isNotRadioOrTabbableRadio","tagName","type","name","radioScope","ownerDocument","radioSet","querySelectorAll","undefined","getAllTabbingElements","parentElem","currentActiveElement","document","activeElement","tabbableNodes","join","onlyTabbable","disabled","getTabindex","push","tabTrappingKey","event","key","contains","process","env","NODE_ENV","console","warn","target","allTabbingElements","firstFocusableElement","lastFocusableElement","shiftKey","focus","preventDefault","tabindexAttr","parseInt","getAttribute","isNaN","isContentEditable","tabIndex","FocusTrap","container","initialFocusRef","refLastFocus","useRef","useEffect","handleKeyEvent","current","addEventListener","savePreviousFocus","findIndex","selector","matches","requestAnimationFrame","removeEventListener","modals","modalManager","add","newModal","remove","oldModal","filter","modal","isTopModal","useModalManager","ref","open","useScrollLock","refModal","showPortal","blockScroll","reserveScrollBarGap","oldRef","disableBodyScroll","enableBodyScroll","root","overlay","overlayAnimationIn","overlayAnimationOut","modalContainer","modalContainerCenter","modalAnimationIn","modalAnimationOut","Modal","forwardRef","center","closeOnEsc","closeOnOverlayClick","showCloseIcon","closeIconId","focusTrapped","animationDuration","role","ariaDescribedby","ariaLabelledby","containerId","modalId","onClose","onEscKeyDown","onOverlayClick","onAnimationEnd","children","refDialog","useForwardedRef","refShouldClose","refContainer","createElement","useState","setShowPortal","handleOpen","body","appendChild","handleKeydown","handleClose","removeChild","keyCode","handleClickOverlay","handleModalEvent","handleAnimationEnd","containerModal","overlayAnimation","modalAnimation","ReactDom","createPortal","animation","onMouseDown","onMouseUp"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoBA,IAAMA,SAAS,GAAG,SAAZA,SAAY;AAAA,MAChBC,OADgB,QAChBA,OADgB;AAAA,MAEhBC,UAFgB,QAEhBA,UAFgB;AAAA,MAGhBC,MAHgB,QAGhBA,MAHgB;AAAA,MAIhBC,EAJgB,QAIhBA,EAJgB;AAAA,MAKhBC,SALgB,QAKhBA,SALgB;AAAA,MAMhBC,OANgB,QAMhBA,OANgB;AAAA,SAQhBC,mBAAA,SAAA;AACEH,IAAAA,EAAE,EAAEA;AACJI,IAAAA,SAAS,EAAEC,EAAE,CAACR,OAAO,CAACS,WAAT,EAAsBR,UAAtB,oBAAsBA,UAAU,CAAEQ,WAAlC;AACbC,IAAAA,KAAK,EAAER,MAAF,oBAAEA,MAAM,CAAEO;AACfJ,IAAAA,OAAO,EAAEA;mBACG;GALd,EAOGD,SAAS,GACRA,SADQ,GAGRE,mBAAA,MAAA;AACEC,IAAAA,SAAS,EAAEN,UAAF,oBAAEA,UAAU,CAAEG;AACvBM,IAAAA,KAAK,EAAER,MAAF,oBAAEA,MAAM,CAAEE;AACfO,IAAAA,KAAK,EAAE;AACPC,IAAAA,MAAM,EAAE;AACRC,IAAAA,OAAO,EAAC;mBACI;GANd,EAQEP,mBAAA,OAAA;AAAMQ,IAAAA,CAAC,EAAC;GAAR,CARF,CAVJ,CARgB;AAAA,CAAlB;;ACpBO,IAAMC,SAAS,GAAG,OAAOC,MAAP,KAAkB,WAApC;;ACAP;AAEA,AAAO,IAAMC,kBAAkB,GAAG,CAChC,OADgC,EAEhC,QAFgC,EAGhC,UAHgC,EAIhC,SAJgC,EAKhC,QALgC,EAMhC,YANgC,EAOhC,iBAPgC,EAQhC,iBARgC,EAShC,kDATgC,CAA3B;;AAYP,SAASC,QAAT,CAAkBC,IAAlB;AACE;AAC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AgB5F,UAAhB,oBAAgBA,UAAU,CAAE4F,KAA5B;AACbnF,IAAAA,KAAK;AACHiJ,MAAAA,SAAS,EAAKH,cAAL,SAAuB9B,iBAAvB;AADN,OAEAxH,MAFA,oBAEAA,MAAM,CAAE2F,KAFR;AAIL+D,IAAAA,WAAW,EAAER;AACbS,IAAAA,SAAS,EAAET;AACX/I,IAAAA,OAAO,EAAE+I;AACTjB,IAAAA,cAAc,EAAEkB;AAChBlJ,IAAAA,EAAE,EAAE4H;AACJJ,IAAAA,IAAI,EAAEA;kBACK;uBACME;wBACCD;mBACN;AACZtD,IAAAA,QAAQ,EAAE,CAAC;GAjBb,EAmBGmD,YAAY,IACXnH,mBAAA,CAACiE,SAAD;AACEC,IAAAA,SAAS,EAAE6D;AACX5D,IAAAA,eAAe,EAAEA;GAFnB,CApBJ,EAyBG2D,QAzBH,EA0BGb,aAAa,IACZjH,mBAAA,CAACP,SAAD;AACEC,IAAAA,OAAO,EAAEA;AACTC,IAAAA,UAAU,EAAEA;AACZC,IAAAA,MAAM,EAAEA;AACRE,IAAAA,SAAS,EAAEA;AACXC,IAAAA,OAAO,EAAE2H;AACT7H,IAAAA,EAAE,EAAEqH;GANN,CA3BJ,CAZF,CAdF,CADF,EAkEE8B,cAlEF,CADG,GAqEH,IArEJ;AAsED,CA1NkB,CAAd;;;;;"}
@@ -1 +0,0 @@
1
- export declare const useScrollLock: (refModal: React.RefObject<Element>, open: boolean, showPortal: boolean, blockScroll: boolean, reserveScrollBarGap?: boolean | undefined) => void;
package/dist/utils.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const isBrowser: boolean;