@jsonforms/angular 2.5.2 → 3.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/docs/assets/js/search.json +1 -1
- package/docs/classes/jsonforms.html +54 -33
- package/docs/classes/jsonformsabstractcontrol.html +30 -30
- package/docs/classes/jsonformsangularservice.html +33 -33
- package/docs/classes/jsonformsarraycontrol.html +30 -30
- package/docs/classes/jsonformsbaserenderer.html +4 -4
- package/docs/classes/jsonformscontrol.html +30 -30
- package/docs/classes/jsonformscontrolwithdetail.html +30 -30
- package/docs/classes/jsonformsoutlet.html +14 -14
- package/docs/globals.html +2 -2
- package/docs/index.html +1 -1
- package/lib/abstract-control.js +17 -15
- package/lib/abstract-control.js.map +1 -1
- package/lib/abstract-control.metadata.json +1 -1
- package/lib/array-control.js +1 -0
- package/lib/array-control.js.map +1 -1
- package/lib/base.renderer.js +9 -13
- package/lib/base.renderer.js.map +1 -1
- package/lib/base.renderer.metadata.json +1 -1
- package/lib/control.js +1 -0
- package/lib/control.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/index.metadata.json +1 -1
- package/lib/jsonforms-angular.js +1089 -438
- package/lib/jsonforms-angular.js.map +1 -1
- package/lib/jsonforms-root.component.d.ts +5 -4
- package/lib/jsonforms-root.component.js +37 -60
- package/lib/jsonforms-root.component.js.map +1 -1
- package/lib/jsonforms-root.component.metadata.json +1 -1
- package/lib/jsonforms.component.js +15 -14
- package/lib/jsonforms.component.js.map +1 -1
- package/lib/jsonforms.module.js +8 -8
- package/lib/jsonforms.module.js.map +1 -1
- package/lib/jsonforms.service.d.ts +3 -3
- package/lib/jsonforms.service.js +14 -10
- package/lib/jsonforms.service.js.map +1 -1
- package/lib/jsonforms.service.metadata.json +1 -1
- package/lib/unknown.component.js +7 -7
- package/lib/unknown.component.js.map +1 -1
- package/package.json +10 -10
- package/src/abstract-control.ts +6 -8
- package/src/base.renderer.ts +2 -1
- package/src/index.ts +1 -0
- package/src/jsonforms-root.component.ts +18 -9
- package/src/jsonforms.service.ts +14 -10
|
@@ -23,11 +23,10 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
import {
|
|
26
|
-
Component,
|
|
27
|
-
EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges
|
|
26
|
+
Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges
|
|
28
27
|
} from '@angular/core';
|
|
29
|
-
import { Actions, JsonFormsRendererRegistryEntry, JsonSchema, UISchemaElement, UISchemaTester, ValidationMode } from '@jsonforms/core';
|
|
30
|
-
import
|
|
28
|
+
import { Actions, JsonFormsI18nState, JsonFormsRendererRegistryEntry, JsonSchema, UISchemaElement, UISchemaTester, ValidationMode } from '@jsonforms/core';
|
|
29
|
+
import Ajv, { ErrorObject } from 'ajv';
|
|
31
30
|
import { JsonFormsAngularService, USE_STATE_VALUE } from './jsonforms.service';
|
|
32
31
|
@Component({
|
|
33
32
|
selector: 'jsonforms',
|
|
@@ -42,11 +41,11 @@ export class JsonForms implements OnChanges, OnInit {
|
|
|
42
41
|
@Input() renderers: JsonFormsRendererRegistryEntry[];
|
|
43
42
|
@Input() uischemas: { tester: UISchemaTester; uischema: UISchemaElement; }[];
|
|
44
43
|
@Output() dataChange = new EventEmitter<any>();
|
|
45
|
-
@Input() locale: string;
|
|
46
44
|
@Input() readonly: boolean;
|
|
47
45
|
@Input() validationMode: ValidationMode;
|
|
48
46
|
@Input() ajv: Ajv;
|
|
49
47
|
@Input() config: any;
|
|
48
|
+
@Input() i18n: JsonFormsI18nState;
|
|
50
49
|
@Output() errors = new EventEmitter<ErrorObject[]>();
|
|
51
50
|
|
|
52
51
|
private previousData:any;
|
|
@@ -67,7 +66,7 @@ export class JsonForms implements OnChanges, OnInit {
|
|
|
67
66
|
validationMode: this.validationMode
|
|
68
67
|
},
|
|
69
68
|
uischemas: this.uischemas,
|
|
70
|
-
i18n:
|
|
69
|
+
i18n: this.i18n,
|
|
71
70
|
renderers: this.renderers,
|
|
72
71
|
config: this.config,
|
|
73
72
|
readonly: this.readonly
|
|
@@ -87,6 +86,14 @@ export class JsonForms implements OnChanges, OnInit {
|
|
|
87
86
|
this.initialized = true;
|
|
88
87
|
}
|
|
89
88
|
|
|
89
|
+
ngDoCheck(): void {
|
|
90
|
+
// we can't use ngOnChanges as then nested i18n changes will not be detected
|
|
91
|
+
// the update will result in a no-op when the parameters did not change
|
|
92
|
+
this.jsonformsService.updateI18n(
|
|
93
|
+
Actions.updateI18n(this.i18n?.locale, this.i18n?.translate, this.i18n?.translateError)
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
90
97
|
// tslint:disable-next-line: cyclomatic-complexity
|
|
91
98
|
ngOnChanges(changes: SimpleChanges): void {
|
|
92
99
|
if (!this.initialized) {
|
|
@@ -97,7 +104,7 @@ export class JsonForms implements OnChanges, OnInit {
|
|
|
97
104
|
const newUiSchema = changes.uischema;
|
|
98
105
|
const newRenderers = changes.renderers;
|
|
99
106
|
const newUischemas = changes.uischemas;
|
|
100
|
-
const
|
|
107
|
+
const newI18n = changes.i18n;
|
|
101
108
|
const newReadonly = changes.readonly;
|
|
102
109
|
const newValidationMode = changes.validationMode;
|
|
103
110
|
const newAjv = changes.ajv;
|
|
@@ -121,8 +128,10 @@ export class JsonForms implements OnChanges, OnInit {
|
|
|
121
128
|
this.jsonformsService.setUiSchemas(newUischemas.currentValue);
|
|
122
129
|
}
|
|
123
130
|
|
|
124
|
-
if (
|
|
125
|
-
this.jsonformsService.
|
|
131
|
+
if (newI18n && !newI18n.isFirstChange()) {
|
|
132
|
+
this.jsonformsService.updateI18n(
|
|
133
|
+
Actions.updateI18n(newI18n.currentValue?.locale, newI18n.currentValue?.translate, newI18n.currentValue?.translateError)
|
|
134
|
+
);
|
|
126
135
|
}
|
|
127
136
|
|
|
128
137
|
if (newReadonly && !newReadonly.isFirstChange()) {
|
package/src/jsonforms.service.ts
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
JsonFormsState,
|
|
35
35
|
JsonFormsSubStates,
|
|
36
36
|
JsonSchema,
|
|
37
|
-
|
|
37
|
+
I18nActions,
|
|
38
38
|
RankedTester,
|
|
39
39
|
setConfig,
|
|
40
40
|
SetConfigAction,
|
|
@@ -42,13 +42,14 @@ import {
|
|
|
42
42
|
UISchemaElement,
|
|
43
43
|
uischemaRegistryReducer,
|
|
44
44
|
UISchemaTester,
|
|
45
|
-
ValidationMode
|
|
45
|
+
ValidationMode,
|
|
46
|
+
updateI18n
|
|
46
47
|
} from '@jsonforms/core';
|
|
47
48
|
import { BehaviorSubject, Observable } from 'rxjs';
|
|
48
49
|
import { JsonFormsBaseRenderer } from './base.renderer';
|
|
49
50
|
|
|
50
51
|
import { cloneDeep } from 'lodash';
|
|
51
|
-
import
|
|
52
|
+
import Ajv from 'ajv';
|
|
52
53
|
|
|
53
54
|
export const USE_STATE_VALUE = Symbol('Marker to use state value');
|
|
54
55
|
export class JsonFormsAngularService {
|
|
@@ -56,9 +57,10 @@ export class JsonFormsAngularService {
|
|
|
56
57
|
private _state: JsonFormsSubStates;
|
|
57
58
|
private state: BehaviorSubject<JsonFormsState>;
|
|
58
59
|
|
|
59
|
-
init(initialState: JsonFormsSubStates = { core: { data: undefined, schema: undefined, uischema: undefined } }) {
|
|
60
|
+
init(initialState: JsonFormsSubStates = { core: { data: undefined, schema: undefined, uischema: undefined, validationMode: 'ValidateAndShow' } }) {
|
|
60
61
|
this._state = initialState;
|
|
61
62
|
this._state.config = configReducer(undefined, setConfig(this._state.config));
|
|
63
|
+
this._state.i18n = i18nReducer(this._state.i18n, updateI18n(this._state.i18n?.locale, this._state.i18n?.translate, this._state.i18n?.translateError));
|
|
62
64
|
this.state = new BehaviorSubject({ jsonforms: this._state });
|
|
63
65
|
const data = initialState.core.data;
|
|
64
66
|
const schema = initialState.core.schema ?? generateJsonSchema(data);
|
|
@@ -117,16 +119,18 @@ export class JsonFormsAngularService {
|
|
|
117
119
|
this.updateSubject();
|
|
118
120
|
}
|
|
119
121
|
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
this._state.i18n
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
updateI18n<T extends I18nActions>(i18nAction: T): T {
|
|
123
|
+
const i18nState = i18nReducer(this._state.i18n, i18nAction);
|
|
124
|
+
if (i18nState !== this._state.i18n) {
|
|
125
|
+
this._state.i18n = i18nState;
|
|
126
|
+
this.updateSubject();
|
|
127
|
+
}
|
|
128
|
+
return i18nAction;
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
updateCore<T extends CoreActions>(coreAction: T): T {
|
|
128
132
|
const coreState = coreReducer(this._state.core, coreAction);
|
|
129
|
-
if(coreState !== this._state.core) {
|
|
133
|
+
if (coreState !== this._state.core) {
|
|
130
134
|
this._state.core = coreState;
|
|
131
135
|
this.updateSubject();
|
|
132
136
|
}
|