@moontra/moonui-pro 2.4.6 → 2.5.1

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,311 @@
1
+ "use client"
2
+
3
+ import React from 'react'
4
+ import { Dashboard } from './index'
5
+ import { Widget, MetricData, ChartData, ActivityItem } from './types'
6
+ import { MetricCard } from './widgets/metric-card'
7
+ import { ChartWidget } from './widgets/chart-widget'
8
+ import { ActivityFeed } from './widgets/activity-feed'
9
+ import {
10
+ Users,
11
+ DollarSign,
12
+ ShoppingCart,
13
+ TrendingUp,
14
+ Package,
15
+ CreditCard,
16
+ Activity,
17
+ AlertCircle
18
+ } from 'lucide-react'
19
+
20
+ // Örnek metrik verileri
21
+ const sampleMetrics: MetricData[] = [
22
+ {
23
+ id: 'revenue',
24
+ title: 'Total Revenue',
25
+ value: 54234,
26
+ unit: '$',
27
+ change: { value: 12.5, type: 'increase', period: 'last month' },
28
+ icon: <DollarSign className="h-4 w-4" />,
29
+ color: 'success',
30
+ sparkline: [30, 40, 35, 50, 49, 60, 70, 91, 125],
31
+ target: 60000,
32
+ forecast: 58500
33
+ },
34
+ {
35
+ id: 'users',
36
+ title: 'Active Users',
37
+ value: 2453,
38
+ change: { value: 8.2, type: 'increase', period: 'last week' },
39
+ icon: <Users className="h-4 w-4" />,
40
+ color: 'primary',
41
+ sparkline: [200, 220, 210, 230, 225, 240, 254, 260, 245]
42
+ },
43
+ {
44
+ id: 'orders',
45
+ title: 'New Orders',
46
+ value: 846,
47
+ change: { value: 3.1, type: 'decrease', period: 'yesterday' },
48
+ icon: <ShoppingCart className="h-4 w-4" />,
49
+ color: 'warning',
50
+ sparkline: [80, 85, 90, 88, 85, 82, 84, 86, 84]
51
+ },
52
+ {
53
+ id: 'conversion',
54
+ title: 'Conversion Rate',
55
+ value: '3.24%',
56
+ change: { value: 0.5, type: 'increase', period: 'last month' },
57
+ icon: <TrendingUp className="h-4 w-4" />,
58
+ color: 'info',
59
+ sparkline: [2.8, 2.9, 3.0, 2.95, 3.1, 3.15, 3.2, 3.22, 3.24]
60
+ }
61
+ ]
62
+
63
+ // Örnek chart verileri
64
+ const revenueChartData: ChartData = {
65
+ type: 'area',
66
+ data: [
67
+ { name: 'Jan', revenue: 4000, profit: 2400, expenses: 1600 },
68
+ { name: 'Feb', revenue: 3000, profit: 1398, expenses: 1602 },
69
+ { name: 'Mar', revenue: 5000, profit: 3200, expenses: 1800 },
70
+ { name: 'Apr', revenue: 4500, profit: 2900, expenses: 1600 },
71
+ { name: 'May', revenue: 6000, profit: 3800, expenses: 2200 },
72
+ { name: 'Jun', revenue: 5500, profit: 3400, expenses: 2100 },
73
+ { name: 'Jul', revenue: 7000, profit: 4200, expenses: 2800 }
74
+ ]
75
+ }
76
+
77
+ const salesByProductData: ChartData = {
78
+ type: 'pie',
79
+ data: [
80
+ { name: 'Product A', value: 35 },
81
+ { name: 'Product B', value: 25 },
82
+ { name: 'Product C', value: 20 },
83
+ { name: 'Product D', value: 15 },
84
+ { name: 'Product E', value: 5 }
85
+ ]
86
+ }
87
+
88
+ const performanceData: ChartData = {
89
+ type: 'radar',
90
+ data: [
91
+ { subject: 'Sales', A: 120, B: 110, fullMark: 150 },
92
+ { subject: 'Marketing', A: 98, B: 130, fullMark: 150 },
93
+ { subject: 'Development', A: 86, B: 130, fullMark: 150 },
94
+ { subject: 'Customer Support', A: 99, B: 100, fullMark: 150 },
95
+ { subject: 'Technology', A: 85, B: 90, fullMark: 150 },
96
+ { subject: 'HR', A: 65, B: 85, fullMark: 150 }
97
+ ]
98
+ }
99
+
100
+ // Örnek aktivite verileri
101
+ const sampleActivities: ActivityItem[] = [
102
+ {
103
+ id: '1',
104
+ type: 'success',
105
+ title: 'completed a purchase',
106
+ description: 'Order #12345 - Premium Plan ($299)',
107
+ timestamp: new Date(Date.now() - 1000 * 60 * 5),
108
+ user: { name: 'John Doe', avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=John' },
109
+ icon: <CreditCard className="h-4 w-4" />
110
+ },
111
+ {
112
+ id: '2',
113
+ type: 'info',
114
+ title: 'deployed new version',
115
+ description: 'v2.1.0 deployed to production',
116
+ timestamp: new Date(Date.now() - 1000 * 60 * 15),
117
+ user: { name: 'Sarah Chen' },
118
+ icon: <Package className="h-4 w-4" />
119
+ },
120
+ {
121
+ id: '3',
122
+ type: 'warning',
123
+ title: 'high server load detected',
124
+ description: 'CPU usage above 80% on server-02',
125
+ timestamp: new Date(Date.now() - 1000 * 60 * 30),
126
+ icon: <AlertCircle className="h-4 w-4" />
127
+ },
128
+ {
129
+ id: '4',
130
+ type: 'success',
131
+ title: 'new user registered',
132
+ description: 'Welcome email sent',
133
+ timestamp: new Date(Date.now() - 1000 * 60 * 45),
134
+ user: { name: 'Mike Johnson' }
135
+ },
136
+ {
137
+ id: '5',
138
+ type: 'error',
139
+ title: 'payment failed',
140
+ description: 'Card declined - Order #12346',
141
+ timestamp: new Date(Date.now() - 1000 * 60 * 60),
142
+ user: { name: 'Emma Wilson' }
143
+ }
144
+ ]
145
+
146
+ // Örnek widget'lar
147
+ const sampleWidgets: Widget[] = [
148
+ // Metrik widget'ları
149
+ {
150
+ id: 'metric-revenue',
151
+ type: 'metric',
152
+ title: 'Revenue',
153
+ size: { w: 3, h: 2 },
154
+ position: { x: 0, y: 0 },
155
+ data: sampleMetrics[0]
156
+ },
157
+ {
158
+ id: 'metric-users',
159
+ type: 'metric',
160
+ title: 'Users',
161
+ size: { w: 3, h: 2 },
162
+ position: { x: 3, y: 0 },
163
+ data: sampleMetrics[1]
164
+ },
165
+ {
166
+ id: 'metric-orders',
167
+ type: 'metric',
168
+ title: 'Orders',
169
+ size: { w: 3, h: 2 },
170
+ position: { x: 6, y: 0 },
171
+ data: sampleMetrics[2]
172
+ },
173
+ {
174
+ id: 'metric-conversion',
175
+ type: 'metric',
176
+ title: 'Conversion',
177
+ size: { w: 3, h: 2 },
178
+ position: { x: 9, y: 0 },
179
+ data: sampleMetrics[3]
180
+ },
181
+ // Chart widget'ları
182
+ {
183
+ id: 'chart-revenue-trend',
184
+ type: 'chart',
185
+ title: 'Revenue Trend',
186
+ description: 'Monthly revenue, profit and expenses',
187
+ size: { w: 8, h: 4 },
188
+ position: { x: 0, y: 2 },
189
+ data: revenueChartData
190
+ },
191
+ {
192
+ id: 'chart-sales-by-product',
193
+ type: 'chart',
194
+ title: 'Sales by Product',
195
+ description: 'Product distribution',
196
+ size: { w: 4, h: 4 },
197
+ position: { x: 8, y: 2 },
198
+ data: salesByProductData
199
+ },
200
+ {
201
+ id: 'chart-performance',
202
+ type: 'chart',
203
+ title: 'Team Performance',
204
+ description: 'Department comparison',
205
+ size: { w: 6, h: 4 },
206
+ position: { x: 0, y: 6 },
207
+ data: performanceData
208
+ },
209
+ // Activity feed
210
+ {
211
+ id: 'activity-feed',
212
+ type: 'activity',
213
+ title: 'Recent Activity',
214
+ size: { w: 6, h: 4 },
215
+ position: { x: 6, y: 6 },
216
+ data: {
217
+ items: sampleActivities,
218
+ realtime: true
219
+ }
220
+ }
221
+ ]
222
+
223
+ export function DashboardDemo() {
224
+ return (
225
+ <div className="min-h-screen bg-background">
226
+ <Dashboard
227
+ title="Analytics Dashboard"
228
+ description="Real-time insights and performance metrics"
229
+ widgets={sampleWidgets}
230
+ editable={true}
231
+ realtime={true}
232
+ glassmorphism={true}
233
+ onWidgetAdd={(widget) => {
234
+ console.log('Widget added:', widget)
235
+ }}
236
+ onWidgetRemove={(widgetId) => {
237
+ console.log('Widget removed:', widgetId)
238
+ }}
239
+ onWidgetUpdate={(widgetId, updates) => {
240
+ console.log('Widget updated:', widgetId, updates)
241
+ }}
242
+ onExport={(format) => {
243
+ console.log('Export dashboard as:', format)
244
+ }}
245
+ />
246
+ </div>
247
+ )
248
+ }
249
+
250
+ // Standalone widget demos
251
+ export function MetricCardDemo() {
252
+ return (
253
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 p-6">
254
+ {sampleMetrics.map((metric) => (
255
+ <MetricCard
256
+ key={metric.id}
257
+ data={metric}
258
+ showSparkline={true}
259
+ showForecast={true}
260
+ interactive={true}
261
+ glassmorphism={true}
262
+ onAction={(action) => console.log('Metric action:', action)}
263
+ />
264
+ ))}
265
+ </div>
266
+ )
267
+ }
268
+
269
+ export function ChartWidgetDemo() {
270
+ return (
271
+ <div className="grid grid-cols-1 lg:grid-cols-2 gap-6 p-6">
272
+ <ChartWidget
273
+ id="demo-1"
274
+ title="Revenue Analysis"
275
+ description="Monthly revenue breakdown"
276
+ data={revenueChartData}
277
+ height={300}
278
+ interactive={true}
279
+ glassmorphism={true}
280
+ onAction={(action, data) => console.log('Chart action:', action, data)}
281
+ />
282
+ <ChartWidget
283
+ id="demo-2"
284
+ title="Product Sales"
285
+ description="Sales distribution by product"
286
+ data={salesByProductData}
287
+ height={300}
288
+ interactive={true}
289
+ glassmorphism={true}
290
+ />
291
+ </div>
292
+ )
293
+ }
294
+
295
+ export function ActivityFeedDemo() {
296
+ return (
297
+ <div className="max-w-2xl mx-auto p-6">
298
+ <ActivityFeed
299
+ items={sampleActivities}
300
+ title="System Activity"
301
+ height={400}
302
+ showFilters={true}
303
+ showNotifications={true}
304
+ glassmorphism={true}
305
+ realtime={true}
306
+ onItemClick={(item) => console.log('Activity clicked:', item)}
307
+ onAction={(action, data) => console.log('Feed action:', action, data)}
308
+ />
309
+ </div>
310
+ )
311
+ }