@bomjan133/react-crud-ui 1.2.5

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.
@@ -0,0 +1,586 @@
1
+ # UI Components Guide
2
+
3
+ Complete reference for all UI components included in @sujanbomjan/react-crud-ui.
4
+
5
+ ## Table of Contents
6
+ 1. [Button](#button)
7
+ 2. [Card](#card)
8
+ 3. [Badge](#badge)
9
+ 4. [Input & Label](#input--label)
10
+ 5. [Select](#select)
11
+ 6. [Checkbox & Switch](#checkbox--switch)
12
+ 7. [Dialog](#dialog)
13
+ 8. [Dropdown Menu](#dropdown-menu)
14
+ 9. [Tabs](#tabs)
15
+ 10. [Table](#table)
16
+ 11. [Avatar](#avatar)
17
+ 12. [Tooltip](#tooltip)
18
+ 13. [Date Picker](#date-picker)
19
+ 14. [Rich Text Editor](#rich-text-editor)
20
+ 15. [Separator](#separator)
21
+ 16. [Skeleton](#skeleton)
22
+ 16. [Alert](#alert)
23
+
24
+ ---
25
+
26
+ ## Button
27
+
28
+ ```jsx
29
+ import { Button, buttonVariants } from '@sujanbomjan/react-crud-ui';
30
+
31
+ // Variants
32
+ <Button>Default</Button>
33
+ <Button variant="secondary">Secondary</Button>
34
+ <Button variant="destructive">Destructive</Button>
35
+ <Button variant="outline">Outline</Button>
36
+ <Button variant="ghost">Ghost</Button>
37
+ <Button variant="link">Link</Button>
38
+ <Button variant="success">Success</Button>
39
+
40
+ // Sizes
41
+ <Button size="sm">Small</Button>
42
+ <Button size="default">Default</Button>
43
+ <Button size="lg">Large</Button>
44
+ <Button size="icon"><Icon /></Button>
45
+
46
+ // With icon
47
+ <Button>
48
+ <Plus className="h-4 w-4 mr-2" />
49
+ Add Item
50
+ </Button>
51
+
52
+ // Loading state
53
+ <Button disabled>
54
+ <Loader2 className="h-4 w-4 mr-2 animate-spin" />
55
+ Loading...
56
+ </Button>
57
+
58
+ // As link using buttonVariants
59
+ <a href="/path" className={buttonVariants({ variant: "outline" })}>
60
+ Link Button
61
+ </a>
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Card
67
+
68
+ ```jsx
69
+ import {
70
+ Card,
71
+ CardHeader,
72
+ CardTitle,
73
+ CardDescription,
74
+ CardContent,
75
+ CardFooter
76
+ } from '@sujanbomjan/react-crud-ui';
77
+
78
+ <Card>
79
+ <CardHeader>
80
+ <CardTitle>Card Title</CardTitle>
81
+ <CardDescription>Card description text</CardDescription>
82
+ </CardHeader>
83
+ <CardContent>
84
+ <p>Card content goes here</p>
85
+ </CardContent>
86
+ <CardFooter className="flex justify-end gap-2">
87
+ <Button variant="outline">Cancel</Button>
88
+ <Button>Save</Button>
89
+ </CardFooter>
90
+ </Card>
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Badge
96
+
97
+ ```jsx
98
+ import { Badge, badgeVariants } from '@sujanbomjan/react-crud-ui';
99
+
100
+ // Variants
101
+ <Badge>Default</Badge>
102
+ <Badge variant="secondary">Secondary</Badge>
103
+ <Badge variant="destructive">Destructive</Badge>
104
+ <Badge variant="outline">Outline</Badge>
105
+ <Badge variant="success">Success</Badge>
106
+ <Badge variant="warning">Warning</Badge>
107
+ <Badge variant="info">Info</Badge>
108
+
109
+ // Status badges pattern
110
+ const StatusBadge = ({ status }) => {
111
+ const variants = {
112
+ active: 'success',
113
+ pending: 'warning',
114
+ inactive: 'secondary',
115
+ error: 'destructive',
116
+ };
117
+ return <Badge variant={variants[status]}>{status}</Badge>;
118
+ };
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Input & Label
124
+
125
+ ```jsx
126
+ import { Input } from '@sujanbomjan/react-crud-ui';
127
+ import { Label } from '@sujanbomjan/react-crud-ui';
128
+
129
+ // Basic input
130
+ <div className="space-y-2">
131
+ <Label htmlFor="email">Email</Label>
132
+ <Input
133
+ id="email"
134
+ type="email"
135
+ placeholder="Enter email"
136
+ value={value}
137
+ onChange={(e) => setValue(e.target.value)}
138
+ />
139
+ </div>
140
+
141
+ // With error
142
+ <div className="space-y-2">
143
+ <Label htmlFor="name">Name</Label>
144
+ <Input
145
+ id="name"
146
+ className="border-destructive"
147
+ value={value}
148
+ onChange={(e) => setValue(e.target.value)}
149
+ />
150
+ <p className="text-sm text-destructive">Name is required</p>
151
+ </div>
152
+
153
+ // Disabled
154
+ <Input disabled placeholder="Disabled input" />
155
+ ```
156
+
157
+ ---
158
+
159
+ ## Select
160
+
161
+ ```jsx
162
+ import {
163
+ Select,
164
+ SelectGroup,
165
+ SelectValue,
166
+ SelectTrigger,
167
+ SelectContent,
168
+ SelectLabel,
169
+ SelectItem,
170
+ SelectSeparator,
171
+ } from '@sujanbomjan/react-crud-ui';
172
+
173
+ // Basic select
174
+ <Select value={value} onValueChange={setValue}>
175
+ <SelectTrigger className="w-[200px]">
176
+ <SelectValue placeholder="Select option" />
177
+ </SelectTrigger>
178
+ <SelectContent>
179
+ <SelectItem value="option1">Option 1</SelectItem>
180
+ <SelectItem value="option2">Option 2</SelectItem>
181
+ <SelectItem value="option3">Option 3</SelectItem>
182
+ </SelectContent>
183
+ </Select>
184
+
185
+ // With groups
186
+ <Select>
187
+ <SelectTrigger>
188
+ <SelectValue placeholder="Select fruit" />
189
+ </SelectTrigger>
190
+ <SelectContent>
191
+ <SelectGroup>
192
+ <SelectLabel>Fruits</SelectLabel>
193
+ <SelectItem value="apple">Apple</SelectItem>
194
+ <SelectItem value="banana">Banana</SelectItem>
195
+ </SelectGroup>
196
+ <SelectSeparator />
197
+ <SelectGroup>
198
+ <SelectLabel>Vegetables</SelectLabel>
199
+ <SelectItem value="carrot">Carrot</SelectItem>
200
+ <SelectItem value="potato">Potato</SelectItem>
201
+ </SelectGroup>
202
+ </SelectContent>
203
+ </Select>
204
+ ```
205
+
206
+ ---
207
+
208
+ ## Checkbox & Switch
209
+
210
+ ```jsx
211
+ import { Checkbox } from '@sujanbomjan/react-crud-ui';
212
+ import { Switch } from '@sujanbomjan/react-crud-ui';
213
+ import { Label } from '@sujanbomjan/react-crud-ui';
214
+
215
+ // Checkbox
216
+ <div className="flex items-center space-x-2">
217
+ <Checkbox
218
+ id="terms"
219
+ checked={checked}
220
+ onCheckedChange={setChecked}
221
+ />
222
+ <Label htmlFor="terms">Accept terms and conditions</Label>
223
+ </div>
224
+
225
+ // Switch
226
+ <div className="flex items-center space-x-2">
227
+ <Switch
228
+ id="active"
229
+ checked={active}
230
+ onCheckedChange={setActive}
231
+ />
232
+ <Label htmlFor="active">Active</Label>
233
+ </div>
234
+
235
+ // Switch with description
236
+ <div className="flex items-center justify-between rounded-lg border p-4">
237
+ <div className="space-y-0.5">
238
+ <Label>Marketing emails</Label>
239
+ <p className="text-sm text-muted-foreground">
240
+ Receive emails about new products
241
+ </p>
242
+ </div>
243
+ <Switch checked={marketing} onCheckedChange={setMarketing} />
244
+ </div>
245
+ ```
246
+
247
+ ---
248
+
249
+ ## Dialog
250
+
251
+ ```jsx
252
+ import {
253
+ Dialog,
254
+ DialogTrigger,
255
+ DialogContent,
256
+ DialogHeader,
257
+ DialogTitle,
258
+ DialogDescription,
259
+ DialogFooter,
260
+ DialogClose,
261
+ } from '@sujanbomjan/react-crud-ui';
262
+
263
+ <Dialog open={open} onOpenChange={setOpen}>
264
+ <DialogTrigger asChild>
265
+ <Button>Open Dialog</Button>
266
+ </DialogTrigger>
267
+ <DialogContent>
268
+ <DialogHeader>
269
+ <DialogTitle>Dialog Title</DialogTitle>
270
+ <DialogDescription>
271
+ This is the dialog description.
272
+ </DialogDescription>
273
+ </DialogHeader>
274
+ <div className="py-4">
275
+ {/* Dialog content */}
276
+ </div>
277
+ <DialogFooter>
278
+ <DialogClose asChild>
279
+ <Button variant="outline">Cancel</Button>
280
+ </DialogClose>
281
+ <Button onClick={handleSubmit}>Save</Button>
282
+ </DialogFooter>
283
+ </DialogContent>
284
+ </Dialog>
285
+ ```
286
+
287
+ ---
288
+
289
+ ## Dropdown Menu
290
+
291
+ ```jsx
292
+ import {
293
+ DropdownMenu,
294
+ DropdownMenuTrigger,
295
+ DropdownMenuContent,
296
+ DropdownMenuItem,
297
+ DropdownMenuLabel,
298
+ DropdownMenuSeparator,
299
+ DropdownMenuCheckboxItem,
300
+ DropdownMenuRadioGroup,
301
+ DropdownMenuRadioItem,
302
+ DropdownMenuSub,
303
+ DropdownMenuSubTrigger,
304
+ DropdownMenuSubContent,
305
+ } from '@sujanbomjan/react-crud-ui';
306
+
307
+ <DropdownMenu>
308
+ <DropdownMenuTrigger asChild>
309
+ <Button variant="ghost" size="icon">
310
+ <MoreHorizontal className="h-4 w-4" />
311
+ </Button>
312
+ </DropdownMenuTrigger>
313
+ <DropdownMenuContent align="end">
314
+ <DropdownMenuLabel>Actions</DropdownMenuLabel>
315
+ <DropdownMenuSeparator />
316
+ <DropdownMenuItem onClick={() => handleEdit(item)}>
317
+ <Edit className="h-4 w-4 mr-2" />
318
+ Edit
319
+ </DropdownMenuItem>
320
+ <DropdownMenuItem onClick={() => handleView(item)}>
321
+ <Eye className="h-4 w-4 mr-2" />
322
+ View
323
+ </DropdownMenuItem>
324
+ <DropdownMenuSeparator />
325
+ <DropdownMenuItem
326
+ onClick={() => handleDelete(item)}
327
+ className="text-destructive"
328
+ >
329
+ <Trash className="h-4 w-4 mr-2" />
330
+ Delete
331
+ </DropdownMenuItem>
332
+ </DropdownMenuContent>
333
+ </DropdownMenu>
334
+ ```
335
+
336
+ ---
337
+
338
+ ## Tabs
339
+
340
+ ```jsx
341
+ import { Tabs, TabsList, TabsTrigger, TabsContent } from '@sujanbomjan/react-crud-ui';
342
+ import { QTabs } from '@sujanbomjan/react-crud-ui';
343
+
344
+ // Basic Tabs
345
+ <Tabs defaultValue="tab1">
346
+ <TabsList>
347
+ <TabsTrigger value="tab1">Tab 1</TabsTrigger>
348
+ <TabsTrigger value="tab2">Tab 2</TabsTrigger>
349
+ <TabsTrigger value="tab3">Tab 3</TabsTrigger>
350
+ </TabsList>
351
+ <TabsContent value="tab1">Content 1</TabsContent>
352
+ <TabsContent value="tab2">Content 2</TabsContent>
353
+ <TabsContent value="tab3">Content 3</TabsContent>
354
+ </Tabs>
355
+
356
+ // QTabs - Quick tabs with config
357
+ const tabs = [
358
+ { value: 'overview', label: 'Overview', content: <Overview /> },
359
+ { value: 'analytics', label: 'Analytics', content: <Analytics /> },
360
+ { value: 'settings', label: 'Settings', content: <Settings /> },
361
+ ];
362
+
363
+ <QTabs tabs={tabs} defaultValue="overview" />
364
+ ```
365
+
366
+ ---
367
+
368
+ ## Table
369
+
370
+ ```jsx
371
+ import {
372
+ Table,
373
+ TableHeader,
374
+ TableBody,
375
+ TableFooter,
376
+ TableHead,
377
+ TableRow,
378
+ TableCell,
379
+ TableCaption,
380
+ } from '@sujanbomjan/react-crud-ui';
381
+
382
+ <Table>
383
+ <TableCaption>A list of recent invoices.</TableCaption>
384
+ <TableHeader>
385
+ <TableRow>
386
+ <TableHead>Invoice</TableHead>
387
+ <TableHead>Status</TableHead>
388
+ <TableHead>Method</TableHead>
389
+ <TableHead className="text-right">Amount</TableHead>
390
+ </TableRow>
391
+ </TableHeader>
392
+ <TableBody>
393
+ {invoices.map((invoice) => (
394
+ <TableRow key={invoice.id}>
395
+ <TableCell className="font-medium">{invoice.id}</TableCell>
396
+ <TableCell>{invoice.status}</TableCell>
397
+ <TableCell>{invoice.method}</TableCell>
398
+ <TableCell className="text-right">{invoice.amount}</TableCell>
399
+ </TableRow>
400
+ ))}
401
+ </TableBody>
402
+ <TableFooter>
403
+ <TableRow>
404
+ <TableCell colSpan={3}>Total</TableCell>
405
+ <TableCell className="text-right">$2,500.00</TableCell>
406
+ </TableRow>
407
+ </TableFooter>
408
+ </Table>
409
+ ```
410
+
411
+ ---
412
+
413
+ ## Avatar
414
+
415
+ ```jsx
416
+ import { Avatar, AvatarImage, AvatarFallback } from '@sujanbomjan/react-crud-ui';
417
+
418
+ <Avatar>
419
+ <AvatarImage src="/avatar.jpg" alt="User" />
420
+ <AvatarFallback>JD</AvatarFallback>
421
+ </Avatar>
422
+
423
+ // With size
424
+ <Avatar className="h-16 w-16">
425
+ <AvatarImage src="/avatar.jpg" alt="User" />
426
+ <AvatarFallback className="text-lg">JD</AvatarFallback>
427
+ </Avatar>
428
+ ```
429
+
430
+ ---
431
+
432
+ ## Tooltip
433
+
434
+ ```jsx
435
+ import {
436
+ Tooltip,
437
+ TooltipTrigger,
438
+ TooltipContent,
439
+ TooltipProvider
440
+ } from '@sujanbomjan/react-crud-ui';
441
+
442
+ // Wrap your app with TooltipProvider
443
+ <TooltipProvider>
444
+ <App />
445
+ </TooltipProvider>
446
+
447
+ // Usage
448
+ <Tooltip>
449
+ <TooltipTrigger asChild>
450
+ <Button variant="ghost" size="icon">
451
+ <Info className="h-4 w-4" />
452
+ </Button>
453
+ </TooltipTrigger>
454
+ <TooltipContent>
455
+ <p>This is helpful information</p>
456
+ </TooltipContent>
457
+ </Tooltip>
458
+ ```
459
+
460
+ ---
461
+
462
+ ## Date Picker
463
+
464
+ ```jsx
465
+ import { DatePicker, DateRangePicker } from '@sujanbomjan/react-crud-ui';
466
+
467
+ // Single date picker
468
+ const [date, setDate] = useState();
469
+ <DatePicker
470
+ date={date}
471
+ onDateChange={setDate}
472
+ placeholder="Pick a date"
473
+ />
474
+
475
+ // Date range picker
476
+ const [dateRange, setDateRange] = useState();
477
+ <DateRangePicker
478
+ dateRange={dateRange}
479
+ onDateRangeChange={setDateRange}
480
+ placeholder="Pick a date range"
481
+ />
482
+ ```
483
+
484
+ ---
485
+
486
+ ## Rich Text Editor
487
+
488
+ ```jsx
489
+ import { RichTextEditor } from '@sujanbomjan/react-crud-ui';
490
+
491
+ const [content, setContent] = useState('');
492
+
493
+ <RichTextEditor
494
+ value={content}
495
+ onChange={setContent}
496
+ placeholder="Start writing..."
497
+ height="300px"
498
+ />
499
+ ```
500
+
501
+ ---
502
+
503
+ ## Separator
504
+
505
+ ```jsx
506
+ import { Separator } from '@sujanbomjan/react-crud-ui';
507
+
508
+ // Horizontal
509
+ <div>
510
+ <h2>Section 1</h2>
511
+ <Separator className="my-4" />
512
+ <h2>Section 2</h2>
513
+ </div>
514
+
515
+ // Vertical
516
+ <div className="flex h-5 items-center space-x-4">
517
+ <span>Item 1</span>
518
+ <Separator orientation="vertical" />
519
+ <span>Item 2</span>
520
+ <Separator orientation="vertical" />
521
+ <span>Item 3</span>
522
+ </div>
523
+ ```
524
+
525
+ ---
526
+
527
+ ## Skeleton
528
+
529
+ ```jsx
530
+ import { Skeleton } from '@sujanbomjan/react-crud-ui';
531
+
532
+ // Basic skeleton
533
+ <Skeleton className="h-4 w-[250px]" />
534
+
535
+ // Card skeleton
536
+ <div className="flex items-center space-x-4">
537
+ <Skeleton className="h-12 w-12 rounded-full" />
538
+ <div className="space-y-2">
539
+ <Skeleton className="h-4 w-[250px]" />
540
+ <Skeleton className="h-4 w-[200px]" />
541
+ </div>
542
+ </div>
543
+
544
+ // Table skeleton
545
+ <div className="space-y-2">
546
+ {[1, 2, 3, 4, 5].map((i) => (
547
+ <Skeleton key={i} className="h-10 w-full" />
548
+ ))}
549
+ </div>
550
+ ```
551
+
552
+ ---
553
+
554
+ ## Alert
555
+
556
+ ```jsx
557
+ import {
558
+ Alert,
559
+ AlertTitle,
560
+ AlertDescription,
561
+ AlertWithIcon,
562
+ alertVariants
563
+ } from '@sujanbomjan/react-crud-ui';
564
+
565
+ // Basic alert
566
+ <Alert>
567
+ <AlertTitle>Heads up!</AlertTitle>
568
+ <AlertDescription>
569
+ You can add components to your app using the cli.
570
+ </AlertDescription>
571
+ </Alert>
572
+
573
+ // Destructive alert
574
+ <Alert variant="destructive">
575
+ <AlertTitle>Error</AlertTitle>
576
+ <AlertDescription>
577
+ Your session has expired. Please log in again.
578
+ </AlertDescription>
579
+ </Alert>
580
+
581
+ // With icon
582
+ <AlertWithIcon type="success" title="Success" message="Changes saved successfully" />
583
+ <AlertWithIcon type="error" title="Error" message="Something went wrong" />
584
+ <AlertWithIcon type="warning" title="Warning" message="This action cannot be undone" />
585
+ <AlertWithIcon type="info" title="Info" message="New features available" />
586
+ ```