virtua 0.49.2 → 0.50.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.
Files changed (59) hide show
  1. package/README.md +39 -5
  2. package/lib/angular/ListItem.d.ts +1 -0
  3. package/lib/angular/VList.d.ts +85 -0
  4. package/lib/angular/Virtualizer.d.ts +141 -0
  5. package/lib/angular/WindowVirtualizer.d.ts +103 -0
  6. package/lib/angular/index.d.ts +6 -0
  7. package/lib/angular/index.js +1148 -0
  8. package/lib/angular/index.js.map +1 -0
  9. package/lib/angular/utils.d.ts +19 -0
  10. package/lib/core/index.cjs +237 -233
  11. package/lib/core/index.cjs.map +1 -1
  12. package/lib/core/index.d.ts +6 -6
  13. package/lib/core/index.js +272 -272
  14. package/lib/core/index.js.map +1 -1
  15. package/lib/index.cjs +529 -499
  16. package/lib/index.cjs.map +1 -1
  17. package/lib/index.d.ts +2 -2
  18. package/lib/index.js +321 -315
  19. package/lib/index.js.map +1 -1
  20. package/lib/react/VGrid.d.ts +2 -2
  21. package/lib/react/VList.d.ts +3 -3
  22. package/lib/react/Virtualizer.d.ts +3 -3
  23. package/lib/react/WindowVirtualizer.d.ts +3 -3
  24. package/lib/react/index.d.ts +9 -9
  25. package/lib/react/types.d.ts +1 -1
  26. package/lib/solid/VList.d.ts +3 -6
  27. package/lib/solid/Virtualizer.d.ts +2 -5
  28. package/lib/solid/WindowVirtualizer.d.ts +2 -5
  29. package/lib/solid/index.cjs +331 -323
  30. package/lib/solid/index.cjs.map +1 -1
  31. package/lib/solid/index.d.ts +7 -7
  32. package/lib/solid/index.js +249 -257
  33. package/lib/solid/index.js.map +1 -1
  34. package/lib/solid/index.jsx +1224 -1566
  35. package/lib/solid/index.jsx.map +1 -1
  36. package/lib/solid/types.d.ts +1 -1
  37. package/lib/svelte/ListItem.svelte +12 -2
  38. package/lib/svelte/VList.svelte +2 -0
  39. package/lib/svelte/VList.type.d.ts +3 -3
  40. package/lib/svelte/Virtualizer.svelte +2 -0
  41. package/lib/svelte/Virtualizer.type.d.ts +8 -3
  42. package/lib/svelte/WindowVirtualizer.type.d.ts +2 -2
  43. package/lib/svelte/index.d.ts +6 -6
  44. package/lib/svelte/index.js +4 -4
  45. package/lib/svelte/types.d.ts +1 -1
  46. package/lib/svelte/utils.d.ts +7 -0
  47. package/lib/svelte/utils.js +11 -11
  48. package/lib/svelte/utils.js.map +1 -1
  49. package/lib/vue/VList.d.ts +2 -3
  50. package/lib/vue/Virtualizer.d.ts +3 -4
  51. package/lib/vue/WindowVirtualizer.d.ts +2 -3
  52. package/lib/vue/index.cjs +327 -317
  53. package/lib/vue/index.cjs.map +1 -1
  54. package/lib/vue/index.d.ts +6 -6
  55. package/lib/vue/index.js +284 -284
  56. package/lib/vue/index.js.map +1 -1
  57. package/lib/vue/utils.d.ts +1 -1
  58. package/package.json +40 -17
  59. package/lib/svelte/index.js.map +0 -1
@@ -0,0 +1,1148 @@
1
+ import * as e from "@angular/core";
2
+
3
+ import { ApplicationRef as t, ChangeDetectionStrategy as i, DestroyRef as s, ElementRef as n, TemplateRef as r, afterNextRender as o, afterRenderEffect as l, computed as a, contentChild as c, effect as u, inject as m, input as h, output as p, signal as f, untracked as d, viewChild as g } from "@angular/core";
4
+
5
+ import { NgTemplateOutlet as y } from "@angular/common";
6
+
7
+ var {min: S, max: z, abs: v, floor: b} = Math, N = (e, t, i) => S(i, z(t, e)), I = e => [ ...e ].sort((e, t) => e - t), P = "function" == typeof queueMicrotask ? queueMicrotask : e => {
8
+ Promise.resolve().then(e);
9
+ }, R = () => {
10
+ let e;
11
+ return [ new Promise(t => {
12
+ e = t;
13
+ }), e ];
14
+ }, x = e => {
15
+ let t;
16
+ return () => (e && (t = e(), e = void 0), t);
17
+ }, k = (e, t, i) => {
18
+ const s = i ? "unshift" : "push";
19
+ for (let i = 0; i < t; i++) e[s](-1);
20
+ return e;
21
+ }, q = (e, t) => {
22
+ const i = e.t[t];
23
+ return -1 === i ? e.i : i;
24
+ }, $ = (e, t, i) => {
25
+ const s = -1 === e.t[t];
26
+ return e.t[t] = i, e.o = S(t, e.o), s;
27
+ }, F = (e, t) => {
28
+ if (!e.l) return 0;
29
+ if (e.o >= t) return e.u[t];
30
+ e.o < 0 && (e.u[0] = 0, e.o = 0);
31
+ let i = e.o, s = e.u[i];
32
+ for (;i < t; ) s += q(e, i), e.u[++i] = s;
33
+ return e.o = t, s;
34
+ }, T = (e, t, i = 0, s = e.l - 1) => {
35
+ let n = i;
36
+ for (;i <= s; ) {
37
+ const r = b((i + s) / 2);
38
+ F(e, r) <= t ? (n = r, i = r + 1) : s = r - 1;
39
+ }
40
+ return N(n, 0, e.l - 1);
41
+ }, w = (e, t, i) => {
42
+ const s = t - e.l;
43
+ return e.o = i ? -1 : S(t - 1, e.o), e.l = t, s > 0 ? (k(e.u, s), k(e.t, s, i),
44
+ e.i * s) : (e.u.splice(s), (i ? e.t.splice(0, -s) : e.t.splice(s)).reduce((t, i) => t - (-1 === i ? e.i : i), 0));
45
+ }, O = e => e.documentElement, C = e => e.ownerDocument, _ = e => e.defaultView, M = /*#__PURE__*/ x(() => !!/iP(hone|od|ad)/.test(navigator.userAgent) || "MacIntel" === navigator.platform && navigator.maxTouchPoints > 0), V = /*#__PURE__*/ x(() => "scrollBehavior" in O(document).style), K = (e, t = 40, i = 0, s, n = !1) => {
46
+ let r = !!i, o = 1, l = 0, a = 0, c = 0, u = 0, m = 0, h = 0, p = 0, f = 0, d = null, g = [ 0, r ? z(i - 1, 0) : -1 ], y = 0, b = !1;
47
+ const N = ((e, t, i) => ({
48
+ i: t,
49
+ t: i ? k(i.slice(0, S(e, i.length)), z(0, e - i.length)) : k([], e),
50
+ l: e,
51
+ o: -1,
52
+ u: k([], e + 1)
53
+ }))(e, s ? s[1] : t, s && s[0]), P = /* @__PURE__ */ new Set, R = () => c - a, x = () => R() + m + u, O = (e, t) => ((e, t, i, s) => {
54
+ if (s = S(s, e.l - 1), F(e, s) <= t) {
55
+ const n = T(e, i, s);
56
+ return [ T(e, t, s, n), n ];
57
+ }
58
+ {
59
+ const n = T(e, t, void 0, s);
60
+ return [ n, T(e, i, n) ];
61
+ }
62
+ })(N, e, t, g[0]), C = () => F(N, N.l), _ = (e, t) => {
63
+ const i = F(N, e) - m;
64
+ return t ? C() - i - V(e) : i;
65
+ }, V = e => q(N, e), K = (e, t = -1) => N.t[e] === t, E = e => {
66
+ e && (M() && 0 !== p || d && 1 === f ? m += e : u += e);
67
+ };
68
+ return {
69
+ $dispose: () => {
70
+ P.clear();
71
+ },
72
+ $getStateVersion: () => o,
73
+ $getCacheSnapshot: () => (e => [ e.t.slice(), e.i ])(N),
74
+ $getRange: (e = 200) => {
75
+ if (!b || r) return g;
76
+ let t, i;
77
+ if (h) [t, i] = g; else {
78
+ let s = z(0, x()), r = s + l;
79
+ n || (e = z(0, e), 1 !== p && (s -= e), 2 !== p && (r += e)), [t, i] = g = O(z(0, s), z(0, r)),
80
+ d && (t = S(t, d[0]), i = z(i, d[1]));
81
+ }
82
+ return [ z(t, 0), S(i, N.l - 1) ];
83
+ },
84
+ $findItemIndex: e => T(N, e - a),
85
+ $isUnmeasuredItem: K,
86
+ $getItemOffset: _,
87
+ $getItemSize: V,
88
+ $getItemsLength: () => N.l,
89
+ $getScrollOffset: () => c,
90
+ $isScrolling: () => 0 !== p,
91
+ $getViewportSize: () => l,
92
+ $getStartSpacerSize: () => a,
93
+ $getTotalSize: C,
94
+ m: () => (h = u, u = 0, [ h, 2 === f ]),
95
+ $subscribe: (e, t) => {
96
+ const i = [ e, t ];
97
+ return P.add(i), () => {
98
+ P.delete(i);
99
+ };
100
+ },
101
+ $update: (e, t) => {
102
+ let i, s, g = 0;
103
+ switch (e) {
104
+ case 1:
105
+ {
106
+ if (t === c && 0 === f) break;
107
+ const e = h;
108
+ h = 0;
109
+ const i = t - c, n = v(i);
110
+ e && n < v(e) + 1 || 0 !== f || (p = i < 0 ? 2 : 1), r && (r = !1), c = t, g = 4;
111
+ const o = R();
112
+ o >= -l && o <= C() && (g += 1, s = n > l);
113
+ break;
114
+ }
115
+
116
+ case 2:
117
+ g = 8, 0 !== p && (i = !0, g += 1), p = 0, f = 0, d = null;
118
+ break;
119
+
120
+ case 3:
121
+ {
122
+ const e = t.filter(([e, t]) => !K(e, t));
123
+ if (!e.length) break;
124
+ E(e.reduce((e, [t, i]) => {
125
+ let s;
126
+ if (2 === f) s = !0; else if (d && 1 === f) s = t < d[0]; else {
127
+ const e = R(), i = _(t), n = V(t);
128
+ s = 1 !== p && 0 === f ? i + n <= e : i < e && i + n < e + l;
129
+ }
130
+ return s && (e += i - V(t)), e;
131
+ }, 0));
132
+ for (const [t, i] of e) {
133
+ const e = V(t), s = $(N, t, i);
134
+ n && (y += s ? i : i - e);
135
+ }
136
+ n && l && y > l && (E(((e, t) => {
137
+ let i = 0;
138
+ const s = [];
139
+ e.t.forEach((e, n) => {
140
+ -1 !== e && (s.push(e), n < t && i++);
141
+ }), e.o = -1;
142
+ const n = I(s), r = n.length, o = r / 2 | 0, l = r % 2 == 0 ? (n[o - 1] + n[o]) / 2 : n[o], a = e.i;
143
+ return ((e.i = l) - a) * z(t - i, 0);
144
+ })(N, T(N, x()))), n = !1), g = 3, s = !0;
145
+ break;
146
+ }
147
+
148
+ case 4:
149
+ l !== t && (l || (b = s = !0), l = t, g = 3);
150
+ break;
151
+
152
+ case 5:
153
+ t[1] ? (E(w(N, t[0], !0)), f = 2, g = 1) : (w(N, t[0]), g = 1);
154
+ break;
155
+
156
+ case 6:
157
+ a = t;
158
+ break;
159
+
160
+ case 7:
161
+ f = 1;
162
+ break;
163
+
164
+ case 8:
165
+ d = O(t, t + l), g = 1;
166
+ }
167
+ g && (o = 1 + (2147483647 & o), i && m && (u += m, m = 0), P.forEach(([e, t]) => {
168
+ g & e && t(s);
169
+ }));
170
+ }
171
+ };
172
+ }, E = setTimeout, D = (e, t) => t ? -e : e, L = (e, t, i, s, n, r) => {
173
+ const o = Date.now;
174
+ let l = 0, a = !1, c = !1, u = !1, m = !1;
175
+ const h = (() => {
176
+ let t;
177
+ const i = () => {
178
+ null != t && clearTimeout(t);
179
+ }, s = () => {
180
+ i(), t = E(() => {
181
+ t = null, (() => {
182
+ if (a || c) return a = !1, void h();
183
+ u = !1, e.$update(2);
184
+ })();
185
+ }, 150);
186
+ };
187
+ return s.h = i, s;
188
+ })(), p = () => {
189
+ l = o(), u && (m = !0), r && e.$update(6, r()), e.$update(1, s()), h();
190
+ }, f = t => {
191
+ if (a || !e.$isScrolling() || t.ctrlKey) return;
192
+ const s = o() - l;
193
+ 150 > s && 50 < s && (i ? t.deltaX : t.deltaY) && (a = !0);
194
+ }, d = () => {
195
+ c = !0, u = m = !1;
196
+ }, g = () => {
197
+ c = !1, M() && (u = !0);
198
+ };
199
+ return t.addEventListener("scroll", p), t.addEventListener("wheel", f, {
200
+ passive: !0
201
+ }), t.addEventListener("touchstart", d, {
202
+ passive: !0
203
+ }), t.addEventListener("touchend", g, {
204
+ passive: !0
205
+ }), {
206
+ p: () => {
207
+ t.removeEventListener("scroll", p), t.removeEventListener("wheel", f), t.removeEventListener("touchstart", d),
208
+ t.removeEventListener("touchend", g), h.h();
209
+ },
210
+ S: () => {
211
+ const [t, i] = e.m();
212
+ t && (n(t, i, m), m = !1, i && e.$getViewportSize() > e.$getTotalSize() && e.$update(1, s()));
213
+ }
214
+ };
215
+ }, B = (e, t, i) => {
216
+ let s;
217
+ return [ async (n, r) => {
218
+ if (!await t()) return;
219
+ s && s();
220
+ const o = () => {
221
+ const [t, i] = R();
222
+ return s = () => {
223
+ i(!1);
224
+ }, e.$getViewportSize() && E(s, 150), [ t, e.$subscribe(2, () => {
225
+ i(!0);
226
+ }) ];
227
+ };
228
+ if (r && V()) e.$update(8, n()), P(async () => {
229
+ for (;;) {
230
+ let t = !0;
231
+ for (let [i, s] = e.$getRange(); i <= s; i++) if (e.$isUnmeasuredItem(i)) {
232
+ t = !1;
233
+ break;
234
+ }
235
+ if (t) break;
236
+ const [i, s] = o();
237
+ try {
238
+ if (!await i) return;
239
+ } finally {
240
+ s();
241
+ }
242
+ }
243
+ e.$update(7), i(n(), r);
244
+ }); else for (;;) {
245
+ const [t, s] = o();
246
+ try {
247
+ if (e.$update(7), i(n()), !await t) return;
248
+ } finally {
249
+ s();
250
+ }
251
+ }
252
+ }, () => {
253
+ s && s();
254
+ } ];
255
+ }, J = e => {
256
+ let t;
257
+ return {
258
+ v(i) {
259
+ (t || (t = new (_(C(i)).ResizeObserver)(e))).observe(i);
260
+ },
261
+ N(e) {
262
+ t.unobserve(e);
263
+ },
264
+ p() {
265
+ t && t.disconnect();
266
+ }
267
+ };
268
+ }, W = class t {
269
+ index=h.required();
270
+ offset=h.required();
271
+ hide=h.required();
272
+ horizontal=h.required();
273
+ resizer=h.required();
274
+ attrs=h();
275
+ style=a(() => {
276
+ const e = this.horizontal(), t = {
277
+ contain: "layout style",
278
+ position: "absolute",
279
+ [e ? "height" : "width"]: "100%",
280
+ [e ? "top" : "left"]: "0px",
281
+ [e ? "left" : "top"]: this.offset() + "px",
282
+ visibility: this.hide() ? "hidden" : void 0,
283
+ ...this.attrs()?.style
284
+ };
285
+ return e && (t.display = "inline-flex"), t;
286
+ });
287
+ constructor() {
288
+ const e = m(n).nativeElement;
289
+ let t;
290
+ l({
291
+ read: () => {
292
+ const i = this.index();
293
+ t && t(), t = d(this.resizer)(e, i);
294
+ }
295
+ });
296
+ let i = [];
297
+ u(() => {
298
+ const t = this.attrs();
299
+ for (const t of i) e.removeAttribute(t);
300
+ i = [];
301
+ for (const s in t) "style" !== s && "class" !== s && (e.setAttribute(s, t[s]), i.push(s));
302
+ }), m(s).onDestroy(() => {
303
+ t && t();
304
+ });
305
+ }
306
+ static ɵfac=/*@__PURE__*/ e.ɵɵngDeclareFactory({
307
+ minVersion: "12.0.0",
308
+ version: "22.0.8",
309
+ ngImport: e,
310
+ type: t,
311
+ deps: [],
312
+ target: e.ɵɵFactoryTarget.Directive
313
+ });
314
+ static ɵdir=/*@__PURE__*/ e.ɵɵngDeclareDirective({
315
+ minVersion: "17.1.0",
316
+ version: "22.0.8",
317
+ type: t,
318
+ isStandalone: !0,
319
+ selector: "div[virtuaListItem]",
320
+ inputs: {
321
+ index: {
322
+ classPropertyName: "index",
323
+ publicName: "index",
324
+ isSignal: !0,
325
+ isRequired: !0,
326
+ transformFunction: null
327
+ },
328
+ offset: {
329
+ classPropertyName: "offset",
330
+ publicName: "offset",
331
+ isSignal: !0,
332
+ isRequired: !0,
333
+ transformFunction: null
334
+ },
335
+ hide: {
336
+ classPropertyName: "hide",
337
+ publicName: "hide",
338
+ isSignal: !0,
339
+ isRequired: !0,
340
+ transformFunction: null
341
+ },
342
+ horizontal: {
343
+ classPropertyName: "horizontal",
344
+ publicName: "horizontal",
345
+ isSignal: !0,
346
+ isRequired: !0,
347
+ transformFunction: null
348
+ },
349
+ resizer: {
350
+ classPropertyName: "resizer",
351
+ publicName: "resizer",
352
+ isSignal: !0,
353
+ isRequired: !0,
354
+ transformFunction: null
355
+ },
356
+ attrs: {
357
+ classPropertyName: "attrs",
358
+ publicName: "attrs",
359
+ isSignal: !0,
360
+ isRequired: !1,
361
+ transformFunction: null
362
+ }
363
+ },
364
+ host: {
365
+ properties: {
366
+ style: "style()",
367
+ class: "attrs()?.class"
368
+ }
369
+ },
370
+ ngImport: e
371
+ });
372
+ }, j = (e, t) => "_" + t, X = class i {
373
+ data=h.required();
374
+ getKey=h(j);
375
+ itemProps=h();
376
+ bufferSize=h();
377
+ scrollRef=h();
378
+ itemSize=h();
379
+ ssrCount=h();
380
+ shift=h(!1);
381
+ horizontal=h(!1);
382
+ keepMounted=h();
383
+ cache=h();
384
+ startMargin=h(0);
385
+ scroll=p();
386
+ scrollEnd=p();
387
+ itemTemplate=h();
388
+ contentTemplate=c(r);
389
+ template=a(() => this.itemTemplate() ?? this.contentTemplate());
390
+ I;
391
+ resizer;
392
+ P;
393
+ R=m(n).nativeElement;
394
+ k=m(t);
395
+ q=f(void 0);
396
+ $=a(() => {
397
+ this.q();
398
+ const e = this.data().length, [t, i] = this.I.$getRange(this.bufferSize()), s = this.keepMounted(), n = [];
399
+ if (s) {
400
+ const r = new Set(s);
401
+ for (let e = t; e <= i; e++) r.add(e);
402
+ for (const t of I([ ...r ])) t < e && n.push(t);
403
+ } else for (let s = t; s <= i; s++) s < e && n.push(s);
404
+ return n;
405
+ });
406
+ items=a(() => {
407
+ this.q();
408
+ const e = this.I, t = this.data(), i = this.getKey(), s = this.itemProps(), n = this.P.$isNegative();
409
+ return this.$().map(r => {
410
+ const o = t[r];
411
+ return {
412
+ key: i(o, r),
413
+ index: r,
414
+ data: o,
415
+ offset: e.$getItemOffset(r, n),
416
+ hide: e.$isUnmeasuredItem(r),
417
+ attrs: s?.({
418
+ item: o,
419
+ index: r
420
+ })
421
+ };
422
+ });
423
+ });
424
+ containerStyle=a(() => {
425
+ this.q();
426
+ const e = this.horizontal(), t = this.I.$getTotalSize();
427
+ return {
428
+ display: "block",
429
+ contain: "size style",
430
+ "overflow-anchor": "none",
431
+ flex: "none",
432
+ position: "relative",
433
+ width: e ? t + "px" : "100%",
434
+ height: e ? "100%" : t + "px",
435
+ "pointer-events": this.I.$isScrolling() ? "none" : void 0
436
+ };
437
+ });
438
+ constructor() {
439
+ u(() => {
440
+ const e = this.data().length;
441
+ this.I && e !== this.I.$getItemsLength() && this.I.$update(5, [ e, d(this.shift) ]);
442
+ }), u(() => {
443
+ const e = this.startMargin();
444
+ this.I && e !== this.I.$getStartSpacerSize() && this.I.$update(6, e);
445
+ }), o({
446
+ read: () => {
447
+ const e = this.scrollRef() ?? this.R.parentElement;
448
+ this.resizer.$observeRoot(e), this.P.$observe(this.R, e);
449
+ }
450
+ }), l({
451
+ read: () => {
452
+ this.q(), this.P.$fixScrollJump();
453
+ }
454
+ }), m(s).onDestroy(() => {
455
+ this.I?.$dispose(), this.resizer?.$dispose(), this.P?.$dispose();
456
+ });
457
+ }
458
+ ngOnInit() {
459
+ const e = this.itemSize(), t = this.I = K(this.data().length, e, this.ssrCount(), this.cache(), !e);
460
+ this.resizer = (e => {
461
+ let t;
462
+ const i = this.horizontal() ? "width" : "height", s = /* @__PURE__ */ new WeakMap, n = J(n => {
463
+ const r = [];
464
+ for (const {target: o, contentRect: l} of n) if (o.offsetParent) if (o === t) e.$update(4, l[i]); else {
465
+ const e = s.get(o);
466
+ null != e && r.push([ e, l[i] ]);
467
+ }
468
+ r.length && e.$update(3, r);
469
+ });
470
+ return {
471
+ $observeRoot(e) {
472
+ n.v(t = e);
473
+ },
474
+ $observeItem: (e, t) => (s.set(e, t), n.v(e), () => {
475
+ s.delete(e), n.N(e);
476
+ }),
477
+ $dispose: n.p
478
+ };
479
+ })(t), this.P = ((e, t) => {
480
+ let i, s, n = R(), r = !1;
481
+ const o = t ? "scrollLeft" : "scrollTop", l = t ? "overflowX" : "overflowY", [a, c] = B(e, () => n[0], (e, s) => {
482
+ e = D(e, r), s ? i.scrollTo({
483
+ [t ? "left" : "top"]: e,
484
+ behavior: "smooth"
485
+ }) : i[o] = e;
486
+ });
487
+ return {
488
+ $observe(a, u) {
489
+ i = u, t && (r = "rtl" === getComputedStyle(u).direction), s = L(e, u, t, () => D(u[o], r), (t, i, s) => {
490
+ if (s) {
491
+ const e = u.style, t = e[l];
492
+ e[l] = "hidden", E(() => {
493
+ e[l] = t;
494
+ });
495
+ }
496
+ u[o] = D(e.$getScrollOffset() + t, r), i && c();
497
+ }), n[1](!0);
498
+ },
499
+ $dispose() {
500
+ s && s.p(), n[1](!1), n = R();
501
+ },
502
+ $isNegative: () => r,
503
+ $scrollTo(e) {
504
+ a(() => e);
505
+ },
506
+ $scrollBy(t) {
507
+ t += e.$getScrollOffset(), a(() => t);
508
+ },
509
+ $scrollToIndex(t, {align: i, smooth: s, offset: n = 0} = {}) {
510
+ if (t = N(t, 0, e.$getItemsLength() - 1), "nearest" === i) {
511
+ const s = e.$getItemOffset(t), n = e.$getScrollOffset();
512
+ if (s < n) i = "start"; else {
513
+ if (!(s + e.$getItemSize(t) > n + e.$getViewportSize())) return;
514
+ i = "end";
515
+ }
516
+ }
517
+ a(() => n + e.$getStartSpacerSize() + e.$getItemOffset(t) + ("end" === i ? e.$getItemSize(t) - e.$getViewportSize() : "center" === i ? (e.$getItemSize(t) - e.$getViewportSize()) / 2 : 0), s);
518
+ },
519
+ $fixScrollJump: () => {
520
+ s && s.S();
521
+ }
522
+ };
523
+ })(t, this.horizontal()), t.$subscribe(1, e => {
524
+ this.q.set(t.$getStateVersion()), e && this.k.tick();
525
+ }), t.$subscribe(4, () => {
526
+ this.scroll.emit(t.$getScrollOffset());
527
+ }), t.$subscribe(8, () => {
528
+ this.scrollEnd.emit();
529
+ }), this.q.set(t.$getStateVersion());
530
+ }
531
+ getCache() {
532
+ return this.I.$getCacheSnapshot();
533
+ }
534
+ getScrollOffset() {
535
+ return this.I.$getScrollOffset();
536
+ }
537
+ getScrollSize() {
538
+ return e = this.I, z(e.$getTotalSize(), e.$getViewportSize());
539
+ var e;
540
+ }
541
+ getViewportSize() {
542
+ return this.I.$getViewportSize();
543
+ }
544
+ findItemIndex(e) {
545
+ return this.I.$findItemIndex(e);
546
+ }
547
+ getItemOffset(e) {
548
+ return this.I.$getItemOffset(e);
549
+ }
550
+ getItemSize(e) {
551
+ return this.I.$getItemSize(e);
552
+ }
553
+ scrollToIndex(e, t) {
554
+ this.P.$scrollToIndex(e, t);
555
+ }
556
+ scrollTo(e) {
557
+ this.P.$scrollTo(e);
558
+ }
559
+ scrollBy(e) {
560
+ this.P.$scrollBy(e);
561
+ }
562
+ static ɵfac=/*@__PURE__*/ e.ɵɵngDeclareFactory({
563
+ minVersion: "12.0.0",
564
+ version: "22.0.8",
565
+ ngImport: e,
566
+ type: i,
567
+ deps: [],
568
+ target: e.ɵɵFactoryTarget.Component
569
+ });
570
+ static ɵcmp=/*@__PURE__*/ e.ɵɵngDeclareComponent({
571
+ minVersion: "17.0.0",
572
+ version: "22.0.8",
573
+ type: i,
574
+ isStandalone: !0,
575
+ selector: "virtua-virtualizer, [virtuaVirtualizer]",
576
+ inputs: {
577
+ data: {
578
+ classPropertyName: "data",
579
+ publicName: "data",
580
+ isSignal: !0,
581
+ isRequired: !0,
582
+ transformFunction: null
583
+ },
584
+ getKey: {
585
+ classPropertyName: "getKey",
586
+ publicName: "getKey",
587
+ isSignal: !0,
588
+ isRequired: !1,
589
+ transformFunction: null
590
+ },
591
+ itemProps: {
592
+ classPropertyName: "itemProps",
593
+ publicName: "itemProps",
594
+ isSignal: !0,
595
+ isRequired: !1,
596
+ transformFunction: null
597
+ },
598
+ bufferSize: {
599
+ classPropertyName: "bufferSize",
600
+ publicName: "bufferSize",
601
+ isSignal: !0,
602
+ isRequired: !1,
603
+ transformFunction: null
604
+ },
605
+ scrollRef: {
606
+ classPropertyName: "scrollRef",
607
+ publicName: "scrollRef",
608
+ isSignal: !0,
609
+ isRequired: !1,
610
+ transformFunction: null
611
+ },
612
+ itemSize: {
613
+ classPropertyName: "itemSize",
614
+ publicName: "itemSize",
615
+ isSignal: !0,
616
+ isRequired: !1,
617
+ transformFunction: null
618
+ },
619
+ ssrCount: {
620
+ classPropertyName: "ssrCount",
621
+ publicName: "ssrCount",
622
+ isSignal: !0,
623
+ isRequired: !1,
624
+ transformFunction: null
625
+ },
626
+ shift: {
627
+ classPropertyName: "shift",
628
+ publicName: "shift",
629
+ isSignal: !0,
630
+ isRequired: !1,
631
+ transformFunction: null
632
+ },
633
+ horizontal: {
634
+ classPropertyName: "horizontal",
635
+ publicName: "horizontal",
636
+ isSignal: !0,
637
+ isRequired: !1,
638
+ transformFunction: null
639
+ },
640
+ keepMounted: {
641
+ classPropertyName: "keepMounted",
642
+ publicName: "keepMounted",
643
+ isSignal: !0,
644
+ isRequired: !1,
645
+ transformFunction: null
646
+ },
647
+ cache: {
648
+ classPropertyName: "cache",
649
+ publicName: "cache",
650
+ isSignal: !0,
651
+ isRequired: !1,
652
+ transformFunction: null
653
+ },
654
+ startMargin: {
655
+ classPropertyName: "startMargin",
656
+ publicName: "startMargin",
657
+ isSignal: !0,
658
+ isRequired: !1,
659
+ transformFunction: null
660
+ },
661
+ itemTemplate: {
662
+ classPropertyName: "itemTemplate",
663
+ publicName: "itemTemplate",
664
+ isSignal: !0,
665
+ isRequired: !1,
666
+ transformFunction: null
667
+ }
668
+ },
669
+ outputs: {
670
+ scroll: "scroll",
671
+ scrollEnd: "scrollEnd"
672
+ },
673
+ host: {
674
+ properties: {
675
+ style: "containerStyle()"
676
+ }
677
+ },
678
+ queries: [ {
679
+ propertyName: "contentTemplate",
680
+ first: !0,
681
+ predicate: r,
682
+ emitDistinctChangesOnly: !1,
683
+ descendants: !0,
684
+ isSignal: !0
685
+ } ],
686
+ ngImport: e,
687
+ template: '\n @for (item of items(); track item.key) {\n <div\n virtuaListItem\n [index]="item.index"\n [offset]="item.offset"\n [hide]="item.hide"\n [attrs]="item.attrs"\n [horizontal]="horizontal()"\n [resizer]="resizer.$observeItem"\n >\n <ng-container\n [ngTemplateOutlet]="template()"\n [ngTemplateOutletContext]="{\n $implicit: item.data,\n index: item.index,\n }"\n />\n </div>\n }\n ',
688
+ isInline: !0,
689
+ dependencies: [ {
690
+ kind: "directive",
691
+ type: e.forwardRef(() => W),
692
+ selector: "div[virtuaListItem]",
693
+ inputs: [ "index", "offset", "hide", "horizontal", "resizer", "attrs" ]
694
+ }, {
695
+ kind: "directive",
696
+ type: e.forwardRef(() => y),
697
+ selector: "[ngTemplateOutlet]",
698
+ inputs: [ "ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector" ]
699
+ } ],
700
+ changeDetection: e.ChangeDetectionStrategy.OnPush
701
+ });
702
+ };
703
+
704
+ i.OnPush;
705
+
706
+ var Y = class t {
707
+ data=h.required();
708
+ getKey=h(j);
709
+ itemProps=h();
710
+ bufferSize=h();
711
+ itemSize=h();
712
+ ssrCount=h();
713
+ shift=h(!1);
714
+ horizontal=h(!1);
715
+ keepMounted=h();
716
+ cache=h();
717
+ scroll=p();
718
+ scrollEnd=p();
719
+ template=c.required(r);
720
+ virtualizer=g.required(X);
721
+ R=m(n).nativeElement;
722
+ ngOnInit() {
723
+ const e = this.horizontal(), t = this.R;
724
+ t.setAttribute("style", `display:${e ? "inline-block" : "block"};${e ? "overflow-x" : "overflow-y"}:auto;contain:strict;width:100%;height:100%;` + (t.getAttribute("style") || ""));
725
+ }
726
+ getCache() {
727
+ return this.virtualizer().getCache();
728
+ }
729
+ getScrollOffset() {
730
+ return this.virtualizer().getScrollOffset();
731
+ }
732
+ getScrollSize() {
733
+ return this.virtualizer().getScrollSize();
734
+ }
735
+ getViewportSize() {
736
+ return this.virtualizer().getViewportSize();
737
+ }
738
+ findItemIndex(e) {
739
+ return this.virtualizer().findItemIndex(e);
740
+ }
741
+ getItemOffset(e) {
742
+ return this.virtualizer().getItemOffset(e);
743
+ }
744
+ getItemSize(e) {
745
+ return this.virtualizer().getItemSize(e);
746
+ }
747
+ scrollToIndex(e, t) {
748
+ this.virtualizer().scrollToIndex(e, t);
749
+ }
750
+ scrollTo(e) {
751
+ this.virtualizer().scrollTo(e);
752
+ }
753
+ scrollBy(e) {
754
+ this.virtualizer().scrollBy(e);
755
+ }
756
+ static ɵfac=/*@__PURE__*/ e.ɵɵngDeclareFactory({
757
+ minVersion: "12.0.0",
758
+ version: "22.0.8",
759
+ ngImport: e,
760
+ type: t,
761
+ deps: [],
762
+ target: e.ɵɵFactoryTarget.Component
763
+ });
764
+ static ɵcmp=/*@__PURE__*/ e.ɵɵngDeclareComponent({
765
+ minVersion: "17.2.0",
766
+ version: "22.0.8",
767
+ type: t,
768
+ isStandalone: !0,
769
+ selector: "virtua-vlist",
770
+ inputs: {
771
+ data: {
772
+ classPropertyName: "data",
773
+ publicName: "data",
774
+ isSignal: !0,
775
+ isRequired: !0,
776
+ transformFunction: null
777
+ },
778
+ getKey: {
779
+ classPropertyName: "getKey",
780
+ publicName: "getKey",
781
+ isSignal: !0,
782
+ isRequired: !1,
783
+ transformFunction: null
784
+ },
785
+ itemProps: {
786
+ classPropertyName: "itemProps",
787
+ publicName: "itemProps",
788
+ isSignal: !0,
789
+ isRequired: !1,
790
+ transformFunction: null
791
+ },
792
+ bufferSize: {
793
+ classPropertyName: "bufferSize",
794
+ publicName: "bufferSize",
795
+ isSignal: !0,
796
+ isRequired: !1,
797
+ transformFunction: null
798
+ },
799
+ itemSize: {
800
+ classPropertyName: "itemSize",
801
+ publicName: "itemSize",
802
+ isSignal: !0,
803
+ isRequired: !1,
804
+ transformFunction: null
805
+ },
806
+ ssrCount: {
807
+ classPropertyName: "ssrCount",
808
+ publicName: "ssrCount",
809
+ isSignal: !0,
810
+ isRequired: !1,
811
+ transformFunction: null
812
+ },
813
+ shift: {
814
+ classPropertyName: "shift",
815
+ publicName: "shift",
816
+ isSignal: !0,
817
+ isRequired: !1,
818
+ transformFunction: null
819
+ },
820
+ horizontal: {
821
+ classPropertyName: "horizontal",
822
+ publicName: "horizontal",
823
+ isSignal: !0,
824
+ isRequired: !1,
825
+ transformFunction: null
826
+ },
827
+ keepMounted: {
828
+ classPropertyName: "keepMounted",
829
+ publicName: "keepMounted",
830
+ isSignal: !0,
831
+ isRequired: !1,
832
+ transformFunction: null
833
+ },
834
+ cache: {
835
+ classPropertyName: "cache",
836
+ publicName: "cache",
837
+ isSignal: !0,
838
+ isRequired: !1,
839
+ transformFunction: null
840
+ }
841
+ },
842
+ outputs: {
843
+ scroll: "scroll",
844
+ scrollEnd: "scrollEnd"
845
+ },
846
+ queries: [ {
847
+ propertyName: "template",
848
+ first: !0,
849
+ predicate: r,
850
+ emitDistinctChangesOnly: !1,
851
+ descendants: !0,
852
+ isSignal: !0
853
+ } ],
854
+ viewQueries: [ {
855
+ propertyName: "virtualizer",
856
+ first: !0,
857
+ predicate: X,
858
+ emitDistinctChangesOnly: !1,
859
+ descendants: !0,
860
+ isSignal: !0
861
+ } ],
862
+ ngImport: e,
863
+ template: '\n <div\n virtuaVirtualizer\n [data]="data()"\n [getKey]="getKey()"\n [itemProps]="itemProps()"\n [bufferSize]="bufferSize()"\n [itemSize]="itemSize()"\n [ssrCount]="ssrCount()"\n [shift]="shift()"\n [horizontal]="horizontal()"\n [keepMounted]="keepMounted()"\n [cache]="cache()"\n [itemTemplate]="template()"\n (scroll)="scroll.emit($event)"\n (scrollEnd)="scrollEnd.emit()"\n ></div>\n ',
864
+ isInline: !0,
865
+ dependencies: [ {
866
+ kind: "directive",
867
+ type: e.forwardRef(() => X),
868
+ selector: "virtua-virtualizer",
869
+ inputs: [ "data", "getKey", "itemProps", "bufferSize", "scrollRef", "itemSize", "ssrCount", "shift", "horizontal", "keepMounted", "cache", "startMargin", "itemTemplate" ],
870
+ outputs: [ "scroll", "scrollEnd" ]
871
+ } ],
872
+ changeDetection: e.ChangeDetectionStrategy.OnPush
873
+ });
874
+ };
875
+
876
+ i.OnPush;
877
+
878
+ var H = class i {
879
+ data=h.required();
880
+ getKey=h(j);
881
+ bufferSize=h();
882
+ itemSize=h();
883
+ shift=h(!1);
884
+ horizontal=h(!1);
885
+ cache=h();
886
+ scroll=p();
887
+ scrollEnd=p();
888
+ template=c.required(r);
889
+ I;
890
+ resizer;
891
+ P;
892
+ R=m(n).nativeElement;
893
+ k=m(t);
894
+ q=f(void 0);
895
+ items=a(() => {
896
+ this.q();
897
+ const e = this.I, t = this.data(), i = this.getKey(), s = this.P.$isNegative(), [n, r] = e.$getRange(this.bufferSize()), o = [];
898
+ for (let l = n; l <= r && l < t.length; l++) {
899
+ const n = t[l];
900
+ o.push({
901
+ key: i(n, l),
902
+ index: l,
903
+ data: n,
904
+ offset: e.$getItemOffset(l, s),
905
+ hide: e.$isUnmeasuredItem(l)
906
+ });
907
+ }
908
+ return o;
909
+ });
910
+ containerStyle=a(() => {
911
+ this.q();
912
+ const e = this.horizontal(), t = this.I.$getTotalSize();
913
+ return {
914
+ display: "block",
915
+ contain: "size style",
916
+ "overflow-anchor": "none",
917
+ flex: "none",
918
+ position: "relative",
919
+ width: e ? t + "px" : "100%",
920
+ height: e ? "100%" : t + "px",
921
+ "pointer-events": this.I.$isScrolling() ? "none" : void 0
922
+ };
923
+ });
924
+ constructor() {
925
+ u(() => {
926
+ const e = this.data().length;
927
+ this.I && e !== this.I.$getItemsLength() && this.I.$update(5, [ e, d(this.shift) ]);
928
+ }), o({
929
+ read: () => {
930
+ this.resizer.$observeRoot(this.R), this.P.$observe(this.R);
931
+ }
932
+ }), l({
933
+ read: () => {
934
+ this.q(), this.P.$fixScrollJump();
935
+ }
936
+ }), m(s).onDestroy(() => {
937
+ this.I?.$dispose(), this.resizer?.$dispose(), this.P?.$dispose();
938
+ });
939
+ }
940
+ ngOnInit() {
941
+ const e = this.itemSize(), t = this.I = K(this.data().length, e, void 0, this.cache(), !e);
942
+ this.resizer = ((e, t) => {
943
+ const i = t ? "width" : "height", s = t ? "innerWidth" : "innerHeight", n = /* @__PURE__ */ new WeakMap, r = J(t => {
944
+ const s = [];
945
+ for (const {target: e, contentRect: r} of t) {
946
+ if (!e.offsetParent) continue;
947
+ const t = n.get(e);
948
+ null != t && s.push([ t, r[i] ]);
949
+ }
950
+ s.length && e.$update(3, s);
951
+ });
952
+ let o;
953
+ return {
954
+ $observeRoot(t) {
955
+ const i = _(C(t)), n = () => {
956
+ e.$update(4, i[s]);
957
+ };
958
+ i.addEventListener("resize", n), P(n), o = () => {
959
+ i.removeEventListener("resize", n);
960
+ };
961
+ },
962
+ $observeItem: (e, t) => (n.set(e, t), r.v(e), () => {
963
+ n.delete(e), r.N(e);
964
+ }),
965
+ $dispose() {
966
+ o && o(), r.p();
967
+ }
968
+ };
969
+ })(t, this.horizontal()), this.P = ((e, t) => {
970
+ let i, s, n = R(), r = !1;
971
+ const o = t ? "left" : "top", [l] = B(e, () => n[0], (e, t) => {
972
+ e = D(e, r);
973
+ const s = _(C(i));
974
+ t ? s.scroll({
975
+ [o]: e,
976
+ behavior: "smooth"
977
+ }) : s.scroll({
978
+ [o]: e
979
+ });
980
+ }), a = (e, t, i, s, n = 0) => {
981
+ const o = s ? "offsetLeft" : "offsetTop", l = n + (s && r ? i.innerWidth - e[o] - e.offsetWidth : e[o]), c = e.offsetParent;
982
+ return e !== t && c ? a(c, t, i, s, l) : l;
983
+ };
984
+ return {
985
+ $observe(l) {
986
+ i = l;
987
+ const c = t ? "scrollX" : "scrollY", u = C(l), m = _(u);
988
+ t && (r = "rtl" === getComputedStyle(O(u)).direction), s = L(e, m, t, () => D(m[c], r), (t, i) => {
989
+ i ? m.scroll({
990
+ [o]: D(e.$getScrollOffset() + t, r)
991
+ }) : m.scrollBy({
992
+ [o]: D(t, r)
993
+ });
994
+ }, () => a(l, u.body, m, t)), n[1](!0);
995
+ },
996
+ $dispose() {
997
+ s && s.p(), i = void 0, n[1](!1), n = R();
998
+ },
999
+ $isNegative: () => r,
1000
+ $fixScrollJump: () => {
1001
+ s && s.S();
1002
+ },
1003
+ $scrollToIndex(s, {align: n, smooth: r, offset: o = 0} = {}) {
1004
+ if (!i) return;
1005
+ if (s = N(s, 0, e.$getItemsLength() - 1), "nearest" === n) {
1006
+ const t = e.$getItemOffset(s), i = e.$getScrollOffset();
1007
+ if (t < i) n = "start"; else {
1008
+ if (!(t + e.$getItemSize(s) > i + e.$getViewportSize())) return;
1009
+ n = "end";
1010
+ }
1011
+ }
1012
+ const c = C(i), u = _(c), m = O(c), h = () => e.$getViewportSize() - (t ? m.clientWidth : m.clientHeight);
1013
+ l(() => o + a(i, c.body, u, t) + e.$getItemOffset(s) + ("end" === n ? e.$getItemSize(s) - (e.$getViewportSize() - h()) : "center" === n ? (e.$getItemSize(s) - (e.$getViewportSize() - h())) / 2 : 0), r);
1014
+ }
1015
+ };
1016
+ })(t, this.horizontal()), t.$subscribe(1, e => {
1017
+ this.q.set(t.$getStateVersion()), e && this.k.tick();
1018
+ }), t.$subscribe(4, () => {
1019
+ this.scroll.emit();
1020
+ }), t.$subscribe(8, () => {
1021
+ this.scrollEnd.emit();
1022
+ }), this.q.set(t.$getStateVersion());
1023
+ }
1024
+ getCache() {
1025
+ return this.I.$getCacheSnapshot();
1026
+ }
1027
+ getScrollOffset() {
1028
+ return this.I.$getScrollOffset();
1029
+ }
1030
+ getViewportSize() {
1031
+ return this.I.$getViewportSize();
1032
+ }
1033
+ findItemIndex(e) {
1034
+ return this.I.$findItemIndex(e);
1035
+ }
1036
+ getItemOffset(e) {
1037
+ return this.I.$getItemOffset(e);
1038
+ }
1039
+ getItemSize(e) {
1040
+ return this.I.$getItemSize(e);
1041
+ }
1042
+ scrollToIndex(e, t) {
1043
+ this.P.$scrollToIndex(e, t);
1044
+ }
1045
+ static ɵfac=/*@__PURE__*/ e.ɵɵngDeclareFactory({
1046
+ minVersion: "12.0.0",
1047
+ version: "22.0.8",
1048
+ ngImport: e,
1049
+ type: i,
1050
+ deps: [],
1051
+ target: e.ɵɵFactoryTarget.Component
1052
+ });
1053
+ static ɵcmp=/*@__PURE__*/ e.ɵɵngDeclareComponent({
1054
+ minVersion: "17.0.0",
1055
+ version: "22.0.8",
1056
+ type: i,
1057
+ isStandalone: !0,
1058
+ selector: "virtua-window-virtualizer, [virtuaWindowVirtualizer]",
1059
+ inputs: {
1060
+ data: {
1061
+ classPropertyName: "data",
1062
+ publicName: "data",
1063
+ isSignal: !0,
1064
+ isRequired: !0,
1065
+ transformFunction: null
1066
+ },
1067
+ getKey: {
1068
+ classPropertyName: "getKey",
1069
+ publicName: "getKey",
1070
+ isSignal: !0,
1071
+ isRequired: !1,
1072
+ transformFunction: null
1073
+ },
1074
+ bufferSize: {
1075
+ classPropertyName: "bufferSize",
1076
+ publicName: "bufferSize",
1077
+ isSignal: !0,
1078
+ isRequired: !1,
1079
+ transformFunction: null
1080
+ },
1081
+ itemSize: {
1082
+ classPropertyName: "itemSize",
1083
+ publicName: "itemSize",
1084
+ isSignal: !0,
1085
+ isRequired: !1,
1086
+ transformFunction: null
1087
+ },
1088
+ shift: {
1089
+ classPropertyName: "shift",
1090
+ publicName: "shift",
1091
+ isSignal: !0,
1092
+ isRequired: !1,
1093
+ transformFunction: null
1094
+ },
1095
+ horizontal: {
1096
+ classPropertyName: "horizontal",
1097
+ publicName: "horizontal",
1098
+ isSignal: !0,
1099
+ isRequired: !1,
1100
+ transformFunction: null
1101
+ },
1102
+ cache: {
1103
+ classPropertyName: "cache",
1104
+ publicName: "cache",
1105
+ isSignal: !0,
1106
+ isRequired: !1,
1107
+ transformFunction: null
1108
+ }
1109
+ },
1110
+ outputs: {
1111
+ scroll: "scroll",
1112
+ scrollEnd: "scrollEnd"
1113
+ },
1114
+ host: {
1115
+ properties: {
1116
+ style: "containerStyle()"
1117
+ }
1118
+ },
1119
+ queries: [ {
1120
+ propertyName: "template",
1121
+ first: !0,
1122
+ predicate: r,
1123
+ emitDistinctChangesOnly: !1,
1124
+ descendants: !0,
1125
+ isSignal: !0
1126
+ } ],
1127
+ ngImport: e,
1128
+ template: '\n @for (item of items(); track item.key) {\n <div\n virtuaListItem\n [index]="item.index"\n [offset]="item.offset"\n [hide]="item.hide"\n [horizontal]="horizontal()"\n [resizer]="resizer.$observeItem"\n >\n <ng-container\n [ngTemplateOutlet]="template()"\n [ngTemplateOutletContext]="{\n $implicit: item.data,\n index: item.index,\n }"\n />\n </div>\n }\n ',
1129
+ isInline: !0,
1130
+ dependencies: [ {
1131
+ kind: "directive",
1132
+ type: e.forwardRef(() => W),
1133
+ selector: "div[virtuaListItem]",
1134
+ inputs: [ "index", "offset", "hide", "horizontal", "resizer", "attrs" ]
1135
+ }, {
1136
+ kind: "directive",
1137
+ type: e.forwardRef(() => y),
1138
+ selector: "[ngTemplateOutlet]",
1139
+ inputs: [ "ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector" ]
1140
+ } ],
1141
+ changeDetection: e.ChangeDetectionStrategy.OnPush
1142
+ });
1143
+ };
1144
+
1145
+ i.OnPush;
1146
+
1147
+ export { Y as VList, X as Virtualizer, H as WindowVirtualizer };
1148
+ //# sourceMappingURL=index.js.map