Skip to content

Commit

Permalink
refactor: deprecated InputBoolean, InputNumber and InputCssPixel
Browse files Browse the repository at this point in the history
  • Loading branch information
HyperLife1119 committed May 31, 2024
1 parent 710e20e commit 19869a3
Show file tree
Hide file tree
Showing 130 changed files with 906 additions and 1,233 deletions.
13 changes: 5 additions & 8 deletions components/affix/affix.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Inject,
Input,
NgZone,
numberAttribute,
OnChanges,
OnDestroy,
OnInit,
Expand All @@ -32,8 +33,8 @@ import { map, takeUntil, throttleTime } from 'rxjs/operators';
import { NzResizeObserver } from 'ng-zorro-antd/cdk/resize-observer';
import { NzConfigKey, NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { NzScrollService } from 'ng-zorro-antd/core/services';
import { NgStyleInterface, NumberInput, NzSafeAny } from 'ng-zorro-antd/core/types';
import { getStyleAsText, InputNumber, shallowEqual } from 'ng-zorro-antd/core/util';
import { NgStyleInterface, NzSafeAny } from 'ng-zorro-antd/core/types';
import { getStyleAsText, shallowEqual } from 'ng-zorro-antd/core/util';

import { AffixRespondEvents } from './respond-events';
import { getTargetRect, SimpleRect } from './utils';
Expand All @@ -57,21 +58,17 @@ const NZ_AFFIX_DEFAULT_SCROLL_TIME = 20;
})
export class NzAffixComponent implements AfterViewInit, OnChanges, OnDestroy, OnInit {
readonly _nzModuleName: NzConfigKey = NZ_CONFIG_MODULE_NAME;
static ngAcceptInputType_nzOffsetTop: NumberInput;
static ngAcceptInputType_nzOffsetBottom: NumberInput;

@ViewChild('fixedEl', { static: true }) private fixedEl!: ElementRef<HTMLDivElement>;

@Input() nzTarget?: string | Element | Window;

@Input()
@Input({ transform: numberAttribute })
@WithConfig<number | null>()
@InputNumber(undefined)
nzOffsetTop?: null | number;

@Input()
@Input({ transform: numberAttribute })
@WithConfig<number | null>()
@InputNumber(undefined)
nzOffsetBottom?: null | number;

@Output() readonly nzChange = new EventEmitter<boolean>();
Expand Down
17 changes: 6 additions & 11 deletions components/alert/alert.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ import {
Output,
SimpleChanges,
TemplateRef,
ViewEncapsulation
ViewEncapsulation,
booleanAttribute
} from '@angular/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

import { slideAlertMotion } from 'ng-zorro-antd/core/animation';
import { NzConfigKey, NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { BooleanInput } from 'ng-zorro-antd/core/types';
import { InputBoolean } from 'ng-zorro-antd/core/util';
import { NzIconModule } from 'ng-zorro-antd/icon';

const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'alert';
Expand Down Expand Up @@ -105,21 +104,17 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'alert';
})
export class NzAlertComponent implements OnChanges, OnDestroy, OnInit {
readonly _nzModuleName: NzConfigKey = NZ_CONFIG_MODULE_NAME;
static ngAcceptInputType_nzCloseable: BooleanInput;
static ngAcceptInputType_nzShowIcon: BooleanInput;
static ngAcceptInputType_nzBanner: BooleanInput;
static ngAcceptInputType_nzNoAnimation: BooleanInput;

@Input() nzAction: string | TemplateRef<void> | null = null;
@Input() nzCloseText: string | TemplateRef<void> | null = null;
@Input() nzIconType: string | null = null;
@Input() nzMessage: string | TemplateRef<void> | null = null;
@Input() nzDescription: string | TemplateRef<void> | null = null;
@Input() nzType: 'success' | 'info' | 'warning' | 'error' = 'info';
@Input() @WithConfig() @InputBoolean() nzCloseable: boolean = false;
@Input() @WithConfig() @InputBoolean() nzShowIcon: boolean = false;
@Input() @InputBoolean() nzBanner = false;
@Input() @InputBoolean() nzNoAnimation = false;
@Input({ transform: booleanAttribute }) @WithConfig() nzCloseable: boolean = false;
@Input({ transform: booleanAttribute }) @WithConfig() nzShowIcon: boolean = false;
@Input({ transform: booleanAttribute }) nzBanner = false;
@Input({ transform: booleanAttribute }) nzNoAnimation = false;
@Input() nzIcon: string | TemplateRef<void> | null = null;
@Output() readonly nzOnClose = new EventEmitter<boolean>();
closed = false;
Expand Down
23 changes: 8 additions & 15 deletions components/anchor/anchor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { normalizePassiveListenerOptions, Platform } from '@angular/cdk/platform
import { DOCUMENT, NgClass, NgIf, NgStyle, NgTemplateOutlet } from '@angular/common';
import {
AfterViewInit,
booleanAttribute,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
Expand All @@ -15,6 +16,7 @@ import {
Inject,
Input,
NgZone,
numberAttribute,
OnChanges,
OnDestroy,
Output,
Expand All @@ -29,8 +31,7 @@ import { takeUntil, throttleTime } from 'rxjs/operators';
import { NzAffixModule } from 'ng-zorro-antd/affix';
import { NzConfigKey, NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { NzScrollService } from 'ng-zorro-antd/core/services';
import { BooleanInput, NgStyleInterface, NumberInput, NzDirectionVHType, NzSafeAny } from 'ng-zorro-antd/core/types';
import { InputBoolean, InputNumber } from 'ng-zorro-antd/core/util';
import { NgStyleInterface, NzDirectionVHType, NzSafeAny } from 'ng-zorro-antd/core/types';

import { NzAnchorLinkComponent } from './anchor-link.component';
import { getOffsetTop } from './util';
Expand Down Expand Up @@ -81,32 +82,24 @@ const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: t
})
export class NzAnchorComponent implements OnDestroy, AfterViewInit, OnChanges {
readonly _nzModuleName: NzConfigKey = NZ_CONFIG_MODULE_NAME;
static ngAcceptInputType_nzAffix: BooleanInput;
static ngAcceptInputType_nzShowInkInFixed: BooleanInput;
static ngAcceptInputType_nzBounds: NumberInput;
static ngAcceptInputType_nzOffsetTop: NumberInput;

@ViewChild('ink', { static: false }) private ink!: ElementRef;

@Input() @InputBoolean() nzAffix = true;
@Input({ transform: booleanAttribute }) nzAffix = true;

@Input()
@Input({ transform: booleanAttribute })
@WithConfig()
@InputBoolean()
nzShowInkInFixed: boolean = false;

@Input()
@Input({ transform: numberAttribute })
@WithConfig()
@InputNumber()
nzBounds: number = 5;

@Input()
@InputNumber(undefined)
@Input({ transform: numberAttribute })
@WithConfig<number>()
nzOffsetTop?: number = undefined;

@Input()
@InputNumber(undefined)
@Input({ transform: numberAttribute })
@WithConfig<number>()
nzTargetOffset?: number = undefined;

Expand Down
13 changes: 6 additions & 7 deletions components/auto-complete/autocomplete-option.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ import {
OnInit,
Optional,
Output,
ViewEncapsulation
ViewEncapsulation,
booleanAttribute
} from '@angular/core';
import { fromEvent, Subject } from 'rxjs';
import { Subject, fromEvent } from 'rxjs';
import { filter, takeUntil } from 'rxjs/operators';

import { BooleanInput, NzSafeAny } from 'ng-zorro-antd/core/types';
import { InputBoolean, scrollIntoView } from 'ng-zorro-antd/core/util';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { scrollIntoView } from 'ng-zorro-antd/core/util';

import { NzAutocompleteOptgroupComponent } from './autocomplete-optgroup.component';

Expand Down Expand Up @@ -57,11 +58,9 @@ export class NzOptionSelectionChange {
}
})
export class NzAutocompleteOptionComponent implements OnInit, OnDestroy {
static ngAcceptInputType_nzDisabled: BooleanInput;

@Input() nzValue: NzSafeAny;
@Input() nzLabel?: string;
@Input() @InputBoolean() nzDisabled = false;
@Input({ transform: booleanAttribute }) nzDisabled = false;
@Output() readonly selectionChange = new EventEmitter<NzOptionSelectionChange>();
@Output() readonly mouseEntered = new EventEmitter<NzAutocompleteOptionComponent>();

Expand Down
18 changes: 8 additions & 10 deletions components/auto-complete/autocomplete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ import {
ViewChild,
ViewChildren,
ViewEncapsulation,
inject
booleanAttribute,
inject,
numberAttribute
} from '@angular/core';
import { defer, merge, Observable, Subject, Subscription } from 'rxjs';
import { Observable, Subject, Subscription, defer, merge } from 'rxjs';
import { filter, switchMap, takeUntil } from 'rxjs/operators';

import { slideMotion } from 'ng-zorro-antd/core/animation';
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
import { NZ_AFTER_NEXT_RENDER$ } from 'ng-zorro-antd/core/render';
import { BooleanInput, CompareWith, NzSafeAny } from 'ng-zorro-antd/core/types';
import { InputBoolean } from 'ng-zorro-antd/core/util';
import { CompareWith, NzSafeAny } from 'ng-zorro-antd/core/types';

import { NzAutocompleteOptionComponent, NzOptionSelectionChange } from './autocomplete-option.component';

Expand Down Expand Up @@ -101,14 +102,11 @@ function normalizeDataSource(value: AutocompleteDataSource): AutocompleteDataSou
animations: [slideMotion]
})
export class NzAutocompleteComponent implements AfterContentInit, AfterViewInit, OnDestroy, OnInit, OnChanges {
static ngAcceptInputType_nzDefaultActiveFirstOption: BooleanInput;
static ngAcceptInputType_nzBackfill: BooleanInput;

@Input() nzWidth?: number;
@Input({ transform: numberAttribute }) nzWidth?: number;
@Input() nzOverlayClassName = '';
@Input() nzOverlayStyle: { [key: string]: string } = {};
@Input() @InputBoolean() nzDefaultActiveFirstOption = true;
@Input() @InputBoolean() nzBackfill = false;
@Input({ transform: booleanAttribute }) nzDefaultActiveFirstOption = true;
@Input({ transform: booleanAttribute }) nzBackfill = false;
@Input() compareWith: CompareWith = (o1, o2) => o1 === o2;
@Input() nzDataSource?: AutocompleteDataSource;
@Output()
Expand Down
10 changes: 4 additions & 6 deletions components/avatar/avatar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import {
OnChanges,
Output,
ViewChild,
ViewEncapsulation
ViewEncapsulation,
numberAttribute
} from '@angular/core';

import { NzConfigKey, NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { NgClassInterface, NumberInput, NzShapeSCType, NzSizeLDSType } from 'ng-zorro-antd/core/types';
import { InputNumber } from 'ng-zorro-antd/core/util';
import { NgClassInterface, NzShapeSCType, NzSizeLDSType } from 'ng-zorro-antd/core/types';
import { NzIconModule } from 'ng-zorro-antd/icon';

const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'avatar';
Expand Down Expand Up @@ -60,12 +60,10 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'avatar';
encapsulation: ViewEncapsulation.None
})
export class NzAvatarComponent implements OnChanges, AfterViewInit {
static ngAcceptInputType_nzGap: NumberInput;

readonly _nzModuleName: NzConfigKey = NZ_CONFIG_MODULE_NAME;
@Input() @WithConfig() nzShape: NzShapeSCType = 'circle';
@Input() @WithConfig() nzSize: NzSizeLDSType | number = 'default';
@Input() @WithConfig() @InputNumber() nzGap = 4;
@Input({ transform: numberAttribute }) @WithConfig() nzGap = 4;
@Input() nzText?: string;
@Input() nzSrc?: string;
@Input() nzSrcSet?: string;
Expand Down
16 changes: 7 additions & 9 deletions components/back-top/back-top.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { Direction, Directionality } from '@angular/cdk/bidi';
import { normalizePassiveListenerOptions, Platform } from '@angular/cdk/platform';
import { Platform, normalizePassiveListenerOptions } from '@angular/cdk/platform';
import { DOCUMENT, NgIf, NgTemplateOutlet } from '@angular/common';
import {
ChangeDetectionStrategy,
Expand All @@ -23,16 +23,16 @@ import {
SimpleChanges,
TemplateRef,
ViewChild,
ViewEncapsulation
ViewEncapsulation,
numberAttribute
} from '@angular/core';
import { fromEvent, Subject, Subscription } from 'rxjs';
import { Subject, Subscription, fromEvent } from 'rxjs';
import { debounceTime, takeUntil } from 'rxjs/operators';

import { fadeMotion } from 'ng-zorro-antd/core/animation';
import { NzConfigKey, NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { NzDestroyService, NzScrollService } from 'ng-zorro-antd/core/services';
import { NumberInput, NzSafeAny } from 'ng-zorro-antd/core/types';
import { InputNumber } from 'ng-zorro-antd/core/util';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { NzIconModule } from 'ng-zorro-antd/icon';

const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'backTop';
Expand Down Expand Up @@ -66,8 +66,6 @@ const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: t
})
export class NzBackTopComponent implements OnInit, OnDestroy, OnChanges {
readonly _nzModuleName: NzConfigKey = NZ_CONFIG_MODULE_NAME;
static ngAcceptInputType_nzVisibilityHeight: NumberInput;
static ngAcceptInputType_nzDuration: NumberInput;

private scrollListenerDestroy$ = new Subject<boolean>();
private target: HTMLElement | null = null;
Expand All @@ -76,9 +74,9 @@ export class NzBackTopComponent implements OnInit, OnDestroy, OnChanges {
dir: Direction = 'ltr';

@Input() nzTemplate?: TemplateRef<void>;
@Input() @WithConfig() @InputNumber() nzVisibilityHeight: number = 400;
@Input({ transform: numberAttribute }) @WithConfig() nzVisibilityHeight: number = 400;
@Input() nzTarget?: string | HTMLElement;
@Input() @InputNumber() nzDuration: number = 450;
@Input({ transform: numberAttribute }) nzDuration: number = 450;
@Output() readonly nzClick: EventEmitter<boolean> = new EventEmitter();

@ViewChild('backTop', { static: false })
Expand Down
7 changes: 4 additions & 3 deletions components/badge/badge-sup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
OnInit,
SimpleChanges,
TemplateRef,
ViewEncapsulation
ViewEncapsulation,
numberAttribute
} from '@angular/core';

import { zoomBadgeMotion } from 'ng-zorro-antd/core/animation';
Expand Down Expand Up @@ -67,9 +68,9 @@ export class NzBadgeSupComponent implements OnInit, OnChanges {
@Input() nzTitle?: string | null | undefined;
@Input() nzStyle: { [key: string]: string } | null = null;
@Input() nzDot = false;
@Input() nzOverflowCount: number = 99;
@Input({ transform: numberAttribute }) nzOverflowCount: number = 99;
@Input() disableAnimation = false;
@Input() nzCount?: number | TemplateRef<NzSafeAny>;
@Input({ transform: numberAttribute }) nzCount?: number | TemplateRef<NzSafeAny>;
@Input() noAnimation = false;
@Input() nzSize: NzSizeDSType = 'default';
maxNumberArray: string[] = [];
Expand Down
19 changes: 8 additions & 11 deletions components/badge/badge.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
Renderer2,
SimpleChanges,
TemplateRef,
ViewEncapsulation
ViewEncapsulation,
booleanAttribute
} from '@angular/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
Expand All @@ -28,8 +29,7 @@ import { zoomBadgeMotion } from 'ng-zorro-antd/core/animation';
import { NzConfigKey, NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { BooleanInput, NzSafeAny, NzSizeDSType } from 'ng-zorro-antd/core/types';
import { InputBoolean } from 'ng-zorro-antd/core/util';
import { NzSafeAny, NzSizeDSType } from 'ng-zorro-antd/core/types';

import { NzBadgeSupComponent } from './badge-sup.component';
import { badgePresetColors } from './preset-colors';
Expand Down Expand Up @@ -82,18 +82,15 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'badge';
})
export class NzBadgeComponent implements OnChanges, OnDestroy, OnInit {
readonly _nzModuleName: NzConfigKey = NZ_CONFIG_MODULE_NAME;
static ngAcceptInputType_nzShowZero: BooleanInput;
static ngAcceptInputType_nzShowDot: BooleanInput;
static ngAcceptInputType_nzDot: BooleanInput;
static ngAcceptInputType_nzStandalone: BooleanInput;

showSup = false;
presetColor: string | null = null;
dir: Direction = 'ltr';
private destroy$ = new Subject<void>();
@Input() @InputBoolean() nzShowZero: boolean = false;
@Input() @InputBoolean() nzShowDot = true;
@Input() @InputBoolean() nzStandalone = false;
@Input() @InputBoolean() nzDot = false;
@Input({ transform: booleanAttribute }) nzShowZero: boolean = false;
@Input({ transform: booleanAttribute }) nzShowDot = true;
@Input({ transform: booleanAttribute }) nzStandalone = false;
@Input({ transform: booleanAttribute }) nzDot = false;
@Input() @WithConfig() nzOverflowCount: number = 99;
@Input() @WithConfig() nzColor?: string = undefined;
@Input() nzStyle: { [key: string]: string } | null = null;
Expand Down

0 comments on commit 19869a3

Please sign in to comment.