Skip to content

Commit

Permalink
refactor(module: all): normalize class name and export way (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisherspy authored and 3fuyu committed May 16, 2019
1 parent 7ad01ba commit 02d1ffd
Show file tree
Hide file tree
Showing 173 changed files with 739 additions and 737 deletions.
4 changes: 2 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"browserTarget": "ng-zorro-antd-mobile:build"
},
"configurations": {
"prod": {
"browserTarget": "ng-zorro-antd-mobile:build:prod"
"production": {
"browserTarget": "ng-zorro-antd-mobile:build:production"
}
}
},
Expand Down
8 changes: 4 additions & 4 deletions components/accordion/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './accordion.module';
export * from './accordion.service';
export * from './accordion.component';
export * from './accordion-group/accordion-group.component';
export { AccordionModule } from './accordion.module';
export { AccordionService } from './accordion.service';
export { AccordionComponent } from './accordion.component';
export { AccordionGroupComponent } from './accordion-group/accordion-group.component';
2 changes: 1 addition & 1 deletion components/action-sheet/action-sheet-subject.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const enum actionSheetEvent {
}

@Injectable()
export class ActionSheetSubject extends Subject<any> {
export class ActionSheetSubjectService extends Subject<any> {
modalId: string;
private _eventsQueue = {};

Expand Down
5 changes: 3 additions & 2 deletions components/action-sheet/action-sheet.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { WingBlankModule } from '../wing-blank/wing-blank.module';
import { WhiteSpaceModule} from '../white-space/white-space.module';
import { LocaleProviderModule } from '../locale-provider/locale-provider.module';
import { PopupService } from '../core/services/popup.service';
import { ActionSheet } from './action-sheet.service';
import { ActionSheetService } from './action-sheet.service';

@NgModule({
imports: [CommonModule, NgZorroAntdMobilePipesModule, ListModule, WhiteSpaceModule, WingBlankModule, LocaleProviderModule],
declarations: [
Expand All @@ -17,6 +18,6 @@ import { ActionSheet } from './action-sheet.service';
ActionSheetComponent
],
entryComponents: [ActionSheetComponent],
providers: [PopupService, ActionSheet]
providers: [PopupService, ActionSheetService]
})
export class ActionSheetModule { }
28 changes: 14 additions & 14 deletions components/action-sheet/action-sheet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function noop() {}
@Injectable({
providedIn: 'root'
})
export class ActionSheet extends PopupService {
export class ActionSheetService extends PopupService {
static compRef: ComponentRef<any> = null;
static _actionSheetCompFactory: ComponentFactory<ActionSheetComponent> = null;
static appRef: ApplicationRef = null;
Expand All @@ -41,7 +41,7 @@ export class ActionSheet extends PopupService {
config = Object.assign(options, config, {
close: (): void => {
if (config.maskClosable) {
ActionSheet.closeWithAnimation(config.transitionName, config.maskTransitionName);
ActionSheetService.closeWithAnimation(config.transitionName, config.maskTransitionName);
}
}
});
Expand All @@ -55,8 +55,8 @@ export class ActionSheet extends PopupService {

static _open(props: ActionSheetOptions) {
setTimeout(() => {
ActionSheet.comRef = ActionSheet.showPopup('ActionSheetComponent', ActionSheetComponent);
ActionSheet.comRef.instance.option = props;
ActionSheetService.comRef = ActionSheetService.showPopup('ActionSheetComponent', ActionSheetComponent);
ActionSheetService.comRef.instance.option = props;
}, 0);
}

Expand All @@ -70,39 +70,39 @@ export class ActionSheet extends PopupService {
options.transitionName = `${transitionName}-enter ${transitionName}-enter-active`;
const maskTransitionName = config.maskTransitionName ? config.maskTransitionName : options.maskTransitionName;
options.maskTransitionName = `${maskTransitionName}-enter ${maskTransitionName}-enter-active`;
const props = ActionSheet._initConfig(config, options);
const props = ActionSheetService._initConfig(config, options);
Object.assign(props, { onPress: cb }, { flag: flag }, { maskClose: props.maskClosable ? cb : () => {}});
function cb(index: any, rowIndex = 0, event) {
event.stopPropagation();
const res = callback(index, rowIndex);
if (res && res.then) {
res.then(() => {
ActionSheet.closeWithAnimation(transitionName, maskTransitionName);
ActionSheetService.closeWithAnimation(transitionName, maskTransitionName);
});
} else {
ActionSheet.closeWithAnimation(transitionName, maskTransitionName);
ActionSheetService.closeWithAnimation(transitionName, maskTransitionName);
}
}
return ActionSheet._open(props);
return ActionSheetService._open(props);
}

static closeWithAnimation(transitionName, maskTransitionName) {
ActionSheet.comRef.instance.option.transitionName = `${transitionName}-leave ${transitionName}-leave-active`;
ActionSheet.comRef.instance.option.maskTransitionName = `${maskTransitionName}-leave ${maskTransitionName}-leave-active`;
ActionSheetService.comRef.instance.option.transitionName = `${transitionName}-leave ${transitionName}-leave-active`;
ActionSheetService.comRef.instance.option.maskTransitionName = `${maskTransitionName}-leave ${maskTransitionName}-leave-active`;
setTimeout(() => {
ActionSheet.close();
ActionSheetService.close();
}, 200);
}

static showActionSheetWithOptions(config: ActionSheetWithOptions, callback: ActionCallBack = noop) {
ActionSheet.createActionSheet(NORMAL, config, callback);
ActionSheetService.createActionSheet(NORMAL, config, callback);
}

static showShareActionSheetWithOptions(config: ShareActionSheetWithOptions, callback: ActionCallBack = noop) {
ActionSheet.createActionSheet(SHARE, config, callback);
ActionSheetService.createActionSheet(SHARE, config, callback);
}

static close() {
ActionSheet.hidePopup('ActionSheetComponent');
ActionSheetService.hidePopup('ActionSheetComponent');
}
}
12 changes: 6 additions & 6 deletions components/action-sheet/demo/basic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { ActionSheet, Toast } from 'ng-zorro-antd-mobile';
import { ActionSheetService, ToastService } from 'ng-zorro-antd-mobile';
import { en_US, ru_RU, zh_CN, sv_SE, da_DK } from 'ng-zorro-antd-mobile';
@Component({
selector: 'demo-action-sheet-basic',
Expand Down Expand Up @@ -29,11 +29,11 @@ export class DemoActionSheetBasicComponent {
title: obj.title
}));

constructor(private _actionSheet: ActionSheet, private _toast: Toast) {}
constructor(private _actionSheet: ActionSheetService, private _toast: ToastService) {}

showActionSheet = message => {
const BUTTONS = ['Operation1', 'Operation2', 'Operation2', 'Delete', 'Cancel'];
ActionSheet.showActionSheetWithOptions(
ActionSheetService.showActionSheetWithOptions(
{
options: BUTTONS,
cancelButtonIndex: BUTTONS.length - 1,
Expand All @@ -49,15 +49,15 @@ export class DemoActionSheetBasicComponent {
}

showShareActionSheet = () => {
ActionSheet.showShareActionSheetWithOptions(
ActionSheetService.showShareActionSheetWithOptions(
{
options: this.dataList,
message: 'I am description, description, description',
locale: zh_CN
},
buttonIndex => {
return new Promise(resolve => {
Toast.info('closed after 1000ms');
ToastService.info('closed after 1000ms');
setTimeout(resolve, 1000);
});
}
Expand All @@ -66,7 +66,7 @@ export class DemoActionSheetBasicComponent {

showShareActionSheetMulpitleLine = () => {
const data = [[...this.dataList, this.dataList[2]], [this.dataList[3], this.dataList[4]]];
ActionSheet.showShareActionSheetWithOptions(
ActionSheetService.showShareActionSheetWithOptions(
{
options: data,
message: 'I am description, description, description',
Expand Down
10 changes: 5 additions & 5 deletions components/action-sheet/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './action-sheet.module';
export * from './action-sheet.service';
export * from './action-sheet.component';
export * from './action-sheet-subject.service';
export * from './action-sheet-options.provider';
export { ActionSheetModule } from './action-sheet.module';
export { ActionSheetComponent } from './action-sheet.component';
export { ActionSheetSubjectService } from './action-sheet-subject.service';
export { ActionSheetService, ActionSheetService as ActionSheet } from './action-sheet.service';
export { ActionSheetOptions, ShareOption, ShareActionSheetWithOptions, ActionSheetWithOptions, ActionCallBack } from './action-sheet-options.provider';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Component, OnInit, Input, HostBinding } from '@angular/core';
selector: 'ActivityIndicator , nzm-ctivity-indicator',
templateUrl: './activity-indicator.component.html'
})
export class ActivityIndicator implements OnInit {
export class ActivityIndicatorComponent implements OnInit {
prefixCls: string = 'am-activity-indicator';
spinnerClass: object = {};

Expand Down
6 changes: 3 additions & 3 deletions components/activity-indicator/activity-indicator.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NgModule } from '@angular/core';
import { ActivityIndicator } from './activity-indicator.component';
import { ActivityIndicatorComponent } from './activity-indicator.component';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';

@NgModule({
exports: [ActivityIndicator],
declarations: [ActivityIndicator],
exports: [ActivityIndicatorComponent],
declarations: [ActivityIndicatorComponent],
imports: [CommonModule, FormsModule]
})
export class ActivityIndicatorModule {}
4 changes: 2 additions & 2 deletions components/activity-indicator/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './activity-indicator.module';
export * from './activity-indicator.component';
export { ActivityIndicatorModule } from './activity-indicator.module';
export { ActivityIndicatorComponent } from './activity-indicator.component';
2 changes: 1 addition & 1 deletion components/badge/badge.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Component, OnInit, Input, HostBinding, OnChanges, ElementRef, AfterView
selector: 'Badge, nzm-badge',
templateUrl: './badge.component.html'
})
export class Badge implements OnChanges, OnInit, AfterViewInit {
export class BadgeComponent implements OnChanges, OnInit, AfterViewInit {
prefixCls: string = 'am-badge';
scrollNumberCls: object = {};
style: object = {};
Expand Down
6 changes: 3 additions & 3 deletions components/badge/badge.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NgModule } from '@angular/core';
import { Badge } from './badge.component';
import { BadgeComponent } from './badge.component';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';

@NgModule({
exports: [Badge],
declarations: [Badge],
exports: [BadgeComponent],
declarations: [BadgeComponent],
imports: [CommonModule, FormsModule]
})
export class BadgeModule {}
4 changes: 2 additions & 2 deletions components/badge/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './badge.module';
export * from './badge.component';
export { BadgeModule } from './badge.module';
export { BadgeComponent } from './badge.component';
4 changes: 2 additions & 2 deletions components/button/button.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { By } from '@angular/platform-browser';
import { async, TestBed } from '@angular/core/testing';
import { Button } from './button.component';
import { ButtonComponent } from './button.component';
import { ButtonModule } from './button.module';
import { IconModule, WingBlankModule, WhiteSpaceModule, ListModule } from '../..';
import { dispatchTouchEvent } from '../core/testing';
Expand All @@ -23,7 +23,7 @@ describe('button', () => {
beforeEach(() => {
fixture = TestBed.createComponent(TestButton);
component = fixture.componentInstance;
buttons = fixture.debugElement.queryAll(By.directive(Button));
buttons = fixture.debugElement.queryAll(By.directive(ButtonComponent));
fixture.detectChanges();
});

Expand Down
2 changes: 1 addition & 1 deletion components/button/button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
encapsulation: ViewEncapsulation.None,
templateUrl: './button.component.html'
})
export class Button implements AfterViewInit {
export class ButtonComponent implements AfterViewInit {
prefixCls: string = 'am-button';
ngTemplate: boolean = false;
iconType: any;
Expand Down
4 changes: 2 additions & 2 deletions components/button/button.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NgModule } from '@angular/core';
import { Button } from './button.component';
import { ButtonComponent } from './button.component';
import { CommonModule } from '@angular/common';
import { IconModule } from '../icon/icon.module';
import { WingBlankModule } from '../wing-blank/wing-blank.module';
import { WhiteSpaceModule } from '../white-space/white-space.module';
import { ListModule } from '../list/list.module';
export const NZ_BUTTON_DIRECTIVES: Array<any> = [Button];
export const NZ_BUTTON_DIRECTIVES: Array<any> = [ButtonComponent];

@NgModule({
declarations: NZ_BUTTON_DIRECTIVES,
Expand Down
4 changes: 2 additions & 2 deletions components/button/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './button.module';
export * from './button.component';
export { ButtonModule } from './button.module';
export { ButtonComponent } from './button.component';
4 changes: 2 additions & 2 deletions components/calendar/calendar.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LocaleProviderService } from '../locale-provider/locale-provider.service';
import { LocaleProviderModule } from '../locale-provider/locale-provider.module';
import { ModalModule } from '../modal/modal.module';
import { Modal } from '../modal/modal.service';
import { ModalService } from '../modal/modal.service';
import { ModalComponent } from '../modal/modal.component';
import { CalendarModule } from './calendar.module';
import { dispatchTouchEvent } from '../core/testing';
Expand All @@ -18,7 +18,7 @@ describe('CalendarComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [TestCalendarBasicComponent],
providers: [LocaleProviderService, Modal],
providers: [LocaleProviderService],
imports: [LocaleProviderModule, CalendarModule, FormsModule, ModalModule]
}).compileComponents();
TestBed.overrideModule(CalendarModule, {
Expand Down
24 changes: 12 additions & 12 deletions components/calendar/calendar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import {
EventEmitter
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { Models } from './date/DataTypes';
import { DateModels } from './date/DataTypes';
import zhCN from './locale/zh_CN';
import enUS from './locale/en_US';
import PropsType from './calendar.props.component';
import { CalendarPropsType } from './calendar.props.component';
import { LocaleProviderService } from '../locale-provider/locale-provider.service';
import { mergeDateTime, isSameDate } from './util/index';
import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';

export { PropsType };
export { CalendarPropsType };

export interface StateType {
export interface CalendarStateType {
showTimePicker: boolean;
timePickerTitle?: string;
startDate?: Date;
Expand Down Expand Up @@ -51,7 +51,7 @@ export class CalendarComponent implements ControlValueAccessor, OnInit, OnDestro
prefixCls: 'rmc-calendar',
type: 'range',
defaultTimeValue: new Date(2000, 0, 1, 8)
} as PropsType;
} as CalendarPropsType;

state = {
showTimePicker: false,
Expand All @@ -60,7 +60,7 @@ export class CalendarComponent implements ControlValueAccessor, OnInit, OnDestro
endDate: undefined,
disConfirmBtn: true,
clientHight: 0
} as StateType;
} as CalendarStateType;

private _unsubscribe$ = new Subject<void>();
private _enterDirection: string;
Expand Down Expand Up @@ -206,7 +206,7 @@ export class CalendarComponent implements ControlValueAccessor, OnInit, OnDestro
this.onTouchFn = fn;
}

receiveProps(nextProps: PropsType) {
receiveProps(nextProps: CalendarPropsType) {
if (nextProps.visible && nextProps.defaultValue) {
this.shortcutSelect(nextProps.defaultValue[0], nextProps.defaultValue[1], nextProps);
}
Expand Down Expand Up @@ -237,10 +237,10 @@ export class CalendarComponent implements ControlValueAccessor, OnInit, OnDestro
props = this.props
) => {
if (!date) {
return {} as StateType;
return {} as CalendarStateType;
}
let newState = {} as StateType;
const { type, pickTime, defaultTimeValue, locale = {} as Models.Locale } = props;
let newState = {} as CalendarStateType;
const { type, pickTime, defaultTimeValue, locale = {} as DateModels.Locale } = props;
const newDate = pickTime && !useDateTime ? mergeDateTime(date, defaultTimeValue) : date;
const { startDate, endDate } = oldState;

Expand Down Expand Up @@ -360,7 +360,7 @@ export class CalendarComponent implements ControlValueAccessor, OnInit, OnDestro
endDate: undefined,
disConfirmBtn: true,
clientHight: 0
} as StateType;
} as CalendarStateType;
this.showClear = !!this.state.startDate;
}

Expand Down Expand Up @@ -424,7 +424,7 @@ export class CalendarComponent implements ControlValueAccessor, OnInit, OnDestro
}

this._localeProviderService.localeChange.pipe(takeUntil(this._unsubscribe$)).subscribe(_ => {
this.props.locale = { ...this._localeProviderService.getLocaleSubObj('Calendar') } as Models.Locale;
this.props.locale = { ...this._localeProviderService.getLocaleSubObj('Calendar') } as DateModels.Locale;
});
}

Expand Down
Loading

0 comments on commit 02d1ffd

Please sign in to comment.