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 🙏

© 2024 – Pkg Stats / Ryan Hefner

reactabular-column-extensions

v8.9.3

Published

Column extensions for Reactabular

Downloads

479

Readme

build status bitHound Score codecov

reactabular-column-extensions - Syntax extensions for Reactabular

reactabular-column-extensions provide syntax extensions for Reactabular column definition. Instead of typing out import and the related code, this takes some of that work away. You still have to connect the data processing portion, though.

API

The API provides a bind function that merges the given extensions together with the provided column definition.

import * as extensions from 'reactabular-column-extensions';

// Or you can cherry-pick
import { bind } from 'sortabular';
import { bind as bindExtensions } from 'sortabular';

Binding

extensions.bind([<extension>]) => ([<column>]) => [<adjusted column>]

The binder accepts an array of extensions and a column definition. It adjusts the columns based on this information and merges the configuration emitted by extensions top to bottom.

An extension has to be an object like this:

{
  match(column) {
    // If a column has `demo` property set, evaluate and merge
    return column.demo;
  },
  evaluate(column) {
    // Emit a structure to attach to the column definition
    return {
      demo: true
    }
  }
}

If you want to implement a custom extension, you can wrap the object to a function and set defaults there.

Extensions

extensions.draggableHeader({ onMoveColumns: <function> }) => <extension>

draggableHeader injects the configuration expected by reactabular-dnd if header.draggable is set. You still have to configure the rest, though.

extensions.highlightCell() => <extension>

highlightCell injects the configuration expected by highlighting functionality from searchtabular if cell.highlight is set. You have to connect the highlighting logic with your data processing to make this work.

extensions.resizableHeader({ window, onDragColumnStart, onDragColumn, onDragColumnEnd, props }) => <extension>

resizableHeader injects the configuration required for resizable headers if header.resizable is set. It accepts window so you can make resizing work in an iframe. Most often you don't need to touch the parameter, though. You should define onDragColumn(width, { column } handler and deal with the new width there. reactabular-resizable can be useful for that purpose. props allow you to inject custom styling/props to resizable.column.

extensions.sortableHeader({ sortingColumns, onSort, props, strategy }) => <extension>

sortableHeader is a light wrapper to sortabular that gets injected if header.sortable is set. It sets logic and user interface needed for altering sorting state. It also injects sort reset transform. sortingColumns, onSort(sortingColumns), props, and strategy follow sortabular interface. props allow you to customize styling/props of sortabular.sort.

extensions.toggleChildrenCell({ idField, parentField, onToggleShowingChildren, props, rows }) => <extension>

toggleChildrenCell gets injected if cell.toggleChildren is set. It has been designed to work with nested tree data of treetabular. It allows you to customize tree idField and parentField. In addition you have to define what happens when children are toggled using onToggleShowingChildren(rowIndex). If you want to customize treetabular.toggleChildren, you can pass props to it. The extension also expects you to pass the rows of your application to it.

Column Extension Example

The example below shows how the transformation works.

Example:

/*
import * as extensions from 'reactabular-column-extensions';
*/

const columns = [
  {
    property: 'color',
    header: {
      label: 'Color',
      draggable: true
    }
  },
  {
    property: 'name',
    header: {
      label: 'Name'
    },
    cell: {
      highlight: true
    }
  }
];

const extendedColumns = extensions.bind([
  extensions.draggableHeader({
    onMoveColumns: () => ({})
  }),
  extensions.highlightCell()
])(columns);

<ul>{
  (extendedColumns).map((d, i) =>
    <li key={`value-${i}`}>{JSON.stringify(d, null, 2)}</li>
  )
}</ul>

License

MIT.