diff --git a/components/affix/nz-affix.component.ts b/components/affix/nz-affix.component.ts index 746ad9e1814..4d2e9781492 100644 --- a/components/affix/nz-affix.component.ts +++ b/components/affix/nz-affix.component.ts @@ -46,6 +46,7 @@ interface SimpleRect { bottom?: number; } +const NZ_CONFIG_COMPONENT_NAME = 'affix'; const NZ_AFFIX_CLS_PREFIX = 'ant-affix'; const NZ_AFFIX_DEFAULT_SCROLL_TIME = 20; const NZ_AFFIX_RESPOND_EVENTS = ['resize', 'scroll', 'touchstart', 'touchmove', 'touchend', 'pageshow', 'load']; @@ -68,8 +69,16 @@ export class NzAffixComponent implements AfterViewInit, OnChanges, OnDestroy { @ViewChild('fixedEl', { static: true }) private fixedEl: ElementRef; @Input() nzTarget: string | Element | Window; - @Input() @WithConfig(0) @InputNumber() nzOffsetTop: null | number; - @Input() @WithConfig(null) @InputNumber() nzOffsetBottom: null | number; + + @Input() + @WithConfig(NZ_CONFIG_COMPONENT_NAME, 0) + @InputNumber() + nzOffsetTop: null | number; + + @Input() + @WithConfig(NZ_CONFIG_COMPONENT_NAME, null) + @InputNumber() + nzOffsetBottom: null | number; @Output() readonly nzChange = new EventEmitter(); @@ -153,7 +162,13 @@ export class NzAffixComponent implements AfterViewInit, OnChanges, OnDestroy { } private getTargetRect(target: Element | Window): SimpleRect { - return !isTargetWindow(target) ? target.getBoundingClientRect() : { top: 0, left: 0, bottom: 0 }; + return !isTargetWindow(target) + ? target.getBoundingClientRect() + : { + top: 0, + left: 0, + bottom: 0 + }; } private setAffixStyle(e: Event, affixStyle?: NgStyleInterface): void { @@ -196,7 +211,10 @@ export class NzAffixComponent implements AfterViewInit, OnChanges, OnDestroy { } this.placeholderNode.style.cssText = ''; this.placeholderStyle = undefined; - const styleObj = { width: this.placeholderNode.offsetWidth, height: this.fixedEl.nativeElement.offsetHeight }; + const styleObj = { + width: this.placeholderNode.offsetWidth, + height: this.fixedEl.nativeElement.offsetHeight + }; this.setAffixStyle(e, { ...this.affixStyle, ...styleObj @@ -269,7 +287,10 @@ export class NzAffixComponent implements AfterViewInit, OnChanges, OnDestroy { this.affixStyle.position === 'fixed' && this.placeholderNode.offsetWidth ) { - this.setAffixStyle(e, { ...this.affixStyle, width: this.placeholderNode.offsetWidth }); + this.setAffixStyle(e, { + ...this.affixStyle, + width: this.placeholderNode.offsetWidth + }); } else { this.setAffixStyle(e); } diff --git a/components/alert/nz-alert.component.ts b/components/alert/nz-alert.component.ts index 2c3a5df06d2..d528053d00a 100644 --- a/components/alert/nz-alert.component.ts +++ b/components/alert/nz-alert.component.ts @@ -19,6 +19,8 @@ import { } from '@angular/core'; import { slideAlertMotion, InputBoolean, NgClassType, NzConfigService, WithConfig } from 'ng-zorro-antd/core'; +const NZ_CONFIG_COMPONENT_NAME = 'alert'; + @Component({ selector: 'nz-alert', exportAs: 'nzAlert', @@ -41,8 +43,8 @@ export class NzAlertComponent implements OnChanges { @Input() nzMessage: string | TemplateRef; @Input() nzDescription: string | TemplateRef; @Input() nzType: 'success' | 'info' | 'warning' | 'error' = 'info'; - @Input() @WithConfig(false) @InputBoolean() nzCloseable: boolean; - @Input() @WithConfig(false) @InputBoolean() nzShowIcon: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzCloseable: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzShowIcon: boolean; @Input() @InputBoolean() nzBanner = false; @Output() readonly nzOnClose = new EventEmitter(); diff --git a/components/anchor/nz-anchor.component.ts b/components/anchor/nz-anchor.component.ts index 58740a4717e..e5314120e33 100644 --- a/components/anchor/nz-anchor.component.ts +++ b/components/anchor/nz-anchor.component.ts @@ -42,6 +42,7 @@ interface Section { top: number; } +const NZ_CONFIG_COMPONENT_NAME = 'anchor'; const sharpMatcherRegx = /#([^#]+)$/; @Component({ @@ -56,11 +57,19 @@ export class NzAnchorComponent implements OnDestroy, AfterViewInit { @ViewChild('ink', { static: false }) private ink: ElementRef; @Input() @InputBoolean() nzAffix = true; - @Input() @WithConfig(false) @InputBoolean() nzShowInkInFixed: boolean; - @Input() @WithConfig(5) @InputNumber() nzBounds: number; @Input() - @WithConfig() + @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) + @InputBoolean() + nzShowInkInFixed: boolean; + + @Input() + @WithConfig(NZ_CONFIG_COMPONENT_NAME, 5) + @InputNumber() + nzBounds: number; + + @Input() + @WithConfig(NZ_CONFIG_COMPONENT_NAME) set nzOffsetTop(value: number) { this._offsetTop = toNumber(value, 0); this.wrapperStyle = { diff --git a/components/avatar/nz-avatar.component.ts b/components/avatar/nz-avatar.component.ts index 54f9d8c3928..7149125d861 100644 --- a/components/avatar/nz-avatar.component.ts +++ b/components/avatar/nz-avatar.component.ts @@ -31,6 +31,8 @@ import { WithConfig } from 'ng-zorro-antd/core'; +const NZ_CONFIG_COMPONENT_NAME = 'avatar'; + @Component({ selector: 'nz-avatar', exportAs: 'nzAvatar', @@ -41,8 +43,8 @@ import { encapsulation: ViewEncapsulation.None }) export class NzAvatarComponent implements OnChanges { - @Input() @WithConfig('circle') nzShape: NzShapeSCType; - @Input() @WithConfig('default') nzSize: NzSizeLDSType | number; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'circle') nzShape: NzShapeSCType; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default') nzSize: NzSizeLDSType | number; @Input() nzText: string; @Input() nzSrc: string; @Input() nzSrcSet: string; diff --git a/components/back-top/nz-back-top.component.ts b/components/back-top/nz-back-top.component.ts index a229a367ce0..b5c7d36ec64 100644 --- a/components/back-top/nz-back-top.component.ts +++ b/components/back-top/nz-back-top.component.ts @@ -26,6 +26,8 @@ import { fadeMotion, InputNumber, NzConfigService, NzScrollService, WithConfig } import { fromEvent, Subscription } from 'rxjs'; import { distinctUntilChanged, throttleTime } from 'rxjs/operators'; +const NZ_CONFIG_COMPONENT_NAME = 'backTop'; + @Component({ selector: 'nz-back-top', exportAs: 'nzBackTop', @@ -42,7 +44,7 @@ export class NzBackTopComponent implements OnInit, OnDestroy { visible: boolean = false; @Input() nzTemplate: TemplateRef; - @Input() @WithConfig(400) @InputNumber() nzVisibilityHeight: number; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 400) @InputNumber() nzVisibilityHeight: number; @Input() set nzTarget(el: string | HTMLElement) { diff --git a/components/badge/nz-badge.component.ts b/components/badge/nz-badge.component.ts index 917af9d16f7..fff7f15c9cb 100644 --- a/components/badge/nz-badge.component.ts +++ b/components/badge/nz-badge.component.ts @@ -30,6 +30,8 @@ import { startWith, take, takeUntil } from 'rxjs/operators'; export type NzBadgeStatusType = 'success' | 'processing' | 'default' | 'error' | 'warning'; +const NZ_CONFIG_COMPONENT_NAME = 'backTop'; + @Component({ selector: 'nz-badge', exportAs: 'nzBadge', @@ -70,9 +72,9 @@ export class NzBadgeComponent implements OnInit, AfterViewInit, OnChanges, OnDes @Input() @InputBoolean() nzShowZero: boolean = false; @Input() @InputBoolean() nzShowDot = true; @Input() @InputBoolean() nzDot = false; - @Input() @WithConfig(99) nzOverflowCount: number; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 99) nzOverflowCount: number; @Input() nzText: string; - @Input() @WithConfig() nzColor: string; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) nzColor: string; @Input() nzTitle: string; @Input() nzStyle: { [key: string]: string }; @Input() nzStatus: NzBadgeStatusType; diff --git a/components/button/nz-button.component.ts b/components/button/nz-button.component.ts index 9c61da76547..9d782a755dd 100644 --- a/components/button/nz-button.component.ts +++ b/components/button/nz-button.component.ts @@ -35,7 +35,6 @@ import { findFirstNotEmptyNode, findLastNotEmptyNode, isEmpty, - trimComponentName, InputBoolean, NzConfigService, NzSizeLDSType, @@ -53,6 +52,8 @@ import { startWith, takeUntil } from 'rxjs/operators'; export type NzButtonType = 'primary' | 'dashed' | 'danger' | 'default' | 'link'; export type NzButtonShape = 'circle' | 'round' | null; +const NZ_CONFIG_COMPONENT_NAME = 'button'; + @Component({ selector: '[nz-button]', exportAs: 'nzButton', @@ -78,7 +79,7 @@ export class NzButtonComponent implements AfterContentInit, OnInit, OnDestroy, O @Input() @InputBoolean() nzLoading: boolean = false; @Input() nzType: NzButtonType = 'default'; @Input() nzShape: NzButtonShape = null; - @Input() @WithConfig('default') nzSize: NzSizeLDSType; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default') nzSize: NzSizeLDSType; readonly el: HTMLElement = this.elementRef.nativeElement; isInDropdown = false; @@ -155,7 +156,7 @@ export class NzButtonComponent implements AfterContentInit, OnInit, OnDestroy, O ) { this.renderer.addClass(elementRef.nativeElement, 'ant-btn'); this.nzConfigService - .getConfigChangeEventForComponent(trimComponentName(this.constructor.name)) + .getConfigChangeEventForComponent(NZ_CONFIG_COMPONENT_NAME) .pipe(takeUntil(this.destroy$)) .subscribe(() => { this.setClassMap(); diff --git a/components/card/nz-card.component.ts b/components/card/nz-card.component.ts index bc06148d515..f1d98aa4d9f 100755 --- a/components/card/nz-card.component.ts +++ b/components/card/nz-card.component.ts @@ -22,6 +22,8 @@ import { InputBoolean, NzConfigService, NzSizeDSType, WithConfig } from 'ng-zorr import { NzCardGridDirective } from './nz-card-grid.directive'; import { NzCardTabComponent } from './nz-card-tab.component'; +const NZ_CONFIG_COMPONENT_NAME = 'card'; + @Component({ selector: 'nz-card', exportAs: 'nzCard', @@ -47,14 +49,14 @@ import { NzCardTabComponent } from './nz-card-tab.component'; } }) export class NzCardComponent { - @Input() @WithConfig(true) @InputBoolean() nzBordered: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) @InputBoolean() nzBordered: boolean; @Input() @InputBoolean() nzLoading = false; - @Input() @WithConfig(false) @InputBoolean() nzHoverable: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzHoverable: boolean; @Input() nzBodyStyle: { [key: string]: string }; @Input() nzCover: TemplateRef; @Input() nzActions: Array> = []; @Input() nzType: string; - @Input() @WithConfig('default') nzSize: NzSizeDSType; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default') nzSize: NzSizeDSType; @Input() nzTitle: string | TemplateRef; @Input() nzExtra: string | TemplateRef; @ContentChild(NzCardTabComponent, { static: false }) tab: NzCardTabComponent; diff --git a/components/carousel/nz-carousel.component.ts b/components/carousel/nz-carousel.component.ts index 1e731ace135..b89f58b1556 100755 --- a/components/carousel/nz-carousel.component.ts +++ b/components/carousel/nz-carousel.component.ts @@ -57,6 +57,8 @@ import { NzCarouselBaseStrategy } from './strategies/base-strategy'; import { NzCarouselOpacityStrategy } from './strategies/opacity-strategy'; import { NzCarouselTransformStrategy } from './strategies/transform-strategy'; +const NZ_CONFIG_COMPONENT_NAME = 'carousel'; + @Component({ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, @@ -94,11 +96,11 @@ export class NzCarouselComponent implements AfterContentInit, AfterViewInit, OnD @ViewChild('slickTrack', { static: false }) slickTrack: ElementRef; @Input() nzDotRender: TemplateRef<{ $implicit: number }>; - @Input() @WithConfig('scrollx') nzEffect: NzCarouselEffects; - @Input() @WithConfig(true) @InputBoolean() nzEnableSwipe: boolean; - @Input() @WithConfig(true) @InputBoolean() nzDots: boolean; - @Input() @WithConfig(false) @InputBoolean() nzAutoPlay: boolean; - @Input() @WithConfig(3000) @InputNumber() nzAutoPlaySpeed: number; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'scrollx') nzEffect: NzCarouselEffects; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) @InputBoolean() nzEnableSwipe: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) @InputBoolean() nzDots: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzAutoPlay: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 3000) @InputNumber() nzAutoPlaySpeed: number; @Input() @InputNumber() nzTransitionSpeed = 500; @Input() @@ -113,7 +115,7 @@ export class NzCarouselComponent implements AfterContentInit, AfterViewInit, OnD } @Input() - @WithConfig('bottom') + @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'bottom') set nzDotPosition(value: NzCarouselDotPosition) { this._dotPosition = value; if (value === 'left' || value === 'right') { diff --git a/components/cascader/nz-cascader.component.ts b/components/cascader/nz-cascader.component.ts index 8f5ff080c64..b5cc53272b7 100644 --- a/components/cascader/nz-cascader.component.ts +++ b/components/cascader/nz-cascader.component.ts @@ -36,7 +36,6 @@ import { startWith, takeUntil } from 'rxjs/operators'; import { slideMotion, toArray, - trimComponentName, warnDeprecation, DEFAULT_DROPDOWN_POSITIONS, InputBoolean, @@ -60,6 +59,7 @@ import { import { NzCascaderOptionComponent } from './nz-cascader-li.component'; import { NzCascaderService } from './nz-cascader.service'; +const NZ_CONFIG_COMPONENT_NAME = 'cascader'; const defaultDisplayRender = (labels: string[]) => labels.join(' / '); @Component({ @@ -119,7 +119,7 @@ export class NzCascaderComponent implements NzCascaderComponentAsSource, OnInit, @Input() nzLabelRender: TemplateRef; @Input() nzLabelProperty = 'label'; @Input() nzNotFoundContent: string | TemplateRef; - @Input() @WithConfig('default') nzSize: NzCascaderSize; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default') nzSize: NzCascaderSize; @Input() nzShowSearch: boolean | NzShowSearchOptions; @Input() nzPlaceHolder: string; @Input() nzMenuClassName: string; @@ -274,7 +274,7 @@ export class NzCascaderComponent implements NzCascaderComponentAsSource, OnInit, }); this.nzConfigService - .getConfigChangeEventForComponent(trimComponentName(this.constructor.name)) + .getConfigChangeEventForComponent(NZ_CONFIG_COMPONENT_NAME) .pipe(takeUntil(this.$destroy)) .subscribe(() => { this.cdr.markForCheck(); diff --git a/components/collapse/nz-collapse-panel.component.ts b/components/collapse/nz-collapse-panel.component.ts index bf5dd5446cf..dc4473b3c4f 100644 --- a/components/collapse/nz-collapse-panel.component.ts +++ b/components/collapse/nz-collapse-panel.component.ts @@ -26,6 +26,8 @@ import { collapseMotion, InputBoolean, NzConfigService, WithConfig } from 'ng-zo import { NzCollapseComponent } from './nz-collapse.component'; +const NZ_CONFIG_COMPONENT_NAME = 'collapsePanel'; + @Component({ selector: 'nz-collapse-panel', exportAs: 'nzCollapsePanel', @@ -49,7 +51,7 @@ import { NzCollapseComponent } from './nz-collapse.component'; export class NzCollapsePanelComponent implements OnInit, OnDestroy { @Input() @InputBoolean() nzActive = false; @Input() @InputBoolean() nzDisabled = false; - @Input() @WithConfig(true) @InputBoolean() nzShowArrow: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) @InputBoolean() nzShowArrow: boolean; @Input() nzExtra: string | TemplateRef; @Input() nzHeader: string | TemplateRef; @Input() nzExpandedIcon: string | TemplateRef; diff --git a/components/collapse/nz-collapse.component.ts b/components/collapse/nz-collapse.component.ts index ebd548d0005..cbbee93fd1d 100644 --- a/components/collapse/nz-collapse.component.ts +++ b/components/collapse/nz-collapse.component.ts @@ -12,6 +12,8 @@ import { InputBoolean, NzConfigService, WithConfig } from 'ng-zorro-antd/core'; import { NzCollapsePanelComponent } from './nz-collapse-panel.component'; +const NZ_CONFIG_COMPONENT_NAME = 'collapse'; + @Component({ selector: 'nz-collapse', exportAs: 'nzCollapse', @@ -28,8 +30,8 @@ import { NzCollapsePanelComponent } from './nz-collapse-panel.component'; }) export class NzCollapseComponent { private listOfNzCollapsePanelComponent: NzCollapsePanelComponent[] = []; - @Input() @WithConfig(false) @InputBoolean() nzAccordion: boolean; - @Input() @WithConfig(true) @InputBoolean() nzBordered: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzAccordion: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) @InputBoolean() nzBordered: boolean; constructor(public nzConfigService: NzConfigService) {} diff --git a/components/core/config/config.service.ts b/components/core/config/config.service.ts index cf164c042a9..de33c3ee088 100644 --- a/components/core/config/config.service.ts +++ b/components/core/config/config.service.ts @@ -52,28 +52,14 @@ export class NzConfigService { // tslint:disable:no-invalid-this // tslint:disable:no-any -const lowercaseFirstLetter = (s: string): string => { - return s.charAt(0).toLowerCase() + s.slice(1); -}; - -export const trimComponentName = (componentName: string): NzConfigKey => { - return lowercaseFirstLetter( - componentName - .replace('Nz', '') - .replace(/(Component|Directive|Service|ContainerComponent)$/g, '') - .toLowerCase() - ) as NzConfigKey; -}; - /** * This decorator is used to decorate properties. If a property is decorated, it would try to load default value from * config. */ // tslint:disable-next-line:typedef -export function WithConfig(innerDefaultValue?: T) { +export function WithConfig(componentName: NzConfigKey, innerDefaultValue?: T) { return function ConfigDecorator(target: any, propName: any, originalDescriptor?: TypedPropertyDescriptor): any { const privatePropName = `$$__assignedValue__${propName}`; - const componentName = trimComponentName(target.constructor.name) as NzConfigKey; if (Object.prototype.hasOwnProperty.call(target, privatePropName)) { console.warn( diff --git a/components/core/config/config.spec.ts b/components/core/config/config.spec.ts index c1424248bf8..02c8f1887f7 100644 --- a/components/core/config/config.spec.ts +++ b/components/core/config/config.spec.ts @@ -9,7 +9,7 @@ import { NzConfigService, NZ_CONFIG, WithConfig } from 'ng-zorro-antd/core'; template: '' }) export class NzGlobalConfigTestBindTwiceComponent { - @WithConfig('b') @WithConfig('a') v: string; + @WithConfig('button', 'b') @WithConfig('button', 'a') v: string; constructor(public nzConfigService: NzConfigService) {} } diff --git a/components/descriptions/nz-descriptions.component.ts b/components/descriptions/nz-descriptions.component.ts index a66d4a964b5..563e24fe8fe 100644 --- a/components/descriptions/nz-descriptions.component.ts +++ b/components/descriptions/nz-descriptions.component.ts @@ -37,6 +37,7 @@ import { import { NzDescriptionsItemRenderProps, NzDescriptionsLayout, NzDescriptionsSize } from './nz-descriptions-definitions'; import { NzDescriptionsItemComponent } from './nz-descriptions-item.component'; +const NZ_CONFIG_COMPONENT_NAME = 'descriptions'; const defaultColumnMap: { [key in NzBreakpoint]: number } = { xxl: 3, xl: 3, @@ -70,12 +71,12 @@ const defaultColumnMap: { [key in NzBreakpoint]: number } = { export class NzDescriptionsComponent implements OnChanges, OnDestroy, AfterContentInit { @ContentChildren(NzDescriptionsItemComponent) items: QueryList; - @Input() @InputBoolean() @WithConfig(false) nzBordered: boolean; + @Input() @InputBoolean() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) nzBordered: boolean; @Input() nzLayout: NzDescriptionsLayout = 'horizontal'; - @Input() @WithConfig(defaultColumnMap) nzColumn: number | { [key in NzBreakpoint]: number }; - @Input() @WithConfig('default') nzSize: NzDescriptionsSize; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, defaultColumnMap) nzColumn: number | { [key in NzBreakpoint]: number }; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default') nzSize: NzDescriptionsSize; @Input() nzTitle: string | TemplateRef = ''; - @Input() @WithConfig(true) @InputBoolean() nzColon: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) @InputBoolean() nzColon: boolean; itemMatrix: NzDescriptionsItemRenderProps[][] = []; diff --git a/components/drawer/nz-drawer.component.ts b/components/drawer/nz-drawer.component.ts index 43a4ef5fce3..ba117a123c1 100644 --- a/components/drawer/nz-drawer.component.ts +++ b/components/drawer/nz-drawer.component.ts @@ -43,6 +43,8 @@ import { NzDrawerRef } from './nz-drawer-ref'; export const DRAWER_ANIMATE_DURATION = 300; +const NZ_CONFIG_COMPONENT_NAME = 'drawer'; + @Component({ selector: 'nz-drawer', exportAs: 'nzDrawer', @@ -55,8 +57,8 @@ export class NzDrawerComponent extends NzDrawerRef implements OnInit, OnDestroy, AfterViewInit, OnChanges, NzDrawerOptionsOfComponent { @Input() nzContent: TemplateRef<{ $implicit: D; drawerRef: NzDrawerRef }> | Type; @Input() @InputBoolean() nzClosable: boolean = true; - @Input() @WithConfig(true) @InputBoolean() nzMaskClosable: boolean; - @Input() @WithConfig(true) @InputBoolean() nzMask: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) @InputBoolean() nzMaskClosable: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) @InputBoolean() nzMask: boolean; @Input() @InputBoolean() nzNoAnimation = false; @Input() @InputBoolean() nzKeyboard: boolean = true; @Input() nzTitle: string | TemplateRef<{}>; diff --git a/components/form/nz-form.directive.ts b/components/form/nz-form.directive.ts index 73dda6e3188..36e13502353 100644 --- a/components/form/nz-form.directive.ts +++ b/components/form/nz-form.directive.ts @@ -26,6 +26,8 @@ import { InputBoolean, NzConfigService, NzUpdateHostClassService, WithConfig } f import { NzFormLabelComponent } from './nz-form-label.component'; +const NZ_CONFIG_COMPONENT_NAME = 'form'; + @Directive({ selector: '[nz-form]', exportAs: 'nzForm', @@ -33,7 +35,7 @@ import { NzFormLabelComponent } from './nz-form-label.component'; }) export class NzFormDirective implements OnInit, OnChanges, AfterContentInit, OnDestroy { @Input() nzLayout = 'horizontal'; - @Input() @WithConfig(false) @InputBoolean() nzNoColon: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzNoColon: boolean; @ContentChildren(NzFormLabelComponent, { descendants: true }) nzFormLabelComponent: QueryList; diff --git a/components/icon/nz-icon.service.ts b/components/icon/nz-icon.service.ts index 0f85131ec61..d82488cac8c 100644 --- a/components/icon/nz-icon.service.ts +++ b/components/icon/nz-icon.service.ts @@ -49,7 +49,7 @@ import { UploadOutline, UpOutline } from '@ant-design/icons-angular/icons'; -import { trimComponentName, warn, warnDeprecation, IconConfig, NzConfigService } from 'ng-zorro-antd/core'; +import { warn, warnDeprecation, IconConfig, NzConfigService } from 'ng-zorro-antd/core'; import { Subject } from 'rxjs'; export interface NzIconfontOption { @@ -57,11 +57,8 @@ export interface NzIconfontOption { } export const NZ_ICONS = new InjectionToken('nz_icons'); - export const NZ_ICON_DEFAULT_TWOTONE_COLOR = new InjectionToken('nz_icon_default_twotone_color'); - export const DEFAULT_TWOTONE_COLOR = '#1890ff'; - export const NZ_ICONS_USED_BY_ZORRO: IconDefinition[] = [ BarsOutline, CalendarOutline, @@ -186,7 +183,7 @@ export class NzIconService extends IconService { } private onConfigChange(): void { - this.nzConfigService.getConfigChangeEventForComponent(trimComponentName(this.constructor.name)).subscribe(() => { + this.nzConfigService.getConfigChangeEventForComponent('icon').subscribe(() => { this.configDefaultTwotoneColor(); this.configDefaultTheme(); this.configUpdated$.next(); @@ -216,6 +213,6 @@ export class NzIconService extends IconService { } private getConfig(): IconConfig { - return (this.nzConfigService.getConfigForComponent(trimComponentName(this.constructor.name)) as IconConfig) || {}; + return this.nzConfigService.getConfigForComponent('icon') || {}; } } diff --git a/components/message/nz-message-container.component.ts b/components/message/nz-message-container.component.ts index ebbadb81518..4dbc0b924ba 100644 --- a/components/message/nz-message-container.component.ts +++ b/components/message/nz-message-container.component.ts @@ -17,11 +17,13 @@ import { } from '@angular/core'; import { Subject } from 'rxjs'; -import { toCssPixel, trimComponentName, warnDeprecation, NzConfigService } from 'ng-zorro-antd/core'; +import { toCssPixel, warnDeprecation, NzConfigService } from 'ng-zorro-antd/core'; import { NzMessageConfigLegacy, NZ_MESSAGE_CONFIG, NZ_MESSAGE_DEFAULT_CONFIG } from './nz-message-config'; import { NzMessageDataFilled, NzMessageDataOptions } from './nz-message.definitions'; +const NZ_CONFIG_COMPONENT_NAME = 'message'; + @Component({ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, @@ -100,16 +102,14 @@ export class NzMessageContainerComponent implements OnInit { } protected subscribeConfigChange(): void { - this.nzConfigService - .getConfigChangeEventForComponent(trimComponentName(this.constructor.name)) - .subscribe(() => this.setConfig()); + this.nzConfigService.getConfigChangeEventForComponent(NZ_CONFIG_COMPONENT_NAME).subscribe(() => this.setConfig()); } protected mergeMessageConfig(config?: NzMessageConfigLegacy): Required { return { ...this.config, ...config, - ...this.nzConfigService.getConfigForComponent(trimComponentName(this.constructor.name)) + ...this.nzConfigService.getConfigForComponent(NZ_CONFIG_COMPONENT_NAME) }; } diff --git a/components/modal/nz-modal.component.ts b/components/modal/nz-modal.component.ts index 351ac489373..0d6f85df4ca 100644 --- a/components/modal/nz-modal.component.ts +++ b/components/modal/nz-modal.component.ts @@ -56,9 +56,11 @@ import { NzModalRef } from './nz-modal-ref.class'; import { ModalButtonOptions, ModalOptions, ModalType, OnClickCallback } from './nz-modal.type'; export const MODAL_ANIMATE_DURATION = 200; // Duration when perform animations (ms) +export const WRAP_CLASS_NAME = 'ant-modal-wrap'; type AnimationState = 'enter' | 'leave' | null; -export const WRAP_CLASS_NAME = 'ant-modal-wrap'; + +const NZ_CONFIG_COMPONENT_NAME = 'modal'; @Component({ selector: 'nz-modal', @@ -81,8 +83,8 @@ export class NzModalComponent extends NzModalRef @Input() @InputBoolean() nzNoAnimation = false; // TODO(hsuanxyz): add default value once old API is deprecated. - @Input() @WithConfig() @InputBoolean() nzMask: boolean; - @Input() @WithConfig() @InputBoolean() nzMaskClosable: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) @InputBoolean() nzMask: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) @InputBoolean() nzMaskClosable: boolean; @Input() nzContent: string | TemplateRef<{}> | Type; // [STATIC] If not specified, will use @Input() nzComponentParams: T; // [STATIC] ONLY avaliable when nzContent is a component diff --git a/components/notification/nz-notification-container.component.ts b/components/notification/nz-notification-container.component.ts index 4b533837448..cf3311b366f 100644 --- a/components/notification/nz-notification-container.component.ts +++ b/components/notification/nz-notification-container.component.ts @@ -16,7 +16,7 @@ import { } from '@angular/core'; import { Subject } from 'rxjs'; -import { toCssPixel, trimComponentName, warnDeprecation, NzConfigService } from 'ng-zorro-antd/core'; +import { toCssPixel, warnDeprecation, NzConfigService } from 'ng-zorro-antd/core'; import { NzMessageContainerComponent } from 'ng-zorro-antd/message'; import { @@ -26,6 +26,8 @@ import { } from './nz-notification-config'; import { NzNotificationDataFilled, NzNotificationDataOptions } from './nz-notification.definitions'; +const NZ_CONFIG_COMPONENT_NAME = 'notification'; + @Component({ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, @@ -64,7 +66,7 @@ export class NzNotificationContainerComponent extends NzMessageContainerComponen const newConfig = (this.config = { ...this.config, ...config, - ...this.nzConfigService.getConfigForComponent(trimComponentName(this.constructor.name)) + ...this.nzConfigService.getConfigForComponent(NZ_CONFIG_COMPONENT_NAME) }); const placement = this.config.nzPlacement; @@ -104,9 +106,7 @@ export class NzNotificationContainerComponent extends NzMessageContainerComponen * @override */ protected subscribeConfigChange(): void { - this.nzConfigService - .getConfigChangeEventForComponent(trimComponentName(this.constructor.name)) - .subscribe(() => this.setConfig()); + this.nzConfigService.getConfigChangeEventForComponent(NZ_CONFIG_COMPONENT_NAME).subscribe(() => this.setConfig()); } private replaceNotification(old: NzNotificationDataFilled, _new: NzNotificationDataFilled): void { diff --git a/components/progress/nz-progress.component.ts b/components/progress/nz-progress.component.ts index 16a2790565d..683a0ba4ce9 100644 --- a/components/progress/nz-progress.component.ts +++ b/components/progress/nz-progress.component.ts @@ -17,14 +17,7 @@ import { ViewEncapsulation } from '@angular/core'; -import { - isNotNil, - trimComponentName, - InputNumber, - NgStyleInterface, - NzConfigService, - WithConfig -} from 'ng-zorro-antd/core'; +import { isNotNil, InputNumber, NgStyleInterface, NzConfigService, WithConfig } from 'ng-zorro-antd/core'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; @@ -43,6 +36,7 @@ import { let gradientIdSeed = 0; +const NZ_CONFIG_COMPONENT_NAME = 'progress'; const statusIconNameMap = new Map([['success', 'check'], ['exception', 'close']]); const statusColorMap = new Map([['normal', '#108ee9'], ['exception', '#ff5500'], ['success', '#87d068']]); const defaultFormatter: NzProgressFormatter = (p: number): string => `${p}%`; @@ -56,19 +50,19 @@ const defaultFormatter: NzProgressFormatter = (p: number): string => `${p}%`; templateUrl: './nz-progress.component.html' }) export class NzProgressComponent implements OnChanges, OnInit, OnDestroy { - @Input() @WithConfig(true) nzShowInfo: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) nzShowInfo: boolean; @Input() nzWidth = 132; - @Input() @WithConfig() nzStrokeColor: NzProgressStrokeColorType; - @Input() @WithConfig('default') nzSize: 'default' | 'small'; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) nzStrokeColor: NzProgressStrokeColorType; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default') nzSize: 'default' | 'small'; @Input() nzFormat?: NzProgressFormatter; @Input() @InputNumber() nzSuccessPercent?: number; @Input() @InputNumber() nzPercent: number = 0; - @Input() @WithConfig() @InputNumber() nzStrokeWidth: number; - @Input() @WithConfig() @InputNumber() nzGapDegree: number; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) @InputNumber() nzStrokeWidth: number; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) @InputNumber() nzGapDegree: number; @Input() nzStatus: NzProgressStatusType; @Input() nzType: NzProgressTypeType = 'line'; - @Input() @WithConfig('top') nzGapPosition: NzProgressGapPositionType; - @Input() @WithConfig('round') nzStrokeLinecap: NzProgressStrokeLinecapType; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'top') nzGapPosition: NzProgressGapPositionType; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'round') nzStrokeLinecap: NzProgressStrokeLinecapType; /** Gradient style when `nzType` is `line`. */ lineGradient: string | null = null; @@ -159,7 +153,7 @@ export class NzProgressComponent implements OnChanges, OnInit, OnDestroy { ngOnInit(): void { this.nzConfigService - .getConfigChangeEventForComponent(trimComponentName(this.constructor.name)) + .getConfigChangeEventForComponent(NZ_CONFIG_COMPONENT_NAME) .pipe(takeUntil(this.destroy$)) .subscribe(() => { this.updateIcon(); diff --git a/components/rate/nz-rate.component.ts b/components/rate/nz-rate.component.ts index 73a07023c18..08fba2341d8 100644 --- a/components/rate/nz-rate.component.ts +++ b/components/rate/nz-rate.component.ts @@ -27,11 +27,13 @@ import { ViewEncapsulation } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; - -import { trimComponentName, InputBoolean, NgClassType, NzConfigService, WithConfig } from 'ng-zorro-antd/core'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; +import { InputBoolean, NgClassType, NzConfigService, WithConfig } from 'ng-zorro-antd/core'; + +const NZ_CONFIG_COMPONENT_NAME = 'rate'; + @Component({ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, @@ -50,8 +52,8 @@ import { takeUntil } from 'rxjs/operators'; export class NzRateComponent implements OnInit, OnDestroy, ControlValueAccessor, AfterViewInit, OnChanges { @ViewChild('ulElement', { static: false }) private ulElement: ElementRef; - @Input() @WithConfig(true) @InputBoolean() nzAllowClear: boolean; - @Input() @WithConfig(false) @InputBoolean() nzAllowHalf: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) @InputBoolean() nzAllowClear: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzAllowHalf: boolean; @Input() @InputBoolean() nzDisabled: boolean = false; @Input() @InputBoolean() nzAutoFocus: boolean = false; @Input() nzCharacter: TemplateRef; @@ -117,7 +119,7 @@ export class NzRateComponent implements OnInit, OnDestroy, ControlValueAccessor, this.updateStarArray(); this.nzConfigService - .getConfigChangeEventForComponent(trimComponentName(this.constructor.name)) + .getConfigChangeEventForComponent(NZ_CONFIG_COMPONENT_NAME) .pipe(takeUntil(this.destroy$)) .subscribe(() => this.cdr.markForCheck()); } diff --git a/components/spin/nz-spin.component.ts b/components/spin/nz-spin.component.ts index 657fdb9cd33..b010e4d9610 100644 --- a/components/spin/nz-spin.component.ts +++ b/components/spin/nz-spin.component.ts @@ -21,14 +21,9 @@ import { import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs'; import { debounceTime, takeUntil } from 'rxjs/operators'; -import { - trimComponentName, - InputBoolean, - InputNumber, - NzConfigService, - NzSizeLDSType, - WithConfig -} from 'ng-zorro-antd/core'; +import { InputBoolean, InputNumber, NzConfigService, NzSizeLDSType, WithConfig } from 'ng-zorro-antd/core'; + +const NZ_CONFIG_COMPONENT_NAME = 'spin'; @Component({ selector: 'nz-spin', @@ -49,7 +44,7 @@ import { ] }) export class NzSpinComponent implements OnChanges, OnDestroy, OnInit { - @Input() @WithConfig() nzIndicator: TemplateRef; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) nzIndicator: TemplateRef; @Input() nzSize: NzSizeLDSType = 'default'; @Input() nzTip: string; @Input() @InputNumber() nzDelay = 0; @@ -82,7 +77,7 @@ export class NzSpinComponent implements OnChanges, OnDestroy, OnInit { this.subscribeLoading(); this.nzConfigService - .getConfigChangeEventForComponent(trimComponentName(this.constructor.name)) + .getConfigChangeEventForComponent(NZ_CONFIG_COMPONENT_NAME) .pipe(takeUntil(this.destroy$)) .subscribe(() => this.cdr.markForCheck()); } diff --git a/components/switch/nz-switch.component.ts b/components/switch/nz-switch.component.ts index 3742b130589..950017a37b9 100644 --- a/components/switch/nz-switch.component.ts +++ b/components/switch/nz-switch.component.ts @@ -25,6 +25,8 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { InputBoolean, NzConfigService, NzSizeDSType, WithConfig } from 'ng-zorro-antd/core'; +const NZ_CONFIG_COMPONENT_NAME = 'switch'; + @Component({ selector: 'nz-switch', exportAs: 'nzSwitch', @@ -60,7 +62,7 @@ export class NzSwitchComponent implements ControlValueAccessor, AfterViewInit, O @Input() @InputBoolean() nzControl = false; @Input() nzCheckedChildren: string | TemplateRef; @Input() nzUnCheckedChildren: string | TemplateRef; - @Input() @WithConfig('default') nzSize: NzSizeDSType; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default') nzSize: NzSizeDSType; hostClick(e: MouseEvent): void { e.preventDefault(); diff --git a/components/table/nz-table.component.ts b/components/table/nz-table.component.ts index 938a52541cc..aaf5d0a57d2 100644 --- a/components/table/nz-table.component.ts +++ b/components/table/nz-table.component.ts @@ -50,6 +50,8 @@ import { NzThComponent } from './nz-th.component'; import { NzTheadComponent } from './nz-thead.component'; import { NzVirtualScrollDirective } from './nz-virtual-scroll.directive'; +const NZ_CONFIG_COMPONENT_NAME = 'table'; + @Component({ selector: 'nz-table', exportAs: 'nzTable', @@ -89,7 +91,7 @@ export class NzTableComponent implements OnInit, AfterViewInit, OnDestr @ViewChild(CdkVirtualScrollViewport, { static: false, read: CdkVirtualScrollViewport }) cdkVirtualScrollViewport: CdkVirtualScrollViewport; @ContentChild(NzVirtualScrollDirective, { static: false }) nzVirtualScrollDirective: NzVirtualScrollDirective; - @Input() @WithConfig('default') nzSize: NzSizeMDSType; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default') nzSize: NzSizeMDSType; @Input() nzShowTotal: TemplateRef<{ $implicit: number; range: [number, number] }>; @Input() nzPageSizeOptions = [10, 20, 30, 40, 50]; @Input() @InputBoolean() nzVirtualScroll = false; @@ -119,13 +121,13 @@ export class NzTableComponent implements OnInit, AfterViewInit, OnDestr @Input() @InputBoolean() nzFrontPagination = true; @Input() @InputBoolean() nzTemplateMode = false; - @Input() @WithConfig(false) @InputBoolean() nzBordered: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzBordered: boolean; @Input() @InputBoolean() nzShowPagination = true; @Input() @InputBoolean() nzLoading = false; - @Input() @WithConfig(false) @InputBoolean() nzShowSizeChanger: boolean; - @Input() @WithConfig(false) @InputBoolean() nzHideOnSinglePage: boolean; - @Input() @WithConfig(false) @InputBoolean() nzShowQuickJumper: boolean; - @Input() @WithConfig(false) @InputBoolean() nzSimple: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzShowSizeChanger: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzHideOnSinglePage: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzShowQuickJumper: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzSimple: boolean; @Output() readonly nzPageSizeChange: EventEmitter = new EventEmitter(); @Output() readonly nzPageIndexChange: EventEmitter = new EventEmitter(); /* tslint:disable-next-line:no-any */ diff --git a/components/tabs/nz-tabset.component.ts b/components/tabs/nz-tabset.component.ts index 419b216d353..8f319fd01ce 100644 --- a/components/tabs/nz-tabset.component.ts +++ b/components/tabs/nz-tabset.component.ts @@ -63,6 +63,8 @@ export type NzTabPosition = NzFourDirectionType; export type NzTabPositionMode = 'horizontal' | 'vertical'; export type NzTabType = 'line' | 'card'; +const NZ_CONFIG_COMPONENT_NAME = 'tabs'; + @Component({ selector: 'nz-tabset', exportAs: 'nzTabset', @@ -97,14 +99,14 @@ export class NzTabSetComponent @ViewChild('tabContent', { static: false }) tabContent: ElementRef; @Input() nzTabBarExtraContent: TemplateRef; - @Input() @WithConfig(true) nzShowPagination: boolean; - @Input() @WithConfig(true) nzAnimated: NzAnimatedInterface | boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) nzShowPagination: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) nzAnimated: NzAnimatedInterface | boolean; @Input() nzHideAll = false; @Input() nzTabPosition: NzTabPosition = 'top'; - @Input() @WithConfig('default') nzSize: NzSizeLDSType; - @Input() @WithConfig() nzTabBarGutter: number; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default') nzSize: NzSizeLDSType; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) nzTabBarGutter: number; @Input() nzTabBarStyle: { [key: string]: string }; - @Input() @WithConfig('line') nzType: NzTabType; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'line') nzType: NzTabType; @Input() @InputBoolean() nzLinkRouter = false; @Input() @InputBoolean() nzLinkExact = true; diff --git a/components/time-picker/nz-time-picker.component.ts b/components/time-picker/nz-time-picker.component.ts index 5d5c1d5e9ab..9fedc7787c1 100644 --- a/components/time-picker/nz-time-picker.component.ts +++ b/components/time-picker/nz-time-picker.component.ts @@ -35,6 +35,8 @@ import { WithConfig } from 'ng-zorro-antd/core'; +const NZ_CONFIG_COMPONENT_NAME = 'timePicker'; + @Component({ encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, @@ -62,24 +64,24 @@ export class NzTimePickerComponent implements ControlValueAccessor, OnInit, Afte ]; @ViewChild('inputElement', { static: true }) inputRef: ElementRef; @Input() nzSize: string | null = null; - @Input() @WithConfig(1) nzHourStep: number; - @Input() @WithConfig(1) nzMinuteStep: number; - @Input() @WithConfig(1) nzSecondStep: number; - @Input() @WithConfig('clear') nzClearText: string; - @Input() @WithConfig() nzPopupClassName: string; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 1) nzHourStep: number; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 1) nzMinuteStep: number; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 1) nzSecondStep: number; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'clear') nzClearText: string; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) nzPopupClassName: string; @Input() nzPlaceHolder = ''; @Input() nzAddOn: TemplateRef; @Input() nzDefaultOpenValue = new Date(); @Input() nzDisabledHours: () => number[]; @Input() nzDisabledMinutes: (hour: number) => number[]; @Input() nzDisabledSeconds: (hour: number, minute: number) => number[]; - @Input() @WithConfig('HH:mm:ss') nzFormat: string; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'HH:mm:ss') nzFormat: string; @Input() nzOpen = false; - @Input() @WithConfig(false) @InputBoolean() nzUse12Hours: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzUse12Hours: boolean; @Output() readonly nzOpenChange = new EventEmitter(); @Input() @InputBoolean() nzHideDisabledOptions = false; - @Input() @WithConfig(true) @InputBoolean() nzAllowEmpty: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) @InputBoolean() nzAllowEmpty: boolean; @Input() @InputBoolean() nzDisabled = false; @Input() @InputBoolean() nzAutoFocus = false; diff --git a/components/tree-select/nz-tree-select.component.ts b/components/tree-select/nz-tree-select.component.ts index 4e38abcc6ec..b739b0dae70 100644 --- a/components/tree-select/nz-tree-select.component.ts +++ b/components/tree-select/nz-tree-select.component.ts @@ -59,6 +59,8 @@ export function higherOrderServiceFactory(injector: Injector): NzTreeBaseService return injector.get(NzTreeSelectService); } +const NZ_CONFIG_COMPONENT_NAME = 'treeSelect'; + @Component({ selector: 'nz-tree-select', exportAs: 'nzTreeSelect', @@ -104,10 +106,10 @@ export class NzTreeSelectComponent extends NzTreeBase implements ControlValueAcc @Input() @InputBoolean() nzAllowClear: boolean = true; @Input() @InputBoolean() nzShowExpand: boolean = true; @Input() @InputBoolean() nzShowLine: boolean = false; - @Input() @InputBoolean() @WithConfig(true) nzDropdownMatchSelectWidth: boolean; + @Input() @InputBoolean() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) nzDropdownMatchSelectWidth: boolean; @Input() @InputBoolean() nzCheckable: boolean = false; - @Input() @InputBoolean() @WithConfig(false) nzHideUnMatched: boolean; - @Input() @InputBoolean() @WithConfig(false) nzShowIcon: boolean; + @Input() @InputBoolean() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) nzHideUnMatched: boolean; + @Input() @InputBoolean() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) nzShowIcon: boolean; @Input() @InputBoolean() nzShowSearch: boolean = false; @Input() @InputBoolean() nzDisabled = false; @Input() @InputBoolean() nzAsyncData = false; @@ -118,7 +120,7 @@ export class NzTreeSelectComponent extends NzTreeBase implements ControlValueAcc @Input() nzNotFoundContent: string; @Input() nzNodes: Array = []; @Input() nzOpen = false; - @Input() @WithConfig('default') nzSize: NzSizeLDSType; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default') nzSize: NzSizeLDSType; @Input() nzPlaceHolder = ''; @Input() nzDropdownStyle: { [key: string]: string }; /** diff --git a/components/tree/nz-tree.component.ts b/components/tree/nz-tree.component.ts index 073f13d0eb2..91277e9cca7 100644 --- a/components/tree/nz-tree.component.ts +++ b/components/tree/nz-tree.component.ts @@ -53,6 +53,8 @@ export function NzTreeServiceFactory( return higherOrderService ? higherOrderService : treeService; } +const NZ_CONFIG_COMPONENT_NAME = 'tree'; + @Component({ selector: 'nz-tree', exportAs: 'nzTree', @@ -73,7 +75,7 @@ export function NzTreeServiceFactory( ] }) export class NzTreeComponent extends NzTreeBase implements OnInit, OnDestroy, ControlValueAccessor, OnChanges { - @Input() @InputBoolean() @WithConfig(false) nzShowIcon: boolean; + @Input() @InputBoolean() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) nzShowIcon: boolean; @Input() @InputBoolean() nzShowExpand: boolean = true; @Input() @InputBoolean() nzShowLine = false; @Input() nzExpandedIcon: TemplateRef<{ $implicit: NzTreeNode }>; @@ -81,10 +83,10 @@ export class NzTreeComponent extends NzTreeBase implements OnInit, OnDestroy, Co @Input() @InputBoolean() nzAsyncData = false; @Input() @InputBoolean() nzDraggable: boolean = false; - @Input() @InputBoolean() @WithConfig(false) nzHideUnMatched: boolean; + @Input() @InputBoolean() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) nzHideUnMatched: boolean; @Input() @InputBoolean() nzSelectMode = false; @Input() @InputBoolean() nzCheckStrictly = false; - @Input() @WithConfig(false) @InputBoolean() nzBlockNode: boolean; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzBlockNode: boolean; @Input() @InputBoolean() nzExpandAll = false; @Input() nzTreeTemplate: TemplateRef<{ $implicit: NzTreeNode }>; diff --git a/components/typography/nz-typography.component.ts b/components/typography/nz-typography.component.ts index 2774fad0460..1bc36cd5fdb 100644 --- a/components/typography/nz-typography.component.ts +++ b/components/typography/nz-typography.component.ts @@ -47,6 +47,8 @@ import { NzI18nService } from 'ng-zorro-antd/i18n'; import { NzTextCopyComponent } from './nz-text-copy.component'; import { NzTextEditComponent } from './nz-text-edit.component'; +const NZ_CONFIG_COMPONENT_NAME = 'typography'; + @Component({ selector: ` nz-typography, @@ -80,7 +82,7 @@ export class NzTypographyComponent implements OnInit, AfterViewInit, OnDestroy, @Input() @InputBoolean() nzExpandable = false; @Input() @InputBoolean() nzEllipsis = false; @Input() nzContent: string; - @Input() @WithConfig(1) @InputNumber() nzEllipsisRows: number; + @Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 1) @InputNumber() nzEllipsisRows: number; @Input() nzType: 'secondary' | 'warning' | 'danger' | undefined; @Input() nzCopyText: string | undefined; @Output() readonly nzContentChange = new EventEmitter();