diff --git a/package-lock.json b/package-lock.json index 1675c109..ff8bb734 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "demo", - "version": "13.1.1", + "version": "13.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 1c4a9399..42bc7731 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "demo", - "version": "13.1.1", + "version": "13.1.2", "author": "https://github.com/hamzahamidi/Angular6-json-schema-form/graphs/contributors", "description": "Angular JSON Schema Form builder Demo", "engines": { @@ -55,7 +55,7 @@ "ng": "ng", "prestart": "npm run build:libs", "start": "ng serve", - "start:prod": "ng serve --configuration production", + "start:demo-only": "ng serve", "build:core": "ng build @ajsf/core --configuration production", "postbuild:core": "cp README.md LICENSE dist/@ajsf/core/", "build:bs3": "ng build @ajsf/bootstrap3 --configuration production", diff --git a/projects/ajsf-bootstrap3/package.json b/projects/ajsf-bootstrap3/package.json index fa93b2ae..a44fa0fa 100644 --- a/projects/ajsf-bootstrap3/package.json +++ b/projects/ajsf-bootstrap3/package.json @@ -1,6 +1,6 @@ { "name": "@ajsf/bootstrap3", - "version": "0.5.1-beta.2", + "version": "0.5.1-beta.3", "description": "Angular JSON Schema Form builder using Bootstrap 3 UI", "author": "https://github.com/hamzahamidi/ajsf/graphs/contributors", "keywords": [ @@ -29,7 +29,7 @@ "private": false, "dependencies": { "lodash-es": "~4.17.21", - "@ajsf/core": "~0.5.1-beta.2", + "@ajsf/core": "~0.5.1-beta.3", "tslib": "^2.0.0" }, "peerDependencies": { diff --git a/projects/ajsf-bootstrap3/src/lib/bootstrap3-framework.component.spec.ts b/projects/ajsf-bootstrap3/src/lib/bootstrap3-framework.component.spec.ts index d056cecc..4f155685 100644 --- a/projects/ajsf-bootstrap3/src/lib/bootstrap3-framework.component.spec.ts +++ b/projects/ajsf-bootstrap3/src/lib/bootstrap3-framework.component.spec.ts @@ -2,6 +2,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { CommonModule } from '@angular/common'; import { JsonSchemaFormModule, + JsonSchemaFormService, WidgetLibraryModule } from '@ajsf/core'; import { Bootstrap3FrameworkComponent } from './bootstrap3-framework.component'; @@ -17,7 +18,8 @@ describe('Bootstrap3FrameworkComponent', () => { CommonModule, WidgetLibraryModule, ], - declarations: [Bootstrap3FrameworkComponent] + declarations: [Bootstrap3FrameworkComponent], + providers: [JsonSchemaFormService] }) .compileComponents(); })); diff --git a/projects/ajsf-bootstrap4/package.json b/projects/ajsf-bootstrap4/package.json index 46560eac..75d526dd 100644 --- a/projects/ajsf-bootstrap4/package.json +++ b/projects/ajsf-bootstrap4/package.json @@ -1,6 +1,6 @@ { "name": "@ajsf/bootstrap4", - "version": "0.5.1-beta.2", + "version": "0.5.1-beta.3", "description": "Angular JSON Schema Form builder using Bootstrap 4 UI", "author": "https://github.com/hamzahamidi/ajsf/graphs/contributors", "keywords": [ @@ -29,7 +29,7 @@ "private": false, "dependencies": { "lodash-es": "~4.17.21", - "@ajsf/core": "~0.5.1-beta.2", + "@ajsf/core": "~0.5.1-beta.3", "tslib": "^2.0.0" }, "peerDependencies": { diff --git a/projects/ajsf-bootstrap4/src/lib/bootstrap4-framework.component.spec.ts b/projects/ajsf-bootstrap4/src/lib/bootstrap4-framework.component.spec.ts index 18a2e269..9b95fc97 100644 --- a/projects/ajsf-bootstrap4/src/lib/bootstrap4-framework.component.spec.ts +++ b/projects/ajsf-bootstrap4/src/lib/bootstrap4-framework.component.spec.ts @@ -2,6 +2,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { CommonModule } from '@angular/common'; import { JsonSchemaFormModule, + JsonSchemaFormService, WidgetLibraryModule } from '@ajsf/core'; import { Bootstrap4FrameworkComponent } from './bootstrap4-framework.component'; @@ -17,7 +18,8 @@ describe('FwBootstrap4Component', () => { CommonModule, WidgetLibraryModule, ], - declarations: [Bootstrap4FrameworkComponent] + declarations: [Bootstrap4FrameworkComponent], + providers: [JsonSchemaFormService] }) .compileComponents(); })); diff --git a/projects/ajsf-core/package.json b/projects/ajsf-core/package.json index ef05a7be..6fe88266 100644 --- a/projects/ajsf-core/package.json +++ b/projects/ajsf-core/package.json @@ -1,6 +1,6 @@ { "name": "@ajsf/core", - "version": "0.5.1-beta.2", + "version": "0.5.1-beta.3", "description": "Angular JSON Schema Form builder core", "author": "https://github.com/hamzahamidi/ajsf/graphs/contributors", "keywords": [ diff --git a/projects/ajsf-core/src/lib/json-schema-form.component.ts b/projects/ajsf-core/src/lib/json-schema-form.component.ts index 99ef13cb..4ab9a423 100755 --- a/projects/ajsf-core/src/lib/json-schema-form.component.ts +++ b/projects/ajsf-core/src/lib/json-schema-form.component.ts @@ -6,13 +6,14 @@ import { ChangeDetectorRef, Component, EventEmitter, + forwardRef, Input, OnChanges, OnInit, Output, SimpleChanges, } from '@angular/core'; -import { ControlValueAccessor } from '@angular/forms'; +import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { convertSchemaToDraft6 } from './shared/convert-schema-to-draft6.function'; import { forEach, hasOwn } from './shared/utility.functions'; import { FrameworkLibraryService } from './framework-library/framework-library.service'; @@ -28,6 +29,11 @@ import { JsonSchemaFormService } from './json-schema-form.service'; import { resolveSchemaReferences } from './shared/json-schema.functions'; import { WidgetLibraryService } from './widget-library/widget-library.service'; +export const JSON_SCHEMA_FORM_VALUE_ACCESSOR: any = { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => JsonSchemaFormComponent), + multi: true, +}; /** * @module 'JsonSchemaFormComponent' - Angular JSON Schema Form @@ -67,7 +73,10 @@ import { WidgetLibraryService } from './widget-library/widget-library.service'; // tslint:disable-next-line:component-selector selector: 'json-schema-form', templateUrl: './json-schema-form.component.html', - changeDetection: ChangeDetectionStrategy.OnPush + changeDetection: ChangeDetectionStrategy.OnPush, + // Adding 'JsonSchemaFormService' here, instead of in the module, + // creates a separate instance of the service for each component + providers: [ JsonSchemaFormService, JSON_SCHEMA_FORM_VALUE_ACCESSOR ], }) export class JsonSchemaFormComponent implements ControlValueAccessor, OnChanges, OnInit { debugOutput: any; // Debug information, if requested diff --git a/projects/ajsf-core/src/lib/json-schema-form.service.ts b/projects/ajsf-core/src/lib/json-schema-form.service.ts index c220335a..384acc7e 100755 --- a/projects/ajsf-core/src/lib/json-schema-form.service.ts +++ b/projects/ajsf-core/src/lib/json-schema-form.service.ts @@ -50,9 +50,7 @@ export interface ErrorMessages { }[]; } -@Injectable({ - providedIn: 'root', -}) +@Injectable() export class JsonSchemaFormService { JsonFormCompatibility = false; ReactJsonSchemaFormCompatibility = false; diff --git a/projects/ajsf-material/package.json b/projects/ajsf-material/package.json index e04c565d..5fb71293 100644 --- a/projects/ajsf-material/package.json +++ b/projects/ajsf-material/package.json @@ -1,6 +1,6 @@ { "name": "@ajsf/material", - "version": "0.5.1-beta.2", + "version": "0.5.1-beta.3", "description": "Angular JSON Schema Form builder using Angular Material UI", "author": "https://github.com/hamzahamidi/ajsf/graphs/contributors", "keywords": [ @@ -29,7 +29,7 @@ "private": false, "dependencies": { "lodash-es": "~4.17.21", - "@ajsf/core": "~0.5.1-beta.2", + "@ajsf/core": "~0.5.1-beta.3", "tslib": "^2.0.0" }, "peerDependencies": { diff --git a/projects/ajsf-material/src/lib/material-design-framework.component.spec.ts b/projects/ajsf-material/src/lib/material-design-framework.component.spec.ts index 3e361ce7..dcc04263 100644 --- a/projects/ajsf-material/src/lib/material-design-framework.component.spec.ts +++ b/projects/ajsf-material/src/lib/material-design-framework.component.spec.ts @@ -2,6 +2,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { CommonModule } from '@angular/common'; import { JsonSchemaFormModule, + JsonSchemaFormService, WidgetLibraryModule } from '@ajsf/core'; import { MaterialDesignFrameworkComponent } from './material-design-framework.component'; @@ -17,7 +18,8 @@ describe('FwBootstrap4Component', () => { CommonModule, WidgetLibraryModule, ], - declarations: [MaterialDesignFrameworkComponent] + declarations: [MaterialDesignFrameworkComponent], + providers: [JsonSchemaFormService] }) .compileComponents(); }));