@jsonforms/core 2.5.2 → 3.0.0-alpha.3
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 +1124 -1081
- package/docs/index.html +70 -88
- 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 +18 -0
- package/lib/i18n/i18nUtil.js +71 -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 +29 -0
- package/lib/reducers/reducers.js +98 -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 +60 -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 +19 -18
- package/lib/util/renderer.js +163 -78
- 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 +6 -8
- 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 +105 -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 +128 -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 +170 -88
- 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/i18n/i18nUtil.test.ts +48 -0
- package/test/reducers/core.test.ts +33 -226
- package/test/util/cell.test.ts +33 -2
- package/test/util/renderer.test.ts +543 -31
- 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 '
|
|
4
|
+
import { CombinatorKeyword } from './combinators';
|
|
5
|
+
import { AnyAction, Dispatch } from './type';
|
|
5
6
|
import { CoreActions } from '../actions';
|
|
6
7
|
import { ErrorObject } from 'ajv';
|
|
7
8
|
import { JsonFormsState } from '../store';
|
|
8
|
-
import {
|
|
9
|
-
import { JsonFormsCellRendererRegistryEntry } from '../reducers/cells';
|
|
10
|
-
import { JsonFormsUISchemaRegistryEntry } from '../reducers/uischemas';
|
|
11
|
-
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;
|
|
9
|
+
import { Translator } from '../i18n';
|
|
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, fallbackI18nKey?: 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;
|
|
@@ -365,6 +366,7 @@ export interface StatePropsOfCombinator extends OwnPropsOfControl {
|
|
|
365
366
|
uischemas: JsonFormsUISchemaRegistryEntry[];
|
|
366
367
|
data: any;
|
|
367
368
|
}
|
|
369
|
+
export declare const mapStateToCombinatorRendererProps: (state: JsonFormsState, ownProps: OwnPropsOfControl, keyword: CombinatorKeyword) => StatePropsOfCombinator;
|
|
368
370
|
export interface CombinatorRendererProps extends StatePropsOfCombinator, DispatchPropsOfControl {
|
|
369
371
|
}
|
|
370
372
|
/**
|
|
@@ -388,7 +390,6 @@ export interface StatePropsOfArrayLayout extends StatePropsOfControlWithDetail {
|
|
|
388
390
|
* @returns {StatePropsOfArrayControl} state props for a table control
|
|
389
391
|
*/
|
|
390
392
|
export declare const mapStateToArrayLayoutProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfArrayLayout;
|
|
391
|
-
export declare type CombinatorProps = StatePropsOfCombinator & DispatchPropsOfControl;
|
|
392
393
|
/**
|
|
393
394
|
* Props of an array control.
|
|
394
395
|
*/
|
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.mapStateToCombinatorRendererProps = 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,96 @@ 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, fallbackI18nKey) {
|
|
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 (fallbackI18nKey) {
|
|
140
|
+
label = t(fallbackI18nKey + "." + 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) {
|
|
118
159
|
var uischema = ownProps.uischema;
|
|
119
160
|
var rootData = reducers_1.getData(state);
|
|
120
|
-
var path =
|
|
121
|
-
var visible = ownProps.visible === undefined ||
|
|
122
|
-
?
|
|
161
|
+
var path = path_1.composeWithUi(uischema, ownProps.path);
|
|
162
|
+
var visible = ownProps.visible === undefined || runtime_1.hasShowRule(uischema)
|
|
163
|
+
? runtime_2.isVisible(uischema, rootData, ownProps.path, reducers_1.getAjv(state))
|
|
123
164
|
: 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
165
|
var controlElement = uischema;
|
|
129
166
|
var id = ownProps.id;
|
|
130
167
|
var rootSchema = reducers_1.getSchema(state);
|
|
131
168
|
var required = controlElement.scope !== undefined &&
|
|
132
169
|
isRequired(ownProps.schema, controlElement.scope, rootSchema);
|
|
133
170
|
var resolvedSchema = util_1.Resolve.schema(ownProps.schema || rootSchema, controlElement.scope, rootSchema);
|
|
134
|
-
var errors =
|
|
171
|
+
var errors = reducers_1.getErrorAt(path, resolvedSchema)(state);
|
|
135
172
|
var description = resolvedSchema !== undefined ? resolvedSchema.description : '';
|
|
136
173
|
var data = util_1.Resolve.data(rootData, path);
|
|
137
|
-
var labelDesc =
|
|
174
|
+
var labelDesc = label_1.createLabelDescriptionFrom(uischema, resolvedSchema);
|
|
138
175
|
var label = labelDesc.show ? labelDesc.text : '';
|
|
176
|
+
var config = reducers_1.getConfig(state);
|
|
177
|
+
var enabled = runtime_1.isInherentlyEnabled(state, ownProps, uischema, resolvedSchema || rootSchema, rootData, config);
|
|
178
|
+
var schema = resolvedSchema !== null && resolvedSchema !== void 0 ? resolvedSchema : rootSchema;
|
|
179
|
+
var t = reducers_1.getTranslator()(state);
|
|
180
|
+
var te = reducers_1.getErrorTranslator()(state);
|
|
181
|
+
var i18nLabel = t(i18n_1.getI18nKey(schema, uischema, path, 'label'), label);
|
|
182
|
+
var i18nDescription = t(i18n_1.getI18nKey(schema, uischema, path, 'description'), description);
|
|
183
|
+
var i18nErrorMessage = i18n_1.getCombinedErrorMessage(errors, te, t, schema, uischema, path);
|
|
139
184
|
return {
|
|
140
185
|
data: data,
|
|
141
|
-
description:
|
|
142
|
-
errors:
|
|
143
|
-
label:
|
|
186
|
+
description: i18nDescription,
|
|
187
|
+
errors: i18nErrorMessage,
|
|
188
|
+
label: i18nLabel,
|
|
144
189
|
visible: visible,
|
|
145
190
|
enabled: enabled,
|
|
146
191
|
id: id,
|
|
147
192
|
path: path,
|
|
148
193
|
required: required,
|
|
149
|
-
uischema:
|
|
150
|
-
schema:
|
|
194
|
+
uischema: uischema,
|
|
195
|
+
schema: schema,
|
|
151
196
|
config: reducers_1.getConfig(state),
|
|
152
197
|
cells: ownProps.cells || state.jsonforms.cells,
|
|
153
198
|
rootSchema: rootSchema
|
|
154
199
|
};
|
|
155
200
|
};
|
|
201
|
+
exports.mapStateToControlProps = mapStateToControlProps;
|
|
156
202
|
/**
|
|
157
203
|
*
|
|
158
204
|
* Map dispatch to control props.
|
|
@@ -160,57 +206,77 @@ exports.mapStateToControlProps = function (state, ownProps) {
|
|
|
160
206
|
* @param dispatch the store's dispatch method
|
|
161
207
|
* @returns {DispatchPropsOfControl} dispatch props for a control
|
|
162
208
|
*/
|
|
163
|
-
|
|
209
|
+
var mapDispatchToControlProps = function (dispatch) { return ({
|
|
164
210
|
handleChange: function (path, value) {
|
|
165
211
|
dispatch(actions_1.update(path, function () { return value; }));
|
|
166
212
|
}
|
|
167
213
|
}); };
|
|
214
|
+
exports.mapDispatchToControlProps = mapDispatchToControlProps;
|
|
168
215
|
/**
|
|
169
216
|
* Default mapStateToCellProps for enum control. Options is used for populating dropdown list
|
|
170
217
|
* @param state
|
|
171
218
|
* @param ownProps
|
|
172
219
|
* @returns {StatePropsOfControl & OwnPropsOfEnum}
|
|
173
220
|
*/
|
|
174
|
-
|
|
221
|
+
var mapStateToEnumControlProps = function (state, ownProps) {
|
|
175
222
|
var _a;
|
|
176
223
|
var props = exports.mapStateToControlProps(state, ownProps);
|
|
177
|
-
var options = ownProps.options ||
|
|
178
|
-
props.schema.
|
|
224
|
+
var options = ownProps.options ||
|
|
225
|
+
((_a = props.schema.enum) === null || _a === void 0 ? void 0 : _a.map(function (e) {
|
|
226
|
+
return exports.enumToEnumOptionMapper(e, reducers_1.getTranslator()(state), i18n_1.getI18nKeyPrefix(props.schema, props.uischema, props.path));
|
|
227
|
+
})) ||
|
|
228
|
+
(props.schema.const && [
|
|
229
|
+
exports.enumToEnumOptionMapper(props.schema.const, reducers_1.getTranslator()(state), i18n_1.getI18nKeyPrefix(props.schema, props.uischema, props.path))
|
|
230
|
+
]);
|
|
179
231
|
return tslib_1.__assign(tslib_1.__assign({}, props), { options: options });
|
|
180
232
|
};
|
|
233
|
+
exports.mapStateToEnumControlProps = mapStateToEnumControlProps;
|
|
181
234
|
/**
|
|
182
235
|
* Default mapStateToCellProps for enum control based on oneOf. Options is used for populating dropdown list
|
|
183
236
|
* @param state
|
|
184
237
|
* @param ownProps
|
|
185
238
|
* @returns {StatePropsOfControl & OwnPropsOfEnum}
|
|
186
239
|
*/
|
|
187
|
-
|
|
240
|
+
var mapStateToOneOfEnumControlProps = function (state, ownProps) {
|
|
188
241
|
var _a;
|
|
189
242
|
var props = exports.mapStateToControlProps(state, ownProps);
|
|
190
|
-
var options = ownProps.options ||
|
|
243
|
+
var options = ownProps.options ||
|
|
244
|
+
((_a = props.schema.oneOf) === null || _a === void 0 ? void 0 : _a.map(function (oneOfSubSchema) {
|
|
245
|
+
return exports.oneOfToEnumOptionMapper(oneOfSubSchema, reducers_1.getTranslator()(state), i18n_1.getI18nKeyPrefix(props.schema, props.uischema, props.path));
|
|
246
|
+
}));
|
|
191
247
|
return tslib_1.__assign(tslib_1.__assign({}, props), { options: options });
|
|
192
248
|
};
|
|
249
|
+
exports.mapStateToOneOfEnumControlProps = mapStateToOneOfEnumControlProps;
|
|
193
250
|
/**
|
|
194
251
|
* Default mapStateToCellProps for multi enum control. Options is used for populating dropdown list
|
|
195
252
|
* @param state
|
|
196
253
|
* @param ownProps
|
|
197
254
|
* @returns {StatePropsOfControl & OwnPropsOfEnum}
|
|
198
255
|
*/
|
|
199
|
-
|
|
256
|
+
var mapStateToMultiEnumControlProps = function (state, ownProps) {
|
|
200
257
|
var _a;
|
|
201
258
|
var props = exports.mapStateToControlProps(state, ownProps);
|
|
202
259
|
var items = props.schema.items;
|
|
203
260
|
var options = ownProps.options ||
|
|
204
|
-
((items === null || items === void 0 ? void 0 : items.oneOf) &&
|
|
261
|
+
((items === null || items === void 0 ? void 0 : items.oneOf) &&
|
|
262
|
+
items.oneOf.map(function (oneOfSubSchema) {
|
|
263
|
+
var _a;
|
|
264
|
+
return exports.oneOfToEnumOptionMapper(oneOfSubSchema, (_a = state.jsonforms.i18n) === null || _a === void 0 ? void 0 : _a.translate, i18n_1.getI18nKeyPrefix(props.schema, props.uischema, props.path));
|
|
265
|
+
})) ||
|
|
266
|
+
((_a = items === null || items === void 0 ? void 0 : items.enum) === null || _a === void 0 ? void 0 : _a.map(function (e) {
|
|
267
|
+
var _a;
|
|
268
|
+
return exports.enumToEnumOptionMapper(e, (_a = state.jsonforms.i18n) === null || _a === void 0 ? void 0 : _a.translate, i18n_1.getI18nKeyPrefix(props.schema, props.uischema, props.path));
|
|
269
|
+
}));
|
|
205
270
|
return tslib_1.__assign(tslib_1.__assign({}, props), { options: options });
|
|
206
271
|
};
|
|
272
|
+
exports.mapStateToMultiEnumControlProps = mapStateToMultiEnumControlProps;
|
|
207
273
|
/**
|
|
208
274
|
* Map state to control props.
|
|
209
275
|
* @param state the store's state
|
|
210
276
|
* @param ownProps any own props
|
|
211
277
|
* @returns {StatePropsOfControl} state props for a control
|
|
212
278
|
*/
|
|
213
|
-
|
|
279
|
+
var mapStateToMasterListItemProps = function (state, ownProps) {
|
|
214
280
|
var schema = ownProps.schema, path = ownProps.path, index = ownProps.index;
|
|
215
281
|
var firstPrimitiveProp = schema.properties
|
|
216
282
|
? find_1.default(Object.keys(schema.properties), function (propName) {
|
|
@@ -220,11 +286,12 @@ exports.mapStateToMasterListItemProps = function (state, ownProps) {
|
|
|
220
286
|
prop.type === 'integer');
|
|
221
287
|
})
|
|
222
288
|
: undefined;
|
|
223
|
-
var childPath =
|
|
289
|
+
var childPath = path_1.composePaths(path, "" + index);
|
|
224
290
|
var childData = util_1.Resolve.data(reducers_1.getData(state), childPath);
|
|
225
291
|
var childLabel = firstPrimitiveProp ? childData[firstPrimitiveProp] : '';
|
|
226
292
|
return tslib_1.__assign(tslib_1.__assign({}, ownProps), { childLabel: childLabel });
|
|
227
293
|
};
|
|
294
|
+
exports.mapStateToMasterListItemProps = mapStateToMasterListItemProps;
|
|
228
295
|
/**
|
|
229
296
|
* Map state to control with detail props
|
|
230
297
|
*
|
|
@@ -232,10 +299,11 @@ exports.mapStateToMasterListItemProps = function (state, ownProps) {
|
|
|
232
299
|
* @param ownProps any element's own props
|
|
233
300
|
* @returns {StatePropsOfArrayControl} state props for a table control
|
|
234
301
|
*/
|
|
235
|
-
|
|
302
|
+
var mapStateToControlWithDetailProps = function (state, ownProps) {
|
|
236
303
|
var props = tslib_1.__rest(exports.mapStateToControlProps(state, ownProps), []);
|
|
237
304
|
return tslib_1.__assign(tslib_1.__assign({}, props), { uischemas: state.jsonforms.uischemas });
|
|
238
305
|
};
|
|
306
|
+
exports.mapStateToControlWithDetailProps = mapStateToControlWithDetailProps;
|
|
239
307
|
/**
|
|
240
308
|
* Map state to table props
|
|
241
309
|
*
|
|
@@ -243,20 +311,21 @@ exports.mapStateToControlWithDetailProps = function (state, ownProps) {
|
|
|
243
311
|
* @param ownProps any element's own props
|
|
244
312
|
* @returns {StatePropsOfArrayControl} state props for a table control
|
|
245
313
|
*/
|
|
246
|
-
|
|
314
|
+
var mapStateToArrayControlProps = function (state, ownProps) {
|
|
247
315
|
var _a = exports.mapStateToControlWithDetailProps(state, ownProps), path = _a.path, schema = _a.schema, uischema = _a.uischema, props = tslib_1.__rest(_a, ["path", "schema", "uischema"]);
|
|
248
316
|
var resolvedSchema = util_1.Resolve.schema(schema, 'items', props.rootSchema);
|
|
249
317
|
var childErrors = reducers_1.getSubErrorsAt(path, resolvedSchema)(state);
|
|
250
318
|
return tslib_1.__assign(tslib_1.__assign({}, props), { path: path,
|
|
251
319
|
uischema: uischema, schema: resolvedSchema, childErrors: childErrors, renderers: ownProps.renderers || reducers_1.getRenderers(state), cells: ownProps.cells || reducers_1.getCells(state) });
|
|
252
320
|
};
|
|
321
|
+
exports.mapStateToArrayControlProps = mapStateToArrayControlProps;
|
|
253
322
|
/**
|
|
254
323
|
* Maps state to dispatch properties of an array control.
|
|
255
324
|
*
|
|
256
325
|
* @param dispatch the store's dispatch method
|
|
257
326
|
* @returns {DispatchPropsOfArrayControl} dispatch props of an array control
|
|
258
327
|
*/
|
|
259
|
-
|
|
328
|
+
var mapDispatchToArrayControlProps = function (dispatch) { return ({
|
|
260
329
|
addItem: function (path, value) { return function () {
|
|
261
330
|
dispatch(actions_1.update(path, function (array) {
|
|
262
331
|
if (array === undefined || array === null) {
|
|
@@ -277,18 +346,19 @@ exports.mapDispatchToArrayControlProps = function (dispatch) { return ({
|
|
|
277
346
|
}; },
|
|
278
347
|
moveUp: function (path, toMove) { return function () {
|
|
279
348
|
dispatch(actions_1.update(path, function (array) {
|
|
280
|
-
|
|
349
|
+
array_1.moveUp(array, toMove);
|
|
281
350
|
return array;
|
|
282
351
|
}));
|
|
283
352
|
}; },
|
|
284
353
|
moveDown: function (path, toMove) { return function () {
|
|
285
354
|
dispatch(actions_1.update(path, function (array) {
|
|
286
|
-
|
|
355
|
+
array_1.moveDown(array, toMove);
|
|
287
356
|
return array;
|
|
288
357
|
}));
|
|
289
358
|
}; }
|
|
290
359
|
}); };
|
|
291
|
-
exports.
|
|
360
|
+
exports.mapDispatchToArrayControlProps = mapDispatchToArrayControlProps;
|
|
361
|
+
var mapDispatchToMultiEnumProps = function (dispatch) { return ({
|
|
292
362
|
addItem: function (path, value) {
|
|
293
363
|
dispatch(actions_1.update(path, function (data) {
|
|
294
364
|
if (data === undefined || data === null) {
|
|
@@ -306,6 +376,7 @@ exports.mapDispatchToMultiEnumProps = function (dispatch) { return ({
|
|
|
306
376
|
}));
|
|
307
377
|
}
|
|
308
378
|
}); };
|
|
379
|
+
exports.mapDispatchToMultiEnumProps = mapDispatchToMultiEnumProps;
|
|
309
380
|
exports.layoutDefaultProps = {
|
|
310
381
|
visible: true,
|
|
311
382
|
enabled: true,
|
|
@@ -327,22 +398,22 @@ var getDirection = function (uischema) {
|
|
|
327
398
|
* @param ownProps any own props
|
|
328
399
|
* @returns {StatePropsOfLayout}
|
|
329
400
|
*/
|
|
330
|
-
|
|
401
|
+
var mapStateToLayoutProps = function (state, ownProps) {
|
|
331
402
|
var _a;
|
|
332
403
|
var rootData = reducers_1.getData(state);
|
|
333
404
|
var uischema = ownProps.uischema;
|
|
334
|
-
var visible = ownProps.visible === undefined ||
|
|
335
|
-
?
|
|
405
|
+
var visible = ownProps.visible === undefined || runtime_1.hasShowRule(uischema)
|
|
406
|
+
? runtime_2.isVisible(ownProps.uischema, rootData, ownProps.path, reducers_1.getAjv(state))
|
|
336
407
|
: 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
408
|
var data = util_1.Resolve.data(rootData, ownProps.path);
|
|
409
|
+
var config = reducers_1.getConfig(state);
|
|
410
|
+
var enabled = runtime_1.isInherentlyEnabled(state, ownProps, uischema, undefined, // layouts have no associated schema
|
|
411
|
+
rootData, config);
|
|
342
412
|
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
413
|
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
414
|
};
|
|
345
|
-
exports.
|
|
415
|
+
exports.mapStateToLayoutProps = mapStateToLayoutProps;
|
|
416
|
+
var mapStateToJsonFormsRendererProps = function (state, ownProps) {
|
|
346
417
|
var uischema = ownProps.uischema;
|
|
347
418
|
if (uischema === undefined) {
|
|
348
419
|
if (ownProps.schema) {
|
|
@@ -358,31 +429,30 @@ exports.mapStateToJsonFormsRendererProps = function (state, ownProps) {
|
|
|
358
429
|
schema: ownProps.schema || reducers_1.getSchema(state),
|
|
359
430
|
rootSchema: reducers_1.getSchema(state),
|
|
360
431
|
uischema: uischema,
|
|
361
|
-
refResolver: function (schema) {
|
|
362
|
-
return json_schema_ref_parser_1.default.dereference(schema, reducers_1.getRefParserOptions(state));
|
|
363
|
-
},
|
|
364
432
|
path: ownProps.path
|
|
365
433
|
};
|
|
366
434
|
};
|
|
435
|
+
exports.mapStateToJsonFormsRendererProps = mapStateToJsonFormsRendererProps;
|
|
367
436
|
exports.controlDefaultProps = tslib_1.__assign(tslib_1.__assign({}, exports.layoutDefaultProps), { errors: [] });
|
|
368
437
|
var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
|
|
369
438
|
var uischema = ownProps.uischema;
|
|
370
|
-
var path =
|
|
439
|
+
var path = path_1.composeWithUi(uischema, ownProps.path);
|
|
371
440
|
var rootSchema = reducers_1.getSchema(state);
|
|
372
441
|
var resolvedSchema = util_1.Resolve.schema(ownProps.schema || rootSchema, uischema.scope, rootSchema);
|
|
373
|
-
var visible = ownProps.visible === undefined ||
|
|
374
|
-
?
|
|
442
|
+
var visible = ownProps.visible === undefined || runtime_1.hasShowRule(uischema)
|
|
443
|
+
? runtime_2.isVisible(uischema, reducers_1.getData(state), ownProps.path, reducers_1.getAjv(state))
|
|
375
444
|
: ownProps.visible;
|
|
376
445
|
var id = ownProps.id;
|
|
377
446
|
var data = util_1.Resolve.data(reducers_1.getData(state), path);
|
|
378
447
|
var ajv = state.jsonforms.core.ajv;
|
|
379
448
|
var schema = resolvedSchema || rootSchema;
|
|
380
|
-
var _schema =
|
|
449
|
+
var _schema = combinators_1.resolveSubSchemas(schema, rootSchema, keyword);
|
|
381
450
|
var structuralKeywords = [
|
|
382
451
|
'required',
|
|
383
452
|
'additionalProperties',
|
|
384
453
|
'type',
|
|
385
|
-
'enum'
|
|
454
|
+
'enum',
|
|
455
|
+
'const'
|
|
386
456
|
];
|
|
387
457
|
var dataIsValid = function (errors) {
|
|
388
458
|
return (!errors ||
|
|
@@ -390,12 +460,20 @@ var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
|
|
|
390
460
|
!errors.find(function (e) { return structuralKeywords.indexOf(e.keyword) !== -1; }));
|
|
391
461
|
};
|
|
392
462
|
var indexOfFittingSchema;
|
|
463
|
+
// TODO instead of compiling the combinator subschemas we can compile the original schema
|
|
464
|
+
// without the combinator alternatives and then revalidate and check the errors for the
|
|
465
|
+
// element
|
|
393
466
|
for (var i = 0; i < _schema[keyword].length; i++) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
467
|
+
try {
|
|
468
|
+
var valFn = ajv.compile(_schema[keyword][i]);
|
|
469
|
+
valFn(data);
|
|
470
|
+
if (dataIsValid(valFn.errors)) {
|
|
471
|
+
indexOfFittingSchema = i;
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
catch (error) {
|
|
476
|
+
console.debug("Combinator subschema is not self contained, can't hand it over to AJV");
|
|
399
477
|
}
|
|
400
478
|
}
|
|
401
479
|
return {
|
|
@@ -410,21 +488,25 @@ var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
|
|
|
410
488
|
uischema: uischema
|
|
411
489
|
};
|
|
412
490
|
};
|
|
491
|
+
exports.mapStateToCombinatorRendererProps = mapStateToCombinatorRendererProps;
|
|
413
492
|
/**
|
|
414
493
|
* Map state to all of renderer props.
|
|
415
494
|
* @param state the store's state
|
|
416
495
|
* @param ownProps any own props
|
|
417
496
|
* @returns {StatePropsOfCombinator} state props for a combinator
|
|
418
497
|
*/
|
|
419
|
-
|
|
420
|
-
return mapStateToCombinatorRendererProps(state, ownProps, 'allOf');
|
|
498
|
+
var mapStateToAllOfProps = function (state, ownProps) {
|
|
499
|
+
return exports.mapStateToCombinatorRendererProps(state, ownProps, 'allOf');
|
|
421
500
|
};
|
|
422
|
-
exports.
|
|
423
|
-
|
|
501
|
+
exports.mapStateToAllOfProps = mapStateToAllOfProps;
|
|
502
|
+
var mapStateToAnyOfProps = function (state, ownProps) {
|
|
503
|
+
return exports.mapStateToCombinatorRendererProps(state, ownProps, 'anyOf');
|
|
424
504
|
};
|
|
425
|
-
exports.
|
|
426
|
-
|
|
505
|
+
exports.mapStateToAnyOfProps = mapStateToAnyOfProps;
|
|
506
|
+
var mapStateToOneOfProps = function (state, ownProps) {
|
|
507
|
+
return exports.mapStateToCombinatorRendererProps(state, ownProps, 'oneOf');
|
|
427
508
|
};
|
|
509
|
+
exports.mapStateToOneOfProps = mapStateToOneOfProps;
|
|
428
510
|
/**
|
|
429
511
|
* Map state to table props
|
|
430
512
|
*
|
|
@@ -432,14 +514,17 @@ exports.mapStateToOneOfProps = function (state, ownProps) {
|
|
|
432
514
|
* @param ownProps any element's own props
|
|
433
515
|
* @returns {StatePropsOfArrayControl} state props for a table control
|
|
434
516
|
*/
|
|
435
|
-
|
|
517
|
+
var mapStateToArrayLayoutProps = function (state, ownProps) {
|
|
436
518
|
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
519
|
var resolvedSchema = util_1.Resolve.schema(schema, 'items', props.rootSchema);
|
|
438
|
-
|
|
520
|
+
// TODO Does not consider a specialized '.custom' error message overriding all other error messages
|
|
521
|
+
// TODO Does not consider 'i18n' keys which are specified in the ui schemas of the sub errors
|
|
522
|
+
var childErrors = i18n_1.getCombinedErrorMessage(reducers_1.getSubErrorsAt(path, resolvedSchema)(state), reducers_1.getErrorTranslator()(state), reducers_1.getTranslator()(state), undefined, undefined, undefined);
|
|
439
523
|
var allErrors = errors +
|
|
440
524
|
(errors.length > 0 && childErrors.length > 0 ? '\n' : '') +
|
|
441
525
|
childErrors;
|
|
442
526
|
return tslib_1.__assign(tslib_1.__assign({}, props), { path: path,
|
|
443
527
|
uischema: uischema, schema: resolvedSchema, data: props.data ? props.data.length : 0, errors: allErrors, minItems: schema.minItems });
|
|
444
528
|
};
|
|
529
|
+
exports.mapStateToArrayLayoutProps = mapStateToArrayLayoutProps;
|
|
445
530
|
//# sourceMappingURL=renderer.js.map
|