@moontra/moonui-pro 2.17.5 → 2.18.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.
@@ -90,6 +90,8 @@ export function VirtualList<T = any>({
90
90
  const isScrollingTimeoutRef = useRef<NodeJS.Timeout | undefined>(undefined)
91
91
 
92
92
  // Container dimensions tracking
93
+ const [containerDimensions, setContainerDimensions] = useState({ width: 0, height: 0 })
94
+
93
95
  useEffect(() => {
94
96
  if (!containerRef.current) return
95
97
 
@@ -107,21 +109,8 @@ export function VirtualList<T = any>({
107
109
  return () => resizeObserver.disconnect()
108
110
  }, [])
109
111
 
110
- // Grid layout calculation
111
- const gridPositions = useGridLayout(
112
- items,
113
- gridConfig,
114
- direction,
115
- containerDimensions.width || (typeof width === 'number' ? width : 800),
116
- itemHeight,
117
- itemWidth
118
- )
119
-
120
112
  // Item pozisyonlarını hesapla
121
113
  const itemPositions = useMemo(() => {
122
- if (direction === 'grid') {
123
- return gridPositions
124
- }
125
114
 
126
115
  const positions: ItemInfo[] = []
127
116
  let currentTop = 0
@@ -131,40 +120,23 @@ export function VirtualList<T = any>({
131
120
  const currentHeight = variableHeight
132
121
  ? (itemHeights.get(i) || estimatedItemHeight)
133
122
  : itemHeight
134
-
135
- const currentWidth = variableWidth
136
- ? (itemWidths.get(i) || estimatedItemWidth)
137
- : (direction === 'horizontal' ? itemWidth : containerDimensions.width || 0)
138
123
 
139
124
  positions.push({
140
125
  index: i,
141
126
  height: currentHeight,
142
- width: currentWidth,
143
- top: direction === 'horizontal' ? 0 : currentTop,
144
- left: direction === 'horizontal' ? currentLeft : 0
127
+ top: currentTop
145
128
  })
146
129
 
147
- if (direction === 'horizontal') {
148
- currentLeft += currentWidth
149
- } else {
150
- currentTop += currentHeight
151
- }
130
+ currentTop += currentHeight
152
131
  }
153
132
 
154
133
  return positions
155
134
  }, [
156
135
  items.length,
157
136
  itemHeight,
158
- itemWidth,
159
137
  estimatedItemHeight,
160
- estimatedItemWidth,
161
138
  variableHeight,
162
- variableWidth,
163
- itemHeights,
164
- itemWidths,
165
- direction,
166
- containerDimensions.width,
167
- gridPositions
139
+ itemHeights
168
140
  ])
169
141
 
170
142
  // Toplam içerik yüksekliği
@@ -199,14 +171,6 @@ export function VirtualList<T = any>({
199
171
  }
200
172
  }, [scrollTop, height, itemPositions, overscan, items.length, itemHeight])
201
173
 
202
- // Memory Management Hook
203
- const {
204
- metrics,
205
- memoryCache,
206
- updateScrollDistance,
207
- optimizeGC,
208
- trackRenderPerformance
209
- } = useMemoryManagement(memoryManagement, visibleRange, items.length)
210
174
 
211
175
  // Görünür itemlar
212
176
  const visibleItems = useMemo(() => {
@@ -242,12 +206,6 @@ export function VirtualList<T = any>({
242
206
  setScrollTop(scrollTop)
243
207
  setIsScrolling(true)
244
208
 
245
- // Memory management scroll tracking
246
- updateScrollDistance(scrollTop)
247
-
248
- // Garbage collection optimization
249
- optimizeGC()
250
-
251
209
  // Scroll callback
252
210
  if (onScroll) {
253
211
  onScroll(scrollTop)
@@ -276,7 +234,7 @@ export function VirtualList<T = any>({
276
234
  isScrollingTimeoutRef.current = setTimeout(() => {
277
235
  setIsScrolling(false)
278
236
  }, 150)
279
- }, [onScroll, hasNextPage, isLoadingNextPage, onLoadMore, loadMoreThreshold, updateScrollDistance, optimizeGC])
237
+ }, [onScroll, hasNextPage, isLoadingNextPage, onLoadMore, loadMoreThreshold])
280
238
 
281
239
  // Variable height için resize observer
282
240
  useEffect(() => {
@@ -489,67 +447,10 @@ export function VirtualList<T = any>({
489
447
  </motion.div>
490
448
  )}
491
449
 
492
- {/* Performance Monitor */}
493
- {enablePerformanceMonitoring && memoryManagement.enableDebugMode && (
494
- <PerformanceMonitor metrics={metrics} />
495
- )}
496
450
  </ContainerComponent>
497
451
  )
498
452
  }
499
453
 
500
- // Performance Monitor Component
501
- function PerformanceMonitor({ metrics }: { metrics: VirtualListPerformanceMetrics }) {
502
- const formatMemory = (bytes: number) => {
503
- const kb = bytes / 1024
504
- const mb = kb / 1024
505
-
506
- if (mb >= 1) return `${mb.toFixed(2)} MB`
507
- if (kb >= 1) return `${kb.toFixed(2)} KB`
508
- return `${bytes} B`
509
- }
510
-
511
- return (
512
- <motion.div
513
- className="absolute top-2 left-2 bg-black/90 text-white p-3 rounded-lg text-xs font-mono shadow-lg"
514
- initial={{ opacity: 0, x: -20 }}
515
- animate={{ opacity: 1, x: 0 }}
516
- transition={{ duration: 0.3 }}
517
- >
518
- <div className="space-y-1">
519
- <div className="text-green-400 font-semibold">🚀 Performance Monitor</div>
520
- <div className="grid grid-cols-2 gap-x-4 gap-y-1">
521
- <span>Renders:</span>
522
- <span className="text-blue-300">{metrics.renderCount}</span>
523
-
524
- <span>Avg Render:</span>
525
- <span className="text-blue-300">{metrics.averageRenderTime.toFixed(2)}ms</span>
526
-
527
- <span>Memory:</span>
528
- <span className={`${metrics.memoryUsage > 5 * 1024 * 1024 ? 'text-red-400' : 'text-green-400'}`}>
529
- {formatMemory(metrics.memoryUsage)}
530
- </span>
531
-
532
- <span>Visible Items:</span>
533
- <span className="text-yellow-300">{metrics.visibleItemsCount}</span>
534
-
535
- <span>Scroll FPS:</span>
536
- <span className={`${metrics.scrollFPS < 50 ? 'text-red-400' : 'text-green-400'}`}>
537
- {metrics.scrollFPS}
538
- </span>
539
-
540
- <span>Distance:</span>
541
- <span className="text-purple-300">{Math.round(metrics.totalScrollDistance)}px</span>
542
- </div>
543
-
544
- {metrics.lastGCTime && (
545
- <div className="text-orange-400 text-xs mt-2">
546
- Last GC: {new Date(metrics.lastGCTime).toLocaleTimeString()}
547
- </div>
548
- )}
549
- </div>
550
- </motion.div>
551
- )
552
- }
553
454
 
554
455
  // Utility hook for virtual list state management
555
456
  export function useVirtualList<T>(