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

lightweight-react-table-component

v1.0.1

Published

A simple table component in react inspired by bootstrapVue table component, using bootstrap css

Downloads

10

Readme

React Table Component

React Table Component is a lightweight and customizable table component built with React, using Bootstrap 5 CSS. It is inspired by the Bootstrap Vue Table component.

Installation

You can install the package via npm:

npm install react-table-component

Usage

To use the Table component, import it from the package:

import Table from "react-table-component";
import "react-bootstrap-vue-table/dist/style.css"

Then, you can use the Table component in your React application like this:

import Table from "react-table-component";

function App() {
  type items = {
    [key: string]: string | number | boolean;
  };

  const fields = [
    "first_name",
    "last_name",
    {
      key: "age",
      label: "My Age",
      sortable: true,
      formatter: (value: string | number): number => {
        return Number(value) + 500;
      },
    },
    {
      key: "full_name",
      label: "Full Name",
      formatter: (_value: string | number, item: any): any => {
        return item.first_name + " " + item.last_name;
      },
    },
  ] as any;


  const items: items[] = [
    {
      isActive: true,
      age: 40,
      first_name: "Dickerson",
      last_name: "Macdonald",
    },
    { isActive: false, age: 21, first_name: "Larsen", last_name: "Shaw" },
    { isActive: false, age: 89, first_name: "Geneva", last_name: "Wilson" },
    { isActive: true, age: 38, first_name: "Jami", last_name: "Carney" },
  ];

  return (
    <div className="container">
      <Table
        TableBusy={<h1 className="text-center">Loading</h1>}
        busy={false}
        hover
        small
        bordered
        fields={fields}
        items={items}
        onRowClicked={(e) => console.log(e)}
        cell={{
          first_name: (value: string | number | boolean) => {
            return <button className="btn btn-primary">{value}</button>;
          },
          full_name: (value: string | number | boolean, _item: any) => {
            return <a href={value as string}>{value}</a>
          },
        }}
      />
    </div>
  );
}

export default App;

Props

Here is a list of the props that the Table component accepts:

  • fields - an array of objects that describe the columns in the table. Each object should have a key property that corresponds to the key in the data object, and may also have a label, sortable, and formatter property.
  • items - an array of data objects to be displayed in the table.
  • busy - a boolean that determines whether to show a loading spinner or not.
  • TableBusy - a custom element to be displayed instead of the default loading spinner.
  • hover - a boolean that determines whether to show a hover effect on the table rows.
  • small - a boolean that determines whether to make the table smaller.
  • bordered - a boolean that determines whether to add borders to the table.
  • cell - an object that maps column keys to custom cell renderers. Each value should be a function that takes the cell value and returns a React element
  • onRowClicked - a function that return the row data when its being clicked