import { DataSource } from '@angular/cdk/collections'; import { BehaviorSubject, Observable, Subject } from 'rxjs'; import { Page, RequestRowsRange, FieldSortDefinition, FieldFilterDefinition, DataStoreProvider } from '../interfaces/datastore-provider.interface'; export interface TableVirtualScrollDataStoreSizes { totalElements: number; totalFilteredElements: number; } export interface TVSDataSource { /** * Attach a TableItemSizeDirective to the DataSource. * The returned observable emits the absolute and the filtered size of the content of the * data store to the virtual scroller e.g. after sorting or filtering of data or with * manual trigger (when the data store content size changed). * @param rangeToDisplay$ - Observable emitting objects defining the rows required by the TableItemSizeDirective * @returns Observable emitting the absolute and the filtered size of the content of the data store */ attachVirtualScroller(rangeToDisplay$: Observable): Observable; } /** * Check, if a given object is of type TableVirtualScrollDataSource. * @param dataSource - object under inspection * @returns true, if dataSource is of type TableVirtualScrollDataSource */ export declare const isTVSDataSource: (dataSource: unknown) => dataSource is TVSDataSource; export declare class TableVirtualScrollDataSource extends DataSource implements TVSDataSource { private datastoreProviderObject?; /** Stream that gets the range of rows to display from the TableItemSizeDirective. */ private rangeToDisplay$; /** Subscription to the stream of ranges that the virtual scroller emits to update the table rendered rows. */ private rangeToDisplaySubscription; /** Stream that emits when the rangeToDisplay$ gets changed */ private readonly rangeToDisplayChanges$; /** Stream that emits when the number of the entries in the data source changes (e.g. by filtering or adding/deleting data). */ private readonly dataStoreSizes$; /** Stream that emits to request the number of entries the data source. */ private readonly requestDataStoreSizes$; /** Stream emitting render data to the table (depends on ordered data changes). */ private readonly renderData; /** Is this DataSource connected to a table? */ private isConnectedToTable; /** maximum number of rows available in data store after filtering */ private filteredSizeOfDataStore; private requestForSizesOnly; /** Last rows requested by virtual scroller */ private lastRangeToDisplay; private lastRowsContent; private readonly unsubscribe$; private readonly loadingSubject; loading$: Observable; /** Sort definition for this datasource */ get sorts(): FieldSortDefinition[]; set sorts(newSorts: FieldSortDefinition[]); private _sorts; /** Filter definition for this datasource */ get filters(): FieldFilterDefinition[]; set filters(newFilters: FieldFilterDefinition[]); private _filters; get dataStoreProvider(): DataStoreProvider; set dataStoreProvider(newDataStoreProvider: DataStoreProvider); private _dataStoreProvider; constructor(datastoreProviderObject?: DataStoreProvider | undefined); /** * Used by the MatTable. Called when it connects to the data source. * @returns stream that emits array to be rendered by material table */ connect(): BehaviorSubject; /** * Used by the MatTable. Called when it disconnects from the data source. */ disconnect(): void; /** * Attach TableItemSizeDirective to this DataSource. * @param rangeToDisplay - observable emitting range of rows to display * @returns observable emitting size of data store */ attachVirtualScroller(rangeToDisplay: Subject): Observable; /** * Reload the size of the datastore. */ reloadSizeOfDatastore(): void; /** * Get index of row in filtered and sorted list of rows. * The index is in the range of 0..n-1 or * -1 if the row is not part of filtered list. * @param row - row to get index for * @returns observable that emits index of row */ rowToIndex(row: T): Observable; /** * Attach the handlers to the stream of row ranges to display, emitted * by the virtual scroller. */ private _updateRangeToDisplaySubscription; /** * Generate a preliminary representation of the next range of rows * to display. Used to update display immediately after scrolling, * even when the data from the data store is not yet available. * As the virtual scroller requests rows beyond the size of the * data store content, we have to limit the output to the maximum * number of rows available after filtering. * @param range - range of rows to scroll to * @returns array with preliminary row content */ private preliminaryRowsToDisplay; /** * Did the size of the datastore change since the last request? * @param page - Page object returned from datastore * @returns true, if the totalElements or the totalFilteredElements changed */ private datastoreSizesChanged; } /** * Class that implements an empty datastore used as a default dataStoreProvider * for the TableVirtualScrollDataSource class. * @template T */ export declare class EmptyDataStoreProvider implements DataStoreProvider { getPagedData(rowsRange: RequestRowsRange, sorts?: FieldSortDefinition[], filters?: FieldFilterDefinition[]): Observable>; indexOfRow(row: T, sorts?: FieldSortDefinition[], filters?: FieldFilterDefinition[]): Observable; }