@dnd-kit/utilities
Internal utilities to bee shared between @dnd-kit
packages.
Internal utilities to bee shared between @dnd-kit
packages
#748 59ca82b
Thanks @clauderic! - Introduced the findFirstFocusableNode
utility function that returns the first focusable node within a given HTMLElement, or the element itself if it is focusable.
#733 035021a
Thanks @clauderic! - Introduced the useEvent
hook based on implementation breakdown in the RFC. In the future, this hook will be used as a polyfill if the native React hook is unavailble.
#518 6310227
Thanks @clauderic! - Major internal refactor of measuring and collision detection.
Previously, all collision detection algorithms were relative to the top and left points of the document. While this approach worked in most situations, it broke down in a number of different use-cases, such as fixed position droppable containers and trying to drag between containers that had different scroll positions.
This new approach changes the frame of comparison to be relative to the viewport. This is a major breaking change, and will need to be released under a new major version bump.
@dnd-kit
now ignores only the transforms applied to the draggable / droppable node itself, but considers all the transforms applied to its ancestors. This should provide the right balance of flexibility for most consumers.ViewRect
, LayoutRect
to just a single concept of ClientRect
.ClientRect
interface no longer holds the offsetTop
and offsetLeft
properties. For most use-cases, you can replace offsetTop
with top
and offsetLeft
with left
.@dnd-kit/core
package with getClientRect
:getBoundingClientRect
getViewRect
getLayoutRect
getViewportLayoutRect
translatedRect
from the SensorContext
interface. Replace usage with collisionRect
.activeNodeClientRect
on the DndContext
interface. Replace with activeNodeRect
.528c67e
Thanks @clauderic! - Introduced the useLatestValue
hook, which returns a ref that holds the latest value of a given argument. Optionally, the second argument can be used to customize the dependencies passed to the effect.
02edd26
Thanks @clauderic! - - The useNodeRef
hook's onChange
argument now receives both the current node and the previous node that were attached to the ref.onChange
argument is only called if the previous node differs from the current nodedfa8d69
Thanks @Nauss! - fix: isWindow
has been updated to support checking wether an element is a window object in Electron applications.#509 1c6369e
Thanks @clauderic! - Helpers have been updated to support rendering in foreign window
contexts (via ReactDOM.render
or ReactDOM.createPortal
).
For example, checking if an element is an instance of an HTMLElement
is normally done like so:
if (element instanceof HTMLElement)
However, when rendering in a different window, this can return false even if the element is indeed an HTMLElement, because this code is equivalent to:
if (element instanceof window.HTMLElement)
And in this case, the window
of the element
is different from the main execution context window
, because we are rendering via a portal into another window.
This can be solved by finding the local window of the element:
const elementWindow = element.ownerDocument.defaultView;
if (element instanceof elementWindow.HTMLElement)
1f5ca27
Thanks @clauderic! - Added react to peerDependencies of @dnd-kit/utilities13be602
Thanks @trentmwillis! - Move Coordinates
interface along with getEventCoordinates
, isMouseEvent
and isTouchEvent
helpers to @dnd-kit/utilities0e628bc
Thanks @chestozo! - Added PointerEvent support to the getEventCoordinates
method. This fixes testing the PointerSensor with Cypress (#436)a9d92cf
#174 Thanks @clauderic! - Distributed assets now only target modern browsers. Browserlist config:
defaults
last 2 version
not IE 11
not dead
If you need to support older browsers, include the appropriate polyfills in your project's build process.
6a5c8a1
#154 Thanks @clauderic! - Update implementation of FirstArgument423610c
#56 Thanks @clauderic! - Add MIT license to package.json and distributed files0b343c7
#52 Thanks @clauderic! - Add repository entry to package.json files2912350
Thanks @clauderic! - Initial public release.7bd4568
#30 - Initial beta release, authored by @clauderic.