Skip to content

A react library for rendering highly configurable tables.

Notifications You must be signed in to change notification settings

zendricom/tableus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tableus

A react library for rapidly building highly configurable tables flawlessly integrated with your backend

Summary

Tableus offers a configurable out-of-the-box react table. It is intended to be integrated fully with your backend to deliver tables with sorting, filtering and pagination. Tableus does not state any requirements on your preferred UI (bootstrap, material UI, etc.) or backend API (REST, GraphQL, etc.), by externalizing those into seperate modules called fetchers and UIs.
If your UI and backend API are already available as a package, then you are ready to go to create complex tables with minimal effort and zero boilerplate. Tableus is built on top of Tanstack Table and often the API is the same. If you are already familiar with Tanstack Table (formerly React Table), then you will feel familiar with Tableus fast!

Available Fetchers & UIs

Fetchers

UIs

Installation

npm install @tableus/core
npm install @tableus/fetcher-[your-preferred-fetcher]
npm install @tableus/ui-[your-preferred-ui]```

Requirements

  • Your preferred UI has to be available as a package. If not you have to implement a tableus-ui yourself. Look here on how to do that.
  • Your backend API has to be compatible with one of the available fetchers. If not you have to implement a tableus-fetcher yourself. Look here on how to do that.
  • You have to provide a QueryClient from react-query in your App, as tableus uses react-query under the hood to improve performance.

Quick Start

  1. Provide a project-wide TableusConfig with the TableusContextProvider, where you specify your UI. Also be sure that a react-query QueryClient is provided .
import { initTableComponents } from '@tableus/ui-bootstrap5';
import { TableusConfig } from '@tableus/core/dist/context';
import { TableusContextProvider } from '@tableus/core';
import { QueryClient, QueryClientProvider } from 'react-query';

const tableusConfig: TableusConfig = {
  tableUI: initTableComponents(),
};

const queryClient = new QueryClient();

export function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <TableusContextProvider config={tableusConfig}>
        {...}
      </TableusContextProvider>
    </QueryClientProvider>
  );
}
  1. Init the table object and pass the type data that the table will display.
const table = createTable<TableEntry>();
  1. Specify the columns of your table.
const columns = [
  table.createDataColumn("id", {
    header: "ID",
  }),
  table.createDataColumn(
    (row) => `${row.user.firstname} ${row.user.lastname}`,
    {
      id: "name",
      header: "Name",
    }
  ),
];
  1. Initialize your fetcher. E.g. here we use a REST fetcher. The url /users should return an array of users in the format expected by the LaravelRestFetcher, where each entry is of the form of TableEntry.
const fetcher = new LaravelRestFetcher<TableEntry>("/users");
  1. Call useTableus.
const { tableusProps } = useTableus(table, {
  columns,
  fetcher,
  key: "users",
});
  1. Render Tableus
<Tableus {...tableusProps} />
  1. Done!

About

A react library for rendering highly configurable tables.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published