Skip to content

Commit

Permalink
chore(module:tree, tree-select): remove deprecated API (#4601)
Browse files Browse the repository at this point in the history
* chore(module:tree, tree-select): remove deprecated API


BREAKING CHANGE:

* tree
 - Removed `[nzDefaultExpandAll]` use `[nzExpandAll]` instead.
 - Removed `[nzDefaultExpandedKeys]` use `[nzExpandedKeys]` instead.
 - Removed `[nzDefaultSelectedKeys]` use `[nzSelectedKeys]` instead.
 - Removed `[nzDefaultCheckedKeys]` use `[nzCheckedKeys]` instead.
 - Removed `(nzOnSearchNode)` use `(nzSearchValueChange)` instead.

* tree-select
 - Removed `[nzDefaultExpandedKeys]` use `[nzExpandedKeys]` instead.
  • Loading branch information
hsuanxyz authored and wenqi73 committed Jan 8, 2020
1 parent 3c5d24e commit 1ec18e4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 94 deletions.
12 changes: 0 additions & 12 deletions components/tree-select/nz-tree-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import {
NzTreeNode,
NzTreeNodeOptions,
slideMotion,
warnDeprecation,
WithConfig,
zoomMotion
} from 'ng-zorro-antd/core';
Expand Down Expand Up @@ -123,17 +122,6 @@ export class NzTreeSelectComponent extends NzTreeBase implements ControlValueAcc
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default') nzSize: NzSizeLDSType;
@Input() nzPlaceHolder = '';
@Input() nzDropdownStyle: { [key: string]: string };
/**
* @deprecated 9.0.0 - use `nzExpandedKeys` instead.
*/
@Input()
set nzDefaultExpandedKeys(value: string[]) {
warnDeprecation(`'nzDefaultExpandedKeys' would be removed in 9.0.0. Please use 'nzExpandedKeys' instead.`);
this.expandedKeys = value;
}
get nzDefaultExpandedKeys(): string[] {
return this.expandedKeys;
}

@Input()
set nzExpandedKeys(value: string[]) {
Expand Down
5 changes: 1 addition & 4 deletions components/tree-select/nz-tree-select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ describe('tree-select component', () => {
testComponent.expandKeys = [];
treeSelect.nativeElement.click();
fixture.detectChanges();
expect(treeSelectComponent.nzDefaultExpandedKeys.length === 0).toBe(true);
expect(treeSelectComponent.nzExpandedKeys.length === 0).toBe(true);
expect(treeSelectComponent.nzOpen).toBe(true);
let targetSwitcher = overlayContainerElement.querySelector('.ant-select-tree-switcher')!;
Expand All @@ -503,7 +502,6 @@ describe('tree-select component', () => {
dispatchMouseEvent(targetSwitcher, 'click');
fixture.detectChanges();
expect(targetSwitcher.classList.contains('ant-select-tree-switcher_open')).toBe(true);
expect(treeSelectComponent.nzDefaultExpandedKeys[0] === '1001').toBe(true);
expect(treeSelectComponent.nzExpandedKeys[0] === '1001').toBe(true);
treeSelect.nativeElement.click();
fixture.detectChanges();
Expand All @@ -513,7 +511,6 @@ describe('tree-select component', () => {
targetSwitcher = overlayContainerElement.querySelector('.ant-select-tree-switcher')!;
expect(treeSelectComponent.nzOpen).toBe(true);
expect(targetSwitcher.classList.contains('ant-select-tree-switcher_open')).toBe(true);
expect(treeSelectComponent.nzDefaultExpandedKeys[0] === '1001').toBe(true);
expect(treeSelectComponent.nzExpandedKeys[0] === '1001').toBe(true);
});
});
Expand Down Expand Up @@ -636,7 +633,7 @@ export class NzTestTreeSelectBasicComponent {
<nz-tree-select
style="width: 250px"
nzPlaceHolder="Please select"
[nzDefaultExpandedKeys]="expandKeys"
[nzExpandedKeys]="expandKeys"
[nzNodes]="nodes"
[nzShowSearch]="showSearch"
[nzCheckable]="true"
Expand Down
19 changes: 1 addition & 18 deletions components/tree/nz-tree-node.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ import {
NzNoAnimationDirective,
NzTreeBaseService,
NzTreeNode,
treeCollapseMotion,
warnDeprecation
treeCollapseMotion
} from 'ng-zorro-antd/core';

@Component({
Expand Down Expand Up @@ -74,22 +73,6 @@ export class NzTreeNodeComponent implements OnInit, OnChanges, OnDestroy {
return this._nzDraggable;
}

/**
* @deprecated use `nzExpandAll` instead.
*/
@Input()
set nzDefaultExpandAll(value: boolean) {
warnDeprecation(`'nzDefaultExpandAll' is going to be removed in 9.0.0. Please use 'nzExpandAll' instead.`);
this._nzExpandAll = value;
if (value && this.nzTreeNode && !this.nzTreeNode.isLeaf) {
this.nzTreeNode.isExpanded = true;
}
}

get nzDefaultExpandAll(): boolean {
return this._nzExpandAll;
}

// default set
@Input()
set nzExpandAll(value: boolean) {
Expand Down
55 changes: 0 additions & 55 deletions components/tree/nz-tree.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {
NzTreeBaseService,
NzTreeHigherOrderServiceToken,
NzTreeNode,
warnDeprecation,
WithConfig
} from 'ng-zorro-antd/core';

Expand Down Expand Up @@ -91,23 +90,6 @@ export class NzTreeComponent extends NzTreeBase implements OnInit, OnDestroy, Co
return this.nzTreeTemplate || this.nzTreeTemplateChild;
}

/**
* @deprecated 9.0.0 use `nzExpandAll` instead.
*/
@Input()
@InputBoolean()
set nzDefaultExpandAll(value: boolean) {
warnDeprecation(`'nzDefaultExpandAll' would be removed in 9.0.0. Please use 'nzExpandAll' instead.`);
this.nzExpandAll = value;
this._nzDefaultExpandAll = value;
}

get nzDefaultExpandAll(): boolean {
return this._nzDefaultExpandAll;
}

private _nzDefaultExpandAll = false;

@Input() nzBeforeDrop: (confirm: NzFormatBeforeDropEvent) => Observable<boolean>;

@Input() @InputBoolean() nzMultiple = false;
Expand All @@ -118,33 +100,6 @@ export class NzTreeComponent extends NzTreeBase implements OnInit, OnDestroy, Co
this.initNzData(value);
}

/**
* @deprecated 9.0.0 - use `nzExpandedKeys` instead.
*/
@Input()
set nzDefaultExpandedKeys(value: string[]) {
warnDeprecation(`'nzDefaultExpandedKeys' would be removed in 9.0.0. Please use 'nzExpandedKeys' instead.`);
this.nzDefaultSubject.next({ type: 'nzExpandedKeys', keys: value });
}

/**
* @deprecated 9.0.0 - use `nzSelectedKeys` instead.
*/
@Input()
set nzDefaultSelectedKeys(value: string[]) {
warnDeprecation(`'nzDefaultSelectedKeys' would be removed in 9.0.0. Please use 'nzSelectedKeys' instead.`);
this.nzDefaultSubject.next({ type: 'nzSelectedKeys', keys: value });
}

/**
* @deprecated 9.0.0 - use `nzCheckedKeys` instead.
*/
@Input()
set nzDefaultCheckedKeys(value: string[]) {
warnDeprecation(`'nzDefaultCheckedKeys' would be removed in 9.0.0. Please use 'nzCheckedKeys' instead.`);
this.nzDefaultSubject.next({ type: 'nzCheckedKeys', keys: value });
}

@Input()
set nzExpandedKeys(value: string[]) {
this.nzDefaultSubject.next({ type: 'nzExpandedKeys', keys: value });
Expand All @@ -166,11 +121,6 @@ export class NzTreeComponent extends NzTreeBase implements OnInit, OnDestroy, Co
this.nzTreeService.searchExpand(value);
if (isNotNil(value)) {
this.nzSearchValueChange.emit(this.nzTreeService.formatEvent('search', null, null));
/**
* @deprecated 9.0.0 - use `nzOnSearchNode` instead.
* Hide warning, need remove next version
*/
this.nzOnSearchNode.emit(this.nzTreeService.formatEvent('search', null, null));
}
}

Expand All @@ -191,11 +141,6 @@ export class NzTreeComponent extends NzTreeBase implements OnInit, OnDestroy, Co

@Output() readonly nzSearchValueChange = new EventEmitter<NzFormatEmitEvent>();

/**
* @deprecated use `nzSearchValueChange` instead.
*/
@Output() readonly nzOnSearchNode = new EventEmitter<NzFormatEmitEvent>();

@Output() readonly nzClick = new EventEmitter<NzFormatEmitEvent>();
@Output() readonly nzDblClick = new EventEmitter<NzFormatEmitEvent>();
@Output() readonly nzContextMenu = new EventEmitter<NzFormatEmitEvent>();
Expand Down
10 changes: 5 additions & 5 deletions components/tree/nz-tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('nz-tree', () => {
treeElement = fixture.debugElement.query(By.directive(NzTreeComponent)).nativeElement;
}));

it('should set nzDefaultXXX correctly', fakeAsync(() => {
it('should set default property correctly', fakeAsync(() => {
fixture.detectChanges();
flush();
tick(300);
Expand Down Expand Up @@ -878,10 +878,10 @@ export class NzTestTreeDraggableComponent {
<nz-tree
[(ngModel)]="modelNodes"
[nzMultiple]="true"
[nzDefaultExpandedKeys]="expandKeys"
[nzDefaultCheckedKeys]="checkedKeys"
[nzDefaultSelectedKeys]="selectedKeys"
[nzDefaultExpandAll]="expandDefault"
[nzExpandedKeys]="expandKeys"
[nzCheckedKeys]="checkedKeys"
[nzSelectedKeys]="selectedKeys"
[nzExpandAll]="expandDefault"
(nzExpandChange)="nzEvent()"
>
</nz-tree>
Expand Down

0 comments on commit 1ec18e4

Please sign in to comment.