Skip to content

Commit

Permalink
fix(module:esm5): fix esm5 package (NG-ZORRO#2357)
Browse files Browse the repository at this point in the history
* fix(module:esm5): fix esm5 package
close NG-ZORRO#2339

* refactor(module:all): refactor all constructor

* fix(module:esm5): fix esm5 error
  • Loading branch information
vthinkxie authored Oct 26, 2018
1 parent 1bc67cb commit 6e07bd1
Show file tree
Hide file tree
Showing 33 changed files with 109 additions and 50 deletions.
5 changes: 2 additions & 3 deletions components/avatar/nz-avatar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type NzAvatarSize = 'small' | 'large' | 'default';
changeDetection : ChangeDetectionStrategy.OnPush
})
export class NzAvatarComponent implements OnChanges {
private el: HTMLElement;
private el: HTMLElement = this.elementRef.nativeElement;
private prefixCls = 'ant-avatar';
private sizeMap = { large: 'lg', small: 'sm' };
private _icon: string;
Expand Down Expand Up @@ -109,8 +109,7 @@ export class NzAvatarComponent implements OnChanges {
return this;
}

constructor(elementRef: ElementRef, private cd: ChangeDetectorRef, private updateHostClassService: NzUpdateHostClassService) {
this.el = elementRef.nativeElement;
constructor(private elementRef: ElementRef, private cd: ChangeDetectorRef, private updateHostClassService: NzUpdateHostClassService) {
}

ngOnChanges(changes: SimpleChanges): void {
Expand Down
5 changes: 2 additions & 3 deletions components/button/nz-button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class NzButtonComponent implements AfterContentInit, OnInit, OnDestroy {
private _size: NzButtonSize;
private _loading = false;
private _block = false;
private el: HTMLElement;
private el: HTMLElement = this.elementRef.nativeElement;
private iconElement: HTMLElement;
private iconOnly = false;
private prefixCls = 'ant-btn';
Expand Down Expand Up @@ -195,15 +195,14 @@ export class NzButtonComponent implements AfterContentInit, OnInit, OnDestroy {
}

constructor(private elementRef: ElementRef, private cdr: ChangeDetectorRef, private renderer: Renderer2, private nzUpdateHostClassService: NzUpdateHostClassService, private ngZone: NgZone) {
this.el = this.elementRef.nativeElement;
this.renderer.addClass(this.el, this.prefixCls);
}

ngAfterContentInit(): void {
this.checkContent();
}

ngOnInit(): void {
this.renderer.addClass(this.el, this.prefixCls);
this.nzWave.ngOnInit();
}

Expand Down
3 changes: 1 addition & 2 deletions components/carousel/nz-carousel-content.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class NzCarouselContentDirective implements OnInit {
private _left: number;
private _top: number;
private _fadeMode = false;
el: HTMLElement;
el: HTMLElement = this.elementRef.nativeElement;

set width(value: number) {
this._width = value;
Expand Down Expand Up @@ -91,7 +91,6 @@ export class NzCarouselContentDirective implements OnInit {
}

constructor(private elementRef: ElementRef, private renderer: Renderer2) {
this.el = this.elementRef.nativeElement;
}

ngOnInit(): void {
Expand Down
4 changes: 2 additions & 2 deletions components/cascader/nz-cascader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ export class NzCascaderComponent implements OnInit, OnDestroy, ControlValueAcces
private _menuCls: { [ name: string ]: any };
private _menuColumnCls: { [ name: string ]: any };

public el: HTMLElement;
public el: HTMLElement = this.elementRef.nativeElement;

private isFocused = false;

/** 选择选项后,渲染显示文本 */
Expand Down Expand Up @@ -1119,7 +1120,6 @@ export class NzCascaderComponent implements OnInit, OnDestroy, ControlValueAcces
constructor(private elementRef: ElementRef,
private cdr: ChangeDetectorRef,
private nzUpdateHostClassService: NzUpdateHostClassService) {
this.el = this.elementRef.nativeElement;
}

private findOption(option: any, index: number): CascaderOption {
Expand Down
3 changes: 1 addition & 2 deletions components/checkbox/nz-checkbox-group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface NzCheckBoxOptionInterface {
})
export class NzCheckboxGroupComponent implements ControlValueAccessor, OnInit {
private _disabled = false;
private el: HTMLElement;
private el: HTMLElement = this.elementRef.nativeElement;
private prefixCls = 'ant-checkbox-group';
private onChange = Function.prototype;
private onTouched = Function.prototype;
Expand Down Expand Up @@ -67,7 +67,6 @@ export class NzCheckboxGroupComponent implements ControlValueAccessor, OnInit {
}

constructor(private elementRef: ElementRef, private renderer: Renderer2) {
this.el = this.elementRef.nativeElement;
}

ngOnInit(): void {
Expand Down
3 changes: 1 addition & 2 deletions components/checkbox/nz-checkbox.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class NzCheckboxComponent implements OnInit, ControlValueAccessor, OnChan
private _indeterminate = false;
private _autoFocus = false;
private _checked = false;
private el: HTMLElement;
private el: HTMLElement = this.elementRef.nativeElement;
private isInit = false;
private prefixCls = 'ant-checkbox';
private onChange = Function.prototype;
Expand Down Expand Up @@ -162,7 +162,6 @@ export class NzCheckboxComponent implements OnInit, ControlValueAccessor, OnChan
}

constructor(private elementRef: ElementRef, private renderer: Renderer2, @Optional() private nzCheckboxWrapperComponent: NzCheckboxWrapperComponent) {
this.el = this.elementRef.nativeElement;
}

ngOnInit(): void {
Expand Down
3 changes: 1 addition & 2 deletions components/collapse/nz-collapse-panel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class NzCollapsePanelComponent implements OnDestroy, OnInit {
private _active = false;
private _header: string | TemplateRef<void>;
isHeaderString: boolean;
private el: HTMLElement;
private el: HTMLElement = this.elementRef.nativeElement;
@Output() nzActiveChange = new EventEmitter<boolean>();

@Input() set nzShowArrow(value: boolean) {
Expand Down Expand Up @@ -110,7 +110,6 @@ export class NzCollapsePanelComponent implements OnDestroy, OnInit {
}

constructor(@Host() private nzCollapseComponent: NzCollapseComponent, private elementRef: ElementRef) {
this.el = this.elementRef.nativeElement;
}

ngOnInit(): void {
Expand Down
4 changes: 4 additions & 0 deletions components/date-picker/date-picker.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { forwardRef, Component } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { NzI18nService } from '../i18n/nz-i18n.service';

import { DateRangePickerComponent } from './date-range-picker.component';

Expand All @@ -18,4 +19,7 @@ import { DateRangePickerComponent } from './date-range-picker.component';

export class NzDatePickerComponent extends DateRangePickerComponent {
isRange: boolean = false;
constructor(i18n: NzI18nService) {
super(i18n);
}
}
3 changes: 1 addition & 2 deletions components/date-picker/date-range-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChange

import { FunctionProp } from '../core/types/common-wrap';
import { toBoolean, valueFunctionProp, InputBoolean } from '../core/util/convert';
import { LoggerService } from '../core/util/logger/logger.service';
import { NzI18nService } from '../i18n/nz-i18n.service';
import { CandyDate } from './lib/candy-date';

Expand Down Expand Up @@ -39,7 +38,7 @@ export class DateRangePickerComponent extends AbstractPickerComponent implements
pickerStyle: object; // Final picker style that contains width fix corrections etc.
extraFooter: TemplateRef<void> | string;

constructor(i18n: NzI18nService, private logger: LoggerService) {
constructor(i18n: NzI18nService) {
super(i18n);
}

Expand Down
4 changes: 4 additions & 0 deletions components/date-picker/month-picker.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { forwardRef, Component, Input } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { NzI18nService } from '../i18n/nz-i18n.service';

import { HeaderPickerComponent, SupportHeaderPanel } from './header-picker.component';

Expand All @@ -20,4 +21,7 @@ export class NzMonthPickerComponent extends HeaderPickerComponent {
@Input() nzFormat: string = 'yyyy-MM';

endPanelMode: SupportHeaderPanel = 'month';
constructor(i18n: NzI18nService) {
super(i18n);
}
}
5 changes: 5 additions & 0 deletions components/date-picker/range-picker.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { forwardRef, Component } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { NzI18nService } from '../i18n/nz-i18n.service';

import { DateRangePickerComponent } from './date-range-picker.component';

Expand All @@ -18,4 +19,8 @@ import { DateRangePickerComponent } from './date-range-picker.component';

export class NzRangePickerComponent extends DateRangePickerComponent {
isRange: boolean = true;
constructor(i18n: NzI18nService) {
super(i18n);
}

}
4 changes: 4 additions & 0 deletions components/date-picker/week-picker.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { forwardRef, Component } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { NzI18nService } from '../i18n/nz-i18n.service';

import { DateRangePickerComponent } from './date-range-picker.component';

Expand All @@ -18,4 +19,7 @@ import { DateRangePickerComponent } from './date-range-picker.component';

export class NzWeekPickerComponent extends DateRangePickerComponent {
showWeek: boolean = true;
constructor(i18n: NzI18nService) {
super(i18n);
}
}
4 changes: 4 additions & 0 deletions components/date-picker/year-picker.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { forwardRef, Component, Input } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { NzI18nService } from '../i18n/nz-i18n.service';

import { HeaderPickerComponent, SupportHeaderPanel } from './header-picker.component';

Expand All @@ -20,4 +21,7 @@ export class NzYearPickerComponent extends HeaderPickerComponent {
@Input() nzFormat: string = 'yyyy';

endPanelMode: SupportHeaderPanel = 'year';
constructor(i18n: NzI18nService) {
super(i18n);
}
}
6 changes: 6 additions & 0 deletions components/dropdown/nz-dropdown-button.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {
AfterViewInit,
ChangeDetectorRef,
Component,
EventEmitter,
Input,
OnDestroy,
OnInit,
Output,
Renderer2,
ViewChild
} from '@angular/core';

Expand Down Expand Up @@ -59,6 +61,10 @@ export class NzDropDownButtonComponent extends NzDropDownComponent implements On
this.changeDetector.markForCheck();
}

constructor(renderer: Renderer2, changeDetector: ChangeDetectorRef) {
super(renderer, changeDetector);
}

/** rewrite afterViewInit hook */
ngAfterViewInit(): void {
this.startSubscribe(this.$visibleChange);
Expand Down
18 changes: 17 additions & 1 deletion components/form/nz-form-control.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import { AfterContentInit, Component, ContentChild, Input, OnDestroy, OnInit } from '@angular/core';
import {
AfterContentInit,
Component,
ContentChild,
ElementRef,
Host,
Input,
OnDestroy,
OnInit,
Optional,
Renderer2 } from '@angular/core';
import { FormControl, NgControl } from '@angular/forms';
import { Subscription } from 'rxjs';
import { NzUpdateHostClassService } from '../core/services/update-host-class.service';
import { toBoolean } from '../core/util/convert';
import { NzColComponent } from '../grid/nz-col.component';
import { NzRowComponent } from '../grid/nz-row.component';
import { NzRowDirective } from '../grid/nz-row.directive';

@Component({
selector : 'nz-form-control',
Expand Down Expand Up @@ -100,6 +112,10 @@ export class NzFormControlComponent extends NzColComponent implements OnDestroy,
}
}

constructor(nzUpdateHostClassService: NzUpdateHostClassService, elementRef: ElementRef, @Optional() @Host() nzRowComponent: NzRowComponent, @Optional() @Host() nzRowDirective: NzRowDirective, renderer: Renderer2) {
super(nzUpdateHostClassService, elementRef, nzRowComponent, nzRowDirective, renderer);
}

ngOnInit(): void {
this.setClassMap();
this.setControlClassMap();
Expand Down
6 changes: 5 additions & 1 deletion components/form/nz-form-item.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input } from '@angular/core';
import { Component, ElementRef, Input, Renderer2 } from '@angular/core';
import { NzUpdateHostClassService } from '../core/services/update-host-class.service';
import { toBoolean } from '../core/util/convert';
import { NzRowComponent } from '../grid/nz-row.component';
Expand Down Expand Up @@ -38,4 +38,8 @@ export class NzFormItemComponent extends NzRowComponent {
disableHelp(): void {
this.withHelp--;
}

constructor(elementRef: ElementRef, renderer: Renderer2, nzUpdateHostClassService: NzUpdateHostClassService) {
super(elementRef, renderer, nzUpdateHostClassService);
}
}
8 changes: 7 additions & 1 deletion components/form/nz-form-label.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Component, Input } from '@angular/core';
import { Component, ElementRef, Host, Input, Optional, Renderer2 } from '@angular/core';
import { NzUpdateHostClassService } from '../core/services/update-host-class.service';
import { toBoolean } from '../core/util/convert';
import { NzColComponent } from '../grid/nz-col.component';
import { NzRowComponent } from '../grid/nz-row.component';
import { NzRowDirective } from '../grid/nz-row.directive';

@Component({
selector : 'nz-form-label',
Expand All @@ -24,4 +26,8 @@ export class NzFormLabelComponent extends NzColComponent {
get nzRequired(): boolean {
return this._required;
}

constructor(nzUpdateHostClassService: NzUpdateHostClassService, elementRef: ElementRef, @Optional() @Host() nzRowComponent: NzRowComponent, @Optional() @Host() nzRowDirective: NzRowDirective, renderer: Renderer2) {
super(nzUpdateHostClassService, elementRef, nzRowComponent, nzRowDirective, renderer);
}
}
3 changes: 1 addition & 2 deletions components/form/nz-form.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { NzUpdateHostClassService } from '../core/services/update-host-class.ser
providers: [ NzUpdateHostClassService ]
})
export class NzFormDirective implements OnInit {
el: HTMLElement;
el: HTMLElement = this.elementRef.nativeElement;
prefixCls = 'ant-form';
private _layout = 'horizontal';

Expand All @@ -29,7 +29,6 @@ export class NzFormDirective implements OnInit {
}

constructor(private elementRef: ElementRef, private renderer: Renderer2, private nzUpdateHostClassService: NzUpdateHostClassService) {
this.el = this.elementRef.nativeElement;
}

ngOnInit(): void {
Expand Down
3 changes: 1 addition & 2 deletions components/grid/nz-col.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface EmbeddedProperty {
templateUrl : './nz-col.component.html'
})
export class NzColComponent implements OnInit, OnChanges {
private el: HTMLElement;
private el: HTMLElement = this.elementRef.nativeElement;
private prefixCls = 'ant-col';

@HostBinding('style.padding-left.px')
Expand Down Expand Up @@ -100,7 +100,6 @@ export class NzColComponent implements OnInit, OnChanges {
}

constructor(private nzUpdateHostClassService: NzUpdateHostClassService, private elementRef: ElementRef, @Optional() @Host() public nzRowComponent: NzRowComponent, @Optional() @Host() public nzRowDirective: NzRowDirective, private renderer: Renderer2) {
this.el = this.elementRef.nativeElement;
}

ngOnInit(): void {
Expand Down
11 changes: 10 additions & 1 deletion components/grid/nz-col.directive.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import {
Directive
Directive,
ElementRef,
Host,
Optional,
Renderer2
} from '@angular/core';

import { NzUpdateHostClassService } from '../core/services/update-host-class.service';

import { NzColComponent } from './nz-col.component';
import { NzRowComponent } from './nz-row.component';
import { NzRowDirective } from './nz-row.directive';

@Directive({
selector : '[nz-col]',
providers: [ NzUpdateHostClassService ]
})
export class NzColDirective extends NzColComponent {
constructor(nzUpdateHostClassService: NzUpdateHostClassService, elementRef: ElementRef, @Optional() @Host() nzRowComponent: NzRowComponent, @Optional() @Host() nzRowDirective: NzRowDirective, renderer: Renderer2) {
super(nzUpdateHostClassService, elementRef, nzRowComponent, nzRowDirective, renderer);
}
}
4 changes: 2 additions & 2 deletions components/grid/nz-row.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ const responsiveMap: BreakpointMap = {
templateUrl : './nz-row.component.html'
})
export class NzRowComponent implements OnInit {

private _gutter: number | object;
private _type: NzType;
private _align: NzAlign = 'top';
private _justify: NzJustify = 'start';
private el: HTMLElement;
private el: HTMLElement = this.elementRef.nativeElement;
private prefixCls = 'ant-row';
private breakPoint: Breakpoint;
actualGutter: number;
Expand Down Expand Up @@ -137,7 +138,6 @@ export class NzRowComponent implements OnInit {
}

constructor(public elementRef: ElementRef, public renderer: Renderer2, public nzUpdateHostClassService: NzUpdateHostClassService) {
this.el = this.elementRef.nativeElement;
}

ngOnInit(): void {
Expand Down
Loading

0 comments on commit 6e07bd1

Please sign in to comment.