react-click-away-listener
Advanced tools
Comparing version 2.0.0 to 2.0.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 c=r.children,o=r.onClickAway,u=r.mouseEvent,i=void 0===u?"click":u,v=r.touchEvent,a=void 0===v?"touchend":v,d=e(null),l=e(null),f=function(n){var e=n.event,t=n.type;l.current=e.target;var r=null==c?void 0:c.props[t];r&&r(e)};return t((function(){var n=function(n){d.current&&d.current.contains(n.target)||l.current===n.target||o(n)};return document.addEventListener(i,n,{capture:!0}),document.addEventListener(a,n,{capture:!0}),function(){document.removeEventListener(i,n,{capture:!0}),document.removeEventListener(a,n,{capture:!0})}}),[i,o,a]),n.Children.only(n.cloneElement(c,{ref:function(n){d.current=n;var e=c.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})}}))} | ||
//# 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,c=n.mouseEvent,o=void 0===c?"click":c,i=n.touchEvent,a=void 0===i?"touchend":i,f=e.useRef(null),d=e.useRef(null),v=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){f.current&&f.current.contains(e.target)||d.current===e.target||u(e)};return document.addEventListener(o,e,{capture:!0}),document.addEventListener(a,e,{capture:!0}),function(){document.removeEventListener(o,e,{capture:!0}),document.removeEventListener(a,e,{capture:!0})}}),[o,u,a]),t.default.Children.only(t.default.cloneElement(r,{ref:function(e){f.current=e;var n=r.ref;"function"==typeof n?n(e):n&&(n.current=e)},onClick:function(e){return v({type:"onClick",event:e})},onTouchEnd:function(e){return v({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,u=n.onClickAway,o=n.mouseEvent,c=void 0===o?"click":o,i=n.touchEvent,f=void 0===i?"touchend":i,a=e.useRef(null),d=e.useRef(null),l=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){a.current&&a.current.contains(e.target)||d.current===e.target||u(e)};return document.addEventListener(c,e,{capture:!0}),document.addEventListener(f,e,{capture:!0}),function(){document.removeEventListener(c,e,{capture:!0}),document.removeEventListener(f,e,{capture:!0})}}),[c,u,f]),t.default.Children.only(t.default.cloneElement(r,{ref:function(e){a.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.0.1", | ||
"description": "A simple click away listener built with React Hooks", | ||
@@ -37,3 +37,3 @@ "main": "dist/react-click-away-listener.js", | ||
"@rollup/plugin-node-resolve": "^11.1.0", | ||
"@semantic-release/npm": "^7.0.10", | ||
"@semantic-release/npm": "^7.1.0", | ||
"@testing-library/react": "^9.3.1", | ||
@@ -45,2 +45,3 @@ "@testing-library/react-hooks": "^5.0.3", | ||
"coveralls": "^3.1.0", | ||
"cz-conventional-changelog": "3.3.0", | ||
"eslint": "^5.13.0", | ||
@@ -57,12 +58,12 @@ "eslint-config-prettier": "^6.11.0", | ||
"prettier": "^2.0.5", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.38.0", | ||
"rollup-plugin-terser": "^7.0.0", | ||
"typescript": "^3.6.4" | ||
"typescript": "^4.2.3" | ||
}, | ||
"peerDependencies": { | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1" | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2" | ||
}, | ||
@@ -76,3 +77,7 @@ "jest": { | ||
"ghooks": { | ||
"prepare-commit-msg": "exec < /dev/tty && git cz --hook || true", | ||
"pre-commit": "npm run prettier" | ||
}, | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
@@ -79,0 +84,0 @@ }, |
@@ -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> | ||
@@ -47,2 +47,6 @@ ); | ||
Caveats: | ||
- Ensure the ClickAway component has just one child else `React.only` will throw an error. | ||
- It doesn't work with Text nodes. | ||
## Props | ||
@@ -49,0 +53,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
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
21345
66
30