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

@kylebrodeur/d3-hierarchical-grid

v0.1.0

Published

A D3-based hierarchical grid visualization component for React

Readme

@kylebrodeur/d3-hierarchical-grid

A React + D3 component library for rendering zoomable, pannable hierarchical item grids organized by sections and groups.

Description

@kylebrodeur/d3-hierarchical-grid provides a high-performance SVG grid visualization built with D3.js and React. Items are organized into named groups and sections, with smooth zoom/pan, progressive detail rendering at different zoom levels, and programmatic control via an exposed GridControls interface.

Features

  • D3-powered rendering — SVG sections, groups, and items rendered via D3 data joins
  • React 18+ compatible — Functional component with hooks
  • Hierarchical layout — Auto-organizes items into sections → groups → items
  • Zoom & pan — Mouse wheel zoom, drag-to-pan, and programmatic zoomIn/zoomOut/resetZoom/panBy
  • Progressive detail — Renders item images/text conditionally based on zoom level
  • TypeScript first — Full strict-mode types and exported declarations
  • Responsive — Auto fits content on mount and container resize
  • SSR safe — Guards against server-side rendering issues

Installation

pnpm add @kylebrodeur/d3-hierarchical-grid
# or
npm install @kylebrodeur/d3-hierarchical-grid

Peer Dependencies:

  • react >= 18.0.0
  • react-dom >= 18.0.0
  • d3 >= 7.0.0

Basic Usage

import { HierarchicalGrid } from '@kylebrodeur/d3-hierarchical-grid';
import type { HierarchyItem, GridControls } from '@kylebrodeur/d3-hierarchical-grid';

const items: HierarchyItem[] = [
  { id: '1', name: 'Item A', group: 'Group 1', section: 'Section A' },
  { id: '2', name: 'Item B', group: 'Group 1', section: 'Section A' },
  { id: '3', name: 'Item C', group: 'Group 2', section: 'Section B' },
];

function App() {
  const [controls, setControls] = useState<GridControls | null>(null);

  return (
    <div style={{ width: '100%', height: '600px' }}>
      <HierarchicalGrid
        items={items}
        onControlsReady={setControls}
        onItemClick={(item) => console.log('Clicked:', item.name)}
      />
      {controls && (
        <div>
          <button onClick={controls.zoomIn}>+</button>
          <button onClick={controls.zoomOut}>-</button>
          <button onClick={controls.resetZoom}>Reset</button>
        </div>
      )}
    </div>
  );
}

API Overview

<HierarchicalGrid />

Main visualization component.

| Prop | Type | Description | |------|------|-------------| | items | HierarchyItem[] | Data items to render | | config? | GridConfig | Section/group configuration | | theme? | Partial<GridTheme> | Visual theme overrides | | selectedItem? | HierarchyItem | Currently selected item (highlighted) | | onItemClick? | (item: HierarchyItem, pos: ClickPosition) => void | Item click handler | | onItemHover? | (item: HierarchyItem \| null) => void | Item hover handler | | onBackgroundClick? | (pos: LayoutPosition) => void | Background click handler | | onTransformChange? | (transform: ZoomTransform) => void | Zoom/pan change handler | | onControlsReady? | (controls: GridControls) => void | Exposes zoom/pan control methods | | onInitialFitComplete? | () => void | Fires after initial fit-to-view | | className? | string | Additional CSS class |

useZoom(options)

Custom hook for D3 zoom behavior. Returns { zoomIn, zoomOut, resetZoom, setTransform, panBy, currentTransform, zoomBehavior }.

computeLayout(items, config?, theme?)

Pure function. Computes the full grid layout from HierarchyItem[], returning a LayoutResult with positioned sections, groups, items, and bounds.

Key Types

interface HierarchyItem {
  id: string;
  name: string;
  group: string;
  section?: string;
  description?: string;
  imageUrl?: string;
  url?: string;
  metadata?: Record<string, unknown>;
  position?: { x: number | null; y: number | null };
}

interface GridControls {
  zoomIn: () => void;
  zoomOut: () => void;
  resetZoom: () => void;
  fitToView: (options?: FitToViewOptions) => void;
  panBy: (dx: number, dy: number, duration?: number) => void;
  setTransform: (transform: ZoomTransform, animate?: boolean) => void;
  getCurrentTransform: () => ZoomTransform | null;
  clearHighlight: () => void;
}

Development

See AGENTS.md for detailed development guidelines and agent integration notes.

pnpm install       # Install dependencies
pnpm build         # Build to dist/
pnpm test          # Run tests
pnpm typecheck     # Type check
pnpm lint          # Lint

License

MIT © Kyle Brodeur