npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@illusionalsagacity/rescript-dnd-kit

v0.2.0

Published

ReScript bindings for [@dnd-kit/react](https://dndkit.com/) v0.2.x.

Downloads

206

Readme

rescript-dnd-kit

ReScript bindings for @dnd-kit/react v0.2.x.

Installation

npm install @illusionalsagacity/rescript-dnd-kit @dnd-kit/react @dnd-kit/helpers

Add to your rescript.json:

{
  "dependencies": ["@illusionalsagacity/rescript-dnd-kit", "@rescript/react"]
}

Usage

All bindings are in the top-level DndKit module.

Sortable List

module SortableItem = {
  @react.component
  let make = (~id: string, ~index: int) => {
    let {ref, isDragSource} = DndKit.useSortable({
      id: String(id),
      index,
    })

    <div
      ref={ReactDOM.Ref.callbackDomRef(el => {ref(el); None})}
      style={{opacity: isDragSource ? "0.3" : "1"}}>
      {React.string(id)}
    </div>
  }
}

@react.component
let make = () => {
  let (items, setItems) = React.useState(() => ["Apple", "Banana", "Cherry"])

  let onDragOver = (event, _manager) => {
    setItems(prev => DndKit.move(prev, event))
  }

  <DndKit.DragDropProvider
    sensors={[DndKit.pointerSensor, DndKit.keyboardSensor]}
    onDragOver>
    {items
    ->Array.mapWithIndex((item, index) =>
      <SortableItem key={item} id={item} index />
    )
    ->React.array}
  </DndKit.DragDropProvider>
}

Draggable + Droppable

module DraggableCard = {
  @react.component
  let make = (~id: string) => {
    let {ref, isDragSource} = DndKit.useDraggable({id: String(id)})

    <div
      ref={ReactDOM.Ref.callbackDomRef(el => {ref(el); None})}
      style={{opacity: isDragSource ? "0.3" : "1", cursor: "grab"}}>
      {React.string(id)}
    </div>
  }
}

module DropZone = {
  @react.component
  let make = (~id: string, ~children: React.element) => {
    let {ref, isDropTarget} = DndKit.useDroppable({id: String(id)})

    <div
      ref={ReactDOM.Ref.callbackDomRef(el => {ref(el); None})}
      style={{background: isDropTarget ? "#e8f5e9" : "#f5f5f5"}}>
      children
    </div>
  }
}

Event Handling

Events carry an operation with source/target accessible via getters:

let onDragEnd = (event: DndKit.dragEndEvent, _manager) => {
  if !event.canceled {
    let sourceId =
      event.operation
      ->DndKit.operationSource
      ->Nullable.toOption
      ->Option.map(DndKit.draggableId)

    let targetId =
      event.operation
      ->DndKit.operationTarget
      ->Nullable.toOption
      ->Option.map(DndKit.droppableId)

    switch (sourceId, targetId) {
    | (Some(String(from)), Some(String(to_))) => handleDrop(from, to_)
    | _ => ()
    }
  }
}

DragOverlay

Render a preview of the dragged item:

<DndKit.DragOverlay>
  {switch activeItem {
  | Some(item) => <ItemPreview item />
  | None => React.null
  }}
</DndKit.DragOverlay>

Monitoring Events

DndKit.useDragDropMonitor({
  onDragStart: ?Some((event, _manager) => Console.log("started")),
  onDragEnd: ?Some((event, _manager) => Console.log("ended")),
})

Current Drag State

let {source, target} = DndKit.useDragOperation()
let isDragging = source->Nullable.toOption->Option.isSome

Available Bindings

Sensors

| Binding | Source | |---|---| | DndKit.pointerSensor | @dnd-kit/react | | DndKit.keyboardSensor | @dnd-kit/react |

Collision Detectors

| Binding | Source | |---|---| | DndKit.defaultCollisionDetection | @dnd-kit/collision | | DndKit.closestCenter | @dnd-kit/collision | | DndKit.closestCorners | @dnd-kit/collision | | DndKit.pointerIntersection | @dnd-kit/collision | | DndKit.shapeIntersection | @dnd-kit/collision | | DndKit.directionBiased | @dnd-kit/collision | | DndKit.pointerDistance | @dnd-kit/collision |

Modifiers

| Binding | Source | |---|---| | DndKit.restrictToVerticalAxis | @dnd-kit/abstract/modifiers | | DndKit.restrictToHorizontalAxis | @dnd-kit/abstract/modifiers | | DndKit.restrictToWindow | @dnd-kit/dom/modifiers | | DndKit.restrictToElement | @dnd-kit/dom/modifiers |

Helpers

| Binding | Source | |---|---| | DndKit.move | @dnd-kit/helpers | | DndKit.swap | @dnd-kit/helpers | | DndKit.arrayMove | @dnd-kit/helpers | | DndKit.arraySwap | @dnd-kit/helpers |

Examples

See the example/ directory for working demos:

  • SortableDemo — Vertical list reordering with useSortable, DndKit.move, modifiers, DragOverlay, and event monitoring
  • KanbanDemo — Multi-column board with useDraggable/useDroppable for moving cards between columns

Run the examples:

cd example
yarn install
yarn run res:build
yarn run dev