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

wefix-sort-grid

v1.0.0

Published

A powerful JavaScript datagrid library with Redux-powered state management, providing advanced sorting, filtering, and pagination through a declarative control system

Readme

@wefix/sort-grid

A powerful and flexible JavaScript datagrid library providing advanced sorting, filtering, and pagination capabilities through a declarative control system. Built with Redux for predictable state management and Immer for efficient immutable updates.

Version License

Features

  • 🎛️ Declarative Control System - Register custom controls through a simple, extensible API
  • 🔄 Redux-Powered State Management - Predictable, centralized state with time-travel debugging support
  • ⚡ Immutable Updates with Immer - Efficient state updates using copy-on-write semantics
  • 🔍 Advanced Filtering - Button filters with toggle states and customizable logic
  • 📊 Sorting Capabilities - Multi-column sorting with configurable directions
  • 📄 Pagination - Built-in pagination controls for large datasets
  • 💾 State Persistence - Automatic state restoration from deep links, storage, or HTML attributes
  • 🎯 Memoized Selectors - Optimized performance with Reselect for derived state

Installation

npm install @wefix/sort-grid

Or using yarn:

yarn add @wefix/sort-grid

Quick Start

Basic Usage

<!DOCTYPE html>
<html>
<head>
  <title>DataGrid Example</title>
</head>
<body>
  <!-- Include the library -->
  <script src="node_modules/@wefix/sort-grid/datagrid.min.js"></script>

  <!-- Define your grid controls -->
  <button class="filter-control"
          data-id="status-filter"
          data-checked="false">
    Active Items
  </button>

  <script>
    // Your grid initialization code here
  </script>
</body>
</html>

Creating Custom Controls

Register custom controls by extending the global window.datagridControls object:

window.datagridControls['my-custom-control'] = function(control, store, rootSlice) {
  var $control = control.$control;

  // Get control configuration from data attributes
  var dataID = $control.getAttribute('data-id');

  // Subscribe to store updates for reactive behavior
  store.subscribe(function() {
    var state = store.getState();
    var action = state.actions[dataID];

    // Update control based on state
    if (action) {
      // Update UI based on action state
    }
  });

  // Add event listeners
  $control.addEventListener('click', function(evt) {
    evt.preventDefault();

    // Dispatch actions to update state
    store.dispatch({
      type: 'UPDATE_ACTION',
      payload: { /* your data */ }
    });
  });
};

Built-in Control Types

Button Filter

Toggle filter control with checked state management:

<button class="dg-button-filter"
        data-id="my-filter"
        data-checked="true">
  Filter Name
</button>

Features:

  • Automatic checked state toggle
  • CSS class management (dg-checked)
  • State restoration from store or HTML attributes

Pagination

Page navigation controls for dataset pagination:

<div class="dg-pagination"
     data-id="main-pagination">
  <!-- Pagination controls -->
</div>

Architecture

State Management

The library uses Redux with the following state structure:

{
  actions: {
    'control-id': {
      path: 'filter.value',
      // ... other action properties
    }
  },
  // ... other state slices
}

Control Lifecycle

  1. Initialization - Controls are registered on window.datagridControls
  2. Store Subscription - Each control subscribes to relevant state changes
  3. State Restoration - State is restored from:
    • Redux store (priority)
    • Deep links / localStorage
    • Initial HTML attributes (fallback)
  4. Event Handling - User interactions dispatch Redux actions
  5. Reactive Updates - Store subscribers update UI based on new state

API Reference

Control Registration

window.datagridControls[controlType] = function(control, store, rootSlice)

Parameters:

  • control - Control configuration object containing $control DOM element
  • store - Redux store instance with getState(), dispatch(), and subscribe() methods
  • rootSlice - Root state slice for scoped state access

Control Properties

Access control properties via the $control DOM element:

var $control = control.$control;
$control.control     // Reference back to control object
$control.store       // Redux store instance
$control.rootSlice   // Root state slice
$control.dataID      // Control identifier from data-id attribute
$control.checked     // Boolean checked state (for filters)

State Restoration

Controls automatically restore their state from multiple sources in priority order:

  1. Redux Store - Existing state from store.getState().actions[dataID]
  2. Deep Links - URL parameters or browser history
  3. Local Storage - Persisted state from previous sessions
  4. HTML Attributes - Initial state from data-* attributes

Performance Optimizations

  • Memoized Selectors - Reselect library prevents unnecessary recomputations
  • Immutable Updates - Immer ensures efficient structural sharing
  • Middleware Pipeline - Redux Thunk for async operations
  • Development/Production Builds - Optimized minified build for production

Browser Support

The library works in all modern browsers that support:

  • ES5+ JavaScript
  • Redux (included)
  • Proxies (for Immer, with ES5 fallback)

Development

This repository contains the distribution build. To use in development:

<!-- Development build with source maps -->
<script src="node_modules/@wefix/sort-grid/datagrid.js"></script>

<!-- Production build (minified) -->
<script src="node_modules/@wefix/sort-grid/datagrid.min.js"></script>

File Structure

@wefix/sort-grid/
├── datagrid.js         # Development build with source maps (~185KB)
├── datagrid.min.js     # Production minified build (~47KB)
├── datagrid.js.map     # Source map for debugging
├── package.json        # Package metadata
├── license            # ISC License
└── README.md          # This file

Built With

Based on JSOcean DataGrid v2.0.1

Authors

License

This project is licensed under the ISC License - see the license file for details.

Keywords

wefix sort grid datagrid redux filter pagination immutable state-management


Note: This package contains the distribution build only. For source code access or contributions, please contact the maintainers.