@oxog/scrollex 1.0.0 → 1.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.
- package/CHANGELOG.md +86 -5
- package/README.md +30 -22
- package/dist/chunk-CIB3EBBJ.js +734 -0
- package/dist/chunk-CIB3EBBJ.js.map +1 -0
- package/dist/chunk-ND5PV5MU.cjs +747 -0
- package/dist/chunk-ND5PV5MU.cjs.map +1 -0
- package/dist/index.cjs +677 -961
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -784
- package/dist/index.d.ts +5 -784
- package/dist/index.js +651 -949
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.cjs +255 -766
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.d.cts +61 -560
- package/dist/plugins/index.d.ts +61 -560
- package/dist/plugins/index.js +236 -761
- package/dist/plugins/index.js.map +1 -1
- package/dist/scroll-controller-D5AV1E2p.d.cts +809 -0
- package/dist/scroll-controller-D5AV1E2p.d.ts +809 -0
- package/package.json +30 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,581 +1,6 @@
|
|
|
1
|
-
import React$1
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Represents a virtualized item with position and size information.
|
|
5
|
-
*/
|
|
6
|
-
interface VirtualItem {
|
|
7
|
-
/** Index of the item in the data array */
|
|
8
|
-
index: number;
|
|
9
|
-
/** Unique key for React reconciliation */
|
|
10
|
-
key: string | number;
|
|
11
|
-
/** Offset from the start of the scroll container (px) */
|
|
12
|
-
start: number;
|
|
13
|
-
/** End position (start + size) */
|
|
14
|
-
end: number;
|
|
15
|
-
/** Size of the item (height for vertical, width for horizontal) */
|
|
16
|
-
size: number;
|
|
17
|
-
/** Lane/column index for grid and masonry layouts */
|
|
18
|
-
lane: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Represents the visible range of items.
|
|
22
|
-
*/
|
|
23
|
-
interface Range {
|
|
24
|
-
/** First visible item index */
|
|
25
|
-
startIndex: number;
|
|
26
|
-
/** Last visible item index */
|
|
27
|
-
endIndex: number;
|
|
28
|
-
/** First rendered item index (including overscan) */
|
|
29
|
-
overscanStartIndex: number;
|
|
30
|
-
/** Last rendered item index (including overscan) */
|
|
31
|
-
overscanEndIndex: number;
|
|
32
|
-
/** Alias for startIndex */
|
|
33
|
-
start?: number;
|
|
34
|
-
/** Alias for endIndex */
|
|
35
|
-
end?: number;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Represents scroll position in both axes.
|
|
39
|
-
*/
|
|
40
|
-
interface ScrollPosition {
|
|
41
|
-
scrollTop: number;
|
|
42
|
-
scrollLeft: number;
|
|
43
|
-
/** Normalized offset (scrollTop for vertical, scrollLeft for horizontal) */
|
|
44
|
-
offset?: number;
|
|
45
|
-
/** Scroll percentage (0-1) */
|
|
46
|
-
percentage?: number;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Represents the viewport dimensions.
|
|
50
|
-
*/
|
|
51
|
-
interface Viewport {
|
|
52
|
-
/** Visible width of the container */
|
|
53
|
-
width: number;
|
|
54
|
-
/** Visible height of the container */
|
|
55
|
-
height: number;
|
|
56
|
-
/** Total scrollable height */
|
|
57
|
-
scrollHeight: number;
|
|
58
|
-
/** Total scrollable width */
|
|
59
|
-
scrollWidth: number;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Scroll direction.
|
|
63
|
-
*/
|
|
64
|
-
type ScrollDirection = 'up' | 'down' | 'left' | 'right' | 'none';
|
|
65
|
-
/**
|
|
66
|
-
* Scroll behavior.
|
|
67
|
-
*/
|
|
68
|
-
type ScrollBehavior = 'auto' | 'smooth';
|
|
69
|
-
/**
|
|
70
|
-
* Alignment options for scrollToIndex.
|
|
71
|
-
*/
|
|
72
|
-
type ScrollAlignment = 'start' | 'center' | 'end' | 'auto';
|
|
73
|
-
/**
|
|
74
|
-
* All possible event types.
|
|
75
|
-
*/
|
|
76
|
-
type EventType = 'scroll' | 'scroll-start' | 'scroll-end' | 'visible-range-change' | 'item-measured' | 'resize' | 'load-more' | 'items-change' | 'scrollStart' | 'scrollEnd' | 'visibleRangeChange' | 'itemMeasured' | 'loadMore' | 'itemsChange';
|
|
77
|
-
/**
|
|
78
|
-
* Scroll event payload.
|
|
79
|
-
*/
|
|
80
|
-
interface ScrollEvent {
|
|
81
|
-
type: 'scroll';
|
|
82
|
-
scrollTop: number;
|
|
83
|
-
scrollLeft: number;
|
|
84
|
-
deltaY: number;
|
|
85
|
-
deltaX: number;
|
|
86
|
-
direction: ScrollDirection;
|
|
87
|
-
timestamp: number;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Scroll start event payload.
|
|
91
|
-
*/
|
|
92
|
-
interface ScrollStartEvent {
|
|
93
|
-
type: 'scroll-start';
|
|
94
|
-
scrollTop: number;
|
|
95
|
-
scrollLeft: number;
|
|
96
|
-
timestamp: number;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Scroll end event payload.
|
|
100
|
-
*/
|
|
101
|
-
interface ScrollEndEvent {
|
|
102
|
-
type: 'scroll-end';
|
|
103
|
-
scrollTop: number;
|
|
104
|
-
scrollLeft: number;
|
|
105
|
-
timestamp: number;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Visible range change event payload.
|
|
109
|
-
*/
|
|
110
|
-
interface VisibleRangeChangeEvent {
|
|
111
|
-
type: 'visible-range-change';
|
|
112
|
-
range: Range;
|
|
113
|
-
previousRange: Range | null;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Item measured event payload.
|
|
117
|
-
*/
|
|
118
|
-
interface ItemMeasuredEvent {
|
|
119
|
-
type: 'item-measured';
|
|
120
|
-
index: number;
|
|
121
|
-
height: number;
|
|
122
|
-
previousHeight: number | undefined;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Resize event payload.
|
|
126
|
-
*/
|
|
127
|
-
interface ResizeEvent {
|
|
128
|
-
type: 'resize';
|
|
129
|
-
viewport: Viewport;
|
|
130
|
-
previousViewport: Viewport | null;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Load more event payload.
|
|
134
|
-
*/
|
|
135
|
-
interface LoadMoreEvent {
|
|
136
|
-
type: 'load-more';
|
|
137
|
-
direction: 'forward' | 'backward';
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Items change event payload.
|
|
141
|
-
*/
|
|
142
|
-
interface ItemsChangeEvent {
|
|
143
|
-
type: 'items-change';
|
|
144
|
-
count: number;
|
|
145
|
-
previousCount: number;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Union of all kernel events.
|
|
149
|
-
*/
|
|
150
|
-
type KernelEvent = ScrollEvent | ScrollStartEvent | ScrollEndEvent | VisibleRangeChangeEvent | ItemMeasuredEvent | ResizeEvent | LoadMoreEvent | ItemsChangeEvent;
|
|
151
|
-
/**
|
|
152
|
-
* Event handler function type.
|
|
153
|
-
*/
|
|
154
|
-
type EventHandler<T = KernelEvent> = (event: T) => void;
|
|
155
|
-
/**
|
|
156
|
-
* Unsubscribe function returned by event subscriptions.
|
|
157
|
-
*/
|
|
158
|
-
type Unsubscribe = () => void;
|
|
159
|
-
/**
|
|
160
|
-
* Options for scroll operations.
|
|
161
|
-
*/
|
|
162
|
-
interface ScrollOptions {
|
|
163
|
-
/** Scroll behavior */
|
|
164
|
-
behavior?: ScrollBehavior;
|
|
165
|
-
/** Duration for smooth scroll (ms) */
|
|
166
|
-
duration?: number;
|
|
167
|
-
/** Easing function for smooth scroll */
|
|
168
|
-
easing?: EasingFunction;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Options for scrollToIndex operations.
|
|
172
|
-
*/
|
|
173
|
-
interface ScrollToIndexOptions extends ScrollOptions {
|
|
174
|
-
/** Alignment of the item in the viewport */
|
|
175
|
-
align?: ScrollAlignment;
|
|
176
|
-
/** Additional offset (px) */
|
|
177
|
-
offset?: number;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Easing function type.
|
|
181
|
-
*/
|
|
182
|
-
type EasingFunction = (t: number) => number;
|
|
183
|
-
/**
|
|
184
|
-
* Plugin type - core plugins are always loaded, optional are loaded on demand.
|
|
185
|
-
*/
|
|
186
|
-
type PluginType = 'core' | 'optional';
|
|
187
|
-
/**
|
|
188
|
-
* Plugin hooks interface.
|
|
189
|
-
*/
|
|
190
|
-
interface PluginHooks {
|
|
191
|
-
/** Called on scroll */
|
|
192
|
-
onScroll?: (event: ScrollEvent) => void;
|
|
193
|
-
/** Called when scroll starts */
|
|
194
|
-
onScrollStart?: (event: ScrollStartEvent) => void;
|
|
195
|
-
/** Called when scroll ends */
|
|
196
|
-
onScrollEnd?: (event: ScrollEndEvent) => void;
|
|
197
|
-
/** Called when visible range changes */
|
|
198
|
-
onVisibleRangeChange?: (range: Range, previousRange: Range | null) => void;
|
|
199
|
-
/** Called when an item is measured */
|
|
200
|
-
onItemMeasured?: (index: number, height: number) => void;
|
|
201
|
-
/** Called on viewport resize */
|
|
202
|
-
onResize?: (viewport: Viewport) => void;
|
|
203
|
-
/** Called when load more is triggered */
|
|
204
|
-
onLoadMore?: (direction: 'forward' | 'backward') => void;
|
|
205
|
-
/** Called when item count changes */
|
|
206
|
-
onItemsChange?: (count: number, previousCount: number) => void;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Plugin metadata.
|
|
210
|
-
*/
|
|
211
|
-
interface PluginInfo {
|
|
212
|
-
name: string;
|
|
213
|
-
version: string;
|
|
214
|
-
type: PluginType;
|
|
215
|
-
enabled: boolean;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Plugin interface.
|
|
219
|
-
*/
|
|
220
|
-
interface Plugin {
|
|
221
|
-
/** Unique plugin name */
|
|
222
|
-
name: string;
|
|
223
|
-
/** Plugin version */
|
|
224
|
-
version: string;
|
|
225
|
-
/** Plugin type (core or optional) */
|
|
226
|
-
type: PluginType;
|
|
227
|
-
/** Install plugin into kernel */
|
|
228
|
-
install?(kernel: Kernel): void;
|
|
229
|
-
/** Uninstall plugin */
|
|
230
|
-
uninstall?(): void;
|
|
231
|
-
/** Plugin hooks */
|
|
232
|
-
hooks?: PluginHooks;
|
|
233
|
-
/** Public API exposed by the plugin */
|
|
234
|
-
api?: any;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Plugin configuration for createPlugin helper.
|
|
238
|
-
*/
|
|
239
|
-
interface PluginConfig {
|
|
240
|
-
name: string;
|
|
241
|
-
version: string;
|
|
242
|
-
type: PluginType;
|
|
243
|
-
install: (kernel: Kernel) => void;
|
|
244
|
-
uninstall?: () => void;
|
|
245
|
-
hooks?: PluginHooks;
|
|
246
|
-
api?: Record<string, unknown>;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Kernel configuration options.
|
|
250
|
-
*/
|
|
251
|
-
interface KernelOptions {
|
|
252
|
-
/** Total number of items */
|
|
253
|
-
itemCount: number;
|
|
254
|
-
/** Estimated height of items (used before measurement) */
|
|
255
|
-
estimatedItemHeight: number;
|
|
256
|
-
/** Number of extra items to render outside viewport */
|
|
257
|
-
overscan: number;
|
|
258
|
-
/** Scroll direction */
|
|
259
|
-
direction: 'vertical' | 'horizontal';
|
|
260
|
-
/** Function to get item key */
|
|
261
|
-
getItemKey?: (index: number) => string | number;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Kernel interface - the core of the virtualization engine.
|
|
265
|
-
*/
|
|
266
|
-
interface Kernel {
|
|
267
|
-
/** Register a plugin */
|
|
268
|
-
register(plugin: Plugin): void;
|
|
269
|
-
/** Unregister a plugin by name */
|
|
270
|
-
unregister(pluginName: string): void;
|
|
271
|
-
/** Get a plugin by name */
|
|
272
|
-
getPlugin<T extends Plugin>(name: string): T | undefined;
|
|
273
|
-
/** List all registered plugins */
|
|
274
|
-
listPlugins(): PluginInfo[];
|
|
275
|
-
/** Get current scroll position */
|
|
276
|
-
getScrollPosition(): ScrollPosition;
|
|
277
|
-
/** Set scroll position directly */
|
|
278
|
-
setScrollPosition(position: ScrollPosition): void;
|
|
279
|
-
/** Scroll to offset */
|
|
280
|
-
scrollTo(offset: number, options?: ScrollOptions): void;
|
|
281
|
-
/** Scroll to item index */
|
|
282
|
-
scrollToIndex(index: number, options?: ScrollToIndexOptions): void;
|
|
283
|
-
/** Get viewport dimensions */
|
|
284
|
-
getViewport(): Viewport;
|
|
285
|
-
/** Get visible range */
|
|
286
|
-
getVisibleRange(): Range;
|
|
287
|
-
/** Get render range (including overscan) */
|
|
288
|
-
getRenderRange(): Range;
|
|
289
|
-
/** Measure an item's size */
|
|
290
|
-
measureItem(index: number, size: number): void;
|
|
291
|
-
/** Get cached height for an item */
|
|
292
|
-
getCachedHeight(index: number): number | undefined;
|
|
293
|
-
/** Invalidate measurement for an item */
|
|
294
|
-
invalidateMeasurement(index: number): void;
|
|
295
|
-
/** Invalidate all measurements */
|
|
296
|
-
invalidateAllMeasurements(): void;
|
|
297
|
-
/** Get estimated item height */
|
|
298
|
-
getEstimatedHeight(): number;
|
|
299
|
-
/** Get item offset */
|
|
300
|
-
getItemOffset(index: number): number;
|
|
301
|
-
/** Emit an event */
|
|
302
|
-
emit(event: KernelEvent): void;
|
|
303
|
-
/** Subscribe to an event type */
|
|
304
|
-
on<T extends KernelEvent>(eventType: T['type'], handler: EventHandler<T>): Unsubscribe;
|
|
305
|
-
/** Unsubscribe from an event type */
|
|
306
|
-
off<T extends KernelEvent>(eventType: T['type'], handler: EventHandler<T>): void;
|
|
307
|
-
/** Update kernel configuration */
|
|
308
|
-
configure(options: Partial<KernelOptions>): void;
|
|
309
|
-
/** Get current configuration */
|
|
310
|
-
getOptions(): KernelOptions;
|
|
311
|
-
/** Check if currently scrolling */
|
|
312
|
-
isScrolling(): boolean;
|
|
313
|
-
/** Get item count */
|
|
314
|
-
getItemCount(): number;
|
|
315
|
-
/** Get total scroll size */
|
|
316
|
-
getTotalSize(): number;
|
|
317
|
-
/** Attach to a container element */
|
|
318
|
-
attach(container: HTMLElement): void;
|
|
319
|
-
/** Detach from container */
|
|
320
|
-
detach(): void;
|
|
321
|
-
/** Destroy the kernel */
|
|
322
|
-
destroy(): void;
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Props passed to the renderItem function.
|
|
326
|
-
*/
|
|
327
|
-
interface RenderItemProps<T> {
|
|
328
|
-
/** The item data */
|
|
329
|
-
item: T;
|
|
330
|
-
/** Item index in the data array */
|
|
331
|
-
index: number;
|
|
332
|
-
/** Styles to apply (position, height) */
|
|
333
|
-
style: CSSProperties;
|
|
334
|
-
/** Ref callback for measuring dynamic heights */
|
|
335
|
-
measureRef: RefCallback<HTMLElement>;
|
|
336
|
-
/** Whether the item is in the visible range (not just rendered for overscan) */
|
|
337
|
-
isVisible: boolean;
|
|
338
|
-
/** Whether the list is currently scrolling */
|
|
339
|
-
isScrolling: boolean;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Props for grid item rendering.
|
|
343
|
-
*/
|
|
344
|
-
interface GridRenderItemProps<T> extends RenderItemProps<T> {
|
|
345
|
-
/** Column index (0-based) */
|
|
346
|
-
columnIndex: number;
|
|
347
|
-
/** Row index (0-based) */
|
|
348
|
-
rowIndex: number;
|
|
349
|
-
/** Calculated column width */
|
|
350
|
-
columnWidth: number;
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Props for masonry item rendering.
|
|
354
|
-
*/
|
|
355
|
-
interface MasonryRenderItemProps<T> extends GridRenderItemProps<T> {
|
|
356
|
-
/** Calculated item width */
|
|
357
|
-
width: number;
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Information about rendered items.
|
|
361
|
-
*/
|
|
362
|
-
interface ItemsRenderedInfo {
|
|
363
|
-
overscanStartIndex: number;
|
|
364
|
-
overscanEndIndex: number;
|
|
365
|
-
visibleStartIndex: number;
|
|
366
|
-
visibleEndIndex: number;
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* VirtualList component props.
|
|
370
|
-
*/
|
|
371
|
-
interface VirtualListProps<T> {
|
|
372
|
-
/** Array of items to render */
|
|
373
|
-
data: T[];
|
|
374
|
-
/** Function to render each item */
|
|
375
|
-
renderItem: (props: RenderItemProps<T>) => ReactNode;
|
|
376
|
-
/** Fixed item height or 'auto' for dynamic measurement */
|
|
377
|
-
itemHeight: number | 'auto';
|
|
378
|
-
/** Estimated height for auto measurement (required when itemHeight='auto') */
|
|
379
|
-
estimatedItemHeight?: number;
|
|
380
|
-
/** Container height (number for px, string for CSS value) */
|
|
381
|
-
height?: number | string;
|
|
382
|
-
/** Container width (number for px, string for CSS value) */
|
|
383
|
-
width?: number | string;
|
|
384
|
-
/** Scroll direction */
|
|
385
|
-
direction?: 'vertical' | 'horizontal';
|
|
386
|
-
/** Number of extra items to render outside viewport */
|
|
387
|
-
overscan?: number;
|
|
388
|
-
/** Initial scroll offset */
|
|
389
|
-
initialScrollOffset?: number;
|
|
390
|
-
/** Function to get unique key for each item */
|
|
391
|
-
getItemKey?: (index: number, data: T[]) => string | number;
|
|
392
|
-
/** Callback when more items should be loaded */
|
|
393
|
-
onLoadMore?: () => void | Promise<void>;
|
|
394
|
-
/** Whether there are more items to load */
|
|
395
|
-
hasMore?: boolean;
|
|
396
|
-
/** Whether currently loading more items */
|
|
397
|
-
isLoading?: boolean;
|
|
398
|
-
/** Loading indicator element */
|
|
399
|
-
loadingIndicator?: ReactNode;
|
|
400
|
-
/** Threshold in pixels from edge to trigger load more */
|
|
401
|
-
threshold?: number;
|
|
402
|
-
/** Callback on scroll */
|
|
403
|
-
onScroll?: (scrollTop: number, scrollLeft: number) => void;
|
|
404
|
-
/** Callback when visible range changes */
|
|
405
|
-
onVisibleRangeChange?: (range: Range) => void;
|
|
406
|
-
/** Callback when items are rendered */
|
|
407
|
-
onItemsRendered?: (info: ItemsRenderedInfo) => void;
|
|
408
|
-
/** Array of plugins to use */
|
|
409
|
-
plugins?: Plugin[];
|
|
410
|
-
/** Class name for outer container */
|
|
411
|
-
className?: string;
|
|
412
|
-
/** Style for outer container */
|
|
413
|
-
style?: CSSProperties;
|
|
414
|
-
/** Class name for inner container */
|
|
415
|
-
innerClassName?: string;
|
|
416
|
-
/** Style for inner container */
|
|
417
|
-
innerStyle?: CSSProperties;
|
|
418
|
-
/** Class name for item wrapper */
|
|
419
|
-
itemClassName?: string;
|
|
420
|
-
/** Style for item wrapper */
|
|
421
|
-
itemStyle?: CSSProperties;
|
|
422
|
-
/** ARIA role for container */
|
|
423
|
-
role?: string;
|
|
424
|
-
/** ARIA label */
|
|
425
|
-
ariaLabel?: string;
|
|
426
|
-
/** Tab index */
|
|
427
|
-
tabIndex?: number;
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* Gap configuration for grid layouts.
|
|
431
|
-
*/
|
|
432
|
-
interface GridGap {
|
|
433
|
-
x: number;
|
|
434
|
-
y: number;
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* VirtualGrid component props.
|
|
438
|
-
*/
|
|
439
|
-
interface VirtualGridProps<T> extends Omit<VirtualListProps<T>, 'itemHeight' | 'renderItem'> {
|
|
440
|
-
/** Render function for grid items */
|
|
441
|
-
renderItem: (props: GridRenderItemProps<T>) => ReactNode;
|
|
442
|
-
/** Fixed row height */
|
|
443
|
-
itemHeight: number;
|
|
444
|
-
/** Number of columns or 'auto' for responsive */
|
|
445
|
-
columns: number | 'auto';
|
|
446
|
-
/** Minimum column width for auto columns */
|
|
447
|
-
minColumnWidth?: number;
|
|
448
|
-
/** Gap between items */
|
|
449
|
-
gap?: number | GridGap;
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* VirtualMasonry component props.
|
|
453
|
-
*/
|
|
454
|
-
interface VirtualMasonryProps<T> extends Omit<VirtualGridProps<T>, 'itemHeight' | 'renderItem'> {
|
|
455
|
-
/** Render function for masonry items */
|
|
456
|
-
renderItem: (props: MasonryRenderItemProps<T>) => ReactNode;
|
|
457
|
-
/** Function to calculate item height based on item and column width */
|
|
458
|
-
getItemHeight: (item: T, columnWidth: number) => number;
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* Options for useVirtualList hook.
|
|
462
|
-
*/
|
|
463
|
-
interface UseVirtualListOptions {
|
|
464
|
-
/** Total number of items */
|
|
465
|
-
count: number;
|
|
466
|
-
/** Function to get item height */
|
|
467
|
-
getItemHeight?: (index: number) => number;
|
|
468
|
-
/** Estimated height for unmeasured items */
|
|
469
|
-
estimatedItemHeight?: number;
|
|
470
|
-
/** Number of extra items to render */
|
|
471
|
-
overscan?: number;
|
|
472
|
-
/** Padding at the start of the list */
|
|
473
|
-
paddingStart?: number;
|
|
474
|
-
/** Padding at the end of the list */
|
|
475
|
-
paddingEnd?: number;
|
|
476
|
-
/** Scroll margin */
|
|
477
|
-
scrollMargin?: number;
|
|
478
|
-
/** Initial scroll offset */
|
|
479
|
-
initialOffset?: number;
|
|
480
|
-
/** Function to get item key */
|
|
481
|
-
getItemKey?: (index: number) => string | number;
|
|
482
|
-
/** Whether to scroll horizontally */
|
|
483
|
-
horizontal?: boolean;
|
|
484
|
-
/** Container ref */
|
|
485
|
-
containerRef: RefObject<HTMLElement>;
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* Return type for useVirtualList hook.
|
|
489
|
-
*/
|
|
490
|
-
interface UseVirtualListReturn {
|
|
491
|
-
/** Virtual items to render */
|
|
492
|
-
virtualItems: VirtualItem[];
|
|
493
|
-
/** Total scroll size */
|
|
494
|
-
totalSize: number;
|
|
495
|
-
/** Current scroll offset */
|
|
496
|
-
scrollOffset: number;
|
|
497
|
-
/** Whether currently scrolling */
|
|
498
|
-
isScrolling: boolean;
|
|
499
|
-
/** Scroll to offset */
|
|
500
|
-
scrollTo: (offset: number, options?: ScrollOptions) => void;
|
|
501
|
-
/** Scroll to item index */
|
|
502
|
-
scrollToIndex: (index: number, options?: ScrollToIndexOptions) => void;
|
|
503
|
-
/** Measure an element */
|
|
504
|
-
measureElement: (index: number, element: HTMLElement | null) => void;
|
|
505
|
-
/** Visible range */
|
|
506
|
-
range: Range;
|
|
507
|
-
/** Get measurement for an index */
|
|
508
|
-
getMeasurement: (index: number) => number | undefined;
|
|
509
|
-
/** Invalidate measurement for an index */
|
|
510
|
-
invalidateMeasurement: (index: number) => void;
|
|
511
|
-
/** Invalidate all measurements */
|
|
512
|
-
invalidateAllMeasurements: () => void;
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Options for useVirtualGrid hook.
|
|
516
|
-
*/
|
|
517
|
-
interface UseVirtualGridOptions extends Omit<UseVirtualListOptions, 'getItemHeight'> {
|
|
518
|
-
/** Number of columns */
|
|
519
|
-
columns: number;
|
|
520
|
-
/** Row height */
|
|
521
|
-
rowHeight: number;
|
|
522
|
-
/** Gap between items */
|
|
523
|
-
gap?: number | GridGap;
|
|
524
|
-
}
|
|
525
|
-
/**
|
|
526
|
-
* Return type for useVirtualGrid hook.
|
|
527
|
-
*/
|
|
528
|
-
interface UseVirtualGridReturn extends UseVirtualListReturn {
|
|
529
|
-
/** Number of columns */
|
|
530
|
-
columnCount: number;
|
|
531
|
-
/** Width of each column */
|
|
532
|
-
columnWidth: number;
|
|
533
|
-
/** Number of rows */
|
|
534
|
-
rowCount: number;
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* Options for useVirtualMasonry hook.
|
|
538
|
-
*/
|
|
539
|
-
interface UseVirtualMasonryOptions {
|
|
540
|
-
/** Total number of items */
|
|
541
|
-
count: number;
|
|
542
|
-
/** Number of columns */
|
|
543
|
-
columns: number;
|
|
544
|
-
/** Function to get item height given index and column width */
|
|
545
|
-
getItemHeight: (index: number, columnWidth: number) => number;
|
|
546
|
-
/** Gap between items */
|
|
547
|
-
gap?: number;
|
|
548
|
-
/** Container ref */
|
|
549
|
-
containerRef: RefObject<HTMLElement>;
|
|
550
|
-
/** Number of extra items to render */
|
|
551
|
-
overscan?: number;
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* Return type for useVirtualMasonry hook.
|
|
555
|
-
*/
|
|
556
|
-
interface UseVirtualMasonryReturn extends UseVirtualListReturn {
|
|
557
|
-
/** Number of columns */
|
|
558
|
-
columnCount: number;
|
|
559
|
-
/** Width of each column */
|
|
560
|
-
columnWidth: number;
|
|
561
|
-
/** Heights of each column */
|
|
562
|
-
columnHeights: number[];
|
|
563
|
-
}
|
|
564
|
-
/**
|
|
565
|
-
* Handle exposed by VirtualList component ref.
|
|
566
|
-
*/
|
|
567
|
-
interface VirtualListHandle {
|
|
568
|
-
/** Scroll to offset */
|
|
569
|
-
scrollTo: (offset: number, options?: ScrollOptions) => void;
|
|
570
|
-
/** Scroll to item index */
|
|
571
|
-
scrollToIndex: (index: number, options?: ScrollToIndexOptions) => void;
|
|
572
|
-
/** Scroll to top */
|
|
573
|
-
scrollToTop: (options?: ScrollOptions) => void;
|
|
574
|
-
/** Scroll to bottom */
|
|
575
|
-
scrollToBottom: (options?: ScrollOptions) => void;
|
|
576
|
-
/** Get current scroll position */
|
|
577
|
-
getScrollPosition: () => ScrollPosition;
|
|
578
|
-
}
|
|
1
|
+
import React$1 from 'react';
|
|
2
|
+
import { V as VirtualListProps, a as VirtualListHandle, b as VirtualGridProps, c as VirtualMasonryProps, U as UseVirtualListOptions, d as UseVirtualListReturn, e as UseVirtualGridOptions, f as UseVirtualGridReturn, g as UseVirtualMasonryOptions, h as UseVirtualMasonryReturn, K as Kernel, i as KernelOptions, P as Plugin } from './scroll-controller-D5AV1E2p.js';
|
|
3
|
+
export { A as AutoMeasurerAPI, j as AutoMeasurerOptions, E as EasingFunction, k as EventHandler, l as EventType, G as GridGap, m as GridRenderItemProps, n as GridRendererAPI, o as GridRendererOptions, I as InfiniteLoaderAPI, p as InfiniteLoaderOptions, q as ItemMeasuredEvent, r as ItemsChangeEvent, s as ItemsRenderedInfo, t as KernelEvent, L as ListRendererAPI, u as ListRendererOptions, v as LoadDirection, w as LoadMoreEvent, M as MasonryRenderItemProps, x as PluginConfig, y as PluginHooks, z as PluginInfo, B as PluginType, R as Range, C as RenderItemProps, D as ResizeEvent, S as ScrollAlignment, F as ScrollBehavior, H as ScrollControllerAPI, J as ScrollControllerOptions, N as ScrollDirection, O as ScrollEndEvent, Q as ScrollEvent, T as ScrollOptions, W as ScrollPosition, X as ScrollStartEvent, Y as ScrollToIndexOptions, Z as Unsubscribe, _ as Viewport, $ as VirtualItem, a0 as VisibleRangeChangeEvent, a1 as autoMeasurerPlugin, a2 as gridRendererPlugin, a3 as infiniteLoaderPlugin, a4 as listRendererPlugin, a5 as scrollControllerPlugin } from './scroll-controller-D5AV1E2p.js';
|
|
579
4
|
|
|
580
5
|
/**
|
|
581
6
|
* VirtualList component with forwardRef.
|
|
@@ -876,209 +301,5 @@ declare const easings: {
|
|
|
876
301
|
readonly easeInOutCubic: (t: number) => number;
|
|
877
302
|
};
|
|
878
303
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
*/
|
|
882
|
-
interface ListRendererOptions {
|
|
883
|
-
/** Get item key for React reconciliation */
|
|
884
|
-
getItemKey?: (index: number) => string | number;
|
|
885
|
-
}
|
|
886
|
-
/**
|
|
887
|
-
* List renderer plugin API.
|
|
888
|
-
*/
|
|
889
|
-
interface ListRendererAPI {
|
|
890
|
-
/** Get virtual items to render */
|
|
891
|
-
getVirtualItems(): VirtualItem[];
|
|
892
|
-
/** Get total scroll height */
|
|
893
|
-
getTotalHeight(): number;
|
|
894
|
-
/** Get start offset (for positioning) */
|
|
895
|
-
getStartOffset(): number;
|
|
896
|
-
/** Get end offset */
|
|
897
|
-
getEndOffset(): number;
|
|
898
|
-
/** Check if an item is visible */
|
|
899
|
-
isItemVisible(index: number): boolean;
|
|
900
|
-
/** Force recalculation */
|
|
901
|
-
recalculate(): void;
|
|
902
|
-
}
|
|
903
|
-
/**
|
|
904
|
-
* Creates a list renderer plugin.
|
|
905
|
-
* This is the core virtualization engine for list rendering.
|
|
906
|
-
*
|
|
907
|
-
* @param options - Plugin options
|
|
908
|
-
* @returns Plugin instance
|
|
909
|
-
*/
|
|
910
|
-
declare function listRendererPlugin(options?: ListRendererOptions): Plugin;
|
|
911
|
-
|
|
912
|
-
/**
|
|
913
|
-
* Grid renderer plugin options.
|
|
914
|
-
*/
|
|
915
|
-
interface GridRendererOptions {
|
|
916
|
-
/** Number of columns or 'auto' for responsive */
|
|
917
|
-
columns: number | 'auto';
|
|
918
|
-
/** Minimum column width for auto columns */
|
|
919
|
-
minColumnWidth?: number;
|
|
920
|
-
/** Row height */
|
|
921
|
-
rowHeight: number;
|
|
922
|
-
/** Gap between items */
|
|
923
|
-
gap?: number | GridGap;
|
|
924
|
-
/** Get item key for React reconciliation */
|
|
925
|
-
getItemKey?: (index: number) => string | number;
|
|
926
|
-
}
|
|
927
|
-
/**
|
|
928
|
-
* Grid renderer plugin API.
|
|
929
|
-
*/
|
|
930
|
-
interface GridRendererAPI {
|
|
931
|
-
/** Get virtual items to render */
|
|
932
|
-
getVirtualItems(): VirtualItem[];
|
|
933
|
-
/** Get total scroll height */
|
|
934
|
-
getTotalHeight(): number;
|
|
935
|
-
/** Get number of columns */
|
|
936
|
-
getColumnCount(): number;
|
|
937
|
-
/** Get column width */
|
|
938
|
-
getColumnWidth(): number;
|
|
939
|
-
/** Get number of items per row */
|
|
940
|
-
getItemsPerRow(): number;
|
|
941
|
-
/** Get row count */
|
|
942
|
-
getRowCount(): number;
|
|
943
|
-
/** Force recalculation */
|
|
944
|
-
recalculate(): void;
|
|
945
|
-
}
|
|
946
|
-
/**
|
|
947
|
-
* Creates a grid renderer plugin.
|
|
948
|
-
* Handles multi-column grid virtualization.
|
|
949
|
-
*
|
|
950
|
-
* @param options - Plugin options
|
|
951
|
-
* @returns Plugin instance
|
|
952
|
-
*/
|
|
953
|
-
declare function gridRendererPlugin(options: GridRendererOptions): Plugin;
|
|
954
|
-
|
|
955
|
-
/**
|
|
956
|
-
* Auto measurer plugin options.
|
|
957
|
-
*/
|
|
958
|
-
interface AutoMeasurerOptions {
|
|
959
|
-
/** Estimated item height for initial layout */
|
|
960
|
-
estimatedItemHeight?: number;
|
|
961
|
-
/** Whether to re-measure when item content resizes */
|
|
962
|
-
measureOnResize?: boolean;
|
|
963
|
-
/** Debounce time for resize measurements (ms) */
|
|
964
|
-
debounceMs?: number;
|
|
965
|
-
}
|
|
966
|
-
/**
|
|
967
|
-
* Auto measurer plugin API.
|
|
968
|
-
*/
|
|
969
|
-
interface AutoMeasurerAPI {
|
|
970
|
-
/** Measure an element and update cache */
|
|
971
|
-
measureElement(index: number, element: HTMLElement): number;
|
|
972
|
-
/** Get cached size for an index */
|
|
973
|
-
getCachedSize(index: number): number | undefined;
|
|
974
|
-
/** Invalidate measurement for an index */
|
|
975
|
-
invalidate(index: number): void;
|
|
976
|
-
/** Invalidate all measurements */
|
|
977
|
-
invalidateAll(): void;
|
|
978
|
-
/** Get the measurement cache */
|
|
979
|
-
getMeasurementCache(): Map<number, number>;
|
|
980
|
-
/** Observe an element for size changes */
|
|
981
|
-
observe(index: number, element: HTMLElement): void;
|
|
982
|
-
/** Stop observing an element */
|
|
983
|
-
unobserve(element: HTMLElement): void;
|
|
984
|
-
}
|
|
985
|
-
/**
|
|
986
|
-
* Creates an auto measurer plugin.
|
|
987
|
-
* Handles automatic measurement of variable height items.
|
|
988
|
-
*
|
|
989
|
-
* @param options - Plugin options
|
|
990
|
-
* @returns Plugin instance
|
|
991
|
-
*/
|
|
992
|
-
declare function autoMeasurerPlugin(options?: AutoMeasurerOptions): Plugin;
|
|
993
|
-
|
|
994
|
-
/**
|
|
995
|
-
* Load direction.
|
|
996
|
-
*/
|
|
997
|
-
type LoadDirection = 'forward' | 'backward';
|
|
998
|
-
/**
|
|
999
|
-
* Infinite loader plugin options.
|
|
1000
|
-
*/
|
|
1001
|
-
interface InfiniteLoaderOptions {
|
|
1002
|
-
/** Pixels from edge to trigger load */
|
|
1003
|
-
threshold?: number;
|
|
1004
|
-
/** Items from edge to trigger load */
|
|
1005
|
-
thresholdItems?: number;
|
|
1006
|
-
/** Direction to load more */
|
|
1007
|
-
direction?: LoadDirection | 'both';
|
|
1008
|
-
/** Callback when more items should be loaded */
|
|
1009
|
-
onLoadMore: (direction: LoadDirection) => void | Promise<void>;
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
|
-
* Infinite loader plugin API.
|
|
1013
|
-
*/
|
|
1014
|
-
interface InfiniteLoaderAPI {
|
|
1015
|
-
/** Check if currently loading */
|
|
1016
|
-
isLoading(): boolean;
|
|
1017
|
-
/** Set loading state */
|
|
1018
|
-
setLoading(loading: boolean): void;
|
|
1019
|
-
/** Check if there are more items to load */
|
|
1020
|
-
hasMore(): boolean;
|
|
1021
|
-
/** Set whether there are more items */
|
|
1022
|
-
setHasMore(hasMore: boolean): void;
|
|
1023
|
-
/** Check if can load forward */
|
|
1024
|
-
hasMoreForward(): boolean;
|
|
1025
|
-
/** Set whether can load forward */
|
|
1026
|
-
setHasMoreForward(hasMore: boolean): void;
|
|
1027
|
-
/** Check if can load backward */
|
|
1028
|
-
hasMoreBackward(): boolean;
|
|
1029
|
-
/** Set whether can load backward */
|
|
1030
|
-
setHasMoreBackward(hasMore: boolean): void;
|
|
1031
|
-
/** Reset loading state */
|
|
1032
|
-
reset(): void;
|
|
1033
|
-
/** Trigger load manually */
|
|
1034
|
-
triggerLoad(direction: LoadDirection): void;
|
|
1035
|
-
}
|
|
1036
|
-
/**
|
|
1037
|
-
* Creates an infinite loader plugin.
|
|
1038
|
-
* Handles infinite scroll detection and triggering.
|
|
1039
|
-
*
|
|
1040
|
-
* @param options - Plugin options
|
|
1041
|
-
* @returns Plugin instance
|
|
1042
|
-
*/
|
|
1043
|
-
declare function infiniteLoaderPlugin(options: InfiniteLoaderOptions): Plugin;
|
|
1044
|
-
|
|
1045
|
-
/**
|
|
1046
|
-
* Scroll controller plugin options.
|
|
1047
|
-
*/
|
|
1048
|
-
interface ScrollControllerOptions {
|
|
1049
|
-
/** Default scroll duration (ms) */
|
|
1050
|
-
defaultDuration?: number;
|
|
1051
|
-
/** Default easing function */
|
|
1052
|
-
defaultEasing?: EasingFunction;
|
|
1053
|
-
}
|
|
1054
|
-
/**
|
|
1055
|
-
* Scroll controller plugin API.
|
|
1056
|
-
*/
|
|
1057
|
-
interface ScrollControllerAPI {
|
|
1058
|
-
/** Scroll to an offset */
|
|
1059
|
-
scrollTo(offset: number, options?: ScrollOptions): void;
|
|
1060
|
-
/** Scroll to an item index */
|
|
1061
|
-
scrollToIndex(index: number, options?: ScrollToIndexOptions): void;
|
|
1062
|
-
/** Scroll to the top */
|
|
1063
|
-
scrollToTop(options?: ScrollOptions): void;
|
|
1064
|
-
/** Scroll to the bottom */
|
|
1065
|
-
scrollToBottom(options?: ScrollOptions): void;
|
|
1066
|
-
/** Get current scroll position */
|
|
1067
|
-
getScrollPosition(): ScrollPosition;
|
|
1068
|
-
/** Check if currently scrolling */
|
|
1069
|
-
isScrolling(): boolean;
|
|
1070
|
-
/** Check if animation is in progress */
|
|
1071
|
-
isAnimating(): boolean;
|
|
1072
|
-
/** Stop current scroll animation */
|
|
1073
|
-
stopAnimation(): void;
|
|
1074
|
-
}
|
|
1075
|
-
/**
|
|
1076
|
-
* Creates a scroll controller plugin.
|
|
1077
|
-
* Provides programmatic scroll control with smooth animations.
|
|
1078
|
-
*
|
|
1079
|
-
* @param options - Plugin options
|
|
1080
|
-
* @returns Plugin instance
|
|
1081
|
-
*/
|
|
1082
|
-
declare function scrollControllerPlugin(options?: ScrollControllerOptions): Plugin;
|
|
1083
|
-
|
|
1084
|
-
export { type AutoMeasurerAPI, type AutoMeasurerOptions, type EasingFunction, type EventHandler, type EventType, type GridGap, type GridRenderItemProps, type GridRendererAPI, type GridRendererOptions, type InfiniteLoaderAPI, type InfiniteLoaderOptions, type ItemMeasuredEvent, type ItemsChangeEvent, type ItemsRenderedInfo, type Kernel, type KernelEvent, type KernelOptions, type ListRendererAPI, type ListRendererOptions, type LoadDirection, type LoadMoreEvent, type MasonryRenderItemProps, type Plugin, type PluginConfig, type PluginHooks, type PluginInfo, type PluginType, type Range, type RenderItemProps, type ResizeEvent, type ScrollAlignment, type ScrollBehavior, type ScrollControllerAPI, type ScrollControllerOptions, type ScrollDirection, type ScrollEndEvent, type ScrollEvent, type ScrollOptions, type ScrollPosition, type ScrollStartEvent, type ScrollToIndexOptions, type Unsubscribe, type UseVirtualGridOptions, type UseVirtualGridReturn, type UseVirtualListOptions, type UseVirtualListReturn, type UseVirtualMasonryOptions, type UseVirtualMasonryReturn, type Viewport, VirtualGrid, type VirtualGridProps, type VirtualItem, VirtualList, type VirtualListHandle, type VirtualListProps, VirtualMasonry, type VirtualMasonryProps, type VisibleRangeChangeEvent, autoMeasurerPlugin, createKernel, createPlugin, easings, gridRendererPlugin, infiniteLoaderPlugin, listRendererPlugin, scrollControllerPlugin, useMeasure, useMeasureMany, useScrollex, useScrollexRequired, useVirtualGrid, useVirtualList, useVirtualMasonry };
|
|
304
|
+
export { Kernel, KernelOptions, Plugin, UseVirtualGridOptions, UseVirtualGridReturn, UseVirtualListOptions, UseVirtualListReturn, UseVirtualMasonryOptions, UseVirtualMasonryReturn, VirtualGrid, VirtualGridProps, VirtualList, VirtualListHandle, VirtualListProps, VirtualMasonry, VirtualMasonryProps, createKernel, createPlugin, easings, useMeasure, useMeasureMany, useScrollex, useScrollexRequired, useVirtualGrid, useVirtualList, useVirtualMasonry };
|
|
305
|
+
export type { UseMeasureOptions, UseMeasureReturn };
|