UNPKG

@react-hook/click

Version:

```jsx harmony import useClick from '@react-hook/click'

3 lines (2 loc) 946 B
function t(t){return t.trim()}import{useCallback as r}from"react";import e from"@react-hook/latest";var i={single:"detail=1",double:"detail=2",triple:"detail=3",left:"button=0",middle:"button=1",right:"button=2",shift:"shiftKey",control:"ctrlKey",meta:"metaKey",alt:"altKey"};export default function(n,l){var o=e(n),a=e(l);return r(r=>{if(1==function r(e,n){for(var l,o=0;o<n.length;o++){var a=n[o];if(a.indexOf("|")>-1){var f=a.split("|").map(t),u=1;for(l=0;l<f.length&&!(u=r(e,[f[l]]));l++);if(!u)return 0}else{var c=a.split("+");for(l=0;l<c.length;l++){var d=c[l]in i?i[c[l]]:c[l],[g,p]=d.split("=");if(void 0!==p){if(String(e[g])!==String(p))return 0}else if(0==e[g])return 0}}}return 1}(r,Array.isArray(o.current)?o.current:[o.current])){var{left:e,top:n}=r.target.getBoundingClientRect();a.current(r,{x:r.clientX-Math.floor(e),y:r.clientY-Math.floor(n),count:r.detail})}},[a,o])}export{i as CLICK_TYPES}; //# sourceMappingURL=index.mjs.map