table.mjs 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. import * as i0 from '@angular/core';
  2. import { Directive, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, booleanAttribute, NgModule } from '@angular/core';
  3. import { CdkTable, CDK_TABLE, _COALESCED_STYLE_SCHEDULER, _CoalescedStyleScheduler, STICKY_POSITIONING_LISTENER, HeaderRowOutlet, DataRowOutlet, NoDataRowOutlet, FooterRowOutlet, CdkCellDef, CdkHeaderCellDef, CdkFooterCellDef, CdkColumnDef, CdkHeaderCell, CdkFooterCell, CdkCell, CdkHeaderRowDef, CdkFooterRowDef, CdkRowDef, CdkHeaderRow, CdkCellOutlet, CdkFooterRow, CdkRow, CdkNoDataRow, CdkTextColumn, CdkTableModule } from '@angular/cdk/table';
  4. import { _VIEW_REPEATER_STRATEGY, _RecycleViewRepeaterStrategy, _DisposeViewRepeaterStrategy, DataSource } from '@angular/cdk/collections';
  5. import { M as MatCommonModule } from './common-module-WayjW0Pb.mjs';
  6. import { BehaviorSubject, Subject, merge, of, combineLatest } from 'rxjs';
  7. import { _isNumberValue } from '@angular/cdk/coercion';
  8. import { map } from 'rxjs/operators';
  9. import '@angular/cdk/a11y';
  10. import '@angular/cdk/bidi';
  11. /**
  12. * Enables the recycle view repeater strategy, which reduces rendering latency. Not compatible with
  13. * tables that animate rows.
  14. */
  15. class MatRecycleRows {
  16. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatRecycleRows, deps: [], target: i0.ɵɵFactoryTarget.Directive });
  17. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatRecycleRows, isStandalone: true, selector: "mat-table[recycleRows], table[mat-table][recycleRows]", providers: [{ provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy }], ngImport: i0 });
  18. }
  19. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatRecycleRows, decorators: [{
  20. type: Directive,
  21. args: [{
  22. selector: 'mat-table[recycleRows], table[mat-table][recycleRows]',
  23. providers: [{ provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy }],
  24. }]
  25. }] });
  26. class MatTable extends CdkTable {
  27. /** Overrides the sticky CSS class set by the `CdkTable`. */
  28. stickyCssClass = 'mat-mdc-table-sticky';
  29. /** Overrides the need to add position: sticky on every sticky cell element in `CdkTable`. */
  30. needsPositionStickyOnElement = false;
  31. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatTable, deps: null, target: i0.ɵɵFactoryTarget.Component });
  32. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.6", type: MatTable, isStandalone: true, selector: "mat-table, table[mat-table]", host: { properties: { "class.mdc-table-fixed-layout": "fixedLayout" }, classAttribute: "mat-mdc-table mdc-data-table__table" }, providers: [
  33. { provide: CdkTable, useExisting: MatTable },
  34. { provide: CDK_TABLE, useExisting: MatTable },
  35. { provide: _COALESCED_STYLE_SCHEDULER, useClass: _CoalescedStyleScheduler },
  36. // TODO(michaeljamesparsons) Abstract the view repeater strategy to a directive API so this code
  37. // is only included in the build if used.
  38. { provide: _VIEW_REPEATER_STRATEGY, useClass: _DisposeViewRepeaterStrategy },
  39. // Prevent nested tables from seeing this table's StickyPositioningListener.
  40. { provide: STICKY_POSITIONING_LISTENER, useValue: null },
  41. ], exportAs: ["matTable"], usesInheritance: true, ngImport: i0, template: `
  42. <ng-content select="caption"/>
  43. <ng-content select="colgroup, col"/>
  44. <!--
  45. Unprojected content throws a hydration error so we need this to capture it.
  46. It gets removed on the client so it doesn't affect the layout.
  47. -->
  48. @if (_isServer) {
  49. <ng-content/>
  50. }
  51. @if (_isNativeHtmlTable) {
  52. <thead role="rowgroup">
  53. <ng-container headerRowOutlet/>
  54. </thead>
  55. <tbody class="mdc-data-table__content" role="rowgroup">
  56. <ng-container rowOutlet/>
  57. <ng-container noDataRowOutlet/>
  58. </tbody>
  59. <tfoot role="rowgroup">
  60. <ng-container footerRowOutlet/>
  61. </tfoot>
  62. } @else {
  63. <ng-container headerRowOutlet/>
  64. <ng-container rowOutlet/>
  65. <ng-container noDataRowOutlet/>
  66. <ng-container footerRowOutlet/>
  67. }
  68. `, isInline: true, styles: [".mat-mdc-table-sticky{position:sticky !important}mat-table{display:block}mat-header-row{min-height:var(--mat-table-header-container-height, 56px)}mat-row{min-height:var(--mat-table-row-item-container-height, 52px)}mat-footer-row{min-height:var(--mat-table-footer-container-height, 52px)}mat-row,mat-header-row,mat-footer-row{display:flex;border-width:0;border-bottom-width:1px;border-style:solid;align-items:center;box-sizing:border-box}mat-cell:first-of-type,mat-header-cell:first-of-type,mat-footer-cell:first-of-type{padding-left:24px}[dir=rtl] mat-cell:first-of-type:not(:only-of-type),[dir=rtl] mat-header-cell:first-of-type:not(:only-of-type),[dir=rtl] mat-footer-cell:first-of-type:not(:only-of-type){padding-left:0;padding-right:24px}mat-cell:last-of-type,mat-header-cell:last-of-type,mat-footer-cell:last-of-type{padding-right:24px}[dir=rtl] mat-cell:last-of-type:not(:only-of-type),[dir=rtl] mat-header-cell:last-of-type:not(:only-of-type),[dir=rtl] mat-footer-cell:last-of-type:not(:only-of-type){padding-right:0;padding-left:24px}mat-cell,mat-header-cell,mat-footer-cell{flex:1;display:flex;align-items:center;overflow:hidden;word-wrap:break-word;min-height:inherit}.mat-mdc-table{min-width:100%;border:0;border-spacing:0;table-layout:auto;white-space:normal;background-color:var(--mat-table-background-color, var(--mat-sys-surface))}.mdc-data-table__cell{box-sizing:border-box;overflow:hidden;text-align:left;text-overflow:ellipsis}[dir=rtl] .mdc-data-table__cell{text-align:right}.mdc-data-table__cell,.mdc-data-table__header-cell{padding:0 16px}.mat-mdc-header-row{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;height:var(--mat-table-header-container-height, 56px);color:var(--mat-table-header-headline-color, var(--mat-sys-on-surface, rgba(0, 0, 0, 0.87)));font-family:var(--mat-table-header-headline-font, var(--mat-sys-title-small-font, Roboto, sans-serif));line-height:var(--mat-table-header-headline-line-height, var(--mat-sys-title-small-line-height));font-size:var(--mat-table-header-headline-size, var(--mat-sys-title-small-size, 14px));font-weight:var(--mat-table-header-headline-weight, var(--mat-sys-title-small-weight, 500))}.mat-mdc-row{height:var(--mat-table-row-item-container-height, 52px);color:var(--mat-table-row-item-label-text-color, var(--mat-sys-on-surface, rgba(0, 0, 0, 0.87)))}.mat-mdc-row,.mdc-data-table__content{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-family:var(--mat-table-row-item-label-text-font, var(--mat-sys-body-medium-font, Roboto, sans-serif));line-height:var(--mat-table-row-item-label-text-line-height, var(--mat-sys-body-medium-line-height));font-size:var(--mat-table-row-item-label-text-size, var(--mat-sys-body-medium-size, 14px));font-weight:var(--mat-table-row-item-label-text-weight, var(--mat-sys-body-medium-weight))}.mat-mdc-footer-row{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;height:var(--mat-table-footer-container-height, 52px);color:var(--mat-table-row-item-label-text-color, var(--mat-sys-on-surface, rgba(0, 0, 0, 0.87)));font-family:var(--mat-table-footer-supporting-text-font, var(--mat-sys-body-medium-font, Roboto, sans-serif));line-height:var(--mat-table-footer-supporting-text-line-height, var(--mat-sys-body-medium-line-height));font-size:var(--mat-table-footer-supporting-text-size, var(--mat-sys-body-medium-size, 14px));font-weight:var(--mat-table-footer-supporting-text-weight, var(--mat-sys-body-medium-weight));letter-spacing:var(--mat-table-footer-supporting-text-tracking, var(--mat-sys-body-medium-tracking))}.mat-mdc-header-cell{border-bottom-color:var(--mat-table-row-item-outline-color, var(--mat-sys-outline, rgba(0, 0, 0, 0.12)));border-bottom-width:var(--mat-table-row-item-outline-width, 1px);border-bottom-style:solid;letter-spacing:var(--mat-table-header-headline-tracking, var(--mat-sys-title-small-tracking));font-weight:inherit;line-height:inherit;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;outline:none;text-align:left}[dir=rtl] .mat-mdc-header-cell{text-align:right}.mdc-data-table__row:last-child>.mat-mdc-header-cell{border-bottom:none}.mat-mdc-cell{border-bottom-color:var(--mat-table-row-item-outline-color, var(--mat-sys-outline, rgba(0, 0, 0, 0.12)));border-bottom-width:var(--mat-table-row-item-outline-width, 1px);border-bottom-style:solid;letter-spacing:var(--mat-table-row-item-label-text-tracking, var(--mat-sys-body-medium-tracking));line-height:inherit}.mdc-data-table__row:last-child>.mat-mdc-cell{border-bottom:none}.mat-mdc-footer-cell{letter-spacing:var(--mat-table-row-item-label-text-tracking, var(--mat-sys-body-medium-tracking))}mat-row.mat-mdc-row,mat-header-row.mat-mdc-header-row,mat-footer-row.mat-mdc-footer-row{border-bottom:none}.mat-mdc-table tbody,.mat-mdc-table tfoot,.mat-mdc-table thead,.mat-mdc-cell,.mat-mdc-footer-cell,.mat-mdc-header-row,.mat-mdc-row,.mat-mdc-footer-row,.mat-mdc-table .mat-mdc-header-cell{background:inherit}.mat-mdc-table mat-header-row.mat-mdc-header-row,.mat-mdc-table mat-row.mat-mdc-row,.mat-mdc-table mat-footer-row.mat-mdc-footer-cell{height:unset}mat-header-cell.mat-mdc-header-cell,mat-cell.mat-mdc-cell,mat-footer-cell.mat-mdc-footer-cell{align-self:stretch}\n"], dependencies: [{ kind: "directive", type: HeaderRowOutlet, selector: "[headerRowOutlet]" }, { kind: "directive", type: DataRowOutlet, selector: "[rowOutlet]" }, { kind: "directive", type: NoDataRowOutlet, selector: "[noDataRowOutlet]" }, { kind: "directive", type: FooterRowOutlet, selector: "[footerRowOutlet]" }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None });
  69. }
  70. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatTable, decorators: [{
  71. type: Component,
  72. args: [{ selector: 'mat-table, table[mat-table]', exportAs: 'matTable', template: `
  73. <ng-content select="caption"/>
  74. <ng-content select="colgroup, col"/>
  75. <!--
  76. Unprojected content throws a hydration error so we need this to capture it.
  77. It gets removed on the client so it doesn't affect the layout.
  78. -->
  79. @if (_isServer) {
  80. <ng-content/>
  81. }
  82. @if (_isNativeHtmlTable) {
  83. <thead role="rowgroup">
  84. <ng-container headerRowOutlet/>
  85. </thead>
  86. <tbody class="mdc-data-table__content" role="rowgroup">
  87. <ng-container rowOutlet/>
  88. <ng-container noDataRowOutlet/>
  89. </tbody>
  90. <tfoot role="rowgroup">
  91. <ng-container footerRowOutlet/>
  92. </tfoot>
  93. } @else {
  94. <ng-container headerRowOutlet/>
  95. <ng-container rowOutlet/>
  96. <ng-container noDataRowOutlet/>
  97. <ng-container footerRowOutlet/>
  98. }
  99. `, host: {
  100. 'class': 'mat-mdc-table mdc-data-table__table',
  101. '[class.mdc-table-fixed-layout]': 'fixedLayout',
  102. }, providers: [
  103. { provide: CdkTable, useExisting: MatTable },
  104. { provide: CDK_TABLE, useExisting: MatTable },
  105. { provide: _COALESCED_STYLE_SCHEDULER, useClass: _CoalescedStyleScheduler },
  106. // TODO(michaeljamesparsons) Abstract the view repeater strategy to a directive API so this code
  107. // is only included in the build if used.
  108. { provide: _VIEW_REPEATER_STRATEGY, useClass: _DisposeViewRepeaterStrategy },
  109. // Prevent nested tables from seeing this table's StickyPositioningListener.
  110. { provide: STICKY_POSITIONING_LISTENER, useValue: null },
  111. ], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.Default, imports: [HeaderRowOutlet, DataRowOutlet, NoDataRowOutlet, FooterRowOutlet], styles: [".mat-mdc-table-sticky{position:sticky !important}mat-table{display:block}mat-header-row{min-height:var(--mat-table-header-container-height, 56px)}mat-row{min-height:var(--mat-table-row-item-container-height, 52px)}mat-footer-row{min-height:var(--mat-table-footer-container-height, 52px)}mat-row,mat-header-row,mat-footer-row{display:flex;border-width:0;border-bottom-width:1px;border-style:solid;align-items:center;box-sizing:border-box}mat-cell:first-of-type,mat-header-cell:first-of-type,mat-footer-cell:first-of-type{padding-left:24px}[dir=rtl] mat-cell:first-of-type:not(:only-of-type),[dir=rtl] mat-header-cell:first-of-type:not(:only-of-type),[dir=rtl] mat-footer-cell:first-of-type:not(:only-of-type){padding-left:0;padding-right:24px}mat-cell:last-of-type,mat-header-cell:last-of-type,mat-footer-cell:last-of-type{padding-right:24px}[dir=rtl] mat-cell:last-of-type:not(:only-of-type),[dir=rtl] mat-header-cell:last-of-type:not(:only-of-type),[dir=rtl] mat-footer-cell:last-of-type:not(:only-of-type){padding-right:0;padding-left:24px}mat-cell,mat-header-cell,mat-footer-cell{flex:1;display:flex;align-items:center;overflow:hidden;word-wrap:break-word;min-height:inherit}.mat-mdc-table{min-width:100%;border:0;border-spacing:0;table-layout:auto;white-space:normal;background-color:var(--mat-table-background-color, var(--mat-sys-surface))}.mdc-data-table__cell{box-sizing:border-box;overflow:hidden;text-align:left;text-overflow:ellipsis}[dir=rtl] .mdc-data-table__cell{text-align:right}.mdc-data-table__cell,.mdc-data-table__header-cell{padding:0 16px}.mat-mdc-header-row{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;height:var(--mat-table-header-container-height, 56px);color:var(--mat-table-header-headline-color, var(--mat-sys-on-surface, rgba(0, 0, 0, 0.87)));font-family:var(--mat-table-header-headline-font, var(--mat-sys-title-small-font, Roboto, sans-serif));line-height:var(--mat-table-header-headline-line-height, var(--mat-sys-title-small-line-height));font-size:var(--mat-table-header-headline-size, var(--mat-sys-title-small-size, 14px));font-weight:var(--mat-table-header-headline-weight, var(--mat-sys-title-small-weight, 500))}.mat-mdc-row{height:var(--mat-table-row-item-container-height, 52px);color:var(--mat-table-row-item-label-text-color, var(--mat-sys-on-surface, rgba(0, 0, 0, 0.87)))}.mat-mdc-row,.mdc-data-table__content{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-family:var(--mat-table-row-item-label-text-font, var(--mat-sys-body-medium-font, Roboto, sans-serif));line-height:var(--mat-table-row-item-label-text-line-height, var(--mat-sys-body-medium-line-height));font-size:var(--mat-table-row-item-label-text-size, var(--mat-sys-body-medium-size, 14px));font-weight:var(--mat-table-row-item-label-text-weight, var(--mat-sys-body-medium-weight))}.mat-mdc-footer-row{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;height:var(--mat-table-footer-container-height, 52px);color:var(--mat-table-row-item-label-text-color, var(--mat-sys-on-surface, rgba(0, 0, 0, 0.87)));font-family:var(--mat-table-footer-supporting-text-font, var(--mat-sys-body-medium-font, Roboto, sans-serif));line-height:var(--mat-table-footer-supporting-text-line-height, var(--mat-sys-body-medium-line-height));font-size:var(--mat-table-footer-supporting-text-size, var(--mat-sys-body-medium-size, 14px));font-weight:var(--mat-table-footer-supporting-text-weight, var(--mat-sys-body-medium-weight));letter-spacing:var(--mat-table-footer-supporting-text-tracking, var(--mat-sys-body-medium-tracking))}.mat-mdc-header-cell{border-bottom-color:var(--mat-table-row-item-outline-color, var(--mat-sys-outline, rgba(0, 0, 0, 0.12)));border-bottom-width:var(--mat-table-row-item-outline-width, 1px);border-bottom-style:solid;letter-spacing:var(--mat-table-header-headline-tracking, var(--mat-sys-title-small-tracking));font-weight:inherit;line-height:inherit;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;outline:none;text-align:left}[dir=rtl] .mat-mdc-header-cell{text-align:right}.mdc-data-table__row:last-child>.mat-mdc-header-cell{border-bottom:none}.mat-mdc-cell{border-bottom-color:var(--mat-table-row-item-outline-color, var(--mat-sys-outline, rgba(0, 0, 0, 0.12)));border-bottom-width:var(--mat-table-row-item-outline-width, 1px);border-bottom-style:solid;letter-spacing:var(--mat-table-row-item-label-text-tracking, var(--mat-sys-body-medium-tracking));line-height:inherit}.mdc-data-table__row:last-child>.mat-mdc-cell{border-bottom:none}.mat-mdc-footer-cell{letter-spacing:var(--mat-table-row-item-label-text-tracking, var(--mat-sys-body-medium-tracking))}mat-row.mat-mdc-row,mat-header-row.mat-mdc-header-row,mat-footer-row.mat-mdc-footer-row{border-bottom:none}.mat-mdc-table tbody,.mat-mdc-table tfoot,.mat-mdc-table thead,.mat-mdc-cell,.mat-mdc-footer-cell,.mat-mdc-header-row,.mat-mdc-row,.mat-mdc-footer-row,.mat-mdc-table .mat-mdc-header-cell{background:inherit}.mat-mdc-table mat-header-row.mat-mdc-header-row,.mat-mdc-table mat-row.mat-mdc-row,.mat-mdc-table mat-footer-row.mat-mdc-footer-cell{height:unset}mat-header-cell.mat-mdc-header-cell,mat-cell.mat-mdc-cell,mat-footer-cell.mat-mdc-footer-cell{align-self:stretch}\n"] }]
  112. }] });
  113. /**
  114. * Cell definition for the mat-table.
  115. * Captures the template of a column's data row cell as well as cell-specific properties.
  116. */
  117. class MatCellDef extends CdkCellDef {
  118. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatCellDef, deps: null, target: i0.ɵɵFactoryTarget.Directive });
  119. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatCellDef, isStandalone: true, selector: "[matCellDef]", providers: [{ provide: CdkCellDef, useExisting: MatCellDef }], usesInheritance: true, ngImport: i0 });
  120. }
  121. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatCellDef, decorators: [{
  122. type: Directive,
  123. args: [{
  124. selector: '[matCellDef]',
  125. providers: [{ provide: CdkCellDef, useExisting: MatCellDef }],
  126. }]
  127. }] });
  128. /**
  129. * Header cell definition for the mat-table.
  130. * Captures the template of a column's header cell and as well as cell-specific properties.
  131. */
  132. class MatHeaderCellDef extends CdkHeaderCellDef {
  133. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatHeaderCellDef, deps: null, target: i0.ɵɵFactoryTarget.Directive });
  134. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatHeaderCellDef, isStandalone: true, selector: "[matHeaderCellDef]", providers: [{ provide: CdkHeaderCellDef, useExisting: MatHeaderCellDef }], usesInheritance: true, ngImport: i0 });
  135. }
  136. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatHeaderCellDef, decorators: [{
  137. type: Directive,
  138. args: [{
  139. selector: '[matHeaderCellDef]',
  140. providers: [{ provide: CdkHeaderCellDef, useExisting: MatHeaderCellDef }],
  141. }]
  142. }] });
  143. /**
  144. * Footer cell definition for the mat-table.
  145. * Captures the template of a column's footer cell and as well as cell-specific properties.
  146. */
  147. class MatFooterCellDef extends CdkFooterCellDef {
  148. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatFooterCellDef, deps: null, target: i0.ɵɵFactoryTarget.Directive });
  149. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatFooterCellDef, isStandalone: true, selector: "[matFooterCellDef]", providers: [{ provide: CdkFooterCellDef, useExisting: MatFooterCellDef }], usesInheritance: true, ngImport: i0 });
  150. }
  151. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatFooterCellDef, decorators: [{
  152. type: Directive,
  153. args: [{
  154. selector: '[matFooterCellDef]',
  155. providers: [{ provide: CdkFooterCellDef, useExisting: MatFooterCellDef }],
  156. }]
  157. }] });
  158. /**
  159. * Column definition for the mat-table.
  160. * Defines a set of cells available for a table column.
  161. */
  162. class MatColumnDef extends CdkColumnDef {
  163. /** Unique name for this column. */
  164. get name() {
  165. return this._name;
  166. }
  167. set name(name) {
  168. this._setNameInput(name);
  169. }
  170. /**
  171. * Add "mat-column-" prefix in addition to "cdk-column-" prefix.
  172. * In the future, this will only add "mat-column-" and columnCssClassName
  173. * will change from type string[] to string.
  174. * @docs-private
  175. */
  176. _updateColumnCssClassName() {
  177. super._updateColumnCssClassName();
  178. this._columnCssClassName.push(`mat-column-${this.cssClassFriendlyName}`);
  179. }
  180. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatColumnDef, deps: null, target: i0.ɵɵFactoryTarget.Directive });
  181. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatColumnDef, isStandalone: true, selector: "[matColumnDef]", inputs: { name: ["matColumnDef", "name"] }, providers: [
  182. { provide: CdkColumnDef, useExisting: MatColumnDef },
  183. { provide: 'MAT_SORT_HEADER_COLUMN_DEF', useExisting: MatColumnDef },
  184. ], usesInheritance: true, ngImport: i0 });
  185. }
  186. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatColumnDef, decorators: [{
  187. type: Directive,
  188. args: [{
  189. selector: '[matColumnDef]',
  190. providers: [
  191. { provide: CdkColumnDef, useExisting: MatColumnDef },
  192. { provide: 'MAT_SORT_HEADER_COLUMN_DEF', useExisting: MatColumnDef },
  193. ],
  194. }]
  195. }], propDecorators: { name: [{
  196. type: Input,
  197. args: ['matColumnDef']
  198. }] } });
  199. /** Header cell template container that adds the right classes and role. */
  200. class MatHeaderCell extends CdkHeaderCell {
  201. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatHeaderCell, deps: null, target: i0.ɵɵFactoryTarget.Directive });
  202. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatHeaderCell, isStandalone: true, selector: "mat-header-cell, th[mat-header-cell]", host: { attributes: { "role": "columnheader" }, classAttribute: "mat-mdc-header-cell mdc-data-table__header-cell" }, usesInheritance: true, ngImport: i0 });
  203. }
  204. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatHeaderCell, decorators: [{
  205. type: Directive,
  206. args: [{
  207. selector: 'mat-header-cell, th[mat-header-cell]',
  208. host: {
  209. 'class': 'mat-mdc-header-cell mdc-data-table__header-cell',
  210. 'role': 'columnheader',
  211. },
  212. }]
  213. }] });
  214. /** Footer cell template container that adds the right classes and role. */
  215. class MatFooterCell extends CdkFooterCell {
  216. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatFooterCell, deps: null, target: i0.ɵɵFactoryTarget.Directive });
  217. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatFooterCell, isStandalone: true, selector: "mat-footer-cell, td[mat-footer-cell]", host: { classAttribute: "mat-mdc-footer-cell mdc-data-table__cell" }, usesInheritance: true, ngImport: i0 });
  218. }
  219. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatFooterCell, decorators: [{
  220. type: Directive,
  221. args: [{
  222. selector: 'mat-footer-cell, td[mat-footer-cell]',
  223. host: {
  224. 'class': 'mat-mdc-footer-cell mdc-data-table__cell',
  225. },
  226. }]
  227. }] });
  228. /** Cell template container that adds the right classes and role. */
  229. class MatCell extends CdkCell {
  230. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatCell, deps: null, target: i0.ɵɵFactoryTarget.Directive });
  231. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatCell, isStandalone: true, selector: "mat-cell, td[mat-cell]", host: { classAttribute: "mat-mdc-cell mdc-data-table__cell" }, usesInheritance: true, ngImport: i0 });
  232. }
  233. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatCell, decorators: [{
  234. type: Directive,
  235. args: [{
  236. selector: 'mat-cell, td[mat-cell]',
  237. host: {
  238. 'class': 'mat-mdc-cell mdc-data-table__cell',
  239. },
  240. }]
  241. }] });
  242. // We can't reuse `CDK_ROW_TEMPLATE` because it's incompatible with local compilation mode.
  243. const ROW_TEMPLATE = `<ng-container cdkCellOutlet></ng-container>`;
  244. /**
  245. * Header row definition for the mat-table.
  246. * Captures the header row's template and other header properties such as the columns to display.
  247. */
  248. class MatHeaderRowDef extends CdkHeaderRowDef {
  249. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatHeaderRowDef, deps: null, target: i0.ɵɵFactoryTarget.Directive });
  250. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "19.2.6", type: MatHeaderRowDef, isStandalone: true, selector: "[matHeaderRowDef]", inputs: { columns: ["matHeaderRowDef", "columns"], sticky: ["matHeaderRowDefSticky", "sticky", booleanAttribute] }, providers: [{ provide: CdkHeaderRowDef, useExisting: MatHeaderRowDef }], usesInheritance: true, ngImport: i0 });
  251. }
  252. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatHeaderRowDef, decorators: [{
  253. type: Directive,
  254. args: [{
  255. selector: '[matHeaderRowDef]',
  256. providers: [{ provide: CdkHeaderRowDef, useExisting: MatHeaderRowDef }],
  257. inputs: [
  258. { name: 'columns', alias: 'matHeaderRowDef' },
  259. { name: 'sticky', alias: 'matHeaderRowDefSticky', transform: booleanAttribute },
  260. ],
  261. }]
  262. }] });
  263. /**
  264. * Footer row definition for the mat-table.
  265. * Captures the footer row's template and other footer properties such as the columns to display.
  266. */
  267. class MatFooterRowDef extends CdkFooterRowDef {
  268. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatFooterRowDef, deps: null, target: i0.ɵɵFactoryTarget.Directive });
  269. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "19.2.6", type: MatFooterRowDef, isStandalone: true, selector: "[matFooterRowDef]", inputs: { columns: ["matFooterRowDef", "columns"], sticky: ["matFooterRowDefSticky", "sticky", booleanAttribute] }, providers: [{ provide: CdkFooterRowDef, useExisting: MatFooterRowDef }], usesInheritance: true, ngImport: i0 });
  270. }
  271. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatFooterRowDef, decorators: [{
  272. type: Directive,
  273. args: [{
  274. selector: '[matFooterRowDef]',
  275. providers: [{ provide: CdkFooterRowDef, useExisting: MatFooterRowDef }],
  276. inputs: [
  277. { name: 'columns', alias: 'matFooterRowDef' },
  278. { name: 'sticky', alias: 'matFooterRowDefSticky', transform: booleanAttribute },
  279. ],
  280. }]
  281. }] });
  282. /**
  283. * Data row definition for the mat-table.
  284. * Captures the data row's template and other properties such as the columns to display and
  285. * a when predicate that describes when this row should be used.
  286. */
  287. class MatRowDef extends CdkRowDef {
  288. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatRowDef, deps: null, target: i0.ɵɵFactoryTarget.Directive });
  289. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatRowDef, isStandalone: true, selector: "[matRowDef]", inputs: { columns: ["matRowDefColumns", "columns"], when: ["matRowDefWhen", "when"] }, providers: [{ provide: CdkRowDef, useExisting: MatRowDef }], usesInheritance: true, ngImport: i0 });
  290. }
  291. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatRowDef, decorators: [{
  292. type: Directive,
  293. args: [{
  294. selector: '[matRowDef]',
  295. providers: [{ provide: CdkRowDef, useExisting: MatRowDef }],
  296. inputs: [
  297. { name: 'columns', alias: 'matRowDefColumns' },
  298. { name: 'when', alias: 'matRowDefWhen' },
  299. ],
  300. }]
  301. }] });
  302. /** Header template container that contains the cell outlet. Adds the right class and role. */
  303. class MatHeaderRow extends CdkHeaderRow {
  304. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatHeaderRow, deps: null, target: i0.ɵɵFactoryTarget.Component });
  305. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: MatHeaderRow, isStandalone: true, selector: "mat-header-row, tr[mat-header-row]", host: { attributes: { "role": "row" }, classAttribute: "mat-mdc-header-row mdc-data-table__header-row" }, providers: [{ provide: CdkHeaderRow, useExisting: MatHeaderRow }], exportAs: ["matHeaderRow"], usesInheritance: true, ngImport: i0, template: "<ng-container cdkCellOutlet></ng-container>", isInline: true, dependencies: [{ kind: "directive", type: CdkCellOutlet, selector: "[cdkCellOutlet]" }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None });
  306. }
  307. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatHeaderRow, decorators: [{
  308. type: Component,
  309. args: [{
  310. selector: 'mat-header-row, tr[mat-header-row]',
  311. template: ROW_TEMPLATE,
  312. host: {
  313. 'class': 'mat-mdc-header-row mdc-data-table__header-row',
  314. 'role': 'row',
  315. },
  316. // See note on CdkTable for explanation on why this uses the default change detection strategy.
  317. // tslint:disable-next-line:validate-decorators
  318. changeDetection: ChangeDetectionStrategy.Default,
  319. encapsulation: ViewEncapsulation.None,
  320. exportAs: 'matHeaderRow',
  321. providers: [{ provide: CdkHeaderRow, useExisting: MatHeaderRow }],
  322. imports: [CdkCellOutlet],
  323. }]
  324. }] });
  325. /** Footer template container that contains the cell outlet. Adds the right class and role. */
  326. class MatFooterRow extends CdkFooterRow {
  327. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatFooterRow, deps: null, target: i0.ɵɵFactoryTarget.Component });
  328. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: MatFooterRow, isStandalone: true, selector: "mat-footer-row, tr[mat-footer-row]", host: { attributes: { "role": "row" }, classAttribute: "mat-mdc-footer-row mdc-data-table__row" }, providers: [{ provide: CdkFooterRow, useExisting: MatFooterRow }], exportAs: ["matFooterRow"], usesInheritance: true, ngImport: i0, template: "<ng-container cdkCellOutlet></ng-container>", isInline: true, dependencies: [{ kind: "directive", type: CdkCellOutlet, selector: "[cdkCellOutlet]" }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None });
  329. }
  330. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatFooterRow, decorators: [{
  331. type: Component,
  332. args: [{
  333. selector: 'mat-footer-row, tr[mat-footer-row]',
  334. template: ROW_TEMPLATE,
  335. host: {
  336. 'class': 'mat-mdc-footer-row mdc-data-table__row',
  337. 'role': 'row',
  338. },
  339. // See note on CdkTable for explanation on why this uses the default change detection strategy.
  340. // tslint:disable-next-line:validate-decorators
  341. changeDetection: ChangeDetectionStrategy.Default,
  342. encapsulation: ViewEncapsulation.None,
  343. exportAs: 'matFooterRow',
  344. providers: [{ provide: CdkFooterRow, useExisting: MatFooterRow }],
  345. imports: [CdkCellOutlet],
  346. }]
  347. }] });
  348. /** Data row template container that contains the cell outlet. Adds the right class and role. */
  349. class MatRow extends CdkRow {
  350. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatRow, deps: null, target: i0.ɵɵFactoryTarget.Component });
  351. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: MatRow, isStandalone: true, selector: "mat-row, tr[mat-row]", host: { attributes: { "role": "row" }, classAttribute: "mat-mdc-row mdc-data-table__row" }, providers: [{ provide: CdkRow, useExisting: MatRow }], exportAs: ["matRow"], usesInheritance: true, ngImport: i0, template: "<ng-container cdkCellOutlet></ng-container>", isInline: true, dependencies: [{ kind: "directive", type: CdkCellOutlet, selector: "[cdkCellOutlet]" }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None });
  352. }
  353. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatRow, decorators: [{
  354. type: Component,
  355. args: [{
  356. selector: 'mat-row, tr[mat-row]',
  357. template: ROW_TEMPLATE,
  358. host: {
  359. 'class': 'mat-mdc-row mdc-data-table__row',
  360. 'role': 'row',
  361. },
  362. // See note on CdkTable for explanation on why this uses the default change detection strategy.
  363. // tslint:disable-next-line:validate-decorators
  364. changeDetection: ChangeDetectionStrategy.Default,
  365. encapsulation: ViewEncapsulation.None,
  366. exportAs: 'matRow',
  367. providers: [{ provide: CdkRow, useExisting: MatRow }],
  368. imports: [CdkCellOutlet],
  369. }]
  370. }] });
  371. /** Row that can be used to display a message when no data is shown in the table. */
  372. class MatNoDataRow extends CdkNoDataRow {
  373. _contentClassName = 'mat-mdc-no-data-row';
  374. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatNoDataRow, deps: null, target: i0.ɵɵFactoryTarget.Directive });
  375. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatNoDataRow, isStandalone: true, selector: "ng-template[matNoDataRow]", providers: [{ provide: CdkNoDataRow, useExisting: MatNoDataRow }], usesInheritance: true, ngImport: i0 });
  376. }
  377. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatNoDataRow, decorators: [{
  378. type: Directive,
  379. args: [{
  380. selector: 'ng-template[matNoDataRow]',
  381. providers: [{ provide: CdkNoDataRow, useExisting: MatNoDataRow }],
  382. }]
  383. }] });
  384. /**
  385. * Column that simply shows text content for the header and row cells. Assumes that the table
  386. * is using the native table implementation (`<table>`).
  387. *
  388. * By default, the name of this column will be the header text and data property accessor.
  389. * The header text can be overridden with the `headerText` input. Cell values can be overridden with
  390. * the `dataAccessor` input. Change the text justification to the start or end using the `justify`
  391. * input.
  392. */
  393. class MatTextColumn extends CdkTextColumn {
  394. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatTextColumn, deps: null, target: i0.ɵɵFactoryTarget.Component });
  395. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: MatTextColumn, isStandalone: true, selector: "mat-text-column", usesInheritance: true, ngImport: i0, template: `
  396. <ng-container matColumnDef>
  397. <th mat-header-cell *matHeaderCellDef [style.text-align]="justify">
  398. {{headerText}}
  399. </th>
  400. <td mat-cell *matCellDef="let data" [style.text-align]="justify">
  401. {{dataAccessor(data, name)}}
  402. </td>
  403. </ng-container>
  404. `, isInline: true, dependencies: [{ kind: "directive", type: MatColumnDef, selector: "[matColumnDef]", inputs: ["matColumnDef"] }, { kind: "directive", type: MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: MatCell, selector: "mat-cell, td[mat-cell]" }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None });
  405. }
  406. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatTextColumn, decorators: [{
  407. type: Component,
  408. args: [{
  409. selector: 'mat-text-column',
  410. template: `
  411. <ng-container matColumnDef>
  412. <th mat-header-cell *matHeaderCellDef [style.text-align]="justify">
  413. {{headerText}}
  414. </th>
  415. <td mat-cell *matCellDef="let data" [style.text-align]="justify">
  416. {{dataAccessor(data, name)}}
  417. </td>
  418. </ng-container>
  419. `,
  420. encapsulation: ViewEncapsulation.None,
  421. // Change detection is intentionally not set to OnPush. This component's template will be provided
  422. // to the table to be inserted into its view. This is problematic when change detection runs since
  423. // the bindings in this template will be evaluated _after_ the table's view is evaluated, which
  424. // mean's the template in the table's view will not have the updated value (and in fact will cause
  425. // an ExpressionChangedAfterItHasBeenCheckedError).
  426. // tslint:disable-next-line:validate-decorators
  427. changeDetection: ChangeDetectionStrategy.Default,
  428. imports: [MatColumnDef, MatHeaderCellDef, MatHeaderCell, MatCellDef, MatCell],
  429. }]
  430. }] });
  431. const EXPORTED_DECLARATIONS = [
  432. // Table
  433. MatTable,
  434. MatRecycleRows,
  435. // Template defs
  436. MatHeaderCellDef,
  437. MatHeaderRowDef,
  438. MatColumnDef,
  439. MatCellDef,
  440. MatRowDef,
  441. MatFooterCellDef,
  442. MatFooterRowDef,
  443. // Cell directives
  444. MatHeaderCell,
  445. MatCell,
  446. MatFooterCell,
  447. // Row directives
  448. MatHeaderRow,
  449. MatRow,
  450. MatFooterRow,
  451. MatNoDataRow,
  452. MatTextColumn,
  453. ];
  454. class MatTableModule {
  455. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatTableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  456. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: MatTableModule, imports: [MatCommonModule, CdkTableModule,
  457. // Table
  458. MatTable,
  459. MatRecycleRows,
  460. // Template defs
  461. MatHeaderCellDef,
  462. MatHeaderRowDef,
  463. MatColumnDef,
  464. MatCellDef,
  465. MatRowDef,
  466. MatFooterCellDef,
  467. MatFooterRowDef,
  468. // Cell directives
  469. MatHeaderCell,
  470. MatCell,
  471. MatFooterCell,
  472. // Row directives
  473. MatHeaderRow,
  474. MatRow,
  475. MatFooterRow,
  476. MatNoDataRow,
  477. MatTextColumn], exports: [MatCommonModule,
  478. // Table
  479. MatTable,
  480. MatRecycleRows,
  481. // Template defs
  482. MatHeaderCellDef,
  483. MatHeaderRowDef,
  484. MatColumnDef,
  485. MatCellDef,
  486. MatRowDef,
  487. MatFooterCellDef,
  488. MatFooterRowDef,
  489. // Cell directives
  490. MatHeaderCell,
  491. MatCell,
  492. MatFooterCell,
  493. // Row directives
  494. MatHeaderRow,
  495. MatRow,
  496. MatFooterRow,
  497. MatNoDataRow,
  498. MatTextColumn] });
  499. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatTableModule, imports: [MatCommonModule, CdkTableModule, MatCommonModule] });
  500. }
  501. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatTableModule, decorators: [{
  502. type: NgModule,
  503. args: [{
  504. imports: [MatCommonModule, CdkTableModule, ...EXPORTED_DECLARATIONS],
  505. exports: [MatCommonModule, EXPORTED_DECLARATIONS],
  506. }]
  507. }] });
  508. /**
  509. * Corresponds to `Number.MAX_SAFE_INTEGER`. Moved out into a variable here due to
  510. * flaky browser support and the value not being defined in Closure's typings.
  511. */
  512. const MAX_SAFE_INTEGER = 9007199254740991;
  513. /**
  514. * Data source that accepts a client-side data array and includes native support of filtering,
  515. * sorting (using MatSort), and pagination (using MatPaginator).
  516. *
  517. * Allows for sort customization by overriding sortingDataAccessor, which defines how data
  518. * properties are accessed. Also allows for filter customization by overriding filterPredicate,
  519. * which defines how row data is converted to a string for filter matching.
  520. *
  521. * **Note:** This class is meant to be a simple data source to help you get started. As such
  522. * it isn't equipped to handle some more advanced cases like robust i18n support or server-side
  523. * interactions. If your app needs to support more advanced use cases, consider implementing your
  524. * own `DataSource`.
  525. */
  526. class MatTableDataSource extends DataSource {
  527. /** Stream that emits when a new data array is set on the data source. */
  528. _data;
  529. /** Stream emitting render data to the table (depends on ordered data changes). */
  530. _renderData = new BehaviorSubject([]);
  531. /** Stream that emits when a new filter string is set on the data source. */
  532. _filter = new BehaviorSubject('');
  533. /** Used to react to internal changes of the paginator that are made by the data source itself. */
  534. _internalPageChanges = new Subject();
  535. /**
  536. * Subscription to the changes that should trigger an update to the table's rendered rows, such
  537. * as filtering, sorting, pagination, or base data changes.
  538. */
  539. _renderChangesSubscription = null;
  540. /**
  541. * The filtered set of data that has been matched by the filter string, or all the data if there
  542. * is no filter. Useful for knowing the set of data the table represents.
  543. * For example, a 'selectAll()' function would likely want to select the set of filtered data
  544. * shown to the user rather than all the data.
  545. */
  546. filteredData;
  547. /** Array of data that should be rendered by the table, where each object represents one row. */
  548. get data() {
  549. return this._data.value;
  550. }
  551. set data(data) {
  552. data = Array.isArray(data) ? data : [];
  553. this._data.next(data);
  554. // Normally the `filteredData` is updated by the re-render
  555. // subscription, but that won't happen if it's inactive.
  556. if (!this._renderChangesSubscription) {
  557. this._filterData(data);
  558. }
  559. }
  560. /**
  561. * Filter term that should be used to filter out objects from the data array. To override how
  562. * data objects match to this filter string, provide a custom function for filterPredicate.
  563. */
  564. get filter() {
  565. return this._filter.value;
  566. }
  567. set filter(filter) {
  568. this._filter.next(filter);
  569. // Normally the `filteredData` is updated by the re-render
  570. // subscription, but that won't happen if it's inactive.
  571. if (!this._renderChangesSubscription) {
  572. this._filterData(this.data);
  573. }
  574. }
  575. /**
  576. * Instance of the MatSort directive used by the table to control its sorting. Sort changes
  577. * emitted by the MatSort will trigger an update to the table's rendered data.
  578. */
  579. get sort() {
  580. return this._sort;
  581. }
  582. set sort(sort) {
  583. this._sort = sort;
  584. this._updateChangeSubscription();
  585. }
  586. _sort;
  587. /**
  588. * Instance of the paginator component used by the table to control what page of the data is
  589. * displayed. Page changes emitted by the paginator will trigger an update to the
  590. * table's rendered data.
  591. *
  592. * Note that the data source uses the paginator's properties to calculate which page of data
  593. * should be displayed. If the paginator receives its properties as template inputs,
  594. * e.g. `[pageLength]=100` or `[pageIndex]=1`, then be sure that the paginator's view has been
  595. * initialized before assigning it to this data source.
  596. */
  597. get paginator() {
  598. return this._paginator;
  599. }
  600. set paginator(paginator) {
  601. this._paginator = paginator;
  602. this._updateChangeSubscription();
  603. }
  604. _paginator;
  605. /**
  606. * Data accessor function that is used for accessing data properties for sorting through
  607. * the default sortData function.
  608. * This default function assumes that the sort header IDs (which defaults to the column name)
  609. * matches the data's properties (e.g. column Xyz represents data['Xyz']).
  610. * May be set to a custom function for different behavior.
  611. * @param data Data object that is being accessed.
  612. * @param sortHeaderId The name of the column that represents the data.
  613. */
  614. sortingDataAccessor = (data, sortHeaderId) => {
  615. const value = data[sortHeaderId];
  616. if (_isNumberValue(value)) {
  617. const numberValue = Number(value);
  618. // Numbers beyond `MAX_SAFE_INTEGER` can't be compared reliably so we leave them as strings.
  619. // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
  620. return numberValue < MAX_SAFE_INTEGER ? numberValue : value;
  621. }
  622. return value;
  623. };
  624. /**
  625. * Gets a sorted copy of the data array based on the state of the MatSort. Called
  626. * after changes are made to the filtered data or when sort changes are emitted from MatSort.
  627. * By default, the function retrieves the active sort and its direction and compares data
  628. * by retrieving data using the sortingDataAccessor. May be overridden for a custom implementation
  629. * of data ordering.
  630. * @param data The array of data that should be sorted.
  631. * @param sort The connected MatSort that holds the current sort state.
  632. */
  633. sortData = (data, sort) => {
  634. const active = sort.active;
  635. const direction = sort.direction;
  636. if (!active || direction == '') {
  637. return data;
  638. }
  639. return data.sort((a, b) => {
  640. let valueA = this.sortingDataAccessor(a, active);
  641. let valueB = this.sortingDataAccessor(b, active);
  642. // If there are data in the column that can be converted to a number,
  643. // it must be ensured that the rest of the data
  644. // is of the same type so as not to order incorrectly.
  645. const valueAType = typeof valueA;
  646. const valueBType = typeof valueB;
  647. if (valueAType !== valueBType) {
  648. if (valueAType === 'number') {
  649. valueA += '';
  650. }
  651. if (valueBType === 'number') {
  652. valueB += '';
  653. }
  654. }
  655. // If both valueA and valueB exist (truthy), then compare the two. Otherwise, check if
  656. // one value exists while the other doesn't. In this case, existing value should come last.
  657. // This avoids inconsistent results when comparing values to undefined/null.
  658. // If neither value exists, return 0 (equal).
  659. let comparatorResult = 0;
  660. if (valueA != null && valueB != null) {
  661. // Check if one value is greater than the other; if equal, comparatorResult should remain 0.
  662. if (valueA > valueB) {
  663. comparatorResult = 1;
  664. }
  665. else if (valueA < valueB) {
  666. comparatorResult = -1;
  667. }
  668. }
  669. else if (valueA != null) {
  670. comparatorResult = 1;
  671. }
  672. else if (valueB != null) {
  673. comparatorResult = -1;
  674. }
  675. return comparatorResult * (direction == 'asc' ? 1 : -1);
  676. });
  677. };
  678. /**
  679. * Checks if a data object matches the data source's filter string. By default, each data object
  680. * is converted to a string of its properties and returns true if the filter has
  681. * at least one occurrence in that string. By default, the filter string has its whitespace
  682. * trimmed and the match is case-insensitive. May be overridden for a custom implementation of
  683. * filter matching.
  684. * @param data Data object used to check against the filter.
  685. * @param filter Filter string that has been set on the data source.
  686. * @returns Whether the filter matches against the data
  687. */
  688. filterPredicate = (data, filter) => {
  689. // Transform the filter by converting it to lowercase and removing whitespace.
  690. const transformedFilter = filter.trim().toLowerCase();
  691. // Loops over the values in the array and returns true if any of them match the filter string
  692. return Object.values(data).some(value => `${value}`.toLowerCase().includes(transformedFilter));
  693. };
  694. constructor(initialData = []) {
  695. super();
  696. this._data = new BehaviorSubject(initialData);
  697. this._updateChangeSubscription();
  698. }
  699. /**
  700. * Subscribe to changes that should trigger an update to the table's rendered rows. When the
  701. * changes occur, process the current state of the filter, sort, and pagination along with
  702. * the provided base data and send it to the table for rendering.
  703. */
  704. _updateChangeSubscription() {
  705. // Sorting and/or pagination should be watched if sort and/or paginator are provided.
  706. // The events should emit whenever the component emits a change or initializes, or if no
  707. // component is provided, a stream with just a null event should be provided.
  708. // The `sortChange` and `pageChange` acts as a signal to the combineLatests below so that the
  709. // pipeline can progress to the next step. Note that the value from these streams are not used,
  710. // they purely act as a signal to progress in the pipeline.
  711. const sortChange = this._sort
  712. ? merge(this._sort.sortChange, this._sort.initialized)
  713. : of(null);
  714. const pageChange = this._paginator
  715. ? merge(this._paginator.page, this._internalPageChanges, this._paginator.initialized)
  716. : of(null);
  717. const dataStream = this._data;
  718. // Watch for base data or filter changes to provide a filtered set of data.
  719. const filteredData = combineLatest([dataStream, this._filter]).pipe(map(([data]) => this._filterData(data)));
  720. // Watch for filtered data or sort changes to provide an ordered set of data.
  721. const orderedData = combineLatest([filteredData, sortChange]).pipe(map(([data]) => this._orderData(data)));
  722. // Watch for ordered data or page changes to provide a paged set of data.
  723. const paginatedData = combineLatest([orderedData, pageChange]).pipe(map(([data]) => this._pageData(data)));
  724. // Watched for paged data changes and send the result to the table to render.
  725. this._renderChangesSubscription?.unsubscribe();
  726. this._renderChangesSubscription = paginatedData.subscribe(data => this._renderData.next(data));
  727. }
  728. /**
  729. * Returns a filtered data array where each filter object contains the filter string within
  730. * the result of the filterPredicate function. If no filter is set, returns the data array
  731. * as provided.
  732. */
  733. _filterData(data) {
  734. // If there is a filter string, filter out data that does not contain it.
  735. // Each data object is converted to a string using the function defined by filterPredicate.
  736. // May be overridden for customization.
  737. this.filteredData =
  738. this.filter == null || this.filter === ''
  739. ? data
  740. : data.filter(obj => this.filterPredicate(obj, this.filter));
  741. if (this.paginator) {
  742. this._updatePaginator(this.filteredData.length);
  743. }
  744. return this.filteredData;
  745. }
  746. /**
  747. * Returns a sorted copy of the data if MatSort has a sort applied, otherwise just returns the
  748. * data array as provided. Uses the default data accessor for data lookup, unless a
  749. * sortDataAccessor function is defined.
  750. */
  751. _orderData(data) {
  752. // If there is no active sort or direction, return the data without trying to sort.
  753. if (!this.sort) {
  754. return data;
  755. }
  756. return this.sortData(data.slice(), this.sort);
  757. }
  758. /**
  759. * Returns a paged slice of the provided data array according to the provided paginator's page
  760. * index and length. If there is no paginator provided, returns the data array as provided.
  761. */
  762. _pageData(data) {
  763. if (!this.paginator) {
  764. return data;
  765. }
  766. const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
  767. return data.slice(startIndex, startIndex + this.paginator.pageSize);
  768. }
  769. /**
  770. * Updates the paginator to reflect the length of the filtered data, and makes sure that the page
  771. * index does not exceed the paginator's last page. Values are changed in a resolved promise to
  772. * guard against making property changes within a round of change detection.
  773. */
  774. _updatePaginator(filteredDataLength) {
  775. Promise.resolve().then(() => {
  776. const paginator = this.paginator;
  777. if (!paginator) {
  778. return;
  779. }
  780. paginator.length = filteredDataLength;
  781. // If the page index is set beyond the page, reduce it to the last page.
  782. if (paginator.pageIndex > 0) {
  783. const lastPageIndex = Math.ceil(paginator.length / paginator.pageSize) - 1 || 0;
  784. const newPageIndex = Math.min(paginator.pageIndex, lastPageIndex);
  785. if (newPageIndex !== paginator.pageIndex) {
  786. paginator.pageIndex = newPageIndex;
  787. // Since the paginator only emits after user-generated changes,
  788. // we need our own stream so we know to should re-render the data.
  789. this._internalPageChanges.next();
  790. }
  791. }
  792. });
  793. }
  794. /**
  795. * Used by the MatTable. Called when it connects to the data source.
  796. * @docs-private
  797. */
  798. connect() {
  799. if (!this._renderChangesSubscription) {
  800. this._updateChangeSubscription();
  801. }
  802. return this._renderData;
  803. }
  804. /**
  805. * Used by the MatTable. Called when it disconnects from the data source.
  806. * @docs-private
  807. */
  808. disconnect() {
  809. this._renderChangesSubscription?.unsubscribe();
  810. this._renderChangesSubscription = null;
  811. }
  812. }
  813. export { MatCell, MatCellDef, MatColumnDef, MatFooterCell, MatFooterCellDef, MatFooterRow, MatFooterRowDef, MatHeaderCell, MatHeaderCellDef, MatHeaderRow, MatHeaderRowDef, MatNoDataRow, MatRecycleRows, MatRow, MatRowDef, MatTable, MatTableDataSource, MatTableModule, MatTextColumn };
  814. //# sourceMappingURL=table.mjs.map