react-cool-onclickoutside
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,1 +0,1 @@ | ||
import{useRef as n,useCallback as e,useEffect as t}from"react";var r=function(n){return document.documentElement.clientWidth<=n.clientX||document.documentElement.clientHeight<=n.clientY},o=function(n){return!(!n.includes("touch")||!function(){if("undefined"==typeof window||"function"!=typeof window.addEventListener)return!1;var n=!1,e=Object.defineProperty({},"passive",{get:function(){n=!0}}),t=function(){return null};return window.addEventListener("test",t,e),window.removeEventListener("test",t,e),n}())&&{passive:!0}};export default function(i){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=u.eventTypes,d=void 0===c?["mousedown","touchstart"]:c,f=u.excludeScrollbar,l=void 0!==f&&f;if("undefined"==typeof document||!document.createElement)return null;var a=n([]),v=e((function(n){n&&a.current.push(n)}),[]),m=e((function(n){var e=a.current;if(e.length&&i&&(!l||!r(n))){var t=!0,o=!1,u=void 0;try{for(var c,d=e[Symbol.iterator]();!(t=(c=d.next()).done);t=!0){if(c.value.contains(n.target))return}}catch(n){o=!0,u=n}finally{try{t||null==d.return||d.return()}finally{if(o)throw u}}i(n)}}),[a,l,i]);return t((function(){return i?(d.forEach((function(n){document.addEventListener(n,m,o(n))})),function(){d.forEach((function(n){document.removeEventListener(n,m,o(n))}))}):null}),[i,d]),v} | ||
import{useRef as n,useCallback as e,useEffect as t}from"react";var r=function(n){return document.documentElement.clientWidth<=n.clientX||document.documentElement.clientHeight<=n.clientY},o=function(n){return!(!n.includes("touch")||!function(){if("undefined"==typeof window||"function"!=typeof window.addEventListener)return!1;var n=!1,e=Object.defineProperty({},"passive",{get:function(){n=!0}}),t=function(){return null};return window.addEventListener("test",t,e),window.removeEventListener("test",t,e),n}())&&{passive:!0}};export default function(i){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=u.eventTypes,d=void 0===c?["mousedown","touchstart"]:c,f=u.excludeScrollbar,l=void 0!==f&&f;if("undefined"==typeof document||!document.createElement)return null;var a=n([]),v=e((function(n){n&&a.current.push(n)}),[]),m=e((function(n){var e=a.current;if(e.length&&i&&(!l||!r(n))){var t=!0,o=!1,u=void 0;try{for(var c,d=e[Symbol.iterator]();!(t=(c=d.next()).done);t=!0){if(c.value.contains(n.target))return}}catch(n){o=!0,u=n}finally{try{t||null==d.return||d.return()}finally{if(o)throw u}}i(n)}}),[a,l,i]);return t((function(){return i?(d.forEach((function(n){document.addEventListener(n,m,o(n))})),function(){d.forEach((function(n){document.removeEventListener(n,m,o(n))}))}):null}),[i,d,m]),v} |
@@ -1,1 +0,1 @@ | ||
"use strict";var e=require("react"),n=function(e){return document.documentElement.clientWidth<=e.clientX||document.documentElement.clientHeight<=e.clientY},t=function(e){return!(!e.includes("touch")||!function(){if("undefined"==typeof window||"function"!=typeof window.addEventListener)return!1;var e=!1,n=Object.defineProperty({},"passive",{get:function(){e=!0}}),t=function(){return null};return window.addEventListener("test",t,n),window.removeEventListener("test",t,n),e}())&&{passive:!0}};module.exports=function(r){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=u.eventTypes,i=void 0===o?["mousedown","touchstart"]:o,c=u.excludeScrollbar,d=void 0!==c&&c;if("undefined"==typeof document||!document.createElement)return null;var f=e.useRef([]),l=e.useCallback((function(e){e&&f.current.push(e)}),[]),a=e.useCallback((function(e){var t=f.current;if(t.length&&r&&(!d||!n(e))){var u=!0,o=!1,i=void 0;try{for(var c,l=t[Symbol.iterator]();!(u=(c=l.next()).done);u=!0){if(c.value.contains(e.target))return}}catch(e){o=!0,i=e}finally{try{u||null==l.return||l.return()}finally{if(o)throw i}}r(e)}}),[f,d,r]);return e.useEffect((function(){return r?(i.forEach((function(e){document.addEventListener(e,a,t(e))})),function(){i.forEach((function(e){document.removeEventListener(e,a,t(e))}))}):null}),[r,i]),l}; | ||
"use strict";var e=require("react"),n=function(e){return document.documentElement.clientWidth<=e.clientX||document.documentElement.clientHeight<=e.clientY},t=function(e){return!(!e.includes("touch")||!function(){if("undefined"==typeof window||"function"!=typeof window.addEventListener)return!1;var e=!1,n=Object.defineProperty({},"passive",{get:function(){e=!0}}),t=function(){return null};return window.addEventListener("test",t,n),window.removeEventListener("test",t,n),e}())&&{passive:!0}};module.exports=function(r){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=u.eventTypes,i=void 0===o?["mousedown","touchstart"]:o,c=u.excludeScrollbar,d=void 0!==c&&c;if("undefined"==typeof document||!document.createElement)return null;var f=e.useRef([]),l=e.useCallback((function(e){e&&f.current.push(e)}),[]),a=e.useCallback((function(e){var t=f.current;if(t.length&&r&&(!d||!n(e))){var u=!0,o=!1,i=void 0;try{for(var c,l=t[Symbol.iterator]();!(u=(c=l.next()).done);u=!0){if(c.value.contains(e.target))return}}catch(e){o=!0,i=e}finally{try{u||null==l.return||l.return()}finally{if(o)throw i}}r(e)}}),[f,d,r]);return e.useEffect((function(){return r?(i.forEach((function(e){document.addEventListener(e,a,t(e))})),function(){i.forEach((function(e){document.removeEventListener(e,a,t(e))}))}):null}),[r,i,a]),l}; |
{ | ||
"name": "react-cool-onclickoutside", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "React hook to listen for clicks outside of the component(s).", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17966