luxtable 0.3.4 → 0.3.6

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 CHANGED
@@ -12,12 +12,14 @@ LuxTable is a high-performance, feature-rich data grid library designed specific
12
12
 
13
13
  - ⚡ **High-Velocity Performance** - Optimized rendering engine capable of handling massive datasets with 60fps fluidity
14
14
  - 🎨 **Shadcn-Native Design** - Crafted with Tailwind CSS and Radix UI primitives
15
+ - 🚀 **Zero-Config Magic** - Auto-generate columns from data, auto-detect cell types by field names
15
16
  - 🔍 **Advanced Filtering** - Column-level filters with multiple filter types (text, number, select)
16
- - 🔄 **Smart Sorting** - Multi-column sorting with intuitive click interactions
17
+ - 🔄 **Smart Sorting** - Multi-column sorting with Shift+Click support
17
18
  - ✅ **Row Selection** - Single and multi-select with checkbox support
18
19
  - 📄 **Pagination** - Built-in pagination with customizable page sizes
19
20
  - 🛠️ **Column Actions** - Hide/show columns, sorting controls in a unified dropdown
20
21
  - 🔎 **Global Search** - Search across all columns instantly
22
+ - 🎯 **Auto Cell Detection** - Automatically detects and renders status, date, currency, boolean, and copyable fields
21
23
  - 🔒 **Type-Safe Excellence** - First-class TypeScript support with full type inference
22
24
  - 📱 **Fully Responsive** - Adaptive layouts from ultra-wide monitors to mobile screens
23
25
 
@@ -77,8 +79,63 @@ yarn add luxtable
77
79
 
78
80
  ### Basic Usage
79
81
 
82
+ #### Zero-Config: Auto-Generated Columns
83
+
84
+ LuxTable can automatically generate columns from your data - no column definitions needed!
85
+
86
+ ```tsx
87
+ import { LuxTable } from "luxtable";
88
+
89
+ type User = {
90
+ id: number;
91
+ name: string;
92
+ email: string;
93
+ status: "active" | "inactive" | "pending";
94
+ joinDate: string;
95
+ salary: number;
96
+ };
97
+
98
+ const data: User[] = [
99
+ { id: 1, name: "John Doe", email: "john@example.com", status: "active", joinDate: "2024-01-15", salary: 75000 },
100
+ { id: 2, name: "Jane Smith", email: "jane@example.com", status: "active", joinDate: "2024-02-20", salary: 65000 },
101
+ // ... more data
102
+ ];
103
+
104
+ export default function App() {
105
+ return (
106
+ <LuxTable
107
+ data={data}
108
+ options={{
109
+ pagination: true,
110
+ filtering: true,
111
+ sorting: true,
112
+ multiSort: true, // Shift+Click to sort by multiple columns
113
+ selection: "multiple",
114
+ showToolbar: true,
115
+ showGlobalSearch: true,
116
+ showColumnVisibility: true,
117
+ }}
118
+ />
119
+ );
120
+ }
121
+ ```
122
+
123
+ **What happens automatically:**
124
+ - ✅ Columns are auto-generated from data keys
125
+ - ✅ Headers are auto-formatted (camelCase → Title Case)
126
+ - ✅ Cell types are auto-detected:
127
+ - `status` → StatusCell (colored badges)
128
+ - `joinDate`, `createdAt` → DateCell (formatted dates)
129
+ - `salary`, `price` → CurrencyCell (formatted currency)
130
+ - `id`, `email` → CopyableCell (click to copy)
131
+ - Boolean fields → BooleanCell (Yes/No)
132
+
133
+ #### Manual Column Definitions
134
+
135
+ You can also define columns manually for full control:
136
+
80
137
  ```tsx
81
- import { LuxTable } from "@/components/lux-table/lux-table";
138
+ import { LuxTable, createColumnHelper } from "luxtable";
82
139
  import { ColumnDef } from "@tanstack/react-table";
83
140
 
84
141
  type User = {
@@ -88,23 +145,22 @@ type User = {
88
145
  status: "active" | "inactive";
89
146
  };
90
147
 
148
+ const columnHelper = createColumnHelper<User>();
149
+
91
150
  const columns: ColumnDef<User>[] = [
92
- {
93
- accessorKey: "id",
151
+ columnHelper.accessor("id", {
94
152
  header: "ID",
95
- },
96
- {
97
- accessorKey: "name",
153
+ size: 80,
154
+ }),
155
+ columnHelper.accessor("name", {
98
156
  header: "Name",
99
- },
100
- {
101
- accessorKey: "email",
157
+ }),
158
+ columnHelper.accessor("email", {
102
159
  header: "Email",
103
- },
104
- {
105
- accessorKey: "status",
160
+ }),
161
+ columnHelper.accessor("status", {
106
162
  header: "Status",
107
- },
163
+ }),
108
164
  ];
109
165
 
110
166
  const data: User[] = [
@@ -130,52 +186,132 @@ export default function App() {
130
186
 
131
187
  ## 📦 Cell Renderers
132
188
 
133
- LuxTable comes with built-in cell renderers for common use cases:
189
+ LuxTable comes with built-in cell renderers that are automatically applied based on field names and values. You can also use them manually:
134
190
 
135
- ```tsx
136
- import { StatusCell, ProgressCell, DateCell, CopyableCell } from "@/components/lux-table/cell-renderers";
191
+ ### Available Cell Renderers
137
192
 
138
- // Status badges
139
- {
140
- accessorKey: "status",
141
- header: "Status",
142
- cell: ({ row }) => <StatusCell value={row.getValue("status")} />,
143
- }
193
+ - **StatusCell** - Colored status badges (Active, Pending, etc.)
194
+ - **ProgressCell** - Progress bars with percentage
195
+ - **DateCell** - Formatted dates (short, long, relative)
196
+ - **CurrencyCell** - Formatted currency values
197
+ - **BooleanCell** - Yes/No indicators
198
+ - **CopyableCell** - Click-to-copy text with icon
144
199
 
145
- // Progress bars
146
- {
147
- accessorKey: "progress",
148
- header: "Progress",
149
- cell: ({ row }) => <ProgressCell value={row.getValue("progress")} />,
150
- }
200
+ ### Auto-Detection
151
201
 
152
- // Formatted dates
153
- {
154
- accessorKey: "createdAt",
155
- header: "Created",
156
- cell: ({ row }) => <DateCell value={row.getValue("createdAt")} />,
157
- }
202
+ Cell renderers are automatically applied based on field names:
158
203
 
159
- // Copy to clipboard
204
+ ```tsx
205
+ // These fields are auto-detected and rendered:
160
206
  {
161
- accessorKey: "id",
162
- header: "ID",
163
- cell: ({ row }) => <CopyableCell value={row.getValue("id")} />,
207
+ status: "active", // → StatusCell (colored badge)
208
+ joinDate: "2024-01-15", // → DateCell (formatted date)
209
+ salary: 75000, // CurrencyCell (formatted currency)
210
+ isActive: true, // → BooleanCell (Yes/No)
211
+ id: "123", // → CopyableCell (click to copy)
164
212
  }
165
213
  ```
166
214
 
215
+ ### Manual Usage
216
+
217
+ You can also use cell renderers manually in column definitions:
218
+
219
+ ```tsx
220
+ import { StatusCell, ProgressCell, DateCell, CopyableCell, CurrencyCell, BooleanCell } from "luxtable";
221
+
222
+ const columns = [
223
+ {
224
+ accessorKey: "status",
225
+ header: "Status",
226
+ cell: ({ row }) => <StatusCell value={row.getValue("status")} />,
227
+ },
228
+ {
229
+ accessorKey: "progress",
230
+ header: "Progress",
231
+ cell: ({ row }) => <ProgressCell value={row.getValue("progress")} />,
232
+ },
233
+ {
234
+ accessorKey: "createdAt",
235
+ header: "Created",
236
+ cell: ({ row }) => <DateCell value={row.getValue("createdAt")} format="long" />,
237
+ },
238
+ {
239
+ accessorKey: "salary",
240
+ header: "Salary",
241
+ cell: ({ row }) => <CurrencyCell value={row.getValue("salary")} currency="USD" />,
242
+ },
243
+ {
244
+ accessorKey: "isActive",
245
+ header: "Active",
246
+ cell: ({ row }) => <BooleanCell value={row.getValue("isActive")} />,
247
+ },
248
+ {
249
+ accessorKey: "id",
250
+ header: "ID",
251
+ cell: ({ row }) => <CopyableCell value={String(row.getValue("id"))} />,
252
+ },
253
+ ];
254
+ ```
255
+
256
+ ### Custom Cell Configuration
257
+
258
+ You can customize auto-detection behavior using `cellConfig`:
259
+
260
+ ```tsx
261
+ <LuxTable
262
+ data={data}
263
+ cellConfig={{
264
+ // Custom field configurations
265
+ fields: {
266
+ customStatus: { type: "status" },
267
+ customDate: { type: "date", format: "long" },
268
+ },
269
+ // Custom auto-detection patterns
270
+ patterns: {
271
+ status: ["status", "state", "customStatus"],
272
+ date: ["date", "createdAt", "customDate"],
273
+ },
274
+ // Default status colors
275
+ defaultStatusColors: {
276
+ active: { bg: "bg-green-100", text: "text-green-800" },
277
+ pending: { bg: "bg-yellow-100", text: "text-yellow-800" },
278
+ },
279
+ }}
280
+ />
281
+ ```
282
+
167
283
  ## 🎯 Options
168
284
 
169
285
  | Option | Type | Default | Description |
170
286
  |--------|------|---------|-------------|
171
287
  | `pagination` | `boolean` | `false` | Enable/disable pagination |
172
288
  | `pageSize` | `number` | `10` | Default rows per page |
289
+ | `sorting` | `boolean` | `true` | Enable/disable column sorting |
290
+ | `multiSort` | `boolean` | `true` | Enable multi-column sorting (Shift+Click) |
291
+ | `maxMultiSortColCount` | `number` | `undefined` | Maximum columns for multi-sort (unlimited by default) |
173
292
  | `filtering` | `boolean` | `false` | Enable column-level filtering |
174
293
  | `selection` | `"single" \| "multiple" \| "none"` | `"none"` | Row selection mode |
294
+ | `showSelectionCheckbox` | `boolean` | `true` | Show selection checkbox (when selection is enabled) |
175
295
  | `showToolbar` | `boolean` | `false` | Show toolbar with search and column visibility |
176
296
  | `showGlobalSearch` | `boolean` | `true` | Show global search in toolbar |
177
297
  | `showColumnVisibility` | `boolean` | `true` | Show column visibility controls |
178
298
 
299
+ ### Props
300
+
301
+ | Prop | Type | Description |
302
+ |------|------|-------------|
303
+ | `data` | `TData[]` | Table data (required) |
304
+ | `columns` | `ColumnDef<TData>[]` | Column definitions (optional - auto-generated if not provided) |
305
+ | `options` | `LuxTableOptions` | Table options (see above) |
306
+ | `cellConfig` | `GlobalCellConfig` | Custom cell configuration for auto-detection |
307
+ | `sorting` | `SortingState` | Controlled sorting state |
308
+ | `onSortingChange` | `(sorting: SortingState) => void` | Called when sorting changes |
309
+ | `rowSelection` | `RowSelectionState` | Controlled row selection state |
310
+ | `onRowSelectionChange` | `(selection: RowSelectionState) => void` | Called when row selection changes |
311
+ | `onSelectedRowsChange` | `(rows: TData[]) => void` | Called when selected rows change (with row data) |
312
+ | `getRowId` | `(row: TData, index: number) => string` | Custom row ID function (default: uses "id" field or index) |
313
+ | `className` | `string` | Additional CSS classes |
314
+
179
315
  ## 🛠 Tech Stack
180
316
 
181
317
  - **Core**: React & TanStack Table
@@ -185,7 +321,9 @@ import { StatusCell, ProgressCell, DateCell, CopyableCell } from "@/components/l
185
321
 
186
322
  ## 📖 Documentation
187
323
 
188
- Visit our [documentation](https://luxtable.dev/docs) for detailed guides and examples.
324
+ - **Usage Guide**: See [USAGE.md](./USAGE.md) for detailed setup and examples
325
+ - **Examples**: See [EXAMPLE.md](./EXAMPLE.md) for quick start guide
326
+ - **Full Documentation**: Visit [https://luxtable.dev/docs](https://luxtable.dev/docs) for complete API reference
189
327
 
190
328
  ## 💡 Why LuxTable?
191
329