luxtable 0.3.1 → 0.3.4

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/USAGE.md ADDED
@@ -0,0 +1,631 @@
1
+ # LuxTable Usage Guide
2
+
3
+ ## 🚀 Getting Started with Vite + React + TypeScript
4
+
5
+ This guide will walk you through setting up LuxTable in a new or existing Vite + React + TypeScript project.
6
+
7
+ ---
8
+
9
+ ## 📦 Installation
10
+
11
+ ### Option 1: New Project Setup
12
+
13
+ ```bash
14
+ # Create a new Vite project with React and TypeScript
15
+ npm create vite@latest my-app -- --template react-ts
16
+ cd my-app
17
+
18
+ # Install dependencies
19
+ npm install
20
+
21
+ # Install LuxTable
22
+ npm install luxtable
23
+
24
+ # Install TailwindCSS (required for styling)
25
+ npm install -D tailwindcss postcss autoprefixer
26
+ npx tailwindcss init -p
27
+ ```
28
+
29
+ ### Option 2: Existing Project
30
+
31
+ ```bash
32
+ # Install LuxTable
33
+ npm install luxtable
34
+ # or
35
+ pnpm add luxtable
36
+ # or
37
+ yarn add luxtable
38
+ ```
39
+
40
+ ---
41
+
42
+ ## ⚙️ Configuration
43
+
44
+ ### 1. Configure TailwindCSS
45
+
46
+ Update your `tailwind.config.js`:
47
+
48
+ ```js
49
+ /** @type {import('tailwindcss').Config} */
50
+ export default {
51
+ content: [
52
+ "./index.html",
53
+ "./src/**/*.{js,ts,jsx,tsx}",
54
+ // Include LuxTable components
55
+ "./node_modules/luxtable/**/*.{js,ts,jsx,tsx}",
56
+ ],
57
+ darkMode: "class",
58
+ theme: {
59
+ extend: {
60
+ colors: {
61
+ border: "hsl(var(--border))",
62
+ input: "hsl(var(--input))",
63
+ ring: "hsl(var(--ring))",
64
+ background: "hsl(var(--background))",
65
+ foreground: "hsl(var(--foreground))",
66
+ primary: {
67
+ DEFAULT: "hsl(var(--primary))",
68
+ foreground: "hsl(var(--primary-foreground))",
69
+ },
70
+ secondary: {
71
+ DEFAULT: "hsl(var(--secondary))",
72
+ foreground: "hsl(var(--secondary-foreground))",
73
+ },
74
+ destructive: {
75
+ DEFAULT: "hsl(var(--destructive))",
76
+ foreground: "hsl(var(--destructive-foreground))",
77
+ },
78
+ muted: {
79
+ DEFAULT: "hsl(var(--muted))",
80
+ foreground: "hsl(var(--muted-foreground))",
81
+ },
82
+ accent: {
83
+ DEFAULT: "hsl(var(--accent))",
84
+ foreground: "hsl(var(--accent-foreground))",
85
+ },
86
+ popover: {
87
+ DEFAULT: "hsl(var(--popover))",
88
+ foreground: "hsl(var(--popover-foreground))",
89
+ },
90
+ card: {
91
+ DEFAULT: "hsl(var(--card))",
92
+ foreground: "hsl(var(--card-foreground))",
93
+ },
94
+ },
95
+ borderRadius: {
96
+ lg: "var(--radius)",
97
+ md: "calc(var(--radius) - 2px)",
98
+ sm: "calc(var(--radius) - 4px)",
99
+ },
100
+ },
101
+ },
102
+ plugins: [],
103
+ }
104
+ ```
105
+
106
+ ### 2. Add CSS Variables
107
+
108
+ Add the following to your `src/index.css`:
109
+
110
+ ```css
111
+ @tailwind base;
112
+ @tailwind components;
113
+ @tailwind utilities;
114
+
115
+ @layer base {
116
+ :root {
117
+ --background: 0 0% 100%;
118
+ --foreground: 222.2 84% 4.9%;
119
+ --card: 0 0% 100%;
120
+ --card-foreground: 222.2 84% 4.9%;
121
+ --popover: 0 0% 100%;
122
+ --popover-foreground: 222.2 84% 4.9%;
123
+ --primary: 222.2 47.4% 11.2%;
124
+ --primary-foreground: 210 40% 98%;
125
+ --secondary: 210 40% 96.1%;
126
+ --secondary-foreground: 222.2 47.4% 11.2%;
127
+ --muted: 210 40% 96.1%;
128
+ --muted-foreground: 215.4 16.3% 46.9%;
129
+ --accent: 210 40% 96.1%;
130
+ --accent-foreground: 222.2 47.4% 11.2%;
131
+ --destructive: 0 84.2% 60.2%;
132
+ --destructive-foreground: 210 40% 98%;
133
+ --border: 214.3 31.8% 91.4%;
134
+ --input: 214.3 31.8% 91.4%;
135
+ --ring: 222.2 84% 4.9%;
136
+ --radius: 0.5rem;
137
+ }
138
+
139
+ .dark {
140
+ --background: 222.2 84% 4.9%;
141
+ --foreground: 210 40% 98%;
142
+ --card: 222.2 84% 4.9%;
143
+ --card-foreground: 210 40% 98%;
144
+ --popover: 222.2 84% 4.9%;
145
+ --popover-foreground: 210 40% 98%;
146
+ --primary: 210 40% 98%;
147
+ --primary-foreground: 222.2 47.4% 11.2%;
148
+ --secondary: 217.2 32.6% 17.5%;
149
+ --secondary-foreground: 210 40% 98%;
150
+ --muted: 217.2 32.6% 17.5%;
151
+ --muted-foreground: 215 20.2% 65.1%;
152
+ --accent: 217.2 32.6% 17.5%;
153
+ --accent-foreground: 210 40% 98%;
154
+ --destructive: 0 62.8% 30.6%;
155
+ --destructive-foreground: 210 40% 98%;
156
+ --border: 217.2 32.6% 17.5%;
157
+ --input: 217.2 32.6% 17.5%;
158
+ --ring: 212.7 26.8% 83.9%;
159
+ }
160
+ }
161
+
162
+ @layer base {
163
+ * {
164
+ @apply border-border;
165
+ }
166
+ body {
167
+ @apply bg-background text-foreground;
168
+ }
169
+ }
170
+ ```
171
+
172
+ ---
173
+
174
+ ## 📝 Basic Usage
175
+
176
+ ### Simple Table Example
177
+
178
+ ```tsx
179
+ // src/App.tsx
180
+ import { LuxTable, createColumnHelper } from 'luxtable';
181
+
182
+ // Define your data type
183
+ interface User {
184
+ id: number;
185
+ name: string;
186
+ email: string;
187
+ role: string;
188
+ status: 'Active' | 'Inactive';
189
+ }
190
+
191
+ // Sample data
192
+ const data: User[] = [
193
+ { id: 1, name: 'John Doe', email: 'john@example.com', role: 'Admin', status: 'Active' },
194
+ { id: 2, name: 'Jane Smith', email: 'jane@example.com', role: 'User', status: 'Active' },
195
+ { id: 3, name: 'Bob Johnson', email: 'bob@example.com', role: 'Editor', status: 'Inactive' },
196
+ ];
197
+
198
+ // Create column helper
199
+ const columnHelper = createColumnHelper<User>();
200
+
201
+ // Define columns
202
+ const columns = [
203
+ columnHelper.accessor('id', {
204
+ header: 'ID',
205
+ size: 80,
206
+ }),
207
+ columnHelper.accessor('name', {
208
+ header: 'Name',
209
+ }),
210
+ columnHelper.accessor('email', {
211
+ header: 'Email',
212
+ }),
213
+ columnHelper.accessor('role', {
214
+ header: 'Role',
215
+ }),
216
+ columnHelper.accessor('status', {
217
+ header: 'Status',
218
+ }),
219
+ ];
220
+
221
+ function App() {
222
+ return (
223
+ <div className="container mx-auto p-8">
224
+ <h1 className="text-3xl font-bold mb-6">User Management</h1>
225
+ <LuxTable
226
+ data={data}
227
+ columns={columns}
228
+ enableSorting
229
+ enablePagination
230
+ />
231
+ </div>
232
+ );
233
+ }
234
+
235
+ export default App;
236
+ ```
237
+
238
+ ---
239
+
240
+ ## ✨ Advanced Features
241
+
242
+ ### With Cell Renderers
243
+
244
+ ```tsx
245
+ import {
246
+ LuxTable,
247
+ createColumnHelper,
248
+ StatusCell,
249
+ DateCell,
250
+ CopyableCell,
251
+ ProgressCell
252
+ } from 'luxtable';
253
+
254
+ interface Task {
255
+ id: number;
256
+ title: string;
257
+ status: 'pending' | 'in-progress' | 'completed';
258
+ dueDate: string;
259
+ progress: number;
260
+ taskId: string;
261
+ }
262
+
263
+ const data: Task[] = [
264
+ {
265
+ id: 1,
266
+ title: 'Complete documentation',
267
+ status: 'in-progress',
268
+ dueDate: '2024-01-15',
269
+ progress: 65,
270
+ taskId: 'TASK-001'
271
+ },
272
+ // ...more data
273
+ ];
274
+
275
+ const columnHelper = createColumnHelper<Task>();
276
+
277
+ const columns = [
278
+ columnHelper.accessor('taskId', {
279
+ header: 'Task ID',
280
+ cell: (info) => <CopyableCell value={info.getValue()} />,
281
+ }),
282
+ columnHelper.accessor('title', {
283
+ header: 'Title',
284
+ }),
285
+ columnHelper.accessor('status', {
286
+ header: 'Status',
287
+ cell: (info) => (
288
+ <StatusCell
289
+ value={info.getValue()}
290
+ colorMap={{
291
+ 'pending': '#f59e0b',
292
+ 'in-progress': '#3b82f6',
293
+ 'completed': '#10b981',
294
+ }}
295
+ labelMap={{
296
+ 'pending': 'Pending',
297
+ 'in-progress': 'In Progress',
298
+ 'completed': 'Completed',
299
+ }}
300
+ />
301
+ ),
302
+ }),
303
+ columnHelper.accessor('dueDate', {
304
+ header: 'Due Date',
305
+ cell: (info) => <DateCell value={info.getValue()} format="long" />,
306
+ }),
307
+ columnHelper.accessor('progress', {
308
+ header: 'Progress',
309
+ cell: (info) => <ProgressCell value={info.getValue()} />,
310
+ }),
311
+ ];
312
+
313
+ function App() {
314
+ return (
315
+ <LuxTable
316
+ data={data}
317
+ columns={columns}
318
+ enableSorting
319
+ enablePagination
320
+ enableColumnFilters
321
+ showToolbar
322
+ showGlobalSearch
323
+ />
324
+ );
325
+ }
326
+ ```
327
+
328
+ ### With Row Selection
329
+
330
+ ```tsx
331
+ import { useState } from 'react';
332
+ import { LuxTable, createColumnHelper, RowSelectionState } from 'luxtable';
333
+
334
+ function App() {
335
+ const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
336
+
337
+ const handleSelectionChange = (selection: RowSelectionState) => {
338
+ setRowSelection(selection);
339
+ console.log('Selected rows:', Object.keys(selection));
340
+ };
341
+
342
+ const handleBulkDelete = () => {
343
+ const selectedIds = Object.keys(rowSelection).map(index => data[parseInt(index)].id);
344
+ console.log('Deleting:', selectedIds);
345
+ };
346
+
347
+ return (
348
+ <div>
349
+ {Object.keys(rowSelection).length > 0 && (
350
+ <div className="mb-4 p-4 bg-blue-50 rounded-lg">
351
+ <span>{Object.keys(rowSelection).length} rows selected</span>
352
+ <button onClick={handleBulkDelete} className="ml-4 text-red-600">
353
+ Delete Selected
354
+ </button>
355
+ </div>
356
+ )}
357
+
358
+ <LuxTable
359
+ data={data}
360
+ columns={columns}
361
+ enableRowSelection
362
+ rowSelection={rowSelection}
363
+ onRowSelectionChange={handleSelectionChange}
364
+ />
365
+ </div>
366
+ );
367
+ }
368
+ ```
369
+
370
+ ### With Row Actions
371
+
372
+ ```tsx
373
+ import { LuxTable, createColumnHelper } from 'luxtable';
374
+ import { Edit, Trash2, MoreHorizontal } from 'lucide-react';
375
+
376
+ const columnHelper = createColumnHelper<User>();
377
+
378
+ const columns = [
379
+ // ...other columns
380
+ columnHelper.display({
381
+ id: 'actions',
382
+ header: 'Actions',
383
+ cell: ({ row }) => (
384
+ <div className="flex items-center gap-2">
385
+ <button
386
+ onClick={() => handleEdit(row.original)}
387
+ className="p-1 hover:bg-muted rounded"
388
+ >
389
+ <Edit className="h-4 w-4" />
390
+ </button>
391
+ <button
392
+ onClick={() => handleDelete(row.original.id)}
393
+ className="p-1 hover:bg-destructive/10 rounded text-destructive"
394
+ >
395
+ <Trash2 className="h-4 w-4" />
396
+ </button>
397
+ </div>
398
+ ),
399
+ }),
400
+ ];
401
+ ```
402
+
403
+ ---
404
+
405
+ ## 🎨 Toolbar Features
406
+
407
+ ```tsx
408
+ <LuxTable
409
+ data={data}
410
+ columns={columns}
411
+ // Toolbar options
412
+ showToolbar // Show the toolbar
413
+ showGlobalSearch // Enable global search input
414
+ showColumnVisibility // Enable column visibility toggle
415
+ showFilterToggle // Enable filter toggle button
416
+
417
+ // Filtering & Sorting
418
+ enableSorting // Enable column sorting
419
+ enableColumnFilters // Enable column-level filters
420
+
421
+ // Pagination
422
+ enablePagination // Enable pagination
423
+ pageSize={10} // Default page size
424
+ pageSizeOptions={[10, 20, 50, 100]}
425
+
426
+ // Row Selection
427
+ enableRowSelection // Enable row selection with checkboxes
428
+ />
429
+ ```
430
+
431
+ ---
432
+
433
+ ## 🔧 Full Configuration Options
434
+
435
+ ```tsx
436
+ interface LuxTableProps<T> {
437
+ // Required
438
+ data: T[];
439
+ columns: ColumnDef<T>[];
440
+
441
+ // Sorting
442
+ enableSorting?: boolean;
443
+ defaultSort?: SortingState;
444
+ onSortingChange?: (sorting: SortingState) => void;
445
+
446
+ // Pagination
447
+ enablePagination?: boolean;
448
+ pageSize?: number;
449
+ pageSizeOptions?: number[];
450
+
451
+ // Filtering
452
+ enableColumnFilters?: boolean;
453
+ enableGlobalFilter?: boolean;
454
+
455
+ // Row Selection
456
+ enableRowSelection?: boolean;
457
+ rowSelection?: RowSelectionState;
458
+ onRowSelectionChange?: (selection: RowSelectionState) => void;
459
+
460
+ // Toolbar
461
+ showToolbar?: boolean;
462
+ showGlobalSearch?: boolean;
463
+ showColumnVisibility?: boolean;
464
+ showFilterToggle?: boolean;
465
+
466
+ // Styling
467
+ className?: string;
468
+ headerClassName?: string;
469
+ rowClassName?: string | ((row: Row<T>) => string);
470
+ cellClassName?: string;
471
+ }
472
+ ```
473
+
474
+ ---
475
+
476
+ ## 📚 Available Cell Renderers
477
+
478
+ | Renderer | Description | Props |
479
+ |----------|-------------|-------|
480
+ | `StatusCell` | Displays status badges with colors | `value`, `colorMap`, `labelMap` |
481
+ | `DateCell` | Formats date values | `value`, `format`, `locale` |
482
+ | `CopyableCell` | Copyable text with icon | `value` |
483
+ | `ProgressCell` | Progress bar visualization | `value`, `showLabel`, `color` |
484
+
485
+ ---
486
+
487
+ ## 🌐 shadcn/ui Registry Installation (Alternative Method)
488
+
489
+ If you're using shadcn/ui in your project, you can install LuxTable components directly via the shadcn CLI. This method copies the source files directly into your project.
490
+
491
+ ### Prerequisites
492
+
493
+ Before using shadcn CLI, make sure you have:
494
+
495
+ 1. **A shadcn/ui project** - Initialize with:
496
+ ```bash
497
+ npx shadcn@latest init
498
+ ```
499
+
500
+ 2. **Required shadcn components** - LuxTable depends on these:
501
+ ```bash
502
+ npx shadcn@latest add button checkbox dropdown-menu input select
503
+ ```
504
+
505
+ ### Step 1: Install the Main LuxTable Component
506
+
507
+ ```bash
508
+ # Using npx
509
+ npx shadcn@latest add "https://unpkg.com/luxtable/registry/lux-table.json"
510
+
511
+ # Using pnpm
512
+ pnpm dlx shadcn@latest add "https://unpkg.com/luxtable/registry/lux-table.json"
513
+ ```
514
+
515
+ This will install:
516
+ - `components/lux-table/lux-table.tsx` - Main table component
517
+ - `components/lux-table/types.ts` - TypeScript types
518
+ - `components/lux-table/column-filter.tsx` - Column filter component
519
+ - `components/lux-table/column-header.tsx` - Column header with actions
520
+ - `components/lux-table/pagination.tsx` - Pagination component
521
+ - `components/lux-table/table-toolbar.tsx` - Toolbar component
522
+ - `components/table/table.tsx` - Base table primitives
523
+
524
+ ### Step 2: Install Column Helper (Recommended)
525
+
526
+ ```bash
527
+ npx shadcn@latest add "https://unpkg.com/luxtable/registry/lux-table-column-helper.json"
528
+ ```
529
+
530
+ This will install:
531
+ - `lib/column-helper.tsx` - Type-safe column definition helper
532
+
533
+ ### Step 3: Install Cell Renderers (Optional)
534
+
535
+ ```bash
536
+ npx shadcn@latest add "https://unpkg.com/luxtable/registry/lux-table-cell-renderers.json"
537
+ ```
538
+
539
+ This will install:
540
+ - `components/lux-table/cell-renderers/status-cell.tsx`
541
+ - `components/lux-table/cell-renderers/progress-cell.tsx`
542
+ - `components/lux-table/cell-renderers/date-cell.tsx`
543
+ - `components/lux-table/cell-renderers/copyable-cell.tsx`
544
+ - `components/lux-table/cell-renderers/currency-cell.tsx`
545
+ - `components/lux-table/cell-renderers/boolean-cell.tsx`
546
+
547
+ ### Step 4: Install Dependencies
548
+
549
+ After installing via shadcn CLI, install the required npm dependencies:
550
+
551
+ ```bash
552
+ npm install @tanstack/react-table lucide-react clsx tailwind-merge
553
+ ```
554
+
555
+ ### Step 5: Usage with shadcn Installation
556
+
557
+ ```tsx
558
+ // Import from your local components
559
+ import { LuxTable } from "@/components/lux-table/lux-table";
560
+ import { createColumnHelper } from "@/lib/column-helper";
561
+ import { StatusCell } from "@/components/lux-table/cell-renderers/status-cell";
562
+
563
+ // Define columns and use as normal
564
+ const columnHelper = createColumnHelper<User>();
565
+
566
+ const columns = [
567
+ columnHelper.accessor('name', { header: 'Name' }),
568
+ columnHelper.accessor('status', {
569
+ header: 'Status',
570
+ cell: (info) => <StatusCell value={info.getValue()} />
571
+ }),
572
+ ];
573
+
574
+ function App() {
575
+ return (
576
+ <LuxTable
577
+ data={data}
578
+ columns={columns}
579
+ options={{
580
+ pagination: true,
581
+ sorting: true,
582
+ showToolbar: true,
583
+ }}
584
+ />
585
+ );
586
+ }
587
+ ```
588
+
589
+ ### npm vs shadcn CLI - When to Use Which?
590
+
591
+ | Method | Best For | Pros | Cons |
592
+ |--------|----------|------|------|
593
+ | **npm install** | Quick setup, updates | Easy updates, smaller bundle | Less customization |
594
+ | **shadcn CLI** | Full customization | Full source access, can modify | Manual updates needed |
595
+
596
+ ---
597
+
598
+ ## 📖 More Examples
599
+
600
+ For more detailed examples and full API documentation, visit:
601
+ - **Documentation**: [https://luxtable.dev](https://luxtable.dev)
602
+ - **GitHub**: [https://github.com/luxtable/luxtable](https://github.com/luxtable/luxtable)
603
+ - **npm**: [https://www.npmjs.com/package/luxtable](https://www.npmjs.com/package/luxtable)
604
+
605
+ ---
606
+
607
+ ## 🆘 Troubleshooting
608
+
609
+ ### Common Issues
610
+
611
+ **1. Styles not applied**
612
+ Make sure you've:
613
+ - Added LuxTable to your Tailwind content array
614
+ - Imported your CSS file with Tailwind directives
615
+ - Added the CSS variables to your stylesheet
616
+
617
+ **2. TypeScript errors**
618
+ Ensure you're using `createColumnHelper<YourType>()` with the correct generic type.
619
+
620
+ **3. Module not found**
621
+ Try clearing your node_modules and reinstalling:
622
+ ```bash
623
+ rm -rf node_modules
624
+ npm install
625
+ ```
626
+
627
+ ---
628
+
629
+ ## 📄 License
630
+
631
+ MIT © LuxTable
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "luxtable",
3
- "version": "0.3.1",
3
+ "version": "0.3.4",
4
4
  "private": false,
5
5
  "description": "Enterprise-Grade Data Management. Minimalist Aesthetics.",
6
6
  "keywords": [
@@ -34,7 +34,9 @@
34
34
  "files": [
35
35
  "dist",
36
36
  "registry",
37
- "README.md"
37
+ "README.md",
38
+ "USAGE.md",
39
+ "EXAMPLE.md"
38
40
  ],
39
41
  "publishConfig": {
40
42
  "access": "public"