Skip to content

Commit

Permalink
chore(module:tooltip,popover,popconfirm): remove component API (#4390)
Browse files Browse the repository at this point in the history
* chore(module:tooltip): remove deprecated API

* fix(module:tooltip): fix lifecycle and remove redundant calls

* docs: remove internal using of old API

* refactor(module:tooltip): flatten base folder

* docs: change deprecation warning

* chore: fix deprecation version

* fix: test

BREAKING CHANGE: `<nz-tooltip>` `<nz-popover>` `<nz-popconfirm>` components has been removed, use its directives instead.
  • Loading branch information
Wendell authored and hsuanxyz committed Nov 22, 2019
1 parent 313f7b8 commit f82e8a6
Show file tree
Hide file tree
Showing 17 changed files with 443 additions and 931 deletions.
2 changes: 1 addition & 1 deletion components/input/demo/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Component, ElementRef, ViewChild, ViewEncapsulation } from '@angular/co
style="width: 120px"
nz-input
nz-tooltip
nzTrigger="focus"
nzTooltipTrigger="focus"
nzPlacement="topLeft"
nzOverlayClassName="numeric-input"
[ngModel]="value"
Expand Down
45 changes: 23 additions & 22 deletions components/popconfirm/nz-popconfirm.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
EventEmitter,
Host,
Input,
OnDestroy,
Optional,
Output,
TemplateRef,
ViewEncapsulation
} from '@angular/core';

import { zoomBigMotion, InputBoolean, NzNoAnimationDirective } from 'ng-zorro-antd/core';
import { NzTooltipBaseComponentLegacy, NzTooltipTrigger, NzToolTipComponent } from 'ng-zorro-antd/tooltip';
import { zoomBigMotion, NzNoAnimationDirective } from 'ng-zorro-antd/core';
import { NzTooltipTrigger, NzToolTipComponent } from 'ng-zorro-antd/tooltip';
import { Subject } from 'rxjs';

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
Expand All @@ -30,12 +29,6 @@ import { NzTooltipBaseComponentLegacy, NzTooltipTrigger, NzToolTipComponent } fr
preserveWhitespaces: false,
animations: [zoomBigMotion],
templateUrl: './nz-popconfirm.component.html',
providers: [
{
provide: NzTooltipBaseComponentLegacy,
useExisting: NzPopconfirmComponent
}
],
styles: [
`
.ant-popover {
Expand All @@ -44,24 +37,32 @@ import { NzTooltipBaseComponentLegacy, NzTooltipTrigger, NzToolTipComponent } fr
`
]
})
export class NzPopconfirmComponent extends NzToolTipComponent {
@Input() nzOkText: string;
@Input() nzOkType: string = 'primary';
@Input() nzCancelText: string;
@Input() @InputBoolean() nzCondition = false;
@Input() nzIcon: string | TemplateRef<void>;
export class NzPopconfirmComponent extends NzToolTipComponent implements OnDestroy {
nzCancelText: string;
nzCondition = false;
nzIcon: string | TemplateRef<void>;
nzOkText: string;
nzOkType: string = 'primary';

readonly nzOnCancel = new Subject<void>();
readonly nzOnConfirm = new Subject<void>();

@Output() readonly nzOnCancel: EventEmitter<void> = new EventEmitter();
@Output() readonly nzOnConfirm: EventEmitter<void> = new EventEmitter();
protected _trigger: NzTooltipTrigger = 'click';

_prefix = 'ant-popover-placement';
_trigger: NzTooltipTrigger = 'click';
_hasBackdrop = true;

constructor(cdr: ChangeDetectorRef, @Host() @Optional() public noAnimation?: NzNoAnimationDirective) {
super(cdr, noAnimation);
}

ngOnDestroy(): void {
super.ngOnDestroy();

this.nzOnCancel.complete();
this.nzOnConfirm.complete();
}

show(): void {
if (!this.nzCondition) {
super.show();
Expand All @@ -71,12 +72,12 @@ export class NzPopconfirmComponent extends NzToolTipComponent {
}

onCancel(): void {
this.nzOnCancel.emit();
this.nzOnCancel.next();
super.hide();
}

onConfirm(): void {
this.nzOnConfirm.emit();
this.nzOnConfirm.next();
super.hide();
}
}
15 changes: 7 additions & 8 deletions components/popconfirm/nz-popconfirm.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ export class NzPopconfirmDirective extends NzTooltipBaseDirective implements OnI
@Input() @InputBoolean() nzCondition: boolean;

/**
* @deprecated 9.0.0. This is deprecated and going to be removed in 9.0.0.
* @deprecated 10.0.0. This is deprecated and going to be removed in 10.0.0.
* Please use a more specific API. Like `nzTooltipTrigger`.
*/
@Input() nzTrigger: NzTooltipTrigger = 'click';

@Output() readonly nzOnCancel = new EventEmitter<void>();
@Output() readonly nzOnConfirm = new EventEmitter<void>();

componentFactory: ComponentFactory<NzPopconfirmComponent> = this.resolver.resolveComponentFactory(
protected readonly componentFactory: ComponentFactory<NzPopconfirmComponent> = this.resolver.resolveComponentFactory(
NzPopconfirmComponent
);

protected needProxyProperties = [
protected readonly needProxyProperties = [
'nzOverlayClassName',
'nzOverlayStyle',
'nzMouseEnterDelay',
Expand All @@ -78,17 +78,16 @@ export class NzPopconfirmDirective extends NzTooltipBaseDirective implements OnI
hostView: ViewContainerRef,
resolver: ComponentFactoryResolver,
renderer: Renderer2,
@Optional() tooltip: NzPopconfirmComponent,
@Host() @Optional() public noAnimation?: NzNoAnimationDirective
@Host() @Optional() noAnimation?: NzNoAnimationDirective
) {
super(elementRef, hostView, resolver, renderer, tooltip, noAnimation);
super(elementRef, hostView, resolver, renderer, noAnimation);
}

/**
* @override
*/
protected createDynamicTooltipComponent(): void {
super.createDynamicTooltipComponent();
protected createTooltipComponent(): void {
super.createTooltipComponent();

(this.tooltip as NzPopconfirmComponent).nzOnCancel.pipe(takeUntil(this.$destroy)).subscribe(() => {
this.nzOnCancel.emit();
Expand Down
Loading

0 comments on commit f82e8a6

Please sign in to comment.