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 Apr 8, 2024
1 parent d2917e6 commit f1088a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
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
10 changes: 9 additions & 1 deletion components/core/util/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

import { coerceBooleanProperty, coerceCssPixelValue, _isNumberValue } from '@angular/cdk/coercion';
import { _isNumberValue, coerceBooleanProperty, coerceCssPixelValue } from '@angular/cdk/coercion';

import { warn } from 'ng-zorro-antd/core/logger';
import { FunctionProp, NzSafeAny } from 'ng-zorro-antd/core/types';
Expand Down Expand Up @@ -70,6 +70,8 @@ function propDecoratorFactory<T, D>(
}

/**
* @deprecated Use input transform instead: `@Input({ transform })`
*
* Input decorator that handle a prop to do get/set automatically with toBoolean
*
* Why not using @InputBoolean alone without @Input? AOT needs @Input to be visible
Expand All @@ -89,10 +91,16 @@ export function InputBoolean(): NzSafeAny {
return propDecoratorFactory('InputBoolean', toBoolean);
}

/**
* @deprecated
*/
export function InputCssPixel(): NzSafeAny {
return propDecoratorFactory('InputCssPixel', toCssPixel);
}

/**
* @deprecated
*/
export function InputNumber(fallbackValue?: NzSafeAny): NzSafeAny {
return propDecoratorFactory('InputNumber', (value: string | number) => toNumber(value, fallbackValue));
}

0 comments on commit f1088a4

Please sign in to comment.