Skip to content

Commit 0b741d4

Browse files
committed
Base setup for tanstack table wrapper
1 parent 19fa2c5 commit 0b741d4

38 files changed

+11491
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

.storybook/main.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { StorybookConfig } from "@storybook/react-vite";
2+
3+
const config: StorybookConfig = {
4+
stories: ["../stories/*.mdx", "../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
5+
addons: ["@storybook/addon-docs"],
6+
framework: {
7+
name: "@storybook/react-vite",
8+
options: {},
9+
},
10+
};
11+
export default config;

.storybook/preview.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { Preview } from "@storybook/react-vite";
2+
import "../stories/tailwind.css";
3+
4+
const preview: Preview = {
5+
parameters: {
6+
controls: {
7+
matchers: {
8+
color: /(background|color)$/i,
9+
date: /Date$/i,
10+
},
11+
},
12+
},
13+
};
14+
15+
export default preview;

README.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# TableAdapter
2+
3+
A powerful, flexible, and feature-rich React table component built on top of [TanStack Table (React Table v8)](https://tanstack.com/table/v8). Designed for both client-side and server-side data, TableAdapter provides advanced features like pagination, sorting, filtering, row selection, column resizing, and more, with a simple and customizable API.
4+
5+
[![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](./LICENSE)
6+
7+
---
8+
9+
## Features
10+
11+
- **Client-side & server-side** pagination, sorting, filtering, and grouping
12+
- **Row selection**, expansion, pinning, and grouping
13+
- **Column resizing**, ordering, and visibility toggles
14+
- **Custom renderers** for headers, footers, cells, pagination, and more
15+
- **Loading states** and customizable loading components
16+
- **Accessibility**: ARIA labels and keyboard navigation
17+
- **TypeScript** support with strong generics
18+
- **Export to CSV** utility
19+
- **Tailwind CSS**-friendly by default
20+
21+
---
22+
23+
## Installation
24+
25+
```bash
26+
npm install @TechFusionMasters/tanstack-table-adapter
27+
```
28+
29+
Or with yarn:
30+
31+
```bash
32+
yarn add @TechFusionMasters/tanstack-table-adapter
33+
```
34+
35+
---
36+
37+
## Usage
38+
39+
```tsx
40+
import React from "react";
41+
import { TableAdapter } from "@TechFusionMasters/tanstack-table-adapter";
42+
43+
const columns = [
44+
{ accessorKey: "id", header: "ID" },
45+
{ accessorKey: "name", header: "Name" },
46+
{ accessorKey: "age", header: "Age" },
47+
];
48+
49+
const data = [
50+
{ id: 1, name: "Alice", age: 25 },
51+
{ id: 2, name: "Bob", age: 30 },
52+
{ id: 3, name: "Charlie", age: 22 },
53+
];
54+
55+
export default function App() {
56+
return (
57+
<TableAdapter
58+
data={data}
59+
columns={columns}
60+
enablePagination
61+
enableSorting
62+
className="w-full max-w-2xl"
63+
/>
64+
);
65+
}
66+
```
67+
68+
---
69+
70+
## API
71+
72+
### `<TableAdapter />` Props
73+
74+
#### Core
75+
76+
- `data`: Array of row objects
77+
- `columns`: Array of column definitions ([TanStack Table ColumnDef](https://tanstack.com/table/v8/docs/api/core/column-def))
78+
- `totalRowCount?`: For server-side pagination
79+
- `id?`, `debugTable?`, `getRowId?`
80+
81+
#### Features
82+
83+
- `enablePagination?`, `enableSorting?`, `enableMultiSort?`, `enableColumnFilters?`, `enableGlobalFilter?`, `enableColumnResizing?`, `enableRowSelection?`, `enableExpanding?`, `enablePinning?`, `enableStickyHeader?`, `enableGrouping?`
84+
85+
#### State & Control
86+
87+
- `pageSize?`, `pageIndex?`, `sorting?`, `columnFilters?`, `globalFilter?`, `columnVisibility?`, `rowSelection?`, `expanded?`, `columnOrder?`, `columnPinning?`, `grouping?`
88+
- `onPaginationChange?`, `onSortingChange?`, `onColumnFiltersChange?`, `onGlobalFilterChange?`, `onColumnVisibilityChange?`, `onRowSelectionChange?`, `onExpandedChange?`, `onColumnOrderChange?`, `onColumnPinningChange?`, `onGroupingChange?`
89+
90+
#### Advanced
91+
92+
- `manualPagination?`, `manualSorting?`, `manualFiltering?`, `manualGrouping?`, `pageCount?`, `autoResetPageIndex?`, `globalFilterFn?`
93+
94+
#### Custom Renderers
95+
96+
- `renderTableHeader?`, `renderTableFooter?`, `renderPagination?`, `renderNoResults?`, `renderExpanded?`, `renderRowSubComponent?`, `renderGroupedCell?`, `renderSortIcon?`
97+
98+
#### Events
99+
100+
- `onRowClick?`, `onCellClick?`, `onExportData?`
101+
102+
#### Loading & Accessibility
103+
104+
- `isLoading?`, `isPaginationLoading?`, `loadingComponent?`, `paginationLoadingComponent?`, `showOverlayLoading?`
105+
- `ariaLabel?`, `ariaLabelledBy?`, `ariaDescribedBy?`
106+
107+
#### Styling
108+
109+
- `className?`, `tableClassName?`, `headerClassName?`, `bodyClassName?`, `rowClassName?`, `cellClassName?`, `columnResizeMode?`, `pageSizeOptions?`, `enableSortingRemoval?`
110+
111+
---
112+
113+
## Utilities & Helpers
114+
115+
- `exportToCSV(data, columns, filename?)`: Export table data to CSV
116+
- `fuzzyFilter`: Fuzzy text filter function for global/column filtering
117+
- `GlobalFilterInput`: Ready-to-use global filter input component
118+
- `ColumnVisibilityToggle`: UI for toggling column visibility
119+
120+
---
121+
122+
## Customization
123+
124+
- **Custom loading, pagination, and no-results components** can be provided via props
125+
- **Full control** over table state (controlled/uncontrolled)
126+
- **Composable** with your own UI and TanStack Table plugins
127+
128+
---
129+
130+
## License
131+
132+
MIT © 2025 TechFusionMasters

0 commit comments

Comments
 (0)