1.0.6 β€’ Published 5 months ago

craft-table-listing v1.0.6

Weekly downloads
-
License
-
Repository
-
Last release
5 months ago

πŸ“¦ Installation

To use craft-table, install it along with its peer dependencies:

npm install craft-table @tanstack/react-table

Craft Table

craft-table is a highly customizable React table component built on top of TanStack Table. It provides powerful table functionality with features for server-side processing, column management, and additional UI enhancements.

We highly recommend providing a max-height in your CSS for the class ts__table__wrapper, tailored to your requirements, to ensure the best experience.

πŸš€ Features

craft-table supports a wide range of features out of the box:

Core Features

  • Striped layout
  • Compact mode
  • Custom Nested Component.
  • In-built default loader as well as custom loader option.
  • Custom hook that provides all the states of table, for e.g. pagination page size (useCraftTable).
  • Fullscreen mode to focus only on Table contents.
  • Word break all for table content.
  • Column content alignment.

TanStack Table Features

  • Sorting
  • Server Side Sorting
  • Pagination
  • Server Side Pagination
  • Column Reordering (Drag and Drop)
  • Column Sizing
  • Column Resizing
  • Column Pinning
  • Row Selection
  • Toggle column on and off (required Topbar)

πŸ›  Usage

Here’s an example of how to use craft-table:

import TableWrapper from 'craft-table';

const newData = [
  { id: 1, name: 'John Doe', age: 28 },
  { id: 2, name: 'Jane Doe', age: 34 },
  ];

const defaultColumns = [
  { accessorKey: 'id', header: 'ID' },
  { accessorKey: 'name', header: 'Name' },
  { accessorKey: 'age', header: 'Age' },
  ];

export default function App() {
  return (
    <TableWrapper
      data={newData}
      columns={defaultColumns}
      featureOptions={{
        striped: true,
        enableColumnReordering: true,
        enableColumnPinning: true,
      }}
      loadingOptions={{
        isLoading: false,
        loaderText: "Loading...",
      }}
    />
  );
}

πŸ”§ API Reference

CraftTable

Props

PropTypeDescription
dataArrayThe data to be displayed in the table.
columnsArrayColumn definitions, compatible with TanStack Table.
featureOptionsCraftTableFeaturePropsObject containing feature flags for enabling/disabling specific functionalities.
loadingOptionsLoadingOptionsObject for controlling loading behavior.

CraftTableFeatureProps

FeatureTypeDefaultDescription
enableSortingbooleantrueEnables client-side sorting.
enableServerSideSortingbooleanfalseEnables server-side sorting.
enableServerSidePaginationbooleanfalseEnables server-side pagination.
enableRowSelectionbooleantrueEnables row selection functionality.
enableColumnResizingbooleantrueAllows columns to be resized by dragging.
enableColumnReorderingbooleanfalseAllows columns to be reordered via drag-and-drop.
enableColumnPinningbooleanfalseEnables pinning columns to the left or right of the table.
enableTopbarbooleantrueEnables a custom topbar for the table.
enableWordBreakAllbooleanfalseApplies word-break: break-all to prevent text overflow.
stickyHeaderbooleantrueMakes the table header sticky when scrolling vertically.
compactTablebooleanfalseReduces row height for a compact layout.
stripedbooleanfalseAdds striped row styling for better readability.

LoadingOptions

OptionTypeDefaultDescription
isLoadingbooleanfalseWhether the table is in a loading state.
loaderTextstring"Loading..."Text to display when loading.
loadingComponentReactNodeundefinedCustom loading component to render.

πŸ“˜ Documentation

For detailed documentation and examples, visit the TanStack Table Docs.

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago