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/EXAMPLE.md +348 -348
- package/README.md +178 -40
- package/USAGE.md +823 -631
- package/dist/index.d.mts +156 -23
- package/dist/index.d.ts +156 -23
- package/dist/index.js +1608 -729
- package/dist/index.mjs +1528 -652
- package/package.json +5 -2
- package/src/styles/README.md +141 -0
- package/src/styles/variables.css +283 -0
package/USAGE.md
CHANGED
|
@@ -1,631 +1,823 @@
|
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
```css
|
|
111
|
-
@tailwind base;
|
|
112
|
-
@tailwind components;
|
|
113
|
-
@tailwind utilities;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
--
|
|
134
|
-
--
|
|
135
|
-
--
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
--
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
--
|
|
148
|
-
--
|
|
149
|
-
--
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
```tsx
|
|
179
|
-
// src/App.tsx
|
|
180
|
-
import { LuxTable
|
|
181
|
-
|
|
182
|
-
// Define your data type
|
|
183
|
-
interface User {
|
|
184
|
-
id: number;
|
|
185
|
-
name: string;
|
|
186
|
-
email: string;
|
|
187
|
-
role: string;
|
|
188
|
-
status: '
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
{ id:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
},
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
###
|
|
534
|
-
|
|
535
|
-
```
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
---
|
|
597
|
-
|
|
598
|
-
##
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
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
|
+
LuxTable uses a comprehensive CSS variable system that works seamlessly in both light and dark modes. Import the variables file in your `src/index.css`:
|
|
109
|
+
|
|
110
|
+
```css
|
|
111
|
+
@tailwind base;
|
|
112
|
+
@tailwind components;
|
|
113
|
+
@tailwind utilities;
|
|
114
|
+
|
|
115
|
+
/* Import LuxTable CSS Variables */
|
|
116
|
+
@import 'luxtable/src/styles/variables.css';
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Or if you're using a monorepo structure:
|
|
120
|
+
|
|
121
|
+
```css
|
|
122
|
+
@import '../../packages/luxtable/src/styles/variables.css';
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### Customizing Colors
|
|
126
|
+
|
|
127
|
+
All LuxTable colors use CSS variables with HSL format, making them easy to override. Simply override the variables in your CSS:
|
|
128
|
+
|
|
129
|
+
```css
|
|
130
|
+
@layer base {
|
|
131
|
+
:root {
|
|
132
|
+
/* Override table colors */
|
|
133
|
+
--lux-table-background: 0 0% 100%;
|
|
134
|
+
--lux-table-foreground: 222 47% 11%;
|
|
135
|
+
--lux-table-border: 214 32% 91%;
|
|
136
|
+
|
|
137
|
+
/* Override status colors */
|
|
138
|
+
--lux-status-active-bg: 142 76% 36%;
|
|
139
|
+
--lux-status-active-text: 0 0% 100%;
|
|
140
|
+
|
|
141
|
+
/* Override primary accent */
|
|
142
|
+
--lux-focus-ring: 221 83% 53%;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.dark {
|
|
146
|
+
/* Override dark mode colors */
|
|
147
|
+
--lux-table-background: 222 47% 11%;
|
|
148
|
+
--lux-table-foreground: 210 40% 98%;
|
|
149
|
+
--lux-table-border: 217 33% 18%;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### Available CSS Variables
|
|
155
|
+
|
|
156
|
+
LuxTable provides variables for all components:
|
|
157
|
+
|
|
158
|
+
- **Table**: `--lux-table-*` (background, foreground, border, etc.)
|
|
159
|
+
- **Toolbar**: `--lux-toolbar-*` (background, border, input colors, etc.)
|
|
160
|
+
- **Pagination**: `--lux-pagination-*` (background, active, hover, etc.)
|
|
161
|
+
- **Status**: `--lux-status-*` (active, inactive, pending, completed, cancelled)
|
|
162
|
+
- **Selection**: `--lux-selection-*` (background, foreground, border)
|
|
163
|
+
- **Progress**: `--lux-progress-*` (background, bar, text)
|
|
164
|
+
- **Boolean**: `--lux-boolean-*` (true, false colors)
|
|
165
|
+
- **Filter**: `--lux-filter-*` (background, border, foreground)
|
|
166
|
+
- **Focus**: `--lux-focus-ring` (focus ring color)
|
|
167
|
+
|
|
168
|
+
All variables automatically adapt to light/dark mode when you use the `.dark` class.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 📝 Basic Usage
|
|
173
|
+
|
|
174
|
+
### Zero-Config: Auto-Generated Columns (Recommended)
|
|
175
|
+
|
|
176
|
+
LuxTable can automatically generate columns from your data - no column definitions needed! Cell types are also auto-detected based on field names.
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
// src/App.tsx
|
|
180
|
+
import { LuxTable } 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' | 'pending';
|
|
189
|
+
joinDate: string;
|
|
190
|
+
salary: number;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Sample data
|
|
194
|
+
const data: User[] = [
|
|
195
|
+
{ id: 1, name: 'John Doe', email: 'john@example.com', role: 'Admin', status: 'active', joinDate: '2024-01-15', salary: 75000 },
|
|
196
|
+
{ id: 2, name: 'Jane Smith', email: 'jane@example.com', role: 'User', status: 'active', joinDate: '2024-02-20', salary: 65000 },
|
|
197
|
+
{ id: 3, name: 'Bob Johnson', email: 'bob@example.com', role: 'Editor', status: 'inactive', joinDate: '2023-11-10', salary: 55000 },
|
|
198
|
+
];
|
|
199
|
+
|
|
200
|
+
function App() {
|
|
201
|
+
return (
|
|
202
|
+
<div className="container mx-auto p-8">
|
|
203
|
+
<h1 className="text-3xl font-bold mb-6">User Management</h1>
|
|
204
|
+
<LuxTable
|
|
205
|
+
data={data}
|
|
206
|
+
options={{
|
|
207
|
+
sorting: true,
|
|
208
|
+
multiSort: true, // Shift+Click to sort by multiple columns
|
|
209
|
+
filtering: true,
|
|
210
|
+
pagination: true,
|
|
211
|
+
pageSize: 10,
|
|
212
|
+
selection: "multiple",
|
|
213
|
+
showToolbar: true,
|
|
214
|
+
showGlobalSearch: true,
|
|
215
|
+
showColumnVisibility: true,
|
|
216
|
+
}}
|
|
217
|
+
/>
|
|
218
|
+
</div>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export default App;
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**What happens automatically:**
|
|
226
|
+
- ✅ Columns are auto-generated from data keys
|
|
227
|
+
- ✅ Headers are auto-formatted (camelCase → Title Case)
|
|
228
|
+
- ✅ `status` → StatusCell (colored badges)
|
|
229
|
+
- ✅ `joinDate` → DateCell (formatted dates)
|
|
230
|
+
- ✅ `salary` → CurrencyCell (formatted currency)
|
|
231
|
+
- ✅ `id`, `email` → CopyableCell (click to copy)
|
|
232
|
+
|
|
233
|
+
### Manual Column Definitions
|
|
234
|
+
|
|
235
|
+
You can also define columns manually for full control:
|
|
236
|
+
|
|
237
|
+
```tsx
|
|
238
|
+
// src/App.tsx
|
|
239
|
+
import { LuxTable, createColumnHelper } from 'luxtable';
|
|
240
|
+
|
|
241
|
+
// Define your data type
|
|
242
|
+
interface User {
|
|
243
|
+
id: number;
|
|
244
|
+
name: string;
|
|
245
|
+
email: string;
|
|
246
|
+
role: string;
|
|
247
|
+
status: 'active' | 'inactive';
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Sample data
|
|
251
|
+
const data: User[] = [
|
|
252
|
+
{ id: 1, name: 'John Doe', email: 'john@example.com', role: 'Admin', status: 'active' },
|
|
253
|
+
{ id: 2, name: 'Jane Smith', email: 'jane@example.com', role: 'User', status: 'active' },
|
|
254
|
+
{ id: 3, name: 'Bob Johnson', email: 'bob@example.com', role: 'Editor', status: 'inactive' },
|
|
255
|
+
];
|
|
256
|
+
|
|
257
|
+
// Create column helper
|
|
258
|
+
const columnHelper = createColumnHelper<User>();
|
|
259
|
+
|
|
260
|
+
// Define columns
|
|
261
|
+
const columns = [
|
|
262
|
+
columnHelper.accessor('id', {
|
|
263
|
+
header: 'ID',
|
|
264
|
+
size: 80,
|
|
265
|
+
}),
|
|
266
|
+
columnHelper.accessor('name', {
|
|
267
|
+
header: 'Name',
|
|
268
|
+
}),
|
|
269
|
+
columnHelper.accessor('email', {
|
|
270
|
+
header: 'Email',
|
|
271
|
+
}),
|
|
272
|
+
columnHelper.accessor('role', {
|
|
273
|
+
header: 'Role',
|
|
274
|
+
}),
|
|
275
|
+
columnHelper.accessor('status', {
|
|
276
|
+
header: 'Status',
|
|
277
|
+
}),
|
|
278
|
+
];
|
|
279
|
+
|
|
280
|
+
function App() {
|
|
281
|
+
return (
|
|
282
|
+
<div className="container mx-auto p-8">
|
|
283
|
+
<h1 className="text-3xl font-bold mb-6">User Management</h1>
|
|
284
|
+
<LuxTable
|
|
285
|
+
data={data}
|
|
286
|
+
columns={columns}
|
|
287
|
+
options={{
|
|
288
|
+
sorting: true,
|
|
289
|
+
pagination: true,
|
|
290
|
+
}}
|
|
291
|
+
/>
|
|
292
|
+
</div>
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export default App;
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## ✨ Advanced Features
|
|
302
|
+
|
|
303
|
+
### Auto Cell Detection
|
|
304
|
+
|
|
305
|
+
LuxTable automatically detects and renders cell types based on field names. No configuration needed!
|
|
306
|
+
|
|
307
|
+
```tsx
|
|
308
|
+
import { LuxTable } from 'luxtable';
|
|
309
|
+
|
|
310
|
+
interface Task {
|
|
311
|
+
id: number;
|
|
312
|
+
title: string;
|
|
313
|
+
status: 'pending' | 'in-progress' | 'completed';
|
|
314
|
+
dueDate: string;
|
|
315
|
+
progress: number;
|
|
316
|
+
taskId: string;
|
|
317
|
+
isActive: boolean;
|
|
318
|
+
price: number;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const data: Task[] = [
|
|
322
|
+
{
|
|
323
|
+
id: 1,
|
|
324
|
+
title: 'Complete documentation',
|
|
325
|
+
status: 'in-progress',
|
|
326
|
+
dueDate: '2024-01-15',
|
|
327
|
+
progress: 65,
|
|
328
|
+
taskId: 'TASK-001',
|
|
329
|
+
isActive: true,
|
|
330
|
+
price: 99.99
|
|
331
|
+
},
|
|
332
|
+
// ...more data
|
|
333
|
+
];
|
|
334
|
+
|
|
335
|
+
function App() {
|
|
336
|
+
return (
|
|
337
|
+
<LuxTable
|
|
338
|
+
data={data}
|
|
339
|
+
options={{
|
|
340
|
+
sorting: true,
|
|
341
|
+
pagination: true,
|
|
342
|
+
filtering: true,
|
|
343
|
+
showToolbar: true,
|
|
344
|
+
showGlobalSearch: true,
|
|
345
|
+
}}
|
|
346
|
+
/>
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**Auto-detected fields:**
|
|
352
|
+
- `status` → StatusCell (colored badge)
|
|
353
|
+
- `dueDate` → DateCell (formatted date)
|
|
354
|
+
- `taskId`, `id` → CopyableCell (click to copy)
|
|
355
|
+
- `isActive` → BooleanCell (Yes/No)
|
|
356
|
+
- `price` → CurrencyCell (formatted currency)
|
|
357
|
+
- `progress` → Can be configured as ProgressCell
|
|
358
|
+
|
|
359
|
+
### Manual Cell Renderers
|
|
360
|
+
|
|
361
|
+
You can also use cell renderers manually in column definitions:
|
|
362
|
+
|
|
363
|
+
```tsx
|
|
364
|
+
import {
|
|
365
|
+
LuxTable,
|
|
366
|
+
createColumnHelper,
|
|
367
|
+
StatusCell,
|
|
368
|
+
DateCell,
|
|
369
|
+
CopyableCell,
|
|
370
|
+
ProgressCell,
|
|
371
|
+
CurrencyCell,
|
|
372
|
+
BooleanCell
|
|
373
|
+
} from 'luxtable';
|
|
374
|
+
|
|
375
|
+
interface Task {
|
|
376
|
+
id: number;
|
|
377
|
+
title: string;
|
|
378
|
+
status: 'pending' | 'in-progress' | 'completed';
|
|
379
|
+
dueDate: string;
|
|
380
|
+
progress: number;
|
|
381
|
+
taskId: string;
|
|
382
|
+
isActive: boolean;
|
|
383
|
+
price: number;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const data: Task[] = [
|
|
387
|
+
{
|
|
388
|
+
id: 1,
|
|
389
|
+
title: 'Complete documentation',
|
|
390
|
+
status: 'in-progress',
|
|
391
|
+
dueDate: '2024-01-15',
|
|
392
|
+
progress: 65,
|
|
393
|
+
taskId: 'TASK-001',
|
|
394
|
+
isActive: true,
|
|
395
|
+
price: 99.99
|
|
396
|
+
},
|
|
397
|
+
// ...more data
|
|
398
|
+
];
|
|
399
|
+
|
|
400
|
+
const columnHelper = createColumnHelper<Task>();
|
|
401
|
+
|
|
402
|
+
const columns = [
|
|
403
|
+
columnHelper.accessor('taskId', {
|
|
404
|
+
header: 'Task ID',
|
|
405
|
+
cell: (info) => <CopyableCell value={String(info.getValue())} />,
|
|
406
|
+
}),
|
|
407
|
+
columnHelper.accessor('title', {
|
|
408
|
+
header: 'Title',
|
|
409
|
+
}),
|
|
410
|
+
columnHelper.accessor('status', {
|
|
411
|
+
header: 'Status',
|
|
412
|
+
cell: (info) => (
|
|
413
|
+
<StatusCell
|
|
414
|
+
value={String(info.getValue())}
|
|
415
|
+
colors={{
|
|
416
|
+
'pending': { bg: 'bg-yellow-100', text: 'text-yellow-800' },
|
|
417
|
+
'in-progress': { bg: 'bg-blue-100', text: 'text-blue-800' },
|
|
418
|
+
'completed': { bg: 'bg-green-100', text: 'text-green-800' },
|
|
419
|
+
}}
|
|
420
|
+
/>
|
|
421
|
+
),
|
|
422
|
+
}),
|
|
423
|
+
columnHelper.accessor('dueDate', {
|
|
424
|
+
header: 'Due Date',
|
|
425
|
+
cell: (info) => <DateCell value={info.getValue() as string} format="long" />,
|
|
426
|
+
}),
|
|
427
|
+
columnHelper.accessor('progress', {
|
|
428
|
+
header: 'Progress',
|
|
429
|
+
cell: (info) => <ProgressCell value={Number(info.getValue())} showLabel />,
|
|
430
|
+
}),
|
|
431
|
+
columnHelper.accessor('price', {
|
|
432
|
+
header: 'Price',
|
|
433
|
+
cell: (info) => <CurrencyCell value={Number(info.getValue())} currency="USD" />,
|
|
434
|
+
}),
|
|
435
|
+
columnHelper.accessor('isActive', {
|
|
436
|
+
header: 'Active',
|
|
437
|
+
cell: (info) => <BooleanCell value={Boolean(info.getValue())} />,
|
|
438
|
+
}),
|
|
439
|
+
];
|
|
440
|
+
|
|
441
|
+
function App() {
|
|
442
|
+
return (
|
|
443
|
+
<LuxTable
|
|
444
|
+
data={data}
|
|
445
|
+
columns={columns}
|
|
446
|
+
options={{
|
|
447
|
+
sorting: true,
|
|
448
|
+
pagination: true,
|
|
449
|
+
filtering: true,
|
|
450
|
+
showToolbar: true,
|
|
451
|
+
showGlobalSearch: true,
|
|
452
|
+
}}
|
|
453
|
+
/>
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### Custom Cell Configuration
|
|
459
|
+
|
|
460
|
+
You can customize auto-detection behavior:
|
|
461
|
+
|
|
462
|
+
```tsx
|
|
463
|
+
<LuxTable
|
|
464
|
+
data={data}
|
|
465
|
+
cellConfig={{
|
|
466
|
+
// Custom field configurations
|
|
467
|
+
fields: {
|
|
468
|
+
customStatus: { type: "status" },
|
|
469
|
+
customDate: { type: "date", format: "long" },
|
|
470
|
+
progress: { type: "progress", showLabel: true },
|
|
471
|
+
},
|
|
472
|
+
// Custom auto-detection patterns
|
|
473
|
+
patterns: {
|
|
474
|
+
status: ["status", "state", "customStatus"],
|
|
475
|
+
date: ["date", "createdAt", "customDate"],
|
|
476
|
+
currency: ["price", "amount", "cost"],
|
|
477
|
+
},
|
|
478
|
+
// Default status colors
|
|
479
|
+
defaultStatusColors: {
|
|
480
|
+
active: { bg: "bg-green-100", text: "text-green-800" },
|
|
481
|
+
pending: { bg: "bg-yellow-100", text: "text-yellow-800" },
|
|
482
|
+
},
|
|
483
|
+
// Disable auto-detection if needed
|
|
484
|
+
autoDetect: true, // default: true
|
|
485
|
+
}}
|
|
486
|
+
/>
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
### With Row Selection
|
|
490
|
+
|
|
491
|
+
```tsx
|
|
492
|
+
import { useState } from 'react';
|
|
493
|
+
import { LuxTable, RowSelectionState } from 'luxtable';
|
|
494
|
+
|
|
495
|
+
function App() {
|
|
496
|
+
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
|
497
|
+
|
|
498
|
+
const handleSelectedRowsChange = (selectedRows: typeof data) => {
|
|
499
|
+
console.log('Selected rows:', selectedRows);
|
|
500
|
+
// Do something with selected rows
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
const handleBulkDelete = () => {
|
|
504
|
+
const selectedRows = data.filter((_, index) => rowSelection[index]);
|
|
505
|
+
console.log('Deleting:', selectedRows);
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
return (
|
|
509
|
+
<div>
|
|
510
|
+
{Object.keys(rowSelection).length > 0 && (
|
|
511
|
+
<div className="mb-4 p-4 bg-blue-50 rounded-lg">
|
|
512
|
+
<span>{Object.keys(rowSelection).length} rows selected</span>
|
|
513
|
+
<button onClick={handleBulkDelete} className="ml-4 text-red-600">
|
|
514
|
+
Delete Selected
|
|
515
|
+
</button>
|
|
516
|
+
</div>
|
|
517
|
+
)}
|
|
518
|
+
|
|
519
|
+
<LuxTable
|
|
520
|
+
data={data}
|
|
521
|
+
options={{
|
|
522
|
+
selection: "multiple", // or "single" or "none"
|
|
523
|
+
}}
|
|
524
|
+
rowSelection={rowSelection}
|
|
525
|
+
onRowSelectionChange={setRowSelection}
|
|
526
|
+
onSelectedRowsChange={handleSelectedRowsChange}
|
|
527
|
+
/>
|
|
528
|
+
</div>
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
### With Row Actions
|
|
534
|
+
|
|
535
|
+
```tsx
|
|
536
|
+
import { LuxTable, createColumnHelper } from 'luxtable';
|
|
537
|
+
import { Edit, Trash2, MoreHorizontal } from 'lucide-react';
|
|
538
|
+
|
|
539
|
+
const columnHelper = createColumnHelper<User>();
|
|
540
|
+
|
|
541
|
+
const columns = [
|
|
542
|
+
// ...other columns
|
|
543
|
+
columnHelper.display({
|
|
544
|
+
id: 'actions',
|
|
545
|
+
header: 'Actions',
|
|
546
|
+
cell: ({ row }) => (
|
|
547
|
+
<div className="flex items-center gap-2">
|
|
548
|
+
<button
|
|
549
|
+
onClick={() => handleEdit(row.original)}
|
|
550
|
+
className="p-1 hover:bg-muted rounded"
|
|
551
|
+
>
|
|
552
|
+
<Edit className="h-4 w-4" />
|
|
553
|
+
</button>
|
|
554
|
+
<button
|
|
555
|
+
onClick={() => handleDelete(row.original.id)}
|
|
556
|
+
className="p-1 hover:bg-destructive/10 rounded text-destructive"
|
|
557
|
+
>
|
|
558
|
+
<Trash2 className="h-4 w-4" />
|
|
559
|
+
</button>
|
|
560
|
+
</div>
|
|
561
|
+
),
|
|
562
|
+
}),
|
|
563
|
+
];
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
---
|
|
567
|
+
|
|
568
|
+
## 🎨 Toolbar Features
|
|
569
|
+
|
|
570
|
+
```tsx
|
|
571
|
+
<LuxTable
|
|
572
|
+
data={data}
|
|
573
|
+
columns={columns}
|
|
574
|
+
options={{
|
|
575
|
+
// Toolbar options
|
|
576
|
+
showToolbar: true, // Show the toolbar
|
|
577
|
+
showGlobalSearch: true, // Enable global search input
|
|
578
|
+
showColumnVisibility: true, // Enable column visibility toggle
|
|
579
|
+
|
|
580
|
+
// Filtering & Sorting
|
|
581
|
+
sorting: true, // Enable column sorting
|
|
582
|
+
multiSort: true, // Enable multi-column sorting (Shift+Click)
|
|
583
|
+
filtering: true, // Enable column-level filters
|
|
584
|
+
|
|
585
|
+
// Pagination
|
|
586
|
+
pagination: true, // Enable pagination
|
|
587
|
+
pageSize: 10, // Default page size
|
|
588
|
+
|
|
589
|
+
// Row Selection
|
|
590
|
+
selection: "multiple", // "single" | "multiple" | "none"
|
|
591
|
+
showSelectionCheckbox: true, // Show selection checkbox
|
|
592
|
+
}}
|
|
593
|
+
/>
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
---
|
|
597
|
+
|
|
598
|
+
## 🔧 Full Configuration Options
|
|
599
|
+
|
|
600
|
+
```tsx
|
|
601
|
+
interface LuxTableProps<TData> {
|
|
602
|
+
// Required
|
|
603
|
+
data: TData[];
|
|
604
|
+
|
|
605
|
+
// Optional
|
|
606
|
+
columns?: ColumnDef<TData, any>[]; // Auto-generated if not provided
|
|
607
|
+
className?: string;
|
|
608
|
+
|
|
609
|
+
// Options
|
|
610
|
+
options?: {
|
|
611
|
+
pagination?: boolean; // Default: false
|
|
612
|
+
pageSize?: number; // Default: 10
|
|
613
|
+
sorting?: boolean; // Default: true
|
|
614
|
+
multiSort?: boolean; // Default: true
|
|
615
|
+
maxMultiSortColCount?: number; // Default: undefined (unlimited)
|
|
616
|
+
filtering?: boolean; // Default: false
|
|
617
|
+
selection?: "single" | "multiple" | "none"; // Default: "none"
|
|
618
|
+
showSelectionCheckbox?: boolean; // Default: true (when selection enabled)
|
|
619
|
+
showToolbar?: boolean; // Default: false
|
|
620
|
+
showGlobalSearch?: boolean; // Default: true
|
|
621
|
+
showColumnVisibility?: boolean; // Default: true
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
// Cell Configuration
|
|
625
|
+
cellConfig?: GlobalCellConfig; // Custom cell auto-detection config
|
|
626
|
+
|
|
627
|
+
// Controlled State
|
|
628
|
+
sorting?: SortingState;
|
|
629
|
+
onSortingChange?: (sorting: SortingState) => void;
|
|
630
|
+
rowSelection?: RowSelectionState;
|
|
631
|
+
onRowSelectionChange?: (selection: RowSelectionState) => void;
|
|
632
|
+
onSelectedRowsChange?: (rows: TData[]) => void;
|
|
633
|
+
|
|
634
|
+
// Utilities
|
|
635
|
+
getRowId?: (row: TData, index: number) => string; // Default: uses "id" field or index
|
|
636
|
+
}
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
---
|
|
640
|
+
|
|
641
|
+
## 📚 Available Cell Renderers
|
|
642
|
+
|
|
643
|
+
| Renderer | Description | Props |
|
|
644
|
+
|----------|-------------|-------|
|
|
645
|
+
| `StatusCell` | Displays status badges with colors | `value`, `colors`, `className` |
|
|
646
|
+
| `DateCell` | Formats date values | `value`, `format` ("short" \| "long" \| "relative"), `locale` |
|
|
647
|
+
| `CopyableCell` | Copyable text with icon | `value`, `tooltip`, `alwaysShowIcon`, `onCopy`, `className` |
|
|
648
|
+
| `ProgressCell` | Progress bar visualization | `value`, `showLabel`, `barColor`, `className` |
|
|
649
|
+
| `CurrencyCell` | Formatted currency values | `value`, `currency`, `locale` |
|
|
650
|
+
| `BooleanCell` | Yes/No indicators | `value`, `trueLabel`, `falseLabel`, `trueColor`, `falseColor` |
|
|
651
|
+
|
|
652
|
+
### Auto-Detection Patterns
|
|
653
|
+
|
|
654
|
+
Cell renderers are automatically applied based on field names:
|
|
655
|
+
|
|
656
|
+
- **Status**: `status`, `state`, `stage`, `phase`
|
|
657
|
+
- **Date**: `date`, `createdAt`, `updatedAt`, `joinDate`, `startDate`, `endDate`, `birthDate`, `publishedAt`
|
|
658
|
+
- **Currency**: `price`, `amount`, `salary`, `cost`, `revenue`, `total`, `balance`, `fee`
|
|
659
|
+
- **Boolean**: `isActive`, `isVerified`, `isEnabled`, `isDeleted`, `isPublished`, `isPublic`
|
|
660
|
+
- **Copyable**: `id`, `email`, `phone`, `code`, `token`, `reference`, `orderId`
|
|
661
|
+
|
|
662
|
+
---
|
|
663
|
+
|
|
664
|
+
## 🌐 shadcn/ui Registry Installation (Alternative Method)
|
|
665
|
+
|
|
666
|
+
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.
|
|
667
|
+
|
|
668
|
+
### Prerequisites
|
|
669
|
+
|
|
670
|
+
Before using shadcn CLI, make sure you have:
|
|
671
|
+
|
|
672
|
+
1. **A shadcn/ui project** - Initialize with:
|
|
673
|
+
```bash
|
|
674
|
+
npx shadcn@latest init
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
2. **Required shadcn components** - LuxTable depends on these:
|
|
678
|
+
```bash
|
|
679
|
+
npx shadcn@latest add button checkbox dropdown-menu input select
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
### Step 1: Install the Main LuxTable Component
|
|
683
|
+
|
|
684
|
+
```bash
|
|
685
|
+
# Using npx
|
|
686
|
+
npx shadcn@latest add "https://unpkg.com/luxtable/registry/lux-table.json"
|
|
687
|
+
|
|
688
|
+
# Using pnpm
|
|
689
|
+
pnpm dlx shadcn@latest add "https://unpkg.com/luxtable/registry/lux-table.json"
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
This will install:
|
|
693
|
+
- `components/lux-table/lux-table.tsx` - Main table component
|
|
694
|
+
- `components/lux-table/types.ts` - TypeScript types
|
|
695
|
+
- `components/lux-table/column-filter.tsx` - Column filter component
|
|
696
|
+
- `components/lux-table/column-header.tsx` - Column header with actions
|
|
697
|
+
- `components/lux-table/pagination.tsx` - Pagination component
|
|
698
|
+
- `components/lux-table/table-toolbar.tsx` - Toolbar component
|
|
699
|
+
- `components/table/table.tsx` - Base table primitives
|
|
700
|
+
|
|
701
|
+
### Step 2: Install Column Helper (Recommended)
|
|
702
|
+
|
|
703
|
+
```bash
|
|
704
|
+
npx shadcn@latest add "https://unpkg.com/luxtable/registry/lux-table-column-helper.json"
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
This will install:
|
|
708
|
+
- `lib/column-helper.tsx` - Type-safe column definition helper
|
|
709
|
+
|
|
710
|
+
### Step 3: Install Cell Renderers (Optional)
|
|
711
|
+
|
|
712
|
+
```bash
|
|
713
|
+
npx shadcn@latest add "https://unpkg.com/luxtable/registry/lux-table-cell-renderers.json"
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
This will install:
|
|
717
|
+
- `components/lux-table/cell-renderers/status-cell.tsx`
|
|
718
|
+
- `components/lux-table/cell-renderers/progress-cell.tsx`
|
|
719
|
+
- `components/lux-table/cell-renderers/date-cell.tsx`
|
|
720
|
+
- `components/lux-table/cell-renderers/copyable-cell.tsx`
|
|
721
|
+
- `components/lux-table/cell-renderers/currency-cell.tsx`
|
|
722
|
+
- `components/lux-table/cell-renderers/boolean-cell.tsx`
|
|
723
|
+
|
|
724
|
+
### Step 4: Install Dependencies
|
|
725
|
+
|
|
726
|
+
After installing via shadcn CLI, install the required npm dependencies:
|
|
727
|
+
|
|
728
|
+
```bash
|
|
729
|
+
npm install @tanstack/react-table lucide-react clsx tailwind-merge
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
### Step 5: Usage with shadcn Installation
|
|
733
|
+
|
|
734
|
+
```tsx
|
|
735
|
+
// Import from your local components
|
|
736
|
+
import { LuxTable } from "@/components/lux-table/lux-table";
|
|
737
|
+
import { createColumnHelper } from "@/lib/column-helper";
|
|
738
|
+
import { StatusCell } from "@/components/lux-table/cell-renderers/status-cell";
|
|
739
|
+
|
|
740
|
+
// Option 1: Zero-config (auto-generated columns)
|
|
741
|
+
function App() {
|
|
742
|
+
return (
|
|
743
|
+
<LuxTable
|
|
744
|
+
data={data}
|
|
745
|
+
options={{
|
|
746
|
+
pagination: true,
|
|
747
|
+
sorting: true,
|
|
748
|
+
filtering: true,
|
|
749
|
+
showToolbar: true,
|
|
750
|
+
}}
|
|
751
|
+
/>
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
// Option 2: Manual column definitions
|
|
756
|
+
const columnHelper = createColumnHelper<User>();
|
|
757
|
+
|
|
758
|
+
const columns = [
|
|
759
|
+
columnHelper.accessor('name', { header: 'Name' }),
|
|
760
|
+
columnHelper.accessor('status', {
|
|
761
|
+
header: 'Status',
|
|
762
|
+
cell: (info) => <StatusCell value={info.getValue()} />
|
|
763
|
+
}),
|
|
764
|
+
];
|
|
765
|
+
|
|
766
|
+
function App() {
|
|
767
|
+
return (
|
|
768
|
+
<LuxTable
|
|
769
|
+
data={data}
|
|
770
|
+
columns={columns}
|
|
771
|
+
options={{
|
|
772
|
+
pagination: true,
|
|
773
|
+
sorting: true,
|
|
774
|
+
showToolbar: true,
|
|
775
|
+
}}
|
|
776
|
+
/>
|
|
777
|
+
);
|
|
778
|
+
}
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
### npm vs shadcn CLI - When to Use Which?
|
|
782
|
+
|
|
783
|
+
| Method | Best For | Pros | Cons |
|
|
784
|
+
|--------|----------|------|------|
|
|
785
|
+
| **npm install** | Quick setup, updates | Easy updates, smaller bundle | Less customization |
|
|
786
|
+
| **shadcn CLI** | Full customization | Full source access, can modify | Manual updates needed |
|
|
787
|
+
|
|
788
|
+
---
|
|
789
|
+
|
|
790
|
+
## 📖 More Examples
|
|
791
|
+
|
|
792
|
+
For more detailed examples and full API documentation, visit:
|
|
793
|
+
- **Documentation**: [https://luxtable.dev](https://luxtable.dev)
|
|
794
|
+
- **GitHub**: [https://github.com/Huseyin-altun/luxtable](https://github.com/Huseyin-altun/luxtable)
|
|
795
|
+
- **npm**: [https://www.npmjs.com/package/luxtable](https://www.npmjs.com/package/luxtable)
|
|
796
|
+
|
|
797
|
+
---
|
|
798
|
+
|
|
799
|
+
## 🆘 Troubleshooting
|
|
800
|
+
|
|
801
|
+
### Common Issues
|
|
802
|
+
|
|
803
|
+
**1. Styles not applied**
|
|
804
|
+
Make sure you've:
|
|
805
|
+
- Added LuxTable to your Tailwind content array
|
|
806
|
+
- Imported your CSS file with Tailwind directives
|
|
807
|
+
- Added the CSS variables to your stylesheet
|
|
808
|
+
|
|
809
|
+
**2. TypeScript errors**
|
|
810
|
+
Ensure you're using `createColumnHelper<YourType>()` with the correct generic type.
|
|
811
|
+
|
|
812
|
+
**3. Module not found**
|
|
813
|
+
Try clearing your node_modules and reinstalling:
|
|
814
|
+
```bash
|
|
815
|
+
rm -rf node_modules
|
|
816
|
+
npm install
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
---
|
|
820
|
+
|
|
821
|
+
## 📄 License
|
|
822
|
+
|
|
823
|
+
MIT © LuxTable
|