react-responsive-modal 6.4.2 → 7.1.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 +20 -0
- package/dist/index.cjs +339 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +148 -0
- package/dist/index.d.ts +148 -140
- package/dist/index.js +311 -5
- package/dist/index.js.map +1 -0
- package/package.json +52 -45
- package/src/FocusTrap.tsx +3 -3
- package/src/index.tsx +20 -14
- package/src/lib/focusTrapJs.ts +1 -1
- package/src/useScrollLock.ts +2 -2
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["classes","node: any","nodes: any","form: any","parentElem: any","event: any","event: KeyboardEvent","modals: Ref<Element>[]","newModal: Ref<Element>","oldModal: Ref<Element>","modal: Ref<Element>","ref: Ref<Element>","open: boolean","refModal: React.RefObject<Element | null>","open: boolean","showPortal: boolean","blockScroll: boolean","reserveScrollBarGap?: boolean","ref: React.ForwardedRef<HTMLDivElement>","event: KeyboardEvent","event: React.MouseEvent<HTMLDivElement, MouseEvent>","CloseIcon"],"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 | null>;\n}\n\nexport const FocusTrap = ({ container, initialFocusRef }: FocusTrapProps) => {\n const refLastFocus = useRef<HTMLElement | null>(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 | null>,\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 { createPortal } from 'react-dom';\nimport cx from 'classnames';\nimport { useForwardedRef } from '@bedrock-layout/use-forwarded-ref';\nimport CloseIcon from './CloseIcon';\nimport { FocusTrap } from './FocusTrap';\nimport { modalManager, useModalManager } from './modalManager';\nimport { useScrollLock } from './useScrollLock';\nimport { isBrowser } from './utils';\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 | null>;\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 ariaLabel?: 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 ariaLabel,\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 ? 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-label={ariaLabel}\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"],"mappings":";;;;;;;;AAoBA,MAAM,YAAY,CAAC,EACjB,oBACA,YACA,QACA,IACA,WACA,SACe,qBACf,IAAC;CACK;CACJ,WAAW,GAAGA,UAAQ,aAAa,YAAY,YAAY;CAC3D,OAAO,QAAQ;CACN;CACT,eAAY;WAEX,YACC,4BAEA,IAAC;EACC,WAAW,YAAY;EACvB,OAAO,QAAQ;EACf,OAAO;EACP,QAAQ;EACR,SAAQ;EACR,eAAY;4BAEZ,IAAC,UAAK,GAAE,wHAAwH;GAC5H;EAED;AAGX,wBAAe;;;;ACpDf,MAAa,mBAAmB,WAAW;;;;ACE3C,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAED,SAAS,SAASC,MAAW;AAG3B,QACE,KAAK,iBAAiB,QAAQ,iBAAiB,KAAK,CAAC,eAAe;AAEvE;AAED,SAAS,gBAAgBC,OAAYC,MAAW;AAC9C,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,IAChC,KAAI,MAAM,GAAG,WAAW,MAAM,GAAG,SAAS,KACxC,QAAO,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QAAQ,mBACxC,YAAY,qBAAqB,QAAQ;AAE9C,QAAO,cAAc,iBACjB,6BACE,KAAC;EACC,WAAW,GAAG,QAAQ,MAAM,YAAY,KAAK;EAC7C,OAAO,QAAQ;EACf,eAAY;6BAEZ,IAAC;GACC,WAAW,GAAG,QAAQ,SAAS,YAAY,QAAQ;GACnD,eAAY;GACZ,eAAa;GACb,OAAO;IACL,YAAY,EAAE,iBAAiB,GAAG,kBAAkB;IACpD,GAAG,QAAQ;GACZ;IACD,kBACF,IAAC;GACC,KAAK;GACL,IAAI;GACJ,WAAW,GACT,QAAQ,gBACR,UAAU,QAAQ,sBAClB,YAAY,eACb;GACD,OAAO,QAAQ;GACf,eAAY;GACZ,SAAS;6BAET,KAAC;IACC,KAAK;IACL,WAAW,GAAG,QAAQ,OAAO,YAAY,MAAM;IAC/C,OAAO;KACL,YAAY,EAAE,eAAe,GAAG,kBAAkB;KAClD,GAAG,QAAQ;IACZ;IACD,aAAa;IACb,WAAW;IACX,SAAS;IACT,gBAAgB;IAChB,IAAI;IACE;IACN,cAAW;IACX,cAAY;IACZ,mBAAiB;IACjB,oBAAkB;IAClB,eAAY;IACZ,UAAU;;KAET,gCACC,IAAC;MACC,WAAW;MACM;OACjB;KAEH;KACA,iCACC,IAACC;MACU;MACG;MACJ;MACG;MACX,SAAS;MACT,IAAI;OACJ;;KAEA;IACF;GACF,EACN,eACD,GACD;AACL,EACF;AAED,kBAAe"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-responsive-modal",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.1.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.
|
|
@@ -120,6 +120,10 @@ export interface ModalProps {
|
|
|
120
120
|
* Default to 'dialog'.
|
|
121
121
|
*/
|
|
122
122
|
role?: string;
|
|
123
|
+
/**
|
|
124
|
+
* ARIA label for modal
|
|
125
|
+
*/
|
|
126
|
+
ariaLabel?: string;
|
|
123
127
|
/**
|
|
124
128
|
* ARIA label for modal
|
|
125
129
|
*/
|
|
@@ -152,7 +156,7 @@ export interface ModalProps {
|
|
|
152
156
|
* Callback fired when the overlay is clicked.
|
|
153
157
|
*/
|
|
154
158
|
onOverlayClick?: (
|
|
155
|
-
event: React.MouseEvent<HTMLDivElement, MouseEvent
|
|
159
|
+
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
|
156
160
|
) => void;
|
|
157
161
|
/**
|
|
158
162
|
* Callback fired when the Modal has exited and the animation is finished.
|
|
@@ -179,6 +183,7 @@ export const Modal = React.forwardRef(
|
|
|
179
183
|
classNames,
|
|
180
184
|
styles,
|
|
181
185
|
role = 'dialog',
|
|
186
|
+
ariaLabel,
|
|
182
187
|
ariaDescribedby,
|
|
183
188
|
ariaLabelledby,
|
|
184
189
|
containerId,
|
|
@@ -190,7 +195,7 @@ export const Modal = React.forwardRef(
|
|
|
190
195
|
children,
|
|
191
196
|
reserveScrollBarGap,
|
|
192
197
|
}: ModalProps,
|
|
193
|
-
ref: React.ForwardedRef<HTMLDivElement
|
|
198
|
+
ref: React.ForwardedRef<HTMLDivElement>,
|
|
194
199
|
) => {
|
|
195
200
|
const refDialog = useForwardedRef(ref);
|
|
196
201
|
const refModal = useRef<HTMLDivElement>(null);
|
|
@@ -267,7 +272,7 @@ export const Modal = React.forwardRef(
|
|
|
267
272
|
}, [open]);
|
|
268
273
|
|
|
269
274
|
const handleClickOverlay = (
|
|
270
|
-
event: React.MouseEvent<HTMLDivElement, MouseEvent
|
|
275
|
+
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
|
271
276
|
) => {
|
|
272
277
|
if (refShouldClose.current === null) {
|
|
273
278
|
refShouldClose.current = true;
|
|
@@ -302,15 +307,15 @@ export const Modal = React.forwardRef(
|
|
|
302
307
|
const containerModal = container || refContainer.current;
|
|
303
308
|
|
|
304
309
|
const overlayAnimation = open
|
|
305
|
-
? classNames?.overlayAnimationIn ?? classes.overlayAnimationIn
|
|
306
|
-
: classNames?.overlayAnimationOut ?? classes.overlayAnimationOut;
|
|
310
|
+
? (classNames?.overlayAnimationIn ?? classes.overlayAnimationIn)
|
|
311
|
+
: (classNames?.overlayAnimationOut ?? classes.overlayAnimationOut);
|
|
307
312
|
|
|
308
313
|
const modalAnimation = open
|
|
309
|
-
? classNames?.modalAnimationIn ?? classes.modalAnimationIn
|
|
310
|
-
: classNames?.modalAnimationOut ?? classes.modalAnimationOut;
|
|
314
|
+
? (classNames?.modalAnimationIn ?? classes.modalAnimationIn)
|
|
315
|
+
: (classNames?.modalAnimationOut ?? classes.modalAnimationOut);
|
|
311
316
|
|
|
312
317
|
return showPortal && containerModal
|
|
313
|
-
?
|
|
318
|
+
? createPortal(
|
|
314
319
|
<div
|
|
315
320
|
className={cx(classes.root, classNames?.root)}
|
|
316
321
|
style={styles?.root}
|
|
@@ -331,7 +336,7 @@ export const Modal = React.forwardRef(
|
|
|
331
336
|
className={cx(
|
|
332
337
|
classes.modalContainer,
|
|
333
338
|
center && classes.modalContainerCenter,
|
|
334
|
-
classNames?.modalContainer
|
|
339
|
+
classNames?.modalContainer,
|
|
335
340
|
)}
|
|
336
341
|
style={styles?.modalContainer}
|
|
337
342
|
data-testid="modal-container"
|
|
@@ -351,6 +356,7 @@ export const Modal = React.forwardRef(
|
|
|
351
356
|
id={modalId}
|
|
352
357
|
role={role}
|
|
353
358
|
aria-modal="true"
|
|
359
|
+
aria-label={ariaLabel}
|
|
354
360
|
aria-labelledby={ariaLabelledby}
|
|
355
361
|
aria-describedby={ariaDescribedby}
|
|
356
362
|
data-testid="modal"
|
|
@@ -376,10 +382,10 @@ export const Modal = React.forwardRef(
|
|
|
376
382
|
</div>
|
|
377
383
|
</div>
|
|
378
384
|
</div>,
|
|
379
|
-
containerModal
|
|
385
|
+
containerModal,
|
|
380
386
|
)
|
|
381
387
|
: null;
|
|
382
|
-
}
|
|
388
|
+
},
|
|
383
389
|
);
|
|
384
390
|
|
|
385
391
|
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/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;
|