@moontra/moonui-pro 2.0.22 → 2.1.0

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.
Files changed (99) hide show
  1. package/dist/index.mjs +215 -214
  2. package/package.json +4 -2
  3. package/src/__tests__/use-intersection-observer.test.tsx +216 -0
  4. package/src/__tests__/use-local-storage.test.tsx +174 -0
  5. package/src/__tests__/use-pro-access.test.tsx +183 -0
  6. package/src/components/advanced-chart/advanced-chart.test.tsx +281 -0
  7. package/src/components/advanced-chart/index.tsx +412 -0
  8. package/src/components/advanced-forms/index.tsx +431 -0
  9. package/src/components/animated-button/index.tsx +202 -0
  10. package/src/components/calendar/event-dialog.tsx +372 -0
  11. package/src/components/calendar/index.tsx +557 -0
  12. package/src/components/color-picker/index.tsx +434 -0
  13. package/src/components/dashboard/index.tsx +334 -0
  14. package/src/components/data-table/data-table.test.tsx +187 -0
  15. package/src/components/data-table/index.tsx +368 -0
  16. package/src/components/draggable-list/index.tsx +100 -0
  17. package/src/components/enhanced/button.tsx +360 -0
  18. package/src/components/enhanced/card.tsx +272 -0
  19. package/src/components/enhanced/dialog.tsx +248 -0
  20. package/src/components/enhanced/index.ts +3 -0
  21. package/src/components/error-boundary/index.tsx +111 -0
  22. package/src/components/file-upload/file-upload.test.tsx +242 -0
  23. package/src/components/file-upload/index.tsx +362 -0
  24. package/src/components/floating-action-button/index.tsx +209 -0
  25. package/src/components/github-stars/index.tsx +414 -0
  26. package/src/components/health-check/index.tsx +441 -0
  27. package/src/components/hover-card-3d/index.tsx +170 -0
  28. package/src/components/index.ts +76 -0
  29. package/src/components/kanban/index.tsx +436 -0
  30. package/src/components/lazy-component/index.tsx +342 -0
  31. package/src/components/magnetic-button/index.tsx +170 -0
  32. package/src/components/memory-efficient-data/index.tsx +352 -0
  33. package/src/components/optimized-image/index.tsx +427 -0
  34. package/src/components/performance-debugger/index.tsx +591 -0
  35. package/src/components/performance-monitor/index.tsx +775 -0
  36. package/src/components/pinch-zoom/index.tsx +172 -0
  37. package/src/components/rich-text-editor/index-old-backup.tsx +443 -0
  38. package/src/components/rich-text-editor/index.tsx +1537 -0
  39. package/src/components/rich-text-editor/slash-commands-extension.ts +220 -0
  40. package/src/components/rich-text-editor/slash-commands.css +35 -0
  41. package/src/components/rich-text-editor/table-styles.css +65 -0
  42. package/src/components/spotlight-card/index.tsx +194 -0
  43. package/src/components/swipeable-card/index.tsx +100 -0
  44. package/src/components/timeline/index.tsx +333 -0
  45. package/src/components/ui/animated-button.tsx +185 -0
  46. package/src/components/ui/avatar.tsx +135 -0
  47. package/src/components/ui/badge.tsx +225 -0
  48. package/src/components/ui/button.tsx +221 -0
  49. package/src/components/ui/card.tsx +141 -0
  50. package/src/components/ui/checkbox.tsx +256 -0
  51. package/src/components/ui/color-picker.tsx +95 -0
  52. package/src/components/ui/dialog.tsx +332 -0
  53. package/src/components/ui/dropdown-menu.tsx +200 -0
  54. package/src/components/ui/hover-card-3d.tsx +103 -0
  55. package/src/components/ui/index.ts +33 -0
  56. package/src/components/ui/input.tsx +219 -0
  57. package/src/components/ui/label.tsx +26 -0
  58. package/src/components/ui/magnetic-button.tsx +129 -0
  59. package/src/components/ui/popover.tsx +183 -0
  60. package/src/components/ui/select.tsx +273 -0
  61. package/src/components/ui/separator.tsx +140 -0
  62. package/src/components/ui/slider.tsx +351 -0
  63. package/src/components/ui/spotlight-card.tsx +119 -0
  64. package/src/components/ui/switch.tsx +83 -0
  65. package/src/components/ui/tabs.tsx +195 -0
  66. package/src/components/ui/textarea.tsx +25 -0
  67. package/src/components/ui/toast.tsx +313 -0
  68. package/src/components/ui/tooltip.tsx +152 -0
  69. package/src/components/virtual-list/index.tsx +369 -0
  70. package/src/hooks/use-chart.ts +205 -0
  71. package/src/hooks/use-data-table.ts +182 -0
  72. package/src/hooks/use-docs-pro-access.ts +13 -0
  73. package/src/hooks/use-license-check.ts +65 -0
  74. package/src/hooks/use-subscription.ts +19 -0
  75. package/src/index.ts +14 -0
  76. package/src/lib/micro-interactions.ts +255 -0
  77. package/src/lib/utils.ts +6 -0
  78. package/src/patterns/login-form/index.tsx +276 -0
  79. package/src/patterns/login-form/types.ts +67 -0
  80. package/src/setupTests.ts +41 -0
  81. package/src/styles/design-system.css +365 -0
  82. package/src/styles/index.css +4 -0
  83. package/src/styles/tailwind.css +6 -0
  84. package/src/styles/tokens.css +453 -0
  85. package/src/types/moonui.d.ts +22 -0
  86. package/src/use-intersection-observer.tsx +154 -0
  87. package/src/use-local-storage.tsx +71 -0
  88. package/src/use-paddle.ts +138 -0
  89. package/src/use-performance-optimizer.ts +379 -0
  90. package/src/use-pro-access.ts +141 -0
  91. package/src/use-scroll-animation.ts +221 -0
  92. package/src/use-subscription.ts +37 -0
  93. package/src/use-toast.ts +32 -0
  94. package/src/utils/chart-helpers.ts +257 -0
  95. package/src/utils/cn.ts +69 -0
  96. package/src/utils/data-processing.ts +151 -0
  97. package/src/utils/license-guard.tsx +177 -0
  98. package/src/utils/license-validator.tsx +183 -0
  99. package/src/utils/package-guard.ts +60 -0
@@ -0,0 +1,591 @@
1
+ "use client"
2
+
3
+ import React, { useState, useEffect, useRef, useCallback } from "react"
4
+ import { motion, AnimatePresence } from "framer-motion"
5
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../ui/card"
6
+ import { Button } from "../ui/button"
7
+ import { Badge } from "../ui/badge"
8
+ import { Progress } from "@moontra/moonui"
9
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs"
10
+ import { cn } from "../../lib/utils"
11
+ import {
12
+ Activity,
13
+ Zap,
14
+ Clock,
15
+ Eye,
16
+ EyeOff,
17
+ Download,
18
+ RefreshCw,
19
+ AlertTriangle,
20
+ CheckCircle,
21
+ TrendingUp,
22
+ TrendingDown,
23
+ Lock,
24
+ Sparkles,
25
+ Cpu,
26
+ MemoryStick,
27
+ Network,
28
+ HardDrive
29
+ } from "lucide-react"
30
+ import { useSubscription } from "../../hooks/use-subscription"
31
+
32
+ export interface PerformanceMetric {
33
+ name: string
34
+ value: number
35
+ unit: string
36
+ threshold?: {
37
+ good: number
38
+ needs_improvement: number
39
+ }
40
+ description?: string
41
+ }
42
+
43
+ export interface PerformanceEntry {
44
+ timestamp: number
45
+ metrics: PerformanceMetric[]
46
+ url: string
47
+ userAgent: string
48
+ }
49
+
50
+ export interface PerformanceDebuggerProps {
51
+ autoCapture?: boolean
52
+ captureInterval?: number
53
+ maxEntries?: number
54
+ showRealTime?: boolean
55
+ showWebVitals?: boolean
56
+ showResourceTiming?: boolean
57
+ showNavigationTiming?: boolean
58
+ onMetricChange?: (metrics: PerformanceMetric[]) => void
59
+ className?: string
60
+ }
61
+
62
+ const PerformanceDebuggerInternal: React.FC<PerformanceDebuggerProps> = ({
63
+ autoCapture = true,
64
+ captureInterval = 5000,
65
+ maxEntries = 50,
66
+ showRealTime = true,
67
+ showWebVitals = true,
68
+ showResourceTiming = true,
69
+ showNavigationTiming = true,
70
+ onMetricChange,
71
+ className
72
+ }) => {
73
+ const [entries, setEntries] = useState<PerformanceEntry[]>([])
74
+ const [currentMetrics, setCurrentMetrics] = useState<PerformanceMetric[]>([])
75
+ const [isCapturing, setIsCapturing] = useState(autoCapture)
76
+ const [isVisible, setIsVisible] = useState(true)
77
+ const intervalRef = useRef<NodeJS.Timeout>()
78
+
79
+ // Core Web Vitals thresholds
80
+ const webVitalsThresholds = {
81
+ FCP: { good: 1800, needs_improvement: 3000 },
82
+ LCP: { good: 2500, needs_improvement: 4000 },
83
+ FID: { good: 100, needs_improvement: 300 },
84
+ CLS: { good: 0.1, needs_improvement: 0.25 },
85
+ INP: { good: 200, needs_improvement: 500 },
86
+ TTFB: { good: 800, needs_improvement: 1800 }
87
+ }
88
+
89
+ // Get performance metrics
90
+ const captureMetrics = useCallback(() => {
91
+ const metrics: PerformanceMetric[] = []
92
+
93
+ // Navigation Timing
94
+ if (showNavigationTiming && 'performance' in window) {
95
+ const nav = performance.getEntriesByType('navigation')[0] as PerformanceNavigationTiming
96
+ if (nav) {
97
+ metrics.push(
98
+ {
99
+ name: 'DNS Lookup',
100
+ value: nav.domainLookupEnd - nav.domainLookupStart,
101
+ unit: 'ms',
102
+ description: 'Time to resolve domain name'
103
+ },
104
+ {
105
+ name: 'TCP Connection',
106
+ value: nav.connectEnd - nav.connectStart,
107
+ unit: 'ms',
108
+ description: 'Time to establish TCP connection'
109
+ },
110
+ {
111
+ name: 'Request/Response',
112
+ value: nav.responseEnd - nav.requestStart,
113
+ unit: 'ms',
114
+ description: 'Time to get first byte and complete response'
115
+ },
116
+ {
117
+ name: 'DOM Processing',
118
+ value: nav.domComplete - nav.domLoading,
119
+ unit: 'ms',
120
+ description: 'Time to process DOM'
121
+ },
122
+ {
123
+ name: 'Load Complete',
124
+ value: nav.loadEventEnd - nav.loadEventStart,
125
+ unit: 'ms',
126
+ description: 'Time to fire load event'
127
+ }
128
+ )
129
+ }
130
+ }
131
+
132
+ // Web Vitals (simulated - in real app you'd use web-vitals library)
133
+ if (showWebVitals) {
134
+ const paintEntries = performance.getEntriesByType('paint')
135
+ const fcpEntry = paintEntries.find(entry => entry.name === 'first-contentful-paint')
136
+
137
+ if (fcpEntry) {
138
+ metrics.push({
139
+ name: 'FCP',
140
+ value: fcpEntry.startTime,
141
+ unit: 'ms',
142
+ threshold: webVitalsThresholds.FCP,
143
+ description: 'First Contentful Paint'
144
+ })
145
+ }
146
+
147
+ // Simulated LCP (in real app, use PerformanceObserver)
148
+ metrics.push({
149
+ name: 'LCP',
150
+ value: Math.random() * 4000 + 1000,
151
+ unit: 'ms',
152
+ threshold: webVitalsThresholds.LCP,
153
+ description: 'Largest Contentful Paint'
154
+ })
155
+
156
+ // Simulated CLS
157
+ metrics.push({
158
+ name: 'CLS',
159
+ value: Math.random() * 0.3,
160
+ unit: '',
161
+ threshold: webVitalsThresholds.CLS,
162
+ description: 'Cumulative Layout Shift'
163
+ })
164
+ }
165
+
166
+ // Memory usage (if available)
167
+ if ('memory' in performance) {
168
+ const memory = (performance as any).memory
169
+ metrics.push(
170
+ {
171
+ name: 'JS Heap Used',
172
+ value: memory.usedJSHeapSize / 1024 / 1024,
173
+ unit: 'MB',
174
+ description: 'JavaScript heap memory in use'
175
+ },
176
+ {
177
+ name: 'JS Heap Total',
178
+ value: memory.totalJSHeapSize / 1024 / 1024,
179
+ unit: 'MB',
180
+ description: 'Total JavaScript heap memory'
181
+ },
182
+ {
183
+ name: 'JS Heap Limit',
184
+ value: memory.jsHeapSizeLimit / 1024 / 1024,
185
+ unit: 'MB',
186
+ description: 'JavaScript heap memory limit'
187
+ }
188
+ )
189
+ }
190
+
191
+ // Resource timing
192
+ if (showResourceTiming) {
193
+ const resources = performance.getEntriesByType('resource')
194
+ const totalSize = resources.reduce((acc, resource) => {
195
+ return acc + ((resource as any).transferSize || 0)
196
+ }, 0)
197
+
198
+ metrics.push({
199
+ name: 'Resources Loaded',
200
+ value: resources.length,
201
+ unit: 'count',
202
+ description: 'Total number of resources loaded'
203
+ })
204
+
205
+ if (totalSize > 0) {
206
+ metrics.push({
207
+ name: 'Total Transfer Size',
208
+ value: totalSize / 1024,
209
+ unit: 'KB',
210
+ description: 'Total size of transferred resources'
211
+ })
212
+ }
213
+ }
214
+
215
+ // Current performance scores (simulated)
216
+ metrics.push(
217
+ {
218
+ name: 'Performance Score',
219
+ value: Math.random() * 40 + 60,
220
+ unit: '/100',
221
+ threshold: { good: 90, needs_improvement: 50 },
222
+ description: 'Overall performance score'
223
+ },
224
+ {
225
+ name: 'CPU Usage',
226
+ value: Math.random() * 50 + 20,
227
+ unit: '%',
228
+ threshold: { good: 30, needs_improvement: 70 },
229
+ description: 'Current CPU usage'
230
+ }
231
+ )
232
+
233
+ return metrics
234
+ }, [showNavigationTiming, showWebVitals, showResourceTiming])
235
+
236
+ // Capture performance data
237
+ const capture = useCallback(() => {
238
+ const metrics = captureMetrics()
239
+ const entry: PerformanceEntry = {
240
+ timestamp: Date.now(),
241
+ metrics,
242
+ url: window.location.href,
243
+ userAgent: navigator.userAgent
244
+ }
245
+
246
+ setEntries(prev => [entry, ...prev.slice(0, maxEntries - 1)])
247
+ setCurrentMetrics(metrics)
248
+ onMetricChange?.(metrics)
249
+ }, [captureMetrics, maxEntries, onMetricChange])
250
+
251
+ // Auto capture
252
+ useEffect(() => {
253
+ if (isCapturing && showRealTime) {
254
+ capture() // Initial capture
255
+ intervalRef.current = setInterval(capture, captureInterval)
256
+ } else {
257
+ if (intervalRef.current) {
258
+ clearInterval(intervalRef.current)
259
+ }
260
+ }
261
+
262
+ return () => {
263
+ if (intervalRef.current) {
264
+ clearInterval(intervalRef.current)
265
+ }
266
+ }
267
+ }, [isCapturing, showRealTime, capture, captureInterval])
268
+
269
+ // Initial capture on mount
270
+ useEffect(() => {
271
+ capture()
272
+ }, [])
273
+
274
+ const getMetricStatus = (metric: PerformanceMetric): 'good' | 'needs_improvement' | 'poor' => {
275
+ if (!metric.threshold) return 'good'
276
+
277
+ if (metric.value <= metric.threshold.good) return 'good'
278
+ if (metric.value <= metric.threshold.needs_improvement) return 'needs_improvement'
279
+ return 'poor'
280
+ }
281
+
282
+ const getStatusColor = (status: string) => {
283
+ switch (status) {
284
+ case 'good': return 'text-green-500'
285
+ case 'needs_improvement': return 'text-yellow-500'
286
+ case 'poor': return 'text-red-500'
287
+ default: return 'text-muted-foreground'
288
+ }
289
+ }
290
+
291
+ const getStatusIcon = (status: string) => {
292
+ switch (status) {
293
+ case 'good': return <CheckCircle className="h-4 w-4 text-green-500" />
294
+ case 'needs_improvement': return <AlertTriangle className="h-4 w-4 text-yellow-500" />
295
+ case 'poor': return <AlertTriangle className="h-4 w-4 text-red-500" />
296
+ default: return <Activity className="h-4 w-4 text-muted-foreground" />
297
+ }
298
+ }
299
+
300
+ const exportData = () => {
301
+ const data = {
302
+ timestamp: new Date().toISOString(),
303
+ entries,
304
+ currentMetrics
305
+ }
306
+
307
+ const blob = new Blob([JSON.stringify(data, null, 2)], {
308
+ type: 'application/json'
309
+ })
310
+
311
+ const url = URL.createObjectURL(blob)
312
+ const link = document.createElement('a')
313
+ link.href = url
314
+ link.download = `performance-debug-${Date.now()}.json`
315
+ document.body.appendChild(link)
316
+ link.click()
317
+ document.body.removeChild(link)
318
+ URL.revokeObjectURL(url)
319
+ }
320
+
321
+ const clearData = () => {
322
+ setEntries([])
323
+ setCurrentMetrics([])
324
+ }
325
+
326
+ const formatValue = (value: number, unit: string) => {
327
+ const formatted = unit === 'ms' || unit === 'MB' || unit === 'KB'
328
+ ? value.toFixed(1)
329
+ : unit === '%' || unit === '/100'
330
+ ? Math.round(value)
331
+ : value.toString()
332
+
333
+ return `${formatted}${unit}`
334
+ }
335
+
336
+ if (!isVisible) {
337
+ return (
338
+ <Button
339
+ variant="outline"
340
+ size="sm"
341
+ onClick={() => setIsVisible(true)}
342
+ className="fixed bottom-4 right-4 z-50"
343
+ >
344
+ <Activity className="h-4 w-4 mr-2" />
345
+ Performance
346
+ </Button>
347
+ )
348
+ }
349
+
350
+ return (
351
+ <Card className={cn("w-full max-w-4xl", className)}>
352
+ <CardHeader>
353
+ <div className="flex items-center justify-between">
354
+ <div>
355
+ <CardTitle className="flex items-center gap-2">
356
+ <Zap className="h-5 w-5" />
357
+ Performance Debugger
358
+ </CardTitle>
359
+ <CardDescription>
360
+ Real-time performance monitoring and web vitals tracking
361
+ </CardDescription>
362
+ </div>
363
+
364
+ <div className="flex items-center gap-2">
365
+ <Badge variant={isCapturing ? "default" : "secondary"} className="gap-1">
366
+ {isCapturing ? <Activity className="h-3 w-3 animate-pulse" /> : <Clock className="h-3 w-3" />}
367
+ {isCapturing ? "Live" : "Paused"}
368
+ </Badge>
369
+
370
+ <Button
371
+ variant="outline"
372
+ size="sm"
373
+ onClick={() => setIsCapturing(!isCapturing)}
374
+ >
375
+ {isCapturing ? "Pause" : "Start"}
376
+ </Button>
377
+
378
+ <Button
379
+ variant="outline"
380
+ size="sm"
381
+ onClick={capture}
382
+ >
383
+ <RefreshCw className="h-4 w-4" />
384
+ </Button>
385
+
386
+ <Button
387
+ variant="outline"
388
+ size="sm"
389
+ onClick={exportData}
390
+ >
391
+ <Download className="h-4 w-4" />
392
+ </Button>
393
+
394
+ <Button
395
+ variant="ghost"
396
+ size="sm"
397
+ onClick={() => setIsVisible(false)}
398
+ >
399
+ <EyeOff className="h-4 w-4" />
400
+ </Button>
401
+ </div>
402
+ </div>
403
+ </CardHeader>
404
+
405
+ <CardContent>
406
+ <Tabs defaultValue="current" className="w-full">
407
+ <TabsList className="grid w-full grid-cols-3">
408
+ <TabsTrigger value="current">Current Metrics</TabsTrigger>
409
+ <TabsTrigger value="history">History</TabsTrigger>
410
+ <TabsTrigger value="vitals">Web Vitals</TabsTrigger>
411
+ </TabsList>
412
+
413
+ <TabsContent value="current" className="space-y-4">
414
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
415
+ <AnimatePresence>
416
+ {currentMetrics.map((metric, index) => {
417
+ const status = getMetricStatus(metric)
418
+ return (
419
+ <motion.div
420
+ key={metric.name}
421
+ initial={{ opacity: 0, y: 20 }}
422
+ animate={{ opacity: 1, y: 0 }}
423
+ exit={{ opacity: 0, y: -20 }}
424
+ transition={{ delay: index * 0.05 }}
425
+ >
426
+ <Card>
427
+ <CardContent className="p-4">
428
+ <div className="flex items-center justify-between mb-2">
429
+ <div className="flex items-center gap-2">
430
+ {getStatusIcon(status)}
431
+ <span className="font-medium text-sm">{metric.name}</span>
432
+ </div>
433
+ <span className={cn("font-bold", getStatusColor(status))}>
434
+ {formatValue(metric.value, metric.unit)}
435
+ </span>
436
+ </div>
437
+
438
+ {metric.threshold && (
439
+ <div className="space-y-1">
440
+ <Progress
441
+ value={Math.min((metric.value / (metric.threshold.needs_improvement * 2)) * 100, 100)}
442
+ className="h-2"
443
+ />
444
+ <div className="text-xs text-muted-foreground">
445
+ Good: &lt;{metric.threshold.good}{metric.unit} |
446
+ Needs improvement: &lt;{metric.threshold.needs_improvement}{metric.unit}
447
+ </div>
448
+ </div>
449
+ )}
450
+
451
+ {metric.description && (
452
+ <p className="text-xs text-muted-foreground mt-2">
453
+ {metric.description}
454
+ </p>
455
+ )}
456
+ </CardContent>
457
+ </Card>
458
+ </motion.div>
459
+ )
460
+ })}
461
+ </AnimatePresence>
462
+ </div>
463
+ </TabsContent>
464
+
465
+ <TabsContent value="history" className="space-y-4">
466
+ <div className="flex items-center justify-between">
467
+ <div className="text-sm text-muted-foreground">
468
+ {entries.length} entries captured
469
+ </div>
470
+ <Button variant="outline" size="sm" onClick={clearData}>
471
+ Clear History
472
+ </Button>
473
+ </div>
474
+
475
+ <div className="space-y-2 max-h-96 overflow-y-auto">
476
+ {entries.map((entry, index) => (
477
+ <Card key={entry.timestamp}>
478
+ <CardContent className="p-4">
479
+ <div className="flex items-center justify-between mb-2">
480
+ <span className="text-sm font-medium">
481
+ {new Date(entry.timestamp).toLocaleTimeString()}
482
+ </span>
483
+ <Badge variant="outline" className="text-xs">
484
+ {entry.metrics.length} metrics
485
+ </Badge>
486
+ </div>
487
+
488
+ <div className="grid grid-cols-2 md:grid-cols-4 gap-2 text-xs">
489
+ {entry.metrics.slice(0, 4).map((metric) => (
490
+ <div key={metric.name} className="flex justify-between">
491
+ <span className="text-muted-foreground">{metric.name}:</span>
492
+ <span className={getStatusColor(getMetricStatus(metric))}>
493
+ {formatValue(metric.value, metric.unit)}
494
+ </span>
495
+ </div>
496
+ ))}
497
+ </div>
498
+ </CardContent>
499
+ </Card>
500
+ ))}
501
+ </div>
502
+ </TabsContent>
503
+
504
+ <TabsContent value="vitals" className="space-y-4">
505
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
506
+ {currentMetrics
507
+ .filter(metric => ['FCP', 'LCP', 'CLS', 'FID', 'INP', 'TTFB'].includes(metric.name))
508
+ .map((metric) => {
509
+ const status = getMetricStatus(metric)
510
+ return (
511
+ <Card key={metric.name}>
512
+ <CardContent className="p-6">
513
+ <div className="flex items-center justify-between mb-4">
514
+ <div>
515
+ <h3 className="font-semibold">{metric.name}</h3>
516
+ <p className="text-sm text-muted-foreground">
517
+ {metric.description}
518
+ </p>
519
+ </div>
520
+ {getStatusIcon(status)}
521
+ </div>
522
+
523
+ <div className="text-2xl font-bold mb-2 text-center">
524
+ <span className={getStatusColor(status)}>
525
+ {formatValue(metric.value, metric.unit)}
526
+ </span>
527
+ </div>
528
+
529
+ {metric.threshold && (
530
+ <div className="space-y-2">
531
+ <Progress
532
+ value={Math.min((metric.value / (metric.threshold.needs_improvement * 2)) * 100, 100)}
533
+ className="h-3"
534
+ />
535
+ <div className="flex justify-between text-xs text-muted-foreground">
536
+ <span>Good: &lt;{metric.threshold.good}{metric.unit}</span>
537
+ <span>Poor: &gt;{metric.threshold.needs_improvement}{metric.unit}</span>
538
+ </div>
539
+ </div>
540
+ )}
541
+ </CardContent>
542
+ </Card>
543
+ )
544
+ })}
545
+ </div>
546
+ </TabsContent>
547
+ </Tabs>
548
+ </CardContent>
549
+ </Card>
550
+ )
551
+ }
552
+
553
+ export const PerformanceDebugger: React.FC<PerformanceDebuggerProps> = ({ className, ...props }) => {
554
+ // Check if we're in docs mode or have pro access
555
+ const docsProAccess = { hasAccess: true } // Pro access assumed in package
556
+ const { hasProAccess, isLoading } = useSubscription()
557
+
558
+ // In docs mode, always show the component
559
+ const canShowComponent = docsProAccess.isDocsMode || hasProAccess
560
+
561
+ // If not in docs mode and no pro access, show upgrade prompt
562
+ if (!docsProAccess.isDocsMode && !isLoading && !hasProAccess) {
563
+ return (
564
+ <Card className={cn("w-fit", className)}>
565
+ <CardContent className="py-6 text-center">
566
+ <div className="space-y-4">
567
+ <div className="rounded-full bg-purple-100 dark:bg-purple-900/30 p-3 w-fit mx-auto">
568
+ <Lock className="h-6 w-6 text-purple-600 dark:text-purple-400" />
569
+ </div>
570
+ <div>
571
+ <h3 className="font-semibold text-sm mb-2">Pro Feature</h3>
572
+ <p className="text-muted-foreground text-xs mb-4">
573
+ Performance Debugger is available exclusively to MoonUI Pro subscribers.
574
+ </p>
575
+ <a href="/pricing">
576
+ <Button size="sm">
577
+ <Sparkles className="mr-2 h-4 w-4" />
578
+ Upgrade to Pro
579
+ </Button>
580
+ </a>
581
+ </div>
582
+ </div>
583
+ </CardContent>
584
+ </Card>
585
+ )
586
+ }
587
+
588
+ return <PerformanceDebuggerInternal className={className} {...props} />
589
+ }
590
+
591
+ export type { PerformanceMetric, PerformanceEntry, PerformanceDebuggerProps }