/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { CollectionViewer, DataSource, ListRange, _RecycleViewRepeaterStrategy } from '@angular/cdk/collections'; import { DoCheck, IterableDiffers, NgIterable, NgZone, OnDestroy, TemplateRef, TrackByFunction, ViewContainerRef } from '@angular/core'; import { NumberInput } from '@angular/cdk/coercion'; import { Observable, Subject } from 'rxjs'; import { CdkVirtualScrollRepeater } from './virtual-scroll-repeater'; import { CdkVirtualScrollViewport } from './virtual-scroll-viewport'; /** The context for an item rendered by `CdkVirtualForOf` */ export declare type CdkVirtualForOfContext = { /** The item value. */ $implicit: T; /** The DataSource, Observable, or NgIterable that was passed to *cdkVirtualFor. */ cdkVirtualForOf: DataSource | Observable | NgIterable; /** The index of the item in the DataSource. */ index: number; /** The number of items in the DataSource. */ count: number; /** Whether this is the first item in the DataSource. */ first: boolean; /** Whether this is the last item in the DataSource. */ last: boolean; /** Whether the index is even. */ even: boolean; /** Whether the index is odd. */ odd: boolean; }; /** * A directive similar to `ngForOf` to be used for rendering data inside a virtual scrolling * container. */ export declare class CdkVirtualForOf implements CdkVirtualScrollRepeater, CollectionViewer, DoCheck, OnDestroy { /** The view container to add items to. */ private _viewContainerRef; /** The template to use when stamping out new items. */ private _template; /** The set of available differs. */ private _differs; /** The strategy used to render items in the virtual scroll viewport. */ private _viewRepeater; /** The virtual scrolling viewport that these items are being rendered in. */ private _viewport; /** Emits when the rendered view of the data changes. */ readonly viewChange: Subject; /** Subject that emits when a new DataSource instance is given. */ private readonly _dataSourceChanges; /** The DataSource to display. */ get cdkVirtualForOf(): DataSource | Observable | NgIterable | null | undefined; set cdkVirtualForOf(value: DataSource | Observable | NgIterable | null | undefined); _cdkVirtualForOf: DataSource | Observable | NgIterable | null | undefined; /** * The `TrackByFunction` to use for tracking changes. The `TrackByFunction` takes the index and * the item and produces a value to be used as the item's identity when tracking changes. */ get cdkVirtualForTrackBy(): TrackByFunction | undefined; set cdkVirtualForTrackBy(fn: TrackByFunction | undefined); private _cdkVirtualForTrackBy; /** The template used to stamp out new elements. */ set cdkVirtualForTemplate(value: TemplateRef>); /** * The size of the cache used to store templates that are not being used for re-use later. * Setting the cache size to `0` will disable caching. Defaults to 20 templates. */ get cdkVirtualForTemplateCacheSize(): number; set cdkVirtualForTemplateCacheSize(size: number); /** Emits whenever the data in the current DataSource changes. */ readonly dataStream: Observable; /** The differ used to calculate changes to the data. */ private _differ; /** The most recent data emitted from the DataSource. */ private _data; /** The currently rendered items. */ private _renderedItems; /** The currently rendered range of indices. */ private _renderedRange; /** Whether the rendered data should be updated during the next ngDoCheck cycle. */ private _needsUpdate; private readonly _destroyed; constructor( /** The view container to add items to. */ _viewContainerRef: ViewContainerRef, /** The template to use when stamping out new items. */ _template: TemplateRef>, /** The set of available differs. */ _differs: IterableDiffers, /** The strategy used to render items in the virtual scroll viewport. */ _viewRepeater: _RecycleViewRepeaterStrategy>, /** The virtual scrolling viewport that these items are being rendered in. */ _viewport: CdkVirtualScrollViewport, ngZone: NgZone); /** * Measures the combined size (width for horizontal orientation, height for vertical) of all items * in the specified range. Throws an error if the range includes items that are not currently * rendered. */ measureRangeSize(range: ListRange, orientation: 'horizontal' | 'vertical'): number; ngDoCheck(): void; ngOnDestroy(): void; /** React to scroll state changes in the viewport. */ private _onRenderedDataChange; /** Swap out one `DataSource` for another. */ private _changeDataSource; /** Update the `CdkVirtualForOfContext` for all views. */ private _updateContext; /** Apply changes to the DOM. */ private _applyChanges; /** Update the computed properties on the `CdkVirtualForOfContext`. */ private _updateComputedContextProperties; private _getEmbeddedViewArgs; static ngAcceptInputType_cdkVirtualForTemplateCacheSize: NumberInput; }