react-click-away-listener
Advanced tools
Comparing version 2.0.0 to 2.1.0-beta.1
@@ -1,2 +0,2 @@ | ||
import n,{useRef as e,useEffect as t}from"react";export default function(r){var o=r.children,c=r.onClickAway,u=r.mouseEvent,i=void 0===u?"click":u,v=r.touchEvent,d=void 0===v?"touchend":v,l=e(null),a=e(null),f=function(n){var e=n.event,t=n.type;a.current=e.target;var r=null==o?void 0:o.props[t];r&&r(e)};return t((function(){var n=function(n){l.current&&l.current.contains(n.target)||a.current===n.target||c(n)};return document.addEventListener(i,n),document.addEventListener(d,n),function(){document.removeEventListener(i,n),document.removeEventListener(d,n)}}),[i,c,d]),n.Children.only(n.cloneElement(o,{ref:function(n){l.current=n;var e=o.ref;"function"==typeof e?e(n):e&&(e.current=n)},onClick:function(n){return f({type:"onClick",event:n})},onTouchEnd:function(n){return f({type:"onTouchEnd",event:n})}}))} | ||
import n,{useRef as e,useEffect as t}from"react";export default function(r){var o=r.children,c=r.onClickAway,u=r.mouseEvent,i=void 0===u?"click":u,v=r.touchEvent,d=void 0===v?"touchend":v,a=e(null),f=e(null),l=function(n){var e=n.event,t=n.type;f.current=e.target;var r=null==o?void 0:o.props[t];r&&r(e)};return t((function(){var n=function(n){a.current&&a.current.contains(n.target)||f.current===n.target||c(n)};return document.addEventListener(i,n),document.addEventListener(d,n),function(){document.removeEventListener(i,n),document.removeEventListener(d,n)}}),[i,c,d]),n.cloneElement(o,{ref:function(n){a.current=n;var e=o.ref;"function"==typeof e?e(n):e&&(e.current=n)},onClick:function(n){return l({type:"onClick",event:n})},onTouchEnd:function(n){return l({type:"onTouchEnd",event:n})}})} | ||
//# sourceMappingURL=react-click-away-listener.es.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var e=require("react");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=n(e);module.exports=function(n){var r=n.children,u=n.onClickAway,o=n.mouseEvent,c=void 0===o?"click":o,i=n.touchEvent,f=void 0===i?"touchend":i,d=e.useRef(null),v=e.useRef(null),l=function(e){var n=e.event,t=e.type;v.current=n.target;var u=null==r?void 0:r.props[t];u&&u(n)};return e.useEffect((function(){var e=function(e){d.current&&d.current.contains(e.target)||v.current===e.target||u(e)};return document.addEventListener(c,e),document.addEventListener(f,e),function(){document.removeEventListener(c,e),document.removeEventListener(f,e)}}),[c,u,f]),t.default.Children.only(t.default.cloneElement(r,{ref:function(e){d.current=e;var n=r.ref;"function"==typeof n?n(e):n&&(n.current=e)},onClick:function(e){return l({type:"onClick",event:e})},onTouchEnd:function(e){return l({type:"onTouchEnd",event:e})}}))}; | ||
"use strict";var e=require("react");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=n(e);module.exports=function(n){var r=n.children,u=n.onClickAway,o=n.mouseEvent,c=void 0===o?"click":o,i=n.touchEvent,f=void 0===i?"touchend":i,v=e.useRef(null),d=e.useRef(null),a=function(e){var n=e.event,t=e.type;d.current=n.target;var u=null==r?void 0:r.props[t];u&&u(n)};return e.useEffect((function(){var e=function(e){v.current&&v.current.contains(e.target)||d.current===e.target||u(e)};return document.addEventListener(c,e),document.addEventListener(f,e),function(){document.removeEventListener(c,e),document.removeEventListener(f,e)}}),[c,u,f]),t.default.cloneElement(r,{ref:function(e){v.current=e;var n=r.ref;"function"==typeof n?n(e):n&&(n.current=e)},onClick:function(e){return a({type:"onClick",event:e})},onTouchEnd:function(e){return a({type:"onTouchEnd",event:e})}})}; | ||
//# sourceMappingURL=react-click-away-listener.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("react")):"function"==typeof define&&define.amd?define(["react"],n):(e="undefined"!=typeof globalThis?globalThis:e||self)["react-click-away-listener"]=n(e.react)}(this,(function(e){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=n(e);return function(n){var r=n.children,o=n.onClickAway,u=n.mouseEvent,c=void 0===u?"click":u,i=n.touchEvent,f=void 0===i?"touchend":i,d=e.useRef(null),l=e.useRef(null),a=function(e){var n=e.event,t=e.type;l.current=n.target;var o=null==r?void 0:r.props[t];o&&o(n)};return e.useEffect((function(){var e=function(e){d.current&&d.current.contains(e.target)||l.current===e.target||o(e)};return document.addEventListener(c,e),document.addEventListener(f,e),function(){document.removeEventListener(c,e),document.removeEventListener(f,e)}}),[c,o,f]),t.default.Children.only(t.default.cloneElement(r,{ref:function(e){d.current=e;var n=r.ref;"function"==typeof n?n(e):n&&(n.current=e)},onClick:function(e){return a({type:"onClick",event:e})},onTouchEnd:function(e){return a({type:"onTouchEnd",event:e})}}))}})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("react")):"function"==typeof define&&define.amd?define(["react"],n):(e="undefined"!=typeof globalThis?globalThis:e||self)["react-click-away-listener"]=n(e.react)}(this,(function(e){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=n(e);return function(n){var r=n.children,o=n.onClickAway,u=n.mouseEvent,c=void 0===u?"click":u,i=n.touchEvent,f=void 0===i?"touchend":i,d=e.useRef(null),a=e.useRef(null),l=function(e){var n=e.event,t=e.type;a.current=n.target;var o=null==r?void 0:r.props[t];o&&o(n)};return e.useEffect((function(){var e=function(e){d.current&&d.current.contains(e.target)||a.current===e.target||o(e)};return document.addEventListener(c,e),document.addEventListener(f,e),function(){document.removeEventListener(c,e),document.removeEventListener(f,e)}}),[c,o,f]),t.default.cloneElement(r,{ref:function(e){d.current=e;var n=r.ref;"function"==typeof n?n(e):n&&(n.current=e)},onClick:function(e){return l({type:"onClick",event:e})},onTouchEnd:function(e){return l({type:"onTouchEnd",event:e})}})}})); | ||
//# sourceMappingURL=react-click-away-listener.umd.js.map |
{ | ||
"name": "react-click-away-listener", | ||
"version": "2.0.0", | ||
"version": "2.1.0-beta.1", | ||
"description": "A simple click away listener built with React Hooks", | ||
@@ -13,3 +13,3 @@ "main": "dist/react-click-away-listener.js", | ||
"coverage": "jest --coverage", | ||
"prepublish": "npm run build", | ||
"prepare": "npm run build", | ||
"build:rollup": "rollup -c rollup.config.js", | ||
@@ -16,0 +16,0 @@ "build:declaration": "tsc", |
@@ -40,3 +40,3 @@ <p align="center"> | ||
</ClickAwayListener> | ||
<div id="rest-of-the-app">Don't name a div like that :(</div> | ||
<div id="something-else">Hola, mi amigos</div> | ||
</div> | ||
@@ -43,0 +43,0 @@ ); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
20026
4