react-click-away-listener
Advanced tools
Comparing version 1.6.2 to 1.6.3
@@ -1,12 +0,12 @@ | ||
import { ReactElement, FunctionComponent, HTMLAttributes } from 'react'; | ||
import React, { FunctionComponent } from 'react'; | ||
declare type MouseEvents = 'click' | 'mousedown' | 'mouseup'; | ||
declare type TouchEvents = 'touchstart' | 'touchend'; | ||
declare type Events = MouseEvent | TouchEvent; | ||
interface Props extends HTMLAttributes<HTMLElement> { | ||
interface Props extends React.HTMLAttributes<HTMLElement> { | ||
onClickAway: (event: Events) => void; | ||
mouseEvent?: MouseEvents; | ||
touchEvent?: TouchEvents; | ||
children: ReactElement<any>; | ||
as?: React.ElementType; | ||
} | ||
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=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 e,{useRef as t,useEffect as r}from"react";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}export default function(u){var i=u.as,l=void 0===i?"div":i,a=u.onClickAway,f=u.mouseEvent,O=void 0===f?"click":f,b=u.touchEvent,p=void 0===b?"touchend":b,s=c(u,["as","onClickAway","mouseEvent","touchEvent"]),v=t(null),y=t(null),d=function(e){y.current=e.target};return r((function(){var e=function(e){v.current&&v.current.contains(e.target)||y.current===e.target||a(e)};return document.addEventListener(O,e),document.addEventListener(p,e),function(){document.removeEventListener(O,e),document.removeEventListener(p,e)}}),[O,a,p]),e.createElement(l,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({ref:v,onClick:d,onTouchEnd:d},s))} | ||
//# 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,t=require("react"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}module.exports=function(e){var u=e.as,i=void 0===u?"div":u,f=e.onClickAway,l=e.mouseEvent,a=void 0===l?"click":l,s=e.touchEvent,b=void 0===s?"touchend":s,O=c(e,["as","onClickAway","mouseEvent","touchEvent"]),v=t.useRef(null),p=t.useRef(null),d=function(e){p.current=e.target};return t.useEffect((function(){var e=function(e){v.current&&v.current.contains(e.target)||p.current===e.target||f(e)};return document.addEventListener(a,e),document.addEventListener(b,e),function(){document.removeEventListener(a,e),document.removeEventListener(b,e)}}),[a,f,b]),r.createElement(i,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({ref:v,onClick:d,onTouchEnd:d},O))}; | ||
//# 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,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e=e||self)["react-click-away-listener"]=t(e.react)}(this,(function(e){"use strict";var t="default"in e?e.default:e;function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},c=Object.keys(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}return function(c){var u=c.as,i=void 0===u?"div":u,f=c.onClickAway,a=c.mouseEvent,l=void 0===a?"click":a,s=c.touchEvent,d=void 0===s?"touchend":s,p=o(c,["as","onClickAway","mouseEvent","touchEvent"]),b=e.useRef(null),O=e.useRef(null),v=function(e){O.current=e.target};return e.useEffect((function(){var e=function(e){b.current&&b.current.contains(e.target)||O.current===e.target||f(e)};return document.addEventListener(l,e),document.addEventListener(d,e),function(){document.removeEventListener(l,e),document.removeEventListener(d,e)}}),[l,f,d]),t.createElement(i,function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?r(Object(o),!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}({ref:b,onClick:v,onTouchEnd:v},p))}})); | ||
//# sourceMappingURL=react-click-away-listener.umd.js.map |
{ | ||
"name": "react-click-away-listener", | ||
"version": "1.6.2", | ||
"version": "1.6.3", | ||
"description": "A simple click away listener built with React Hooks", | ||
@@ -16,3 +16,2 @@ "main": "dist/react-click-away-listener.js", | ||
"build:declaration": "tsc", | ||
"semantic-release": "semantic-release", | ||
"cleanup": "rimraf dist", | ||
@@ -37,6 +36,3 @@ "build": "npm run cleanup && npm-run-all build:*", | ||
"@rollup/plugin-babel": "^5.2.0", | ||
"@rollup/plugin-node-resolve": "^11.1.0", | ||
"@semantic-release/npm": "^7.0.10", | ||
"@testing-library/react": "^9.3.1", | ||
"@testing-library/react-hooks": "^5.0.3", | ||
"@types/jest": "^24.0.21", | ||
@@ -60,3 +56,3 @@ "@types/react": "^16.9.11", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.38.0", | ||
"rollup": "^1.26.3", | ||
"rollup-plugin-terser": "^7.0.0", | ||
@@ -78,16 +74,3 @@ "typescript": "^3.6.4" | ||
} | ||
}, | ||
"release": { | ||
"branches": [ | ||
"main", | ||
{ | ||
"name": "beta", | ||
"prerelease": true | ||
} | ||
], | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/npm" | ||
] | ||
} | ||
} |
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
26
37
19299