From cb8144044ea39f2427038a432545930148d11eda Mon Sep 17 00:00:00 2001 From: "Kevin C. Coram" Date: Sat, 4 Jan 2020 09:42:53 -0500 Subject: [PATCH] Add fourth approach: Static methods on child components --- angular.json | 87 ++++++++++++++++++ apps/static-factory-methods/browserslist | 12 +++ apps/static-factory-methods/jest.config.js | 9 ++ .../address-list/address-list.component.css | 0 .../address-list/address-list.component.html | 3 + .../address-list.component.spec.ts | 28 ++++++ .../address-list/address-list.component.ts | 31 +++++++ .../src/app/address/address.component.css | 0 .../src/app/address/address.component.html | 27 ++++++ .../src/app/address/address.component.spec.ts | 27 ++++++ .../src/app/address/address.component.ts | 28 ++++++ .../src/app/app.component.css | 0 .../src/app/app.component.html | 8 ++ .../src/app/app.component.spec.ts | 33 +++++++ .../src/app/app.component.ts | 44 +++++++++ .../src/app/app.module.ts | 23 +++++ .../src/app/name/name.component.css | 0 .../src/app/name/name.component.html | 27 ++++++ .../src/app/name/name.component.spec.ts | 26 ++++++ .../src/app/name/name.component.ts | 26 ++++++ .../src/assets/.gitkeep | 0 .../src/environments/environment.prod.ts | 3 + .../src/environments/environment.ts | 16 ++++ apps/static-factory-methods/src/favicon.ico | Bin 0 -> 5430 bytes apps/static-factory-methods/src/index.html | 14 +++ apps/static-factory-methods/src/main.ts | 13 +++ apps/static-factory-methods/src/polyfills.ts | 62 +++++++++++++ apps/static-factory-methods/src/styles.css | 1 + apps/static-factory-methods/src/test-setup.ts | 1 + apps/static-factory-methods/tsconfig.app.json | 9 ++ apps/static-factory-methods/tsconfig.json | 7 ++ .../static-factory-methods/tsconfig.spec.json | 10 ++ apps/static-factory-methods/tslint.json | 7 ++ nx.json | 3 + 34 files changed, 585 insertions(+) create mode 100644 apps/static-factory-methods/browserslist create mode 100644 apps/static-factory-methods/jest.config.js create mode 100644 apps/static-factory-methods/src/app/address-list/address-list.component.css create mode 100644 apps/static-factory-methods/src/app/address-list/address-list.component.html create mode 100644 apps/static-factory-methods/src/app/address-list/address-list.component.spec.ts create mode 100644 apps/static-factory-methods/src/app/address-list/address-list.component.ts create mode 100644 apps/static-factory-methods/src/app/address/address.component.css create mode 100644 apps/static-factory-methods/src/app/address/address.component.html create mode 100644 apps/static-factory-methods/src/app/address/address.component.spec.ts create mode 100644 apps/static-factory-methods/src/app/address/address.component.ts create mode 100644 apps/static-factory-methods/src/app/app.component.css create mode 100644 apps/static-factory-methods/src/app/app.component.html create mode 100644 apps/static-factory-methods/src/app/app.component.spec.ts create mode 100644 apps/static-factory-methods/src/app/app.component.ts create mode 100644 apps/static-factory-methods/src/app/app.module.ts create mode 100644 apps/static-factory-methods/src/app/name/name.component.css create mode 100644 apps/static-factory-methods/src/app/name/name.component.html create mode 100644 apps/static-factory-methods/src/app/name/name.component.spec.ts create mode 100644 apps/static-factory-methods/src/app/name/name.component.ts create mode 100644 apps/static-factory-methods/src/assets/.gitkeep create mode 100644 apps/static-factory-methods/src/environments/environment.prod.ts create mode 100644 apps/static-factory-methods/src/environments/environment.ts create mode 100644 apps/static-factory-methods/src/favicon.ico create mode 100644 apps/static-factory-methods/src/index.html create mode 100644 apps/static-factory-methods/src/main.ts create mode 100644 apps/static-factory-methods/src/polyfills.ts create mode 100644 apps/static-factory-methods/src/styles.css create mode 100644 apps/static-factory-methods/src/test-setup.ts create mode 100644 apps/static-factory-methods/tsconfig.app.json create mode 100644 apps/static-factory-methods/tsconfig.json create mode 100644 apps/static-factory-methods/tsconfig.spec.json create mode 100644 apps/static-factory-methods/tslint.json diff --git a/angular.json b/angular.json index 0e3c6c3..9bcdf5f 100644 --- a/angular.json +++ b/angular.json @@ -287,6 +287,93 @@ } } } + }, + "static-factory-methods": { + "projectType": "application", + "schematics": {}, + "root": "apps/static-factory-methods", + "sourceRoot": "apps/static-factory-methods/src", + "prefix": "nested-forms", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/apps/static-factory-methods", + "index": "apps/static-factory-methods/src/index.html", + "main": "apps/static-factory-methods/src/main.ts", + "polyfills": "apps/static-factory-methods/src/polyfills.ts", + "tsConfig": "apps/static-factory-methods/tsconfig.app.json", + "aot": false, + "assets": [ + "apps/static-factory-methods/src/favicon.ico", + "apps/static-factory-methods/src/assets" + ], + "styles": ["apps/static-factory-methods/src/styles.css"], + "scripts": [] + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "apps/static-factory-methods/src/environments/environment.ts", + "with": "apps/static-factory-methods/src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + } + ] + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "static-factory-methods:build" + }, + "configurations": { + "production": { + "browserTarget": "static-factory-methods:build:production" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "static-factory-methods:build" + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "apps/static-factory-methods/tsconfig.app.json", + "apps/static-factory-methods/tsconfig.spec.json" + ], + "exclude": ["**/node_modules/**", "!apps/static-factory-methods/**"] + } + }, + "test": { + "builder": "@nrwl/jest:jest", + "options": { + "jestConfig": "apps/static-factory-methods/jest.config.js", + "tsConfig": "apps/static-factory-methods/tsconfig.spec.json", + "setupFile": "apps/static-factory-methods/src/test-setup.ts" + } + } + } } }, "cli": { diff --git a/apps/static-factory-methods/browserslist b/apps/static-factory-methods/browserslist new file mode 100644 index 0000000..8084853 --- /dev/null +++ b/apps/static-factory-methods/browserslist @@ -0,0 +1,12 @@ +# This file is used by the build system to adjust CSS and JS output to support the specified browsers below. +# For additional information regarding the format and rule options, please see: +# https://github.com/browserslist/browserslist#queries + +# You can see what browsers were selected by your queries by running: +# npx browserslist + +> 0.5% +last 2 versions +Firefox ESR +not dead +not IE 9-11 # For IE 9-11 support, remove 'not'. \ No newline at end of file diff --git a/apps/static-factory-methods/jest.config.js b/apps/static-factory-methods/jest.config.js new file mode 100644 index 0000000..dc6332a --- /dev/null +++ b/apps/static-factory-methods/jest.config.js @@ -0,0 +1,9 @@ +module.exports = { + name: 'static-factory-methods', + preset: '../../jest.config.js', + coverageDirectory: '../../coverage/apps/static-factory-methods', + snapshotSerializers: [ + 'jest-preset-angular/AngularSnapshotSerializer.js', + 'jest-preset-angular/HTMLCommentSerializer.js', + ], +}; diff --git a/apps/static-factory-methods/src/app/address-list/address-list.component.css b/apps/static-factory-methods/src/app/address-list/address-list.component.css new file mode 100644 index 0000000..e69de29 diff --git a/apps/static-factory-methods/src/app/address-list/address-list.component.html b/apps/static-factory-methods/src/app/address-list/address-list.component.html new file mode 100644 index 0000000..38a4d8f --- /dev/null +++ b/apps/static-factory-methods/src/app/address-list/address-list.component.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/apps/static-factory-methods/src/app/address-list/address-list.component.spec.ts b/apps/static-factory-methods/src/app/address-list/address-list.component.spec.ts new file mode 100644 index 0000000..d6d52c2 --- /dev/null +++ b/apps/static-factory-methods/src/app/address-list/address-list.component.spec.ts @@ -0,0 +1,28 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ReactiveFormsModule } from '@angular/forms'; + +import { AddressComponent } from './../address/address.component'; +import { AddressListComponent } from './address-list.component'; + +describe('AddressListComponent', () => { + let component: AddressListComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ReactiveFormsModule], + declarations: [ AddressListComponent, AddressComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AddressListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/apps/static-factory-methods/src/app/address-list/address-list.component.ts b/apps/static-factory-methods/src/app/address-list/address-list.component.ts new file mode 100644 index 0000000..c912e2a --- /dev/null +++ b/apps/static-factory-methods/src/app/address-list/address-list.component.ts @@ -0,0 +1,31 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { FormArray, FormBuilder } from '@angular/forms'; +import { Address } from '@nested-forms/contact'; +import { AddressComponent } from '../address/address.component'; + +@Component({ + selector: 'nested-forms-address-list', + templateUrl: './address-list.component.html', + styleUrls: ['./address-list.component.css'] +}) +export class AddressListComponent implements OnInit { + @Input() addressArray: FormArray; + + static createContactAddressListForm(addresses: Address[], fb: FormBuilder): FormArray { + const list: FormArray = fb.array([]); + + if (addresses) { + addresses.forEach(addr => { + list.push(AddressComponent.createContactAddressForm(addr, fb)); + }); + } + + return list; + } + + constructor() { } + + ngOnInit() { + } + +} diff --git a/apps/static-factory-methods/src/app/address/address.component.css b/apps/static-factory-methods/src/app/address/address.component.css new file mode 100644 index 0000000..e69de29 diff --git a/apps/static-factory-methods/src/app/address/address.component.html b/apps/static-factory-methods/src/app/address/address.component.html new file mode 100644 index 0000000..1315e69 --- /dev/null +++ b/apps/static-factory-methods/src/app/address/address.component.html @@ -0,0 +1,27 @@ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ \ No newline at end of file diff --git a/apps/static-factory-methods/src/app/address/address.component.spec.ts b/apps/static-factory-methods/src/app/address/address.component.spec.ts new file mode 100644 index 0000000..a14de29 --- /dev/null +++ b/apps/static-factory-methods/src/app/address/address.component.spec.ts @@ -0,0 +1,27 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ReactiveFormsModule } from '@angular/forms'; + +import { AddressComponent } from './address.component'; + +describe('AddressComponent', () => { + let component: AddressComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ReactiveFormsModule], + declarations: [ AddressComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AddressComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/apps/static-factory-methods/src/app/address/address.component.ts b/apps/static-factory-methods/src/app/address/address.component.ts new file mode 100644 index 0000000..e2d58f5 --- /dev/null +++ b/apps/static-factory-methods/src/app/address/address.component.ts @@ -0,0 +1,28 @@ +import { Component, OnInit, Input } from '@angular/core'; +import { FormBuilder, FormGroup } from '@angular/forms'; +import { Address } from '@nested-forms/contact'; + +@Component({ + selector: 'nested-forms-address', + templateUrl: './address.component.html', + styleUrls: ['./address.component.css'] +}) +export class AddressComponent implements OnInit { + @Input() addressGroup: FormGroup; + + static createContactAddressForm(addr: Address, fb: FormBuilder): FormGroup { + return fb.group({ + line1: [addr ? addr.line1 : ''], + line2: [addr ? addr.line2 : ''], + city: [addr ? addr.city : ''], + state: [addr ? addr.state : ''], + postalCode: [addr ? addr.postalCode : ''], + }); + } + + constructor() { } + + ngOnInit() { + } + +} diff --git a/apps/static-factory-methods/src/app/app.component.css b/apps/static-factory-methods/src/app/app.component.css new file mode 100644 index 0000000..e69de29 diff --git a/apps/static-factory-methods/src/app/app.component.html b/apps/static-factory-methods/src/app/app.component.html new file mode 100644 index 0000000..d8c6a21 --- /dev/null +++ b/apps/static-factory-methods/src/app/app.component.html @@ -0,0 +1,8 @@ +
+ + +
+
+
+  {{ form.value | json }}
+
diff --git a/apps/static-factory-methods/src/app/app.component.spec.ts b/apps/static-factory-methods/src/app/app.component.spec.ts new file mode 100644 index 0000000..a59e4aa --- /dev/null +++ b/apps/static-factory-methods/src/app/app.component.spec.ts @@ -0,0 +1,33 @@ +import { ReactiveFormsModule } from '@angular/forms'; +import { RouterTestingModule } from '@angular/router/testing'; +import { TestBed, async } from '@angular/core/testing'; +import { AppComponent } from './app.component'; +import { NameComponent } from './name/name.component'; +import { AddressListComponent } from './address-list/address-list.component'; +import { AddressComponent } from './address/address.component'; +import { ContactModule } from '@nested-forms/contact'; + +describe('AppComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ + RouterTestingModule, + ReactiveFormsModule, + ContactModule.forRoot(), + ], + declarations: [ + AppComponent, + NameComponent, + AddressComponent, + AddressListComponent, + ], + providers: [], + }).compileComponents(); + })); + + it('should create the app', () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.debugElement.componentInstance; + expect(app).toBeTruthy(); + }); +}); diff --git a/apps/static-factory-methods/src/app/app.component.ts b/apps/static-factory-methods/src/app/app.component.ts new file mode 100644 index 0000000..2beff5d --- /dev/null +++ b/apps/static-factory-methods/src/app/app.component.ts @@ -0,0 +1,44 @@ +import { Component, OnDestroy, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup } from '@angular/forms'; +import { + Contact, + ContactService, +} from '@nested-forms/contact'; +import { Subscription } from 'rxjs'; +import { NameComponent } from './name/name.component'; +import { AddressListComponent } from './address-list/address-list.component'; + +@Component({ + selector: 'nested-forms-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.css'], +}) +export class AppComponent implements OnInit, OnDestroy { + contact: Contact; + form: FormGroup; + + private subscription: Subscription; + + constructor( + private service: ContactService, + private fb: FormBuilder, + ) {} + + public ngOnInit() { + this.subscription = this.service + .loadContact() + .subscribe((data: Contact) => { + this.contact = data; + this.form = this.fb.group({ + name: NameComponent.createContactNameForm(data.name, this.fb), + addresses: AddressListComponent.createContactAddressListForm(data.addresses, this.fb), + }); + }); + } + + public ngOnDestroy() { + if (this.subscription) { + this.subscription.unsubscribe(); + } + } +} diff --git a/apps/static-factory-methods/src/app/app.module.ts b/apps/static-factory-methods/src/app/app.module.ts new file mode 100644 index 0000000..45b56b2 --- /dev/null +++ b/apps/static-factory-methods/src/app/app.module.ts @@ -0,0 +1,23 @@ +import { BrowserModule } from '@angular/platform-browser'; +import { NgModule } from '@angular/core'; + +import { AppComponent } from './app.component'; +import { RouterModule } from '@angular/router'; +import { ReactiveFormsModule } from '@angular/forms'; +import { NameComponent } from './name/name.component'; +import { ContactModule } from '@nested-forms/contact'; +import { AddressListComponent } from './address-list/address-list.component'; +import { AddressComponent } from './address/address.component'; + +@NgModule({ + declarations: [AppComponent, NameComponent, AddressListComponent, AddressComponent], + imports: [ + BrowserModule, + RouterModule.forRoot([], { initialNavigation: 'enabled' }), + ReactiveFormsModule, + ContactModule.forRoot() + ], + providers: [], + bootstrap: [AppComponent] +}) +export class AppModule {} diff --git a/apps/static-factory-methods/src/app/name/name.component.css b/apps/static-factory-methods/src/app/name/name.component.css new file mode 100644 index 0000000..e69de29 diff --git a/apps/static-factory-methods/src/app/name/name.component.html b/apps/static-factory-methods/src/app/name/name.component.html new file mode 100644 index 0000000..f688e17 --- /dev/null +++ b/apps/static-factory-methods/src/app/name/name.component.html @@ -0,0 +1,27 @@ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ \ No newline at end of file diff --git a/apps/static-factory-methods/src/app/name/name.component.spec.ts b/apps/static-factory-methods/src/app/name/name.component.spec.ts new file mode 100644 index 0000000..6f115d7 --- /dev/null +++ b/apps/static-factory-methods/src/app/name/name.component.spec.ts @@ -0,0 +1,26 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ReactiveFormsModule } from '@angular/forms'; + +import { NameComponent } from './name.component'; + +describe('NameComponent', () => { + let component: NameComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ReactiveFormsModule], + declarations: [NameComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(NameComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/apps/static-factory-methods/src/app/name/name.component.ts b/apps/static-factory-methods/src/app/name/name.component.ts new file mode 100644 index 0000000..2241985 --- /dev/null +++ b/apps/static-factory-methods/src/app/name/name.component.ts @@ -0,0 +1,26 @@ +import { FormBuilder, FormGroup } from '@angular/forms'; +import { Component, OnInit, Input } from '@angular/core'; +import { Name } from '@nested-forms/contact'; + +@Component({ + selector: 'nested-forms-name', + templateUrl: './name.component.html', + styleUrls: ['./name.component.css'] +}) +export class NameComponent implements OnInit { + @Input() nameGroup: FormGroup; + + static createContactNameForm(name: Name, fb: FormBuilder): FormGroup { + return fb.group({ + firstName: [name ? name.firstName : ''], + lastName: [name ? name.lastName : ''], + middleName: [name ? name.middleName : ''], + prefix: [name ? name.prefix : ''], + suffix: [name ? name.suffix : ''], + }) + } + + constructor() {} + + ngOnInit() {} +} diff --git a/apps/static-factory-methods/src/assets/.gitkeep b/apps/static-factory-methods/src/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/apps/static-factory-methods/src/environments/environment.prod.ts b/apps/static-factory-methods/src/environments/environment.prod.ts new file mode 100644 index 0000000..3612073 --- /dev/null +++ b/apps/static-factory-methods/src/environments/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/apps/static-factory-methods/src/environments/environment.ts b/apps/static-factory-methods/src/environments/environment.ts new file mode 100644 index 0000000..7b4f817 --- /dev/null +++ b/apps/static-factory-methods/src/environments/environment.ts @@ -0,0 +1,16 @@ +// This file can be replaced during build by using the `fileReplacements` array. +// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. +// The list of file replacements can be found in `angular.json`. + +export const environment = { + production: false +}; + +/* + * For easier debugging in development mode, you can import the following file + * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. + * + * This import should be commented out in production mode because it will have a negative impact + * on performance if an error is thrown. + */ +// import 'zone.js/dist/zone-error'; // Included with Angular CLI. diff --git a/apps/static-factory-methods/src/favicon.ico b/apps/static-factory-methods/src/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..8081c7ceaf2be08bf59010158c586170d9d2d517 GIT binary patch literal 5430 zcmc(je{54#6vvCoAI3i*G5%$U7!sA3wtMZ$fH6V9C`=eXGJb@R1%(I_{vnZtpD{6n z5Pl{DmxzBDbrB>}`90e12m8T*36WoeDLA&SD_hw{H^wM!cl_RWcVA!I+x87ee975; z@4kD^=bYPn&pmG@(+JZ`rqQEKxW<}RzhW}I!|ulN=fmjVi@x{p$cC`)5$a!)X&U+blKNvN5tg=uLvuLnuqRM;Yc*swiexsoh#XPNu{9F#c`G zQLe{yWA(Y6(;>y|-efAy11k<09(@Oo1B2@0`PtZSkqK&${ zgEY}`W@t{%?9u5rF?}Y7OL{338l*JY#P!%MVQY@oqnItpZ}?s z!r?*kwuR{A@jg2Chlf0^{q*>8n5Ir~YWf*wmsh7B5&EpHfd5@xVaj&gqsdui^spyL zB|kUoblGoO7G(MuKTfa9?pGH0@QP^b#!lM1yHWLh*2iq#`C1TdrnO-d#?Oh@XV2HK zKA{`eo{--^K&MW66Lgsktfvn#cCAc*(}qsfhrvOjMGLE?`dHVipu1J3Kgr%g?cNa8 z)pkmC8DGH~fG+dlrp(5^-QBeEvkOvv#q7MBVLtm2oD^$lJZx--_=K&Ttd=-krx(Bb zcEoKJda@S!%%@`P-##$>*u%T*mh+QjV@)Qa=Mk1?#zLk+M4tIt%}wagT{5J%!tXAE;r{@=bb%nNVxvI+C+$t?!VJ@0d@HIyMJTI{vEw0Ul ze(ha!e&qANbTL1ZneNl45t=#Ot??C0MHjjgY8%*mGisN|S6%g3;Hlx#fMNcL<87MW zZ>6moo1YD?P!fJ#Jb(4)_cc50X5n0KoDYfdPoL^iV`k&o{LPyaoqMqk92wVM#_O0l z09$(A-D+gVIlq4TA&{1T@BsUH`Bm=r#l$Z51J-U&F32+hfUP-iLo=jg7Xmy+WLq6_tWv&`wDlz#`&)Jp~iQf zZP)tu>}pIIJKuw+$&t}GQuqMd%Z>0?t%&BM&Wo^4P^Y z)c6h^f2R>X8*}q|bblAF?@;%?2>$y+cMQbN{X$)^R>vtNq_5AB|0N5U*d^T?X9{xQnJYeU{ zoZL#obI;~Pp95f1`%X3D$Mh*4^?O?IT~7HqlWguezmg?Ybq|7>qQ(@pPHbE9V?f|( z+0xo!#m@Np9PljsyxBY-UA*{U*la#8Wz2sO|48_-5t8%_!n?S$zlGe+NA%?vmxjS- zHE5O3ZarU=X}$7>;Okp(UWXJxI%G_J-@IH;%5#Rt$(WUX?6*Ux!IRd$dLP6+SmPn= z8zjm4jGjN772R{FGkXwcNv8GBcZI#@Y2m{RNF_w8(Z%^A*!bS*!}s6sh*NnURytky humW;*g7R+&|Ledvc- + + + + GlobalForm + + + + + + + + + diff --git a/apps/static-factory-methods/src/main.ts b/apps/static-factory-methods/src/main.ts new file mode 100644 index 0000000..fa4e0ae --- /dev/null +++ b/apps/static-factory-methods/src/main.ts @@ -0,0 +1,13 @@ +import { enableProdMode } from '@angular/core'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { AppModule } from './app/app.module'; +import { environment } from './environments/environment'; + +if (environment.production) { + enableProdMode(); +} + +platformBrowserDynamic() + .bootstrapModule(AppModule) + .catch(err => console.error(err)); diff --git a/apps/static-factory-methods/src/polyfills.ts b/apps/static-factory-methods/src/polyfills.ts new file mode 100644 index 0000000..2f258e5 --- /dev/null +++ b/apps/static-factory-methods/src/polyfills.ts @@ -0,0 +1,62 @@ +/** + * This file includes polyfills needed by Angular and is loaded before the app. + * You can add your own extra polyfills to this file. + * + * This file is divided into 2 sections: + * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. + * 2. Application imports. Files imported after ZoneJS that should be loaded before your main + * file. + * + * The current setup is for so-called "evergreen" browsers; the last versions of browsers that + * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), + * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. + * + * Learn more in https://angular.io/guide/browser-support + */ + +/*************************************************************************************************** + * BROWSER POLYFILLS + */ + +/** IE10 and IE11 requires the following for NgClass support on SVG elements */ +// import 'classlist.js'; // Run `npm install --save classlist.js`. + +/** + * Web Animations `@angular/platform-browser/animations` + * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. + * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). + */ +// import 'web-animations-js'; // Run `npm install --save web-animations-js`. + +/** + * By default, zone.js will patch all possible macroTask and DomEvents + * user can disable parts of macroTask/DomEvents patch by setting following flags + * because those flags need to be set before `zone.js` being loaded, and webpack + * will put import in the top of bundle, so user need to create a separate file + * in this directory (for example: zone-flags.ts), and put the following flags + * into that file, and then add the following code before importing zone.js. + * import './zone-flags.ts'; + * + * The flags allowed in zone-flags.ts are listed here. + * + * The following flags will work for all browsers. + * + * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame + * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick + * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames + * + * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js + * with the following flag, it will bypass `zone.js` patch for IE/Edge + * + * (window as any).__Zone_enable_cross_context_check = true; + * + */ + +/*************************************************************************************************** + * Zone JS is required by default for Angular itself. + */ +import 'zone.js/dist/zone'; // Included with Angular CLI. + +/*************************************************************************************************** + * APPLICATION IMPORTS + */ diff --git a/apps/static-factory-methods/src/styles.css b/apps/static-factory-methods/src/styles.css new file mode 100644 index 0000000..90d4ee0 --- /dev/null +++ b/apps/static-factory-methods/src/styles.css @@ -0,0 +1 @@ +/* You can add global styles to this file, and also import other style files */ diff --git a/apps/static-factory-methods/src/test-setup.ts b/apps/static-factory-methods/src/test-setup.ts new file mode 100644 index 0000000..8d88704 --- /dev/null +++ b/apps/static-factory-methods/src/test-setup.ts @@ -0,0 +1 @@ +import 'jest-preset-angular'; diff --git a/apps/static-factory-methods/tsconfig.app.json b/apps/static-factory-methods/tsconfig.app.json new file mode 100644 index 0000000..827b630 --- /dev/null +++ b/apps/static-factory-methods/tsconfig.app.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": [] + }, + "include": ["**/*.ts"], + "exclude": ["src/test-setup.ts", "**/*.spec.ts"] +} diff --git a/apps/static-factory-methods/tsconfig.json b/apps/static-factory-methods/tsconfig.json new file mode 100644 index 0000000..e5decd5 --- /dev/null +++ b/apps/static-factory-methods/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "types": ["node", "jest"] + }, + "include": ["**/*.ts"] +} diff --git a/apps/static-factory-methods/tsconfig.spec.json b/apps/static-factory-methods/tsconfig.spec.json new file mode 100644 index 0000000..cfff29a --- /dev/null +++ b/apps/static-factory-methods/tsconfig.spec.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "files": ["src/test-setup.ts"], + "include": ["**/*.spec.ts", "**/*.d.ts"] +} diff --git a/apps/static-factory-methods/tslint.json b/apps/static-factory-methods/tslint.json new file mode 100644 index 0000000..b179968 --- /dev/null +++ b/apps/static-factory-methods/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tslint.json", + "rules": { + "directive-selector": [true, "attribute", "nestedForms", "camelCase"], + "component-selector": [true, "element", "nested-forms", "kebab-case"] + } +} diff --git a/nx.json b/nx.json index 0da6034..c73aee4 100644 --- a/nx.json +++ b/nx.json @@ -19,6 +19,9 @@ }, "baseline": { "tags": [] + }, + "static-factory-methods": { + "tags": [] } } }