@jsonforms/core 3.1.0-alpha.0 → 3.1.0-alpha.1
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/lib/Helpers.d.ts +1 -1
- package/lib/actions/actions.d.ts +6 -5
- package/lib/generators/Generate.d.ts +1 -1
- package/lib/generators/schema.d.ts +1 -1
- package/lib/i18n/i18nTypes.d.ts +3 -2
- package/lib/i18n/i18nUtil.d.ts +2 -2
- package/lib/jsonforms-core.cjs.js +3 -3
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +2 -2
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/models/jsonSchema.d.ts +2 -2
- package/lib/models/uischema.d.ts +1 -1
- package/lib/reducers/cells.d.ts +2 -2
- package/lib/reducers/config.d.ts +1 -1
- package/lib/reducers/core.d.ts +3 -2
- package/lib/reducers/default-data.d.ts +1 -1
- package/lib/reducers/i18n.d.ts +1 -1
- package/lib/reducers/reducers.d.ts +4 -4
- package/lib/reducers/renderers.d.ts +2 -2
- package/lib/reducers/selectors.d.ts +6 -6
- package/lib/reducers/uischemas.d.ts +2 -2
- package/lib/store.d.ts +3 -3
- package/lib/testers/testers.d.ts +1 -1
- package/lib/util/cell.d.ts +3 -3
- package/lib/util/combinators.d.ts +1 -1
- package/lib/util/label.d.ts +1 -1
- package/lib/util/path.d.ts +6 -3
- package/lib/util/renderer.d.ts +5 -5
- package/lib/util/resolvers.d.ts +1 -1
- package/lib/util/runtime.d.ts +2 -2
- package/lib/util/util.d.ts +2 -2
- package/lib/util/validator.d.ts +1 -1
- package/package.json +7 -3
- package/src/Helpers.ts +1 -1
- package/src/actions/actions.ts +6 -5
- package/src/generators/Generate.ts +1 -1
- package/src/generators/schema.ts +1 -1
- package/src/i18n/i18nTypes.ts +3 -2
- package/src/i18n/i18nUtil.ts +2 -2
- package/src/models/jsonSchema.ts +2 -2
- package/src/models/uischema.ts +1 -1
- package/src/reducers/cells.ts +2 -2
- package/src/reducers/config.ts +1 -1
- package/src/reducers/core.ts +4 -3
- package/src/reducers/default-data.ts +1 -1
- package/src/reducers/i18n.ts +1 -1
- package/src/reducers/reducers.ts +4 -4
- package/src/reducers/renderers.ts +2 -2
- package/src/reducers/selectors.ts +6 -6
- package/src/reducers/uischemas.ts +2 -2
- package/src/store.ts +3 -3
- package/src/testers/testers.ts +2 -2
- package/src/util/cell.ts +3 -3
- package/src/util/combinators.ts +1 -1
- package/src/util/label.ts +1 -1
- package/src/util/path.ts +6 -3
- package/src/util/renderer.ts +5 -5
- package/src/util/resolvers.ts +2 -2
- package/src/util/runtime.ts +2 -2
- package/src/util/util.ts +2 -2
- package/src/util/validator.ts +1 -1
- package/.nycrc +0 -6
- package/docs/assets/css/main.css +0 -1
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -51
- package/docs/assets/js/search.json +0 -1
- package/docs/classes/gen.html +0 -406
- package/docs/enums/ruleeffect.html +0 -214
- package/docs/globals.html +0 -10568
- package/docs/index.html +0 -1297
- package/docs/interfaces/action.html +0 -166
- package/docs/interfaces/addcellrendereraction.html +0 -181
- package/docs/interfaces/addrendereraction.html +0 -181
- package/docs/interfaces/adduischemaaction.html +0 -181
- package/docs/interfaces/andcondition.html +0 -181
- package/docs/interfaces/anyaction.html +0 -189
- package/docs/interfaces/arraycontrolprops.html +0 -653
- package/docs/interfaces/arraylayoutprops.html +0 -648
- package/docs/interfaces/categorization.html +0 -281
- package/docs/interfaces/category.html +0 -279
- package/docs/interfaces/cellprops.html +0 -452
- package/docs/interfaces/combinatorrendererprops.html +0 -503
- package/docs/interfaces/combinatorsubschemarenderinfo.html +0 -181
- package/docs/interfaces/composablecondition.html +0 -193
- package/docs/interfaces/condition.html +0 -176
- package/docs/interfaces/controlelement.html +0 -280
- package/docs/interfaces/controlprops.html +0 -497
- package/docs/interfaces/controlstate.html +0 -184
- package/docs/interfaces/controlwithdetailprops.html +0 -501
- package/docs/interfaces/dispatchcellprops.html +0 -388
- package/docs/interfaces/dispatchcellstateprops.html +0 -408
- package/docs/interfaces/dispatchpropsofarraycontrol.html +0 -322
- package/docs/interfaces/dispatchpropsofcontrol.html +0 -204
- package/docs/interfaces/dispatchpropsofmultienumcontrol.html +0 -215
- package/docs/interfaces/enumcellprops.html +0 -467
- package/docs/interfaces/enumoption.html +0 -167
- package/docs/interfaces/formatted.html +0 -226
- package/docs/interfaces/grouplayout.html +0 -284
- package/docs/interfaces/horizontallayout.html +0 -234
- package/docs/interfaces/initaction.html +0 -209
- package/docs/interfaces/initactionoptions.html +0 -181
- package/docs/interfaces/internationalizable.html +0 -170
- package/docs/interfaces/jsonformscellrendererregistryentry.html +0 -167
- package/docs/interfaces/jsonformscore.html +0 -251
- package/docs/interfaces/jsonformsdefaultdataregistryentry.html +0 -167
- package/docs/interfaces/jsonformsextendedstate.html +0 -175
- package/docs/interfaces/jsonformsi18nstate.html +0 -181
- package/docs/interfaces/jsonformsprops.html +0 -321
- package/docs/interfaces/jsonformsrendererregistryentry.html +0 -167
- package/docs/interfaces/jsonformsstate.html +0 -170
- package/docs/interfaces/jsonformsstore.html +0 -376
- package/docs/interfaces/jsonformssubstates.html +0 -276
- package/docs/interfaces/jsonformsuischemaregistryentry.html +0 -167
- package/docs/interfaces/jsonschema4.html +0 -758
- package/docs/interfaces/jsonschema7.html +0 -884
- package/docs/interfaces/labelable.html +0 -184
- package/docs/interfaces/labeldescription.html +0 -184
- package/docs/interfaces/labeled.html +0 -182
- package/docs/interfaces/labelelement.html +0 -251
- package/docs/interfaces/labelprops.html +0 -339
- package/docs/interfaces/layout.html +0 -253
- package/docs/interfaces/layoutprops.html +0 -359
- package/docs/interfaces/leafcondition.html +0 -209
- package/docs/interfaces/orcondition.html +0 -181
- package/docs/interfaces/ownpropsofcell.html +0 -321
- package/docs/interfaces/ownpropsofcontrol.html +0 -305
- package/docs/interfaces/ownpropsofenum.html +0 -161
- package/docs/interfaces/ownpropsofenumcell.html +0 -335
- package/docs/interfaces/ownpropsofjsonformsrenderer.html +0 -296
- package/docs/interfaces/ownpropsoflabel.html +0 -286
- package/docs/interfaces/ownpropsoflayout.html +0 -305
- package/docs/interfaces/ownpropsofmasterlistitem.html +0 -289
- package/docs/interfaces/ownpropsofrenderer.html +0 -292
- package/docs/interfaces/referenceschemamap.html +0 -138
- package/docs/interfaces/registerdefaultdataaction.html +0 -181
- package/docs/interfaces/removecellrendereraction.html +0 -181
- package/docs/interfaces/removerendereraction.html +0 -181
- package/docs/interfaces/removeuischemaaction.html +0 -167
- package/docs/interfaces/rendererprops.html +0 -331
- package/docs/interfaces/rule.html +0 -185
- package/docs/interfaces/schemabasedcondition.html +0 -202
- package/docs/interfaces/scopable.html +0 -171
- package/docs/interfaces/scoped.html +0 -183
- package/docs/interfaces/setajvaction.html +0 -167
- package/docs/interfaces/setconfigaction.html +0 -167
- package/docs/interfaces/setlocaleaction.html +0 -167
- package/docs/interfaces/setschemaaction.html +0 -167
- package/docs/interfaces/settranslatoraction.html +0 -181
- package/docs/interfaces/setuischemaaction.html +0 -167
- package/docs/interfaces/setvalidationmodeaction.html +0 -167
- package/docs/interfaces/statepropsofarraycontrol.html +0 -474
- package/docs/interfaces/statepropsofarraylayout.html +0 -461
- package/docs/interfaces/statepropsofcell.html +0 -408
- package/docs/interfaces/statepropsofcombinator.html +0 -449
- package/docs/interfaces/statepropsofcontrol.html +0 -451
- package/docs/interfaces/statepropsofcontrolwithdetail.html +0 -463
- package/docs/interfaces/statepropsofenumcell.html +0 -422
- package/docs/interfaces/statepropsofjsonformsrenderer.html +0 -324
- package/docs/interfaces/statepropsoflabel.html +0 -343
- package/docs/interfaces/statepropsoflayout.html +0 -369
- package/docs/interfaces/statepropsofmasteritem.html +0 -309
- package/docs/interfaces/statepropsofrenderer.html +0 -331
- package/docs/interfaces/statepropsofscopedrenderer.html +0 -391
- package/docs/interfaces/store.html +0 -386
- package/docs/interfaces/testercontext.html +0 -184
- package/docs/interfaces/uischemaelement.html +0 -225
- package/docs/interfaces/unregisterdefaultdataaction.html +0 -167
- package/docs/interfaces/updateaction.html +0 -202
- package/docs/interfaces/updatecoreaction.html +0 -209
- package/docs/interfaces/updateerrorsaction.html +0 -167
- package/docs/interfaces/updatei18naction.html +0 -195
- package/docs/interfaces/verticallayout.html +0 -234
- package/docs/interfaces/withclassname.html +0 -153
- package/rollup.config.js +0 -44
- package/stats.html +0 -3279
- package/test/actions/actions.test.ts +0 -93
- package/test/generators/schema.test.ts +0 -224
- package/test/generators/uischema.test.ts +0 -576
- package/test/i18n/i18nUtil.test.ts +0 -88
- package/test/reducers/core.test.ts +0 -1682
- package/test/reducers/uischemas.test.ts +0 -173
- package/test/testers.test.ts +0 -948
- package/test/util/array.test.ts +0 -28
- package/test/util/cell.test.ts +0 -354
- package/test/util/derivetype.test.ts +0 -101
- package/test/util/label.test.ts +0 -364
- package/test/util/path.test.ts +0 -259
- package/test/util/renderer.test.ts +0 -1830
- package/test/util/resolvers.test.ts +0 -157
- package/test/util/runtime.test.ts +0 -779
- package/tsconfig.json +0 -13
|
@@ -1,576 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The MIT License
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
|
-
https://github.com/eclipsesource/jsonforms
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import test from 'ava';
|
|
26
|
-
import { generateDefaultUISchema } from '../../src/generators/uischema';
|
|
27
|
-
import {
|
|
28
|
-
ControlElement,
|
|
29
|
-
Layout,
|
|
30
|
-
VerticalLayout
|
|
31
|
-
} from '../../src/models/uischema';
|
|
32
|
-
import { JsonSchema } from '../../src';
|
|
33
|
-
|
|
34
|
-
test('generate ui schema for Control element by resolving refs', t => {
|
|
35
|
-
const schema: JsonSchema = {
|
|
36
|
-
type: 'object',
|
|
37
|
-
properties: {
|
|
38
|
-
type: {
|
|
39
|
-
type: 'string',
|
|
40
|
-
const: 'Control',
|
|
41
|
-
default: 'Control'
|
|
42
|
-
},
|
|
43
|
-
label: {
|
|
44
|
-
type: 'string'
|
|
45
|
-
},
|
|
46
|
-
scope: {
|
|
47
|
-
$ref: '#/definitions/scope'
|
|
48
|
-
},
|
|
49
|
-
rule: {
|
|
50
|
-
$ref: '#/definitions/rule'
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
required: ['type', 'scope'],
|
|
54
|
-
definitions: {
|
|
55
|
-
scope: {
|
|
56
|
-
type: 'string',
|
|
57
|
-
pattern: '^#\\/properties\\/{1}'
|
|
58
|
-
},
|
|
59
|
-
rule: {
|
|
60
|
-
type: 'object',
|
|
61
|
-
properties: {
|
|
62
|
-
effect: {
|
|
63
|
-
type: 'string',
|
|
64
|
-
enum: ['HIDE', 'SHOW', 'DISABLE', 'ENABLE']
|
|
65
|
-
},
|
|
66
|
-
condition: {
|
|
67
|
-
type: 'object',
|
|
68
|
-
properties: {
|
|
69
|
-
type: {
|
|
70
|
-
type: 'string',
|
|
71
|
-
const: 'LEAF'
|
|
72
|
-
},
|
|
73
|
-
scope: {
|
|
74
|
-
$ref: '#/definitions/scope'
|
|
75
|
-
},
|
|
76
|
-
expectedValue: {
|
|
77
|
-
type: ['string', 'integer', 'number', 'boolean']
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
required: ['type', 'scope', 'expectedValue']
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
required: ['effect', 'condition']
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const typeControl: ControlElement = {
|
|
88
|
-
type: 'Control',
|
|
89
|
-
scope: '#/properties/type'
|
|
90
|
-
};
|
|
91
|
-
const labelControl: ControlElement = {
|
|
92
|
-
type: 'Control',
|
|
93
|
-
scope: '#/properties/label'
|
|
94
|
-
};
|
|
95
|
-
const scopeControl: ControlElement = {
|
|
96
|
-
type: 'Control',
|
|
97
|
-
scope: '#/properties/scope'
|
|
98
|
-
};
|
|
99
|
-
const ruleControl: ControlElement = {
|
|
100
|
-
type: 'Control',
|
|
101
|
-
scope: '#/properties/rule'
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const uischema: VerticalLayout = {
|
|
105
|
-
type: 'VerticalLayout',
|
|
106
|
-
elements: [typeControl, labelControl, scopeControl, ruleControl]
|
|
107
|
-
};
|
|
108
|
-
const generatedUiSchema = generateDefaultUISchema(schema);
|
|
109
|
-
t.deepEqual(generatedUiSchema, uischema);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
test('generate ui schema for schema w/o properties', t => {
|
|
113
|
-
const schema: JsonSchema = {
|
|
114
|
-
type: 'object'
|
|
115
|
-
};
|
|
116
|
-
const uischema: Layout = {
|
|
117
|
-
type: 'VerticalLayout',
|
|
118
|
-
elements: []
|
|
119
|
-
};
|
|
120
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
test('generate ui schema for schema with one property', t => {
|
|
124
|
-
const schema: JsonSchema = {
|
|
125
|
-
type: 'object',
|
|
126
|
-
properties: {
|
|
127
|
-
name: {
|
|
128
|
-
type: 'string'
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
const control = {
|
|
133
|
-
type: 'Control',
|
|
134
|
-
scope: '#/properties/name'
|
|
135
|
-
};
|
|
136
|
-
const uischema: Layout = {
|
|
137
|
-
type: 'VerticalLayout',
|
|
138
|
-
elements: [control]
|
|
139
|
-
};
|
|
140
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
test('generate ui schema for schema without object root', t => {
|
|
144
|
-
const schema: JsonSchema = {
|
|
145
|
-
type: 'string'
|
|
146
|
-
};
|
|
147
|
-
const control: ControlElement = {
|
|
148
|
-
type: 'Control',
|
|
149
|
-
scope: '#'
|
|
150
|
-
};
|
|
151
|
-
const uischema: Layout = {
|
|
152
|
-
type: 'VerticalLayout',
|
|
153
|
-
elements: [control]
|
|
154
|
-
};
|
|
155
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
test('generate ui schema for schema with unspecified object root', t => {
|
|
159
|
-
const schema: JsonSchema = {
|
|
160
|
-
properties: {
|
|
161
|
-
age: {
|
|
162
|
-
type: 'integer'
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
const controlElement = {
|
|
167
|
-
type: 'Control',
|
|
168
|
-
scope: '#/properties/age'
|
|
169
|
-
};
|
|
170
|
-
const uischema: Layout = {
|
|
171
|
-
type: 'VerticalLayout',
|
|
172
|
-
elements: [controlElement]
|
|
173
|
-
};
|
|
174
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
test(`nested object not expanded`, t => {
|
|
178
|
-
const schema = {
|
|
179
|
-
type: 'object',
|
|
180
|
-
properties: {
|
|
181
|
-
id: {
|
|
182
|
-
type: 'string'
|
|
183
|
-
},
|
|
184
|
-
private: {
|
|
185
|
-
type: 'object',
|
|
186
|
-
properties: {
|
|
187
|
-
name: {
|
|
188
|
-
type: 'string'
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
const idControl: ControlElement = {
|
|
195
|
-
type: 'Control',
|
|
196
|
-
scope: '#/properties/id'
|
|
197
|
-
};
|
|
198
|
-
const privateControl: ControlElement = {
|
|
199
|
-
type: 'Control',
|
|
200
|
-
scope: '#/properties/private'
|
|
201
|
-
};
|
|
202
|
-
const uischema: Layout = {
|
|
203
|
-
type: 'VerticalLayout',
|
|
204
|
-
elements: [idControl, privateControl]
|
|
205
|
-
};
|
|
206
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
test(`don't ignore non-json-schema id attributes`, t => {
|
|
210
|
-
const schema = {
|
|
211
|
-
type: 'object',
|
|
212
|
-
properties: {
|
|
213
|
-
id: {
|
|
214
|
-
type: 'string'
|
|
215
|
-
},
|
|
216
|
-
name: {
|
|
217
|
-
type: 'string'
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
const idControl: ControlElement = {
|
|
222
|
-
type: 'Control',
|
|
223
|
-
scope: '#/properties/id'
|
|
224
|
-
};
|
|
225
|
-
const nameControl: ControlElement = {
|
|
226
|
-
type: 'Control',
|
|
227
|
-
scope: '#/properties/name'
|
|
228
|
-
};
|
|
229
|
-
const uischema: Layout = {
|
|
230
|
-
type: 'VerticalLayout',
|
|
231
|
-
elements: [idControl, nameControl]
|
|
232
|
-
};
|
|
233
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
test('generate ui schema for schema with multiple properties', t => {
|
|
237
|
-
const schema: JsonSchema = {
|
|
238
|
-
type: 'object',
|
|
239
|
-
properties: {
|
|
240
|
-
id: {
|
|
241
|
-
type: 'string',
|
|
242
|
-
format: 'objectId'
|
|
243
|
-
},
|
|
244
|
-
lastName: {
|
|
245
|
-
type: 'string'
|
|
246
|
-
},
|
|
247
|
-
email: {
|
|
248
|
-
type: 'string'
|
|
249
|
-
},
|
|
250
|
-
firstName: {
|
|
251
|
-
type: 'string'
|
|
252
|
-
},
|
|
253
|
-
gender: {
|
|
254
|
-
type: 'string',
|
|
255
|
-
enum: ['Male', 'Female']
|
|
256
|
-
},
|
|
257
|
-
active: {
|
|
258
|
-
type: 'boolean'
|
|
259
|
-
},
|
|
260
|
-
registrationTime: {
|
|
261
|
-
type: 'string',
|
|
262
|
-
format: 'date-time'
|
|
263
|
-
},
|
|
264
|
-
weight: {
|
|
265
|
-
type: 'number'
|
|
266
|
-
},
|
|
267
|
-
height: {
|
|
268
|
-
type: 'integer'
|
|
269
|
-
},
|
|
270
|
-
nationality: {
|
|
271
|
-
type: 'string',
|
|
272
|
-
enum: ['German', 'French', 'UK', 'US', 'Spanish', 'Italian', 'Russian']
|
|
273
|
-
},
|
|
274
|
-
birthDate: {
|
|
275
|
-
type: 'string',
|
|
276
|
-
format: 'date-time'
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
additionalProperties: false,
|
|
280
|
-
required: ['id', 'lastName', 'email']
|
|
281
|
-
};
|
|
282
|
-
const uischema: Layout = {
|
|
283
|
-
type: 'VerticalLayout',
|
|
284
|
-
elements: [
|
|
285
|
-
{
|
|
286
|
-
type: 'Control',
|
|
287
|
-
scope: '#/properties/id'
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
type: 'Control',
|
|
291
|
-
scope: '#/properties/lastName'
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
type: 'Control',
|
|
295
|
-
scope: '#/properties/email'
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
type: 'Control',
|
|
299
|
-
scope: '#/properties/firstName'
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
type: 'Control',
|
|
303
|
-
scope: '#/properties/gender'
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
type: 'Control',
|
|
307
|
-
scope: '#/properties/active'
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
type: 'Control',
|
|
311
|
-
scope: '#/properties/registrationTime'
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
type: 'Control',
|
|
315
|
-
scope: '#/properties/weight'
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
type: 'Control',
|
|
319
|
-
scope: '#/properties/height'
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
type: 'Control',
|
|
323
|
-
scope: '#/properties/nationality'
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
type: 'Control',
|
|
327
|
-
scope: '#/properties/birthDate'
|
|
328
|
-
}
|
|
329
|
-
] as ControlElement[]
|
|
330
|
-
};
|
|
331
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
test('generate named array control', t => {
|
|
335
|
-
const schema: JsonSchema = {
|
|
336
|
-
type: 'object',
|
|
337
|
-
properties: {
|
|
338
|
-
comments: {
|
|
339
|
-
type: 'array',
|
|
340
|
-
items: {
|
|
341
|
-
properties: {
|
|
342
|
-
msg: { type: 'string' }
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
const control: ControlElement = {
|
|
349
|
-
type: 'Control',
|
|
350
|
-
scope: '#/properties/comments'
|
|
351
|
-
};
|
|
352
|
-
const uischema: Layout = {
|
|
353
|
-
type: 'VerticalLayout',
|
|
354
|
-
elements: [control]
|
|
355
|
-
};
|
|
356
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
test('generate unnamed array control', t => {
|
|
360
|
-
const schema: JsonSchema = {
|
|
361
|
-
type: 'array',
|
|
362
|
-
items: {
|
|
363
|
-
properties: {
|
|
364
|
-
msg: { type: 'string' }
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
const control: ControlElement = {
|
|
369
|
-
type: 'Control',
|
|
370
|
-
scope: '#'
|
|
371
|
-
};
|
|
372
|
-
const uischema: Layout = {
|
|
373
|
-
type: 'VerticalLayout',
|
|
374
|
-
elements: [control]
|
|
375
|
-
};
|
|
376
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
test('generate unnamed array control w/o type', t => {
|
|
380
|
-
const schema: JsonSchema = {
|
|
381
|
-
items: {
|
|
382
|
-
properties: {
|
|
383
|
-
msg: { type: 'string' }
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
};
|
|
387
|
-
const control = {
|
|
388
|
-
type: 'Control',
|
|
389
|
-
scope: '#'
|
|
390
|
-
};
|
|
391
|
-
const uischema: Layout = {
|
|
392
|
-
type: 'VerticalLayout',
|
|
393
|
-
elements: [control]
|
|
394
|
-
};
|
|
395
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
test('generate for empty schema', t => {
|
|
399
|
-
const schema: JsonSchema = {};
|
|
400
|
-
const uischema: Layout = null;
|
|
401
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
test('generate for null schema', t => {
|
|
405
|
-
const schema: JsonSchema = null;
|
|
406
|
-
const uischema: Layout = null;
|
|
407
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
test('generate for undefined schema', t => {
|
|
411
|
-
const schema: JsonSchema = undefined;
|
|
412
|
-
const uischema: Layout = null;
|
|
413
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
test('generate control for oneOf', t => {
|
|
417
|
-
const schema: JsonSchema = {
|
|
418
|
-
oneOf: [
|
|
419
|
-
{
|
|
420
|
-
properties: {
|
|
421
|
-
name: {
|
|
422
|
-
type: 'string'
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
type: 'number'
|
|
428
|
-
}
|
|
429
|
-
]
|
|
430
|
-
};
|
|
431
|
-
const control = {
|
|
432
|
-
type: 'Control',
|
|
433
|
-
scope: '#'
|
|
434
|
-
};
|
|
435
|
-
const uischema: Layout = {
|
|
436
|
-
type: 'VerticalLayout',
|
|
437
|
-
elements: [control]
|
|
438
|
-
};
|
|
439
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
test('generate control for anyOf', t => {
|
|
443
|
-
const schema: JsonSchema = {
|
|
444
|
-
anyOf: [
|
|
445
|
-
{
|
|
446
|
-
properties: {
|
|
447
|
-
name: {
|
|
448
|
-
type: 'string'
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
},
|
|
452
|
-
{
|
|
453
|
-
type: 'number'
|
|
454
|
-
}
|
|
455
|
-
]
|
|
456
|
-
};
|
|
457
|
-
const control = {
|
|
458
|
-
type: 'Control',
|
|
459
|
-
scope: '#'
|
|
460
|
-
};
|
|
461
|
-
const uischema: Layout = {
|
|
462
|
-
type: 'VerticalLayout',
|
|
463
|
-
elements: [control]
|
|
464
|
-
};
|
|
465
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
test('generate control for allOf', t => {
|
|
469
|
-
const schema: JsonSchema = {
|
|
470
|
-
allOf: [
|
|
471
|
-
{
|
|
472
|
-
properties: {
|
|
473
|
-
name: {
|
|
474
|
-
type: 'string'
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
},
|
|
478
|
-
{
|
|
479
|
-
type: 'number'
|
|
480
|
-
}
|
|
481
|
-
]
|
|
482
|
-
};
|
|
483
|
-
const control = {
|
|
484
|
-
type: 'Control',
|
|
485
|
-
scope: '#'
|
|
486
|
-
};
|
|
487
|
-
const uischema: Layout = {
|
|
488
|
-
type: 'VerticalLayout',
|
|
489
|
-
elements: [control]
|
|
490
|
-
};
|
|
491
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
test('no separate control for oneOf in array', t => {
|
|
495
|
-
const schema: JsonSchema = {
|
|
496
|
-
properties: {
|
|
497
|
-
myarray: {
|
|
498
|
-
items: {
|
|
499
|
-
oneOf: [
|
|
500
|
-
{
|
|
501
|
-
properties: {
|
|
502
|
-
name: {
|
|
503
|
-
type: 'string'
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
type: 'number'
|
|
509
|
-
}
|
|
510
|
-
]
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
};
|
|
515
|
-
const control = {
|
|
516
|
-
type: 'Control',
|
|
517
|
-
scope: '#/properties/myarray'
|
|
518
|
-
};
|
|
519
|
-
const uischema: Layout = {
|
|
520
|
-
type: 'VerticalLayout',
|
|
521
|
-
elements: [control]
|
|
522
|
-
};
|
|
523
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
test('generate control for nested oneOf', t => {
|
|
527
|
-
const schema: JsonSchema = {
|
|
528
|
-
properties: {
|
|
529
|
-
myarray: {
|
|
530
|
-
properties: {
|
|
531
|
-
nameOrAge: {
|
|
532
|
-
oneOf: [
|
|
533
|
-
{
|
|
534
|
-
properties: {
|
|
535
|
-
name: {
|
|
536
|
-
type: 'string'
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
},
|
|
540
|
-
{
|
|
541
|
-
type: 'number'
|
|
542
|
-
}
|
|
543
|
-
]
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
};
|
|
549
|
-
const control = {
|
|
550
|
-
type: 'Control',
|
|
551
|
-
scope: '#/properties/myarray'
|
|
552
|
-
};
|
|
553
|
-
const uischema: Layout = {
|
|
554
|
-
type: 'VerticalLayout',
|
|
555
|
-
elements: [control]
|
|
556
|
-
};
|
|
557
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
test('encode "/" in generated ui schema', t => {
|
|
561
|
-
const schema: JsonSchema = {
|
|
562
|
-
properties: {
|
|
563
|
-
'some / initial / value': {
|
|
564
|
-
type : 'integer'
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
|
-
const uischema: Layout = {
|
|
569
|
-
type: 'VerticalLayout',
|
|
570
|
-
elements: [{
|
|
571
|
-
type: 'Control',
|
|
572
|
-
scope: '#/properties/some ~1 initial ~1 value'
|
|
573
|
-
}] as ControlElement[]
|
|
574
|
-
};
|
|
575
|
-
t.deepEqual(generateDefaultUISchema(schema), uischema);
|
|
576
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The MIT License
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2017-2021 EclipseSource Munich
|
|
5
|
-
https://github.com/eclipsesource/jsonforms
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import test from 'ava';
|
|
26
|
-
|
|
27
|
-
import { ControlElement, getI18nKeyPrefixBySchema, i18nJsonSchema, transformPathToI18nPrefix } from '../../src';
|
|
28
|
-
|
|
29
|
-
test('transformPathToI18nPrefix returns root when empty', t => {
|
|
30
|
-
t.is(transformPathToI18nPrefix(''), 'root');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('transformPathToI18nPrefix does not modify non-array paths', t => {
|
|
34
|
-
t.is(transformPathToI18nPrefix('foo'), 'foo');
|
|
35
|
-
t.is(transformPathToI18nPrefix('foo.bar'), 'foo.bar');
|
|
36
|
-
t.is(transformPathToI18nPrefix('bar3.foo2'), 'bar3.foo2');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('transformPathToI18nPrefix removes array indices', t => {
|
|
40
|
-
t.is(transformPathToI18nPrefix('foo.2.bar'), 'foo.bar');
|
|
41
|
-
t.is(transformPathToI18nPrefix('foo.234324234.bar'), 'foo.bar');
|
|
42
|
-
t.is(transformPathToI18nPrefix('foo.0.bar'), 'foo.bar');
|
|
43
|
-
t.is(transformPathToI18nPrefix('foo.0.bar.1.foobar'), 'foo.bar.foobar');
|
|
44
|
-
t.is(transformPathToI18nPrefix('3.foobar'), 'foobar');
|
|
45
|
-
t.is(transformPathToI18nPrefix('foobar.3'), 'foobar');
|
|
46
|
-
t.is(transformPathToI18nPrefix('foo1.23.b2ar3.1.5.foo'), 'foo1.b2ar3.foo');
|
|
47
|
-
t.is(transformPathToI18nPrefix('3'), 'root');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('getI18nKeyPrefixBySchema gets key from uischema over schema', t => {
|
|
51
|
-
const control: ControlElement = {
|
|
52
|
-
type: 'Control',
|
|
53
|
-
scope: '#/properties/foo',
|
|
54
|
-
i18n: 'controlFoo'
|
|
55
|
-
};
|
|
56
|
-
const schema: i18nJsonSchema = {
|
|
57
|
-
type: 'string',
|
|
58
|
-
i18n: 'schemaFoo'
|
|
59
|
-
}
|
|
60
|
-
t.is(getI18nKeyPrefixBySchema(schema, control), 'controlFoo');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('getI18nKeyPrefixBySchema gets schema key for missing uischema key', t => {
|
|
64
|
-
const control: ControlElement = {
|
|
65
|
-
type: 'Control',
|
|
66
|
-
scope: '#/properties/foo',
|
|
67
|
-
};
|
|
68
|
-
const schema: i18nJsonSchema = {
|
|
69
|
-
type: 'string',
|
|
70
|
-
i18n: 'schemaFoo'
|
|
71
|
-
}
|
|
72
|
-
t.is(getI18nKeyPrefixBySchema(schema, control), 'schemaFoo');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test('getI18nKeyPrefixBySchema returns undefined for missing uischema and schema keys', t => {
|
|
76
|
-
const control: ControlElement = {
|
|
77
|
-
type: 'Control',
|
|
78
|
-
scope: '#/properties/foo',
|
|
79
|
-
};
|
|
80
|
-
const schema: i18nJsonSchema = {
|
|
81
|
-
type: 'string',
|
|
82
|
-
}
|
|
83
|
-
t.is(getI18nKeyPrefixBySchema(schema, control), undefined);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
test('getI18nKeyPrefixBySchema returns undefined for undefined parameters', t => {
|
|
87
|
-
t.is(getI18nKeyPrefixBySchema(undefined, undefined), undefined);
|
|
88
|
-
});
|