@glhrmoura/vue-virtualize 0.1.4 → 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.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { shallowRef as Me, ref as L, toValue as o, watch as ve, onBeforeUnmount as Se, computed as O, defineComponent as ie, openBlock as T, createBlock as q, resolveDynamicComponent as U, normalizeStyle as F, withCtx as Z, renderSlot as j, createElementBlock as V, Fragment as W, renderList as _, unref as K, mergeProps as ne, createElementVNode as le, toDisplayString as ue, createTextVNode as Re } from "vue";
2
- function ee(e) {
1
+ import { shallowRef as _e, ref as W, toValue as l, watch as Ee, onBeforeUnmount as Ce, computed as C, defineComponent as ge, openBlock as V, createBlock as le, resolveDynamicComponent as ae, normalizeStyle as B, withCtx as ce, renderSlot as U, createElementBlock as K, Fragment as te, renderList as ne, unref as j, mergeProps as we, createElementVNode as Me, toDisplayString as Oe, createTextVNode as Xe } from "vue";
2
+ function he(e) {
3
3
  return !Number.isFinite(e) || e < 0 ? 0 : e;
4
4
  }
5
- class Te {
5
+ class Ye {
6
6
  sizes = /* @__PURE__ */ new Map();
7
7
  divergent = !1;
8
8
  get(t) {
@@ -29,28 +29,38 @@ class Te {
29
29
  }
30
30
  }
31
31
  }
32
+ shift(t) {
33
+ if (!t) return;
34
+ const i = /* @__PURE__ */ new Map();
35
+ for (const [n, r] of this.sizes) {
36
+ const s = n + t;
37
+ s >= 0 && i.set(s, r);
38
+ }
39
+ this.sizes.clear();
40
+ for (const [n, r] of i) this.sizes.set(n, r);
41
+ }
32
42
  }
33
- function ze(e, t, i) {
43
+ function Te(e, t, i) {
34
44
  return Math.min(i, Math.max(t, e));
35
45
  }
36
- const Ee = 16777216;
37
- function B(e, t, i) {
46
+ const qe = 16777216;
47
+ function J(e, t, i) {
38
48
  const n = Math.max(0, t - Math.max(0, i));
39
- return ze(Number.isFinite(e) ? e : 0, 0, n);
49
+ return Te(Number.isFinite(e) ? e : 0, 0, n);
40
50
  }
41
- function G(e, t) {
42
- const i = Math.max(0, Number.isFinite(e) ? e : 0), n = Math.min(i, Ee);
51
+ function H(e, t) {
52
+ const i = Math.max(0, Number.isFinite(e) ? e : 0), n = Math.min(i, qe);
43
53
  return t === void 0 || !Number.isFinite(t) || t <= 0 ? n : Math.min(n, t);
44
54
  }
45
- function Ce(e, t, i, n) {
55
+ function Ue(e, t, i, n) {
46
56
  const r = Math.max(0, t - Math.max(0, n)), s = Math.max(0, i - Math.max(0, n));
47
- return r <= 0 ? 0 : s <= 0 || s >= r ? B(e, t, n) : Math.max(0, e) / s * r;
57
+ return r <= 0 ? 0 : s <= 0 || s >= r ? J(e, t, n) : Math.max(0, e) / s * r;
48
58
  }
49
- function ke(e, t, i, n) {
59
+ function Ze(e, t, i, n) {
50
60
  const r = Math.max(0, t - Math.max(0, n)), s = Math.max(0, i - Math.max(0, n));
51
- return s <= 0 ? 0 : r <= 0 || s >= r ? B(e, t, n) : B(e, t, n) / r * s;
61
+ return s <= 0 ? 0 : r <= 0 || s >= r ? J(e, t, n) : J(e, t, n) / r * s;
52
62
  }
53
- function Ve(e, t, i) {
63
+ function Je(e, t, i) {
54
64
  if (e <= 0) return 0;
55
65
  let n = 0, r = e - 1, s = e - 1;
56
66
  for (; n <= r; ) {
@@ -59,7 +69,7 @@ function Ve(e, t, i) {
59
69
  }
60
70
  return s;
61
71
  }
62
- function Ae(e, t, i) {
72
+ function Qe(e, t, i) {
63
73
  if (e <= 0) return 0;
64
74
  let n = 0, r = e - 1, s = 0;
65
75
  for (; n <= r; ) {
@@ -68,7 +78,7 @@ function Ae(e, t, i) {
68
78
  }
69
79
  return s;
70
80
  }
71
- function $e(e) {
81
+ function et(e) {
72
82
  const t = e.start + e.size;
73
83
  let i = e.align;
74
84
  if (i === "auto") {
@@ -78,7 +88,7 @@ function $e(e) {
78
88
  }
79
89
  return i === "center" ? e.start - (e.viewport - e.size) / 2 : i === "end" ? t - e.viewport : e.start;
80
90
  }
81
- class Fe {
91
+ class tt {
82
92
  count = 0;
83
93
  estimateSize = () => 0;
84
94
  overscan = 0;
@@ -90,14 +100,14 @@ class Fe {
90
100
  viewportSize = 0;
91
101
  scrollOffset = 0;
92
102
  getItemKey = (t) => t;
93
- measurements = new Te();
103
+ measurements = new Ye();
94
104
  built = 0;
95
105
  offsets = [];
96
106
  laneCursor = [];
97
107
  laneEnd = [];
98
108
  setOptions(t) {
99
- const i = Math.max(1, Math.floor(t.lanes ?? 1)), n = t.gap ?? 0, r = t.paddingStart ?? 0, s = t.paddingEnd ?? 0, d = Math.max(0, Math.floor(t.count)), p = t.itemSize === void 0 || t.itemSize === null ? null : ee(t.itemSize), w = this.itemSize, I = i !== this.lanes || n !== this.gap || r !== this.paddingStart || s !== this.paddingEnd || t.estimateSize !== this.estimateSize || p !== this.itemSize;
100
- this.count = d, this.lanes = i, this.gap = n, this.paddingStart = r, this.paddingEnd = s, this.overscan = Math.max(0, Math.floor(t.overscan ?? 0)), this.estimateSize = t.estimateSize, this.itemSize = p, this.getItemKey = t.getItemKey ?? ((y) => y), t.viewportSize !== void 0 && (this.viewportSize = Math.max(0, t.viewportSize)), p !== w && this.measurements.clear(), this.measurements.trim(this.count, this.itemSize), (I || this.built > this.count) && this.resetGeometry();
109
+ const i = Math.max(1, Math.floor(t.lanes ?? 1)), n = t.gap ?? 0, r = t.paddingStart ?? 0, s = t.paddingEnd ?? 0, d = Math.max(0, Math.floor(t.count)), I = t.itemSize === void 0 || t.itemSize === null ? null : he(t.itemSize), O = this.itemSize, p = i !== this.lanes || n !== this.gap || r !== this.paddingStart || s !== this.paddingEnd || t.estimateSize !== this.estimateSize || I !== this.itemSize;
110
+ this.count = d, this.lanes = i, this.gap = n, this.paddingStart = r, this.paddingEnd = s, this.overscan = Math.max(0, Math.floor(t.overscan ?? 0)), this.estimateSize = t.estimateSize, this.itemSize = I, this.getItemKey = t.getItemKey ?? ((c) => c), t.viewportSize !== void 0 && (this.viewportSize = Math.max(0, t.viewportSize)), I !== O && this.measurements.clear(), this.measurements.trim(this.count, this.itemSize), (p || this.built > this.count) && this.resetGeometry();
101
111
  }
102
112
  setScrollOffset(t) {
103
113
  this.scrollOffset = Number.isFinite(t) ? t : 0;
@@ -110,7 +120,7 @@ class Fe {
110
120
  }
111
121
  measure(t, i) {
112
122
  if (t < 0 || t >= this.count) return !1;
113
- const n = ee(i), r = this.measurements.get(t);
123
+ const n = he(i), r = this.measurements.get(t);
114
124
  if (r !== void 0 && Math.abs(r - n) < 0.5) return !1;
115
125
  const s = this.getItemSize(t);
116
126
  return this.measurements.set(t, n, this.itemSize), Math.abs(s - n) < 0.5 ? !1 : (this.resetGeometry(), !0);
@@ -118,9 +128,12 @@ class Fe {
118
128
  clearMeasurements() {
119
129
  this.measurements.clear(), this.resetGeometry();
120
130
  }
131
+ shiftMeasurements(t) {
132
+ t && (this.measurements.shift(t), this.resetGeometry());
133
+ }
121
134
  getItemSize(t) {
122
135
  const i = this.measurements.get(t);
123
- return i !== void 0 ? i : this.itemSize !== null ? this.itemSize : ee(this.estimateSize(t));
136
+ return i !== void 0 ? i : this.itemSize !== null ? this.itemSize : he(this.estimateSize(t));
124
137
  }
125
138
  getItemOffset(t) {
126
139
  if (t <= 0 || this.count <= 0) return this.paddingStart;
@@ -152,26 +165,26 @@ class Fe {
152
165
  }
153
166
  getVirtualItems() {
154
167
  if (this.count <= 0 || this.viewportSize <= 0) return [];
155
- const t = B(this.scrollOffset, this.getTotalSize(), this.viewportSize), i = t + this.viewportSize, n = [];
168
+ const t = J(this.scrollOffset, this.getTotalSize(), this.viewportSize), i = t + this.viewportSize, n = [];
156
169
  for (let r = 0; r < this.lanes; r += 1) {
157
170
  const s = this.laneLength(r);
158
171
  if (s <= 0) continue;
159
- const d = Ve(s, t, (y) => {
160
- const b = this.ordinalIndex(r, y);
161
- return this.getItemOffset(b) + this.getItemSize(b);
162
- }), p = Ae(
172
+ const d = Je(s, t, (c) => {
173
+ const g = this.ordinalIndex(r, c);
174
+ return this.getItemOffset(g) + this.getItemSize(g);
175
+ }), I = Qe(
163
176
  s,
164
177
  i,
165
- (y) => this.getItemOffset(this.ordinalIndex(r, y))
166
- ), w = Math.max(0, Math.min(d, p) - this.overscan), I = Math.min(s - 1, Math.max(d, p) + this.overscan);
167
- for (let y = w; y <= I; y += 1) {
168
- const b = this.ordinalIndex(r, y), E = this.getItemOffset(b), C = this.getItemSize(b);
178
+ (c) => this.getItemOffset(this.ordinalIndex(r, c))
179
+ ), O = Math.max(0, Math.min(d, I) - this.overscan), p = Math.min(s - 1, Math.max(d, I) + this.overscan);
180
+ for (let c = O; c <= p; c += 1) {
181
+ const g = this.ordinalIndex(r, c), k = this.getItemOffset(g), A = this.getItemSize(g);
169
182
  n.push({
170
- index: b,
171
- key: this.getItemKey(b),
172
- start: E,
173
- size: C,
174
- end: E + C,
183
+ index: g,
184
+ key: this.getItemKey(g),
185
+ start: k,
186
+ size: A,
187
+ end: k + A,
175
188
  lane: r
176
189
  });
177
190
  }
@@ -180,14 +193,14 @@ class Fe {
180
193
  }
181
194
  getOffsetForIndex(t, i = "auto") {
182
195
  if (this.count <= 0) return 0;
183
- const n = ze(t, 0, this.count - 1), r = this.getItemOffset(n), s = this.getItemSize(n), d = $e({
196
+ const n = Te(t, 0, this.count - 1), r = this.getItemOffset(n), s = this.getItemSize(n), d = et({
184
197
  start: r,
185
198
  size: s,
186
199
  viewport: this.viewportSize,
187
200
  current: this.scrollOffset,
188
201
  align: i
189
202
  });
190
- return B(d, this.getTotalSize(), this.viewportSize);
203
+ return J(d, this.getTotalSize(), this.viewportSize);
191
204
  }
192
205
  usesFixedPath() {
193
206
  return this.itemSize !== null && !this.measurements.hasDivergent;
@@ -212,13 +225,13 @@ class Fe {
212
225
  this.built = 0, this.offsets = [], this.laneCursor = Array.from({ length: this.lanes }, () => this.paddingStart), this.laneEnd = Array.from({ length: this.lanes }, () => this.paddingStart);
213
226
  }
214
227
  }
215
- function D() {
228
+ function Z() {
216
229
  return typeof window < "u" && typeof document < "u";
217
230
  }
218
- function ye(e) {
231
+ function ke(e) {
219
232
  return typeof Element > "u" ? null : e instanceof Element ? e : null;
220
233
  }
221
- function Ke(e, t, i, n) {
234
+ function nt(e, t, i, n) {
222
235
  if (n === "smooth" && typeof e.scrollTo == "function") {
223
236
  e.scrollTo({
224
237
  top: i ? e.scrollTop : t,
@@ -229,22 +242,45 @@ function Ke(e, t, i, n) {
229
242
  }
230
243
  i ? e.scrollLeft = t : e.scrollTop = t;
231
244
  }
232
- function ce(e, t) {
245
+ function it(e, t, i) {
246
+ if (!(typeof window > "u")) {
247
+ if (i === "smooth") {
248
+ window.scrollTo({
249
+ top: t ? window.scrollY : e,
250
+ left: t ? e : window.scrollX,
251
+ behavior: i
252
+ });
253
+ return;
254
+ }
255
+ t ? window.scrollTo(e, window.scrollY) : window.scrollTo(window.scrollX, e);
256
+ }
257
+ }
258
+ function Ie(e, t) {
233
259
  return t ? e.scrollLeft : e.scrollTop;
234
260
  }
235
- function fe(e, t) {
261
+ function rt(e) {
262
+ return typeof window > "u" ? 0 : e ? window.scrollX : window.scrollY;
263
+ }
264
+ function st(e, t) {
236
265
  return t ? e.clientWidth : e.clientHeight;
237
266
  }
238
- function Le(e, t) {
267
+ function ot(e) {
268
+ return typeof window > "u" ? 0 : e ? window.innerWidth : window.innerHeight;
269
+ }
270
+ function lt(e, t) {
239
271
  return t ? e.scrollWidth : e.scrollHeight;
240
272
  }
241
- function de(e) {
273
+ function at(e, t) {
274
+ const i = e.getBoundingClientRect();
275
+ return typeof window > "u" ? t ? i.left : i.top : t ? i.left + window.scrollX : i.top + window.scrollY;
276
+ }
277
+ function ct(e) {
242
278
  return typeof requestAnimationFrame == "function" ? requestAnimationFrame(e) : setTimeout(e, 0);
243
279
  }
244
- function he(e) {
280
+ function ut(e) {
245
281
  e && (typeof cancelAnimationFrame == "function" ? cancelAnimationFrame(e) : clearTimeout(e));
246
282
  }
247
- function je(e, t) {
283
+ function dt(e, t) {
248
284
  if (e.length !== t.length) return !1;
249
285
  for (let i = 0; i < e.length; i += 1) {
250
286
  const n = e[i], r = t[i];
@@ -253,176 +289,232 @@ function je(e, t) {
253
289
  }
254
290
  return !0;
255
291
  }
256
- function te(e) {
257
- const t = new Fe(), i = Me([]), n = L(0), r = L(0), s = L(0), d = L(!1), p = (a) => e.estimateSize(a);
258
- let w = null, I = null, y = null, b = 0, E = 0, C = 0, u = o(e.revision);
259
- const c = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), l = [];
260
- function S() {
261
- const a = o(e.container);
262
- return typeof HTMLElement > "u" ? null : a instanceof HTMLElement ? a : null;
263
- }
264
- function m() {
265
- return o(e.horizontal) ?? !1;
266
- }
267
- function N() {
268
- const a = o(e.initialRect);
269
- return a ? m() ? a.width : a.height : 0;
270
- }
271
- function X(a, f) {
272
- return a ? G(f, Le(a, m())) : G(f);
273
- }
274
- function P(a, f, g) {
275
- return Ce(
276
- ce(a, m()),
277
- f,
278
- X(a, f),
279
- g
280
- );
292
+ function me(e) {
293
+ const t = new tt(), i = _e([]), n = W(0), r = W(0), s = W(0), d = W(!1), I = (o) => e.estimateSize(o);
294
+ let O = null, p = !1, c = null, g = null, k = 0, A = 0, f = 0, b = l(e.revision), S = l(e.count), v = e.getItemKey?.(0) ?? 0, z = !1, h = "";
295
+ const T = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), G = [];
296
+ function D() {
297
+ const o = l(e.container);
298
+ return typeof HTMLElement > "u" ? null : o instanceof HTMLElement ? o : null;
299
+ }
300
+ function $() {
301
+ return l(e.horizontal) ?? !1;
302
+ }
303
+ function u() {
304
+ return l(e.windowScroll) ?? !1;
305
+ }
306
+ function R() {
307
+ return l(e.reverse) ?? !1;
308
+ }
309
+ function y() {
310
+ const o = l(e.initialRect);
311
+ return o ? $() ? o.width : o.height : 0;
312
+ }
313
+ function L() {
314
+ const o = D(), a = l(e.scrollMargin) ?? 0;
315
+ return !o || !Z() ? a : at(o, $()) + a;
316
+ }
317
+ function ee(o, a) {
318
+ return u() || !o ? H(a) : H(a, lt(o, $()));
319
+ }
320
+ function $e(o) {
321
+ return u() ? Math.max(0, rt($()) - L()) : o ? Ie(o, $()) : 0;
322
+ }
323
+ function ve(o) {
324
+ return u() ? ot($()) : o ? st(o, $()) : 0;
325
+ }
326
+ function Ae(o, a, m) {
327
+ if (u()) {
328
+ it(a + L(), $(), m);
329
+ return;
330
+ }
331
+ o && nt(o, a, $(), m);
281
332
  }
282
- function v(a, f, g, R, M) {
283
- Ke(
333
+ function ue(o, a, m) {
334
+ return Ue(
335
+ $e(o),
284
336
  a,
285
- ke(f, g, X(a, g), R),
286
- m(),
287
- M
337
+ ee(o, a),
338
+ m
288
339
  );
289
340
  }
290
- function x() {
291
- const a = o(e.revision);
292
- Object.is(a, u) || (u = a, t.clearMeasurements());
293
- const f = S(), g = f ? fe(f, m()) : 0, R = o(e.viewportInset) ?? 0, M = Math.max(0, (g > 0 ? g : N()) - R), A = o(e.itemSize);
294
- t.setOptions({
295
- count: o(e.count),
296
- estimateSize: p,
297
- overscan: o(e.overscan) ?? 5,
298
- gap: o(e.gap) ?? 0,
299
- paddingStart: o(e.paddingStart) ?? 0,
300
- paddingEnd: o(e.paddingEnd) ?? 0,
301
- lanes: o(e.lanes) ?? 1,
302
- itemSize: A ?? null,
341
+ function P(o, a, m, w, x) {
342
+ Ae(
343
+ o,
344
+ Ze(a, m, ee(o, m), w),
345
+ x
346
+ );
347
+ }
348
+ function Fe() {
349
+ const o = e.onVisibleRangeChange;
350
+ if (!o) return;
351
+ const a = i.value, m = l(e.count), w = a.length ? {
352
+ startIndex: a[0]?.index ?? 0,
353
+ endIndex: a[a.length - 1]?.index ?? -1,
354
+ count: m
355
+ } : { startIndex: 0, endIndex: -1, count: m }, x = `${w.startIndex}:${w.endIndex}:${w.count}`;
356
+ x !== h && (h = x, o(w));
357
+ }
358
+ function F() {
359
+ const o = l(e.revision);
360
+ Object.is(o, b) || (b = o, t.clearMeasurements());
361
+ const a = l(e.count), m = e.getItemKey?.(0) ?? 0, w = R() && S > 0 && a > S && m !== v, x = R() && S > 0 && a > S && m === v, E = w || x ? a - S : 0, _ = R() && t.getViewportSize() > 0 && t.getScrollOffset() + t.getViewportSize() >= t.getTotalSize() - 64;
362
+ w && E > 0 && t.shiftMeasurements(E);
363
+ const X = D(), xe = ve(X), He = l(e.viewportInset) ?? 0, Y = Math.max(0, (xe > 0 ? xe : y()) - He), De = l(e.itemSize);
364
+ if (t.setOptions({
365
+ count: a,
366
+ estimateSize: I,
367
+ overscan: (l(e.overscan) ?? 8) + f,
368
+ gap: l(e.gap) ?? 0,
369
+ paddingStart: l(e.paddingStart) ?? 0,
370
+ paddingEnd: l(e.paddingEnd) ?? 0,
371
+ lanes: l(e.lanes) ?? 1,
372
+ itemSize: De ?? null,
303
373
  getItemKey: e.getItemKey,
304
- viewportSize: M
305
- });
306
- const $ = t.getTotalSize(), J = Math.max(0, $ - M);
307
- t.getScrollOffset() > J && (t.setScrollOffset(J), f && v(f, J, $, M, "auto"));
308
- const oe = t.getVirtualItems();
309
- je(i.value, oe) || (i.value = oe), n.value !== $ && (n.value = $);
310
- const Q = t.getScrollOffset();
311
- r.value !== Q && (r.value = Q);
312
- const ae = f ? Q - ce(f, m()) : 0;
313
- s.value !== ae && (s.value = ae);
314
- }
315
- function z() {
316
- if (!D()) {
317
- x();
374
+ viewportSize: Y
375
+ }), w && E > 0) {
376
+ let re = 0;
377
+ const Pe = l(e.gap) ?? 0;
378
+ for (let se = 0; se < E; se += 1)
379
+ re += t.getItemSize(se), se < E - 1 && (re += Pe);
380
+ re > 0 && t.setScrollOffset(t.getScrollOffset() + re);
381
+ }
382
+ const N = t.getTotalSize(), q = Math.max(0, N - Y);
383
+ R() && !z && N > 0 && Y > 0 ? (z = !0, t.setScrollOffset(q), P(X, q, N, Y, "auto")) : x && _ || t.getScrollOffset() > q ? (t.setScrollOffset(q), P(X, q, N, Y, "auto")) : w && E > 0 && P(X, t.getScrollOffset(), N, Y, "auto"), S = a, v = m;
384
+ const pe = t.getVirtualItems();
385
+ dt(i.value, pe) || (i.value = pe), n.value !== N && (n.value = N);
386
+ const fe = t.getScrollOffset();
387
+ r.value !== fe && (r.value = fe);
388
+ const be = X && !u() ? fe - Ie(X, $()) : 0;
389
+ s.value !== be && (s.value = be), Fe();
390
+ }
391
+ function Ke() {
392
+ d.value = !1, f = 0;
393
+ for (const [o, a] of T)
394
+ G.push({ element: o, index: a });
395
+ ze(), F(), e.onScrollEnd?.();
396
+ }
397
+ function Le() {
398
+ d.value = !0, !(typeof window > "u") && (window.clearTimeout(A), A = window.setTimeout(Ke, 120));
399
+ }
400
+ function ie() {
401
+ const o = D();
402
+ if (!u() && !o) return;
403
+ Le();
404
+ const a = t.getViewportSize(), m = t.getTotalSize(), w = ue(o, m, a), x = t.getScrollOffset(), E = Math.max(1, l(e.itemSize) ?? 48);
405
+ f = Math.min(24, Math.ceil(Math.abs(w - x) / E)), t.setScrollOffset(w), F();
406
+ }
407
+ function de() {
408
+ O && (O.removeEventListener("scroll", ie), O = null), p && typeof window < "u" && (window.removeEventListener("scroll", ie), window.removeEventListener("resize", F), p = !1), c?.disconnect(), c = null;
409
+ }
410
+ function Be() {
411
+ const o = D();
412
+ if (u()) {
413
+ if (p && O === o || (de(), O = o, !Z())) return;
414
+ p = !0;
415
+ const x = t.getViewportSize(), E = t.getTotalSize();
416
+ t.getScrollOffset() > 0 ? P(o, t.getScrollOffset(), E, x, "auto") : t.setScrollOffset(ue(o, E, x)), window.addEventListener("scroll", ie, { passive: !0 }), window.addEventListener("resize", F), o && typeof ResizeObserver < "u" && (c = new ResizeObserver(() => F()), c.observe(o));
318
417
  return;
319
418
  }
320
- b || (b = de(() => {
321
- b = 0, d.value = !0, x(), typeof window < "u" && (window.clearTimeout(C), C = window.setTimeout(() => {
322
- d.value = !1;
323
- }, 150));
324
- }));
419
+ if (o === O && !p || (de(), O = o, !o || !Z())) return;
420
+ const m = t.getViewportSize(), w = t.getTotalSize();
421
+ t.getScrollOffset() > 0 ? P(o, t.getScrollOffset(), w, m, "auto") : t.setScrollOffset(ue(o, w, m)), o.addEventListener("scroll", ie, { passive: !0 }), typeof ResizeObserver < "u" && (c = new ResizeObserver(() => F()), c.observe(o));
325
422
  }
326
- function k() {
327
- const a = S();
328
- if (!a) return;
329
- const f = t.getViewportSize(), g = t.getTotalSize();
330
- t.setScrollOffset(P(a, g, f)), z();
331
- }
332
- function Y() {
333
- const a = S();
334
- if (a === w || (w && (w.removeEventListener("scroll", k), I?.disconnect(), I = null), w = a, !a || !D())) return;
335
- const f = t.getViewportSize(), g = t.getTotalSize();
336
- t.getScrollOffset() > 0 ? v(a, t.getScrollOffset(), g, f, "auto") : t.setScrollOffset(P(a, g, f)), a.addEventListener("scroll", k, { passive: !0 }), typeof ResizeObserver < "u" && (I = new ResizeObserver(() => x()), I.observe(a));
337
- }
338
- function xe() {
339
- return !D() || typeof ResizeObserver > "u" ? null : (y || (y = new ResizeObserver((a) => {
340
- const f = m();
341
- let g = !1;
342
- for (const R of a) {
343
- const M = c.get(R.target);
344
- if (M === void 0) continue;
345
- const A = R.borderBoxSize?.[0], $ = f ? A?.inlineSize ?? R.contentRect.width : A?.blockSize ?? R.contentRect.height;
346
- $ > 0 && t.measure(M, $) && (g = !0);
423
+ function je() {
424
+ return !Z() || typeof ResizeObserver > "u" ? null : (g || (g = new ResizeObserver((o) => {
425
+ const a = $();
426
+ let m = !1;
427
+ if (!d.value) {
428
+ for (const w of o) {
429
+ const x = T.get(w.target);
430
+ if (x === void 0) continue;
431
+ const E = w.borderBoxSize?.[0], _ = Math.round(
432
+ a ? E?.inlineSize ?? w.contentRect.width : E?.blockSize ?? w.contentRect.height
433
+ );
434
+ _ > 0 && t.measure(x, _) && (m = !0);
435
+ }
436
+ m && F();
347
437
  }
348
- g && x();
349
- })), y);
350
- }
351
- function pe() {
352
- E = 0;
353
- const a = l.splice(0, l.length), f = m();
354
- let g = !1;
355
- for (const R of a) {
356
- if (!R.element.isConnected) continue;
357
- const M = R.element.getBoundingClientRect(), A = f ? M.width : M.height;
358
- A > 0 && t.measure(R.index, A) && (g = !0);
438
+ })), g);
439
+ }
440
+ function ze() {
441
+ if (k = 0, d.value) return;
442
+ const o = G.splice(0, G.length), a = $();
443
+ let m = !1;
444
+ for (const w of o) {
445
+ if (!w.element.isConnected) continue;
446
+ const x = w.element.getBoundingClientRect(), E = Math.round(a ? x.width : x.height);
447
+ E > 0 && t.measure(w.index, E) && (m = !0);
359
448
  }
360
- g && x();
449
+ m && F();
361
450
  }
362
- function be(a, f) {
363
- const g = ye(a), R = xe(), M = h.get(f);
364
- M && M !== g && (R?.unobserve(M), c.delete(M), h.delete(f)), g && (h.set(f, g), c.set(g, f), R?.observe(g), l.push({ element: g, index: f }), !E && (E = de(pe)));
451
+ function Ge(o, a) {
452
+ const m = ke(o), w = je(), x = M.get(a);
453
+ x && x !== m && (w?.unobserve(x), T.delete(x), M.delete(a)), m && (M.set(a, m), T.set(m, a), w?.observe(m), G.push({ element: m, index: a }), !(d.value || k) && (k = ct(ze)));
365
454
  }
366
- function se(a, f = "auto") {
367
- const g = S(), R = g ? fe(g, m()) : 0, M = R > 0 ? R : t.getViewportSize(), A = t.getTotalSize(), $ = B(a, A, M);
368
- t.setScrollOffset($), g && v(g, $, A, M, f), x();
455
+ function ye(o, a = "auto") {
456
+ const m = D(), w = ve(m), x = w > 0 ? w : t.getViewportSize(), E = t.getTotalSize(), _ = J(o, E, x);
457
+ t.setScrollOffset(_), P(m, _, E, x, a), F();
369
458
  }
370
- function Ie(a, f) {
371
- const g = t.getOffsetForIndex(a, f?.align ?? "auto");
372
- se(g, f?.behavior ?? "auto");
459
+ function We(o, a) {
460
+ const m = t.getOffsetForIndex(o, a?.align ?? "auto");
461
+ ye(m, a?.behavior ?? "auto");
373
462
  }
374
- function Oe(a, f) {
375
- t.measure(a, f) && x();
463
+ function Ne(o, a) {
464
+ t.measure(o, a) && F();
376
465
  }
377
- return x(), ve(
466
+ return F(), Ee(
378
467
  () => [
379
- o(e.count),
380
- o(e.overscan),
381
- o(e.gap),
382
- o(e.paddingStart),
383
- o(e.paddingEnd),
384
- o(e.lanes),
385
- o(e.horizontal),
386
- o(e.itemSize),
387
- o(e.viewportInset),
388
- o(e.revision),
389
- o(e.container),
390
- o(e.initialRect)?.width,
391
- o(e.initialRect)?.height
468
+ l(e.count),
469
+ l(e.overscan),
470
+ l(e.gap),
471
+ l(e.paddingStart),
472
+ l(e.paddingEnd),
473
+ l(e.lanes),
474
+ l(e.horizontal),
475
+ l(e.itemSize),
476
+ l(e.viewportInset),
477
+ l(e.revision),
478
+ l(e.container),
479
+ l(e.windowScroll),
480
+ l(e.scrollMargin),
481
+ l(e.reverse),
482
+ l(e.initialRect)?.width,
483
+ l(e.initialRect)?.height
392
484
  ],
393
485
  () => {
394
- Y(), x();
486
+ Be(), F();
395
487
  },
396
488
  { flush: "post" }
397
- ), Se(() => {
398
- w && w.removeEventListener("scroll", k), I?.disconnect(), y?.disconnect(), he(b), he(E), typeof window < "u" && window.clearTimeout(C), c.clear(), h.clear(), l.length = 0;
489
+ ), Ce(() => {
490
+ de(), g?.disconnect(), ut(k), typeof window < "u" && window.clearTimeout(A), T.clear(), M.clear(), G.length = 0;
399
491
  }), {
400
- virtualItems: O(() => i.value),
401
- totalSize: O(() => n.value),
402
- scrollOffset: O(() => r.value),
403
- scrollAdjust: O(() => s.value),
404
- isScrolling: O(() => d.value),
405
- scrollToIndex: Ie,
406
- scrollToOffset: se,
407
- measure: Oe,
408
- measureElement: be
492
+ virtualItems: C(() => i.value),
493
+ totalSize: C(() => n.value),
494
+ scrollOffset: C(() => r.value),
495
+ scrollAdjust: C(() => s.value),
496
+ isScrolling: C(() => d.value),
497
+ scrollToIndex: We,
498
+ scrollToOffset: ye,
499
+ measure: Ne,
500
+ measureElement: Ge
409
501
  };
410
502
  }
411
- function Ge(e, t, i) {
503
+ function ft(e, t, i) {
412
504
  return typeof e == "function" ? e(t, i) : typeof e == "number" ? e : 48;
413
505
  }
414
- function we(e) {
415
- const t = te({
416
- count: () => o(e.items).length,
506
+ function Ve(e) {
507
+ const t = me({
508
+ count: () => l(e.items).length,
417
509
  estimateSize: (n) => {
418
- const r = o(e.items);
419
- return Ge(e.estimateSize, n, r[n]);
510
+ const r = l(e.items);
511
+ return ft(e.estimateSize, n, r[n]);
420
512
  },
421
513
  getItemKey: (n) => {
422
- const s = o(e.items)[n];
514
+ const s = l(e.items)[n];
423
515
  return e.getItemKey?.(s, n) ?? n;
424
516
  },
425
- itemSize: () => e.itemSize !== void 0 ? o(e.itemSize) : typeof e.estimateSize == "number" ? e.estimateSize : void 0,
517
+ itemSize: () => e.itemSize !== void 0 ? l(e.itemSize) : typeof e.estimateSize == "number" ? e.estimateSize : void 0,
426
518
  container: e.container,
427
519
  horizontal: e.horizontal,
428
520
  overscan: e.overscan,
@@ -431,11 +523,16 @@ function we(e) {
431
523
  paddingEnd: e.paddingEnd,
432
524
  initialRect: e.initialRect,
433
525
  viewportInset: e.viewportInset,
434
- revision: e.revision
526
+ revision: e.revision,
527
+ windowScroll: e.windowScroll,
528
+ scrollMargin: e.scrollMargin,
529
+ reverse: e.reverse,
530
+ onVisibleRangeChange: e.onVisibleRangeChange,
531
+ onScrollEnd: e.onScrollEnd
435
532
  });
436
533
  return {
437
- virtualItems: O(() => {
438
- const n = o(e.items);
534
+ virtualItems: C(() => {
535
+ const n = l(e.items);
439
536
  return t.virtualItems.value.map((r) => {
440
537
  const s = n[r.index];
441
538
  return {
@@ -455,87 +552,93 @@ function we(e) {
455
552
  measureElement: t.measureElement
456
553
  };
457
554
  }
458
- function me(e, t, i) {
555
+ function Re(e, t, i) {
459
556
  return typeof e == "function" ? e(t) : typeof e == "number" ? e : i;
460
557
  }
461
- function Ne(e) {
462
- const t = O(() => Math.max(1, Math.floor(o(e.columnCount) || 1))), i = O(() => Math.ceil(o(e.items).length / t.value)), n = /* @__PURE__ */ new Map(), r = te({
558
+ function ht(e) {
559
+ const t = C(() => Math.max(1, Math.floor(l(e.columnCount) || 1))), i = C(() => Math.ceil(l(e.items).length / t.value)), n = /* @__PURE__ */ new Map(), r = me({
463
560
  count: () => i.value,
464
- estimateSize: (u) => me(o(e.estimateRowSize), u, 48),
561
+ estimateSize: (f) => Re(l(e.estimateRowSize), f, 48),
465
562
  itemSize: () => {
466
- const u = o(e.estimateRowSize);
467
- return typeof u == "number" ? u : void 0;
563
+ const f = l(e.estimateRowSize);
564
+ return typeof f == "number" ? f : void 0;
468
565
  },
469
- overscan: () => o(e.overscanRows) ?? o(e.overscan) ?? 2,
470
- gap: () => o(e.rowGap) ?? 0,
566
+ overscan: () => l(e.overscanRows) ?? l(e.overscan) ?? 2,
567
+ gap: () => l(e.rowGap) ?? 0,
471
568
  horizontal: !1,
472
569
  container: e.container,
473
570
  initialRect: e.initialRect,
474
- revision: e.revision
475
- }), s = te({
571
+ revision: e.revision,
572
+ windowScroll: e.windowScroll,
573
+ scrollMargin: e.scrollMargin,
574
+ onVisibleRangeChange: e.onVisibleRangeChange,
575
+ onScrollEnd: e.onScrollEnd
576
+ }), s = me({
476
577
  count: () => t.value,
477
- estimateSize: (u) => me(o(e.estimateColumnSize), u, 160),
578
+ estimateSize: (f) => Re(l(e.estimateColumnSize), f, 160),
478
579
  itemSize: () => {
479
- const u = o(e.estimateColumnSize);
480
- return typeof u == "number" ? u : void 0;
580
+ const f = l(e.estimateColumnSize);
581
+ return typeof f == "number" ? f : void 0;
481
582
  },
482
- overscan: () => o(e.overscanColumns) ?? o(e.overscan) ?? 1,
483
- gap: () => o(e.columnGap) ?? 0,
583
+ overscan: () => l(e.overscanColumns) ?? l(e.overscan) ?? 1,
584
+ gap: () => l(e.columnGap) ?? 0,
484
585
  horizontal: !0,
485
586
  container: e.container,
486
587
  initialRect: e.initialRect,
487
- revision: e.revision
488
- }), d = O(() => {
489
- const u = o(e.items), c = t.value, h = [];
490
- for (const l of r.virtualItems.value)
491
- for (const S of s.virtualItems.value) {
492
- const m = l.index * c + S.index;
493
- if (m >= u.length) continue;
494
- const N = u[m];
495
- h.push({
496
- index: m,
497
- key: e.getItemKey?.(N, m) ?? m,
498
- item: N,
499
- row: l,
500
- column: S
588
+ revision: e.revision,
589
+ windowScroll: e.windowScroll,
590
+ scrollMargin: e.scrollMargin
591
+ }), d = C(() => {
592
+ const f = l(e.items), b = t.value, S = [];
593
+ for (const v of r.virtualItems.value)
594
+ for (const z of s.virtualItems.value) {
595
+ const h = v.index * b + z.index;
596
+ if (h >= f.length) continue;
597
+ const T = f[h];
598
+ S.push({
599
+ index: h,
600
+ key: e.getItemKey?.(T, h) ?? h,
601
+ item: T,
602
+ row: v,
603
+ column: z
501
604
  });
502
605
  }
503
- return h;
606
+ return S;
504
607
  });
505
- function p(u, c) {
506
- const h = o(e.items);
507
- if (!h.length) return;
508
- const l = Math.min(Math.max(u, 0), h.length - 1), S = t.value;
509
- r.scrollToIndex(Math.floor(l / S), c), s.scrollToIndex(l % S, c);
510
- }
511
- function w(u, c = "auto") {
512
- u.top !== void 0 && r.scrollToOffset(u.top, c), u.left !== void 0 && s.scrollToOffset(u.left, c);
513
- }
514
- function I(u, c) {
515
- const h = Math.max(n.get(u) ?? 0, c);
516
- h <= 0 || h === n.get(u) || (n.set(u, h), r.measure(u, h));
517
- }
518
- let y = null;
519
- const b = /* @__PURE__ */ new Map();
520
- function E() {
521
- return !D() || typeof ResizeObserver > "u" ? null : (y || (y = new ResizeObserver((u) => {
522
- for (const c of u) {
523
- const h = b.get(c.target);
524
- if (h === void 0) continue;
525
- const S = c.borderBoxSize?.[0]?.blockSize ?? c.contentRect.height;
526
- S > 0 && I(h, S);
608
+ function I(f, b) {
609
+ const S = l(e.items);
610
+ if (!S.length) return;
611
+ const v = Math.min(Math.max(f, 0), S.length - 1), z = t.value;
612
+ r.scrollToIndex(Math.floor(v / z), b), s.scrollToIndex(v % z, b);
613
+ }
614
+ function O(f, b = "auto") {
615
+ f.top !== void 0 && r.scrollToOffset(f.top, b), f.left !== void 0 && s.scrollToOffset(f.left, b);
616
+ }
617
+ function p(f, b) {
618
+ const S = Math.max(n.get(f) ?? 0, b);
619
+ S <= 0 || S === n.get(f) || (n.set(f, S), r.measure(f, S));
620
+ }
621
+ let c = null;
622
+ const g = /* @__PURE__ */ new Map();
623
+ function k() {
624
+ return !Z() || typeof ResizeObserver > "u" ? null : (c || (c = new ResizeObserver((f) => {
625
+ for (const b of f) {
626
+ const S = g.get(b.target);
627
+ if (S === void 0) continue;
628
+ const z = b.borderBoxSize?.[0]?.blockSize ?? b.contentRect.height;
629
+ z > 0 && p(S, z);
527
630
  }
528
- })), y);
631
+ })), c);
529
632
  }
530
- function C(u, c) {
531
- const h = ye(u), l = E();
532
- if (!h) return;
533
- b.set(h, c), l?.observe(h);
534
- const S = h.getBoundingClientRect().height;
535
- S > 0 && I(c, S);
633
+ function A(f, b) {
634
+ const S = ke(f), v = k();
635
+ if (!S) return;
636
+ g.set(S, b), v?.observe(S);
637
+ const z = S.getBoundingClientRect().height;
638
+ z > 0 && p(b, z);
536
639
  }
537
- return Se(() => {
538
- y?.disconnect(), b.clear();
640
+ return Ce(() => {
641
+ c?.disconnect(), g.clear();
539
642
  }), {
540
643
  virtualRows: r.virtualItems,
541
644
  virtualColumns: s.virtualItems,
@@ -544,15 +647,15 @@ function Ne(e) {
544
647
  totalWidth: s.totalSize,
545
648
  scrollAdjustX: s.scrollAdjust,
546
649
  scrollAdjustY: r.scrollAdjust,
547
- scrollToIndex: p,
548
- scrollToOffset: w,
549
- measureRow: I,
550
- measureRowElement: C,
650
+ scrollToIndex: I,
651
+ scrollToOffset: O,
652
+ measureRow: p,
653
+ measureRowElement: A,
551
654
  measureColumn: s.measure
552
655
  };
553
656
  }
554
- function Be(e) {
555
- const t = we({
657
+ function mt(e) {
658
+ const t = Ve({
556
659
  items: e.rows,
557
660
  estimateSize: e.estimateRowSize,
558
661
  container: e.container,
@@ -561,25 +664,49 @@ function Be(e) {
561
664
  initialRect: e.initialRect,
562
665
  viewportInset: e.viewportInset,
563
666
  revision: e.revision,
564
- itemSize: e.itemSize
565
- }), i = O(() => {
566
- const s = o(e.columns);
667
+ itemSize: e.itemSize,
668
+ windowScroll: e.windowScroll,
669
+ scrollMargin: e.scrollMargin,
670
+ reverse: e.reverse,
671
+ onVisibleRangeChange: e.onVisibleRangeChange,
672
+ onScrollEnd: e.onScrollEnd
673
+ }), i = C(() => {
674
+ const s = l(e.columns);
567
675
  let d = 0;
568
- return s.map((p) => {
569
- const w = p.width ?? p.minWidth ?? 160, I = {
570
- ...p,
676
+ const I = s.map((c) => {
677
+ const g = c.width ?? c.minWidth ?? 160, k = {
678
+ ...c,
571
679
  start: d,
572
- size: w,
573
- end: d + w
680
+ size: g,
681
+ end: d + g,
682
+ pinOffset: 0,
683
+ stickyStyle: {}
574
684
  };
575
- return d += w, I;
685
+ return d += g, k;
576
686
  });
577
- }), n = O(() => {
687
+ let O = 0;
688
+ for (const c of I)
689
+ c.pin === "start" && (c.pinOffset = O, c.stickyStyle = {
690
+ position: "sticky",
691
+ left: `${O}px`,
692
+ zIndex: 2
693
+ }, O += c.size);
694
+ let p = 0;
695
+ for (let c = I.length - 1; c >= 0; c -= 1) {
696
+ const g = I[c];
697
+ !g || g.pin !== "end" || (g.pinOffset = p, g.stickyStyle = {
698
+ position: "sticky",
699
+ right: `${p}px`,
700
+ zIndex: 2
701
+ }, p += g.size);
702
+ }
703
+ return I;
704
+ }), n = C(() => {
578
705
  const s = i.value;
579
706
  return s.length ? s[s.length - 1]?.end ?? 0 : 0;
580
707
  });
581
708
  return {
582
- virtualRows: O(() => t.virtualItems.value),
709
+ virtualRows: C(() => t.virtualItems.value),
583
710
  columns: i,
584
711
  totalHeight: t.totalSize,
585
712
  totalWidth: n,
@@ -592,11 +719,11 @@ function Be(e) {
592
719
  measureElement: t.measureElement
593
720
  };
594
721
  }
595
- function ge(e) {
722
+ function oe(e) {
596
723
  if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
597
724
  if (typeof e == "string" && e.trim()) return e;
598
725
  }
599
- function H(e) {
726
+ function Q(e) {
600
727
  if (typeof e == "number" && Number.isFinite(e)) return e;
601
728
  if (typeof e != "string") return 0;
602
729
  const t = /^(-?\d+(?:\.\d+)?)px$/.exec(e.trim());
@@ -604,34 +731,42 @@ function H(e) {
604
731
  const i = Number(t[1]);
605
732
  return Number.isFinite(i) ? i : 0;
606
733
  }
607
- function re(e) {
608
- return {
734
+ function Se(e) {
735
+ return e.windowScroll ? {
736
+ position: "relative",
737
+ width: oe(e.width) ?? "100%",
738
+ height: oe(e.height),
739
+ overflowAnchor: "none"
740
+ } : {
609
741
  overflow: "auto",
610
742
  position: "relative",
611
- height: ge(e.height) ?? (e.horizontal ? "100%" : void 0),
612
- width: ge(e.width) ?? (e.horizontal ? void 0 : "100%"),
743
+ height: oe(e.height) ?? (e.horizontal ? "100%" : void 0),
744
+ width: oe(e.width) ?? (e.horizontal ? void 0 : "100%"),
613
745
  overflowAnchor: "none"
614
746
  };
615
747
  }
616
- function He(e, t) {
617
- const i = G(e);
748
+ function gt(e, t) {
749
+ const i = H(e);
618
750
  return {
619
751
  position: "relative",
620
752
  width: t ? `${i}px` : "100%",
621
753
  height: t ? "100%" : `${i}px`
622
754
  };
623
755
  }
624
- function Pe(e, t) {
756
+ function wt(e, t, i) {
625
757
  return {
626
758
  position: "absolute",
627
759
  top: 0,
628
760
  left: 0,
629
- width: t ? void 0 : "100%",
630
- height: t ? "100%" : void 0,
631
- transform: t ? `translateX(${e}px)` : `translateY(${e}px)`
761
+ width: t ? i === void 0 ? void 0 : `${i}px` : "100%",
762
+ height: t ? "100%" : i === void 0 ? void 0 : `${i}px`,
763
+ transform: t ? `translateX(${e}px)` : `translateY(${e}px)`,
764
+ contain: "layout style",
765
+ boxSizing: "border-box",
766
+ overflow: "hidden"
632
767
  };
633
768
  }
634
- const Xe = /* @__PURE__ */ ie({
769
+ const yt = /* @__PURE__ */ ge({
635
770
  __name: "VirtualList",
636
771
  props: {
637
772
  items: {},
@@ -639,7 +774,7 @@ const Xe = /* @__PURE__ */ ie({
639
774
  height: {},
640
775
  width: {},
641
776
  horizontal: { type: Boolean, default: !1 },
642
- overscan: { default: 5 },
777
+ overscan: { default: 8 },
643
778
  gap: { default: 0 },
644
779
  paddingStart: { default: 0 },
645
780
  paddingEnd: { default: 0 },
@@ -647,88 +782,98 @@ const Xe = /* @__PURE__ */ ie({
647
782
  tag: { default: "div" },
648
783
  itemTag: { default: "div" },
649
784
  itemAttrs: {},
650
- revision: {}
785
+ revision: {},
786
+ windowScroll: { type: Boolean, default: !1 },
787
+ scrollMargin: { default: 0 },
788
+ reverse: { type: Boolean, default: !1 }
651
789
  },
652
- setup(e, { expose: t }) {
653
- const i = e, n = L(null), { virtualItems: r, totalSize: s, scrollAdjust: d, scrollToIndex: p, scrollToOffset: w, measure: I, measureElement: y } = we({
654
- items: () => i.items,
655
- estimateSize: (c, h) => {
656
- const l = i.estimateSize;
657
- return typeof l == "number" ? l : l(c, h);
790
+ emits: ["visibleRangeChange", "scrollEnd"],
791
+ setup(e, { expose: t, emit: i }) {
792
+ const n = e, r = i, s = W(null), { virtualItems: d, totalSize: I, scrollAdjust: O, scrollToIndex: p, scrollToOffset: c, measure: g, measureElement: k } = Ve({
793
+ items: () => n.items,
794
+ estimateSize: (v, z) => {
795
+ const h = n.estimateSize;
796
+ return typeof h == "number" ? h : h(v, z);
658
797
  },
659
- itemSize: () => typeof i.estimateSize == "number" ? i.estimateSize : void 0,
660
- container: n,
661
- horizontal: () => i.horizontal,
662
- overscan: () => i.overscan,
663
- gap: () => i.gap,
664
- paddingStart: () => i.paddingStart,
665
- paddingEnd: () => i.paddingEnd,
666
- getItemKey: (c, h) => i.getItemKey?.(c, h) ?? h,
798
+ itemSize: () => typeof n.estimateSize == "number" ? n.estimateSize : void 0,
799
+ container: s,
800
+ horizontal: () => n.horizontal,
801
+ overscan: () => n.overscan,
802
+ gap: () => n.gap,
803
+ paddingStart: () => n.paddingStart,
804
+ paddingEnd: () => n.paddingEnd,
805
+ getItemKey: (v, z) => n.getItemKey?.(v, z) ?? z,
667
806
  initialRect: () => ({
668
- width: H(i.width),
669
- height: H(i.height)
807
+ width: Q(n.width),
808
+ height: Q(n.height)
670
809
  }),
671
- revision: () => i.revision
672
- }), b = O(
673
- () => re({
674
- height: i.height,
675
- width: i.width,
676
- horizontal: i.horizontal
810
+ revision: () => n.revision,
811
+ windowScroll: () => n.windowScroll,
812
+ scrollMargin: () => n.scrollMargin,
813
+ reverse: () => n.reverse,
814
+ onVisibleRangeChange: (v) => r("visibleRangeChange", v),
815
+ onScrollEnd: () => r("scrollEnd")
816
+ }), A = C(
817
+ () => Se({
818
+ height: n.height,
819
+ width: n.width,
820
+ horizontal: n.horizontal,
821
+ windowScroll: n.windowScroll
677
822
  })
678
- ), E = O(() => He(s.value, i.horizontal));
679
- function C(c) {
680
- return Pe(c, i.horizontal);
823
+ ), f = C(() => gt(I.value, n.horizontal));
824
+ function b(v, z) {
825
+ return wt(v, n.horizontal, z);
681
826
  }
682
- function u(c) {
683
- return (h) => {
684
- y(h, c);
827
+ function S(v) {
828
+ return (z) => {
829
+ k(z, v);
685
830
  };
686
831
  }
687
832
  return t({
688
833
  scrollToIndex: p,
689
- scrollToOffset: w,
690
- measure: I
691
- }), (c, h) => (T(), q(U(e.tag), {
834
+ scrollToOffset: c,
835
+ measure: g
836
+ }), (v, z) => (V(), le(ae(e.tag), {
692
837
  ref_key: "container",
693
- ref: n,
838
+ ref: s,
694
839
  "data-virtual-container": "",
695
840
  role: "list",
696
- style: F(b.value)
841
+ style: B(A.value)
697
842
  }, {
698
- default: Z(() => [
699
- e.items.length ? (T(), V("div", {
843
+ default: ce(() => [
844
+ e.items.length ? (V(), K("div", {
700
845
  key: 1,
701
846
  "data-virtual-spacer": "",
702
- style: F(E.value)
847
+ style: B(f.value)
703
848
  }, [
704
- (T(!0), V(W, null, _(K(r), (l) => (T(), q(U(e.itemTag), ne({
705
- key: l.key,
849
+ (V(!0), K(te, null, ne(j(d), (h) => (V(), le(ae(e.itemTag), we({
850
+ key: h.key,
706
851
  ref_for: !0,
707
- ref: u(l.index),
852
+ ref: S(h.index),
708
853
  role: "listitem",
709
- "data-index": l.index,
710
- "data-key": String(l.key),
854
+ "data-index": h.index,
855
+ "data-key": String(h.key),
711
856
  "aria-setsize": e.items.length,
712
- "aria-posinset": l.index + 1,
713
- style: C(l.start - K(d))
857
+ "aria-posinset": h.index + 1,
858
+ style: b(h.start - j(O), h.size)
714
859
  }, { ref_for: !0 }, e.itemAttrs), {
715
- default: Z(() => [
716
- j(c.$slots, "default", {
717
- item: l.item,
718
- index: l.index,
719
- start: l.start,
720
- size: l.size,
721
- end: l.end
860
+ default: ce(() => [
861
+ U(v.$slots, "default", {
862
+ item: h.item,
863
+ index: h.index,
864
+ start: h.start,
865
+ size: h.size,
866
+ end: h.end
722
867
  })
723
868
  ]),
724
869
  _: 2
725
870
  }, 1040, ["data-index", "data-key", "aria-setsize", "aria-posinset", "style"]))), 128))
726
- ], 4)) : j(c.$slots, "empty", {}, void 0, void 0, 0)
871
+ ], 4)) : U(v.$slots, "empty", {}, void 0, void 0, 0)
727
872
  ]),
728
873
  _: 3
729
874
  }, 8, ["style"]));
730
875
  }
731
- }), We = ["data-index", "data-key"], Ye = /* @__PURE__ */ ie({
876
+ }), St = ["data-index", "data-key"], xt = /* @__PURE__ */ ge({
732
877
  __name: "VirtualGrid",
733
878
  props: {
734
879
  items: {},
@@ -745,102 +890,114 @@ const Xe = /* @__PURE__ */ ie({
745
890
  getItemKey: {},
746
891
  tag: { default: "div" },
747
892
  itemAttrs: {},
748
- revision: {}
893
+ revision: {},
894
+ windowScroll: { type: Boolean, default: !1 },
895
+ scrollMargin: { default: 0 }
749
896
  },
750
- setup(e, { expose: t }) {
751
- const i = e, n = L(null), {
752
- virtualCells: r,
753
- totalWidth: s,
754
- totalHeight: d,
897
+ emits: ["visibleRangeChange", "scrollEnd"],
898
+ setup(e, { expose: t, emit: i }) {
899
+ const n = e, r = i, s = W(null), {
900
+ virtualCells: d,
901
+ totalWidth: I,
902
+ totalHeight: O,
755
903
  scrollAdjustX: p,
756
- scrollAdjustY: w,
757
- scrollToIndex: I,
758
- scrollToOffset: y,
759
- measureRow: b,
760
- measureRowElement: E
761
- } = Ne({
762
- items: () => i.items,
763
- columnCount: () => i.columnCount,
764
- estimateRowSize: () => i.estimateRowSize,
765
- estimateColumnSize: () => i.estimateColumnSize,
766
- container: n,
767
- overscan: () => i.overscan,
768
- overscanRows: () => i.overscanRows,
769
- overscanColumns: () => i.overscanColumns,
770
- rowGap: () => i.rowGap,
771
- columnGap: () => i.columnGap,
772
- getItemKey: (l, S) => i.getItemKey?.(l, S) ?? S,
904
+ scrollAdjustY: c,
905
+ scrollToIndex: g,
906
+ scrollToOffset: k,
907
+ measureRow: A,
908
+ measureRowElement: f
909
+ } = ht({
910
+ items: () => n.items,
911
+ columnCount: () => n.columnCount,
912
+ estimateRowSize: () => n.estimateRowSize,
913
+ estimateColumnSize: () => n.estimateColumnSize,
914
+ container: s,
915
+ overscan: () => n.overscan,
916
+ overscanRows: () => n.overscanRows,
917
+ overscanColumns: () => n.overscanColumns,
918
+ rowGap: () => n.rowGap,
919
+ columnGap: () => n.columnGap,
920
+ getItemKey: (h, T) => n.getItemKey?.(h, T) ?? T,
773
921
  initialRect: () => ({
774
- width: H(i.width),
775
- height: H(i.height)
922
+ width: Q(n.width),
923
+ height: Q(n.height)
776
924
  }),
777
- revision: () => i.revision
778
- }), C = O(
779
- () => re({
780
- height: i.height,
781
- width: i.width,
782
- horizontal: !1
925
+ revision: () => n.revision,
926
+ windowScroll: () => n.windowScroll,
927
+ scrollMargin: () => n.scrollMargin,
928
+ onVisibleRangeChange: (h) => r("visibleRangeChange", h),
929
+ onScrollEnd: () => r("scrollEnd")
930
+ }), b = C(
931
+ () => Se({
932
+ height: n.height,
933
+ width: n.width,
934
+ horizontal: !1,
935
+ windowScroll: n.windowScroll
783
936
  })
784
- ), u = O(() => ({
937
+ ), S = C(() => ({
785
938
  position: "relative",
786
- width: `${G(s.value)}px`,
787
- height: `${G(d.value)}px`
939
+ width: `${H(I.value)}px`,
940
+ height: `${H(O.value)}px`
788
941
  }));
789
- function c(l) {
790
- return (S) => {
791
- E(S, l);
942
+ function v(h) {
943
+ return (T) => {
944
+ f(T, h);
792
945
  };
793
946
  }
794
- function h(l, S, m) {
947
+ function z(h, T, M, G) {
795
948
  return {
796
949
  position: "absolute",
797
950
  top: 0,
798
951
  left: 0,
799
- width: `${S}px`,
800
- transform: `translate(${l}px, ${m}px)`
952
+ width: `${T}px`,
953
+ height: `${G}px`,
954
+ transform: `translate(${h}px, ${M}px)`,
955
+ contain: "layout style",
956
+ boxSizing: "border-box",
957
+ overflow: "hidden"
801
958
  };
802
959
  }
803
960
  return t({
804
- scrollToIndex: I,
805
- scrollToOffset: y,
806
- measureRow: b
807
- }), (l, S) => (T(), q(U(e.tag), {
961
+ scrollToIndex: g,
962
+ scrollToOffset: k,
963
+ measureRow: A
964
+ }), (h, T) => (V(), le(ae(e.tag), {
808
965
  ref_key: "container",
809
- ref: n,
966
+ ref: s,
810
967
  "data-virtual-container": "",
811
968
  role: "grid",
812
- style: F(C.value)
969
+ style: B(b.value)
813
970
  }, {
814
- default: Z(() => [
815
- e.items.length ? (T(), V("div", {
971
+ default: ce(() => [
972
+ e.items.length ? (V(), K("div", {
816
973
  key: 1,
817
974
  "data-virtual-spacer": "",
818
- style: F(u.value)
975
+ style: B(S.value)
819
976
  }, [
820
- (T(!0), V(W, null, _(K(r), (m) => (T(), V("div", ne({
821
- key: m.key,
977
+ (V(!0), K(te, null, ne(j(d), (M) => (V(), K("div", we({
978
+ key: M.key,
822
979
  ref_for: !0,
823
- ref: c(m.row.index),
980
+ ref: v(M.row.index),
824
981
  role: "gridcell",
825
- "data-index": m.index,
826
- "data-key": String(m.key),
827
- style: h(m.column.start - K(p), m.column.size, m.row.start - K(w))
982
+ "data-index": M.index,
983
+ "data-key": String(M.key),
984
+ style: z(M.column.start - j(p), M.column.size, M.row.start - j(c), M.row.size)
828
985
  }, { ref_for: !0 }, e.itemAttrs), [
829
- j(l.$slots, "default", {
830
- item: m.item,
831
- index: m.index,
832
- rowIndex: m.row.index,
833
- columnIndex: m.column.index,
834
- row: m.row,
835
- column: m.column
986
+ U(h.$slots, "default", {
987
+ item: M.item,
988
+ index: M.index,
989
+ rowIndex: M.row.index,
990
+ columnIndex: M.column.index,
991
+ row: M.row,
992
+ column: M.column
836
993
  })
837
- ], 16, We))), 128))
838
- ], 4)) : j(l.$slots, "empty", {}, void 0, void 0, 0)
994
+ ], 16, St))), 128))
995
+ ], 4)) : U(h.$slots, "empty", {}, void 0, void 0, 0)
839
996
  ]),
840
997
  _: 3
841
998
  }, 8, ["style"]));
842
999
  }
843
- }), _e = ["data-index", "data-key", "aria-rowindex"], qe = /* @__PURE__ */ ie({
1000
+ }), vt = ["data-index", "data-key", "aria-rowindex"], pt = /* @__PURE__ */ ge({
844
1001
  __name: "VirtualTable",
845
1002
  props: {
846
1003
  rows: {},
@@ -848,155 +1005,171 @@ const Xe = /* @__PURE__ */ ie({
848
1005
  estimateRowSize: { type: [Number, Function], default: 44 },
849
1006
  height: {},
850
1007
  width: {},
851
- overscan: { default: 5 },
1008
+ overscan: { default: 8 },
852
1009
  getRowKey: {},
853
1010
  stickyHeader: { type: Boolean, default: !0 },
854
1011
  tag: { default: "div" },
855
1012
  rowAttrs: {},
856
- revision: {}
1013
+ revision: {},
1014
+ windowScroll: { type: Boolean, default: !1 },
1015
+ scrollMargin: { default: 0 },
1016
+ reverse: { type: Boolean, default: !1 }
857
1017
  },
858
- setup(e, { expose: t }) {
859
- const i = e, n = L(null), r = L(null), s = L(0), {
860
- virtualRows: d,
1018
+ emits: ["visibleRangeChange", "scrollEnd"],
1019
+ setup(e, { expose: t, emit: i }) {
1020
+ const n = e, r = i, s = W(null), d = W(null), I = W(0), {
1021
+ virtualRows: O,
861
1022
  columns: p,
862
- totalWidth: w,
863
- totalHeight: I,
864
- scrollAdjust: y,
865
- scrollToIndex: b,
866
- scrollToOffset: E,
867
- measure: C,
868
- measureElement: u
869
- } = Be({
870
- rows: () => i.rows,
871
- columns: () => i.columns,
872
- estimateRowSize: (v, x) => {
873
- const z = i.estimateRowSize;
874
- return typeof z == "number" ? z : z(v, x);
1023
+ totalWidth: c,
1024
+ totalHeight: g,
1025
+ scrollAdjust: k,
1026
+ scrollToIndex: A,
1027
+ scrollToOffset: f,
1028
+ measure: b,
1029
+ measureElement: S
1030
+ } = mt({
1031
+ rows: () => n.rows,
1032
+ columns: () => n.columns,
1033
+ estimateRowSize: (u, R) => {
1034
+ const y = n.estimateRowSize;
1035
+ return typeof y == "number" ? y : y(u, R);
875
1036
  },
876
- container: n,
877
- overscan: () => i.overscan,
878
- getRowKey: (v, x) => i.getRowKey?.(v, x) ?? x,
1037
+ container: s,
1038
+ overscan: () => n.overscan,
1039
+ getRowKey: (u, R) => n.getRowKey?.(u, R) ?? R,
879
1040
  initialRect: () => ({
880
- width: H(i.width),
881
- height: H(i.height)
1041
+ width: Q(n.width),
1042
+ height: Q(n.height)
882
1043
  }),
883
- viewportInset: s,
884
- revision: () => i.revision,
885
- itemSize: () => typeof i.estimateRowSize == "number" ? i.estimateRowSize : void 0
1044
+ viewportInset: I,
1045
+ revision: () => n.revision,
1046
+ itemSize: () => typeof n.estimateRowSize == "number" ? n.estimateRowSize : void 0,
1047
+ windowScroll: () => n.windowScroll,
1048
+ scrollMargin: () => n.scrollMargin,
1049
+ reverse: () => n.reverse,
1050
+ onVisibleRangeChange: (u) => r("visibleRangeChange", u),
1051
+ onScrollEnd: () => r("scrollEnd")
886
1052
  });
887
- ve(r, (v, x, z) => {
888
- if (x === v && !v || !v || !D() || typeof ResizeObserver > "u") return;
889
- const k = () => {
890
- s.value = v.getBoundingClientRect().height;
891
- }, Y = new ResizeObserver(k);
892
- Y.observe(v), k(), z(() => Y.disconnect());
1053
+ Ee(d, (u, R, y) => {
1054
+ if (R === u && !u || !u || !Z() || typeof ResizeObserver > "u") return;
1055
+ const L = () => {
1056
+ I.value = u.getBoundingClientRect().height;
1057
+ }, ee = new ResizeObserver(L);
1058
+ ee.observe(u), L(), y(() => ee.disconnect());
893
1059
  });
894
- const c = O(
895
- () => re({
896
- height: i.height,
897
- width: i.width,
898
- horizontal: !1
1060
+ const v = C(
1061
+ () => Se({
1062
+ height: n.height,
1063
+ width: n.width,
1064
+ horizontal: !1,
1065
+ windowScroll: n.windowScroll
899
1066
  })
900
- ), h = O(() => ({
901
- minWidth: `${w.value}px`
902
- })), l = O(() => ({
903
- position: i.stickyHeader ? "sticky" : "relative",
904
- top: i.stickyHeader ? "0px" : void 0,
905
- zIndex: 1,
1067
+ ), z = C(() => ({
1068
+ minWidth: `${c.value}px`
1069
+ })), h = C(() => ({
1070
+ position: n.stickyHeader ? "sticky" : "relative",
1071
+ top: n.stickyHeader ? "0px" : void 0,
1072
+ zIndex: 3,
906
1073
  display: "flex",
907
- width: `${w.value}px`
908
- })), S = O(() => ({
1074
+ width: `${c.value}px`
1075
+ })), T = C(() => ({
909
1076
  position: "relative",
910
- height: `${G(I.value)}px`,
911
- width: `${G(w.value)}px`
1077
+ height: `${H(g.value)}px`,
1078
+ width: `${H(c.value)}px`
912
1079
  }));
913
- function m(v) {
1080
+ function M(u) {
914
1081
  return {
915
- width: `${v.size}px`,
916
- minWidth: `${v.size}px`,
1082
+ width: `${u.size}px`,
1083
+ minWidth: `${u.size}px`,
917
1084
  flex: "0 0 auto",
918
- textAlign: v.align ?? "left"
1085
+ textAlign: u.align ?? "left",
1086
+ ...u.stickyStyle,
1087
+ zIndex: u.pin ? n.stickyHeader ? 4 : 2 : u.stickyStyle.zIndex
919
1088
  };
920
1089
  }
921
- function N(v) {
1090
+ function G(u, R) {
922
1091
  return {
923
1092
  position: "absolute",
924
1093
  top: 0,
925
1094
  left: 0,
926
1095
  width: "100%",
1096
+ height: `${R}px`,
927
1097
  display: "flex",
928
- transform: `translateY(${v}px)`
1098
+ transform: `translateY(${u}px)`,
1099
+ contain: "layout style",
1100
+ boxSizing: "border-box",
1101
+ overflow: "hidden"
929
1102
  };
930
1103
  }
931
- function X(v) {
932
- return (x) => {
933
- u(x, v);
1104
+ function D(u) {
1105
+ return (R) => {
1106
+ S(R, u);
934
1107
  };
935
1108
  }
936
- function P(v, x, z) {
937
- return x.accessor ? x.accessor(v, z) : v && typeof v == "object" && x.id in v ? v[x.id] : "";
1109
+ function $(u, R, y) {
1110
+ return R.accessor ? R.accessor(u, y) : u && typeof u == "object" && R.id in u ? u[R.id] : "";
938
1111
  }
939
1112
  return t({
940
- scrollToIndex: b,
941
- scrollToOffset: E,
942
- measure: C
943
- }), (v, x) => (T(), q(U(e.tag), {
1113
+ scrollToIndex: A,
1114
+ scrollToOffset: f,
1115
+ measure: b
1116
+ }), (u, R) => (V(), le(ae(e.tag), {
944
1117
  ref_key: "container",
945
- ref: n,
1118
+ ref: s,
946
1119
  "data-virtual-container": "",
947
1120
  role: "table",
948
- style: F(c.value)
1121
+ style: B(v.value)
949
1122
  }, {
950
- default: Z(() => [
951
- le("div", {
952
- style: F(h.value)
1123
+ default: ce(() => [
1124
+ Me("div", {
1125
+ style: B(z.value)
953
1126
  }, [
954
- le("div", {
1127
+ Me("div", {
955
1128
  ref_key: "header",
956
- ref: r,
1129
+ ref: d,
957
1130
  role: "row",
958
- style: F(l.value)
1131
+ style: B(h.value)
959
1132
  }, [
960
- j(v.$slots, "header", { columns: K(p) }, () => [
961
- (T(!0), V(W, null, _(K(p), (z) => (T(), V("div", {
962
- key: z.id,
1133
+ U(u.$slots, "header", { columns: j(p) }, () => [
1134
+ (V(!0), K(te, null, ne(j(p), (y) => (V(), K("div", {
1135
+ key: y.id,
963
1136
  role: "columnheader",
964
- style: F(m(z))
965
- }, ue(z.header), 5))), 128))
1137
+ style: B(M(y))
1138
+ }, Oe(y.header), 5))), 128))
966
1139
  ])
967
1140
  ], 4),
968
- e.rows.length ? (T(), V("div", {
1141
+ e.rows.length ? (V(), K("div", {
969
1142
  key: 1,
970
1143
  "data-virtual-spacer": "",
971
1144
  role: "rowgroup",
972
- style: F(S.value)
1145
+ style: B(T.value)
973
1146
  }, [
974
- (T(!0), V(W, null, _(K(d), (z) => (T(), V("div", ne({
975
- key: z.key,
1147
+ (V(!0), K(te, null, ne(j(O), (y) => (V(), K("div", we({
1148
+ key: y.key,
976
1149
  ref_for: !0,
977
- ref: X(z.index),
1150
+ ref: D(y.index),
978
1151
  role: "row",
979
- "data-index": z.index,
980
- "data-key": String(z.key),
981
- "aria-rowindex": z.index + 1,
982
- style: N(z.start - K(y))
1152
+ "data-index": y.index,
1153
+ "data-key": String(y.key),
1154
+ "aria-rowindex": y.index + 1,
1155
+ style: G(y.start - j(k), y.size)
983
1156
  }, { ref_for: !0 }, e.rowAttrs), [
984
- (T(!0), V(W, null, _(K(p), (k) => (T(), V("div", {
985
- key: k.id,
1157
+ (V(!0), K(te, null, ne(j(p), (L) => (V(), K("div", {
1158
+ key: L.id,
986
1159
  role: "cell",
987
- style: F(m(k))
1160
+ style: B(M(L))
988
1161
  }, [
989
- j(v.$slots, "cell", {
990
- row: z.item,
991
- column: k,
992
- rowIndex: z.index,
993
- value: P(z.item, k, z.index)
1162
+ U(u.$slots, "cell", {
1163
+ row: y.item,
1164
+ column: L,
1165
+ rowIndex: y.index,
1166
+ value: $(y.item, L, y.index)
994
1167
  }, () => [
995
- Re(ue(P(z.item, k, z.index)), 1)
1168
+ Xe(Oe($(y.item, L, y.index)), 1)
996
1169
  ])
997
1170
  ], 4))), 128))
998
- ], 16, _e))), 128))
999
- ], 4)) : j(v.$slots, "empty", {}, void 0, void 0, 0)
1171
+ ], 16, vt))), 128))
1172
+ ], 4)) : U(u.$slots, "empty", {}, void 0, void 0, 0)
1000
1173
  ], 4)
1001
1174
  ]),
1002
1175
  _: 3
@@ -1004,20 +1177,20 @@ const Xe = /* @__PURE__ */ ie({
1004
1177
  }
1005
1178
  });
1006
1179
  export {
1007
- Te as MeasurementCache,
1008
- Ye as VirtualGrid,
1009
- Xe as VirtualList,
1010
- qe as VirtualTable,
1011
- Fe as Virtualizer,
1012
- B as clampScrollOffset,
1013
- Ce as mapDomOffsetToVirtual,
1014
- ke as mapVirtualOffsetToDom,
1015
- ee as normalizeSize,
1016
- $e as resolveScrollOffset,
1017
- G as scrollContentSize,
1018
- Ne as useVirtualGrid,
1019
- we as useVirtualList,
1020
- Be as useVirtualTable,
1021
- te as useVirtualizer
1180
+ Ye as MeasurementCache,
1181
+ xt as VirtualGrid,
1182
+ yt as VirtualList,
1183
+ pt as VirtualTable,
1184
+ tt as Virtualizer,
1185
+ J as clampScrollOffset,
1186
+ Ue as mapDomOffsetToVirtual,
1187
+ Ze as mapVirtualOffsetToDom,
1188
+ he as normalizeSize,
1189
+ et as resolveScrollOffset,
1190
+ H as scrollContentSize,
1191
+ ht as useVirtualGrid,
1192
+ Ve as useVirtualList,
1193
+ mt as useVirtualTable,
1194
+ me as useVirtualizer
1022
1195
  };
1023
1196
  //# sourceMappingURL=index.mjs.map