ng-virtual-list 18.2.0 → 18.3.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/README.md +4 -4
- package/esm2022/lib/components/ng-virtual-list-item.component.mjs +6 -4
- package/esm2022/lib/enums/direction.mjs +1 -1
- package/esm2022/lib/models/base-virtual-list-item-component.mjs +9 -0
- package/esm2022/lib/models/collection.model.mjs +1 -1
- package/esm2022/lib/models/component.model.mjs +2 -0
- package/esm2022/lib/models/index.mjs +3 -2
- package/esm2022/lib/models/item.model.mjs +1 -2
- package/esm2022/lib/ng-virtual-list.component.mjs +31 -9
- package/esm2022/lib/utils/index.mjs +4 -3
- package/esm2022/lib/utils/trackBox.mjs +2 -2
- package/esm2022/lib/utils/tracker.mjs +1 -1
- package/esm2022/public-api.mjs +2 -1
- package/fesm2022/ng-virtual-list.mjs +44 -12
- package/fesm2022/ng-virtual-list.mjs.map +1 -1
- package/lib/components/ng-virtual-list-item.component.d.ts +2 -1
- package/lib/enums/direction.d.ts +1 -1
- package/lib/models/base-virtual-list-item-component.d.ts +25 -0
- package/lib/models/collection.model.d.ts +1 -1
- package/lib/models/component.model.d.ts +3 -0
- package/lib/models/index.d.ts +4 -1
- package/lib/models/item.model.d.ts +2 -2
- package/lib/ng-virtual-list.component.d.ts +44 -30
- package/lib/utils/index.d.ts +4 -2
- package/lib/utils/trackBox.d.ts +30 -22
- package/lib/utils/tracker.d.ts +7 -5
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
|
@@ -82,13 +82,22 @@ const SCROLL_END = 'scrollend';
|
|
|
82
82
|
const CLASS_LIST_VERTICAL = 'vertical';
|
|
83
83
|
const CLASS_LIST_HORIZONTAL = 'horizontal';
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Virtual List Item Interface
|
|
87
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/18.x/projects/ng-virtual-list/src/lib/models/base-virtual-list-item-component.ts
|
|
88
|
+
* @author Evgenii Grebennikov
|
|
89
|
+
* @email djonnyx@gmail.com
|
|
90
|
+
*/
|
|
91
|
+
class BaseVirtualListItemComponent {
|
|
92
|
+
}
|
|
93
|
+
|
|
85
94
|
/**
|
|
86
95
|
* Virtual list item component
|
|
87
96
|
* @link https://github.com/DjonnyX/ng-virtual-list/blob/18.x/projects/ng-virtual-list/src/lib/components/ng-virtual-list-item.component.ts
|
|
88
97
|
* @author Evgenii Grebennikov
|
|
89
98
|
* @email djonnyx@gmail.com
|
|
90
99
|
*/
|
|
91
|
-
class NgVirtualListItemComponent {
|
|
100
|
+
class NgVirtualListItemComponent extends BaseVirtualListItemComponent {
|
|
92
101
|
static __nextId = 0;
|
|
93
102
|
_id;
|
|
94
103
|
get id() {
|
|
@@ -102,7 +111,7 @@ class NgVirtualListItemComponent {
|
|
|
102
111
|
if (this._data === v) {
|
|
103
112
|
return;
|
|
104
113
|
}
|
|
105
|
-
|
|
114
|
+
this._data = v;
|
|
106
115
|
this.update();
|
|
107
116
|
this.data.set(v);
|
|
108
117
|
this._cdr.detectChanges();
|
|
@@ -131,6 +140,7 @@ class NgVirtualListItemComponent {
|
|
|
131
140
|
return this._elementRef.nativeElement;
|
|
132
141
|
}
|
|
133
142
|
constructor() {
|
|
143
|
+
super();
|
|
134
144
|
this._id = NgVirtualListItemComponent.__nextId = NgVirtualListItemComponent.__nextId === Number.MAX_SAFE_INTEGER
|
|
135
145
|
? 0 : NgVirtualListItemComponent.__nextId + 1;
|
|
136
146
|
}
|
|
@@ -199,7 +209,7 @@ class NgVirtualListItemComponent {
|
|
|
199
209
|
styles.zIndex = HIDDEN_ZINDEX;
|
|
200
210
|
}
|
|
201
211
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgVirtualListItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
202
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: NgVirtualListItemComponent, selector: "ng-virtual-list-item", host: { classAttribute: "ngvl__item" }, ngImport: i0, template: "@let item = data();\r\n@let renderer = itemRenderer();\r\n\r\n@if (item) {\r\n <li #listItem part=\"item\" class=\"ngvl-item__container\" [ngClass]=\"{'snapped': item.config.snapped,\r\n 'snapped-out': item.config.snappedOut}\">\r\n @if (renderer) {\r\n <ng-container [ngTemplateOutlet]=\"renderer\"\r\n [ngTemplateOutletContext]=\"{data: item.data || {}, config: item.config}\" />\r\n }\r\n </li>\r\n}", styles: [":host{display:block;position:absolute;left:0;top:0;box-sizing:border-box;overflow:hidden;will-change:scroll-position}.ngvl-item__container{margin:0;padding:0;overflow:hidden;background-color:#fff;width:inherit;height:inherit}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
212
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: NgVirtualListItemComponent, selector: "ng-virtual-list-item", host: { classAttribute: "ngvl__item" }, usesInheritance: true, ngImport: i0, template: "@let item = data();\r\n@let renderer = itemRenderer();\r\n\r\n@if (item) {\r\n <li #listItem part=\"item\" class=\"ngvl-item__container\" [ngClass]=\"{'snapped': item.config.snapped,\r\n 'snapped-out': item.config.snappedOut}\">\r\n @if (renderer) {\r\n <ng-container [ngTemplateOutlet]=\"renderer\"\r\n [ngTemplateOutletContext]=\"{data: item.data || {}, config: item.config}\" />\r\n }\r\n </li>\r\n}", styles: [":host{display:block;position:absolute;left:0;top:0;box-sizing:border-box;overflow:hidden;will-change:scroll-position}.ngvl-item__container{margin:0;padding:0;overflow:hidden;background-color:#fff;width:inherit;height:inherit}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
203
213
|
}
|
|
204
214
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgVirtualListItemComponent, decorators: [{
|
|
205
215
|
type: Component,
|
|
@@ -1489,6 +1499,7 @@ class NgVirtualListComponent {
|
|
|
1489
1499
|
* Rendering element template.
|
|
1490
1500
|
*/
|
|
1491
1501
|
itemRenderer = input.required();
|
|
1502
|
+
_itemRenderer = signal(undefined);
|
|
1492
1503
|
/**
|
|
1493
1504
|
* Dictionary zIndex by id of the list element. If the value is not set or equal to 0,
|
|
1494
1505
|
* then a simple element is displayed, if the value is greater than 0, then the sticky position mode is enabled for the element.
|
|
@@ -1597,10 +1608,18 @@ class NgVirtualListComponent {
|
|
|
1597
1608
|
* The name of the property by which tracking is performed
|
|
1598
1609
|
*/
|
|
1599
1610
|
trackBy = input(TRACK_BY_PROPERTY_NAME);
|
|
1611
|
+
/**
|
|
1612
|
+
* Base class of the element component
|
|
1613
|
+
*/
|
|
1614
|
+
_itemComponentClass = NgVirtualListItemComponent;
|
|
1615
|
+
/**
|
|
1616
|
+
* Base class trackBox
|
|
1617
|
+
*/
|
|
1618
|
+
_trackBoxClass = TrackBox;
|
|
1600
1619
|
/**
|
|
1601
1620
|
* Dictionary of element sizes by their id
|
|
1602
1621
|
*/
|
|
1603
|
-
_trackBox = new
|
|
1622
|
+
_trackBox = new this._trackBoxClass(this.trackBy());
|
|
1604
1623
|
_onTrackBoxChangeHandler = (v) => {
|
|
1605
1624
|
this._cacheVersion.set(v);
|
|
1606
1625
|
};
|
|
@@ -1657,12 +1676,19 @@ class NgVirtualListComponent {
|
|
|
1657
1676
|
}
|
|
1658
1677
|
return of(displayItems);
|
|
1659
1678
|
})).subscribe();
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1679
|
+
this.setupRenderer();
|
|
1680
|
+
}
|
|
1681
|
+
setupRenderer() {
|
|
1682
|
+
const $itemRenderer = toObservable(this.itemRenderer);
|
|
1683
|
+
$itemRenderer.pipe(takeUntilDestroyed(), distinctUntilChanged(), filter(v => !!v), tap(v => {
|
|
1684
|
+
this._itemRenderer.set(v);
|
|
1685
|
+
})).subscribe();
|
|
1663
1686
|
}
|
|
1664
1687
|
/** @internal */
|
|
1665
1688
|
ngOnInit() {
|
|
1689
|
+
this.onInit();
|
|
1690
|
+
}
|
|
1691
|
+
onInit() {
|
|
1666
1692
|
this._initialized.set(true);
|
|
1667
1693
|
}
|
|
1668
1694
|
listenCacheChangesIfNeed(value) {
|
|
@@ -1692,7 +1718,7 @@ class NgVirtualListComponent {
|
|
|
1692
1718
|
}
|
|
1693
1719
|
if (this._isSnappingMethodAdvanced && this.snap()) {
|
|
1694
1720
|
if (!this._snapedDisplayComponent && this._snapContainerRef) {
|
|
1695
|
-
const comp = this._snapContainerRef.createComponent(
|
|
1721
|
+
const comp = this._snapContainerRef.createComponent(this._itemComponentClass);
|
|
1696
1722
|
comp.instance.regular = true;
|
|
1697
1723
|
this._snapedDisplayComponent = comp;
|
|
1698
1724
|
this._trackBox.snapedDisplayComponent = this._snapedDisplayComponent;
|
|
@@ -1705,7 +1731,7 @@ class NgVirtualListComponent {
|
|
|
1705
1731
|
const maxLength = displayItems.length, components = this._displayComponents;
|
|
1706
1732
|
while (components.length < maxLength) {
|
|
1707
1733
|
if (_listContainerRef) {
|
|
1708
|
-
const comp = _listContainerRef.createComponent(
|
|
1734
|
+
const comp = _listContainerRef.createComponent(this._itemComponentClass);
|
|
1709
1735
|
components.push(comp);
|
|
1710
1736
|
this._componentsResizeObserver.observe(comp.instance.element);
|
|
1711
1737
|
}
|
|
@@ -1721,13 +1747,13 @@ class NgVirtualListComponent {
|
|
|
1721
1747
|
const item = components[i];
|
|
1722
1748
|
if (item) {
|
|
1723
1749
|
const id = item.instance.id;
|
|
1724
|
-
item.instance.renderer = itemRenderer || this.
|
|
1750
|
+
item.instance.renderer = itemRenderer || this._itemRenderer();
|
|
1725
1751
|
doMap[id] = i;
|
|
1726
1752
|
}
|
|
1727
1753
|
}
|
|
1728
1754
|
if (this._isSnappingMethodAdvanced && this.snap() && this._snapedDisplayComponent && this._snapContainerRef) {
|
|
1729
1755
|
const comp = this._snapedDisplayComponent;
|
|
1730
|
-
comp.instance.renderer = itemRenderer || this.
|
|
1756
|
+
comp.instance.renderer = itemRenderer || this._itemRenderer();
|
|
1731
1757
|
}
|
|
1732
1758
|
this._trackBox.setDisplayObjectIndexMapById(doMap);
|
|
1733
1759
|
}
|
|
@@ -1845,6 +1871,9 @@ class NgVirtualListComponent {
|
|
|
1845
1871
|
};
|
|
1846
1872
|
/** @internal */
|
|
1847
1873
|
ngAfterViewInit() {
|
|
1874
|
+
this.afterViewInit();
|
|
1875
|
+
}
|
|
1876
|
+
afterViewInit() {
|
|
1848
1877
|
const containerEl = this._container();
|
|
1849
1878
|
if (containerEl) {
|
|
1850
1879
|
// for direction calculation
|
|
@@ -1858,6 +1887,9 @@ class NgVirtualListComponent {
|
|
|
1858
1887
|
}
|
|
1859
1888
|
/** @internal */
|
|
1860
1889
|
ngOnDestroy() {
|
|
1890
|
+
this.dispose();
|
|
1891
|
+
}
|
|
1892
|
+
dispose() {
|
|
1861
1893
|
this.clearScrollToRepeatExecutionTimeout();
|
|
1862
1894
|
if (this._trackBox) {
|
|
1863
1895
|
this._trackBox.dispose();
|
|
@@ -1924,5 +1956,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
|
1924
1956
|
* Generated bundle index. Do not edit.
|
|
1925
1957
|
*/
|
|
1926
1958
|
|
|
1927
|
-
export { Directions, NgVirtualListComponent, NgVirtualListModule, SnappingMethods };
|
|
1959
|
+
export { BaseVirtualListItemComponent, Directions, NgVirtualListComponent, NgVirtualListItemComponent, NgVirtualListModule, SnappingMethods };
|
|
1928
1960
|
//# sourceMappingURL=ng-virtual-list.mjs.map
|