row.d.ts 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. */
  8. import { IterableChanges, IterableDiffer, IterableDiffers, OnChanges, OnDestroy, SimpleChanges, TemplateRef, ViewContainerRef } from '@angular/core';
  9. import { CanStick, CanStickCtor } from './can-stick';
  10. import { CdkCellDef, CdkColumnDef } from './cell';
  11. /**
  12. * The row template that can be used by the mat-table. Should not be used outside of the
  13. * material library.
  14. */
  15. export declare const CDK_ROW_TEMPLATE = "<ng-container cdkCellOutlet></ng-container>";
  16. /**
  17. * Base class for the CdkHeaderRowDef and CdkRowDef that handles checking their columns inputs
  18. * for changes and notifying the table.
  19. */
  20. export declare abstract class BaseRowDef implements OnChanges {
  21. /** @docs-private */ template: TemplateRef<any>;
  22. protected _differs: IterableDiffers;
  23. /** The columns to be displayed on this row. */
  24. columns: Iterable<string>;
  25. /** Differ used to check if any changes were made to the columns. */
  26. protected _columnsDiffer: IterableDiffer<any>;
  27. constructor(
  28. /** @docs-private */ template: TemplateRef<any>, _differs: IterableDiffers);
  29. ngOnChanges(changes: SimpleChanges): void;
  30. /**
  31. * Returns the difference between the current columns and the columns from the last diff, or null
  32. * if there is no difference.
  33. */
  34. getColumnsDiff(): IterableChanges<any> | null;
  35. /** Gets this row def's relevant cell template from the provided column def. */
  36. extractCellTemplate(column: CdkColumnDef): TemplateRef<any>;
  37. }
  38. /** @docs-private */
  39. declare class CdkHeaderRowDefBase extends BaseRowDef {
  40. }
  41. declare const _CdkHeaderRowDefBase: CanStickCtor & typeof CdkHeaderRowDefBase;
  42. /**
  43. * Header row definition for the CDK table.
  44. * Captures the header row's template and other header properties such as the columns to display.
  45. */
  46. export declare class CdkHeaderRowDef extends _CdkHeaderRowDefBase implements CanStick, OnChanges {
  47. constructor(template: TemplateRef<any>, _differs: IterableDiffers);
  48. ngOnChanges(changes: SimpleChanges): void;
  49. }
  50. /** @docs-private */
  51. declare class CdkFooterRowDefBase extends BaseRowDef {
  52. }
  53. declare const _CdkFooterRowDefBase: CanStickCtor & typeof CdkFooterRowDefBase;
  54. /**
  55. * Footer row definition for the CDK table.
  56. * Captures the footer row's template and other footer properties such as the columns to display.
  57. */
  58. export declare class CdkFooterRowDef extends _CdkFooterRowDefBase implements CanStick, OnChanges {
  59. constructor(template: TemplateRef<any>, _differs: IterableDiffers);
  60. ngOnChanges(changes: SimpleChanges): void;
  61. }
  62. /**
  63. * Data row definition for the CDK table.
  64. * Captures the header row's template and other row properties such as the columns to display and
  65. * a when predicate that describes when this row should be used.
  66. */
  67. export declare class CdkRowDef<T> extends BaseRowDef {
  68. /**
  69. * Function that should return true if this row template should be used for the provided index
  70. * and row data. If left undefined, this row will be considered the default row template to use
  71. * when no other when functions return true for the data.
  72. * For every row, there must be at least one when function that passes or an undefined to default.
  73. */
  74. when: (index: number, rowData: T) => boolean;
  75. constructor(template: TemplateRef<any>, _differs: IterableDiffers);
  76. }
  77. /** Context provided to the row cells when `multiTemplateDataRows` is false */
  78. export interface CdkCellOutletRowContext<T> {
  79. /** Data for the row that this cell is located within. */
  80. $implicit?: T;
  81. /** Index of the data object in the provided data array. */
  82. index?: number;
  83. /** Length of the number of total rows. */
  84. count?: number;
  85. /** True if this cell is contained in the first row. */
  86. first?: boolean;
  87. /** True if this cell is contained in the last row. */
  88. last?: boolean;
  89. /** True if this cell is contained in a row with an even-numbered index. */
  90. even?: boolean;
  91. /** True if this cell is contained in a row with an odd-numbered index. */
  92. odd?: boolean;
  93. }
  94. /**
  95. * Context provided to the row cells when `multiTemplateDataRows` is true. This context is the same
  96. * as CdkCellOutletRowContext except that the single `index` value is replaced by `dataIndex` and
  97. * `renderIndex`.
  98. */
  99. export interface CdkCellOutletMultiRowContext<T> {
  100. /** Data for the row that this cell is located within. */
  101. $implicit?: T;
  102. /** Index of the data object in the provided data array. */
  103. dataIndex?: number;
  104. /** Index location of the rendered row that this cell is located within. */
  105. renderIndex?: number;
  106. /** Length of the number of total rows. */
  107. count?: number;
  108. /** True if this cell is contained in the first row. */
  109. first?: boolean;
  110. /** True if this cell is contained in the last row. */
  111. last?: boolean;
  112. /** True if this cell is contained in a row with an even-numbered index. */
  113. even?: boolean;
  114. /** True if this cell is contained in a row with an odd-numbered index. */
  115. odd?: boolean;
  116. }
  117. /**
  118. * Outlet for rendering cells inside of a row or header row.
  119. * @docs-private
  120. */
  121. export declare class CdkCellOutlet implements OnDestroy {
  122. _viewContainer: ViewContainerRef;
  123. /** The ordered list of cells to render within this outlet's view container */
  124. cells: CdkCellDef[];
  125. /** The data context to be provided to each cell */
  126. context: any;
  127. /**
  128. * Static property containing the latest constructed instance of this class.
  129. * Used by the CDK table when each CdkHeaderRow and CdkRow component is created using
  130. * createEmbeddedView. After one of these components are created, this property will provide
  131. * a handle to provide that component's cells and context. After init, the CdkCellOutlet will
  132. * construct the cells with the provided context.
  133. */
  134. static mostRecentCellOutlet: CdkCellOutlet | null;
  135. constructor(_viewContainer: ViewContainerRef);
  136. ngOnDestroy(): void;
  137. }
  138. /** Header template container that contains the cell outlet. Adds the right class and role. */
  139. export declare class CdkHeaderRow {
  140. }
  141. /** Footer template container that contains the cell outlet. Adds the right class and role. */
  142. export declare class CdkFooterRow {
  143. }
  144. /** Data row template container that contains the cell outlet. Adds the right class and role. */
  145. export declare class CdkRow {
  146. }
  147. export {};