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-table-fast

v1.0.16

Published

A library to render HTML tables with advanced features.

Downloads

42

Readme

react-table-fast

A library to render HTML tables with advanced features.

NPM JavaScript Style Guide

Install

npm install --save react-table-fast

or

yarn add react-table-fast

Usage

  1. Create a container to position the table
  2. In the header, associate the column names to the data attributes
  3. In the body, just set the data to show
  4. In the footer (optional), you can apply aggregation function as SUM, AVG or CNT (count)
import React from "react"

import { TableFast, TableHeader, TableBody, TableFooter, TableAggregationFunctions, TableFormats } from "react-table-fast"

const App = () => {
  return (
    <div style={{ width: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>

      <TableFast
        filterable
        style={{ width: 600 }}
        className="highlight"
      >
        <TableHeader
          columns={[
            { name: 'Name', attr: 'name' },
            { name: 'Age', attr: 'age' },
            { name: 'Amount', attr: 'amount', format: TableFormats.currency }
          ]}
        />

        <TableBody
          data={[
            { id: 1, name: 'Felipe', age: 31, amount: 1280.45 },
            { id: 2, name: 'Ana', age: 24, amount: 1470.13 },
            { id: 3, name: 'João', age: 32, amount: 2170.77 },
            { id: 4, name: 'Pedro', age: 29, amount: 1421.8 }
          ]} />

          <TableFooter
            columns={[
              { text: 'TOTAL', colspan: 2 },
              {
                calculate: {
                  type: TableAggregationFunctions.SUM,
                  attr: 'amount',
                  format: TableFormats.currency
                }
              }
            ]}
          />
      </TableFast>

    </div>
  )
}

export default App

Expected result:

It's possible to define an action by clicking on a table row using the handleRowClick attribute being passed to the TableBody component, as below:

<TableBody
  data={[
    { id: 1, name: 'Name 1', age: 31, amount: 1280.45 },
    { id: 2, name: 'Name 2', age: 24, amount: 1470.13 },
    { id: 3, name: 'Name 3', age: 32, amount: 2170.77 },
    { id: 4, name: 'Name 4', age: 29, amount: 553.8 },
    { id: 5, name: 'Name 5', age: 43, amount: 1683.8 },
    { id: 6, name: 'Name 6', age: 20, amount: 778.8 },
    { id: 7, name: 'Name 7', age: 56, amount: 344.8 }
  ]}
  handleRowClick={row => {
    console.log(`${row.name}'s row has clicked!`)
  }}
/>

API Reference

<TableFast>

It is a wrapper, containing all other components.

| Attribute | Default | Type | |:----------: |:-------: |:-------: | | filterable | false | boolean | | className | '' | string | | style | {} | object |

<TableBody>

Contains all the data to be listed.

| Attribute | Default | Type | |:----------------: |:---------: |:--------: | | data | null | array | | handleRowClick | undefined | function | | deletion | undefined | {} | | deletion.handler | undefined | function | | deletion.effect | undefined | fadeOut |

<TableHeader>

Contains table headings, with parameterized titles and sorting action.

| Attribute | Default | Type | |:---------: |:---------: |:-------: | | columns | undefined | array | | sortable | true | boolean | | style | {} | object | | className | '' | string |

<TableFooter>

It can display the sum of a given numeric column, the total number of records or an arithmetic mean, through the aggregation functions available in the TableAggregationFunctions component.

| Attribute | Default | Type | |:---------: |:---------: |:------: | | columns | undefined | array | | style | {} | object | | className | '' | string |

TableAggregationFunctions

Provides some aggregation functions to be used in conjunction with the TableFooter component.

| Constant | Implements | |:--------: |:------------------------------------------: | | AVG | Arithmetic mean over the specified column. | | SUM | The summation over the specified column. | | CNT | The total number of rows. |

TableHoverEffects

Provides some hover effects for action icons.

| Effect | |:-------: | | ROTATE | | SCALE | | OPACITY |

TableFormats

It must be used within the objects contained in the date, passed to the THeader component. It provides some common masks that will be applied to all values in the specified column.

| Mask | |:-------: | | currency | | avatar | | component |

License

MIT © felipeleite11