@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/uischema.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,28 +23,34 @@ 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.iterateSchema = exports.unsetReadonly = exports.setReadonly = void 0;
|
|
28
|
+
var tslib_1 = require("tslib");
|
|
28
29
|
var isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
29
|
-
var
|
|
30
|
+
var models_1 = require("../models");
|
|
30
31
|
var setReadonlyPropertyValue = function (value) { return function (child) {
|
|
31
32
|
if (!child.options) {
|
|
32
33
|
child.options = {};
|
|
33
34
|
}
|
|
34
35
|
child.options.readonly = value;
|
|
35
36
|
}; };
|
|
36
|
-
|
|
37
|
+
var setReadonly = function (uischema) {
|
|
37
38
|
exports.iterateSchema(uischema, setReadonlyPropertyValue(true));
|
|
38
39
|
};
|
|
39
|
-
exports.
|
|
40
|
+
exports.setReadonly = setReadonly;
|
|
41
|
+
var unsetReadonly = function (uischema) {
|
|
40
42
|
exports.iterateSchema(uischema, setReadonlyPropertyValue(false));
|
|
41
43
|
};
|
|
42
|
-
exports.
|
|
44
|
+
exports.unsetReadonly = unsetReadonly;
|
|
45
|
+
var iterateSchema = function (uischema, toApply) {
|
|
43
46
|
if (isEmpty_1.default(uischema)) {
|
|
44
47
|
return;
|
|
45
48
|
}
|
|
46
|
-
if (
|
|
49
|
+
if (models_1.isLayout(uischema)) {
|
|
47
50
|
uischema.elements.forEach(function (child) { return exports.iterateSchema(child, toApply); });
|
|
48
51
|
return;
|
|
49
52
|
}
|
|
50
53
|
toApply(uischema);
|
|
51
54
|
};
|
|
55
|
+
exports.iterateSchema = iterateSchema;
|
|
52
56
|
//# sourceMappingURL=uischema.js.map
|
package/lib/util/uischema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uischema.js","sourceRoot":"","sources":["../../src/util/uischema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uischema.js","sourceRoot":"","sources":["../../src/util/uischema.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;EAuBE;;;;AAEF,mEAAqC;AACrC,oCAAsD;AAItD,IAAM,wBAAwB,GAAG,UAAC,KAAc,IAAsB,OAAA,UACpE,KAAsB;IAEtB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;QAClB,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;KACpB;IACD,KAAK,CAAC,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;AACjC,CAAC,EAPqE,CAOrE,CAAC;AACK,IAAM,WAAW,GAAG,UAAC,QAAyB;IACnD,qBAAa,CAAC,QAAQ,EAAE,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1D,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB;AACK,IAAM,aAAa,GAAG,UAAC,QAAyB;IACrD,qBAAa,CAAC,QAAQ,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3D,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AACK,IAAM,aAAa,GAAG,UAC3B,QAAyB,EACzB,OAAwB;IAExB,IAAI,iBAAO,CAAC,QAAQ,CAAC,EAAE;QACrB,OAAO;KACR;IACD,IAAI,iBAAQ,CAAC,QAAQ,CAAC,EAAE;QACtB,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,KAAK,IAAI,OAAA,qBAAa,CAAC,KAAK,EAAE,OAAO,CAAC,EAA7B,CAA6B,CAAC,CAAC;QAClE,OAAO;KACR;IACD,OAAO,CAAC,QAAQ,CAAC,CAAC;AACpB,CAAC,CAAC;AAZW,QAAA,aAAa,iBAYxB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { JsonSchema, Scopable, UISchemaElement } from '..';
|
|
2
|
+
import Ajv from 'ajv';
|
|
3
|
+
/**
|
|
4
|
+
* Escape the given string such that it can be used as a class name,
|
|
5
|
+
* i.e. hashes and slashes will be replaced.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} s the string that should be converted to a valid class name
|
|
8
|
+
* @returns {string} the escaped string
|
|
9
|
+
*/
|
|
10
|
+
export declare const convertToValidClassName: (s: string) => string;
|
|
11
|
+
export declare const formatErrorMessage: (errors: string[]) => string;
|
|
12
|
+
export declare const hasType: (jsonSchema: JsonSchema, expected: string) => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Derives the type of the jsonSchema element
|
|
15
|
+
*/
|
|
16
|
+
export declare const deriveTypes: (jsonSchema: JsonSchema) => string[];
|
|
17
|
+
/**
|
|
18
|
+
* Convenience wrapper around resolveData and resolveSchema.
|
|
19
|
+
*/
|
|
20
|
+
export declare const Resolve: {
|
|
21
|
+
schema(schema: JsonSchema, schemaPath: string, rootSchema?: JsonSchema): JsonSchema;
|
|
22
|
+
data(data: any, path: string): any;
|
|
23
|
+
};
|
|
24
|
+
export declare const Paths: {
|
|
25
|
+
compose: (path1: string, path2: string) => string;
|
|
26
|
+
fromScopable: (scopable: Scopable) => string;
|
|
27
|
+
};
|
|
28
|
+
export declare const Runtime: {
|
|
29
|
+
isEnabled(uischema: UISchemaElement, data: any, ajv: Ajv): boolean;
|
|
30
|
+
isVisible(uischema: UISchemaElement, data: any, ajv: Ajv): boolean;
|
|
31
|
+
};
|
package/lib/util/util.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
The MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2017-2019 EclipseSource Munich
|
|
6
|
+
https://github.com/eclipsesource/jsonforms
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
|
16
|
+
all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.Runtime = exports.Paths = exports.Resolve = exports.deriveTypes = exports.hasType = exports.formatErrorMessage = exports.convertToValidClassName = void 0;
|
|
28
|
+
var tslib_1 = require("tslib");
|
|
29
|
+
var isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
30
|
+
var isArray_1 = tslib_1.__importDefault(require("lodash/isArray"));
|
|
31
|
+
var includes_1 = tslib_1.__importDefault(require("lodash/includes"));
|
|
32
|
+
var find_1 = tslib_1.__importDefault(require("lodash/find"));
|
|
33
|
+
var resolvers_1 = require("./resolvers");
|
|
34
|
+
var path_1 = require("./path");
|
|
35
|
+
var runtime_1 = require("./runtime");
|
|
36
|
+
/**
|
|
37
|
+
* Escape the given string such that it can be used as a class name,
|
|
38
|
+
* i.e. hashes and slashes will be replaced.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} s the string that should be converted to a valid class name
|
|
41
|
+
* @returns {string} the escaped string
|
|
42
|
+
*/
|
|
43
|
+
var convertToValidClassName = function (s) {
|
|
44
|
+
return s.replace('#', 'root').replace(new RegExp('/', 'g'), '_');
|
|
45
|
+
};
|
|
46
|
+
exports.convertToValidClassName = convertToValidClassName;
|
|
47
|
+
var formatErrorMessage = function (errors) {
|
|
48
|
+
if (errors === undefined || errors === null) {
|
|
49
|
+
return '';
|
|
50
|
+
}
|
|
51
|
+
return errors.join('\n');
|
|
52
|
+
};
|
|
53
|
+
exports.formatErrorMessage = formatErrorMessage;
|
|
54
|
+
var hasType = function (jsonSchema, expected) {
|
|
55
|
+
return includes_1.default(exports.deriveTypes(jsonSchema), expected);
|
|
56
|
+
};
|
|
57
|
+
exports.hasType = hasType;
|
|
58
|
+
/**
|
|
59
|
+
* Derives the type of the jsonSchema element
|
|
60
|
+
*/
|
|
61
|
+
var deriveTypes = function (jsonSchema) {
|
|
62
|
+
if (isEmpty_1.default(jsonSchema)) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
if (!isEmpty_1.default(jsonSchema.type) && typeof jsonSchema.type === 'string') {
|
|
66
|
+
return [jsonSchema.type];
|
|
67
|
+
}
|
|
68
|
+
if (isArray_1.default(jsonSchema.type)) {
|
|
69
|
+
return jsonSchema.type;
|
|
70
|
+
}
|
|
71
|
+
if (!isEmpty_1.default(jsonSchema.properties) ||
|
|
72
|
+
!isEmpty_1.default(jsonSchema.additionalProperties)) {
|
|
73
|
+
return ['object'];
|
|
74
|
+
}
|
|
75
|
+
if (!isEmpty_1.default(jsonSchema.items)) {
|
|
76
|
+
return ['array'];
|
|
77
|
+
}
|
|
78
|
+
if (!isEmpty_1.default(jsonSchema.allOf)) {
|
|
79
|
+
var allOfType = find_1.default(jsonSchema.allOf, function (schema) { return exports.deriveTypes(schema).length !== 0; });
|
|
80
|
+
if (allOfType) {
|
|
81
|
+
return exports.deriveTypes(allOfType);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// ignore all remaining cases
|
|
85
|
+
return [];
|
|
86
|
+
};
|
|
87
|
+
exports.deriveTypes = deriveTypes;
|
|
88
|
+
/**
|
|
89
|
+
* Convenience wrapper around resolveData and resolveSchema.
|
|
90
|
+
*/
|
|
91
|
+
exports.Resolve = {
|
|
92
|
+
schema: resolvers_1.resolveSchema,
|
|
93
|
+
data: resolvers_1.resolveData
|
|
94
|
+
};
|
|
95
|
+
// Paths --
|
|
96
|
+
var fromScopable = function (scopable) {
|
|
97
|
+
return path_1.toDataPathSegments(scopable.scope).join('.');
|
|
98
|
+
};
|
|
99
|
+
exports.Paths = {
|
|
100
|
+
compose: path_1.composePaths,
|
|
101
|
+
fromScopable: fromScopable
|
|
102
|
+
};
|
|
103
|
+
// Runtime --
|
|
104
|
+
exports.Runtime = {
|
|
105
|
+
isEnabled: function (uischema, data, ajv) {
|
|
106
|
+
return runtime_1.isEnabled(uischema, data, undefined, ajv);
|
|
107
|
+
},
|
|
108
|
+
isVisible: function (uischema, data, ajv) {
|
|
109
|
+
return runtime_1.isVisible(uischema, data, undefined, ajv);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util/util.ts"],"names":[],"mappings":"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"}
|
package/lib/util/validator.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
import { Options } from 'ajv';
|
|
3
|
+
export declare const createAjv: (options?: Options) => Ajv;
|
package/lib/util/validator.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAjv = void 0;
|
|
3
4
|
var tslib_1 = require("tslib");
|
|
4
5
|
/*
|
|
5
6
|
The MIT License
|
|
@@ -26,11 +27,11 @@ var tslib_1 = require("tslib");
|
|
|
26
27
|
THE SOFTWARE.
|
|
27
28
|
*/
|
|
28
29
|
var ajv_1 = tslib_1.__importDefault(require("ajv"));
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
var ajv = new ajv_1.default(tslib_1.__assign({
|
|
32
|
-
|
|
33
|
-
ajv.addMetaSchema(draft4_1.Draft4);
|
|
30
|
+
var ajv_formats_1 = tslib_1.__importDefault(require("ajv-formats"));
|
|
31
|
+
var createAjv = function (options) {
|
|
32
|
+
var ajv = new ajv_1.default(tslib_1.__assign({ allErrors: true, verbose: true, strict: false }, options));
|
|
33
|
+
ajv_formats_1.default(ajv);
|
|
34
34
|
return ajv;
|
|
35
35
|
};
|
|
36
|
+
exports.createAjv = createAjv;
|
|
36
37
|
//# sourceMappingURL=validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/util/validator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/util/validator.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACF,oDAAsB;AACtB,oEAAqC;AAG9B,IAAM,SAAS,GAAG,UAAC,OAAiB;IACzC,IAAM,GAAG,GAAG,IAAI,aAAG,oBACjB,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,IAAI,EACb,MAAM,EAAE,KAAK,IACV,OAAO,EACV,CAAC;IACH,qBAAU,CAAC,GAAG,CAAC,CAAC;IAChB,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AATW,QAAA,SAAS,aASpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsonforms/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.3",
|
|
4
4
|
"description": "Core module of JSON Forms",
|
|
5
5
|
"repository": "https://github.com/eclipsesource/jsonforms",
|
|
6
6
|
"bugs": "https://github.com/eclipsesource/jsonforms/issues",
|
|
@@ -62,11 +62,9 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@types/json-schema": "^7.0.3",
|
|
65
|
-
"ajv": "^6.
|
|
66
|
-
"
|
|
67
|
-
"lodash": "^4.17.15"
|
|
68
|
-
"uri-js": "^4.2.2",
|
|
69
|
-
"uuid": "^3.3.3"
|
|
65
|
+
"ajv": "^8.6.1",
|
|
66
|
+
"ajv-formats": "^2.1.0",
|
|
67
|
+
"lodash": "^4.17.15"
|
|
70
68
|
},
|
|
71
69
|
"devDependencies": {
|
|
72
70
|
"@istanbuljs/nyc-config-typescript": "0.1.3",
|
|
@@ -83,9 +81,9 @@
|
|
|
83
81
|
"ts-node": "^8.5.3",
|
|
84
82
|
"tslint": "^5.20.1",
|
|
85
83
|
"typedoc": "^0.19.2",
|
|
86
|
-
"typescript": "
|
|
84
|
+
"typescript": "4.2.3",
|
|
87
85
|
"webpack": "^4.41.2",
|
|
88
86
|
"webpack-cli": "^3.2.1"
|
|
89
87
|
},
|
|
90
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "81f1f19dac49b1864e712e9abbc5c5c6355a2b91"
|
|
91
89
|
}
|
package/src/Helpers.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
|
|
26
|
+
import { convertToValidClassName, createLabelDescriptionFrom } from './util';
|
|
27
|
+
import { ControlElement, JsonSchema, LabelDescription } from './models';
|
|
28
|
+
|
|
29
|
+
export const Helpers: {
|
|
30
|
+
createLabelDescriptionFrom(
|
|
31
|
+
withLabel: ControlElement,
|
|
32
|
+
schema: JsonSchema
|
|
33
|
+
): LabelDescription;
|
|
34
|
+
convertToValidClassName(s: string): string;
|
|
35
|
+
} = {
|
|
36
|
+
createLabelDescriptionFrom,
|
|
37
|
+
convertToValidClassName
|
|
38
|
+
};
|
|
@@ -0,0 +1,345 @@
|
|
|
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
|
+
|
|
26
|
+
import AJV, { ErrorObject } from 'ajv';
|
|
27
|
+
import { JsonSchema, UISchemaElement } from '../models';
|
|
28
|
+
import { generateDefaultUISchema, generateJsonSchema } from '../generators';
|
|
29
|
+
|
|
30
|
+
import { RankedTester } from '../testers';
|
|
31
|
+
import { UISchemaTester, ValidationMode } from '../reducers';
|
|
32
|
+
import { ErrorTranslator, Translator } from '../i18n';
|
|
33
|
+
|
|
34
|
+
export const INIT: 'jsonforms/INIT' = 'jsonforms/INIT';
|
|
35
|
+
export const UPDATE_CORE: 'jsonforms/UPDATE_CORE' = `jsonforms/UPDATE_CORE`;
|
|
36
|
+
export const SET_AJV: 'jsonforms/SET_AJV' = 'jsonforms/SET_AJV';
|
|
37
|
+
export const UPDATE_DATA: 'jsonforms/UPDATE' = 'jsonforms/UPDATE';
|
|
38
|
+
export const UPDATE_ERRORS: 'jsonforms/UPDATE_ERRORS' =
|
|
39
|
+
'jsonforms/UPDATE_ERRORS';
|
|
40
|
+
export const VALIDATE: 'jsonforms/VALIDATE' = 'jsonforms/VALIDATE';
|
|
41
|
+
export const ADD_RENDERER: 'jsonforms/ADD_RENDERER' = 'jsonforms/ADD_RENDERER';
|
|
42
|
+
export const REMOVE_RENDERER: 'jsonforms/REMOVE_RENDERER' =
|
|
43
|
+
'jsonforms/REMOVE_RENDERER';
|
|
44
|
+
export const ADD_CELL: 'jsonforms/ADD_CELL' = 'jsonforms/ADD_CELL';
|
|
45
|
+
export const REMOVE_CELL: 'jsonforms/REMOVE_CELL' = 'jsonforms/REMOVE_CELL';
|
|
46
|
+
export const SET_CONFIG: 'jsonforms/SET_CONFIG' = 'jsonforms/SET_CONFIG';
|
|
47
|
+
export const ADD_UI_SCHEMA: 'jsonforms/ADD_UI_SCHEMA' = `jsonforms/ADD_UI_SCHEMA`;
|
|
48
|
+
export const REMOVE_UI_SCHEMA: 'jsonforms/REMOVE_UI_SCHEMA' = `jsonforms/REMOVE_UI_SCHEMA`;
|
|
49
|
+
export const SET_SCHEMA: 'jsonforms/SET_SCHEMA' = `jsonforms/SET_SCHEMA`;
|
|
50
|
+
export const SET_UISCHEMA: 'jsonforms/SET_UISCHEMA' = `jsonforms/SET_UISCHEMA`;
|
|
51
|
+
export const SET_VALIDATION_MODE: 'jsonforms/SET_VALIDATION_MODE' =
|
|
52
|
+
'jsonforms/SET_VALIDATION_MODE';
|
|
53
|
+
|
|
54
|
+
export const SET_LOCALE: 'jsonforms/SET_LOCALE' = `jsonforms/SET_LOCALE`;
|
|
55
|
+
export const SET_TRANSLATOR: 'jsonforms/SET_TRANSLATOR' =
|
|
56
|
+
'jsonforms/SET_TRANSLATOR';
|
|
57
|
+
export const UPDATE_I18N: 'jsonforms/UPDATE_I18N' =
|
|
58
|
+
'jsonforms/UPDATE_I18N';
|
|
59
|
+
|
|
60
|
+
export const ADD_DEFAULT_DATA: 'jsonforms/ADD_DEFAULT_DATA' = `jsonforms/ADD_DEFAULT_DATA`;
|
|
61
|
+
export const REMOVE_DEFAULT_DATA: 'jsonforms/REMOVE_DEFAULT_DATA' = `jsonforms/REMOVE_DEFAULT_DATA`;
|
|
62
|
+
|
|
63
|
+
export type CoreActions =
|
|
64
|
+
| InitAction
|
|
65
|
+
| UpdateCoreAction
|
|
66
|
+
| UpdateAction
|
|
67
|
+
| UpdateErrorsAction
|
|
68
|
+
| SetAjvAction
|
|
69
|
+
| SetSchemaAction
|
|
70
|
+
| SetUISchemaAction
|
|
71
|
+
| SetValidationModeAction;
|
|
72
|
+
|
|
73
|
+
export interface UpdateAction {
|
|
74
|
+
type: 'jsonforms/UPDATE';
|
|
75
|
+
path: string;
|
|
76
|
+
updater(existingData?: any): any;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface UpdateErrorsAction {
|
|
80
|
+
type: 'jsonforms/UPDATE_ERRORS';
|
|
81
|
+
errors: ErrorObject[];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface InitAction {
|
|
85
|
+
type: 'jsonforms/INIT';
|
|
86
|
+
data: any;
|
|
87
|
+
schema: JsonSchema;
|
|
88
|
+
uischema: UISchemaElement;
|
|
89
|
+
options?: InitActionOptions | AJV;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface UpdateCoreAction {
|
|
93
|
+
type: 'jsonforms/UPDATE_CORE';
|
|
94
|
+
data?: any;
|
|
95
|
+
schema?: JsonSchema;
|
|
96
|
+
uischema?: UISchemaElement;
|
|
97
|
+
options?: InitActionOptions | AJV;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface InitActionOptions {
|
|
101
|
+
ajv?: AJV;
|
|
102
|
+
validationMode?: ValidationMode;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface SetValidationModeAction {
|
|
106
|
+
type: 'jsonforms/SET_VALIDATION_MODE'
|
|
107
|
+
validationMode: ValidationMode
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const init = (
|
|
111
|
+
data: any,
|
|
112
|
+
schema: JsonSchema = generateJsonSchema(data),
|
|
113
|
+
uischema?: UISchemaElement,
|
|
114
|
+
options?: InitActionOptions | AJV
|
|
115
|
+
) => ({
|
|
116
|
+
type: INIT,
|
|
117
|
+
data,
|
|
118
|
+
schema,
|
|
119
|
+
uischema:
|
|
120
|
+
typeof uischema === 'object' ? uischema : generateDefaultUISchema(schema),
|
|
121
|
+
options
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
export const updateCore = (
|
|
125
|
+
data: any,
|
|
126
|
+
schema: JsonSchema,
|
|
127
|
+
uischema?: UISchemaElement,
|
|
128
|
+
options?: AJV | InitActionOptions
|
|
129
|
+
): UpdateCoreAction => ({
|
|
130
|
+
type: UPDATE_CORE,
|
|
131
|
+
data,
|
|
132
|
+
schema,
|
|
133
|
+
uischema,
|
|
134
|
+
options
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
export interface RegisterDefaultDataAction {
|
|
138
|
+
type: 'jsonforms/ADD_DEFAULT_DATA';
|
|
139
|
+
schemaPath: string;
|
|
140
|
+
data: any;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const registerDefaultData = (schemaPath: string, data: any) => ({
|
|
144
|
+
type: ADD_DEFAULT_DATA,
|
|
145
|
+
schemaPath,
|
|
146
|
+
data
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
export interface UnregisterDefaultDataAction {
|
|
150
|
+
type: 'jsonforms/REMOVE_DEFAULT_DATA';
|
|
151
|
+
schemaPath: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export const unregisterDefaultData = (schemaPath: string) => ({
|
|
155
|
+
type: REMOVE_DEFAULT_DATA,
|
|
156
|
+
schemaPath
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
export interface SetAjvAction {
|
|
160
|
+
type: 'jsonforms/SET_AJV';
|
|
161
|
+
ajv: AJV;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export const setAjv = (ajv: AJV) => ({
|
|
165
|
+
type: SET_AJV,
|
|
166
|
+
ajv
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
export const update = (
|
|
170
|
+
path: string,
|
|
171
|
+
updater: (existingData: any) => any
|
|
172
|
+
): UpdateAction => ({
|
|
173
|
+
type: UPDATE_DATA,
|
|
174
|
+
path,
|
|
175
|
+
updater
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
export const updateErrors = (errors: ErrorObject[]): UpdateErrorsAction => ({
|
|
179
|
+
type: UPDATE_ERRORS,
|
|
180
|
+
errors
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
export interface AddRendererAction {
|
|
184
|
+
type: 'jsonforms/ADD_RENDERER';
|
|
185
|
+
tester: RankedTester;
|
|
186
|
+
renderer: any;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export const registerRenderer = (tester: RankedTester, renderer: any) => ({
|
|
190
|
+
type: ADD_RENDERER,
|
|
191
|
+
tester,
|
|
192
|
+
renderer
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
export interface AddCellRendererAction {
|
|
196
|
+
type: 'jsonforms/ADD_CELL';
|
|
197
|
+
tester: RankedTester;
|
|
198
|
+
cell: any;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export const registerCell = (tester: RankedTester, cell: any) => ({
|
|
202
|
+
type: ADD_CELL,
|
|
203
|
+
tester,
|
|
204
|
+
cell
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
export interface RemoveCellRendererAction {
|
|
208
|
+
type: 'jsonforms/REMOVE_CELL';
|
|
209
|
+
tester: RankedTester;
|
|
210
|
+
cell: any;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export const unregisterCell = (tester: RankedTester, cell: any) => ({
|
|
214
|
+
type: REMOVE_CELL,
|
|
215
|
+
tester,
|
|
216
|
+
cell
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
export interface RemoveRendererAction {
|
|
220
|
+
type: 'jsonforms/REMOVE_RENDERER';
|
|
221
|
+
tester: RankedTester;
|
|
222
|
+
renderer: any;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export const unregisterRenderer = (tester: RankedTester, renderer: any) => ({
|
|
226
|
+
type: REMOVE_RENDERER,
|
|
227
|
+
tester,
|
|
228
|
+
renderer
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
export interface SetConfigAction {
|
|
232
|
+
type: 'jsonforms/SET_CONFIG';
|
|
233
|
+
config: any;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export const setConfig = (config: any): SetConfigAction => ({
|
|
237
|
+
type: SET_CONFIG,
|
|
238
|
+
config
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
export const setValidationMode = (validationMode: ValidationMode): SetValidationModeAction => ({
|
|
242
|
+
type: SET_VALIDATION_MODE,
|
|
243
|
+
validationMode
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
export type UISchemaActions = AddUISchemaAction | RemoveUISchemaAction;
|
|
247
|
+
|
|
248
|
+
export interface AddUISchemaAction {
|
|
249
|
+
type: 'jsonforms/ADD_UI_SCHEMA';
|
|
250
|
+
tester: UISchemaTester;
|
|
251
|
+
uischema: UISchemaElement;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export const registerUISchema = (
|
|
255
|
+
tester: UISchemaTester,
|
|
256
|
+
uischema: UISchemaElement
|
|
257
|
+
): AddUISchemaAction => {
|
|
258
|
+
return {
|
|
259
|
+
type: ADD_UI_SCHEMA,
|
|
260
|
+
tester,
|
|
261
|
+
uischema
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
export interface RemoveUISchemaAction {
|
|
266
|
+
type: 'jsonforms/REMOVE_UI_SCHEMA';
|
|
267
|
+
tester: UISchemaTester;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export const unregisterUISchema = (
|
|
271
|
+
tester: UISchemaTester
|
|
272
|
+
): RemoveUISchemaAction => {
|
|
273
|
+
return {
|
|
274
|
+
type: REMOVE_UI_SCHEMA,
|
|
275
|
+
tester
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export type I18nActions =
|
|
280
|
+
| SetLocaleAction
|
|
281
|
+
| SetTranslatorAction
|
|
282
|
+
| UpdateI18nAction
|
|
283
|
+
|
|
284
|
+
export interface SetLocaleAction {
|
|
285
|
+
type: 'jsonforms/SET_LOCALE';
|
|
286
|
+
locale: string | undefined;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export const setLocale = (locale: string | undefined): SetLocaleAction => ({
|
|
290
|
+
type: SET_LOCALE,
|
|
291
|
+
locale
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
export interface SetSchemaAction {
|
|
295
|
+
type: 'jsonforms/SET_SCHEMA';
|
|
296
|
+
schema: JsonSchema;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export const setSchema = (schema: JsonSchema): SetSchemaAction => ({
|
|
300
|
+
type: SET_SCHEMA,
|
|
301
|
+
schema
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
export interface SetTranslatorAction {
|
|
305
|
+
type: 'jsonforms/SET_TRANSLATOR';
|
|
306
|
+
translator?: Translator;
|
|
307
|
+
errorTranslator?: ErrorTranslator;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export const setTranslator = (
|
|
311
|
+
translator?: Translator,
|
|
312
|
+
errorTranslator?: ErrorTranslator
|
|
313
|
+
): SetTranslatorAction => ({
|
|
314
|
+
type: SET_TRANSLATOR,
|
|
315
|
+
translator,
|
|
316
|
+
errorTranslator
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
export interface UpdateI18nAction {
|
|
320
|
+
type: 'jsonforms/UPDATE_I18N';
|
|
321
|
+
locale: string | undefined;
|
|
322
|
+
translator: Translator | undefined;
|
|
323
|
+
errorTranslator: ErrorTranslator | undefined;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export const updateI18n = (
|
|
327
|
+
locale: string | undefined,
|
|
328
|
+
translator: Translator | undefined,
|
|
329
|
+
errorTranslator: ErrorTranslator | undefined
|
|
330
|
+
): UpdateI18nAction => ({
|
|
331
|
+
type: UPDATE_I18N,
|
|
332
|
+
locale,
|
|
333
|
+
translator,
|
|
334
|
+
errorTranslator
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
export interface SetUISchemaAction {
|
|
338
|
+
type: 'jsonforms/SET_UISCHEMA';
|
|
339
|
+
uischema: UISchemaElement;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export const setUISchema = (uischema: UISchemaElement): SetUISchemaAction => ({
|
|
343
|
+
type: SET_UISCHEMA,
|
|
344
|
+
uischema
|
|
345
|
+
});
|