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-npm-table-data-set

v1.22.0

Published

A react component to display data in a table format, using a bootstrap 3 style

Downloads

19

Readme

react-npm-table-data-set

A React component to display data in a table format, using a bootstrap 3 style.

npm Version Build Status

Overview

A react component to display data in a table format, using a bootstrap 3 style.(Wrapper component for: https://react-bootstrap.github.io/components.html#tables)

let data = {
  rows: [
    ['foo', 'bar', 'baz'],
    ['a', 'b', 'c']
  ]
};
<TableDataSet params={data} />;

Params in more detail:

This is a full params object in all it's glory. See details about each key below.

{
  "header": "This is a table of people and their ages",
  "columns": {
    "titles": [
      {
        "name": "First Name",
        "sortable": true
      },
      {
        "name": "Last Name",
        "sortable": false
      },
      {
        "name": "Age",
        "sortable": true
      }
    ],
    "components": [
      {},
      {},
      {
        "name": "NumericLabel",
        "params": {
          "justification": "R"
        }
      }
    ]
  },
  "rows": [
    [
      "Cam",
      "Stuart",
      43
    ],
    [
      "Deepak",
      "Khandelwal",
      28
    ]
  ],
  "styling": {
    "bs3": [
      "responsive",
      "striped",
      "condensed",
      "hover",
      "bordered"
    ],
    "common": {
      "fontFamilyCss": "'Consolas', 'Courier', monospace;",
      "fontSizeCss": "100%",
      "textTransformCss": "uppercase;"
    },
    "header": {
      "fontSizeCss": "150%",
      "backgroundCss": "#0093D0"
    },
    "titles": {
      "fontSizeCss": "120%",
      "backgroundCss": "#999999"
    }
  },
  "pagination": {}
}

caption

An optional table caption that is a full width cell containing a heading of the table. If this key is not present, then no heading is displayed

columns

This part of the params object defines the behavior of the columns

titles

An optional array of column titles, displayed as <th> elements. If this key is not present then there are no titles

components

An optional array of objects specifying react component names and parameters to be used when rendering the cell. Passing null, undefined or {} (empty object) means no component will be used, and the cell will display it's data as is

currently this package support following component

  • NumericLabel
  • ResultStatusLabel

rows

A required array of rows, containing an array of rows

styling

This part of the params object defines the styling of the table

bs3

See also: https://react-bootstrap.github.io/components.html#tables

An array bootstrap 3 style and behaviour to be passed into the react-bootstrap table. EG:

"bs3": [
      "condensed",
      "hover",
      "bordered"
    ]

Would result in:

<Table condensed hover bordered>...</Table>

common

An optional object of common css styling to be applied across the entire table. The example above are the default values to be used

fontFamilyCss

The font type / family

textTransformCss

Any css text transformations

fontSizeCss

Font css values such as percentage, pixels, ect.

header

Styling for the header

titles

Styling for the title

pagination

An optional object specifying pagination behavior.

Features

  • Display table in bootstrap style.
  • Display table with sorting functionality.
  • Display rows with html tag.
  • Display columns according to component passed through params.
  • Display table with custom style
  • Display table with pagination
  • Runs in the browser and Node.js.
  • Built on standards.

Example

import React,{Component} from 'react';
import ReactDOM from 'react-dom';
import TableDataSet from 'react-npm-table-data-set'

class App extends Component {
	constructor(props){
		super(props);
	}

	render() {
    let data = {
      "header": "This is a table of people and their ages",
      "columns": {
        "titles": [
          {
            "name": "First Name",
            "sortable": true
          },
          {
            "name": "Last Name",
            "sortable": false
          },
          {
            "name": "Age",
            "sortable": true
          },
          {
            "name": "Status",
            "sortable": false
          },
        ],
        "components": [
          {},
          {},
          {
            "name": "NumericLabel",
            "params": {
              "justification": "R"
            }
          },
          {
            "name": "ResultStatusLabel",
            "params": {
              'bgColorMap' : {
                'pass' : '#3cb521',
                'ok' : '#3cb521',
                'fail' : '#474949',
                'alert' : '#d47500',
                'inc' : '#3cb521',
                'flag' : '#474949',
                'label' : '#ffffff'
              },
              'textColorMap' : {
                'pass' : '#ffffff',
                'ok' : '#ffffff',
                'fail' : '#ffffff',
                'alert' : '#ffffff',
                'inc' : '#cd0200',
                'flag' : '#ffffff',
                'label' : '#ffffff'
              },
            }
          }
        ]
      },
      "rows": [
        ['Cam', 'Stuart', 43,'ok'],
        ['Deepak', 'Khandelwal', 25,'ok'],
        ['Shweta', 'Fatnani', 27,'ok'],
        ['Raunak', 'Singh', 20,'ok'],
        ['Shifali', 'Baghel', 19,'fail'],
        ['Santosh', 'Saini', 26,'ok'],
        ['Vivek', 'Kumar', 26,'ok'],
        ['Raunak', 'Kumar', 20,'ok'],
        ['Shahil', 'Jindal', 26,'ok'],
        ['Rajat', 'Maggo', 24,'ok'],
        ['Shobhana', 'Singh', 23,'ok'],
        ['Sunil', 'Thakur', 29,'ok'],
        ['Yogesh', 'Saini', 34,'fail'],
        ['Rajat', 'Chhug', 40,'pass'],
        ['Pradeep', 'Bhatia', 50,'ok']
      ],
      "styling": {
        "bs3": [
          "responsive",
          "striped",
          "condensed",
          "hover",
          "bordered"
        ],
        "common": {
          "fontFamilyCss": "'Consolas', 'Courier', monospace",
          "fontSizeCss": "100%",
          //"textTransformCss": "uppercase"
        },
        "header": {
          "fontSizeCss": "100%",
          "backgroundCss": "#0093D0",
          "heightCss": "30px",
          "paddingCss": "5px",
          "colorCss" : "#fff"
        },
        "titles": {
          "fontSizeCss": "120%",
          "backgroundCss": "#999999"
        }
      },
      "pagination": {
        "itemPerPage" : 10,
      },
      "search":true
    };
		return(
			<div>
      <TableDataSet params={data} />
			</div>
		);
	}
}

ReactDOM.render(<App />,document.querySelector('.container'));

Technology Stack:

  • react
  • mocha

Usage:

Clone the repo as a new project:

git clone https://github.com/lobdev/react-npm-table-data-set <table-data-set>

Start Server:

First you have to replace the lib/component/table-data-set.js to server.js in package.json
cd table-data-set
npm i
npm start

Run App:

npm start command automatically initiate browser at 3000 port
http:://localhost:3000

Run tests:

cd table-data-set
npm i
npm test

Developer Notes:

Make sure you configure your editor/IDE to use:

.editorconfig
.eslintrc