1.6.6-alpha • Published 3 months ago

opt-table v1.6.6-alpha

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

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! 🚀

1.6.6-alpha

3 months ago

1.6.2-alpha

3 months ago

1.6.1-alpha

3 months ago

1.6.5-alpha

3 months ago

1.6.4-alpha

3 months ago

1.6.3-alpha

3 months ago

1.5.9-alpha

3 months ago

1.5.8-alpha

3 months ago

1.6.0-alpha

3 months ago

1.5.7-alpha

3 months ago

1.5.4-alpha

3 months ago

1.5.1-alpha

3 months ago

1.5.3-alpha

3 months ago

1.5.6-alpha

3 months ago

1.5.2-alpha

3 months ago

1.5.5-alpha

3 months ago

1.4.9-alpha

4 months ago

1.5.0-alpha

4 months ago

1.4.8-alpha

4 months ago

1.4.6-alpha

4 months ago

1.4.5-alpha

4 months ago

1.4.7-alpha

4 months ago

1.4.1-alpha

4 months ago

1.4.2-alpha

4 months ago

1.4.4-alpha

4 months ago

1.4.0-alpha

4 months ago

1.4.3-alpha

4 months ago

1.3.9-alpha

4 months ago

1.3.8-alpha

4 months ago

1.3.7-alpha

4 months ago

1.3.6-alpha

5 months ago

1.3.5-alpha

5 months ago

1.3.4-alpha

6 months ago

1.3.3-alpha

6 months ago

1.3.2-alpha

6 months ago

1.3.1-alpha

6 months ago

1.3.0-alpha

6 months ago

1.2.7-alpha

6 months ago

1.2.6-alpha

6 months ago

1.2.5-alpha

6 months ago

1.2.4-alpha

6 months ago

1.2.3-alpha

6 months ago

1.2.2-alpha

6 months ago

1.2.1-alpha

6 months ago

1.2.0-alpha

6 months ago

1.1.9-alpha

6 months ago

1.1.8-alpha

6 months ago

1.1.7-alpha

6 months ago

1.1.6-alpha

6 months ago

1.1.5-alpha

6 months ago

1.1.4-alpha

6 months ago

1.1.3-alpha

6 months ago

1.1.2-alpha

6 months ago

1.1.1-alpha

6 months ago

1.1.0-alpha

6 months ago

1.0.9-alpha

6 months ago

1.0.8-alpha

6 months ago

1.0.7-alpha

6 months ago

1.0.6-alpha

6 months ago

1.0.5-alpha

6 months ago

1.0.4-alpha

6 months ago

1.0.2-alpha

6 months ago

1.0.1-alpha

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago