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-tabulize

v1.0.3

Published

`Rtabulize` is a customizable React table component designed to handle dynamic data with features such as sorting, pagination, and filtering. It provides a flexible way to display tabular data with additional functionalities like search and custom column

Downloads

11

Readme

Rtabulize Component

Rtabulize is a customizable React table component designed to handle dynamic data with features such as sorting, pagination, and filtering. It provides a flexible way to display tabular data with additional functionalities like search and custom column rendering.

Features

  • Search: Filter table data based on a search term.
  • Sorting: Clickable column headers for ascending/descending sorting.
  • Pagination: Navigate through data with next and previous controls.
  • Custom Column Rendering: Apply custom styles or components to specific columns.

Installation

To use the Rtabulize component, you need to have a React environment set up. You can include this component in your project by copying the Rtabulize component code into your project directory.

Usage

Here is a basic example of how to use the Rtabulize component:

import React from 'react';
import Rtabulize from 'react-tabulize'; 

const MyComponent = () => {
  const data = [
    { _id: 1, name: 'John Doe', phone: '123456789', msg: 'Hello', url: 'https://example.com', status: 1, screenshot: '/images/screenshot1.png' },
    // More data objects...
  ];

  const header = [
    { key: '_id', label: 'Id' },
    { key: 'name', label: 'Customer Name' },
    { key: 'phone', label: 'Phone No' },
    { key: 'msg', label: 'Msg' },
    { key: 'url', label: 'URL' },
    { key: 'status', label: 'Status' },
    { key: 'screenshot', label: 'Screen-Shot' },
  ];

  const columnStyle = [
    {
      targets: [6],
      tag: function (data) {
        return (
          <img style={{ width: "50px" }} src={`${process.env.REACT_APP_API_URL + data.screenshot}`} alt="screenshot" />
        );
      },
    },
    {
      targets: [5],
      tag: function (data) {
        return data.status === 1 || data.status === 0 ? (
          <>
            <span className="badge bg-danger">Msg not send</span><br />
            <span style={{ cursor: 'pointer' }} onClick={() => console.log(`Resend message for ID: ${data._id}`)}>
              <u>Resend Msg</u>
            </span>
          </>
        ) : (
          <span className="badge bg-success">Msg send</span>
        );
      },
    },
  ];

  return (
    <Rtabulize
      tableClass="table"
      header={header}
      data={data}
      columnStyle={columnStyle}
      pageLength={10}
    />
  );
};

export default MyComponent;

Props

  • tableClass (string, optional)
    Description: CSS class name(s) to style the table.
    Default: ""

  • header (array of objects, required)
    Description: Defines the structure of the table header. Each object in the array should have a key corresponding to the data field and a label for the column header.
    Example: [ { key: 'name', label: 'Customer Name' }, { key: 'status', label: 'Status' } ]

  • data (array of objects, required)
    Description: The dataset to be displayed in the table. Each object should have keys corresponding to the header keys.
    Example: [ { name: 'John Doe', status: 1 } ]

  • columnStyle (array of objects, optional)
    Description: Allows custom rendering of specific columns. Each object in the array should specify targets (array of column indexes) and a tag function that returns JSX for rendering.
    Example: [ { targets: [0], tag: (data) => <img src={data.url} alt="image" /> } ]

  • pageLength (number, optional)
    Description: Number of rows to display per page.
    Default: 10

  • search (boolean, optional)
    Description: Enables or disables the search functionality.
    Default: true

  • sort (boolean, optional)
    Description: Enables or disables sorting on all columns.
    Default: true

  • pagination (boolean, optional)
    Description: Enables or disables pagination controls.
    Default: true