@dnd-kit/utilities
Advanced tools
Comparing version 3.2.0 to 3.2.1-next-2022102925547
# @dnd-kit/utilities | ||
## 3.2.1-next-2022102925547 | ||
### Patch Changes | ||
- [#948](https://github.com/clauderic/dnd-kit/pull/948) [`da7c60d`](https://github.com/clauderic/dnd-kit/commit/da7c60dcbb76d89cf1fcb421e69a4abcea2eeebe) Thanks [@Ayc0](https://github.com/Ayc0)! - Upgrade to TypeScript to 4.8 | ||
## 3.2.0 | ||
@@ -4,0 +10,0 @@ |
@@ -1,2 +0,2 @@ | ||
/// <reference types="react" /> | ||
export declare function useLatestValue<T extends any>(value: T, dependencies?: T[]): import("react").MutableRefObject<T>; | ||
import type { DependencyList } from 'react'; | ||
export declare function useLatestValue<T extends any>(value: T, dependencies?: DependencyList): import("react").MutableRefObject<T>; |
@@ -7,3 +7,7 @@ 'use strict'; | ||
function useCombinedRefs(...refs) { | ||
function useCombinedRefs() { | ||
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) { | ||
refs[_key] = arguments[_key]; | ||
} | ||
return react.useMemo(() => node => { | ||
@@ -101,3 +105,7 @@ refs.forEach(ref => ref(node)); | ||
}); | ||
return react.useCallback(function (...args) { | ||
return react.useCallback(function () { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return handlerRef.current == null ? void 0 : handlerRef.current(...args); | ||
@@ -121,3 +129,7 @@ }, []); | ||
function useLatestValue(value, dependencies = [value]) { | ||
function useLatestValue(value, dependencies) { | ||
if (dependencies === void 0) { | ||
dependencies = [value]; | ||
} | ||
const valueRef = react.useRef(value); | ||
@@ -173,3 +185,3 @@ useIsomorphicLayoutEffect(() => { | ||
ids[prefix] = id; | ||
return `${prefix}-${id}`; | ||
return prefix + "-" + id; | ||
}, [prefix, value]); | ||
@@ -179,3 +191,7 @@ } | ||
function createAdjustmentFn(modifier) { | ||
return (object, ...adjustments) => { | ||
return function (object) { | ||
for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
adjustments[_key - 1] = arguments[_key]; | ||
} | ||
return adjustments.reduce((accumulator, adjustment) => { | ||
@@ -275,3 +291,3 @@ const entries = Object.entries(adjustment); | ||
} = transform; | ||
return `translate3d(${x ? Math.round(x) : 0}px, ${y ? Math.round(y) : 0}px, 0)`; | ||
return "translate3d(" + (x ? Math.round(x) : 0) + "px, " + (y ? Math.round(y) : 0) + "px, 0)"; | ||
} | ||
@@ -290,3 +306,3 @@ | ||
} = transform; | ||
return `scaleX(${scaleX}) scaleY(${scaleY})`; | ||
return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")"; | ||
} | ||
@@ -306,8 +322,9 @@ | ||
Transition: { | ||
toString({ | ||
property, | ||
duration, | ||
easing | ||
}) { | ||
return `${property} ${duration}ms ${easing}`; | ||
toString(_ref) { | ||
let { | ||
property, | ||
duration, | ||
easing | ||
} = _ref; | ||
return property + " " + duration + "ms " + easing; | ||
} | ||
@@ -314,0 +331,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;function i(t){const n=e.useRef(t);return s(()=>{n.current=t}),e.useCallback((function(...e){return null==n.current?void 0:n.current(...e)}),[])}let a={};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 f=l(1),d=l(-1);function p(e){return"clientX"in e&&"clientY"in e}function x(e){if(!e)return!1;const{TouchEvent:t}=o(e.target);return t&&e instanceof t}const m=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[m.Translate.toString(e),m.Scale.toString(e)].join(" ")}},Transition:{toString:({property:e,duration:t,easing:n})=>`${e} ${t}ms ${n}`}}),b="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";exports.CSS=m,exports.add=f,exports.canUseDOM=t,exports.findFirstFocusableNode=function(e){return e.matches(b)?e:e.querySelector(b)},exports.getEventCoordinates=function(e){if(x(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 p(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=p,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=x,exports.isWindow=n,exports.subtract=d,exports.useCombinedRefs=function(...t){return e.useMemo(()=>e=>{t.forEach(t=>t(e))},t)},exports.useEvent=i,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.useLatestValue=function(t,n=[t]){const r=e.useRef(t);return s(()=>{r.current!==t&&(r.current=t)},n),r},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=i(t),r=e.useRef(null),o=e.useCallback(e=>{e!==r.current&&(null==n||n(e,r.current)),r.current=e},[]);return[r,o]},exports.usePrevious=function(t){const n=e.useRef();return e.useEffect(()=>{n.current=t},[t]),n.current},exports.useUniqueId=function(t,n){return e.useMemo(()=>{if(n)return n;const e=null==a[t]?0:a[t]+1;return a[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;function i(t){const n=e.useRef(t);return s(()=>{n.current=t}),e.useCallback((function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return null==n.current?void 0:n.current(...t)}),[])}let a={};function l(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.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 f=l(1),d=l(-1);function p(e){return"clientX"in e&&"clientY"in e}function x(e){if(!e)return!1;const{TouchEvent:t}=o(e.target);return t&&e instanceof t}const m=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[m.Translate.toString(e),m.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),h="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";exports.CSS=m,exports.add=f,exports.canUseDOM=t,exports.findFirstFocusableNode=function(e){return e.matches(h)?e:e.querySelector(h)},exports.getEventCoordinates=function(e){if(x(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 p(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=p,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=x,exports.isWindow=n,exports.subtract=d,exports.useCombinedRefs=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.useMemo(()=>e=>{n.forEach(t=>t(e))},n)},exports.useEvent=i,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.useLatestValue=function(t,n){void 0===n&&(n=[t]);const r=e.useRef(t);return s(()=>{r.current!==t&&(r.current=t)},n),r},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=i(t),r=e.useRef(null),o=e.useCallback(e=>{e!==r.current&&(null==n||n(e,r.current)),r.current=e},[]);return[r,o]},exports.usePrevious=function(t){const n=e.useRef();return e.useEffect(()=>{n.current=t},[t]),n.current},exports.useUniqueId=function(t,n){return e.useMemo(()=>{if(n)return n;const e=null==a[t]?0:a[t]+1;return a[t]=e,t+"-"+e},[t,n])}; | ||
//# sourceMappingURL=utilities.cjs.production.min.js.map |
import { useMemo, useLayoutEffect, useEffect, useRef, useCallback } from 'react'; | ||
function useCombinedRefs(...refs) { | ||
function useCombinedRefs() { | ||
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) { | ||
refs[_key] = arguments[_key]; | ||
} | ||
return useMemo(() => node => { | ||
@@ -96,3 +100,7 @@ refs.forEach(ref => ref(node)); | ||
}); | ||
return useCallback(function (...args) { | ||
return useCallback(function () { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return handlerRef.current == null ? void 0 : handlerRef.current(...args); | ||
@@ -116,3 +124,7 @@ }, []); | ||
function useLatestValue(value, dependencies = [value]) { | ||
function useLatestValue(value, dependencies) { | ||
if (dependencies === void 0) { | ||
dependencies = [value]; | ||
} | ||
const valueRef = useRef(value); | ||
@@ -168,3 +180,3 @@ useIsomorphicLayoutEffect(() => { | ||
ids[prefix] = id; | ||
return `${prefix}-${id}`; | ||
return prefix + "-" + id; | ||
}, [prefix, value]); | ||
@@ -174,3 +186,7 @@ } | ||
function createAdjustmentFn(modifier) { | ||
return (object, ...adjustments) => { | ||
return function (object) { | ||
for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
adjustments[_key - 1] = arguments[_key]; | ||
} | ||
return adjustments.reduce((accumulator, adjustment) => { | ||
@@ -270,3 +286,3 @@ const entries = Object.entries(adjustment); | ||
} = transform; | ||
return `translate3d(${x ? Math.round(x) : 0}px, ${y ? Math.round(y) : 0}px, 0)`; | ||
return "translate3d(" + (x ? Math.round(x) : 0) + "px, " + (y ? Math.round(y) : 0) + "px, 0)"; | ||
} | ||
@@ -285,3 +301,3 @@ | ||
} = transform; | ||
return `scaleX(${scaleX}) scaleY(${scaleY})`; | ||
return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")"; | ||
} | ||
@@ -301,8 +317,9 @@ | ||
Transition: { | ||
toString({ | ||
property, | ||
duration, | ||
easing | ||
}) { | ||
return `${property} ${duration}ms ${easing}`; | ||
toString(_ref) { | ||
let { | ||
property, | ||
duration, | ||
easing | ||
} = _ref; | ||
return property + " " + duration + "ms " + easing; | ||
} | ||
@@ -309,0 +326,0 @@ |
{ | ||
"name": "@dnd-kit/utilities", | ||
"version": "3.2.0", | ||
"version": "3.2.1-next-2022102925547", | ||
"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
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
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
87877
701
3