@jsonforms/core 2.5.2-alpha.0 → 3.0.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 +1 -1
- package/docs/assets/js/search.json +1 -1
- package/docs/enums/ruleeffect.html +4 -4
- package/docs/globals.html +1061 -1120
- package/docs/index.html +64 -91
- 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 +22 -22
- package/docs/interfaces/arraylayoutprops.html +22 -22
- package/docs/interfaces/categorization.html +5 -5
- package/docs/interfaces/category.html +5 -5
- package/docs/interfaces/cellprops.html +14 -14
- package/docs/interfaces/combinatorrendererprops.html +13 -13
- package/docs/interfaces/combinatorsubschemarenderinfo.html +3 -3
- package/docs/interfaces/composablecondition.html +2 -2
- package/docs/interfaces/condition.html +1 -1
- package/docs/interfaces/controlelement.html +5 -5
- package/docs/interfaces/controlprops.html +17 -17
- package/docs/interfaces/controlstate.html +2 -2
- package/docs/interfaces/controlwithdetailprops.html +18 -18
- package/docs/interfaces/dispatchcellprops.html +13 -13
- package/docs/interfaces/dispatchcellstateprops.html +13 -13
- 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 +15 -15
- package/docs/interfaces/enumoption.html +2 -2
- package/docs/interfaces/formatted.html +2 -2
- package/docs/interfaces/grouplayout.html +5 -5
- package/docs/interfaces/horizontallayout.html +4 -4
- package/docs/interfaces/initaction.html +6 -6
- package/docs/interfaces/initactionoptions.html +3 -17
- package/docs/interfaces/jsonformscellrendererregistryentry.html +2 -2
- package/docs/interfaces/jsonformscore.html +7 -21
- package/docs/interfaces/jsonformsdefaultdataregistryentry.html +2 -2
- package/docs/interfaces/jsonformsextendedstate.html +1 -1
- package/docs/interfaces/{jsonformslocalestate.html → jsonformsi18nstate.html} +20 -20
- package/docs/interfaces/jsonformsprops.html +9 -24
- package/docs/interfaces/jsonformsrendererregistryentry.html +2 -2
- package/docs/interfaces/jsonformsstate.html +1 -1
- package/docs/interfaces/jsonformsstore.html +5 -5
- package/docs/interfaces/jsonformssubstates.html +18 -8
- package/docs/interfaces/jsonformsuischemaregistryentry.html +2 -2
- 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 +3 -3
- package/docs/interfaces/orcondition.html +2 -2
- package/docs/interfaces/ownpropsofcell.html +10 -10
- package/docs/interfaces/ownpropsofcontrol.html +9 -9
- package/docs/interfaces/ownpropsofenum.html +1 -1
- package/docs/interfaces/ownpropsofenumcell.html +11 -11
- 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 +3 -3
- package/docs/interfaces/scopable.html +1 -1
- package/docs/interfaces/setajvaction.html +3 -3
- package/docs/interfaces/setconfigaction.html +2 -2
- package/docs/interfaces/setlocaleaction.html +3 -3
- package/docs/interfaces/setschemaaction.html +2 -2
- package/docs/interfaces/{setlocalizeduischemasaction.html → settranslatoraction.html} +29 -15
- package/docs/interfaces/setuischemaaction.html +2 -2
- package/docs/interfaces/setvalidationmodeaction.html +2 -2
- package/docs/interfaces/statepropsofarraycontrol.html +18 -18
- package/docs/interfaces/statepropsofarraylayout.html +18 -18
- package/docs/interfaces/statepropsofcell.html +13 -13
- package/docs/interfaces/statepropsofcombinator.html +12 -12
- package/docs/interfaces/statepropsofcontrol.html +16 -16
- package/docs/interfaces/statepropsofcontrolwithdetail.html +17 -17
- package/docs/interfaces/statepropsofenumcell.html +14 -14
- package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -23
- 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/updateaction.html +3 -3
- package/docs/interfaces/updatecoreaction.html +6 -6
- package/docs/interfaces/updateerrorsaction.html +2 -2
- package/docs/interfaces/{setlocalizedschemasaction.html → updatei18naction.html} +43 -15
- package/docs/interfaces/verticallayout.html +4 -4
- package/docs/interfaces/withclassname.html +1 -1
- package/lib/Helpers.d.ts +5 -0
- package/lib/Helpers.js +33 -0
- package/lib/Helpers.js.map +1 -0
- package/lib/actions/actions.d.ts +181 -0
- package/lib/actions/actions.js +173 -0
- package/lib/actions/actions.js.map +1 -0
- package/lib/actions/index.d.ts +1 -180
- package/lib/actions/index.js +26 -122
- package/lib/actions/index.js.map +1 -1
- package/lib/configDefault.js +2 -1
- package/lib/configDefault.js.map +1 -1
- package/lib/generators/Generate.d.ts +6 -0
- package/lib/generators/Generate.js +35 -0
- package/lib/generators/Generate.js.map +1 -0
- package/lib/generators/index.d.ts +3 -10
- package/lib/generators/index.js +28 -9
- package/lib/generators/index.js.map +1 -1
- package/lib/generators/schema.d.ts +1 -1
- package/lib/generators/schema.js +3 -1
- package/lib/generators/schema.js.map +1 -1
- package/lib/generators/uischema.d.ts +1 -2
- package/lib/generators/uischema.js +12 -10
- package/lib/generators/uischema.js.map +1 -1
- package/lib/i18n/i18nTypes.d.ts +15 -0
- package/lib/i18n/i18nTypes.js +3 -0
- package/lib/i18n/i18nTypes.js.map +1 -0
- package/lib/i18n/i18nUtil.d.ts +11 -0
- package/lib/i18n/i18nUtil.js +58 -0
- package/lib/i18n/i18nUtil.js.map +1 -0
- package/lib/i18n/index.d.ts +2 -0
- package/lib/i18n/index.js +6 -0
- package/lib/i18n/index.js.map +1 -0
- package/lib/index.d.ts +6 -18
- package/lib/index.js +10 -15
- package/lib/index.js.map +1 -1
- package/lib/jsonforms-core.js +9 -12
- package/lib/jsonforms-core.js.map +1 -1
- package/lib/models/draft4.js +2 -1
- package/lib/models/draft4.js.map +1 -1
- package/lib/models/index.d.ts +5 -0
- package/lib/models/index.js +33 -0
- package/lib/models/index.js.map +1 -0
- package/lib/models/jsonSchema.js +24 -0
- package/lib/models/jsonSchema.js.map +1 -1
- package/lib/models/uischema.js +29 -2
- package/lib/models/uischema.js.map +1 -1
- package/lib/reducers/cells.d.ts +1 -1
- package/lib/reducers/cells.js +27 -1
- package/lib/reducers/cells.js.map +1 -1
- package/lib/reducers/config.d.ts +1 -1
- package/lib/reducers/config.js +5 -3
- package/lib/reducers/config.js.map +1 -1
- package/lib/reducers/core.d.ts +5 -7
- package/lib/reducers/core.js +78 -63
- package/lib/reducers/core.js.map +1 -1
- package/lib/reducers/default-data.d.ts +1 -1
- package/lib/reducers/default-data.js +6 -3
- package/lib/reducers/default-data.js.map +1 -1
- package/lib/reducers/i18n.d.ts +8 -11
- package/lib/reducers/i18n.js +40 -23
- package/lib/reducers/i18n.js.map +1 -1
- package/lib/reducers/index.d.ts +9 -49
- package/lib/reducers/index.js +33 -91
- package/lib/reducers/index.js.map +1 -1
- package/lib/reducers/reducers.d.ts +37 -0
- package/lib/reducers/reducers.js +107 -0
- package/lib/reducers/reducers.js.map +1 -0
- package/lib/reducers/renderers.d.ts +1 -1
- package/lib/reducers/renderers.js +27 -1
- package/lib/reducers/renderers.js.map +1 -1
- package/lib/reducers/selectors.d.ts +15 -0
- package/lib/reducers/selectors.js +56 -0
- package/lib/reducers/selectors.js.map +1 -0
- package/lib/reducers/uischemas.d.ts +2 -2
- package/lib/reducers/uischemas.js +9 -6
- package/lib/reducers/uischemas.js.map +1 -1
- package/lib/store.d.ts +5 -8
- package/lib/store.js +24 -0
- package/lib/store.js.map +1 -1
- package/lib/testers/index.d.ts +1 -204
- package/lib/testers/index.js +3 -376
- package/lib/testers/index.js.map +1 -1
- package/lib/testers/testers.d.ts +203 -0
- package/lib/testers/testers.js +421 -0
- package/lib/testers/testers.js.map +1 -0
- package/lib/util/Formatted.js +24 -0
- package/lib/util/Formatted.js.map +1 -1
- package/lib/util/array.js +25 -0
- package/lib/util/array.js.map +1 -1
- package/lib/util/cell.d.ts +11 -4
- package/lib/util/cell.js +61 -17
- package/lib/util/cell.js.map +1 -1
- package/lib/util/combinators.d.ts +2 -3
- package/lib/util/combinators.js +5 -2
- package/lib/util/combinators.js.map +1 -1
- package/lib/util/ids.js +8 -4
- package/lib/util/ids.js.map +1 -1
- package/lib/util/index.d.ts +11 -45
- package/lib/util/index.js +14 -104
- package/lib/util/index.js.map +1 -1
- package/lib/util/label.d.ts +1 -2
- package/lib/util/label.js +7 -4
- package/lib/util/label.js.map +1 -1
- package/lib/util/path.d.ts +2 -1
- package/lib/util/path.js +12 -6
- package/lib/util/path.js.map +1 -1
- package/lib/util/renderer.d.ts +17 -17
- package/lib/util/renderer.js +163 -76
- package/lib/util/renderer.js.map +1 -1
- package/lib/util/resolvers.d.ts +1 -14
- package/lib/util/resolvers.js +9 -215
- package/lib/util/resolvers.js.map +1 -1
- package/lib/util/runtime.d.ts +12 -2
- package/lib/util/runtime.js +59 -17
- package/lib/util/runtime.js.map +1 -1
- package/lib/util/schema.js +27 -1
- package/lib/util/schema.js.map +1 -1
- package/lib/util/uischema.d.ts +1 -1
- package/lib/util/uischema.js +11 -7
- package/lib/util/uischema.js.map +1 -1
- package/lib/util/util.d.ts +31 -0
- package/lib/util/util.js +112 -0
- package/lib/util/util.js.map +1 -0
- package/lib/util/validator.d.ts +3 -2
- package/lib/util/validator.js +6 -5
- package/lib/util/validator.js.map +1 -1
- package/package.json +7 -9
- package/src/Helpers.ts +38 -0
- package/src/actions/actions.ts +345 -0
- package/src/actions/index.ts +1 -312
- package/src/configDefault.ts +1 -0
- package/src/generators/Generate.ts +43 -0
- package/src/generators/index.ts +3 -21
- package/src/generators/schema.ts +1 -1
- package/src/generators/uischema.ts +4 -4
- package/src/i18n/i18nTypes.ts +17 -0
- package/src/i18n/i18nUtil.ts +76 -0
- package/src/i18n/index.ts +2 -0
- package/src/index.ts +7 -31
- package/src/models/draft4.ts +1 -0
- package/src/models/index.ts +30 -0
- package/src/models/jsonSchema.ts +1 -0
- package/src/models/uischema.ts +1 -0
- package/src/reducers/cells.ts +2 -1
- package/src/reducers/config.ts +2 -1
- package/src/reducers/core.ts +74 -81
- package/src/reducers/default-data.ts +2 -1
- package/src/reducers/i18n.ts +42 -35
- package/src/reducers/index.ts +9 -158
- package/src/reducers/reducers.ts +148 -0
- package/src/reducers/renderers.ts +2 -1
- package/src/reducers/selectors.ts +65 -0
- package/src/reducers/uischemas.ts +4 -2
- package/src/store.ts +11 -8
- package/src/testers/index.ts +1 -516
- package/src/testers/testers.ts +547 -0
- package/src/util/Formatted.ts +1 -0
- package/src/util/array.ts +25 -0
- package/src/util/cell.ts +91 -19
- package/src/util/combinators.ts +2 -4
- package/src/util/ids.ts +1 -0
- package/src/util/index.ts +11 -126
- package/src/util/label.ts +2 -2
- package/src/util/path.ts +4 -1
- package/src/util/renderer.ts +168 -85
- package/src/util/resolvers.ts +2 -261
- package/src/util/runtime.ts +46 -2
- package/src/util/schema.ts +26 -1
- package/src/util/uischema.ts +2 -1
- package/src/util/util.ts +127 -0
- package/src/util/validator.ts +5 -8
- package/test/reducers/core.test.ts +31 -223
- package/test/util/cell.test.ts +33 -2
- package/test/util/renderer.test.ts +483 -3
- package/test/util/resolvers.test.ts +1 -59
- package/test/util/runtime.test.ts +264 -4
- package/docs/interfaces/labels.html +0 -157
- package/docs/interfaces/schemaref.html +0 -160
- package/docs/interfaces/schemarefs.html +0 -138
package/lib/util/renderer.d.ts
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
import { ControlElement, UISchemaElement } from '../models
|
|
1
|
+
import { ControlElement, JsonSchema, UISchemaElement } from '../models';
|
|
2
|
+
import { JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry, JsonFormsUISchemaRegistryEntry } from '../reducers';
|
|
2
3
|
import { RankedTester } from '../testers';
|
|
3
|
-
import {
|
|
4
|
-
import { AnyAction, Dispatch } from '../util';
|
|
4
|
+
import { AnyAction, Dispatch } from './type';
|
|
5
5
|
import { CoreActions } from '../actions';
|
|
6
6
|
import { ErrorObject } from 'ajv';
|
|
7
7
|
import { JsonFormsState } from '../store';
|
|
8
|
-
import {
|
|
9
|
-
import { JsonFormsCellRendererRegistryEntry } from '../reducers/cells';
|
|
10
|
-
import { JsonFormsUISchemaRegistryEntry } from '../reducers/uischemas';
|
|
8
|
+
import { Translator } from '../i18n';
|
|
11
9
|
export { JsonFormsRendererRegistryEntry, JsonFormsCellRendererRegistryEntry };
|
|
12
|
-
export interface Labels {
|
|
13
|
-
default: string;
|
|
14
|
-
[additionalLabels: string]: string;
|
|
15
|
-
}
|
|
16
|
-
export declare const isPlainLabel: (label: string | Labels) => label is string;
|
|
17
10
|
/**
|
|
18
11
|
* Adds an asterisk to the given label string based
|
|
19
12
|
* on the required parameter.
|
|
20
13
|
*
|
|
21
14
|
* @param {string} label the label string
|
|
22
15
|
* @param {boolean} required whether the label belongs to a control which is required
|
|
16
|
+
* @param {boolean} hideRequiredAsterisk applied UI Schema option
|
|
23
17
|
* @returns {string} the label string
|
|
24
18
|
*/
|
|
25
19
|
export declare const computeLabel: (label: string, required: boolean, hideRequiredAsterisk: boolean) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Indicates whether to mark a field as required.
|
|
22
|
+
*
|
|
23
|
+
* @param {boolean} required whether the label belongs to a control which is required
|
|
24
|
+
* @param {boolean} hideRequiredAsterisk applied UI Schema option
|
|
25
|
+
* @returns {boolean} should the field be marked as required
|
|
26
|
+
*/
|
|
27
|
+
export declare const showAsRequired: (required: boolean, hideRequiredAsterisk: boolean) => boolean;
|
|
26
28
|
/**
|
|
27
29
|
* Create a default value based on the given scheam.
|
|
28
30
|
* @param schema the schema for which to create a default value.
|
|
@@ -46,8 +48,8 @@ export interface EnumOption {
|
|
|
46
48
|
label: string;
|
|
47
49
|
value: any;
|
|
48
50
|
}
|
|
49
|
-
export declare const enumToEnumOptionMapper: (e: any) => EnumOption;
|
|
50
|
-
export declare const oneOfToEnumOptionMapper: (e: any) => EnumOption;
|
|
51
|
+
export declare const enumToEnumOptionMapper: (e: any, t?: Translator, i18nKey?: string) => EnumOption;
|
|
52
|
+
export declare const oneOfToEnumOptionMapper: (e: any, t?: Translator, uiSchemaI18nKey?: string) => EnumOption;
|
|
51
53
|
export interface OwnPropsOfRenderer {
|
|
52
54
|
/**
|
|
53
55
|
* The UI schema to be rendered.
|
|
@@ -164,7 +166,7 @@ export interface StatePropsOfControl extends StatePropsOfScopedRenderer {
|
|
|
164
166
|
/**
|
|
165
167
|
* The label for the rendered element.
|
|
166
168
|
*/
|
|
167
|
-
label: string
|
|
169
|
+
label: string;
|
|
168
170
|
/**
|
|
169
171
|
* Description of input cell
|
|
170
172
|
*/
|
|
@@ -345,7 +347,6 @@ export interface OwnPropsOfJsonFormsRenderer extends OwnPropsOfRenderer {
|
|
|
345
347
|
}
|
|
346
348
|
export interface StatePropsOfJsonFormsRenderer extends OwnPropsOfJsonFormsRenderer {
|
|
347
349
|
rootSchema: JsonSchema;
|
|
348
|
-
refResolver: any;
|
|
349
350
|
}
|
|
350
351
|
export interface JsonFormsProps extends StatePropsOfJsonFormsRenderer {
|
|
351
352
|
}
|
|
@@ -355,7 +356,7 @@ export declare const controlDefaultProps: {
|
|
|
355
356
|
visible: boolean;
|
|
356
357
|
enabled: boolean;
|
|
357
358
|
path: string;
|
|
358
|
-
direction:
|
|
359
|
+
direction: 'row' | 'column';
|
|
359
360
|
};
|
|
360
361
|
export interface StatePropsOfCombinator extends OwnPropsOfControl {
|
|
361
362
|
rootSchema: JsonSchema;
|
|
@@ -388,7 +389,6 @@ export interface StatePropsOfArrayLayout extends StatePropsOfControlWithDetail {
|
|
|
388
389
|
* @returns {StatePropsOfArrayControl} state props for a table control
|
|
389
390
|
*/
|
|
390
391
|
export declare const mapStateToArrayLayoutProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfArrayLayout;
|
|
391
|
-
export declare type CombinatorProps = StatePropsOfCombinator & DispatchPropsOfControl;
|
|
392
392
|
/**
|
|
393
393
|
* Props of an array control.
|
|
394
394
|
*/
|
package/lib/util/renderer.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var tslib_1 = require("tslib");
|
|
4
2
|
/*
|
|
5
3
|
The MIT License
|
|
6
4
|
|
|
@@ -25,16 +23,21 @@ var tslib_1 = require("tslib");
|
|
|
25
23
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
24
|
THE SOFTWARE.
|
|
27
25
|
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.mapStateToArrayLayoutProps = exports.mapStateToOneOfProps = exports.mapStateToAnyOfProps = exports.mapStateToAllOfProps = exports.controlDefaultProps = exports.mapStateToJsonFormsRendererProps = exports.mapStateToLayoutProps = exports.layoutDefaultProps = exports.mapDispatchToMultiEnumProps = exports.mapDispatchToArrayControlProps = exports.mapStateToArrayControlProps = exports.mapStateToControlWithDetailProps = exports.mapStateToMasterListItemProps = exports.mapStateToMultiEnumControlProps = exports.mapStateToOneOfEnumControlProps = exports.mapStateToEnumControlProps = exports.mapDispatchToControlProps = exports.mapStateToControlProps = exports.oneOfToEnumOptionMapper = exports.enumToEnumOptionMapper = exports.isDescriptionHidden = exports.createDefaultValue = exports.showAsRequired = exports.computeLabel = void 0;
|
|
28
|
+
var tslib_1 = require("tslib");
|
|
28
29
|
var get_1 = tslib_1.__importDefault(require("lodash/get"));
|
|
29
|
-
var union_1 = tslib_1.__importDefault(require("lodash/union"));
|
|
30
30
|
var find_1 = tslib_1.__importDefault(require("lodash/find"));
|
|
31
|
-
var json_schema_ref_parser_1 = tslib_1.__importDefault(require("json-schema-ref-parser"));
|
|
32
31
|
var reducers_1 = require("../reducers");
|
|
33
|
-
var
|
|
32
|
+
var runtime_1 = require("./runtime");
|
|
33
|
+
var label_1 = require("./label");
|
|
34
|
+
var combinators_1 = require("./combinators");
|
|
35
|
+
var array_1 = require("./array");
|
|
36
|
+
var util_1 = require("./util");
|
|
37
|
+
var path_1 = require("./path");
|
|
38
|
+
var runtime_2 = require("./runtime");
|
|
34
39
|
var actions_1 = require("../actions");
|
|
35
|
-
|
|
36
|
-
return typeof label === 'string';
|
|
37
|
-
};
|
|
40
|
+
var i18n_1 = require("../i18n");
|
|
38
41
|
var isRequired = function (schema, schemaPath, rootSchema) {
|
|
39
42
|
var pathSegments = schemaPath.split('/');
|
|
40
43
|
var lastSegment = pathSegments[pathSegments.length - 1];
|
|
@@ -51,17 +54,30 @@ var isRequired = function (schema, schemaPath, rootSchema) {
|
|
|
51
54
|
*
|
|
52
55
|
* @param {string} label the label string
|
|
53
56
|
* @param {boolean} required whether the label belongs to a control which is required
|
|
57
|
+
* @param {boolean} hideRequiredAsterisk applied UI Schema option
|
|
54
58
|
* @returns {string} the label string
|
|
55
59
|
*/
|
|
56
|
-
|
|
60
|
+
var computeLabel = function (label, required, hideRequiredAsterisk) {
|
|
57
61
|
return required && !hideRequiredAsterisk ? label + '*' : label;
|
|
58
62
|
};
|
|
63
|
+
exports.computeLabel = computeLabel;
|
|
64
|
+
/**
|
|
65
|
+
* Indicates whether to mark a field as required.
|
|
66
|
+
*
|
|
67
|
+
* @param {boolean} required whether the label belongs to a control which is required
|
|
68
|
+
* @param {boolean} hideRequiredAsterisk applied UI Schema option
|
|
69
|
+
* @returns {boolean} should the field be marked as required
|
|
70
|
+
*/
|
|
71
|
+
var showAsRequired = function (required, hideRequiredAsterisk) {
|
|
72
|
+
return required && !hideRequiredAsterisk;
|
|
73
|
+
};
|
|
74
|
+
exports.showAsRequired = showAsRequired;
|
|
59
75
|
/**
|
|
60
76
|
* Create a default value based on the given scheam.
|
|
61
77
|
* @param schema the schema for which to create a default value.
|
|
62
78
|
* @returns {any}
|
|
63
79
|
*/
|
|
64
|
-
|
|
80
|
+
var createDefaultValue = function (schema) {
|
|
65
81
|
switch (schema.type) {
|
|
66
82
|
case 'string':
|
|
67
83
|
if (schema.format === 'date-time' ||
|
|
@@ -83,6 +99,7 @@ exports.createDefaultValue = function (schema) {
|
|
|
83
99
|
return {};
|
|
84
100
|
}
|
|
85
101
|
};
|
|
102
|
+
exports.createDefaultValue = createDefaultValue;
|
|
86
103
|
/**
|
|
87
104
|
* Whether an element's description should be hidden.
|
|
88
105
|
*
|
|
@@ -92,67 +109,97 @@ exports.createDefaultValue = function (schema) {
|
|
|
92
109
|
*
|
|
93
110
|
* @returns {boolean} true, if the description is to be hidden, false otherwise
|
|
94
111
|
*/
|
|
95
|
-
|
|
112
|
+
var isDescriptionHidden = function (visible, description, isFocused, showUnfocusedDescription) {
|
|
96
113
|
return (description === undefined ||
|
|
97
114
|
(description !== undefined && !visible) ||
|
|
98
115
|
(!showUnfocusedDescription && !isFocused));
|
|
99
116
|
};
|
|
100
|
-
exports.
|
|
101
|
-
|
|
102
|
-
|
|
117
|
+
exports.isDescriptionHidden = isDescriptionHidden;
|
|
118
|
+
var enumToEnumOptionMapper = function (e, t, i18nKey) {
|
|
119
|
+
var label = typeof e === 'string' ? e : JSON.stringify(e);
|
|
120
|
+
if (t) {
|
|
121
|
+
if (i18nKey) {
|
|
122
|
+
label = t(i18nKey + "." + label, label);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
label = t(label, label);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return { label: label, value: e };
|
|
103
129
|
};
|
|
104
|
-
exports.
|
|
130
|
+
exports.enumToEnumOptionMapper = enumToEnumOptionMapper;
|
|
131
|
+
var oneOfToEnumOptionMapper = function (e, t, uiSchemaI18nKey) {
|
|
105
132
|
var _a;
|
|
106
|
-
|
|
133
|
+
var label = (_a = e.title) !== null && _a !== void 0 ? _a : (typeof e.const === 'string' ? e.const : JSON.stringify(e.const));
|
|
134
|
+
if (t) {
|
|
135
|
+
// prefer schema keys as they can be more specialized
|
|
136
|
+
if (e.i18n) {
|
|
137
|
+
label = t(e.i18n, label);
|
|
138
|
+
}
|
|
139
|
+
else if (uiSchemaI18nKey) {
|
|
140
|
+
label = t(uiSchemaI18nKey + "." + label, label);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
label = t(label, label);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
label: label,
|
|
107
148
|
value: e.const,
|
|
108
|
-
|
|
109
|
-
});
|
|
149
|
+
};
|
|
110
150
|
};
|
|
151
|
+
exports.oneOfToEnumOptionMapper = oneOfToEnumOptionMapper;
|
|
111
152
|
/**
|
|
112
153
|
* Map state to control props.
|
|
113
154
|
* @param state the store's state
|
|
114
155
|
* @param ownProps any own props
|
|
115
156
|
* @returns {StatePropsOfControl} state props for a control
|
|
116
157
|
*/
|
|
117
|
-
|
|
158
|
+
var mapStateToControlProps = function (state, ownProps) {
|
|
159
|
+
var _a, _b;
|
|
118
160
|
var uischema = ownProps.uischema;
|
|
119
161
|
var rootData = reducers_1.getData(state);
|
|
120
|
-
var path =
|
|
121
|
-
var visible = ownProps.visible === undefined ||
|
|
122
|
-
?
|
|
162
|
+
var path = path_1.composeWithUi(uischema, ownProps.path);
|
|
163
|
+
var visible = ownProps.visible === undefined || runtime_1.hasShowRule(uischema)
|
|
164
|
+
? runtime_2.isVisible(uischema, rootData, ownProps.path, reducers_1.getAjv(state))
|
|
123
165
|
: ownProps.visible;
|
|
124
|
-
var readonly = state.jsonforms.readonly;
|
|
125
|
-
var enabled = !readonly && (ownProps.enabled === undefined || util_1.hasEnableRule(uischema)
|
|
126
|
-
? util_1.isEnabled(uischema, rootData, ownProps.path, reducers_1.getAjv(state))
|
|
127
|
-
: ownProps.enabled);
|
|
128
166
|
var controlElement = uischema;
|
|
129
167
|
var id = ownProps.id;
|
|
130
168
|
var rootSchema = reducers_1.getSchema(state);
|
|
131
169
|
var required = controlElement.scope !== undefined &&
|
|
132
170
|
isRequired(ownProps.schema, controlElement.scope, rootSchema);
|
|
133
171
|
var resolvedSchema = util_1.Resolve.schema(ownProps.schema || rootSchema, controlElement.scope, rootSchema);
|
|
134
|
-
var errors =
|
|
172
|
+
var errors = reducers_1.getErrorAt(path, resolvedSchema)(state);
|
|
135
173
|
var description = resolvedSchema !== undefined ? resolvedSchema.description : '';
|
|
136
174
|
var data = util_1.Resolve.data(rootData, path);
|
|
137
|
-
var labelDesc =
|
|
175
|
+
var labelDesc = label_1.createLabelDescriptionFrom(uischema, resolvedSchema);
|
|
138
176
|
var label = labelDesc.show ? labelDesc.text : '';
|
|
177
|
+
var config = reducers_1.getConfig(state);
|
|
178
|
+
var enabled = runtime_1.isInherentlyEnabled(state, ownProps, uischema, resolvedSchema || rootSchema, rootData, config);
|
|
179
|
+
var schema = resolvedSchema !== null && resolvedSchema !== void 0 ? resolvedSchema : rootSchema;
|
|
180
|
+
var t = reducers_1.getTranslator()(state);
|
|
181
|
+
var te = reducers_1.getErrorTranslator()(state);
|
|
182
|
+
var i18nLabel = t((_a = i18n_1.getI18nKey(schema, uischema, 'label')) !== null && _a !== void 0 ? _a : label, label);
|
|
183
|
+
var i18nDescription = t((_b = i18n_1.getI18nKey(schema, uischema, 'description')) !== null && _b !== void 0 ? _b : description, description);
|
|
184
|
+
var i18nErrorMessage = i18n_1.getCombinedErrorMessage(errors, te, t, schema, uischema);
|
|
139
185
|
return {
|
|
140
186
|
data: data,
|
|
141
|
-
description:
|
|
142
|
-
errors:
|
|
143
|
-
label:
|
|
187
|
+
description: i18nDescription,
|
|
188
|
+
errors: i18nErrorMessage,
|
|
189
|
+
label: i18nLabel,
|
|
144
190
|
visible: visible,
|
|
145
191
|
enabled: enabled,
|
|
146
192
|
id: id,
|
|
147
193
|
path: path,
|
|
148
194
|
required: required,
|
|
149
|
-
uischema:
|
|
150
|
-
schema:
|
|
195
|
+
uischema: uischema,
|
|
196
|
+
schema: schema,
|
|
151
197
|
config: reducers_1.getConfig(state),
|
|
152
198
|
cells: ownProps.cells || state.jsonforms.cells,
|
|
153
199
|
rootSchema: rootSchema
|
|
154
200
|
};
|
|
155
201
|
};
|
|
202
|
+
exports.mapStateToControlProps = mapStateToControlProps;
|
|
156
203
|
/**
|
|
157
204
|
*
|
|
158
205
|
* Map dispatch to control props.
|
|
@@ -160,57 +207,79 @@ exports.mapStateToControlProps = function (state, ownProps) {
|
|
|
160
207
|
* @param dispatch the store's dispatch method
|
|
161
208
|
* @returns {DispatchPropsOfControl} dispatch props for a control
|
|
162
209
|
*/
|
|
163
|
-
|
|
210
|
+
var mapDispatchToControlProps = function (dispatch) { return ({
|
|
164
211
|
handleChange: function (path, value) {
|
|
165
212
|
dispatch(actions_1.update(path, function () { return value; }));
|
|
166
213
|
}
|
|
167
214
|
}); };
|
|
215
|
+
exports.mapDispatchToControlProps = mapDispatchToControlProps;
|
|
168
216
|
/**
|
|
169
217
|
* Default mapStateToCellProps for enum control. Options is used for populating dropdown list
|
|
170
218
|
* @param state
|
|
171
219
|
* @param ownProps
|
|
172
220
|
* @returns {StatePropsOfControl & OwnPropsOfEnum}
|
|
173
221
|
*/
|
|
174
|
-
|
|
175
|
-
var _a;
|
|
222
|
+
var mapStateToEnumControlProps = function (state, ownProps) {
|
|
223
|
+
var _a, _b, _c, _d;
|
|
176
224
|
var props = exports.mapStateToControlProps(state, ownProps);
|
|
177
|
-
var options = ownProps.options ||
|
|
178
|
-
props.schema.
|
|
225
|
+
var options = ownProps.options ||
|
|
226
|
+
((_a = props.schema.enum) === null || _a === void 0 ? void 0 : _a.map(function (e) {
|
|
227
|
+
var _a, _b, _c;
|
|
228
|
+
return exports.enumToEnumOptionMapper(e, reducers_1.getTranslator()(state), (_c = (_b = (_a = props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.i18n) !== null && _c !== void 0 ? _c : props.schema.i18n);
|
|
229
|
+
})) ||
|
|
230
|
+
(props.schema.const && [
|
|
231
|
+
exports.enumToEnumOptionMapper(props.schema.const, reducers_1.getTranslator()(state), (_d = (_c = (_b = props.uischema) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.i18n) !== null && _d !== void 0 ? _d : props.schema.i18n)
|
|
232
|
+
]);
|
|
179
233
|
return tslib_1.__assign(tslib_1.__assign({}, props), { options: options });
|
|
180
234
|
};
|
|
235
|
+
exports.mapStateToEnumControlProps = mapStateToEnumControlProps;
|
|
181
236
|
/**
|
|
182
237
|
* Default mapStateToCellProps for enum control based on oneOf. Options is used for populating dropdown list
|
|
183
238
|
* @param state
|
|
184
239
|
* @param ownProps
|
|
185
240
|
* @returns {StatePropsOfControl & OwnPropsOfEnum}
|
|
186
241
|
*/
|
|
187
|
-
|
|
242
|
+
var mapStateToOneOfEnumControlProps = function (state, ownProps) {
|
|
188
243
|
var _a;
|
|
189
244
|
var props = exports.mapStateToControlProps(state, ownProps);
|
|
190
|
-
var options = ownProps.options ||
|
|
245
|
+
var options = ownProps.options ||
|
|
246
|
+
((_a = props.schema.oneOf) === null || _a === void 0 ? void 0 : _a.map(function (oneOfSubSchema) {
|
|
247
|
+
var _a, _b;
|
|
248
|
+
return exports.oneOfToEnumOptionMapper(oneOfSubSchema, reducers_1.getTranslator()(state), (_b = (_a = props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.i18n);
|
|
249
|
+
}));
|
|
191
250
|
return tslib_1.__assign(tslib_1.__assign({}, props), { options: options });
|
|
192
251
|
};
|
|
252
|
+
exports.mapStateToOneOfEnumControlProps = mapStateToOneOfEnumControlProps;
|
|
193
253
|
/**
|
|
194
254
|
* Default mapStateToCellProps for multi enum control. Options is used for populating dropdown list
|
|
195
255
|
* @param state
|
|
196
256
|
* @param ownProps
|
|
197
257
|
* @returns {StatePropsOfControl & OwnPropsOfEnum}
|
|
198
258
|
*/
|
|
199
|
-
|
|
259
|
+
var mapStateToMultiEnumControlProps = function (state, ownProps) {
|
|
200
260
|
var _a;
|
|
201
261
|
var props = exports.mapStateToControlProps(state, ownProps);
|
|
202
262
|
var items = props.schema.items;
|
|
203
263
|
var options = ownProps.options ||
|
|
204
|
-
((items === null || items === void 0 ? void 0 : items.oneOf) &&
|
|
264
|
+
((items === null || items === void 0 ? void 0 : items.oneOf) &&
|
|
265
|
+
items.oneOf.map(function (oneOfSubSchema) {
|
|
266
|
+
var _a, _b, _c;
|
|
267
|
+
return exports.oneOfToEnumOptionMapper(oneOfSubSchema, (_a = state.jsonforms.i18n) === null || _a === void 0 ? void 0 : _a.translate, (_c = (_b = props.uischema) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.i18n);
|
|
268
|
+
})) ||
|
|
269
|
+
((_a = items === null || items === void 0 ? void 0 : items.enum) === null || _a === void 0 ? void 0 : _a.map(function (e) {
|
|
270
|
+
var _a, _b, _c, _d;
|
|
271
|
+
return exports.enumToEnumOptionMapper(e, (_a = state.jsonforms.i18n) === null || _a === void 0 ? void 0 : _a.translate, (_d = (_c = (_b = props.uischema) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.i18n) !== null && _d !== void 0 ? _d : props.schema.i18n);
|
|
272
|
+
}));
|
|
205
273
|
return tslib_1.__assign(tslib_1.__assign({}, props), { options: options });
|
|
206
274
|
};
|
|
275
|
+
exports.mapStateToMultiEnumControlProps = mapStateToMultiEnumControlProps;
|
|
207
276
|
/**
|
|
208
277
|
* Map state to control props.
|
|
209
278
|
* @param state the store's state
|
|
210
279
|
* @param ownProps any own props
|
|
211
280
|
* @returns {StatePropsOfControl} state props for a control
|
|
212
281
|
*/
|
|
213
|
-
|
|
282
|
+
var mapStateToMasterListItemProps = function (state, ownProps) {
|
|
214
283
|
var schema = ownProps.schema, path = ownProps.path, index = ownProps.index;
|
|
215
284
|
var firstPrimitiveProp = schema.properties
|
|
216
285
|
? find_1.default(Object.keys(schema.properties), function (propName) {
|
|
@@ -220,11 +289,12 @@ exports.mapStateToMasterListItemProps = function (state, ownProps) {
|
|
|
220
289
|
prop.type === 'integer');
|
|
221
290
|
})
|
|
222
291
|
: undefined;
|
|
223
|
-
var childPath =
|
|
292
|
+
var childPath = path_1.composePaths(path, "" + index);
|
|
224
293
|
var childData = util_1.Resolve.data(reducers_1.getData(state), childPath);
|
|
225
294
|
var childLabel = firstPrimitiveProp ? childData[firstPrimitiveProp] : '';
|
|
226
295
|
return tslib_1.__assign(tslib_1.__assign({}, ownProps), { childLabel: childLabel });
|
|
227
296
|
};
|
|
297
|
+
exports.mapStateToMasterListItemProps = mapStateToMasterListItemProps;
|
|
228
298
|
/**
|
|
229
299
|
* Map state to control with detail props
|
|
230
300
|
*
|
|
@@ -232,10 +302,11 @@ exports.mapStateToMasterListItemProps = function (state, ownProps) {
|
|
|
232
302
|
* @param ownProps any element's own props
|
|
233
303
|
* @returns {StatePropsOfArrayControl} state props for a table control
|
|
234
304
|
*/
|
|
235
|
-
|
|
305
|
+
var mapStateToControlWithDetailProps = function (state, ownProps) {
|
|
236
306
|
var props = tslib_1.__rest(exports.mapStateToControlProps(state, ownProps), []);
|
|
237
307
|
return tslib_1.__assign(tslib_1.__assign({}, props), { uischemas: state.jsonforms.uischemas });
|
|
238
308
|
};
|
|
309
|
+
exports.mapStateToControlWithDetailProps = mapStateToControlWithDetailProps;
|
|
239
310
|
/**
|
|
240
311
|
* Map state to table props
|
|
241
312
|
*
|
|
@@ -243,20 +314,21 @@ exports.mapStateToControlWithDetailProps = function (state, ownProps) {
|
|
|
243
314
|
* @param ownProps any element's own props
|
|
244
315
|
* @returns {StatePropsOfArrayControl} state props for a table control
|
|
245
316
|
*/
|
|
246
|
-
|
|
317
|
+
var mapStateToArrayControlProps = function (state, ownProps) {
|
|
247
318
|
var _a = exports.mapStateToControlWithDetailProps(state, ownProps), path = _a.path, schema = _a.schema, uischema = _a.uischema, props = tslib_1.__rest(_a, ["path", "schema", "uischema"]);
|
|
248
319
|
var resolvedSchema = util_1.Resolve.schema(schema, 'items', props.rootSchema);
|
|
249
320
|
var childErrors = reducers_1.getSubErrorsAt(path, resolvedSchema)(state);
|
|
250
321
|
return tslib_1.__assign(tslib_1.__assign({}, props), { path: path,
|
|
251
322
|
uischema: uischema, schema: resolvedSchema, childErrors: childErrors, renderers: ownProps.renderers || reducers_1.getRenderers(state), cells: ownProps.cells || reducers_1.getCells(state) });
|
|
252
323
|
};
|
|
324
|
+
exports.mapStateToArrayControlProps = mapStateToArrayControlProps;
|
|
253
325
|
/**
|
|
254
326
|
* Maps state to dispatch properties of an array control.
|
|
255
327
|
*
|
|
256
328
|
* @param dispatch the store's dispatch method
|
|
257
329
|
* @returns {DispatchPropsOfArrayControl} dispatch props of an array control
|
|
258
330
|
*/
|
|
259
|
-
|
|
331
|
+
var mapDispatchToArrayControlProps = function (dispatch) { return ({
|
|
260
332
|
addItem: function (path, value) { return function () {
|
|
261
333
|
dispatch(actions_1.update(path, function (array) {
|
|
262
334
|
if (array === undefined || array === null) {
|
|
@@ -277,18 +349,19 @@ exports.mapDispatchToArrayControlProps = function (dispatch) { return ({
|
|
|
277
349
|
}; },
|
|
278
350
|
moveUp: function (path, toMove) { return function () {
|
|
279
351
|
dispatch(actions_1.update(path, function (array) {
|
|
280
|
-
|
|
352
|
+
array_1.moveUp(array, toMove);
|
|
281
353
|
return array;
|
|
282
354
|
}));
|
|
283
355
|
}; },
|
|
284
356
|
moveDown: function (path, toMove) { return function () {
|
|
285
357
|
dispatch(actions_1.update(path, function (array) {
|
|
286
|
-
|
|
358
|
+
array_1.moveDown(array, toMove);
|
|
287
359
|
return array;
|
|
288
360
|
}));
|
|
289
361
|
}; }
|
|
290
362
|
}); };
|
|
291
|
-
exports.
|
|
363
|
+
exports.mapDispatchToArrayControlProps = mapDispatchToArrayControlProps;
|
|
364
|
+
var mapDispatchToMultiEnumProps = function (dispatch) { return ({
|
|
292
365
|
addItem: function (path, value) {
|
|
293
366
|
dispatch(actions_1.update(path, function (data) {
|
|
294
367
|
if (data === undefined || data === null) {
|
|
@@ -306,6 +379,7 @@ exports.mapDispatchToMultiEnumProps = function (dispatch) { return ({
|
|
|
306
379
|
}));
|
|
307
380
|
}
|
|
308
381
|
}); };
|
|
382
|
+
exports.mapDispatchToMultiEnumProps = mapDispatchToMultiEnumProps;
|
|
309
383
|
exports.layoutDefaultProps = {
|
|
310
384
|
visible: true,
|
|
311
385
|
enabled: true,
|
|
@@ -327,22 +401,22 @@ var getDirection = function (uischema) {
|
|
|
327
401
|
* @param ownProps any own props
|
|
328
402
|
* @returns {StatePropsOfLayout}
|
|
329
403
|
*/
|
|
330
|
-
|
|
404
|
+
var mapStateToLayoutProps = function (state, ownProps) {
|
|
331
405
|
var _a;
|
|
332
406
|
var rootData = reducers_1.getData(state);
|
|
333
407
|
var uischema = ownProps.uischema;
|
|
334
|
-
var visible = ownProps.visible === undefined ||
|
|
335
|
-
?
|
|
408
|
+
var visible = ownProps.visible === undefined || runtime_1.hasShowRule(uischema)
|
|
409
|
+
? runtime_2.isVisible(ownProps.uischema, rootData, ownProps.path, reducers_1.getAjv(state))
|
|
336
410
|
: ownProps.visible;
|
|
337
|
-
var readonly = state.jsonforms.readonly;
|
|
338
|
-
var enabled = !readonly && (ownProps.enabled === undefined || util_1.hasEnableRule(uischema)
|
|
339
|
-
? util_1.isEnabled(ownProps.uischema, rootData, ownProps.path, reducers_1.getAjv(state))
|
|
340
|
-
: ownProps.enabled);
|
|
341
411
|
var data = util_1.Resolve.data(rootData, ownProps.path);
|
|
412
|
+
var config = reducers_1.getConfig(state);
|
|
413
|
+
var enabled = runtime_1.isInherentlyEnabled(state, ownProps, uischema, undefined, // layouts have no associated schema
|
|
414
|
+
rootData, config);
|
|
342
415
|
return tslib_1.__assign(tslib_1.__assign({}, exports.layoutDefaultProps), { renderers: ownProps.renderers || reducers_1.getRenderers(state), cells: ownProps.cells || reducers_1.getCells(state), visible: visible,
|
|
343
416
|
enabled: enabled, path: ownProps.path, data: data, uischema: ownProps.uischema, schema: ownProps.schema, direction: (_a = ownProps.direction) !== null && _a !== void 0 ? _a : getDirection(uischema) });
|
|
344
417
|
};
|
|
345
|
-
exports.
|
|
418
|
+
exports.mapStateToLayoutProps = mapStateToLayoutProps;
|
|
419
|
+
var mapStateToJsonFormsRendererProps = function (state, ownProps) {
|
|
346
420
|
var uischema = ownProps.uischema;
|
|
347
421
|
if (uischema === undefined) {
|
|
348
422
|
if (ownProps.schema) {
|
|
@@ -358,31 +432,30 @@ exports.mapStateToJsonFormsRendererProps = function (state, ownProps) {
|
|
|
358
432
|
schema: ownProps.schema || reducers_1.getSchema(state),
|
|
359
433
|
rootSchema: reducers_1.getSchema(state),
|
|
360
434
|
uischema: uischema,
|
|
361
|
-
refResolver: function (schema) {
|
|
362
|
-
return json_schema_ref_parser_1.default.dereference(schema, reducers_1.getRefParserOptions(state));
|
|
363
|
-
},
|
|
364
435
|
path: ownProps.path
|
|
365
436
|
};
|
|
366
437
|
};
|
|
438
|
+
exports.mapStateToJsonFormsRendererProps = mapStateToJsonFormsRendererProps;
|
|
367
439
|
exports.controlDefaultProps = tslib_1.__assign(tslib_1.__assign({}, exports.layoutDefaultProps), { errors: [] });
|
|
368
440
|
var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
|
|
369
441
|
var uischema = ownProps.uischema;
|
|
370
|
-
var path =
|
|
442
|
+
var path = path_1.composeWithUi(uischema, ownProps.path);
|
|
371
443
|
var rootSchema = reducers_1.getSchema(state);
|
|
372
444
|
var resolvedSchema = util_1.Resolve.schema(ownProps.schema || rootSchema, uischema.scope, rootSchema);
|
|
373
|
-
var visible = ownProps.visible === undefined ||
|
|
374
|
-
?
|
|
445
|
+
var visible = ownProps.visible === undefined || runtime_1.hasShowRule(uischema)
|
|
446
|
+
? runtime_2.isVisible(uischema, reducers_1.getData(state), ownProps.path, reducers_1.getAjv(state))
|
|
375
447
|
: ownProps.visible;
|
|
376
448
|
var id = ownProps.id;
|
|
377
449
|
var data = util_1.Resolve.data(reducers_1.getData(state), path);
|
|
378
450
|
var ajv = state.jsonforms.core.ajv;
|
|
379
451
|
var schema = resolvedSchema || rootSchema;
|
|
380
|
-
var _schema =
|
|
452
|
+
var _schema = combinators_1.resolveSubSchemas(schema, rootSchema, keyword);
|
|
381
453
|
var structuralKeywords = [
|
|
382
454
|
'required',
|
|
383
455
|
'additionalProperties',
|
|
384
456
|
'type',
|
|
385
|
-
'enum'
|
|
457
|
+
'enum',
|
|
458
|
+
'const'
|
|
386
459
|
];
|
|
387
460
|
var dataIsValid = function (errors) {
|
|
388
461
|
return (!errors ||
|
|
@@ -390,12 +463,20 @@ var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
|
|
|
390
463
|
!errors.find(function (e) { return structuralKeywords.indexOf(e.keyword) !== -1; }));
|
|
391
464
|
};
|
|
392
465
|
var indexOfFittingSchema;
|
|
466
|
+
// TODO instead of compiling the combinator subschemas we can compile the original schema
|
|
467
|
+
// without the combinator alternatives and then revalidate and check the errors for the
|
|
468
|
+
// element
|
|
393
469
|
for (var i = 0; i < _schema[keyword].length; i++) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
470
|
+
try {
|
|
471
|
+
var valFn = ajv.compile(_schema[keyword][i]);
|
|
472
|
+
valFn(data);
|
|
473
|
+
if (dataIsValid(valFn.errors)) {
|
|
474
|
+
indexOfFittingSchema = i;
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
catch (error) {
|
|
479
|
+
console.debug("Combinator subschema is not self contained, can't hand it over to AJV");
|
|
399
480
|
}
|
|
400
481
|
}
|
|
401
482
|
return {
|
|
@@ -416,15 +497,18 @@ var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
|
|
|
416
497
|
* @param ownProps any own props
|
|
417
498
|
* @returns {StatePropsOfCombinator} state props for a combinator
|
|
418
499
|
*/
|
|
419
|
-
|
|
500
|
+
var mapStateToAllOfProps = function (state, ownProps) {
|
|
420
501
|
return mapStateToCombinatorRendererProps(state, ownProps, 'allOf');
|
|
421
502
|
};
|
|
422
|
-
exports.
|
|
503
|
+
exports.mapStateToAllOfProps = mapStateToAllOfProps;
|
|
504
|
+
var mapStateToAnyOfProps = function (state, ownProps) {
|
|
423
505
|
return mapStateToCombinatorRendererProps(state, ownProps, 'anyOf');
|
|
424
506
|
};
|
|
425
|
-
exports.
|
|
507
|
+
exports.mapStateToAnyOfProps = mapStateToAnyOfProps;
|
|
508
|
+
var mapStateToOneOfProps = function (state, ownProps) {
|
|
426
509
|
return mapStateToCombinatorRendererProps(state, ownProps, 'oneOf');
|
|
427
510
|
};
|
|
511
|
+
exports.mapStateToOneOfProps = mapStateToOneOfProps;
|
|
428
512
|
/**
|
|
429
513
|
* Map state to table props
|
|
430
514
|
*
|
|
@@ -432,14 +516,17 @@ exports.mapStateToOneOfProps = function (state, ownProps) {
|
|
|
432
516
|
* @param ownProps any element's own props
|
|
433
517
|
* @returns {StatePropsOfArrayControl} state props for a table control
|
|
434
518
|
*/
|
|
435
|
-
|
|
519
|
+
var mapStateToArrayLayoutProps = function (state, ownProps) {
|
|
436
520
|
var _a = exports.mapStateToControlWithDetailProps(state, ownProps), path = _a.path, schema = _a.schema, uischema = _a.uischema, errors = _a.errors, props = tslib_1.__rest(_a, ["path", "schema", "uischema", "errors"]);
|
|
437
521
|
var resolvedSchema = util_1.Resolve.schema(schema, 'items', props.rootSchema);
|
|
438
|
-
|
|
522
|
+
// TODO Does not consider a specialized '.custom' error message overriding all other error messages
|
|
523
|
+
// TODO Does not consider 'i18n' keys which are specified in the ui schemas of the sub errors
|
|
524
|
+
var childErrors = i18n_1.getCombinedErrorMessage(reducers_1.getSubErrorsAt(path, resolvedSchema)(state), reducers_1.getErrorTranslator()(state), reducers_1.getTranslator()(state), undefined, undefined);
|
|
439
525
|
var allErrors = errors +
|
|
440
526
|
(errors.length > 0 && childErrors.length > 0 ? '\n' : '') +
|
|
441
527
|
childErrors;
|
|
442
528
|
return tslib_1.__assign(tslib_1.__assign({}, props), { path: path,
|
|
443
529
|
uischema: uischema, schema: resolvedSchema, data: props.data ? props.data.length : 0, errors: allErrors, minItems: schema.minItems });
|
|
444
530
|
};
|
|
531
|
+
exports.mapStateToArrayLayoutProps = mapStateToArrayLayoutProps;
|
|
445
532
|
//# sourceMappingURL=renderer.js.map
|