@pdanpdan/virtual-scroll 0.1.0 → 0.2.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/dist/index.css +2 -1
- package/dist/index.d.ts +476 -0
- package/dist/index.js +818 -955
- package/dist/index.js.map +1 -1
- package/package.json +15 -6
- package/src/components/VirtualScroll.vue +3 -3
- package/src/composables/useVirtualScroll.ts +2 -2
- package/src/index.ts +3 -3
- package/src/utils/scroll.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,961 +1,824 @@
|
|
|
1
|
-
import {
|
|
2
|
-
class
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
let g = 0;
|
|
62
|
-
const n = this.tree.length;
|
|
63
|
-
let W = 1 << Math.floor(Math.log2(n - 1));
|
|
64
|
-
for (; W > 0; ) {
|
|
65
|
-
const Z = g + W;
|
|
66
|
-
if (Z < n) {
|
|
67
|
-
const U = this.tree[Z] || 0;
|
|
68
|
-
U <= a && (g = Z, a -= U);
|
|
69
|
-
}
|
|
70
|
-
W >>= 1;
|
|
71
|
-
}
|
|
72
|
-
return g;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Rebuild the entire tree from the current values array in O(N).
|
|
76
|
-
* Useful after bulk updates to the values array.
|
|
77
|
-
*/
|
|
78
|
-
rebuild() {
|
|
79
|
-
this.tree.fill(0);
|
|
80
|
-
for (let a = 0; a < this.values.length; a++)
|
|
81
|
-
this.tree[a + 1] = this.values[a] || 0;
|
|
82
|
-
for (let a = 1; a < this.tree.length; a++) {
|
|
83
|
-
const g = a + (a & -a);
|
|
84
|
-
g < this.tree.length && (this.tree[g] = this.tree[g] + this.tree[a]);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Resize the tree while preserving existing values.
|
|
89
|
-
* @param size New size of the tree
|
|
90
|
-
*/
|
|
91
|
-
resize(a) {
|
|
92
|
-
if (a === this.values.length)
|
|
93
|
-
return;
|
|
94
|
-
const g = new Float64Array(a);
|
|
95
|
-
g.set(this.values.subarray(0, Math.min(a, this.values.length))), this.values = g, this.tree = new Float64Array(a + 1), this.rebuild();
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Shift values by a given offset and rebuild the tree.
|
|
99
|
-
* Useful when items are prepended to the list.
|
|
100
|
-
* @param offset Number of positions to shift (positive for prepending)
|
|
101
|
-
*/
|
|
102
|
-
shift(a) {
|
|
103
|
-
if (a === 0)
|
|
104
|
-
return;
|
|
105
|
-
const g = this.values.length, n = new Float64Array(g);
|
|
106
|
-
a > 0 ? n.set(this.values.subarray(0, Math.min(g - a, this.values.length)), a) : n.set(this.values.subarray(-a)), this.values = n, this.rebuild();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function pe(e) {
|
|
110
|
-
return !!e && "getBoundingClientRect" in e;
|
|
1
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, getCurrentInstance, nextTick, normalizeClass, normalizeStyle, onMounted, onUnmounted, openBlock, reactive, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, watch, withCtx } from "vue";
|
|
2
|
+
var FenwickTree = class {
|
|
3
|
+
tree;
|
|
4
|
+
values;
|
|
5
|
+
constructor(e) {
|
|
6
|
+
this.tree = new Float64Array(e + 1), this.values = new Float64Array(e);
|
|
7
|
+
}
|
|
8
|
+
update(e, t) {
|
|
9
|
+
if (!(e < 0 || e >= this.values.length)) for (this.values[e] = this.values[e] + t, e++; e < this.tree.length;) this.tree[e] = this.tree[e] + t, e += e & -e;
|
|
10
|
+
}
|
|
11
|
+
query(e) {
|
|
12
|
+
let t = 0;
|
|
13
|
+
for (; e > 0;) t += this.tree[e] || 0, e -= e & -e;
|
|
14
|
+
return t;
|
|
15
|
+
}
|
|
16
|
+
set(e, t) {
|
|
17
|
+
e < 0 || e >= this.values.length || (this.values[e] = t);
|
|
18
|
+
}
|
|
19
|
+
get length() {
|
|
20
|
+
return this.values.length;
|
|
21
|
+
}
|
|
22
|
+
get(e) {
|
|
23
|
+
return this.values[e] || 0;
|
|
24
|
+
}
|
|
25
|
+
getValues() {
|
|
26
|
+
return this.values;
|
|
27
|
+
}
|
|
28
|
+
findLowerBound(e) {
|
|
29
|
+
let t = 0, n = this.tree.length, r = 1 << Math.floor(Math.log2(n - 1));
|
|
30
|
+
for (; r > 0;) {
|
|
31
|
+
let i = t + r;
|
|
32
|
+
if (i < n) {
|
|
33
|
+
let n = this.tree[i] || 0;
|
|
34
|
+
n <= e && (t = i, e -= n);
|
|
35
|
+
}
|
|
36
|
+
r >>= 1;
|
|
37
|
+
}
|
|
38
|
+
return t;
|
|
39
|
+
}
|
|
40
|
+
rebuild() {
|
|
41
|
+
this.tree.fill(0);
|
|
42
|
+
for (let e = 0; e < this.values.length; e++) this.tree[e + 1] = this.values[e] || 0;
|
|
43
|
+
for (let e = 1; e < this.tree.length; e++) {
|
|
44
|
+
let t = e + (e & -e);
|
|
45
|
+
t < this.tree.length && (this.tree[t] = this.tree[t] + this.tree[e]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
resize(e) {
|
|
49
|
+
if (e === this.values.length) return;
|
|
50
|
+
let t = new Float64Array(e);
|
|
51
|
+
t.set(this.values.subarray(0, Math.min(e, this.values.length))), this.values = t, this.tree = new Float64Array(e + 1), this.rebuild();
|
|
52
|
+
}
|
|
53
|
+
shift(e) {
|
|
54
|
+
if (e === 0) return;
|
|
55
|
+
let t = this.values.length, n = new Float64Array(t);
|
|
56
|
+
e > 0 ? n.set(this.values.subarray(0, Math.min(t - e, this.values.length)), e) : n.set(this.values.subarray(-e)), this.values = n, this.rebuild();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
function isElement(e) {
|
|
60
|
+
return !!e && "getBoundingClientRect" in e;
|
|
111
61
|
}
|
|
112
|
-
function
|
|
113
|
-
|
|
62
|
+
function isScrollableElement(e) {
|
|
63
|
+
return !!e && "scrollLeft" in e;
|
|
114
64
|
}
|
|
115
|
-
function
|
|
116
|
-
|
|
65
|
+
function isScrollToIndexOptions(e) {
|
|
66
|
+
return typeof e == "object" && !!e && ("align" in e || "behavior" in e || "isCorrection" in e);
|
|
117
67
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
68
|
+
function getPaddingX(e, t) {
|
|
69
|
+
return typeof e == "object" && e ? e.x || 0 : t === "horizontal" && e || 0;
|
|
120
70
|
}
|
|
121
|
-
function
|
|
122
|
-
|
|
71
|
+
function getPaddingY(e, t) {
|
|
72
|
+
return typeof e == "object" && e ? e.y || 0 : (t === "vertical" || t === "both") && e || 0;
|
|
123
73
|
}
|
|
124
|
-
const
|
|
125
|
-
function
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
})), {
|
|
540
|
-
/**
|
|
541
|
-
* Array of items to be rendered with their calculated offsets and sizes.
|
|
542
|
-
*/
|
|
543
|
-
renderedItems: i,
|
|
544
|
-
/**
|
|
545
|
-
* Total calculated width of all items including gaps.
|
|
546
|
-
*/
|
|
547
|
-
totalWidth: p,
|
|
548
|
-
/**
|
|
549
|
-
* Total calculated height of all items including gaps.
|
|
550
|
-
*/
|
|
551
|
-
totalHeight: oe,
|
|
552
|
-
/**
|
|
553
|
-
* Detailed information about the current scroll state.
|
|
554
|
-
* Includes currentIndex, scrollOffset, viewportSize, totalSize, and isScrolling.
|
|
555
|
-
*/
|
|
556
|
-
scrollDetails: c,
|
|
557
|
-
/**
|
|
558
|
-
* Programmatically scroll to a specific row and/or column.
|
|
559
|
-
* @param rowIndex - The row index to scroll to
|
|
560
|
-
* @param colIndex - The column index to scroll to
|
|
561
|
-
* @param options - Alignment and behavior options
|
|
562
|
-
*/
|
|
563
|
-
scrollToIndex: ke,
|
|
564
|
-
/**
|
|
565
|
-
* Programmatically scroll to a specific pixel offset.
|
|
566
|
-
* @param x - The pixel offset to scroll to on the X axis
|
|
567
|
-
* @param y - The pixel offset to scroll to on the Y axis
|
|
568
|
-
* @param options - Behavior options
|
|
569
|
-
*/
|
|
570
|
-
scrollToOffset: Xe,
|
|
571
|
-
/**
|
|
572
|
-
* Stops any currently active programmatic scroll and clears pending corrections.
|
|
573
|
-
*/
|
|
574
|
-
stopProgrammaticScroll: C,
|
|
575
|
-
/**
|
|
576
|
-
* Updates the stored size of an item. Should be called when an item is measured (e.g., via ResizeObserver).
|
|
577
|
-
* @param index - The item index
|
|
578
|
-
* @param width - The measured width
|
|
579
|
-
* @param height - The measured height
|
|
580
|
-
* @param element - The measured element (optional, used for grid column detection)
|
|
581
|
-
*/
|
|
582
|
-
updateItemSize: me,
|
|
583
|
-
/**
|
|
584
|
-
* Updates the stored size of multiple items. Should be called when items are measured (e.g., via ResizeObserver).
|
|
585
|
-
* @param updates - Array of item updates
|
|
586
|
-
*/
|
|
587
|
-
updateItemSizes: H,
|
|
588
|
-
/**
|
|
589
|
-
* Recalculates the host element's offset relative to the scroll container.
|
|
590
|
-
*/
|
|
591
|
-
updateHostOffset: he,
|
|
592
|
-
/**
|
|
593
|
-
* Information about the current visible range of columns.
|
|
594
|
-
*/
|
|
595
|
-
columnRange: r,
|
|
596
|
-
/**
|
|
597
|
-
* Helper to get the width of a specific column based on current configuration.
|
|
598
|
-
* @param index - The column index
|
|
599
|
-
*/
|
|
600
|
-
getColumnWidth: He,
|
|
601
|
-
/**
|
|
602
|
-
* Resets all dynamic measurements and re-initializes from props.
|
|
603
|
-
*/
|
|
604
|
-
refresh: () => {
|
|
605
|
-
R.resize(0), x.resize(0), T.resize(0), ae.fill(0), J.fill(0), A.fill(0), de.value = 0, ve.value = 0, Ye();
|
|
606
|
-
},
|
|
607
|
-
/**
|
|
608
|
-
* Whether the component has finished its first client-side mount and hydration.
|
|
609
|
-
*/
|
|
610
|
-
isHydrated: W
|
|
611
|
-
};
|
|
74
|
+
const DEFAULT_ITEM_SIZE = 50, DEFAULT_COLUMN_WIDTH = 150, DEFAULT_BUFFER = 5;
|
|
75
|
+
function useVirtualScroll(e) {
|
|
76
|
+
let n = ref(0), r = ref(0), i = ref(!1), a = ref(!1), o = ref(!1), l = ref(!1), u = ref(0), p = ref(0), g = reactive({
|
|
77
|
+
x: 0,
|
|
78
|
+
y: 0
|
|
79
|
+
}), _, v = ref(!1), y = new FenwickTree(e.value.items.length), b = new FenwickTree(e.value.items.length), S = new FenwickTree(e.value.columnCount || 0), D = ref(0), O = new Uint8Array(), k = new Uint8Array(), A = new Uint8Array(), j = ref(null), M = ref(0), N = ref(0), P = ref(!1), F = [], I = computed(() => e.value.itemSize === void 0 || e.value.itemSize === null || e.value.itemSize === 0), L = computed(() => e.value.columnWidth === void 0 || e.value.columnWidth === null || e.value.columnWidth === 0), R = computed(() => typeof e.value.itemSize == "number" && e.value.itemSize > 0 ? e.value.itemSize : null), z = computed(() => R.value || e.value.defaultItemSize || 50), B = computed(() => [...e.value.stickyIndices || []].sort((e, t) => e - t)), V = computed(() => {
|
|
80
|
+
if (D.value, !a.value && e.value.ssrRange && !l.value) {
|
|
81
|
+
let { start: t = 0, end: n = 0, colStart: r = 0, colEnd: i = 0 } = e.value.ssrRange, a = e.value.columnCount || 0;
|
|
82
|
+
if (e.value.direction === "both" && a > 0) return S.query(i || a) - S.query(r);
|
|
83
|
+
if (e.value.direction === "horizontal") return R.value === null ? y.query(n) - y.query(t) : (n - t) * (R.value + (e.value.columnGap || 0));
|
|
84
|
+
}
|
|
85
|
+
return e.value.direction === "both" && e.value.columnCount ? S.query(e.value.columnCount) : e.value.direction === "vertical" ? 0 : R.value === null ? y.query(e.value.items.length) : e.value.items.length * (R.value + (e.value.columnGap || 0));
|
|
86
|
+
}), H = computed(() => {
|
|
87
|
+
if (D.value, !a.value && e.value.ssrRange && !l.value) {
|
|
88
|
+
let { start: t, end: n } = e.value.ssrRange;
|
|
89
|
+
if (e.value.direction === "vertical" || e.value.direction === "both") return R.value === null ? b.query(n) - b.query(t) : (n - t) * (R.value + (e.value.gap || 0));
|
|
90
|
+
}
|
|
91
|
+
return e.value.direction === "horizontal" ? 0 : R.value === null ? b.query(e.value.items.length) : e.value.items.length * (R.value + (e.value.gap || 0));
|
|
92
|
+
}), U = computed(() => {
|
|
93
|
+
let t = e.value.direction === "horizontal" || e.value.direction === "both" ? getPaddingX(e.value.scrollPaddingStart, e.value.direction) : 0;
|
|
94
|
+
return Math.max(0, n.value + t - g.x);
|
|
95
|
+
}), W = computed(() => {
|
|
96
|
+
let t = e.value.direction === "vertical" || e.value.direction === "both" ? getPaddingY(e.value.scrollPaddingStart, e.value.direction) : 0;
|
|
97
|
+
return Math.max(0, r.value + t - g.y);
|
|
98
|
+
}), G = (t) => {
|
|
99
|
+
D.value;
|
|
100
|
+
let n = e.value.columnWidth;
|
|
101
|
+
return typeof n == "number" && n > 0 ? n : Array.isArray(n) && n.length > 0 ? n[t % n.length] || 150 : typeof n == "function" ? n(t) : S.get(t) || e.value.defaultColumnWidth || 150;
|
|
102
|
+
}, K = (t, a, o) => {
|
|
103
|
+
let s = typeof o == "object" && o && "isCorrection" in o ? o.isCorrection : !1;
|
|
104
|
+
s || (j.value = {
|
|
105
|
+
rowIndex: t,
|
|
106
|
+
colIndex: a,
|
|
107
|
+
options: o
|
|
108
|
+
});
|
|
109
|
+
let c = e.value.container || window, l = R.value, d = e.value.gap || 0, f = e.value.columnGap || 0, m, h;
|
|
110
|
+
isScrollToIndexOptions(o) ? (m = o.align, h = o.behavior) : m = o;
|
|
111
|
+
let _ = (typeof m == "object" ? m.x : m) || "auto", x = (typeof m == "object" ? m.y : m) || "auto", C = getPaddingX(e.value.scrollPaddingStart, e.value.direction), D = getPaddingX(e.value.scrollPaddingEnd, e.value.direction), O = getPaddingY(e.value.scrollPaddingStart, e.value.direction), k = getPaddingY(e.value.scrollPaddingEnd, e.value.direction), A = e.value.direction === "vertical" || e.value.direction === "both", M = e.value.direction === "horizontal" || e.value.direction === "both", N = u.value - (M ? C + D : 0), P = p.value - (A ? O + k : 0), F = U.value, I = W.value, L = 0, z = 0;
|
|
112
|
+
if (t != null && (t >= e.value.items.length ? (I = H.value, z = 0) : (I = l === null ? b.query(t) : t * (l + d), z = l === null ? b.get(t) - d : l), x === "start" || (x === "center" ? I -= (P - z) / 2 : x === "end" ? I -= P - z : I >= W.value && I + z <= W.value + P || I < W.value || (I -= P - z))), a != null) {
|
|
113
|
+
let t = e.value.columnCount || 0;
|
|
114
|
+
a >= t && t > 0 ? (F = V.value, L = 0) : e.value.direction === "horizontal" ? (F = l === null ? y.query(a) : a * (l + f), L = l === null ? y.get(a) - f : l) : (F = S.query(a), L = S.get(a)), _ === "start" || (_ === "center" ? F -= (N - L) / 2 : _ === "end" ? F -= N - L : F >= U.value && F + L <= U.value + N || F < U.value || (F -= N - L));
|
|
115
|
+
}
|
|
116
|
+
F = Math.max(0, Math.min(F, Math.max(0, V.value - N))), I = Math.max(0, Math.min(I, Math.max(0, H.value - P)));
|
|
117
|
+
let B = F + g.x - (M ? C : 0), G = I + g.y - (A ? O : 0), K = a == null || Math.abs(U.value - F) < 1, q = t == null || Math.abs(W.value - I) < 1;
|
|
118
|
+
if (!K || !q) {
|
|
119
|
+
let e = 0, n = 0, r = 0, i = 0, o = 0, s = 0;
|
|
120
|
+
if (typeof window < "u") {
|
|
121
|
+
if (c === window ? (e = window.scrollX, n = window.scrollY, r = document.documentElement.scrollWidth, i = document.documentElement.scrollHeight, o = window.innerWidth, s = window.innerHeight) : isElement(c) && (e = c.scrollLeft, n = c.scrollTop, r = c.scrollWidth, i = c.scrollHeight, o = c.clientWidth, s = c.clientHeight), !K && a != null) {
|
|
122
|
+
let t = e <= 1 && B <= 1, n = e >= r - o - 1 && B >= r - o - 1;
|
|
123
|
+
(t || n) && (K = !0);
|
|
124
|
+
}
|
|
125
|
+
if (!q && t != null) {
|
|
126
|
+
let e = n <= 1 && G <= 1, t = n >= i - s - 1 && G >= i - s - 1;
|
|
127
|
+
(e || t) && (q = !0);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
let J = s ? "auto" : h || "smooth";
|
|
132
|
+
if (v.value = !0, typeof window < "u" && c === window) window.scrollTo({
|
|
133
|
+
left: a == null ? void 0 : Math.max(0, B),
|
|
134
|
+
top: t == null ? void 0 : Math.max(0, G),
|
|
135
|
+
behavior: J
|
|
136
|
+
});
|
|
137
|
+
else if (isScrollableElement(c)) {
|
|
138
|
+
let e = { behavior: J };
|
|
139
|
+
a != null && (e.left = Math.max(0, B)), t != null && (e.top = Math.max(0, G)), typeof c.scrollTo == "function" ? c.scrollTo(e) : (e.left !== void 0 && (c.scrollLeft = e.left), e.top !== void 0 && (c.scrollTop = e.top));
|
|
140
|
+
}
|
|
141
|
+
(J === "auto" || J === void 0) && (a != null && (n.value = Math.max(0, B)), t != null && (r.value = Math.max(0, G))), K && q && !i.value && (j.value = null);
|
|
142
|
+
}, q = (t, i, a) => {
|
|
143
|
+
let o = e.value.container || window;
|
|
144
|
+
v.value = !0;
|
|
145
|
+
let s = e.value.direction === "vertical" || e.value.direction === "both", c = e.value.direction === "horizontal" || e.value.direction === "both", l = getPaddingX(e.value.scrollPaddingStart, e.value.direction), u = getPaddingY(e.value.scrollPaddingStart, e.value.direction), d = typeof window < "u" && o === window ? window.scrollX : o.scrollLeft, f = typeof window < "u" && o === window ? window.scrollY : o.scrollTop, p = t == null ? d : t + g.x - (c ? l : 0), m = i == null ? f : i + g.y - (s ? u : 0);
|
|
146
|
+
if (typeof window < "u" && o === window) window.scrollTo({
|
|
147
|
+
left: t == null ? void 0 : p,
|
|
148
|
+
top: i == null ? void 0 : m,
|
|
149
|
+
behavior: a?.behavior || "auto"
|
|
150
|
+
});
|
|
151
|
+
else if (isScrollableElement(o)) {
|
|
152
|
+
let e = { behavior: a?.behavior || "auto" };
|
|
153
|
+
t != null && (e.left = p), i != null && (e.top = m), typeof o.scrollTo == "function" ? o.scrollTo(e) : (e.left !== void 0 && (o.scrollLeft = e.left), e.top !== void 0 && (o.scrollTop = e.top));
|
|
154
|
+
}
|
|
155
|
+
(a?.behavior === "auto" || a?.behavior === void 0) && (t != null && (n.value = p), i != null && (r.value = m));
|
|
156
|
+
}, J = () => {
|
|
157
|
+
let t = e.value.items, n = t.length, r = e.value.columnCount || 0;
|
|
158
|
+
if (y.resize(n), b.resize(n), S.resize(r), k.length !== n) {
|
|
159
|
+
let e = new Uint8Array(n);
|
|
160
|
+
e.set(k.subarray(0, Math.min(n, k.length))), k = e;
|
|
161
|
+
}
|
|
162
|
+
if (A.length !== n) {
|
|
163
|
+
let e = new Uint8Array(n);
|
|
164
|
+
e.set(A.subarray(0, Math.min(n, A.length))), A = e;
|
|
165
|
+
}
|
|
166
|
+
if (O.length !== r) {
|
|
167
|
+
let e = new Uint8Array(r);
|
|
168
|
+
e.set(O.subarray(0, Math.min(r, O.length))), O = e;
|
|
169
|
+
}
|
|
170
|
+
let i = 0;
|
|
171
|
+
if (e.value.restoreScrollOnPrepend && F.length > 0 && n > F.length) {
|
|
172
|
+
let e = F[0];
|
|
173
|
+
if (e !== void 0) {
|
|
174
|
+
for (let r = 1; r <= n - F.length; r++) if (t[r] === e) {
|
|
175
|
+
i = r;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (i > 0) {
|
|
181
|
+
y.shift(i), b.shift(i), j.value && j.value.rowIndex !== null && j.value.rowIndex !== void 0 && (j.value.rowIndex += i);
|
|
182
|
+
let r = new Uint8Array(n), a = new Uint8Array(n);
|
|
183
|
+
r.set(k.subarray(0, Math.min(n - i, k.length)), i), a.set(A.subarray(0, Math.min(n - i, A.length)), i), k = r, A = a;
|
|
184
|
+
let o = e.value.gap || 0, s = e.value.columnGap || 0, l = 0, u = 0;
|
|
185
|
+
for (let n = 0; n < i; n++) {
|
|
186
|
+
let r = typeof e.value.itemSize == "function" ? e.value.itemSize(t[n], n) : z.value;
|
|
187
|
+
e.value.direction === "horizontal" ? l += r + s : u += r + o;
|
|
188
|
+
}
|
|
189
|
+
(l > 0 || u > 0) && nextTick(() => {
|
|
190
|
+
q(l > 0 ? U.value + l : null, u > 0 ? W.value + u : null, { behavior: "auto" });
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (r > 0) {
|
|
194
|
+
let t = e.value.columnGap || 0, n = !1;
|
|
195
|
+
for (let e = 0; e < r; e++) {
|
|
196
|
+
let r = G(e), i = S.get(e);
|
|
197
|
+
if (!L.value || i === 0) {
|
|
198
|
+
let a = r + t;
|
|
199
|
+
Math.abs(i - a) > .5 && (S.set(e, a), n = !0);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
n && S.rebuild();
|
|
203
|
+
}
|
|
204
|
+
let a = e.value.gap || 0, o = e.value.columnGap || 0, s = !1;
|
|
205
|
+
for (let t = 0; t < n; t++) {
|
|
206
|
+
let n = e.value.items[t], r = y.get(t), i = b.get(t);
|
|
207
|
+
if (I.value && (r > 0 || i > 0)) continue;
|
|
208
|
+
let c = typeof e.value.itemSize == "function" ? e.value.itemSize(n, t) : z.value, l = e.value.direction === "vertical", d = e.value.direction === "horizontal", f = e.value.direction === "both", p = d ? c + o : 0, m = l || f ? c + a : 0;
|
|
209
|
+
Math.abs(r - p) > .5 && (y.set(t, p), s = !0), Math.abs(i - m) > .5 && (b.set(t, m), s = !0);
|
|
210
|
+
let h = d ? c : f ? Math.max(c, u.value) : 0, g = l || f ? c : 0;
|
|
211
|
+
h > M.value && (M.value = h), g > N.value && (N.value = g);
|
|
212
|
+
}
|
|
213
|
+
s && (y.rebuild(), b.rebuild()), F = [...t], P.value = !0, D.value++;
|
|
214
|
+
}, Y = () => {
|
|
215
|
+
if (e.value.hostElement && typeof window < "u") {
|
|
216
|
+
let t = e.value.hostElement.getBoundingClientRect(), n = e.value.container || window, r = 0, i = 0;
|
|
217
|
+
if (n === window) r = t.left + window.scrollX, i = t.top + window.scrollY;
|
|
218
|
+
else if (n === e.value.hostElement) r = 0, i = 0;
|
|
219
|
+
else if (isElement(n)) {
|
|
220
|
+
let e = n.getBoundingClientRect();
|
|
221
|
+
r = t.left - e.left + n.scrollLeft, i = t.top - e.top + n.scrollTop;
|
|
222
|
+
}
|
|
223
|
+
(Math.abs(g.x - r) > .1 || Math.abs(g.y - i) > .1) && (g.x = r, g.y = i);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
watch([
|
|
227
|
+
() => e.value.items.length,
|
|
228
|
+
() => e.value.columnCount,
|
|
229
|
+
() => e.value.columnWidth,
|
|
230
|
+
() => e.value.itemSize,
|
|
231
|
+
() => e.value.gap,
|
|
232
|
+
() => e.value.columnGap
|
|
233
|
+
], J, { immediate: !0 }), watch(() => [e.value.container, e.value.hostElement], () => {
|
|
234
|
+
Y();
|
|
235
|
+
});
|
|
236
|
+
let X = computed(() => {
|
|
237
|
+
if (D.value, (!a.value || o.value) && e.value.ssrRange) return {
|
|
238
|
+
start: e.value.ssrRange.start,
|
|
239
|
+
end: e.value.ssrRange.end
|
|
240
|
+
};
|
|
241
|
+
let t = e.value.direction || "vertical", n = e.value.ssrRange && !i.value ? 0 : e.value.bufferBefore ?? 5, r = e.value.bufferAfter ?? 5, s = e.value.gap || 0, c = e.value.columnGap || 0, l = R.value, d = getPaddingX(e.value.scrollPaddingStart, t), f = getPaddingX(e.value.scrollPaddingEnd, t), m = getPaddingY(e.value.scrollPaddingStart, t), h = getPaddingY(e.value.scrollPaddingEnd, t), g = t === "vertical" || t === "both", _ = t === "horizontal" || t === "both", v = u.value - (_ ? d + f : 0), x = p.value - (g ? m + h : 0), S = 0, C = e.value.items.length;
|
|
242
|
+
if (g) if (l !== null) S = Math.floor(W.value / (l + s)), C = Math.ceil((W.value + x) / (l + s));
|
|
243
|
+
else {
|
|
244
|
+
S = b.findLowerBound(W.value);
|
|
245
|
+
let t = b.query(S), n = S;
|
|
246
|
+
for (; n < e.value.items.length && t < W.value + x;) t = b.query(++n);
|
|
247
|
+
C = n;
|
|
248
|
+
}
|
|
249
|
+
else if (l !== null) S = Math.floor(U.value / (l + c)), C = Math.ceil((U.value + v) / (l + c));
|
|
250
|
+
else {
|
|
251
|
+
S = y.findLowerBound(U.value);
|
|
252
|
+
let t = y.query(S), n = S;
|
|
253
|
+
for (; n < e.value.items.length && t < U.value + v;) t = y.query(++n);
|
|
254
|
+
C = n;
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
start: Math.max(0, S - n),
|
|
258
|
+
end: Math.min(e.value.items.length, C + r)
|
|
259
|
+
};
|
|
260
|
+
}), Z = computed(() => {
|
|
261
|
+
D.value;
|
|
262
|
+
let t = R.value, n = e.value.gap || 0, r = e.value.columnGap || 0;
|
|
263
|
+
return e.value.direction === "horizontal" ? t === null ? y.findLowerBound(U.value) : Math.floor(U.value / (t + r)) : t === null ? b.findLowerBound(W.value) : Math.floor(W.value / (t + n));
|
|
264
|
+
}), Q = computed(() => {
|
|
265
|
+
D.value;
|
|
266
|
+
let { start: t, end: n } = X.value, r = [], i = R.value, o = e.value.gap || 0, s = e.value.columnGap || 0, c = B.value, l = /* @__PURE__ */ new Set();
|
|
267
|
+
for (let e = t; e < n; e++) l.add(e);
|
|
268
|
+
if (a.value || !e.value.ssrRange) {
|
|
269
|
+
let e = Z.value, r, i = 0, a = c.length - 1;
|
|
270
|
+
for (; i <= a;) {
|
|
271
|
+
let t = i + a >>> 1;
|
|
272
|
+
c[t] < e ? (r = c[t], i = t + 1) : a = t - 1;
|
|
273
|
+
}
|
|
274
|
+
r !== void 0 && l.add(r);
|
|
275
|
+
for (let e of c) e >= t && e < n && l.add(e);
|
|
276
|
+
}
|
|
277
|
+
let d = Array.from(l).sort((e, t) => e - t), f = e.value.ssrRange?.start || 0, m = e.value.ssrRange?.colStart || 0, h = 0, g = 0;
|
|
278
|
+
!a.value && e.value.ssrRange && (g = e.value.direction === "vertical" || e.value.direction === "both" ? i === null ? b.query(f) : f * (i + o) : 0, e.value.direction === "horizontal" ? h = i === null ? y.query(m) : m * (i + s) : e.value.direction === "both" && (h = S.query(m)));
|
|
279
|
+
for (let t of d) {
|
|
280
|
+
let n = e.value.items[t];
|
|
281
|
+
if (n === void 0) continue;
|
|
282
|
+
let a = 0, l = 0, d = 0, f = 0;
|
|
283
|
+
e.value.direction === "horizontal" ? (a = i === null ? y.query(t) : t * (i + s), d = i === null ? y.get(t) - s : i, f = p.value) : (l = (e.value.direction === "vertical" || e.value.direction === "both") && i !== null ? t * (i + o) : b.query(t), f = i === null ? b.get(t) - o : i, d = e.value.direction === "both" ? V.value : u.value);
|
|
284
|
+
let m = c.includes(t), _ = a, v = l, x = !1, S = {
|
|
285
|
+
x: 0,
|
|
286
|
+
y: 0
|
|
287
|
+
};
|
|
288
|
+
if (m) {
|
|
289
|
+
if (e.value.direction === "vertical" || e.value.direction === "both") {
|
|
290
|
+
if (W.value > v) {
|
|
291
|
+
x = !0;
|
|
292
|
+
let e, n = 0, r = c.length - 1;
|
|
293
|
+
for (; n <= r;) {
|
|
294
|
+
let i = n + r >>> 1;
|
|
295
|
+
c[i] > t ? (e = c[i], r = i - 1) : n = i + 1;
|
|
296
|
+
}
|
|
297
|
+
if (e !== void 0) {
|
|
298
|
+
let t = (i === null ? b.query(e) : e * (i + o)) - W.value;
|
|
299
|
+
t < f && (S.y = -(f - t));
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
} else if (e.value.direction === "horizontal" && U.value > _) {
|
|
303
|
+
x = !0;
|
|
304
|
+
let e, n = 0, r = c.length - 1;
|
|
305
|
+
for (; n <= r;) {
|
|
306
|
+
let i = n + r >>> 1;
|
|
307
|
+
c[i] > t ? (e = c[i], r = i - 1) : n = i + 1;
|
|
308
|
+
}
|
|
309
|
+
if (e !== void 0) {
|
|
310
|
+
let t = (i === null ? y.query(e) : e * (i + s)) - U.value;
|
|
311
|
+
t < d && (S.x = -(d - t));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
r.push({
|
|
316
|
+
item: n,
|
|
317
|
+
index: t,
|
|
318
|
+
offset: {
|
|
319
|
+
x: _ - h,
|
|
320
|
+
y: v - g
|
|
321
|
+
},
|
|
322
|
+
size: {
|
|
323
|
+
width: d,
|
|
324
|
+
height: f
|
|
325
|
+
},
|
|
326
|
+
originalX: _,
|
|
327
|
+
originalY: v,
|
|
328
|
+
isSticky: m,
|
|
329
|
+
isStickyActive: x,
|
|
330
|
+
stickyOffset: S
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
return r;
|
|
334
|
+
}), ne = computed(() => {
|
|
335
|
+
D.value;
|
|
336
|
+
let t = e.value.columnCount || 0;
|
|
337
|
+
if (!t) return {
|
|
338
|
+
start: 0,
|
|
339
|
+
end: 0,
|
|
340
|
+
padStart: 0,
|
|
341
|
+
padEnd: 0
|
|
342
|
+
};
|
|
343
|
+
if ((!a.value || o.value) && e.value.ssrRange) {
|
|
344
|
+
let { colStart: n = 0, colEnd: r = 0 } = e.value.ssrRange;
|
|
345
|
+
return {
|
|
346
|
+
start: Math.max(0, n),
|
|
347
|
+
end: Math.min(t, r || t),
|
|
348
|
+
padStart: 0,
|
|
349
|
+
padEnd: 0
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
let n = S.findLowerBound(U.value), r = S.query(n), s = n;
|
|
353
|
+
for (; s < t && r < U.value + u.value;) r = S.query(++s);
|
|
354
|
+
let c = e.value.ssrRange && !i.value ? 0 : 2, l = Math.max(0, n - c), d = Math.min(t, s + c);
|
|
355
|
+
return {
|
|
356
|
+
start: l,
|
|
357
|
+
end: d,
|
|
358
|
+
padStart: S.query(l),
|
|
359
|
+
padEnd: S.query(t) - S.query(d)
|
|
360
|
+
};
|
|
361
|
+
}), re = computed(() => {
|
|
362
|
+
D.value;
|
|
363
|
+
let t = R.value, n = e.value.columnGap || 0, r = 0;
|
|
364
|
+
return (e.value.direction === "horizontal" || e.value.direction === "both") && (r = t === null ? y.findLowerBound(U.value) : Math.floor(U.value / (t + n))), {
|
|
365
|
+
items: Q.value,
|
|
366
|
+
currentIndex: Z.value,
|
|
367
|
+
currentColIndex: r,
|
|
368
|
+
scrollOffset: {
|
|
369
|
+
x: U.value,
|
|
370
|
+
y: W.value
|
|
371
|
+
},
|
|
372
|
+
viewportSize: {
|
|
373
|
+
width: u.value,
|
|
374
|
+
height: p.value
|
|
375
|
+
},
|
|
376
|
+
totalSize: {
|
|
377
|
+
width: V.value,
|
|
378
|
+
height: H.value
|
|
379
|
+
},
|
|
380
|
+
isScrolling: i.value,
|
|
381
|
+
isProgrammaticScroll: v.value,
|
|
382
|
+
range: X.value,
|
|
383
|
+
columnRange: ne.value
|
|
384
|
+
};
|
|
385
|
+
}), ie = () => {
|
|
386
|
+
v.value = !1, j.value = null;
|
|
387
|
+
}, $ = (e) => {
|
|
388
|
+
let t = e.target;
|
|
389
|
+
typeof window > "u" || (t === window || t === document ? (n.value = window.scrollX, r.value = window.scrollY) : isScrollableElement(t) && (n.value = t.scrollLeft, r.value = t.scrollTop), i.value ||= (v.value || (j.value = null), !0), clearTimeout(_), _ = setTimeout(() => {
|
|
390
|
+
i.value = !1, v.value = !1;
|
|
391
|
+
}, 250));
|
|
392
|
+
}, ae = (t) => {
|
|
393
|
+
let n = !1, r = e.value.gap || 0, i = e.value.columnGap || 0;
|
|
394
|
+
for (let { index: a, inlineSize: o, blockSize: s, element: c } of t) {
|
|
395
|
+
if (I.value) {
|
|
396
|
+
if (o > M.value && (M.value = o), s > N.value && (N.value = s), e.value.direction === "horizontal") {
|
|
397
|
+
let e = y.get(a), t = o + i;
|
|
398
|
+
Math.abs(e - t) > .5 && (t > e || !k[a]) && (y.update(a, t - e), k[a] = 1, n = !0);
|
|
399
|
+
}
|
|
400
|
+
if (e.value.direction === "vertical" || e.value.direction === "both") {
|
|
401
|
+
let t = b.get(a), i = s + r;
|
|
402
|
+
e.value.direction === "both" ? (i > t || !A[a]) && (b.update(a, i - t), A[a] = 1, n = !0) : Math.abs(t - i) > .5 && (i > t || !A[a]) && (b.update(a, i - t), A[a] = 1, n = !0);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (e.value.direction === "both" && c && e.value.columnCount && L.value) {
|
|
406
|
+
let t = c.dataset.colIndex === void 0 ? Array.from(c.querySelectorAll("[data-col-index]")) : [c];
|
|
407
|
+
for (let r of t) {
|
|
408
|
+
let t = Number.parseInt(r.dataset.colIndex, 10);
|
|
409
|
+
if (t >= 0 && t < (e.value.columnCount || 0)) {
|
|
410
|
+
let e = r.offsetWidth, a = S.get(t), o = e + i;
|
|
411
|
+
(o > a || !O[t]) && (S.update(t, o - a), O[t] = 1, n = !0);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
n && D.value++;
|
|
417
|
+
}, oe = (e, t, n, r) => {
|
|
418
|
+
ae([{
|
|
419
|
+
index: e,
|
|
420
|
+
inlineSize: t,
|
|
421
|
+
blockSize: n,
|
|
422
|
+
element: r
|
|
423
|
+
}]);
|
|
424
|
+
}, se = () => {
|
|
425
|
+
if (j.value && !o.value) {
|
|
426
|
+
let { rowIndex: e, colIndex: t, options: n } = j.value;
|
|
427
|
+
K(e, t, isScrollToIndexOptions(n) ? {
|
|
428
|
+
...n,
|
|
429
|
+
isCorrection: !0
|
|
430
|
+
} : {
|
|
431
|
+
align: n,
|
|
432
|
+
isCorrection: !0
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
watch(D, se), watch(i, (e) => {
|
|
437
|
+
e || se();
|
|
438
|
+
});
|
|
439
|
+
let ce = null, le = (e) => {
|
|
440
|
+
if (!e || typeof window > "u") return;
|
|
441
|
+
let t = e === window ? document : e;
|
|
442
|
+
if (t.addEventListener("scroll", $, { passive: !0 }), e === window) {
|
|
443
|
+
u.value = window.innerWidth, p.value = window.innerHeight, n.value = window.scrollX, r.value = window.scrollY;
|
|
444
|
+
let e = () => {
|
|
445
|
+
u.value = window.innerWidth, p.value = window.innerHeight, Y();
|
|
446
|
+
};
|
|
447
|
+
return window.addEventListener("resize", e), () => {
|
|
448
|
+
t.removeEventListener("scroll", $), window.removeEventListener("resize", e);
|
|
449
|
+
};
|
|
450
|
+
} else return u.value = e.clientWidth, p.value = e.clientHeight, n.value = e.scrollLeft, r.value = e.scrollTop, ce = new ResizeObserver((t) => {
|
|
451
|
+
for (let n of t) n.target === e && (u.value = e.clientWidth, p.value = e.clientHeight, Y());
|
|
452
|
+
}), ce.observe(e), () => {
|
|
453
|
+
t.removeEventListener("scroll", $), ce?.disconnect();
|
|
454
|
+
};
|
|
455
|
+
}, ue;
|
|
456
|
+
return getCurrentInstance() && (onMounted(() => {
|
|
457
|
+
l.value = !0, watch(() => e.value.container, (e) => {
|
|
458
|
+
ue?.(), ue = le(e || null);
|
|
459
|
+
}, { immediate: !0 }), Y(), e.value.ssrRange || e.value.initialScrollIndex !== void 0 ? nextTick(() => {
|
|
460
|
+
Y();
|
|
461
|
+
let t = e.value.initialScrollIndex === void 0 ? e.value.ssrRange?.start : e.value.initialScrollIndex, n = e.value.initialScrollAlign || "start";
|
|
462
|
+
t != null && K(t, e.value.ssrRange?.colStart, {
|
|
463
|
+
align: n,
|
|
464
|
+
behavior: "auto"
|
|
465
|
+
}), a.value = !0, o.value = !0, nextTick(() => {
|
|
466
|
+
o.value = !1;
|
|
467
|
+
});
|
|
468
|
+
}) : a.value = !0;
|
|
469
|
+
}), onUnmounted(() => {
|
|
470
|
+
ue?.();
|
|
471
|
+
})), {
|
|
472
|
+
renderedItems: Q,
|
|
473
|
+
totalWidth: V,
|
|
474
|
+
totalHeight: H,
|
|
475
|
+
scrollDetails: re,
|
|
476
|
+
scrollToIndex: K,
|
|
477
|
+
scrollToOffset: q,
|
|
478
|
+
stopProgrammaticScroll: ie,
|
|
479
|
+
updateItemSize: oe,
|
|
480
|
+
updateItemSizes: ae,
|
|
481
|
+
updateHostOffset: Y,
|
|
482
|
+
columnRange: ne,
|
|
483
|
+
getColumnWidth: G,
|
|
484
|
+
refresh: () => {
|
|
485
|
+
y.resize(0), b.resize(0), S.resize(0), O.fill(0), k.fill(0), A.fill(0), M.value = 0, N.value = 0, J();
|
|
486
|
+
},
|
|
487
|
+
isHydrated: a
|
|
488
|
+
};
|
|
612
489
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
},
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
export {
|
|
949
|
-
lt as DEFAULT_BUFFER,
|
|
950
|
-
tt as DEFAULT_COLUMN_WIDTH,
|
|
951
|
-
vt as DEFAULT_ITEM_SIZE,
|
|
952
|
-
Qe as FenwickTree,
|
|
953
|
-
St as VirtualScroll,
|
|
954
|
-
we as getPaddingX,
|
|
955
|
-
Se as getPaddingY,
|
|
956
|
-
pe as isElement,
|
|
957
|
-
et as isScrollToIndexOptions,
|
|
958
|
-
_e as isScrollableElement,
|
|
959
|
-
ft as useVirtualScroll
|
|
960
|
-
};
|
|
961
|
-
//# sourceMappingURL=index.js.map
|
|
490
|
+
var _hoisted_1 = {
|
|
491
|
+
key: 0,
|
|
492
|
+
class: "virtual-scroll-debug-info"
|
|
493
|
+
}, VirtualScroll_default = /* @__PURE__ */ ((e, t) => {
|
|
494
|
+
let n = e.__vccOpts || e;
|
|
495
|
+
for (let [e, r] of t) n[e] = r;
|
|
496
|
+
return n;
|
|
497
|
+
})(/* @__PURE__ */ defineComponent({
|
|
498
|
+
__name: "VirtualScroll",
|
|
499
|
+
props: {
|
|
500
|
+
items: {},
|
|
501
|
+
itemSize: {},
|
|
502
|
+
direction: { default: "vertical" },
|
|
503
|
+
bufferBefore: { default: 5 },
|
|
504
|
+
bufferAfter: { default: 5 },
|
|
505
|
+
container: {},
|
|
506
|
+
ssrRange: {},
|
|
507
|
+
columnCount: { default: 0 },
|
|
508
|
+
columnWidth: {},
|
|
509
|
+
containerTag: { default: "div" },
|
|
510
|
+
wrapperTag: { default: "div" },
|
|
511
|
+
itemTag: { default: "div" },
|
|
512
|
+
scrollPaddingStart: { default: 0 },
|
|
513
|
+
scrollPaddingEnd: { default: 0 },
|
|
514
|
+
stickyHeader: {
|
|
515
|
+
type: Boolean,
|
|
516
|
+
default: !1
|
|
517
|
+
},
|
|
518
|
+
stickyFooter: {
|
|
519
|
+
type: Boolean,
|
|
520
|
+
default: !1
|
|
521
|
+
},
|
|
522
|
+
gap: { default: 0 },
|
|
523
|
+
columnGap: { default: 0 },
|
|
524
|
+
stickyIndices: { default: () => [] },
|
|
525
|
+
loadDistance: { default: 50 },
|
|
526
|
+
loading: {
|
|
527
|
+
type: Boolean,
|
|
528
|
+
default: !1
|
|
529
|
+
},
|
|
530
|
+
restoreScrollOnPrepend: {
|
|
531
|
+
type: Boolean,
|
|
532
|
+
default: !1
|
|
533
|
+
},
|
|
534
|
+
initialScrollIndex: {},
|
|
535
|
+
initialScrollAlign: {},
|
|
536
|
+
defaultItemSize: {},
|
|
537
|
+
defaultColumnWidth: {},
|
|
538
|
+
debug: {
|
|
539
|
+
type: Boolean,
|
|
540
|
+
default: !1
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
emits: [
|
|
544
|
+
"scroll",
|
|
545
|
+
"load",
|
|
546
|
+
"visibleRangeChange"
|
|
547
|
+
],
|
|
548
|
+
setup(o, { expose: s, emit: c }) {
|
|
549
|
+
let m = o, C = c, w = computed(() => m.debug), T = ref(null), E = ref(null), D = ref(null), O = ref(null), k = /* @__PURE__ */ new Map(), M = ref(0), N = ref(0), P = computed(() => {
|
|
550
|
+
let e = m.container === void 0 ? T.value : m.container;
|
|
551
|
+
return e === T.value || typeof window < "u" && (e === window || e === null);
|
|
552
|
+
}), { isHydrated: F, columnRange: I, renderedItems: L, scrollDetails: R, totalHeight: z, totalWidth: B, getColumnWidth: V, scrollToIndex: H, scrollToOffset: U, updateHostOffset: W, updateItemSizes: G, refresh: K, stopProgrammaticScroll: q } = useVirtualScroll(computed(() => {
|
|
553
|
+
let e = m.scrollPaddingStart, t = m.scrollPaddingEnd, n = typeof e == "object" ? e.x || 0 : m.direction === "horizontal" && e || 0, r = typeof e == "object" ? e.y || 0 : m.direction === "horizontal" ? 0 : e || 0, i = typeof t == "object" ? t.x || 0 : m.direction === "horizontal" && t || 0, a = typeof t == "object" ? t.y || 0 : m.direction === "horizontal" ? 0 : t || 0;
|
|
554
|
+
return {
|
|
555
|
+
items: m.items,
|
|
556
|
+
itemSize: m.itemSize,
|
|
557
|
+
direction: m.direction,
|
|
558
|
+
bufferBefore: m.bufferBefore,
|
|
559
|
+
bufferAfter: m.bufferAfter,
|
|
560
|
+
container: m.container === void 0 ? T.value : m.container,
|
|
561
|
+
hostElement: E.value,
|
|
562
|
+
ssrRange: m.ssrRange,
|
|
563
|
+
columnCount: m.columnCount,
|
|
564
|
+
columnWidth: m.columnWidth,
|
|
565
|
+
scrollPaddingStart: {
|
|
566
|
+
x: n,
|
|
567
|
+
y: r + (m.stickyHeader && P.value ? M.value : 0)
|
|
568
|
+
},
|
|
569
|
+
scrollPaddingEnd: {
|
|
570
|
+
x: i,
|
|
571
|
+
y: a + (m.stickyFooter && P.value ? N.value : 0)
|
|
572
|
+
},
|
|
573
|
+
gap: m.gap,
|
|
574
|
+
columnGap: m.columnGap,
|
|
575
|
+
stickyIndices: m.stickyIndices,
|
|
576
|
+
loadDistance: m.loadDistance,
|
|
577
|
+
loading: m.loading,
|
|
578
|
+
restoreScrollOnPrepend: m.restoreScrollOnPrepend,
|
|
579
|
+
initialScrollIndex: m.initialScrollIndex,
|
|
580
|
+
initialScrollAlign: m.initialScrollAlign,
|
|
581
|
+
defaultItemSize: m.defaultItemSize,
|
|
582
|
+
defaultColumnWidth: m.defaultColumnWidth,
|
|
583
|
+
debug: w.value
|
|
584
|
+
};
|
|
585
|
+
}));
|
|
586
|
+
watch(R, (e, t) => {
|
|
587
|
+
F.value && (C("scroll", e), (!t || e.range.start !== t.range.start || e.range.end !== t.range.end || e.columnRange.start !== t.columnRange.start || e.columnRange.end !== t.columnRange.end) && C("visibleRangeChange", {
|
|
588
|
+
start: e.range.start,
|
|
589
|
+
end: e.range.end,
|
|
590
|
+
colStart: e.columnRange.start,
|
|
591
|
+
colEnd: e.columnRange.end
|
|
592
|
+
}), !m.loading && (m.direction !== "horizontal" && e.totalSize.height - (e.scrollOffset.y + e.viewportSize.height) <= m.loadDistance && C("load", "vertical"), m.direction !== "vertical" && e.totalSize.width - (e.scrollOffset.x + e.viewportSize.width) <= m.loadDistance && C("load", "horizontal")));
|
|
593
|
+
}), watch(F, (e) => {
|
|
594
|
+
e && C("visibleRangeChange", {
|
|
595
|
+
start: R.value.range.start,
|
|
596
|
+
end: R.value.range.end,
|
|
597
|
+
colStart: R.value.columnRange.start,
|
|
598
|
+
colEnd: R.value.columnRange.end
|
|
599
|
+
});
|
|
600
|
+
}, { once: !0 });
|
|
601
|
+
let J = typeof window > "u" ? null : new ResizeObserver(W), Y = typeof window > "u" ? null : new ResizeObserver((e) => {
|
|
602
|
+
let t = [];
|
|
603
|
+
for (let n of e) {
|
|
604
|
+
let e = n.target, r = Number(e.dataset.index);
|
|
605
|
+
if (e.dataset.colIndex !== void 0) t.push({
|
|
606
|
+
index: -1,
|
|
607
|
+
inlineSize: 0,
|
|
608
|
+
blockSize: 0,
|
|
609
|
+
element: e
|
|
610
|
+
});
|
|
611
|
+
else if (!Number.isNaN(r)) {
|
|
612
|
+
let i = n.contentRect.width, a = n.contentRect.height;
|
|
613
|
+
n.borderBoxSize && n.borderBoxSize.length > 0 ? (i = n.borderBoxSize[0].inlineSize, a = n.borderBoxSize[0].blockSize) : (i = e.offsetWidth, a = e.offsetHeight), t.push({
|
|
614
|
+
index: r,
|
|
615
|
+
inlineSize: i,
|
|
616
|
+
blockSize: a,
|
|
617
|
+
element: e
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
t.length > 0 && G(t);
|
|
622
|
+
}), X = typeof window > "u" ? null : new ResizeObserver(() => {
|
|
623
|
+
M.value = D.value?.offsetHeight || 0, N.value = O.value?.offsetHeight || 0, W();
|
|
624
|
+
});
|
|
625
|
+
watch(D, (e, t) => {
|
|
626
|
+
t && X?.unobserve(t), e && X?.observe(e);
|
|
627
|
+
}, { immediate: !0 }), watch(O, (e, t) => {
|
|
628
|
+
t && X?.unobserve(t), e && X?.observe(e);
|
|
629
|
+
}, { immediate: !0 });
|
|
630
|
+
let Z = computed(() => L.value[0]?.index);
|
|
631
|
+
watch(Z, (e, t) => {
|
|
632
|
+
if (m.direction === "both") {
|
|
633
|
+
if (t !== void 0) {
|
|
634
|
+
let e = k.get(t);
|
|
635
|
+
e && e.querySelectorAll("[data-col-index]").forEach((e) => Y?.unobserve(e));
|
|
636
|
+
}
|
|
637
|
+
if (e !== void 0) {
|
|
638
|
+
let t = k.get(e);
|
|
639
|
+
t && t.querySelectorAll("[data-col-index]").forEach((e) => Y?.observe(e));
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}, { flush: "post" }), onMounted(() => {
|
|
643
|
+
T.value && J?.observe(T.value);
|
|
644
|
+
for (let e of k.values()) Y?.observe(e);
|
|
645
|
+
if (Z.value !== void 0) {
|
|
646
|
+
let e = k.get(Z.value);
|
|
647
|
+
e && e.querySelectorAll("[data-col-index]").forEach((e) => Y?.observe(e));
|
|
648
|
+
}
|
|
649
|
+
}), watch([T, E], ([e], [t]) => {
|
|
650
|
+
t && J?.unobserve(t), e && J?.observe(e);
|
|
651
|
+
});
|
|
652
|
+
function Q(e, t) {
|
|
653
|
+
if (e) k.set(t, e), Y?.observe(e);
|
|
654
|
+
else {
|
|
655
|
+
let e = k.get(t);
|
|
656
|
+
e && (Y?.unobserve(e), k.delete(t));
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
function ne(e) {
|
|
660
|
+
q();
|
|
661
|
+
let { viewportSize: t, scrollOffset: n } = R.value, r = m.direction !== "vertical", i = m.direction !== "horizontal";
|
|
662
|
+
if (e.key === "Home") {
|
|
663
|
+
e.preventDefault(), H(0, 0, "start");
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
if (e.key === "End") {
|
|
667
|
+
e.preventDefault();
|
|
668
|
+
let t = m.items.length - 1, n = (m.columnCount || 0) > 0 ? m.columnCount - 1 : 0;
|
|
669
|
+
r && i ? H(t, n, "end") : H(0, t, "end");
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
if (e.key === "ArrowUp") {
|
|
673
|
+
e.preventDefault(), U(null, n.y - 40);
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
if (e.key === "ArrowDown") {
|
|
677
|
+
e.preventDefault(), U(null, n.y + 40);
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
if (e.key === "ArrowLeft") {
|
|
681
|
+
e.preventDefault(), U(n.x - 40, null);
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
if (e.key === "ArrowRight") {
|
|
685
|
+
e.preventDefault(), U(n.x + 40, null);
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
if (e.key === "PageUp") {
|
|
689
|
+
e.preventDefault(), U(r ? n.x - t.width : null, i ? n.y - t.height : null);
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
e.key === "PageDown" && (e.preventDefault(), U(r ? n.x + t.width : null, i ? n.y + t.height : null));
|
|
693
|
+
}
|
|
694
|
+
onUnmounted(() => {
|
|
695
|
+
J?.disconnect(), Y?.disconnect(), X?.disconnect();
|
|
696
|
+
});
|
|
697
|
+
let re = computed(() => {
|
|
698
|
+
let e = m.container;
|
|
699
|
+
return e === null || typeof window < "u" && e === window ? !0 : e && typeof e == "object" && "tagName" in e ? e.tagName === "BODY" : !1;
|
|
700
|
+
}), ie = computed(() => re.value ? { ...m.direction === "vertical" ? {} : { whiteSpace: "nowrap" } } : m.containerTag === "table" ? { minInlineSize: m.direction === "vertical" ? "100%" : "auto" } : { ...m.direction === "vertical" ? {} : { whiteSpace: "nowrap" } }), $ = computed(() => ({
|
|
701
|
+
inlineSize: m.direction === "vertical" ? "100%" : `${B.value}px`,
|
|
702
|
+
blockSize: m.direction === "horizontal" ? "100%" : `${z.value}px`
|
|
703
|
+
})), ae = computed(() => {
|
|
704
|
+
let e = m.direction === "horizontal";
|
|
705
|
+
return {
|
|
706
|
+
display: e ? "inline-block" : "block",
|
|
707
|
+
...e ? {
|
|
708
|
+
blockSize: "100%",
|
|
709
|
+
verticalAlign: "top"
|
|
710
|
+
} : { inlineSize: "100%" }
|
|
711
|
+
};
|
|
712
|
+
}), oe = computed(() => ({
|
|
713
|
+
inlineSize: m.direction === "vertical" ? "1px" : `${B.value}px`,
|
|
714
|
+
blockSize: m.direction === "horizontal" ? "1px" : `${z.value}px`
|
|
715
|
+
}));
|
|
716
|
+
function se(e) {
|
|
717
|
+
let t = m.direction === "vertical", n = m.direction === "horizontal", r = m.direction === "both", i = m.itemSize === void 0 || m.itemSize === null || m.itemSize === 0, a = { blockSize: n ? "100%" : i ? "auto" : `${e.size.height}px` };
|
|
718
|
+
return t && m.containerTag === "table" ? a.minInlineSize = "100%" : a.inlineSize = t ? "100%" : i ? "auto" : `${e.size.width}px`, i && (t || (a.minInlineSize = `${e.size.width}px`), n || (a.minBlockSize = `${e.size.height}px`)), F.value && (e.isStickyActive ? ((t || r) && (a.insetBlockStart = `${getPaddingY(m.scrollPaddingStart, m.direction)}px`), (n || r) && (a.insetInlineStart = `${getPaddingX(m.scrollPaddingStart, m.direction)}px`), a.transform = `translate(${e.stickyOffset.x}px, ${e.stickyOffset.y}px)`) : a.transform = `translate(${e.offset.x}px, ${e.offset.y}px)`), a;
|
|
719
|
+
}
|
|
720
|
+
return s({
|
|
721
|
+
scrollDetails: R,
|
|
722
|
+
columnRange: I,
|
|
723
|
+
getColumnWidth: V,
|
|
724
|
+
scrollToIndex: H,
|
|
725
|
+
scrollToOffset: U,
|
|
726
|
+
refresh: K,
|
|
727
|
+
stopProgrammaticScroll: q
|
|
728
|
+
}), (t, s) => (openBlock(), createBlock(resolveDynamicComponent(o.containerTag), {
|
|
729
|
+
ref_key: "hostRef",
|
|
730
|
+
ref: T,
|
|
731
|
+
class: normalizeClass(["virtual-scroll-container", [`virtual-scroll--${o.direction}`, {
|
|
732
|
+
"virtual-scroll--hydrated": unref(F),
|
|
733
|
+
"virtual-scroll--window": re.value,
|
|
734
|
+
"virtual-scroll--table": o.containerTag === "table"
|
|
735
|
+
}]]),
|
|
736
|
+
style: normalizeStyle(ie.value),
|
|
737
|
+
tabindex: "0",
|
|
738
|
+
onKeydown: ne,
|
|
739
|
+
onWheelPassive: unref(q),
|
|
740
|
+
onPointerdownPassive: unref(q),
|
|
741
|
+
onTouchstartPassive: unref(q)
|
|
742
|
+
}, {
|
|
743
|
+
default: withCtx(() => [
|
|
744
|
+
t.$slots.header ? (openBlock(), createBlock(resolveDynamicComponent(o.containerTag === "table" ? "thead" : "div"), {
|
|
745
|
+
key: 0,
|
|
746
|
+
ref_key: "headerRef",
|
|
747
|
+
ref: D,
|
|
748
|
+
class: normalizeClass(["virtual-scroll-header", { "virtual-scroll--sticky": o.stickyHeader }])
|
|
749
|
+
}, {
|
|
750
|
+
default: withCtx(() => [renderSlot(t.$slots, "header", {}, void 0, !0)]),
|
|
751
|
+
_: 3
|
|
752
|
+
}, 8, ["class"])) : createCommentVNode("", !0),
|
|
753
|
+
(openBlock(), createBlock(resolveDynamicComponent(o.wrapperTag), {
|
|
754
|
+
ref_key: "wrapperRef",
|
|
755
|
+
ref: E,
|
|
756
|
+
class: "virtual-scroll-wrapper",
|
|
757
|
+
style: normalizeStyle($.value)
|
|
758
|
+
}, {
|
|
759
|
+
default: withCtx(() => [o.containerTag === "table" ? (openBlock(), createBlock(resolveDynamicComponent(o.itemTag), {
|
|
760
|
+
key: 0,
|
|
761
|
+
class: "virtual-scroll-spacer",
|
|
762
|
+
style: normalizeStyle(oe.value)
|
|
763
|
+
}, {
|
|
764
|
+
default: withCtx(() => [...s[0] ||= [createElementVNode("td", { style: {
|
|
765
|
+
padding: "0",
|
|
766
|
+
border: "none",
|
|
767
|
+
"block-size": "inherit"
|
|
768
|
+
} }, null, -1)]]),
|
|
769
|
+
_: 1
|
|
770
|
+
}, 8, ["style"])) : createCommentVNode("", !0), (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(L), (e) => (openBlock(), createBlock(resolveDynamicComponent(o.itemTag), {
|
|
771
|
+
key: e.index,
|
|
772
|
+
ref_for: !0,
|
|
773
|
+
ref: (t) => Q(t, e.index),
|
|
774
|
+
"data-index": e.index,
|
|
775
|
+
class: normalizeClass(["virtual-scroll-item", {
|
|
776
|
+
"virtual-scroll--sticky": e.isStickyActive,
|
|
777
|
+
"virtual-scroll--debug": w.value
|
|
778
|
+
}]),
|
|
779
|
+
style: normalizeStyle(se(e))
|
|
780
|
+
}, {
|
|
781
|
+
default: withCtx(() => [renderSlot(t.$slots, "item", {
|
|
782
|
+
item: e.item,
|
|
783
|
+
index: e.index,
|
|
784
|
+
columnRange: unref(I),
|
|
785
|
+
getColumnWidth: unref(V),
|
|
786
|
+
isSticky: e.isSticky,
|
|
787
|
+
isStickyActive: e.isStickyActive
|
|
788
|
+
}, void 0, !0), w.value ? (openBlock(), createElementBlock("div", _hoisted_1, " #" + toDisplayString(e.index) + " (" + toDisplayString(Math.round(e.offset.x)) + ", " + toDisplayString(Math.round(e.offset.y)) + ") ", 1)) : createCommentVNode("", !0)]),
|
|
789
|
+
_: 2
|
|
790
|
+
}, 1032, [
|
|
791
|
+
"data-index",
|
|
792
|
+
"class",
|
|
793
|
+
"style"
|
|
794
|
+
]))), 128))]),
|
|
795
|
+
_: 3
|
|
796
|
+
}, 8, ["style"])),
|
|
797
|
+
o.loading && t.$slots.loading ? (openBlock(), createElementBlock("div", {
|
|
798
|
+
key: 1,
|
|
799
|
+
class: "virtual-scroll-loading",
|
|
800
|
+
style: normalizeStyle(ae.value)
|
|
801
|
+
}, [renderSlot(t.$slots, "loading", {}, void 0, !0)], 4)) : createCommentVNode("", !0),
|
|
802
|
+
t.$slots.footer ? (openBlock(), createBlock(resolveDynamicComponent(o.containerTag === "table" ? "tfoot" : "div"), {
|
|
803
|
+
key: 2,
|
|
804
|
+
ref_key: "footerRef",
|
|
805
|
+
ref: O,
|
|
806
|
+
class: normalizeClass(["virtual-scroll-footer", { "virtual-scroll--sticky": o.stickyFooter }])
|
|
807
|
+
}, {
|
|
808
|
+
default: withCtx(() => [renderSlot(t.$slots, "footer", {}, void 0, !0)]),
|
|
809
|
+
_: 3
|
|
810
|
+
}, 8, ["class"])) : createCommentVNode("", !0)
|
|
811
|
+
]),
|
|
812
|
+
_: 3
|
|
813
|
+
}, 40, [
|
|
814
|
+
"class",
|
|
815
|
+
"style",
|
|
816
|
+
"onWheelPassive",
|
|
817
|
+
"onPointerdownPassive",
|
|
818
|
+
"onTouchstartPassive"
|
|
819
|
+
]));
|
|
820
|
+
}
|
|
821
|
+
}), [["__scopeId", "data-v-8d960026"]]);
|
|
822
|
+
export { DEFAULT_BUFFER, DEFAULT_COLUMN_WIDTH, DEFAULT_ITEM_SIZE, FenwickTree, VirtualScroll_default as VirtualScroll, getPaddingX, getPaddingY, isElement, isScrollToIndexOptions, isScrollableElement, useVirtualScroll };
|
|
823
|
+
|
|
824
|
+
//# sourceMappingURL=index.js.map
|