react-click-away-listener
Advanced tools
Comparing version 2.0.0-alpha.6 to 2.0.0
@@ -1,11 +0,12 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import { ReactElement, FunctionComponent, HTMLAttributes } from 'react'; | ||
declare type MouseEvents = 'click' | 'mousedown' | 'mouseup'; | ||
declare type TouchEvents = 'touchstart' | 'touchend'; | ||
declare type Events = MouseEvent | TouchEvent; | ||
interface Props extends React.HTMLAttributes<HTMLElement> { | ||
interface Props extends HTMLAttributes<HTMLElement> { | ||
onClickAway: (event: Events) => void; | ||
mouseEvent?: MouseEvents; | ||
touchEvent?: TouchEvents; | ||
children: ReactElement<any>; | ||
} | ||
declare const ClickAwayListener: FunctionComponent<Props>; | ||
export default ClickAwayListener; |
@@ -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=o,c=null==r?void 0:r.props[t];c&&c(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,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})}}))} | ||
//# 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=r,o=null==u?void 0:u.props[t];o&&o(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,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})}}))}; | ||
//# 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=r,u=null==o?void 0:o.props[t];u&&u(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),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})}}))}})); | ||
//# sourceMappingURL=react-click-away-listener.umd.js.map |
{ | ||
"name": "react-click-away-listener", | ||
"version": "2.0.0-alpha.6", | ||
"version": "2.0.0", | ||
"description": "A simple click away listener built with React Hooks", | ||
@@ -16,2 +16,3 @@ "main": "dist/react-click-away-listener.js", | ||
"build:declaration": "tsc", | ||
"semantic-release": "semantic-release", | ||
"cleanup": "rimraf dist", | ||
@@ -37,2 +38,3 @@ "build": "npm run cleanup && npm-run-all build:*", | ||
"@rollup/plugin-node-resolve": "^11.1.0", | ||
"@semantic-release/npm": "^7.0.10", | ||
"@testing-library/react": "^9.3.1", | ||
@@ -55,4 +57,4 @@ "@testing-library/react-hooks": "^5.0.3", | ||
"prettier": "^2.0.5", | ||
"react": "16.13.1", | ||
"react-dom": "16.13.1", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1", | ||
"rimraf": "^3.0.2", | ||
@@ -76,3 +78,17 @@ "rollup": "^2.38.0", | ||
} | ||
}, | ||
"release": { | ||
"branches": [ | ||
"main", | ||
{ | ||
"name": "beta", | ||
"prerelease": true | ||
} | ||
], | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/npm" | ||
] | ||
} | ||
} |
@@ -7,3 +7,3 @@ <p align="center"> | ||
<a href="https://coveralls.io/github/ooade/react-click-away-listener?branch=master"><img src="https://coveralls.io/repos/github/ooade/react-click-away-listener/badge.svg?branch=master" alt="Coverage Status" /></a> | ||
<a href="https://github.com/ooade/react-click-away-listener/blob/main/.github/workflows/build-test-code.yml"><img src="https://github.com/ooade/react-click-away-listener/workflows/CI%20Tests/badge.svg" alt="CI Tests"/></a> | ||
<a href="https://github.com/ooade/react-click-away-listener/blob/main/.github/workflows/build-test-code.yml"><img src="https://github.com/ooade/react-click-away-listener/workflows/Test/badge.svg" alt="Test"/></a> | ||
<a href="https://www.npmjs.org/package/react-click-away-listener"><img src="https://img.shields.io/npm/dm/react-click-away-listener.svg?style=flat-square" alt="downloads/month"></a> | ||
@@ -10,0 +10,0 @@ <a href="http://makeapullrequest.com"><img src="https://img.shields.io/badge/PR(s)-welcome-brightgreen.svg?style=flat-square" alt="pullrequest"></a> |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
20422
28
3
29