Skip to content

Commit 8fca7bb

Browse files
authored
refactor(module:*) remove deprecated APIs in v21 (#9531)
* refactor(module:checkbox): remove deprecated nz-checkbox-wrapper please use nz-checkbox-group instead * refactor(module:input-number): remove deprecated input `nzBordered` please use `nzVariant` instead * refactor(module:mention): remove deprecated NZ_MENTION_TRIGGER_ACCESSOR * refactor(module:mention): remove deprecated NzToolTipModule which had been renamed to NzTooltipModule in v20 * refactor(module:input): remove deprecated input `nzBorderless` please use `nzVariant` instead * refactor(module:core): remove deprecated `NzHighlightModule` please use `NzHighlightPipe` directly instead * refactor(module:date-picker): remove deprecated input `nzBorderless` please use `nzVariant` instead * refactor(module:auto-complete): remove NZ_AUTOCOMPLETE_VALUE_ACCESSOR * refactor(module:select): remove deprecated input `nzBorderless` please use `nzVariant` instead * refactor(module:time-picker): remove deprecated input `nzBorderless` please use `nzVariant` instead * refactor(module:*): add missing nzConfig field `nzVariant`
1 parent 2c3b0a3 commit 8fca7bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+140
-458
lines changed

components/auto-complete/autocomplete-trigger.directive.ts

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
Directive,
2121
DOCUMENT,
2222
ElementRef,
23-
ExistingProvider,
2423
forwardRef,
2524
inject,
2625
Injector,
@@ -38,31 +37,18 @@ import { NzInputGroupWhitSuffixOrPrefixDirective } from 'ng-zorro-antd/input';
3837

3938
import { NzAutocompleteOptionComponent } from './autocomplete-option.component';
4039
import { NzAutocompleteComponent } from './autocomplete.component';
41-
42-
/**
43-
* @deprecated Internally used, will be removed in v21, please do not use it.
44-
*/
45-
export const NZ_AUTOCOMPLETE_VALUE_ACCESSOR: ExistingProvider = {
46-
provide: NG_VALUE_ACCESSOR,
47-
useExisting: forwardRef(() => NzAutocompleteTriggerDirective),
48-
multi: true
49-
};
50-
51-
/**
52-
* @deprecated Internally used, will not be exported in v21, please do not use it.
53-
*/
54-
export function getNzAutocompleteMissingPanelError(): Error {
55-
return Error(
56-
'Attempting to open an undefined instance of `nz-autocomplete`. ' +
57-
'Make sure that the id passed to the `nzAutocomplete` is correct and that ' +
58-
"you're attempting to open it after the ngAfterContentInit hook."
59-
);
60-
}
40+
import { getNzAutocompleteMissingPanelError } from './error';
6141

6242
@Directive({
6343
selector: `input[nzAutocomplete], textarea[nzAutocomplete]`,
6444
exportAs: 'nzAutocompleteTrigger',
65-
providers: [NZ_AUTOCOMPLETE_VALUE_ACCESSOR],
45+
providers: [
46+
{
47+
provide: NG_VALUE_ACCESSOR,
48+
useExisting: forwardRef(() => NzAutocompleteTriggerDirective),
49+
multi: true
50+
}
51+
],
6652
host: {
6753
autocomplete: 'off',
6854
'aria-autocomplete': 'list',

components/auto-complete/autocomplete.spec.ts

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {
4646
import { NzSafeAny } from 'ng-zorro-antd/core/types';
4747
import { NzInputModule } from 'ng-zorro-antd/input';
4848

49-
import { getNzAutocompleteMissingPanelError } from './autocomplete-trigger.directive';
49+
import { getNzAutocompleteMissingPanelError } from './error';
5050
import {
5151
NzAutocompleteComponent,
5252
NzAutocompleteModule,
@@ -933,29 +933,25 @@ describe('auto-complete', () => {
933933
}).toThrow(getNzAutocompleteMissingPanelError());
934934
}));
935935

936-
it(
937-
'should show the panel when the options are initialized later within a component with ' +
938-
'OnPush change detection',
939-
fakeAsync(() => {
940-
fixture = TestBed.createComponent(NzTestAutocompleteWithOnPushDelayComponent);
941-
fixture.detectChanges();
936+
it('should show the panel when the options are initialized later within a component with OnPush change detection', fakeAsync(() => {
937+
fixture = TestBed.createComponent(NzTestAutocompleteWithOnPushDelayComponent);
938+
fixture.detectChanges();
942939

943-
dispatchFakeEvent(fixture.debugElement.query(By.css('input')).nativeElement, 'focusin');
944-
fixture.detectChanges();
945-
tick(1000);
940+
dispatchFakeEvent(fixture.debugElement.query(By.css('input')).nativeElement, 'focusin');
941+
fixture.detectChanges();
942+
tick(1000);
943+
944+
fixture.detectChanges();
945+
tick();
946946

947+
Promise.resolve().then(() => {
948+
fixture.detectChanges();
949+
flush();
947950
fixture.detectChanges();
948-
tick();
949-
950-
Promise.resolve().then(() => {
951-
fixture.detectChanges();
952-
flush();
953-
fixture.detectChanges();
954-
const panel = overlayContainerElement.querySelector('.ant-select-dropdown') as HTMLElement;
955-
expect(panel.classList).not.toContain('ant-select-dropdown-hidden');
956-
});
957-
})
958-
);
951+
const panel = overlayContainerElement.querySelector('.ant-select-dropdown') as HTMLElement;
952+
expect(panel.classList).not.toContain('ant-select-dropdown-hidden');
953+
});
954+
}));
959955
});
960956

961957
describe('within input-wrapper', () => {

components/auto-complete/error.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Use of this source code is governed by an MIT-style license that can be
3+
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
4+
*/
5+
6+
/**
7+
* @note Internally used, please do not use it
8+
*/
9+
export function getNzAutocompleteMissingPanelError(): Error {
10+
return Error(
11+
'Attempting to open an undefined instance of `nz-autocomplete`. ' +
12+
'Make sure that the id passed to the `nzAutocomplete` is correct and that ' +
13+
"you're attempting to open it after the ngAfterContentInit hook."
14+
);
15+
}

components/checkbox/checkbox-wrapper.component.ts

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

components/checkbox/checkbox.component.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ import {
2626
} from '@angular/core';
2727
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
2828
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
29-
import { Subject } from 'rxjs';
3029

3130
import { NzFormStatusService } from 'ng-zorro-antd/core/form';
3231
import { NzSafeAny, OnChangeType, OnTouchedType } from 'ng-zorro-antd/core/types';
3332
import { fromEventOutsideAngular } from 'ng-zorro-antd/core/util';
3433

35-
import { NzCheckboxWrapperComponent } from './checkbox-wrapper.component';
3634
import { NZ_CHECKBOX_GROUP } from './tokens';
3735

3836
@Component({
@@ -89,11 +87,8 @@ export class NzCheckboxComponent implements OnInit, ControlValueAccessor, AfterV
8987
private destroyRef = inject(DestroyRef);
9088
protected checkboxGroupComponent = inject(NZ_CHECKBOX_GROUP, { optional: true });
9189
protected nzFormStatusService = inject(NzFormStatusService, { optional: true });
92-
/** @deprecated */
93-
private nzCheckboxWrapperComponent = inject(NzCheckboxWrapperComponent, { optional: true });
9490

9591
dir: Direction = 'ltr';
96-
private destroy$ = new Subject<void>();
9792
private isNzDisableFirstChange: boolean = true;
9893

9994
onChange: OnChangeType = () => {};
@@ -111,7 +106,6 @@ export class NzCheckboxComponent implements OnInit, ControlValueAccessor, AfterV
111106
innerCheckedChange(checked: boolean): void {
112107
if (!this.nzDisabled && !this.checkboxGroupComponent?.finalDisabled()) {
113108
this.setValue(checked);
114-
this.nzCheckboxWrapperComponent?.onChange();
115109
this.checkboxGroupComponent?.onCheckedChange(this.nzValue, checked);
116110
}
117111
}
@@ -146,7 +140,6 @@ export class NzCheckboxComponent implements OnInit, ControlValueAccessor, AfterV
146140
constructor() {
147141
this.destroyRef.onDestroy(() => {
148142
this.focusMonitor.stopMonitoring(this.elementRef);
149-
this.nzCheckboxWrapperComponent?.removeCheckbox(this);
150143
});
151144
if (this.checkboxGroupComponent) {
152145
effect(() => {
@@ -167,8 +160,6 @@ export class NzCheckboxComponent implements OnInit, ControlValueAccessor, AfterV
167160
}
168161
});
169162

170-
this.nzCheckboxWrapperComponent?.addCheckbox(this);
171-
172163
this.directionality.change.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(direction => {
173164
this.dir = direction;
174165
this.cdr.detectChanges();

components/checkbox/checkbox.module.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
import { NgModule } from '@angular/core';
77

88
import { NzCheckboxGroupComponent } from './checkbox-group.component';
9-
import { NzCheckboxWrapperComponent } from './checkbox-wrapper.component';
109
import { NzCheckboxComponent } from './checkbox.component';
1110

1211
@NgModule({
13-
imports: [NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxWrapperComponent],
14-
exports: [NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxWrapperComponent]
12+
imports: [NzCheckboxComponent, NzCheckboxGroupComponent],
13+
exports: [NzCheckboxComponent, NzCheckboxGroupComponent]
1514
})
1615
export class NzCheckboxModule {}

components/checkbox/checkbox.spec.ts

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import { ComponentFixture, TestBed, fakeAsync, flush } from '@angular/core/testi
99
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
1010
import { By } from '@angular/platform-browser';
1111

12-
import { NzSafeAny } from 'ng-zorro-antd/core/types';
13-
14-
import { NzCheckboxWrapperComponent } from './checkbox-wrapper.component';
1512
import { NzCheckboxComponent } from './checkbox.component';
1613
import { NzCheckboxModule } from './checkbox.module';
1714

@@ -212,32 +209,6 @@ describe('checkbox', () => {
212209
}));
213210
});
214211

215-
describe('checkbox wrapper', () => {
216-
let fixture: ComponentFixture<NzTestCheckboxWrapperComponent>;
217-
let testComponent: NzTestCheckboxWrapperComponent;
218-
let checkboxWrapper: DebugElement;
219-
let inputElement: HTMLInputElement;
220-
221-
beforeEach(fakeAsync(() => {
222-
fixture = TestBed.createComponent(NzTestCheckboxWrapperComponent);
223-
fixture.detectChanges();
224-
flush();
225-
fixture.detectChanges();
226-
testComponent = fixture.debugElement.componentInstance;
227-
checkboxWrapper = fixture.debugElement.query(By.directive(NzCheckboxWrapperComponent));
228-
inputElement = checkboxWrapper.nativeElement.querySelector('input') as HTMLInputElement;
229-
}));
230-
it('should className correct', fakeAsync(() => {
231-
expect(checkboxWrapper.nativeElement.classList).toContain('ant-checkbox-group');
232-
}));
233-
it('should onChange correct', fakeAsync(() => {
234-
inputElement.click();
235-
flush();
236-
fixture.detectChanges();
237-
expect(testComponent.onChange).toHaveBeenCalledWith([]);
238-
expect(testComponent.onChange).toHaveBeenCalledTimes(1);
239-
}));
240-
});
241212
describe('RTL', () => {
242213
it('should single checkbox className correct on dir change', () => {
243214
const fixture = TestBed.createComponent(NzTestCheckboxSingleRtlComponent);
@@ -277,22 +248,6 @@ export class NzTestCheckboxSingleComponent {
277248
modelChange = jasmine.createSpy('change callback');
278249
}
279250

280-
@Component({
281-
imports: [FormsModule, NzCheckboxModule],
282-
template: `
283-
<nz-checkbox-wrapper (nzOnChange)="onChange($event)">
284-
<div><label nz-checkbox nzValue="A" [ngModel]="true">A</label></div>
285-
<div><label nz-checkbox nzValue="B">B</label></div>
286-
<div><label nz-checkbox nzValue="C">C</label></div>
287-
<div><label nz-checkbox nzValue="D">D</label></div>
288-
<div><label nz-checkbox nzValue="E">E</label></div>
289-
</nz-checkbox-wrapper>
290-
`
291-
})
292-
export class NzTestCheckboxWrapperComponent {
293-
onChange = jasmine.createSpy('change callback');
294-
}
295-
296251
@Component({
297252
imports: [ReactiveFormsModule, NzCheckboxModule],
298253
template: `
@@ -347,34 +302,4 @@ describe('checkbox component', () => {
347302
component.ngAfterViewInit();
348303
expect(component.focus).toHaveBeenCalled();
349304
});
350-
351-
describe('checkbox wrapper component', () => {
352-
let fixture: ComponentFixture<NzCheckboxWrapperComponent>;
353-
let component: NzCheckboxWrapperComponent;
354-
355-
beforeEach(() => {
356-
fixture = TestBed.createComponent(NzCheckboxWrapperComponent);
357-
component = fixture.componentInstance;
358-
});
359-
360-
it('should emit correct value', () => {
361-
(component as NzSafeAny)['checkboxList'] = [
362-
{
363-
nzChecked: true,
364-
nzValue: 'value 1'
365-
},
366-
{
367-
nzChecked: true,
368-
nzValue: 'value 2'
369-
},
370-
{
371-
nzChecked: false,
372-
nzValue: 'value 3'
373-
}
374-
];
375-
spyOn(component.nzOnChange, 'emit');
376-
component.onChange();
377-
expect(component.nzOnChange.emit).toHaveBeenCalledWith(['value 1', 'value 2']);
378-
});
379-
});
380305
});

components/checkbox/demo/layout-legacy.md

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

components/checkbox/demo/layout-legacy.ts

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

components/checkbox/doc/index.en-US.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ description: Collect user's choices.
3636
| `[nzDisabled]` | Disable all checkboxes | `boolean` | `false` |
3737
| `(ngModelChange)` | The callback function that is triggered when the state changes. | `EventEmitter<string[] \| number[]>` | - |
3838

39-
### nz-checkbox-wrapper
40-
41-
| Property | Description | Type | Default |
42-
| -------------- | --------------------------------------------------------------- | --------------------- | ------- |
43-
| `(nzOnChange)` | The callback function that is triggered when the state changes. | `EventEmitter<any[]>` | - |
44-
4539
## Methods
4640

4741
### [nz-checkbox]

0 commit comments

Comments
 (0)