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

dbl-table

v1.3.2

Published

A simple lightweight React Table Component

Downloads

298

Readme

DBLTable

DBLTable is a versatile lightweight React table component that allows you to display, search, paginate, and export tabular data easily. It supports various customization options and features, making it suitable for a wide range of applications. It is fully customizable. Make sure TailwindCSS is already installed in your project as the table depends on it.

Installation

You can install DBLTable using npm:

npm install dbl-table

Usage

Basic Usage

import React from 'react';
import DBLTable from 'dbl-table';

const YourComponent = () => {
  // Your data and columns configuration
  const data = [...]; // Array of objects
  const columns = [...]; // Array of TableColumn objects

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

export default YourComponent;

Advanced Usage

import React, { useState } from 'react';
import DBLTable from 'dbl-table';


const YourComponent = () => {
  // Your advanced data and columns configuration
  const data = [...]; // Array of objects
  const columns = [...]; // Array of TableColumn objects

  // Your custom styles
  const customStyles = {
    component: { /* Your custom styles for the component wrapper */ },
    table: { /* Your custom styles for the table */ },
    header: { /* Your custom styles for the table header */ },
    body: { /* Your custom styles for the table body */ },
    footer: { /* Your custom styles for the table footer */ },
    stripeStyle: { /* Your custom styles for striped rows */ },
    tableCell: { /* Your custom styles for table cells*/ }
  };

  // Your additional features
  const toolbars = [...]; // Additional components or buttons
  const onPaginationChange = (pagination) => { /* Handle server-side pagination */ };
  const onGlobalTableSearchChange = (searchTerm) => { /* Handle global table search */ };
  const renderRowDetails = (props) => { /* Render additional details for each row */ };
  const showActions = (rowData) => { /* Render actions for each row */ };
  const onRowSelection = ({ rowState, rowData }) => { /* Handle row selection */ };
  const userComponents = (<div>{/* Render your own components */}</div>)

  return (
    <DBLTable
      data={data}
      columns={columns}
      toolbars={toolbars}
      enableServerPagination={true}
      onPaginationChange={onPaginationChange}
      onGlobalTableSearchChange={onGlobalTableSearchChange}
      loading={false}
      renderRowDetails={renderRowDetails}
      showActions={showActions}
      enableStripStyle={true}
      removeStraightLines={false}
      printTools={true}
      tableTitle="Your Table Title"
      onRowSelection={onRowSelection}
      userComponents={userComponents}
      customStyles={customStyles}
    />
  );
};

export default YourComponent;

Props

| Prop | Type | Description | | --------------------------- | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | data | TableData | An array of objects representing the tabular data to be displayed. | | columns | TableColumn[] | An array of objects defining the columns of the table. Each object should have key, label, an optional renderCell function for custom rendering. and optional width | | toolbars | React.ReactNode[] (optional) | An array of React components or buttons to be displayed above the table for additional functionality. | | enableServerPagination | boolean (optional) | Enable or disable server-side pagination. Default is false. | | onPaginationChange | (pagination: { pageIndex: number; pageSize: number }) => void (optional) | Callback function triggered when the page index or page size changes. Useful for server-side pagination. | | onGlobalTableSearchChange | (searchTerm: string) => void (optional) | Callback function triggered when the global search term changes. | | loading | boolean (optional) | Indicates whether the table is in a loading state. Default is false. | | isError | boolean (optional) | Indicates whether there was an error in data fetch. Default is false. | | renderRowDetails | (props: { row: any }) => React.ReactNode (optional) | Function to render additional details for each row. It receives a row object as a parameter. | | showActions | (rowData: any) => React.ReactNode (optional) | Function to render actions for each row. It receives a rowData object as a parameter. | | enableStripStyle | boolean (optional) | Enable or disable striped table styling. Default is true. | | removeStraightLines | boolean (optional) | Remove straight lines (borders) between cells. Default is false. | | printTools | boolean (optional) | Enable or disable printing tools, such as exporting to Excel. Default is true. | | tableTitle | string (optional) | Title to be displayed above the table. | | onRowSelection | (rowData: { rowState: boolean, rowData: any }) => void (optional) | Callback function triggered when a row is selected/deselected. It provides the row state and data. | | customStyles | customStylingProp (optional) | Custom styles for various parts of the table (component, table, tableCell header, body, footer, stripeStyle). | | userComponents | () => React.ReactNode (optional) | Allows users to pass their own custom components to the table. |

Additional Features

  • Export to Excel: Click on the Excel button to export the table data to a CSV file.
  • Search: Use the search input to filter data globally.
  • Pagination: Navigate through different pages using the navigation buttons.
  • Sorting: Click on column headers to sort data in ascending or descending order.
  • Row Selection: Enable row selection with the ability to handle selection events.
  • Custom Styling: Customize the table appearance with the customStyles prop.

Feel free to customize and extend the component according to your specific requirements. If you encounter any issues or have suggestions for improvements, please open an issue on the GitHub repository.

Happy coding! 🚀