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

@flafonso/react-datatable-component

v1.0.7

Published

## Description

Downloads

13

Readme

@flafonso/react-datatable-component

Description

@flafonso/react-datatable-component is a customizable table component for React that enables sorting, filtering, and pagination of data in a dynamic way. It is designed to replace older jQuery-based solutions, offering improved performance and modularity for modern React applications.

This component was developed as part of a project aimed at modernizing an internal employee management application. It’s simple to use and integrates seamlessly into any React project.

Features

  • Pagination: Navigate through data pages using "Next" and "Previous" buttons or by selecting a page number directly.
  • Sorting: Sort the data in ascending or descending order by clicking on column headers.
  • Filtering: Search the table using a text input to find matching employee records.
  • Rows per page selection: Allows users to control how many rows are displayed per page via a dropdown selector.

Installation

npm install @flafonso/react-datatable-component

Usage Example

Here’s an example of how to integrate the @flafonso/react-datatable-component into a React application to display a list of employees.

Note: The example uses Redux to manage state. The DataTable component itself is independent of Redux and can be used with any state management approach.

Basic Usage

import { useSelector } from "react-redux";
import { DataTable } from "@flafonso/react-datatable-component";

const columns = [
  { title: "First Name", data: "firstName" },
  { title: "Last Name", data: "lastName" },
  { title: "Start Date", data: "startDate" },
  { title: "Department", data: "department" },
  { title: "Date of Birth", data: "dateOfBirth" },
  { title: "Street", data: "street" },
  { title: "City", data: "city" },
  { title: "State", data: "state" },
  { title: "Zip Code", data: "zipCode" },
];

function EmployeeList() {
  const employees = useSelector((state) => state.employeeList.employees);

  return (
    <>
      <DataTable
        id="employee-table"
        className="employee-table"
        data={employees}
        columns={columns}
      />
    </>
  );
}

export default EmployeeList;

Sample Data

Here’s an example of the kind of data that can be displayed in the table:

[
  {
    "firstName": "Jean",
    "lastName": "Paul",
    "dateOfBirth": "08/17/1995",
    "startDate": "10/02/2022",
    "street": "Rue 123",
    "city": "Ville 123",
    "state": "NC",
    "zipCode": "12323-3434",
    "department": "Human Resources"
  },
  {
    "firstName": "Michelle",
    "lastName": "Gris",
    "dateOfBirth": "05/16/2000",
    "startDate": "10/27/2024",
    "street": "Rue 123",
    "city": "Ville 123",
    "state": "NC",
    "zipCode": "12323",
    "department": "Human Resources"
  }
]

Props

id (string) [required]
A unique identifier for the table, used to differentiate between multiple instances of the component.

className (string) [optional]
A custom CSS class to style the table.

data (array of objects) [required]
The data to be displayed in the table. Each object represents a row in the table, with keys corresponding to the defined columns.

columns (array of objects) [required]
Defines the table columns. Each object in the array must have the following properties:

  • title: The name displayed in the column header.
  • data: The key in the data object that corresponds to the column's values. Example:
const columns = [
  { title: "First Name", data: "firstName" },
  { title: "Last Name", data: "lastName" }
];

Dependencies

The component relies on the following external libraries:

  • React: 17.0.2 or later
  • ReactDOM: 17.0.2 or later