create-bluecopa-react-app 1.0.4 → 1.0.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 +47 -10
- package/bin/create-bluecopa-react-app.js +257 -51
- package/package.json +6 -5
- package/templates/latest/Agent.md +254 -0
- package/templates/latest/Dockerfile +22 -0
- package/templates/latest/README.md +157 -221
- package/templates/latest/app/app.css +134 -0
- package/templates/latest/app/app.tsx +46 -0
- package/templates/latest/app/components/app-sidebar.tsx +174 -0
- package/templates/latest/app/components/chart-area-interactive.tsx +290 -0
- package/templates/latest/app/components/data-table.tsx +807 -0
- package/templates/latest/app/components/nav-documents.tsx +92 -0
- package/templates/latest/app/components/nav-main.tsx +56 -0
- package/templates/latest/app/components/nav-secondary.tsx +42 -0
- package/templates/latest/app/components/nav-user.tsx +112 -0
- package/templates/latest/app/components/section-cards.tsx +102 -0
- package/templates/latest/app/components/site-header.tsx +19 -0
- package/templates/latest/app/components/ui/avatar.tsx +53 -0
- package/templates/latest/app/components/ui/badge.tsx +46 -0
- package/templates/latest/app/components/ui/breadcrumb.tsx +109 -0
- package/templates/latest/app/components/ui/button.tsx +58 -0
- package/templates/latest/app/components/ui/card.tsx +92 -0
- package/templates/latest/app/components/ui/chart.tsx +352 -0
- package/templates/latest/app/components/ui/checkbox.tsx +30 -0
- package/templates/latest/app/components/ui/drawer.tsx +139 -0
- package/templates/latest/app/components/ui/dropdown-menu.tsx +258 -0
- package/templates/latest/app/components/ui/input.tsx +21 -0
- package/templates/latest/app/components/ui/label.tsx +24 -0
- package/templates/latest/app/components/ui/select.tsx +183 -0
- package/templates/latest/app/components/ui/separator.tsx +26 -0
- package/templates/latest/app/components/ui/sheet.tsx +139 -0
- package/templates/latest/app/components/ui/sidebar.tsx +731 -0
- package/templates/latest/app/components/ui/skeleton.tsx +13 -0
- package/templates/latest/app/components/ui/sonner.tsx +23 -0
- package/templates/latest/app/components/ui/table.tsx +117 -0
- package/templates/latest/app/components/ui/tabs.tsx +66 -0
- package/templates/latest/app/components/ui/toggle-group.tsx +73 -0
- package/templates/latest/app/components/ui/toggle.tsx +47 -0
- package/templates/latest/app/components/ui/tooltip.tsx +59 -0
- package/templates/latest/app/dashboard/data.json +614 -0
- package/templates/latest/app/hooks/use-bluecopa-user.ts +37 -0
- package/templates/latest/app/hooks/use-mobile.ts +19 -0
- package/templates/latest/{src → app}/lib/utils.ts +1 -1
- package/templates/latest/app/main.tsx +12 -0
- package/templates/latest/app/routes/home.tsx +40 -0
- package/templates/latest/app/routes.tsx +15 -0
- package/templates/latest/{src → app}/single-spa.tsx +38 -28
- package/templates/latest/components.json +22 -0
- package/templates/latest/dist/assets/__federation_expose_App-DRwKKpS2.js +91 -0
- package/templates/latest/dist/assets/__federation_fn_import-CzfA7kmP.js +438 -0
- package/templates/latest/dist/assets/__federation_shared_react-Bp6HVBS4.js +16 -0
- package/templates/latest/dist/assets/__federation_shared_react-dom-BCcRGiYp.js +17 -0
- package/templates/latest/dist/assets/client-DgSav55y.js +12658 -0
- package/templates/latest/dist/assets/home-DOL6GrYV.js +54951 -0
- package/templates/latest/dist/assets/index-BzNimew1.js +69 -0
- package/templates/latest/dist/assets/index-DMFtQdNS.js +412 -0
- package/templates/latest/dist/assets/index-DdYpcDMk.js +60 -0
- package/templates/latest/dist/assets/remoteEntry.js +88 -0
- package/templates/latest/dist/assets/style-36A39bNN.css +3683 -0
- package/templates/latest/dist/avatars/shadcn.svg +6 -0
- package/templates/latest/dist/favicon.ico +0 -0
- package/templates/latest/dist/index.html +19 -0
- package/templates/latest/index.html +1 -1
- package/templates/latest/package-lock.json +1227 -3353
- package/templates/latest/package.json +47 -43
- package/templates/latest/pnpm-lock.yaml +4767 -0
- package/templates/latest/preview/index.html +32 -2
- package/templates/latest/public/avatars/shadcn.svg +6 -0
- package/templates/latest/public/favicon.ico +0 -0
- package/templates/latest/tsconfig.json +18 -11
- package/templates/latest/vite.config.ts +41 -41
- package/templates/latest/.env.example +0 -14
- package/templates/latest/.eslintrc.cjs +0 -42
- package/templates/latest/AGENT.md +0 -284
- package/templates/latest/clean.sh +0 -39
- package/templates/latest/postcss.config.cjs +0 -6
- package/templates/latest/public/bluecopa-logo.svg +0 -30
- package/templates/latest/public/favicon-32x32.png +0 -0
- package/templates/latest/public/favicon-96x96.png +0 -0
- package/templates/latest/setup.sh +0 -55
- package/templates/latest/src/App.tsx +0 -15
- package/templates/latest/src/components/layout/dashboard-header.tsx +0 -139
- package/templates/latest/src/components/layout/dashboard-layout.tsx +0 -29
- package/templates/latest/src/components/layout/sidebar.tsx +0 -54
- package/templates/latest/src/components/page/dashboard.tsx +0 -1506
- package/templates/latest/src/components/page/navbar.tsx +0 -104
- package/templates/latest/src/components/tables/data-grid.tsx +0 -439
- package/templates/latest/src/components/ui/alert.tsx +0 -59
- package/templates/latest/src/components/ui/avatar.tsx +0 -50
- package/templates/latest/src/components/ui/badge.tsx +0 -36
- package/templates/latest/src/components/ui/bluecopa-logo.tsx +0 -54
- package/templates/latest/src/components/ui/button.tsx +0 -58
- package/templates/latest/src/components/ui/card.tsx +0 -79
- package/templates/latest/src/components/ui/dropdown-menu.tsx +0 -200
- package/templates/latest/src/components/ui/input.tsx +0 -24
- package/templates/latest/src/components/ui/label.tsx +0 -23
- package/templates/latest/src/components/ui/select.tsx +0 -29
- package/templates/latest/src/hooks/use-api.ts +0 -55
- package/templates/latest/src/index.css +0 -59
- package/templates/latest/src/main.tsx +0 -13
- package/templates/latest/src/pages/Dashboard.tsx +0 -13
- package/templates/latest/src/pages/Home.tsx +0 -622
- package/templates/latest/src/providers/query-provider.tsx +0 -48
- package/templates/latest/src/types/api.ts +0 -78
- package/templates/latest/src/vite-env.d.ts +0 -11
- package/templates/latest/tailwind.config.js +0 -88
- package/templates/latest/tsconfig.app.json +0 -26
- package/templates/latest/tsconfig.node.json +0 -10
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { Link, useLocation } from 'react-router-dom'
|
|
2
|
-
import { cn } from '@/lib/utils'
|
|
3
|
-
import {
|
|
4
|
-
Home,
|
|
5
|
-
LayoutDashboard,
|
|
6
|
-
Menu,
|
|
7
|
-
X
|
|
8
|
-
} from 'lucide-react'
|
|
9
|
-
import { useState } from 'react'
|
|
10
|
-
import { BluecopaLogo } from "@/components/ui/bluecopa-logo";
|
|
11
|
-
|
|
12
|
-
const navigation = [
|
|
13
|
-
{ name: 'Home', href: '/', icon: Home },
|
|
14
|
-
{ name: 'Dashboard', href: '/dashboard', icon: LayoutDashboard },
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
export default function Navbar() {
|
|
18
|
-
const location = useLocation()
|
|
19
|
-
const [mobileMenuOpen, setMobileMenuOpen] = useState(false)
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<nav className="bg-[#041e42] border-b border-gray-200 sticky top-0 z-50">
|
|
23
|
-
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
24
|
-
<div className="flex justify-between h-16">
|
|
25
|
-
<div className="flex">
|
|
26
|
-
{/* Logo */}
|
|
27
|
-
<div className="flex-shrink-0 flex items-center">
|
|
28
|
-
<Link to="/" className="flex items-center space-x-2">
|
|
29
|
-
<BluecopaLogo className="h-6 w-6 text-white" />
|
|
30
|
-
<span className="text-xl font-bold text-white">Bluecopa</span>
|
|
31
|
-
</Link>
|
|
32
|
-
</div>
|
|
33
|
-
|
|
34
|
-
{/* Desktop Navigation */}
|
|
35
|
-
<div className="hidden sm:ml-6 sm:flex sm:space-x-8">
|
|
36
|
-
{navigation.map((item) => {
|
|
37
|
-
const isActive = location.pathname === item.href
|
|
38
|
-
return (
|
|
39
|
-
<Link
|
|
40
|
-
key={item.name}
|
|
41
|
-
to={item.href}
|
|
42
|
-
className={cn(
|
|
43
|
-
'inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium transition-colors',
|
|
44
|
-
isActive
|
|
45
|
-
? 'border-blue-400 text-white'
|
|
46
|
-
: 'border-transparent text-blue-200 hover:border-blue-300 hover:text-white'
|
|
47
|
-
)}
|
|
48
|
-
>
|
|
49
|
-
<item.icon className="h-4 w-4 mr-2" />
|
|
50
|
-
{item.name}
|
|
51
|
-
</Link>
|
|
52
|
-
)
|
|
53
|
-
})}
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
|
|
57
|
-
{/* Mobile menu button */}
|
|
58
|
-
<div className="sm:hidden flex items-center">
|
|
59
|
-
<button
|
|
60
|
-
type="button"
|
|
61
|
-
className="inline-flex items-center justify-center p-2 rounded-md text-blue-200 hover:text-white hover:bg-blue-700"
|
|
62
|
-
onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
|
|
63
|
-
>
|
|
64
|
-
{mobileMenuOpen ? (
|
|
65
|
-
<X className="h-6 w-6" />
|
|
66
|
-
) : (
|
|
67
|
-
<Menu className="h-6 w-6" />
|
|
68
|
-
)}
|
|
69
|
-
</button>
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
</div>
|
|
73
|
-
|
|
74
|
-
{/* Mobile menu */}
|
|
75
|
-
{mobileMenuOpen && (
|
|
76
|
-
<div className="sm:hidden">
|
|
77
|
-
<div className="pt-2 pb-3 space-y-1 bg-[#041e42]">
|
|
78
|
-
{navigation.map((item) => {
|
|
79
|
-
const isActive = location.pathname === item.href
|
|
80
|
-
return (
|
|
81
|
-
<Link
|
|
82
|
-
key={item.name}
|
|
83
|
-
to={item.href}
|
|
84
|
-
className={cn(
|
|
85
|
-
'block pl-3 pr-4 py-2 text-base font-medium transition-colors',
|
|
86
|
-
isActive
|
|
87
|
-
? 'bg-blue-700 border-r-4 border-blue-400 text-white'
|
|
88
|
-
: 'text-blue-200 hover:text-white hover:bg-blue-700'
|
|
89
|
-
)}
|
|
90
|
-
onClick={() => setMobileMenuOpen(false)}
|
|
91
|
-
>
|
|
92
|
-
<div className="flex items-center">
|
|
93
|
-
<item.icon className="h-5 w-5 mr-3" />
|
|
94
|
-
{item.name}
|
|
95
|
-
</div>
|
|
96
|
-
</Link>
|
|
97
|
-
)
|
|
98
|
-
})}
|
|
99
|
-
</div>
|
|
100
|
-
</div>
|
|
101
|
-
)}
|
|
102
|
-
</nav>
|
|
103
|
-
)
|
|
104
|
-
}
|
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useState, useMemo } from 'react'
|
|
4
|
-
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
|
5
|
-
import { Button } from '@/components/ui/button'
|
|
6
|
-
import { Badge } from '@/components/ui/badge'
|
|
7
|
-
import { Input } from '@/components/ui/input'
|
|
8
|
-
import {
|
|
9
|
-
ArrowUpDown,
|
|
10
|
-
ChevronLeft,
|
|
11
|
-
ChevronRight,
|
|
12
|
-
Search,
|
|
13
|
-
Download,
|
|
14
|
-
Filter,
|
|
15
|
-
MoreVertical
|
|
16
|
-
} from 'lucide-react'
|
|
17
|
-
|
|
18
|
-
interface DataGridColumn {
|
|
19
|
-
key: string
|
|
20
|
-
title: string
|
|
21
|
-
sortable?: boolean
|
|
22
|
-
filterable?: boolean
|
|
23
|
-
formatter?: (value: any) => React.ReactNode
|
|
24
|
-
align?: 'left' | 'center' | 'right'
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface DataGridProps {
|
|
28
|
-
data: any[]
|
|
29
|
-
columns: DataGridColumn[]
|
|
30
|
-
pageSize?: number
|
|
31
|
-
title?: string
|
|
32
|
-
description?: string
|
|
33
|
-
searchable?: boolean
|
|
34
|
-
exportable?: boolean
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Sample data for demonstration
|
|
38
|
-
const sampleData = [
|
|
39
|
-
{
|
|
40
|
-
id: 'TXN-001',
|
|
41
|
-
customer: 'John Doe',
|
|
42
|
-
amount: 1250.00,
|
|
43
|
-
category: 'Electronics',
|
|
44
|
-
payment_method: 'Credit Card',
|
|
45
|
-
status: 'Completed',
|
|
46
|
-
date: '2024-01-15'
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
id: 'TXN-002',
|
|
50
|
-
customer: 'Jane Smith',
|
|
51
|
-
amount: 890.50,
|
|
52
|
-
category: 'Clothing',
|
|
53
|
-
payment_method: 'PayPal',
|
|
54
|
-
status: 'Pending',
|
|
55
|
-
date: '2024-01-14'
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
id: 'TXN-003',
|
|
59
|
-
customer: 'Bob Johnson',
|
|
60
|
-
amount: 2100.75,
|
|
61
|
-
category: 'Home & Garden',
|
|
62
|
-
payment_method: 'Bank Transfer',
|
|
63
|
-
status: 'Completed',
|
|
64
|
-
date: '2024-01-13'
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
id: 'TXN-004',
|
|
68
|
-
customer: 'Alice Brown',
|
|
69
|
-
amount: 675.25,
|
|
70
|
-
category: 'Books',
|
|
71
|
-
payment_method: 'Credit Card',
|
|
72
|
-
status: 'Failed',
|
|
73
|
-
date: '2024-01-12'
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
id: 'TXN-005',
|
|
77
|
-
customer: 'Charlie Wilson',
|
|
78
|
-
amount: 1450.00,
|
|
79
|
-
category: 'Sports',
|
|
80
|
-
payment_method: 'Cash',
|
|
81
|
-
status: 'Completed',
|
|
82
|
-
date: '2024-01-11'
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: 'TXN-006',
|
|
86
|
-
customer: 'Diana Davis',
|
|
87
|
-
amount: 320.80,
|
|
88
|
-
category: 'Beauty',
|
|
89
|
-
payment_method: 'Credit Card',
|
|
90
|
-
status: 'Completed',
|
|
91
|
-
date: '2024-01-10'
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
id: 'TXN-007',
|
|
95
|
-
customer: 'Eve Martinez',
|
|
96
|
-
amount: 1875.90,
|
|
97
|
-
category: 'Electronics',
|
|
98
|
-
payment_method: 'PayPal',
|
|
99
|
-
status: 'Pending',
|
|
100
|
-
date: '2024-01-09'
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
id: 'TXN-008',
|
|
104
|
-
customer: 'Frank Garcia',
|
|
105
|
-
amount: 540.25,
|
|
106
|
-
category: 'Clothing',
|
|
107
|
-
payment_method: 'Bank Transfer',
|
|
108
|
-
status: 'Completed',
|
|
109
|
-
date: '2024-01-08'
|
|
110
|
-
}
|
|
111
|
-
]
|
|
112
|
-
|
|
113
|
-
const sampleColumns: DataGridColumn[] = [
|
|
114
|
-
{
|
|
115
|
-
key: 'id',
|
|
116
|
-
title: 'Transaction ID',
|
|
117
|
-
sortable: true,
|
|
118
|
-
filterable: true,
|
|
119
|
-
formatter: (value) => <span className="font-mono text-sm">{value}</span>
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
key: 'customer',
|
|
123
|
-
title: 'Customer',
|
|
124
|
-
sortable: true,
|
|
125
|
-
filterable: true,
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
key: 'amount',
|
|
129
|
-
title: 'Amount',
|
|
130
|
-
sortable: true,
|
|
131
|
-
align: 'right',
|
|
132
|
-
formatter: (value) => <span className="font-semibold">${value.toLocaleString()}</span>
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
key: 'category',
|
|
136
|
-
title: 'Category',
|
|
137
|
-
sortable: true,
|
|
138
|
-
filterable: true,
|
|
139
|
-
formatter: (value) => <Badge variant="outline">{value}</Badge>
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
key: 'payment_method',
|
|
143
|
-
title: 'Payment Method',
|
|
144
|
-
sortable: true,
|
|
145
|
-
filterable: true,
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
key: 'status',
|
|
149
|
-
title: 'Status',
|
|
150
|
-
sortable: true,
|
|
151
|
-
filterable: true,
|
|
152
|
-
formatter: (value) => (
|
|
153
|
-
<Badge
|
|
154
|
-
variant={value === 'Completed' ? 'default' : value === 'Pending' ? 'secondary' : 'destructive'}
|
|
155
|
-
>
|
|
156
|
-
{value}
|
|
157
|
-
</Badge>
|
|
158
|
-
)
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
key: 'date',
|
|
162
|
-
title: 'Date',
|
|
163
|
-
sortable: true,
|
|
164
|
-
formatter: (value) => new Date(value).toLocaleDateString()
|
|
165
|
-
}
|
|
166
|
-
]
|
|
167
|
-
|
|
168
|
-
export function DataGrid({
|
|
169
|
-
data = sampleData,
|
|
170
|
-
columns = sampleColumns,
|
|
171
|
-
pageSize = 10,
|
|
172
|
-
title = "Data Table",
|
|
173
|
-
description = "Advanced data table with sorting, filtering, and pagination",
|
|
174
|
-
searchable = true,
|
|
175
|
-
exportable = true
|
|
176
|
-
}: DataGridProps) {
|
|
177
|
-
const [currentPage, setCurrentPage] = useState(1)
|
|
178
|
-
const [sortColumn, setSortColumn] = useState<string | null>(null)
|
|
179
|
-
const [sortDirection, setSortDirection] = useState<'asc' | 'desc'>('asc')
|
|
180
|
-
const [searchTerm, setSearchTerm] = useState('')
|
|
181
|
-
const [filters, setFilters] = useState<Record<string, string>>({})
|
|
182
|
-
|
|
183
|
-
// Filter and search data
|
|
184
|
-
const filteredData = useMemo(() => {
|
|
185
|
-
let result = data
|
|
186
|
-
|
|
187
|
-
// Apply search
|
|
188
|
-
if (searchTerm) {
|
|
189
|
-
result = result.filter(row =>
|
|
190
|
-
Object.values(row).some(value =>
|
|
191
|
-
String(value).toLowerCase().includes(searchTerm.toLowerCase())
|
|
192
|
-
)
|
|
193
|
-
)
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Apply column filters
|
|
197
|
-
Object.entries(filters).forEach(([column, filterValue]) => {
|
|
198
|
-
if (filterValue) {
|
|
199
|
-
result = result.filter(row =>
|
|
200
|
-
String(row[column]).toLowerCase().includes(filterValue.toLowerCase())
|
|
201
|
-
)
|
|
202
|
-
}
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
return result
|
|
206
|
-
}, [data, searchTerm, filters])
|
|
207
|
-
|
|
208
|
-
// Sort data
|
|
209
|
-
const sortedData = useMemo(() => {
|
|
210
|
-
if (!sortColumn) return filteredData
|
|
211
|
-
|
|
212
|
-
return [...filteredData].sort((a, b) => {
|
|
213
|
-
const aValue = a[sortColumn]
|
|
214
|
-
const bValue = b[sortColumn]
|
|
215
|
-
|
|
216
|
-
let comparison = 0
|
|
217
|
-
if (aValue < bValue) comparison = -1
|
|
218
|
-
if (aValue > bValue) comparison = 1
|
|
219
|
-
|
|
220
|
-
return sortDirection === 'desc' ? comparison * -1 : comparison
|
|
221
|
-
})
|
|
222
|
-
}, [filteredData, sortColumn, sortDirection])
|
|
223
|
-
|
|
224
|
-
// Paginate data
|
|
225
|
-
const paginatedData = useMemo(() => {
|
|
226
|
-
const startIndex = (currentPage - 1) * pageSize
|
|
227
|
-
return sortedData.slice(startIndex, startIndex + pageSize)
|
|
228
|
-
}, [sortedData, currentPage, pageSize])
|
|
229
|
-
|
|
230
|
-
const totalPages = Math.ceil(sortedData.length / pageSize)
|
|
231
|
-
|
|
232
|
-
const handleSort = (column: string) => {
|
|
233
|
-
if (sortColumn === column) {
|
|
234
|
-
setSortDirection(sortDirection === 'asc' ? 'desc' : 'asc')
|
|
235
|
-
} else {
|
|
236
|
-
setSortColumn(column)
|
|
237
|
-
setSortDirection('asc')
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const handleColumnFilter = (column: string, value: string) => {
|
|
242
|
-
setFilters(prev => ({ ...prev, [column]: value }))
|
|
243
|
-
setCurrentPage(1) // Reset to first page when filtering
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const exportToCSV = () => {
|
|
247
|
-
const headers = columns.map(col => col.title)
|
|
248
|
-
const csvContent = [
|
|
249
|
-
headers.join(','),
|
|
250
|
-
...sortedData.map(row =>
|
|
251
|
-
columns.map(col => row[col.key]).join(',')
|
|
252
|
-
)
|
|
253
|
-
].join('\n')
|
|
254
|
-
|
|
255
|
-
const blob = new Blob([csvContent], { type: 'text/csv' })
|
|
256
|
-
const url = window.URL.createObjectURL(blob)
|
|
257
|
-
const a = document.createElement('a')
|
|
258
|
-
a.href = url
|
|
259
|
-
a.download = 'data-export.csv'
|
|
260
|
-
a.click()
|
|
261
|
-
window.URL.revokeObjectURL(url)
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
return (
|
|
265
|
-
<Card>
|
|
266
|
-
<CardHeader>
|
|
267
|
-
<div className="flex items-center justify-between">
|
|
268
|
-
<div>
|
|
269
|
-
<CardTitle>{title}</CardTitle>
|
|
270
|
-
<CardDescription>{description}</CardDescription>
|
|
271
|
-
</div>
|
|
272
|
-
<div className="flex items-center space-x-2">
|
|
273
|
-
{exportable && (
|
|
274
|
-
<Button variant="outline" size="sm" onClick={exportToCSV}>
|
|
275
|
-
<Download className="h-4 w-4 mr-2" />
|
|
276
|
-
Export
|
|
277
|
-
</Button>
|
|
278
|
-
)}
|
|
279
|
-
<Button variant="outline" size="sm">
|
|
280
|
-
<Filter className="h-4 w-4 mr-2" />
|
|
281
|
-
Filters
|
|
282
|
-
</Button>
|
|
283
|
-
<Button variant="outline" size="sm">
|
|
284
|
-
<MoreVertical className="h-4 w-4" />
|
|
285
|
-
</Button>
|
|
286
|
-
</div>
|
|
287
|
-
</div>
|
|
288
|
-
|
|
289
|
-
{searchable && (
|
|
290
|
-
<div className="flex items-center space-x-2 mt-4">
|
|
291
|
-
<div className="relative flex-1 max-w-sm">
|
|
292
|
-
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 h-4 w-4" />
|
|
293
|
-
<Input
|
|
294
|
-
placeholder="Search all columns..."
|
|
295
|
-
value={searchTerm}
|
|
296
|
-
onChange={(e) => setSearchTerm(e.target.value)}
|
|
297
|
-
className="pl-10"
|
|
298
|
-
/>
|
|
299
|
-
</div>
|
|
300
|
-
<div className="text-sm text-gray-500">
|
|
301
|
-
Showing {sortedData.length} of {data.length} results
|
|
302
|
-
</div>
|
|
303
|
-
</div>
|
|
304
|
-
)}
|
|
305
|
-
</CardHeader>
|
|
306
|
-
|
|
307
|
-
<CardContent>
|
|
308
|
-
<div className="overflow-x-auto">
|
|
309
|
-
<table className="w-full border-collapse">
|
|
310
|
-
<thead>
|
|
311
|
-
<tr className="border-b">
|
|
312
|
-
{columns.map((column) => (
|
|
313
|
-
<th
|
|
314
|
-
key={column.key}
|
|
315
|
-
className={`px-4 py-3 text-left font-medium text-gray-900 ${
|
|
316
|
-
column.align === 'right' ? 'text-right' :
|
|
317
|
-
column.align === 'center' ? 'text-center' : 'text-left'
|
|
318
|
-
}`}
|
|
319
|
-
>
|
|
320
|
-
<div className="flex items-center space-x-2">
|
|
321
|
-
<span>{column.title}</span>
|
|
322
|
-
{column.sortable && (
|
|
323
|
-
<Button
|
|
324
|
-
variant="ghost"
|
|
325
|
-
size="sm"
|
|
326
|
-
className="h-6 w-6 p-0"
|
|
327
|
-
onClick={() => handleSort(column.key)}
|
|
328
|
-
>
|
|
329
|
-
<ArrowUpDown className="h-3 w-3" />
|
|
330
|
-
</Button>
|
|
331
|
-
)}
|
|
332
|
-
</div>
|
|
333
|
-
{column.filterable && (
|
|
334
|
-
<Input
|
|
335
|
-
placeholder="Filter..."
|
|
336
|
-
size={10}
|
|
337
|
-
className="mt-1 h-7 text-xs"
|
|
338
|
-
onChange={(e) => handleColumnFilter(column.key, e.target.value)}
|
|
339
|
-
/>
|
|
340
|
-
)}
|
|
341
|
-
</th>
|
|
342
|
-
))}
|
|
343
|
-
</tr>
|
|
344
|
-
</thead>
|
|
345
|
-
<tbody>
|
|
346
|
-
{paginatedData.map((row, index) => (
|
|
347
|
-
<tr
|
|
348
|
-
key={index}
|
|
349
|
-
className="border-b hover:bg-gray-50 transition-colors"
|
|
350
|
-
>
|
|
351
|
-
{columns.map((column) => (
|
|
352
|
-
<td
|
|
353
|
-
key={column.key}
|
|
354
|
-
className={`px-4 py-3 ${
|
|
355
|
-
column.align === 'right' ? 'text-right' :
|
|
356
|
-
column.align === 'center' ? 'text-center' : 'text-left'
|
|
357
|
-
}`}
|
|
358
|
-
>
|
|
359
|
-
{column.formatter ? column.formatter(row[column.key]) : row[column.key]}
|
|
360
|
-
</td>
|
|
361
|
-
))}
|
|
362
|
-
</tr>
|
|
363
|
-
))}
|
|
364
|
-
</tbody>
|
|
365
|
-
</table>
|
|
366
|
-
</div>
|
|
367
|
-
|
|
368
|
-
{/* Pagination */}
|
|
369
|
-
<div className="flex items-center justify-between mt-4">
|
|
370
|
-
<div className="text-sm text-gray-500">
|
|
371
|
-
Page {currentPage} of {totalPages} ({sortedData.length} total items)
|
|
372
|
-
</div>
|
|
373
|
-
<div className="flex items-center space-x-2">
|
|
374
|
-
<Button
|
|
375
|
-
variant="outline"
|
|
376
|
-
size="sm"
|
|
377
|
-
onClick={() => setCurrentPage(Math.max(1, currentPage - 1))}
|
|
378
|
-
disabled={currentPage === 1}
|
|
379
|
-
>
|
|
380
|
-
<ChevronLeft className="h-4 w-4" />
|
|
381
|
-
</Button>
|
|
382
|
-
|
|
383
|
-
{/* Page numbers */}
|
|
384
|
-
{Array.from({ length: Math.min(5, totalPages) }, (_, i) => {
|
|
385
|
-
const pageNum = Math.max(1, currentPage - 2) + i
|
|
386
|
-
if (pageNum > totalPages) return null
|
|
387
|
-
|
|
388
|
-
return (
|
|
389
|
-
<Button
|
|
390
|
-
key={pageNum}
|
|
391
|
-
variant={pageNum === currentPage ? "default" : "outline"}
|
|
392
|
-
size="sm"
|
|
393
|
-
onClick={() => setCurrentPage(pageNum)}
|
|
394
|
-
>
|
|
395
|
-
{pageNum}
|
|
396
|
-
</Button>
|
|
397
|
-
)
|
|
398
|
-
})}
|
|
399
|
-
|
|
400
|
-
<Button
|
|
401
|
-
variant="outline"
|
|
402
|
-
size="sm"
|
|
403
|
-
onClick={() => setCurrentPage(Math.min(totalPages, currentPage + 1))}
|
|
404
|
-
disabled={currentPage === totalPages}
|
|
405
|
-
>
|
|
406
|
-
<ChevronRight className="h-4 w-4" />
|
|
407
|
-
</Button>
|
|
408
|
-
</div>
|
|
409
|
-
</div>
|
|
410
|
-
</CardContent>
|
|
411
|
-
</Card>
|
|
412
|
-
)
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
// Example usage component
|
|
416
|
-
export function TableExamples() {
|
|
417
|
-
return (
|
|
418
|
-
<div className="space-y-8">
|
|
419
|
-
<DataGrid
|
|
420
|
-
data={sampleData}
|
|
421
|
-
columns={sampleColumns}
|
|
422
|
-
title="Transaction Records"
|
|
423
|
-
description="Complete transaction history with advanced filtering and sorting"
|
|
424
|
-
pageSize={5}
|
|
425
|
-
/>
|
|
426
|
-
|
|
427
|
-
{/* Compact version */}
|
|
428
|
-
<DataGrid
|
|
429
|
-
data={sampleData.slice(0, 4)}
|
|
430
|
-
columns={sampleColumns.slice(0, 4)}
|
|
431
|
-
title="Quick Overview"
|
|
432
|
-
description="Simplified view of recent transactions"
|
|
433
|
-
pageSize={10}
|
|
434
|
-
searchable={false}
|
|
435
|
-
exportable={false}
|
|
436
|
-
/>
|
|
437
|
-
</div>
|
|
438
|
-
)
|
|
439
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
-
|
|
4
|
-
import { cn } from "@/lib/utils"
|
|
5
|
-
|
|
6
|
-
const alertVariants = cva(
|
|
7
|
-
"relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",
|
|
8
|
-
{
|
|
9
|
-
variants: {
|
|
10
|
-
variant: {
|
|
11
|
-
default: "bg-background text-foreground",
|
|
12
|
-
destructive:
|
|
13
|
-
"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
defaultVariants: {
|
|
17
|
-
variant: "default",
|
|
18
|
-
},
|
|
19
|
-
}
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
const Alert = React.forwardRef<
|
|
23
|
-
HTMLDivElement,
|
|
24
|
-
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
|
|
25
|
-
>(({ className, variant, ...props }, ref) => (
|
|
26
|
-
<div
|
|
27
|
-
ref={ref}
|
|
28
|
-
role="alert"
|
|
29
|
-
className={cn(alertVariants({ variant }), className)}
|
|
30
|
-
{...props}
|
|
31
|
-
/>
|
|
32
|
-
))
|
|
33
|
-
Alert.displayName = "Alert"
|
|
34
|
-
|
|
35
|
-
const AlertTitle = React.forwardRef<
|
|
36
|
-
HTMLParagraphElement,
|
|
37
|
-
React.HTMLAttributes<HTMLHeadingElement>
|
|
38
|
-
>(({ className, ...props }, ref) => (
|
|
39
|
-
<h5
|
|
40
|
-
ref={ref}
|
|
41
|
-
className={cn("mb-1 font-medium leading-none tracking-tight", className)}
|
|
42
|
-
{...props}
|
|
43
|
-
/>
|
|
44
|
-
))
|
|
45
|
-
AlertTitle.displayName = "AlertTitle"
|
|
46
|
-
|
|
47
|
-
const AlertDescription = React.forwardRef<
|
|
48
|
-
HTMLParagraphElement,
|
|
49
|
-
React.HTMLAttributes<HTMLParagraphElement>
|
|
50
|
-
>(({ className, ...props }, ref) => (
|
|
51
|
-
<div
|
|
52
|
-
ref={ref}
|
|
53
|
-
className={cn("text-sm [&_p]:leading-relaxed", className)}
|
|
54
|
-
{...props}
|
|
55
|
-
/>
|
|
56
|
-
))
|
|
57
|
-
AlertDescription.displayName = "AlertDescription"
|
|
58
|
-
|
|
59
|
-
export { Alert, AlertTitle, AlertDescription }
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import * as AvatarPrimitive from "@radix-ui/react-avatar"
|
|
5
|
-
|
|
6
|
-
import { cn } from "@/lib/utils"
|
|
7
|
-
|
|
8
|
-
const Avatar = React.forwardRef<
|
|
9
|
-
React.ElementRef<typeof AvatarPrimitive.Root>,
|
|
10
|
-
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
|
|
11
|
-
>(({ className, ...props }, ref) => (
|
|
12
|
-
<AvatarPrimitive.Root
|
|
13
|
-
ref={ref}
|
|
14
|
-
className={cn(
|
|
15
|
-
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
|
|
16
|
-
className
|
|
17
|
-
)}
|
|
18
|
-
{...props}
|
|
19
|
-
/>
|
|
20
|
-
))
|
|
21
|
-
Avatar.displayName = AvatarPrimitive.Root.displayName
|
|
22
|
-
|
|
23
|
-
const AvatarImage = React.forwardRef<
|
|
24
|
-
React.ElementRef<typeof AvatarPrimitive.Image>,
|
|
25
|
-
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
|
26
|
-
>(({ className, ...props }, ref) => (
|
|
27
|
-
<AvatarPrimitive.Image
|
|
28
|
-
ref={ref}
|
|
29
|
-
className={cn("aspect-square h-full w-full", className)}
|
|
30
|
-
{...props}
|
|
31
|
-
/>
|
|
32
|
-
))
|
|
33
|
-
AvatarImage.displayName = AvatarPrimitive.Image.displayName
|
|
34
|
-
|
|
35
|
-
const AvatarFallback = React.forwardRef<
|
|
36
|
-
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
|
37
|
-
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
|
38
|
-
>(({ className, ...props }, ref) => (
|
|
39
|
-
<AvatarPrimitive.Fallback
|
|
40
|
-
ref={ref}
|
|
41
|
-
className={cn(
|
|
42
|
-
"flex h-full w-full items-center justify-center rounded-full bg-muted",
|
|
43
|
-
className
|
|
44
|
-
)}
|
|
45
|
-
{...props}
|
|
46
|
-
/>
|
|
47
|
-
))
|
|
48
|
-
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName
|
|
49
|
-
|
|
50
|
-
export { Avatar, AvatarImage, AvatarFallback }
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
-
|
|
4
|
-
import { cn } from "@/lib/utils"
|
|
5
|
-
|
|
6
|
-
const badgeVariants = cva(
|
|
7
|
-
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
8
|
-
{
|
|
9
|
-
variants: {
|
|
10
|
-
variant: {
|
|
11
|
-
default:
|
|
12
|
-
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
|
|
13
|
-
secondary:
|
|
14
|
-
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
15
|
-
destructive:
|
|
16
|
-
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
|
17
|
-
outline: "text-foreground",
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
defaultVariants: {
|
|
21
|
-
variant: "default",
|
|
22
|
-
},
|
|
23
|
-
}
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
export interface BadgeProps
|
|
27
|
-
extends React.HTMLAttributes<HTMLDivElement>,
|
|
28
|
-
VariantProps<typeof badgeVariants> {}
|
|
29
|
-
|
|
30
|
-
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
31
|
-
return (
|
|
32
|
-
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { Badge, badgeVariants }
|