ng-virtual-list 20.2.0 → 20.3.1

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 (38) hide show
  1. package/README.md +10 -10
  2. package/fesm2022/ng-virtual-list.mjs +54 -19
  3. package/fesm2022/ng-virtual-list.mjs.map +1 -1
  4. package/index.d.ts +802 -3
  5. package/package.json +1 -1
  6. package/lib/components/ng-virtual-list-item.component.d.ts +0 -34
  7. package/lib/const/index.d.ts +0 -41
  8. package/lib/enums/direction.d.ts +0 -8
  9. package/lib/enums/directions.d.ts +0 -16
  10. package/lib/enums/index.d.ts +0 -7
  11. package/lib/enums/snapping-method.d.ts +0 -10
  12. package/lib/enums/snapping-methods.d.ts +0 -16
  13. package/lib/models/collection.model.d.ts +0 -9
  14. package/lib/models/index.d.ts +0 -6
  15. package/lib/models/item.model.d.ts +0 -14
  16. package/lib/models/render-collection.model.d.ts +0 -9
  17. package/lib/models/render-item-config.model.d.ts +0 -41
  18. package/lib/models/render-item.model.d.ts +0 -33
  19. package/lib/models/scroll-direction.model.d.ts +0 -5
  20. package/lib/models/scroll-event.model.d.ts +0 -50
  21. package/lib/models/sticky-map.model.d.ts +0 -14
  22. package/lib/ng-virtual-list.component.d.ts +0 -144
  23. package/lib/types/id.d.ts +0 -7
  24. package/lib/types/index.d.ts +0 -4
  25. package/lib/types/rect.d.ts +0 -17
  26. package/lib/types/size.d.ts +0 -16
  27. package/lib/utils/browser.d.ts +0 -2
  28. package/lib/utils/cacheMap.d.ts +0 -60
  29. package/lib/utils/debounce.d.ts +0 -16
  30. package/lib/utils/eventEmitter.d.ts +0 -40
  31. package/lib/utils/index.d.ts +0 -7
  32. package/lib/utils/isDirection.d.ts +0 -8
  33. package/lib/utils/scrollEvent.d.ts +0 -39
  34. package/lib/utils/snapping-method.d.ts +0 -3
  35. package/lib/utils/toggleClassName.d.ts +0 -7
  36. package/lib/utils/trackBox.d.ts +0 -180
  37. package/lib/utils/tracker.d.ts +0 -44
  38. package/public-api.d.ts +0 -4
package/index.d.ts CHANGED
@@ -1,5 +1,804 @@
1
+ import * as ng_virtual_list from 'ng-virtual-list';
2
+ import * as _angular_core from '@angular/core';
3
+ import { WritableSignal, TemplateRef, ElementRef, ComponentRef, AfterViewInit, OnInit, OnDestroy, ViewContainerRef } from '@angular/core';
4
+ import { Observable } from 'rxjs';
5
+
1
6
  /**
2
- * Generated bundle index. Do not edit.
7
+ * Identifier type
8
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts
9
+ * @author Evgenii Grebennikov
10
+ * @email djonnyx@gmail.com
3
11
  */
4
- /// <amd-module name="ng-virtual-list" />
5
- export * from './public-api';
12
+ type Id = string | number;
13
+
14
+ /**
15
+ * Area area Interface
16
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/size.ts
17
+ * @author Evgenii Grebennikov
18
+ * @email djonnyx@gmail.com
19
+ */
20
+ interface ISize {
21
+ /**
22
+ * Width value.
23
+ */
24
+ width: number;
25
+ /**
26
+ * Height value.
27
+ */
28
+ height: number;
29
+ }
30
+
31
+ /**
32
+ * Rectangular area interface
33
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/rect.ts
34
+ * @author Evgenii Grebennikov
35
+ * @email djonnyx@gmail.com
36
+ */
37
+ interface IRect extends ISize {
38
+ /**
39
+ * X coordinate.
40
+ */
41
+ x: number;
42
+ /**
43
+ * Y coordinate.
44
+ */
45
+ y: number;
46
+ }
47
+
48
+ /**
49
+ * Virtual list element model
50
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/item.model.ts
51
+ * @author Evgenii Grebennikov
52
+ * @email djonnyx@gmail.com
53
+ */
54
+ type IVirtualListItem<E = Object> = E & {
55
+ /**
56
+ * Unique identifier of the element.
57
+ */
58
+ id: Id;
59
+ [x: string]: any;
60
+ };
61
+
62
+ /**
63
+ * Object with configuration parameters for IRenderVirtualListItem
64
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/render-item-config.model.ts
65
+ * @author Evgenii Grebennikov
66
+ * @email djonnyx@gmail.com
67
+ *
68
+ */
69
+ interface IRenderVirtualListItemConfig {
70
+ /**
71
+ * If greater than 0, the element will have a sticky position with the given zIndex.
72
+ */
73
+ sticky: number;
74
+ /**
75
+ * Specifies whether the element will snap.
76
+ */
77
+ snap: boolean;
78
+ /**
79
+ * Indicates that the element is snapped.
80
+ */
81
+ snapped: boolean;
82
+ /**
83
+ * Indicates that the element is being shifted by another snap element.
84
+ */
85
+ snappedOut: boolean;
86
+ /**
87
+ * Indicates that the element is a vertical list item.
88
+ */
89
+ isVertical: boolean;
90
+ /**
91
+ * Specifies that the element adapts to the size of its content.
92
+ */
93
+ dynamic: boolean;
94
+ /**
95
+ * Returns true if the snapping method is advanced
96
+ */
97
+ isSnappingMethodAdvanced: boolean;
98
+ /**
99
+ * z-index
100
+ */
101
+ zIndex: string;
102
+ }
103
+
104
+ /**
105
+ * List screen element model
106
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/render-item.model.ts
107
+ * @author Evgenii Grebennikov
108
+ * @email djonnyx@gmail.com
109
+ */
110
+ interface IRenderVirtualListItem {
111
+ /**
112
+ * Unique identifier of the element.
113
+ */
114
+ id: Id;
115
+ /**
116
+ * Element metrics.
117
+ */
118
+ measures: IRect & {
119
+ /**
120
+ * Delta is calculated for Snapping Method.ADVANCED
121
+ */
122
+ delta: number;
123
+ };
124
+ /**
125
+ * Element data.
126
+ */
127
+ data: IVirtualListItem;
128
+ /**
129
+ * Object with configuration parameters for IRenderVirtualListItem.
130
+ */
131
+ config: IRenderVirtualListItemConfig;
132
+ }
133
+
134
+ /**
135
+ * A value of -1 indicates the direction is up or left (if the list direction is horizontal).
136
+ * A value of 1 indicates the direction is down or right (if the list direction is horizontal).
137
+ */
138
+ type ScrollDirection = -1 | 1 | 0;
139
+
140
+ /**
141
+ * Interface IScrollEvent.
142
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/scroll-event.model.ts
143
+ * @author Evgenii Grebennikov
144
+ * @email djonnyx@gmail.com
145
+ */
146
+ interface IScrollEvent {
147
+ /**
148
+ * Scroll area offset
149
+ */
150
+ scrollSize: number;
151
+ /**
152
+ * Full size of the scroll area
153
+ */
154
+ scrollWeight: number;
155
+ /**
156
+ * Viewport size
157
+ */
158
+ size: number;
159
+ /**
160
+ * Size of the list of elements
161
+ */
162
+ listSize: number;
163
+ /**
164
+ * Specifies whether the list orientation is vertical.
165
+ */
166
+ isVertical: boolean;
167
+ /**
168
+ * A value of -1 indicates the direction is up or left (if the list direction is horizontal).
169
+ * A value of 1 indicates the direction is down or right (if the list direction is horizontal).
170
+ */
171
+ direction: ScrollDirection;
172
+ /**
173
+ * If true then indicates that the list has been scrolled to the end.
174
+ */
175
+ isStart: boolean;
176
+ /**
177
+ * If true then indicates that the list has been scrolled to the end.
178
+ */
179
+ isEnd: boolean;
180
+ /**
181
+ * Delta of marked and unmarked area
182
+ */
183
+ delta: number;
184
+ /**
185
+ * Scroll delta
186
+ */
187
+ scrollDelta: number;
188
+ }
189
+
190
+ /**
191
+ * Dictionary zIndex by id of the list element. If the value is not set or equal to 0, then a simple element is displayed,
192
+ * if the value is greater than 0, then the sticky position mode is enabled for the element. 1 - position start, 2 - position end.
193
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/sticky-map.model.ts
194
+ * @author Evgenii Grebennikov
195
+ * @email djonnyx@gmail.com
196
+ */
197
+ interface IVirtualListStickyMap {
198
+ /**
199
+ * Sets zIndex for the element ID. If zIndex is greater than 0, then sticky position is applied.
200
+ * 1 - position start, 2 - position end.
201
+ */
202
+ [id: string]: 0 | 1 | 2;
203
+ }
204
+
205
+ /**
206
+ * Virtual list elements collection interface
207
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/collection.model.ts
208
+ * @author Evgenii Grebennikov
209
+ * @email djonnyx@gmail.com
210
+ */
211
+ interface IVirtualListCollection<E = Object> extends Array<IVirtualListItem<E>> {
212
+ }
213
+
214
+ /**
215
+ * Virtual List Item Interface
216
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/-basevirtual-list-item-component.ts
217
+ * @author Evgenii Grebennikov
218
+ * @email djonnyx@gmail.com
219
+ */
220
+ declare abstract class BaseVirtualListItemComponent {
221
+ abstract get id(): number;
222
+ abstract data: WritableSignal<IRenderVirtualListItem | undefined>;
223
+ abstract regular: boolean;
224
+ abstract set regularLength(v: string);
225
+ abstract set item(v: IRenderVirtualListItem | null | undefined);
226
+ abstract get item(): IRenderVirtualListItem | null | undefined;
227
+ abstract get itemId(): Id | undefined;
228
+ abstract itemRenderer: WritableSignal<TemplateRef<any> | undefined>;
229
+ abstract set renderer(v: TemplateRef<any> | undefined);
230
+ abstract get element(): HTMLElement;
231
+ protected abstract update(): void;
232
+ abstract getBounds(): ISize;
233
+ abstract show(): void;
234
+ abstract hide(): void;
235
+ }
236
+
237
+ interface Component$1<T> extends Function {
238
+ new (...args: any[]): T;
239
+ }
240
+
241
+ /**
242
+ * Virtual list item component
243
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/components/ng-virtual-list-item.component.ts
244
+ * @author Evgenii Grebennikov
245
+ * @email djonnyx@gmail.com
246
+ */
247
+ declare class NgVirtualListItemComponent extends BaseVirtualListItemComponent {
248
+ protected static __nextId: number;
249
+ protected _id: number;
250
+ get id(): number;
251
+ regular: boolean;
252
+ data: _angular_core.WritableSignal<IRenderVirtualListItem | undefined>;
253
+ protected _data: IRenderVirtualListItem | undefined;
254
+ set item(v: IRenderVirtualListItem | undefined);
255
+ protected _regularLength: string;
256
+ set regularLength(v: string);
257
+ get item(): IRenderVirtualListItem | undefined;
258
+ get itemId(): ng_virtual_list.Id | undefined;
259
+ itemRenderer: _angular_core.WritableSignal<TemplateRef<any> | undefined>;
260
+ set renderer(v: TemplateRef<any> | undefined);
261
+ protected _elementRef: ElementRef<HTMLElement>;
262
+ get element(): HTMLElement;
263
+ constructor();
264
+ protected update(): void;
265
+ getBounds(): ISize;
266
+ show(): void;
267
+ hide(): void;
268
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgVirtualListItemComponent, never>;
269
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<NgVirtualListItemComponent, "ng-virtual-list-item", never, {}, {}, never, never, true, never>;
270
+ }
271
+
272
+ /**
273
+ * Virtual list screen elements collection interface
274
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/render-collection.model.ts
275
+ * @author Evgenii Grebennikov
276
+ * @email djonnyx@gmail.com
277
+ */
278
+ interface IRenderVirtualListCollection extends Array<IRenderVirtualListItem> {
279
+ }
280
+
281
+ /**
282
+ * Axis of the arrangement of virtual list elements.
283
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/enums/directions.ts
284
+ * @author Evgenii Grebennikov
285
+ * @email djonnyx@gmail.com
286
+ */
287
+ declare enum Directions {
288
+ /**
289
+ * Horizontal axis.
290
+ */
291
+ HORIZONTAL = "horizontal",
292
+ /**
293
+ * Vertical axis.
294
+ */
295
+ VERTICAL = "vertical"
296
+ }
297
+
298
+ /**
299
+ * Axis of the arrangement of virtual list elements.
300
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/enums/direction.ts
301
+ * @author Evgenii Grebennikov
302
+ * @email djonnyx@gmail.com
303
+ */
304
+ type Direction = Directions | 'horizontal' | 'vertical';
305
+
306
+ /**
307
+ * Snapping method.
308
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/enums/snapping-method.ts
309
+ * @author Evgenii Grebennikov
310
+ * @email djonnyx@gmail.com
311
+ */
312
+ declare enum SnappingMethods {
313
+ /**
314
+ * Normal group rendering.
315
+ */
316
+ NORMAL = "normal",
317
+ /**
318
+ * The group is rendered on a transparent background. List items below the group are not rendered.
319
+ */
320
+ ADVANCED = "advanced"
321
+ }
322
+
323
+ /**
324
+ * Snapping method.
325
+ * 'normal' - Normal group rendering.
326
+ * 'advanced' - The group is rendered on a transparent background. List items below the group are not rendered.
327
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/enums/snapping-method.ts
328
+ * @author Evgenii Grebennikov
329
+ * @email djonnyx@gmail.com
330
+ */
331
+ type SnappingMethod = SnappingMethods | 'normal' | 'advanced';
332
+
333
+ /**
334
+ * Tracks display items by property
335
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/utils/tracker.ts
336
+ * @author Evgenii Grebennikov
337
+ * @email djonnyx@gmail.com
338
+ */
339
+ declare class Tracker<C extends BaseVirtualListItemComponent = any> {
340
+ /**
341
+ * display objects dictionary of indexes by id
342
+ */
343
+ private _displayObjectIndexMapById;
344
+ set displayObjectIndexMapById(v: {
345
+ [id: number]: number;
346
+ });
347
+ get displayObjectIndexMapById(): {
348
+ [id: number]: number;
349
+ };
350
+ /**
351
+ * Dictionary displayItems propertyNameId by items propertyNameId
352
+ */
353
+ private _trackMap;
354
+ get trackMap(): {
355
+ [id: string]: number;
356
+ [id: number]: number;
357
+ } | null;
358
+ private _trackingPropertyName;
359
+ set trackingPropertyName(v: string);
360
+ constructor(trackingPropertyName: string);
361
+ /**
362
+ * tracking by propName
363
+ */
364
+ track(items: Array<any>, components: Array<ComponentRef<C>>, snapedComponent: ComponentRef<C> | null | undefined, direction: ScrollDirection): void;
365
+ untrackComponentByIdProperty(component?: C): void;
366
+ dispose(): void;
367
+ }
368
+
369
+ type TEventHandler = (...args: Array<any>) => void;
370
+ /**
371
+ * Simple event emitter
372
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/utils/eventEmitter.ts
373
+ * @author Evgenii Grebennikov
374
+ * @email djonnyx@gmail.com
375
+ */
376
+ declare class EventEmitter<E = string, H = TEventHandler> {
377
+ private _listeners;
378
+ protected _disposed: boolean;
379
+ constructor();
380
+ /**
381
+ * Emits the event
382
+ */
383
+ dispatch(event: E, ...args: Array<any>): void;
384
+ /**
385
+ * Emits the event async
386
+ */
387
+ dispatchAsync(event: E, ...args: Array<any>): void;
388
+ /**
389
+ * Returns true if the event listener is already subscribed.
390
+ */
391
+ hasEventListener(eventName: E, handler: H): boolean;
392
+ /**
393
+ * Add event listener
394
+ */
395
+ addEventListener(eventName: E, handler: H): void;
396
+ /**
397
+ * Remove event listener
398
+ */
399
+ removeEventListener(eventName: E, handler: H): void;
400
+ /**
401
+ * Remove all listeners
402
+ */
403
+ removeAllListeners(): void;
404
+ /**
405
+ * Method of destroying handlers
406
+ */
407
+ dispose(): void;
408
+ }
409
+
410
+ declare class CMap<K = string, V = any> {
411
+ private _dict;
412
+ constructor(dict?: CMap<K, V>);
413
+ get(key: K): V;
414
+ set(key: K, value: V): this;
415
+ has(key: K): boolean;
416
+ delete(key: K): void;
417
+ clear(): void;
418
+ }
419
+ interface ICacheMap<I = any, B = any> {
420
+ set: (id: I, bounds: B) => CMap<I, B>;
421
+ has: (id: I) => boolean;
422
+ get: (id: I) => B | undefined;
423
+ }
424
+ declare const CACHE_BOX_CHANGE_EVENT_NAME = "change";
425
+ type CacheMapEvents$1 = typeof CACHE_BOX_CHANGE_EVENT_NAME;
426
+ type OnChangeEventListener$1 = (version: number) => void;
427
+ type CacheMapListeners$1 = OnChangeEventListener$1;
428
+ /**
429
+ * Cache map.
430
+ * Emits a change event on each mutation.
431
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/utils/cacheMap.ts
432
+ * @author Evgenii Grebennikov
433
+ * @email djonnyx@gmail.com
434
+ */
435
+ declare class CacheMap<I = string | number, B = any, E = CacheMapEvents$1, L = CacheMapListeners$1> extends EventEmitter<E, L> implements ICacheMap {
436
+ protected _map: CMap<I, B>;
437
+ protected _snapshot: CMap<I, B>;
438
+ protected _version: number;
439
+ protected _previousVersion: number;
440
+ protected _lifeCircleTimeout: any;
441
+ protected _delta: number;
442
+ get delta(): number;
443
+ protected _deltaDirection: ScrollDirection;
444
+ set deltaDirection(v: ScrollDirection);
445
+ get deltaDirection(): ScrollDirection;
446
+ private _scrollDirectionCache;
447
+ private _scrollDirection;
448
+ get scrollDirection(): ScrollDirection;
449
+ get version(): number;
450
+ private _clearScrollDirectionDebounce;
451
+ constructor();
452
+ protected changesDetected(): boolean;
453
+ protected stopLifeCircle(): void;
454
+ protected nextTick(cb: () => void): any;
455
+ protected lifeCircle(): void;
456
+ protected lifeCircleDo(): void;
457
+ clearScrollDirectionCache(): void;
458
+ private calcScrollDirection;
459
+ protected bumpVersion(): void;
460
+ protected fireChangeIfNeed(): void;
461
+ set(id: I, bounds: B): CMap<I, B>;
462
+ has(id: I): boolean;
463
+ get(id: I): B | undefined;
464
+ snapshot(): void;
465
+ dispose(): void;
466
+ }
467
+
468
+ declare const WIDTH_PROP_NAME = "width";
469
+ declare const HEIGHT_PROP_NAME = "height";
470
+
471
+ declare const TRACK_BOX_CHANGE_EVENT_NAME = "change";
472
+ interface IMetrics {
473
+ delta: number;
474
+ normalizedItemWidth: number;
475
+ normalizedItemHeight: number;
476
+ width: number;
477
+ height: number;
478
+ dynamicSize: boolean;
479
+ itemSize: number;
480
+ itemsFromStartToScrollEnd: number;
481
+ itemsFromStartToDisplayEnd: number;
482
+ itemsOnDisplayWeight: number;
483
+ itemsOnDisplayLength: number;
484
+ isVertical: boolean;
485
+ leftHiddenItemsWeight: number;
486
+ leftItemLength: number;
487
+ leftItemsWeight: number;
488
+ renderItems: number;
489
+ rightItemLength: number;
490
+ rightItemsWeight: number;
491
+ scrollSize: number;
492
+ leftSizeOfAddedItems: number;
493
+ sizeProperty: typeof HEIGHT_PROP_NAME | typeof WIDTH_PROP_NAME;
494
+ snap: boolean;
495
+ snippedPos: number;
496
+ startIndex: number;
497
+ startPosition: number;
498
+ totalItemsToDisplayEndWeight: number;
499
+ totalLength: number;
500
+ totalSize: number;
501
+ typicalItemSize: number;
502
+ }
503
+ interface IRecalculateMetricsOptions<I extends {
504
+ id: Id;
505
+ }, C extends Array<I>> {
506
+ bounds: ISize;
507
+ collection: C;
508
+ isVertical: boolean;
509
+ itemSize: number;
510
+ itemsOffset: number;
511
+ dynamicSize: boolean;
512
+ scrollSize: number;
513
+ snap: boolean;
514
+ enabledBufferOptimization: boolean;
515
+ fromItemId?: Id;
516
+ previousTotalSize: number;
517
+ crudDetected: boolean;
518
+ deletedItemsMap: {
519
+ [index: number]: ISize;
520
+ };
521
+ }
522
+ interface IGetItemPositionOptions<I extends {
523
+ id: Id;
524
+ }, C extends Array<I>> extends Omit<IRecalculateMetricsOptions<I, C>, 'previousTotalSize' | 'crudDetected' | 'deletedItemsMap'> {
525
+ }
526
+ interface IUpdateCollectionOptions<I extends {
527
+ id: Id;
528
+ }, C extends Array<I>> extends Omit<IRecalculateMetricsOptions<I, C>, 'collection' | 'previousTotalSize' | 'crudDetected' | 'deletedItemsMap'> {
529
+ }
530
+ type CacheMapEvents = typeof TRACK_BOX_CHANGE_EVENT_NAME;
531
+ type OnChangeEventListener = (version: number) => void;
532
+ type CacheMapListeners = OnChangeEventListener;
533
+ declare enum ItemDisplayMethods {
534
+ CREATE = 0,
535
+ UPDATE = 1,
536
+ DELETE = 2,
537
+ NOT_CHANGED = 3
538
+ }
539
+ interface IUpdateCollectionReturns {
540
+ displayItems: IRenderVirtualListCollection;
541
+ totalSize: number;
542
+ delta: number;
543
+ crudDetected: boolean;
544
+ }
545
+ /**
546
+ * An object that performs tracking, calculations and caching.
547
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/utils/trackBox.ts
548
+ * @author Evgenii Grebennikov
549
+ * @email djonnyx@gmail.com
550
+ */
551
+ declare class TrackBox<C extends BaseVirtualListItemComponent = any> extends CacheMap<Id, ISize & {
552
+ method?: ItemDisplayMethods;
553
+ }, CacheMapEvents, CacheMapListeners> {
554
+ protected _tracker: Tracker<C>;
555
+ protected _items: IRenderVirtualListCollection | null | undefined;
556
+ set items(v: IRenderVirtualListCollection | null | undefined);
557
+ protected _displayComponents: Array<ComponentRef<C>> | null | undefined;
558
+ set displayComponents(v: Array<ComponentRef<C>> | null | undefined);
559
+ protected _snapedDisplayComponent: ComponentRef<C> | null | undefined;
560
+ set snapedDisplayComponent(v: ComponentRef<C> | null | undefined);
561
+ protected _isSnappingMethodAdvanced: boolean;
562
+ set isSnappingMethodAdvanced(v: boolean);
563
+ /**
564
+ * Set the trackBy property
565
+ */
566
+ set trackingPropertyName(v: string);
567
+ constructor(trackingPropertyName: string);
568
+ set(id: Id, bounds: ISize): CMap<Id, ISize>;
569
+ protected _previousCollection: Array<{
570
+ id: Id;
571
+ }> | null | undefined;
572
+ protected _deletedItemsMap: {
573
+ [index: number]: ISize;
574
+ };
575
+ protected _crudDetected: boolean;
576
+ get crudDetected(): boolean;
577
+ protected fireChangeIfNeed(): void;
578
+ protected _previousTotalSize: number;
579
+ protected _scrollDelta: number;
580
+ get scrollDelta(): number;
581
+ protected lifeCircle(): void;
582
+ /**
583
+ * Scans the collection for deleted items and flushes the deleted item cache.
584
+ */
585
+ resetCollection<I extends {
586
+ id: Id;
587
+ }, C extends Array<I>>(currentCollection: C | null | undefined, itemSize: number): void;
588
+ /**
589
+ * Update the cache of items from the list
590
+ */
591
+ protected updateCache<I extends {
592
+ id: Id;
593
+ }, C extends Array<I>>(previousCollection: C | null | undefined, currentCollection: C | null | undefined, itemSize: number): void;
594
+ /**
595
+ * Finds the position of a collection element by the given Id
596
+ */
597
+ getItemPosition<I extends {
598
+ id: Id;
599
+ }, C extends Array<I>>(id: Id, stickyMap: IVirtualListStickyMap, options: IGetItemPositionOptions<I, C>): number;
600
+ /**
601
+ * Updates the collection of display objects
602
+ */
603
+ updateCollection<I extends {
604
+ id: Id;
605
+ }, C extends Array<I>>(items: C, stickyMap: IVirtualListStickyMap, options: IUpdateCollectionOptions<I, C>): IUpdateCollectionReturns;
606
+ /**
607
+ * Finds the closest element in the collection by scrollSize
608
+ */
609
+ getNearestItem<I extends {
610
+ id: Id;
611
+ }, C extends Array<I>>(scrollSize: number, items: C, itemSize: number, isVertical: boolean): I | undefined;
612
+ /**
613
+ * Calculates the position of an element based on the given scrollSize
614
+ */
615
+ protected getElementFromStart<I extends {
616
+ id: Id;
617
+ }, C extends Array<I>>(scrollSize: number, collection: C, map: CMap<Id, ISize>, typicalItemSize: number, isVertical: boolean): I | undefined;
618
+ /**
619
+ * Calculates the entry into the overscroll area and returns the number of overscroll elements
620
+ */
621
+ protected getElementNumToEnd<I extends {
622
+ id: Id;
623
+ }, C extends Array<I>>(i: number, collection: C, map: CMap<Id, ISize>, typicalItemSize: number, size: number, isVertical: boolean, indexOffset?: number): {
624
+ num: number;
625
+ offset: number;
626
+ };
627
+ /**
628
+ * Calculates list metrics
629
+ */
630
+ protected recalculateMetrics<I extends {
631
+ id: Id;
632
+ }, C extends Array<I>>(options: IRecalculateMetricsOptions<I, C>): IMetrics;
633
+ clearDeltaDirection(): void;
634
+ clearDelta(clearDirectionDetector?: boolean): void;
635
+ changes(): void;
636
+ protected generateDisplayCollection<I extends {
637
+ id: Id;
638
+ }, C extends Array<I>>(items: C, stickyMap: IVirtualListStickyMap, metrics: IMetrics): IRenderVirtualListCollection;
639
+ /**
640
+ * tracking by propName
641
+ */
642
+ track(): void;
643
+ setDisplayObjectIndexMapById(v: {
644
+ [id: number]: number;
645
+ }): void;
646
+ untrackComponentByIdProperty(component?: C | undefined): void;
647
+ getItemBounds(id: Id): ISize | undefined;
648
+ protected cacheElements(): void;
649
+ dispose(): void;
650
+ }
651
+
652
+ /**
653
+ * Virtual list component.
654
+ * Maximum performance for extremely large lists.
655
+ * It is based on algorithms for virtualization of screen objects.
656
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/ng-virtual-list.component.ts
657
+ * @author Evgenii Grebennikov
658
+ * @email djonnyx@gmail.com
659
+ */
660
+ declare class NgVirtualListComponent implements AfterViewInit, OnInit, OnDestroy {
661
+ protected static __nextId: number;
662
+ protected _id: number;
663
+ /**
664
+ * Readonly. Returns the unique identifier of the component.
665
+ */
666
+ get id(): number;
667
+ protected _listContainerRef: ViewContainerRef | undefined;
668
+ protected _snapContainerRef: ViewContainerRef | undefined;
669
+ protected _snappedContainer: _angular_core.Signal<ElementRef<HTMLDivElement> | undefined>;
670
+ protected _container: _angular_core.Signal<ElementRef<HTMLDivElement> | undefined>;
671
+ protected _list: _angular_core.Signal<ElementRef<HTMLUListElement> | undefined>;
672
+ /**
673
+ * Fires when the list has been scrolled.
674
+ */
675
+ onScroll: _angular_core.OutputEmitterRef<IScrollEvent>;
676
+ /**
677
+ * Fires when the list has completed scrolling.
678
+ */
679
+ onScrollEnd: _angular_core.OutputEmitterRef<IScrollEvent>;
680
+ protected _itemsOptions: any;
681
+ /**
682
+ * Collection of list items.
683
+ */
684
+ items: _angular_core.InputSignal<IVirtualListCollection<Object>>;
685
+ /**
686
+ * Determines whether elements will snap. Default value is "true".
687
+ */
688
+ snap: _angular_core.InputSignal<boolean>;
689
+ /**
690
+ * Experimental!
691
+ * Enables buffer optimization.
692
+ * Can only be used if items in the collection are not added or updated. Otherwise, artifacts in the form of twitching of the scroll area are possible.
693
+ * Works only if the property dynamic = true
694
+ */
695
+ enabledBufferOptimization: _angular_core.InputSignal<boolean>;
696
+ /**
697
+ * Rendering element template.
698
+ */
699
+ itemRenderer: _angular_core.InputSignal<TemplateRef<any>>;
700
+ protected _itemRenderer: WritableSignal<TemplateRef<any> | undefined>;
701
+ /**
702
+ * Dictionary zIndex by id of the list element. If the value is not set or equal to 0,
703
+ * then a simple element is displayed, if the value is greater than 0, then the sticky position mode is enabled for the element.
704
+ */
705
+ stickyMap: _angular_core.InputSignal<IVirtualListStickyMap>;
706
+ protected _itemSizeOptions: any;
707
+ /**
708
+ * If direction = 'vertical', then the height of a typical element. If direction = 'horizontal', then the width of a typical element.
709
+ * Ignored if the dynamicSize property is true.
710
+ */
711
+ itemSize: _angular_core.InputSignal<number>;
712
+ /**
713
+ * If true then the items in the list can have different sizes and the itemSize property is ignored.
714
+ * If false then the items in the list have a fixed size specified by the itemSize property. The default value is false.
715
+ */
716
+ dynamicSize: _angular_core.InputSignal<boolean>;
717
+ /**
718
+ * Determines the direction in which elements are placed. Default value is "vertical".
719
+ */
720
+ direction: _angular_core.InputSignal<Direction>;
721
+ /**
722
+ * Number of elements outside the scope of visibility. Default value is 2.
723
+ */
724
+ itemsOffset: _angular_core.InputSignal<number>;
725
+ /**
726
+ * Snapping method.
727
+ * 'default' - Normal group rendering.
728
+ * 'advanced' - The group is rendered on a transparent background. List items below the group are not rendered.
729
+ */
730
+ snappingMethod: _angular_core.InputSignal<SnappingMethod>;
731
+ protected _isSnappingMethodAdvanced: boolean;
732
+ get isSnappingMethodAdvanced(): boolean;
733
+ protected _isVertical: boolean;
734
+ protected _displayComponents: Array<ComponentRef<BaseVirtualListItemComponent>>;
735
+ protected _snapedDisplayComponent: ComponentRef<BaseVirtualListItemComponent> | undefined;
736
+ protected _bounds: WritableSignal<ISize | null>;
737
+ protected _scrollSize: WritableSignal<number>;
738
+ protected _resizeObserver: ResizeObserver | null;
739
+ protected _resizeSnappedComponentHandler: () => void;
740
+ protected _resizeSnappedObserver: ResizeObserver | null;
741
+ protected _componentsResizeObserver: ResizeObserver;
742
+ protected _onResizeHandler: () => void;
743
+ protected _onScrollHandler: (e?: Event) => void;
744
+ protected _elementRef: ElementRef<any>;
745
+ protected _initialized: WritableSignal<boolean>;
746
+ readonly $initialized: Observable<boolean>;
747
+ /**
748
+ * The name of the property by which tracking is performed
749
+ */
750
+ trackBy: _angular_core.InputSignal<string>;
751
+ /**
752
+ * Base class of the element component
753
+ */
754
+ protected _itemComponentClass: Component$1<BaseVirtualListItemComponent>;
755
+ /**
756
+ * Base class trackBox
757
+ */
758
+ protected _trackBoxClass: Component$1<TrackBox>;
759
+ /**
760
+ * Dictionary of element sizes by their id
761
+ */
762
+ protected _trackBox: TrackBox;
763
+ protected _onTrackBoxChangeHandler: (v: number) => void;
764
+ protected _cacheVersion: WritableSignal<number>;
765
+ constructor();
766
+ protected setupRenderer(): void;
767
+ protected onInit(): void;
768
+ protected listenCacheChangesIfNeed(value: boolean): void;
769
+ protected getIsSnappingMethodAdvanced(m?: SnappingMethod): boolean;
770
+ protected getIsVertical(d?: Direction): boolean;
771
+ protected createDisplayComponentsIfNeed(displayItems: IRenderVirtualListCollection | null): void;
772
+ protected updateRegularRenderer(): void;
773
+ protected resetRenderers(itemRenderer?: TemplateRef<HTMLElement>): void;
774
+ /**
775
+ * Tracking by id
776
+ */
777
+ protected tracking(): void;
778
+ protected resetBoundsSize(isVertical: boolean, totalSize: number): void;
779
+ /**
780
+ * Returns the bounds of an element with a given id
781
+ */
782
+ getItemBounds(id: Id): ISize | undefined;
783
+ /**
784
+ * The method scrolls the list to the element with the given id and returns the value of the scrolled area.
785
+ * Behavior accepts the values ​​"auto", "instant" and "smooth".
786
+ */
787
+ scrollTo(id: Id, behavior?: ScrollBehavior): void;
788
+ protected _scrollToRepeatExecutionTimeout: number | undefined;
789
+ protected clearScrollToRepeatExecutionTimeout(): void;
790
+ protected scrollToExecutor(id: Id, behavior: ScrollBehavior, iteration?: number, isLastIteration?: boolean): void;
791
+ /**
792
+ * Scrolls the scroll area to the desired element with the specified ID.
793
+ */
794
+ scrollToEnd(behavior?: ScrollBehavior): void;
795
+ protected _onContainerScrollHandler: (e: Event) => void;
796
+ protected _onContainerScrollEndHandler: (e: Event) => void;
797
+ protected afterViewInit(): void;
798
+ protected dispose(): void;
799
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgVirtualListComponent, never>;
800
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<NgVirtualListComponent, "ng-virtual-list", never, { "items": { "alias": "items"; "required": true; "isSignal": true; }; "snap": { "alias": "snap"; "required": false; "isSignal": true; }; "enabledBufferOptimization": { "alias": "enabledBufferOptimization"; "required": false; "isSignal": true; }; "itemRenderer": { "alias": "itemRenderer"; "required": true; "isSignal": true; }; "stickyMap": { "alias": "stickyMap"; "required": false; "isSignal": true; }; "itemSize": { "alias": "itemSize"; "required": false; "isSignal": true; }; "dynamicSize": { "alias": "dynamicSize"; "required": false; "isSignal": true; }; "direction": { "alias": "direction"; "required": false; "isSignal": true; }; "itemsOffset": { "alias": "itemsOffset"; "required": false; "isSignal": true; }; "snappingMethod": { "alias": "snappingMethod"; "required": false; "isSignal": true; }; "trackBy": { "alias": "trackBy"; "required": false; "isSignal": true; }; }, { "onScroll": "onScroll"; "onScrollEnd": "onScrollEnd"; }, never, never, true, never>;
801
+ }
802
+
803
+ export { BaseVirtualListItemComponent, Directions, NgVirtualListComponent, NgVirtualListItemComponent, SnappingMethods };
804
+ export type { Component$1, Direction, IRect, IScrollEvent, ISize, IVirtualListCollection, IVirtualListItem, IVirtualListStickyMap, Id, ScrollDirection, SnappingMethod };