Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-click-away-listener

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-click-away-listener - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

2

dist/react-click-away-listener.es.js

@@ -1,2 +0,2 @@

import e from"prop-types";import n,{useEffect as r}from"react";var t=function(e){var t=e.children,o=e.onClickAway,c=n.createRef(null);return r(function(){var e=document.addEventListener("mousedown",function(e){c&&c.current&&!c.current.contains(e.target)&&o()});return function(){document.removeEventListener("mousedown",e)}}),n.createElement("div",{ref:c},t)};t.defaultProps={children:null,onClickAway:function(){}},t.propTypes={children:e.oneOfType([e.arrayOf(e.node),e.node]),onClickAway:e.func};export default t;
import r from"prop-types";import e,{useRef as n,useEffect as t}from"react";function o(){return(o=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r}).apply(this,arguments)}var a=function(r){var o=r.children,a=r.onClickAway,c=r.forwardedRef,f=n(null);return c||(c=f),t(function(){var r=document.addEventListener("mousedown",function(r){var e=c&&c.current,n=f&&f.current;e&&!c.current.contains(r.target)&&n&&!f.current.contains(r.target)&&a()});return function(){document.removeEventListener("mousedown",r)}}),e.createElement("div",{ref:f},o)};a.defaultProps={children:null,forwardRef:null,onClickAway:function(){}},a.propTypes={children:r.oneOfType([r.arrayOf(r.node),r.node]),forwardedRef:r.any,onClickAway:r.func};export default e.forwardRef(function(r,n){return e.createElement(a,o({},r,{forwardedRef:n}))});
//# sourceMappingURL=react-click-away-listener.es.js.map

@@ -1,2 +0,2 @@

"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var Proptypes=_interopDefault(require("prop-types")),React=require("react"),React__default=_interopDefault(React),ClickAwayListener=function(e){var t=e.children,n=e.onClickAway,r=React__default.createRef(null);return React.useEffect(function(){var e=document.addEventListener("mousedown",function(e){r&&r.current&&!r.current.contains(e.target)&&n()});return function(){document.removeEventListener("mousedown",e)}}),React__default.createElement("div",{ref:r},t)};ClickAwayListener.defaultProps={children:null,onClickAway:function(){}},ClickAwayListener.propTypes={children:Proptypes.oneOfType([Proptypes.arrayOf(Proptypes.node),Proptypes.node]),onClickAway:Proptypes.func},module.exports=ClickAwayListener;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var Proptypes=_interopDefault(require("prop-types")),React=require("react"),React__default=_interopDefault(React);function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var ClickAway=function(e){var t=e.children,r=e.onClickAway,n=e.forwardedRef,a=React.useRef(null);return n||(n=a),React.useEffect(function(){var e=document.addEventListener("mousedown",function(e){var t=n&&n.current,o=a&&a.current;t&&!n.current.contains(e.target)&&o&&!a.current.contains(e.target)&&r()});return function(){document.removeEventListener("mousedown",e)}}),React__default.createElement("div",{ref:a},t)};ClickAway.defaultProps={children:null,forwardRef:null,onClickAway:function(){}},ClickAway.propTypes={children:Proptypes.oneOfType([Proptypes.arrayOf(Proptypes.node),Proptypes.node]),forwardedRef:Proptypes.any,onClickAway:Proptypes.func};var ClickAwayListener=React__default.forwardRef(function(e,t){return React__default.createElement(ClickAway,_extends({},e,{forwardedRef:t}))});module.exports=ClickAwayListener;
//# sourceMappingURL=react-click-away-listener.js.map

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("prop-types"),require("react")):"function"==typeof define&&define.amd?define(["prop-types","react"],n):(e=e||self)["react-click-away-listener"]=n(e["prop-types"],e.react)}(this,function(e,n){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var t="default"in n?n.default:n,r=function(e){var r=e.children,o=e.onClickAway,u=t.createRef(null);return n.useEffect(function(){var e=document.addEventListener("mousedown",function(e){u&&u.current&&!u.current.contains(e.target)&&o()});return function(){document.removeEventListener("mousedown",e)}}),t.createElement("div",{ref:u},r)};return r.defaultProps={children:null,onClickAway:function(){}},r.propTypes={children:e.oneOfType([e.arrayOf(e.node),e.node]),onClickAway:e.func},r});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("prop-types"),require("react")):"function"==typeof define&&define.amd?define(["prop-types","react"],r):(e=e||self)["react-click-away-listener"]=r(e["prop-types"],e.react)}(this,function(e,r){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var n="default"in r?r.default:r;function t(){return(t=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}var o=function(e){var t=e.children,o=e.onClickAway,a=e.forwardedRef,f=r.useRef(null);return a||(a=f),r.useEffect(function(){var e=document.addEventListener("mousedown",function(e){var r=a&&a.current,n=f&&f.current;r&&!a.current.contains(e.target)&&n&&!f.current.contains(e.target)&&o()});return function(){document.removeEventListener("mousedown",e)}}),n.createElement("div",{ref:f},t)};return o.defaultProps={children:null,forwardRef:null,onClickAway:function(){}},o.propTypes={children:e.oneOfType([e.arrayOf(e.node),e.node]),forwardedRef:e.any,onClickAway:e.func},n.forwardRef(function(e,r){return n.createElement(o,t({},e,{forwardedRef:r}))})});
//# sourceMappingURL=react-click-away-listener.umd.js.map
{
"name": "react-click-away-listener",
"version": "0.1.1",
"version": "0.2.0",
"description": "A simple click away listener built with React Hooks",

@@ -5,0 +5,0 @@ "main": "dist/react-click-away-listener.js",

@@ -17,3 +17,3 @@ <p align="center">

```sh
yarn add react-click-event-listener
yarn add react-click-away-listener
```

@@ -20,0 +20,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc