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

@bw-ui/datatable-history

v1.0.2

Published

Undo/Redo plugin for @bw-ui/datatable

Readme

@bw-ui/datatable-history

Undo/Redo plugin for BWDataTable.

Features

  • Undo/Redo - Revert cell edits, selection changes
  • ⌨️ Keyboard Shortcuts - Ctrl+Z, Ctrl+Y, Ctrl+Shift+Z
  • 📚 History Stack - Configurable max history size
  • 🔄 Full State Restore - Data, sort, filters, selection

Installation

npm install @bw-ui/datatable-history

Usage

import { BWDataTable } from '@bw-ui/datatable';
import { HistoryPlugin } from '@bw-ui/datatable-history';

const table = new BWDataTable('#table', { data }).use(HistoryPlugin, {
  maxHistory: 50, // Max undo states (default: 50)
  shortcuts: true, // Enable keyboard shortcuts (default: true)
});

// Programmatic undo/redo
table.undo();
table.redo();

// Check availability
if (table.canUndo()) {
  console.log('Can undo');
}

if (table.canRedo()) {
  console.log('Can redo');
}

// Clear history
table.clearHistory();

// Get history state
const history = table.getHistory();
console.log(
  `Undo: ${history.undoStack.length}, Redo: ${history.redoStack.length}`
);

Options

| Option | Type | Default | Description | | ------------ | --------- | ------- | --------------------------- | | maxHistory | number | 50 | Maximum undo states to keep | | shortcuts | boolean | true | Enable keyboard shortcuts |

Keyboard Shortcuts

| Shortcut | Action | | ------------------------------ | ------ | | Ctrl+Z / Cmd+Z | Undo | | Ctrl+Y / Cmd+Y | Redo | | Ctrl+Shift+Z / Cmd+Shift+Z | Redo |

API

Methods (added to table)

// Undo last action
table.undo(); // Returns: boolean (true if undone)

// Redo last undone action
table.redo(); // Returns: boolean (true if redone)

// Check if undo is available
table.canUndo(); // Returns: boolean

// Check if redo is available
table.canRedo(); // Returns: boolean

// Clear all history
table.clearHistory();

// Get history state
table.getHistory();
// Returns: {
//   undoStack: HistorySnapshot[],
//   redoStack: HistorySnapshot[],
//   canUndo: boolean,
//   canRedo: boolean,
// }

Events

// History state changed
table.on('history:change', ({ canUndo, canRedo, undoCount, redoCount }) => {
  // Update UI buttons
  undoBtn.disabled = !canUndo;
  redoBtn.disabled = !canRedo;
});

// After undo
table.on('history:undo', ({ action }) => {
  console.log('Undid:', action);
});

// After redo
table.on('history:redo', ({ action }) => {
  console.log('Redid:', action);
});

// History cleared
table.on('history:clear', () => {
  console.log('History cleared');
});

What Gets Tracked

The History plugin automatically tracks:

  • Cell edits - When you edit a cell value
  • Row selection - When selection changes
  • Sort state - Column and direction
  • Filter state - Search term and column filters

Example: Undo/Redo Buttons

const table = new BWDataTable('#table', { data }).use(HistoryPlugin);

const undoBtn = document.getElementById('undo');
const redoBtn = document.getElementById('redo');

// Update button states
table.on('history:change', ({ canUndo, canRedo }) => {
  undoBtn.disabled = !canUndo;
  redoBtn.disabled = !canRedo;
});

undoBtn.addEventListener('click', () => table.undo());
redoBtn.addEventListener('click', () => table.redo());

TypeScript

import { BWDataTable } from '@bw-ui/datatable';
import { HistoryPlugin, HistoryPluginOptions } from '@bw-ui/datatable-history';

const options: HistoryPluginOptions = {
  maxHistory: 100,
  shortcuts: true,
};

const table = new BWDataTable('#table', { data }).use(HistoryPlugin, options);

// Methods are typed
const canUndo: boolean = table.canUndo();
const history = table.getHistory();

License

MIT © BW UI