ng-virtual-list 0.7.2 → 14.0.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 (66) hide show
  1. package/README.md +44 -71
  2. package/esm2020/lib/components/ng-virtual-list-item.component.mjs +80 -0
  3. package/esm2020/lib/const/index.mjs +34 -0
  4. package/esm2020/lib/enums/direction.mjs +2 -0
  5. package/esm2020/lib/enums/directions.mjs +18 -0
  6. package/esm2020/lib/enums/index.mjs +3 -0
  7. package/esm2020/lib/models/collection.model.mjs +3 -0
  8. package/esm2020/lib/models/index.mjs +2 -0
  9. package/esm2020/lib/models/item.model.mjs +3 -0
  10. package/esm2020/lib/models/render-collection.model.mjs +3 -0
  11. package/esm2020/lib/models/render-item-config.model.mjs +2 -0
  12. package/esm2020/lib/models/render-item.model.mjs +3 -0
  13. package/esm2020/lib/models/sticky-map.model.mjs +2 -0
  14. package/esm2020/lib/ng-virtual-list.component.mjs +510 -0
  15. package/esm2020/lib/ng-virtual-list.module.mjs +20 -0
  16. package/esm2020/lib/types/id.mjs +2 -0
  17. package/esm2020/lib/types/index.mjs +2 -0
  18. package/esm2020/lib/types/rect.mjs +2 -0
  19. package/esm2020/lib/types/size.mjs +2 -0
  20. package/esm2020/lib/utils/cacheMap.mjs +52 -0
  21. package/esm2020/lib/utils/debounce.mjs +31 -0
  22. package/esm2020/lib/utils/disposableComponent.mjs +29 -0
  23. package/esm2020/lib/utils/eventEmitter.mjs +106 -0
  24. package/esm2020/lib/utils/index.mjs +8 -0
  25. package/esm2020/lib/utils/isDirection.mjs +15 -0
  26. package/esm2020/lib/utils/toggleClassName.mjs +15 -0
  27. package/esm2020/lib/utils/trackBox.mjs +352 -0
  28. package/esm2020/lib/utils/tracker.mjs +108 -0
  29. package/esm2020/ng-virtual-list.mjs +5 -0
  30. package/esm2020/public-api.mjs +8 -0
  31. package/fesm2015/ng-virtual-list.mjs +1360 -0
  32. package/fesm2015/ng-virtual-list.mjs.map +1 -0
  33. package/fesm2020/ng-virtual-list.mjs +1359 -0
  34. package/fesm2020/ng-virtual-list.mjs.map +1 -0
  35. package/index.d.ts +5 -5
  36. package/lib/components/ng-virtual-list-item.component.d.ts +28 -35
  37. package/lib/const/index.d.ts +32 -31
  38. package/lib/enums/direction.d.ts +8 -2
  39. package/lib/enums/directions.d.ts +16 -4
  40. package/lib/enums/index.d.ts +4 -4
  41. package/lib/models/collection.model.d.ts +9 -3
  42. package/lib/models/index.d.ts +4 -4
  43. package/lib/models/item.model.d.ts +14 -5
  44. package/lib/models/render-collection.model.d.ts +9 -3
  45. package/lib/models/render-item-config.model.d.ts +33 -7
  46. package/lib/models/render-item.model.d.ts +28 -10
  47. package/lib/models/sticky-map.model.d.ts +12 -6
  48. package/lib/ng-virtual-list.component.d.ts +151 -110
  49. package/lib/ng-virtual-list.module.d.ts +9 -0
  50. package/lib/types/id.d.ts +7 -1
  51. package/lib/types/index.d.ts +4 -4
  52. package/lib/types/rect.d.ts +17 -5
  53. package/lib/types/size.d.ts +16 -4
  54. package/lib/utils/cacheMap.d.ts +34 -31
  55. package/lib/utils/debounce.d.ts +16 -10
  56. package/lib/utils/disposableComponent.d.ts +15 -0
  57. package/lib/utils/eventEmitter.d.ts +40 -37
  58. package/lib/utils/index.d.ts +7 -6
  59. package/lib/utils/isDirection.d.ts +8 -2
  60. package/lib/utils/toggleClassName.d.ts +7 -1
  61. package/lib/utils/trackBox.d.ts +113 -73
  62. package/lib/utils/tracker.d.ts +38 -38
  63. package/package.json +18 -6
  64. package/public-api.d.ts +4 -3
  65. package/fesm2022/ng-virtual-list.mjs +0 -942
  66. package/fesm2022/ng-virtual-list.mjs.map +0 -1
@@ -1,73 +1,113 @@
1
- import { ComponentRef } from "@angular/core";
2
- import { NgVirtualListItemComponent } from "../components/ng-virtual-list-item.component";
3
- import { IVirtualListCollection } from "../models/collection.model";
4
- import { IRenderVirtualListCollection } from "../models/render-collection.model";
5
- import { IRenderVirtualListItem } from "../models/render-item.model";
6
- import { Id } from "../types/id";
7
- import { IRect } from "../types/rect";
8
- import { CacheMap } from "./cacheMap";
9
- import { Tracker } from "./tracker";
10
- import { ISize } from "../types";
11
- export declare const TRACK_BOX_CHANGE_EVENT_NAME = "change";
12
- export interface IMetrics {
13
- itemsFromStartToScrollEnd: number;
14
- itemsFromStartToDisplayEnd: number;
15
- itemsOnDisplay: number;
16
- itemsOnDisplayLength: number;
17
- leftHiddenItemsWeight: number;
18
- leftItemLength: number;
19
- leftItemsWeight: number;
20
- rightItemLength: number;
21
- rightItemsWeight: number;
22
- snippedPos: number;
23
- totalItemsToDisplayEndWeight: number;
24
- totalSize: number;
25
- typicalItemSize: number;
26
- }
27
- interface IRecalculateMetricsOptions {
28
- bounds: ISize;
29
- collection: IVirtualListCollection;
30
- isVertical: boolean;
31
- itemSize: number;
32
- itemsOffset: number;
33
- dynamicSize: boolean;
34
- scrollSize: number;
35
- snap: boolean;
36
- }
37
- type CacheMapEvents = typeof TRACK_BOX_CHANGE_EVENT_NAME;
38
- type OnChangeEventListener = (version: number) => void;
39
- type CacheMapListeners = OnChangeEventListener;
40
- /**
41
- * An object that performs tracking, calculations and caching.
42
- * @homepage https://github.com/DjonnyX/ng-virtual-list/tree/main/projects/ng-virtual-list
43
- * @author Evgenii Grebennikov
44
- * @email djonnyx@gmail.com
45
- */
46
- export declare class TrackBox extends CacheMap<Id, IRect, CacheMapEvents, CacheMapListeners> {
47
- protected _tracker: Tracker<IRenderVirtualListItem, NgVirtualListItemComponent>;
48
- protected _items: IRenderVirtualListCollection | null | undefined;
49
- set items(v: IRenderVirtualListCollection | null | undefined);
50
- protected _displayComponents: Array<ComponentRef<NgVirtualListItemComponent>> | null | undefined;
51
- set displayComponents(v: Array<ComponentRef<NgVirtualListItemComponent>> | null | undefined);
52
- constructor(trackingPropertyName: string);
53
- set(id: Id, bounds: IRect): Map<Id, IRect>;
54
- private _fireChanges;
55
- private _debounceChanges;
56
- protected fireChange(): void;
57
- recalculateMetrics(options: IRecalculateMetricsOptions): IMetrics;
58
- /**
59
- * tracking by propName
60
- */
61
- track(): void;
62
- setDisplayObjectIndexMapById(v: {
63
- [id: number]: number;
64
- }): void;
65
- untrackComponentByIdProperty(component?: NgVirtualListItemComponent | undefined): void;
66
- cacheElements(): void;
67
- /**
68
- * Returns calculated bounds from cache
69
- */
70
- private getBoundsFromCache;
71
- dispose(): void;
72
- }
73
- export {};
1
+ import { ComponentRef } from "@angular/core";
2
+ import { NgVirtualListItemComponent } from "../components/ng-virtual-list-item.component";
3
+ import { IRenderVirtualListCollection } from "../models/render-collection.model";
4
+ import { IRenderVirtualListItem } from "../models/render-item.model";
5
+ import { Id } from "../types/id";
6
+ import { IRect } from "../types/rect";
7
+ import { CacheMap } from "./cacheMap";
8
+ import { Tracker } from "./tracker";
9
+ import { ISize } from "../types";
10
+ import { HEIGHT_PROP_NAME, WIDTH_PROP_NAME } from "../const";
11
+ import { IVirtualListStickyMap } from "../models";
12
+ export declare const TRACK_BOX_CHANGE_EVENT_NAME = "change";
13
+ export interface IMetrics {
14
+ delta: number;
15
+ normalizedItemWidth: number;
16
+ normalizedItemHeight: number;
17
+ width: number;
18
+ height: number;
19
+ dynamicSize: boolean;
20
+ itemSize: number;
21
+ itemsFromStartToScrollEnd: number;
22
+ itemsFromStartToDisplayEnd: number;
23
+ itemsOnDisplay: number;
24
+ itemsOnDisplayLength: number;
25
+ isVertical: boolean;
26
+ leftHiddenItemsWeight: number;
27
+ leftItemLength: number;
28
+ leftItemsWeight: number;
29
+ renderItems: number;
30
+ rightItemLength: number;
31
+ rightItemsWeight: number;
32
+ scrollSize: number;
33
+ sizeProperty: typeof HEIGHT_PROP_NAME | typeof WIDTH_PROP_NAME;
34
+ snap: boolean;
35
+ snippedPos: number;
36
+ startIndex: number;
37
+ startPosition: number;
38
+ totalItemsToDisplayEndWeight: number;
39
+ totalLength: number;
40
+ totalSize: number;
41
+ typicalItemSize: number;
42
+ }
43
+ export declare type ScrollDirection = -1 | 0 | 1;
44
+ export interface IRecalculateMetricsOptions<I extends {
45
+ id: Id;
46
+ }, C extends Array<I>> {
47
+ bounds: ISize;
48
+ collection: C;
49
+ isVertical: boolean;
50
+ itemSize: number;
51
+ itemsOffset: number;
52
+ dynamicSize: boolean;
53
+ scrollSize: number;
54
+ snap: boolean;
55
+ fromItemId?: Id;
56
+ scrollDirection?: ScrollDirection;
57
+ }
58
+ declare type CacheMapEvents = typeof TRACK_BOX_CHANGE_EVENT_NAME;
59
+ declare type OnChangeEventListener = (version: number) => void;
60
+ declare type CacheMapListeners = OnChangeEventListener;
61
+ /**
62
+ * An object that performs tracking, calculations and caching.
63
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/utils/trackBox.ts
64
+ * @author Evgenii Grebennikov
65
+ * @email djonnyx@gmail.com
66
+ */
67
+ export declare class TrackBox extends CacheMap<Id, IRect, CacheMapEvents, CacheMapListeners> {
68
+ protected _tracker: Tracker<IRenderVirtualListItem, NgVirtualListItemComponent>;
69
+ protected _items: IRenderVirtualListCollection | null | undefined;
70
+ set items(v: IRenderVirtualListCollection | null | undefined);
71
+ protected _displayComponents: Array<ComponentRef<NgVirtualListItemComponent>> | null | undefined;
72
+ set displayComponents(v: Array<ComponentRef<NgVirtualListItemComponent>> | null | undefined);
73
+ constructor(trackingPropertyName: string);
74
+ set(id: Id, bounds: IRect): Map<Id, IRect>;
75
+ private _fireChanges;
76
+ private _debounceChanges;
77
+ protected fireChange(): void;
78
+ getItemPosition<I extends {
79
+ id: Id;
80
+ }, C extends Array<I>>(id: Id, stickyMap: IVirtualListStickyMap, options: IRecalculateMetricsOptions<I, C>): number;
81
+ updateCollection<I extends {
82
+ id: Id;
83
+ }, C extends Array<I>>(items: C, stickyMap: IVirtualListStickyMap, options: Omit<IRecalculateMetricsOptions<I, C>, 'collection'>): {
84
+ displayItems: IRenderVirtualListCollection;
85
+ totalSize: number;
86
+ delta: number;
87
+ };
88
+ /**
89
+ * Calculates list metrics
90
+ */
91
+ protected recalculateMetrics<I extends {
92
+ id: Id;
93
+ }, C extends Array<I>>(options: IRecalculateMetricsOptions<I, C>): IMetrics;
94
+ clearDelta(): void;
95
+ protected generateDisplayCollection<I extends {
96
+ id: Id;
97
+ }, C extends Array<I>>(items: C, stickyMap: IVirtualListStickyMap, metrics: IMetrics): IRenderVirtualListCollection;
98
+ /**
99
+ * tracking by propName
100
+ */
101
+ track(): void;
102
+ setDisplayObjectIndexMapById(v: {
103
+ [id: number]: number;
104
+ }): void;
105
+ untrackComponentByIdProperty(component?: NgVirtualListItemComponent | undefined): void;
106
+ protected cacheElements(): void;
107
+ /**
108
+ * Returns calculated bounds from cache
109
+ */
110
+ private getBoundsFromCache;
111
+ dispose(): void;
112
+ }
113
+ export {};
@@ -1,38 +1,38 @@
1
- import { ComponentRef } from "@angular/core";
2
- /**
3
- * Tracks display items by property
4
- * @homepage https://github.com/DjonnyX/ng-virtual-list/tree/main/projects/ng-virtual-list
5
- * @author Evgenii Grebennikov
6
- * @email djonnyx@gmail.com
7
- */
8
- export declare class Tracker<I = any, C = {
9
- [prop: string]: any;
10
- }> {
11
- /**
12
- * display objects dictionary of indexes by id
13
- */
14
- private _displayObjectIndexMapById;
15
- set displayObjectIndexMapById(v: {
16
- [id: number]: number;
17
- });
18
- get displayObjectIndexMapById(): {
19
- [id: number]: number;
20
- };
21
- /**
22
- * Dictionary displayItems propertyNameId by items propertyNameId
23
- */
24
- private _trackMap;
25
- get trackMap(): {
26
- [id: string]: number;
27
- [id: number]: number;
28
- } | null;
29
- private _trackingPropertyName;
30
- constructor(trackingPropertyName: string);
31
- /**
32
- * tracking by propName
33
- */
34
- track(items: Array<any>, components: Array<ComponentRef<any>>, afterComponentSetup?: (component: C, item: I) => void): void;
35
- untrackComponentByIdProperty(component?: C): void;
36
- private _checkComponentProperty;
37
- dispose(): void;
38
- }
1
+ import { ComponentRef } from "@angular/core";
2
+ /**
3
+ * Tracks display items by property
4
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/utils/tracker.ts
5
+ * @author Evgenii Grebennikov
6
+ * @email djonnyx@gmail.com
7
+ */
8
+ export declare class Tracker<I = any, C = {
9
+ [prop: string]: any;
10
+ }> {
11
+ /**
12
+ * display objects dictionary of indexes by id
13
+ */
14
+ private _displayObjectIndexMapById;
15
+ set displayObjectIndexMapById(v: {
16
+ [id: number]: number;
17
+ });
18
+ get displayObjectIndexMapById(): {
19
+ [id: number]: number;
20
+ };
21
+ /**
22
+ * Dictionary displayItems propertyNameId by items propertyNameId
23
+ */
24
+ private _trackMap;
25
+ get trackMap(): {
26
+ [id: string]: number;
27
+ [id: number]: number;
28
+ } | null;
29
+ private _trackingPropertyName;
30
+ constructor(trackingPropertyName: string);
31
+ /**
32
+ * tracking by propName
33
+ */
34
+ track(items: Array<any>, components: Array<ComponentRef<any>>, afterComponentSetup?: (component: C, item: I) => void): void;
35
+ untrackComponentByIdProperty(component?: C): void;
36
+ private _checkComponentProperty;
37
+ dispose(): void;
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-virtual-list",
3
- "version": "0.7.2",
3
+ "version": "14.0.0",
4
4
  "author": {
5
5
  "name": "Evgenii Grebennikov",
6
6
  "email": "djonnyx@gmail.com"
@@ -13,17 +13,25 @@
13
13
  "virtual",
14
14
  "virtualized",
15
15
  "list",
16
- "scroll"
16
+ "group",
17
+ "grouped",
18
+ "scroll",
19
+ "scrolling",
20
+ "scroller"
17
21
  ],
18
22
  "peerDependencies": {
19
- "@angular/common": "^19.2.0",
20
- "@angular/core": "^19.2.0"
23
+ "@angular/common": "^14.2.0",
24
+ "@angular/core": "^14.2.0"
21
25
  },
22
26
  "dependencies": {
23
27
  "tslib": "^2.3.0"
24
28
  },
25
29
  "sideEffects": false,
26
- "module": "fesm2022/ng-virtual-list.mjs",
30
+ "module": "fesm2015/ng-virtual-list.mjs",
31
+ "es2020": "fesm2020/ng-virtual-list.mjs",
32
+ "esm2020": "esm2020/ng-virtual-list.mjs",
33
+ "fesm2020": "fesm2020/ng-virtual-list.mjs",
34
+ "fesm2015": "fesm2015/ng-virtual-list.mjs",
27
35
  "typings": "index.d.ts",
28
36
  "exports": {
29
37
  "./package.json": {
@@ -31,7 +39,11 @@
31
39
  },
32
40
  ".": {
33
41
  "types": "./index.d.ts",
34
- "default": "./fesm2022/ng-virtual-list.mjs"
42
+ "esm2020": "./esm2020/ng-virtual-list.mjs",
43
+ "es2020": "./fesm2020/ng-virtual-list.mjs",
44
+ "es2015": "./fesm2015/ng-virtual-list.mjs",
45
+ "node": "./fesm2015/ng-virtual-list.mjs",
46
+ "default": "./fesm2020/ng-virtual-list.mjs"
35
47
  }
36
48
  }
37
49
  }
package/public-api.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export * from './lib/ng-virtual-list.component';
2
- export * from './lib/models';
3
- export * from './lib/types';
1
+ export * from './lib/ng-virtual-list.module';
2
+ export * from './lib/ng-virtual-list.component';
3
+ export * from './lib/models';
4
+ export * from './lib/types';