Skip to content

Commit

Permalink
refactor(module:*): migrate the source code to Angular v10 (#5494)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuanxyz committed Jul 2, 2020
1 parent 20b3d6b commit 4dcc428
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion angular.json
Expand Up @@ -235,7 +235,7 @@
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "less"
"style": "less"
},
"@schematics/angular:directive": {
"prefix": "app"
Expand Down
4 changes: 1 addition & 3 deletions components/affix/affix.module.ts
Expand Up @@ -5,14 +5,12 @@
import { PlatformModule } from '@angular/cdk/platform';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { SCROLL_SERVICE_PROVIDER } from 'ng-zorro-antd/core/services';

import { NzAffixComponent } from './affix.component';

@NgModule({
declarations: [NzAffixComponent],
exports: [NzAffixComponent],
imports: [CommonModule, PlatformModule],
providers: [SCROLL_SERVICE_PROVIDER]
imports: [CommonModule, PlatformModule]
})
export class NzAffixModule {}
4 changes: 1 addition & 3 deletions components/anchor/anchor.module.ts
Expand Up @@ -6,15 +6,13 @@ import { PlatformModule } from '@angular/cdk/platform';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { NzAffixModule } from 'ng-zorro-antd/affix';
import { SCROLL_SERVICE_PROVIDER } from 'ng-zorro-antd/core/services';

import { NzAnchorLinkComponent } from './anchor-link.component';
import { NzAnchorComponent } from './anchor.component';

@NgModule({
declarations: [NzAnchorComponent, NzAnchorLinkComponent],
exports: [NzAnchorComponent, NzAnchorLinkComponent],
imports: [CommonModule, NzAffixModule, PlatformModule],
providers: [SCROLL_SERVICE_PROVIDER]
imports: [CommonModule, NzAffixModule, PlatformModule]
})
export class NzAnchorModule {}
4 changes: 1 addition & 3 deletions components/back-top/back-top.module.ts
Expand Up @@ -5,14 +5,12 @@
import { PlatformModule } from '@angular/cdk/platform';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { SCROLL_SERVICE_PROVIDER } from 'ng-zorro-antd/core/services';

import { NzBackTopComponent } from './back-top.component';

@NgModule({
declarations: [NzBackTopComponent],
exports: [NzBackTopComponent],
imports: [CommonModule, PlatformModule],
providers: [SCROLL_SERVICE_PROVIDER]
imports: [CommonModule, PlatformModule]
})
export class NzBackTopModule {}
16 changes: 4 additions & 12 deletions components/core/services/scroll.ts
Expand Up @@ -4,7 +4,7 @@
*/

import { DOCUMENT } from '@angular/common';
import { Inject, Injectable, Optional, Provider, SkipSelf } from '@angular/core';
import { Inject, Injectable } from '@angular/core';
import { reqAnimFrame } from 'ng-zorro-antd/core/polyfill';
import { NzSafeAny } from 'ng-zorro-antd/core/types';

Expand All @@ -20,7 +20,9 @@ function easeInOutCubic(t: number, b: number, c: number, d: number): number {
}
}

@Injectable()
@Injectable({
providedIn: 'root'
})
export class NzScrollService {
private doc: Document;

Expand Down Expand Up @@ -103,13 +105,3 @@ export class NzScrollService {
reqAnimFrame(frameFunc);
}
}

export function SCROLL_SERVICE_PROVIDER_FACTORY(doc: Document, scrollService: NzScrollService): NzScrollService {
return scrollService || new NzScrollService(doc);
}

export const SCROLL_SERVICE_PROVIDER: Provider = {
provide: NzScrollService,
useFactory: SCROLL_SERVICE_PROVIDER_FACTORY,
deps: [DOCUMENT, [new Optional(), new SkipSelf(), NzScrollService]]
};
4 changes: 3 additions & 1 deletion components/date-picker/lib/abstract-panel-header.ts
Expand Up @@ -3,12 +3,14 @@
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

import { EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { Directive, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { CandyDate } from 'ng-zorro-antd/core/time';
import { NzCalendarI18nInterface } from 'ng-zorro-antd/i18n';
import { NzDateMode } from '../standard-types';
import { PanelSelector } from './interface';

@Directive()
// tslint:disable-next-line:directive-class-suffix
export abstract class AbstractPanelHeader implements OnInit, OnChanges {
prefixCls: string = `ant-picker-header`;
selectors: PanelSelector[] = [];
Expand Down
4 changes: 3 additions & 1 deletion components/date-picker/lib/abstract-table.ts
Expand Up @@ -3,12 +3,14 @@
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

import { EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, TemplateRef } from '@angular/core';
import { Directive, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, TemplateRef } from '@angular/core';
import { CandyDate } from 'ng-zorro-antd/core/time';
import { FunctionProp, NzSafeAny } from 'ng-zorro-antd/core/types';
import { isNonEmptyString, isTemplateRef } from 'ng-zorro-antd/core/util';
import { DateBodyRow, DateCell } from './interface';

@Directive()
// tslint:disable-next-line:directive-class-suffix
export abstract class AbstractTable implements OnInit, OnChanges {
isTemplateRef = isTemplateRef;
isNonEmptyString = isNonEmptyString;
Expand Down
2 changes: 2 additions & 0 deletions components/timeline/timeline.service.ts
Expand Up @@ -2,8 +2,10 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
import { Injectable } from '@angular/core';
import { ReplaySubject } from 'rxjs';

@Injectable()
export class TimelineService {
check$ = new ReplaySubject(1);
markForCheck(): void {
Expand Down
8 changes: 7 additions & 1 deletion components/tooltip/base.ts
Expand Up @@ -9,6 +9,7 @@ import {
ChangeDetectorRef,
ComponentFactory,
ComponentFactoryResolver,
Directive,
ElementRef,
EventEmitter,
Input,
Expand All @@ -24,13 +25,14 @@ import {
import { warnDeprecation } from 'ng-zorro-antd/core/logger';
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
import { DEFAULT_TOOLTIP_POSITIONS, getPlacementName, POSITION_MAP } from 'ng-zorro-antd/core/overlay';
import { NgClassInterface, NgStyleInterface, NzSafeAny, NzTSType } from 'ng-zorro-antd/core/types';
import { BooleanInput, NgClassInterface, NgStyleInterface, NzSafeAny, NzTSType } from 'ng-zorro-antd/core/types';
import { isNotNil, toBoolean } from 'ng-zorro-antd/core/util';
import { Subject } from 'rxjs';
import { distinctUntilChanged, takeUntil } from 'rxjs/operators';

export type NzTooltipTrigger = 'click' | 'focus' | 'hover' | null;

@Directive()
export abstract class NzTooltipBaseDirective implements OnChanges, OnDestroy, AfterViewInit {
directiveNameTitle?: NzTSType | null;
specificTitle?: NzTSType | null;
Expand Down Expand Up @@ -345,7 +347,11 @@ export abstract class NzTooltipBaseDirective implements OnChanges, OnDestroy, Af
}
}

@Directive()
// tslint:disable-next-line:directive-class-suffix
export abstract class NzTooltipBaseComponent implements OnDestroy {
static ngAcceptInputType_nzVisible: BooleanInput;

@ViewChild('overlay', { static: false }) overlay!: CdkConnectedOverlay;

nzVisibleChange = new Subject<boolean>();
Expand Down

0 comments on commit 4dcc428

Please sign in to comment.