angular-layout-virtual 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AngularRenderer.d.ts +11 -14
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
* @author Alexandr Kalabin
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import type {
|
|
6
|
+
import { BaseRenderer } from 'layout-virtual';
|
|
7
|
+
import type { IRangeRenderer, ScrollDirection, VirtualScrollStructure } from 'layout-virtual/types';
|
|
8
8
|
export interface ListItemProps<T = unknown> {
|
|
9
9
|
data: T;
|
|
10
10
|
index: number;
|
|
@@ -17,25 +17,22 @@ export type AngularListItem<T = unknown> = {
|
|
|
17
17
|
data: T;
|
|
18
18
|
render?: unknown;
|
|
19
19
|
};
|
|
20
|
-
export default class AngularRenderer<
|
|
20
|
+
export default class AngularRenderer<DataType = unknown> extends BaseRenderer implements IRangeRenderer<DataType> {
|
|
21
21
|
private _store;
|
|
22
|
-
private _scrollableContainer;
|
|
23
|
-
private _renderedIndexRegistry;
|
|
24
|
-
private _renderedItemsRegistry;
|
|
25
22
|
private _itemsSetter;
|
|
26
23
|
private _itemsFlusher;
|
|
27
24
|
private _listItems;
|
|
28
|
-
|
|
29
|
-
constructor(opts: AngularRendererOptions<T>);
|
|
30
|
-
render(startIndex: number, endIndex: number, direction: ScrollDirection): number;
|
|
25
|
+
constructor(opts: AngularRendererOptions<DataType>);
|
|
31
26
|
renderRange(startIndex: number, endIndex: number, direction: ScrollDirection): void;
|
|
32
|
-
removeRange(startIndex: number, endIndex: number, direction
|
|
27
|
+
removeRange(startIndex: number, endIndex: number, direction?: ScrollDirection): {
|
|
28
|
+
itemsToRemove: Element[];
|
|
29
|
+
removedHeight: number;
|
|
30
|
+
};
|
|
33
31
|
clear(): void;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
get scrollableContainer(): ScrollableContainer;
|
|
37
|
-
attach(store: IItemStore<IItem<T>>): void;
|
|
32
|
+
setData(store: DataType[]): void;
|
|
33
|
+
setRenderItem(): void;
|
|
38
34
|
flush(): Promise<void>;
|
|
39
35
|
commit(renderedRefs: Map<number, Element>): void;
|
|
36
|
+
get dataSize(): number;
|
|
40
37
|
}
|
|
41
38
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CommonModule as t}from"@angular/common";import{Input as e,ContentChild as i,TemplateRef as r,ViewChild as n,Component as s,inject as o,ChangeDetectorRef as a}from"@angular/core";import
|
|
1
|
+
import{CommonModule as t}from"@angular/common";import{Input as e,ContentChild as i,TemplateRef as r,ViewChild as n,Component as s,inject as o,ChangeDetectorRef as a}from"@angular/core";import{BaseRenderer as c,DynamicListLayout as l,LayoutVirtual as h}from"layout-virtual";class m extends c{t=[];i;o;l=[];constructor(t){super(t),this.i=t.itemsSetter,this.o=t.itemsFlusher}renderRange(t,e,i){const r=this.t,n=this.l,s=[];for(let o=t;o<=e;o++){const t=r[o];t&&s.push({data:t,index:o})}this.l="down"===i?n.concat(s):"up"===i?s.concat(n):this.l}removeRange(t,e,i){const r=super.removeRange(t,e),n=r.itemsToRemove.length;return n&&(this.l="down"===i?this.l.slice(n):"up"===i?this.l.slice(0,-n):this.l),r}clear(){super.clear(),this.l=[],this.i(this.l)}setData(t){this.t=t}setRenderItem(){}flush(){return this.i(this.l),this.o(),Promise.resolve()}commit(t){for(const[e,i]of t.entries())this.registerElement(e,i);t.clear()}get dataSize(){return this.t.length}}var d=Object.defineProperty,p=Object.getOwnPropertyDescriptor,v=(t,e,i,r)=>{for(var n,s=r>1?void 0:r?p(e,i):e,o=t.length-1;o>=0;o--)(n=t[o])&&(s=(r?n(e,i,s):n(s))||s);return r&&s&&d(e,i,s),s};let f=class{data=[];overscanHeight=200;renderItemTemplate;containerRef;scrollHeightFillerRef;viewportContainerRef;scrollCanvasRef;topSpacerRef;contentLayerRef;bottomSpacerRef;visibleItems=[];renderer;changeDetectorRef=o(a);ngAfterViewInit(){this.renderer=new m({container:this.containerRef.nativeElement,scrollHeightFiller:this.scrollHeightFillerRef.nativeElement,viewportContainer:this.viewportContainerRef.nativeElement,scrollCanvas:this.scrollCanvasRef.nativeElement,topSpacer:this.topSpacerRef.nativeElement,contentLayer:this.contentLayerRef.nativeElement,bottomSpacer:this.bottomSpacerRef.nativeElement,itemsSetter:this.setVisibleItems,itemsFlusher:this.flushVisibleItems});const t=new l({overscanHeight:this.overscanHeight,renderer:this.renderer});new h({layout:t}).setData(this.data)}trackByIndex(t,e){return e.index}getItemContext(t){return{$implicit:t.data,data:t.data,index:t.index}}setVisibleItems=t=>{this.visibleItems=t};flushVisibleItems=()=>{this.changeDetectorRef.detectChanges(),this.commit()};commit(){const t=/* @__PURE__ */new Map;Array.from(this.contentLayerRef.nativeElement.children).forEach((e,i)=>{const r=this.visibleItems[i];r&&t.set(r.index,e)}),this.renderer?.commit(t)}};v([e({required:!0})],f.prototype,"data",2),v([e()],f.prototype,"overscanHeight",2),v([i("renderItem",{read:r})],f.prototype,"renderItemTemplate",2),v([n("container",{static:!0})],f.prototype,"containerRef",2),v([n("scrollHeightFiller",{static:!0})],f.prototype,"scrollHeightFillerRef",2),v([n("viewportContainer",{static:!0})],f.prototype,"viewportContainerRef",2),v([n("scrollCanvas",{static:!0})],f.prototype,"scrollCanvasRef",2),v([n("topSpacer",{static:!0})],f.prototype,"topSpacerRef",2),v([n("contentLayer",{static:!0})],f.prototype,"contentLayerRef",2),v([n("bottomSpacer",{static:!0})],f.prototype,"bottomSpacerRef",2),f=v([s({selector:"angular-layout-virtual",standalone:!0,imports:[t],host:{style:"display: contents;"},template:'\n <div #container>\n <div #scrollHeightFiller></div>\n <div #viewportContainer>\n <div #scrollCanvas>\n <div #topSpacer></div>\n <div #contentLayer>\n <ng-container\n *ngFor="let item of visibleItems; trackBy: trackByIndex"\n >\n <ng-container\n *ngTemplateOutlet="\n renderItemTemplate;\n context: getItemContext(item)\n "\n ></ng-container>\n </ng-container>\n </div>\n <div #bottomSpacer></div>\n </div>\n </div>\n </div>\n '})],f);export{f as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "angular-layout-virtual",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Angular virtual scrolling component for responsive lists and grids with dynamic item sizes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"virtual",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"prepublishOnly": "npm run build"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"layout-virtual": "^0.0
|
|
46
|
+
"layout-virtual": "^0.1.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@angular/common": "^21.0.0",
|