@dnd-kit/utilities
Advanced tools
Comparing version
# @dnd-kit/utilities | ||
## 3.1.0-next-20220533340 | ||
## 3.1.0-next-20220714748 | ||
@@ -5,0 +5,0 @@ ### Minor Changes |
@@ -5,2 +5,2 @@ import type { Coordinates } from './types'; | ||
*/ | ||
export declare function getEventCoordinates(event: Event): Coordinates; | ||
export declare function getEventCoordinates(event: Event): Coordinates | null; |
@@ -223,6 +223,3 @@ 'use strict'; | ||
return { | ||
x: 0, | ||
y: 0 | ||
}; | ||
return null; | ||
} | ||
@@ -229,0 +226,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");const t="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function n(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function r(e){return"nodeType"in e}function o(e){var t,o;return e?n(e)?e:r(e)&&null!=(t=null==(o=e.ownerDocument)?void 0:o.defaultView)?t:window:window}function u(e){const{Document:t}=o(e);return e instanceof t}function c(e){return!n(e)&&e instanceof o(e).HTMLElement}const s=t?e.useLayoutEffect:e.useEffect;let i={};function l(e){return(t,...n)=>n.reduce((t,n)=>{const r=Object.entries(n);for(const[n,o]of r){const r=t[n];null!=r&&(t[n]=r+e*o)}return t},{...t})}const a=l(1),f=l(-1);function d(e){return"clientX"in e&&"clientY"in e}function p(e){if(!e)return!1;const{TouchEvent:t}=o(e.target);return t&&e instanceof t}const x=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return`translate3d(${t?Math.round(t):0}px, ${n?Math.round(n):0}px, 0)`}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return`scaleX(${t}) scaleY(${n})`}},Transform:{toString(e){if(e)return[x.Translate.toString(e),x.Scale.toString(e)].join(" ")}},Transition:{toString:({property:e,duration:t,easing:n})=>`${e} ${t}ms ${n}`}});exports.CSS=x,exports.add=a,exports.canUseDOM=t,exports.getEventCoordinates=function(e){if(p(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return d(e)?{x:e.clientX,y:e.clientY}:{x:0,y:0}},exports.getOwnerDocument=function(e){return e?n(e)?e.document:r(e)?u(e)?e:c(e)?e.ownerDocument:document:document:document},exports.getWindow=o,exports.hasViewportRelativeCoordinates=d,exports.isDocument=u,exports.isHTMLElement=c,exports.isKeyboardEvent=function(e){if(!e)return!1;const{KeyboardEvent:t}=o(e.target);return t&&e instanceof t},exports.isNode=r,exports.isSVGElement=function(e){return e instanceof o(e).SVGElement},exports.isTouchEvent=p,exports.isWindow=n,exports.subtract=f,exports.useCombinedRefs=function(...t){return e.useMemo(()=>e=>{t.forEach(t=>t(e))},t)},exports.useInterval=function(){const t=e.useRef(null);return[e.useCallback((e,n)=>{t.current=setInterval(e,n)},[]),e.useCallback(()=>{null!==t.current&&(clearInterval(t.current),t.current=null)},[])]},exports.useIsomorphicLayoutEffect=s,exports.useLazyMemo=function(t,n){const r=e.useRef();return e.useMemo(()=>{const e=t(r.current);return r.current=e,e},[...n])},exports.useNodeRef=function(t){const n=e.useRef(null),r=e.useCallback(e=>{n.current=e,null==t||t(e)},[t]);return[n,r]},exports.useUniqueId=function(t,n){return e.useMemo(()=>{if(n)return n;const e=null==i[t]?0:i[t]+1;return i[t]=e,`${t}-${e}`},[t,n])}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");const t="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function n(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function r(e){return"nodeType"in e}function o(e){var t,o;return e?n(e)?e:r(e)&&null!=(t=null==(o=e.ownerDocument)?void 0:o.defaultView)?t:window:window}function u(e){const{Document:t}=o(e);return e instanceof t}function c(e){return!n(e)&&e instanceof o(e).HTMLElement}const s=t?e.useLayoutEffect:e.useEffect;let i={};function l(e){return(t,...n)=>n.reduce((t,n)=>{const r=Object.entries(n);for(const[n,o]of r){const r=t[n];null!=r&&(t[n]=r+e*o)}return t},{...t})}const a=l(1),f=l(-1);function d(e){return"clientX"in e&&"clientY"in e}function p(e){if(!e)return!1;const{TouchEvent:t}=o(e.target);return t&&e instanceof t}const x=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return`translate3d(${t?Math.round(t):0}px, ${n?Math.round(n):0}px, 0)`}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return`scaleX(${t}) scaleY(${n})`}},Transform:{toString(e){if(e)return[x.Translate.toString(e),x.Scale.toString(e)].join(" ")}},Transition:{toString:({property:e,duration:t,easing:n})=>`${e} ${t}ms ${n}`}});exports.CSS=x,exports.add=a,exports.canUseDOM=t,exports.getEventCoordinates=function(e){if(p(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return d(e)?{x:e.clientX,y:e.clientY}:null},exports.getOwnerDocument=function(e){return e?n(e)?e.document:r(e)?u(e)?e:c(e)?e.ownerDocument:document:document:document},exports.getWindow=o,exports.hasViewportRelativeCoordinates=d,exports.isDocument=u,exports.isHTMLElement=c,exports.isKeyboardEvent=function(e){if(!e)return!1;const{KeyboardEvent:t}=o(e.target);return t&&e instanceof t},exports.isNode=r,exports.isSVGElement=function(e){return e instanceof o(e).SVGElement},exports.isTouchEvent=p,exports.isWindow=n,exports.subtract=f,exports.useCombinedRefs=function(...t){return e.useMemo(()=>e=>{t.forEach(t=>t(e))},t)},exports.useInterval=function(){const t=e.useRef(null);return[e.useCallback((e,n)=>{t.current=setInterval(e,n)},[]),e.useCallback(()=>{null!==t.current&&(clearInterval(t.current),t.current=null)},[])]},exports.useIsomorphicLayoutEffect=s,exports.useLazyMemo=function(t,n){const r=e.useRef();return e.useMemo(()=>{const e=t(r.current);return r.current=e,e},[...n])},exports.useNodeRef=function(t){const n=e.useRef(null),r=e.useCallback(e=>{n.current=e,null==t||t(e)},[t]);return[n,r]},exports.useUniqueId=function(t,n){return e.useMemo(()=>{if(n)return n;const e=null==i[t]?0:i[t]+1;return i[t]=e,`${t}-${e}`},[t,n])}; | ||
//# sourceMappingURL=utilities.cjs.production.min.js.map |
@@ -219,6 +219,3 @@ import { useMemo, useLayoutEffect, useEffect, useRef, useCallback } from 'react'; | ||
return { | ||
x: 0, | ||
y: 0 | ||
}; | ||
return null; | ||
} | ||
@@ -225,0 +222,0 @@ |
{ | ||
"name": "@dnd-kit/utilities", | ||
"version": "3.1.0-next-20220533340", | ||
"version": "3.1.0-next-20220714748", | ||
"description": "Internal utilities to bee shared between `@dnd-kit` packages", | ||
@@ -5,0 +5,0 @@ "author": "Claudéric Demers", |
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
72792
-0.3%582
-1.02%