Skip to content

Commit

Permalink
feat(module: all): support Angular 9 (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
tirelyl committed Apr 7, 2020
1 parent b2dbe84 commit 2150bcb
Show file tree
Hide file tree
Showing 76 changed files with 258 additions and 210 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -2,7 +2,7 @@ sudo: required
dist: trusty
language: node_js
node_js:
- '10.16.3'
- '12.3.1'

env:
- TASK=pre-release
Expand Down
2 changes: 1 addition & 1 deletion README-zh_CN.md
Expand Up @@ -76,7 +76,7 @@ $ ng add ng-zorro-antd-mobile
2. [<img alt="Segment Fault" src="https://gw.alipayobjects.com/zos/rmsportal/hfYFfCvHTQTUKntlJbMF.svg" width="100" />](https://segmentfault.com/t/ng-zorro-mobile)(中文)
3. [![Gitter](https://img.shields.io/gitter/room/ng-zorro/ng-zorro-antd-mobile.svg?style=flat-square)](https://gitter.im/ng-zorro/ng-zorro-antd-mobile)(English & 中文)
4. 加入钉钉 **NG-ZORRO-MOBILE** 自助服务群(中文)<br/>
<img src="https://gw.alicdn.com/tfs/TB1_8dtJCzqK1RjSZPcXXbTepXa-1125-1485.jpg" width="300">
<img src="https://img.alicdn.com/tfs/TB1cABKAkL0gK0jSZFAXXcA9pXa-1125-1485.jpg" width="300">

## 谁在使用

Expand Down
20 changes: 17 additions & 3 deletions angular.json
Expand Up @@ -16,6 +16,7 @@
"main": "./site/src/main.ts",
"tsConfig": "./site/src/tsconfig.app.json",
"polyfills": "./site/src/polyfills.ts",
"aot": true,
"assets": [
"site/src/assets",
"site/src/favicon.ico",
Expand All @@ -34,6 +35,12 @@
},
"configurations": {
"production": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"fileReplacements": [
{
"replace": "./site/src/environments/environment.ts",
Expand All @@ -45,7 +52,6 @@
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": false,
"vendorChunk": false,
"buildOptimizer": true,
Expand Down Expand Up @@ -92,8 +98,13 @@
"options": {
"tsConfig": "components/tsconfig.lib.json",
"project": "components/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "components/tsconfig.lib.prod.json"
}
}
},
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
Expand All @@ -111,10 +122,13 @@
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "less"
"style": "less"
},
"@schematics/angular:directive": {
"prefix": "app"
}
},
"cli": {
"analytics": false
}
}
2 changes: 1 addition & 1 deletion components/accordion/accordion.component.spec.ts
Expand Up @@ -117,7 +117,7 @@ export class TestAccordionComponent implements OnInit {
accordion = true;
activeKey = undefined;

@ViewChild(AccordionComponent, { static: false }) accordionComponent: AccordionComponent;
@ViewChild(AccordionComponent) accordionComponent: AccordionComponent;

onChange(event) {
console.log(event);
Expand Down
9 changes: 3 additions & 6 deletions components/action-sheet/action-sheet.component.spec.ts
Expand Up @@ -18,9 +18,7 @@ describe('ActionSheetComponent', () => {
imports: [NgZorroAntdMobilePipesModule, ActionSheetModule, ButtonModule],
providers: [ActionSheet, Overlay]
}).compileComponents();
TestBed.overrideModule(ActionSheetModule, {
set: { entryComponents: [ActionSheetComponent, TestActionSheetBasicComponent] }
}).compileComponents();
TestBed.overrideModule(ActionSheetModule, {}).compileComponents();
}));

beforeEach(() => {
Expand Down Expand Up @@ -118,8 +116,7 @@ describe('ActionSheetComponent', () => {
<div class="am-action-sheet-message">123</div>
</ng-template>
`,
providers: [ActionSheet],
entryComponents: [ActionSheetComponent]
providers: [ActionSheet]
})
export class TestActionSheetBasicComponent {
dataList = [
Expand All @@ -144,7 +141,7 @@ export class TestActionSheetBasicComponent {
}));
locale = en_US;

@ViewChild('message', { static: false })
@ViewChild('message')
message: ViewChild;

constructor(private _actionSheet: ActionSheet) {}
Expand Down
1 change: 0 additions & 1 deletion components/action-sheet/action-sheet.module.ts
Expand Up @@ -22,7 +22,6 @@ import { OverlayModule } from '@angular/cdk/overlay';
],
declarations: [ActionSheetComponent],
exports: [ActionSheetComponent],
entryComponents: [ActionSheetComponent],
providers: [PopupService, ActionSheetService]
})
export class ActionSheetModule {}
2 changes: 1 addition & 1 deletion components/calendar/calendar.component.html
Expand Up @@ -36,9 +36,9 @@
></CalendarShortcutPanel>
<CalendarConfirmPanel
*ngIf="state.startDate"
[propsData]="props"
[startDateTime]="state.startDate"
[endDateTime]="state.endDate"
[propsData]="props"
[disableBtn]="state.disConfirmBtn"
[formatStr]="props.pickTime ? props.locale.dateTimeFormat : props.locale.dateFormat"
[onConfirm]="triggerConfirm"
Expand Down
4 changes: 2 additions & 2 deletions components/calendar/calendar.component.spec.ts
Expand Up @@ -315,7 +315,7 @@ describe('CalendarComponent', () => {
component.state.pickTime = true;
component.state.defaultTimeValue = new Date(2000, 0, 1, 8);
component.state.now = new Date(2018, 8, 2);
component.state.mimDate = new Date(2018, 8, 2);
component.state.minDate = new Date(2018, 8, 2);
component.state.maxDate = new Date(2018, 8, 3);
fixture.detectChanges();
calendarEle.nativeElement
Expand Down Expand Up @@ -486,7 +486,7 @@ export class TestCalendarBasicComponent {
}
};

@ViewChild(CalendarComponent, { static: false })
@ViewChild(CalendarComponent)
datepicker: CalendarComponent;

constructor() {}
Expand Down
2 changes: 1 addition & 1 deletion components/calendar/calendar.component.ts
Expand Up @@ -71,7 +71,7 @@ export class CalendarComponent implements ControlValueAccessor, OnInit, OnDestro
private _dateModelValue: any;
private _dateModelTime: number = 0;

@ViewChild(CalendarDatePickerComponent, { static: false })
@ViewChild(CalendarDatePickerComponent)
datepicker: CalendarDatePickerComponent;

@Input()
Expand Down
2 changes: 1 addition & 1 deletion components/carousel/carousel.component.spec.ts
Expand Up @@ -144,7 +144,7 @@ export class TestCarouselComponent {
],
imgHeight: '184px'
};
@ViewChild(CarouselComponent, { static: false }) carouselComponent: CarouselComponent;
@ViewChild(CarouselComponent) carouselComponent: CarouselComponent;
dataOutPut(event) {
this.data = event;
}
Expand Down
2 changes: 1 addition & 1 deletion components/checkbox/checkbox.component.spec.ts
Expand Up @@ -100,7 +100,7 @@ export class TestCheckboxComponent {
checked: boolean = false;
disabled: boolean = false;

@ViewChild(CheckboxComponent, { static: false })
@ViewChild(CheckboxComponent)
checkbox: CheckboxComponent;

onChange(e) {
Expand Down
9 changes: 4 additions & 5 deletions components/core/testing/event-objects.ts
Expand Up @@ -35,11 +35,10 @@ export function createMouseEvent(type: string, x = 0, y = 0): MouseEvent {
export function createTouchEvent(type: string, pageX: number = 0, pageY: number = 0): UIEvent {
// In favor of creating events that work for most of the browsers, the event is created
// as a basic UI Event. The necessary details for the event will be set manually.
const event = document.createEvent('UIEvent');
const event = new UIEvent(type, { detail: 0, view: window });
const touchDetails = { pageX, pageY };
const changedTouchesDetails = { clientX: pageX, clientY: pageY };

event.initUIEvent(type, true, true, window, 0);
event.initEvent(type, true, true);

// Most of the browsers don't have a "initTouchEvent" method that can be used to define
// the touch details.
Expand All @@ -48,7 +47,7 @@ export function createTouchEvent(type: string, pageX: number = 0, pageY: number
changedTouches: { value: [changedTouchesDetails] }
});

return event as UIEvent;
return event;
}

/** Dispatches a keydown event from an element. */
Expand All @@ -70,7 +69,7 @@ export function createKeyboardEvent(type: string, keyCode: number, target?: Elem

// IE won't set `defaultPrevented` on synthetic events so we need to do it manually.
event.preventDefault = function() {
Object.defineProperty(event, 'defaultPrevented', { get: () => true });
Object.defineProperty(event, 'defaultPrevented', { get: () => true, configurable: true });
return originalPreventDefault.apply(this, arguments);
};

Expand Down
3 changes: 2 additions & 1 deletion components/date-picker/date-picker-options.provider.ts
@@ -1,4 +1,4 @@
import { EventEmitter } from '@angular/core';
import { EventEmitter, Injectable } from '@angular/core';
import { zh_CN } from '../locale-provider/locale';
export interface DatePickerOptionsInterface {
mode: string;
Expand All @@ -18,6 +18,7 @@ export interface DatePickerOptionsInterface {
showErrorToastInterval: number;
}

@Injectable()
export class DatePickerOptions implements DatePickerOptionsInterface {
mode = 'date';
value = new Date();
Expand Down
5 changes: 1 addition & 4 deletions components/date-picker/date-picker.component.spec.ts
Expand Up @@ -9,7 +9,6 @@ import {
ListModule,
ToastModule,
ButtonModule,
ToastComponent,
LocaleProviderModule,
LocaleProviderService
} from '../..';
Expand All @@ -28,9 +27,7 @@ describe('DatePickerComponent', () => {
providers: [DatePickerOptions, LocaleProviderService, Toast],
imports: [DatePickerModule, LocaleProviderModule, ButtonModule, ListModule, ToastModule, FormsModule]
}).compileComponents();
TestBed.overrideModule(DatePickerModule, {
set: { entryComponents: [DatePickerComponent] }
}).compileComponents();
TestBed.overrideModule(DatePickerModule, {}).compileComponents();
}));

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/date-picker.component.ts
Expand Up @@ -64,7 +64,7 @@ export class DatePickerComponent implements OnInit, OnDestroy, AfterViewInit {
ngModelOnChange: (value: Date) => {};
ngModelOnTouched: () => {};

@ViewChild('picker', { static: true, read: ViewContainerRef })
@ViewChild('picker', { read: ViewContainerRef })
picker: ViewContainerRef;

@HostListener('mousedown', ['$event'])
Expand Down
7 changes: 6 additions & 1 deletion components/date-picker/date-picker.directive.ts
Expand Up @@ -30,6 +30,7 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
})
export class DatePickerDirective implements OnDestroy, OnChanges, OnInit, ControlValueAccessor {
picker: ComponentRef<DatePickerComponent>;
appendToBodyElement: HTMLElement;
private _eventListeners: Array<() => void> = [];
private _ngModelOnChange: (value: Date) => {};
private _ngModelOnTouched: () => {};
Expand Down Expand Up @@ -148,13 +149,17 @@ export class DatePickerDirective implements OnDestroy, OnChanges, OnInit, Contro
childInjector
);
if (options.appendToBody) {
document.body.appendChild(this.picker.location.nativeElement);
this.appendToBodyElement = document.body.appendChild(this.picker.location.nativeElement);
}
this.onVisibleChange.emit(true);
}
}

hidePicker(): void {
if (this.appendToBodyElement) {
document.body.removeChild(this.appendToBodyElement);
this.appendToBodyElement = null;
}
if (this.picker) {
this.picker.destroy();
delete this.picker;
Expand Down
1 change: 0 additions & 1 deletion components/date-picker/date-picker.module.ts
Expand Up @@ -12,7 +12,6 @@ import { ToastComponent } from '../toast/toast.component';
imports: [CommonModule, LocaleProviderModule, ToastModule, FormsModule],
exports: [DatePickerComponent, DatePickerDirective],
declarations: [DatePickerComponent, DatePickerDirective],
entryComponents: [DatePickerComponent],
providers: [DatePickerOptions, LocaleProviderModule]
})
export class DatePickerModule {}
2 changes: 1 addition & 1 deletion components/drawer/drawer.component.spec.ts
Expand Up @@ -399,7 +399,7 @@ export class TestDrawerComponent {
dragHandleStyle = { color: '#A6A6A9' };
touch = true;

@ViewChild(DrawerComponent, { static: false })
@ViewChild(DrawerComponent)
drawer: DrawerComponent;

onOpenChange(value) {
Expand Down
2 changes: 1 addition & 1 deletion components/image-picker/image-picker.component.spec.ts
Expand Up @@ -149,7 +149,7 @@ export class TestImagePickerComponent {
multiple = true;
selectable = true;
len = 3;
@ViewChild(ImagePickerComponent, { static: false }) imagePicker: ImagePickerComponent;
@ViewChild(ImagePickerComponent) imagePicker: ImagePickerComponent;
imageChangeCallback = jasmine.createSpy('imageChangeCallback is callback');
imageClickCallback = jasmine.createSpy('imageClickCallback is callback');

Expand Down
2 changes: 1 addition & 1 deletion components/image-picker/image-picker.component.ts
Expand Up @@ -20,7 +20,7 @@ export class ImagePickerComponent {
private _files: Array<any> = [];
private _multiple: boolean = false;

@ViewChild('fileSelectorInput', { read: ViewContainerRef, static: false })
@ViewChild('fileSelectorInput', { read: ViewContainerRef })
private _fileSelectorInput: ViewContainerRef;

@Input() capture: boolean | string = false;
Expand Down
4 changes: 2 additions & 2 deletions components/input-item/input-item.component.spec.ts
Expand Up @@ -455,10 +455,10 @@ export class TestInputComponent {
focus;
content = 'content';

@ViewChild(InputItemComponent, { static: false })
@ViewChild(InputItemComponent)
inputItemComp: InputItemComponent;

@ViewChild('extraTemplate', { static: false })
@ViewChild('extraTemplate')
extraTpl: TemplateRef<any>;

errorClick = jasmine.createSpy('errorClick callback');
Expand Down
2 changes: 1 addition & 1 deletion components/input-item/input-item.component.ts
Expand Up @@ -64,7 +64,7 @@ export class InputItemComponent implements OnInit, AfterViewInit, ControlValueAc

@ViewChild('lableContent', { static: true })
lableRef: ElementRef;
@ViewChild('inputElement', { static: false })
@ViewChild('inputElement')
inputElementRef: ElementRef;

@Input()
Expand Down
1 change: 0 additions & 1 deletion components/input-item/input-item.module.ts
Expand Up @@ -8,7 +8,6 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@NgModule({
exports: [InputItemComponent, CustomKeyboardComponent, CustomInputComponent],
declarations: [InputItemComponent, CustomKeyboardComponent, CustomInputComponent],
entryComponents: [CustomKeyboardComponent],
imports: [CommonModule, FormsModule, ReactiveFormsModule]
})
export class InputItemModule {}
2 changes: 1 addition & 1 deletion components/locale-provider/locale-provider.module.ts
@@ -1,4 +1,4 @@
import { NgModule } from '@angular/core';
import { NgModule, Injectable } from '@angular/core';
import zh_CN from './locale/zh_CN';
import { LocaleProviderPipe } from './locale-provider.pipe';
import { LOCAL_PROVIDER_TOKEN } from './locale-provider.token';
Expand Down
2 changes: 1 addition & 1 deletion components/menu/menu.component.spec.ts
Expand Up @@ -336,7 +336,7 @@ export class TestMenuComponent {
height = document.documentElement.clientHeight / 2;
multiSelect = false;

@ViewChild(MenuComponent, { static: false })
@ViewChild(MenuComponent)
menu: MenuComponent;

constructor() {}
Expand Down
8 changes: 3 additions & 5 deletions components/modal/modal.component.spec.ts
Expand Up @@ -28,9 +28,7 @@ describe('ModalComponent', () => {
],
providers: [Overlay, ModalOptions, AlertOptions]
}).compileComponents();
TestBed.overrideModule(ModalModule, {
set: { entryComponents: [ModalServiceComponent] }
}).compileComponents();
TestBed.overrideModule(ModalModule, {}).compileComponents();
}));

beforeEach(() => {
Expand Down Expand Up @@ -301,8 +299,8 @@ export class TestModalBasicComponent {
}
}
];
@ViewChild('title', { static: false }) titleRef: ViewChild;
@ViewChild(ModalComponent, { static: false }) modalServiceComponent: ModalComponent;
@ViewChild('title') titleRef: ViewChild;
@ViewChild(ModalComponent) modalServiceComponent: ModalComponent;
templateOpenSpy = jasmine.createSpy('template afterOpen spy');
templateCloseSpy = jasmine.createSpy('template afterClose spy');
constructor(private _modal: ModalService) {
Expand Down
1 change: 0 additions & 1 deletion components/modal/modal.module.ts
Expand Up @@ -25,7 +25,6 @@ import { PopupService } from '../core/services/popup.service';
],
exports: [ModalComponent, ModalServiceComponent],
declarations: [ModalComponent, ModalServiceComponent],
entryComponents: [ModalServiceComponent],
providers: [AlertOptions, ModalService, PopupService]
})
export class ModalModule {}

0 comments on commit 2150bcb

Please sign in to comment.