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

v1.0.2

Published

A plugin for implementing data tables on Reactjs

Downloads

10

Readme

react-plugin-table

A react plugin for implementing data tables

NPM downloads NPM version Package size

NPM Storybook

Installation

npm install react-plugin-table

Usage

import { Table } from 'react-plugin-table';

Next, declare the columns your table will need in an array of objects :

  const columns = [
  {
    label: 'First column',
    cell: 'firstColumn',
    isSortable: true,
  },
  {
    label: 'Second column',
    cell: 'secondColumn'
  },
  {
    label: 'Third column',
    cell: 'thirdColumn'
  }
];

Declare the contents of your table with an array containing an object corresponding to each row. If you don't want any cells to appear, simply don't declare the column.

Warning: a unique id must be declared in each object

An example of data :

  const rows = [
  {
    id: '1',
    firstColumn: 'First Line',
    secondColumn: 'First Line',
    thirdColumn: 'First Line',
  },
  {
    id: '2',
    firstColumn: 'Second Line',
    secondColumn: 'Second Line',
    thirdColumn: 'Second Line',
  },
  {
    id: '3',
    firstColumn: 'Third Line',
    secondColumn: 'Third Line',
    thirdColumn: 'Third Line',
  },
];

To finish, use the table as follows:

  return (
  <Table columns={columns} label="Table label" description="Table description" rows={rows}/>
);

Features

  • Column sorting : The columns having the sortable boolean to true will have the sort option active, which allows them to be ascendingly sorted on the first click on the header of the column, and descendingly sorted on second click of the column.
  • Search : A table with isFiltered boolean with true value, a search input will be displayed.
  • Pagination : A pagination system is implemented to present tables with many entries in a simple way. You can select the amount of data to be displayed per page using a selector.
  • Responsive : The component is responsive and can be displayed on desktops and small screens without scrolling.

Future developments

Essential

  • [ ] Make the colours used in css customisable
  • [ ] Finish implementing accessible elements (aria attributes and keyboard navigation management)
  • [ ] Be able to add action buttons to a list with selection

For later

  • [ ] Add unit tests
  • [ ] Add support for defining column groups
  • [ ] Add a deltaPagination props to the component to customise the number of pages required before and after the active (currently only 2 possible)
  • [ ] Allow the use of ajax calls for searching and pagination

Summary Props

Table

| Name | Type | Default | Description | |--------------------|----------|---------|------------------------------------------------------------------------------------| | columns | Array | | For more information, please refer to the summary Table.columns | | rows | Array | - | For more information, please refer to the summary Table.rows | | label | String | - | Title for the table | | description | String | - | Description for the table | | isFiltered | Boolean | false | A search input will be displayed with true value | | rowsPerPage | Number | 10 | Number of items per page desired when the component is loaded | | rowsPerPageOptions | Number[] | null | Define the list of select options for the number of items to be displayed per page | | sortField | String | null | Specify the column to be sorted by default when the component is loaded | | checkboxSelection | Boolean | false | Each row becomes selectable with a checkbox and a ‘Select all’ for the column |

Table.columns

| Name | Type | Default | Description | |------------|---------|---------|------------------------------------------------------| | label | String | | Content of a cell | | isSortable | Boolean | | Is the column sortable ? | | cell | String | | key associated with the contents of the desired cell |

Table.rows

| Name | Type | Default | Description | |------|--------------------------|---------|-------------------| | id | String | Number | | Id of a row | | - | String | Number | Date | | Content of a cell |

Licence