Skip to content

Commit

Permalink
refactor(module:date-picker): remove deprecated APIs for v10 (#5793)
Browse files Browse the repository at this point in the history
BREAKING CHANGES:

- `NZ_DATE_FNS_COMPATIBLE` has been removed. Please migrate to date-fns v2 manually.
- nz-date-picker,nz-week-picker,nz-month-picker,nz-year-picker,nz-range-picker
  * [nzClassName]` has been removed, use `ngClass` instead.
  * [nzStyle]` has been removed, use `ngStyle` instead.
  • Loading branch information
wenqi73 committed Sep 17, 2020
1 parent 6e4419c commit 5159900
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 252 deletions.
18 changes: 1 addition & 17 deletions components/date-picker/date-picker.component.spec.ts
Expand Up @@ -16,7 +16,7 @@ import { NgStyleInterface } from 'ng-zorro-antd/core/types';
import { NzI18nModule, NzI18nService, NZ_DATE_LOCALE } from 'ng-zorro-antd/i18n';
import en_US from '../i18n/languages/en_US';
import { NzDatePickerModule } from './date-picker.module';
import { ENTER_EVENT, getPicker, getPickerAbstract, getPickerInput } from './testing/util';
import { ENTER_EVENT, getPickerAbstract, getPickerInput } from './testing/util';
import { PREFIX_CLASS } from './util';

registerLocaleData(zh);
Expand Down Expand Up @@ -243,12 +243,6 @@ describe('NzDatePickerComponent', () => {
expect(input.value).toBe('24.02.2020');
}));

it('should support nzClassName', () => {
const className = (fixtureInstance.nzClassName = 'my-test-class');
fixture.detectChanges();
expect(getPicker(fixture.debugElement).classList.contains(className)).toBeTruthy();
});

it('should support nzDisabledDate', fakeAsync(() => {
fixture.detectChanges();
const compareDate = new Date('2018-11-15 00:00:00');
Expand Down Expand Up @@ -314,12 +308,6 @@ describe('NzDatePickerComponent', () => {
expect(getPickerAbstract(fixture.debugElement).classList.contains(`${PREFIX_CLASS}-small`)).toBeTruthy();
});

it('should support nzStyle', () => {
fixtureInstance.nzStyle = { color: 'blue' };
fixture.detectChanges();
expect(getPicker(fixture.debugElement).style.color).toBe('blue');
});

it('should support nzOnOpenChange', fakeAsync(() => {
const nzOnOpenChange = spyOn(fixtureInstance, 'nzOnOpenChange');
fixture.detectChanges();
Expand Down Expand Up @@ -973,15 +961,13 @@ describe('date-fns testing', () => {
[nzAutoFocus]="nzAutoFocus"
[nzDisabled]="nzDisabled"
[nzInputReadOnly]="nzInputReadOnly"
[nzClassName]="nzClassName"
[nzDisabledDate]="nzDisabledDate"
[nzFormat]="nzFormat"
[nzLocale]="nzLocale"
[nzPlaceHolder]="nzPlaceHolder"
[nzPopupStyle]="nzPopupStyle"
[nzDropdownClassName]="nzDropdownClassName"
[nzSize]="nzSize"
[nzStyle]="nzStyle"
(nzOnOpenChange)="nzOnOpenChange($event)"
[ngModel]="nzValue"
(ngModelChange)="nzOnChange($event)"
Expand Down Expand Up @@ -1024,15 +1010,13 @@ class NzTestDatePickerComponent {
nzAutoFocus: boolean = false;
nzDisabled: boolean = false;
nzInputReadOnly: boolean = false;
nzClassName!: string;
nzFormat!: string;
nzDisabledDate!: (d: Date) => boolean;
nzLocale: any; // tslint:disable-line:no-any
nzPlaceHolder!: string;
nzPopupStyle!: NgStyleInterface;
nzDropdownClassName!: string;
nzSize!: string;
nzStyle!: NgStyleInterface;

nzOnChange(_: Date | null): void {}
nzOnCalendarChange(): void {}
Expand Down
23 changes: 0 additions & 23 deletions components/date-picker/date-picker.component.ts
Expand Up @@ -24,7 +24,6 @@ import {
ViewEncapsulation
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { warnDeprecation } from 'ng-zorro-antd/core/logger';
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
import { CandyDate, cloneDate, CompatibleValue } from 'ng-zorro-antd/core/time';
import { BooleanInput, FunctionProp, NzSafeAny, OnChangeType, OnTouchedType } from 'ng-zorro-antd/core/types';
Expand Down Expand Up @@ -61,9 +60,7 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'datePicker';
[allowClear]="nzAllowClear"
[autoFocus]="nzAutoFocus"
[placeholder]="nzPlaceHolder"
[ngClass]="nzClassName"
style="display: inherit; align-items: center; width: 100%;"
[ngStyle]="nzStyle"
[dropdownClassName]="nzDropdownClassName"
[popupStyle]="nzPopupStyle"
[noAnimation]="!!noAnimation?.nzNoAnimation"
Expand Down Expand Up @@ -136,20 +133,12 @@ export class NzDatePickerComponent implements OnInit, OnChanges, OnDestroy, Cont
@Input() @InputBoolean() nzDisabled: boolean = false;
@Input() @InputBoolean() nzInputReadOnly: boolean = false;
@Input() @InputBoolean() nzOpen?: boolean;
/**
* @deprecated 10.0.0. This is deprecated and going to be removed in 10.0.0.
*/
@Input() nzClassName: string = '';
@Input() nzDisabledDate?: (d: Date) => boolean;
@Input() nzLocale!: NzDatePickerI18nInterface;
@Input() nzPlaceHolder: string | [string, string] = '';
@Input() nzPopupStyle: object = POPUP_STYLE_PATCH;
@Input() nzDropdownClassName?: string;
@Input() nzSize: 'large' | 'small' | 'default' = 'default';
/**
* @deprecated 10.0.0. This is deprecated and going to be removed in 10.0.0.
*/
@Input() nzStyle: object | null = null;
@Input() nzFormat!: string;
@Input() nzDateRender?: TemplateRef<NzSafeAny> | string | FunctionProp<TemplateRef<Date> | string>;
@Input() nzDisabledTime?: DisabledTimeFn;
Expand Down Expand Up @@ -253,18 +242,6 @@ export class NzDatePickerComponent implements OnInit, OnChanges, OnDestroy, Cont
this.extraFooter = valueFunctionProp(this.nzRenderExtraFooter!);
}

if (changes.nzStyle) {
warnDeprecation(
`'nzStyle' in DatePicker is going to be removed in 10.0.0. Please use CSS style attribute like <nz-date-picker style="..."></nz-date-picker> instead.`
);
}

if (changes.nzClassName) {
warnDeprecation(
`'nzClassName' in DatePicker is going to be removed in 10.0.0. Please use CSS class attribute like <nz-date-picker class="..."></nz-date-picker> instead.`
);
}

if (changes.nzMode) {
this.setPanelMode();
}
Expand Down
18 changes: 1 addition & 17 deletions components/date-picker/month-picker.component.spec.ts
Expand Up @@ -10,7 +10,7 @@ import isBefore from 'date-fns/isBefore';

import { dispatchMouseEvent } from 'ng-zorro-antd/core/testing';
import { NgStyleInterface } from 'ng-zorro-antd/core/types';
import { ENTER_EVENT, getPicker, getPickerAbstract, getPickerInput } from 'ng-zorro-antd/date-picker/testing/util';
import { ENTER_EVENT, getPickerAbstract, getPickerInput } from 'ng-zorro-antd/date-picker/testing/util';
import { PREFIX_CLASS } from 'ng-zorro-antd/date-picker/util';
import { NzInputModule } from 'ng-zorro-antd/input';

Expand Down Expand Up @@ -146,12 +146,6 @@ describe('NzMonthPickerComponent', () => {
});
}));

it('should support nzClassName', () => {
const className = (fixtureInstance.nzClassName = 'my-test-class');
fixture.detectChanges();
expect(getPicker(fixture.debugElement).classList.contains(className)).toBeTruthy();
});

it('should support nzCompact', () => {
fixtureInstance.useSuite = 4;

Expand Down Expand Up @@ -215,12 +209,6 @@ describe('NzMonthPickerComponent', () => {
expect(getPickerAbstract(fixture.debugElement).classList.contains('ant-picker-small')).toBeTruthy();
});

it('should support nzStyle', () => {
fixtureInstance.nzStyle = { color: 'blue' };
fixture.detectChanges();
expect(getPicker(fixture.debugElement).style.color).toBe('blue');
});

it('should support nzOnOpenChange', fakeAsync(() => {
const nzOnOpenChange = spyOn(fixtureInstance, 'nzOnOpenChange');
fixture.detectChanges();
Expand Down Expand Up @@ -426,14 +414,12 @@ describe('NzMonthPickerComponent', () => {
[nzAllowClear]="nzAllowClear"
[nzAutoFocus]="nzAutoFocus"
[nzDisabled]="nzDisabled"
[nzClassName]="nzClassName"
[nzDisabledDate]="nzDisabledDate"
[nzLocale]="nzLocale"
[nzPlaceHolder]="nzPlaceHolder"
[nzPopupStyle]="nzPopupStyle"
[nzDropdownClassName]="nzDropdownClassName"
[nzSize]="nzSize"
[nzStyle]="nzStyle"
(nzOnOpenChange)="nzOnOpenChange($event)"
[ngModel]="nzValue"
(ngModelChange)="nzOnChange($event)"
Expand Down Expand Up @@ -463,14 +449,12 @@ class NzTestMonthPickerComponent {
nzAllowClear: boolean = false;
nzAutoFocus: boolean = false;
nzDisabled: boolean = false;
nzClassName!: string;
nzDisabledDate!: (d: Date) => boolean;
nzLocale: any; // tslint:disable-line:no-any
nzPlaceHolder!: string;
nzPopupStyle!: NgStyleInterface;
nzDropdownClassName!: string;
nzSize!: string;
nzStyle!: NgStyleInterface;

nzOnOpenChange(_: boolean): void {}

Expand Down
24 changes: 1 addition & 23 deletions components/date-picker/range-picker.component.spec.ts
Expand Up @@ -14,13 +14,7 @@ import { dispatchKeyboardEvent, dispatchMouseEvent, typeInElement } from 'ng-zor
import { CandyDate } from 'ng-zorro-antd/core/time';
import { NgStyleInterface } from 'ng-zorro-antd/core/types';
import { RangePartType } from 'ng-zorro-antd/date-picker/standard-types';
import {
ENTER_EVENT,
getPicker,
getPickerAbstract,
getPickerInput,
getRangePickerRightInput
} from 'ng-zorro-antd/date-picker/testing/util';
import { ENTER_EVENT, getPickerAbstract, getPickerInput, getRangePickerRightInput } from 'ng-zorro-antd/date-picker/testing/util';
import { PREFIX_CLASS } from 'ng-zorro-antd/date-picker/util';
import { NzDatePickerModule } from './date-picker.module';

Expand Down Expand Up @@ -159,12 +153,6 @@ describe('NzRangePickerComponent', () => {
expect(getPickerContainer()).toBeNull();
}));

it('should support nzClassName', () => {
const className = (fixtureInstance.nzClassName = 'my-test-class');
fixture.detectChanges();
expect(getPicker(fixture.debugElement).classList.contains(className)).toBeTruthy();
});

it('should support nzDisabledDate', fakeAsync(() => {
fixture.detectChanges();
const compareDate = new Date('2018-11-15 00:00:00');
Expand Down Expand Up @@ -216,12 +204,6 @@ describe('NzRangePickerComponent', () => {
expect(getPickerAbstract(fixture.debugElement).classList.contains('ant-picker-small')).toBeTruthy();
});

it('should support nzStyle', () => {
fixtureInstance.nzStyle = { color: 'blue' };
fixture.detectChanges();
expect(getPicker(fixture.debugElement).style.color).toBe('blue');
});

it('should support nzOnOpenChange', fakeAsync(() => {
const nzOnOpenChange = spyOn(fixtureInstance, 'nzOnOpenChange');
fixture.detectChanges();
Expand Down Expand Up @@ -886,14 +868,12 @@ describe('NzRangePickerComponent', () => {
[nzAllowClear]="nzAllowClear"
[nzAutoFocus]="nzAutoFocus"
[nzDisabled]="nzDisabled"
[nzClassName]="nzClassName"
[nzDisabledDate]="nzDisabledDate"
[nzLocale]="nzLocale"
[nzPlaceHolder]="nzPlaceHolder"
[nzPopupStyle]="nzPopupStyle"
[nzDropdownClassName]="nzDropdownClassName"
[nzSize]="nzSize"
[nzStyle]="nzStyle"
[nzSeparator]="nzSeparator"
(nzOnOpenChange)="nzOnOpenChange($event)"
[(ngModel)]="modelValue"
Expand Down Expand Up @@ -933,14 +913,12 @@ class NzTestRangePickerComponent {
nzAllowClear: boolean = false;
nzAutoFocus: boolean = false;
nzDisabled: boolean = false;
nzClassName!: string;
nzDisabledDate!: (d: Date) => boolean;
nzLocale: any; // tslint:disable-line:no-any
nzPlaceHolder!: string[];
nzPopupStyle!: NgStyleInterface;
nzDropdownClassName!: string;
nzSize!: string;
nzStyle!: NgStyleInterface;
nzOnOpenChange(_: boolean): void {}
modelValue: Array<Date | null> = [];
modelValueChange(_: Date[]): void {}
Expand Down
18 changes: 1 addition & 17 deletions components/date-picker/year-picker.component.spec.ts
Expand Up @@ -7,7 +7,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';

import { dispatchMouseEvent } from 'ng-zorro-antd/core/testing';
import { NgStyleInterface } from 'ng-zorro-antd/core/types';
import { ENTER_EVENT, getPicker, getPickerAbstract, getPickerInput } from 'ng-zorro-antd/date-picker/testing/util';
import { ENTER_EVENT, getPickerAbstract, getPickerInput } from 'ng-zorro-antd/date-picker/testing/util';
import { PREFIX_CLASS } from 'ng-zorro-antd/date-picker/util';
import { NzInputModule } from 'ng-zorro-antd/input';

Expand Down Expand Up @@ -143,12 +143,6 @@ describe('NzYearPickerComponent', () => {
});
}));

it('should support nzClassName', () => {
const className = (fixtureInstance.nzClassName = 'my-test-class');
fixture.detectChanges();
expect(getPicker(fixture.debugElement).classList.contains(className)).toBeTruthy();
});

it('should support nzCompact', () => {
fixtureInstance.useSuite = 4;
fixture.detectChanges();
Expand Down Expand Up @@ -209,12 +203,6 @@ describe('NzYearPickerComponent', () => {
expect(getPickerAbstract(fixture.debugElement).classList.contains('ant-picker-small')).toBeTruthy();
});

it('should support nzStyle', () => {
fixtureInstance.nzStyle = { color: 'blue' };
fixture.detectChanges();
expect(getPicker(fixture.debugElement).style.color).toBe('blue');
});

it('should support nzOnOpenChange', fakeAsync(() => {
const nzOnOpenChange = spyOn(fixtureInstance, 'nzOnOpenChange');
fixture.detectChanges();
Expand Down Expand Up @@ -368,13 +356,11 @@ describe('NzYearPickerComponent', () => {
[nzAutoFocus]="nzAutoFocus"
[nzDisabled]="nzDisabled"
[nzDisabledDate]="nzDisabledDate"
[nzClassName]="nzClassName"
[nzLocale]="nzLocale"
[nzPlaceHolder]="nzPlaceHolder"
[nzPopupStyle]="nzPopupStyle"
[nzDropdownClassName]="nzDropdownClassName"
[nzSize]="nzSize"
[nzStyle]="nzStyle"
(nzOnOpenChange)="nzOnOpenChange($event)"
[ngModel]="nzValue"
(ngModelChange)="nzOnChange($event)"
Expand Down Expand Up @@ -405,14 +391,12 @@ class NzTestYearPickerComponent {
nzAllowClear: boolean = false;
nzAutoFocus: boolean = false;
nzDisabled: boolean = false;
nzClassName?: string;
nzDisabledDate?: (d: Date) => boolean;
nzLocale: any; // tslint:disable-line:no-any
nzPlaceHolder?: string;
nzPopupStyle?: NgStyleInterface;
nzDropdownClassName?: string;
nzSize?: string;
nzStyle?: NgStyleInterface;

nzOnOpenChange(_: boolean): void {}

Expand Down

0 comments on commit 5159900

Please sign in to comment.