From 32f42d6fb5289d3ac9e161ffed88e4590ce21ffc Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Wed, 23 Aug 2017 13:28:36 -0700 Subject: [PATCH] compat(table): add mat-compatible rows (#6603) --- src/lib/table/index.ts | 8 +++++--- src/lib/table/row.ts | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/lib/table/index.ts b/src/lib/table/index.ts index 69251537632..7976a84b62e 100644 --- a/src/lib/table/index.ts +++ b/src/lib/table/index.ts @@ -10,7 +10,7 @@ import {NgModule} from '@angular/core'; import {MdTable} from './table'; import {CdkTableModule} from '@angular/cdk/table'; import {MdCell, MdHeaderCell, MdCellDef, MdHeaderCellDef, MdColumnDef} from './cell'; -import {MdHeaderRow, MdRow, MdHeaderRowDef, MdRowDef} from './row'; +import {MdHeaderRow, MdRow, MdHeaderRowDef, MdRowDef, MatHeaderRowDef, MatRowDef} from './row'; import {CommonModule} from '@angular/common'; import {MdCommonModule} from '../core'; @@ -22,9 +22,11 @@ export * from './row'; imports: [CdkTableModule, CommonModule, MdCommonModule], exports: [MdTable, MdCellDef, MdHeaderCellDef, MdColumnDef, MdHeaderRowDef, MdRowDef, - MdHeaderCell, MdCell, MdHeaderRow, MdRow], + MdHeaderCell, MdCell, MdHeaderRow, MdRow, + MatHeaderRowDef, MatRowDef], declarations: [MdTable, MdCellDef, MdHeaderCellDef, MdColumnDef, MdHeaderRowDef, MdRowDef, - MdHeaderCell, MdCell, MdHeaderRow, MdRow], + MdHeaderCell, MdCell, MdHeaderRow, MdRow, + MatHeaderRowDef, MatRowDef], }) export class MdTableModule {} diff --git a/src/lib/table/row.ts b/src/lib/table/row.ts index 1dbdfeb3243..2549e440339 100644 --- a/src/lib/table/row.ts +++ b/src/lib/table/row.ts @@ -26,23 +26,39 @@ export const _MdRow = CdkRow; * Captures the header row's template and other header properties such as the columns to display. */ @Directive({ - selector: '[mdHeaderRowDef], [matHeaderRowDef]', + selector: '[mdHeaderRowDef]', providers: [{provide: CdkHeaderRowDef, useExisting: MdHeaderRowDef}], inputs: ['columns: mdHeaderRowDef'], }) export class MdHeaderRowDef extends _MdHeaderRowDef { } +/** Mat-compatible version of MdHeaderRowDef */ +@Directive({ + selector: '[matHeaderRowDef]', + providers: [{provide: CdkHeaderRowDef, useExisting: MatHeaderRowDef}], + inputs: ['columns: matHeaderRowDef'], +}) +export class MatHeaderRowDef extends _MdHeaderRowDef { } + /** * Data row definition for the md-table. * Captures the header row's template and other row properties such as the columns to display. */ @Directive({ - selector: '[mdRowDef], [matRowDef]', + selector: '[mdRowDef]', providers: [{provide: CdkRowDef, useExisting: MdRowDef}], inputs: ['columns: mdRowDefColumns'], }) export class MdRowDef extends _MdCdkRowDef { } +/** Mat-compatible version of MdRowDef */ +@Directive({ + selector: '[matRowDef]', + providers: [{provide: CdkRowDef, useExisting: MatRowDef}], + inputs: ['columns: matRowDefColumns'], +}) +export class MatRowDef extends _MdCdkRowDef { } + /** Header template container that contains the cell outlet. Adds the right class and role. */ @Component({ selector: 'md-header-row, mat-header-row',