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

opt-table

v1.6.6-alpha

Published

A Responsive and Customizable Rich Table

Downloads

23

Readme

opt-table

opt-table is a versatile and customizable React table package built with Material-UI and Framer Motion. It provides a feature-rich table component for your React applications, including support for pagination, collapsible rows, sorting, and a responsive design.

Features

  • َAdd Rows: Add new Row will be implemented by providing a Promise to options for newDataHandler method an accessing the refs of table .

  • َUpdate Rows: Edit Row will be implemented by providing a Promise to options for editDataHandler and add the edit_row flag to options property of table .

  • َDelete Rows: Delete Row will be implemented by providing a Promise to options for deleteDataHandler and add the edit_row flag to options property of table .

  • Pagination: Easily implement pagination with options for the number of rows per page and navigation controls.

  • Collapsible Rows: Make your table more interactive by allowing users to expand and collapse rows for additional details.

  • Sorting: Enable sorting on one or multiple columns for a better user experience.

  • Responsive Design: "opt-table" is designed to adapt to different screen sizes, making it suitable for both desktop and mobile applications.

  • Customization: You have full control over the appearance and behavior of the table through custom styling and callbacks.

Props

  • table_header_list: An array of objects with the following properties.

    type tableHeaderProps = {
      width?: string | number,
      is_server_side?: boolean,
      has_details_penel?: boolean,
      header_style?: React.CSSProperties,
      row_style?: React.CSSProperties,
      Render?: React.FunctionComponent<{ renderData: T }>,
      title: string | undefined,
      table_key: string,
      align: "center" | "left" | "right" | "inherit" | "justify" | undefined,
      sortable?: boolean,
    };
  • data: An array of objects with the actual data - every header uses table_key to access it's coresponding data.

  • DetailsPanel: An array of objects - with the following data.

    type detailPanelProps = {
      // you should specify a table key from your data object ,so when that cell is clicked collapse table will opens
      table_key: string,
      // a component to be render as a detail panel ,this component will recive an ebject with the row data
      Component: React.FunctionComponent,
    };
  • container_style: css properties for table container

  • default_sort: default sort for table.

  • has_pagination: a boolean to specify has pagination or not .

  • options: awailable options for table so far :

type optionType<T> = {
  //
  // Set The direction of the table
  direction: "rtl" | "ltr",
  //
  // PROVIDE THIS METHOD FOR ACCESSING NEW DATA
  newDataHandler: (result: T) => Promise<boolean>,
  //
  //  PROVIDE THIS METHOD FOR ACCESSING EDITED DATA
  editDataHandler: (result: T) => Promise<boolean>,
  //  PROVIDE THIS METHOD FOR ACCESSING DELETED DATA
  deleteDataHandler: (result: T) => Promise<boolean>,
  //
  // FOR ROWS TO HAVE EDIT AND DELETE iCONS NEED TO ADD THIS PROPPS
  edit_row?: boolean,
  delete_modal_title?: React.ReactNode,
  //
  // THE ACEEPT TITLE FOR DELETEING THE ROW MODAL
  modal_yes_title?: string,
  //
  // THE CANCEL TITLE FOR DELETEING THE ROW MODAL
  modal_no_title?: string,
};
  • ref: to access table methods :
type OptTableRefProps<T> = {
  //
  // By accesing this method from ref an calling it , table will toggles between add new rows mode
  addNewRow: () => Void,
};

Installation

Install opt-table and its dependencies using npm :

npm install opt-table --legacy-peer-deps

Usage

import React from "react";
import { OptTable } from "opt-table";

function MyTable() {
  // Your data source
  const data = [
    // Your data objects here
  ];

  // Define columns

  const table_head_list = [
    /*
      an array of object with tableHeaderProps types

    */
  ];

  return (
    <OptTable
      data={data}
      table_head_list={columns}
      default_sort="name"
      has_pagination={true}
      DetailsPanel={[
        { table_key: "name", Component: ProfileDetailPanel },
        { table_key: "resume", Component: ResumeDetailPanel },
      ]}
      container_style={{ border: "1px solid #999" }}
    />
  );
}

Please refer to the official documentation for more details and customization options.

TypeScript Support

opt-table is developed using TypeScript, providing strong type checking and improved development experiences for TypeScript users.

License

This package is open-source and available under the MIT License.

Issues

If you encounter any issues or have feature requests, please submit them on our GitHub Issues page.

Author

"opt-table" is developed and maintained by Amin Hoseiny.

Happy tabling with opt-table! 🚀