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

wc-grid-table

v3.1.14

Published

A table component implemented with css-grid and webcomponents.

Readme

wc-grid-table

codepen

Description

wc-grid-table (short: wgt) is a Free and Open-Source, CSS-Grid, Table WebComponent. The goal of this WebComponent is high customizability and a low barrier to entry. It uses no required dependencies (lodash.debounce as optional plugin) and is only around 30kB (unzipped, minified) in size.

Current version: 3.1.13

Features

  • Sortable columns, including stable multi-column sort (later columns keep their order when an earlier column is reversed)
  • Locale-aware number sorting and comparison filters (0,16 and 0.16 are both treated as decimals)
  • Per-column filters (contains / not-contains regex, equals, greater, less, …)
  • Filters run on the raw values; formatters only change what is displayed
  • Pagination, column chooser (modal) and a footer that stays put while cells scroll
  • Optional URL rewrite so filter, sort, pagination and hidden columns survive a reload
  • Optional debug logging

Installation

Install via npm:

npm install wc-grid-table

Use via CDN:

<script src="https://unpkg.com/[email protected]/dist/standalone/bundle.min.js"></script>

Build from Source

First install all dev-dependencies:

npm install

wgt uses Browserify as bundler. To build the component and the examples:

npm run build:all

Useful scripts:

| Script | Purpose | | --- | --- | | npm test | Jest tests | | npm run serve | Serve dist/ and open the standalone example | | npm run build:all | Create dist/ folders if needed, then build all bundles |

Usage

Getting Started

Include it in your page:

<body>
  ...
  <script src="https://unpkg.com/[email protected]/dist/standalone/bundle.min.js"></script>
</body>

Afterwards register the custom element. Use the provided defineCustomElement() function to register it as wc-grid-table, or call customElements.define with a custom name:

WcGridTable.defineCustomElement();

// or

customElements.define('your-fancy-name', WcGridTable.TableComponent);

The name has to include at least one hyphen. After creating a wgt element the only thing needed is to add data:

let data = [
  {
    firstname: "Hans",
    lastname: "Dieter",
    age: 28,
    hobby: "running"
  },{
    firstname: "Karl",
    lastname: "Heinrich",
    age: 52
  },{
    firstname: "Manfred",
    lastname: "Steibl",
    age: 60
  }
]

let table = document.createElement('wc-grid-table');
table.setData(data);

document.querySelector('body').append(table);

Formatters can wrap values for display (for example as links) without changing filter or sort:

table.formatter.Artikelnummer = [
  (value) => value != undefined
    ? `<a href="/article/${value}">${value}</a>`
    : ''
];

Customization

Methods

The following functions are exposed on the wgt element (documented in their respective docstring):

  • useDefaultOptions()
  • connectedCallback()
  • setDebounceFn(debounceFn, sortDebounceOptions, filterDebouncedOptions)
  • setData(data)
  • getDisplayedData()
  • getOriginalData()
  • redrawData()
  • redrawTable()
  • registerPlugin(plugin)

Properties

The following properties can be accessed / set directly on the wgt element:

  • root_document — either document or the connected shadowRoot
  • conditionalColumnStyle — an object with keys [condition, styles] where condition is a function (data: Array<Object>, column: string) => Boolean and styles is an Array of CSS strings applied when condition returns true for a column
  • conditionalRowStyle — like column styles, but per row / cell
  • conditionalStyleOptions{ active: Boolean }
  • formatter — an Object with column names as keys, containing lists of formatter functions applied before displaying a value. Signature: (value, rowIndex, completeData) => any. Formatters run left to right. They do not change the values used for filter and sort
  • formatterOptions{ active: Boolean }
  • filter — an Object with column names as keys, containing the filter input strings
  • filterOptions{ active: Boolean }
  • filterOperations — list of { name, char, fn(filterInput, testValue) }. Default operations: contains / not-contains (regex), equals, greater, greater-or-equal, less, less-or-equal, not-equal. Cycle them with the symbol next to each filter input
  • sortedBy — Array of { col, dir } (dir is "asc" or "desc"). Sorting is stacked, so primary, secondary, tertiary, … sorting is possible
  • sortOptions{ active: Boolean }
  • customChooseSortsCompareFn — maps a column to a compare function. Signature: (table, data, column) => CompareFn
  • customCompareNumbers / customCompareText — replacements for the default number / text compare functions (Array.prototype.sort style)
  • pagination{ active, currentPage, pageSize } (default page size is 40)
  • hiddenColumns / visibleColumns / hiddenColumnsCondition — control which columns are shown. The footer columns button opens a modal to toggle them

Attributes

  • noheader — hide header row
  • nofilter — hide filter row
  • nofooter — hide footer
  • nopagekey — do not bind left/right keys for pagination
  • norewriteurl — do not write table state into the URL
  • debug — verbose console.log output (sort, filter, format, plugins)
  • page-size — initial page size, e.g. page-size="25"
  • height — max-height of the table container, e.g. height="80vh"
  • options — serialized initial options (same shape as the URL state)
<wc-grid-table height="80vh" page-size="25" debug></wc-grid-table>

License

ISC. See LICENSE.