Skip to content

Commit

Permalink
feat: support strictTemplates for public components (NG-ZORRO#5006)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuanxyz authored Apr 15, 2020
1 parent 4eec497 commit a3180d0
Show file tree
Hide file tree
Showing 90 changed files with 691 additions and 79 deletions.
5 changes: 4 additions & 1 deletion components/affix/affix.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from '@angular/core';
import { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { NzScrollService } from 'ng-zorro-antd/core/services';
import { NgStyleInterface, NzSafeAny } from 'ng-zorro-antd/core/types';
import { NgStyleInterface, NumberInput, NzSafeAny } from 'ng-zorro-antd/core/types';
import { getStyleAsText, InputNumber, shallowEqual } from 'ng-zorro-antd/core/util';

import { fromEvent, merge, ReplaySubject, Subject, Subscription } from 'rxjs';
Expand All @@ -52,6 +52,9 @@ const NZ_AFFIX_DEFAULT_SCROLL_TIME = 20;
encapsulation: ViewEncapsulation.None
})
export class NzAffixComponent implements AfterViewInit, OnChanges, OnDestroy {
static ngAcceptInputType_nzOffsetTop: NumberInput;
static ngAcceptInputType_nzOffsetBottom: NumberInput;

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

@Input() nzTarget: string | Element | Window;
Expand Down
5 changes: 5 additions & 0 deletions components/alert/alert.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from '@angular/core';
import { slideAlertMotion } from 'ng-zorro-antd/core/animation';
import { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { BooleanInput } from 'ng-zorro-antd/core/types';
import { InputBoolean } from 'ng-zorro-antd/core/util';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
Expand Down Expand Up @@ -72,6 +73,10 @@ const NZ_CONFIG_COMPONENT_NAME = 'alert';
preserveWhitespaces: false
})
export class NzAlertComponent implements OnChanges, OnDestroy {
static ngAcceptInputType_nzCloseable: BooleanInput;
static ngAcceptInputType_nzShowIcon: BooleanInput;
static ngAcceptInputType_nzBanner: BooleanInput;

@Input() nzCloseText: string | TemplateRef<void> | null = null;
@Input() nzIconType: string | null = null;
@Input() nzMessage: string | TemplateRef<void> | null = null;
Expand Down
7 changes: 6 additions & 1 deletion components/anchor/anchor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
import { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { warnDeprecation } from 'ng-zorro-antd/core/logger';
import { NzScrollService } from 'ng-zorro-antd/core/services';
import { NgStyleInterface, NzSafeAny } from 'ng-zorro-antd/core/types';
import { BooleanInput, NgStyleInterface, NumberInput, NzSafeAny } from 'ng-zorro-antd/core/types';
import { InputBoolean, InputNumber } from 'ng-zorro-antd/core/util';
import { fromEvent, Subject } from 'rxjs';
import { takeUntil, throttleTime } from 'rxjs/operators';
Expand Down Expand Up @@ -68,6 +68,11 @@ const sharpMatcherRegx = /#([^#]+)$/;
changeDetection: ChangeDetectionStrategy.OnPush
})
export class NzAnchorComponent implements OnDestroy, AfterViewInit, OnChanges {
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;
Expand Down
4 changes: 3 additions & 1 deletion components/auto-complete/autocomplete-option.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
Output,
ViewEncapsulation
} from '@angular/core';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { BooleanInput, NzSafeAny } from 'ng-zorro-antd/core/types';
import { InputBoolean, scrollIntoView } from 'ng-zorro-antd/core/util';

import { NzAutocompleteOptgroupComponent } from './autocomplete-optgroup.component';
Expand Down Expand Up @@ -52,6 +52,8 @@ export class NzOptionSelectionChange {
}
})
export class NzAutocompleteOptionComponent {
static ngAcceptInputType_nzDisabled: BooleanInput;

@Input() nzValue: NzSafeAny;
@Input() nzLabel: string;
@Input() @InputBoolean() nzDisabled = false;
Expand Down
5 changes: 4 additions & 1 deletion components/auto-complete/autocomplete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from '@angular/core';
import { slideMotion } from 'ng-zorro-antd/core/animation';
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
import { CompareWith, NzDropDownPosition, NzSafeAny } from 'ng-zorro-antd/core/types';
import { BooleanInput, CompareWith, NzDropDownPosition, NzSafeAny } from 'ng-zorro-antd/core/types';
import { InputBoolean } from 'ng-zorro-antd/core/util';
import { defer, merge, Observable, Subscription } from 'rxjs';
import { filter, switchMap, take } from 'rxjs/operators';
Expand Down Expand Up @@ -78,6 +78,9 @@ export type AutocompleteDataSource = AutocompleteDataSourceItem[] | string[] | n
animations: [slideMotion]
})
export class NzAutocompleteComponent implements AfterContentInit, AfterViewInit, OnDestroy {
static ngAcceptInputType_nzDefaultActiveFirstOption: BooleanInput;
static ngAcceptInputType_nzBackfill: BooleanInput;

@Input() nzWidth: number;
@Input() nzOverlayClassName = '';
@Input() nzOverlayStyle: { [key: string]: string } = {};
Expand Down
4 changes: 3 additions & 1 deletion components/back-top/back-top.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { fadeMotion } from 'ng-zorro-antd/core/animation';
import { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { NzScrollService } from 'ng-zorro-antd/core/services';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { NumberInput, NzSafeAny } from 'ng-zorro-antd/core/types';
import { InputNumber } from 'ng-zorro-antd/core/util';

import { fromEvent, Subject } from 'rxjs';
Expand All @@ -54,6 +54,8 @@ const NZ_CONFIG_COMPONENT_NAME = 'backTop';
preserveWhitespaces: false
})
export class NzBackTopComponent implements OnInit, OnDestroy, OnChanges {
static ngAcceptInputType_nzVisibilityHeight: NumberInput;

private scrollListenerDestroy$ = new Subject();
private target: HTMLElement | null = null;

Expand Down
5 changes: 5 additions & 0 deletions components/badge/badge.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from '@angular/core';
import { zoomBadgeMotion } from 'ng-zorro-antd/core/animation';
import { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { BooleanInput } from 'ng-zorro-antd/core/types';
import { InputBoolean, isEmpty } from 'ng-zorro-antd/core/util';
import { Subject } from 'rxjs';
import { startWith, take, takeUntil } from 'rxjs/operators';
Expand Down Expand Up @@ -88,6 +89,10 @@ const NZ_CONFIG_COMPONENT_NAME = 'backTop';
}
})
export class NzBadgeComponent implements OnInit, AfterViewInit, OnChanges, OnDestroy {
static ngAcceptInputType_nzShowZero: BooleanInput;
static ngAcceptInputType_nzShowDot: BooleanInput;
static ngAcceptInputType_nzDot: BooleanInput;

private destroy$ = new Subject();
notWrapper = true;
viewInit = false;
Expand Down
12 changes: 4 additions & 8 deletions components/breadcrumb/breadcrumb.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
} from '@angular/core';
import { ActivatedRoute, NavigationEnd, Params, PRIMARY_OUTLET, Router } from '@angular/router';
import { PREFIX } from 'ng-zorro-antd/core/logger';
import { BooleanInput } from 'ng-zorro-antd/core/types';

import { InputBoolean } from 'ng-zorro-antd/core/util';
import { Subject } from 'rxjs';
Expand Down Expand Up @@ -49,6 +50,8 @@ export interface BreadcrumbOption {
`
})
export class NzBreadCrumbComponent implements OnInit, OnDestroy {
static ngAcceptInputType_nzAutoGenerate: BooleanInput;

@Input() @InputBoolean() nzAutoGenerate = false;
@Input() nzSeparator: string | TemplateRef<void> | null = '/';
@Input() nzRouteLabel: string = 'breadcrumb';
Expand Down Expand Up @@ -81,14 +84,7 @@ export class NzBreadCrumbComponent implements OnInit, OnDestroy {
navigate(url: string, e: MouseEvent): void {
e.preventDefault();

this.ngZone
.run(() =>
this.injector
.get(Router)
.navigateByUrl(url)
.then()
)
.then();
this.ngZone.run(() => this.injector.get(Router).navigateByUrl(url).then()).then();
}

private registerRouterChange(): void {
Expand Down
7 changes: 7 additions & 0 deletions components/button/button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
ViewEncapsulation
} from '@angular/core';
import { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { BooleanInput } from 'ng-zorro-antd/core/types';
import { InputBoolean } from 'ng-zorro-antd/core/util';

import { NzIconDirective } from 'ng-zorro-antd/icon';
Expand Down Expand Up @@ -62,6 +63,12 @@ const NZ_CONFIG_COMPONENT_NAME = 'button';
}
})
export class NzButtonComponent implements OnDestroy, OnChanges, AfterViewInit, AfterContentInit {
static ngAcceptInputType_nzBlock: BooleanInput;
static ngAcceptInputType_nzGhost: BooleanInput;
static ngAcceptInputType_nzSearch: BooleanInput;
static ngAcceptInputType_nzLoading: BooleanInput;
static ngAcceptInputType_nzDanger: BooleanInput;

@ContentChild(NzIconDirective, { read: ElementRef }) nzIconDirectiveElement: ElementRef;
@Input() @InputBoolean() nzBlock: boolean = false;
@Input() @InputBoolean() nzGhost: boolean = false;
Expand Down
3 changes: 3 additions & 0 deletions components/calendar/calendar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';

import { CandyDate } from 'ng-zorro-antd/core/time';
import { BooleanInput } from 'ng-zorro-antd/core/types';
import { InputBoolean } from 'ng-zorro-antd/core/util';
import {
NzDateCellDirective as DateCell,
Expand Down Expand Up @@ -87,6 +88,8 @@ type NzCalendarDateTemplate = TemplateRef<{ $implicit: Date }>;
providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NzCalendarComponent), multi: true }]
})
export class NzCalendarComponent implements ControlValueAccessor, OnChanges {
static ngAcceptInputType_nzFullscreen: BooleanInput;

activeDate: CandyDate = new CandyDate();
prefixCls: string = 'ant-picker-calendar';

Expand Down
2 changes: 2 additions & 0 deletions components/card/card-grid.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { Directive, Input } from '@angular/core';
import { BooleanInput } from 'ng-zorro-antd/core/types';
import { InputBoolean } from 'ng-zorro-antd/core/util';

@Directive({
Expand All @@ -18,5 +19,6 @@ import { InputBoolean } from 'ng-zorro-antd/core/util';
}
})
export class NzCardGridDirective {
static ngAcceptInputType_nzHoverable: BooleanInput;
@Input() @InputBoolean() nzHoverable = true;
}
6 changes: 5 additions & 1 deletion components/card/card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
ViewEncapsulation
} from '@angular/core';
import { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { NzSizeDSType } from 'ng-zorro-antd/core/types';
import { BooleanInput, NzSizeDSType } from 'ng-zorro-antd/core/types';
import { InputBoolean } from 'ng-zorro-antd/core/util';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
Expand Down Expand Up @@ -77,6 +77,10 @@ const NZ_CONFIG_COMPONENT_NAME = 'card';
}
})
export class NzCardComponent implements OnDestroy {
static ngAcceptInputType_nzBordered: BooleanInput;
static ngAcceptInputType_nzLoading: BooleanInput;
static ngAcceptInputType_nzHoverable: BooleanInput;

@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) @InputBoolean() nzBordered: boolean;
@Input() @InputBoolean() nzLoading = false;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzHoverable: boolean;
Expand Down
8 changes: 7 additions & 1 deletion components/carousel/carousel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
} from '@angular/core';
import { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { NzDragService, NzResizeService } from 'ng-zorro-antd/core/services';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { BooleanInput, NumberInput, NzSafeAny } from 'ng-zorro-antd/core/types';
import { InputBoolean, InputNumber } from 'ng-zorro-antd/core/util';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
Expand Down Expand Up @@ -97,6 +97,12 @@ const NZ_CONFIG_COMPONENT_NAME = 'carousel';
}
})
export class NzCarouselComponent implements AfterContentInit, AfterViewInit, OnDestroy, OnChanges {
static ngAcceptInputType_nzEnableSwipe: BooleanInput;
static ngAcceptInputType_nzDots: BooleanInput;
static ngAcceptInputType_nzAutoPlay: BooleanInput;
static ngAcceptInputType_nzAutoPlaySpeed: NumberInput;
static ngAcceptInputType_nzTransitionSpeed: NumberInput;

@ContentChildren(NzCarouselContentDirective) carouselContents: QueryList<NzCarouselContentDirective>;

@ViewChild('slickList', { static: false }) slickList: ElementRef;
Expand Down
9 changes: 8 additions & 1 deletion components/cascader/cascader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { slideMotion } from 'ng-zorro-antd/core/animation';
import { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
import { DEFAULT_CASCADER_POSITIONS } from 'ng-zorro-antd/core/overlay';
import { NgClassType, NgStyleInterface, NzSafeAny } from 'ng-zorro-antd/core/types';
import { BooleanInput, NgClassType, NgStyleInterface, NzSafeAny } from 'ng-zorro-antd/core/types';
import { InputBoolean, toArray } from 'ng-zorro-antd/core/util';
import { Subject } from 'rxjs';
import { startWith, takeUntil } from 'rxjs/operators';
Expand Down Expand Up @@ -190,6 +190,13 @@ const defaultDisplayRender = (labels: string[]) => labels.join(' / ');
}
})
export class NzCascaderComponent implements NzCascaderComponentAsSource, OnInit, OnDestroy, ControlValueAccessor {
static ngAcceptInputType_nzShowInput: BooleanInput;
static ngAcceptInputType_nzShowArrow: BooleanInput;
static ngAcceptInputType_nzAllowClear: BooleanInput;
static ngAcceptInputType_nzAutoFocus: BooleanInput;
static ngAcceptInputType_nzChangeOnSelect: BooleanInput;
static ngAcceptInputType_nzDisabled: BooleanInput;

@ViewChild('input', { static: false }) input: ElementRef;
@ViewChild('menu', { static: false }) menu: ElementRef;
@ViewChild(CdkConnectedOverlay, { static: false }) overlay: CdkConnectedOverlay;
Expand Down
4 changes: 3 additions & 1 deletion components/checkbox/checkbox-group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { FocusMonitor } from '@angular/cdk/a11y';
import { ChangeDetectorRef, Component, ElementRef, forwardRef, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { OnChangeType, OnTouchedType } from 'ng-zorro-antd/core/types';
import { BooleanInput, OnChangeType, OnTouchedType } from 'ng-zorro-antd/core/types';
import { InputBoolean } from 'ng-zorro-antd/core/util';

export interface NzCheckBoxOptionInterface {
Expand Down Expand Up @@ -48,6 +48,8 @@ export interface NzCheckBoxOptionInterface {
}
})
export class NzCheckboxGroupComponent implements ControlValueAccessor, OnInit, OnDestroy {
static ngAcceptInputType_nzDisabled: BooleanInput;

onChange: OnChangeType = () => {};
onTouched: OnTouchedType = () => {};
options: NzCheckBoxOptionInterface[] = [];
Expand Down
7 changes: 6 additions & 1 deletion components/checkbox/checkbox.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
ViewEncapsulation
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { NzSafeAny, OnChangeType, OnTouchedType } from 'ng-zorro-antd/core/types';
import { BooleanInput, NzSafeAny, OnChangeType, OnTouchedType } from 'ng-zorro-antd/core/types';
import { InputBoolean } from 'ng-zorro-antd/core/util';
import { NzCheckboxWrapperComponent } from './checkbox-wrapper.component';

Expand Down Expand Up @@ -70,6 +70,11 @@ import { NzCheckboxWrapperComponent } from './checkbox-wrapper.component';
}
})
export class NzCheckboxComponent implements OnInit, ControlValueAccessor, OnDestroy, AfterViewInit {
static ngAcceptInputType_nzAutoFocus: BooleanInput;
static ngAcceptInputType_nzDisabled: BooleanInput;
static ngAcceptInputType_nzIndeterminate: BooleanInput;
static ngAcceptInputType_nzChecked: BooleanInput;

onChange: OnChangeType = () => {};
onTouched: OnTouchedType = () => {};
@ViewChild('inputElement', { static: true }) private inputElement: ElementRef;
Expand Down
4 changes: 4 additions & 0 deletions components/code-editor/code-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { NzSafeAny, OnChangeType, OnTouchedType } from 'ng-zorro-antd';
import { warn } from 'ng-zorro-antd/core/logger';
import { BooleanInput } from 'ng-zorro-antd/core/types';
import { inNextTick, InputBoolean } from 'ng-zorro-antd/core/util';
import { BehaviorSubject, combineLatest, fromEvent, Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged, filter, map, takeUntil } from 'rxjs/operators';
Expand Down Expand Up @@ -64,6 +65,9 @@ declare const monaco: NzSafeAny;
]
})
export class NzCodeEditorComponent implements OnDestroy, AfterViewInit {
static ngAcceptInputType_nzLoading: BooleanInput;
static ngAcceptInputType_nzFullControl: BooleanInput;

@Input() nzEditorMode: NzEditorMode = 'normal';
@Input() nzOriginalText = '';
@Input() @InputBoolean() nzLoading = false;
Expand Down
5 changes: 5 additions & 0 deletions components/collapse/collapse-panel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import { collapseMotion } from 'ng-zorro-antd/core/animation';

import { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { BooleanInput } from 'ng-zorro-antd/core/types';
import { InputBoolean } from 'ng-zorro-antd/core/util';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
Expand Down Expand Up @@ -63,6 +64,10 @@ const NZ_CONFIG_COMPONENT_NAME = 'collapsePanel';
}
})
export class NzCollapsePanelComponent implements OnInit, OnDestroy {
static ngAcceptInputType_nzActive: BooleanInput;
static ngAcceptInputType_nzDisabled: BooleanInput;
static ngAcceptInputType_nzShowArrow: BooleanInput;

@Input() @InputBoolean() nzActive = false;
@Input() @InputBoolean() nzDisabled = false;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) @InputBoolean() nzShowArrow: boolean;
Expand Down
8 changes: 5 additions & 3 deletions components/collapse/collapse.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnDestroy, ViewEncapsulation } from '@angular/core';

import { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { BooleanInput } from 'ng-zorro-antd/core/types';
import { InputBoolean } from 'ng-zorro-antd/core/util';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
Expand All @@ -22,9 +23,7 @@ const NZ_CONFIG_COMPONENT_NAME = 'collapse';
exportAs: 'nzCollapse',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
template: `
<ng-content></ng-content>
`,
template: ` <ng-content></ng-content> `,
host: {
'[class.ant-collapse]': 'true',
'[class.ant-collapse-icon-position-left]': `nzExpandIconPosition === 'left'`,
Expand All @@ -33,6 +32,9 @@ const NZ_CONFIG_COMPONENT_NAME = 'collapse';
}
})
export class NzCollapseComponent implements OnDestroy {
static ngAcceptInputType_nzAccordion: BooleanInput;
static ngAcceptInputType_nzBordered: BooleanInput;

@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzAccordion: boolean;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, true) @InputBoolean() nzBordered: boolean;
@Input() nzExpandIconPosition: 'left' | 'right' = 'left';
Expand Down
Loading

0 comments on commit a3180d0

Please sign in to comment.