import { OnInit, OnDestroy } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import { MatTableDataSource, Sort } from '@angular/material'; import { Observable } from 'rxjs'; import { FilterControls, FilterValues, Page, Params, BackendDataSourceFunction } from '../../../core/public-api'; /** * A collection of CSS styles. */ export declare type CssStyles = Params; /** * An enum that represents how to wrap the content of a table cell. */ export declare enum CellContentWrap { /** * The `break` wrap breaks the content when reaching the end of a line. */ break = 0, /** * The `ellipsis` wrap clips the remaining content and renders an ellipsis ("...") * to represent the clipped content. */ ellipsis = 1, /** * The `responsible` wrap is the default style. It only applies the responsible styles * that are defined in the table. */ responsible = 2 } export interface TableAction { icon: string; route: string; tooltip: string; } /** * A interface that represents the content of a table control. * The generic parameter T always refers to the type of data that it is dealing with. */ export interface TableContent { /** * Returns the array of strings that indicates the object property name of the columns. * By default, its value is `[]`. */ columnsObjectProperty?: string[]; /** * Returns the array of strings that indicates the header text of the columns. * By default, its value is `[]`. */ columnsHeaderText?: string[]; /** * Returns the array of strings that indicates the width of the columns. * By default, its value is `[]`. */ columnsWidth?: string[]; /** * Returns the array of `CellContentWrap` that indicates how to wrap the content of the columns. * By default, its value is `[]`. */ columnContentWrap?: CellContentWrap[]; /** * Returns a function that creates the list of CSS classes to apply to the table rows. * In order to take effect these classes, the table CSS file must have defined these classes. * By default, its value is `undefined`. * @param rowData The data that is contained in the row. */ createCssClassesForRow?: (rowData: any) => { [className: string]: boolean; }; /** * Returns the property name of the data contained in `page` that is used to identify that data. * By default, its value is `''`. */ propertyNameToIdentify?: string; /** * The current filter state. * By default, its value is `{}`. */ filter?: FilterControls; /** * The current sort state. * By default, its value is `{ 'active': propertyNameToIdentify, 'direction': SortDirection.asc }`. */ sort?: Sort; /** * Returns the length of the total number of items that are being paginated. * By default, its value is `0`. */ length?: number; /** * Returns the zero-based page index of the displayed list of items. * By default, its value is `0`. */ pageIndex?: number; /** * Returns the number of items to display on a page. * By default, its value is `50`. */ pageSize?: number; /** * Returns the set of provided page size options to display to the user. * By default, its value is `[10, 20, 50]`. */ pageSizeOptions?: number[]; /** * Returns true if it hides the page size selection UI from the user; otherwise, false. * By default, its value is `false`. */ hidePageSize?: boolean; /** * Returns true if it shows the first/last buttons UI to the user; otherwise, false. * By default, its value is `false`. */ showFirstLastButtons?: boolean; /** * Returns the function that is used to get the data source from backend. * The generic parameter T always refers to the type of data that it is dealing with. * By default, its value is `undefined`. */ endpoint?: BackendDataSourceFunction; actions?: TableAction[]; } /** * Returns a new object that represents the default `TableContent`. */ export declare function defaultTableContent(): TableContent; /** * @description * Represents a table control. */ export declare class TableComponent implements OnInit, OnDestroy { private _router; private _activatedRoute; /** * Returns the amount of backend subscriptions. * When its value is different of 0, means the component is loading the data source. * In this way, it shows/hides the loading progress control. * By default, its value is `0`. */ private _countBackendSubscriptions; private _content; /** * Returns the stream that emits the page that should be rendered by the table, * when there is a change in the filtering, sorting, or pagination of the data. Each object * in the `data` field represents one row. This is made for someone that wants to know it. */ private readonly _page; private _pageAsObservable; private _dataSource; private static readonly _defaultDataSource; private _selectedRow; /** * Stream that emits when a new filter is set on the data source. * Because of the behavior and appearance of the component, it is necessary to use * `Subject` instead of `BehaviorSubject` to represent the `_filterValuesChange`. */ private readonly _filterValuesChange; private _filterValues; private _filterValuesSubscription; private _sort; private _paginator; /** * Subscription to the changes that should trigger an update to the table's rendered rows, such * as filtering, sorting, or pagination. */ private _renderChangesSubscription; constructor(_router: Router, _activatedRoute: ActivatedRoute); ngOnInit(): void; ngOnDestroy(): void; /** * Returns true if the data source is empty; otherwise, false. */ readonly isEmpty: boolean; /** * Initializes the component. */ protected init(): void; /** * Initializes the `content` input property. */ private _initContent; /** * Updates the fields related to the filter component. */ private _updateFilter; /** * Updates the fields related to sorting. * @param sortEvent The new sorting to set. */ private _updateSort; /** * Sets the `MatSort` initial values. * The filter component and `MatPaginator` are initialized in a different way. */ private _setMatSortInitialValue; /** * Updates the fields related to pagination. * @param newPage The new page to set. Its type is `Page` or `PageEvent`. */ private _updatePaginator; /** * Sets the `MatSort` and `MatPaginator` disabled or not. * @param disabled Whether the `MatSort` and `MatPaginator` are disabled. */ private _disabledSortPaginator; /** * Subscribes to changes that should trigger an update to the table's rendered rows. When the * changes occur, process the current state of the filter, sort, and pagination along with * the provided base data and send it to the table for rendering. */ private _updateChangeSubscription; /** * Returns the list of CSS classes to apply to the table rows. This method must be only overwrite, * but must never be called for performance reason; it is called in the correct places internally. * In order to take effect these classes, the table CSS file must have defined these classes. * @param rowData The data that is contained in the row. */ protected defaultCreateCssClassesForRow(rowData: any): { [className: string]: boolean; }; /** * Returns the list of CSS styles to apply to the table headers. This method must never be called * because it is for internal use only; it is called in the correct places internally. * @param pos The column position. */ _createCssStylesForHeader(pos: number): CssStyles; /** * Returns the list of CSS styles to apply to the table cells. This method must never be called * because it is for internal use only; it is called in the correct places internally. * @param pos The column position. */ _createCssStylesForCell(pos: number): CssStyles; private _addCssStyles_CellWidth; private _addCssStyles_CellContentWrap; /** * Returns true if it is loading the data source; otherwise, false. */ readonly isLoading: boolean; /** * Returns the selected row. */ readonly selectedRow: number; /** * Returns the input field that contains the content of this class (the table control content to show). */ /** * Sets the input field that contains the content of this class (the table control content to show). * In this way, the component is updated correctly. * @param newContent The new content to set. * If the value is null, sets to `defaultTableContent`. */ content: TableContent; /** * Returns the stream that emits the page that should be rendered by the table, * when there is a change in the filtering, sorting, or pagination of the data. Each object * in the `data` field represents one row. This is made for someone that wants to know it. */ readonly page: Observable>; /** * Sets the page that should be rendered by the table, it erases the data. For internal use only. * @param sortEvent The current sort state. * @param pageEvent The current paginator state. */ private _setDataBeforeCallEndpoint; /** * Sets the page that should be rendered by the table, where each object in the `newPage.data` * represents one row. For internal use only. * @param newPage The new page to set. */ private _setDataAfterCallEndpoint; /** * Returns the data source to render. If the data source is empty, then returns the default data source * that contains only one empty element (it is used to show one row that contains the empty * table information). For internal use only. */ readonly _getDataSource: MatTableDataSource; /** * Checks column. Logs a warn to the console is the array of columns is empty. */ checkColumn(): void; /** * Navigates to the view that shows information about the specified `rowData`. * @param relativeUrl The relative URL to navigate. * @param rowData The data that is contained in the row. */ navigateTo(relativeUrl: string, rowData: any): void; /** * Selects the specified row. * @param rowData The data that is contained in the row. */ selectRow(rowData: any): void; /** * Applies the filter model that should be used to filter out objects from the data source. * Assumes that the backend will call the `trim()` method over its properties. * This method is accepting a partial representation of the filter model. * It combines the specified filter with the last one. This way old filter properties * won't be overridden when only one property is updated. * @param filter The partial representation of the filter model to combine. */ applyFilters(filter: Partial): void; /** * Applies the filter model that should be used to filter out objects from the data source. * Assumes that the backend will call the `trim()` method over its properties. * It combines the specified filter property with the last one. This way old filter properties * won't be overridden when only one property is updated. * @param name The filter name. * @param value The filter value. */ applyFilter(name: string, value: any): void; }