@jsonforms/core 3.1.0-alpha.0 → 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/Helpers.d.ts +1 -1
- package/lib/actions/actions.d.ts +27 -26
- package/lib/generators/Generate.d.ts +1 -1
- package/lib/generators/schema.d.ts +1 -1
- package/lib/i18n/arrayTranslations.d.ts +24 -0
- package/lib/i18n/i18nTypes.d.ts +3 -2
- package/lib/i18n/i18nUtil.d.ts +5 -2
- package/lib/i18n/index.d.ts +1 -0
- package/lib/jsonforms-core.cjs.js +428 -259
- 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/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 -4
- 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 +11 -7
- 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 +16 -5
- package/src/Helpers.ts +2 -2
- package/src/actions/actions.ts +59 -61
- package/src/configDefault.ts +1 -1
- package/src/generators/Generate.ts +4 -2
- package/src/generators/schema.ts +30 -26
- package/src/generators/uischema.ts +7 -6
- package/src/i18n/arrayTranslations.ts +54 -0
- package/src/i18n/i18nTypes.ts +12 -7
- package/src/i18n/i18nUtil.ts +66 -16
- package/src/i18n/index.ts +1 -0
- package/src/models/draft4.ts +33 -33
- package/src/models/jsonSchema.ts +2 -2
- package/src/models/uischema.ts +18 -7
- package/src/reducers/cells.ts +10 -9
- package/src/reducers/config.ts +1 -1
- package/src/reducers/core.ts +115 -75
- package/src/reducers/default-data.ts +8 -8
- package/src/reducers/i18n.ts +22 -10
- package/src/reducers/reducers.ts +24 -34
- package/src/reducers/renderers.ts +9 -9
- package/src/reducers/selectors.ts +10 -11
- package/src/reducers/uischemas.ts +27 -26
- package/src/store.ts +4 -4
- package/src/testers/testers.ts +200 -147
- package/src/util/cell.ts +27 -29
- package/src/util/combinators.ts +6 -4
- package/src/util/label.ts +2 -2
- package/src/util/path.ts +15 -8
- package/src/util/renderer.ts +123 -72
- package/src/util/resolvers.ts +16 -14
- package/src/util/runtime.ts +4 -4
- 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 +54 -54
- package/src/util/validator.ts +2 -2
- 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,779 +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 {
|
|
27
|
-
AndCondition,
|
|
28
|
-
ControlElement,
|
|
29
|
-
createAjv,
|
|
30
|
-
isInherentlyEnabled,
|
|
31
|
-
JsonFormsCore,
|
|
32
|
-
LeafCondition,
|
|
33
|
-
OrCondition,
|
|
34
|
-
RuleEffect,
|
|
35
|
-
SchemaBasedCondition
|
|
36
|
-
} from '../../src';
|
|
37
|
-
import { evalEnablement, evalVisibility } from '../../src/util/runtime';
|
|
38
|
-
|
|
39
|
-
test('evalVisibility show valid case', t => {
|
|
40
|
-
const leafCondition: LeafCondition = {
|
|
41
|
-
type: 'LEAF',
|
|
42
|
-
scope: '#/properties/ruleValue',
|
|
43
|
-
expectedValue: 'bar'
|
|
44
|
-
};
|
|
45
|
-
const uischema: ControlElement = {
|
|
46
|
-
type: 'Control',
|
|
47
|
-
scope: '#/properties/value',
|
|
48
|
-
rule: {
|
|
49
|
-
effect: RuleEffect.SHOW,
|
|
50
|
-
condition: leafCondition
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const data = {
|
|
54
|
-
value: 'foo',
|
|
55
|
-
ruleValue: 'bar'
|
|
56
|
-
};
|
|
57
|
-
t.is(evalVisibility(uischema, data, undefined, createAjv()), true);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test('evalVisibility show valid case based on AndCondition', t => {
|
|
61
|
-
const leafCondition1: LeafCondition = {
|
|
62
|
-
type: 'LEAF',
|
|
63
|
-
scope: '#/properties/ruleValue1',
|
|
64
|
-
expectedValue: 'bar'
|
|
65
|
-
};
|
|
66
|
-
const leafCondition2: LeafCondition = {
|
|
67
|
-
type: 'LEAF',
|
|
68
|
-
scope: '#/properties/ruleValue2',
|
|
69
|
-
expectedValue: 'foo'
|
|
70
|
-
};
|
|
71
|
-
const condition: AndCondition = {
|
|
72
|
-
type: 'AND',
|
|
73
|
-
conditions: [leafCondition1, leafCondition2]
|
|
74
|
-
};
|
|
75
|
-
const uischema: ControlElement = {
|
|
76
|
-
type: 'Control',
|
|
77
|
-
scope: '#/properties/value',
|
|
78
|
-
rule: {
|
|
79
|
-
effect: RuleEffect.SHOW,
|
|
80
|
-
condition: condition
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const data = {
|
|
84
|
-
value: 'hello',
|
|
85
|
-
ruleValue1: 'bar',
|
|
86
|
-
ruleValue2: 'foo'
|
|
87
|
-
};
|
|
88
|
-
t.is(evalVisibility(uischema, data, undefined, createAjv()), true);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test('evalVisibility show invalid case based on AndCondition', t => {
|
|
92
|
-
const leafCondition1: LeafCondition = {
|
|
93
|
-
type: 'LEAF',
|
|
94
|
-
scope: '#/properties/ruleValue1',
|
|
95
|
-
expectedValue: 'bar'
|
|
96
|
-
};
|
|
97
|
-
const leafCondition2: LeafCondition = {
|
|
98
|
-
type: 'LEAF',
|
|
99
|
-
scope: '#/properties/ruleValue2',
|
|
100
|
-
expectedValue: 'bar'
|
|
101
|
-
};
|
|
102
|
-
const condition: AndCondition = {
|
|
103
|
-
type: 'AND',
|
|
104
|
-
conditions: [leafCondition1, leafCondition2]
|
|
105
|
-
};
|
|
106
|
-
const uischema: ControlElement = {
|
|
107
|
-
type: 'Control',
|
|
108
|
-
scope: '#/properties/value',
|
|
109
|
-
rule: {
|
|
110
|
-
effect: RuleEffect.SHOW,
|
|
111
|
-
condition: condition
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
const data = {
|
|
115
|
-
value: 'hello',
|
|
116
|
-
ruleValue1: 'bar',
|
|
117
|
-
ruleValue2: 'foo'
|
|
118
|
-
};
|
|
119
|
-
t.is(evalVisibility(uischema, data, undefined, createAjv()), false);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
test('evalVisibility show valid case based on OrCondition', t => {
|
|
123
|
-
const leafCondition1: LeafCondition = {
|
|
124
|
-
type: 'LEAF',
|
|
125
|
-
scope: '#/properties/ruleValue1',
|
|
126
|
-
expectedValue: 'bar'
|
|
127
|
-
};
|
|
128
|
-
const leafCondition2: LeafCondition = {
|
|
129
|
-
type: 'LEAF',
|
|
130
|
-
scope: '#/properties/ruleValue2',
|
|
131
|
-
expectedValue: 'foo'
|
|
132
|
-
};
|
|
133
|
-
const condition: OrCondition = {
|
|
134
|
-
type: 'OR',
|
|
135
|
-
conditions: [leafCondition1, leafCondition2]
|
|
136
|
-
};
|
|
137
|
-
const uischema: ControlElement = {
|
|
138
|
-
type: 'Control',
|
|
139
|
-
scope: '#/properties/value',
|
|
140
|
-
rule: {
|
|
141
|
-
effect: RuleEffect.SHOW,
|
|
142
|
-
condition: condition
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
const data = {
|
|
146
|
-
value: 'hello',
|
|
147
|
-
ruleValue1: 'bar1',
|
|
148
|
-
ruleValue2: 'foo'
|
|
149
|
-
};
|
|
150
|
-
t.is(evalVisibility(uischema, data, undefined, createAjv()), true);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
test('evalVisibility show invalid case based on OrCondition', t => {
|
|
154
|
-
const leafCondition1: LeafCondition = {
|
|
155
|
-
type: 'LEAF',
|
|
156
|
-
scope: '#/properties/ruleValue1',
|
|
157
|
-
expectedValue: 'foo'
|
|
158
|
-
};
|
|
159
|
-
const leafCondition2: LeafCondition = {
|
|
160
|
-
type: 'LEAF',
|
|
161
|
-
scope: '#/properties/ruleValue2',
|
|
162
|
-
expectedValue: 'bar'
|
|
163
|
-
};
|
|
164
|
-
const condition: OrCondition = {
|
|
165
|
-
type: 'OR',
|
|
166
|
-
conditions: [leafCondition1, leafCondition2]
|
|
167
|
-
};
|
|
168
|
-
const uischema: ControlElement = {
|
|
169
|
-
type: 'Control',
|
|
170
|
-
scope: '#/properties/value',
|
|
171
|
-
rule: {
|
|
172
|
-
effect: RuleEffect.SHOW,
|
|
173
|
-
condition: condition
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
const data = {
|
|
177
|
-
value: 'hello',
|
|
178
|
-
ruleValue1: 'bar',
|
|
179
|
-
ruleValue2: 'foo'
|
|
180
|
-
};
|
|
181
|
-
t.is(evalVisibility(uischema, data, undefined, createAjv()), false);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
test('evalVisibility show valid case based on schema condition', t => {
|
|
185
|
-
const condition: SchemaBasedCondition = {
|
|
186
|
-
scope: '#/properties/ruleValue',
|
|
187
|
-
schema: {
|
|
188
|
-
const: 'bar'
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
const uischema: ControlElement = {
|
|
192
|
-
type: 'Control',
|
|
193
|
-
scope: '#/properties/value',
|
|
194
|
-
rule: {
|
|
195
|
-
effect: RuleEffect.SHOW,
|
|
196
|
-
condition
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
const data = {
|
|
200
|
-
value: 'foo',
|
|
201
|
-
ruleValue: 'bar'
|
|
202
|
-
};
|
|
203
|
-
t.is(evalVisibility(uischema, data, undefined, createAjv()), true);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
test('evalVisibility show valid case based on schema condition and enum', t => {
|
|
207
|
-
const condition: SchemaBasedCondition = {
|
|
208
|
-
scope: '#/properties/ruleValue',
|
|
209
|
-
schema: {
|
|
210
|
-
enum: ['bar', 'baz']
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
const uischema: ControlElement = {
|
|
214
|
-
type: 'Control',
|
|
215
|
-
scope: '#/properties/value',
|
|
216
|
-
rule: {
|
|
217
|
-
effect: RuleEffect.SHOW,
|
|
218
|
-
condition
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
const data = {
|
|
222
|
-
value: 'foo',
|
|
223
|
-
ruleValue: 'bar'
|
|
224
|
-
};
|
|
225
|
-
t.is(evalVisibility(uischema, data, undefined, createAjv()), true);
|
|
226
|
-
t.is(
|
|
227
|
-
evalVisibility(
|
|
228
|
-
uischema,
|
|
229
|
-
{ ...data, ruleValue: 'baz' },
|
|
230
|
-
undefined,
|
|
231
|
-
createAjv()
|
|
232
|
-
),
|
|
233
|
-
true
|
|
234
|
-
);
|
|
235
|
-
t.is(
|
|
236
|
-
evalVisibility(
|
|
237
|
-
uischema,
|
|
238
|
-
{ ...data, ruleValue: 'foo' },
|
|
239
|
-
undefined,
|
|
240
|
-
createAjv()
|
|
241
|
-
),
|
|
242
|
-
false
|
|
243
|
-
);
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
test('evalVisibility show invalid case', t => {
|
|
247
|
-
const leafCondition: LeafCondition = {
|
|
248
|
-
type: 'LEAF',
|
|
249
|
-
scope: '#/properties/ruleValue',
|
|
250
|
-
expectedValue: 'bar'
|
|
251
|
-
};
|
|
252
|
-
const uischema: ControlElement = {
|
|
253
|
-
type: 'Control',
|
|
254
|
-
scope: '#/properties/value',
|
|
255
|
-
rule: {
|
|
256
|
-
effect: RuleEffect.SHOW,
|
|
257
|
-
condition: leafCondition
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
const data = {
|
|
261
|
-
value: 'foo',
|
|
262
|
-
ruleValue: 'foobar'
|
|
263
|
-
};
|
|
264
|
-
t.deepEqual(evalVisibility(uischema, data, undefined, createAjv()), false);
|
|
265
|
-
});
|
|
266
|
-
test('evalVisibility hide valid case', t => {
|
|
267
|
-
const leafCondition: LeafCondition = {
|
|
268
|
-
type: 'LEAF',
|
|
269
|
-
scope: '#/properties/ruleValue',
|
|
270
|
-
expectedValue: 'bar'
|
|
271
|
-
};
|
|
272
|
-
const uischema: ControlElement = {
|
|
273
|
-
type: 'Control',
|
|
274
|
-
scope: '#/properties/value',
|
|
275
|
-
rule: {
|
|
276
|
-
effect: RuleEffect.HIDE,
|
|
277
|
-
condition: leafCondition
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
const data = {
|
|
281
|
-
value: 'foo',
|
|
282
|
-
ruleValue: 'bar'
|
|
283
|
-
};
|
|
284
|
-
t.is(evalVisibility(uischema, data, undefined, createAjv()), false);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
test('evalVisibility hide invalid case', t => {
|
|
288
|
-
const leafCondition: LeafCondition = {
|
|
289
|
-
type: 'LEAF',
|
|
290
|
-
scope: '#/properties/ruleValue',
|
|
291
|
-
expectedValue: 'bar'
|
|
292
|
-
};
|
|
293
|
-
const uischema: ControlElement = {
|
|
294
|
-
type: 'Control',
|
|
295
|
-
scope: '#/properties/value',
|
|
296
|
-
rule: {
|
|
297
|
-
effect: RuleEffect.HIDE,
|
|
298
|
-
condition: leafCondition
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
const data = {
|
|
302
|
-
value: 'foo',
|
|
303
|
-
ruleValue: 'foobar'
|
|
304
|
-
};
|
|
305
|
-
t.is(evalVisibility(uischema, data, undefined, createAjv()), true);
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
test('evalEnablement enable valid case', t => {
|
|
309
|
-
const leafCondition: LeafCondition = {
|
|
310
|
-
type: 'LEAF',
|
|
311
|
-
scope: '#/properties/ruleValue',
|
|
312
|
-
expectedValue: 'bar'
|
|
313
|
-
};
|
|
314
|
-
const uischema: ControlElement = {
|
|
315
|
-
type: 'Control',
|
|
316
|
-
scope: '#/properties/value',
|
|
317
|
-
rule: {
|
|
318
|
-
effect: RuleEffect.ENABLE,
|
|
319
|
-
condition: leafCondition
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
const data = {
|
|
323
|
-
value: 'foo',
|
|
324
|
-
ruleValue: 'bar'
|
|
325
|
-
};
|
|
326
|
-
t.is(evalEnablement(uischema, data, undefined, createAjv()), true);
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
test('evalEnablement show valid case based on AndCondition', t => {
|
|
330
|
-
const leafCondition1: LeafCondition = {
|
|
331
|
-
type: 'LEAF',
|
|
332
|
-
scope: '#/properties/ruleValue1',
|
|
333
|
-
expectedValue: 'bar'
|
|
334
|
-
};
|
|
335
|
-
const leafCondition2: LeafCondition = {
|
|
336
|
-
type: 'LEAF',
|
|
337
|
-
scope: '#/properties/ruleValue2',
|
|
338
|
-
expectedValue: 'foo'
|
|
339
|
-
};
|
|
340
|
-
const condition: AndCondition = {
|
|
341
|
-
type: 'AND',
|
|
342
|
-
conditions: [leafCondition1, leafCondition2]
|
|
343
|
-
};
|
|
344
|
-
const uischema: ControlElement = {
|
|
345
|
-
type: 'Control',
|
|
346
|
-
scope: '#/properties/value',
|
|
347
|
-
rule: {
|
|
348
|
-
effect: RuleEffect.ENABLE,
|
|
349
|
-
condition: condition
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
const data = {
|
|
353
|
-
value: 'hello',
|
|
354
|
-
ruleValue1: 'bar',
|
|
355
|
-
ruleValue2: 'foo'
|
|
356
|
-
};
|
|
357
|
-
t.is(evalEnablement(uischema, data, undefined, createAjv()), true);
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
test('evalEnablement show invalid case based on AndCondition', t => {
|
|
361
|
-
const leafCondition1: LeafCondition = {
|
|
362
|
-
type: 'LEAF',
|
|
363
|
-
scope: '#/properties/ruleValue1',
|
|
364
|
-
expectedValue: 'bar'
|
|
365
|
-
};
|
|
366
|
-
const leafCondition2: LeafCondition = {
|
|
367
|
-
type: 'LEAF',
|
|
368
|
-
scope: '#/properties/ruleValue2',
|
|
369
|
-
expectedValue: 'bar'
|
|
370
|
-
};
|
|
371
|
-
const condition: AndCondition = {
|
|
372
|
-
type: 'AND',
|
|
373
|
-
conditions: [leafCondition1, leafCondition2]
|
|
374
|
-
};
|
|
375
|
-
const uischema: ControlElement = {
|
|
376
|
-
type: 'Control',
|
|
377
|
-
scope: '#/properties/value',
|
|
378
|
-
rule: {
|
|
379
|
-
effect: RuleEffect.ENABLE,
|
|
380
|
-
condition: condition
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
const data = {
|
|
384
|
-
value: 'hello',
|
|
385
|
-
ruleValue1: 'bar',
|
|
386
|
-
ruleValue2: 'foo'
|
|
387
|
-
};
|
|
388
|
-
t.is(evalEnablement(uischema, data, undefined, createAjv()), false);
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
test('evalEnablement show valid case based on OrCondition', t => {
|
|
392
|
-
const leafCondition1: LeafCondition = {
|
|
393
|
-
type: 'LEAF',
|
|
394
|
-
scope: '#/properties/ruleValue1',
|
|
395
|
-
expectedValue: 'bar'
|
|
396
|
-
};
|
|
397
|
-
const leafCondition2: LeafCondition = {
|
|
398
|
-
type: 'LEAF',
|
|
399
|
-
scope: '#/properties/ruleValue2',
|
|
400
|
-
expectedValue: 'foo'
|
|
401
|
-
};
|
|
402
|
-
const condition: OrCondition = {
|
|
403
|
-
type: 'OR',
|
|
404
|
-
conditions: [leafCondition1, leafCondition2]
|
|
405
|
-
};
|
|
406
|
-
const uischema: ControlElement = {
|
|
407
|
-
type: 'Control',
|
|
408
|
-
scope: '#/properties/value',
|
|
409
|
-
rule: {
|
|
410
|
-
effect: RuleEffect.ENABLE,
|
|
411
|
-
condition: condition
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
const data = {
|
|
415
|
-
value: 'hello',
|
|
416
|
-
ruleValue1: 'bar1',
|
|
417
|
-
ruleValue2: 'foo'
|
|
418
|
-
};
|
|
419
|
-
t.is(evalEnablement(uischema, data, undefined, createAjv()), true);
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
test('evalEnablement show invalid case based on OrCondition', t => {
|
|
423
|
-
const leafCondition1: LeafCondition = {
|
|
424
|
-
type: 'LEAF',
|
|
425
|
-
scope: '#/properties/ruleValue1',
|
|
426
|
-
expectedValue: 'foo'
|
|
427
|
-
};
|
|
428
|
-
const leafCondition2: LeafCondition = {
|
|
429
|
-
type: 'LEAF',
|
|
430
|
-
scope: '#/properties/ruleValue2',
|
|
431
|
-
expectedValue: 'bar'
|
|
432
|
-
};
|
|
433
|
-
const condition: OrCondition = {
|
|
434
|
-
type: 'OR',
|
|
435
|
-
conditions: [leafCondition1, leafCondition2]
|
|
436
|
-
};
|
|
437
|
-
const uischema: ControlElement = {
|
|
438
|
-
type: 'Control',
|
|
439
|
-
scope: '#/properties/value',
|
|
440
|
-
rule: {
|
|
441
|
-
effect: RuleEffect.ENABLE,
|
|
442
|
-
condition: condition
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
const data = {
|
|
446
|
-
value: 'hello',
|
|
447
|
-
ruleValue1: 'bar',
|
|
448
|
-
ruleValue2: 'foo'
|
|
449
|
-
};
|
|
450
|
-
t.is(evalEnablement(uischema, data, undefined, createAjv()), false);
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
test('evalEnablement enable invalid case', t => {
|
|
454
|
-
const leafCondition: LeafCondition = {
|
|
455
|
-
type: 'LEAF',
|
|
456
|
-
scope: '#/properties/ruleValue',
|
|
457
|
-
expectedValue: 'bar'
|
|
458
|
-
};
|
|
459
|
-
const uischema: ControlElement = {
|
|
460
|
-
type: 'Control',
|
|
461
|
-
scope: '#/properties/value',
|
|
462
|
-
rule: {
|
|
463
|
-
effect: RuleEffect.ENABLE,
|
|
464
|
-
condition: leafCondition
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
const data = {
|
|
468
|
-
value: 'foo',
|
|
469
|
-
ruleValue: 'foobar'
|
|
470
|
-
};
|
|
471
|
-
t.is(evalEnablement(uischema, data, undefined, createAjv()), false);
|
|
472
|
-
});
|
|
473
|
-
test('evalEnablement disable valid case', t => {
|
|
474
|
-
const leafCondition: LeafCondition = {
|
|
475
|
-
type: 'LEAF',
|
|
476
|
-
scope: '#/properties/ruleValue',
|
|
477
|
-
expectedValue: 'bar'
|
|
478
|
-
};
|
|
479
|
-
const uischema: ControlElement = {
|
|
480
|
-
type: 'Control',
|
|
481
|
-
scope: '#/properties/value',
|
|
482
|
-
rule: {
|
|
483
|
-
effect: RuleEffect.DISABLE,
|
|
484
|
-
condition: leafCondition
|
|
485
|
-
}
|
|
486
|
-
};
|
|
487
|
-
const data = {
|
|
488
|
-
value: 'foo',
|
|
489
|
-
ruleValue: 'bar'
|
|
490
|
-
};
|
|
491
|
-
t.is(evalEnablement(uischema, data, undefined, createAjv()), false);
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
test('evalEnablement disable invalid case', t => {
|
|
495
|
-
const leafCondition: LeafCondition = {
|
|
496
|
-
type: 'LEAF',
|
|
497
|
-
scope: '#/properties/ruleValue',
|
|
498
|
-
expectedValue: 'bar'
|
|
499
|
-
};
|
|
500
|
-
const uischema: ControlElement = {
|
|
501
|
-
type: 'Control',
|
|
502
|
-
scope: '#/properties/value',
|
|
503
|
-
rule: {
|
|
504
|
-
effect: RuleEffect.DISABLE,
|
|
505
|
-
condition: leafCondition
|
|
506
|
-
}
|
|
507
|
-
};
|
|
508
|
-
const data = {
|
|
509
|
-
value: 'foo',
|
|
510
|
-
ruleValue: 'foobar'
|
|
511
|
-
};
|
|
512
|
-
t.is(evalEnablement(uischema, data, undefined, createAjv()), true);
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
test('evalEnablement disable invalid case based on schema condition', t => {
|
|
516
|
-
const condition: SchemaBasedCondition = {
|
|
517
|
-
scope: '#/properties/ruleValue',
|
|
518
|
-
schema: {
|
|
519
|
-
enum: ['bar', 'baz']
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
const uischema: ControlElement = {
|
|
523
|
-
type: 'Control',
|
|
524
|
-
scope: '#/properties/value',
|
|
525
|
-
rule: {
|
|
526
|
-
effect: RuleEffect.DISABLE,
|
|
527
|
-
condition
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
const data = {
|
|
531
|
-
value: 'foo',
|
|
532
|
-
ruleValue: 'bar'
|
|
533
|
-
};
|
|
534
|
-
t.is(evalEnablement(uischema, data, undefined, createAjv()), false);
|
|
535
|
-
t.is(
|
|
536
|
-
evalEnablement(
|
|
537
|
-
uischema,
|
|
538
|
-
{ ...data, ruleValue: 'baz' },
|
|
539
|
-
undefined,
|
|
540
|
-
createAjv()
|
|
541
|
-
),
|
|
542
|
-
false
|
|
543
|
-
);
|
|
544
|
-
t.is(
|
|
545
|
-
evalEnablement(
|
|
546
|
-
uischema,
|
|
547
|
-
{ ...data, ruleValue: 'foo' },
|
|
548
|
-
undefined,
|
|
549
|
-
createAjv()
|
|
550
|
-
),
|
|
551
|
-
true
|
|
552
|
-
);
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
test('isInherentlyEnabled disabled globally', t => {
|
|
556
|
-
t.false(
|
|
557
|
-
isInherentlyEnabled(
|
|
558
|
-
{ jsonforms: { readonly: true } },
|
|
559
|
-
null,
|
|
560
|
-
null,
|
|
561
|
-
null,
|
|
562
|
-
null,
|
|
563
|
-
null
|
|
564
|
-
)
|
|
565
|
-
);
|
|
566
|
-
});
|
|
567
|
-
|
|
568
|
-
test('isInherentlyEnabled disabled by ownProps', t => {
|
|
569
|
-
t.false(
|
|
570
|
-
isInherentlyEnabled(null, { enabled: false }, null, null, null, null)
|
|
571
|
-
);
|
|
572
|
-
});
|
|
573
|
-
|
|
574
|
-
test('isInherentlyEnabled enabled by ownProps', t => {
|
|
575
|
-
t.true(isInherentlyEnabled(null, { enabled: true }, null, null, null, null));
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
test('isInherentlyEnabled disabled by uischema', t => {
|
|
579
|
-
t.false(
|
|
580
|
-
isInherentlyEnabled(
|
|
581
|
-
null,
|
|
582
|
-
null,
|
|
583
|
-
({ options: { readonly: true } } as unknown) as ControlElement,
|
|
584
|
-
null,
|
|
585
|
-
null,
|
|
586
|
-
null
|
|
587
|
-
)
|
|
588
|
-
);
|
|
589
|
-
});
|
|
590
|
-
|
|
591
|
-
test('isInherentlyEnabled disabled by uischema over ownProps', t => {
|
|
592
|
-
t.false(
|
|
593
|
-
isInherentlyEnabled(
|
|
594
|
-
null,
|
|
595
|
-
{ enabled: true },
|
|
596
|
-
({ options: { readonly: true } } as unknown) as ControlElement,
|
|
597
|
-
null,
|
|
598
|
-
null,
|
|
599
|
-
null
|
|
600
|
-
)
|
|
601
|
-
);
|
|
602
|
-
});
|
|
603
|
-
|
|
604
|
-
test('isInherentlyEnabled enabled by uischema over schema', t => {
|
|
605
|
-
t.true(
|
|
606
|
-
isInherentlyEnabled(
|
|
607
|
-
null,
|
|
608
|
-
null,
|
|
609
|
-
({ options: { readonly: false } } as unknown) as ControlElement,
|
|
610
|
-
{ readOnly: true },
|
|
611
|
-
null,
|
|
612
|
-
null
|
|
613
|
-
)
|
|
614
|
-
);
|
|
615
|
-
});
|
|
616
|
-
|
|
617
|
-
test('isInherentlyEnabled disabled by ownProps over schema enablement', t => {
|
|
618
|
-
t.false(
|
|
619
|
-
isInherentlyEnabled(
|
|
620
|
-
null,
|
|
621
|
-
{ enabled: false},
|
|
622
|
-
null,
|
|
623
|
-
{ readOnly: false },
|
|
624
|
-
null,
|
|
625
|
-
null
|
|
626
|
-
)
|
|
627
|
-
);
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
test('isInherentlyEnabled disabled by uischema over schema', t => {
|
|
631
|
-
t.false(
|
|
632
|
-
isInherentlyEnabled(
|
|
633
|
-
null,
|
|
634
|
-
null,
|
|
635
|
-
({ options: { readonly: true } } as unknown) as ControlElement,
|
|
636
|
-
{ readOnly: false },
|
|
637
|
-
null,
|
|
638
|
-
null
|
|
639
|
-
)
|
|
640
|
-
);
|
|
641
|
-
});
|
|
642
|
-
|
|
643
|
-
test('isInherentlyEnabled disabled by schema', t => {
|
|
644
|
-
t.false(
|
|
645
|
-
isInherentlyEnabled(null, null, null, { readOnly: true }, null, null)
|
|
646
|
-
);
|
|
647
|
-
});
|
|
648
|
-
|
|
649
|
-
test('isInherentlyEnabled disabled by schema over ownProps', t => {
|
|
650
|
-
t.false(
|
|
651
|
-
isInherentlyEnabled(
|
|
652
|
-
null,
|
|
653
|
-
{ enabled: true },
|
|
654
|
-
null,
|
|
655
|
-
{ readOnly: true },
|
|
656
|
-
null,
|
|
657
|
-
null
|
|
658
|
-
)
|
|
659
|
-
);
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
test('isInherentlyEnabled disabled by rule', t => {
|
|
663
|
-
const leafCondition: SchemaBasedCondition = {
|
|
664
|
-
scope: '#/properties/ruleValue',
|
|
665
|
-
schema: { type: 'string', pattern: 'bar' }
|
|
666
|
-
};
|
|
667
|
-
const uischema: ControlElement = {
|
|
668
|
-
type: 'Control',
|
|
669
|
-
scope: '#/properties/value',
|
|
670
|
-
rule: {
|
|
671
|
-
effect: RuleEffect.DISABLE,
|
|
672
|
-
condition: leafCondition
|
|
673
|
-
}
|
|
674
|
-
};
|
|
675
|
-
const data = {
|
|
676
|
-
value: 'foo',
|
|
677
|
-
ruleValue: 'bar'
|
|
678
|
-
};
|
|
679
|
-
|
|
680
|
-
t.false(
|
|
681
|
-
isInherentlyEnabled(
|
|
682
|
-
{ jsonforms: { core: { ajv: createAjv() } as JsonFormsCore } },
|
|
683
|
-
null,
|
|
684
|
-
uischema,
|
|
685
|
-
null,
|
|
686
|
-
data,
|
|
687
|
-
null
|
|
688
|
-
)
|
|
689
|
-
);
|
|
690
|
-
});
|
|
691
|
-
|
|
692
|
-
test('isInherentlyEnabled disabled by global over rule ', t => {
|
|
693
|
-
const leafCondition: SchemaBasedCondition = {
|
|
694
|
-
scope: '#/properties/ruleValue',
|
|
695
|
-
schema: { type: 'string', pattern: 'bar' }
|
|
696
|
-
};
|
|
697
|
-
const uischema: ControlElement = {
|
|
698
|
-
type: 'Control',
|
|
699
|
-
scope: '#/properties/value',
|
|
700
|
-
rule: {
|
|
701
|
-
effect: RuleEffect.ENABLE,
|
|
702
|
-
condition: leafCondition
|
|
703
|
-
}
|
|
704
|
-
};
|
|
705
|
-
const data = {
|
|
706
|
-
value: 'foo',
|
|
707
|
-
ruleValue: 'bar'
|
|
708
|
-
};
|
|
709
|
-
|
|
710
|
-
t.false(
|
|
711
|
-
isInherentlyEnabled(
|
|
712
|
-
{
|
|
713
|
-
jsonforms: {
|
|
714
|
-
readonly: true,
|
|
715
|
-
core: { ajv: createAjv() } as JsonFormsCore
|
|
716
|
-
}
|
|
717
|
-
},
|
|
718
|
-
null,
|
|
719
|
-
uischema,
|
|
720
|
-
null,
|
|
721
|
-
data,
|
|
722
|
-
null
|
|
723
|
-
)
|
|
724
|
-
);
|
|
725
|
-
});
|
|
726
|
-
|
|
727
|
-
test('isInherentlyEnabled disabled by config', t => {
|
|
728
|
-
t.false(
|
|
729
|
-
isInherentlyEnabled(null, null, null, null, null, { readonly: true })
|
|
730
|
-
);
|
|
731
|
-
});
|
|
732
|
-
|
|
733
|
-
test('isInherentlyEnabled enabled by config over ownProps', t => {
|
|
734
|
-
t.true(
|
|
735
|
-
isInherentlyEnabled(null, { enabled: false }, null, null, null, {
|
|
736
|
-
readonly: false
|
|
737
|
-
})
|
|
738
|
-
);
|
|
739
|
-
});
|
|
740
|
-
|
|
741
|
-
test('isInherentlyEnabled enabled by uischema over config', t => {
|
|
742
|
-
t.true(
|
|
743
|
-
isInherentlyEnabled(
|
|
744
|
-
null,
|
|
745
|
-
null,
|
|
746
|
-
({ options: { readonly: false } } as unknown) as ControlElement,
|
|
747
|
-
null,
|
|
748
|
-
null,
|
|
749
|
-
{ readonly: true }
|
|
750
|
-
)
|
|
751
|
-
);
|
|
752
|
-
});
|
|
753
|
-
|
|
754
|
-
test('isInherentlyEnabled prefer readonly over readOnly', t => {
|
|
755
|
-
t.true(
|
|
756
|
-
isInherentlyEnabled(
|
|
757
|
-
null,
|
|
758
|
-
null,
|
|
759
|
-
({ options: { readonly: false, readOnly: true } } as unknown) as ControlElement,
|
|
760
|
-
null,
|
|
761
|
-
null,
|
|
762
|
-
null
|
|
763
|
-
)
|
|
764
|
-
);
|
|
765
|
-
t.false(
|
|
766
|
-
isInherentlyEnabled(
|
|
767
|
-
null,
|
|
768
|
-
null,
|
|
769
|
-
({ options: { readonly: true, readOnly: false } } as unknown) as ControlElement,
|
|
770
|
-
null,
|
|
771
|
-
null,
|
|
772
|
-
null
|
|
773
|
-
)
|
|
774
|
-
);
|
|
775
|
-
});
|
|
776
|
-
|
|
777
|
-
test('isInherentlyEnabled enabled', t => {
|
|
778
|
-
t.true(isInherentlyEnabled(null, null, null, null, null, null));
|
|
779
|
-
});
|