@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.
Files changed (46) hide show
  1. package/README.md +3 -3
  2. package/lib/actions/actions.d.ts +21 -21
  3. package/lib/i18n/arrayTranslations.d.ts +24 -0
  4. package/lib/i18n/i18nUtil.d.ts +3 -0
  5. package/lib/i18n/index.d.ts +1 -0
  6. package/lib/jsonforms-core.cjs.js +427 -258
  7. package/lib/jsonforms-core.cjs.js.map +1 -1
  8. package/lib/jsonforms-core.esm.js +313 -200
  9. package/lib/jsonforms-core.esm.js.map +1 -1
  10. package/lib/util/cell.d.ts +0 -1
  11. package/lib/util/renderer.d.ts +6 -2
  12. package/package.json +11 -4
  13. package/src/Helpers.ts +1 -1
  14. package/src/actions/actions.ts +52 -55
  15. package/src/configDefault.ts +1 -1
  16. package/src/generators/Generate.ts +3 -1
  17. package/src/generators/schema.ts +29 -25
  18. package/src/generators/uischema.ts +7 -6
  19. package/src/i18n/arrayTranslations.ts +54 -0
  20. package/src/i18n/i18nTypes.ts +10 -6
  21. package/src/i18n/i18nUtil.ts +64 -14
  22. package/src/i18n/index.ts +1 -0
  23. package/src/models/draft4.ts +33 -33
  24. package/src/models/uischema.ts +17 -6
  25. package/src/reducers/cells.ts +8 -7
  26. package/src/reducers/core.ts +112 -73
  27. package/src/reducers/default-data.ts +7 -7
  28. package/src/reducers/i18n.ts +21 -9
  29. package/src/reducers/reducers.ts +20 -30
  30. package/src/reducers/renderers.ts +7 -7
  31. package/src/reducers/selectors.ts +4 -5
  32. package/src/reducers/uischemas.ts +25 -24
  33. package/src/store.ts +1 -1
  34. package/src/testers/testers.ts +199 -146
  35. package/src/util/cell.ts +24 -26
  36. package/src/util/combinators.ts +5 -3
  37. package/src/util/label.ts +1 -1
  38. package/src/util/path.ts +11 -7
  39. package/src/util/renderer.ts +118 -67
  40. package/src/util/resolvers.ts +15 -13
  41. package/src/util/runtime.ts +2 -2
  42. package/src/util/schema.ts +1 -1
  43. package/src/util/type.ts +5 -3
  44. package/src/util/uischema.ts +9 -9
  45. package/src/util/util.ts +52 -52
  46. package/src/util/validator.ts +1 -1
@@ -28,14 +28,14 @@ import { isLayout, UISchemaElement } from '../models';
28
28
 
29
29
  export type IterateCallback = (uischema: UISchemaElement) => void;
30
30
 
31
- const setReadonlyPropertyValue = (value: boolean): IterateCallback => (
32
- child: UISchemaElement
33
- ): void => {
34
- if (!child.options) {
35
- child.options = {};
36
- }
37
- child.options.readonly = value;
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
- if (errors === undefined || errors === null) {
48
- return '';
49
- }
47
+ if (errors === undefined || errors === null) {
48
+ return '';
49
+ }
50
50
 
51
- return errors.join('\n');
51
+ return errors.join('\n');
52
52
  };
53
53
 
54
54
  export const hasType = (jsonSchema: JsonSchema, expected: string): boolean => {
55
- return includes(deriveTypes(jsonSchema), expected);
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
- 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
- }
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
- if (!isEmpty(jsonSchema.allOf)) {
82
- const allOfType = find(
83
- jsonSchema.allOf,
84
- (schema: JsonSchema) => deriveTypes(schema).length !== 0
85
- );
81
+ if (!isEmpty(jsonSchema.allOf)) {
82
+ const allOfType = find(
83
+ jsonSchema.allOf,
84
+ (schema: JsonSchema) => deriveTypes(schema).length !== 0
85
+ );
86
86
 
87
- if (allOfType) {
88
- return deriveTypes(allOfType);
89
- }
90
- }
91
- // ignore all remaining cases
92
- return [];
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
- schema(
100
- schema: JsonSchema,
101
- schemaPath: string,
102
- rootSchema: JsonSchema
103
- ): JsonSchema;
104
- data(data: any, path: string): any;
99
+ schema(
100
+ schema: JsonSchema,
101
+ schemaPath: string,
102
+ rootSchema: JsonSchema
103
+ ): JsonSchema;
104
+ data(data: any, path: string): any;
105
105
  } = {
106
- schema: resolveSchema,
107
- data: resolveData
106
+ schema: resolveSchema,
107
+ data: resolveData,
108
108
  };
109
109
 
110
110
  // Paths --
111
111
  const fromScoped = (scopable: Scoped): string =>
112
- toDataPathSegments(scopable.scope).join('.');
112
+ toDataPathSegments(scopable.scope).join('.');
113
113
 
114
114
  export const Paths = {
115
- compose: composePaths,
116
- fromScoped
115
+ compose: composePaths,
116
+ fromScoped,
117
117
  };
118
118
 
119
119
  // Runtime --
120
120
  export const Runtime = {
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
- }
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
  };
@@ -31,7 +31,7 @@ export const createAjv = (options?: Options) => {
31
31
  allErrors: true,
32
32
  verbose: true,
33
33
  strict: false,
34
- ...options
34
+ ...options,
35
35
  });
36
36
  addFormats(ajv);
37
37
  return ajv;