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.
- package/CHANGELOG.md +13 -0
- package/dist/index.cjs +338 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +144 -0
- package/dist/index.d.ts +144 -140
- package/dist/index.js +310 -5
- package/dist/index.js.map +1 -0
- package/package.json +52 -45
- package/src/FocusTrap.tsx +3 -3
- package/src/index.tsx +14 -14
- package/src/lib/focusTrapJs.ts +1 -1
- package/src/useScrollLock.ts +2 -2
- package/styles.css +7 -0
- package/dist/CloseIcon.d.ts +0 -19
- package/dist/FocusTrap.d.ts +0 -7
- package/dist/lib/focusTrapJs.d.ts +0 -3
- package/dist/modalManager.d.ts +0 -20
- package/dist/react-responsive-modal.cjs.development.js +0 -472
- package/dist/react-responsive-modal.cjs.development.js.map +0 -1
- package/dist/react-responsive-modal.cjs.production.min.js +0 -2
- package/dist/react-responsive-modal.cjs.production.min.js.map +0 -1
- package/dist/react-responsive-modal.esm.js +0 -465
- package/dist/react-responsive-modal.esm.js.map +0 -1
- package/dist/useScrollLock.d.ts +0 -1
- package/dist/utils.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-responsive-modal",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "A simple responsive and accessible react modal",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
8
9
|
"typings": "dist/index.d.ts",
|
|
9
10
|
"scripts": {
|
|
10
|
-
"start": "
|
|
11
|
-
"build": "
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"prepare": "
|
|
11
|
+
"start": "tsdown --watch",
|
|
12
|
+
"build": "tsdown",
|
|
13
|
+
"typecheck": "tsc --noEmit",
|
|
14
|
+
"test": "vitest",
|
|
15
|
+
"prepare": "tsdown",
|
|
15
16
|
"size": "size-limit"
|
|
16
17
|
},
|
|
17
18
|
"files": [
|
|
@@ -19,17 +20,6 @@
|
|
|
19
20
|
"src",
|
|
20
21
|
"styles.css"
|
|
21
22
|
],
|
|
22
|
-
"jest": {
|
|
23
|
-
"setupFilesAfterEnv": [
|
|
24
|
-
"./__tests__/setupTests.ts"
|
|
25
|
-
],
|
|
26
|
-
"modulePathIgnorePatterns": [
|
|
27
|
-
"cypress"
|
|
28
|
-
],
|
|
29
|
-
"coveragePathIgnorePatterns": [
|
|
30
|
-
"src/lib"
|
|
31
|
-
]
|
|
32
|
-
},
|
|
33
23
|
"keywords": [
|
|
34
24
|
"react",
|
|
35
25
|
"responsive",
|
|
@@ -37,7 +27,11 @@
|
|
|
37
27
|
"mobile",
|
|
38
28
|
"flex"
|
|
39
29
|
],
|
|
40
|
-
"repository":
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/pradel/react-responsive-modal.git",
|
|
33
|
+
"directory": "react-responsive-modal"
|
|
34
|
+
},
|
|
41
35
|
"author": "Léo Pradel",
|
|
42
36
|
"bugs": {
|
|
43
37
|
"url": "https://github.com/pradel/react-responsive-modal/issues"
|
|
@@ -46,41 +40,54 @@
|
|
|
46
40
|
"funding": "https://github.com/sponsors/pradel",
|
|
47
41
|
"size-limit": [
|
|
48
42
|
{
|
|
49
|
-
"path": "dist/
|
|
50
|
-
"limit": "
|
|
43
|
+
"path": "dist/index.js",
|
|
44
|
+
"limit": "3.6 KB"
|
|
51
45
|
},
|
|
52
46
|
{
|
|
53
|
-
"path": "dist/
|
|
54
|
-
"limit": "4.
|
|
47
|
+
"path": "dist/index.cjs",
|
|
48
|
+
"limit": "4.0 KB"
|
|
55
49
|
}
|
|
56
50
|
],
|
|
57
51
|
"dependencies": {
|
|
58
|
-
"@bedrock-layout/use-forwarded-ref": "^
|
|
52
|
+
"@bedrock-layout/use-forwarded-ref": "^2.0.17",
|
|
59
53
|
"body-scroll-lock": "^3.1.5",
|
|
60
54
|
"classnames": "^2.3.1"
|
|
61
55
|
},
|
|
62
56
|
"peerDependencies": {
|
|
63
|
-
"react": "^16.8.0 || ^17 || ^18",
|
|
64
|
-
"react-dom": "^16.8.0 || ^17 || ^18"
|
|
57
|
+
"react": "^16.8.0 || ^17 || ^18 || ^19",
|
|
58
|
+
"react-dom": "^16.8.0 || ^17 || ^18 || ^19"
|
|
65
59
|
},
|
|
66
60
|
"devDependencies": {
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"@testing-library/
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"@types/
|
|
73
|
-
"@types/
|
|
74
|
-
"@types/
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
61
|
+
"@codecov/vite-plugin": "1.9.1",
|
|
62
|
+
"@size-limit/preset-small-lib": "11.2.0",
|
|
63
|
+
"@testing-library/dom": "10.4.0",
|
|
64
|
+
"@testing-library/jest-dom": "6.6.3",
|
|
65
|
+
"@testing-library/react": "16.3.0",
|
|
66
|
+
"@types/body-scroll-lock": "2.6.2",
|
|
67
|
+
"@types/classnames": "2.3.4",
|
|
68
|
+
"@types/node": "22.16.3",
|
|
69
|
+
"@types/react": "19.1.8",
|
|
70
|
+
"@types/react-dom": "19.1.6",
|
|
71
|
+
"@vitejs/plugin-react": "4.6.0",
|
|
72
|
+
"@vitest/coverage-istanbul": "3.2.4",
|
|
73
|
+
"cypress": "14.5.1",
|
|
74
|
+
"jsdom": "26.1.0",
|
|
75
|
+
"publint": "0.3.12",
|
|
76
|
+
"react": "19.1.0",
|
|
77
|
+
"react-dom": "19.1.0",
|
|
78
|
+
"size-limit": "11.2.0",
|
|
79
|
+
"tsdown": "0.12.9",
|
|
80
|
+
"tslib": "2.8.1",
|
|
81
|
+
"typescript": "5.8.3",
|
|
82
|
+
"vitest": "3.2.4"
|
|
83
|
+
},
|
|
84
|
+
"types": "./dist/index.d.cts",
|
|
85
|
+
"exports": {
|
|
86
|
+
".": {
|
|
87
|
+
"import": "./dist/index.js",
|
|
88
|
+
"require": "./dist/index.cjs"
|
|
89
|
+
},
|
|
90
|
+
"./package.json": "./package.json",
|
|
91
|
+
"./styles.css": "./styles.css"
|
|
85
92
|
}
|
|
86
93
|
}
|
package/src/FocusTrap.tsx
CHANGED
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
|
|
9
9
|
interface FocusTrapProps {
|
|
10
10
|
container?: React.RefObject<HTMLElement> | null;
|
|
11
|
-
initialFocusRef?: React.RefObject<HTMLElement>;
|
|
11
|
+
initialFocusRef?: React.RefObject<HTMLElement | null>;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const FocusTrap = ({ container, initialFocusRef }: FocusTrapProps) => {
|
|
15
|
-
const refLastFocus = useRef<HTMLElement | null>();
|
|
15
|
+
const refLastFocus = useRef<HTMLElement | null>(null);
|
|
16
16
|
/**
|
|
17
17
|
* Handle focus lock on the modal
|
|
18
18
|
*/
|
|
@@ -33,7 +33,7 @@ export const FocusTrap = ({ container, initialFocusRef }: FocusTrapProps) => {
|
|
|
33
33
|
// only if it's a focusable element
|
|
34
34
|
if (
|
|
35
35
|
candidateSelectors.findIndex((selector) =>
|
|
36
|
-
document.activeElement?.matches(selector)
|
|
36
|
+
document.activeElement?.matches(selector),
|
|
37
37
|
) !== -1
|
|
38
38
|
) {
|
|
39
39
|
refLastFocus.current = document.activeElement as HTMLElement;
|
package/src/index.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
3
|
import cx from 'classnames';
|
|
4
|
+
import { useForwardedRef } from '@bedrock-layout/use-forwarded-ref';
|
|
4
5
|
import CloseIcon from './CloseIcon';
|
|
5
6
|
import { FocusTrap } from './FocusTrap';
|
|
6
7
|
import { modalManager, useModalManager } from './modalManager';
|
|
7
8
|
import { useScrollLock } from './useScrollLock';
|
|
8
9
|
import { isBrowser } from './utils';
|
|
9
|
-
import useForwardedRef from '@bedrock-layout/use-forwarded-ref';
|
|
10
10
|
|
|
11
11
|
const classes = {
|
|
12
12
|
root: 'react-responsive-modal-root',
|
|
@@ -75,7 +75,7 @@ export interface ModalProps {
|
|
|
75
75
|
*
|
|
76
76
|
* Default to undefined.
|
|
77
77
|
*/
|
|
78
|
-
initialFocusRef?: React.RefObject<HTMLElement>;
|
|
78
|
+
initialFocusRef?: React.RefObject<HTMLElement | null>;
|
|
79
79
|
/**
|
|
80
80
|
* You can specify a container prop which should be of type `Element`.
|
|
81
81
|
* The portal will be rendered inside that element.
|
|
@@ -152,7 +152,7 @@ export interface ModalProps {
|
|
|
152
152
|
* Callback fired when the overlay is clicked.
|
|
153
153
|
*/
|
|
154
154
|
onOverlayClick?: (
|
|
155
|
-
event: React.MouseEvent<HTMLDivElement, MouseEvent
|
|
155
|
+
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
|
156
156
|
) => void;
|
|
157
157
|
/**
|
|
158
158
|
* Callback fired when the Modal has exited and the animation is finished.
|
|
@@ -190,7 +190,7 @@ export const Modal = React.forwardRef(
|
|
|
190
190
|
children,
|
|
191
191
|
reserveScrollBarGap,
|
|
192
192
|
}: ModalProps,
|
|
193
|
-
ref: React.ForwardedRef<HTMLDivElement
|
|
193
|
+
ref: React.ForwardedRef<HTMLDivElement>,
|
|
194
194
|
) => {
|
|
195
195
|
const refDialog = useForwardedRef(ref);
|
|
196
196
|
const refModal = useRef<HTMLDivElement>(null);
|
|
@@ -267,7 +267,7 @@ export const Modal = React.forwardRef(
|
|
|
267
267
|
}, [open]);
|
|
268
268
|
|
|
269
269
|
const handleClickOverlay = (
|
|
270
|
-
event: React.MouseEvent<HTMLDivElement, MouseEvent
|
|
270
|
+
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
|
271
271
|
) => {
|
|
272
272
|
if (refShouldClose.current === null) {
|
|
273
273
|
refShouldClose.current = true;
|
|
@@ -302,15 +302,15 @@ export const Modal = React.forwardRef(
|
|
|
302
302
|
const containerModal = container || refContainer.current;
|
|
303
303
|
|
|
304
304
|
const overlayAnimation = open
|
|
305
|
-
? classNames?.overlayAnimationIn ?? classes.overlayAnimationIn
|
|
306
|
-
: classNames?.overlayAnimationOut ?? classes.overlayAnimationOut;
|
|
305
|
+
? (classNames?.overlayAnimationIn ?? classes.overlayAnimationIn)
|
|
306
|
+
: (classNames?.overlayAnimationOut ?? classes.overlayAnimationOut);
|
|
307
307
|
|
|
308
308
|
const modalAnimation = open
|
|
309
|
-
? classNames?.modalAnimationIn ?? classes.modalAnimationIn
|
|
310
|
-
: classNames?.modalAnimationOut ?? classes.modalAnimationOut;
|
|
309
|
+
? (classNames?.modalAnimationIn ?? classes.modalAnimationIn)
|
|
310
|
+
: (classNames?.modalAnimationOut ?? classes.modalAnimationOut);
|
|
311
311
|
|
|
312
312
|
return showPortal && containerModal
|
|
313
|
-
?
|
|
313
|
+
? createPortal(
|
|
314
314
|
<div
|
|
315
315
|
className={cx(classes.root, classNames?.root)}
|
|
316
316
|
style={styles?.root}
|
|
@@ -331,7 +331,7 @@ export const Modal = React.forwardRef(
|
|
|
331
331
|
className={cx(
|
|
332
332
|
classes.modalContainer,
|
|
333
333
|
center && classes.modalContainerCenter,
|
|
334
|
-
classNames?.modalContainer
|
|
334
|
+
classNames?.modalContainer,
|
|
335
335
|
)}
|
|
336
336
|
style={styles?.modalContainer}
|
|
337
337
|
data-testid="modal-container"
|
|
@@ -376,10 +376,10 @@ export const Modal = React.forwardRef(
|
|
|
376
376
|
</div>
|
|
377
377
|
</div>
|
|
378
378
|
</div>,
|
|
379
|
-
containerModal
|
|
379
|
+
containerModal,
|
|
380
380
|
)
|
|
381
381
|
: null;
|
|
382
|
-
}
|
|
382
|
+
},
|
|
383
383
|
);
|
|
384
384
|
|
|
385
385
|
export default Modal;
|
package/src/lib/focusTrapJs.ts
CHANGED
|
@@ -34,7 +34,7 @@ function isNotRadioOrTabbableRadio(node: any) {
|
|
|
34
34
|
}
|
|
35
35
|
var radioScope = node.form || node.ownerDocument;
|
|
36
36
|
var radioSet = radioScope.querySelectorAll(
|
|
37
|
-
'input[type="radio"][name="' + node.name + '"]'
|
|
37
|
+
'input[type="radio"][name="' + node.name + '"]',
|
|
38
38
|
);
|
|
39
39
|
var checked = getCheckedRadio(radioSet, node.form);
|
|
40
40
|
return checked === node || (checked === undefined && radioSet[0] === node);
|
package/src/useScrollLock.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { useEffect, useRef } from 'react';
|
|
|
2
2
|
import { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';
|
|
3
3
|
|
|
4
4
|
export const useScrollLock = (
|
|
5
|
-
refModal: React.RefObject<Element>,
|
|
5
|
+
refModal: React.RefObject<Element | null>,
|
|
6
6
|
open: boolean,
|
|
7
7
|
showPortal: boolean,
|
|
8
8
|
blockScroll: boolean,
|
|
9
|
-
reserveScrollBarGap?: boolean
|
|
9
|
+
reserveScrollBarGap?: boolean,
|
|
10
10
|
) => {
|
|
11
11
|
const oldRef = useRef<Element | null>(null);
|
|
12
12
|
|
package/styles.css
CHANGED
|
@@ -58,6 +58,13 @@
|
|
|
58
58
|
display: flex;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/* Used to fix a screen glitch issues with the animation see https://github.com/pradel/react-responsive-modal/issues/495 */
|
|
62
|
+
.react-responsive-modal-overlay,
|
|
63
|
+
.react-responsive-modal-container,
|
|
64
|
+
.react-responsive-modal-modal {
|
|
65
|
+
animation-fill-mode: forwards !important;
|
|
66
|
+
}
|
|
67
|
+
|
|
61
68
|
@keyframes react-responsive-modal-overlay-in {
|
|
62
69
|
0% {
|
|
63
70
|
opacity: 0;
|
package/dist/CloseIcon.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface CloseIconProps {
|
|
3
|
-
id?: string;
|
|
4
|
-
closeIcon?: React.ReactNode;
|
|
5
|
-
styles?: {
|
|
6
|
-
closeButton?: React.CSSProperties;
|
|
7
|
-
closeIcon?: React.CSSProperties;
|
|
8
|
-
};
|
|
9
|
-
classNames?: {
|
|
10
|
-
closeButton?: string;
|
|
11
|
-
closeIcon?: string;
|
|
12
|
-
};
|
|
13
|
-
classes: {
|
|
14
|
-
closeButton?: string;
|
|
15
|
-
};
|
|
16
|
-
onClick: () => void;
|
|
17
|
-
}
|
|
18
|
-
declare const CloseIcon: ({ classes, classNames, styles, id, closeIcon, onClick, }: CloseIconProps) => JSX.Element;
|
|
19
|
-
export default CloseIcon;
|
package/dist/FocusTrap.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
interface FocusTrapProps {
|
|
3
|
-
container?: React.RefObject<HTMLElement> | null;
|
|
4
|
-
initialFocusRef?: React.RefObject<HTMLElement>;
|
|
5
|
-
}
|
|
6
|
-
export declare const FocusTrap: ({ container, initialFocusRef }: FocusTrapProps) => null;
|
|
7
|
-
export {};
|
package/dist/modalManager.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Ref } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Handle the order of the modals.
|
|
4
|
-
* Inspired by the material-ui implementation.
|
|
5
|
-
*/
|
|
6
|
-
export declare const modalManager: {
|
|
7
|
-
/**
|
|
8
|
-
* Register a new modal
|
|
9
|
-
*/
|
|
10
|
-
add: (newModal: Ref<Element>) => void;
|
|
11
|
-
/**
|
|
12
|
-
* Remove a modal
|
|
13
|
-
*/
|
|
14
|
-
remove: (oldModal: Ref<Element>) => void;
|
|
15
|
-
/**
|
|
16
|
-
* When multiple modals are rendered will return true if current modal is the last one
|
|
17
|
-
*/
|
|
18
|
-
isTopModal: (modal: Ref<Element>) => boolean;
|
|
19
|
-
};
|
|
20
|
-
export declare function useModalManager(ref: Ref<Element>, open: boolean): void;
|