@oxog/scrollex 1.0.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.
- package/CHANGELOG.md +68 -0
- package/LICENSE +21 -0
- package/README.md +328 -0
- package/dist/index.cjs +3494 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1084 -0
- package/dist/index.d.ts +1084 -0
- package/dist/index.js +3475 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/index.cjs +2195 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.cts +1137 -0
- package/dist/plugins/index.d.ts +1137 -0
- package/dist/plugins/index.js +2181 -0
- package/dist/plugins/index.js.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,1137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a virtualized item with position and size information.
|
|
3
|
+
*/
|
|
4
|
+
interface VirtualItem {
|
|
5
|
+
/** Index of the item in the data array */
|
|
6
|
+
index: number;
|
|
7
|
+
/** Unique key for React reconciliation */
|
|
8
|
+
key: string | number;
|
|
9
|
+
/** Offset from the start of the scroll container (px) */
|
|
10
|
+
start: number;
|
|
11
|
+
/** End position (start + size) */
|
|
12
|
+
end: number;
|
|
13
|
+
/** Size of the item (height for vertical, width for horizontal) */
|
|
14
|
+
size: number;
|
|
15
|
+
/** Lane/column index for grid and masonry layouts */
|
|
16
|
+
lane: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Represents the visible range of items.
|
|
20
|
+
*/
|
|
21
|
+
interface Range {
|
|
22
|
+
/** First visible item index */
|
|
23
|
+
startIndex: number;
|
|
24
|
+
/** Last visible item index */
|
|
25
|
+
endIndex: number;
|
|
26
|
+
/** First rendered item index (including overscan) */
|
|
27
|
+
overscanStartIndex: number;
|
|
28
|
+
/** Last rendered item index (including overscan) */
|
|
29
|
+
overscanEndIndex: number;
|
|
30
|
+
/** Alias for startIndex */
|
|
31
|
+
start?: number;
|
|
32
|
+
/** Alias for endIndex */
|
|
33
|
+
end?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Represents scroll position in both axes.
|
|
37
|
+
*/
|
|
38
|
+
interface ScrollPosition {
|
|
39
|
+
scrollTop: number;
|
|
40
|
+
scrollLeft: number;
|
|
41
|
+
/** Normalized offset (scrollTop for vertical, scrollLeft for horizontal) */
|
|
42
|
+
offset?: number;
|
|
43
|
+
/** Scroll percentage (0-1) */
|
|
44
|
+
percentage?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Represents the viewport dimensions.
|
|
48
|
+
*/
|
|
49
|
+
interface Viewport {
|
|
50
|
+
/** Visible width of the container */
|
|
51
|
+
width: number;
|
|
52
|
+
/** Visible height of the container */
|
|
53
|
+
height: number;
|
|
54
|
+
/** Total scrollable height */
|
|
55
|
+
scrollHeight: number;
|
|
56
|
+
/** Total scrollable width */
|
|
57
|
+
scrollWidth: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Scroll direction.
|
|
61
|
+
*/
|
|
62
|
+
type ScrollDirection = 'up' | 'down' | 'left' | 'right' | 'none';
|
|
63
|
+
/**
|
|
64
|
+
* Scroll behavior.
|
|
65
|
+
*/
|
|
66
|
+
type ScrollBehavior = 'auto' | 'smooth';
|
|
67
|
+
/**
|
|
68
|
+
* Alignment options for scrollToIndex.
|
|
69
|
+
*/
|
|
70
|
+
type ScrollAlignment = 'start' | 'center' | 'end' | 'auto';
|
|
71
|
+
/**
|
|
72
|
+
* Scroll event payload.
|
|
73
|
+
*/
|
|
74
|
+
interface ScrollEvent {
|
|
75
|
+
type: 'scroll';
|
|
76
|
+
scrollTop: number;
|
|
77
|
+
scrollLeft: number;
|
|
78
|
+
deltaY: number;
|
|
79
|
+
deltaX: number;
|
|
80
|
+
direction: ScrollDirection;
|
|
81
|
+
timestamp: number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Scroll start event payload.
|
|
85
|
+
*/
|
|
86
|
+
interface ScrollStartEvent {
|
|
87
|
+
type: 'scroll-start';
|
|
88
|
+
scrollTop: number;
|
|
89
|
+
scrollLeft: number;
|
|
90
|
+
timestamp: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Scroll end event payload.
|
|
94
|
+
*/
|
|
95
|
+
interface ScrollEndEvent {
|
|
96
|
+
type: 'scroll-end';
|
|
97
|
+
scrollTop: number;
|
|
98
|
+
scrollLeft: number;
|
|
99
|
+
timestamp: number;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Visible range change event payload.
|
|
103
|
+
*/
|
|
104
|
+
interface VisibleRangeChangeEvent {
|
|
105
|
+
type: 'visible-range-change';
|
|
106
|
+
range: Range;
|
|
107
|
+
previousRange: Range | null;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Item measured event payload.
|
|
111
|
+
*/
|
|
112
|
+
interface ItemMeasuredEvent {
|
|
113
|
+
type: 'item-measured';
|
|
114
|
+
index: number;
|
|
115
|
+
height: number;
|
|
116
|
+
previousHeight: number | undefined;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Resize event payload.
|
|
120
|
+
*/
|
|
121
|
+
interface ResizeEvent {
|
|
122
|
+
type: 'resize';
|
|
123
|
+
viewport: Viewport;
|
|
124
|
+
previousViewport: Viewport | null;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Load more event payload.
|
|
128
|
+
*/
|
|
129
|
+
interface LoadMoreEvent {
|
|
130
|
+
type: 'load-more';
|
|
131
|
+
direction: 'forward' | 'backward';
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Items change event payload.
|
|
135
|
+
*/
|
|
136
|
+
interface ItemsChangeEvent {
|
|
137
|
+
type: 'items-change';
|
|
138
|
+
count: number;
|
|
139
|
+
previousCount: number;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Union of all kernel events.
|
|
143
|
+
*/
|
|
144
|
+
type KernelEvent = ScrollEvent | ScrollStartEvent | ScrollEndEvent | VisibleRangeChangeEvent | ItemMeasuredEvent | ResizeEvent | LoadMoreEvent | ItemsChangeEvent;
|
|
145
|
+
/**
|
|
146
|
+
* Event handler function type.
|
|
147
|
+
*/
|
|
148
|
+
type EventHandler<T = KernelEvent> = (event: T) => void;
|
|
149
|
+
/**
|
|
150
|
+
* Unsubscribe function returned by event subscriptions.
|
|
151
|
+
*/
|
|
152
|
+
type Unsubscribe = () => void;
|
|
153
|
+
/**
|
|
154
|
+
* Options for scroll operations.
|
|
155
|
+
*/
|
|
156
|
+
interface ScrollOptions {
|
|
157
|
+
/** Scroll behavior */
|
|
158
|
+
behavior?: ScrollBehavior;
|
|
159
|
+
/** Duration for smooth scroll (ms) */
|
|
160
|
+
duration?: number;
|
|
161
|
+
/** Easing function for smooth scroll */
|
|
162
|
+
easing?: EasingFunction;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Options for scrollToIndex operations.
|
|
166
|
+
*/
|
|
167
|
+
interface ScrollToIndexOptions extends ScrollOptions {
|
|
168
|
+
/** Alignment of the item in the viewport */
|
|
169
|
+
align?: ScrollAlignment;
|
|
170
|
+
/** Additional offset (px) */
|
|
171
|
+
offset?: number;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Easing function type.
|
|
175
|
+
*/
|
|
176
|
+
type EasingFunction = (t: number) => number;
|
|
177
|
+
/**
|
|
178
|
+
* Plugin type - core plugins are always loaded, optional are loaded on demand.
|
|
179
|
+
*/
|
|
180
|
+
type PluginType = 'core' | 'optional';
|
|
181
|
+
/**
|
|
182
|
+
* Plugin hooks interface.
|
|
183
|
+
*/
|
|
184
|
+
interface PluginHooks {
|
|
185
|
+
/** Called on scroll */
|
|
186
|
+
onScroll?: (event: ScrollEvent) => void;
|
|
187
|
+
/** Called when scroll starts */
|
|
188
|
+
onScrollStart?: (event: ScrollStartEvent) => void;
|
|
189
|
+
/** Called when scroll ends */
|
|
190
|
+
onScrollEnd?: (event: ScrollEndEvent) => void;
|
|
191
|
+
/** Called when visible range changes */
|
|
192
|
+
onVisibleRangeChange?: (range: Range, previousRange: Range | null) => void;
|
|
193
|
+
/** Called when an item is measured */
|
|
194
|
+
onItemMeasured?: (index: number, height: number) => void;
|
|
195
|
+
/** Called on viewport resize */
|
|
196
|
+
onResize?: (viewport: Viewport) => void;
|
|
197
|
+
/** Called when load more is triggered */
|
|
198
|
+
onLoadMore?: (direction: 'forward' | 'backward') => void;
|
|
199
|
+
/** Called when item count changes */
|
|
200
|
+
onItemsChange?: (count: number, previousCount: number) => void;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Plugin metadata.
|
|
204
|
+
*/
|
|
205
|
+
interface PluginInfo {
|
|
206
|
+
name: string;
|
|
207
|
+
version: string;
|
|
208
|
+
type: PluginType;
|
|
209
|
+
enabled: boolean;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Plugin interface.
|
|
213
|
+
*/
|
|
214
|
+
interface Plugin {
|
|
215
|
+
/** Unique plugin name */
|
|
216
|
+
name: string;
|
|
217
|
+
/** Plugin version */
|
|
218
|
+
version: string;
|
|
219
|
+
/** Plugin type (core or optional) */
|
|
220
|
+
type: PluginType;
|
|
221
|
+
/** Install plugin into kernel */
|
|
222
|
+
install?(kernel: Kernel): void;
|
|
223
|
+
/** Uninstall plugin */
|
|
224
|
+
uninstall?(): void;
|
|
225
|
+
/** Plugin hooks */
|
|
226
|
+
hooks?: PluginHooks;
|
|
227
|
+
/** Public API exposed by the plugin */
|
|
228
|
+
api?: any;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Kernel configuration options.
|
|
232
|
+
*/
|
|
233
|
+
interface KernelOptions {
|
|
234
|
+
/** Total number of items */
|
|
235
|
+
itemCount: number;
|
|
236
|
+
/** Estimated height of items (used before measurement) */
|
|
237
|
+
estimatedItemHeight: number;
|
|
238
|
+
/** Number of extra items to render outside viewport */
|
|
239
|
+
overscan: number;
|
|
240
|
+
/** Scroll direction */
|
|
241
|
+
direction: 'vertical' | 'horizontal';
|
|
242
|
+
/** Function to get item key */
|
|
243
|
+
getItemKey?: (index: number) => string | number;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Kernel interface - the core of the virtualization engine.
|
|
247
|
+
*/
|
|
248
|
+
interface Kernel {
|
|
249
|
+
/** Register a plugin */
|
|
250
|
+
register(plugin: Plugin): void;
|
|
251
|
+
/** Unregister a plugin by name */
|
|
252
|
+
unregister(pluginName: string): void;
|
|
253
|
+
/** Get a plugin by name */
|
|
254
|
+
getPlugin<T extends Plugin>(name: string): T | undefined;
|
|
255
|
+
/** List all registered plugins */
|
|
256
|
+
listPlugins(): PluginInfo[];
|
|
257
|
+
/** Get current scroll position */
|
|
258
|
+
getScrollPosition(): ScrollPosition;
|
|
259
|
+
/** Set scroll position directly */
|
|
260
|
+
setScrollPosition(position: ScrollPosition): void;
|
|
261
|
+
/** Scroll to offset */
|
|
262
|
+
scrollTo(offset: number, options?: ScrollOptions): void;
|
|
263
|
+
/** Scroll to item index */
|
|
264
|
+
scrollToIndex(index: number, options?: ScrollToIndexOptions): void;
|
|
265
|
+
/** Get viewport dimensions */
|
|
266
|
+
getViewport(): Viewport;
|
|
267
|
+
/** Get visible range */
|
|
268
|
+
getVisibleRange(): Range;
|
|
269
|
+
/** Get render range (including overscan) */
|
|
270
|
+
getRenderRange(): Range;
|
|
271
|
+
/** Measure an item's size */
|
|
272
|
+
measureItem(index: number, size: number): void;
|
|
273
|
+
/** Get cached height for an item */
|
|
274
|
+
getCachedHeight(index: number): number | undefined;
|
|
275
|
+
/** Invalidate measurement for an item */
|
|
276
|
+
invalidateMeasurement(index: number): void;
|
|
277
|
+
/** Invalidate all measurements */
|
|
278
|
+
invalidateAllMeasurements(): void;
|
|
279
|
+
/** Get estimated item height */
|
|
280
|
+
getEstimatedHeight(): number;
|
|
281
|
+
/** Get item offset */
|
|
282
|
+
getItemOffset(index: number): number;
|
|
283
|
+
/** Emit an event */
|
|
284
|
+
emit(event: KernelEvent): void;
|
|
285
|
+
/** Subscribe to an event type */
|
|
286
|
+
on<T extends KernelEvent>(eventType: T['type'], handler: EventHandler<T>): Unsubscribe;
|
|
287
|
+
/** Unsubscribe from an event type */
|
|
288
|
+
off<T extends KernelEvent>(eventType: T['type'], handler: EventHandler<T>): void;
|
|
289
|
+
/** Update kernel configuration */
|
|
290
|
+
configure(options: Partial<KernelOptions>): void;
|
|
291
|
+
/** Get current configuration */
|
|
292
|
+
getOptions(): KernelOptions;
|
|
293
|
+
/** Check if currently scrolling */
|
|
294
|
+
isScrolling(): boolean;
|
|
295
|
+
/** Get item count */
|
|
296
|
+
getItemCount(): number;
|
|
297
|
+
/** Get total scroll size */
|
|
298
|
+
getTotalSize(): number;
|
|
299
|
+
/** Attach to a container element */
|
|
300
|
+
attach(container: HTMLElement): void;
|
|
301
|
+
/** Detach from container */
|
|
302
|
+
detach(): void;
|
|
303
|
+
/** Destroy the kernel */
|
|
304
|
+
destroy(): void;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Gap configuration for grid layouts.
|
|
308
|
+
*/
|
|
309
|
+
interface GridGap {
|
|
310
|
+
x: number;
|
|
311
|
+
y: number;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* List renderer plugin options.
|
|
316
|
+
*/
|
|
317
|
+
interface ListRendererOptions {
|
|
318
|
+
/** Get item key for React reconciliation */
|
|
319
|
+
getItemKey?: (index: number) => string | number;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* List renderer plugin API.
|
|
323
|
+
*/
|
|
324
|
+
interface ListRendererAPI {
|
|
325
|
+
/** Get virtual items to render */
|
|
326
|
+
getVirtualItems(): VirtualItem[];
|
|
327
|
+
/** Get total scroll height */
|
|
328
|
+
getTotalHeight(): number;
|
|
329
|
+
/** Get start offset (for positioning) */
|
|
330
|
+
getStartOffset(): number;
|
|
331
|
+
/** Get end offset */
|
|
332
|
+
getEndOffset(): number;
|
|
333
|
+
/** Check if an item is visible */
|
|
334
|
+
isItemVisible(index: number): boolean;
|
|
335
|
+
/** Force recalculation */
|
|
336
|
+
recalculate(): void;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Creates a list renderer plugin.
|
|
340
|
+
* This is the core virtualization engine for list rendering.
|
|
341
|
+
*
|
|
342
|
+
* @param options - Plugin options
|
|
343
|
+
* @returns Plugin instance
|
|
344
|
+
*/
|
|
345
|
+
declare function listRendererPlugin(options?: ListRendererOptions): Plugin;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Grid renderer plugin options.
|
|
349
|
+
*/
|
|
350
|
+
interface GridRendererOptions {
|
|
351
|
+
/** Number of columns or 'auto' for responsive */
|
|
352
|
+
columns: number | 'auto';
|
|
353
|
+
/** Minimum column width for auto columns */
|
|
354
|
+
minColumnWidth?: number;
|
|
355
|
+
/** Row height */
|
|
356
|
+
rowHeight: number;
|
|
357
|
+
/** Gap between items */
|
|
358
|
+
gap?: number | GridGap;
|
|
359
|
+
/** Get item key for React reconciliation */
|
|
360
|
+
getItemKey?: (index: number) => string | number;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Grid renderer plugin API.
|
|
364
|
+
*/
|
|
365
|
+
interface GridRendererAPI {
|
|
366
|
+
/** Get virtual items to render */
|
|
367
|
+
getVirtualItems(): VirtualItem[];
|
|
368
|
+
/** Get total scroll height */
|
|
369
|
+
getTotalHeight(): number;
|
|
370
|
+
/** Get number of columns */
|
|
371
|
+
getColumnCount(): number;
|
|
372
|
+
/** Get column width */
|
|
373
|
+
getColumnWidth(): number;
|
|
374
|
+
/** Get number of items per row */
|
|
375
|
+
getItemsPerRow(): number;
|
|
376
|
+
/** Get row count */
|
|
377
|
+
getRowCount(): number;
|
|
378
|
+
/** Force recalculation */
|
|
379
|
+
recalculate(): void;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Creates a grid renderer plugin.
|
|
383
|
+
* Handles multi-column grid virtualization.
|
|
384
|
+
*
|
|
385
|
+
* @param options - Plugin options
|
|
386
|
+
* @returns Plugin instance
|
|
387
|
+
*/
|
|
388
|
+
declare function gridRendererPlugin(options: GridRendererOptions): Plugin;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Auto measurer plugin options.
|
|
392
|
+
*/
|
|
393
|
+
interface AutoMeasurerOptions {
|
|
394
|
+
/** Estimated item height for initial layout */
|
|
395
|
+
estimatedItemHeight?: number;
|
|
396
|
+
/** Whether to re-measure when item content resizes */
|
|
397
|
+
measureOnResize?: boolean;
|
|
398
|
+
/** Debounce time for resize measurements (ms) */
|
|
399
|
+
debounceMs?: number;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Auto measurer plugin API.
|
|
403
|
+
*/
|
|
404
|
+
interface AutoMeasurerAPI {
|
|
405
|
+
/** Measure an element and update cache */
|
|
406
|
+
measureElement(index: number, element: HTMLElement): number;
|
|
407
|
+
/** Get cached size for an index */
|
|
408
|
+
getCachedSize(index: number): number | undefined;
|
|
409
|
+
/** Invalidate measurement for an index */
|
|
410
|
+
invalidate(index: number): void;
|
|
411
|
+
/** Invalidate all measurements */
|
|
412
|
+
invalidateAll(): void;
|
|
413
|
+
/** Get the measurement cache */
|
|
414
|
+
getMeasurementCache(): Map<number, number>;
|
|
415
|
+
/** Observe an element for size changes */
|
|
416
|
+
observe(index: number, element: HTMLElement): void;
|
|
417
|
+
/** Stop observing an element */
|
|
418
|
+
unobserve(element: HTMLElement): void;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Creates an auto measurer plugin.
|
|
422
|
+
* Handles automatic measurement of variable height items.
|
|
423
|
+
*
|
|
424
|
+
* @param options - Plugin options
|
|
425
|
+
* @returns Plugin instance
|
|
426
|
+
*/
|
|
427
|
+
declare function autoMeasurerPlugin(options?: AutoMeasurerOptions): Plugin;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Load direction.
|
|
431
|
+
*/
|
|
432
|
+
type LoadDirection = 'forward' | 'backward';
|
|
433
|
+
/**
|
|
434
|
+
* Infinite loader plugin options.
|
|
435
|
+
*/
|
|
436
|
+
interface InfiniteLoaderOptions {
|
|
437
|
+
/** Pixels from edge to trigger load */
|
|
438
|
+
threshold?: number;
|
|
439
|
+
/** Items from edge to trigger load */
|
|
440
|
+
thresholdItems?: number;
|
|
441
|
+
/** Direction to load more */
|
|
442
|
+
direction?: LoadDirection | 'both';
|
|
443
|
+
/** Callback when more items should be loaded */
|
|
444
|
+
onLoadMore: (direction: LoadDirection) => void | Promise<void>;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Infinite loader plugin API.
|
|
448
|
+
*/
|
|
449
|
+
interface InfiniteLoaderAPI {
|
|
450
|
+
/** Check if currently loading */
|
|
451
|
+
isLoading(): boolean;
|
|
452
|
+
/** Set loading state */
|
|
453
|
+
setLoading(loading: boolean): void;
|
|
454
|
+
/** Check if there are more items to load */
|
|
455
|
+
hasMore(): boolean;
|
|
456
|
+
/** Set whether there are more items */
|
|
457
|
+
setHasMore(hasMore: boolean): void;
|
|
458
|
+
/** Check if can load forward */
|
|
459
|
+
hasMoreForward(): boolean;
|
|
460
|
+
/** Set whether can load forward */
|
|
461
|
+
setHasMoreForward(hasMore: boolean): void;
|
|
462
|
+
/** Check if can load backward */
|
|
463
|
+
hasMoreBackward(): boolean;
|
|
464
|
+
/** Set whether can load backward */
|
|
465
|
+
setHasMoreBackward(hasMore: boolean): void;
|
|
466
|
+
/** Reset loading state */
|
|
467
|
+
reset(): void;
|
|
468
|
+
/** Trigger load manually */
|
|
469
|
+
triggerLoad(direction: LoadDirection): void;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Creates an infinite loader plugin.
|
|
473
|
+
* Handles infinite scroll detection and triggering.
|
|
474
|
+
*
|
|
475
|
+
* @param options - Plugin options
|
|
476
|
+
* @returns Plugin instance
|
|
477
|
+
*/
|
|
478
|
+
declare function infiniteLoaderPlugin(options: InfiniteLoaderOptions): Plugin;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Scroll controller plugin options.
|
|
482
|
+
*/
|
|
483
|
+
interface ScrollControllerOptions {
|
|
484
|
+
/** Default scroll duration (ms) */
|
|
485
|
+
defaultDuration?: number;
|
|
486
|
+
/** Default easing function */
|
|
487
|
+
defaultEasing?: EasingFunction;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Scroll controller plugin API.
|
|
491
|
+
*/
|
|
492
|
+
interface ScrollControllerAPI {
|
|
493
|
+
/** Scroll to an offset */
|
|
494
|
+
scrollTo(offset: number, options?: ScrollOptions): void;
|
|
495
|
+
/** Scroll to an item index */
|
|
496
|
+
scrollToIndex(index: number, options?: ScrollToIndexOptions): void;
|
|
497
|
+
/** Scroll to the top */
|
|
498
|
+
scrollToTop(options?: ScrollOptions): void;
|
|
499
|
+
/** Scroll to the bottom */
|
|
500
|
+
scrollToBottom(options?: ScrollOptions): void;
|
|
501
|
+
/** Get current scroll position */
|
|
502
|
+
getScrollPosition(): ScrollPosition;
|
|
503
|
+
/** Check if currently scrolling */
|
|
504
|
+
isScrolling(): boolean;
|
|
505
|
+
/** Check if animation is in progress */
|
|
506
|
+
isAnimating(): boolean;
|
|
507
|
+
/** Stop current scroll animation */
|
|
508
|
+
stopAnimation(): void;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Creates a scroll controller plugin.
|
|
512
|
+
* Provides programmatic scroll control with smooth animations.
|
|
513
|
+
*
|
|
514
|
+
* @param options - Plugin options
|
|
515
|
+
* @returns Plugin instance
|
|
516
|
+
*/
|
|
517
|
+
declare function scrollControllerPlugin(options?: ScrollControllerOptions): Plugin;
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Masonry renderer plugin options.
|
|
521
|
+
*/
|
|
522
|
+
interface MasonryRendererOptions {
|
|
523
|
+
/** Number of columns or 'auto' for responsive */
|
|
524
|
+
columns: number | 'auto';
|
|
525
|
+
/** Minimum column width for auto columns */
|
|
526
|
+
minColumnWidth?: number;
|
|
527
|
+
/** Gap between items */
|
|
528
|
+
gap?: number;
|
|
529
|
+
/** Function to get item height based on item data and column width */
|
|
530
|
+
getItemHeight: (index: number, columnWidth: number) => number;
|
|
531
|
+
/** Get item key for React reconciliation */
|
|
532
|
+
getItemKey?: (index: number) => string | number;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Masonry renderer plugin API.
|
|
536
|
+
*/
|
|
537
|
+
interface MasonryRendererAPI {
|
|
538
|
+
/** Get virtual items to render */
|
|
539
|
+
getVirtualItems(): VirtualItem[];
|
|
540
|
+
/** Get total scroll height */
|
|
541
|
+
getTotalHeight(): number;
|
|
542
|
+
/** Get heights of each column */
|
|
543
|
+
getColumnHeights(): number[];
|
|
544
|
+
/** Get the index of the shortest column */
|
|
545
|
+
getShortestColumn(): number;
|
|
546
|
+
/** Get the index of the longest column */
|
|
547
|
+
getLongestColumn(): number;
|
|
548
|
+
/** Get number of columns */
|
|
549
|
+
getColumnCount(): number;
|
|
550
|
+
/** Get column width */
|
|
551
|
+
getColumnWidth(): number;
|
|
552
|
+
/** Force recalculation of layout */
|
|
553
|
+
recalculate(): void;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Creates a masonry renderer plugin.
|
|
557
|
+
* Implements Pinterest-style masonry layout with items placed in the shortest column.
|
|
558
|
+
*
|
|
559
|
+
* @param options - Plugin options
|
|
560
|
+
* @returns Plugin instance
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* ```tsx
|
|
564
|
+
* import { masonryRenderer } from '@oxog/scrollex/plugins'
|
|
565
|
+
*
|
|
566
|
+
* <VirtualMasonry
|
|
567
|
+
* data={images}
|
|
568
|
+
* plugins={[masonryRenderer({
|
|
569
|
+
* columns: 3,
|
|
570
|
+
* gap: 8,
|
|
571
|
+
* getItemHeight: (index, columnWidth) => {
|
|
572
|
+
* const item = images[index]
|
|
573
|
+
* return (item.height / item.width) * columnWidth
|
|
574
|
+
* },
|
|
575
|
+
* })]}
|
|
576
|
+
* renderItem={({ item, width }) => (
|
|
577
|
+
* <Image src={item.url} width={width} />
|
|
578
|
+
* )}
|
|
579
|
+
* />
|
|
580
|
+
* ```
|
|
581
|
+
*/
|
|
582
|
+
declare function masonryRenderer(options: MasonryRendererOptions): Plugin;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Sticky headers plugin options.
|
|
586
|
+
*/
|
|
587
|
+
interface StickyHeadersOptions {
|
|
588
|
+
/** Height of headers (or function to get height by group ID) */
|
|
589
|
+
headerHeight: number | ((groupId: string) => number);
|
|
590
|
+
/** Function to determine if an item is a header */
|
|
591
|
+
isHeader: (index: number) => boolean;
|
|
592
|
+
/** Function to get the group ID for an item */
|
|
593
|
+
getGroupId: (index: number) => string;
|
|
594
|
+
/** Z-index for sticky headers */
|
|
595
|
+
zIndex?: number;
|
|
596
|
+
/** Offset from top for sticky positioning */
|
|
597
|
+
stickyOffset?: number;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Sticky headers plugin API.
|
|
601
|
+
*/
|
|
602
|
+
interface StickyHeadersAPI {
|
|
603
|
+
/** Get the currently sticky header index */
|
|
604
|
+
getCurrentStickyHeader(): number | null;
|
|
605
|
+
/** Get the group ID for an item index */
|
|
606
|
+
getGroupForIndex(index: number): string;
|
|
607
|
+
/** Scroll to a group by ID */
|
|
608
|
+
scrollToGroup(groupId: string): void;
|
|
609
|
+
/** Get all header indices */
|
|
610
|
+
getHeaderIndices(): number[];
|
|
611
|
+
/** Get all group IDs */
|
|
612
|
+
getGroupIds(): string[];
|
|
613
|
+
/** Check if an index is a header */
|
|
614
|
+
isHeader(index: number): boolean;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Creates a sticky headers plugin.
|
|
618
|
+
* Enables sticky group headers that remain visible while scrolling.
|
|
619
|
+
*
|
|
620
|
+
* @param options - Plugin options
|
|
621
|
+
* @returns Plugin instance
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* ```tsx
|
|
625
|
+
* import { stickyHeaders } from '@oxog/scrollex/plugins'
|
|
626
|
+
*
|
|
627
|
+
* const groupedItems = [
|
|
628
|
+
* { type: 'header', groupId: 'A', title: 'Group A' },
|
|
629
|
+
* { type: 'item', groupId: 'A', name: 'Item 1' },
|
|
630
|
+
* { type: 'item', groupId: 'A', name: 'Item 2' },
|
|
631
|
+
* { type: 'header', groupId: 'B', title: 'Group B' },
|
|
632
|
+
* { type: 'item', groupId: 'B', name: 'Item 3' },
|
|
633
|
+
* ]
|
|
634
|
+
*
|
|
635
|
+
* <VirtualList
|
|
636
|
+
* data={groupedItems}
|
|
637
|
+
* plugins={[stickyHeaders({
|
|
638
|
+
* headerHeight: 40,
|
|
639
|
+
* isHeader: (index) => groupedItems[index].type === 'header',
|
|
640
|
+
* getGroupId: (index) => groupedItems[index].groupId,
|
|
641
|
+
* })]}
|
|
642
|
+
* renderItem={({ item, style }) => (
|
|
643
|
+
* item.type === 'header'
|
|
644
|
+
* ? <Header style={style}>{item.title}</Header>
|
|
645
|
+
* : <Row style={style}>{item.name}</Row>
|
|
646
|
+
* )}
|
|
647
|
+
* />
|
|
648
|
+
* ```
|
|
649
|
+
*/
|
|
650
|
+
declare function stickyHeaders(options: StickyHeadersOptions): Plugin;
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Keyboard navigation orientation.
|
|
654
|
+
*/
|
|
655
|
+
type KeyboardNavOrientation = 'vertical' | 'horizontal' | 'grid';
|
|
656
|
+
/**
|
|
657
|
+
* Keyboard navigation plugin options.
|
|
658
|
+
*/
|
|
659
|
+
interface KeyboardNavOptions {
|
|
660
|
+
/** Whether keyboard navigation is enabled */
|
|
661
|
+
enabled?: boolean;
|
|
662
|
+
/** Whether to loop around at ends */
|
|
663
|
+
loop?: boolean;
|
|
664
|
+
/** Navigation orientation */
|
|
665
|
+
orientation?: KeyboardNavOrientation;
|
|
666
|
+
/** Items to skip on PageUp/PageDown */
|
|
667
|
+
pageSize?: number;
|
|
668
|
+
/** Number of columns (for grid orientation) */
|
|
669
|
+
columns?: number;
|
|
670
|
+
/** Enable type-ahead search */
|
|
671
|
+
typeahead?: boolean;
|
|
672
|
+
/** Timeout for type-ahead reset (ms) */
|
|
673
|
+
typeaheadTimeout?: number;
|
|
674
|
+
/** Get searchable text for an item */
|
|
675
|
+
getItemText?: (index: number) => string;
|
|
676
|
+
/** Callback when focus changes */
|
|
677
|
+
onFocus?: (index: number) => void;
|
|
678
|
+
/** Callback when item is selected */
|
|
679
|
+
onSelect?: (index: number) => void;
|
|
680
|
+
/** Custom key handler */
|
|
681
|
+
onKeyDown?: (event: KeyboardEvent, focusedIndex: number | null) => boolean | void;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Keyboard navigation plugin API.
|
|
685
|
+
*/
|
|
686
|
+
interface KeyboardNavAPI {
|
|
687
|
+
/** Get the currently focused index */
|
|
688
|
+
getFocusedIndex(): number | null;
|
|
689
|
+
/** Set the focused index */
|
|
690
|
+
setFocusedIndex(index: number | null): void;
|
|
691
|
+
/** Focus the next item */
|
|
692
|
+
focusNext(): void;
|
|
693
|
+
/** Focus the previous item */
|
|
694
|
+
focusPrevious(): void;
|
|
695
|
+
/** Focus the first item */
|
|
696
|
+
focusFirst(): void;
|
|
697
|
+
/** Focus the last item */
|
|
698
|
+
focusLast(): void;
|
|
699
|
+
/** Select the focused item */
|
|
700
|
+
selectFocused(): void;
|
|
701
|
+
/** Enable keyboard navigation */
|
|
702
|
+
enable(): void;
|
|
703
|
+
/** Disable keyboard navigation */
|
|
704
|
+
disable(): void;
|
|
705
|
+
/** Check if enabled */
|
|
706
|
+
isEnabled(): boolean;
|
|
707
|
+
/** Clear type-ahead buffer */
|
|
708
|
+
clearTypeahead(): void;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Creates a keyboard navigation plugin.
|
|
712
|
+
* Provides accessible keyboard navigation for virtualized lists.
|
|
713
|
+
*
|
|
714
|
+
* @param options - Plugin options
|
|
715
|
+
* @returns Plugin instance
|
|
716
|
+
*
|
|
717
|
+
* @example
|
|
718
|
+
* ```tsx
|
|
719
|
+
* import { keyboardNav } from '@oxog/scrollex/plugins'
|
|
720
|
+
*
|
|
721
|
+
* <VirtualList
|
|
722
|
+
* data={items}
|
|
723
|
+
* plugins={[keyboardNav({
|
|
724
|
+
* loop: true,
|
|
725
|
+
* orientation: 'vertical',
|
|
726
|
+
* onSelect: (index) => handleSelect(items[index]),
|
|
727
|
+
* })]}
|
|
728
|
+
* renderItem={...}
|
|
729
|
+
* />
|
|
730
|
+
* ```
|
|
731
|
+
*/
|
|
732
|
+
declare function keyboardNav(options?: KeyboardNavOptions): Plugin;
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Storage interface for scroll restoration.
|
|
736
|
+
*/
|
|
737
|
+
interface ScrollRestorationStorage {
|
|
738
|
+
getItem(key: string): string | null;
|
|
739
|
+
setItem(key: string, value: string): void;
|
|
740
|
+
removeItem(key: string): void;
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Saved scroll state.
|
|
744
|
+
*/
|
|
745
|
+
interface SavedScrollState {
|
|
746
|
+
scrollTop: number;
|
|
747
|
+
scrollLeft: number;
|
|
748
|
+
focusedIndex?: number;
|
|
749
|
+
timestamp: number;
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Scroll restoration plugin options.
|
|
753
|
+
*/
|
|
754
|
+
interface ScrollRestorationOptions {
|
|
755
|
+
/** Unique key for storage */
|
|
756
|
+
key: string;
|
|
757
|
+
/** Storage type or custom storage */
|
|
758
|
+
storage?: 'sessionStorage' | 'localStorage' | ScrollRestorationStorage;
|
|
759
|
+
/** Restore scroll position on mount */
|
|
760
|
+
restoreOnMount?: boolean;
|
|
761
|
+
/** Save scroll position on unmount */
|
|
762
|
+
saveOnUnmount?: boolean;
|
|
763
|
+
/** Save scroll position while scrolling (debounced) */
|
|
764
|
+
saveOnScroll?: boolean;
|
|
765
|
+
/** Debounce time for save on scroll (ms) */
|
|
766
|
+
debounceMs?: number;
|
|
767
|
+
/** Include focused index in saved state */
|
|
768
|
+
includeIndex?: boolean;
|
|
769
|
+
/** Maximum age of saved state (ms), 0 = no expiry */
|
|
770
|
+
maxAge?: number;
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Scroll restoration plugin API.
|
|
774
|
+
*/
|
|
775
|
+
interface ScrollRestorationAPI {
|
|
776
|
+
/** Save current scroll position */
|
|
777
|
+
save(): void;
|
|
778
|
+
/** Restore saved scroll position */
|
|
779
|
+
restore(): boolean;
|
|
780
|
+
/** Clear saved scroll position */
|
|
781
|
+
clear(): void;
|
|
782
|
+
/** Get saved position without restoring */
|
|
783
|
+
getSavedPosition(): SavedScrollState | null;
|
|
784
|
+
/** Check if there's a saved position */
|
|
785
|
+
hasSavedPosition(): boolean;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Creates a scroll restoration plugin.
|
|
789
|
+
* Saves and restores scroll position across sessions.
|
|
790
|
+
*
|
|
791
|
+
* @param options - Plugin options
|
|
792
|
+
* @returns Plugin instance
|
|
793
|
+
*
|
|
794
|
+
* @example
|
|
795
|
+
* ```tsx
|
|
796
|
+
* import { scrollRestoration } from '@oxog/scrollex/plugins'
|
|
797
|
+
*
|
|
798
|
+
* <VirtualList
|
|
799
|
+
* data={items}
|
|
800
|
+
* plugins={[scrollRestoration({
|
|
801
|
+
* key: 'my-list',
|
|
802
|
+
* storage: 'sessionStorage',
|
|
803
|
+
* restoreOnMount: true,
|
|
804
|
+
* saveOnUnmount: true,
|
|
805
|
+
* })]}
|
|
806
|
+
* renderItem={...}
|
|
807
|
+
* />
|
|
808
|
+
* ```
|
|
809
|
+
*/
|
|
810
|
+
declare function scrollRestoration(options: ScrollRestorationOptions): Plugin;
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Bidirectional scroll plugin options.
|
|
814
|
+
*/
|
|
815
|
+
interface BidirectionalOptions {
|
|
816
|
+
/** Initial scroll position */
|
|
817
|
+
initialPosition?: 'top' | 'bottom';
|
|
818
|
+
/** Whether to stick to bottom when new items are added */
|
|
819
|
+
stickToBottom?: boolean;
|
|
820
|
+
/** Threshold in pixels from bottom to activate stick behavior */
|
|
821
|
+
stickThreshold?: number;
|
|
822
|
+
/** Maintain scroll position when items are prepended */
|
|
823
|
+
maintainPositionOnPrepend?: boolean;
|
|
824
|
+
/** Callback when load more is triggered */
|
|
825
|
+
onLoadMore?: (direction: 'forward' | 'backward') => void;
|
|
826
|
+
/** Threshold for triggering load more (pixels from edge) */
|
|
827
|
+
loadMoreThreshold?: number;
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Bidirectional scroll plugin API.
|
|
831
|
+
*/
|
|
832
|
+
interface BidirectionalAPI {
|
|
833
|
+
/** Check if scrolled to bottom */
|
|
834
|
+
isAtBottom(): boolean;
|
|
835
|
+
/** Check if scrolled to top */
|
|
836
|
+
isAtTop(): boolean;
|
|
837
|
+
/** Scroll to bottom */
|
|
838
|
+
scrollToBottom(smooth?: boolean): void;
|
|
839
|
+
/** Scroll to top */
|
|
840
|
+
scrollToTop(smooth?: boolean): void;
|
|
841
|
+
/** Enable/disable stick to bottom */
|
|
842
|
+
setStickToBottom(stick: boolean): void;
|
|
843
|
+
/** Check if sticking to bottom */
|
|
844
|
+
isStickingToBottom(): boolean;
|
|
845
|
+
/** Adjust scroll position when items are prepended */
|
|
846
|
+
adjustForPrepend(prependedHeight: number): void;
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Creates a bidirectional scroll plugin.
|
|
850
|
+
* Ideal for chat applications with messages loaded in both directions.
|
|
851
|
+
*
|
|
852
|
+
* @param options - Plugin options
|
|
853
|
+
* @returns Plugin instance
|
|
854
|
+
*
|
|
855
|
+
* @example
|
|
856
|
+
* ```tsx
|
|
857
|
+
* import { bidirectional } from '@oxog/scrollex/plugins'
|
|
858
|
+
*
|
|
859
|
+
* <VirtualList
|
|
860
|
+
* data={messages}
|
|
861
|
+
* itemHeight="auto"
|
|
862
|
+
* plugins={[bidirectional({
|
|
863
|
+
* stickToBottom: true,
|
|
864
|
+
* initialPosition: 'bottom',
|
|
865
|
+
* maintainPositionOnPrepend: true,
|
|
866
|
+
* })]}
|
|
867
|
+
* onLoadMore={(direction) => {
|
|
868
|
+
* if (direction === 'backward') loadOlderMessages()
|
|
869
|
+
* if (direction === 'forward') loadNewerMessages()
|
|
870
|
+
* }}
|
|
871
|
+
* renderItem={({ item, measureRef }) => (
|
|
872
|
+
* <div ref={measureRef}>
|
|
873
|
+
* <Message message={item} />
|
|
874
|
+
* </div>
|
|
875
|
+
* )}
|
|
876
|
+
* />
|
|
877
|
+
* ```
|
|
878
|
+
*/
|
|
879
|
+
declare function bidirectional(options?: BidirectionalOptions): Plugin;
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Drag axis.
|
|
883
|
+
*/
|
|
884
|
+
type DragAxis = 'vertical' | 'horizontal';
|
|
885
|
+
/**
|
|
886
|
+
* Drop indicator style.
|
|
887
|
+
*/
|
|
888
|
+
type DropIndicatorStyle = 'line' | 'gap' | 'none';
|
|
889
|
+
/**
|
|
890
|
+
* Drag to reorder plugin options.
|
|
891
|
+
*/
|
|
892
|
+
interface DragToReorderOptions {
|
|
893
|
+
/** Whether drag to reorder is enabled */
|
|
894
|
+
enabled?: boolean;
|
|
895
|
+
/** Drag axis */
|
|
896
|
+
axis?: DragAxis;
|
|
897
|
+
/** Require a drag handle (vs dragging anywhere) */
|
|
898
|
+
handle?: boolean;
|
|
899
|
+
/** Auto-scroll when dragging near edges */
|
|
900
|
+
autoScroll?: boolean;
|
|
901
|
+
/** Auto-scroll speed (px per frame) */
|
|
902
|
+
autoScrollSpeed?: number;
|
|
903
|
+
/** Drop indicator style */
|
|
904
|
+
dropIndicator?: DropIndicatorStyle;
|
|
905
|
+
/** Callback when drag starts */
|
|
906
|
+
onDragStart?: (index: number) => void;
|
|
907
|
+
/** Callback when drag ends */
|
|
908
|
+
onDragEnd?: (index: number) => void;
|
|
909
|
+
/** Callback when reorder occurs */
|
|
910
|
+
onReorder: (fromIndex: number, toIndex: number) => void;
|
|
911
|
+
/** Check if an item can be dragged */
|
|
912
|
+
canDrag?: (index: number) => boolean;
|
|
913
|
+
/** Check if an item can be dropped at a position */
|
|
914
|
+
canDrop?: (fromIndex: number, toIndex: number) => boolean;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Drag to reorder plugin API.
|
|
918
|
+
*/
|
|
919
|
+
interface DragToReorderAPI {
|
|
920
|
+
/** Check if currently dragging */
|
|
921
|
+
isDragging(): boolean;
|
|
922
|
+
/** Get the dragged item index */
|
|
923
|
+
getDraggedIndex(): number | null;
|
|
924
|
+
/** Get the current drop target index */
|
|
925
|
+
getDropTargetIndex(): number | null;
|
|
926
|
+
/** Cancel current drag */
|
|
927
|
+
cancelDrag(): void;
|
|
928
|
+
/** Enable drag to reorder */
|
|
929
|
+
enable(): void;
|
|
930
|
+
/** Disable drag to reorder */
|
|
931
|
+
disable(): void;
|
|
932
|
+
/** Check if enabled */
|
|
933
|
+
isEnabled(): boolean;
|
|
934
|
+
/** Create drag handle props */
|
|
935
|
+
getDragHandleProps(index: number): DragHandleProps;
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Props for drag handle element.
|
|
939
|
+
*/
|
|
940
|
+
interface DragHandleProps {
|
|
941
|
+
draggable: boolean;
|
|
942
|
+
onDragStart: (event: DragEvent) => void;
|
|
943
|
+
onDragEnd: (event: DragEvent) => void;
|
|
944
|
+
onDragOver: (event: DragEvent) => void;
|
|
945
|
+
onDragEnter: (event: DragEvent) => void;
|
|
946
|
+
onDragLeave: (event: DragEvent) => void;
|
|
947
|
+
onDrop: (event: DragEvent) => void;
|
|
948
|
+
'data-drag-index': string;
|
|
949
|
+
'aria-grabbed': boolean;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Creates a drag to reorder plugin.
|
|
953
|
+
* Enables drag and drop reordering of list items.
|
|
954
|
+
*
|
|
955
|
+
* @param options - Plugin options
|
|
956
|
+
* @returns Plugin instance
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```tsx
|
|
960
|
+
* import { dragToReorder } from '@oxog/scrollex/plugins'
|
|
961
|
+
*
|
|
962
|
+
* const [items, setItems] = useState(initialItems)
|
|
963
|
+
*
|
|
964
|
+
* <VirtualList
|
|
965
|
+
* data={items}
|
|
966
|
+
* plugins={[dragToReorder({
|
|
967
|
+
* onReorder: (fromIndex, toIndex) => {
|
|
968
|
+
* const newItems = [...items]
|
|
969
|
+
* const [removed] = newItems.splice(fromIndex, 1)
|
|
970
|
+
* newItems.splice(toIndex, 0, removed)
|
|
971
|
+
* setItems(newItems)
|
|
972
|
+
* },
|
|
973
|
+
* })]}
|
|
974
|
+
* renderItem={({ item, index, dragHandleProps }) => (
|
|
975
|
+
* <Row item={item}>
|
|
976
|
+
* <DragHandle {...dragHandleProps} />
|
|
977
|
+
* </Row>
|
|
978
|
+
* )}
|
|
979
|
+
* />
|
|
980
|
+
* ```
|
|
981
|
+
*/
|
|
982
|
+
declare function dragToReorder(options: DragToReorderOptions): Plugin;
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* Debug panel position.
|
|
986
|
+
*/
|
|
987
|
+
type DebugPanelPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
988
|
+
/**
|
|
989
|
+
* Debug panel theme.
|
|
990
|
+
*/
|
|
991
|
+
type DebugPanelTheme = 'light' | 'dark' | 'auto';
|
|
992
|
+
/**
|
|
993
|
+
* Debug panel tab.
|
|
994
|
+
*/
|
|
995
|
+
type DebugPanelTab = 'stats' | 'viewport' | 'items' | 'events';
|
|
996
|
+
/**
|
|
997
|
+
* Performance stats.
|
|
998
|
+
*/
|
|
999
|
+
interface PerformanceStats {
|
|
1000
|
+
/** Frames per second */
|
|
1001
|
+
fps: number;
|
|
1002
|
+
/** Frame time in ms */
|
|
1003
|
+
frameTime: number;
|
|
1004
|
+
/** Memory usage in MB (if available) */
|
|
1005
|
+
memoryUsage: number | null;
|
|
1006
|
+
/** Total items */
|
|
1007
|
+
totalItems: number;
|
|
1008
|
+
/** Visible items count */
|
|
1009
|
+
visibleItems: number;
|
|
1010
|
+
/** Rendered items count */
|
|
1011
|
+
renderedItems: number;
|
|
1012
|
+
/** Overscan items */
|
|
1013
|
+
overscanItems: number;
|
|
1014
|
+
/** Average item height */
|
|
1015
|
+
avgItemHeight: number;
|
|
1016
|
+
/** Scroll position */
|
|
1017
|
+
scrollPosition: ScrollPosition;
|
|
1018
|
+
/** Visible range */
|
|
1019
|
+
visibleRange: Range;
|
|
1020
|
+
/** Render range */
|
|
1021
|
+
renderRange: Range;
|
|
1022
|
+
/** Scroll velocity */
|
|
1023
|
+
scrollVelocity: number;
|
|
1024
|
+
/** Is scrolling */
|
|
1025
|
+
isScrolling: boolean;
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Event log entry.
|
|
1029
|
+
*/
|
|
1030
|
+
interface EventLogEntry {
|
|
1031
|
+
/** Event ID */
|
|
1032
|
+
id: number;
|
|
1033
|
+
/** Event type */
|
|
1034
|
+
type: string;
|
|
1035
|
+
/** Timestamp */
|
|
1036
|
+
timestamp: number;
|
|
1037
|
+
/** Event data */
|
|
1038
|
+
data: unknown;
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Debug panel options.
|
|
1042
|
+
*/
|
|
1043
|
+
interface DebugPanelOptions {
|
|
1044
|
+
/** Whether debug panel is enabled */
|
|
1045
|
+
enabled?: boolean;
|
|
1046
|
+
/** Initial collapsed state */
|
|
1047
|
+
collapsed?: boolean;
|
|
1048
|
+
/** Panel position */
|
|
1049
|
+
position?: DebugPanelPosition;
|
|
1050
|
+
/** Panel theme */
|
|
1051
|
+
theme?: DebugPanelTheme;
|
|
1052
|
+
/** Show FPS counter */
|
|
1053
|
+
showFps?: boolean;
|
|
1054
|
+
/** Show viewport overlay */
|
|
1055
|
+
showViewportOverlay?: boolean;
|
|
1056
|
+
/** Show item boundaries */
|
|
1057
|
+
showItemBoundaries?: boolean;
|
|
1058
|
+
/** Log events to console */
|
|
1059
|
+
logEvents?: boolean;
|
|
1060
|
+
/** Max event log entries */
|
|
1061
|
+
maxEventLogEntries?: number;
|
|
1062
|
+
/** Stats update interval in ms */
|
|
1063
|
+
statsUpdateInterval?: number;
|
|
1064
|
+
}
|
|
1065
|
+
/**
|
|
1066
|
+
* Debug panel API.
|
|
1067
|
+
*/
|
|
1068
|
+
interface DebugPanelAPI {
|
|
1069
|
+
/** Toggle panel visibility */
|
|
1070
|
+
toggle(): void;
|
|
1071
|
+
/** Show panel */
|
|
1072
|
+
show(): void;
|
|
1073
|
+
/** Hide panel */
|
|
1074
|
+
hide(): void;
|
|
1075
|
+
/** Check if visible */
|
|
1076
|
+
isVisible(): boolean;
|
|
1077
|
+
/** Set collapsed state */
|
|
1078
|
+
setCollapsed(collapsed: boolean): void;
|
|
1079
|
+
/** Check if collapsed */
|
|
1080
|
+
isCollapsed(): boolean;
|
|
1081
|
+
/** Get current stats */
|
|
1082
|
+
getStats(): PerformanceStats;
|
|
1083
|
+
/** Get event log */
|
|
1084
|
+
getEventLog(): EventLogEntry[];
|
|
1085
|
+
/** Clear event log */
|
|
1086
|
+
clearEventLog(): void;
|
|
1087
|
+
/** Set active tab */
|
|
1088
|
+
setActiveTab(tab: DebugPanelTab): void;
|
|
1089
|
+
/** Get active tab */
|
|
1090
|
+
getActiveTab(): DebugPanelTab;
|
|
1091
|
+
/** Toggle viewport overlay */
|
|
1092
|
+
toggleViewportOverlay(): void;
|
|
1093
|
+
/** Toggle item boundaries */
|
|
1094
|
+
toggleItemBoundaries(): void;
|
|
1095
|
+
/** Export debug data as JSON */
|
|
1096
|
+
exportData(): string;
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Debug panel state.
|
|
1100
|
+
*/
|
|
1101
|
+
interface DebugPanelState {
|
|
1102
|
+
visible: boolean;
|
|
1103
|
+
collapsed: boolean;
|
|
1104
|
+
activeTab: DebugPanelTab;
|
|
1105
|
+
stats: PerformanceStats;
|
|
1106
|
+
eventLog: EventLogEntry[];
|
|
1107
|
+
showViewportOverlay: boolean;
|
|
1108
|
+
showItemBoundaries: boolean;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* Creates a debug panel plugin.
|
|
1113
|
+
* Provides debugging and performance monitoring tools.
|
|
1114
|
+
*
|
|
1115
|
+
* @param options - Plugin options
|
|
1116
|
+
* @returns Plugin instance
|
|
1117
|
+
*/
|
|
1118
|
+
declare function debugPanel(options?: DebugPanelOptions): Plugin;
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* Props for DebugPanelOverlay component.
|
|
1122
|
+
*/
|
|
1123
|
+
interface DebugPanelOverlayProps {
|
|
1124
|
+
/** Debug panel plugin instance */
|
|
1125
|
+
plugin: Plugin;
|
|
1126
|
+
/** Additional class name */
|
|
1127
|
+
className?: string;
|
|
1128
|
+
/** Custom styles */
|
|
1129
|
+
style?: React.CSSProperties;
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Debug panel overlay component.
|
|
1133
|
+
* Renders a floating debug panel with stats and tools.
|
|
1134
|
+
*/
|
|
1135
|
+
declare function DebugPanelOverlay({ plugin, className, style, }: DebugPanelOverlayProps): React.ReactElement | null;
|
|
1136
|
+
|
|
1137
|
+
export { type AutoMeasurerAPI, type AutoMeasurerOptions, type BidirectionalAPI, type BidirectionalOptions, type DebugPanelAPI, type DebugPanelOptions, DebugPanelOverlay, type DebugPanelOverlayProps, type DebugPanelPosition, type DebugPanelState, type DebugPanelTab, type DebugPanelTheme, type DragAxis, type DragHandleProps, type DragToReorderAPI, type DragToReorderOptions, type DropIndicatorStyle, type EventLogEntry, type GridRendererAPI, type GridRendererOptions, type InfiniteLoaderAPI, type InfiniteLoaderOptions, type KeyboardNavAPI, type KeyboardNavOptions, type KeyboardNavOrientation, type ListRendererAPI, type ListRendererOptions, type LoadDirection, type MasonryRendererAPI, type MasonryRendererOptions, type PerformanceStats, type SavedScrollState, type ScrollControllerAPI, type ScrollControllerOptions, type ScrollRestorationAPI, type ScrollRestorationOptions, type ScrollRestorationStorage, type StickyHeadersAPI, type StickyHeadersOptions, autoMeasurerPlugin, bidirectional, debugPanel, dragToReorder, gridRendererPlugin, infiniteLoaderPlugin, keyboardNav, listRendererPlugin, masonryRenderer, scrollControllerPlugin, scrollRestoration, stickyHeaders };
|