Skip to content

Commit e3b8032

Browse files
authored
feat(material/table): Switch table implementation to use MDC (#25453)
Old implementation is still available under @angular/material/legacy-table BREAKING CHANGE: - DOM and CSS classes for mat-table have changes - Typescript API is largely the same but may have minor differences - See the MDC migration guide for more information about the changes and how to migrate your app (TODO: link when available)
1 parent 0554f18 commit e3b8032

File tree

136 files changed

+2144
-1407
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+2144
-1407
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
/src/material/legacy-snack-bar/** @andrewseguin @crisbeto
3434
/src/material/sort/** @andrewseguin
3535
/src/material/stepper/** @mmalerba
36-
/src/material/table/** @andrewseguin
36+
/src/material/legacy-table/** @andrewseguin
3737
/src/material/legacy-tabs/** @andrewseguin
3838
/src/material/testing/** @andrewseguin
3939
/src/material/toolbar/** @devversion
@@ -131,7 +131,7 @@
131131
/src/material/slider/** @devversion
132132
/src/material/tabs/** @crisbeto
133133
/src/material-experimental/mdc-tooltip/** @crisbeto
134-
/src/material-experimental/mdc-table/** @andrewseguin
134+
/src/material/table/** @andrewseguin
135135
/src/material-experimental/menubar/** @jelbourn
136136
/src/material-experimental/popover-edit/** @andrewseguin
137137
/src/material-experimental/selection/** @andrewseguin
@@ -347,7 +347,7 @@
347347
/tools/public_api_guard/material/legacy-snack-bar** @andrewseguin @crisbeto
348348
/tools/public_api_guard/material/sort** @andrewseguin
349349
/tools/public_api_guard/material/stepper** @mmalerba
350-
/tools/public_api_guard/material/table** @andrewseguin
350+
/tools/public_api_guard/material/legacy-table** @andrewseguin
351351
/tools/public_api_guard/material/legacy-tabs** @andrewseguin
352352
/tools/public_api_guard/material/toolbar** @devversion
353353
/tools/public_api_guard/material/legacy-tooltip** @andrewseguin

.ng-dev/commit-message.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const commitMessage: CommitMessageConfig = {
5252
'material-experimental/mdc-progress-spinner',
5353
'material/slide-toggle',
5454
'material/snack-bar',
55-
'material-experimental/mdc-table',
55+
'material/table',
5656
'material/tabs',
5757
'material-experimental/menubar',
5858
'material-experimental/popover-edit',
@@ -103,7 +103,7 @@ export const commitMessage: CommitMessageConfig = {
103103
'material/legacy-snack-bar',
104104
'material/sort',
105105
'material/stepper',
106-
'material/table',
106+
'material/legacy-table',
107107
'material/legacy-tabs',
108108
'material/testing',
109109
'material/theming',

integration/mdc-migration/golden/src/app/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {MatSelectModule} from '@angular/material-experimental/mdc-select';
2222
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
2323
import {MatSliderModule} from '@angular/material-experimental/mdc-slider';
2424
import {MatSnackBarModule} from '@angular/material/legacy-snack-bar';
25-
import {MatTableModule} from '@angular/material-experimental/mdc-table';
25+
import {MatTableModule} from '@angular/material/table';
2626
import {MatTabsModule} from '@angular/material/tabs';
2727
import {MatTooltipModule} from '@angular/material-experimental/mdc-tooltip';
2828
import {AutocompleteComponent} from './components/autocomplete/autocomplete.component';

integration/mdc-migration/golden/src/app/components/table/table.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {ComponentFixture, TestBed} from '@angular/core/testing';
22
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
3-
import {MatTableModule} from '@angular/material/table';
3+
import {MatTableModule} from '@angular/material/legacy-table';
44
import {TableComponent} from './table.component';
55

66
describe('TableComponent', () => {

integration/mdc-migration/golden/src/styles.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ $sample-project-theme: mat.define-light-theme((
6767
@include mat.mdc-slider-theme($sample-project-theme);
6868
@include mat.mdc-slider-typography($sample-project-theme);
6969
@include mat.snack-bar-typography($sample-project-theme);
70-
@include mat.mdc-table-theme($sample-project-theme);
71-
@include mat.mdc-table-typography($sample-project-theme);
70+
@include mat.table-theme($sample-project-theme);
71+
@include mat.table-typography($sample-project-theme);
7272
@include mat.tabs-theme($sample-project-theme);
7373
@include mat.tabs-typography($sample-project-theme);
7474
@include mat.mdc-tooltip-theme($sample-project-theme);

integration/mdc-migration/sample-project/src/app/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {MatSelectModule} from '@angular/material/select';
2222
import {MatSlideToggleModule} from '@angular/material/legacy-slide-toggle';
2323
import {MatSliderModule} from '@angular/material/slider';
2424
import {MatSnackBarModule} from '@angular/material/legacy-snack-bar';
25-
import {MatTableModule} from '@angular/material/table';
25+
import {MatTableModule} from '@angular/material/legacy-table';
2626
import {MatTabsModule} from '@angular/material/legacy-tabs';
2727
import {MatTooltipModule} from '@angular/material/tooltip';
2828
import {AutocompleteComponent} from './components/autocomplete/autocomplete.component';

integration/mdc-migration/sample-project/src/app/components/table/table.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {ComponentFixture, TestBed} from '@angular/core/testing';
22
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
3-
import {MatTableModule} from '@angular/material/table';
3+
import {MatTableModule} from '@angular/material/legacy-table';
44
import {TableComponent} from './table.component';
55

66
describe('TableComponent', () => {

integration/mdc-migration/sample-project/src/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ $sample-project-theme: mat.define-light-theme((
4545
@include mat.legacy-slide-toggle-theme($sample-project-theme);
4646
@include mat.slider-theme($sample-project-theme);
4747
@include mat.legacy-snack-bar-theme($sample-project-theme);
48-
@include mat.table-theme($sample-project-theme);
48+
@include mat.legacy-table-theme($sample-project-theme);
4949
@include mat.legacy-tabs-theme($sample-project-theme);
5050
@include mat.tooltip-theme($sample-project-theme);
5151

src/components-examples/material-experimental/column-resize/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ng_module(
1111
]),
1212
deps = [
1313
"//src/material-experimental/column-resize",
14-
"//src/material/table",
14+
"//src/material/legacy-table",
1515
],
1616
)
1717

src/components-examples/material-experimental/column-resize/default-enabled-column-resize-flex/default-enabled-column-resize-flex-example-module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
*/
88

99
import {NgModule} from '@angular/core';
10-
import {MatTableModule} from '@angular/material/table';
10+
import {MatLegacyTableModule} from '@angular/material/legacy-table';
1111
import {MatDefaultEnabledColumnResizeModule} from '@angular/material-experimental/column-resize';
1212

1313
import {DefaultEnabledColumnResizeFlexExample} from './default-enabled-column-resize-flex-example';
1414

1515
@NgModule({
16-
imports: [MatDefaultEnabledColumnResizeModule, MatTableModule],
16+
imports: [MatDefaultEnabledColumnResizeModule, MatLegacyTableModule],
1717
declarations: [DefaultEnabledColumnResizeFlexExample],
1818
exports: [DefaultEnabledColumnResizeFlexExample],
1919
})

src/components-examples/material-experimental/column-resize/default-enabled-column-resize/default-enabled-column-resize-example-module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
*/
88

99
import {NgModule} from '@angular/core';
10-
import {MatTableModule} from '@angular/material/table';
10+
import {MatLegacyTableModule} from '@angular/material/legacy-table';
1111
import {MatDefaultEnabledColumnResizeModule} from '@angular/material-experimental/column-resize';
1212

1313
import {DefaultEnabledColumnResizeExample} from './default-enabled-column-resize-example';
1414

1515
@NgModule({
16-
imports: [MatDefaultEnabledColumnResizeModule, MatTableModule],
16+
imports: [MatDefaultEnabledColumnResizeModule, MatLegacyTableModule],
1717
declarations: [DefaultEnabledColumnResizeExample],
1818
exports: [DefaultEnabledColumnResizeExample],
1919
})

src/components-examples/material-experimental/column-resize/opt-in-column-resize/opt-in-column-resize-example-module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
*/
88

99
import {NgModule} from '@angular/core';
10-
import {MatTableModule} from '@angular/material/table';
10+
import {MatLegacyTableModule} from '@angular/material/legacy-table';
1111
import {MatColumnResizeModule} from '@angular/material-experimental/column-resize';
1212

1313
import {OptInColumnResizeExample} from './opt-in-column-resize-example';
1414

1515
@NgModule({
16-
imports: [MatColumnResizeModule, MatTableModule],
16+
imports: [MatColumnResizeModule, MatLegacyTableModule],
1717
declarations: [OptInColumnResizeExample],
1818
exports: [OptInColumnResizeExample],
1919
})

src/components-examples/material-experimental/mdc-table/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ ng_module(
1717
"//src/cdk/table",
1818
"//src/cdk/testing",
1919
"//src/cdk/testing/testbed",
20-
"//src/material-experimental/mdc-table",
2120
"//src/material/button-toggle",
2221
"//src/material/core",
2322
"//src/material/icon",
2423
"//src/material/legacy-button",
2524
"//src/material/legacy-checkbox",
2625
"//src/material/legacy-input",
2726
"//src/material/legacy-paginator",
27+
"//src/material/legacy-table",
28+
"//src/material/legacy-table/testing",
2829
"//src/material/progress-spinner",
2930
"//src/material/sort",
30-
"//src/material/table/testing",
3131
"@npm//@angular/platform-browser",
3232
"@npm//@angular/platform-browser-dynamic",
3333
"@npm//@types/jasmine",
@@ -50,8 +50,8 @@ ng_test_library(
5050
":mdc-table",
5151
"//src/cdk/testing",
5252
"//src/cdk/testing/testbed",
53-
"//src/material/table",
54-
"//src/material/table/testing",
53+
"//src/material/legacy-table",
54+
"//src/material/legacy-table/testing",
5555
"@npm//@angular/platform-browser-dynamic",
5656
],
5757
)

src/components-examples/material-experimental/mdc-table/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {MatLegacyInputModule} from '@angular/material/legacy-input';
99
import {MatLegacyPaginatorModule} from '@angular/material/legacy-paginator';
1010
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
1111
import {MatSortModule} from '@angular/material/sort';
12-
import {MatTableModule} from '@angular/material-experimental/mdc-table';
12+
import {MatTableModule} from '@angular/material/table';
1313
import {DragDropModule} from '@angular/cdk/drag-drop';
1414
import {CdkTableModule} from '@angular/cdk/table';
1515

src/components-examples/material-experimental/mdc-table/table-dynamic-array-data/table-dynamic-array-data-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, ViewChild} from '@angular/core';
2-
import {MatTable} from '@angular/material/table';
2+
import {MatLegacyTable} from '@angular/material/legacy-table';
33

44
export interface PeriodicElement {
55
name: string;
@@ -33,7 +33,7 @@ export class TableDynamicArrayDataExample {
3333
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
3434
dataSource = [...ELEMENT_DATA];
3535

36-
@ViewChild(MatTable) table: MatTable<PeriodicElement>;
36+
@ViewChild(MatLegacyTable) table: MatLegacyTable<PeriodicElement>;
3737

3838
addData() {
3939
const randomElementIndex = Math.floor(Math.random() * ELEMENT_DATA.length);

src/components-examples/material-experimental/mdc-table/table-filtering/table-filtering-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {MatTableDataSource} from '@angular/material/table';
2+
import {MatLegacyTableDataSource} from '@angular/material/legacy-table';
33

44
export interface PeriodicElement {
55
name: string;
@@ -31,7 +31,7 @@ const ELEMENT_DATA: PeriodicElement[] = [
3131
})
3232
export class TableFilteringExample {
3333
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
34-
dataSource = new MatTableDataSource(ELEMENT_DATA);
34+
dataSource = new MatLegacyTableDataSource(ELEMENT_DATA);
3535

3636
applyFilter(event: Event) {
3737
const filterValue = (event.target as HTMLInputElement).value;

src/components-examples/material-experimental/mdc-table/table-harness/table-harness-example.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {ComponentFixture, TestBed} from '@angular/core/testing';
22
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
3-
import {MatTableHarness} from '@angular/material/table/testing';
3+
import {MatLegacyTableHarness} from '@angular/material/legacy-table/testing';
44
import {HarnessLoader, parallel} from '@angular/cdk/testing';
5-
import {MatTableModule} from '@angular/material/table';
5+
import {MatLegacyTableModule} from '@angular/material/legacy-table';
66
import {TableHarnessExample} from './table-harness-example';
77

88
describe('TableHarnessExample', () => {
@@ -11,7 +11,7 @@ describe('TableHarnessExample', () => {
1111

1212
beforeEach(async () => {
1313
await TestBed.configureTestingModule({
14-
imports: [MatTableModule],
14+
imports: [MatLegacyTableModule],
1515
declarations: [TableHarnessExample],
1616
}).compileComponents();
1717
fixture = TestBed.createComponent(TableHarnessExample);
@@ -20,12 +20,12 @@ describe('TableHarnessExample', () => {
2020
});
2121

2222
it('should load harness for a table', async () => {
23-
const tables = await loader.getAllHarnesses(MatTableHarness);
23+
const tables = await loader.getAllHarnesses(MatLegacyTableHarness);
2424
expect(tables.length).toBe(1);
2525
});
2626

2727
it('should get the different kinds of rows in the table', async () => {
28-
const table = await loader.getHarness(MatTableHarness);
28+
const table = await loader.getHarness(MatLegacyTableHarness);
2929
const headerRows = await table.getHeaderRows();
3030
const footerRows = await table.getFooterRows();
3131
const rows = await table.getRows();
@@ -35,7 +35,7 @@ describe('TableHarnessExample', () => {
3535
});
3636

3737
it('should get cells inside a row', async () => {
38-
const table = await loader.getHarness(MatTableHarness);
38+
const table = await loader.getHarness(MatLegacyTableHarness);
3939
const headerRows = await table.getHeaderRows();
4040
const footerRows = await table.getFooterRows();
4141
const rows = await table.getRows();
@@ -53,31 +53,31 @@ describe('TableHarnessExample', () => {
5353
});
5454

5555
it('should be able to get the text of a cell', async () => {
56-
const table = await loader.getHarness(MatTableHarness);
56+
const table = await loader.getHarness(MatLegacyTableHarness);
5757
const secondRow = (await table.getRows())[1];
5858
const cells = await secondRow.getCells();
5959
const cellTexts = await parallel(() => cells.map(cell => cell.getText()));
6060
expect(cellTexts).toEqual(['2', 'Helium', '4.0026', 'He']);
6161
});
6262

6363
it('should be able to get the column name of a cell', async () => {
64-
const table = await loader.getHarness(MatTableHarness);
64+
const table = await loader.getHarness(MatLegacyTableHarness);
6565
const fifthRow = (await table.getRows())[1];
6666
const cells = await fifthRow.getCells();
6767
const cellColumnNames = await parallel(() => cells.map(cell => cell.getColumnName()));
6868
expect(cellColumnNames).toEqual(['position', 'name', 'weight', 'symbol']);
6969
});
7070

7171
it('should be able to filter cells by text', async () => {
72-
const table = await loader.getHarness(MatTableHarness);
72+
const table = await loader.getHarness(MatLegacyTableHarness);
7373
const firstRow = (await table.getRows())[0];
7474
const cells = await firstRow.getCells({text: '1.0079'});
7575
const cellTexts = await parallel(() => cells.map(cell => cell.getText()));
7676
expect(cellTexts).toEqual(['1.0079']);
7777
});
7878

7979
it('should be able to filter cells by column name', async () => {
80-
const table = await loader.getHarness(MatTableHarness);
80+
const table = await loader.getHarness(MatLegacyTableHarness);
8181
const firstRow = (await table.getRows())[0];
8282
const cells = await firstRow.getCells({columnName: 'symbol'});
8383
const cellTexts = await parallel(() => cells.map(cell => cell.getText()));

src/components-examples/material-experimental/mdc-table/table-overview/table-overview-example.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {AfterViewInit, Component, ViewChild} from '@angular/core';
22
import {MatLegacyPaginator} from '@angular/material/legacy-paginator';
33
import {MatSort} from '@angular/material/sort';
4-
import {MatTableDataSource} from '@angular/material/table';
4+
import {MatLegacyTableDataSource} from '@angular/material/legacy-table';
55

66
export interface UserData {
77
id: string;
@@ -53,7 +53,7 @@ const NAMES: string[] = [
5353
})
5454
export class TableOverviewExample implements AfterViewInit {
5555
displayedColumns: string[] = ['id', 'name', 'progress', 'fruit'];
56-
dataSource: MatTableDataSource<UserData>;
56+
dataSource: MatLegacyTableDataSource<UserData>;
5757

5858
@ViewChild(MatLegacyPaginator) paginator: MatLegacyPaginator;
5959
@ViewChild(MatSort) sort: MatSort;
@@ -63,7 +63,7 @@ export class TableOverviewExample implements AfterViewInit {
6363
const users = Array.from({length: 100}, (_, k) => createNewUser(k + 1));
6464

6565
// Assign the data to the data source for the table to render
66-
this.dataSource = new MatTableDataSource(users);
66+
this.dataSource = new MatLegacyTableDataSource(users);
6767
}
6868

6969
ngAfterViewInit() {

src/components-examples/material-experimental/mdc-table/table-pagination/table-pagination-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {AfterViewInit, Component, ViewChild} from '@angular/core';
22
import {MatLegacyPaginator} from '@angular/material/legacy-paginator';
3-
import {MatTableDataSource} from '@angular/material/table';
3+
import {MatLegacyTableDataSource} from '@angular/material/legacy-table';
44

55
/**
66
* @title Table with pagination
@@ -12,7 +12,7 @@ import {MatTableDataSource} from '@angular/material/table';
1212
})
1313
export class TablePaginationExample implements AfterViewInit {
1414
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
15-
dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA);
15+
dataSource = new MatLegacyTableDataSource<PeriodicElement>(ELEMENT_DATA);
1616

1717
@ViewChild(MatLegacyPaginator) paginator: MatLegacyPaginator;
1818

src/components-examples/material-experimental/mdc-table/table-selection/table-selection-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {SelectionModel} from '@angular/cdk/collections';
22
import {Component} from '@angular/core';
3-
import {MatTableDataSource} from '@angular/material/table';
3+
import {MatLegacyTableDataSource} from '@angular/material/legacy-table';
44

55
export interface PeriodicElement {
66
name: string;
@@ -32,7 +32,7 @@ const ELEMENT_DATA: PeriodicElement[] = [
3232
})
3333
export class TableSelectionExample {
3434
displayedColumns: string[] = ['select', 'position', 'name', 'weight', 'symbol'];
35-
dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA);
35+
dataSource = new MatLegacyTableDataSource<PeriodicElement>(ELEMENT_DATA);
3636
selection = new SelectionModel<PeriodicElement>(true, []);
3737

3838
/** Whether the number of selected elements matches the total number of rows. */

src/components-examples/material-experimental/mdc-table/table-sorting/table-sorting-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {AfterViewInit, Component, ViewChild} from '@angular/core';
22
import {MatSort} from '@angular/material/sort';
3-
import {MatTableDataSource} from '@angular/material/table';
3+
import {MatLegacyTableDataSource} from '@angular/material/legacy-table';
44

55
export interface PeriodicElement {
66
name: string;
@@ -32,7 +32,7 @@ const ELEMENT_DATA: PeriodicElement[] = [
3232
})
3333
export class TableSortingExample implements AfterViewInit {
3434
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
35-
dataSource = new MatTableDataSource(ELEMENT_DATA);
35+
dataSource = new MatLegacyTableDataSource(ELEMENT_DATA);
3636

3737
@ViewChild(MatSort) sort: MatSort;
3838

0 commit comments

Comments
 (0)