GoScrobble/web/node_modules/reactjs-popup/dist/reactjs-popup.cjs.development.js.map

1 line
40 KiB
Plaintext
Raw Normal View History

2022-04-25 02:47:15 +00:00
{"version":3,"file":"reactjs-popup.cjs.development.js","sources":["../src/hooks.tsx","../src/styles.ts","../src/Utils.ts","../src/index.tsx"],"sourcesContent":["import { useEffect, RefObject, useLayoutEffect } from 'react';\n\nexport const useOnEscape = (\n handler: (event: KeyboardEvent) => void,\n active = true\n) => {\n useEffect(() => {\n if (!active) return;\n const listener = (event: KeyboardEvent) => {\n // check if key is an Escape\n if (event.key === 'Escape') handler(event);\n };\n document.addEventListener('keyup', listener);\n\n return () => {\n if (!active) return;\n document.removeEventListener('keyup', listener);\n };\n }, [handler, active]);\n};\n\nexport const useRepositionOnResize = (handler: () => void, active = true) => {\n useEffect(() => {\n if (!active) return;\n const listener = () => {\n handler();\n };\n\n window.addEventListener('resize', listener);\n\n return () => {\n if (!active) return;\n window.removeEventListener('resize', listener);\n };\n }, [handler, active]);\n};\n\nexport const useOnClickOutside = (\n ref: RefObject<HTMLElement> | RefObject<HTMLElement>[],\n handler: (event: TouchEvent | MouseEvent) => void,\n active = true\n) => {\n useEffect(() => {\n if (!active) return;\n const listener = (event: TouchEvent | MouseEvent) => {\n // Do nothing if clicking ref's element or descendent elements\n const refs = Array.isArray(ref) ? ref : [ref];\n\n let contains = false;\n refs.forEach(r => {\n if (!r.current || r.current.contains(event.target as Node)) {\n contains = true;\n return;\n }\n });\n event.stopPropagation();\n if (!contains) handler(event);\n };\n\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n\n return () => {\n if (!active) return;\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [ref, handler, active]);\n};\n\n// Make sure that user is not able TAB out of the Modal content on Open\nexport const useTabbing = (\n contentRef: RefObject<HTMLElement>,\n active = true\n) => {\n useEffect(() => {\n if (!active) return;\n const listener = (event: KeyboardEvent) => {\n // check if key is an Tab\n if (event.keyCode === 9) {\n const els = contentRef?.current?.querySelectorAll(\n 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex=\"0\"]'\n );\n\n const focusableEls = Array.prototype.slice.call(els);\n if (focusableEls.length === 1) {\n event.preventDefault();\n return;\n }\n\n const firstFocusableEl = focusableEls[0];\n const lastFocusableEl = focusableEls[focusableEls.length - 1];\n if (event.shiftKey && document.activeElement === firstFocusableEl) {\n event.preventDefault();\n lastFocusableEl.focus();\n } else if (document.activeElement === lastFocusableEl) {\n event.preventDefault();\n firstFocusableEl.focus();\n }\n }\n };\n\n document.addEventListener('keydown', listener);\n\n return () => {\n if (!active) return;\n document.removeEventListener('keydown', listener);\n };\n }, [contentRef, active]);\n};\n\nexport const useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n","import React from 'react';\n\ntype PopupStyle = {\n popupContent: {\n tooltip: React.CSSProperties;\n modal: React.CSSProperties;\n };\n popupArrow: React.CSSProperties;\n overlay: {\n tooltip: React.CSSProperties;\n modal: React.CSSProperties;\n };\n};\n\nconst Style: PopupStyle = {\n popupContent: {\n tooltip: {\n position: 'absolute',\n zIndex: 999,\n },\n modal: {\n position: 'relative',\n margin: 'auto',\n },\n },\n popupArrow: {\n height: '8px',\n