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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@thorobid-ai/react-pivotgrid

v0.1.1

Published

A dynamic pivot grid component for React built on TanStack Table

Readme

@thorobid-ai/react-pivotgrid

npm version License: MIT TypeScript

A dynamic pivot grid component for React built on TanStack Table with drag-and-drop functionality. Transform your flat data into interactive pivot tables with real-time field manipulation and aggregation.

Features

  • TypeScript Support - Complete type safety with TypeScript definitions
  • Drag & Drop Interface - Interactive field management with @dnd-kit
  • Multiple Aggregations - Support for various aggregation functions
  • Field Filtering - Built-in filtering capabilities
  • Debounced Updates - Optimized performance with debounced calculations
  • Customizable Styling - Built with Tailwind CSS for easy customization

📦 Installation

npm install @thorobid-ai/react-pivotgrid

Quick Start

Basic Usage

import React from 'react';
import { ReactPivotGrid } from '@thorobid-ai/react-pivotgrid';
import '@thorobid-ai/react-pivotgrid/dist/style.css';

const sampleData = [
  { region: 'North', product: 'Laptop', category: 'Electronics', sales: 1000, quantity: 10 },
  { region: 'South', product: 'Mouse', category: 'Electronics', sales: 200, quantity: 20 },
  // ... more data
];

function App() {
  return (
    <ReactPivotGrid data={sampleData} />
  );
}

With Initial Configuration

import React from 'react';
import { ReactPivotGrid } from '@thorobid-ai/react-pivotgrid';
import '@thorobid-ai/react-pivotgrid/dist/style.css';

const salesData = [
  { region: 'North', product: 'Laptop', category: 'Electronics', sales: 1000, quantity: 10 },
  { region: 'South', product: 'Mouse', category: 'Electronics', sales: 200, quantity: 20 },
  // ... more data
];

function App() {
  return (
    <ReactPivotGrid
      data={salesData}
      initialConfig={{
        rows: ['region'],
        columns: ['category'],
        values: ['sales'],
        aggregation: 'sum',
        filters: {
          region: ['North', 'South']
        }
      }}
      fieldLabels={{
        region: 'Region',
        product: 'Product',
        category: 'Category',
        sales: 'Sales ($)',
        quantity: 'Quantity'
      }}
    />
  );
}

Aggregation Functions

The library supports multiple aggregation functions:

  • count - Count of records
  • sum - Sum of numeric values
  • average - Arithmetic mean
  • min - Minimum value
  • max - Maximum value

Usage Example

<ReactPivotGrid
  data={data}
  initialConfig={{
    rows: ['category'],
    columns: ['region'],
    values: ['revenue'],
    aggregation: 'sum'
  }}
/>

Field Filtering

Filter data by field values:

<ReactPivotGrid
  data={data}
  initialConfig={{
    rows: ['region'],
    columns: ['category'],
    values: ['sales'],
    aggregation: 'sum',
    filters: {
      region: ['North', 'South'],
      category: ['Electronics']
    }
  }}
/>

API Reference

ReactPivotGrid Props

interface ReactPivotGridProps<T extends Record<string, unknown>> {
  data: DataItem<T>[];
  initialConfig?: {
    rows?: FieldKey<T>[];
    columns?: FieldKey<T>[];
    values?: FieldKey<T>[];
    aggregation?: AggregationFunction;
    filters?: Partial<Record<FieldKey<T>, string[]>>;
  };
  fieldLabels?: Partial<Record<FieldKey<T>, string>>;
  pivotItemThreshold?: number;
}

Types

type DataItem<T> = T & Record<string, unknown>;
type FieldKey<T> = keyof T | string;
type AggregationFunction = 'count' | 'sum' | 'average' | 'min' | 'max';

interface PivotFieldState<T> {
  availableFields: FieldKey<T>[];
  rows: FieldKey<T>[];
  columns: FieldKey<T>[];
  values: FieldKey<T>[];
}

Development

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in UI mode
npm run test:ui

# Type checking
npm run type-check

# Linting
npm run lint

# Run example
npm run example

Advanced Usage

Multi-level Grouping

<ReactPivotGrid
  data={data}
  initialConfig={{
    rows: ['region', 'country'],
    columns: ['year', 'quarter'],
    values: ['revenue'],
    aggregation: 'sum'
  }}
/>

With Field Labels

<ReactPivotGrid
  data={data}
  initialConfig={{
    rows: ['region'],
    columns: ['category'],
    values: ['sales'],
    aggregation: 'sum'
  }}
  fieldLabels={{
    region: 'Sales Region',
    category: 'Product Category',
    sales: 'Revenue ($)'
  }}
/>

Performance Tuning

<ReactPivotGrid
  data={largeDataset}
  pivotItemThreshold={10000} // Optimize for large datasets
/>

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Process

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass: npm test
  6. Run linting: npm run lint
  7. Submit a pull request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

📞 Support


Made with ❤️ by Thorobid AI