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

bit-grid-component

v0.3.0

Published

Framework-agnostic web component for boolean matrices - edit and display 2D boolean arrays with interactive cell selection

Downloads

12

Readme

Demo and Documentations

Framework Usage Example

[!TIP] Example Sources are under ./examples/

Features

  • Web Component: <bit-grid> for 2D boolean matrices
  • Zero-deps ESM: single-file module, framework-agnostic
  • Selection: click + drag ranges with debounced updates
  • Events: dataChange event with 2D boolean array
  • API: update({ data, rowLabels, colLabels, onChange, debounceMs })
  • Theming: CSS custom properties for colors and spacing
  • Examples: Vanilla, React, Vue, Angular, CDN

Installation

npm install bit-grid-component

Usage

Declarative HTML

<!DOCTYPE html>
<html>
<head>
  <script type="module">import 'bit-grid-component'</script>
</head>
<body>
  <bit-grid></bit-grid>
  
  <script>
    const grid = document.querySelector('bit-grid');
    grid.addEventListener('dataChange', (e) => {
      console.log('Data changed:', e.detail);
    });
  </script>
</body>
</html>

Imperative Update

<bit-grid></bit-grid>

<script>
  const grid = document.querySelector('bit-grid');
  
  grid.update({
    data: Array(7).fill(null).map(() => Array(24).fill(false)),
    rowLabels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
    colLabels: Array.from({length: 24}, (_, i) => `${i}:00`)
  });
</script>

JavaScript Constructor

import 'bit-grid-component';
import BitGrid from 'bit-grid-component';

const grid = new BitGrid({
  data: Array(31).fill(null).map(() => Array(24).fill(false)),
  rowLabels: Array.from({length: 31}, (_, i) => `Day ${i + 1}`),
  colLabels: Array.from({length: 24}, (_, i) => `${i}h`)
});

// ⚠️ Must append to DOM
document.getElementById('container').appendChild(grid);

API

Constructor Options

const grid = new BitGrid({
  data: boolean[][],           // Optional: 2D boolean array
  rowLabels: string[],          // Optional: Array of row labels
  colLabels: string[],          // Optional: Array of column labels
  onChange: function,           // Optional: Callback for data changes
  debounceMs: number           // Optional: Debounce delay (default: 100ms)
});

Inference Priority:

  1. If both rowLabels and colLabels provided → data generated automatically
  2. If data provided → labels generated if not provided
  3. Default → 5x5 grid with auto-generated labels

Methods

// Get current data
const data = grid.getData();

// Update data and labels (infers dimensions)
grid.update({ data: newData, rowLabels: [...], colLabels: [...] });

// Convenience methods
grid.setLabels(['Row1', 'Row2'], ['Col1', 'Col2']);
grid.setData(booleanArray);
grid.setCell(row, col, true);
grid.getCell(row, col);
grid.toggleCell(row, col);
grid.fill(false); // Fill all cells with value

// Reset to empty grid
grid.reset();

Events

grid.addEventListener('dataChange', (e) => {
  const data = e.detail; // 2D boolean array
  console.log('Grid data changed:', data);
});

CSS Customization

bit-grid {
  --grid-primary: #3b82f6;                    /* Active cell color */
  --grid-bg: #ffffff;                         /* Background color */
  --grid-cell-bg: #f8fafc;                    /* Cell background */
  --grid-text: #1f2937;                       /* Text color */
  --grid-text-muted: #6b7280;                 /* Muted text color */
  --grid-header-bg: #f1f5f9;                  /* Header background */
  --grid-hover-bg: #e2e8f0;                   /* Hover background */
  --grid-selection-bg: rgba(59, 130, 246, 0.25); /* Selection background */
  --grid-selection-active-bg: rgba(59, 130, 246, 0.7); /* Active selection */
  --grid-cell-size: 28px;                     /* Cell size */
  --grid-header-width: 80px;                  /* Header width */
  --grid-cell-spacing: 4px;                   /* Cell spacing */
  --grid-cell-radius: 8px;                    /* Cell border radius */
}

Examples

Monthly Schedule

<bit-grid></bit-grid>

<script>
  const grid = document.querySelector('bit-grid');
  
  // Just provide labels - data auto-generated
  grid.update({
    rowLabels: Array.from({length: 31}, (_, i) => `Day ${i + 1}`),
    colLabels: Array.from({length: 24}, (_, i) => `${i}h`)
  });
  
  grid.addEventListener('dataChange', (e) => {
    const activeHours = e.detail.flat().filter(cell => cell).length;
    console.log(`Active hours: ${activeHours}`);
  });
</script>

React

import 'bit-grid-component';
import { useEffect, useRef } from 'react';

function AttendanceGrid({ data, onDataChange }) {
  const gridRef = useRef();
  
  useEffect(() => {
    if (gridRef.current) {
      // Labels-first approach
      gridRef.current.update({
        rowLabels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
        colLabels: Array.from({length: 24}, (_, i) => `${i}:00`)
      });
      
      // Then set data if provided
      if (data) {
        gridRef.current.setData(data);
      }
      
      gridRef.current.addEventListener('dataChange', onDataChange);
    }
  }, [data, onDataChange]);
  
  return <bit-grid ref={gridRef} />;
}

License

MIT