Skip to content

Commit

Permalink
Merge pull request #8 from bigBear713/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
bigBear713 authored Jul 28, 2022
2 parents d90afb6 + 1084226 commit adf2848
Show file tree
Hide file tree
Showing 31 changed files with 127 additions and 111 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.EN.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v14.0.0
## Breaking Changes
- feat: Upgrade `angular` to `v14`;

<br/>

# v13.0.0
## Breaking Changes
- feat: Upgrade `angular` to `v13`;
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v14.0.0
## 破坏性更新
- feat: `angular`升级到`v14`;

<br/>

# v13.0.0
## 破坏性更新
- feat: `angular`升级到`v13`;
Expand Down
1 change: 1 addition & 0 deletions README.EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Angular common form lib by bigBear713.
###### The nb-form's major version will keep up with the Angular's major version
- "@bigbear713/nb-form":"^12.0.0" - "@angular/core": "^12.0.0"
- "@bigbear713/nb-form":"^13.0.0" - "@angular/core": "^13.0.0"
- "@bigbear713/nb-form":"^14.0.0" - "@angular/core": "^14.0.0"

<br>

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Angular common form lib by bigBear713.
###### nb-form的大版本和Angular的大版本保持对应关系
- "@bigbear713/nb-form":"^12.0.0" - "@angular/core": "^12.0.0"
- "@bigbear713/nb-form":"^13.0.0" - "@angular/core": "^13.0.0"
- "@bigbear713/nb-form":"^14.0.0" - "@angular/core": "^14.0.0"

<br>

Expand Down
3 changes: 1 addition & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,5 @@
}
}
}
},
"defaultProject": "nb-form-demo"
}
}
2 changes: 1 addition & 1 deletion docs/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<link rel="stylesheet" href="styles.ef46db3751d8e999.css"></head>
<body>
<app-root></app-root>
<script src="runtime.e967317e22394954.js" type="module"></script><script src="polyfills.9da2fefd2250fbbe.js" type="module"></script><script src="main.568f05c94fb83e1e.js" type="module"></script>
<script src="runtime.e967317e22394954.js" type="module"></script><script src="polyfills.81b5a0ac59214453.js" type="module"></script><script src="main.3bb38a3889c1a1aa.js" type="module"></script>

</body></html>
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<link rel="stylesheet" href="styles.ef46db3751d8e999.css"></head>
<body>
<app-root></app-root>
<script src="runtime.e967317e22394954.js" type="module"></script><script src="polyfills.9da2fefd2250fbbe.js" type="module"></script><script src="main.568f05c94fb83e1e.js" type="module"></script>
<script src="runtime.e967317e22394954.js" type="module"></script><script src="polyfills.81b5a0ac59214453.js" type="module"></script><script src="main.3bb38a3889c1a1aa.js" type="module"></script>

</body></html>
1 change: 1 addition & 0 deletions docs/main.3bb38a3889c1a1aa.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/main.568f05c94fb83e1e.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/polyfills.81b5a0ac59214453.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/polyfills.9da2fefd2250fbbe.js

This file was deleted.

34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nb-form-demo",
"version": "13.0.0",
"version": "14.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand All @@ -12,7 +12,7 @@
"build:analyze": "npm run build -- --source-map && npm run view:analyze",
"view:analyze": "node_modules/.bin/source-map-explorer dist/nb-form-demo/*",
"test:lib": "ng test nb-form",
"deploy": "ng build --outputPath=docs --base-href=/nb-form/ && cp docs/index.html docs/404.html",
"deploy": "ng build --output-path=docs --base-href=/nb-form/ && cp docs/index.html docs/404.html",
"publish:lib": "npm run build:lib && cd ./dist/nb-form && npm publish --access=public",
"copy:readmeEn": "cp projects/nb-form/README.EN.md dist/nb-form/",
"copy:changelog": "cp CHANGELOG.* dist/nb-form/",
Expand All @@ -21,25 +21,25 @@
},
"private": true,
"dependencies": {
"@angular/animations": "~13.3.5",
"@angular/common": "~13.3.5",
"@angular/compiler": "~13.3.5",
"@angular/core": "~13.3.5",
"@angular/forms": "~13.3.5",
"@angular/platform-browser": "~13.3.5",
"@angular/platform-browser-dynamic": "~13.3.5",
"@angular/router": "~13.3.5",
"@bigbear713/nb-common": "^13.0.0",
"@bigbear713/nb-trans": "^13.0.0",
"@angular/animations": "^14.1.0",
"@angular/common": "^14.1.0",
"@angular/compiler": "^14.1.0",
"@angular/core": "^14.1.0",
"@angular/forms": "^14.1.0",
"@angular/platform-browser": "^14.1.0",
"@angular/platform-browser-dynamic": "^14.1.0",
"@angular/router": "^14.1.0",
"@bigbear713/nb-common": "^14.0.0",
"@bigbear713/nb-trans": "^14.0.0",
"lodash-es": "^4.17.21",
"rxjs": "~6.6.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.3.4",
"@angular/cli": "~13.3.4",
"@angular/compiler-cli": "~13.3.5",
"@angular-devkit/build-angular": "^14.1.0",
"@angular/cli": "^14.1.0",
"@angular/compiler-cli": "^14.1.0",
"@types/jasmine": "~3.8.0",
"@types/lodash-es": "^4.17.5",
"@types/node": "^12.11.1",
Expand All @@ -49,8 +49,8 @@
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"ng-packagr": "^13.3.1",
"ng-packagr": "^14.1.0",
"source-map-explorer": "^2.5.2",
"typescript": "~4.6.4"
}
}
}
1 change: 1 addition & 0 deletions projects/nb-form/README.EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Angular common form lib by bigBear713.
###### The nb-form's major version will keep up with the Angular's major version
- "@bigbear713/nb-form":"^12.0.0" - "@angular/core": "^12.0.0"
- "@bigbear713/nb-form":"^13.0.0" - "@angular/core": "^13.0.0"
- "@bigbear713/nb-form":"^14.0.0" - "@angular/core": "^14.0.0"

<br>

Expand Down
1 change: 1 addition & 0 deletions projects/nb-form/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Angular common form lib by bigBear713.
###### nb-form的大版本和Angular的大版本保持对应关系
- "@bigbear713/nb-form":"^12.0.0" - "@angular/core": "^12.0.0"
- "@bigbear713/nb-form":"^13.0.0" - "@angular/core": "^13.0.0"
- "@bigbear713/nb-form":"^14.0.0" - "@angular/core": "^14.0.0"

<br>

Expand Down
11 changes: 6 additions & 5 deletions projects/nb-form/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "@bigbear713/nb-form",
"version": "13.0.0",
"version": "14.0.0",
"homepage": "https://github.com/bigBear713/nb-form/blob/master/projects/nb-form/README.md",
"description": "Angular common form lib by bigBear713.",
"keywords": [
"ng",
"angular",
"angular2+",
"angular13",
"angular14",
"form",
"validators",
"bigBear713"
Expand All @@ -21,12 +22,12 @@
"url": "https://github.com/bigBear713/nb-form/issues"
},
"peerDependencies": {
"@angular/common": "^13.0.0",
"@angular/core": "^13.0.0",
"@angular/forms": "^13.0.0"
"@angular/common": "^14.0.0",
"@angular/core": "^14.0.0",
"@angular/forms": "^14.0.0"
},
"dependencies": {
"@bigbear713/nb-common": "^13.0.0",
"@bigbear713/nb-common": "^14.0.0",
"lodash-es": "^4.17.21",
"tslib": "^2.3.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Optional,
SimpleChanges
} from '@angular/core';
import { AbstractControl, FormControl } from '@angular/forms';
import { AbstractControl, UntypedFormControl } from '@angular/forms';
import { INbControlErrInfo } from '../../models';
import { NB_CONTROL_COMMON_ERR_INFO_TOKEN } from '../../constants';
import { Subject } from 'rxjs';
Expand Down Expand Up @@ -44,7 +44,7 @@ export class NbControlErrComponent implements OnChanges, OnDestroy {

allErrInfo: INbControlErrInfo = {};

errControl = new FormControl();
errControl = new UntypedFormControl();

hasErr: boolean = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NbFormTestingModule } from '../../testing';
import { NB_CONTROL_COMMON_ERR_INFO_TOKEN } from '../../constants';
import { ChangeDetectorRef, SimpleChange } from '@angular/core';
import { INbControlErrInfo } from '../../models';
import { AbstractControl, FormControl } from '@angular/forms';
import { AbstractControl, UntypedFormControl } from '@angular/forms';
import { NbFormValidators } from '../../validators';
import { NbFormService } from '../../services';

Expand Down Expand Up @@ -39,7 +39,7 @@ describe('NbControlErrComponent', () => {
{
title: 'The control is valid and dirty is false',
testData: {
control: new FormControl(),
control: new UntypedFormControl(),
operateControl: (control: AbstractControl) => { },
},
expect: {
Expand All @@ -49,7 +49,7 @@ describe('NbControlErrComponent', () => {
{
title: 'The control is valid and dirty is true',
testData: {
control: new FormControl(),
control: new UntypedFormControl(),
operateControl: (control: AbstractControl) => {
const service: NbFormService = TestBed.inject(NbFormService);
service.showAllErrInfo(control);
Expand All @@ -62,7 +62,7 @@ describe('NbControlErrComponent', () => {
{
title: 'The control is invalid and dirty is true',
testData: {
control: new FormControl('', [NbFormValidators.required(true)]),
control: new UntypedFormControl('', [NbFormValidators.required(true)]),
operateControl: (control: AbstractControl) => {
const service: NbFormService = TestBed.inject(NbFormService);
service.showAllErrInfo(control);
Expand All @@ -75,7 +75,7 @@ describe('NbControlErrComponent', () => {
{
title: 'The control is invalid and dirty is false',
testData: {
control: new FormControl('', [NbFormValidators.required(true)]),
control: new UntypedFormControl('', [NbFormValidators.required(true)]),
operateControl: (control: AbstractControl) => { },
},
expect: {
Expand All @@ -99,7 +99,7 @@ describe('NbControlErrComponent', () => {
});

it('The control is in initial status, and the dirty is true, status is invalid', () => {
const control = new FormControl('', [NbFormValidators.required(true)]);
const control = new UntypedFormControl('', [NbFormValidators.required(true)]);
control.markAsDirty();

component.control = control;
Expand All @@ -117,7 +117,7 @@ describe('NbControlErrComponent', () => {
const instance = createComponent();
const fixture = instance.fixture;
const component = instance.component;
component.control = new FormControl('', [NbFormValidators.required(true)]);
component.control = new UntypedFormControl('', [NbFormValidators.required(true)]);
const service: NbFormService = TestBed.inject(NbFormService);

const changes = {
Expand Down Expand Up @@ -209,7 +209,7 @@ describe('NbControlErrComponent', () => {
function createComponent() {
const fixture = TestBed.createComponent(NbControlErrComponent);
const component = fixture.componentInstance;
component.control = new FormControl();
component.control = new UntypedFormControl();
fixture.detectChanges();
return { fixture, component };
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormControl } from '@angular/forms';
import { UntypedFormControl } from '@angular/forms';
import { INbControlErrInfo } from '../../models';
import { NbFormTestingModule } from '../../testing';
import { NbFieldItemComponent } from './field-item.component';
Expand All @@ -16,7 +16,7 @@ import { NbFieldItemComponent } from './field-item.component';
`
})
class UIComponent {
control!: FormControl;
control!: UntypedFormControl;
errInfo!: INbControlErrInfo;
required: boolean | undefined = true;
}
Expand All @@ -36,7 +36,7 @@ describe('NbFieldItemComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(NbFieldItemComponent);
component = fixture.componentInstance;
component.control = new FormControl();
component.control = new UntypedFormControl();
fixture.detectChanges();
});

Expand All @@ -52,7 +52,7 @@ describe('NbFieldItemComponent', () => {
beforeEach(() => {
uiFixture = TestBed.createComponent(UIComponent);
uiComponent = uiFixture.componentInstance;
uiComponent.control = new FormControl();
uiComponent.control = new UntypedFormControl();
uiFixture.detectChanges();
uiHostEle = uiFixture.debugElement.nativeElement;
});
Expand Down
6 changes: 3 additions & 3 deletions projects/nb-form/src/lib/services/form-tools.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { FormArray, FormGroup, ValidatorFn, Validators } from '@angular/forms';
import { UntypedFormArray, UntypedFormGroup, ValidatorFn, Validators } from '@angular/forms';
import { INbControlConfig, NbAbstractControl } from '../models';
import { NbFormValidators } from '../validators';

Expand All @@ -10,11 +10,11 @@ export class NbFormToolsService {

constructor() { }

doFormArrayFn(control: FormArray, fn: (item: NbAbstractControl) => void): void {
doFormArrayFn(control: UntypedFormArray, fn: (item: NbAbstractControl) => void): void {
control.controls.forEach(item => fn(item));
}

doFormGroupFn(control: FormGroup, fn: (item: NbAbstractControl) => void): void {
doFormGroupFn(control: UntypedFormGroup, fn: (item: NbAbstractControl) => void): void {
Object.keys(control.controls).forEach(key => fn(control.get(key)));
}

Expand Down
10 changes: 5 additions & 5 deletions projects/nb-form/src/lib/services/form.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { AbstractControl, FormArray, FormGroup, ValidatorFn } from '@angular/forms';
import { AbstractControl, UntypedFormArray, UntypedFormGroup, ValidatorFn } from '@angular/forms';
import { isEqual } from 'lodash-es';
import { combineLatest, Subject, Subscription } from 'rxjs';
import { distinctUntilChanged, startWith, takeUntil, tap } from 'rxjs/operators';
Expand Down Expand Up @@ -32,9 +32,9 @@ export class NbFormService {
control?.markAsDirty(opts);

const fn = (controlItem: NbAbstractControl): void => this.markAllAsDirty(controlItem, opts)
if (control instanceof FormArray) {
if (control instanceof UntypedFormArray) {
this.formTools.doFormArrayFn(control, fn);
} else if (control instanceof FormGroup) {
} else if (control instanceof UntypedFormGroup) {
this.formTools.doFormGroupFn(control, fn);
}
}
Expand All @@ -49,9 +49,9 @@ export class NbFormService {
control?.updateValueAndValidity(opts);

const fn = (controlItem: NbAbstractControl): void => this.updateAllValueAndValidity(controlItem, opts)
if (control instanceof FormArray) {
if (control instanceof UntypedFormArray) {
this.formTools.doFormArrayFn(control, fn);
} else if (control instanceof FormGroup) {
} else if (control instanceof UntypedFormGroup) {
this.formTools.doFormGroupFn(control, fn);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TestBed } from '@angular/core/testing';
import { FormArray, FormControl, FormGroup } from '@angular/forms';
import { UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { NbAbstractControl } from '../../models';
import { NbFormTestingModule } from '../../testing';
import { NbFormToolsService } from '../form-tools.service';
Expand All @@ -26,8 +26,8 @@ describe('Service: FormTools', () => {
};
spyOn(fnObj, 'doFn').and.callThrough();

const control = new FormControl();
const form = new FormArray([control]);
const control = new UntypedFormControl();
const form = new UntypedFormArray([control]);
service.doFormArrayFn(form, fnObj.doFn);

expect(fnObj.doFn).toHaveBeenCalledTimes(form.length);
Expand All @@ -40,8 +40,8 @@ describe('Service: FormTools', () => {
};
spyOn(fnObj, 'doFn').and.callThrough();

const control = new FormControl();
const form = new FormGroup({
const control = new UntypedFormControl();
const form = new UntypedFormGroup({
control,
});
service.doFormGroupFn(form, fnObj.doFn);
Expand Down
Loading

0 comments on commit adf2848

Please sign in to comment.