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

react-jsx-super-table

v2.0.1

Published

A lightweight table with search and soring options for a React app which takes regular JSX to render the body.

Downloads

40

Readme

react-jsx-super-table

npm

A lightweight table with search and soring options for a React app which takes regular JSX to render the body.

This table was born out of frustation of using too much boilerplate for simple tables. I just wanted to write JSX for the body instead of passing down all my data, all my functions and their params and all the other props that were required. Don't get me wrong, if you have a need for a fairly complex table or grid those types of components are probably what you need, that's why they were created. This component is made specifically for smaller tables so you can develop them a little quicker and manage them a lot more easily, although for more complex uses you could write a really nice pagination function and put it in the footer to use this component

Installation

$ npm install react-jsx-super-table

Usage

The best way to see usages of the component is to look through our examples, you should be able to find an example for your needs. Also if you have a created a really nice implementation then please add it to the examples!

The only props required to use this component are data (an array of objects containing values, a string to be searched on for the row and row, the row you want to display) and it looks like this:

data={randomData
  .map(random => ({
    values: `${random.name}${random.type}`,
    row: (
      <tr key={random.id}>
        <td>{random.name}</td>
        <td>{random.type}</td>
      </tr>
    )
  }))}

and headers (an array obf objects containing key, value pairs which should be both strings along with an optional sort param to disable to column sorting) which looks like this:

  headers={[
    {
      key: 'name',
      value: 'Name'
    },
    {
      key: 'type',
      value: 'Type'
    }
  ]}

Sorting

You can also pass it a onHeaderSortClick function to sort the headers, in which you would keep columnToSort: string in state, a simple example of function would be this:

onHeaderSortClick = (key) => (
  this.setState({
    columnToSort: key
  })
);

Then add a sort, like Ramda's sortBy to the data before passing it to the component:

import {sortBy, prop} from 'ramda';

sortBy(prop(columnToSort), data).map((...

Searching

Client side searching is enabled by default but from version 1.3 and above you can have external searching (including the ability to do server side searching). This requires two props isExternalSearch which is a boolean and should be set to true and getSearchString which is a function that will return the search string to the client, from there the client will have to minipulate the data themselves.

An example of this is included in the project here

All props

There are other props you can avail of which are included in the table below:

| Props | Type | Required | | ------------ | ------------ | ---------| | className | string | No | | debounceTimeout | number | No | | data | Array<{values: string, row: node}> | Yes | | getSearchString | () => string | No (Yes for external search) | | headers | Array<{key: string, value: string, sort?: boolean}> | Yes | | isExternalSearch | boolean | No | | onHeaderSortClick | Function ((key: string) => void) | No | | searchPlaceholderText | string | No | | sortingIcon | string | No | | footer | node | No | | title | string/node | No | | titleClassName | string | No |

Development

We welcome any pull requests and here's how you can get started:

Install dependencies:

$ npm install

Run the example app at http://localhost:3000:

$ npm start

Run tests and watch for code changes using jest:

$ npm test

Lint src and test files:

$ npm run lint

License

MIT