0">
+
{{ panel.name }}
+
0">
-
- A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
+
+
+ A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a
+ welcome guest in many households across the world.
+
`,
- styles : []
+ styles: []
})
export class NzDemoCollapseMixComponent {
panels = [
{
- active : true,
- disabled : false,
- name : 'This is panel header 1',
+ active: true,
+ disabled: false,
+ name: 'This is panel header 1',
childPanel: [
{
active: true,
- name : 'This is panel header 1-1'
+ name: 'This is panel header 1-1'
},
{
active: false,
- name : 'This is panel header 1-2'
+ name: 'This is panel header 1-2'
}
]
},
{
- active : false,
+ active: false,
disabled: true,
- name : 'This is panel header 2'
+ name: 'This is panel header 2'
},
{
- active : false,
+ active: false,
disabled: false,
- name : 'This is panel header 3'
+ name: 'This is panel header 3'
}
];
}
diff --git a/components/collapse/demo/noarrow.ts b/components/collapse/demo/noarrow.ts
index c6407dcbe0..d9c9befc2c 100644
--- a/components/collapse/demo/noarrow.ts
+++ b/components/collapse/demo/noarrow.ts
@@ -4,24 +4,33 @@ import { Component } from '@angular/core';
selector: 'nz-demo-collapse-noarrow',
template: `
-
- A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
+
+
+ A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome
+ guest in many households across the world.
+
`,
- styles : []
+ styles: []
})
export class NzDemoCollapseNoarrowComponent {
panels = [
{
active: true,
- name : 'This is panel header 1',
- arrow : true
+ name: 'This is panel header 1',
+ arrow: true
},
{
active: false,
- arrow : false,
- name : 'This is panel header 2'
+ arrow: false,
+ name: 'This is panel header 2'
}
];
}
diff --git a/components/collapse/nz-collapse-panel.component.ts b/components/collapse/nz-collapse-panel.component.ts
index c6d637932a..b18d9bc0de 100644
--- a/components/collapse/nz-collapse-panel.component.ts
+++ b/components/collapse/nz-collapse-panel.component.ts
@@ -1,11 +1,16 @@
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
- Component, ElementRef,
- EventEmitter, Host,
+ Component,
+ ElementRef,
+ EventEmitter,
+ Host,
HostBinding,
- Input, OnDestroy, OnInit,
- Output, Renderer2,
+ Input,
+ OnDestroy,
+ OnInit,
+ Output,
+ Renderer2,
TemplateRef,
ViewEncapsulation
} from '@angular/core';
@@ -15,21 +20,22 @@ import { InputBoolean } from '../core/util/convert';
import { NzCollapseComponent } from './nz-collapse.component';
@Component({
- selector : 'nz-collapse-panel',
- templateUrl : './nz-collapse-panel.component.html',
+ selector: 'nz-collapse-panel',
+ templateUrl: './nz-collapse-panel.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation : ViewEncapsulation.None,
- animations : [ collapseMotion ],
- styles : [
- ` nz-collapse-panel {
- display: block
- }`
+ encapsulation: ViewEncapsulation.None,
+ animations: [collapseMotion],
+ styles: [
+ `
+ nz-collapse-panel {
+ display: block;
+ }
+ `
],
- host : {
+ host: {
'[class.ant-collapse-no-arrow]': '!nzShowArrow'
}
})
-
export class NzCollapsePanelComponent implements OnInit, OnDestroy {
@Input() @InputBoolean() @HostBinding('class.ant-collapse-item-active') nzActive = false;
@Input() @InputBoolean() @HostBinding('class.ant-collapse-item-disabled') nzDisabled = false;
@@ -48,7 +54,12 @@ export class NzCollapsePanelComponent implements OnInit, OnDestroy {
this.cdr.markForCheck();
}
- constructor(private cdr: ChangeDetectorRef, @Host() private nzCollapseComponent: NzCollapseComponent, elementRef: ElementRef, renderer: Renderer2) {
+ constructor(
+ private cdr: ChangeDetectorRef,
+ @Host() private nzCollapseComponent: NzCollapseComponent,
+ elementRef: ElementRef,
+ renderer: Renderer2
+ ) {
renderer.addClass(elementRef.nativeElement, 'ant-collapse-item');
}
diff --git a/components/collapse/nz-collapse.component.ts b/components/collapse/nz-collapse.component.ts
index f3ceb74659..d032c14217 100644
--- a/components/collapse/nz-collapse.component.ts
+++ b/components/collapse/nz-collapse.component.ts
@@ -1,21 +1,18 @@
-import {
- ChangeDetectionStrategy,
- Component,
- Input,
- ViewEncapsulation
-} from '@angular/core';
+import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation } from '@angular/core';
import { InputBoolean } from '../core/util/convert';
import { NzCollapsePanelComponent } from './nz-collapse-panel.component';
@Component({
- selector : 'nz-collapse',
- templateUrl : './nz-collapse.component.html',
+ selector: 'nz-collapse',
+ templateUrl: './nz-collapse.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation : ViewEncapsulation.None,
- styles : [
- `nz-collapse {
- display: block;
- }`
+ encapsulation: ViewEncapsulation.None,
+ styles: [
+ `
+ nz-collapse {
+ display: block;
+ }
+ `
]
})
export class NzCollapseComponent {
@@ -33,13 +30,15 @@ export class NzCollapseComponent {
click(collapse: NzCollapsePanelComponent): void {
if (this.nzAccordion && !collapse.nzActive) {
- this.listOfNzCollapsePanelComponent.filter(item => item !== collapse).forEach(item => {
- if (item.nzActive) {
- item.nzActive = false;
- item.nzActiveChange.emit(item.nzActive);
- item.markForCheck();
- }
- });
+ this.listOfNzCollapsePanelComponent
+ .filter(item => item !== collapse)
+ .forEach(item => {
+ if (item.nzActive) {
+ item.nzActive = false;
+ item.nzActiveChange.emit(item.nzActive);
+ item.markForCheck();
+ }
+ });
}
collapse.nzActive = !collapse.nzActive;
collapse.nzActiveChange.emit(collapse.nzActive);
diff --git a/components/collapse/nz-collapse.module.ts b/components/collapse/nz-collapse.module.ts
index e96dc68517..2363082bbf 100644
--- a/components/collapse/nz-collapse.module.ts
+++ b/components/collapse/nz-collapse.module.ts
@@ -7,10 +7,8 @@ import { NzCollapsePanelComponent } from './nz-collapse-panel.component';
import { NzCollapseComponent } from './nz-collapse.component';
@NgModule({
- declarations: [ NzCollapsePanelComponent, NzCollapseComponent ],
- exports : [ NzCollapsePanelComponent, NzCollapseComponent ],
- imports : [ CommonModule, NzIconModule, NzAddOnModule ]
+ declarations: [NzCollapsePanelComponent, NzCollapseComponent],
+ exports: [NzCollapsePanelComponent, NzCollapseComponent],
+ imports: [CommonModule, NzIconModule, NzAddOnModule]
})
-
-export class NzCollapseModule {
-}
+export class NzCollapseModule {}
diff --git a/components/collapse/nz-collapse.spec.ts b/components/collapse/nz-collapse.spec.ts
index 96a075962b..52347a795c 100644
--- a/components/collapse/nz-collapse.spec.ts
+++ b/components/collapse/nz-collapse.spec.ts
@@ -10,8 +10,8 @@ import { NzCollapseModule } from './nz-collapse.module';
describe('collapse', () => {
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
- imports : [ NzCollapseModule, NoopAnimationsModule ],
- declarations: [ NzTestCollapseBasicComponent, NzTestCollapseTemplateComponent, NzTestCollapseIconComponent ]
+ imports: [NzCollapseModule, NoopAnimationsModule],
+ declarations: [NzTestCollapseBasicComponent, NzTestCollapseTemplateComponent, NzTestCollapseIconComponent]
});
TestBed.compileComponents();
}));
@@ -42,92 +42,92 @@ describe('collapse', () => {
});
it('should showArrow work', () => {
fixture.detectChanges();
- expect(panels[ 0 ].nativeElement.querySelector('.ant-collapse-arrow').firstElementChild).toBeDefined();
+ expect(panels[0].nativeElement.querySelector('.ant-collapse-arrow').firstElementChild).toBeDefined();
testComponent.showArrow = false;
fixture.detectChanges();
- expect(panels[ 0 ].nativeElement.querySelector('.ant-collapse-arrow')).toBeNull();
+ expect(panels[0].nativeElement.querySelector('.ant-collapse-arrow')).toBeNull();
});
it('should active work', () => {
fixture.detectChanges();
- expect(panels[ 0 ].nativeElement.classList).not.toContain('ant-collapse-item-active');
+ expect(panels[0].nativeElement.classList).not.toContain('ant-collapse-item-active');
testComponent.active01 = true;
fixture.detectChanges();
- expect(panels[ 0 ].nativeElement.classList).toContain('ant-collapse-item-active');
+ expect(panels[0].nativeElement.classList).toContain('ant-collapse-item-active');
expect(testComponent.active01Change).toHaveBeenCalledTimes(0);
});
it('should click work', () => {
fixture.detectChanges();
- expect(panels[ 0 ].nativeElement.classList).not.toContain('ant-collapse-item-active');
+ expect(panels[0].nativeElement.classList).not.toContain('ant-collapse-item-active');
expect(testComponent.active01).toBe(false);
- panels[ 0 ].nativeElement.querySelector('.ant-collapse-header').click();
+ panels[0].nativeElement.querySelector('.ant-collapse-header').click();
fixture.detectChanges();
expect(testComponent.active01).toBe(true);
- expect(panels[ 0 ].nativeElement.classList).toContain('ant-collapse-item-active');
+ expect(panels[0].nativeElement.classList).toContain('ant-collapse-item-active');
expect(testComponent.active01Change).toHaveBeenCalledTimes(1);
});
it('should disabled work', () => {
testComponent.disabled = true;
fixture.detectChanges();
- expect(panels[ 1 ].nativeElement.classList).not.toContain('ant-collapse-item-active');
+ expect(panels[1].nativeElement.classList).not.toContain('ant-collapse-item-active');
expect(testComponent.active02).toBe(false);
- panels[ 1 ].nativeElement.querySelector('.ant-collapse-header').click();
+ panels[1].nativeElement.querySelector('.ant-collapse-header').click();
fixture.detectChanges();
expect(testComponent.active02).toBe(false);
- expect(panels[ 1 ].nativeElement.classList).toContain('ant-collapse-item-disabled');
- expect(panels[ 1 ].nativeElement.classList).not.toContain('ant-collapse-item-active');
+ expect(panels[1].nativeElement.classList).toContain('ant-collapse-item-disabled');
+ expect(panels[1].nativeElement.classList).not.toContain('ant-collapse-item-active');
expect(testComponent.active02Change).toHaveBeenCalledTimes(0);
});
it('should accordion work', () => {
testComponent.accordion = true;
fixture.detectChanges();
- expect(panels[ 0 ].nativeElement.classList).not.toContain('ant-collapse-item-active');
+ expect(panels[0].nativeElement.classList).not.toContain('ant-collapse-item-active');
expect(testComponent.active01).toBe(false);
- panels[ 0 ].nativeElement.querySelector('.ant-collapse-header').click();
+ panels[0].nativeElement.querySelector('.ant-collapse-header').click();
fixture.detectChanges();
expect(testComponent.active01).toBe(true);
expect(testComponent.active02).toBe(false);
- expect(panels[ 0 ].nativeElement.classList).toContain('ant-collapse-item-active');
- expect(panels[ 1 ].nativeElement.classList).not.toContain('ant-collapse-item-active');
+ expect(panels[0].nativeElement.classList).toContain('ant-collapse-item-active');
+ expect(panels[1].nativeElement.classList).not.toContain('ant-collapse-item-active');
expect(testComponent.active01Change).toHaveBeenCalledTimes(1);
expect(testComponent.active02Change).toHaveBeenCalledTimes(0);
- panels[ 1 ].nativeElement.querySelector('.ant-collapse-header').click();
+ panels[1].nativeElement.querySelector('.ant-collapse-header').click();
fixture.detectChanges();
expect(testComponent.active01).toBe(false);
expect(testComponent.active02).toBe(true);
- expect(panels[ 0 ].nativeElement.classList).not.toContain('ant-collapse-item-active');
- expect(panels[ 1 ].nativeElement.classList).toContain('ant-collapse-item-active');
+ expect(panels[0].nativeElement.classList).not.toContain('ant-collapse-item-active');
+ expect(panels[1].nativeElement.classList).toContain('ant-collapse-item-active');
expect(testComponent.active01Change).toHaveBeenCalledTimes(2);
expect(testComponent.active02Change).toHaveBeenCalledTimes(1);
});
it('should click to fold up work with accordion', () => {
testComponent.accordion = true;
fixture.detectChanges();
- expect(panels[ 0 ].nativeElement.classList).not.toContain('ant-collapse-item-active');
+ expect(panels[0].nativeElement.classList).not.toContain('ant-collapse-item-active');
expect(testComponent.active01).toBe(false);
- panels[ 0 ].nativeElement.querySelector('.ant-collapse-header').click();
+ panels[0].nativeElement.querySelector('.ant-collapse-header').click();
fixture.detectChanges();
- panels[ 1 ].nativeElement.querySelector('.ant-collapse-header').click();
+ panels[1].nativeElement.querySelector('.ant-collapse-header').click();
fixture.detectChanges();
- panels[ 0 ].nativeElement.querySelector('.ant-collapse-header').click();
+ panels[0].nativeElement.querySelector('.ant-collapse-header').click();
fixture.detectChanges();
expect(testComponent.active01).toBe(true);
expect(testComponent.active02).toBe(false);
- expect(panels[ 0 ].nativeElement.classList).toContain('ant-collapse-item-active');
- expect(panels[ 1 ].nativeElement.classList).not.toContain('ant-collapse-item-active');
+ expect(panels[0].nativeElement.classList).toContain('ant-collapse-item-active');
+ expect(panels[1].nativeElement.classList).not.toContain('ant-collapse-item-active');
expect(testComponent.active01Change).toHaveBeenCalledTimes(3);
expect(testComponent.active02Change).toHaveBeenCalledTimes(2);
- panels[ 0 ].nativeElement.querySelector('.ant-collapse-header').click();
+ panels[0].nativeElement.querySelector('.ant-collapse-header').click();
fixture.detectChanges();
expect(testComponent.active01).toBe(false);
expect(testComponent.active02).toBe(false);
- expect(panels[ 0 ].nativeElement.classList).not.toContain('ant-collapse-item-active');
- expect(panels[ 1 ].nativeElement.classList).not.toContain('ant-collapse-item-active');
+ expect(panels[0].nativeElement.classList).not.toContain('ant-collapse-item-active');
+ expect(panels[1].nativeElement.classList).not.toContain('ant-collapse-item-active');
expect(testComponent.active01Change).toHaveBeenCalledTimes(4);
expect(testComponent.active02Change).toHaveBeenCalledTimes(2);
});
it('should header work', () => {
fixture.detectChanges();
- expect(panels[ 0 ].nativeElement.querySelector('.ant-collapse-header').innerText).toBe('string');
+ expect(panels[0].nativeElement.querySelector('.ant-collapse-header').innerText).toBe('string');
});
});
describe('collapse template', () => {
@@ -140,7 +140,7 @@ describe('collapse', () => {
});
it('should header work', () => {
fixture.detectChanges();
- expect(panels[ 0 ].nativeElement.querySelector('.ant-collapse-header').innerText).toBe('template');
+ expect(panels[0].nativeElement.querySelector('.ant-collapse-header').innerText).toBe('template');
});
});
@@ -154,9 +154,9 @@ describe('collapse', () => {
});
it('should icon work', () => {
fixture.detectChanges();
- expect(panels[ 0 ].nativeElement.querySelector('.anticon-right')).toBeDefined();
- expect(panels[ 1 ].nativeElement.querySelector('.anticon-double-right')).toBeDefined();
- expect(panels[ 2 ].nativeElement.querySelector('.anticon-caret-right')).toBeDefined();
+ expect(panels[0].nativeElement.querySelector('.anticon-right')).toBeDefined();
+ expect(panels[1].nativeElement.querySelector('.anticon-double-right')).toBeDefined();
+ expect(panels[2].nativeElement.querySelector('.anticon-caret-right')).toBeDefined();
});
});
});
@@ -166,8 +166,12 @@ describe('collapse', () => {
template: `
template
-
+
Panel01
@@ -201,8 +205,7 @@ export class NzTestCollapseBasicComponent {
`
})
-export class NzTestCollapseTemplateComponent {
-}
+export class NzTestCollapseTemplateComponent {}
@Component({
selector: 'nz-test-collapse-icon',
@@ -223,5 +226,4 @@ export class NzTestCollapseTemplateComponent {
`
})
-export class NzTestCollapseIconComponent {
-}
+export class NzTestCollapseIconComponent {}
diff --git a/components/comment/demo/basic.ts b/components/comment/demo/basic.ts
index ddb8dd854a..8e86c8d988 100644
--- a/components/comment/demo/basic.ts
+++ b/components/comment/demo/basic.ts
@@ -5,29 +5,50 @@ import { distanceInWords } from 'date-fns';
selector: 'nz-demo-comment-basic',
template: `
-
+
- We supply a series of design principles, practical patterns and high quality design resources
- (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.
+
+ We supply a series of design principles, practical patterns and high quality design resources (Sketch and
+ Axure), to help people create their product prototypes beautifully and efficiently.
- 0 ? 'twotone' : 'outline'" (click)="like()">
- {{likes}}
+ 0 ? 'twotone' : 'outline'"
+ (click)="like()"
+ >
+ {{ likes }}
- 0 ? 'twotone' : 'outline'" (click)="dislike()">
- {{dislikes}}
+ 0 ? 'twotone' : 'outline'"
+ (click)="dislike()"
+ >
+ {{ dislikes }}
Reply to
`,
- styles : [`
- .count {
- padding-left: 8px;
- cursor: auto;
- }
- `]
+ styles: [
+ `
+ .count {
+ padding-left: 8px;
+ cursor: auto;
+ }
+ `
+ ]
})
export class NzDemoCommentBasicComponent {
likes = 0;
diff --git a/components/comment/demo/editor.ts b/components/comment/demo/editor.ts
index 6fe84bd6aa..40520e56ca 100644
--- a/components/comment/demo/editor.ts
+++ b/components/comment/demo/editor.ts
@@ -9,7 +9,7 @@ import { distanceInWords } from 'date-fns';
- {{item.content}}
+ {{ item.content }}
@@ -28,7 +28,7 @@ import { distanceInWords } from 'date-fns';
`,
- styles : []
+ styles: []
})
export class NzDemoCommentEditorComponent {
data: any[] = [];
@@ -45,12 +45,15 @@ export class NzDemoCommentEditorComponent {
this.inputValue = '';
setTimeout(() => {
this.submitting = false;
- this.data = [...this.data, {
- ...this.user,
- content,
- datetime: new Date(),
- displayTime: distanceInWords(new Date(), new Date())
- }].map(e => {
+ this.data = [
+ ...this.data,
+ {
+ ...this.user,
+ content,
+ datetime: new Date(),
+ displayTime: distanceInWords(new Date(), new Date())
+ }
+ ].map(e => {
return {
...e,
displayTime: distanceInWords(new Date(), e.datetime)
@@ -58,5 +61,4 @@ export class NzDemoCommentEditorComponent {
});
}, 800);
}
-
}
diff --git a/components/comment/demo/list.ts b/components/comment/demo/list.ts
index 2e1ed0687b..95606ab7cd 100644
--- a/components/comment/demo/list.ts
+++ b/components/comment/demo/list.ts
@@ -9,28 +9,30 @@ import { addDays, distanceInWords } from 'date-fns';
- {{item.content}}
+ {{ item.content }}
Reply to
`,
- styles : []
+ styles: []
})
export class NzDemoCommentListComponent {
data = [
{
author: 'Han Solo',
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
- content: 'We supply a series of design principles, practical patterns and high quality design resources' +
+ content:
+ 'We supply a series of design principles, practical patterns and high quality design resources' +
'(Sketch and Axure), to help people create their product prototypes beautifully and efficiently.',
datetime: distanceInWords(new Date(), addDays(new Date(), 1))
},
{
author: 'Han Solo',
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
- content: 'We supply a series of design principles, practical patterns and high quality design resources' +
+ content:
+ 'We supply a series of design principles, practical patterns and high quality design resources' +
'(Sketch and Axure), to help people create their product prototypes beautifully and efficiently.',
datetime: distanceInWords(new Date(), addDays(new Date(), 2))
}
diff --git a/components/comment/demo/nested.ts b/components/comment/demo/nested.ts
index 692f0c788a..161164b8ef 100644
--- a/components/comment/demo/nested.ts
+++ b/components/comment/demo/nested.ts
@@ -7,50 +7,49 @@ import { Component } from '@angular/core';
- {{comment.content}}
+ {{ comment.content }}
Reply to
-
+
-
-
+
`,
- styles : []
+ styles: []
})
export class NzDemoCommentNestedComponent {
data = {
author: 'Han Solo',
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
- content: 'We supply a series of design principles, practical patterns and high quality design resources' +
+ content:
+ 'We supply a series of design principles, practical patterns and high quality design resources' +
'(Sketch and Axure), to help people create their product prototypes beautifully and efficiently.',
children: [
{
author: 'Han Solo',
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
- content: 'We supply a series of design principles, practical patterns and high quality design resources' +
+ content:
+ 'We supply a series of design principles, practical patterns and high quality design resources' +
'(Sketch and Axure), to help people create their product prototypes beautifully and efficiently.',
children: [
{
author: 'Han Solo',
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
- content: 'We supply a series of design principles, practical patterns and high quality design resources' +
+ content:
+ 'We supply a series of design principles, practical patterns and high quality design resources' +
'(Sketch and Axure), to help people create their product prototypes beautifully and efficiently.'
},
{
author: 'Han Solo',
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
- content: 'We supply a series of design principles, practical patterns and high quality design resources' +
+ content:
+ 'We supply a series of design principles, practical patterns and high quality design resources' +
'(Sketch and Axure), to help people create their product prototypes beautifully and efficiently.'
}
]
diff --git a/components/comment/nz-comment-cells.ts b/components/comment/nz-comment-cells.ts
index 7ec788c526..ff2e4e63e2 100644
--- a/components/comment/nz-comment-cells.ts
+++ b/components/comment/nz-comment-cells.ts
@@ -1,36 +1,36 @@
import { CdkPortalOutlet, TemplatePortal } from '@angular/cdk/portal';
import {
ChangeDetectionStrategy,
- Component, ComponentFactoryResolver,
- Directive, Input, OnDestroy,
+ Component,
+ ComponentFactoryResolver,
+ Directive,
+ Input,
+ OnDestroy,
OnInit,
TemplateRef,
ViewChild,
- ViewContainerRef, ViewEncapsulation
+ ViewContainerRef,
+ ViewEncapsulation
} from '@angular/core';
@Directive({
selector: 'nz-avatar[nz-comment-avatar]'
})
-export class NzCommentAvatarDirective {
-}
+export class NzCommentAvatarDirective {}
@Directive({
selector: 'nz-comment-content, [nz-comment-content]',
- host : { 'class': 'ant-comment-content-detail' }
+ host: { class: 'ant-comment-content-detail' }
})
-export class NzCommentContentDirective {
-}
+export class NzCommentContentDirective {}
@Directive({
selector: '[nzCommentActionHost]'
})
export class NzCommentActionHostDirective extends CdkPortalOutlet implements OnInit, OnDestroy {
-
@Input() nzCommentActionHost: TemplatePortal | null;
- constructor(componentFactoryResolver: ComponentFactoryResolver,
- viewContainerRef: ViewContainerRef) {
+ constructor(componentFactoryResolver: ComponentFactoryResolver, viewContainerRef: ViewContainerRef) {
super(componentFactoryResolver, viewContainerRef);
}
@@ -45,10 +45,10 @@ export class NzCommentActionHostDirective extends CdkPortalOutlet implements OnI
}
@Component({
- selector : 'nz-comment-action',
- encapsulation : ViewEncapsulation.None,
+ selector: 'nz-comment-action',
+ encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
- template : '
'
+ template: '
'
})
export class NzCommentActionComponent implements OnInit {
@ViewChild(TemplateRef) implicitContent: TemplateRef
;
@@ -58,9 +58,7 @@ export class NzCommentActionComponent implements OnInit {
return this.contentPortal;
}
- constructor(private viewContainerRef: ViewContainerRef) {
-
- }
+ constructor(private viewContainerRef: ViewContainerRef) {}
ngOnInit(): void {
this.contentPortal = new TemplatePortal(this.implicitContent, this.viewContainerRef);
diff --git a/components/comment/nz-comment.component.ts b/components/comment/nz-comment.component.ts
index 549e502a6b..0832f7662f 100644
--- a/components/comment/nz-comment.component.ts
+++ b/components/comment/nz-comment.component.ts
@@ -10,15 +10,15 @@ import {
import { NzCommentActionComponent as CommentAction } from './nz-comment-cells';
@Component({
- selector : 'nz-comment',
- templateUrl : './nz-comment.component.html',
- encapsulation : ViewEncapsulation.None,
+ selector: 'nz-comment',
+ templateUrl: './nz-comment.component.html',
+ encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
- host : {
- 'class': 'ant-comment'
+ host: {
+ class: 'ant-comment'
},
- styles : [
- `
+ styles: [
+ `
nz-comment {
display: block;
}
@@ -30,12 +30,9 @@ import { NzCommentActionComponent as CommentAction } from './nz-comment-cells';
]
})
export class NzCommentComponent {
-
@Input() nzAuthor: string | TemplateRef;
@Input() nzDatetime: string | TemplateRef;
@ContentChildren(CommentAction) actions: QueryList;
- constructor() {
- }
-
+ constructor() {}
}
diff --git a/components/comment/nz-comment.module.ts b/components/comment/nz-comment.module.ts
index 5d17d71830..b084b41287 100644
--- a/components/comment/nz-comment.module.ts
+++ b/components/comment/nz-comment.module.ts
@@ -17,12 +17,8 @@ const NZ_COMMENT_CELLS = [
];
@NgModule({
- imports : [
- CommonModule,
- NzAddOnModule
- ],
- exports : [ NzCommentComponent, ...NZ_COMMENT_CELLS ],
- declarations: [ NzCommentComponent, ...NZ_COMMENT_CELLS ]
+ imports: [CommonModule, NzAddOnModule],
+ exports: [NzCommentComponent, ...NZ_COMMENT_CELLS],
+ declarations: [NzCommentComponent, ...NZ_COMMENT_CELLS]
})
-export class NzCommentModule {
-}
+export class NzCommentModule {}
diff --git a/components/comment/nz-comment.spec.ts b/components/comment/nz-comment.spec.ts
index 1a44cace53..3428ce919e 100644
--- a/components/comment/nz-comment.spec.ts
+++ b/components/comment/nz-comment.spec.ts
@@ -11,19 +11,17 @@ import { NzCommentComponent } from './nz-comment.component';
import { NzCommentModule } from './nz-comment.module';
describe('NzCommentComponent', () => {
-
beforeEach(async(() => {
TestBed.configureTestingModule({
- imports : [ NzCommentModule, NzListModule ],
- schemas : [ NO_ERRORS_SCHEMA ],
+ imports: [NzCommentModule, NzListModule],
+ schemas: [NO_ERRORS_SCHEMA],
declarations: [
NzDemoCommentBasicComponent,
NzDemoCommentEditorComponent,
NzDemoCommentListComponent,
NzDemoCommentNestedComponent
]
- })
- .compileComponents();
+ }).compileComponents();
}));
it('should basic work', () => {
@@ -51,24 +49,36 @@ describe('NzCommentComponent', () => {
expect(component.dislikes).toBe(0);
expect(comment.nativeElement.classList).toContain('ant-comment');
expect(comment.nativeElement.querySelectorAll('.ant-comment-actions li>span').length).toBe(3);
- expect(comment.nativeElement.querySelector('.ant-comment-actions li>span .like').innerText).toBe(component.likes.toString());
- expect(comment.nativeElement.querySelector('.ant-comment-actions li>span .dislike').innerText).toBe(component.dislikes.toString());
+ expect(comment.nativeElement.querySelector('.ant-comment-actions li>span .like').innerText).toBe(
+ component.likes.toString()
+ );
+ expect(comment.nativeElement.querySelector('.ant-comment-actions li>span .dislike').innerText).toBe(
+ component.dislikes.toString()
+ );
component.like();
fixture.detectChanges();
expect(component.likes).toBe(1);
expect(component.dislikes).toBe(0);
- expect(comment.nativeElement.querySelector('.ant-comment-actions li>span .like').innerText).toBe(component.likes.toString());
- expect(comment.nativeElement.querySelector('.ant-comment-actions li>span .dislike').innerText).toBe(component.dislikes.toString());
+ expect(comment.nativeElement.querySelector('.ant-comment-actions li>span .like').innerText).toBe(
+ component.likes.toString()
+ );
+ expect(comment.nativeElement.querySelector('.ant-comment-actions li>span .dislike').innerText).toBe(
+ component.dislikes.toString()
+ );
component.dislike();
fixture.detectChanges();
expect(component.likes).toBe(0);
expect(component.dislikes).toBe(1);
- expect(comment.nativeElement.querySelector('.ant-comment-actions li>span .like').innerText).toBe(component.likes.toString());
- expect(comment.nativeElement.querySelector('.ant-comment-actions li>span .dislike').innerText).toBe(component.dislikes.toString());
+ expect(comment.nativeElement.querySelector('.ant-comment-actions li>span .like').innerText).toBe(
+ component.likes.toString()
+ );
+ expect(comment.nativeElement.querySelector('.ant-comment-actions li>span .dislike').innerText).toBe(
+ component.dislikes.toString()
+ );
});
it('should list work', () => {
@@ -80,18 +90,17 @@ describe('NzCommentComponent', () => {
expect(component.data.length === comments.length).toBeTruthy();
component.data.forEach((e, i) => {
- const comment = comments[ i ];
+ const comment = comments[i];
expect(comment.nativeElement.querySelector('nz-avatar[nz-comment-avatar]')).toBeTruthy();
expect(comment.nativeElement.querySelector('.ant-comment-content-author-name').innerText).toBe(e.author);
expect(comment.nativeElement.querySelector('.ant-comment-content-detail p').innerText).toBe(e.content);
expect(comment.nativeElement.querySelector('.ant-comment-content-author-time').innerText).toBe(e.datetime);
});
- component.data = [ { ...component.data[ 0 ] } ];
+ component.data = [{ ...component.data[0] }];
fixture.detectChanges();
comments = fixture.debugElement.queryAll(By.directive(NzCommentComponent));
expect(component.data.length === comments.length).toBeTruthy();
-
});
it('should editor work', fakeAsync(() => {
@@ -116,13 +125,12 @@ describe('NzCommentComponent', () => {
comments = fixture.debugElement.queryAll(By.css('nz-list nz-comment'));
component.data.forEach((e, i) => {
- const comment = comments[ i ];
+ const comment = comments[i];
expect(comment.nativeElement.querySelector('nz-avatar[nz-comment-avatar]')).toBeTruthy();
expect(comment.nativeElement.querySelector('.ant-comment-content-author-name').innerText).toBe(e.author);
expect(comment.nativeElement.querySelector('.ant-comment-content-detail p').innerText).toBe(e.content);
expect(comment.nativeElement.querySelector('.ant-comment-content-author-time').innerText).toBe(e.displayTime);
});
-
}));
it('should nested work', () => {
@@ -137,7 +145,5 @@ describe('NzCommentComponent', () => {
const levelThreeComments = levelTwoComment.queryAll(By.directive(NzCommentComponent));
expect(levelThreeComments.length).toBe(2);
-
});
-
});
diff --git a/components/date-picker/abstract-picker.component.ts b/components/date-picker/abstract-picker.component.ts
index 2cdf68b917..2cb87f20e9 100644
--- a/components/date-picker/abstract-picker.component.ts
+++ b/components/date-picker/abstract-picker.component.ts
@@ -21,7 +21,7 @@ import { NzI18nService } from '../i18n/nz-i18n.service';
import { CandyDate } from './lib/candy-date';
import { NzPickerComponent } from './picker.component';
-const POPUP_STYLE_PATCH = { 'position': 'relative' }; // Aim to override antd's style to support overlay's position strategy (position:absolute will cause it not working beacuse the overlay can't get the height/width of it's content)
+const POPUP_STYLE_PATCH = { position: 'relative' }; // Aim to override antd's style to support overlay's position strategy (position:absolute will cause it not working beacuse the overlay can't get the height/width of it's content)
/**
* The base picker for all common APIs
@@ -60,14 +60,17 @@ export abstract class AbstractPickerComponent implements OnInit, OnChanges, OnDe
protected destroyed$: Subject = new Subject();
protected isCustomPlaceHolder: boolean = false;
- constructor(protected i18n: NzI18nService, protected cdr: ChangeDetectorRef, protected dateHelper: DateHelperService, public noAnimation?: NzNoAnimationDirective) { }
+ constructor(
+ protected i18n: NzI18nService,
+ protected cdr: ChangeDetectorRef,
+ protected dateHelper: DateHelperService,
+ public noAnimation?: NzNoAnimationDirective
+ ) {}
ngOnInit(): void {
// Subscribe the every locale change if the nzLocale is not handled by user
if (!this.nzLocale) {
- this.i18n.localeChange
- .pipe(takeUntil(this.destroyed$))
- .subscribe(() => this.setLocale());
+ this.i18n.localeChange.pipe(takeUntil(this.destroyed$)).subscribe(() => this.setLocale());
}
// Default value
@@ -75,7 +78,8 @@ export abstract class AbstractPickerComponent implements OnInit, OnChanges, OnDe
}
ngOnChanges(changes: SimpleChanges): void {
- if (changes.nzPopupStyle) { // Always assign the popup style patch
+ if (changes.nzPopupStyle) {
+ // Always assign the popup style patch
this.nzPopupStyle = this.nzPopupStyle ? { ...this.nzPopupStyle, ...POPUP_STYLE_PATCH } : POPUP_STYLE_PATCH;
}
@@ -84,7 +88,8 @@ export abstract class AbstractPickerComponent implements OnInit, OnChanges, OnDe
this.isCustomPlaceHolder = true;
}
- if (changes.nzLocale) { // The nzLocale is currently handled by user
+ if (changes.nzLocale) {
+ // The nzLocale is currently handled by user
this.setDefaultPlaceHolder();
}
}
@@ -107,7 +112,7 @@ export abstract class AbstractPickerComponent implements OnInit, OnChanges, OnDe
if (this.isRange) {
const vAsRange = this.nzValue as CandyDate[];
if (vAsRange.length) {
- this.onChangeFn([ vAsRange[ 0 ].nativeDate, vAsRange[ 1 ].nativeDate ]);
+ this.onChangeFn([vAsRange[0].nativeDate, vAsRange[1].nativeDate]);
} else {
this.onChangeFn([]);
}
@@ -142,11 +147,13 @@ export abstract class AbstractPickerComponent implements OnInit, OnChanges, OnDe
this.cdr.markForCheck();
}
- registerOnChange(fn: any): void { // tslint:disable-line:no-any
+ // tslint:disable-next-line:no-any
+ registerOnChange(fn: any): void {
this.onChangeFn = fn;
}
- registerOnTouched(fn: any): void { // tslint:disable-line:no-any
+ // tslint:disable-next-line:no-any
+ registerOnTouched(fn: any): void {
this.onTouchedFn = fn;
}
diff --git a/components/date-picker/date-picker.component.spec.ts b/components/date-picker/date-picker.component.spec.ts
index f542c5771f..8e4e887406 100644
--- a/components/date-picker/date-picker.component.spec.ts
+++ b/components/date-picker/date-picker.component.spec.ts
@@ -28,13 +28,11 @@ describe('NzDatePickerComponent', () => {
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
- imports : [ FormsModule, NoopAnimationsModule, NzDatePickerModule, NzI18nModule ],
- providers : [
+ imports: [FormsModule, NoopAnimationsModule, NzDatePickerModule, NzI18nModule],
+ providers: [
// { provide: NZ_DATE_CONFIG, useValue: { firstDayOfWeek: 1 } }
],
- declarations: [
- NzTestDatePickerComponent
- ]
+ declarations: [NzTestDatePickerComponent]
});
TestBed.compileComponents();
@@ -46,7 +44,7 @@ describe('NzDatePickerComponent', () => {
debugElement = fixture.debugElement;
});
- beforeEach(inject([ OverlayContainer, NzI18nService ], (oc: OverlayContainer, i18n: NzI18nService) => {
+ beforeEach(inject([OverlayContainer, NzI18nService], (oc: OverlayContainer, i18n: NzI18nService) => {
overlayContainer = oc;
overlayContainerElement = oc.getContainerElement();
i18nService = i18n;
@@ -57,7 +55,7 @@ describe('NzDatePickerComponent', () => {
});
describe('general api testing', () => {
- beforeEach(() => fixtureInstance.useSuite = 1);
+ beforeEach(() => (fixtureInstance.useSuite = 1));
it('should open by click and close by click at outside', fakeAsync(() => {
fixture.detectChanges();
@@ -86,7 +84,9 @@ describe('NzDatePickerComponent', () => {
fixture.detectChanges();
tick(500);
fixture.detectChanges();
- expect((queryFromOverlay('.ant-calendar-date-input-wrap input.ant-calendar-input') as HTMLInputElement).placeholder).toBe('Select date');
+ expect(
+ (queryFromOverlay('.ant-calendar-date-input-wrap input.ant-calendar-input') as HTMLInputElement).placeholder
+ ).toBe('Select date');
expect(queryFromOverlay('.ant-calendar-table .ant-calendar-column-header-inner').textContent).toContain('Su');
}));
@@ -114,7 +114,7 @@ describe('NzDatePickerComponent', () => {
it('should support nzAllowClear and work properly', fakeAsync(() => {
const clearBtnSelector = By.css('nz-picker i.ant-calendar-picker-clear');
- const initial = fixtureInstance.nzValue = new Date();
+ const initial = (fixtureInstance.nzValue = new Date());
fixtureInstance.nzAllowClear = false;
fixture.detectChanges();
expect(debugElement.query(clearBtnSelector)).toBeFalsy();
@@ -180,7 +180,7 @@ describe('NzDatePickerComponent', () => {
}));
it('should support nzClassName', () => {
- const className = fixtureInstance.nzClassName = 'my-test-class';
+ const className = (fixtureInstance.nzClassName = 'my-test-class');
fixture.detectChanges();
const picker = debugElement.queryAll(By.css('.ant-calendar-picker'))[1].nativeElement as HTMLElement;
expect(picker.classList.contains(className)).toBeTruthy();
@@ -208,7 +208,7 @@ describe('NzDatePickerComponent', () => {
});
it('should support nzPlaceHolder', () => {
- const featureKey = fixtureInstance.nzPlaceHolder = 'TEST_PLACEHOLDER';
+ const featureKey = (fixtureInstance.nzPlaceHolder = 'TEST_PLACEHOLDER');
fixture.detectChanges();
expect(getPickerTrigger().getAttribute('placeholder')).toBe(featureKey);
});
@@ -224,7 +224,7 @@ describe('NzDatePickerComponent', () => {
}));
it('should support nzDropdownClassName', fakeAsync(() => {
- const keyCls = fixtureInstance.nzDropdownClassName = 'my-test-class';
+ const keyCls = (fixtureInstance.nzDropdownClassName = 'my-test-class');
fixture.detectChanges();
dispatchMouseEvent(getPickerTriggerWrapper(), 'click');
fixture.detectChanges();
@@ -312,14 +312,13 @@ describe('NzDatePickerComponent', () => {
tick(500);
fixture.detectChanges();
expect(nzOnChange).toHaveBeenCalled();
- const result = nzOnChange.calls.allArgs()[ 0 ][ 0 ];
+ const result = nzOnChange.calls.allArgs()[0][0];
expect(result.getDate()).toBe(+cellText);
}));
-
});
describe('panel switch and move forward/afterward', () => {
- beforeEach(() => fixtureInstance.useSuite = 1);
+ beforeEach(() => (fixtureInstance.useSuite = 1));
it('should support date panel changes', fakeAsync(() => {
fixtureInstance.nzValue = new Date('2018-11-11');
@@ -373,13 +372,17 @@ describe('NzDatePickerComponent', () => {
tick(500);
fixture.detectChanges();
expect(queryFromOverlay('.ant-calendar-header .ant-calendar-month-panel')).toBeDefined();
- expect(queryFromOverlay('.ant-calendar-month-panel-year-select-content').textContent!.indexOf('2018') > -1).toBeTruthy();
+ expect(
+ queryFromOverlay('.ant-calendar-month-panel-year-select-content').textContent!.indexOf('2018') > -1
+ ).toBeTruthy();
// Goto previous year
dispatchMouseEvent(queryFromOverlay('.ant-calendar-month-panel-prev-year-btn'), 'click');
fixture.detectChanges();
tick(500);
fixture.detectChanges();
- expect(queryFromOverlay('.ant-calendar-month-panel-year-select-content').textContent!.indexOf('2017') > -1).toBeTruthy();
+ expect(
+ queryFromOverlay('.ant-calendar-month-panel-year-select-content').textContent!.indexOf('2017') > -1
+ ).toBeTruthy();
// Goto next year * 2
dispatchMouseEvent(queryFromOverlay('.ant-calendar-month-panel-next-year-btn'), 'click');
fixture.detectChanges();
@@ -389,7 +392,9 @@ describe('NzDatePickerComponent', () => {
fixture.detectChanges();
tick(500);
fixture.detectChanges();
- expect(queryFromOverlay('.ant-calendar-month-panel-year-select-content').textContent!.indexOf('2019') > -1).toBeTruthy();
+ expect(
+ queryFromOverlay('.ant-calendar-month-panel-year-select-content').textContent!.indexOf('2019') > -1
+ ).toBeTruthy();
// Click to choose a year to change panel
dispatchMouseEvent(queryFromOverlay('td.ant-calendar-month-panel-selected-cell'), 'click');
fixture.detectChanges();
@@ -410,8 +415,12 @@ describe('NzDatePickerComponent', () => {
tick(500);
fixture.detectChanges();
expect(queryFromOverlay('.ant-calendar-header .ant-calendar-year-panel')).toBeDefined();
- expect(queryFromOverlay('.ant-calendar-year-panel-decade-select-content').textContent!.indexOf('2010') > -1).toBeTruthy();
- expect(queryFromOverlay('.ant-calendar-year-panel-decade-select-content').textContent!.indexOf('2019') > -1).toBeTruthy();
+ expect(
+ queryFromOverlay('.ant-calendar-year-panel-decade-select-content').textContent!.indexOf('2010') > -1
+ ).toBeTruthy();
+ expect(
+ queryFromOverlay('.ant-calendar-year-panel-decade-select-content').textContent!.indexOf('2019') > -1
+ ).toBeTruthy();
// Coverage for last/next cell
dispatchMouseEvent(queryFromOverlay('.ant-calendar-year-panel-last-decade-cell'), 'click');
fixture.detectChanges();
@@ -426,8 +435,12 @@ describe('NzDatePickerComponent', () => {
fixture.detectChanges();
tick(500);
fixture.detectChanges();
- expect(queryFromOverlay('.ant-calendar-year-panel-decade-select-content').textContent!.indexOf('2000') > -1).toBeTruthy();
- expect(queryFromOverlay('.ant-calendar-year-panel-decade-select-content').textContent!.indexOf('2009') > -1).toBeTruthy();
+ expect(
+ queryFromOverlay('.ant-calendar-year-panel-decade-select-content').textContent!.indexOf('2000') > -1
+ ).toBeTruthy();
+ expect(
+ queryFromOverlay('.ant-calendar-year-panel-decade-select-content').textContent!.indexOf('2009') > -1
+ ).toBeTruthy();
// Goto next decade * 2
dispatchMouseEvent(queryFromOverlay('.ant-calendar-year-panel-next-decade-btn'), 'click');
fixture.detectChanges();
@@ -437,8 +450,12 @@ describe('NzDatePickerComponent', () => {
fixture.detectChanges();
tick(500);
fixture.detectChanges();
- expect(queryFromOverlay('.ant-calendar-year-panel-decade-select-content').textContent!.indexOf('2020') > -1).toBeTruthy();
- expect(queryFromOverlay('.ant-calendar-year-panel-decade-select-content').textContent!.indexOf('2029') > -1).toBeTruthy();
+ expect(
+ queryFromOverlay('.ant-calendar-year-panel-decade-select-content').textContent!.indexOf('2020') > -1
+ ).toBeTruthy();
+ expect(
+ queryFromOverlay('.ant-calendar-year-panel-decade-select-content').textContent!.indexOf('2029') > -1
+ ).toBeTruthy();
// Click to choose a year to change panel
dispatchMouseEvent(queryFromOverlay('td.ant-calendar-year-panel-selected-cell'), 'click');
fixture.detectChanges();
@@ -497,11 +514,10 @@ describe('NzDatePickerComponent', () => {
fixture.detectChanges();
expect(queryFromOverlay('.ant-calendar-header .ant-calendar-year-panel')).toBeDefined();
}));
-
}); // /panel switch and move forward/afterward
describe('specified date picker testing', () => {
- beforeEach(() => fixtureInstance.useSuite = 1);
+ beforeEach(() => (fixtureInstance.useSuite = 1));
it('should support nzDateRender', fakeAsync(() => {
fixtureInstance.nzDateRender = fixtureInstance.tplDateRender;
@@ -515,7 +531,7 @@ describe('NzDatePickerComponent', () => {
it('should support nzDateRender with typeof function', fakeAsync(() => {
const featureKey = 'TEST_FIRST_DAY';
- fixtureInstance.nzDateRender = (d: Date) => d.getDate() === 1 ? featureKey : d.getDate();
+ fixtureInstance.nzDateRender = (d: Date) => (d.getDate() === 1 ? featureKey : d.getDate());
fixture.detectChanges();
dispatchMouseEvent(getPickerTriggerWrapper(), 'click');
fixture.detectChanges();
@@ -540,7 +556,11 @@ describe('NzDatePickerComponent', () => {
tick(500);
fixture.detectChanges();
expect(queryFromOverlay('.ant-calendar-time-picker-inner.ant-calendar-time-picker-column-3')).toBeDefined();
- expect(queryFromOverlay('.ant-calendar-time-picker-select:first-child li.ant-calendar-time-picker-select-option-selected').textContent!.trim()).toBe('11');
+ expect(
+ queryFromOverlay(
+ '.ant-calendar-time-picker-select:first-child li.ant-calendar-time-picker-select-option-selected'
+ ).textContent!.trim()
+ ).toBe('11');
// Click to choose a hour
dispatchMouseEvent(queryFromOverlay('.ant-calendar-time-picker-select:first-child li:first-child'), 'click');
@@ -567,9 +587,9 @@ describe('NzDatePickerComponent', () => {
fixtureInstance.nzShowTime = true;
fixtureInstance.nzDisabledTime = () => {
return {
- nzDisabledHours : () => [ 0, 1, 2 ],
- nzDisabledMinutes: () => [ 0, 1 ],
- nzDisabledSeconds: () => [ 0 ]
+ nzDisabledHours: () => [0, 1, 2],
+ nzDisabledMinutes: () => [0, 1],
+ nzDisabledSeconds: () => [0]
};
};
fixture.detectChanges();
@@ -580,16 +600,34 @@ describe('NzDatePickerComponent', () => {
fixture.detectChanges();
tick(500);
fixture.detectChanges();
- expect(queryFromOverlay('.ant-calendar-time-picker-select:nth-child(1) li:nth-child(3)').classList.contains('ant-calendar-time-picker-select-option-disabled')).toBeTruthy();
- expect(queryFromOverlay('.ant-calendar-time-picker-select:nth-child(2) li:nth-child(2)').classList.contains('ant-calendar-time-picker-select-option-disabled')).toBeTruthy();
- expect(queryFromOverlay('.ant-calendar-time-picker-select:nth-child(3) li:nth-child(1)').classList.contains('ant-calendar-time-picker-select-option-disabled')).toBeTruthy();
+ expect(
+ queryFromOverlay('.ant-calendar-time-picker-select:nth-child(1) li:nth-child(3)').classList.contains(
+ 'ant-calendar-time-picker-select-option-disabled'
+ )
+ ).toBeTruthy();
+ expect(
+ queryFromOverlay('.ant-calendar-time-picker-select:nth-child(2) li:nth-child(2)').classList.contains(
+ 'ant-calendar-time-picker-select-option-disabled'
+ )
+ ).toBeTruthy();
+ expect(
+ queryFromOverlay('.ant-calendar-time-picker-select:nth-child(3) li:nth-child(1)').classList.contains(
+ 'ant-calendar-time-picker-select-option-disabled'
+ )
+ ).toBeTruthy();
// Use nzHideDisabledOptions to hide disabled times
fixtureInstance.nzShowTime = { nzHideDisabledOptions: true };
fixture.detectChanges();
- expect(+queryFromOverlay('.ant-calendar-time-picker-select:nth-child(1) li:first-child').textContent!.trim()).toBe(3);
- expect(+queryFromOverlay('.ant-calendar-time-picker-select:nth-child(2) li:first-child').textContent!.trim()).toBe(2);
- expect(+queryFromOverlay('.ant-calendar-time-picker-select:nth-child(3) li:first-child').textContent!.trim()).toBe(1);
+ expect(
+ +queryFromOverlay('.ant-calendar-time-picker-select:nth-child(1) li:first-child').textContent!.trim()
+ ).toBe(3);
+ expect(
+ +queryFromOverlay('.ant-calendar-time-picker-select:nth-child(2) li:first-child').textContent!.trim()
+ ).toBe(2);
+ expect(
+ +queryFromOverlay('.ant-calendar-time-picker-select:nth-child(3) li:first-child').textContent!.trim()
+ ).toBe(1);
}));
it('should support nzRenderExtraFooter', fakeAsync(() => {
@@ -619,7 +657,7 @@ describe('NzDatePickerComponent', () => {
fixture.detectChanges();
tick(500);
fixture.detectChanges();
- const result = nzOnChange.calls.allArgs()[ 0 ][ 0 ];
+ const result = nzOnChange.calls.allArgs()[0][0];
expect(isSameDay(new Date(), result)).toBeTruthy();
expect(queryFromOverlay('.ant-calendar-picker-container')).toBeFalsy(); // Should closed
}));
@@ -637,7 +675,10 @@ describe('NzDatePickerComponent', () => {
openPickerByClickTrigger();
// Click header to month panel
- dispatchMouseEvent(overlayContainerElement.querySelector('.ant-calendar-header .ant-calendar-month-select')!, 'click');
+ dispatchMouseEvent(
+ overlayContainerElement.querySelector('.ant-calendar-header .ant-calendar-month-select')!,
+ 'click'
+ );
fixture.detectChanges();
tick(500);
fixture.detectChanges();
@@ -683,14 +724,13 @@ describe('NzDatePickerComponent', () => {
flush();
fixture.detectChanges();
expect(nzOnChange).toHaveBeenCalled();
- const result = nzOnChange.calls.allArgs()[ 0 ][ 0 ];
+ const result = nzOnChange.calls.allArgs()[0][0];
expect(result.getDate()).toBe(22);
}));
-
}); // /specified date picker testing
describe('ngModel value accesors', () => {
- beforeEach(() => fixtureInstance.useSuite = 3);
+ beforeEach(() => (fixtureInstance.useSuite = 3));
it('should specified date provide by "modelValue" be choosed', fakeAsync(() => {
fixtureInstance.modelValue = new Date('2018-11-11');
@@ -744,14 +784,14 @@ describe('NzDatePickerComponent', () => {
tick(500);
fixture.detectChanges();
}
-
});
@Component({
template: `
- {
-
+
@@ -812,11 +849,9 @@ class NzTestDatePickerComponent {
nzSize: string;
nzStyle: NGStyleInterface;
- nzOnOpenChange(): void {
- }
+ nzOnOpenChange(): void {}
- nzOnChange(): void {
- }
+ nzOnChange(): void {}
nzValue: Date | null;
@@ -828,11 +863,9 @@ class NzTestDatePickerComponent {
nzMode: string;
// nzRanges;
- nzOnPanelChange(): void {
- }
+ nzOnPanelChange(): void {}
- nzOnOk(): void {
- }
+ nzOnOk(): void {}
// --- Suite 2
nzOpen: boolean;
diff --git a/components/date-picker/date-picker.component.ts b/components/date-picker/date-picker.component.ts
index ea7f4207d5..a3708cb01f 100644
--- a/components/date-picker/date-picker.component.ts
+++ b/components/date-picker/date-picker.component.ts
@@ -18,17 +18,18 @@ import { NzI18nService } from '../i18n/nz-i18n.service';
import { DateRangePickerComponent } from './date-range-picker.component';
@Component({
- encapsulation : ViewEncapsulation.None,
+ encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
- selector : 'nz-date-picker',
- templateUrl : './date-range-picker.component.html',
- providers : [ {
- provide : NG_VALUE_ACCESSOR,
- multi : true,
- useExisting: forwardRef(() => NzDatePickerComponent)
- } ]
+ selector: 'nz-date-picker',
+ templateUrl: './date-range-picker.component.html',
+ providers: [
+ {
+ provide: NG_VALUE_ACCESSOR,
+ multi: true,
+ useExisting: forwardRef(() => NzDatePickerComponent)
+ }
+ ]
})
-
export class NzDatePickerComponent extends DateRangePickerComponent {
isRange: boolean = false;
diff --git a/components/date-picker/date-picker.module.ts b/components/date-picker/date-picker.module.ts
index e82df0ceef..8a2d2db271 100644
--- a/components/date-picker/date-picker.module.ts
+++ b/components/date-picker/date-picker.module.ts
@@ -18,14 +18,7 @@ import { NzWeekPickerComponent } from './week-picker.component';
import { NzYearPickerComponent } from './year-picker.component';
@NgModule({
- imports: [
- CommonModule,
- OverlayModule,
- LibPackerModule,
- NzIconModule,
- NzOverlayModule,
- NzNoAnimationModule
- ],
+ imports: [CommonModule, OverlayModule, LibPackerModule, NzIconModule, NzOverlayModule, NzNoAnimationModule],
exports: [
NzDatePickerComponent,
NzRangePickerComponent,
@@ -45,4 +38,4 @@ import { NzYearPickerComponent } from './year-picker.component';
NzRangePickerComponent
]
})
-export class NzDatePickerModule { }
+export class NzDatePickerModule {}
diff --git a/components/date-picker/date-range-picker.component.ts b/components/date-picker/date-range-picker.component.ts
index 480c7913d1..c5e0856b08 100644
--- a/components/date-picker/date-range-picker.component.ts
+++ b/components/date-picker/date-range-picker.component.ts
@@ -1,4 +1,14 @@
-import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, TemplateRef } from '@angular/core';
+import {
+ ChangeDetectorRef,
+ Component,
+ EventEmitter,
+ Input,
+ OnChanges,
+ OnInit,
+ Output,
+ SimpleChanges,
+ TemplateRef
+} from '@angular/core';
import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive';
import { FunctionProp } from '../core/types/common-wrap';
@@ -25,21 +35,29 @@ export class DateRangePickerComponent extends AbstractPickerComponent implements
@Output() readonly nzOnPanelChange = new EventEmitter();
private _showTime: object | boolean;
- @Input() get nzShowTime(): object | boolean { return this._showTime; }
+ @Input() get nzShowTime(): object | boolean {
+ return this._showTime;
+ }
set nzShowTime(value: object | boolean) {
this._showTime = typeof value === 'object' ? value : toBoolean(value);
}
@Output() readonly nzOnOk = new EventEmitter();
- get realShowToday(): boolean { // Range not support nzShowToday currently
+ get realShowToday(): boolean {
+ // Range not support nzShowToday currently
return !this.isRange && this.nzShowToday;
}
pickerStyle: object; // Final picker style that contains width fix corrections etc.
extraFooter: TemplateRef | string;
- constructor(i18n: NzI18nService, cdr: ChangeDetectorRef, dateHelper: DateHelperService, noAnimation?: NzNoAnimationDirective) {
+ constructor(
+ i18n: NzI18nService,
+ cdr: ChangeDetectorRef,
+ dateHelper: DateHelperService,
+ noAnimation?: NzNoAnimationDirective
+ ) {
super(i18n, cdr, dateHelper, noAnimation);
}
@@ -86,7 +104,7 @@ export class DateRangePickerComponent extends AbstractPickerComponent implements
if (this.isRange) {
const value = this.nzValue as CandyDate[];
if (value.length) {
- this.nzOnOk.emit([ value[ 0 ].nativeDate, value[ 1 ].nativeDate ]);
+ this.nzOnOk.emit([value[0].nativeDate, value[1].nativeDate]);
} else {
this.nzOnOk.emit([]);
}
diff --git a/components/date-picker/demo/basic.ts b/components/date-picker/demo/basic.ts
index a957180ced..dbac78452c 100644
--- a/components/date-picker/demo/basic.ts
+++ b/components/date-picker/demo/basic.ts
@@ -6,24 +6,33 @@ import { en_US, zh_CN, NzI18nService } from 'ng-zorro-antd';
selector: 'nz-demo-date-picker-basic',
template: `
-
-
-
+
+
+
-
+
-
+
-
+
Switch language for all pickers
`,
- styles : [ `
- nz-date-picker, nz-month-picker, nz-year-picker, nz-range-picker, nz-week-picker {
- margin: 0 8px 12px 0;
- }
- ` ]
+ styles: [
+ `
+ nz-date-picker,
+ nz-month-picker,
+ nz-year-picker,
+ nz-range-picker,
+ nz-week-picker {
+ margin: 0 8px 12px 0;
+ }
+ `
+ ]
})
-
export class NzDemoDatePickerBasicComponent {
date = null; // new Date();
dateRange = []; // [ new Date(), addDays(new Date(), 3) ];
diff --git a/components/date-picker/demo/date-render.ts b/components/date-picker/demo/date-render.ts
index 23d77b6785..8191138974 100644
--- a/components/date-picker/demo/date-render.ts
+++ b/components/date-picker/demo/date-render.ts
@@ -12,16 +12,19 @@ import { Component } from '@angular/core';
`,
- styles : [ `
- nz-date-picker, nz-month-picker, nz-range-picker, nz-week-picker {
- margin: 0 8px 12px 0;
- }
- .border{
- border: 1px solid #1890ff;
- border-radius: 50%;
- }
- ` ]
+ styles: [
+ `
+ nz-date-picker,
+ nz-month-picker,
+ nz-range-picker,
+ nz-week-picker {
+ margin: 0 8px 12px 0;
+ }
+ .border {
+ border: 1px solid #1890ff;
+ border-radius: 50%;
+ }
+ `
+ ]
})
-
-export class NzDemoDatePickerDateRenderComponent {
-}
+export class NzDemoDatePickerDateRenderComponent {}
diff --git a/components/date-picker/demo/disabled-date.ts b/components/date-picker/demo/disabled-date.ts
index b95cffd877..e863b9bdb8 100644
--- a/components/date-picker/demo/disabled-date.ts
+++ b/components/date-picker/demo/disabled-date.ts
@@ -9,13 +9,14 @@ import setHours from 'date-fns/set_hours';
nzFormat="yyyy-MM-dd HH:mm:ss"
[nzDisabledDate]="disabledDate"
[nzDisabledTime]="disabledDateTime"
- [nzShowTime]="{ nzDefaultOpenValue: timeDefaultValue }">
+ [nzShowTime]="{ nzDefaultOpenValue: timeDefaultValue }"
+ >
-