Skip to content

Commit

Permalink
refactor(module:tooltip, popover, popconfirm): change deprecated APIs…
Browse files Browse the repository at this point in the history
… for v10 (#5817)

BREAKING CHANGES:

- nz-tooltip
  * `[nzOverlayStyle]` has been removed, use `[nzTooltipOverlayStyle]` instead.
  * `[nzOverlayClassName]` has been removed, use `[nzTooltipOverlayClassName]` instead.
  * `[nzMouseLeaveDelay]` has been removed, use `[nzTooltipMouseLeaveDelay]` instead.
  * `[nzMouseEnterDelay]` has been removed, use `[nzTooltipMouseEnterDelay]` instead.
  * `(nzVisibleChange)` has been removed, use `(nzTooltipVisibleChange)` instead.
- nz-popover
  * `[nzOverlayStyle]` has been removed, use `[nzPopoverOverlayStyle]` instead.
  * `[nzOverlayClassName]` has been removed, use `[nzPopoverOverlayClassName]` instead.
  * `[nzMouseLeaveDelay]` has been removed, use `[nzPopoverMouseLeaveDelay]` instead.
  * `[nzMouseEnterDelay]` has been removed, use `[nzPopoverMouseEnterDelay]` instead.
  * `(nzVisibleChange)` has been removed, use `(nzPopoverVisibleChange)` instead.
- nz-popconfirm
  * `[nzOverlayStyle]` has been removed, use `[nzPopconfirmOverlayStyle]` instead.
  * `[nzOverlayClassName]` has been removed, use `[nzPopconfirmOverlayClassName]` instead.
  * `[nzMouseLeaveDelay]` has been removed, use `[nzPopconfirmMouseLeaveDelay]` instead.
  * `[nzMouseEnterDelay]` has been removed, use `[nzPopconfirmMouseEnterDelay]` instead.
  * `(nzVisibleChange)` has been removed, use `(nzPopconfirmVisibleChange)` instead.
  • Loading branch information
hsuanxyz authored Sep 22, 2020
1 parent 31ca2da commit dc3088c
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 91 deletions.
8 changes: 4 additions & 4 deletions components/popconfirm/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import { NzPopconfirmModule } from 'ng-zorro-antd/popconfirm';
| `[nzPopconfirmOrigin]` | 确认框定位元素 | `ElementRef` | - |
| `[nzPopconfirmVisible]` | 显示隐藏确认框 | `boolean` | `false` |
| `(nzPopconfirmVisibleChange)` | 显示隐藏的事件 | `EventEmitter<boolean>` | - |
| `[nzPopoverMouseEnterDelay]` | 鼠标移入后延时多少才显示确认框,单位:秒 | `number` | `0.15` |
| `[nzPopoverMouseLeaveDelay]` | 鼠标移出后延时多少才隐藏确认框,单位:秒 | `number` | `0.1` |
| `[nzPopoverOverlayClassName]` | 卡片类名 | `string` | - |
| `[nzPopoverOverlayStyle]` | 卡片样式 | `object` | - |
| `[nzPopconfirmMouseEnterDelay]` | 鼠标移入后延时多少才显示确认框,单位:秒 | `number` | `0.15` |
| `[nzPopconfirmMouseLeaveDelay]` | 鼠标移出后延时多少才隐藏确认框,单位:秒 | `number` | `0.1` |
| `[nzPopconfirmOverlayClassName]` | 卡片类名 | `string` | - |
| `[nzPopconfirmOverlayStyle]` | 卡片样式 | `object` | - |

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
Expand Down
18 changes: 4 additions & 14 deletions components/tooltip/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ import {
Directive,
ElementRef,
EventEmitter,
Input,
OnChanges,
OnDestroy,
Output,
Renderer2,
SimpleChanges,
TemplateRef,
Expand Down Expand Up @@ -47,13 +45,6 @@ export abstract class NzTooltipBaseDirective implements OnChanges, OnDestroy, Af
specificOverlayStyle?: NgStyleInterface;
specificVisibleChange = new EventEmitter<boolean>();

@Input() nzMouseEnterDelay?: number;
@Input() nzMouseLeaveDelay?: number;
@Input() nzOverlayClassName?: string;
@Input() nzOverlayStyle?: NgStyleInterface;

@Output() readonly nzVisibleChange = new EventEmitter<boolean>();

/**
* For create tooltip dynamically. This should be override for each different component.
*/
Expand Down Expand Up @@ -83,19 +74,19 @@ export abstract class NzTooltipBaseDirective implements OnChanges, OnDestroy, Af
}

protected get mouseEnterDelay(): number {
return this.specificMouseEnterDelay || this.nzMouseEnterDelay || 0.15;
return this.specificMouseEnterDelay || 0.15;
}

protected get mouseLeaveDelay(): number {
return this.specificMouseLeaveDelay || this.nzMouseLeaveDelay || 0.1;
return this.specificMouseLeaveDelay || 0.1;
}

protected get overlayClassName(): string | null {
return this.specificOverlayClassName || this.nzOverlayClassName || null;
return this.specificOverlayClassName || null;
}

protected get overlayStyle(): NgStyleInterface | null {
return this.specificOverlayStyle || this.nzOverlayStyle || null;
return this.specificOverlayStyle || null;
}

visible = false;
Expand Down Expand Up @@ -176,7 +167,6 @@ export abstract class NzTooltipBaseDirective implements OnChanges, OnDestroy, Af
this.component.nzVisibleChange.pipe(distinctUntilChanged(), takeUntil(this.destroy$)).subscribe((visible: boolean) => {
this.visible = visible;
this.specificVisibleChange.emit(visible);
this.nzVisibleChange.emit(visible);
});
}

Expand Down
240 changes: 167 additions & 73 deletions schematics/ng-update/data/input-names.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,93 @@
import { InputNameUpgradeData, TargetVersion, VersionChanges } from '@angular/cdk/schematics';

const tooltipPrefix = [
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/3909',
changes: [
{
replace : 'nzTitle',
replaceWith: 'nzPopconfirmTitle',
whitelist : {
attributes: ['nz-popconfirm']
}
},
{
replace : 'nzTrigger',
replaceWith: 'nzPopconfirmTrigger',
whitelist : {
attributes: ['nz-popconfirm']
}
},
{
replace : 'nzPlacement',
replaceWith: 'nzPopconfirmPlacement',
whitelist : {
attributes: ['nz-popconfirm']
}
}
]
},
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/3909',
changes: [
{
replace : 'nzTitle',
replaceWith: 'nzTooltipTitle',
whitelist : {
attributes: ['nz-tooltip']
}
},
{
replace : 'nzTrigger',
replaceWith: 'nzTooltipTrigger',
whitelist : {
attributes: ['nz-tooltip']
}
},
{
replace : 'nzPlacement',
replaceWith: 'nzTooltipPlacement',
whitelist : {
attributes: ['nz-tooltip']
}
}
]
},
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/3909',
changes: [
{
replace : 'nzTitle',
replaceWith: 'nzPopoverTitle',
whitelist : {
attributes: ['nz-popover']
}
},
{
replace : 'nzTrigger',
replaceWith: 'nzPopoverTrigger',
whitelist : {
attributes: ['nz-popover']
}
},
{
replace : 'nzPlacement',
replaceWith: 'nzPopoverPlacement',
whitelist : {
attributes: ['nz-popover']
}
},
{
replace : 'nzContent',
replaceWith: 'nzPopoverContent',
whitelist : {
attributes: ['nz-popover']
}
}
]
}
]

export const inputNames: VersionChanges<InputNameUpgradeData> = {
[ TargetVersion.V7 ]: [
{
Expand All @@ -16,136 +104,142 @@ export const inputNames: VersionChanges<InputNameUpgradeData> = {
}
],
[ TargetVersion.V10 ]: [
...tooltipPrefix,
{
pr: 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/5776',
pr: 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/5817',
changes: [
{
replace : 'nzTarget',
replaceWith: 'nzContainer',
replace : 'nzOverlayStyle',
replaceWith: 'nzTooltipOverlayStyle',
whitelist : {
elements: [ 'nz-anchor' ]
attributes: [ 'nz-tooltip' ]
}
}
]
},
{
pr: 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/5792',
changes: [
},
{
replace : 'nzSort',
replaceWith: 'nzSortOrder',
replace : 'nzOverlayStyle',
replaceWith: 'nzPopoverOverlayStyle',
whitelist : {
elements: [ 'th' ]
attributes: [ 'nz-popover' ]
}
}
]
},
{
pr: 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/5793',
changes: [
},
{
replace : 'nzClassName',
replaceWith: 'ngClass',
replace : 'nzOverlayStyle',
replaceWith: 'nzPopconfirmOverlayStyle',
whitelist : {
elements: [ 'nz-date-picker', 'nz-week-picker', 'nz-month-picker', 'nz-year-picker', 'nz-range-picker' ]
attributes: [ 'nz-popconfirm' ]
}
},
{
replace : 'nzStyle',
replaceWith: 'ngStyle',
replace : 'nzOverlayClassName',
replaceWith: 'nzTooltipOverlayClassName',
whitelist : {
elements: [ 'nz-date-picker', 'nz-week-picker', 'nz-month-picker', 'nz-year-picker', 'nz-range-picker' ]
attributes: [ 'nz-tooltip' ]
}
}
]
}
],
[ TargetVersion.V9 ]: [
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/3909',
changes: [
},
{
replace : 'nzTitle',
replaceWith: 'nzPopconfirmTitle',
replace : 'nzOverlayClassName',
replaceWith: 'nzPopoverOverlayClassName',
whitelist : {
attributes: ['nz-popconfirm']
attributes: [ 'nz-popover' ]
}
},
{
replace : 'nzTrigger',
replaceWith: 'nzPopconfirmTrigger',
replace : 'nzOverlayClassName',
replaceWith: 'nzPopconfirmOverlayClassName',
whitelist : {
attributes: ['nz-popconfirm']
attributes: [ 'nz-popconfirm' ]
}
},
{
replace : 'nzPlacement',
replaceWith: 'nzPopconfirmPlacement',
replace : 'nzMouseLeaveDelay',
replaceWith: 'nzTooltipMouseLeaveDelay',
whitelist : {
attributes: ['nz-popconfirm']
attributes: [ 'nz-tooltip' ]
}
}
]
},
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/3909',
changes: [
},
{
replace : 'nzTitle',
replaceWith: 'nzTooltipTitle',
replace : 'nzMouseLeaveDelay',
replaceWith: 'nzPopoverMouseLeaveDelay',
whitelist : {
attributes: ['nz-tooltip']
attributes: [ 'nz-popover' ]
}
},
{
replace : 'nzTrigger',
replaceWith: 'nzTooltipTrigger',
replace : 'nzMouseLeaveDelay',
replaceWith: 'nzPopconfirmMouseLeaveDelay',
whitelist : {
attributes: ['nz-tooltip']
attributes: [ 'nz-popconfirm' ]
}
},
{
replace : 'nzPlacement',
replaceWith: 'nzTooltipPlacement',
replace : 'nzMouseEnterDelay',
replaceWith: 'nzTooltipMouseEnterDelay',
whitelist : {
attributes: ['nz-tooltip']
attributes: [ 'nz-tooltip' ]
}
},
{
replace : 'nzMouseEnterDelay',
replaceWith: 'nzPopoverMouseEnterDelay',
whitelist : {
attributes: [ 'nz-popover' ]
}
},
{
replace : 'nzMouseEnterDelay',
replaceWith: 'nzPopconfirmMouseEnterDelay',
whitelist : {
attributes: [ 'nz-popconfirm' ]
}
}
]
},
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/3909',
pr: 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/5776',
changes: [
{
replace : 'nzTitle',
replaceWith: 'nzPopoverTitle',
replace : 'nzTarget',
replaceWith: 'nzContainer',
whitelist : {
attributes: ['nz-popover']
elements: [ 'nz-anchor' ]
}
},
}
]
},
{
pr: 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/5792',
changes: [
{
replace : 'nzTrigger',
replaceWith: 'nzPopoverTrigger',
replace : 'nzSort',
replaceWith: 'nzSortOrder',
whitelist : {
attributes: ['nz-popover']
elements: [ 'th' ]
}
},
}
]
},
{
pr: 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/5793',
changes: [
{
replace : 'nzPlacement',
replaceWith: 'nzPopoverPlacement',
replace : 'nzClassName',
replaceWith: 'ngClass',
whitelist : {
attributes: ['nz-popover']
elements: [ 'nz-date-picker', 'nz-week-picker', 'nz-month-picker', 'nz-year-picker', 'nz-range-picker' ]
}
},
{
replace : 'nzContent',
replaceWith: 'nzPopoverContent',
replace : 'nzStyle',
replaceWith: 'ngStyle',
whitelist : {
attributes: ['nz-popover']
elements: [ 'nz-date-picker', 'nz-week-picker', 'nz-month-picker', 'nz-year-picker', 'nz-range-picker' ]
}
}
]
},
}
],
[ TargetVersion.V9 ]: [
...tooltipPrefix,
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/4601',
changes: [
Expand Down
Loading

0 comments on commit dc3088c

Please sign in to comment.