diff --git a/.gitignore b/.gitignore index de00da88e0..42cd9f4399 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ integration/**/*.ngsummary.json # dependencies node_modules/ +node_modules.*/ package-lock.json integration/**/package-lock.json yarn.lock diff --git a/index.ts b/index.ts deleted file mode 100644 index 7e3898fb32..0000000000 --- a/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './src/release/ng-zorro-antd.module'; diff --git a/integration/angular-cli/.angular-cli.json b/integration/angular-cli/.angular-cli.json index 096567e975..6c8dc9cd0b 100644 --- a/integration/angular-cli/.angular-cli.json +++ b/integration/angular-cli/.angular-cli.json @@ -55,28 +55,6 @@ }, "defaults": { "styleExt": "css", - "component": { - "spec": false, - "inlineStyle": true, - "inlineTemplate": true - }, - "directive": { - "spec": false - }, - "class": { - "spec": false - }, - "guard": { - "spec": false - }, - "module": { - "spec": false - }, - "pipe": { - "spec": false - }, - "service": { - "spec": false - } + "component": {} } } diff --git a/integration/rollup/rollup.config.js b/integration/rollup/rollup.config.js index 195d9c0a75..c411a47eb7 100644 --- a/integration/rollup/rollup.config.js +++ b/integration/rollup/rollup.config.js @@ -22,7 +22,7 @@ function enableProdMode() { export default { - input: './out-tsc/app/main.js', + input: './out-tsc/app/src/main.js', output: { file: './dist/main.bundle.js', format: 'iife', diff --git a/integration/webpack/webpack.config.js b/integration/webpack/webpack.config.js index d9eb9a0700..39a4592048 100644 --- a/integration/webpack/webpack.config.js +++ b/integration/webpack/webpack.config.js @@ -1,7 +1,7 @@ const path = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin') const UglifyJSPlugin = require('uglifyjs-webpack-plugin') -const { AotPlugin } = require('@ngtools/webpack') +const { AngularCompilerPlugin } = require('@ngtools/webpack') const { PurifyPlugin } = require('@angular-devkit/build-optimizer') function packageSort(packages) { @@ -49,7 +49,7 @@ module.exports = { extensions: ['.js', '.ts'], }, plugins: [ - new AotPlugin({ + new AngularCompilerPlugin({ tsConfigPath: path.resolve(__dirname, 'src/tsconfig.app.json'), entryModule: path.resolve(__dirname, 'src/app/app.module#AppModule'), }), diff --git a/package.json b/package.json index 5eea3e46f4..04c2731153 100644 --- a/package.json +++ b/package.json @@ -35,28 +35,28 @@ "url": "https://github.com/NG-ZORRO/ng-zorro-antd/issues" }, "dependencies": { - "@angular/cdk": "2.0.0-beta.12", + "@angular/cdk": "5.0.0-rc0", "moment": "^2.18.1", "tslib": "^1.7.1" }, "devDependencies": { - "@angular/animations": "^4.4.4", - "@angular/cli": "1.4.7", - "@angular/common": "^4.4.4", - "@angular/compiler": "^4.4.4", - "@angular/compiler-cli": "^4.4.4", - "@angular/core": "^4.4.4", - "@angular/forms": "^4.4.4", - "@angular/http": "^4.4.4", - "@angular/language-service": "^4.4.4", - "@angular/platform-browser": "^4.4.4", - "@angular/platform-browser-dynamic": "^4.4.4", - "@angular/router": "^4.4.4", + "@angular/animations": "^5.0.0", + "@angular/cli": "1.5.0", + "@angular/common": "^5.0.0", + "@angular/compiler": "^5.0.0", + "@angular/compiler-cli": "^5.0.0", + "@angular/core": "^5.0.0", + "@angular/forms": "^5.0.0", + "@angular/http": "^5.0.0", + "@angular/language-service": "^5.0.0", + "@angular/platform-browser": "^5.0.0", + "@angular/platform-browser-dynamic": "^5.0.0", + "@angular/router": "^5.0.0", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", "classlist.js": "^1.1.20150312", - "codelyzer": "~3.1.1", + "codelyzer": "~4.0.1", "core-js": "^2.4.1", "coveralls": "^2.13.1", "highlight.js": "^9.12.0", @@ -75,20 +75,20 @@ "rollup-plugin-commonjs": "^8.2.1", "rollup-plugin-node-resolve": "^3.0.0", "rollup-plugin-replace": "^2.0.0", - "rxjs": "^5.0.1", + "rxjs": "^5.5.2", "ts-node": "~3.2.0", - "tslint": "~5.3.2", - "typescript": "~2.3.3", + "tslint": "~5.7.0", + "typescript": "~2.4.2", "uglify-js": "^3.0.28", "web-animations-js": "^2.3.1", - "zone.js": "^0.8.14" + "zone.js": "^0.8.17" }, "peerDependencies": { - "@angular/animations": "^4.4.4", - "@angular/cdk": "2.0.0-beta.12", - "@angular/common": "^4.4.4", - "@angular/core": "^4.4.4", - "@angular/forms": "^4.4.4", + "@angular/animations": "^5.0.0", + "@angular/cdk": "5.0.0-rc0", + "@angular/common": "^5.0.0", + "@angular/core": "^5.0.0", + "@angular/forms": "^5.0.0", "moment": "^2.18.1" } } diff --git a/rollup.config.js b/rollup.config.js index cf89d06c19..7369aa4b3e 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,20 +6,65 @@ const format = process.env.ROLLUP_FORMAT || 'es'; let globals = { '@angular/animations': 'ng.animations', - // '@angular/cdk': 'ng.cdk', - '@angular/cdk/rxjs': 'ng.cdk.rxjs', - '@angular/cdk/keycodes': 'ng.cdk.keycodes', - '@angular/cdk/overlay': 'ng.cdk.overlay', - '@angular/cdk/portal': 'ng.cdk.portal', - '@angular/cdk/bidi': 'ng.cdk.bidi', - '@angular/cdk/observers': 'ng.cdk.observers', '@angular/core': 'ng.core', '@angular/common': 'ng.common', - '@angular/compiler': 'ng.compiler', '@angular/forms': 'ng.forms', + '@angular/common/http': 'ng.common.http', + '@angular/router': 'ng.router', '@angular/platform-browser': 'ng.platformBrowser', + '@angular/platform-server': 'ng.platformServer', + '@angular/platform-browser-dynamic': 'ng.platformBrowserDynamic', + '@angular/platform-browser/animations': 'ng.platformBrowser.animations', + '@angular/core/testing': 'ng.core.testing', + '@angular/common/testing': 'ng.common.testing', + '@angular/common/http/testing': 'ng.common.http.testing', + + '@angular/cdk': 'ng.cdk', + '@angular/cdk/keycodes': 'ng.cdk.keycodes', + '@angular/cdk/a11y': 'ng.cdk.a11y', + '@angular/cdk/accordion': 'ng.cdk.accordion', + '@angular/cdk/bidi': 'ng.cdk.bidi', + '@angular/cdk/coercion': 'ng.cdk.coercion', + '@angular/cdk/collections': 'ng.cdk.collections', + '@angular/cdk/layout': 'ng.cdk.layout', + '@angular/cdk/observers': 'ng.cdk.observers', + '@angular/cdk/overlay': 'ng.cdk.overlay', + '@angular/cdk/platform': 'ng.cdk.platform', + '@angular/cdk/portal': 'ng.cdk.portal', + '@angular/cdk/scrolling': 'ng.cdk.scrolling', + '@angular/cdk/stepper': 'ng.cdk.stepper', + '@angular/cdk/table': 'ng.cdk.table', + 'moment': 'moment', 'moment/locale/zh-cn': null, + + 'rxjs/Observer': 'Rx', + 'rxjs/Subscriber': 'Rx', + 'rxjs/Scheduler': 'Rx', + + 'rxjs/observable/combineLatest': 'Rx.Observable', + 'rxjs/observable/throw': 'Rx.Observable', + 'rxjs/observable/defer': 'Rx.Observable', + 'rxjs/observable/fromEventPattern': 'Rx.Observable', + 'rxjs/observable/empty': 'Rx.Observable', + + 'rxjs/operators/finalize': 'Rx.Observable', + 'rxjs/operators/catchError': 'Rx.Observable', + 'rxjs/operators/combineLatest': 'Rx.Observable', + + 'rxjs/add/observable/merge': 'Rx.Observable', + 'rxjs/add/observable/fromEvent': 'Rx.Observable', + 'rxjs/add/observable/of': 'Rx.Observable', + 'rxjs/add/observable/interval': 'Rx.Observable', + 'rxjs/add/operator/startWith': 'Rx.Observable.prototype', + 'rxjs/add/operator/map': 'Rx.Observable.prototype', + 'rxjs/add/operator/debounceTime': 'Rx.Observable.prototype', + 'rxjs/add/operator/distinctUntilChanged': 'Rx.Observable.prototype', + 'rxjs/add/operator/first': 'Rx.Observable.prototype', + 'rxjs/add/operator/catch': 'Rx.Observable.prototype', + 'rxjs/add/operator/switchMap': 'Rx.Observable.prototype', + + 'rxjs/BehaviorSubject': 'Rx', 'rxjs/Observable': 'Rx', 'rxjs/Subject': 'Rx', @@ -29,6 +74,8 @@ let globals = { 'rxjs/observable/fromEvent': 'Rx.Observable', 'rxjs/observable/merge': 'Rx.Observable', 'rxjs/observable/of': 'Rx.Observable', + + // Legacy operators used by 3rd packages like @angular/core 'rxjs/operator/auditTime': 'Rx.Observable.prototype', 'rxjs/operator/catch': 'Rx.Observable.prototype', 'rxjs/operator/debounceTime': 'Rx.Observable.prototype', @@ -45,6 +92,25 @@ let globals = { 'rxjs/operator/switchMap': 'Rx.Observable.prototype', 'rxjs/operator/takeUntil': 'Rx.Observable.prototype', 'rxjs/operator/throttleTime': 'Rx.Observable.prototype', + + // Operators with chain-functionality itself (from rxjs 5.x) used by us + 'rxjs/operators/auditTime': 'Rx.Observable.prototype', + 'rxjs/operators/catch': 'Rx.Observable.prototype', + 'rxjs/operators/debounceTime': 'Rx.Observable.prototype', + 'rxjs/operators/delay': 'Rx.Observable.prototype', + 'rxjs/operators/distinctUntilChanged': 'Rx.Observable.prototype', + 'rxjs/operators/do': 'Rx.Observable.prototype', + 'rxjs/operators/filter': 'Rx.Observable.prototype', + 'rxjs/operators/finally': 'Rx.Observable.prototype', + 'rxjs/operators/first': 'Rx.Observable.prototype', + 'rxjs/operators/map': 'Rx.Observable.prototype', + 'rxjs/operators/pluck': 'Rx.Observable.prototype', + 'rxjs/operators/share': 'Rx.Observable.prototype', + 'rxjs/operators/startWith': 'Rx.Observable.prototype', + 'rxjs/operators/switchMap': 'Rx.Observable.prototype', + 'rxjs/operators/takeUntil': 'Rx.Observable.prototype', + 'rxjs/operators/throttleTime': 'Rx.Observable.prototype', + 'rxjs/operators/tap': 'Rx.Observable.prototype', }; if (format === 'es') { diff --git a/src/components/affix/nz-affix.component.ts b/src/components/affix/nz-affix.component.ts index e4a2e005dc..d613191222 100644 --- a/src/components/affix/nz-affix.component.ts +++ b/src/components/affix/nz-affix.component.ts @@ -5,26 +5,25 @@ import { Input, EventEmitter, Output, - Renderer2, OnDestroy, ViewChild, - ElementRef, - HostBinding + ElementRef } from '@angular/core'; -// import { Observable } from 'rxjs/Observable'; -import { RxChain } from '@angular/cdk/rxjs'; import { fromEvent } from 'rxjs/observable/fromEvent'; -import { throttleTime } from 'rxjs/operator/throttleTime'; -import { distinctUntilChanged } from 'rxjs/operator/distinctUntilChanged'; import { Subscription } from 'rxjs/Subscription'; +import { throttleTime } from 'rxjs/operators/throttleTime'; +import { distinctUntilChanged } from 'rxjs/operators/distinctUntilChanged'; import { NzScrollService } from '../core/scroll/nz-scroll.service'; @Component({ - selector: 'nz-affix', + selector : 'nz-affix', encapsulation: ViewEncapsulation.None, - template: `
`, - styleUrls: [ + template : ` +
+ +
`, + styleUrls : [ './style/index.less', './style/patch.less' ] @@ -38,7 +37,7 @@ export class NzAffixComponent implements OnInit, OnDestroy { private target: Element = null; @ViewChild('wrap') private wrap: ElementRef; // 缓存固定状态 - private fixed: boolean = false; + private fixed = false; // 原始位置 private orgOffset: { top: number, left: number }; @@ -48,16 +47,19 @@ export class NzAffixComponent implements OnInit, OnDestroy { this.registerScrollEvent(); } - @Input() nzOffsetTop: number = 0; + @Input() nzOffsetTop = 0; - @Input() nzOffsetBottom: number = 0; + @Input() nzOffsetBottom = 0; @Output() nzChange: EventEmitter = new EventEmitter(); - constructor(private scrollSrv: NzScrollService, private _el: ElementRef, private _renderer: Renderer2) { } + constructor(private scrollSrv: NzScrollService, private _el: ElementRef) { + } ngOnInit(): void { - if (!this.scroll$) this.registerScrollEvent(); + if (!this.scroll$) { + this.registerScrollEvent(); + } } private getTarget(): Element | Window { @@ -65,9 +67,9 @@ export class NzAffixComponent implements OnInit, OnDestroy { } private reCalculate() { - let elOffset = this.scrollSrv.getOffset(this._el.nativeElement); + const elOffset = this.scrollSrv.getOffset(this._el.nativeElement); this.orgOffset = { - top: elOffset.top + this.scrollSrv.getScroll(this.getTarget()), + top : elOffset.top + this.scrollSrv.getScroll(this.getTarget()), left: elOffset.left + this.scrollSrv.getScroll(this.getTarget(), false) }; @@ -75,14 +77,18 @@ export class NzAffixComponent implements OnInit, OnDestroy { } private process() { - if (!this.orgOffset) this.reCalculate(); + if (!this.orgOffset) { + this.reCalculate(); + } const containerScrollTop = this.scrollSrv.getScroll(this.getTarget()); - let fixTop = this.getTarget() === window ? 0 : this.scrollSrv.getOffset(this.getTarget() as Element).top; - let hasFixed = this.orgOffset.top - fixTop - containerScrollTop - this.nzOffsetTop <= 0; - if (this.fixed === hasFixed) return; + const fixTop = this.getTarget() === window ? 0 : this.scrollSrv.getOffset(this.getTarget() as Element).top; + const hasFixed = this.orgOffset.top - fixTop - containerScrollTop - this.nzOffsetTop <= 0; + if (this.fixed === hasFixed) { + return; + } const wrapEl = this.wrap.nativeElement; - wrapEl.classList[hasFixed ? 'add' : 'remove']('ant-affix'); + wrapEl.classList[ hasFixed ? 'add' : 'remove' ]('ant-affix'); if (hasFixed) { wrapEl.style.cssText = `top:${this.nzOffsetTop + fixTop}px;left:${this.orgOffset.left}px`; } else { @@ -94,9 +100,15 @@ export class NzAffixComponent implements OnInit, OnDestroy { } private removeListen() { - if (this.scrollTime) clearTimeout(this.scrollTime); - if (this.scroll$) this.scroll$.unsubscribe(); - if (this.scrollWinInTarget$) this.scrollWinInTarget$.unsubscribe(); + if (this.scrollTime) { + clearTimeout(this.scrollTime); + } + if (this.scroll$) { + this.scroll$.unsubscribe(); + } + if (this.scrollWinInTarget$) { + this.scrollWinInTarget$.unsubscribe(); + } } private registerScrollEvent() { @@ -108,14 +120,12 @@ export class NzAffixComponent implements OnInit, OnDestroy { this.process(); } }, 100); - this.scroll$ = (RxChain.from(fromEvent(this.getTarget(), 'scroll')) as RxChain) + this.scroll$ = fromEvent(this.getTarget(), 'scroll') .subscribe(() => this.didScroll = true); if (this.getTarget() !== window) { // 当 window 滚动位发生变动时,需要重新计算滚动容器 - this.scrollWinInTarget$ = (RxChain.from(fromEvent(window, 'scroll')) as RxChain) - .call(throttleTime, 50) - .call(distinctUntilChanged) + this.scrollWinInTarget$ = fromEvent(window, 'scroll').pipe(throttleTime(50), distinctUntilChanged()) .subscribe(e => { this.orgOffset = null; this.fixed = false; diff --git a/src/components/anchor/nz-anchor.component.ts b/src/components/anchor/nz-anchor.component.ts index 52d5f04db1..bb8777d87a 100644 --- a/src/components/anchor/nz-anchor.component.ts +++ b/src/components/anchor/nz-anchor.component.ts @@ -1,7 +1,6 @@ import { Component, ViewEncapsulation, - OnInit, Input, EventEmitter, Output, @@ -9,47 +8,46 @@ import { OnDestroy, ViewChild, ElementRef, - Inject + Inject, OnInit } from '@angular/core'; -import { DOCUMENT } from '@angular/platform-browser'; -import { RxChain } from '@angular/cdk/rxjs'; +import { DOCUMENT } from '@angular/common'; import { fromEvent } from 'rxjs/observable/fromEvent'; -import { throttleTime } from 'rxjs/operator/throttleTime'; -import { distinctUntilChanged } from 'rxjs/operator/distinctUntilChanged'; +import { throttleTime } from 'rxjs/operators/throttleTime'; +import { distinctUntilChanged } from 'rxjs/operators/distinctUntilChanged'; import { Subscription } from 'rxjs/Subscription'; import { NzScrollService } from '../core/scroll/nz-scroll.service'; import { NzAnchorLinkComponent } from './nz-anchor-link.component'; -type Section = { +interface Section { comp: NzAnchorLinkComponent, top: number -}; +} @Component({ - selector: 'nz-anchor', + selector : 'nz-anchor', encapsulation: ViewEncapsulation.None, - template: ` -
-
-
-
+ template : ` +
+
+
+
+
+
-
-
`, - styleUrls: [ + styleUrls : [ './style/index.less', './style/patch.less' ] }) -export class NzAnchorComponent { +export class NzAnchorComponent implements OnDestroy, OnInit { private links: NzAnchorLinkComponent[] = []; private scroll$: Subscription = null; private target: Element = null; - private animating: boolean = false; + private animating = false; @ViewChild('container') private container: ElementRef; @@ -57,8 +55,8 @@ export class NzAnchorComponent { @ViewChild('ball') private ball: ElementRef; - _top: number = 0; - _visible: boolean = false; + _top = 0; + _visible = false; @Input() set nzTarget(el: Element) { @@ -66,16 +64,19 @@ export class NzAnchorComponent { this.registerScrollEvent(); } - @Input() nzOffsetTop: number = 0; + @Input() nzOffsetTop = 0; - @Input() nzBounds: number = 5; + @Input() nzBounds = 5; @Output() nzScroll: EventEmitter = new EventEmitter(); - constructor(private scrollSrv: NzScrollService, private _renderer: Renderer2, @Inject(DOCUMENT) private doc: Document) { } + constructor(private scrollSrv: NzScrollService, private _renderer: Renderer2, @Inject(DOCUMENT) private doc: any) { + } ngOnInit(): void { - if (!this.scroll$) this.registerScrollEvent(); + if (!this.scroll$) { + this.registerScrollEvent(); + } } private getTarget(): Element | Window { @@ -83,9 +84,11 @@ export class NzAnchorComponent { } private handleScroll() { - if (this.animating) return; + if (this.animating) { + return; + } - let sections: Section[] = []; + const sections: Section[] = []; this.links.forEach(comp => { comp.active = false; const target = this.doc.querySelector(comp.nzHref); @@ -99,20 +102,23 @@ export class NzAnchorComponent { }); this._visible = !!sections.length; - if (!this._visible) + if (!this._visible) { return; + } const maxSection = sections.reduce((prev, curr) => curr.top > prev.top ? curr : prev); maxSection.comp.active = true; - let linkNode = (maxSection.comp.el.nativeElement as HTMLDivElement).querySelector('.ant-anchor-link-title') as HTMLElement; + const linkNode = (maxSection.comp.el.nativeElement as HTMLDivElement).querySelector('.ant-anchor-link-title') as HTMLElement; this.ball.nativeElement.style.top = `${linkNode.offsetTop + linkNode.clientHeight / 2 - 4.5}px`; this.nzScroll.emit(maxSection.comp); } private removeListen() { - if (this.scroll$) this.scroll$.unsubscribe(); + if (this.scroll$) { + this.scroll$.unsubscribe(); + } } private registerScrollEvent() { @@ -122,9 +128,7 @@ export class NzAnchorComponent { setTimeout(() => { this.handleScroll(); }, 500); - this.scroll$ = (RxChain.from(fromEvent(this.getTarget(), 'scroll')) as RxChain) - .call(throttleTime, 50) - .call(distinctUntilChanged) + this.scroll$ = fromEvent(this.getTarget(), 'scroll').pipe(throttleTime(50), distinctUntilChanged()) .subscribe(e => { this.handleScroll(); }); @@ -137,7 +141,9 @@ export class NzAnchorComponent { /** 设置滚动条至 `linkComp` 所处位置 */ scrollTo(linkComp: NzAnchorLinkComponent) { const el = this.doc.querySelector(linkComp.nzHref); - if (!el) return; + if (!el) { + return; + } this.animating = true; const containerScrollTop = this.scrollSrv.getScroll(this.getTarget()); diff --git a/src/components/back-top/nz-back-top.component.ts b/src/components/back-top/nz-back-top.component.ts index 7b008e72e7..eea0fb1f87 100644 --- a/src/components/back-top/nz-back-top.component.ts +++ b/src/components/back-top/nz-back-top.component.ts @@ -17,19 +17,17 @@ import { transition, animate } from '@angular/animations'; -// import { Observable } from 'rxjs/Observable'; -import { RxChain } from '@angular/cdk/rxjs'; import { fromEvent } from 'rxjs/observable/fromEvent'; -import { throttleTime } from 'rxjs/operator/throttleTime'; -import { distinctUntilChanged } from 'rxjs/operator/distinctUntilChanged'; +import { throttleTime } from 'rxjs/operators/throttleTime'; +import { distinctUntilChanged } from 'rxjs/operators/distinctUntilChanged'; import { Subscription } from 'rxjs/Subscription'; import { NzScrollService } from '../core/scroll/nz-scroll.service'; @Component({ - selector: 'nz-back-top', + selector : 'nz-back-top', encapsulation: ViewEncapsulation.None, - animations: [ + animations : [ trigger('enterLeave', [ transition(':enter', [ style({ opacity: 0 }), @@ -41,15 +39,15 @@ import { NzScrollService } from '../core/scroll/nz-scroll.service'; ]) ]) ], - template: ` -
- -
-
- -
+ template : ` +
+ +
+
+ +
`, - styleUrls: [ + styleUrls : [ './style/index.less', './style/patch.less' ] @@ -73,7 +71,8 @@ export class NzBackTopComponent implements OnInit, OnDestroy { @Output() nzClick: EventEmitter = new EventEmitter(); - constructor(private scrollSrv: NzScrollService, private _renderer: Renderer2) { } + constructor(private scrollSrv: NzScrollService, private _renderer: Renderer2) { + } ngOnInit(): void { if (!this.scroll$) this.registerScrollEvent(); @@ -99,9 +98,7 @@ export class NzBackTopComponent implements OnInit, OnDestroy { private registerScrollEvent() { this.removeListen(); this.handleScroll(); - this.scroll$ = (RxChain.from(fromEvent(this.getTarget(), 'scroll')) as RxChain) - .call(throttleTime, 50) - .call(distinctUntilChanged) + this.scroll$ = fromEvent(this.getTarget(), 'scroll').pipe(throttleTime(50), distinctUntilChanged()) .subscribe(e => { this.handleScroll(); }); diff --git a/src/components/collapse/nz-collapseset.component.ts b/src/components/collapse/nz-collapseset.component.ts index 3c89b3984c..5e0244b2e5 100644 --- a/src/components/collapse/nz-collapseset.component.ts +++ b/src/components/collapse/nz-collapseset.component.ts @@ -21,10 +21,7 @@ import { NzCollapseComponent } from './nz-collapse.component'; export class NzCollapsesetComponent { - /** - * all child collapse - * @type {Array} - */ + // all child collapse panels: Array = []; @Input() nzAccordion = false; diff --git a/src/components/core/scroll/nz-scroll.service.spec.ts b/src/components/core/scroll/nz-scroll.service.spec.ts index e45809ca81..71ea95503f 100644 --- a/src/components/core/scroll/nz-scroll.service.spec.ts +++ b/src/components/core/scroll/nz-scroll.service.spec.ts @@ -1,6 +1,6 @@ import { ReflectiveInjector } from '@angular/core'; import { PlatformLocation } from '@angular/common'; -import { DOCUMENT } from '@angular/platform-browser'; +import { DOCUMENT } from '@angular/common'; import { NzScrollService } from './nz-scroll.service'; diff --git a/src/components/core/scroll/nz-scroll.service.ts b/src/components/core/scroll/nz-scroll.service.ts index b1f222d745..c9363b189d 100644 --- a/src/components/core/scroll/nz-scroll.service.ts +++ b/src/components/core/scroll/nz-scroll.service.ts @@ -15,7 +15,7 @@ function easeInOutCubic(t: number, b: number, c: number, d: number) { @Injectable() export class NzScrollService { - constructor(@Inject(DOCUMENT) private doc: Document) { + constructor(@Inject(DOCUMENT) private doc: any) { } /** 设置 `el` 滚动条位置 */ @@ -65,10 +65,10 @@ export class NzScrollService { /** * 使用动画形式将 `el` 滚动至某位置 * - * @param {(Element | Window)} containerEl 容器,默认 `window` - * @param {number} [targetTopValue=0] 滚动至目标 `top` 值,默认:0,相当于顶部 - * @param {Function} [easing] 动作算法,默认:`easeInOutCubic` - * @param {Function} [callback] 动画结束后回调 + * @param containerEl 容器,默认 `window` + * @param targetTopValue 滚动至目标 `top` 值,默认:0,相当于顶部 + * @param easing 动作算法,默认:`easeInOutCubic` + * @param callback 动画结束后回调 */ scrollTo(containerEl: Element | Window, targetTopValue: number = 0, easing?: Function, callback?: Function) { if (!containerEl) containerEl = window; diff --git a/src/components/dropdown/nz-dropdown.component.ts b/src/components/dropdown/nz-dropdown.component.ts index bc15b64711..e8f7cb775d 100644 --- a/src/components/dropdown/nz-dropdown.component.ts +++ b/src/components/dropdown/nz-dropdown.component.ts @@ -13,7 +13,7 @@ import { ChangeDetectorRef } from '@angular/core'; import { merge } from 'rxjs/observable/merge'; -import { debounceTime } from 'rxjs/operator/debounceTime'; +import { debounceTime } from 'rxjs/operators/debounceTime'; import { Observable } from 'rxjs/Observable'; import { Subject } from 'rxjs/Subject'; import { Subscription } from 'rxjs/Subscription'; @@ -79,7 +79,7 @@ export class NzDropDownComponent implements OnInit, OnDestroy, AfterViewInit { @Input() nzTrigger: 'click' | 'hover' = 'hover'; @Input() nzClickHide = true; @Input() nzVisible = false; - @Output() _visibleChange = new Subject(); + @Output() _visibleChange = new Subject(); @Output() nzVisibleChange: EventEmitter = new EventEmitter(); @Input() @@ -148,7 +148,7 @@ export class NzDropDownComponent implements OnInit, OnDestroy, AfterViewInit { } _startSubscribe(observable$: Observable) { - this._subscription = debounceTime.call(observable$, 300) + this._subscription = observable$.pipe(debounceTime(300)) .subscribe(this._onVisibleChange) } diff --git a/src/components/menu/nz-submenu.component.ts b/src/components/menu/nz-submenu.component.ts index 712efe6fe5..f37d9ff921 100644 --- a/src/components/menu/nz-submenu.component.ts +++ b/src/components/menu/nz-submenu.component.ts @@ -5,22 +5,13 @@ import { import { style, animate, state, transition, trigger } from '@angular/animations'; import { NzMenuComponent } from './nz-menu.component'; import { Subject } from 'rxjs/Subject'; -import { debounceTime } from 'rxjs/operator/debounceTime'; +import { debounceTime } from 'rxjs/operators/debounceTime'; @Component({ selector : '[nz-submenu]', animations: [ - trigger('fadeAnimation', [ - state('*', style({ opacity: 1 })), - transition('* => void', [ - animate(150, style({ opacity: 0, display: 'none' })) - ]), - transition('void => *', [ - style({ opacity: '0' }), - animate(150, style({ opacity: 1 })) - ]) - ]), trigger('expandAnimation', [ + state('fade', style({ opacity: 1 })), transition('expand => void', [ style({ height: '*', overflow: 'hidden' }), animate(150, style({ height: 0 })) @@ -28,6 +19,13 @@ import { debounceTime } from 'rxjs/operator/debounceTime'; transition('void => expand', [ style({ height: 0, overflow: 'hidden' }), animate(150, style({ height: '*' })) + ]), + transition('fade => void', [ + animate(150, style({ opacity: 0 })) + ]), + transition('void => fade', [ + style({ opacity: '0' }), + animate(150, style({ opacity: 1 })) ]) ]) ], @@ -43,7 +41,6 @@ import { debounceTime } from 'rxjs/operator/debounceTime';
    e.selected && e.nzSubMenuComponent === this); } + get submenuSelected(): boolean { return !!this.subMenus._results.find(e => e !== this && e.subItemSelected) } get expandState() { - if (this.nzOpen && this.nzMenuComponent.nzMode !== 'vertical') { + if (this.nzOpen && this.nzMenuComponent.nzMode === 'inline') { return 'expand'; + } else if (this.nzOpen && this.nzMenuComponent.nzMode !== 'inline') { + return 'fade' } return null; } @@ -174,8 +174,11 @@ export class NzSubMenuComponent implements OnInit, OnDestroy, AfterViewInit { } ngOnInit() { - debounceTime.call(this._$mouseSubject, 300).subscribe((data: boolean) => { - this.nzOpen = data; + this._$mouseSubject.pipe(debounceTime(300)).subscribe((data: boolean) => { + if (this.nzOpen !== data) { + this.nzOpen = data; + this.nzOpenChange.emit(this.nzOpen); + } }); } diff --git a/src/components/message/nz-message-config.ts b/src/components/message/nz-message-config.ts index 116ad0abf1..0ce7f74066 100644 --- a/src/components/message/nz-message-config.ts +++ b/src/components/message/nz-message-config.ts @@ -1,12 +1,14 @@ import { InjectionToken } from '@angular/core'; -export class NzMessageConfig { +export interface NzMessageConfig { // For all messages as default config (can override when dynamically created) nzDuration?: number; nzPauseOnHover?: boolean; nzAnimate?: boolean; // For message container only nzMaxStack?: number; + + [index: string]: any; } export const NZ_MESSAGE_DEFAULT_CONFIG = new InjectionToken('NZ_MESSAGE_DEFAULT_CONFIG'); @@ -14,11 +16,11 @@ export const NZ_MESSAGE_DEFAULT_CONFIG = new InjectionToken('NZ export const NZ_MESSAGE_CONFIG = new InjectionToken('NZ_MESSAGE_CONFIG'); export const NZ_MESSAGE_DEFAULT_CONFIG_PROVIDER = { - provide: NZ_MESSAGE_DEFAULT_CONFIG, + provide : NZ_MESSAGE_DEFAULT_CONFIG, useValue: { - nzDuration : 1500, - nzAnimate : true, - nzPauseOnHover : true, - nzMaxStack : 7, + nzDuration : 1500, + nzAnimate : true, + nzPauseOnHover: true, + nzMaxStack : 7, } }; diff --git a/src/components/message/nz-message-container.component.ts b/src/components/message/nz-message-container.component.ts index 8e9a2cc4aa..60b90527be 100644 --- a/src/components/message/nz-message-container.component.ts +++ b/src/components/message/nz-message-container.component.ts @@ -14,13 +14,13 @@ import { NZ_MESSAGE_CONFIG, NZ_MESSAGE_DEFAULT_CONFIG, NzMessageConfig } from '. './style/index.less' ] }) -export class NzMessageContainerComponent implements OnInit { +export class NzMessageContainerComponent implements OnInit { messages: NzMessageDataFilled[] = []; - config: Config; + config: NzMessageConfig; - constructor(@Optional() @Inject(NZ_MESSAGE_DEFAULT_CONFIG) defaultConfig: Config, - @Optional() @Inject(NZ_MESSAGE_CONFIG) config: Config) { - this.config = Object.assign({}, defaultConfig, config) as Config; + constructor(@Optional() @Inject(NZ_MESSAGE_DEFAULT_CONFIG) defaultConfig: NzMessageConfig, + @Optional() @Inject(NZ_MESSAGE_CONFIG) config: NzMessageConfig) { + this.config = Object.assign({}, defaultConfig, config) as NzMessageConfig; } ngOnInit() { } diff --git a/src/components/message/nz-message.component.ts b/src/components/message/nz-message.component.ts index 88c4c83072..1b04720c29 100644 --- a/src/components/message/nz-message.component.ts +++ b/src/components/message/nz-message.component.ts @@ -69,7 +69,7 @@ export class NzMessageComponent implements OnInit, OnDestroy { private _eraseTimingStart: number; private _eraseTTL: number; // Time to live - constructor(private _messageContainer: NzMessageContainerComponent) { } + constructor(private _messageContainer: NzMessageContainerComponent) { } ngOnInit() { this._options = this.nzMessage.options; diff --git a/src/components/message/nz-message.service.ts b/src/components/message/nz-message.service.ts index a6aed7e267..3fdd676200 100644 --- a/src/components/message/nz-message.service.ts +++ b/src/components/message/nz-message.service.ts @@ -1,11 +1,10 @@ -import { Injectable, ComponentRef, Type } from '@angular/core'; +import { Injectable, Type } from '@angular/core'; import { Overlay } from '@angular/cdk/overlay'; import { ComponentPortal } from '@angular/cdk/portal'; -import { NzMessageConfig } from './nz-message-config'; import { NzMessageData, NzMessageDataFilled, NzMessageDataOptions } from './nz-message.definitions'; import { NzMessageContainerComponent } from './nz-message-container.component'; -export class NzMessageBaseService, MessageData> { +export class NzMessageBaseService { protected _counter = 0; // Id counter for messages protected _container: ContainerClass; @@ -38,7 +37,7 @@ export class NzMessageBaseService, NzMessageData> { +export class NzMessageService extends NzMessageBaseService { constructor(overlay: Overlay) { super(overlay, NzMessageContainerComponent, 'message-'); diff --git a/src/components/notification/nz-notification-config.ts b/src/components/notification/nz-notification-config.ts index 47b53f46c5..5f24063d4d 100644 --- a/src/components/notification/nz-notification-config.ts +++ b/src/components/notification/nz-notification-config.ts @@ -1,7 +1,7 @@ import { InjectionToken } from '@angular/core'; import { NzMessageConfig } from '../message/nz-message-config'; -export class NzNotificationConfig extends NzMessageConfig { +export interface NzNotificationConfig extends NzMessageConfig { nzTop?: string; nzRight?: string; } diff --git a/src/components/notification/nz-notification-container.component.ts b/src/components/notification/nz-notification-container.component.ts index da2c360a68..8218c96b00 100644 --- a/src/components/notification/nz-notification-container.component.ts +++ b/src/components/notification/nz-notification-container.component.ts @@ -14,7 +14,7 @@ import { NzMessageContainerComponent } from '../message/nz-message-container.com './style/index.less' ] }) -export class NzNotificationContainerComponent extends NzMessageContainerComponent { +export class NzNotificationContainerComponent extends NzMessageContainerComponent { constructor(@Optional() @Inject(NZ_NOTIFICATION_DEFAULT_CONFIG) defaultConfig: NzNotificationConfig, @Optional() @Inject(NZ_NOTIFICATION_CONFIG) config: NzNotificationConfig) { diff --git a/src/components/notification/nz-notification.service.ts b/src/components/notification/nz-notification.service.ts index d5db76dbb2..205abaae8c 100644 --- a/src/components/notification/nz-notification.service.ts +++ b/src/components/notification/nz-notification.service.ts @@ -1,4 +1,4 @@ -import { Injectable, EventEmitter } from '@angular/core'; +import { Injectable } from '@angular/core'; import { Overlay } from '@angular/cdk/overlay'; import { NzNotificationData, NzNotificationDataFilled } from './nz-notification.definitions'; import { NzMessageBaseService } from '../message/nz-message.service'; @@ -14,31 +14,31 @@ export class NzNotificationService extends NzMessageBaseService; - constructor(@Inject(DOCUMENT) _document: Document, injector: Injector, resolver: ComponentFactoryResolver) { + constructor(@Inject(DOCUMENT) _document: any, injector: Injector, resolver: ComponentFactoryResolver) { const componentFactory = resolver.resolveComponentFactory(NzRootStyleComponent); const div = _document.createElement('div'); this.styleHostComponent = componentFactory.create(injector, null, div); diff --git a/src/components/slider/nz-slider.component.ts b/src/components/slider/nz-slider.component.ts index 5ef0ba15c9..e0b813db41 100644 --- a/src/components/slider/nz-slider.component.ts +++ b/src/components/slider/nz-slider.component.ts @@ -13,17 +13,16 @@ import { forwardRef, } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; -import { RxChain } from '@angular/cdk/rxjs'; import { Observable } from 'rxjs/Observable'; import { Subscription } from 'rxjs/Subscription'; import { fromEvent } from 'rxjs/observable/fromEvent'; import { merge } from 'rxjs/observable/merge'; -import { distinctUntilChanged } from 'rxjs/operator/distinctUntilChanged'; -import { _do as doOperator } from 'rxjs/operator/do'; -import { filter as filterOperator } from 'rxjs/operator/filter'; -import { map } from 'rxjs/operator/map'; -import { pluck } from 'rxjs/operator/pluck'; -import { takeUntil } from 'rxjs/operator/takeUntil'; +import { distinctUntilChanged } from 'rxjs/operators/distinctUntilChanged'; +import { tap } from 'rxjs/operators/tap'; +import { map } from 'rxjs/operators/map'; +import { pluck } from 'rxjs/operators/pluck'; +import { takeUntil } from 'rxjs/operators/takeUntil'; +import { filter } from 'rxjs/operators/filter'; import { NzSliderService } from './nz-slider.service'; import { Marks, MarksArray } from './nz-slider-marks.component'; @@ -378,26 +377,26 @@ export class NzSliderComponent implements ControlValueAccessor, OnInit, OnChange }; // make observables [ mouse, touch ].forEach(source => { - const { start, move, end, pluckKey, filter = () => true } = source; + const { start, move, end, pluckKey, filterFunc = ((value: any, index: number) => true) as any } = source; // start - source.startPlucked$ = (RxChain.from(fromEvent(sliderDOM, start)) as RxChain) - .call(filterOperator, filter) - .call(doOperator, this.utils.pauseEvent) - .call(pluck, ...pluckKey) - .call(map, (position: number) => this.findClosestValue(position)) - .result(); + source.startPlucked$ = fromEvent(sliderDOM, start).pipe( + filter(filterFunc), + tap(this.utils.pauseEvent), + pluck(...pluckKey), + map((position: number) => this.findClosestValue(position)) + ); // end source.end$ = fromEvent(document, end); // resolve move - source.moveResolved$ = (RxChain.from(fromEvent(document, move)) as RxChain) - .call(filterOperator, filter) - .call(doOperator, this.utils.pauseEvent) - .call(pluck, ...pluckKey) - .call(distinctUntilChanged) - .call(map, (position: number) => this.findClosestValue(position)) - .call(distinctUntilChanged) - .call(takeUntil, source.end$) - .result(); + source.moveResolved$ = fromEvent(document, move).pipe( + filter(filterFunc), + tap(this.utils.pauseEvent), + pluck(...pluckKey), + distinctUntilChanged(), + map((position: number) => this.findClosestValue(position)), + distinctUntilChanged(), + takeUntil(source.end$), + ); // merge to become moving // source.move$ = source.startPlucked$.mergeMapTo(source.moveResolved$); }); @@ -476,8 +475,8 @@ export class NzSliderComponent implements ControlValueAccessor, OnInit, OnChange points = (nzMarks === null ? [] : Object.keys(nzMarks).map(parseFloat)) as Array; // push closest step if (nzStep !== null && !nzDots) { - const closest = Math.round(val / nzStep) * nzStep; - points.push(closest); + const closestOne = Math.round(val / nzStep) * nzStep; + points.push(closestOne); } // calculate gaps const gaps = points.map(point => Math.abs(val - point)); diff --git a/src/components/tabs/nz-tabs-nav.component.ts b/src/components/tabs/nz-tabs-nav.component.ts index 87229e6549..8d7a20fbed 100644 --- a/src/components/tabs/nz-tabs-nav.component.ts +++ b/src/components/tabs/nz-tabs-nav.component.ts @@ -26,8 +26,8 @@ export type ScrollDirection = 'after' | 'before'; import { of as observableOf } from 'rxjs/observable/of'; import { merge } from 'rxjs/observable/merge'; import { fromEvent } from 'rxjs/observable/fromEvent'; -import { auditTime } from 'rxjs/operator/auditTime'; -import { startWith } from 'rxjs/operator/startWith'; +import { auditTime } from 'rxjs/operators/auditTime'; +import { startWith } from 'rxjs/operators/startWith'; /** duplicated defined https://github.com/angular/angular-cli/issues/2034 **/ export type NzTabPositionMode = 'horizontal' | 'vertical'; @@ -168,10 +168,9 @@ export class NzTabsNavComponent implements AfterContentChecked, AfterContentInit this._realignInkBar = this._ngZone.runOutsideAngular(() => { const dirChange = this._dir ? this._dir.change : observableOf(null); const resize = typeof window !== 'undefined' ? - auditTime.call(fromEvent(window, 'resize'), 10) : + fromEvent(window, 'resize').pipe(auditTime(10)) : observableOf(null); - - return startWith.call(merge(dirChange, resize), null).subscribe(() => { + return merge(dirChange, resize).pipe(startWith(null)).subscribe(() => { if (this.nzShowPagination) { this._updatePagination(); } diff --git a/src/components/tabs/nz-tabset.component.ts b/src/components/tabs/nz-tabset.component.ts index 3d6d9c10a2..2481fc769d 100644 --- a/src/components/tabs/nz-tabset.component.ts +++ b/src/components/tabs/nz-tabset.component.ts @@ -18,7 +18,7 @@ import { import { NzTabComponent } from './nz-tab.component'; import { NzTabsNavComponent } from './nz-tabs-nav.component'; import { Observable } from 'rxjs/Observable'; -import { map } from 'rxjs/operator/map'; +import { map } from 'rxjs/operators/map'; export interface NzAnimatedInterface { inkBar: boolean, @@ -110,7 +110,7 @@ export class NzTabSetComponent implements AfterContentChecked, OnInit, AfterView @Output() get nzSelectedIndexChange(): Observable { - return map.call(this.nzSelectChange, event => event.index); + return this.nzSelectChange.pipe(map(event => event.index)); } @Output() nzSelectChange: EventEmitter = new EventEmitter(true); diff --git a/tslint.json b/tslint.json index e34b567a7d..a0c8d03f93 100644 --- a/tslint.json +++ b/tslint.json @@ -135,9 +135,6 @@ "use-life-cycle-interface": true, "use-pipe-transform-interface": true, "component-class-suffix": true, - "directive-class-suffix": true, - "no-access-missing-member": true, - "templates-use-public": true, - "invoke-injectable": true + "directive-class-suffix": true } }