source: trip-planner-front/node_modules/@angular/cdk/table/table.d.ts@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 23.6 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Directionality } from '@angular/cdk/bidi';
9import { BooleanInput } from '@angular/cdk/coercion';
10import { CollectionViewer, DataSource, _ViewRepeater } from '@angular/cdk/collections';
11import { Platform } from '@angular/cdk/platform';
12import { ViewportRuler } from '@angular/cdk/scrolling';
13import { AfterContentChecked, ChangeDetectorRef, ElementRef, EventEmitter, IterableDiffers, OnDestroy, OnInit, QueryList, TrackByFunction, ViewContainerRef } from '@angular/core';
14import { BehaviorSubject, Observable } from 'rxjs';
15import { CdkColumnDef } from './cell';
16import { _CoalescedStyleScheduler } from './coalesced-style-scheduler';
17import { CdkCellOutletMultiRowContext, CdkCellOutletRowContext, CdkFooterRowDef, CdkHeaderRowDef, CdkNoDataRow, CdkRowDef } from './row';
18import { StickyPositioningListener } from './sticky-position-listener';
19/**
20 * Enables the recycle view repeater strategy, which reduces rendering latency. Not compatible with
21 * tables that animate rows.
22 */
23export declare class CdkRecycleRows {
24}
25/** Interface used to provide an outlet for rows to be inserted into. */
26export interface RowOutlet {
27 viewContainer: ViewContainerRef;
28}
29/**
30 * Union of the types that can be set as the data source for a `CdkTable`.
31 * @docs-private
32 */
33declare type CdkTableDataSourceInput<T> = readonly T[] | DataSource<T> | Observable<readonly T[]>;
34/**
35 * Provides a handle for the table to grab the view container's ng-container to insert data rows.
36 * @docs-private
37 */
38export declare class DataRowOutlet implements RowOutlet {
39 viewContainer: ViewContainerRef;
40 elementRef: ElementRef;
41 constructor(viewContainer: ViewContainerRef, elementRef: ElementRef);
42}
43/**
44 * Provides a handle for the table to grab the view container's ng-container to insert the header.
45 * @docs-private
46 */
47export declare class HeaderRowOutlet implements RowOutlet {
48 viewContainer: ViewContainerRef;
49 elementRef: ElementRef;
50 constructor(viewContainer: ViewContainerRef, elementRef: ElementRef);
51}
52/**
53 * Provides a handle for the table to grab the view container's ng-container to insert the footer.
54 * @docs-private
55 */
56export declare class FooterRowOutlet implements RowOutlet {
57 viewContainer: ViewContainerRef;
58 elementRef: ElementRef;
59 constructor(viewContainer: ViewContainerRef, elementRef: ElementRef);
60}
61/**
62 * Provides a handle for the table to grab the view
63 * container's ng-container to insert the no data row.
64 * @docs-private
65 */
66export declare class NoDataRowOutlet implements RowOutlet {
67 viewContainer: ViewContainerRef;
68 elementRef: ElementRef;
69 constructor(viewContainer: ViewContainerRef, elementRef: ElementRef);
70}
71/**
72 * The table template that can be used by the mat-table. Should not be used outside of the
73 * material library.
74 * @docs-private
75 */
76export declare const CDK_TABLE_TEMPLATE = "\n <ng-content select=\"caption\"></ng-content>\n <ng-content select=\"colgroup, col\"></ng-content>\n <ng-container headerRowOutlet></ng-container>\n <ng-container rowOutlet></ng-container>\n <ng-container noDataRowOutlet></ng-container>\n <ng-container footerRowOutlet></ng-container>\n";
77/**
78 * Interface used to conveniently type the possible context interfaces for the render row.
79 * @docs-private
80 */
81export interface RowContext<T> extends CdkCellOutletMultiRowContext<T>, CdkCellOutletRowContext<T> {
82}
83/**
84 * Set of properties that represents the identity of a single rendered row.
85 *
86 * When the table needs to determine the list of rows to render, it will do so by iterating through
87 * each data object and evaluating its list of row templates to display (when multiTemplateDataRows
88 * is false, there is only one template per data object). For each pair of data object and row
89 * template, a `RenderRow` is added to the list of rows to render. If the data object and row
90 * template pair has already been rendered, the previously used `RenderRow` is added; else a new
91 * `RenderRow` is * created. Once the list is complete and all data objects have been itereated
92 * through, a diff is performed to determine the changes that need to be made to the rendered rows.
93 *
94 * @docs-private
95 */
96export interface RenderRow<T> {
97 data: T;
98 dataIndex: number;
99 rowDef: CdkRowDef<T>;
100}
101/**
102 * A data table that can render a header row, data rows, and a footer row.
103 * Uses the dataSource input to determine the data to be rendered. The data can be provided either
104 * as a data array, an Observable stream that emits the data array to render, or a DataSource with a
105 * connect function that will return an Observable stream that emits the data array to render.
106 */
107export declare class CdkTable<T> implements AfterContentChecked, CollectionViewer, OnDestroy, OnInit {
108 protected readonly _differs: IterableDiffers;
109 protected readonly _changeDetectorRef: ChangeDetectorRef;
110 protected readonly _elementRef: ElementRef;
111 protected readonly _dir: Directionality;
112 private _platform;
113 protected readonly _viewRepeater: _ViewRepeater<T, RenderRow<T>, RowContext<T>>;
114 protected readonly _coalescedStyleScheduler: _CoalescedStyleScheduler;
115 private readonly _viewportRuler;
116 /**
117 * @deprecated `_stickyPositioningListener` parameter to become required.
118 * @breaking-change 13.0.0
119 */
120 protected readonly _stickyPositioningListener: StickyPositioningListener;
121 private _document;
122 /** Latest data provided by the data source. */
123 protected _data: readonly T[];
124 /** Subject that emits when the component has been destroyed. */
125 private readonly _onDestroy;
126 /** List of the rendered rows as identified by their `RenderRow` object. */
127 private _renderRows;
128 /** Subscription that listens for the data provided by the data source. */
129 private _renderChangeSubscription;
130 /**
131 * Map of all the user's defined columns (header, data, and footer cell template) identified by
132 * name. Collection populated by the column definitions gathered by `ContentChildren` as well as
133 * any custom column definitions added to `_customColumnDefs`.
134 */
135 private _columnDefsByName;
136 /**
137 * Set of all row definitions that can be used by this table. Populated by the rows gathered by
138 * using `ContentChildren` as well as any custom row definitions added to `_customRowDefs`.
139 */
140 private _rowDefs;
141 /**
142 * Set of all header row definitions that can be used by this table. Populated by the rows
143 * gathered by using `ContentChildren` as well as any custom row definitions added to
144 * `_customHeaderRowDefs`.
145 */
146 private _headerRowDefs;
147 /**
148 * Set of all row definitions that can be used by this table. Populated by the rows gathered by
149 * using `ContentChildren` as well as any custom row definitions added to
150 * `_customFooterRowDefs`.
151 */
152 private _footerRowDefs;
153 /** Differ used to find the changes in the data provided by the data source. */
154 private _dataDiffer;
155 /** Stores the row definition that does not have a when predicate. */
156 private _defaultRowDef;
157 /**
158 * Column definitions that were defined outside of the direct content children of the table.
159 * These will be defined when, e.g., creating a wrapper around the cdkTable that has
160 * column definitions as *its* content child.
161 */
162 private _customColumnDefs;
163 /**
164 * Data row definitions that were defined outside of the direct content children of the table.
165 * These will be defined when, e.g., creating a wrapper around the cdkTable that has
166 * built-in data rows as *its* content child.
167 */
168 private _customRowDefs;
169 /**
170 * Header row definitions that were defined outside of the direct content children of the table.
171 * These will be defined when, e.g., creating a wrapper around the cdkTable that has
172 * built-in header rows as *its* content child.
173 */
174 private _customHeaderRowDefs;
175 /**
176 * Footer row definitions that were defined outside of the direct content children of the table.
177 * These will be defined when, e.g., creating a wrapper around the cdkTable that has a
178 * built-in footer row as *its* content child.
179 */
180 private _customFooterRowDefs;
181 /** No data row that was defined outside of the direct content children of the table. */
182 private _customNoDataRow;
183 /**
184 * Whether the header row definition has been changed. Triggers an update to the header row after
185 * content is checked. Initialized as true so that the table renders the initial set of rows.
186 */
187 private _headerRowDefChanged;
188 /**
189 * Whether the footer row definition has been changed. Triggers an update to the footer row after
190 * content is checked. Initialized as true so that the table renders the initial set of rows.
191 */
192 private _footerRowDefChanged;
193 /**
194 * Whether the sticky column styles need to be updated. Set to `true` when the visible columns
195 * change.
196 */
197 private _stickyColumnStylesNeedReset;
198 /**
199 * Whether the sticky styler should recalculate cell widths when applying sticky styles. If
200 * `false`, cached values will be used instead. This is only applicable to tables with
201 * {@link fixedLayout} enabled. For other tables, cell widths will always be recalculated.
202 */
203 private _forceRecalculateCellWidths;
204 /**
205 * Cache of the latest rendered `RenderRow` objects as a map for easy retrieval when constructing
206 * a new list of `RenderRow` objects for rendering rows. Since the new list is constructed with
207 * the cached `RenderRow` objects when possible, the row identity is preserved when the data
208 * and row template matches, which allows the `IterableDiffer` to check rows by reference
209 * and understand which rows are added/moved/removed.
210 *
211 * Implemented as a map of maps where the first key is the `data: T` object and the second is the
212 * `CdkRowDef<T>` object. With the two keys, the cache points to a `RenderRow<T>` object that
213 * contains an array of created pairs. The array is necessary to handle cases where the data
214 * array contains multiple duplicate data objects and each instantiated `RenderRow` must be
215 * stored.
216 */
217 private _cachedRenderRowsMap;
218 /** Whether the table is applied to a native `<table>`. */
219 protected _isNativeHtmlTable: boolean;
220 /**
221 * Utility class that is responsible for applying the appropriate sticky positioning styles to
222 * the table's rows and cells.
223 */
224 private _stickyStyler;
225 /**
226 * CSS class added to any row or cell that has sticky positioning applied. May be overriden by
227 * table subclasses.
228 */
229 protected stickyCssClass: string;
230 /**
231 * Whether to manually add positon: sticky to all sticky cell elements. Not needed if
232 * the position is set in a selector associated with the value of stickyCssClass. May be
233 * overridden by table subclasses
234 */
235 protected needsPositionStickyOnElement: boolean;
236 /** Whether the no data row is currently showing anything. */
237 private _isShowingNoDataRow;
238 /**
239 * Tracking function that will be used to check the differences in data changes. Used similarly
240 * to `ngFor` `trackBy` function. Optimize row operations by identifying a row based on its data
241 * relative to the function to know if a row should be added/removed/moved.
242 * Accepts a function that takes two parameters, `index` and `item`.
243 */
244 get trackBy(): TrackByFunction<T>;
245 set trackBy(fn: TrackByFunction<T>);
246 private _trackByFn;
247 /**
248 * The table's source of data, which can be provided in three ways (in order of complexity):
249 * - Simple data array (each object represents one table row)
250 * - Stream that emits a data array each time the array changes
251 * - `DataSource` object that implements the connect/disconnect interface.
252 *
253 * If a data array is provided, the table must be notified when the array's objects are
254 * added, removed, or moved. This can be done by calling the `renderRows()` function which will
255 * render the diff since the last table render. If the data array reference is changed, the table
256 * will automatically trigger an update to the rows.
257 *
258 * When providing an Observable stream, the table will trigger an update automatically when the
259 * stream emits a new array of data.
260 *
261 * Finally, when providing a `DataSource` object, the table will use the Observable stream
262 * provided by the connect function and trigger updates when that stream emits new data array
263 * values. During the table's ngOnDestroy or when the data source is removed from the table, the
264 * table will call the DataSource's `disconnect` function (may be useful for cleaning up any
265 * subscriptions registered during the connect process).
266 */
267 get dataSource(): CdkTableDataSourceInput<T>;
268 set dataSource(dataSource: CdkTableDataSourceInput<T>);
269 private _dataSource;
270 /**
271 * Whether to allow multiple rows per data object by evaluating which rows evaluate their 'when'
272 * predicate to true. If `multiTemplateDataRows` is false, which is the default value, then each
273 * dataobject will render the first row that evaluates its when predicate to true, in the order
274 * defined in the table, or otherwise the default row which does not have a when predicate.
275 */
276 get multiTemplateDataRows(): boolean;
277 set multiTemplateDataRows(v: boolean);
278 _multiTemplateDataRows: boolean;
279 /**
280 * Whether to use a fixed table layout. Enabling this option will enforce consistent column widths
281 * and optimize rendering sticky styles for native tables. No-op for flex tables.
282 */
283 get fixedLayout(): boolean;
284 set fixedLayout(v: boolean);
285 private _fixedLayout;
286 /**
287 * Emits when the table completes rendering a set of data rows based on the latest data from the
288 * data source, even if the set of rows is empty.
289 */
290 readonly contentChanged: EventEmitter<void>;
291 /**
292 * Stream containing the latest information on what rows are being displayed on screen.
293 * Can be used by the data source to as a heuristic of what data should be provided.
294 *
295 * @docs-private
296 */
297 readonly viewChange: BehaviorSubject<{
298 start: number;
299 end: number;
300 }>;
301 _rowOutlet: DataRowOutlet;
302 _headerRowOutlet: HeaderRowOutlet;
303 _footerRowOutlet: FooterRowOutlet;
304 _noDataRowOutlet: NoDataRowOutlet;
305 /**
306 * The column definitions provided by the user that contain what the header, data, and footer
307 * cells should render for each column.
308 */
309 _contentColumnDefs: QueryList<CdkColumnDef>;
310 /** Set of data row definitions that were provided to the table as content children. */
311 _contentRowDefs: QueryList<CdkRowDef<T>>;
312 /** Set of header row definitions that were provided to the table as content children. */
313 _contentHeaderRowDefs: QueryList<CdkHeaderRowDef>;
314 /** Set of footer row definitions that were provided to the table as content children. */
315 _contentFooterRowDefs: QueryList<CdkFooterRowDef>;
316 /** Row definition that will only be rendered if there's no data in the table. */
317 _noDataRow: CdkNoDataRow;
318 constructor(_differs: IterableDiffers, _changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef, role: string, _dir: Directionality, _document: any, _platform: Platform, _viewRepeater: _ViewRepeater<T, RenderRow<T>, RowContext<T>>, _coalescedStyleScheduler: _CoalescedStyleScheduler, _viewportRuler: ViewportRuler,
319 /**
320 * @deprecated `_stickyPositioningListener` parameter to become required.
321 * @breaking-change 13.0.0
322 */
323 _stickyPositioningListener: StickyPositioningListener);
324 ngOnInit(): void;
325 ngAfterContentChecked(): void;
326 ngOnDestroy(): void;
327 /**
328 * Renders rows based on the table's latest set of data, which was either provided directly as an
329 * input or retrieved through an Observable stream (directly or from a DataSource).
330 * Checks for differences in the data since the last diff to perform only the necessary
331 * changes (add/remove/move rows).
332 *
333 * If the table's data source is a DataSource or Observable, this will be invoked automatically
334 * each time the provided Observable stream emits a new data array. Otherwise if your data is
335 * an array, this function will need to be called to render any changes.
336 */
337 renderRows(): void;
338 /** Adds a column definition that was not included as part of the content children. */
339 addColumnDef(columnDef: CdkColumnDef): void;
340 /** Removes a column definition that was not included as part of the content children. */
341 removeColumnDef(columnDef: CdkColumnDef): void;
342 /** Adds a row definition that was not included as part of the content children. */
343 addRowDef(rowDef: CdkRowDef<T>): void;
344 /** Removes a row definition that was not included as part of the content children. */
345 removeRowDef(rowDef: CdkRowDef<T>): void;
346 /** Adds a header row definition that was not included as part of the content children. */
347 addHeaderRowDef(headerRowDef: CdkHeaderRowDef): void;
348 /** Removes a header row definition that was not included as part of the content children. */
349 removeHeaderRowDef(headerRowDef: CdkHeaderRowDef): void;
350 /** Adds a footer row definition that was not included as part of the content children. */
351 addFooterRowDef(footerRowDef: CdkFooterRowDef): void;
352 /** Removes a footer row definition that was not included as part of the content children. */
353 removeFooterRowDef(footerRowDef: CdkFooterRowDef): void;
354 /** Sets a no data row definition that was not included as a part of the content children. */
355 setNoDataRow(noDataRow: CdkNoDataRow | null): void;
356 /**
357 * Updates the header sticky styles. First resets all applied styles with respect to the cells
358 * sticking to the top. Then, evaluating which cells need to be stuck to the top. This is
359 * automatically called when the header row changes its displayed set of columns, or if its
360 * sticky input changes. May be called manually for cases where the cell content changes outside
361 * of these events.
362 */
363 updateStickyHeaderRowStyles(): void;
364 /**
365 * Updates the footer sticky styles. First resets all applied styles with respect to the cells
366 * sticking to the bottom. Then, evaluating which cells need to be stuck to the bottom. This is
367 * automatically called when the footer row changes its displayed set of columns, or if its
368 * sticky input changes. May be called manually for cases where the cell content changes outside
369 * of these events.
370 */
371 updateStickyFooterRowStyles(): void;
372 /**
373 * Updates the column sticky styles. First resets all applied styles with respect to the cells
374 * sticking to the left and right. Then sticky styles are added for the left and right according
375 * to the column definitions for each cell in each row. This is automatically called when
376 * the data source provides a new set of data or when a column definition changes its sticky
377 * input. May be called manually for cases where the cell content changes outside of these events.
378 */
379 updateStickyColumnStyles(): void;
380 /**
381 * Get the list of RenderRow objects to render according to the current list of data and defined
382 * row definitions. If the previous list already contained a particular pair, it should be reused
383 * so that the differ equates their references.
384 */
385 private _getAllRenderRows;
386 /**
387 * Gets a list of `RenderRow<T>` for the provided data object and any `CdkRowDef` objects that
388 * should be rendered for this data. Reuses the cached RenderRow objects if they match the same
389 * `(T, CdkRowDef)` pair.
390 */
391 private _getRenderRowsForData;
392 /** Update the map containing the content's column definitions. */
393 private _cacheColumnDefs;
394 /** Update the list of all available row definitions that can be used. */
395 private _cacheRowDefs;
396 /**
397 * Check if the header, data, or footer rows have changed what columns they want to display or
398 * whether the sticky states have changed for the header or footer. If there is a diff, then
399 * re-render that section.
400 */
401 private _renderUpdatedColumns;
402 /**
403 * Switch to the provided data source by resetting the data and unsubscribing from the current
404 * render change subscription if one exists. If the data source is null, interpret this by
405 * clearing the row outlet. Otherwise start listening for new data.
406 */
407 private _switchDataSource;
408 /** Set up a subscription for the data provided by the data source. */
409 private _observeRenderChanges;
410 /**
411 * Clears any existing content in the header row outlet and creates a new embedded view
412 * in the outlet using the header row definition.
413 */
414 private _forceRenderHeaderRows;
415 /**
416 * Clears any existing content in the footer row outlet and creates a new embedded view
417 * in the outlet using the footer row definition.
418 */
419 private _forceRenderFooterRows;
420 /** Adds the sticky column styles for the rows according to the columns' stick states. */
421 private _addStickyColumnStyles;
422 /** Gets the list of rows that have been rendered in the row outlet. */
423 _getRenderedRows(rowOutlet: RowOutlet): HTMLElement[];
424 /**
425 * Get the matching row definitions that should be used for this row data. If there is only
426 * one row definition, it is returned. Otherwise, find the row definitions that has a when
427 * predicate that returns true with the data. If none return true, return the default row
428 * definition.
429 */
430 _getRowDefs(data: T, dataIndex: number): CdkRowDef<T>[];
431 private _getEmbeddedViewArgs;
432 /**
433 * Creates a new row template in the outlet and fills it with the set of cell templates.
434 * Optionally takes a context to provide to the row and cells, as well as an optional index
435 * of where to place the new row template in the outlet.
436 */
437 private _renderRow;
438 private _renderCellTemplateForItem;
439 /**
440 * Updates the index-related context for each row to reflect any changes in the index of the rows,
441 * e.g. first/last/even/odd.
442 */
443 private _updateRowIndexContext;
444 /** Gets the column definitions for the provided row def. */
445 private _getCellTemplates;
446 /** Adds native table sections (e.g. tbody) and moves the row outlets into them. */
447 private _applyNativeTableSections;
448 /**
449 * Forces a re-render of the data rows. Should be called in cases where there has been an input
450 * change that affects the evaluation of which rows should be rendered, e.g. toggling
451 * `multiTemplateDataRows` or adding/removing row definitions.
452 */
453 private _forceRenderDataRows;
454 /**
455 * Checks if there has been a change in sticky states since last check and applies the correct
456 * sticky styles. Since checking resets the "dirty" state, this should only be performed once
457 * during a change detection and after the inputs are settled (after content check).
458 */
459 private _checkStickyStates;
460 /**
461 * Creates the sticky styler that will be used for sticky rows and columns. Listens
462 * for directionality changes and provides the latest direction to the styler. Re-applies column
463 * stickiness when directionality changes.
464 */
465 private _setupStickyStyler;
466 /** Filters definitions that belong to this table from a QueryList. */
467 private _getOwnDefs;
468 /** Creates or removes the no data row, depending on whether any data is being shown. */
469 private _updateNoDataRow;
470 static ngAcceptInputType_multiTemplateDataRows: BooleanInput;
471 static ngAcceptInputType_fixedLayout: BooleanInput;
472}
473export {};
Note: See TracBrowser for help on using the repository browser.