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

@jivadio/react-datatable

v3.0.3

Published

A React component designed to present diverse data in an HTML table, featuring capabilities for pagination, filtering, and sorting.

Downloads

3

Readme

react-paginated-table

@jivadio/react-datatable is an npm package designed to seamlessly integrate paginated, filtered, and sortable tables into your web applications. Built with React, TypeScript, and TailwindCSS, it offers a robust solution for table management.

Installation

Install the package using npm:

npm install @jivadio/react-datatable

Import the table component into your project:

import DataTable from "@jivadio/react-datatable";

Use it as a standard React component:

<DataTable
  listTitle="Library Inventory"
  dataItems={items}
  columnHeaders={headers}
  actionOptions={action}
  paginationOptions={[5, 10, 15]}
/>

Usage

Arguments

The DataTable component can accept up to 5 arguments:

  • listTitle: A string displayed at the top of the table.
  • dataItems: An array of objects representing the items to display. Each object must have an id property (string). Other properties can be strings or numbers.
  • columnHeaders: An array of objects defining the columns. Each object should have:
    • title: The column header title.
    • sortText: The property name in the item object for sorting and filtering.
  • actionOptions (Optional): An object defining the action column. It includes:
    • title: The action column header title.
    • function: A function executed when the action button is clicked. Receives the item's id as a parameter.
    • label: The label for the action buttons.
  • paginationOptions (Optional): An array of numbers defining the options for the number of items per page. Defaults to [5, 10, 15]. If the values exceed the total items, they will not be displayed.

Functionality

  • Items can be sorted by any provided header field in ascending or descending order. By default, items are sorted in ascending order based on the first provided header field.
  • Items can be filtered using a text input, which searches across all item fields.

See the example below for more details.

Example

An example with the following parameters:

  1. items
const items = [
  {
    id: "1",
    title: "JavaScript: The Good Parts",
    author: "Douglas Crockford",
    genre: "Programming",
    pages: 176,
    price: 25.99,
    stock: 50,
  },
  {
    id: "2",
    title: "Eloquent JavaScript",
    author: "Marijn Haverbeke",
    genre: "Programming",
    pages: 472,
    price: 29.99,
    stock: 35,
  },
  {
    id: "3",
    title: "JavaScript: The Definitive Guide",
    author: "David Flanagan",
    genre: "Programming",
    pages: 1096,
    price: 39.99,
    stock: 20,
  },
  {
    id: "4",
    title: "You Don't Know JS",
    author: "Kyle Simpson",
    genre: "Programming",
    pages: 260,
    price: 24.99,
    stock: 45,
  },
  {
    id: "5",
    title: "Learning React",
    author: "Alex Banks & Eve Porcello",
    genre: "Programming",
    pages: 350,
    price: 31.99,
    stock: 30,
  },
  {
    id: "6",
    title: "JavaScript and JQuery",
    author: "Jon Duckett",
    genre: "Programming",
    pages: 640,
    price: 35.99,
    stock: 25,
  },
];
  1. headers
const headers = [
  {
    title: "Title",
    sortText: "title",
  },
  {
    title: "Author",
    sortText: "author",
  },
  {
    title: "Genre",
    sortText: "genre",
  },
  {
    title: "Pages",
    sortText: "pages",
  },
  {
    title: "Price",
    sortText: "price",
  },
  {
    title: "Stock",
    sortText: "stock",
  },
];
  1. action
const action = {
  title: "Action",
  function: (id) => {
    console.log("Book ID: " + id);
  },
  label: "View Details",
}
  1. Component
<DataTable
  listTitle="Library Inventory"
  dataItems={items}
  columnHeaders={headers}
  actionOptions={action}
  paginationOptions={[5, 10, 15]}
/>