Skip to content

Commit ac4664a

Browse files
committed
refactor(table): rename MatTableDataSource to ClientArrayTableDataSource
Renames the `MatTableDataSource` to `ClientArrayTableDataSource` to make it a bit clearer what it's supposed to be used for. Fixes #14378.
1 parent c5a32c2 commit ac4664a

File tree

13 files changed

+120
-98
lines changed

13 files changed

+120
-98
lines changed

src/lib/schematics/ng-update/data/class-names.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,16 @@ export const classNames: VersionChanges<ClassNameUpgradeData> = {
2727
}
2828
]
2929
},
30+
],
31+
[TargetVersion.V8]: [
32+
{
33+
pr: 'https://github.com/angular/material2/pull/15432',
34+
changes: [
35+
{
36+
replace: 'MatTableDataSource',
37+
replaceWith: 'ClientArrayTableDataSource'
38+
}
39+
]
40+
}
3041
]
3142
};

src/lib/table/public-api.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import {ClientArrayTableDataSource} from './table-data-source';
10+
911
export * from './table-module';
1012
export * from './cell';
1113
export * from './table';
1214
export * from './row';
1315
export * from './table-data-source';
16+
17+
/**
18+
* @deprecated Use `ClientArrayTableDataSource` instead.
19+
* @breaking-change 9.0.0
20+
*/
21+
// tslint:disable-next-line:variable-name
22+
export const MatTableDataSource = ClientArrayTableDataSource;

src/lib/table/table-data-source.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const MAX_SAFE_INTEGER = 9007199254740991;
3535
* properties are accessed. Also allows for filter customization by overriding filterTermAccessor,
3636
* which defines how row data is converted to a string for filter matching.
3737
*/
38-
export class MatTableDataSource<T> extends DataSource<T> {
38+
export class ClientArrayTableDataSource<T> extends DataSource<T> {
3939
/** Stream that emits when a new data array is set on the data source. */
4040
private readonly _data: BehaviorSubject<T[]>;
4141

src/lib/table/table.md

Lines changed: 75 additions & 73 deletions
Large diffs are not rendered by default.

src/lib/table/table.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {MatPaginator, MatPaginatorModule} from '../paginator/index';
1414
import {MatSort, MatSortHeader, MatSortModule} from '../sort/index';
1515
import {MatTableModule} from './index';
1616
import {MatTable} from './table';
17-
import {MatTableDataSource} from './table-data-source';
17+
import {ClientArrayTableDataSource} from './table-data-source';
1818

1919

2020
describe('MatTable', () => {
@@ -99,7 +99,7 @@ describe('MatTable', () => {
9999
]);
100100
});
101101

102-
it('should render with MatTableDataSource and sort', () => {
102+
it('should render with ClientArrayTableDataSource and sort', () => {
103103
let fixture = TestBed.createComponent(MatTableWithSortApp);
104104
fixture.detectChanges();
105105

@@ -113,7 +113,7 @@ describe('MatTable', () => {
113113
]);
114114
});
115115

116-
it('should render with MatTableDataSource and pagination', () => {
116+
it('should render with ClientArrayTableDataSource and pagination', () => {
117117
let fixture = TestBed.createComponent(MatTableWithPaginatorApp);
118118
fixture.detectChanges();
119119

@@ -145,10 +145,10 @@ describe('MatTable', () => {
145145
}).not.toThrow();
146146
}));
147147

148-
describe('with MatTableDataSource and sort/pagination/filter', () => {
148+
describe('with ClientArrayTableDataSource and sort/pagination/filter', () => {
149149
let tableElement: HTMLElement;
150150
let fixture: ComponentFixture<ArrayDataSourceMatTableApp>;
151-
let dataSource: MatTableDataSource<TestData>;
151+
let dataSource: ClientArrayTableDataSource<TestData>;
152152
let component: ArrayDataSourceMatTableApp;
153153

154154
beforeEach(fakeAsync(() => {
@@ -679,7 +679,7 @@ class MatTableWithWhenRowApp {
679679
})
680680
class ArrayDataSourceMatTableApp implements AfterViewInit {
681681
underlyingDataSource = new FakeDataSource();
682-
dataSource = new MatTableDataSource<TestData>();
682+
dataSource = new ClientArrayTableDataSource<TestData>();
683683
columnsToRender = ['column_a', 'column_b', 'column_c'];
684684

685685
@ViewChild(MatTable) table: MatTable<TestData>;
@@ -732,7 +732,7 @@ class ArrayDataSourceMatTableApp implements AfterViewInit {
732732
})
733733
class MatTableWithSortApp implements OnInit {
734734
underlyingDataSource = new FakeDataSource();
735-
dataSource = new MatTableDataSource<TestData>();
735+
dataSource = new ClientArrayTableDataSource<TestData>();
736736
columnsToRender = ['column_a', 'column_b', 'column_c'];
737737

738738
@ViewChild(MatTable) table: MatTable<TestData>;
@@ -783,7 +783,7 @@ class MatTableWithSortApp implements OnInit {
783783
})
784784
class MatTableWithPaginatorApp implements OnInit {
785785
underlyingDataSource = new FakeDataSource();
786-
dataSource = new MatTableDataSource<TestData>();
786+
dataSource = new ClientArrayTableDataSource<TestData>();
787787
columnsToRender = ['column_a', 'column_b', 'column_c'];
788788

789789
@ViewChild(MatTable) table: MatTable<TestData>;

src/material-examples/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';
2+
import {ClientArrayTableDataSource} from '@angular/material';
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 ClientArrayTableDataSource(ELEMENT_DATA);
3535

3636
applyFilter(filterValue: string) {
3737
this.dataSource.filter = filterValue.trim().toLowerCase();

src/material-examples/table-overview/table-overview-example.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, OnInit, ViewChild} from '@angular/core';
2-
import {MatPaginator, MatSort, MatTableDataSource} from '@angular/material';
2+
import {MatPaginator, MatSort, ClientArrayTableDataSource} from '@angular/material';
33

44
export interface UserData {
55
id: string;
@@ -25,7 +25,7 @@ const NAMES: string[] = ['Maia', 'Asher', 'Olivia', 'Atticus', 'Amelia', 'Jack',
2525
})
2626
export class TableOverviewExample implements OnInit {
2727
displayedColumns: string[] = ['id', 'name', 'progress', 'color'];
28-
dataSource: MatTableDataSource<UserData>;
28+
dataSource: ClientArrayTableDataSource<UserData>;
2929

3030
@ViewChild(MatPaginator) paginator: MatPaginator;
3131
@ViewChild(MatSort) sort: MatSort;
@@ -35,7 +35,7 @@ export class TableOverviewExample implements OnInit {
3535
const users = Array.from({length: 100}, (_, k) => createNewUser(k + 1));
3636

3737
// Assign the data to the data source for the table to render
38-
this.dataSource = new MatTableDataSource(users);
38+
this.dataSource = new ClientArrayTableDataSource(users);
3939
}
4040

4141
ngOnInit() {

src/material-examples/table-pagination/table-pagination-example.ts

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

44
/**
55
* @title Table with pagination
@@ -11,7 +11,7 @@ import {MatPaginator, MatTableDataSource} from '@angular/material';
1111
})
1212
export class TablePaginationExample implements OnInit {
1313
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
14-
dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA);
14+
dataSource = new ClientArrayTableDataSource<PeriodicElement>(ELEMENT_DATA);
1515

1616
@ViewChild(MatPaginator) paginator: MatPaginator;
1717

src/material-examples/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';
3+
import {ClientArrayTableDataSource} from '@angular/material';
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 ClientArrayTableDataSource<PeriodicElement>(ELEMENT_DATA);
3636
selection = new SelectionModel<PeriodicElement>(true, []);
3737

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

src/material-examples/table-simple-column/table-simple-column-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
MatSort,
66
MatSortHeader,
77
MatTable,
8-
MatTableDataSource
8+
ClientArrayTableDataSource
99
} from '@angular/material';
1010

1111
export interface PeriodicElement {
@@ -38,7 +38,7 @@ const ELEMENT_DATA: PeriodicElement[] = [
3838
})
3939
export class TableSimpleColumnExample implements OnInit {
4040
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
41-
dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA);
41+
dataSource = new ClientArrayTableDataSource<PeriodicElement>(ELEMENT_DATA);
4242
getWeight = (data: PeriodicElement) => '~' + data.weight;
4343

4444
@ViewChild('sort') sort: MatSort;

0 commit comments

Comments
 (0)