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

v1.0.33

Published

React Table Adv is a customizable and feature-rich table component for React applications, designed to handle complex data display and interaction. ### Note : use in your next js projects.

Downloads

17

Readme

Advanced React Datatable

React Table Adv is a customizable and feature-rich table component for React applications, designed to handle complex data display and interaction.

Note : use in your next js projects.

Features

Customizable Columns

Define columns with custom headers, data accessors, and optional custom rendering.

Sorting

Enable sorting by column headers in ascending or descending order.

Filtering

Implement filters to narrow down data based on specific criteria.

Pagination

Divide large datasets into pages with navigation controls for easier data browsing.

Search

Allow users to search through data rows to find specific information quickly.

Custom Cell Rendering

Render cells with custom components or styles based on data content.

Actions Column

Provide actions like view, edit, and delete for each row.

Responsive Design

Ensure the table adapts to different screen sizes for optimal usability.

Customization Options

Offer various customization options such as colors, styles, and behavior settings.

Installation

You can install React Table Adv via npm :

npm install react-table-adv

add this code to tailwind.config.js

//tailwind.config.ts
....... 
content: [
    ...,
    "./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}",
    "./node_modules/react-table-adv/dist/**/*.{js,ts,jsx,tsx}"
  ],
  .....

Usage

Import the Table component in your React application and configure it with your data:

import React from 'react';
import { Table } from 'react-table-adv';

const App = () => {
  const columns = [
    { uid: 'name', name: 'Name', sortable: true },
    { uid: 'role', name: 'Role' },
  ];

  const data = [
    { id: 1, name: 'John Doe', role: 'Admin' },
    { id: 2, name: 'Jane Smith', role: 'User' },
  // Add more row
  ];

  return (
    <Table columns={columns} data={data} />
  );
};

export default App;

Props

  • columns: An array of column configurations.

  • data: An array of data objects to be displayed.

  • filterOptions: Enable filterOptions feature (optional).

    //add filter options, you can implement multiple filter if you want.
    const filterOptions = [
    {
      uid: "role",
      name: "Role",
      selectMode: "single",
      searchable: true, // only in single mode
      options: [
        { name: "Admin", uid: "Admin" },
        { name: "User", uid: "User" },
      ],
      onChange: (filterUid: any, selection: any, filteredData: any) => {
        console.log(`Filter ${filterUid} changed to ${selection}`);
        console.log('Filtered data:', filteredData);
        // Perform additional actions with filteredData if needed
      },
    },
    ];
    ........
      
    // pass filterOptions in Table component:
      
    <Table columns={columns} data={data} filterOptions={filterOptions}/>
  • searchable : boolean element to show/hide search field, default searchable is true so if you don't need search field just searchable={false}

Examples

Customizing Column Rendering

const columns = [
    { uid: 'name', name: 'Name', sortable: true },
    { uid: 'role', name: 'Role' },
    {
      uid:'status', 
      name:'Status', 
      customRenderer:(item:any) => <strong>Active</strong>
    },
  ];
  // Add more customized columns

Custom Style

Customizing Table Style

const classNames = {
      wrapper: ["max-h-[382px]", "max-w-3xl"],
      th: ["bg-red-500", "text-default-500", "border-b", "border-divider"],
      td: [
        "group-data-[first=true]:bg-default-100",
        "text-small",
        "cursor-pointer",
        "border-b",
        "border-divider",
      ],
      // more props: base, table, thead, tbody, tr
    }

    // and pass in table
    
    <Table data={data} columns={columns} filterOptions={filterOptions} customClass={classNames}/>
    

Acknowledgments

  • Thank you to the React community for their valuable contributions.