/** * Virtual Scroll Utility for NA-Kit UI * * Provides efficient rendering for large lists and tables by only * rendering visible items plus a small buffer. * * @module virtual-scroll */ export interface VirtualScrollConfig { /** Total number of items */ itemCount: number; /** Height of each item in pixels (or estimated average for variable heights) */ itemHeight: number; /** Height of the container viewport in pixels */ containerHeight: number; /** Number of extra items to render above/below the visible area */ overscan?: number; /** Whether items have variable heights */ variableHeights?: boolean; } export interface VirtualScrollState { /** Index of the first visible item */ startIndex: number; /** Index of the last visible item */ endIndex: number; /** Offset from top for the first visible item */ offsetTop: number; /** Total height of all items */ totalHeight: number; /** Items currently visible (indices) */ visibleIndices: number[]; /** Number of visible items */ visibleCount: number; } export interface ScrollPosition { scrollTop: number; scrollLeft: number; } /** * Core virtual scroll logic — framework-agnostic * * @example * ```ts * const vs = new VirtualScrollController({ * itemCount: 10000, * itemHeight: 40, * containerHeight: 500, * overscan: 5, * }); * * // On scroll event: * const state = vs.update(scrollTop); * // Render items from state.startIndex to state.endIndex * // Apply state.offsetTop as transform on the items container * ``` */ export declare class VirtualScrollController { private _config; private _state; private _itemHeights; private _listeners; constructor(config: VirtualScrollConfig); /** Get current state */ get state(): VirtualScrollState; /** Update configuration (e.g. when item count changes) */ updateConfig(config: Partial): void; /** Set a specific item's actual height (for variable-height items) */ setItemHeight(index: number, height: number): void; /** Update scroll position and return new state */ update(scrollTop: number): VirtualScrollState; /** Scroll to a specific item index */ getScrollTopForIndex(index: number): number; /** Subscribe to state changes */ subscribe(listener: (state: VirtualScrollState) => void): () => void; private _getItemHeight; private _calculateState; private _notify; } export interface LazyLoadOptions { /** Root element for intersection (default: viewport) */ root?: Element | null; /** Margin around root */ rootMargin?: string; /** Threshold for triggering */ threshold?: number | number[]; /** Callback when element becomes visible */ onVisible?: (entry: IntersectionObserverEntry) => void; /** Whether to unobserve after first intersection */ once?: boolean; } /** * Create a lazy loading observer for elements */ export declare class LazyLoader { private _observer; private _callbacks; private _once; constructor(options?: LazyLoadOptions); /** Observe an element */ observe(element: Element, callback?: (entry: IntersectionObserverEntry) => void): void; /** Stop observing an element */ unobserve(element: Element): void; /** Disconnect the observer */ destroy(): void; } export interface InfiniteScrollOptions { /** The scrollable container */ container: HTMLElement; /** Distance from bottom to trigger load (px) */ threshold?: number; /** Callback when more items should be loaded */ onLoadMore: () => void | Promise; /** Whether loading is in progress */ isLoading?: () => boolean; /** Whether all items have been loaded */ hasMore?: () => boolean; } /** * Infinite scroll helper — triggers loading when near the bottom */ export declare class InfiniteScroll { private _container; private _threshold; private _onLoadMore; private _isLoading; private _hasMore; private _handleScroll; constructor(options: InfiniteScrollOptions); private _onScroll; /** Remove event listener and clean up */ destroy(): void; } //# sourceMappingURL=virtual-scroll.d.ts.map