Skip to content

Commit 9eee000

Browse files
cleanup
1 parent 45efdc5 commit 9eee000

File tree

16 files changed

+103
-20
lines changed

16 files changed

+103
-20
lines changed

src/cdk-experimental/scrollable-table-body/BUILD.bazel renamed to src/cdk-experimental/table/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite"
33
package(default_visibility = ["//visibility:public"])
44

55
ng_module(
6-
name = "scrollable-table-body",
6+
name = "table",
77
srcs = glob(
88
["**/*.ts"],
99
exclude = ["**/*.spec.ts"],
1010
),
11-
module_name = "@angular/cdk-experimental/scrollable-table-body",
11+
module_name = "@angular/cdk-experimental/table",
1212
deps = [
1313
"//src/cdk/table",
1414
"@npm//@angular/common",

src/cdk-experimental/scrollable-table-body/scrollable-table-body-layout.ts renamed to src/cdk-experimental/table/scrollable-table-body-layout.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,25 @@ import {DOCUMENT} from '@angular/common';
1212
import {
1313
_TABLE_LAYOUT_STRATEGY,
1414
_TableLayoutStrategy,
15-
_DefaultTableLayoutStrategy,
15+
_StandardTableLayoutStrategy,
1616
} from '@angular/cdk/table/table-layout-strategy';
1717

1818
/**
1919
* A {@link _TableLayoutStrategy} that enables scrollable body content for flex tables.
2020
*/
2121
@Injectable()
2222
class ScrollableTableBodyLayoutStrategy implements _TableLayoutStrategy {
23-
private defaultLayout: _DefaultTableLayoutStrategy;
23+
private readonly _document: Document;
24+
private defaultLayout: _StandardTableLayoutStrategy;
2425
private _pendingMaxHeight = 'none';
2526
private _scrollViewport?: HTMLElement;
2627
readonly headerCssClass = 'cdk-table-scrollable-table-header';
2728
readonly bodyCssClass = 'cdk-table-scrollable-table-body';
2829
readonly footerCssClass = 'cdk-table-scrollable-table-footer';
2930

30-
constructor(@Inject(DOCUMENT) private readonly _document: any) {
31-
this.defaultLayout = new _DefaultTableLayoutStrategy(this._document);
31+
constructor(@Inject(DOCUMENT) document: any) {
32+
this._document = document;
33+
this.defaultLayout = new _StandardTableLayoutStrategy(this._document);
3234
}
3335

3436
/**
@@ -47,14 +49,14 @@ class ScrollableTableBodyLayoutStrategy implements _TableLayoutStrategy {
4749
getFlexLayout(table: CdkTable<unknown>): DocumentFragment {
4850
const documentFragment = this._document.createDocumentFragment();
4951
const sections = [
50-
{selector: this.headerCssClass, outlets: [table._headerRowOutlet]},
51-
{selector: this.bodyCssClass, outlets: [table._rowOutlet, table._noDataRowOutlet]},
52-
{selector: this.footerCssClass, outlets: [table._footerRowOutlet]},
52+
{cssClass: this.headerCssClass, outlets: [table._headerRowOutlet]},
53+
{cssClass: this.bodyCssClass, outlets: [table._rowOutlet, table._noDataRowOutlet]},
54+
{cssClass: this.footerCssClass, outlets: [table._footerRowOutlet]},
5355
];
5456

5557
for (const section of sections) {
5658
const element = this._document.createElement('div');
57-
element.classList.add(section.selector);
59+
element.classList.add(section.cssClass);
5860
for (const outlet of section.outlets) {
5961
element.appendChild(outlet.elementRef.nativeElement);
6062
}
@@ -87,7 +89,7 @@ class ScrollableTableBodyLayoutStrategy implements _TableLayoutStrategy {
8789

8890
/** A directive that enables scrollable body content for flex tables. */
8991
@Directive({
90-
selector: 'cdk-table[scrollableBody], mat-table[scrollableBody]',
92+
selector: 'cdk-table[scrollableBody]',
9193
providers: [
9294
{provide: _TABLE_LAYOUT_STRATEGY, useClass: ScrollableTableBodyLayoutStrategy},
9395
]

src/cdk/table/table-layout-strategy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ import {DOCUMENT} from '@angular/common';
1313
/** Interface for a service that constructs the DOM structure for a {@link CdkTable}. */
1414
export interface _TableLayoutStrategy {
1515
/** Constructs the DOM structure for a native table. */
16-
getNativeLayout(table: CdkTable<any>): DocumentFragment;
16+
getNativeLayout(table: CdkTable<unknown>): DocumentFragment;
1717
/** Constructs the DOM structure for a flex table. */
18-
getFlexLayout(table: CdkTable<any>): DocumentFragment;
18+
getFlexLayout(table: CdkTable<unknown>): DocumentFragment;
1919
}
2020

2121
/** Injection token for {@link _TableLayoutStrategy}. */
2222
export const _TABLE_LAYOUT_STRATEGY =
2323
new InjectionToken<_TableLayoutStrategy>('_TableLayoutStrategy');
2424

2525

26-
export class _DefaultTableLayoutStrategy implements _TableLayoutStrategy {
26+
export class _StandardTableLayoutStrategy implements _TableLayoutStrategy {
2727
private readonly _document: Document;
2828

2929
constructor(@Inject(DOCUMENT) document: any) {

src/cdk/table/table.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ import {
8282
import {STICKY_POSITIONING_LISTENER, StickyPositioningListener} from './sticky-position-listener';
8383
import {CDK_TABLE} from './tokens';
8484
import {
85-
_DefaultTableLayoutStrategy,
85+
_StandardTableLayoutStrategy,
8686
_TABLE_LAYOUT_STRATEGY,
8787
_TableLayoutStrategy
8888
} from './table-layout-strategy';
@@ -1157,7 +1157,7 @@ export class CdkTable<T> implements AfterContentChecked, CollectionViewer, OnDes
11571157
}
11581158

11591159
private _initTableLayout() {
1160-
const layoutStrategy = this._layoutStrategy || new _DefaultTableLayoutStrategy(this._document);
1160+
const layoutStrategy = this._layoutStrategy || new _StandardTableLayoutStrategy(this._document);
11611161
const layout = this._isNativeHtmlTable
11621162
? layoutStrategy.getNativeLayout(this)
11631163
: layoutStrategy.getFlexLayout(this);

src/components-examples/cdk-experimental/scrollable-table-body/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {NgModule} from '@angular/core';
22
import {CdkTableModule} from '@angular/cdk/table';
33
import {
44
CdkScrollableTableBodyModule,
5-
} from '@angular/cdk-experimental/scrollable-table-body/scrollable-table-body-module';
5+
} from '@angular/cdk-experimental/table/scrollable-table-body-module';
66
import {
77
CdkScrollableTableBodyFlexExample,
88
} from './cdk-scrollable-table-body-flex/cdk-scrollable-table-body-flex-example';

src/components-examples/material-experimental/scrollable-table-body/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {NgModule} from '@angular/core';
22
import {
33
CdkScrollableTableBodyModule,
4-
} from '@angular/cdk-experimental/scrollable-table-body/scrollable-table-body-module';
4+
} from '@angular/cdk-experimental/table/scrollable-table-body-module';
55
import {
66
MatScrollableTableBodyFlexExample,
77
} from './mat-scrollable-table-body-flex/mat-scrollable-table-body-flex-example';

src/dev-app/scrollable-table-body/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ ng_module(
66
name = "scrollable-table-body",
77
srcs = glob(["**/*.ts"]),
88
deps = [
9-
"//src/components-examples/cdk-experimental/scrollable-table-body",
10-
"//src/components-examples/material-experimental/scrollable-table-body",
9+
"//src/components-examples/cdk-experimental/table",
10+
"//src/components-examples/material-experimental/table",
1111
"//src/dev-app/example",
1212
"@npm//@angular/forms",
1313
"@npm//@angular/router",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load("//tools:defaults.bzl", "ng_module")
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
ng_module(
6+
name = "table",
7+
srcs = glob(
8+
["**/*.ts"],
9+
exclude = ["**/*.spec.ts"],
10+
),
11+
module_name = "@angular/material-experimental/table",
12+
deps = [
13+
"//src/mat/table",
14+
"@npm//@angular/common",
15+
"@npm//@angular/core",
16+
"@npm//rxjs",
17+
],
18+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
export * from './public-api';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
export * from './scrollable-table-body-layout';
10+
export * from './scrollable-table-body-module';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {Directive} from '@angular/core';
10+
import {
11+
_TABLE_LAYOUT_STRATEGY,
12+
} from '@angular/cdk/table/table-layout-strategy';
13+
14+
/** A directive that enables scrollable body content for flex tables. */
15+
@Directive({
16+
selector: 'mat-table[scrollableBody]',
17+
providers: [
18+
{provide: _TABLE_LAYOUT_STRATEGY, useClass: ScrollableTableBodyLayoutStrategy},
19+
]
20+
})
21+
export class MatScrollableTableBody {
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {NgModule} from '@angular/core';
10+
import {MatScrollableTableBody} from './scrollable-table-body-layout';
11+
12+
export {MatScrollableTableBody};
13+
14+
const EXPORTED_DECLARATIONS = [
15+
MatScrollableTableBody,
16+
];
17+
18+
@NgModule({
19+
exports: EXPORTED_DECLARATIONS,
20+
declarations: EXPORTED_DECLARATIONS,
21+
})
22+
export class MatScrollableTableBodyModule { }

0 commit comments

Comments
 (0)