@jsonforms/core 3.0.0-beta.1 → 3.0.0-beta.4
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 +11 -0
- package/docs/assets/js/search.json +1 -1
- package/docs/enums/ruleeffect.html +4 -4
- package/docs/globals.html +357 -217
- package/docs/index.html +29 -4
- package/docs/interfaces/addcellrendereraction.html +3 -3
- package/docs/interfaces/addrendereraction.html +3 -3
- package/docs/interfaces/adduischemaaction.html +3 -3
- package/docs/interfaces/andcondition.html +2 -2
- package/docs/interfaces/arraycontrolprops.html +21 -21
- package/docs/interfaces/arraylayoutprops.html +21 -21
- package/docs/interfaces/categorization.html +5 -5
- package/docs/interfaces/category.html +5 -5
- package/docs/interfaces/cellprops.html +12 -12
- package/docs/interfaces/combinatorrendererprops.html +143 -36
- package/docs/interfaces/composablecondition.html +2 -2
- package/docs/interfaces/condition.html +1 -1
- package/docs/interfaces/controlelement.html +22 -4
- package/docs/interfaces/controlprops.html +16 -16
- package/docs/interfaces/controlstate.html +2 -2
- package/docs/interfaces/controlwithdetailprops.html +17 -17
- package/docs/interfaces/dispatchcellprops.html +10 -10
- package/docs/interfaces/dispatchcellstateprops.html +10 -10
- package/docs/interfaces/dispatchpropsofarraycontrol.html +4 -4
- package/docs/interfaces/dispatchpropsofcontrol.html +1 -1
- package/docs/interfaces/dispatchpropsofmultienumcontrol.html +2 -2
- package/docs/interfaces/enumcellprops.html +13 -13
- package/docs/interfaces/enumoption.html +2 -2
- package/docs/interfaces/grouplayout.html +5 -5
- package/docs/interfaces/horizontallayout.html +4 -4
- package/docs/interfaces/initactionoptions.html +14 -0
- package/docs/interfaces/internationalizable.html +167 -0
- package/docs/interfaces/jsonformscore.html +17 -3
- package/docs/interfaces/jsonformsprops.html +9 -9
- package/docs/interfaces/labeldescription.html +2 -2
- package/docs/interfaces/labelelement.html +4 -4
- package/docs/interfaces/layout.html +4 -4
- package/docs/interfaces/layoutprops.html +10 -10
- package/docs/interfaces/leafcondition.html +2 -2
- package/docs/interfaces/orcondition.html +2 -2
- package/docs/interfaces/ownpropsofcell.html +9 -9
- package/docs/interfaces/ownpropsofcontrol.html +9 -12
- package/docs/interfaces/ownpropsofenum.html +1 -1
- package/docs/interfaces/ownpropsofenumcell.html +10 -10
- package/docs/interfaces/ownpropsofjsonformsrenderer.html +8 -8
- package/docs/interfaces/ownpropsoflayout.html +9 -9
- package/docs/interfaces/ownpropsofmasterlistitem.html +6 -6
- package/docs/interfaces/ownpropsofrenderer.html +8 -8
- package/docs/interfaces/registerdefaultdataaction.html +3 -3
- package/docs/interfaces/removecellrendereraction.html +3 -3
- package/docs/interfaces/removerendereraction.html +3 -3
- package/docs/interfaces/removeuischemaaction.html +2 -2
- package/docs/interfaces/rendererprops.html +9 -9
- package/docs/interfaces/rule.html +2 -2
- package/docs/interfaces/schemabasedcondition.html +2 -2
- package/docs/interfaces/setajvaction.html +2 -2
- package/docs/interfaces/setconfigaction.html +2 -2
- package/docs/interfaces/setlocaleaction.html +2 -2
- package/docs/interfaces/setschemaaction.html +2 -2
- package/docs/interfaces/settranslatoraction.html +3 -3
- package/docs/interfaces/setuischemaaction.html +2 -2
- package/docs/interfaces/setvalidationmodeaction.html +2 -2
- package/docs/interfaces/statepropsofarraycontrol.html +17 -17
- package/docs/interfaces/statepropsofarraylayout.html +17 -17
- package/docs/interfaces/statepropsofcell.html +11 -11
- package/docs/interfaces/statepropsofcombinator.html +147 -40
- package/docs/interfaces/statepropsofcontrol.html +18 -15
- package/docs/interfaces/statepropsofcontrolwithdetail.html +16 -16
- package/docs/interfaces/statepropsofenumcell.html +12 -12
- package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -9
- package/docs/interfaces/statepropsoflayout.html +10 -10
- package/docs/interfaces/statepropsofmasteritem.html +7 -7
- package/docs/interfaces/statepropsofrenderer.html +9 -9
- package/docs/interfaces/statepropsofscopedrenderer.html +12 -12
- package/docs/interfaces/uischemaelement.html +3 -3
- package/docs/interfaces/unregisterdefaultdataaction.html +2 -2
- package/docs/interfaces/updatei18naction.html +4 -4
- package/docs/interfaces/verticallayout.html +4 -4
- package/docs/interfaces/withclassname.html +1 -1
- package/lib/actions/actions.d.ts +1 -0
- package/lib/jsonforms-core.cjs.js +201 -179
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +182 -166
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/models/uischema.d.ts +10 -1
- package/lib/reducers/core.d.ts +1 -0
- package/lib/reducers/reducers.d.ts +2 -2
- package/lib/testers/testers.d.ts +8 -7
- package/lib/util/combinators.d.ts +0 -1
- package/lib/util/path.d.ts +10 -0
- package/lib/util/renderer.d.ts +2 -2
- package/lib/util/resolvers.d.ts +1 -1
- package/lib/util/util.d.ts +1 -1
- package/package.json +2 -2
- package/src/actions/actions.ts +1 -0
- package/src/generators/uischema.ts +4 -4
- package/src/i18n/i18nUtil.ts +10 -7
- package/src/models/uischema.ts +14 -1
- package/src/reducers/core.ts +30 -3
- package/src/reducers/reducers.ts +12 -4
- package/src/testers/testers.ts +61 -34
- package/src/util/combinators.ts +17 -32
- package/src/util/label.ts +2 -2
- package/src/util/path.ts +18 -6
- package/src/util/renderer.ts +20 -32
- package/src/util/resolvers.ts +57 -68
- package/src/util/util.ts +1 -1
- package/stats.html +1 -1
- package/test/generators/uischema.test.ts +18 -0
- package/test/i18n/i18nUtil.test.ts +41 -1
- package/test/reducers/core.test.ts +203 -1
- package/test/testers.test.ts +208 -120
- package/test/util/path.test.ts +37 -20
- package/test/util/renderer.test.ts +1 -1
- package/test/util/resolvers.test.ts +99 -8
package/test/util/path.test.ts
CHANGED
|
@@ -35,7 +35,7 @@ test('resolve ', t => {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
t.deepEqual(Resolve.schema(schema, '#/properties/foo'), {
|
|
38
|
+
t.deepEqual(Resolve.schema(schema, '#/properties/foo', schema), {
|
|
39
39
|
type: 'integer'
|
|
40
40
|
});
|
|
41
41
|
});
|
|
@@ -46,12 +46,39 @@ test('toDataPath ', t => {
|
|
|
46
46
|
test('toDataPath replace anyOf', t => {
|
|
47
47
|
t.is(toDataPath('/anyOf/1/properties/foo/anyOf/1/properties/bar'), 'foo.bar');
|
|
48
48
|
});
|
|
49
|
+
test('toDataPath replace anyOf in combination with conditional schema compositions', t => {
|
|
50
|
+
t.is(toDataPath('/anyOf/1/then/properties/foo'), 'foo');
|
|
51
|
+
});
|
|
52
|
+
test('toDataPath replace multiple directly nested anyOf in combination with conditional schema compositions', t => {
|
|
53
|
+
t.is(toDataPath('/anyOf/1/then/anyOf/0/then/properties/foo'), 'foo');
|
|
54
|
+
});
|
|
55
|
+
test('toDataPath replace multiple nested properties with anyOf in combination with conditional schema compositions', t => {
|
|
56
|
+
t.is(toDataPath('/anyOf/1/properties/foo/anyOf/0/then/properties/bar'), 'foo.bar');
|
|
57
|
+
});
|
|
49
58
|
test('toDataPath replace allOf', t => {
|
|
50
59
|
t.is(toDataPath('/allOf/1/properties/foo/allOf/1/properties/bar'), 'foo.bar');
|
|
51
60
|
});
|
|
61
|
+
test('toDataPath replace allOf in combination with conditional schema compositions', t => {
|
|
62
|
+
t.is(toDataPath('/allOf/1/then/properties/foo'), 'foo');
|
|
63
|
+
});
|
|
64
|
+
test('toDataPath replace multiple directly nested allOf in combination with conditional schema compositions', t => {
|
|
65
|
+
t.is(toDataPath('/allOf/1/then/allOf/0/then/properties/foo'), 'foo');
|
|
66
|
+
});
|
|
67
|
+
test('toDataPath replace multiple nested properties with allOf in combination with conditional schema compositions', t => {
|
|
68
|
+
t.is(toDataPath('/allOf/1/properties/foo/allOf/0/then/properties/bar'), 'foo.bar');
|
|
69
|
+
});
|
|
52
70
|
test('toDataPath replace oneOf', t => {
|
|
53
71
|
t.is(toDataPath('/oneOf/1/properties/foo/oneOf/1/properties/bar'), 'foo.bar');
|
|
54
72
|
});
|
|
73
|
+
test('toDataPath replace oneOf in combination with conditional schema compositions', t => {
|
|
74
|
+
t.is(toDataPath('/oneOf/1/then/properties/foo'), 'foo');
|
|
75
|
+
});
|
|
76
|
+
test('toDataPath replace multiple directly nested oneOf in combination with conditional schema compositions', t => {
|
|
77
|
+
t.is(toDataPath('/oneOf/1/then/oneOf/0/then/properties/foo'), 'foo');
|
|
78
|
+
});
|
|
79
|
+
test('toDataPath replace multiple nested properties with oneOf in combination with conditional schema compositions', t => {
|
|
80
|
+
t.is(toDataPath('/oneOf/1/properties/foo/oneOf/0/then/properties/bar'), 'foo.bar');
|
|
81
|
+
});
|
|
55
82
|
test('toDataPath replace all combinators', t => {
|
|
56
83
|
t.is(
|
|
57
84
|
toDataPath(
|
|
@@ -87,6 +114,9 @@ test('toDataPath use of encoded paths relative without /', t => {
|
|
|
87
114
|
const fooBar = encodeURIComponent('foo/bar');
|
|
88
115
|
t.is(toDataPath(`properties/${fooBar}`), `${fooBar}`);
|
|
89
116
|
});
|
|
117
|
+
test('toDataPath use of encoded special character in pathname', t => {
|
|
118
|
+
t.is(toDataPath('properties/foo~0bar~1baz'), 'foo~bar/baz');
|
|
119
|
+
});
|
|
90
120
|
test('resolve instance', t => {
|
|
91
121
|
const instance = { foo: 123 };
|
|
92
122
|
const result = Resolve.data(instance, toDataPath('#/properties/foo'));
|
|
@@ -136,10 +166,10 @@ test('resolve $ref', t => {
|
|
|
136
166
|
}
|
|
137
167
|
}
|
|
138
168
|
};
|
|
139
|
-
const result = Resolve.schema(schema, '#/properties/foos/items');
|
|
169
|
+
const result = Resolve.schema(schema, '#/properties/foos/items', schema);
|
|
140
170
|
t.deepEqual(result, { type: 'string' });
|
|
141
171
|
});
|
|
142
|
-
test
|
|
172
|
+
test('resolve $ref simple', t => {
|
|
143
173
|
const schema: JsonSchema = {
|
|
144
174
|
definitions: {
|
|
145
175
|
foo: {
|
|
@@ -164,21 +194,21 @@ test.failing('resolve $ref simple', t => {
|
|
|
164
194
|
}
|
|
165
195
|
}
|
|
166
196
|
};
|
|
167
|
-
const result = Resolve.schema(schema, '#/properties/foos/items');
|
|
197
|
+
const result = Resolve.schema(schema, '#/properties/foos/items', schema);
|
|
168
198
|
t.deepEqual(result, {
|
|
169
199
|
type: 'object',
|
|
170
200
|
properties: {
|
|
171
201
|
bar: {
|
|
172
202
|
type: 'array',
|
|
173
203
|
items: {
|
|
174
|
-
$ref: '
|
|
204
|
+
$ref: '#/definitions/foo'
|
|
175
205
|
}
|
|
176
206
|
}
|
|
177
207
|
}
|
|
178
208
|
});
|
|
179
209
|
t.not((schema.definitions.foo.properties.bar.items as JsonSchema).$ref, '#');
|
|
180
210
|
});
|
|
181
|
-
test
|
|
211
|
+
test('resolve $ref complicated', t => {
|
|
182
212
|
const schema: JsonSchema = {
|
|
183
213
|
definitions: {
|
|
184
214
|
foo: {
|
|
@@ -214,21 +244,8 @@ test.failing('resolve $ref complicated', t => {
|
|
|
214
244
|
}
|
|
215
245
|
}
|
|
216
246
|
};
|
|
217
|
-
const result = Resolve.schema(schema, '#/properties/foos/items');
|
|
247
|
+
const result = Resolve.schema(schema, '#/properties/foos/items', schema);
|
|
218
248
|
t.deepEqual(result, {
|
|
219
|
-
definitions: {
|
|
220
|
-
foo2: {
|
|
221
|
-
type: 'object',
|
|
222
|
-
properties: {
|
|
223
|
-
bar: {
|
|
224
|
-
type: 'array',
|
|
225
|
-
items: {
|
|
226
|
-
$ref: '#'
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
249
|
type: 'object',
|
|
233
250
|
properties: {
|
|
234
251
|
bar: {
|
|
@@ -1344,7 +1344,7 @@ test('mapStateToControlProps - i18n - translation via UI Schema i18n key', t =>
|
|
|
1344
1344
|
};
|
|
1345
1345
|
const state: JsonFormsState = createState(coreUISchema);
|
|
1346
1346
|
state.jsonforms.i18n = defaultJsonFormsI18nState;
|
|
1347
|
-
ownProps.uischema = {...ownProps.uischema,
|
|
1347
|
+
ownProps.uischema = {...ownProps.uischema, i18n: 'my-key'};
|
|
1348
1348
|
state.jsonforms.i18n.translate = (key: string, defaultMessage: string | undefined) => {
|
|
1349
1349
|
switch(key){
|
|
1350
1350
|
case 'my-key.label': return 'my label';
|
|
@@ -27,6 +27,29 @@ import test from 'ava';
|
|
|
27
27
|
|
|
28
28
|
test('resolveSchema - resolves schema with any ', t => {
|
|
29
29
|
const schema = {
|
|
30
|
+
$defs: {
|
|
31
|
+
Base: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
width: {
|
|
35
|
+
type: 'integer'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
Child: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
allOf: [
|
|
42
|
+
{ $ref: '#/$defs/Base' },
|
|
43
|
+
{
|
|
44
|
+
properties: {
|
|
45
|
+
geometry: {
|
|
46
|
+
type: 'string'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
30
53
|
type: 'object',
|
|
31
54
|
properties: {
|
|
32
55
|
description: {
|
|
@@ -51,16 +74,84 @@ test('resolveSchema - resolves schema with any ', t => {
|
|
|
51
74
|
type: 'boolean'
|
|
52
75
|
}
|
|
53
76
|
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties: {
|
|
81
|
+
element: {
|
|
82
|
+
$ref: '#/$defs/Child'
|
|
83
|
+
}
|
|
84
|
+
}
|
|
54
85
|
}]
|
|
55
86
|
}
|
|
56
|
-
}
|
|
87
|
+
},
|
|
88
|
+
anyOf: [
|
|
89
|
+
{
|
|
90
|
+
if: {
|
|
91
|
+
properties: {
|
|
92
|
+
exist: {
|
|
93
|
+
const: true
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
then: {
|
|
98
|
+
properties: {
|
|
99
|
+
lastname: {
|
|
100
|
+
type: 'string'
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
else: {
|
|
105
|
+
properties: {
|
|
106
|
+
firstname: {
|
|
107
|
+
type: 'string'
|
|
108
|
+
},
|
|
109
|
+
address: {
|
|
110
|
+
type: 'object',
|
|
111
|
+
anyOf: [
|
|
112
|
+
{
|
|
113
|
+
properties: {
|
|
114
|
+
street: {
|
|
115
|
+
type: 'string'
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
]
|
|
57
125
|
};
|
|
58
126
|
// test backward compatibility
|
|
59
|
-
t.deepEqual(resolveSchema(schema, '#/properties/description/oneOf/0/properties/name'), {type: 'string'});
|
|
60
|
-
t.deepEqual(resolveSchema(schema, '#/properties/description/oneOf/1/properties/index'), {type: 'number'});
|
|
127
|
+
t.deepEqual(resolveSchema(schema, '#/properties/description/oneOf/0/properties/name', schema), {type: 'string'});
|
|
128
|
+
t.deepEqual(resolveSchema(schema, '#/properties/description/oneOf/1/properties/index', schema), {type: 'number'});
|
|
129
|
+
t.deepEqual(resolveSchema(schema, '#/anyOf/0/then/properties/lastname', schema), {type: 'string'});
|
|
130
|
+
t.deepEqual(resolveSchema(schema, '#/anyOf/0/else/properties/firstname', schema), {type: 'string'});
|
|
131
|
+
t.deepEqual(resolveSchema(schema, '#/anyOf/0/else/properties/address/anyOf/0/properties/street', schema), {type: 'string'});
|
|
61
132
|
// new simple approach
|
|
62
|
-
t.deepEqual(resolveSchema(schema, '#/properties/description/properties/name'), {type: 'string'});
|
|
63
|
-
t.deepEqual(resolveSchema(schema, '#/properties/description/properties/index'), {type: 'number'});
|
|
64
|
-
t.deepEqual(resolveSchema(schema, '#/properties/description/properties/exist'), {type: 'boolean'});
|
|
65
|
-
t.
|
|
66
|
-
});
|
|
133
|
+
t.deepEqual(resolveSchema(schema, '#/properties/description/properties/name', schema), {type: 'string'});
|
|
134
|
+
t.deepEqual(resolveSchema(schema, '#/properties/description/properties/index', schema), {type: 'number'});
|
|
135
|
+
t.deepEqual(resolveSchema(schema, '#/properties/description/properties/exist', schema), {type: 'boolean'});
|
|
136
|
+
t.deepEqual(resolveSchema(schema, '#/properties/lastname', schema), {type: 'string'});
|
|
137
|
+
t.deepEqual(resolveSchema(schema, '#/properties/firstname', schema), {type: 'string'});
|
|
138
|
+
t.deepEqual(resolveSchema(schema, '#/properties/address/properties/street', schema), {type: 'string'});
|
|
139
|
+
t.is(resolveSchema(schema, '#/properties/description/properties/notfound', schema), undefined);
|
|
140
|
+
// refs
|
|
141
|
+
t.deepEqual(resolveSchema(schema, '#/properties/description/properties/element/properties/geometry', schema), {type: 'string'});
|
|
142
|
+
t.deepEqual(resolveSchema(schema, '#/properties/description/properties/element/properties/width', schema), {type: 'integer'});
|
|
143
|
+
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test('resolveSchema - resolves schema with encoded characters', t => {
|
|
147
|
+
const schema = {
|
|
148
|
+
type: 'object',
|
|
149
|
+
properties: {
|
|
150
|
+
'foo / ~ bar': {
|
|
151
|
+
type: 'integer'
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
t.deepEqual(resolveSchema(schema, '#/properties/foo ~1 ~0 bar', schema), {type: 'integer'});
|
|
156
|
+
t.is(resolveSchema(schema, '#/properties/foo / bar', schema), undefined);
|
|
157
|
+
});
|