Skip to content

Commit f08b3f0

Browse files
jelbournmmalerba
authored andcommitted
fix: consistent names for all cdk directives (#8088)
Renames: `OverlayOrigin` -> `CdkOverlayOrigin` `ConnectedOverlayDirective` -> `CdkConnectedOverlay` `PortalDirective` -> `CdkPortal` `PortalHostDirective` -> `CdkPortalOutlet` `ObserveContent` -> `CdkObserveContent` Also stop using "mat" completely in the cdk. BREAKING CHANGE: `MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY` is renamed to `CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY`
1 parent cd05b54 commit f08b3f0

22 files changed

+85
-76
lines changed

src/cdk/bidi/directionality.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export type Direction = 'ltr' | 'rtl';
2929
* We also can't re-provide the DOCUMENT token from platform-brower because the unit tests
3030
* themselves use things like `querySelector` in test code.
3131
*/
32-
export const DIR_DOCUMENT = new InjectionToken<Document>('mat-dir-doc');
32+
export const DIR_DOCUMENT = new InjectionToken<Document>('cdk-dir-doc');
3333

3434
/**
3535
* The directionality (LTR / RTL) context for the application (or a subtree of it).

src/cdk/observers/observe-content.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Component} from '@angular/core';
22
import {async, TestBed, ComponentFixture, fakeAsync, tick} from '@angular/core/testing';
3-
import {ObserversModule, MatMutationObserverFactory} from './observe-content';
3+
import {ObserversModule, MutationObserverFactory} from './observe-content';
44

55
// TODO(elad): `ProxyZone` doesn't seem to capture the events raised by
66
// `MutationObserver` and needs to be investigated
@@ -61,7 +61,7 @@ describe('Observe content', () => {
6161
imports: [ObserversModule],
6262
declarations: [ComponentWithDebouncedListener],
6363
providers: [{
64-
provide: MatMutationObserverFactory,
64+
provide: MutationObserverFactory,
6565
useValue: {
6666
create: function(callback: Function) {
6767
callbacks.push(callback);

src/cdk/observers/observe-content.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {debounceTime} from 'rxjs/operators';
2626
* @docs-private
2727
*/
2828
@Injectable()
29-
export class MatMutationObserverFactory {
29+
export class MutationObserverFactory {
3030
create(callback: MutationCallback): MutationObserver | null {
3131
return typeof MutationObserver === 'undefined' ? null : new MutationObserver(callback);
3232
}
@@ -40,7 +40,7 @@ export class MatMutationObserverFactory {
4040
selector: '[cdkObserveContent]',
4141
exportAs: 'cdkObserveContent',
4242
})
43-
export class ObserveContent implements AfterContentInit, OnDestroy {
43+
export class CdkObserveContent implements AfterContentInit, OnDestroy {
4444
private _observer: MutationObserver | null;
4545

4646
/** Event emitted for each change in the element's content. */
@@ -53,7 +53,7 @@ export class ObserveContent implements AfterContentInit, OnDestroy {
5353
@Input() debounce: number;
5454

5555
constructor(
56-
private _mutationObserverFactory: MatMutationObserverFactory,
56+
private _mutationObserverFactory: MutationObserverFactory,
5757
private _elementRef: ElementRef,
5858
private _ngZone: NgZone) { }
5959

@@ -93,8 +93,8 @@ export class ObserveContent implements AfterContentInit, OnDestroy {
9393

9494

9595
@NgModule({
96-
exports: [ObserveContent],
97-
declarations: [ObserveContent],
98-
providers: [MatMutationObserverFactory]
96+
exports: [CdkObserveContent],
97+
declarations: [CdkObserveContent],
98+
providers: [MutationObserverFactory]
9999
})
100100
export class ObserversModule {}

src/cdk/observers/public-api.ts

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

99
export * from './observe-content';
10+
11+
/** @deprecated Use CdkObserveContent */
12+
export {CdkObserveContent as ObserveContent} from './observe-content';

src/cdk/overlay/overlay-container.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {async, inject, TestBed} from '@angular/core/testing';
22
import {Component, NgModule, ViewChild, ViewContainerRef} from '@angular/core';
3-
import {PortalModule, TemplatePortalDirective} from '@angular/cdk/portal';
3+
import {PortalModule, CdkPortal} from '@angular/cdk/portal';
44
import {Overlay, OverlayContainer, OverlayModule} from './index';
55

66
describe('OverlayContainer', () => {
@@ -68,7 +68,7 @@ describe('OverlayContainer', () => {
6868
providers: [Overlay],
6969
})
7070
class TestComponentWithTemplatePortals {
71-
@ViewChild(TemplatePortalDirective) templatePortal: TemplatePortalDirective;
71+
@ViewChild(CdkPortal) templatePortal: CdkPortal;
7272

7373
constructor(public viewContainerRef: ViewContainerRef) { }
7474
}

src/cdk/overlay/overlay-directives.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {ComponentFixture, TestBed, async, inject} from '@angular/core/testing';
44
import {Directionality} from '@angular/cdk/bidi';
55
import {dispatchKeyboardEvent} from '@angular/cdk/testing';
66
import {ESCAPE} from '@angular/cdk/keycodes';
7-
import {ConnectedOverlayDirective, OverlayModule, OverlayOrigin} from './index';
7+
import {CdkConnectedOverlay, OverlayModule, CdkOverlayOrigin} from './index';
88
import {OverlayContainer} from './overlay-container';
99
import {ConnectedPositionStrategy} from './position/connected-position-strategy';
1010
import {ConnectedOverlayPositionChange} from './position/connected-position';
@@ -330,7 +330,7 @@ class ConnectedOverlayDirectiveTest {
330330
detachHandler = jasmine.createSpy('detachHandler');
331331
attachResult: HTMLElement;
332332

333-
@ViewChild(ConnectedOverlayDirective) connectedOverlayDirective: ConnectedOverlayDirective;
333+
@ViewChild(CdkConnectedOverlay) connectedOverlayDirective: CdkConnectedOverlay;
334334
}
335335

336336
@Component({
@@ -339,7 +339,7 @@ class ConnectedOverlayDirectiveTest {
339339
<ng-template cdk-connected-overlay>Menu content</ng-template>`,
340340
})
341341
class ConnectedOverlayPropertyInitOrder {
342-
@ViewChild(ConnectedOverlayDirective) connectedOverlayDirective: ConnectedOverlayDirective;
343-
@ViewChild('trigger') trigger: OverlayOrigin;
342+
@ViewChild(CdkConnectedOverlay) connectedOverlayDirective: CdkConnectedOverlay;
343+
@ViewChild('trigger') trigger: CdkOverlayOrigin;
344344
}
345345

src/cdk/overlay/overlay-directives.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,23 @@ const defaultPositionList = [
5252
];
5353

5454
/** Injection token that determines the scroll handling while the connected overlay is open. */
55-
export const MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY =
56-
new InjectionToken<() => ScrollStrategy>('mat-connected-overlay-scroll-strategy');
55+
export const CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY =
56+
new InjectionToken<() => ScrollStrategy>('cdk-connected-overlay-scroll-strategy');
5757

5858
/** @docs-private */
59-
export function MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay):
59+
export function CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay):
6060
() => RepositionScrollStrategy {
6161
return () => overlay.scrollStrategies.reposition();
6262
}
6363

6464
/** @docs-private */
65-
export const MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER = {
66-
provide: MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY,
65+
export const CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER = {
66+
provide: CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY,
6767
deps: [Overlay],
68-
useFactory: MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY,
68+
useFactory: CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY,
6969
};
7070

7171

72-
7372
/**
7473
* Directive applied to an element to make it usable as an origin for an Overlay using a
7574
* ConnectedPositionStrategy.
@@ -78,22 +77,21 @@ export const MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER = {
7877
selector: '[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]',
7978
exportAs: 'cdkOverlayOrigin',
8079
})
81-
export class OverlayOrigin {
80+
export class CdkOverlayOrigin {
8281
constructor(
8382
/** Reference to the element on which the directive is applied. */
8483
public elementRef: ElementRef) { }
8584
}
8685

8786

88-
8987
/**
9088
* Directive to facilitate declarative creation of an Overlay using a ConnectedPositionStrategy.
9189
*/
9290
@Directive({
9391
selector: '[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]',
9492
exportAs: 'cdkConnectedOverlay'
9593
})
96-
export class ConnectedOverlayDirective implements OnDestroy, OnChanges {
94+
export class CdkConnectedOverlay implements OnDestroy, OnChanges {
9795
private _overlayRef: OverlayRef;
9896
private _templatePortal: TemplatePortal<any>;
9997
private _hasBackdrop = false;
@@ -105,7 +103,7 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges {
105103
private _escapeListener = () => {};
106104

107105
/** Origin for the connected overlay. */
108-
@Input('cdkConnectedOverlayOrigin') origin: OverlayOrigin;
106+
@Input('cdkConnectedOverlayOrigin') origin: CdkOverlayOrigin;
109107

110108
/** Registered connected position pairs. */
111109
@Input('cdkConnectedOverlayPositions') positions: ConnectionPositionPair[];
@@ -159,8 +157,8 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges {
159157

160158
/** @deprecated */
161159
@Input('origin')
162-
get _deprecatedOrigin(): OverlayOrigin { return this.origin; }
163-
set _deprecatedOrigin(_origin: OverlayOrigin) { this.origin = _origin; }
160+
get _deprecatedOrigin(): CdkOverlayOrigin { return this.origin; }
161+
set _deprecatedOrigin(_origin: CdkOverlayOrigin) { this.origin = _origin; }
164162

165163
/** @deprecated */
166164
@Input('positions')
@@ -238,7 +236,7 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges {
238236
private _renderer: Renderer2,
239237
templateRef: TemplateRef<any>,
240238
viewContainerRef: ViewContainerRef,
241-
@Inject(MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY) private _scrollStrategy,
239+
@Inject(CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY) private _scrollStrategy,
242240
@Optional() private _dir: Directionality) {
243241
this._templatePortal = new TemplatePortal(templateRef, viewContainerRef);
244242
}

src/cdk/overlay/overlay-module.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import {NgModule, Provider} from '@angular/core';
1313
import {Overlay} from './overlay';
1414
import {OVERLAY_CONTAINER_PROVIDER} from './overlay-container';
1515
import {
16-
ConnectedOverlayDirective,
17-
MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER,
18-
OverlayOrigin,
16+
CdkConnectedOverlay,
17+
CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER,
18+
CdkOverlayOrigin,
1919
} from './overlay-directives';
2020
import {OverlayPositionBuilder} from './position/overlay-position-builder';
2121
import {OVERLAY_KEYBOARD_DISPATCHER_PROVIDER} from './keyboard/overlay-keyboard-dispatcher';
@@ -27,13 +27,13 @@ export const OVERLAY_PROVIDERS: Provider[] = [
2727
OVERLAY_KEYBOARD_DISPATCHER_PROVIDER,
2828
VIEWPORT_RULER_PROVIDER,
2929
OVERLAY_CONTAINER_PROVIDER,
30-
MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER,
30+
CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER,
3131
];
3232

3333
@NgModule({
3434
imports: [BidiModule, PortalModule, ScrollDispatchModule],
35-
exports: [ConnectedOverlayDirective, OverlayOrigin, ScrollDispatchModule],
36-
declarations: [ConnectedOverlayDirective, OverlayOrigin],
35+
exports: [CdkConnectedOverlay, CdkOverlayOrigin, ScrollDispatchModule],
36+
declarations: [CdkConnectedOverlay, CdkOverlayOrigin],
3737
providers: [OVERLAY_PROVIDERS, ScrollStrategyOptions],
3838
})
3939
export class OverlayModule {}

src/cdk/overlay/overlay.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
ComponentPortal,
55
PortalModule,
66
TemplatePortal,
7-
TemplatePortalDirective
7+
CdkPortal
88
} from '@angular/cdk/portal';
99
import {
1010
Overlay,
@@ -482,7 +482,7 @@ class PizzaMsg { }
482482
/** Test-bed component that contains a TempatePortal and an ElementRef. */
483483
@Component({template: `<ng-template cdk-portal>Cake</ng-template>`})
484484
class TestComponentWithTemplatePortals {
485-
@ViewChild(TemplatePortalDirective) templatePortal: TemplatePortalDirective;
485+
@ViewChild(CdkPortal) templatePortal: CdkPortal;
486486

487487
constructor(public viewContainerRef: ViewContainerRef) { }
488488
}

src/cdk/overlay/public-api.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,25 @@
77
*/
88

99
export * from './overlay-config';
10+
export * from './position/connected-position';
11+
export * from './scroll/index';
12+
export * from './overlay-module';
1013
export {Overlay} from './overlay';
1114
export {OverlayContainer} from './overlay-container';
15+
export {CdkOverlayOrigin, CdkConnectedOverlay} from './overlay-directives';
1216
export {FullscreenOverlayContainer} from './fullscreen-overlay-container';
1317
export {OverlayRef} from './overlay-ref';
14-
export {ConnectedOverlayDirective, OverlayOrigin} from './overlay-directives';
1518
export {ViewportRuler} from '@angular/cdk/scrolling';
1619
export {ComponentType} from '@angular/cdk/portal';
1720

18-
export * from './position/connected-position';
19-
export * from './scroll/index';
20-
export * from './overlay-module';
21-
2221
// Export pre-defined position strategies and interface to build custom ones.
2322
export {PositionStrategy} from './position/position-strategy';
2423
export {GlobalPositionStrategy} from './position/global-position-strategy';
2524
export {ConnectedPositionStrategy} from './position/connected-position-strategy';
2625
export {VIEWPORT_RULER_PROVIDER} from '@angular/cdk/scrolling';
26+
27+
/** @deprecated Use CdkConnectedOverlay */
28+
export {CdkConnectedOverlay as ConnectedOverlayDirective} from './overlay-directives';
29+
30+
/** @deprecated Use CdkOverlayOrigin */
31+
export {CdkOverlayOrigin as OverlayOrigin} from './overlay-directives';

src/cdk/portal/portal-directives.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {Portal, TemplatePortal, ComponentPortal, BasePortalOutlet} from './porta
2828
selector: '[cdk-portal], [cdkPortal], [portal]',
2929
exportAs: 'cdkPortal',
3030
})
31-
export class TemplatePortalDirective extends TemplatePortal<any> {
31+
export class CdkPortal extends TemplatePortal<any> {
3232
constructor(templateRef: TemplateRef<any>, viewContainerRef: ViewContainerRef) {
3333
super(templateRef, viewContainerRef);
3434
}
@@ -47,7 +47,7 @@ export class TemplatePortalDirective extends TemplatePortal<any> {
4747
exportAs: 'cdkPortalOutlet, cdkPortalHost',
4848
inputs: ['portal: cdkPortalOutlet']
4949
})
50-
export class PortalOutletDirective extends BasePortalOutlet implements OnDestroy {
50+
export class CdkPortalOutlet extends BasePortalOutlet implements OnDestroy {
5151
/** The attached portal. */
5252
private _portal: Portal<any> | null = null;
5353

@@ -134,7 +134,7 @@ export class PortalOutletDirective extends BasePortalOutlet implements OnDestroy
134134

135135

136136
@NgModule({
137-
exports: [TemplatePortalDirective, PortalOutletDirective],
138-
declarations: [TemplatePortalDirective, PortalOutletDirective],
137+
exports: [CdkPortal, CdkPortalOutlet],
138+
declarations: [CdkPortal, CdkPortalOutlet],
139139
})
140140
export class PortalModule {}

src/cdk/portal/portal.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ built upon.
2727

2828
#### Portals in practice
2929

30-
##### `TemplatePortalDirective`
31-
Used to get a portal from an `<ng-template>`. `TemplatePortalDirectives` *is* a `Portal`.
30+
##### `CdkPortal`
31+
Used to get a portal from an `<ng-template>`. `CdkPortal` *is* a `Portal`.
3232

3333
Usage:
3434
```html
@@ -45,7 +45,7 @@ Usage:
4545
```
4646

4747
A component can use `@ViewChild` or `@ViewChildren` to get a reference to a
48-
`TemplatePortalDirective`.
48+
`CdkPortal`.
4949

5050
##### `ComponentPortal`
5151
Used to create a portal from a component type. When a component is dynamically created using
@@ -57,8 +57,8 @@ this.userSettingsPortal = new ComponentPortal(UserSettingsComponent);
5757
```
5858

5959

60-
##### `PortalOutletDirective`
61-
Used to add a portal outlet to a template. `PortalOutletDirective` *is* a `PortalOutlet`.
60+
##### `CdkPortalOutlet`
61+
Used to add a portal outlet to a template. `CdkPortalOutlet` *is* a `PortalOutlet`.
6262

6363
Usage:
6464
```html

src/cdk/portal/portal.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
TemplateRef
1414
} from '@angular/core';
1515
import {CommonModule} from '@angular/common';
16-
import {TemplatePortalDirective, PortalOutletDirective, PortalModule} from './portal-directives';
16+
import {CdkPortal, CdkPortalOutlet, PortalModule} from './portal-directives';
1717
import {Portal, ComponentPortal, TemplatePortal} from './portal';
1818
import {DomPortalOutlet} from './dom-portal-outlet';
1919

@@ -28,7 +28,7 @@ describe('Portals', () => {
2828
TestBed.compileComponents();
2929
}));
3030

31-
describe('PortalOutletDirective', () => {
31+
describe('CdkPortalOutlet', () => {
3232
let fixture: ComponentFixture<PortalTestApp>;
3333

3434
beforeEach(() => {
@@ -480,8 +480,8 @@ class ArbitraryViewContainerRefComponent {
480480
`,
481481
})
482482
class PortalTestApp {
483-
@ViewChildren(TemplatePortalDirective) portals: QueryList<TemplatePortalDirective>;
484-
@ViewChild(PortalOutletDirective) portalOutlet: PortalOutletDirective;
483+
@ViewChildren(CdkPortal) portals: QueryList<CdkPortal>;
484+
@ViewChild(CdkPortalOutlet) portalOutlet: CdkPortalOutlet;
485485
@ViewChild('templateRef', { read: TemplateRef }) templateRef: TemplateRef<any>;
486486

487487
selectedPortal: Portal<any>;

src/cdk/portal/public-api.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ export * from './portal-directives';
1212
export * from './portal-injector';
1313

1414
export {DomPortalOutlet as DomPortalHost} from './dom-portal-outlet';
15-
export {PortalOutletDirective as PortalHostDirective} from './portal-directives';
15+
export {
16+
CdkPortalOutlet as PortalHostDirective,
17+
CdkPortal as TemplatePortalDirective,
18+
} from './portal-directives';
1619
export {PortalOutlet as PortalHost, BasePortalOutlet as BasePortalHost} from './portal';

src/cdk/stepper/stepper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ export class CdkStepper {
194194

195195
/** Returns a unique id for each step label element. */
196196
_getStepLabelId(i: number): string {
197-
return `mat-step-label-${this._groupId}-${i}`;
197+
return `cdk-step-label-${this._groupId}-${i}`;
198198
}
199199

200200
/** Returns unique id for each step content element. */
201201
_getStepContentId(i: number): string {
202-
return `mat-step-content-${this._groupId}-${i}`;
202+
return `cdk-step-content-${this._groupId}-${i}`;
203203
}
204204

205205
/** Marks the component to be change detected. */

0 commit comments

Comments
 (0)