Skip to content

Commit 9e8ac75

Browse files
committed
Merge branch 'breaking-changes' of https://github.com/IBM/carbon-components-angular into bannerToNotification
2 parents 4ba0eb6 + 2c9ce61 commit 9e8ac75

26 files changed

+593
-1474
lines changed

package-lock.json

Lines changed: 351 additions & 511 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/button-menu/button-menu-item.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ButtonMenuTestComponent {
2121
}
2222
}
2323

24-
describe("Button Menu", () => {
24+
xdescribe("Button Menu", () => {
2525
let fixture: ComponentFixture<ButtonMenuTestComponent>;
2626
let component: ButtonMenuTestComponent;
2727

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import {
22
Component,
33
OnInit,
4-
Injector,
54
ViewContainerRef,
65
ViewChild
76
} from "@angular/core";
8-
import { DialogPlaceholderService } from "./dialog-placeholder.service";
7+
import { PlaceholderService } from "./../placeholder/placeholder.module";
98

109
/**
10+
* Deprecated as of v2.0, will be removed with v3.0
1111
* Using a dialog (popover, tooltip, etc) with appendToBody="true" in your application
1212
* requires *this* component (`n-dialog-placeholder`).
1313
* It would generally be placed near the end of your app component template
@@ -26,9 +26,7 @@ import { DialogPlaceholderService } from "./dialog-placeholder.service";
2626
* <ibm-dialog-placeholder></ibm-dialog-placeholder>
2727
* ```
2828
*
29-
* @export
30-
* @class DialogPlaceholderComponent
31-
* @implements {OnInit}
29+
* @deprecated
3230
*/
3331
@Component({
3432
selector: "ibm-dialog-placeholder",
@@ -37,23 +35,19 @@ import { DialogPlaceholderService } from "./dialog-placeholder.service";
3735
export class DialogPlaceholderComponent implements OnInit {
3836
/**
3937
* Maintains a reference to the view DOM element of the `DialogPlaceholderComponent`.
40-
* @type {ViewContainerRef}
41-
* @memberof DialogPlaceholderComponent
4238
*/
4339
@ViewChild("dialogPlaceholder", { read: ViewContainerRef }) viewContainerRef: ViewContainerRef;
4440

4541
/**
4642
* Creates an instance of `DialogPlaceholderComponent`.
47-
* @param {DialogPlaceholderService} dialogPlaceholderService
48-
* @memberof DialogPlaceholderComponent
4943
*/
50-
constructor(public dialogPlaceholderService: DialogPlaceholderService) { }
44+
constructor(public placeholderService: PlaceholderService) { }
5145

5246
/**
53-
* Initializes the component using `ModalService`.
54-
* @memberof DialogPlaceholderComponent
47+
* Initializes the component using `PlaceholderService`.
5548
*/
56-
ngOnInit(): void {
57-
this.dialogPlaceholderService.registerViewContainerRef(this.viewContainerRef);
49+
ngOnInit() {
50+
console.warn("`ibm-dialog-placeholder` has been deprecated in favour of `ibm-placeholder`");
51+
this.placeholderService.registerViewContainerRef(this.viewContainerRef);
5852
}
5953
}

src/dialog/dialog-placeholder.service.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/dialog/dialog.module.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// modules
2-
import { NgModule, Optional, SkipSelf } from "@angular/core";
2+
import { NgModule } from "@angular/core";
33
import { CommonModule } from "@angular/common";
44
import { StaticIconModule } from "./../icon/static-icon.module";
55

66
// imports
77
import { DialogService } from "./dialog.service";
8-
import { DialogPlaceholderService } from "./dialog-placeholder.service";
98
import { Dialog } from "./dialog.component";
109
import { DialogDirective } from "./dialog.directive";
1110
import { DialogPlaceholderComponent } from "./dialog-placeholder.component";
@@ -19,10 +18,10 @@ import { OverflowMenuPane } from "./overflow-menu/overflow-menu-pane.component";
1918
import { OverflowMenuDirective } from "./overflow-menu/overflow-menu.directive";
2019
import { OverflowMenuOption } from "./overflow-menu/overflow-menu-option.component";
2120
import { I18nModule } from "./../i18n/i18n.module";
21+
import { PlaceholderModule } from "./../placeholder/placeholder.module";
2222

2323
// exports
2424
export { DialogService } from "./dialog.service";
25-
export { DialogPlaceholderService } from "./dialog-placeholder.service";
2625
export { Dialog } from "./dialog.component";
2726
export { DialogDirective } from "./dialog.directive";
2827
export { DialogPlaceholderComponent } from "./dialog-placeholder.component";
@@ -36,18 +35,6 @@ export { OverflowMenuPane } from "./overflow-menu/overflow-menu-pane.component";
3635
export { OverflowMenuDirective } from "./overflow-menu/overflow-menu.directive";
3736
export { OverflowMenuOption } from "./overflow-menu/overflow-menu-option.component";
3837

39-
// either provides a new instance of DialogPlaceholderService, or returns the parent
40-
export function DIALOG_PLACEHOLDER_SERVICE_PROVIDER_FACTORY(parentService: DialogPlaceholderService) {
41-
return parentService || new DialogPlaceholderService();
42-
}
43-
44-
// placholder service *must* be a singleton to ensure the placeholder viewref is accessible globally
45-
export const DIALOG_PLACEHOLDER_SERVICE_PROVIDER = {
46-
provide: DialogPlaceholderService,
47-
deps: [[new Optional(), new SkipSelf(), DialogPlaceholderService]],
48-
useFactory: DIALOG_PLACEHOLDER_SERVICE_PROVIDER_FACTORY
49-
};
50-
5138
@NgModule({
5239
declarations: [
5340
Dialog,
@@ -73,15 +60,17 @@ export const DIALOG_PLACEHOLDER_SERVICE_PROVIDER = {
7360
OverflowMenuOption,
7461
DialogPlaceholderComponent
7562
],
76-
providers: [
77-
DialogService,
78-
DIALOG_PLACEHOLDER_SERVICE_PROVIDER
79-
],
63+
providers: [ DialogService ],
8064
entryComponents: [
8165
Dialog,
8266
Tooltip,
8367
OverflowMenuPane
8468
],
85-
imports: [CommonModule, StaticIconModule, I18nModule]
69+
imports: [
70+
CommonModule,
71+
StaticIconModule,
72+
I18nModule,
73+
PlaceholderModule
74+
]
8675
})
8776
export class DialogModule {}

src/dialog/dialog.service.ts

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from "@angular/core";
1010
import { Subscription } from "rxjs";
1111
import { DialogConfig } from "./dialog-config.interface";
12-
import { DialogPlaceholderService } from "./dialog-placeholder.service";
12+
import { PlaceholderService } from "./../placeholder/placeholder.module";
1313

1414
/**
1515
* `Dialog` object to be injected into other components.
@@ -67,7 +67,7 @@ export class DialogService {
6767
constructor(
6868
protected componentFactoryResolver: ComponentFactoryResolver,
6969
protected injector: Injector,
70-
protected dialogPlaceholderService: DialogPlaceholderService
70+
protected placeholderService: PlaceholderService
7171
) {}
7272

7373
/**
@@ -103,21 +103,13 @@ export class DialogService {
103103
*/
104104
open(viewContainer: ViewContainerRef, dialogConfig: DialogConfig) {
105105
if (!this.dialogRef) {
106-
// holder for either the provided view, or the view from DialogPlaceholderService
107-
let view = viewContainer;
108-
if (dialogConfig.appendToBody && this.dialogPlaceholderService.viewContainerRef) {
109-
view = this.dialogPlaceholderService.viewContainerRef;
110-
// add our component to the view
111-
this.dialogRef = view.createComponent(this.componentFactory, 0, this.injector);
112-
} else if (dialogConfig.appendToBody && !this.dialogPlaceholderService.viewContainerRef) {
113-
// fallback to the old insertion method if the viewref doesn't exist
114-
this.dialogRef = view.createComponent(this.componentFactory, 0, this.injector);
115-
setTimeout(() => {
116-
window.document.querySelector("body").appendChild(this.dialogRef.location.nativeElement);
117-
});
106+
// holder for either the provided view, or the view from Placeholder
107+
if (dialogConfig.appendToBody) {
108+
// add our component to the placeholder
109+
this.dialogRef = this.placeholderService.createComponent(this.componentFactory, this.injector);
118110
} else {
119111
// add our component to the view
120-
this.dialogRef = view.createComponent(this.componentFactory, 0, this.injector);
112+
this.dialogRef = viewContainer.createComponent(this.componentFactory, 0, this.injector);
121113
}
122114

123115
// initialize some extra options
@@ -128,7 +120,7 @@ export class DialogService {
128120
this.isOpen = true;
129121

130122
this.dialogSubscription = this.onClose.subscribe(() => {
131-
this.close(view);
123+
this.close(viewContainer);
132124
});
133125

134126
this.dialogRef.instance.elementRef.nativeElement.focus();
@@ -148,9 +140,8 @@ export class DialogService {
148140

149141
if (this.dialogRef) {
150142
let elementToFocus = this.dialogRef.instance.dialogConfig["previouslyFocusedElement"];
151-
if (this.dialogRef.instance.dialogConfig.appendToBody && this.dialogPlaceholderService.viewContainerRef) {
152-
const vcRef = this.dialogPlaceholderService.viewContainerRef;
153-
vcRef.remove(vcRef.indexOf(this.dialogRef.hostView));
143+
if (this.dialogRef.instance.dialogConfig.appendToBody) {
144+
this.placeholderService.destroyComponent(this.dialogRef);
154145
} else {
155146
viewContainer.remove(viewContainer.indexOf(this.dialogRef.hostView));
156147
}

src/dialog/popover/popover-menu.component.ts

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)