react-virtual-renderer 1.0.3
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/README.md +170 -0
- package/dist/App.d.ts +3 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +7 -0
- package/dist/App.js.map +1 -0
- package/dist/accessibility/a11y.d.ts +111 -0
- package/dist/accessibility/a11y.d.ts.map +1 -0
- package/dist/accessibility/a11y.js +254 -0
- package/dist/accessibility/a11y.js.map +1 -0
- package/dist/components/VirtualGrid.d.ts +8 -0
- package/dist/components/VirtualGrid.d.ts.map +1 -0
- package/dist/components/VirtualGrid.js +187 -0
- package/dist/components/VirtualGrid.js.map +1 -0
- package/dist/components/VirtualList.d.ts +8 -0
- package/dist/components/VirtualList.d.ts.map +1 -0
- package/dist/components/VirtualList.js +102 -0
- package/dist/components/VirtualList.js.map +1 -0
- package/dist/core/MeasurementSystem.d.ts +52 -0
- package/dist/core/MeasurementSystem.d.ts.map +1 -0
- package/dist/core/MeasurementSystem.js +138 -0
- package/dist/core/MeasurementSystem.js.map +1 -0
- package/dist/core/VirtualizationEngine.d.ts +65 -0
- package/dist/core/VirtualizationEngine.d.ts.map +1 -0
- package/dist/core/VirtualizationEngine.js +203 -0
- package/dist/core/VirtualizationEngine.js.map +1 -0
- package/dist/examples/AdvancedExamples.d.ts +24 -0
- package/dist/examples/AdvancedExamples.d.ts.map +1 -0
- package/dist/examples/AdvancedExamples.js +216 -0
- package/dist/examples/AdvancedExamples.js.map +1 -0
- package/dist/examples/Example.d.ts +26 -0
- package/dist/examples/Example.d.ts.map +1 -0
- package/dist/examples/Example.js +186 -0
- package/dist/examples/Example.js.map +1 -0
- package/dist/hooks/useInfiniteScroll.d.ts +17 -0
- package/dist/hooks/useInfiniteScroll.d.ts.map +1 -0
- package/dist/hooks/useInfiniteScroll.js +41 -0
- package/dist/hooks/useInfiniteScroll.js.map +1 -0
- package/dist/hooks/useLazyLoad.d.ts +16 -0
- package/dist/hooks/useLazyLoad.d.ts.map +1 -0
- package/dist/hooks/useLazyLoad.js +34 -0
- package/dist/hooks/useLazyLoad.js.map +1 -0
- package/dist/hooks/useScrollRestoration.d.ts +10 -0
- package/dist/hooks/useScrollRestoration.d.ts.map +1 -0
- package/dist/hooks/useScrollRestoration.js +63 -0
- package/dist/hooks/useScrollRestoration.js.map +1 -0
- package/dist/hooks/useVirtualList.d.ts +33 -0
- package/dist/hooks/useVirtualList.d.ts.map +1 -0
- package/dist/hooks/useVirtualList.js +226 -0
- package/dist/hooks/useVirtualList.js.map +1 -0
- package/dist/hooks/useVirtualizedSearch.d.ts +40 -0
- package/dist/hooks/useVirtualizedSearch.d.ts.map +1 -0
- package/dist/hooks/useVirtualizedSearch.js +168 -0
- package/dist/hooks/useVirtualizedSearch.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +11 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +6 -0
- package/dist/main.js.map +1 -0
- package/dist/performance/metrics.d.ts +110 -0
- package/dist/performance/metrics.d.ts.map +1 -0
- package/dist/performance/metrics.js +310 -0
- package/dist/performance/metrics.js.map +1 -0
- package/dist/plugin.d.ts +182 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +409 -0
- package/dist/plugin.js.map +1 -0
- package/dist/types.d.ts +84 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/helpers.d.ts +66 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +166 -0
- package/dist/utils/helpers.js.map +1 -0
- package/package.json +111 -0
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
export class PluginManager {
|
|
2
|
+
constructor() {
|
|
3
|
+
Object.defineProperty(this, "plugins", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true,
|
|
7
|
+
value: new Map()
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Register a plugin
|
|
12
|
+
*/
|
|
13
|
+
register(plugin) {
|
|
14
|
+
if (this.plugins.has(plugin.name)) {
|
|
15
|
+
console.warn(`Plugin "${plugin.name}" already registered`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
this.plugins.set(plugin.name, plugin);
|
|
19
|
+
console.log(`✅ Plugin registered: ${plugin.name} v${plugin.version}`);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Unregister a plugin
|
|
23
|
+
*/
|
|
24
|
+
unregister(name) {
|
|
25
|
+
this.plugins.delete(name);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get registered plugins
|
|
29
|
+
*/
|
|
30
|
+
getPlugins() {
|
|
31
|
+
return Array.from(this.plugins.values());
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Call plugin hook
|
|
35
|
+
*/
|
|
36
|
+
async callHook(hookName, ...args) {
|
|
37
|
+
const results = [];
|
|
38
|
+
for (const plugin of this.plugins.values()) {
|
|
39
|
+
const hook = plugin.hooks?.[hookName];
|
|
40
|
+
if (typeof hook === 'function') {
|
|
41
|
+
try {
|
|
42
|
+
const result = await hook(...args);
|
|
43
|
+
results.push(result);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.error(`Error in plugin ${plugin.name}:`, error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return results;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Call plugin method
|
|
54
|
+
*/
|
|
55
|
+
callMethod(pluginName, methodName, ...args) {
|
|
56
|
+
const plugin = this.plugins.get(pluginName);
|
|
57
|
+
if (!plugin || !plugin.methods || !plugin.methods[methodName]) {
|
|
58
|
+
throw new Error(`Method ${methodName} not found in plugin ${pluginName}`);
|
|
59
|
+
}
|
|
60
|
+
return plugin.methods[methodName](...args);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// ============================================
|
|
64
|
+
// LAYOUT SYSTEM
|
|
65
|
+
// ============================================
|
|
66
|
+
export var LayoutType;
|
|
67
|
+
(function (LayoutType) {
|
|
68
|
+
LayoutType["LIST"] = "list";
|
|
69
|
+
LayoutType["GRID"] = "grid";
|
|
70
|
+
LayoutType["MASONRY"] = "masonry";
|
|
71
|
+
LayoutType["WATERFALL"] = "waterfall";
|
|
72
|
+
LayoutType["FEED"] = "feed";
|
|
73
|
+
LayoutType["TIMELINE"] = "timeline";
|
|
74
|
+
})(LayoutType || (LayoutType = {}));
|
|
75
|
+
/**
|
|
76
|
+
* Waterfall Layout - Multi-column layout with items filling shortest column
|
|
77
|
+
* Perfect for: Image galleries, product showcases
|
|
78
|
+
*/
|
|
79
|
+
export class WaterfallLayout {
|
|
80
|
+
constructor(columns, gapSize = 8) {
|
|
81
|
+
Object.defineProperty(this, "columns", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
configurable: true,
|
|
84
|
+
writable: true,
|
|
85
|
+
value: void 0
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(this, "gapSize", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
configurable: true,
|
|
90
|
+
writable: true,
|
|
91
|
+
value: void 0
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(this, "columnHeights", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
configurable: true,
|
|
96
|
+
writable: true,
|
|
97
|
+
value: []
|
|
98
|
+
});
|
|
99
|
+
this.columns = columns;
|
|
100
|
+
this.gapSize = gapSize;
|
|
101
|
+
this.columnHeights = new Array(columns).fill(0);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get position for item
|
|
105
|
+
*/
|
|
106
|
+
getItemPosition(_, itemHeight, width) {
|
|
107
|
+
const shortestColumn = this.columnHeights.indexOf(Math.min(...this.columnHeights));
|
|
108
|
+
const columnWidth = width / this.columns;
|
|
109
|
+
const x = shortestColumn * columnWidth;
|
|
110
|
+
const y = this.columnHeights[shortestColumn];
|
|
111
|
+
this.columnHeights[shortestColumn] += itemHeight + this.gapSize;
|
|
112
|
+
return { x, y, column: shortestColumn };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get total height needed
|
|
116
|
+
*/
|
|
117
|
+
getTotalHeight() {
|
|
118
|
+
return Math.max(...this.columnHeights);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Reset layout
|
|
122
|
+
*/
|
|
123
|
+
reset() {
|
|
124
|
+
this.columnHeights.fill(0);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Feed Layout - Social media feed style (variable width, full-width items)
|
|
129
|
+
* Perfect for: Social feeds, blogs, news
|
|
130
|
+
*/
|
|
131
|
+
export class FeedLayout {
|
|
132
|
+
constructor() {
|
|
133
|
+
Object.defineProperty(this, "itemHeights", {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
configurable: true,
|
|
136
|
+
writable: true,
|
|
137
|
+
value: new Map()
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(this, "itemOffsets", {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
configurable: true,
|
|
142
|
+
writable: true,
|
|
143
|
+
value: new Map()
|
|
144
|
+
});
|
|
145
|
+
Object.defineProperty(this, "totalHeight", {
|
|
146
|
+
enumerable: true,
|
|
147
|
+
configurable: true,
|
|
148
|
+
writable: true,
|
|
149
|
+
value: 0
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Record item height
|
|
154
|
+
*/
|
|
155
|
+
recordItemHeight(index, height) {
|
|
156
|
+
this.itemHeights.set(index, height);
|
|
157
|
+
this.updateOffsets();
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Get item offset and height
|
|
161
|
+
*/
|
|
162
|
+
getItemDimensions(index) {
|
|
163
|
+
return {
|
|
164
|
+
offset: this.itemOffsets.get(index) || 0,
|
|
165
|
+
height: this.itemHeights.get(index) || 0,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Update all offsets
|
|
170
|
+
*/
|
|
171
|
+
updateOffsets() {
|
|
172
|
+
let currentOffset = 0;
|
|
173
|
+
const sortedIndices = Array.from(this.itemHeights.keys()).sort((a, b) => a - b);
|
|
174
|
+
for (const index of sortedIndices) {
|
|
175
|
+
this.itemOffsets.set(index, currentOffset);
|
|
176
|
+
currentOffset += (this.itemHeights.get(index) || 0);
|
|
177
|
+
}
|
|
178
|
+
this.totalHeight = currentOffset;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get total height
|
|
182
|
+
*/
|
|
183
|
+
getTotalHeight() {
|
|
184
|
+
return this.totalHeight;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// ============================================
|
|
188
|
+
// FRAMEWORK ADAPTERS
|
|
189
|
+
// ============================================
|
|
190
|
+
/**
|
|
191
|
+
* Vue 3 Adapter
|
|
192
|
+
*/
|
|
193
|
+
export const createVueVirtualList = () => {
|
|
194
|
+
return {
|
|
195
|
+
name: 'VirtualList',
|
|
196
|
+
template: `
|
|
197
|
+
<div
|
|
198
|
+
class="virtualize-container"
|
|
199
|
+
:style="{ height: height + 'px', width: width + 'px' }"
|
|
200
|
+
@scroll="handleScroll"
|
|
201
|
+
ref="container"
|
|
202
|
+
>
|
|
203
|
+
<div
|
|
204
|
+
v-for="item in virtualItems"
|
|
205
|
+
:key="item.key"
|
|
206
|
+
:style="getItemStyle(item)"
|
|
207
|
+
>
|
|
208
|
+
<slot :item="item.data" :index="item.index" />
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
`,
|
|
212
|
+
props: {
|
|
213
|
+
items: Array,
|
|
214
|
+
height: { type: Number, default: 400 },
|
|
215
|
+
width: { type: Number, default: 300 },
|
|
216
|
+
estimatedItemSize: { type: Number, default: 50 },
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Svelte Component
|
|
222
|
+
*/
|
|
223
|
+
export const SvelteVirtualList = `
|
|
224
|
+
<script>
|
|
225
|
+
import { useVirtualList } from 'virtualize';
|
|
226
|
+
|
|
227
|
+
export let items = [];
|
|
228
|
+
export let height = 400;
|
|
229
|
+
export let width = 300;
|
|
230
|
+
export let estimatedItemSize = 50;
|
|
231
|
+
|
|
232
|
+
let containerRef;
|
|
233
|
+
const { virtualItems, getItemStyle } = useVirtualList({
|
|
234
|
+
items,
|
|
235
|
+
containerHeight: height,
|
|
236
|
+
estimatedItemSize,
|
|
237
|
+
});
|
|
238
|
+
</script>
|
|
239
|
+
|
|
240
|
+
<div
|
|
241
|
+
bind:this={containerRef}
|
|
242
|
+
class="virtualize-container"
|
|
243
|
+
style="height: {height}px; width: {width}px; overflow: auto;"
|
|
244
|
+
>
|
|
245
|
+
{#each $virtualItems as virtualItem (virtualItem.key)}
|
|
246
|
+
<div style={getItemStyle(virtualItem.index, virtualItem.size)}>
|
|
247
|
+
<slot item={virtualItem.data} index={virtualItem.index} />
|
|
248
|
+
</div>
|
|
249
|
+
{/each}
|
|
250
|
+
</div>
|
|
251
|
+
|
|
252
|
+
<style>
|
|
253
|
+
.virtualize-container {
|
|
254
|
+
position: relative;
|
|
255
|
+
border: 1px solid #ccc;
|
|
256
|
+
}
|
|
257
|
+
</style>
|
|
258
|
+
`;
|
|
259
|
+
export class AdvancedAnalytics {
|
|
260
|
+
constructor() {
|
|
261
|
+
Object.defineProperty(this, "events", {
|
|
262
|
+
enumerable: true,
|
|
263
|
+
configurable: true,
|
|
264
|
+
writable: true,
|
|
265
|
+
value: []
|
|
266
|
+
});
|
|
267
|
+
Object.defineProperty(this, "sessionStart", {
|
|
268
|
+
enumerable: true,
|
|
269
|
+
configurable: true,
|
|
270
|
+
writable: true,
|
|
271
|
+
value: Date.now()
|
|
272
|
+
});
|
|
273
|
+
Object.defineProperty(this, "maxEvents", {
|
|
274
|
+
enumerable: true,
|
|
275
|
+
configurable: true,
|
|
276
|
+
writable: true,
|
|
277
|
+
value: 10000
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Track event
|
|
282
|
+
*/
|
|
283
|
+
trackEvent(type, data) {
|
|
284
|
+
if (this.events.length >= this.maxEvents) {
|
|
285
|
+
this.events.shift(); // Remove oldest
|
|
286
|
+
}
|
|
287
|
+
this.events.push({
|
|
288
|
+
type,
|
|
289
|
+
timestamp: Date.now(),
|
|
290
|
+
data,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Get session duration
|
|
295
|
+
*/
|
|
296
|
+
getSessionDuration() {
|
|
297
|
+
return Date.now() - this.sessionStart;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Get analytics report
|
|
301
|
+
*/
|
|
302
|
+
getReport() {
|
|
303
|
+
return {
|
|
304
|
+
sessionDuration: this.getSessionDuration(),
|
|
305
|
+
totalEvents: this.events.length,
|
|
306
|
+
eventBreakdown: this.getEventBreakdown(),
|
|
307
|
+
timeline: this.events,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Get event breakdown
|
|
312
|
+
*/
|
|
313
|
+
getEventBreakdown() {
|
|
314
|
+
const breakdown = {};
|
|
315
|
+
for (const event of this.events) {
|
|
316
|
+
breakdown[event.type] = (breakdown[event.type] || 0) + 1;
|
|
317
|
+
}
|
|
318
|
+
return breakdown;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Send analytics to server
|
|
322
|
+
*/
|
|
323
|
+
async sendAnalytics(endpoint) {
|
|
324
|
+
try {
|
|
325
|
+
const response = await fetch(endpoint, {
|
|
326
|
+
method: 'POST',
|
|
327
|
+
headers: { 'Content-Type': 'application/json' },
|
|
328
|
+
body: JSON.stringify(this.getReport()),
|
|
329
|
+
});
|
|
330
|
+
if (!response.ok) {
|
|
331
|
+
console.error('Failed to send analytics');
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
console.error('Error sending analytics:', error);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Export analytics as CSV
|
|
340
|
+
*/
|
|
341
|
+
exportAsCSV() {
|
|
342
|
+
const headers = ['Type', 'Timestamp', 'Data'];
|
|
343
|
+
const rows = this.events.map((e) => [
|
|
344
|
+
e.type,
|
|
345
|
+
new Date(e.timestamp).toISOString(),
|
|
346
|
+
JSON.stringify(e.data),
|
|
347
|
+
]);
|
|
348
|
+
const csv = [headers, ...rows]
|
|
349
|
+
.map((row) => row.map((cell) => `"${cell}"`).join(','))
|
|
350
|
+
.join('\n');
|
|
351
|
+
return csv;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
// ============================================
|
|
355
|
+
// EXAMPLE PLUGINS
|
|
356
|
+
// ============================================
|
|
357
|
+
/**
|
|
358
|
+
* Example: Analytics Plugin
|
|
359
|
+
*/
|
|
360
|
+
export const AnalyticsPlugin = {
|
|
361
|
+
name: 'analytics',
|
|
362
|
+
version: '2.0.0',
|
|
363
|
+
hooks: {
|
|
364
|
+
onScroll: (offset) => {
|
|
365
|
+
console.log(`📊 Scroll offset: ${offset}`);
|
|
366
|
+
},
|
|
367
|
+
onMeasurement: (index, size) => {
|
|
368
|
+
console.log(`📊 Item ${index} measured: ${size}px`);
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
/**
|
|
373
|
+
* Example: Logger Plugin
|
|
374
|
+
*/
|
|
375
|
+
export const LoggerPlugin = {
|
|
376
|
+
name: 'logger',
|
|
377
|
+
version: '2.0.0',
|
|
378
|
+
hooks: {
|
|
379
|
+
beforeRender: (items) => {
|
|
380
|
+
console.log(`📝 About to render ${items.length} items`);
|
|
381
|
+
return items;
|
|
382
|
+
},
|
|
383
|
+
afterRender: (elements) => {
|
|
384
|
+
console.log(`✅ Rendered ${elements.length} elements`);
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* Example: Custom Plugin
|
|
390
|
+
*/
|
|
391
|
+
export function createCustomPlugin(options) {
|
|
392
|
+
return {
|
|
393
|
+
name: options.name || 'custom-plugin',
|
|
394
|
+
version: options.version || '1.0.0',
|
|
395
|
+
hooks: {
|
|
396
|
+
onScroll: (offset) => {
|
|
397
|
+
console.log(`Custom: Scroll detected at ${offset}`);
|
|
398
|
+
options.onScroll?.(offset);
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
methods: {
|
|
402
|
+
customMethod: (arg) => {
|
|
403
|
+
console.log('Custom method called:', arg);
|
|
404
|
+
return arg;
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAYA,MAAM,OAAO,aAAa;IAA1B;QACI;;;;mBAAiD,IAAI,GAAG,EAAE;WAAC;IAkE/D,CAAC;IAhEG;;OAEG;IACH,QAAQ,CAAC,MAAwB;QAC7B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC/B,OAAO,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,IAAI,sBAAsB,CAAC,CAAC;YAC3D,OAAO;SACV;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,wBAAwB,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1E,CAA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AW,CAAC,CAAC;QAC1D,CAAC;KACJ;CACJ,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAY;IAC3C,OAAO;QACH,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,eAAe;QACrC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,OAAO;QACnC,KAAK,EAAE;YACH,QAAQ,EAAE,CAAC,MAAc,EAAE,EAAE;gBACzB,OAAO,CAAC,GAAG,CAAC,8BAA8B,MAAM,EAAE,CAAC,CAAC;gBACpD,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;YAC/B,CAAC;SACJ;QACD,OAAO,EAAE;YACL,YAAY,EAAE,CAAC,GAAQ,EAAE,EAAE;gBACvB,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;gBAC1C,OAAO,GAAG,CAAC;YACf,CAAC;SACJ;KACJ,CAAC;AACN,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type ScrollDirection = 'forward' | 'reverse' | 'auto';
|
|
3
|
+
export type LayoutMode = 'vertical' | 'horizontal' | 'grid' | 'masonry';
|
|
4
|
+
export interface ItemSize {
|
|
5
|
+
index: number;
|
|
6
|
+
size: number;
|
|
7
|
+
offset: number;
|
|
8
|
+
}
|
|
9
|
+
export interface VirtualItem {
|
|
10
|
+
index: number;
|
|
11
|
+
offset: number;
|
|
12
|
+
size: number;
|
|
13
|
+
isSticky?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ScrollState {
|
|
16
|
+
scrollOffset: number;
|
|
17
|
+
scrollUpdateWasRequested: boolean;
|
|
18
|
+
isScrolling: boolean;
|
|
19
|
+
scrollDirection: ScrollDirection;
|
|
20
|
+
}
|
|
21
|
+
export interface MeasurementCache {
|
|
22
|
+
[key: number]: number;
|
|
23
|
+
}
|
|
24
|
+
export interface VirtualListProps<T> {
|
|
25
|
+
items: T[];
|
|
26
|
+
renderItem: (props: RenderItemProps<T>) => React.ReactNode;
|
|
27
|
+
itemKey?: (index: number, item: T) => string | number;
|
|
28
|
+
height?: number;
|
|
29
|
+
width?: number;
|
|
30
|
+
itemSize?: number | ((index: number) => number);
|
|
31
|
+
overscan?: number;
|
|
32
|
+
scrollDirection?: ScrollDirection;
|
|
33
|
+
onScroll?: (offset: number, direction: ScrollDirection) => void;
|
|
34
|
+
className?: string;
|
|
35
|
+
style?: React.CSSProperties;
|
|
36
|
+
estimatedItemSize?: number;
|
|
37
|
+
getItemSize?: (index: number) => number;
|
|
38
|
+
stickyIndices?: number[];
|
|
39
|
+
onScrollEnd?: () => void;
|
|
40
|
+
scrollMargin?: number;
|
|
41
|
+
innerRef?: React.Ref<HTMLDivElement>;
|
|
42
|
+
scrollOffsetRef?: React.MutableRefObject<number>;
|
|
43
|
+
}
|
|
44
|
+
export interface VirtualGridProps<T> {
|
|
45
|
+
items: T[];
|
|
46
|
+
renderItem: (props: RenderItemProps<T>) => React.ReactNode;
|
|
47
|
+
itemKey?: (index: number, item: T) => string | number;
|
|
48
|
+
height: number;
|
|
49
|
+
width: number;
|
|
50
|
+
columnCount: number | 'auto';
|
|
51
|
+
rowHeight?: number | ((index: number) => number);
|
|
52
|
+
columnWidth?: number | ((index: number) => number);
|
|
53
|
+
layout?: 'grid' | 'masonry';
|
|
54
|
+
overscan?: number;
|
|
55
|
+
gap?: number;
|
|
56
|
+
onScroll?: (offset: number) => void;
|
|
57
|
+
className?: string;
|
|
58
|
+
style?: React.CSSProperties;
|
|
59
|
+
estimatedItemHeight?: number;
|
|
60
|
+
}
|
|
61
|
+
export interface RenderItemProps<T> {
|
|
62
|
+
item: T;
|
|
63
|
+
index: number;
|
|
64
|
+
style: React.CSSProperties;
|
|
65
|
+
isScrolling: boolean;
|
|
66
|
+
isMeasuring?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface UseVirtualListOptions<T> {
|
|
69
|
+
items: T[];
|
|
70
|
+
itemSize?: number | ((index: number) => number);
|
|
71
|
+
containerHeight: number;
|
|
72
|
+
containerWidth?: number;
|
|
73
|
+
overscan?: number;
|
|
74
|
+
scrollDirection?: ScrollDirection;
|
|
75
|
+
estimatedItemSize?: number;
|
|
76
|
+
onScroll?: (offset: number) => void;
|
|
77
|
+
}
|
|
78
|
+
export interface VirtualRange {
|
|
79
|
+
startIndex: number;
|
|
80
|
+
endIndex: number;
|
|
81
|
+
overscanStartIndex: number;
|
|
82
|
+
overscanEndIndex: number;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAC7D,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;AAExE,MAAM,WAAW,QAAQ;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,wBAAwB,EAAE,OAAO,CAAC;IAClC,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,eAAe,CAAC;CACpC;AAED,MAAM,WAAW,gBAAgB;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC;IAC/B,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,UAAU,EAAE,CAAC,KAAK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zB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;CAC5B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binary search to find the item at a given scroll offset
|
|
3
|
+
*/
|
|
4
|
+
export declare function binarySearch(offsets: number[], target: number, low?: number, high?: number): number;
|
|
5
|
+
/**
|
|
6
|
+
* Calculate range with overscan
|
|
7
|
+
*/
|
|
8
|
+
export declare function getOverscanRange(startIndex: number, endIndex: number, overscan: number, itemCount: number): {
|
|
9
|
+
start: number;
|
|
10
|
+
end: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Debounce function
|
|
14
|
+
*/
|
|
15
|
+
export declare function debounce<T extends (...args: any[]) => any>(fn: T, delay: number): (...args: Parameters<T>) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Throttle function
|
|
18
|
+
*/
|
|
19
|
+
export declare function throttle<T extends (...args: any[]) => any>(fn: T, delay: number): (...args: Parameters<T>) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Request animation frame wrapper
|
|
22
|
+
*/
|
|
23
|
+
export declare function requestAnimationFrameWithFallback(callback: FrameRequestCallback): number;
|
|
24
|
+
/**
|
|
25
|
+
* Cancel animation frame with fallback
|
|
26
|
+
*/
|
|
27
|
+
export declare function cancelAnimationFrameWithFallback(id: number): void;
|
|
28
|
+
/**
|
|
29
|
+
* Check if an element is visible in viewport
|
|
30
|
+
*/
|
|
31
|
+
export declare function isElementInViewport(element: HTMLElement, container: HTMLElement): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Get scroll velocity
|
|
34
|
+
*/
|
|
35
|
+
export declare function calculateScrollVelocity(currentOffset: number, previousOffset: number, deltaTime: number): number;
|
|
36
|
+
/**
|
|
37
|
+
* Clamp a value between min and max
|
|
38
|
+
*/
|
|
39
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
40
|
+
/**
|
|
41
|
+
* Check if ResizeObserver is supported
|
|
42
|
+
*/
|
|
43
|
+
export declare function isResizeObserverSupported(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Check if IntersectionObserver is supported
|
|
46
|
+
*/
|
|
47
|
+
export declare function isIntersectionObserverSupported(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Smooth scroll to position
|
|
50
|
+
*/
|
|
51
|
+
export declare function smoothScroll(element: HTMLElement, targetScroll: number, duration?: number): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Create a unique key from index and item
|
|
54
|
+
*/
|
|
55
|
+
export declare function createItemKey<T>(index: number, item: T, keyGetter?: (index: number, item: T) => string | number): string | number;
|
|
56
|
+
/**
|
|
57
|
+
* Log virtualization stats (for debugging)
|
|
58
|
+
*/
|
|
59
|
+
export declare function logVirtualizationStats(stats: {
|
|
60
|
+
itemCount: number;
|
|
61
|
+
visibleCount: number;
|
|
62
|
+
renderedCount: number;
|
|
63
|
+
scrollOffset: number;
|
|
64
|
+
totalSize: number;
|
|
65
|
+
}): void;
|
|
66
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,YAAY,CACxB,OAAO,EAAE,MAAM,EAAE,EACjB,MAAM,EAAE,MAAM,EACd,GAAG,GAAE,MAAU,EACf,IAAI,GAAE,MAA2B,GAClC,MAAM,CAeR;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC5B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAClB;IA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