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

@itrocks/table

v0.0.22

Published

A lightweight, modular HTML table offering near-spreadsheet features such as edit, freeze, lock, scroll, and more

Downloads

349

Readme

npm version npm downloads GitHub issues discord

table

A lightweight, modular HTML table offering near-spreadsheet features such as edit, freeze, lock, scroll, and more.

This documentation was written by an artificial intelligence and may contain errors or approximations. It has not yet been fully reviewed by a human. If anything seems unclear or incomplete, please feel free to contact the author of this package.

Installation

npm i @itrocks/table

Usage

@itrocks/table is a lightweight, modular JavaScript table component that turns a plain HTML <table> into a near‑spreadsheet widget: editable cells, frozen columns, locked headers, horizontal and vertical scrolling, and more.

At runtime you create Table instances from existing DOM elements.

Minimal example

import { tableBySelector } from '@itrocks/table'

// Turn all matching <table> elements into interactive tables
const tables = tableBySelector('.js-data-table')

// Optionally keep a reference to one table
const table = tables[0]

Make sure the DOM is ready before you call tableBySelector (for example after DOMContentLoaded or in your framework's mounted hook).

You can also construct a table directly from an element:

import { tableByElement } from '@itrocks/table'

const element = document.querySelector('table#users') as HTMLTableElement
const table   = tableByElement(element)

For more advanced usage (plugins, styling, demos), check out the GitHub demo folder.

API

The public API is intentionally small and focuses on a single Table class plus a few helpers.

applyStyleSheets()

import { applyStyleSheets } from '@itrocks/table'

applyStyleSheets()

Forces the table module to (re)apply its internal style sheets. In most applications you do not need to call this manually: it is handled when creating Table instances. It can be useful in advanced integration scenarios (dynamic theme switch, hot‑reloaded styles, etc.).

garbageCollector()

import { garbageCollector } from '@itrocks/table'

garbageCollector()

Runs an internal cleanup pass to detach listeners and release resources from tables that are no longer present in the DOM. You might call this periodically in long‑running pages where tables are created and removed dynamically.

getTables()

import { getTables } from '@itrocks/table'

const tables = getTables()

Returns the list of all Table instances currently managed by the module. This is mainly useful for debugging or global operations (for example applying a plugin to every existing table).

type Options = PluginOptions<Table>

Configuration object passed when creating a Table. It is based on the generic plugin system from @itrocks/plugin.

Typical usage:

import type { Options } from '@itrocks/table'

const options: Partial<Options> = {
	// enable / configure plugins here
}

The exact shape of the options depends on the plugins you enable (edit, freeze, reorder, etc.). Refer to each plugin's documentation and the demo code for details.

class Table extends HasPlugins<Table>

Represents an interactive table instance bound to a single HTMLTableElement.

Constructor

import { Table } from '@itrocks/table'

const table = new Table(element, options)

Parameters:

  • element: HTMLTableElement – the DOM table to enhance.
  • options?: Partial<Options> – optional configuration and plugins.

Properties

  • element: HTMLTableElement – underlying table element.
  • id: number – numeric identifier assigned to the table instance.
  • selector: string – selector used when the table was created (when relevant).
  • onReset: (() => void)[] – list of callbacks invoked when the table is reset.
  • styleSheet: string[] – list of CSS rules associated with this table instance.

Methods

addEventListener(element, type, listener, options?)

Delegates the registration of an event listener through the table infrastructure, so it can be properly cleaned up on reset or removal.

table.addEventListener(document, 'keydown', event => {
	// react to keyboard shortcuts related to this table
})
cellColumnNumber(cell: HTMLTableCellElement): number

Returns the zero‑based column index of the given table cell within its row. This is handy when writing plugins that need to know which column a cell belongs to.

reset(): Table

Resets the table to its initial state:

  • clears plugin state,
  • reapplies default configuration,
  • triggers all callbacks registered in onReset.
table.reset()

Helper constructors

In addition to the Table class, the module exposes convenience functions to create tables from different inputs.

tableByElement(element, options?)

import { tableByElement } from '@itrocks/table'

const table = tableByElement(element, { /* options */ })

Creates (or returns an existing) Table instance for the given HTMLTableElement.

tableByElements(elements, options?)

import { tableByElements } from '@itrocks/table'

const nodeList = document.querySelectorAll('table.data')
const tables   = tableByElements(nodeList)

Accepts an array or a NodeListOf<HTMLTableElement> and returns an array of Table instances.

tableBySelector(selector, options?)

import { tableBySelector } from '@itrocks/table'

const tables = tableBySelector('.js-data-table')

Finds all tables matching the CSS selector and returns the corresponding Table instances.

Typical use cases

  • Enhance existing HTML tables with spreadsheet‑like behaviours (edit, freeze, lock, scroll) without rewriting the markup.
  • Build rich back‑office or data‑entry screens where users can edit multiple rows directly in a table.
  • Implement custom plugins on top of HasPlugins<Table> to add domain‑ specific features (validation, inline actions, totals rows, etc.).