1.0.16 • Published 3 years ago

react-table-fast v1.0.16

Weekly downloads
15
License
MIT
Repository
github
Last release
3 years ago

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.

AttributeDefaultType
filterablefalseboolean
className''string
style{}object

<TableBody>

Contains all the data to be listed.

AttributeDefaultType
datanullarray
handleRowClickundefinedfunction
deletionundefined{}
deletion.handlerundefinedfunction
deletion.effectundefinedfadeOut

<TableHeader>

Contains table headings, with parameterized titles and sorting action.

AttributeDefaultType
columnsundefinedarray
sortabletrueboolean
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.

AttributeDefaultType
columnsundefinedarray
style{}object
className''string

TableAggregationFunctions

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

ConstantImplements
AVGArithmetic mean over the specified column.
SUMThe summation over the specified column.
CNTThe 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

1.0.16

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago