@structyl/data-table 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 your-lib contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # @structyl/data-table
2
+
3
+ > The first-class React DataTable that structyl ships and Radix-style libraries leave out.
4
+
5
+ ![npm](https://img.shields.io/npm/v/@structyl/data-table)
6
+ ![license](https://img.shields.io/npm/l/@structyl/data-table)
7
+
8
+ A full-featured, type-safe React DataTable built on [`@tanstack/react-table`](https://tanstack.com/table) and rendered with structyl's accessible primitives and Tailwind CSS v4 styled layer. It pairs a rich, GUI-grid-style column API with row/column virtualization for large datasets and a server-side adapter for sorting, filtering, and pagination handled by your backend. It is the data-grid building block of the [structyl](https://github.com/imirfanul/structyl) component library.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ # pnpm
14
+ pnpm add @structyl/data-table
15
+
16
+ # npm
17
+ npm install @structyl/data-table
18
+
19
+ # yarn
20
+ yarn add @structyl/data-table
21
+ ```
22
+
23
+ `react` and `react-dom` (v18 or v19) are required peer dependencies.
24
+
25
+ ## Usage
26
+
27
+ ```tsx
28
+ import { DataTable, type DataTableColumnDef } from '@structyl/data-table';
29
+
30
+ type Invoice = {
31
+ id: string;
32
+ customer: string;
33
+ amount: number;
34
+ status: 'paid' | 'pending' | 'overdue';
35
+ };
36
+
37
+ const columns: DataTableColumnDef<Invoice>[] = [
38
+ { field: 'customer', headerName: 'Customer' },
39
+ { field: 'amount', headerName: 'Amount', type: 'currency', currencyCode: 'USD', align: 'right' },
40
+ {
41
+ field: 'status',
42
+ headerName: 'Status',
43
+ type: 'badge',
44
+ badgeMap: {
45
+ paid: { label: 'Paid', color: '#16a34a' },
46
+ pending: { label: 'Pending', color: '#d97706' },
47
+ overdue: { label: 'Overdue', color: '#dc2626' },
48
+ },
49
+ },
50
+ ];
51
+
52
+ const data: Invoice[] = [
53
+ { id: '1', customer: 'Acme Corp', amount: 1299.0, status: 'paid' },
54
+ { id: '2', customer: 'Globex', amount: 540.5, status: 'pending' },
55
+ { id: '3', customer: 'Initech', amount: 89.99, status: 'overdue' },
56
+ ];
57
+
58
+ export function InvoicesTable() {
59
+ return (
60
+ <DataTable
61
+ columns={columns}
62
+ data={data}
63
+ enableSorting
64
+ enableFiltering
65
+ enableGlobalSearch
66
+ enablePagination
67
+ enableRowSelection
68
+ pageSize={10}
69
+ />
70
+ );
71
+ }
72
+ ```
73
+
74
+ ### Server-side data
75
+
76
+ When you provide a `serverSide` adapter, the table delegates sorting, filtering, and pagination to your backend and renders the rows you return:
77
+
78
+ ```tsx
79
+ <DataTable
80
+ columns={columns}
81
+ data={rows}
82
+ serverSide={{
83
+ state: serverState,
84
+ onStateChange: setServerState,
85
+ rowCount: totalRowCount,
86
+ }}
87
+ enableSorting
88
+ enablePagination
89
+ />
90
+ ```
91
+
92
+ ## Features
93
+
94
+ - **Sorting & multi-sort** with header indicators, plus client- or server-side modes.
95
+ - **Filtering** — per-column filters, a global search box, and an advanced filter builder with grouped logic and operators.
96
+ - **Virtualization** — row (`virtual`) and column (`virtualColumns`) virtualization via `@tanstack/react-virtual` for large grids.
97
+ - **Server-side adapter** — offload sort/filter/pagination to your API through the `serverSide` prop.
98
+ - **Rich column types** — currency, badge, link, avatar, sparkline, progress, rating, date/datetime, and custom `renderCell`/`renderHeader`.
99
+ - **Column management** — resize, reorder, pin, hide, auto-size, and a full column configuration panel.
100
+ - **Row capabilities** — selection (single/multi), expanding/detail panels, grouping, tree data, reordering, pinning, and row numbers.
101
+ - **Inline editing** — editable cells with value getters/setters and validation.
102
+ - **Aggregations & totals** — column totals, row totals, and pivot configuration.
103
+ - **Bulk & row actions** — bulk-action bar, row action menus and inline buttons, and a configurable toolbar.
104
+ - **Export** — `exportToCSV`, `exportToJSON`, and `exportToXLSX` helpers.
105
+ - **Density, copy/paste, and slots** — density toggle, TSV copy/paste, locale text, and overridable sub-components via `slots`.
106
+ - **Type-safe** — fully generic over your row type with first-class TypeScript types.
107
+
108
+ ## API
109
+
110
+ ### Components
111
+
112
+ | Export | Description |
113
+ | --- | --- |
114
+ | `DataTable` | The main table component (generic over `TData`). |
115
+ | `DataTableToolbar` / `DataTableToolbarButton` | Toolbar surface and action button. |
116
+ | `DataTableAdvancedFilter` | Grouped advanced filter builder. |
117
+ | `DataTableColumnFilter` | Per-column filter control. |
118
+ | `DataTableColumnVisibility` | Column show/hide menu. |
119
+ | `DataTableColumnConfiguration` | Full column configuration panel. |
120
+ | `DataTablePagination` | Pagination controls. |
121
+ | `EditableCell` | Inline-editable cell renderer. |
122
+
123
+ ### Utilities
124
+
125
+ | Export | Description |
126
+ | --- | --- |
127
+ | `exportToCSV` | Export rows to a CSV file. |
128
+ | `exportToJSON` | Export rows to a JSON file. |
129
+ | `exportToXLSX` | Export rows to an XLSX workbook. |
130
+ | `createColumnHelper` | Re-exported from `@tanstack/react-table` for typed column definitions. |
131
+
132
+ ### Types
133
+
134
+ Key exported types include `DataTableProps`, `DataTableColumnDef`, `DataTableColumn`, `DataTableColumnType`, `DataTableDensity`, `ServerData`, `ServerDataState`, `DataTableFilterGroup`, `DataTableBulkAction`, and `DataTableRowActionItem`. Core TanStack table types (`ColumnDef`, `SortingState`, `RowSelectionState`, `Table`, and more) are re-exported for convenience.
135
+
136
+ ## Part of structyl
137
+
138
+ This package is part of [structyl](https://github.com/imirfanul/structyl) — see the full documentation at [structyl.dev](https://structyl.dev).
139
+
140
+ ## License
141
+
142
+ MIT