lite-table-js-v2 1.0.1

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/README.md ADDED
@@ -0,0 +1,205 @@
1
+ # lite-table-js
2
+
3
+ A high-performance, feature-rich React data table component library inspired by AG Grid and MUI DataGrid.
4
+
5
+ ## Features
6
+
7
+ - **Dynamic column configuration** with custom renderers
8
+ - **Sorting** — single and multi-column
9
+ - **Filtering** — column-level (text, number, select, date) and global search
10
+ - **Pagination** — client-side and server-side
11
+ - **Row selection** — single, multiple, select-all with indeterminate state
12
+ - **Inline editing** — double-click to edit, custom editors
13
+ - **Column resizing** — drag column borders
14
+ - **Column reordering** — drag-and-drop headers
15
+ - **Virtual scrolling** — render thousands of rows efficiently
16
+ - **Theming** — CSS custom properties for full style control
17
+ - **Row expansion** — expandable detail rows
18
+ - **CSV export** — one-click data export
19
+ - **Footer aggregation** — column footers with custom renderers
20
+ - **Status bar** — row count, selection count, active filters
21
+ - **TypeScript** — full type definitions
22
+ - **Tree-shakeable** — modular hooks + components
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ npm install lite-table-js
28
+ ```
29
+
30
+ ## Quick Start
31
+
32
+ ```tsx
33
+ import { DataTable, ColumnDef } from 'lite-table-js';
34
+ import 'lite-table-js/dist/styles.css';
35
+
36
+ interface User {
37
+ id: number;
38
+ name: string;
39
+ email: string;
40
+ age: number;
41
+ }
42
+
43
+ const columns: ColumnDef<User>[] = [
44
+ { id: 'name', header: 'Name', accessor: 'name', sortable: true },
45
+ { id: 'email', header: 'Email', accessor: 'email', sortable: true },
46
+ { id: 'age', header: 'Age', accessor: 'age', sortable: true, align: 'right' },
47
+ ];
48
+
49
+ const data: User[] = [
50
+ { id: 1, name: 'Alice', email: 'alice@example.com', age: 30 },
51
+ { id: 2, name: 'Bob', email: 'bob@example.com', age: 25 },
52
+ ];
53
+
54
+ function App() {
55
+ return (
56
+ <DataTable
57
+ columns={columns}
58
+ data={data}
59
+ rowKey="id"
60
+ sortable
61
+ filterable
62
+ paginated
63
+ selectionMode="multiple"
64
+ />
65
+ );
66
+ }
67
+ ```
68
+
69
+ ## Props
70
+
71
+ | Prop | Type | Default | Description |
72
+ |------|------|---------|-------------|
73
+ | `columns` | `ColumnDef<T>[]` | required | Column definitions |
74
+ | `data` | `T[]` | required | Data rows |
75
+ | `rowKey` | `keyof T \| (row: T) => string` | required | Unique row identifier |
76
+ | `sortable` | `boolean` | `false` | Enable sorting |
77
+ | `multiSort` | `boolean` | `false` | Enable multi-column sort |
78
+ | `filterable` | `boolean` | `false` | Enable column filters |
79
+ | `globalFilterEnabled` | `boolean` | `false` | Enable global search |
80
+ | `paginated` | `boolean` | `false` | Enable pagination |
81
+ | `pageSizeOptions` | `number[]` | `[10,25,50,100]` | Page size options |
82
+ | `selectionMode` | `'none'\|'single'\|'multiple'` | `'none'` | Row selection mode |
83
+ | `editable` | `boolean` | `false` | Enable inline editing |
84
+ | `columnResizing` | `boolean` | `false` | Enable column resize |
85
+ | `columnReordering` | `boolean` | `false` | Enable column reorder |
86
+ | `virtualScrolling` | `boolean` | `false` | Enable virtual scroll |
87
+ | `rowHeight` | `number` | `42` | Row height (px) |
88
+ | `theme` | `DataTableTheme` | — | Theme overrides |
89
+ | `striped` | `boolean` | `false` | Alternating row colors |
90
+ | `dense` | `boolean` | `false` | Compact mode |
91
+ | `bordered` | `boolean` | `true` | Show cell borders |
92
+ | `loading` | `boolean` | `false` | Show loading overlay |
93
+ | `exportable` | `boolean` | `false` | Show CSV export button |
94
+ | `expandable` | `boolean` | `false` | Enable row expansion |
95
+ | `showFooter` | `boolean` | `false` | Show footer row |
96
+ | `showStatusBar` | `boolean` | `false` | Show status bar |
97
+
98
+ ## Column Definition
99
+
100
+ ```ts
101
+ interface ColumnDef<T> {
102
+ id: string; // Unique column ID
103
+ header: string | ReactNode; // Header content
104
+ accessor: keyof T | (row: T) => any; // Data accessor
105
+ cell?: (value, row, index) => ReactNode; // Custom cell renderer
106
+ width?: number; // Column width
107
+ minWidth?: number; // Min width for resize
108
+ maxWidth?: number; // Max width for resize
109
+ sortable?: boolean; // Enable sorting
110
+ filterable?: boolean; // Enable filtering
111
+ editable?: boolean; // Enable inline edit
112
+ resizable?: boolean; // Enable resize
113
+ align?: 'left' | 'center' | 'right';
114
+ filterType?: 'text' | 'number' | 'select' | 'date';
115
+ filterOptions?: { label: string; value: any }[];
116
+ footer?: string | (rows: T[]) => ReactNode;
117
+ pinned?: 'left' | 'right' | false;
118
+ }
119
+ ```
120
+
121
+ ## Custom Cell Renderer
122
+
123
+ ```tsx
124
+ const columns: ColumnDef<User>[] = [
125
+ {
126
+ id: 'status',
127
+ header: 'Status',
128
+ accessor: 'status',
129
+ cell: (value) => (
130
+ <span style={{ color: value === 'Active' ? 'green' : 'red' }}>
131
+ {value}
132
+ </span>
133
+ ),
134
+ },
135
+ ];
136
+ ```
137
+
138
+ ## Server-Side Data
139
+
140
+ ```tsx
141
+ <DataTable
142
+ columns={columns}
143
+ data={[]}
144
+ rowKey="id"
145
+ serverSide={{
146
+ getRows: async ({ page, pageSize, sortModel, filterModel }) => {
147
+ const res = await fetch(`/api/users?page=${page}&size=${pageSize}`);
148
+ const json = await res.json();
149
+ return { rows: json.data, totalRows: json.total };
150
+ },
151
+ }}
152
+ paginated
153
+ sortable
154
+ />
155
+ ```
156
+
157
+ ## Theming
158
+
159
+ ```tsx
160
+ <DataTable
161
+ theme={{
162
+ primaryColor: '#6366f1',
163
+ headerBg: '#1e1b4b',
164
+ headerColor: '#e0e7ff',
165
+ rowHoverBg: '#eef2ff',
166
+ borderRadius: '8px',
167
+ }}
168
+ // ...
169
+ />
170
+ ```
171
+
172
+ ## Using Hooks Independently
173
+
174
+ All hooks are exported for custom table implementations:
175
+
176
+ ```tsx
177
+ import { useSort, useFilter, usePagination, useSelection } from 'lite-table-js';
178
+
179
+ function CustomTable({ data, columns }) {
180
+ const { sortedData, toggleSort } = useSort({ columns, data });
181
+ const { filteredData, setColumnFilter } = useFilter({ columns, data: sortedData });
182
+ const { paginatedData, pagination } = usePagination({ data: filteredData });
183
+ // Build your own UI...
184
+ }
185
+ ```
186
+
187
+ ## Scripts
188
+
189
+ ```bash
190
+ npm run build # Build the package
191
+ npm run test # Run tests
192
+ npm run storybook # Launch Storybook
193
+ npm run build-storybook # Build Storybook
194
+ ```
195
+
196
+ ## Build & Publish
197
+
198
+ ```bash
199
+ npm run build
200
+ npm publish
201
+ ```
202
+
203
+ ## License
204
+
205
+ MIT