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

@agallaoui/dnd-core

v1.0.0

Published

Framework-agnostic drag-and-drop core engine with pointer events

Readme

@agallaoui/dnd-core

A lightweight, framework-agnostic drag-and-drop engine built on Pointer Events.

Installation

npm install @agallaoui/dnd-core

Features

  • Framework Agnostic - Works with vanilla JS, React, Angular, or any framework
  • Pointer Events - Modern unified API for mouse, touch, and stylus
  • Type Safe - Full TypeScript support
  • Tree-shakable - Import only what you need
  • Zero Dependencies - No external runtime dependencies
  • Extensible - Built to be extended (see @agallaoui/board-dnd)

Import Paths

| Path | Description | |---|---| | @agallaoui/dnd-core | Core engine (framework-agnostic) | | @agallaoui/dnd-core/react | React hooks & provider | | @agallaoui/dnd-core/angular | Angular service base class |

Usage

Vanilla JavaScript

import { createDndEngine } from '@agallaoui/dnd-core';

const engine = createDndEngine({
  dragThreshold: 5,
  callbacks: {
    onDragStart: ({ item, position }) => {
      console.log(`Started dragging ${item.id}`);
    },
    onDragOver: ({ item, dropZone }) => {
      console.log(`${item.id} over ${dropZone.id}`);
    },
    onDrop: ({ item, dropZone }) => {
      // Handle your state update
    },
    onDragEnd: ({ item, dropped }) => {
      console.log(`Drag ended, dropped: ${dropped}`);
    }
  }
});

// Register a draggable element
const dragHandle = engine.registerDraggable(element, {
  id: 'card-1',
  type: 'card',
  payload: { title: 'My Task' }
});

// Register a drop zone
const dropHandle = engine.registerDroppable(element, {
  id: 'column-1',
  accepts: ['card'],
  payload: { name: 'Todo' }
});

// Subscribe to state changes
const unsubscribe = engine.subscribe((state) => {
  // state.phase: 'idle' | 'dragging' | 'dropping'
});

// Cleanup
dragHandle.destroy();
dropHandle.destroy();
engine.destroy();

React

import {
  DndProvider,
  useDraggable,
  useDroppable,
  useDndState
} from '@agallaoui/dnd-core/react';

function DraggableCard({ id, data }) {
  const { ref, isDragging } = useDraggable({
    id,
    type: 'card',
    payload: data,
  });

  return (
    <div ref={ref} style={{ opacity: isDragging ? 0.5 : 1 }}>
      {data.title}
    </div>
  );
}

function DropZone({ id, children }) {
  const { ref, isOver } = useDroppable({
    id,
    accepts: ['card'],
  });

  return (
    <div ref={ref} className={isOver ? 'highlight' : ''}>
      {children}
    </div>
  );
}

function App() {
  return (
    <DndProvider onDrop={handleDrop}>
      <DropZone id="zone-1">
        <DraggableCard id="card-1" data={{ title: 'Task' }} />
      </DropZone>
    </DndProvider>
  );
}

Angular

import { Injectable, OnDestroy } from '@angular/core';
import { DndServiceBase } from '@agallaoui/dnd-core/angular';

@Injectable({ providedIn: 'root' })
export class DndService extends DndServiceBase implements OnDestroy {
  constructor() {
    super({
      callbacks: {
        onDrop: (event) => this.handleDrop(event)
      }
    });
  }

  ngOnDestroy() {
    this.destroy();
  }
}

API Reference

createDndEngine(config?)

| Option | Type | Default | Description | |---|---|---|---| | dragThreshold | number | 5 | Pixels before drag starts | | capturePointer | boolean | true | Capture pointer events during drag | | draggingBodyClass | string | 'dnd-dragging' | CSS class on body during drag | | callbacks | DndCallbacks | {} | Lifecycle callbacks |

Engine Methods

| Method | Description | |---|---| | registerDraggable(el, options) | Register draggable element | | registerDroppable(el, options) | Register drop zone | | getState() | Get current DnD state | | subscribe(callback) | Subscribe to state changes | | cancel() | Cancel current drag | | destroy() | Clean up all resources |

Callbacks

interface DndCallbacks {
  onDragStart?: (event: DragStartEvent) => void;
  onDragOver?: (event: DragOverEvent) => void;
  onDragLeave?: (dropZone: DropZoneData) => void;
  onDrop?: (event: DropEvent) => void;
  onDragEnd?: (event: DragEndEvent) => void;
}

Bundle Size

| Import | Size (minified + gzip) | |---|---| | Core only | ~2.5kb | | + React adapter | ~3.5kb | | + Angular adapter | ~3.2kb |

License

MIT