@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/plugins/index.cjs
CHANGED
|
@@ -1,684 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkND5PV5MU_cjs = require('../chunk-ND5PV5MU.cjs');
|
|
3
4
|
var react = require('react');
|
|
4
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
6
|
|
|
6
|
-
// src/plugins/core/list-renderer.ts
|
|
7
|
-
var VirtualItemPool = class {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.pool = [];
|
|
10
|
-
}
|
|
11
|
-
acquire() {
|
|
12
|
-
const item = this.pool.pop();
|
|
13
|
-
if (item) {
|
|
14
|
-
return item;
|
|
15
|
-
}
|
|
16
|
-
return { index: 0, key: 0, start: 0, end: 0, size: 0, lane: 0 };
|
|
17
|
-
}
|
|
18
|
-
release(item) {
|
|
19
|
-
item.index = 0;
|
|
20
|
-
item.key = 0;
|
|
21
|
-
item.start = 0;
|
|
22
|
-
item.end = 0;
|
|
23
|
-
item.size = 0;
|
|
24
|
-
item.lane = 0;
|
|
25
|
-
this.pool.push(item);
|
|
26
|
-
}
|
|
27
|
-
releaseAll(items) {
|
|
28
|
-
for (const item of items) {
|
|
29
|
-
this.release(item);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
function listRendererPlugin(options = {}) {
|
|
34
|
-
const { getItemKey = (index) => index } = options;
|
|
35
|
-
let kernel = null;
|
|
36
|
-
let virtualItems = [];
|
|
37
|
-
let currentRange = {
|
|
38
|
-
startIndex: 0,
|
|
39
|
-
endIndex: 0,
|
|
40
|
-
overscanStartIndex: 0,
|
|
41
|
-
overscanEndIndex: 0
|
|
42
|
-
};
|
|
43
|
-
const itemPool = new VirtualItemPool();
|
|
44
|
-
function buildVirtualItems(range) {
|
|
45
|
-
if (!kernel) return [];
|
|
46
|
-
itemPool.releaseAll(virtualItems);
|
|
47
|
-
const items = [];
|
|
48
|
-
range.startIndex;
|
|
49
|
-
range.endIndex;
|
|
50
|
-
for (let i = range.overscanStartIndex; i <= range.overscanEndIndex; i++) {
|
|
51
|
-
const item = itemPool.acquire();
|
|
52
|
-
const offset = kernel.getItemOffset(i);
|
|
53
|
-
const size = kernel.getCachedHeight(i) ?? kernel.getEstimatedHeight();
|
|
54
|
-
item.index = i;
|
|
55
|
-
item.key = getItemKey(i);
|
|
56
|
-
item.start = offset;
|
|
57
|
-
item.end = offset + size;
|
|
58
|
-
item.size = size;
|
|
59
|
-
item.lane = 0;
|
|
60
|
-
items.push(item);
|
|
61
|
-
}
|
|
62
|
-
return items;
|
|
63
|
-
}
|
|
64
|
-
function recalculate() {
|
|
65
|
-
if (!kernel) return;
|
|
66
|
-
currentRange = kernel.getVisibleRange();
|
|
67
|
-
virtualItems = buildVirtualItems(currentRange);
|
|
68
|
-
}
|
|
69
|
-
const api = {
|
|
70
|
-
getVirtualItems() {
|
|
71
|
-
return virtualItems;
|
|
72
|
-
},
|
|
73
|
-
getTotalHeight() {
|
|
74
|
-
return kernel?.getTotalSize() ?? 0;
|
|
75
|
-
},
|
|
76
|
-
getStartOffset() {
|
|
77
|
-
if (virtualItems.length === 0) return 0;
|
|
78
|
-
return virtualItems[0]?.start ?? 0;
|
|
79
|
-
},
|
|
80
|
-
getEndOffset() {
|
|
81
|
-
if (virtualItems.length === 0) return 0;
|
|
82
|
-
const lastItem = virtualItems[virtualItems.length - 1];
|
|
83
|
-
return lastItem?.end ?? 0;
|
|
84
|
-
},
|
|
85
|
-
isItemVisible(index) {
|
|
86
|
-
return index >= currentRange.startIndex && index <= currentRange.endIndex;
|
|
87
|
-
},
|
|
88
|
-
recalculate
|
|
89
|
-
};
|
|
90
|
-
return {
|
|
91
|
-
name: "list-renderer",
|
|
92
|
-
version: "1.0.0",
|
|
93
|
-
type: "core",
|
|
94
|
-
install(k) {
|
|
95
|
-
kernel = k;
|
|
96
|
-
recalculate();
|
|
97
|
-
},
|
|
98
|
-
uninstall() {
|
|
99
|
-
itemPool.releaseAll(virtualItems);
|
|
100
|
-
virtualItems = [];
|
|
101
|
-
kernel = null;
|
|
102
|
-
},
|
|
103
|
-
hooks: {
|
|
104
|
-
onScroll: () => recalculate(),
|
|
105
|
-
onResize: () => recalculate(),
|
|
106
|
-
onItemMeasured: () => recalculate(),
|
|
107
|
-
onVisibleRangeChange: (range) => {
|
|
108
|
-
currentRange = range;
|
|
109
|
-
virtualItems = buildVirtualItems(range);
|
|
110
|
-
},
|
|
111
|
-
onItemsChange: () => recalculate()
|
|
112
|
-
},
|
|
113
|
-
api
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// src/plugins/core/grid-renderer.ts
|
|
118
|
-
function gridRendererPlugin(options) {
|
|
119
|
-
const {
|
|
120
|
-
columns,
|
|
121
|
-
minColumnWidth = 100,
|
|
122
|
-
rowHeight,
|
|
123
|
-
gap = 0,
|
|
124
|
-
getItemKey = (index) => index
|
|
125
|
-
} = options;
|
|
126
|
-
let kernel = null;
|
|
127
|
-
let virtualItems = [];
|
|
128
|
-
let columnCount = typeof columns === "number" ? columns : 1;
|
|
129
|
-
let columnWidth = 0;
|
|
130
|
-
let gapX = typeof gap === "number" ? gap : gap.x;
|
|
131
|
-
let gapY = typeof gap === "number" ? gap : gap.y;
|
|
132
|
-
function calculateColumns(containerWidth) {
|
|
133
|
-
if (typeof columns === "number") {
|
|
134
|
-
columnCount = columns;
|
|
135
|
-
} else {
|
|
136
|
-
columnCount = Math.max(1, Math.floor((containerWidth + gapX) / (minColumnWidth + gapX)));
|
|
137
|
-
}
|
|
138
|
-
columnWidth = (containerWidth - (columnCount - 1) * gapX) / columnCount;
|
|
139
|
-
}
|
|
140
|
-
function getRowCount() {
|
|
141
|
-
if (!kernel) return 0;
|
|
142
|
-
return Math.ceil(kernel.getItemCount() / columnCount);
|
|
143
|
-
}
|
|
144
|
-
function buildVirtualItems() {
|
|
145
|
-
if (!kernel) return [];
|
|
146
|
-
const viewport = kernel.getViewport();
|
|
147
|
-
const scrollPosition = kernel.getScrollPosition();
|
|
148
|
-
const scrollTop = scrollPosition.scrollTop;
|
|
149
|
-
const effectiveRowHeight = rowHeight + gapY;
|
|
150
|
-
const startRow = Math.max(0, Math.floor(scrollTop / effectiveRowHeight));
|
|
151
|
-
const visibleRows = Math.ceil(viewport.height / effectiveRowHeight);
|
|
152
|
-
const overscan = kernel.getOptions().overscan;
|
|
153
|
-
const endRow = Math.min(getRowCount() - 1, startRow + visibleRows + overscan);
|
|
154
|
-
const overscanStartRow = Math.max(0, startRow - overscan);
|
|
155
|
-
const items = [];
|
|
156
|
-
const itemCount = kernel.getItemCount();
|
|
157
|
-
for (let row = overscanStartRow; row <= endRow; row++) {
|
|
158
|
-
for (let col = 0; col < columnCount; col++) {
|
|
159
|
-
const index = row * columnCount + col;
|
|
160
|
-
if (index >= itemCount) break;
|
|
161
|
-
const top = row * effectiveRowHeight;
|
|
162
|
-
items.push({
|
|
163
|
-
index,
|
|
164
|
-
key: getItemKey(index),
|
|
165
|
-
start: top,
|
|
166
|
-
end: top + rowHeight,
|
|
167
|
-
size: rowHeight,
|
|
168
|
-
lane: col
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return items;
|
|
173
|
-
}
|
|
174
|
-
function recalculate() {
|
|
175
|
-
if (!kernel) return;
|
|
176
|
-
const viewport = kernel.getViewport();
|
|
177
|
-
calculateColumns(viewport.width);
|
|
178
|
-
virtualItems = buildVirtualItems();
|
|
179
|
-
}
|
|
180
|
-
const api = {
|
|
181
|
-
getVirtualItems() {
|
|
182
|
-
return virtualItems;
|
|
183
|
-
},
|
|
184
|
-
getTotalHeight() {
|
|
185
|
-
return getRowCount() * (rowHeight + gapY) - gapY;
|
|
186
|
-
},
|
|
187
|
-
getColumnCount() {
|
|
188
|
-
return columnCount;
|
|
189
|
-
},
|
|
190
|
-
getColumnWidth() {
|
|
191
|
-
return columnWidth;
|
|
192
|
-
},
|
|
193
|
-
getItemsPerRow() {
|
|
194
|
-
return columnCount;
|
|
195
|
-
},
|
|
196
|
-
getRowCount,
|
|
197
|
-
recalculate
|
|
198
|
-
};
|
|
199
|
-
return {
|
|
200
|
-
name: "grid-renderer",
|
|
201
|
-
version: "1.0.0",
|
|
202
|
-
type: "core",
|
|
203
|
-
install(k) {
|
|
204
|
-
kernel = k;
|
|
205
|
-
recalculate();
|
|
206
|
-
},
|
|
207
|
-
uninstall() {
|
|
208
|
-
virtualItems = [];
|
|
209
|
-
kernel = null;
|
|
210
|
-
},
|
|
211
|
-
hooks: {
|
|
212
|
-
onScroll: () => {
|
|
213
|
-
virtualItems = buildVirtualItems();
|
|
214
|
-
},
|
|
215
|
-
onResize: () => recalculate(),
|
|
216
|
-
onItemsChange: () => recalculate()
|
|
217
|
-
},
|
|
218
|
-
api
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// src/utils/debounce.ts
|
|
223
|
-
function debounce(fn, wait) {
|
|
224
|
-
let timeoutId = null;
|
|
225
|
-
let lastArgs = null;
|
|
226
|
-
let lastThis = null;
|
|
227
|
-
const debounced = function(...args) {
|
|
228
|
-
lastArgs = args;
|
|
229
|
-
lastThis = this;
|
|
230
|
-
if (timeoutId) {
|
|
231
|
-
clearTimeout(timeoutId);
|
|
232
|
-
}
|
|
233
|
-
timeoutId = setTimeout(() => {
|
|
234
|
-
timeoutId = null;
|
|
235
|
-
if (lastArgs) {
|
|
236
|
-
fn.apply(lastThis, lastArgs);
|
|
237
|
-
lastArgs = null;
|
|
238
|
-
lastThis = null;
|
|
239
|
-
}
|
|
240
|
-
}, wait);
|
|
241
|
-
};
|
|
242
|
-
debounced.cancel = () => {
|
|
243
|
-
if (timeoutId) {
|
|
244
|
-
clearTimeout(timeoutId);
|
|
245
|
-
timeoutId = null;
|
|
246
|
-
}
|
|
247
|
-
lastArgs = null;
|
|
248
|
-
lastThis = null;
|
|
249
|
-
};
|
|
250
|
-
debounced.flush = () => {
|
|
251
|
-
if (timeoutId) {
|
|
252
|
-
clearTimeout(timeoutId);
|
|
253
|
-
timeoutId = null;
|
|
254
|
-
if (lastArgs) {
|
|
255
|
-
fn.apply(lastThis, lastArgs);
|
|
256
|
-
lastArgs = null;
|
|
257
|
-
lastThis = null;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
return debounced;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// src/plugins/core/auto-measurer.ts
|
|
265
|
-
function autoMeasurerPlugin(options = {}) {
|
|
266
|
-
const {
|
|
267
|
-
estimatedItemHeight = 50,
|
|
268
|
-
measureOnResize = true,
|
|
269
|
-
debounceMs = 100
|
|
270
|
-
} = options;
|
|
271
|
-
let kernel = null;
|
|
272
|
-
let resizeObserver = null;
|
|
273
|
-
const observedElements = /* @__PURE__ */ new WeakMap();
|
|
274
|
-
const elementsByIndex = /* @__PURE__ */ new Map();
|
|
275
|
-
let measureQueue = /* @__PURE__ */ new Set();
|
|
276
|
-
let flushScheduled = false;
|
|
277
|
-
const debouncedFlush = debounce(() => {
|
|
278
|
-
flush();
|
|
279
|
-
}, debounceMs);
|
|
280
|
-
function flush() {
|
|
281
|
-
if (!kernel || measureQueue.size === 0) {
|
|
282
|
-
flushScheduled = false;
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
const indicesToMeasure = Array.from(measureQueue);
|
|
286
|
-
measureQueue = /* @__PURE__ */ new Set();
|
|
287
|
-
flushScheduled = false;
|
|
288
|
-
const measurements = [];
|
|
289
|
-
for (const index of indicesToMeasure) {
|
|
290
|
-
const ref = elementsByIndex.get(index);
|
|
291
|
-
const element = ref?.deref();
|
|
292
|
-
if (element) {
|
|
293
|
-
const rect = element.getBoundingClientRect();
|
|
294
|
-
measurements.push({ index, height: rect.height });
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
for (const { index, height } of measurements) {
|
|
298
|
-
if (height > 0) {
|
|
299
|
-
kernel.measureItem(index, height);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
function scheduleFlush() {
|
|
304
|
-
if (!flushScheduled) {
|
|
305
|
-
flushScheduled = true;
|
|
306
|
-
requestAnimationFrame(() => {
|
|
307
|
-
flush();
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
function handleResize(entries) {
|
|
312
|
-
for (const entry of entries) {
|
|
313
|
-
const index = observedElements.get(entry.target);
|
|
314
|
-
if (index !== void 0) {
|
|
315
|
-
measureQueue.add(index);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
if (measureOnResize && measureQueue.size > 0) {
|
|
319
|
-
debouncedFlush();
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
const api = {
|
|
323
|
-
measureElement(index, element) {
|
|
324
|
-
const rect = element.getBoundingClientRect();
|
|
325
|
-
const height = rect.height;
|
|
326
|
-
if (height > 0 && kernel) {
|
|
327
|
-
kernel.measureItem(index, height);
|
|
328
|
-
}
|
|
329
|
-
return height;
|
|
330
|
-
},
|
|
331
|
-
getCachedSize(index) {
|
|
332
|
-
return kernel?.getCachedHeight(index);
|
|
333
|
-
},
|
|
334
|
-
invalidate(index) {
|
|
335
|
-
kernel?.invalidateMeasurement(index);
|
|
336
|
-
},
|
|
337
|
-
invalidateAll() {
|
|
338
|
-
kernel?.invalidateAllMeasurements();
|
|
339
|
-
},
|
|
340
|
-
getMeasurementCache() {
|
|
341
|
-
const cache = /* @__PURE__ */ new Map();
|
|
342
|
-
if (!kernel) return cache;
|
|
343
|
-
const itemCount = kernel.getItemCount();
|
|
344
|
-
for (let i = 0; i < itemCount; i++) {
|
|
345
|
-
const height = kernel.getCachedHeight(i);
|
|
346
|
-
if (height !== void 0) {
|
|
347
|
-
cache.set(i, height);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
return cache;
|
|
351
|
-
},
|
|
352
|
-
observe(index, element) {
|
|
353
|
-
if (!resizeObserver) return;
|
|
354
|
-
const existingRef = elementsByIndex.get(index);
|
|
355
|
-
const existingElement = existingRef?.deref();
|
|
356
|
-
if (existingElement && existingElement !== element) {
|
|
357
|
-
resizeObserver.unobserve(existingElement);
|
|
358
|
-
observedElements.delete(existingElement);
|
|
359
|
-
}
|
|
360
|
-
observedElements.set(element, index);
|
|
361
|
-
elementsByIndex.set(index, new WeakRef(element));
|
|
362
|
-
resizeObserver.observe(element);
|
|
363
|
-
measureQueue.add(index);
|
|
364
|
-
scheduleFlush();
|
|
365
|
-
},
|
|
366
|
-
unobserve(element) {
|
|
367
|
-
if (!resizeObserver) return;
|
|
368
|
-
const index = observedElements.get(element);
|
|
369
|
-
if (index !== void 0) {
|
|
370
|
-
resizeObserver.unobserve(element);
|
|
371
|
-
observedElements.delete(element);
|
|
372
|
-
elementsByIndex.delete(index);
|
|
373
|
-
measureQueue.delete(index);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
return {
|
|
378
|
-
name: "auto-measurer",
|
|
379
|
-
version: "1.0.0",
|
|
380
|
-
type: "core",
|
|
381
|
-
install(k) {
|
|
382
|
-
kernel = k;
|
|
383
|
-
kernel.configure({ estimatedItemHeight });
|
|
384
|
-
if (measureOnResize && typeof ResizeObserver !== "undefined") {
|
|
385
|
-
resizeObserver = new ResizeObserver(handleResize);
|
|
386
|
-
}
|
|
387
|
-
},
|
|
388
|
-
uninstall() {
|
|
389
|
-
if (resizeObserver) {
|
|
390
|
-
resizeObserver.disconnect();
|
|
391
|
-
resizeObserver = null;
|
|
392
|
-
}
|
|
393
|
-
debouncedFlush.cancel();
|
|
394
|
-
measureQueue.clear();
|
|
395
|
-
elementsByIndex.clear();
|
|
396
|
-
flushScheduled = false;
|
|
397
|
-
kernel = null;
|
|
398
|
-
},
|
|
399
|
-
api
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// src/plugins/core/infinite-loader.ts
|
|
404
|
-
function infiniteLoaderPlugin(options) {
|
|
405
|
-
const {
|
|
406
|
-
threshold = 200,
|
|
407
|
-
thresholdItems = 5,
|
|
408
|
-
direction = "forward",
|
|
409
|
-
onLoadMore
|
|
410
|
-
} = options;
|
|
411
|
-
let kernel = null;
|
|
412
|
-
let loading = false;
|
|
413
|
-
let hasMoreForward = true;
|
|
414
|
-
let hasMoreBackward = direction === "backward" || direction === "both";
|
|
415
|
-
let lastCheckTime = 0;
|
|
416
|
-
const checkDebounceMs = 100;
|
|
417
|
-
function checkLoadMore(event) {
|
|
418
|
-
if (loading || !kernel) return;
|
|
419
|
-
const now = performance.now();
|
|
420
|
-
if (now - lastCheckTime < checkDebounceMs) return;
|
|
421
|
-
lastCheckTime = now;
|
|
422
|
-
const viewport = kernel.getViewport();
|
|
423
|
-
const totalSize = kernel.getTotalSize();
|
|
424
|
-
const { scrollTop } = event;
|
|
425
|
-
if ((direction === "forward" || direction === "both") && hasMoreForward) {
|
|
426
|
-
const distanceFromBottom = totalSize - scrollTop - viewport.height;
|
|
427
|
-
if (distanceFromBottom < threshold) {
|
|
428
|
-
triggerLoad("forward");
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
if ((direction === "backward" || direction === "both") && hasMoreBackward) {
|
|
433
|
-
if (scrollTop < threshold) {
|
|
434
|
-
triggerLoad("backward");
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
function checkLoadMoreByRange(range) {
|
|
440
|
-
if (loading || !kernel) return;
|
|
441
|
-
const itemCount = kernel.getItemCount();
|
|
442
|
-
if ((direction === "forward" || direction === "both") && hasMoreForward) {
|
|
443
|
-
const itemsFromEnd = itemCount - 1 - range.endIndex;
|
|
444
|
-
if (itemsFromEnd <= thresholdItems) {
|
|
445
|
-
triggerLoad("forward");
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
if ((direction === "backward" || direction === "both") && hasMoreBackward) {
|
|
450
|
-
if (range.startIndex <= thresholdItems) {
|
|
451
|
-
triggerLoad("backward");
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
async function triggerLoad(loadDirection) {
|
|
457
|
-
if (loading || !kernel) return;
|
|
458
|
-
if (loadDirection === "forward" && !hasMoreForward) return;
|
|
459
|
-
if (loadDirection === "backward" && !hasMoreBackward) return;
|
|
460
|
-
loading = true;
|
|
461
|
-
kernel.emit({
|
|
462
|
-
type: "load-more",
|
|
463
|
-
direction: loadDirection
|
|
464
|
-
});
|
|
465
|
-
try {
|
|
466
|
-
await onLoadMore(loadDirection);
|
|
467
|
-
} catch (error) {
|
|
468
|
-
console.error("[Scrollex] Error in onLoadMore:", error);
|
|
469
|
-
} finally {
|
|
470
|
-
loading = false;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
const api = {
|
|
474
|
-
isLoading() {
|
|
475
|
-
return loading;
|
|
476
|
-
},
|
|
477
|
-
setLoading(l) {
|
|
478
|
-
loading = l;
|
|
479
|
-
},
|
|
480
|
-
hasMore() {
|
|
481
|
-
return hasMoreForward || hasMoreBackward;
|
|
482
|
-
},
|
|
483
|
-
setHasMore(hasMore) {
|
|
484
|
-
hasMoreForward = hasMore;
|
|
485
|
-
hasMoreBackward = hasMore;
|
|
486
|
-
},
|
|
487
|
-
hasMoreForward() {
|
|
488
|
-
return hasMoreForward;
|
|
489
|
-
},
|
|
490
|
-
setHasMoreForward(hasMore) {
|
|
491
|
-
hasMoreForward = hasMore;
|
|
492
|
-
},
|
|
493
|
-
hasMoreBackward() {
|
|
494
|
-
return hasMoreBackward;
|
|
495
|
-
},
|
|
496
|
-
setHasMoreBackward(hasMore) {
|
|
497
|
-
hasMoreBackward = hasMore;
|
|
498
|
-
},
|
|
499
|
-
reset() {
|
|
500
|
-
loading = false;
|
|
501
|
-
hasMoreForward = true;
|
|
502
|
-
hasMoreBackward = direction === "backward" || direction === "both";
|
|
503
|
-
},
|
|
504
|
-
triggerLoad(loadDirection) {
|
|
505
|
-
triggerLoad(loadDirection);
|
|
506
|
-
}
|
|
507
|
-
};
|
|
508
|
-
return {
|
|
509
|
-
name: "infinite-loader",
|
|
510
|
-
version: "1.0.0",
|
|
511
|
-
type: "core",
|
|
512
|
-
install(k) {
|
|
513
|
-
kernel = k;
|
|
514
|
-
},
|
|
515
|
-
uninstall() {
|
|
516
|
-
kernel = null;
|
|
517
|
-
loading = false;
|
|
518
|
-
},
|
|
519
|
-
hooks: {
|
|
520
|
-
onScroll: checkLoadMore,
|
|
521
|
-
onVisibleRangeChange: (range) => checkLoadMoreByRange(range)
|
|
522
|
-
},
|
|
523
|
-
api
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
// src/utils/raf.ts
|
|
528
|
-
function raf(callback) {
|
|
529
|
-
if (typeof requestAnimationFrame !== "undefined") {
|
|
530
|
-
return requestAnimationFrame(callback);
|
|
531
|
-
}
|
|
532
|
-
return setTimeout(() => callback(Date.now()), 16);
|
|
533
|
-
}
|
|
534
|
-
function cancelRaf(id) {
|
|
535
|
-
if (typeof cancelAnimationFrame !== "undefined") {
|
|
536
|
-
cancelAnimationFrame(id);
|
|
537
|
-
} else {
|
|
538
|
-
clearTimeout(id);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
// src/plugins/core/scroll-controller.ts
|
|
543
|
-
var easings = {
|
|
544
|
-
easeInOut: (t) => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t};
|
|
545
|
-
function scrollControllerPlugin(options = {}) {
|
|
546
|
-
const {
|
|
547
|
-
defaultDuration = 300,
|
|
548
|
-
defaultEasing = easings.easeInOut
|
|
549
|
-
} = options;
|
|
550
|
-
let kernel = null;
|
|
551
|
-
let animationId = null;
|
|
552
|
-
let animating = false;
|
|
553
|
-
function animateScroll(targetOffset, duration, easing) {
|
|
554
|
-
if (!kernel) return;
|
|
555
|
-
stopAnimation();
|
|
556
|
-
const startTime = performance.now();
|
|
557
|
-
const startOffset = kernel.getScrollPosition().scrollTop;
|
|
558
|
-
const distance = targetOffset - startOffset;
|
|
559
|
-
if (distance === 0 || duration === 0) {
|
|
560
|
-
kernel.setScrollPosition({ scrollTop: targetOffset, scrollLeft: 0 });
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
animating = true;
|
|
564
|
-
function animate(currentTime) {
|
|
565
|
-
if (!kernel) {
|
|
566
|
-
animating = false;
|
|
567
|
-
return;
|
|
568
|
-
}
|
|
569
|
-
const elapsed = currentTime - startTime;
|
|
570
|
-
const progress = Math.min(elapsed / duration, 1);
|
|
571
|
-
const easedProgress = easing(progress);
|
|
572
|
-
const currentOffset = startOffset + distance * easedProgress;
|
|
573
|
-
kernel.setScrollPosition({ scrollTop: currentOffset, scrollLeft: 0 });
|
|
574
|
-
if (progress < 1) {
|
|
575
|
-
animationId = raf(animate);
|
|
576
|
-
} else {
|
|
577
|
-
animationId = null;
|
|
578
|
-
animating = false;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
animationId = raf(animate);
|
|
582
|
-
}
|
|
583
|
-
function stopAnimation() {
|
|
584
|
-
if (animationId !== null) {
|
|
585
|
-
cancelRaf(animationId);
|
|
586
|
-
animationId = null;
|
|
587
|
-
}
|
|
588
|
-
animating = false;
|
|
589
|
-
}
|
|
590
|
-
const api = {
|
|
591
|
-
scrollTo(offset, options2 = {}) {
|
|
592
|
-
if (!kernel) return;
|
|
593
|
-
const {
|
|
594
|
-
behavior = "auto",
|
|
595
|
-
duration = defaultDuration,
|
|
596
|
-
easing = defaultEasing
|
|
597
|
-
} = options2;
|
|
598
|
-
if (behavior === "auto") {
|
|
599
|
-
stopAnimation();
|
|
600
|
-
kernel.setScrollPosition({ scrollTop: offset, scrollLeft: 0 });
|
|
601
|
-
} else {
|
|
602
|
-
animateScroll(offset, duration, easing);
|
|
603
|
-
}
|
|
604
|
-
},
|
|
605
|
-
scrollToIndex(index, options2 = {}) {
|
|
606
|
-
if (!kernel) return;
|
|
607
|
-
const {
|
|
608
|
-
align = "auto",
|
|
609
|
-
offset: additionalOffset = 0,
|
|
610
|
-
...scrollOptions
|
|
611
|
-
} = options2;
|
|
612
|
-
const itemOffset = kernel.getItemOffset(index);
|
|
613
|
-
const itemSize = kernel.getCachedHeight(index) ?? kernel.getEstimatedHeight();
|
|
614
|
-
const viewport = kernel.getViewport();
|
|
615
|
-
let targetOffset;
|
|
616
|
-
switch (align) {
|
|
617
|
-
case "start":
|
|
618
|
-
targetOffset = itemOffset;
|
|
619
|
-
break;
|
|
620
|
-
case "center":
|
|
621
|
-
targetOffset = itemOffset - viewport.height / 2 + itemSize / 2;
|
|
622
|
-
break;
|
|
623
|
-
case "end":
|
|
624
|
-
targetOffset = itemOffset - viewport.height + itemSize;
|
|
625
|
-
break;
|
|
626
|
-
case "auto":
|
|
627
|
-
default: {
|
|
628
|
-
const scrollPosition = kernel.getScrollPosition();
|
|
629
|
-
const visibleStart = scrollPosition.scrollTop;
|
|
630
|
-
const visibleEnd = visibleStart + viewport.height;
|
|
631
|
-
const itemEnd = itemOffset + itemSize;
|
|
632
|
-
if (itemOffset < visibleStart) {
|
|
633
|
-
targetOffset = itemOffset;
|
|
634
|
-
} else if (itemEnd > visibleEnd) {
|
|
635
|
-
targetOffset = itemEnd - viewport.height;
|
|
636
|
-
} else {
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
break;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
const maxScroll = Math.max(0, kernel.getTotalSize() - viewport.height);
|
|
643
|
-
targetOffset = Math.max(0, Math.min(targetOffset + additionalOffset, maxScroll));
|
|
644
|
-
api.scrollTo(targetOffset, scrollOptions);
|
|
645
|
-
},
|
|
646
|
-
scrollToTop(options2 = {}) {
|
|
647
|
-
api.scrollTo(0, options2);
|
|
648
|
-
},
|
|
649
|
-
scrollToBottom(options2 = {}) {
|
|
650
|
-
if (!kernel) return;
|
|
651
|
-
const viewport = kernel.getViewport();
|
|
652
|
-
const totalSize = kernel.getTotalSize();
|
|
653
|
-
const maxScroll = Math.max(0, totalSize - viewport.height);
|
|
654
|
-
api.scrollTo(maxScroll, options2);
|
|
655
|
-
},
|
|
656
|
-
getScrollPosition() {
|
|
657
|
-
return kernel?.getScrollPosition() ?? { scrollTop: 0, scrollLeft: 0 };
|
|
658
|
-
},
|
|
659
|
-
isScrolling() {
|
|
660
|
-
return kernel?.isScrolling() ?? false;
|
|
661
|
-
},
|
|
662
|
-
isAnimating() {
|
|
663
|
-
return animating;
|
|
664
|
-
},
|
|
665
|
-
stopAnimation
|
|
666
|
-
};
|
|
667
|
-
return {
|
|
668
|
-
name: "scroll-controller",
|
|
669
|
-
version: "1.0.0",
|
|
670
|
-
type: "core",
|
|
671
|
-
install(k) {
|
|
672
|
-
kernel = k;
|
|
673
|
-
},
|
|
674
|
-
uninstall() {
|
|
675
|
-
stopAnimation();
|
|
676
|
-
kernel = null;
|
|
677
|
-
},
|
|
678
|
-
api
|
|
679
|
-
};
|
|
680
|
-
}
|
|
681
|
-
|
|
682
7
|
// src/plugins/optional/masonry-renderer.ts
|
|
683
8
|
function masonryRenderer(options) {
|
|
684
9
|
const {
|
|
@@ -690,16 +15,16 @@ function masonryRenderer(options) {
|
|
|
690
15
|
} = options;
|
|
691
16
|
let kernel = null;
|
|
692
17
|
let virtualItems = [];
|
|
693
|
-
let columnCount = typeof columns === "number" ? columns : 1;
|
|
18
|
+
let columnCount = typeof columns === "number" ? chunkND5PV5MU_cjs.normalizeColumnCount(columns) : 1;
|
|
694
19
|
let columnWidth = 0;
|
|
695
20
|
let columnHeights = [];
|
|
696
21
|
let totalHeight = 0;
|
|
697
22
|
const layoutCache = /* @__PURE__ */ new Map();
|
|
698
23
|
function calculateColumns(containerWidth) {
|
|
699
24
|
if (typeof columns === "number") {
|
|
700
|
-
columnCount = columns;
|
|
25
|
+
columnCount = chunkND5PV5MU_cjs.normalizeColumnCount(columns);
|
|
701
26
|
} else {
|
|
702
|
-
columnCount =
|
|
27
|
+
columnCount = chunkND5PV5MU_cjs.autoColumnCount(containerWidth, minColumnWidth, gap);
|
|
703
28
|
}
|
|
704
29
|
columnWidth = (containerWidth - (columnCount - 1) * gap) / columnCount;
|
|
705
30
|
}
|
|
@@ -707,6 +32,7 @@ function masonryRenderer(options) {
|
|
|
707
32
|
if (!kernel) return;
|
|
708
33
|
const itemCount = kernel.getItemCount();
|
|
709
34
|
columnHeights = new Array(columnCount).fill(0);
|
|
35
|
+
const itemsInColumn = new Array(columnCount).fill(0);
|
|
710
36
|
layoutCache.clear();
|
|
711
37
|
for (let i = 0; i < itemCount; i++) {
|
|
712
38
|
let shortestCol = 0;
|
|
@@ -715,15 +41,15 @@ function masonryRenderer(options) {
|
|
|
715
41
|
shortestCol = j;
|
|
716
42
|
}
|
|
717
43
|
}
|
|
718
|
-
const
|
|
44
|
+
const measured = getItemHeight(i, columnWidth);
|
|
45
|
+
const itemHeight = Number.isFinite(measured) && measured > 0 ? measured : 0;
|
|
719
46
|
const top = columnHeights[shortestCol] ?? 0;
|
|
720
47
|
layoutCache.set(i, { top, lane: shortestCol, height: itemHeight });
|
|
721
48
|
columnHeights[shortestCol] = top + itemHeight + gap;
|
|
49
|
+
itemsInColumn[shortestCol] = (itemsInColumn[shortestCol] ?? 0) + 1;
|
|
722
50
|
}
|
|
51
|
+
columnHeights = columnHeights.map((height, column) => (itemsInColumn[column] ?? 0) > 0 ? height - gap : 0);
|
|
723
52
|
totalHeight = Math.max(...columnHeights, 0);
|
|
724
|
-
if (totalHeight > 0) {
|
|
725
|
-
totalHeight -= gap;
|
|
726
|
-
}
|
|
727
53
|
}
|
|
728
54
|
function buildVirtualItems() {
|
|
729
55
|
if (!kernel) return [];
|
|
@@ -810,6 +136,8 @@ function masonryRenderer(options) {
|
|
|
810
136
|
uninstall() {
|
|
811
137
|
virtualItems = [];
|
|
812
138
|
layoutCache.clear();
|
|
139
|
+
columnHeights = [];
|
|
140
|
+
totalHeight = 0;
|
|
813
141
|
kernel = null;
|
|
814
142
|
},
|
|
815
143
|
hooks: {
|
|
@@ -826,10 +154,8 @@ function masonryRenderer(options) {
|
|
|
826
154
|
// src/plugins/optional/sticky-headers.ts
|
|
827
155
|
function stickyHeaders(options) {
|
|
828
156
|
const {
|
|
829
|
-
headerHeight,
|
|
830
157
|
isHeader,
|
|
831
158
|
getGroupId,
|
|
832
|
-
zIndex = 10,
|
|
833
159
|
stickyOffset = 0
|
|
834
160
|
} = options;
|
|
835
161
|
let kernel = null;
|
|
@@ -854,12 +180,15 @@ function stickyHeaders(options) {
|
|
|
854
180
|
}
|
|
855
181
|
}
|
|
856
182
|
}
|
|
857
|
-
function
|
|
183
|
+
function offsetOf(position) {
|
|
184
|
+
return kernel?.getOptions().direction === "horizontal" ? position.scrollLeft : position.scrollTop;
|
|
185
|
+
}
|
|
186
|
+
function updateStickyHeader(scrollOffset) {
|
|
858
187
|
if (!kernel || headerIndices.length === 0) {
|
|
859
188
|
currentStickyHeader = null;
|
|
860
189
|
return;
|
|
861
190
|
}
|
|
862
|
-
const scrollTop =
|
|
191
|
+
const scrollTop = scrollOffset + stickyOffset;
|
|
863
192
|
let newStickyHeader = null;
|
|
864
193
|
for (const headerIndex of headerIndices) {
|
|
865
194
|
const headerOffset = kernel.getItemOffset(headerIndex);
|
|
@@ -871,6 +200,10 @@ function stickyHeaders(options) {
|
|
|
871
200
|
}
|
|
872
201
|
currentStickyHeader = newStickyHeader;
|
|
873
202
|
}
|
|
203
|
+
function refreshStickyHeader() {
|
|
204
|
+
if (!kernel) return;
|
|
205
|
+
updateStickyHeader(offsetOf(kernel.getScrollPosition()));
|
|
206
|
+
}
|
|
874
207
|
function findHeaderForGroup(groupId) {
|
|
875
208
|
const items = groupIdMap.get(groupId);
|
|
876
209
|
if (!items || items.length === 0) return null;
|
|
@@ -911,6 +244,7 @@ function stickyHeaders(options) {
|
|
|
911
244
|
install(k) {
|
|
912
245
|
kernel = k;
|
|
913
246
|
buildHeaderCache();
|
|
247
|
+
refreshStickyHeader();
|
|
914
248
|
},
|
|
915
249
|
uninstall() {
|
|
916
250
|
headerIndices = [];
|
|
@@ -919,14 +253,24 @@ function stickyHeaders(options) {
|
|
|
919
253
|
kernel = null;
|
|
920
254
|
},
|
|
921
255
|
hooks: {
|
|
922
|
-
onScroll: updateStickyHeader,
|
|
923
|
-
onItemsChange: () =>
|
|
256
|
+
onScroll: (event) => updateStickyHeader(offsetOf(event)),
|
|
257
|
+
onItemsChange: () => {
|
|
258
|
+
buildHeaderCache();
|
|
259
|
+
refreshStickyHeader();
|
|
260
|
+
}
|
|
924
261
|
},
|
|
925
262
|
api
|
|
926
263
|
};
|
|
927
264
|
}
|
|
928
265
|
|
|
929
266
|
// src/plugins/optional/keyboard-nav.ts
|
|
267
|
+
var focusByKernel = /* @__PURE__ */ new WeakMap();
|
|
268
|
+
function isEditableTarget(target) {
|
|
269
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
270
|
+
if (target.isContentEditable) return true;
|
|
271
|
+
const tag = target.tagName;
|
|
272
|
+
return tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT";
|
|
273
|
+
}
|
|
930
274
|
function keyboardNav(options = {}) {
|
|
931
275
|
const {
|
|
932
276
|
enabled: initialEnabled = true,
|
|
@@ -946,6 +290,9 @@ function keyboardNav(options = {}) {
|
|
|
946
290
|
let focusedIndex = null;
|
|
947
291
|
let typeaheadBuffer = "";
|
|
948
292
|
let typeaheadTimer = null;
|
|
293
|
+
function rememberFocus() {
|
|
294
|
+
if (kernel) focusByKernel.set(kernel, focusedIndex);
|
|
295
|
+
}
|
|
949
296
|
function getItemCount() {
|
|
950
297
|
return kernel?.getItemCount() ?? 0;
|
|
951
298
|
}
|
|
@@ -954,18 +301,39 @@ function keyboardNav(options = {}) {
|
|
|
954
301
|
if (count === 0) return 0;
|
|
955
302
|
return Math.max(0, Math.min(index, count - 1));
|
|
956
303
|
}
|
|
957
|
-
function
|
|
304
|
+
function revealIndex(index) {
|
|
305
|
+
if (!kernel) return;
|
|
306
|
+
if (orientation !== "grid" || columns <= 1) {
|
|
307
|
+
kernel.scrollToIndex(index, { align: "auto" });
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const rows = Math.ceil(getItemCount() / columns);
|
|
311
|
+
if (rows === 0) return;
|
|
312
|
+
const pitch = kernel.getTotalSize() / rows;
|
|
313
|
+
const top = Math.floor(index / columns) * pitch;
|
|
314
|
+
const bottom = top + pitch;
|
|
315
|
+
const viewportHeight = kernel.getViewport().height;
|
|
316
|
+
const scrollTop = kernel.getScrollPosition().scrollTop;
|
|
317
|
+
if (top < scrollTop) {
|
|
318
|
+
kernel.scrollTo(top);
|
|
319
|
+
} else if (bottom > scrollTop + viewportHeight) {
|
|
320
|
+
kernel.scrollTo(bottom - viewportHeight);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function setFocus(index, wrap = true) {
|
|
958
324
|
if (index === null) {
|
|
959
325
|
focusedIndex = null;
|
|
326
|
+
rememberFocus();
|
|
960
327
|
return;
|
|
961
328
|
}
|
|
962
329
|
const count = getItemCount();
|
|
963
330
|
if (count === 0) {
|
|
964
331
|
focusedIndex = null;
|
|
332
|
+
rememberFocus();
|
|
965
333
|
return;
|
|
966
334
|
}
|
|
967
335
|
let newIndex = index;
|
|
968
|
-
if (loop) {
|
|
336
|
+
if (loop && wrap) {
|
|
969
337
|
if (newIndex < 0) {
|
|
970
338
|
newIndex = count - 1;
|
|
971
339
|
} else if (newIndex >= count) {
|
|
@@ -976,12 +344,14 @@ function keyboardNav(options = {}) {
|
|
|
976
344
|
}
|
|
977
345
|
if (newIndex !== focusedIndex) {
|
|
978
346
|
focusedIndex = newIndex;
|
|
347
|
+
rememberFocus();
|
|
979
348
|
onFocus?.(newIndex);
|
|
980
|
-
|
|
349
|
+
revealIndex(newIndex);
|
|
981
350
|
}
|
|
982
351
|
}
|
|
983
352
|
function handleKeyDown(event) {
|
|
984
353
|
if (!enabled || !kernel) return;
|
|
354
|
+
if (isEditableTarget(event.target)) return;
|
|
985
355
|
if (onKeyDown) {
|
|
986
356
|
const handled = onKeyDown(event, focusedIndex);
|
|
987
357
|
if (handled === true) {
|
|
@@ -989,19 +359,18 @@ function keyboardNav(options = {}) {
|
|
|
989
359
|
return;
|
|
990
360
|
}
|
|
991
361
|
}
|
|
362
|
+
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
992
363
|
const count = getItemCount();
|
|
993
364
|
if (count === 0) return;
|
|
994
|
-
|
|
995
|
-
setFocus(0);
|
|
996
|
-
}
|
|
365
|
+
const focusBeforeKey = focusedIndex;
|
|
997
366
|
switch (event.key) {
|
|
998
367
|
case "ArrowDown":
|
|
999
368
|
if (orientation === "vertical" || orientation === "grid") {
|
|
1000
369
|
event.preventDefault();
|
|
1001
|
-
if (
|
|
1002
|
-
setFocus(
|
|
370
|
+
if (focusedIndex === null) {
|
|
371
|
+
setFocus(0);
|
|
1003
372
|
} else {
|
|
1004
|
-
setFocus(
|
|
373
|
+
setFocus(focusedIndex + (orientation === "grid" ? columns : 1));
|
|
1005
374
|
}
|
|
1006
375
|
}
|
|
1007
376
|
break;
|
|
@@ -1018,7 +387,7 @@ function keyboardNav(options = {}) {
|
|
|
1018
387
|
case "ArrowRight":
|
|
1019
388
|
if (orientation === "horizontal" || orientation === "grid") {
|
|
1020
389
|
event.preventDefault();
|
|
1021
|
-
setFocus(
|
|
390
|
+
setFocus(focusedIndex === null ? 0 : focusedIndex + 1);
|
|
1022
391
|
}
|
|
1023
392
|
break;
|
|
1024
393
|
case "ArrowLeft":
|
|
@@ -1037,35 +406,35 @@ function keyboardNav(options = {}) {
|
|
|
1037
406
|
break;
|
|
1038
407
|
case "PageUp":
|
|
1039
408
|
event.preventDefault();
|
|
1040
|
-
setFocus((focusedIndex ?? 0) - pageSize);
|
|
409
|
+
setFocus((focusedIndex ?? 0) - pageSize, false);
|
|
1041
410
|
break;
|
|
1042
411
|
case "PageDown":
|
|
1043
412
|
event.preventDefault();
|
|
1044
|
-
setFocus((focusedIndex ?? 0) + pageSize);
|
|
413
|
+
setFocus((focusedIndex ?? 0) + pageSize, false);
|
|
1045
414
|
break;
|
|
1046
415
|
case "Enter":
|
|
1047
416
|
case " ":
|
|
1048
|
-
event.preventDefault();
|
|
1049
417
|
if (focusedIndex !== null) {
|
|
418
|
+
event.preventDefault();
|
|
1050
419
|
onSelect?.(focusedIndex);
|
|
1051
420
|
}
|
|
1052
421
|
break;
|
|
1053
422
|
default:
|
|
1054
423
|
if (typeahead && event.key.length === 1 && !event.ctrlKey && !event.metaKey) {
|
|
1055
424
|
event.preventDefault();
|
|
1056
|
-
handleTypeahead(event.key);
|
|
425
|
+
handleTypeahead(event.key, focusBeforeKey);
|
|
1057
426
|
}
|
|
1058
427
|
break;
|
|
1059
428
|
}
|
|
1060
429
|
}
|
|
1061
|
-
function handleTypeahead(char) {
|
|
430
|
+
function handleTypeahead(char, focusBeforeKey) {
|
|
1062
431
|
if (!kernel) return;
|
|
1063
432
|
if (typeaheadTimer) {
|
|
1064
433
|
clearTimeout(typeaheadTimer);
|
|
1065
434
|
}
|
|
1066
435
|
typeaheadBuffer += char.toLowerCase();
|
|
1067
436
|
const count = getItemCount();
|
|
1068
|
-
const startIndex = focusedIndex !== null ?
|
|
437
|
+
const startIndex = typeaheadBuffer.length > 1 ? focusedIndex ?? 0 : focusBeforeKey !== null ? focusBeforeKey + 1 : 0;
|
|
1069
438
|
for (let i = 0; i < count; i++) {
|
|
1070
439
|
const index = (startIndex + i) % count;
|
|
1071
440
|
const text = getItemText(index).toLowerCase();
|
|
@@ -1134,6 +503,9 @@ function keyboardNav(options = {}) {
|
|
|
1134
503
|
type: "optional",
|
|
1135
504
|
install(k) {
|
|
1136
505
|
kernel = k;
|
|
506
|
+
const remembered = focusByKernel.get(k) ?? null;
|
|
507
|
+
const count = k.getItemCount();
|
|
508
|
+
focusedIndex = remembered === null || count === 0 ? null : Math.min(remembered, count - 1);
|
|
1137
509
|
document.addEventListener("keydown", handleKeyDown);
|
|
1138
510
|
},
|
|
1139
511
|
uninstall() {
|
|
@@ -1160,6 +532,7 @@ function keyboardNav(options = {}) {
|
|
|
1160
532
|
}
|
|
1161
533
|
|
|
1162
534
|
// src/plugins/optional/scroll-restoration.ts
|
|
535
|
+
var restoredKernels = /* @__PURE__ */ new WeakMap();
|
|
1163
536
|
function scrollRestoration(options) {
|
|
1164
537
|
const {
|
|
1165
538
|
key,
|
|
@@ -1173,6 +546,8 @@ function scrollRestoration(options) {
|
|
|
1173
546
|
} = options;
|
|
1174
547
|
let kernel = null;
|
|
1175
548
|
let debouncedSave = null;
|
|
549
|
+
let restoreFrame = null;
|
|
550
|
+
let awaitingContent = false;
|
|
1176
551
|
function getStorage() {
|
|
1177
552
|
if (typeof storage === "string") {
|
|
1178
553
|
if (storage === "sessionStorage") {
|
|
@@ -1229,7 +604,7 @@ function scrollRestoration(options) {
|
|
|
1229
604
|
if (!kernel) return false;
|
|
1230
605
|
const state = getSavedState();
|
|
1231
606
|
if (!state) return false;
|
|
1232
|
-
kernel.scrollTo(state.scrollTop);
|
|
607
|
+
kernel.scrollTo(kernel.getOptions().direction === "horizontal" ? state.scrollLeft : state.scrollTop);
|
|
1233
608
|
if (includeIndex && state.focusedIndex !== void 0) {
|
|
1234
609
|
const keyboardNav2 = kernel.getPlugin("keyboard-nav");
|
|
1235
610
|
if (keyboardNav2?.api?.setFocusedIndex) {
|
|
@@ -1238,6 +613,26 @@ function scrollRestoration(options) {
|
|
|
1238
613
|
}
|
|
1239
614
|
return true;
|
|
1240
615
|
}
|
|
616
|
+
function restoreOnceReachable() {
|
|
617
|
+
if (!kernel || restoredKernels.get(kernel) === key) {
|
|
618
|
+
awaitingContent = false;
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
const state = getSavedState();
|
|
622
|
+
if (state) {
|
|
623
|
+
const horizontal = kernel.getOptions().direction === "horizontal";
|
|
624
|
+
const viewport = kernel.getViewport();
|
|
625
|
+
const target = horizontal ? state.scrollLeft : state.scrollTop;
|
|
626
|
+
const maxScroll = kernel.getTotalSize() - (horizontal ? viewport.width : viewport.height);
|
|
627
|
+
if (target > maxScroll + 1) {
|
|
628
|
+
awaitingContent = true;
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
awaitingContent = false;
|
|
633
|
+
restoredKernels.set(kernel, key);
|
|
634
|
+
restore();
|
|
635
|
+
}
|
|
1241
636
|
function clear() {
|
|
1242
637
|
try {
|
|
1243
638
|
getStorage().removeItem(getStorageKey());
|
|
@@ -1246,6 +641,10 @@ function scrollRestoration(options) {
|
|
|
1246
641
|
}
|
|
1247
642
|
}
|
|
1248
643
|
function handleScroll(_event) {
|
|
644
|
+
if (awaitingContent && kernel) {
|
|
645
|
+
awaitingContent = false;
|
|
646
|
+
restoredKernels.set(kernel, key);
|
|
647
|
+
}
|
|
1249
648
|
if (saveOnScroll && debouncedSave) {
|
|
1250
649
|
debouncedSave();
|
|
1251
650
|
}
|
|
@@ -1268,32 +667,43 @@ function scrollRestoration(options) {
|
|
|
1268
667
|
install(k) {
|
|
1269
668
|
kernel = k;
|
|
1270
669
|
if (saveOnScroll) {
|
|
1271
|
-
debouncedSave = debounce(save, debounceMs);
|
|
670
|
+
debouncedSave = chunkND5PV5MU_cjs.debounce(save, debounceMs);
|
|
1272
671
|
}
|
|
1273
|
-
if (restoreOnMount) {
|
|
1274
|
-
requestAnimationFrame(() => {
|
|
1275
|
-
|
|
672
|
+
if (restoreOnMount && restoredKernels.get(k) !== key) {
|
|
673
|
+
restoreFrame = requestAnimationFrame(() => {
|
|
674
|
+
restoreFrame = null;
|
|
675
|
+
restoreOnceReachable();
|
|
1276
676
|
});
|
|
1277
677
|
}
|
|
1278
678
|
},
|
|
1279
679
|
uninstall() {
|
|
1280
|
-
|
|
680
|
+
const restorePending = restoreFrame !== null;
|
|
681
|
+
if (restoreFrame !== null) {
|
|
682
|
+
cancelAnimationFrame(restoreFrame);
|
|
683
|
+
restoreFrame = null;
|
|
684
|
+
}
|
|
685
|
+
if (saveOnUnmount && !restorePending && !awaitingContent) {
|
|
1281
686
|
save();
|
|
1282
687
|
}
|
|
1283
688
|
if (debouncedSave) {
|
|
1284
689
|
debouncedSave.cancel();
|
|
1285
690
|
debouncedSave = null;
|
|
1286
691
|
}
|
|
692
|
+
awaitingContent = false;
|
|
1287
693
|
kernel = null;
|
|
1288
694
|
},
|
|
1289
695
|
hooks: {
|
|
1290
|
-
onScroll: handleScroll
|
|
696
|
+
onScroll: handleScroll,
|
|
697
|
+
onItemsChange: () => {
|
|
698
|
+
if (awaitingContent) restoreOnceReachable();
|
|
699
|
+
}
|
|
1291
700
|
},
|
|
1292
701
|
api
|
|
1293
702
|
};
|
|
1294
703
|
}
|
|
1295
704
|
|
|
1296
705
|
// src/plugins/optional/bidirectional.ts
|
|
706
|
+
var positionedKernels = /* @__PURE__ */ new WeakSet();
|
|
1297
707
|
function bidirectional(options = {}) {
|
|
1298
708
|
const {
|
|
1299
709
|
initialPosition = "bottom",
|
|
@@ -1308,18 +718,25 @@ function bidirectional(options = {}) {
|
|
|
1308
718
|
let isSticking = initialStickToBottom;
|
|
1309
719
|
let previousTotalSize = 0;
|
|
1310
720
|
let isInitialized = false;
|
|
721
|
+
let initialFrame = null;
|
|
722
|
+
let backwardTriggered = false;
|
|
723
|
+
let forwardTriggered = false;
|
|
724
|
+
function isHorizontal() {
|
|
725
|
+
return kernel?.getOptions().direction === "horizontal";
|
|
726
|
+
}
|
|
727
|
+
function getOffset(position) {
|
|
728
|
+
return isHorizontal() ? position.scrollLeft : position.scrollTop;
|
|
729
|
+
}
|
|
1311
730
|
function checkIsAtBottom() {
|
|
1312
731
|
if (!kernel) return false;
|
|
1313
732
|
const viewport = kernel.getViewport();
|
|
1314
|
-
const scrollPosition = kernel.getScrollPosition();
|
|
1315
733
|
const totalSize = kernel.getTotalSize();
|
|
1316
|
-
const maxScroll = totalSize - viewport.height;
|
|
1317
|
-
return
|
|
734
|
+
const maxScroll = totalSize - (isHorizontal() ? viewport.width : viewport.height);
|
|
735
|
+
return getOffset(kernel.getScrollPosition()) >= maxScroll - stickThreshold;
|
|
1318
736
|
}
|
|
1319
737
|
function checkIsAtTop() {
|
|
1320
738
|
if (!kernel) return false;
|
|
1321
|
-
|
|
1322
|
-
return scrollPosition.scrollTop <= stickThreshold;
|
|
739
|
+
return getOffset(kernel.getScrollPosition()) <= stickThreshold;
|
|
1323
740
|
}
|
|
1324
741
|
function handleScroll(event) {
|
|
1325
742
|
if (!kernel) return;
|
|
@@ -1329,16 +746,30 @@ function bidirectional(options = {}) {
|
|
|
1329
746
|
if (onLoadMore) {
|
|
1330
747
|
const viewport = kernel.getViewport();
|
|
1331
748
|
const totalSize = kernel.getTotalSize();
|
|
1332
|
-
|
|
1333
|
-
|
|
749
|
+
const offset = getOffset(event);
|
|
750
|
+
const viewportSize = isHorizontal() ? viewport.width : viewport.height;
|
|
751
|
+
if (offset < loadMoreThreshold) {
|
|
752
|
+
if (!backwardTriggered) {
|
|
753
|
+
backwardTriggered = true;
|
|
754
|
+
onLoadMore("backward");
|
|
755
|
+
}
|
|
756
|
+
} else {
|
|
757
|
+
backwardTriggered = false;
|
|
1334
758
|
}
|
|
1335
|
-
const distanceFromBottom = totalSize -
|
|
759
|
+
const distanceFromBottom = totalSize - offset - viewportSize;
|
|
1336
760
|
if (distanceFromBottom < loadMoreThreshold) {
|
|
1337
|
-
|
|
761
|
+
if (!forwardTriggered) {
|
|
762
|
+
forwardTriggered = true;
|
|
763
|
+
onLoadMore("forward");
|
|
764
|
+
}
|
|
765
|
+
} else {
|
|
766
|
+
forwardTriggered = false;
|
|
1338
767
|
}
|
|
1339
768
|
}
|
|
1340
769
|
}
|
|
1341
770
|
function handleItemsChange(count, previousCount) {
|
|
771
|
+
backwardTriggered = false;
|
|
772
|
+
forwardTriggered = false;
|
|
1342
773
|
if (!kernel || !isInitialized) return;
|
|
1343
774
|
const newTotalSize = kernel.getTotalSize();
|
|
1344
775
|
const sizeDelta = newTotalSize - previousTotalSize;
|
|
@@ -1348,8 +779,9 @@ function bidirectional(options = {}) {
|
|
|
1348
779
|
if (scrollPosition.scrollTop > stickThreshold) ;
|
|
1349
780
|
}
|
|
1350
781
|
if (isSticking && stickToBottom) {
|
|
782
|
+
const k = kernel;
|
|
1351
783
|
requestAnimationFrame(() => {
|
|
1352
|
-
|
|
784
|
+
k.scrollTo(k.getTotalSize());
|
|
1353
785
|
});
|
|
1354
786
|
}
|
|
1355
787
|
}
|
|
@@ -1381,9 +813,10 @@ function bidirectional(options = {}) {
|
|
|
1381
813
|
adjustForPrepend(prependedHeight) {
|
|
1382
814
|
if (!kernel || prependedHeight <= 0) return;
|
|
1383
815
|
const scrollPosition = kernel.getScrollPosition();
|
|
816
|
+
const horizontal = isHorizontal();
|
|
1384
817
|
kernel.setScrollPosition({
|
|
1385
|
-
scrollTop: scrollPosition.scrollTop + prependedHeight,
|
|
1386
|
-
scrollLeft: scrollPosition.scrollLeft
|
|
818
|
+
scrollTop: scrollPosition.scrollTop + (horizontal ? 0 : prependedHeight),
|
|
819
|
+
scrollLeft: scrollPosition.scrollLeft + (horizontal ? prependedHeight : 0)
|
|
1387
820
|
});
|
|
1388
821
|
}
|
|
1389
822
|
};
|
|
@@ -1393,12 +826,16 @@ function bidirectional(options = {}) {
|
|
|
1393
826
|
type: "optional",
|
|
1394
827
|
install(k) {
|
|
1395
828
|
kernel = k;
|
|
1396
|
-
k.getItemCount();
|
|
1397
829
|
previousTotalSize = k.getTotalSize();
|
|
1398
|
-
|
|
1399
|
-
|
|
830
|
+
isSticking = stickToBottom && (initialPosition === "bottom" && !positionedKernels.has(k) || checkIsAtBottom());
|
|
831
|
+
if (initialPosition === "bottom" && !positionedKernels.has(k)) {
|
|
832
|
+
initialFrame = requestAnimationFrame(() => {
|
|
833
|
+
initialFrame = null;
|
|
1400
834
|
if (kernel) {
|
|
1401
|
-
|
|
835
|
+
if (!positionedKernels.has(kernel)) {
|
|
836
|
+
positionedKernels.add(kernel);
|
|
837
|
+
kernel.scrollTo(kernel.getTotalSize());
|
|
838
|
+
}
|
|
1402
839
|
isInitialized = true;
|
|
1403
840
|
}
|
|
1404
841
|
});
|
|
@@ -1407,8 +844,14 @@ function bidirectional(options = {}) {
|
|
|
1407
844
|
}
|
|
1408
845
|
},
|
|
1409
846
|
uninstall() {
|
|
847
|
+
if (initialFrame !== null) {
|
|
848
|
+
cancelAnimationFrame(initialFrame);
|
|
849
|
+
initialFrame = null;
|
|
850
|
+
}
|
|
1410
851
|
kernel = null;
|
|
1411
852
|
isInitialized = false;
|
|
853
|
+
backwardTriggered = false;
|
|
854
|
+
forwardTriggered = false;
|
|
1412
855
|
},
|
|
1413
856
|
hooks: {
|
|
1414
857
|
onScroll: handleScroll,
|
|
@@ -1419,14 +862,12 @@ function bidirectional(options = {}) {
|
|
|
1419
862
|
}
|
|
1420
863
|
|
|
1421
864
|
// src/plugins/optional/drag-to-reorder.ts
|
|
865
|
+
var dragByKernel = /* @__PURE__ */ new WeakMap();
|
|
1422
866
|
function dragToReorder(options) {
|
|
1423
867
|
const {
|
|
1424
868
|
enabled: initialEnabled = true,
|
|
1425
869
|
axis = "vertical",
|
|
1426
|
-
handle = true,
|
|
1427
870
|
autoScroll = true,
|
|
1428
|
-
autoScrollSpeed = 10,
|
|
1429
|
-
dropIndicator = "line",
|
|
1430
871
|
onDragStart,
|
|
1431
872
|
onDragEnd,
|
|
1432
873
|
onReorder,
|
|
@@ -1438,6 +879,9 @@ function dragToReorder(options) {
|
|
|
1438
879
|
let draggedIndex = null;
|
|
1439
880
|
let dropTargetIndex = null;
|
|
1440
881
|
let autoScrollTimer = null;
|
|
882
|
+
function rememberDrag() {
|
|
883
|
+
if (kernel) dragByKernel.set(kernel, { dragged: draggedIndex, target: dropTargetIndex });
|
|
884
|
+
}
|
|
1441
885
|
function handleDragStart(event, index) {
|
|
1442
886
|
if (!enabled || !canDrag(index)) {
|
|
1443
887
|
event.preventDefault();
|
|
@@ -1445,6 +889,7 @@ function dragToReorder(options) {
|
|
|
1445
889
|
}
|
|
1446
890
|
draggedIndex = index;
|
|
1447
891
|
dropTargetIndex = index;
|
|
892
|
+
rememberDrag();
|
|
1448
893
|
event.dataTransfer?.setData("text/plain", String(index));
|
|
1449
894
|
if (event.dataTransfer) {
|
|
1450
895
|
event.dataTransfer.effectAllowed = "move";
|
|
@@ -1454,27 +899,22 @@ function dragToReorder(options) {
|
|
|
1454
899
|
startAutoScroll();
|
|
1455
900
|
}
|
|
1456
901
|
}
|
|
1457
|
-
function
|
|
902
|
+
function finishDrag() {
|
|
1458
903
|
const currentDraggedIndex = draggedIndex;
|
|
1459
|
-
const currentDropTargetIndex = dropTargetIndex;
|
|
1460
904
|
stopAutoScroll();
|
|
1461
|
-
if (currentDraggedIndex !== null && currentDropTargetIndex !== null && currentDraggedIndex !== currentDropTargetIndex) {
|
|
1462
|
-
if (canDrop(currentDraggedIndex, currentDropTargetIndex)) {
|
|
1463
|
-
onReorder(currentDraggedIndex, currentDropTargetIndex);
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
905
|
if (currentDraggedIndex !== null) {
|
|
1467
906
|
onDragEnd?.(currentDraggedIndex);
|
|
1468
907
|
}
|
|
1469
908
|
draggedIndex = null;
|
|
1470
909
|
dropTargetIndex = null;
|
|
910
|
+
rememberDrag();
|
|
911
|
+
}
|
|
912
|
+
function handleDragEnd(_event) {
|
|
913
|
+
finishDrag();
|
|
1471
914
|
}
|
|
1472
915
|
function handleDragOver(event, index) {
|
|
1473
916
|
if (draggedIndex === null) return;
|
|
1474
917
|
event.preventDefault();
|
|
1475
|
-
if (event.dataTransfer) {
|
|
1476
|
-
event.dataTransfer.dropEffect = canDrop(draggedIndex, index) ? "move" : "none";
|
|
1477
|
-
}
|
|
1478
918
|
const target = event.currentTarget;
|
|
1479
919
|
const rect = target.getBoundingClientRect();
|
|
1480
920
|
let newDropTarget;
|
|
@@ -1489,6 +929,10 @@ function dragToReorder(options) {
|
|
|
1489
929
|
newDropTarget--;
|
|
1490
930
|
}
|
|
1491
931
|
dropTargetIndex = Math.max(0, Math.min(newDropTarget, (kernel?.getItemCount() ?? 1) - 1));
|
|
932
|
+
rememberDrag();
|
|
933
|
+
if (event.dataTransfer) {
|
|
934
|
+
event.dataTransfer.dropEffect = canDrop(draggedIndex, dropTargetIndex) ? "move" : "none";
|
|
935
|
+
}
|
|
1492
936
|
}
|
|
1493
937
|
function handleDragEnter(event, _index) {
|
|
1494
938
|
event.preventDefault();
|
|
@@ -1497,6 +941,14 @@ function dragToReorder(options) {
|
|
|
1497
941
|
}
|
|
1498
942
|
function handleDrop(event, _index) {
|
|
1499
943
|
event.preventDefault();
|
|
944
|
+
const currentDraggedIndex = draggedIndex;
|
|
945
|
+
const currentDropTargetIndex = dropTargetIndex;
|
|
946
|
+
if (currentDraggedIndex !== null && currentDropTargetIndex !== null && currentDraggedIndex !== currentDropTargetIndex) {
|
|
947
|
+
if (canDrop(currentDraggedIndex, currentDropTargetIndex)) {
|
|
948
|
+
onReorder(currentDraggedIndex, currentDropTargetIndex);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
finishDrag();
|
|
1500
952
|
}
|
|
1501
953
|
function startAutoScroll() {
|
|
1502
954
|
if (autoScrollTimer) return;
|
|
@@ -1540,6 +992,7 @@ function dragToReorder(options) {
|
|
|
1540
992
|
stopAutoScroll();
|
|
1541
993
|
draggedIndex = null;
|
|
1542
994
|
dropTargetIndex = null;
|
|
995
|
+
rememberDrag();
|
|
1543
996
|
},
|
|
1544
997
|
enable() {
|
|
1545
998
|
enabled = true;
|
|
@@ -1559,6 +1012,14 @@ function dragToReorder(options) {
|
|
|
1559
1012
|
type: "optional",
|
|
1560
1013
|
install(k) {
|
|
1561
1014
|
kernel = k;
|
|
1015
|
+
const previous = dragByKernel.get(k);
|
|
1016
|
+
if (previous && previous.dragged !== null && enabled) {
|
|
1017
|
+
draggedIndex = previous.dragged;
|
|
1018
|
+
dropTargetIndex = previous.target;
|
|
1019
|
+
if (autoScroll) startAutoScroll();
|
|
1020
|
+
} else if (previous) {
|
|
1021
|
+
rememberDrag();
|
|
1022
|
+
}
|
|
1562
1023
|
},
|
|
1563
1024
|
uninstall() {
|
|
1564
1025
|
stopAutoScroll();
|
|
@@ -1592,6 +1053,7 @@ function debugPanel(options = {}) {
|
|
|
1592
1053
|
let lastFpsUpdate = performance.now();
|
|
1593
1054
|
let currentFps = 60;
|
|
1594
1055
|
let rafId = null;
|
|
1056
|
+
let eventUnsubscribers = [];
|
|
1595
1057
|
const emptyRange = {
|
|
1596
1058
|
startIndex: 0,
|
|
1597
1059
|
endIndex: 0,
|
|
@@ -1662,8 +1124,13 @@ function debugPanel(options = {}) {
|
|
|
1662
1124
|
memoryUsage = Math.round(memory.usedJSHeapSize / 1024 / 1024 * 100) / 100;
|
|
1663
1125
|
}
|
|
1664
1126
|
}
|
|
1665
|
-
const
|
|
1666
|
-
const
|
|
1127
|
+
const countOf = (range) => itemCount === 0 ? 0 : (range.end ?? range.endIndex) - (range.start ?? range.startIndex) + 1;
|
|
1128
|
+
const visibleItems = countOf(visibleRange);
|
|
1129
|
+
const renderedItems = countOf(renderRange);
|
|
1130
|
+
const horizontal = kernel.getOptions().direction === "horizontal";
|
|
1131
|
+
const viewport = kernel.getViewport();
|
|
1132
|
+
const scrollOffset = horizontal ? scrollPos.scrollLeft : scrollPos.scrollTop;
|
|
1133
|
+
const maxScroll = kernel.getTotalSize() - (horizontal ? viewport.width : viewport.height);
|
|
1667
1134
|
state.stats = {
|
|
1668
1135
|
...state.stats,
|
|
1669
1136
|
memoryUsage,
|
|
@@ -1674,8 +1141,8 @@ function debugPanel(options = {}) {
|
|
|
1674
1141
|
avgItemHeight: itemCount > 0 ? kernel.getTotalSize() / itemCount : 0,
|
|
1675
1142
|
scrollPosition: {
|
|
1676
1143
|
...scrollPos,
|
|
1677
|
-
offset:
|
|
1678
|
-
percentage:
|
|
1144
|
+
offset: scrollOffset,
|
|
1145
|
+
percentage: maxScroll > 0 ? Math.min(1, Math.max(0, scrollOffset / maxScroll)) : 0
|
|
1679
1146
|
},
|
|
1680
1147
|
visibleRange: {
|
|
1681
1148
|
...visibleRange,
|
|
@@ -1711,6 +1178,10 @@ function debugPanel(options = {}) {
|
|
|
1711
1178
|
}
|
|
1712
1179
|
function startMonitoring() {
|
|
1713
1180
|
if (rafId !== null) return;
|
|
1181
|
+
const now = performance.now();
|
|
1182
|
+
frameCount = 0;
|
|
1183
|
+
lastFpsUpdate = now;
|
|
1184
|
+
lastFrameTime = now;
|
|
1714
1185
|
updateFps();
|
|
1715
1186
|
statsUpdateTimer = setInterval(updateStats, resolvedOptions.statsUpdateInterval);
|
|
1716
1187
|
}
|
|
@@ -1808,23 +1279,24 @@ function debugPanel(options = {}) {
|
|
|
1808
1279
|
kernel = k;
|
|
1809
1280
|
const eventTypes = [
|
|
1810
1281
|
"scroll",
|
|
1811
|
-
"
|
|
1812
|
-
"
|
|
1813
|
-
"
|
|
1814
|
-
"
|
|
1282
|
+
"scroll-start",
|
|
1283
|
+
"scroll-end",
|
|
1284
|
+
"visible-range-change",
|
|
1285
|
+
"item-measured",
|
|
1815
1286
|
"resize",
|
|
1816
|
-
"
|
|
1817
|
-
"
|
|
1287
|
+
"load-more",
|
|
1288
|
+
"items-change"
|
|
1818
1289
|
];
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
});
|
|
1290
|
+
eventUnsubscribers.forEach((unsubscribe) => unsubscribe());
|
|
1291
|
+
eventUnsubscribers = eventTypes.map((type) => k.on(type, logEvent));
|
|
1822
1292
|
if (state.visible) {
|
|
1823
1293
|
startMonitoring();
|
|
1824
1294
|
}
|
|
1825
1295
|
},
|
|
1826
1296
|
uninstall() {
|
|
1827
1297
|
stopMonitoring();
|
|
1298
|
+
eventUnsubscribers.forEach((unsubscribe) => unsubscribe());
|
|
1299
|
+
eventUnsubscribers = [];
|
|
1828
1300
|
kernel = null;
|
|
1829
1301
|
},
|
|
1830
1302
|
api: extendedApi
|
|
@@ -1834,6 +1306,7 @@ function useDebugPanelState(plugin) {
|
|
|
1834
1306
|
const api = plugin.api;
|
|
1835
1307
|
const [state, setState] = react.useState(api.getState());
|
|
1836
1308
|
react.useEffect(() => {
|
|
1309
|
+
setState({ ...api.getState() });
|
|
1837
1310
|
return api.subscribe(() => {
|
|
1838
1311
|
setState({ ...api.getState() });
|
|
1839
1312
|
});
|
|
@@ -1868,7 +1341,8 @@ function DebugPanelOverlay({
|
|
|
1868
1341
|
}
|
|
1869
1342
|
}, [options.position]);
|
|
1870
1343
|
const themeStyles = react.useMemo(() => {
|
|
1871
|
-
const
|
|
1344
|
+
const prefersDark = typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
1345
|
+
const isDark = options.theme === "dark" || options.theme === "auto" && prefersDark;
|
|
1872
1346
|
return isDark ? {
|
|
1873
1347
|
backgroundColor: "rgba(30, 30, 30, 0.95)",
|
|
1874
1348
|
color: "#e0e0e0",
|
|
@@ -2161,13 +1635,13 @@ function EventsPanel({ eventLog, onClear }) {
|
|
|
2161
1635
|
};
|
|
2162
1636
|
const typeColors = {
|
|
2163
1637
|
scroll: "#6bcb77",
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
1638
|
+
"scroll-start": "#4d96ff",
|
|
1639
|
+
"scroll-end": "#4d96ff",
|
|
1640
|
+
"visible-range-change": "#ffd93d",
|
|
1641
|
+
"item-measured": "#9b59b6",
|
|
2168
1642
|
resize: "#ff6b6b",
|
|
2169
|
-
|
|
2170
|
-
|
|
1643
|
+
"load-more": "#1abc9c",
|
|
1644
|
+
"items-change": "#e74c3c"
|
|
2171
1645
|
};
|
|
2172
1646
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2173
1647
|
/* @__PURE__ */ jsxRuntime.jsx("button", { style: buttonStyles, onClick: onClear, children: "Clear Log" }),
|
|
@@ -2178,17 +1652,32 @@ function EventsPanel({ eventLog, onClear }) {
|
|
|
2178
1652
|
] });
|
|
2179
1653
|
}
|
|
2180
1654
|
|
|
1655
|
+
Object.defineProperty(exports, "autoMeasurerPlugin", {
|
|
1656
|
+
enumerable: true,
|
|
1657
|
+
get: function () { return chunkND5PV5MU_cjs.autoMeasurerPlugin; }
|
|
1658
|
+
});
|
|
1659
|
+
Object.defineProperty(exports, "gridRendererPlugin", {
|
|
1660
|
+
enumerable: true,
|
|
1661
|
+
get: function () { return chunkND5PV5MU_cjs.gridRendererPlugin; }
|
|
1662
|
+
});
|
|
1663
|
+
Object.defineProperty(exports, "infiniteLoaderPlugin", {
|
|
1664
|
+
enumerable: true,
|
|
1665
|
+
get: function () { return chunkND5PV5MU_cjs.infiniteLoaderPlugin; }
|
|
1666
|
+
});
|
|
1667
|
+
Object.defineProperty(exports, "listRendererPlugin", {
|
|
1668
|
+
enumerable: true,
|
|
1669
|
+
get: function () { return chunkND5PV5MU_cjs.listRendererPlugin; }
|
|
1670
|
+
});
|
|
1671
|
+
Object.defineProperty(exports, "scrollControllerPlugin", {
|
|
1672
|
+
enumerable: true,
|
|
1673
|
+
get: function () { return chunkND5PV5MU_cjs.scrollControllerPlugin; }
|
|
1674
|
+
});
|
|
2181
1675
|
exports.DebugPanelOverlay = DebugPanelOverlay;
|
|
2182
|
-
exports.autoMeasurerPlugin = autoMeasurerPlugin;
|
|
2183
1676
|
exports.bidirectional = bidirectional;
|
|
2184
1677
|
exports.debugPanel = debugPanel;
|
|
2185
1678
|
exports.dragToReorder = dragToReorder;
|
|
2186
|
-
exports.gridRendererPlugin = gridRendererPlugin;
|
|
2187
|
-
exports.infiniteLoaderPlugin = infiniteLoaderPlugin;
|
|
2188
1679
|
exports.keyboardNav = keyboardNav;
|
|
2189
|
-
exports.listRendererPlugin = listRendererPlugin;
|
|
2190
1680
|
exports.masonryRenderer = masonryRenderer;
|
|
2191
|
-
exports.scrollControllerPlugin = scrollControllerPlugin;
|
|
2192
1681
|
exports.scrollRestoration = scrollRestoration;
|
|
2193
1682
|
exports.stickyHeaders = stickyHeaders;
|
|
2194
1683
|
//# sourceMappingURL=index.cjs.map
|