@jsonforms/core 3.1.0-alpha.1 → 3.1.0-alpha.2
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 +3 -3
- package/lib/actions/actions.d.ts +21 -21
- package/lib/i18n/arrayTranslations.d.ts +24 -0
- package/lib/i18n/i18nUtil.d.ts +3 -0
- package/lib/i18n/index.d.ts +1 -0
- package/lib/jsonforms-core.cjs.js +427 -258
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +313 -200
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/util/cell.d.ts +0 -1
- package/lib/util/renderer.d.ts +6 -2
- package/package.json +11 -4
- package/src/Helpers.ts +1 -1
- package/src/actions/actions.ts +52 -55
- package/src/configDefault.ts +1 -1
- package/src/generators/Generate.ts +3 -1
- package/src/generators/schema.ts +29 -25
- package/src/generators/uischema.ts +7 -6
- package/src/i18n/arrayTranslations.ts +54 -0
- package/src/i18n/i18nTypes.ts +10 -6
- package/src/i18n/i18nUtil.ts +64 -14
- package/src/i18n/index.ts +1 -0
- package/src/models/draft4.ts +33 -33
- package/src/models/uischema.ts +17 -6
- package/src/reducers/cells.ts +8 -7
- package/src/reducers/core.ts +112 -73
- package/src/reducers/default-data.ts +7 -7
- package/src/reducers/i18n.ts +21 -9
- package/src/reducers/reducers.ts +20 -30
- package/src/reducers/renderers.ts +7 -7
- package/src/reducers/selectors.ts +4 -5
- package/src/reducers/uischemas.ts +25 -24
- package/src/store.ts +1 -1
- package/src/testers/testers.ts +199 -146
- package/src/util/cell.ts +24 -26
- package/src/util/combinators.ts +5 -3
- package/src/util/label.ts +1 -1
- package/src/util/path.ts +11 -7
- package/src/util/renderer.ts +118 -67
- package/src/util/resolvers.ts +15 -13
- package/src/util/runtime.ts +2 -2
- package/src/util/schema.ts +1 -1
- package/src/util/type.ts +5 -3
- package/src/util/uischema.ts +9 -9
- package/src/util/util.ts +52 -52
- package/src/util/validator.ts +1 -1
package/src/util/uischema.ts
CHANGED
|
@@ -28,14 +28,14 @@ import { isLayout, UISchemaElement } from '../models';
|
|
|
28
28
|
|
|
29
29
|
export type IterateCallback = (uischema: UISchemaElement) => void;
|
|
30
30
|
|
|
31
|
-
const setReadonlyPropertyValue =
|
|
32
|
-
|
|
33
|
-
): void => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
31
|
+
const setReadonlyPropertyValue =
|
|
32
|
+
(value: boolean): IterateCallback =>
|
|
33
|
+
(child: UISchemaElement): void => {
|
|
34
|
+
if (!child.options) {
|
|
35
|
+
child.options = {};
|
|
36
|
+
}
|
|
37
|
+
child.options.readonly = value;
|
|
38
|
+
};
|
|
39
39
|
export const setReadonly = (uischema: UISchemaElement): void => {
|
|
40
40
|
iterateSchema(uischema, setReadonlyPropertyValue(true));
|
|
41
41
|
};
|
|
@@ -50,7 +50,7 @@ export const iterateSchema = (
|
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
if (isLayout(uischema)) {
|
|
53
|
-
uischema.elements.forEach(child => iterateSchema(child, toApply));
|
|
53
|
+
uischema.elements.forEach((child) => iterateSchema(child, toApply));
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
toApply(uischema);
|
package/src/util/util.ts
CHANGED
|
@@ -41,87 +41,87 @@ import type Ajv from 'ajv';
|
|
|
41
41
|
* @returns {string} the escaped string
|
|
42
42
|
*/
|
|
43
43
|
export const convertToValidClassName = (s: string): string =>
|
|
44
|
-
s.replace('#', 'root').replace(new RegExp('/', 'g'), '_');
|
|
44
|
+
s.replace('#', 'root').replace(new RegExp('/', 'g'), '_');
|
|
45
45
|
|
|
46
46
|
export const formatErrorMessage = (errors: string[]) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
if (errors === undefined || errors === null) {
|
|
48
|
+
return '';
|
|
49
|
+
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
return errors.join('\n');
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
export const hasType = (jsonSchema: JsonSchema, expected: string): boolean => {
|
|
55
|
-
|
|
55
|
+
return includes(deriveTypes(jsonSchema), expected);
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* Derives the type of the jsonSchema element
|
|
60
60
|
*/
|
|
61
61
|
export const deriveTypes = (jsonSchema: JsonSchema): string[] => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
62
|
+
if (isEmpty(jsonSchema)) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
if (!isEmpty(jsonSchema.type) && typeof jsonSchema.type === 'string') {
|
|
66
|
+
return [jsonSchema.type];
|
|
67
|
+
}
|
|
68
|
+
if (isArray(jsonSchema.type)) {
|
|
69
|
+
return jsonSchema.type;
|
|
70
|
+
}
|
|
71
|
+
if (
|
|
72
|
+
!isEmpty(jsonSchema.properties) ||
|
|
73
|
+
!isEmpty(jsonSchema.additionalProperties)
|
|
74
|
+
) {
|
|
75
|
+
return ['object'];
|
|
76
|
+
}
|
|
77
|
+
if (!isEmpty(jsonSchema.items)) {
|
|
78
|
+
return ['array'];
|
|
79
|
+
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
if (!isEmpty(jsonSchema.allOf)) {
|
|
82
|
+
const allOfType = find(
|
|
83
|
+
jsonSchema.allOf,
|
|
84
|
+
(schema: JsonSchema) => deriveTypes(schema).length !== 0
|
|
85
|
+
);
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
if (allOfType) {
|
|
88
|
+
return deriveTypes(allOfType);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// ignore all remaining cases
|
|
92
|
+
return [];
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Convenience wrapper around resolveData and resolveSchema.
|
|
97
97
|
*/
|
|
98
98
|
export const Resolve: {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
schema(
|
|
100
|
+
schema: JsonSchema,
|
|
101
|
+
schemaPath: string,
|
|
102
|
+
rootSchema: JsonSchema
|
|
103
|
+
): JsonSchema;
|
|
104
|
+
data(data: any, path: string): any;
|
|
105
105
|
} = {
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
schema: resolveSchema,
|
|
107
|
+
data: resolveData,
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
// Paths --
|
|
111
111
|
const fromScoped = (scopable: Scoped): string =>
|
|
112
|
-
|
|
112
|
+
toDataPathSegments(scopable.scope).join('.');
|
|
113
113
|
|
|
114
114
|
export const Paths = {
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
compose: composePaths,
|
|
116
|
+
fromScoped,
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
// Runtime --
|
|
120
120
|
export const Runtime = {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
121
|
+
isEnabled(uischema: UISchemaElement, data: any, ajv: Ajv): boolean {
|
|
122
|
+
return isEnabled(uischema, data, undefined, ajv);
|
|
123
|
+
},
|
|
124
|
+
isVisible(uischema: UISchemaElement, data: any, ajv: Ajv): boolean {
|
|
125
|
+
return isVisible(uischema, data, undefined, ajv);
|
|
126
|
+
},
|
|
127
127
|
};
|