@jsonforms/core 3.0.0-beta.1 → 3.0.0-beta.4
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 +11 -0
- package/docs/assets/js/search.json +1 -1
- package/docs/enums/ruleeffect.html +4 -4
- package/docs/globals.html +357 -217
- package/docs/index.html +29 -4
- 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 +21 -21
- package/docs/interfaces/arraylayoutprops.html +21 -21
- package/docs/interfaces/categorization.html +5 -5
- package/docs/interfaces/category.html +5 -5
- package/docs/interfaces/cellprops.html +12 -12
- package/docs/interfaces/combinatorrendererprops.html +143 -36
- package/docs/interfaces/composablecondition.html +2 -2
- package/docs/interfaces/condition.html +1 -1
- package/docs/interfaces/controlelement.html +22 -4
- package/docs/interfaces/controlprops.html +16 -16
- package/docs/interfaces/controlstate.html +2 -2
- package/docs/interfaces/controlwithdetailprops.html +17 -17
- package/docs/interfaces/dispatchcellprops.html +10 -10
- package/docs/interfaces/dispatchcellstateprops.html +10 -10
- 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 +13 -13
- package/docs/interfaces/enumoption.html +2 -2
- package/docs/interfaces/grouplayout.html +5 -5
- package/docs/interfaces/horizontallayout.html +4 -4
- package/docs/interfaces/initactionoptions.html +14 -0
- package/docs/interfaces/internationalizable.html +167 -0
- package/docs/interfaces/jsonformscore.html +17 -3
- package/docs/interfaces/jsonformsprops.html +9 -9
- 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 +2 -2
- package/docs/interfaces/orcondition.html +2 -2
- package/docs/interfaces/ownpropsofcell.html +9 -9
- package/docs/interfaces/ownpropsofcontrol.html +9 -12
- package/docs/interfaces/ownpropsofenum.html +1 -1
- package/docs/interfaces/ownpropsofenumcell.html +10 -10
- 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 +2 -2
- package/docs/interfaces/setajvaction.html +2 -2
- package/docs/interfaces/setconfigaction.html +2 -2
- package/docs/interfaces/setlocaleaction.html +2 -2
- package/docs/interfaces/setschemaaction.html +2 -2
- package/docs/interfaces/settranslatoraction.html +3 -3
- package/docs/interfaces/setuischemaaction.html +2 -2
- package/docs/interfaces/setvalidationmodeaction.html +2 -2
- package/docs/interfaces/statepropsofarraycontrol.html +17 -17
- package/docs/interfaces/statepropsofarraylayout.html +17 -17
- package/docs/interfaces/statepropsofcell.html +11 -11
- package/docs/interfaces/statepropsofcombinator.html +147 -40
- package/docs/interfaces/statepropsofcontrol.html +18 -15
- package/docs/interfaces/statepropsofcontrolwithdetail.html +16 -16
- package/docs/interfaces/statepropsofenumcell.html +12 -12
- package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -9
- 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/updatei18naction.html +4 -4
- package/docs/interfaces/verticallayout.html +4 -4
- package/docs/interfaces/withclassname.html +1 -1
- package/lib/actions/actions.d.ts +1 -0
- package/lib/jsonforms-core.cjs.js +201 -179
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +182 -166
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/models/uischema.d.ts +10 -1
- package/lib/reducers/core.d.ts +1 -0
- package/lib/reducers/reducers.d.ts +2 -2
- package/lib/testers/testers.d.ts +8 -7
- package/lib/util/combinators.d.ts +0 -1
- package/lib/util/path.d.ts +10 -0
- package/lib/util/renderer.d.ts +2 -2
- package/lib/util/resolvers.d.ts +1 -1
- package/lib/util/util.d.ts +1 -1
- package/package.json +2 -2
- package/src/actions/actions.ts +1 -0
- package/src/generators/uischema.ts +4 -4
- package/src/i18n/i18nUtil.ts +10 -7
- package/src/models/uischema.ts +14 -1
- package/src/reducers/core.ts +30 -3
- package/src/reducers/reducers.ts +12 -4
- package/src/testers/testers.ts +61 -34
- package/src/util/combinators.ts +17 -32
- package/src/util/label.ts +2 -2
- package/src/util/path.ts +18 -6
- package/src/util/renderer.ts +20 -32
- package/src/util/resolvers.ts +57 -68
- package/src/util/util.ts +1 -1
- package/stats.html +1 -1
- package/test/generators/uischema.test.ts +18 -0
- package/test/i18n/i18nUtil.test.ts +41 -1
- package/test/reducers/core.test.ts +203 -1
- package/test/testers.test.ts +208 -120
- package/test/util/path.test.ts +37 -20
- package/test/util/renderer.test.ts +1 -1
- package/test/util/resolvers.test.ts +99 -8
|
@@ -328,6 +328,9 @@ exports.RuleEffect = void 0;
|
|
|
328
328
|
RuleEffect["ENABLE"] = "ENABLE";
|
|
329
329
|
RuleEffect["DISABLE"] = "DISABLE";
|
|
330
330
|
})(exports.RuleEffect || (exports.RuleEffect = {}));
|
|
331
|
+
var isInternationalized = function (element) {
|
|
332
|
+
return typeof element === 'object' && element !== null && typeof element.i18n === 'string';
|
|
333
|
+
};
|
|
331
334
|
var isGroup = function (layout) {
|
|
332
335
|
return layout.type === 'Group';
|
|
333
336
|
};
|
|
@@ -386,6 +389,16 @@ function __rest(s, e) {
|
|
|
386
389
|
t[p[i]] = s[p[i]];
|
|
387
390
|
}
|
|
388
391
|
return t;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function __spreadArray(to, from, pack) {
|
|
395
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
396
|
+
if (ar || !(i in from)) {
|
|
397
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
398
|
+
ar[i] = from[i];
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
389
402
|
}
|
|
390
403
|
|
|
391
404
|
var cellReducer = function (state, _a) {
|
|
@@ -440,6 +453,7 @@ var initState = {
|
|
|
440
453
|
validator: undefined,
|
|
441
454
|
ajv: undefined,
|
|
442
455
|
validationMode: 'ValidateAndShow',
|
|
456
|
+
additionalErrors: []
|
|
443
457
|
};
|
|
444
458
|
var reuseAjvForSchema = function (ajv, schema) {
|
|
445
459
|
if (schema.hasOwnProperty('id') || schema.hasOwnProperty('$id')) {
|
|
@@ -483,6 +497,18 @@ var hasValidationModeOption = function (option) {
|
|
|
483
497
|
}
|
|
484
498
|
return false;
|
|
485
499
|
};
|
|
500
|
+
var hasAdditionalErrorsOption = function (option) {
|
|
501
|
+
if (option) {
|
|
502
|
+
return option.additionalErrors !== undefined;
|
|
503
|
+
}
|
|
504
|
+
return false;
|
|
505
|
+
};
|
|
506
|
+
var getAdditionalErrors = function (state, action) {
|
|
507
|
+
if (action && hasAdditionalErrorsOption(action.options)) {
|
|
508
|
+
return action.options.additionalErrors;
|
|
509
|
+
}
|
|
510
|
+
return state.additionalErrors;
|
|
511
|
+
};
|
|
486
512
|
var coreReducer = function (state, action) {
|
|
487
513
|
if (state === void 0) { state = initState; }
|
|
488
514
|
switch (action.type) {
|
|
@@ -491,7 +517,8 @@ var coreReducer = function (state, action) {
|
|
|
491
517
|
var validationMode = getValidationMode(state, action);
|
|
492
518
|
var v = validationMode === 'NoValidation' ? undefined : thisAjv.compile(action.schema);
|
|
493
519
|
var e = validate(v, action.data);
|
|
494
|
-
|
|
520
|
+
var additionalErrors = getAdditionalErrors(state, action);
|
|
521
|
+
return __assign(__assign({}, state), { data: action.data, schema: action.schema, uischema: action.uischema, additionalErrors: additionalErrors, errors: e, validator: v, ajv: thisAjv, validationMode: validationMode });
|
|
495
522
|
}
|
|
496
523
|
case UPDATE_CORE: {
|
|
497
524
|
var thisAjv = getOrCreateAjv(state, action);
|
|
@@ -510,15 +537,17 @@ var coreReducer = function (state, action) {
|
|
|
510
537
|
else if (state.data !== action.data) {
|
|
511
538
|
errors = validate(validator, action.data);
|
|
512
539
|
}
|
|
540
|
+
var additionalErrors = getAdditionalErrors(state, action);
|
|
513
541
|
var stateChanged = state.data !== action.data ||
|
|
514
542
|
state.schema !== action.schema ||
|
|
515
543
|
state.uischema !== action.uischema ||
|
|
516
544
|
state.ajv !== thisAjv ||
|
|
517
545
|
state.errors !== errors ||
|
|
518
546
|
state.validator !== validator ||
|
|
519
|
-
state.validationMode !== validationMode
|
|
547
|
+
state.validationMode !== validationMode ||
|
|
548
|
+
state.additionalErrors !== additionalErrors;
|
|
520
549
|
return stateChanged
|
|
521
|
-
? __assign(__assign({}, state), { data: action.data, schema: action.schema, uischema: action.uischema, ajv: thisAjv, errors: isEqual__default["default"](errors, state.errors) ? state.errors : errors, validator: validator, validationMode: validationMode }) : state;
|
|
550
|
+
? __assign(__assign({}, state), { data: action.data, schema: action.schema, uischema: action.uischema, ajv: thisAjv, errors: isEqual__default["default"](errors, state.errors) ? state.errors : errors, validator: validator, validationMode: validationMode, additionalErrors: additionalErrors }) : state;
|
|
522
551
|
}
|
|
523
552
|
case SET_AJV: {
|
|
524
553
|
var currentAjv = action.ajv;
|
|
@@ -628,7 +657,10 @@ var isObjectSchema$1 = function (schema) {
|
|
|
628
657
|
};
|
|
629
658
|
var filteredErrorKeywords = ['additionalProperties', 'allOf', 'anyOf', 'oneOf'];
|
|
630
659
|
var getErrorsAt = function (instancePath, schema, matchPath) { return function (state) {
|
|
631
|
-
|
|
660
|
+
var _a, _b;
|
|
661
|
+
var errors = (_a = state.errors) !== null && _a !== void 0 ? _a : [];
|
|
662
|
+
var additionalErrors = (_b = state.additionalErrors) !== null && _b !== void 0 ? _b : [];
|
|
663
|
+
return errorsAt(instancePath, schema, matchPath)(state.validationMode === 'ValidateAndHide' ? additionalErrors : __spreadArray(__spreadArray([], errors), additionalErrors));
|
|
632
664
|
}; };
|
|
633
665
|
var errorAt = function (instancePath, schema) {
|
|
634
666
|
return getErrorsAt(instancePath, schema, function (path) { return path === instancePath; });
|
|
@@ -653,8 +685,11 @@ var defaultDataReducer = function (state, action) {
|
|
|
653
685
|
var extractDefaultData = function (state) { return state; };
|
|
654
686
|
|
|
655
687
|
var getI18nKeyPrefixBySchema = function (schema, uischema) {
|
|
656
|
-
var _a
|
|
657
|
-
|
|
688
|
+
var _a;
|
|
689
|
+
if (isInternationalized(uischema)) {
|
|
690
|
+
return uischema.i18n;
|
|
691
|
+
}
|
|
692
|
+
return (_a = schema === null || schema === void 0 ? void 0 : schema.i18n) !== null && _a !== void 0 ? _a : undefined;
|
|
658
693
|
};
|
|
659
694
|
var transformPathToI18nPrefix = function (path) {
|
|
660
695
|
return ((path === null || path === void 0 ? void 0 : path.split('.').filter(function (segment) { return !/^\d+$/.test(segment); }).join('.')) || 'root');
|
|
@@ -670,27 +705,27 @@ var defaultTranslator = function (_id, defaultMessage) { return defaultMessage;
|
|
|
670
705
|
var defaultErrorTranslator = function (error, t, uischema) {
|
|
671
706
|
var _a;
|
|
672
707
|
var i18nKey = getI18nKey(error.parentSchema, uischema, getControlPath(error), "error." + error.keyword);
|
|
673
|
-
var specializedKeywordMessage = t(i18nKey, undefined);
|
|
708
|
+
var specializedKeywordMessage = t(i18nKey, undefined, { error: error });
|
|
674
709
|
if (specializedKeywordMessage !== undefined) {
|
|
675
710
|
return specializedKeywordMessage;
|
|
676
711
|
}
|
|
677
|
-
var genericKeywordMessage = t("error." + error.keyword, undefined);
|
|
712
|
+
var genericKeywordMessage = t("error." + error.keyword, undefined, { error: error });
|
|
678
713
|
if (genericKeywordMessage !== undefined) {
|
|
679
714
|
return genericKeywordMessage;
|
|
680
715
|
}
|
|
681
|
-
var messageCustomization = t(error.message, undefined);
|
|
716
|
+
var messageCustomization = t(error.message, undefined, { error: error });
|
|
682
717
|
if (messageCustomization !== undefined) {
|
|
683
718
|
return messageCustomization;
|
|
684
719
|
}
|
|
685
720
|
if (error.keyword === 'required' && ((_a = error.message) === null || _a === void 0 ? void 0 : _a.startsWith('must have required property'))) {
|
|
686
|
-
return t('is a required property', 'is a required property');
|
|
721
|
+
return t('is a required property', 'is a required property', { error: error });
|
|
687
722
|
}
|
|
688
723
|
return error.message;
|
|
689
724
|
};
|
|
690
725
|
var getCombinedErrorMessage = function (errors, et, t, schema, uischema, path) {
|
|
691
726
|
if (errors.length > 0 && t) {
|
|
692
727
|
var customErrorKey = getI18nKey(schema, uischema, path, 'error.custom');
|
|
693
|
-
var specializedErrorMessage = t(customErrorKey, undefined);
|
|
728
|
+
var specializedErrorMessage = t(customErrorKey, undefined, { schema: schema, uischema: uischema, path: path, errors: errors });
|
|
694
729
|
if (specializedErrorMessage !== undefined) {
|
|
695
730
|
return specializedErrorMessage;
|
|
696
731
|
}
|
|
@@ -765,7 +800,7 @@ var NOT_APPLICABLE = -1;
|
|
|
765
800
|
var isControl = function (uischema) {
|
|
766
801
|
return !isEmpty__default["default"](uischema) && uischema.scope !== undefined;
|
|
767
802
|
};
|
|
768
|
-
var schemaMatches = function (predicate) { return function (uischema, schema) {
|
|
803
|
+
var schemaMatches = function (predicate) { return function (uischema, schema, rootSchema) {
|
|
769
804
|
if (isEmpty__default["default"](uischema) || !isControl(uischema)) {
|
|
770
805
|
return false;
|
|
771
806
|
}
|
|
@@ -778,27 +813,27 @@ var schemaMatches = function (predicate) { return function (uischema, schema) {
|
|
|
778
813
|
}
|
|
779
814
|
var currentDataSchema = schema;
|
|
780
815
|
if (hasType(schema, 'object')) {
|
|
781
|
-
currentDataSchema = resolveSchema(schema, schemaPath);
|
|
816
|
+
currentDataSchema = resolveSchema(schema, schemaPath, rootSchema);
|
|
782
817
|
}
|
|
783
818
|
if (currentDataSchema === undefined) {
|
|
784
819
|
return false;
|
|
785
820
|
}
|
|
786
|
-
return predicate(currentDataSchema);
|
|
821
|
+
return predicate(currentDataSchema, rootSchema);
|
|
787
822
|
}; };
|
|
788
|
-
var schemaSubPathMatches = function (subPath, predicate) { return function (uischema, schema) {
|
|
823
|
+
var schemaSubPathMatches = function (subPath, predicate) { return function (uischema, schema, rootSchema) {
|
|
789
824
|
if (isEmpty__default["default"](uischema) || !isControl(uischema)) {
|
|
790
825
|
return false;
|
|
791
826
|
}
|
|
792
827
|
var schemaPath = uischema.scope;
|
|
793
828
|
var currentDataSchema = schema;
|
|
794
829
|
if (hasType(schema, 'object')) {
|
|
795
|
-
currentDataSchema = resolveSchema(schema, schemaPath);
|
|
830
|
+
currentDataSchema = resolveSchema(schema, schemaPath, rootSchema);
|
|
796
831
|
}
|
|
797
832
|
currentDataSchema = get__default["default"](currentDataSchema, subPath);
|
|
798
833
|
if (currentDataSchema === undefined) {
|
|
799
834
|
return false;
|
|
800
835
|
}
|
|
801
|
-
return predicate(currentDataSchema);
|
|
836
|
+
return predicate(currentDataSchema, rootSchema);
|
|
802
837
|
}; };
|
|
803
838
|
var schemaTypeIs = function (expectedType) {
|
|
804
839
|
return schemaMatches(function (schema) { return !isEmpty__default["default"](schema) && hasType(schema, expectedType); });
|
|
@@ -807,7 +842,7 @@ var formatIs = function (expectedFormat) {
|
|
|
807
842
|
return schemaMatches(function (schema) {
|
|
808
843
|
return !isEmpty__default["default"](schema) &&
|
|
809
844
|
schema.format === expectedFormat &&
|
|
810
|
-
schema
|
|
845
|
+
hasType(schema, 'string');
|
|
811
846
|
});
|
|
812
847
|
};
|
|
813
848
|
var uiTypeIs = function (expected) { return function (uischema) { return !isEmpty__default["default"](uischema) && uischema.type === expected; }; };
|
|
@@ -836,23 +871,23 @@ var and = function () {
|
|
|
836
871
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
837
872
|
testers[_i] = arguments[_i];
|
|
838
873
|
}
|
|
839
|
-
return function (uischema, schema) { return testers.reduce(function (acc, tester) { return acc && tester(uischema, schema); }, true); };
|
|
874
|
+
return function (uischema, schema, rootSchema) { return testers.reduce(function (acc, tester) { return acc && tester(uischema, schema, rootSchema); }, true); };
|
|
840
875
|
};
|
|
841
876
|
var or = function () {
|
|
842
877
|
var testers = [];
|
|
843
878
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
844
879
|
testers[_i] = arguments[_i];
|
|
845
880
|
}
|
|
846
|
-
return function (uischema, schema) { return testers.reduce(function (acc, tester) { return acc || tester(uischema, schema); }, false); };
|
|
881
|
+
return function (uischema, schema, rootSchema) { return testers.reduce(function (acc, tester) { return acc || tester(uischema, schema, rootSchema); }, false); };
|
|
847
882
|
};
|
|
848
|
-
var rankWith = function (rank, tester) { return function (uischema, schema) {
|
|
849
|
-
if (tester(uischema, schema)) {
|
|
883
|
+
var rankWith = function (rank, tester) { return function (uischema, schema, rootSchema) {
|
|
884
|
+
if (tester(uischema, schema, rootSchema)) {
|
|
850
885
|
return rank;
|
|
851
886
|
}
|
|
852
887
|
return NOT_APPLICABLE;
|
|
853
888
|
}; };
|
|
854
|
-
var withIncreasedRank = function (by, rankedTester) { return function (uischema, schema) {
|
|
855
|
-
var rank = rankedTester(uischema, schema);
|
|
889
|
+
var withIncreasedRank = function (by, rankedTester) { return function (uischema, schema, rootSchema) {
|
|
890
|
+
var rank = rankedTester(uischema, schema, rootSchema);
|
|
856
891
|
if (rank === NOT_APPLICABLE) {
|
|
857
892
|
return NOT_APPLICABLE;
|
|
858
893
|
}
|
|
@@ -875,33 +910,42 @@ var isMultiLineControl = and(uiTypeIs('Control'), optionIs('multi', true));
|
|
|
875
910
|
var isDateControl = and(uiTypeIs('Control'), or(formatIs('date'), optionIs('format', 'date')));
|
|
876
911
|
var isTimeControl = and(uiTypeIs('Control'), or(formatIs('time'), optionIs('format', 'time')));
|
|
877
912
|
var isDateTimeControl = and(uiTypeIs('Control'), or(formatIs('date-time'), optionIs('format', 'date-time')));
|
|
878
|
-
var isObjectArray = and(schemaMatches(function (schema) { return hasType(schema, 'array') && !Array.isArray(schema
|
|
879
|
-
), schemaSubPathMatches('items', function (schema
|
|
913
|
+
var isObjectArray = and(schemaMatches(function (schema, rootSchema) { return hasType(schema, 'array') && !Array.isArray(resolveSchema(schema, 'items', rootSchema)); }
|
|
914
|
+
), schemaSubPathMatches('items', function (schema, rootSchema) {
|
|
915
|
+
var resolvedSchema = schema.$ref ? resolveSchema(rootSchema, schema.$ref, rootSchema) : schema;
|
|
916
|
+
return hasType(resolvedSchema, 'object');
|
|
917
|
+
}));
|
|
880
918
|
var isObjectArrayControl = and(uiTypeIs('Control'), isObjectArray);
|
|
881
|
-
var traverse = function (any, pred) {
|
|
919
|
+
var traverse = function (any, pred, rootSchema) {
|
|
882
920
|
if (isArray__default["default"](any)) {
|
|
883
|
-
return reduce__default["default"](any, function (acc, el) { return acc || traverse(el, pred); }, false);
|
|
921
|
+
return reduce__default["default"](any, function (acc, el) { return acc || traverse(el, pred, rootSchema); }, false);
|
|
884
922
|
}
|
|
885
923
|
if (pred(any)) {
|
|
886
924
|
return true;
|
|
887
925
|
}
|
|
926
|
+
if (any.$ref) {
|
|
927
|
+
var toTraverse = resolveSchema(rootSchema, any.$ref, rootSchema);
|
|
928
|
+
if (toTraverse && !toTraverse.$ref) {
|
|
929
|
+
return traverse(toTraverse, pred, rootSchema);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
888
932
|
if (any.items) {
|
|
889
|
-
return traverse(any.items, pred);
|
|
933
|
+
return traverse(any.items, pred, rootSchema);
|
|
890
934
|
}
|
|
891
935
|
if (any.properties) {
|
|
892
936
|
return reduce__default["default"](toPairs__default["default"](any.properties), function (acc, _a) {
|
|
893
937
|
_a[0]; var val = _a[1];
|
|
894
|
-
return acc || traverse(val, pred);
|
|
938
|
+
return acc || traverse(val, pred, rootSchema);
|
|
895
939
|
}, false);
|
|
896
940
|
}
|
|
897
941
|
return false;
|
|
898
942
|
};
|
|
899
|
-
var isObjectArrayWithNesting = function (uischema, schema) {
|
|
900
|
-
if (!uiTypeIs('Control')(uischema, schema)) {
|
|
943
|
+
var isObjectArrayWithNesting = function (uischema, schema, rootSchema) {
|
|
944
|
+
if (!uiTypeIs('Control')(uischema, schema, rootSchema)) {
|
|
901
945
|
return false;
|
|
902
946
|
}
|
|
903
947
|
var schemaPath = uischema.scope;
|
|
904
|
-
var resolvedSchema = resolveSchema(schema, schemaPath);
|
|
948
|
+
var resolvedSchema = resolveSchema(schema, schemaPath, rootSchema !== null && rootSchema !== void 0 ? rootSchema : schema);
|
|
905
949
|
var wantedNestingByType = {
|
|
906
950
|
object: 2,
|
|
907
951
|
array: 1
|
|
@@ -911,6 +955,9 @@ var isObjectArrayWithNesting = function (uischema, schema) {
|
|
|
911
955
|
if (val === schema) {
|
|
912
956
|
return false;
|
|
913
957
|
}
|
|
958
|
+
if (val.$ref !== undefined) {
|
|
959
|
+
return false;
|
|
960
|
+
}
|
|
914
961
|
if (typeof val.type !== 'string') {
|
|
915
962
|
return true;
|
|
916
963
|
}
|
|
@@ -920,7 +967,7 @@ var isObjectArrayWithNesting = function (uischema, schema) {
|
|
|
920
967
|
}
|
|
921
968
|
wantedNestingByType[val.type] = typeCount - 1;
|
|
922
969
|
return wantedNestingByType[val.type] === 0;
|
|
923
|
-
})) {
|
|
970
|
+
}, rootSchema)) {
|
|
924
971
|
return true;
|
|
925
972
|
}
|
|
926
973
|
if (uischema.options && uischema.options.detail) {
|
|
@@ -936,9 +983,13 @@ var isObjectArrayWithNesting = function (uischema, schema) {
|
|
|
936
983
|
return false;
|
|
937
984
|
};
|
|
938
985
|
var isArrayObjectControl = isObjectArrayControl;
|
|
939
|
-
var isPrimitiveArrayControl = and(uiTypeIs('Control'), schemaMatches(function (schema) {
|
|
940
|
-
|
|
941
|
-
|
|
986
|
+
var isPrimitiveArrayControl = and(uiTypeIs('Control'), schemaMatches(function (schema, rootSchema) {
|
|
987
|
+
return deriveTypes(schema).length !== 0 &&
|
|
988
|
+
!Array.isArray(resolveSchema(schema, 'items', rootSchema));
|
|
989
|
+
}
|
|
990
|
+
), schemaSubPathMatches('items', function (schema, rootSchema) {
|
|
991
|
+
var resolvedSchema = schema.$ref ? resolveSchema(rootSchema, schema.$ref, rootSchema) : schema;
|
|
992
|
+
var types = deriveTypes(resolvedSchema);
|
|
942
993
|
return (types.length === 1 &&
|
|
943
994
|
includes__default["default"](['integer', 'number', 'boolean', 'string'], types[0]));
|
|
944
995
|
}));
|
|
@@ -965,7 +1016,7 @@ var hasCategory = function (categorization) {
|
|
|
965
1016
|
var categorizationHasCategory = function (uischema) {
|
|
966
1017
|
return hasCategory(uischema);
|
|
967
1018
|
};
|
|
968
|
-
var not = function (tester) { return function (uischema, schema) { return !tester(uischema, schema); }; };
|
|
1019
|
+
var not = function (tester) { return function (uischema, schema, rootSchema) { return !tester(uischema, schema, rootSchema); }; };
|
|
969
1020
|
|
|
970
1021
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
971
1022
|
__proto__: null,
|
|
@@ -1046,12 +1097,15 @@ var jsonFormsReducerConfig = {
|
|
|
1046
1097
|
defaultData: defaultDataReducer,
|
|
1047
1098
|
i18n: i18nReducer,
|
|
1048
1099
|
};
|
|
1049
|
-
var findUISchema = function (uischemas, schema, schemaPath, path,
|
|
1050
|
-
if (
|
|
1100
|
+
var findUISchema = function (uischemas, schema, schemaPath, path, fallback, control, rootSchema) {
|
|
1101
|
+
if (fallback === void 0) { fallback = 'VerticalLayout'; }
|
|
1051
1102
|
if (control && control.options && control.options.detail) {
|
|
1052
1103
|
if (typeof control.options.detail === 'string') {
|
|
1053
1104
|
if (control.options.detail.toUpperCase() === 'GENERATE') {
|
|
1054
|
-
|
|
1105
|
+
if (typeof fallback === "function") {
|
|
1106
|
+
return fallback();
|
|
1107
|
+
}
|
|
1108
|
+
return Generate.uiSchema(schema, fallback);
|
|
1055
1109
|
}
|
|
1056
1110
|
}
|
|
1057
1111
|
else if (typeof control.options.detail === 'object') {
|
|
@@ -1063,7 +1117,10 @@ var findUISchema = function (uischemas, schema, schemaPath, path, fallbackLayout
|
|
|
1063
1117
|
}
|
|
1064
1118
|
var uiSchema = findMatchingUISchema(uischemas)(schema, schemaPath, path);
|
|
1065
1119
|
if (uiSchema === undefined) {
|
|
1066
|
-
|
|
1120
|
+
if (typeof fallback === 'function') {
|
|
1121
|
+
return fallback();
|
|
1122
|
+
}
|
|
1123
|
+
return Generate.uiSchema(schema, fallback, '#', rootSchema);
|
|
1067
1124
|
}
|
|
1068
1125
|
return uiSchema;
|
|
1069
1126
|
};
|
|
@@ -1095,6 +1152,44 @@ var getRenderers = function (state) { return get__default["default"](state, 'jso
|
|
|
1095
1152
|
var getCells = function (state) { return get__default["default"](state, 'jsonforms.cells'); };
|
|
1096
1153
|
var getUISchemas = function (state) { return get__default["default"](state, 'jsonforms.uischemas'); };
|
|
1097
1154
|
|
|
1155
|
+
var compose = function (path1, path2) {
|
|
1156
|
+
var p1 = path1;
|
|
1157
|
+
if (!isEmpty__default["default"](path1) && !isEmpty__default["default"](path2) && !path2.startsWith('[')) {
|
|
1158
|
+
p1 = path1 + '.';
|
|
1159
|
+
}
|
|
1160
|
+
if (isEmpty__default["default"](p1)) {
|
|
1161
|
+
return path2;
|
|
1162
|
+
}
|
|
1163
|
+
else if (isEmpty__default["default"](path2)) {
|
|
1164
|
+
return p1;
|
|
1165
|
+
}
|
|
1166
|
+
else {
|
|
1167
|
+
return "" + p1 + path2;
|
|
1168
|
+
}
|
|
1169
|
+
};
|
|
1170
|
+
var toDataPathSegments = function (schemaPath) {
|
|
1171
|
+
var s = schemaPath
|
|
1172
|
+
.replace(/(anyOf|allOf|oneOf)\/[\d]\//g, '')
|
|
1173
|
+
.replace(/(then|else)\//g, '');
|
|
1174
|
+
var segments = s.split('/');
|
|
1175
|
+
var decodedSegments = segments.map(decode);
|
|
1176
|
+
var startFromRoot = decodedSegments[0] === '#' || decodedSegments[0] === '';
|
|
1177
|
+
var startIndex = startFromRoot ? 2 : 1;
|
|
1178
|
+
return range__default["default"](startIndex, decodedSegments.length, 2).map(function (idx) { return decodedSegments[idx]; });
|
|
1179
|
+
};
|
|
1180
|
+
var toDataPath = function (schemaPath) {
|
|
1181
|
+
return toDataPathSegments(schemaPath).join('.');
|
|
1182
|
+
};
|
|
1183
|
+
var composeWithUi = function (scopableUi, path) {
|
|
1184
|
+
var segments = toDataPathSegments(scopableUi.scope);
|
|
1185
|
+
if (isEmpty__default["default"](segments) && path === undefined) {
|
|
1186
|
+
return '';
|
|
1187
|
+
}
|
|
1188
|
+
return isEmpty__default["default"](segments) ? path : compose(path, segments.join('.'));
|
|
1189
|
+
};
|
|
1190
|
+
var encode = function (segment) { return segment === null || segment === void 0 ? void 0 : segment.replace(/~/g, '~0').replace(/\//g, '~1'); };
|
|
1191
|
+
var decode = function (pointerSegment) { return pointerSegment === null || pointerSegment === void 0 ? void 0 : pointerSegment.replace(/~1/g, '/').replace(/~0/, '~'); };
|
|
1192
|
+
|
|
1098
1193
|
var isObjectSchema = function (schema) {
|
|
1099
1194
|
return schema.properties !== undefined;
|
|
1100
1195
|
};
|
|
@@ -1147,92 +1242,42 @@ var invalidSegment = function (pathSegment) {
|
|
|
1147
1242
|
return pathSegment === '#' || pathSegment === undefined || pathSegment === '';
|
|
1148
1243
|
};
|
|
1149
1244
|
var resolveSchema = function (schema, schemaPath, rootSchema) {
|
|
1150
|
-
var
|
|
1245
|
+
var segments = schemaPath === null || schemaPath === void 0 ? void 0 : schemaPath.split('/').map(decode);
|
|
1246
|
+
return resolveSchemaWithSegments(schema, segments, rootSchema);
|
|
1247
|
+
};
|
|
1248
|
+
var resolveSchemaWithSegments = function (schema, pathSegments, rootSchema) {
|
|
1249
|
+
var _a, _b, _c, _d, _e;
|
|
1151
1250
|
if (isEmpty__default["default"](schema)) {
|
|
1152
1251
|
return undefined;
|
|
1153
1252
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
for (var i = 0; i < validPathSegments.length; i++) {
|
|
1157
|
-
var pathSegment = validPathSegments[i];
|
|
1158
|
-
resultSchema =
|
|
1159
|
-
resultSchema === undefined || resultSchema.$ref === undefined
|
|
1160
|
-
? resultSchema
|
|
1161
|
-
: resolveSchema(schema, resultSchema.$ref);
|
|
1162
|
-
if (invalidSegment(pathSegment)) {
|
|
1163
|
-
continue;
|
|
1164
|
-
}
|
|
1165
|
-
var curSchema = get__default["default"](resultSchema, pathSegment);
|
|
1166
|
-
if (!curSchema) {
|
|
1167
|
-
var schemas = [].concat((_a = resultSchema === null || resultSchema === void 0 ? void 0 : resultSchema.oneOf) !== null && _a !== void 0 ? _a : [], (_b = resultSchema === null || resultSchema === void 0 ? void 0 : resultSchema.allOf) !== null && _b !== void 0 ? _b : [], (_c = resultSchema === null || resultSchema === void 0 ? void 0 : resultSchema.anyOf) !== null && _c !== void 0 ? _c : []);
|
|
1168
|
-
for (var _i = 0, schemas_1 = schemas; _i < schemas_1.length; _i++) {
|
|
1169
|
-
var item = schemas_1[_i];
|
|
1170
|
-
curSchema = resolveSchema(item, validPathSegments.slice(i).join('/'));
|
|
1171
|
-
if (curSchema) {
|
|
1172
|
-
break;
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
if (curSchema) {
|
|
1176
|
-
resultSchema = curSchema;
|
|
1177
|
-
break;
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
resultSchema = curSchema;
|
|
1181
|
-
}
|
|
1182
|
-
if (resultSchema !== undefined && resultSchema.$ref !== undefined) {
|
|
1183
|
-
try {
|
|
1184
|
-
return retrieveResolvableSchema(schema, resultSchema.$ref);
|
|
1185
|
-
}
|
|
1186
|
-
catch (e) {
|
|
1187
|
-
return retrieveResolvableSchema(rootSchema, resultSchema.$ref);
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
return resultSchema;
|
|
1191
|
-
};
|
|
1192
|
-
function retrieveResolvableSchema(full, reference) {
|
|
1193
|
-
var child = resolveSchema(full, reference);
|
|
1194
|
-
var allRefs = findAllRefs(child);
|
|
1195
|
-
var innerSelfReference = allRefs[reference];
|
|
1196
|
-
if (innerSelfReference !== undefined) {
|
|
1197
|
-
innerSelfReference.$ref = '#';
|
|
1198
|
-
}
|
|
1199
|
-
return child;
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
var compose = function (path1, path2) {
|
|
1203
|
-
var p1 = path1;
|
|
1204
|
-
if (!isEmpty__default["default"](path1) && !isEmpty__default["default"](path2) && !path2.startsWith('[')) {
|
|
1205
|
-
p1 = path1 + '.';
|
|
1253
|
+
if (schema.$ref) {
|
|
1254
|
+
schema = resolveSchema(rootSchema, schema.$ref, rootSchema);
|
|
1206
1255
|
}
|
|
1207
|
-
if (
|
|
1208
|
-
return
|
|
1256
|
+
if (!pathSegments || pathSegments.length === 0) {
|
|
1257
|
+
return schema;
|
|
1209
1258
|
}
|
|
1210
|
-
|
|
1211
|
-
|
|
1259
|
+
var segment = pathSegments[0], remainingSegments = pathSegments.slice(1);
|
|
1260
|
+
if (invalidSegment(segment)) {
|
|
1261
|
+
return resolveSchemaWithSegments(schema, remainingSegments, rootSchema);
|
|
1212
1262
|
}
|
|
1213
|
-
|
|
1214
|
-
|
|
1263
|
+
var singleSegmentResolveSchema = get__default["default"](schema, segment);
|
|
1264
|
+
var resolvedSchema = resolveSchemaWithSegments(singleSegmentResolveSchema, remainingSegments, rootSchema);
|
|
1265
|
+
if (resolvedSchema) {
|
|
1266
|
+
return resolvedSchema;
|
|
1215
1267
|
}
|
|
1216
|
-
|
|
1217
|
-
var
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
var toDataPath = function (schemaPath) {
|
|
1228
|
-
return toDataPathSegments(schemaPath).join('.');
|
|
1229
|
-
};
|
|
1230
|
-
var composeWithUi = function (scopableUi, path) {
|
|
1231
|
-
var segments = toDataPathSegments(scopableUi.scope);
|
|
1232
|
-
if (isEmpty__default["default"](segments) && path === undefined) {
|
|
1233
|
-
return '';
|
|
1268
|
+
if (segment === 'properties' || segment === 'items') {
|
|
1269
|
+
var alternativeResolveResult = undefined;
|
|
1270
|
+
var subSchemas = [].concat((_a = schema.oneOf) !== null && _a !== void 0 ? _a : [], (_b = schema.allOf) !== null && _b !== void 0 ? _b : [], (_c = schema.anyOf) !== null && _c !== void 0 ? _c : [], (_d = schema.then) !== null && _d !== void 0 ? _d : [], (_e = schema.else) !== null && _e !== void 0 ? _e : []);
|
|
1271
|
+
for (var _i = 0, subSchemas_1 = subSchemas; _i < subSchemas_1.length; _i++) {
|
|
1272
|
+
var subSchema = subSchemas_1[_i];
|
|
1273
|
+
alternativeResolveResult = resolveSchemaWithSegments(subSchema, __spreadArray([segment], remainingSegments), rootSchema);
|
|
1274
|
+
if (alternativeResolveResult) {
|
|
1275
|
+
break;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
return alternativeResolveResult;
|
|
1234
1279
|
}
|
|
1235
|
-
return
|
|
1280
|
+
return undefined;
|
|
1236
1281
|
};
|
|
1237
1282
|
|
|
1238
1283
|
var isOrCondition = function (condition) {
|
|
@@ -1417,7 +1462,7 @@ var deriveLabel = function (controlElement, schemaElement) {
|
|
|
1417
1462
|
}
|
|
1418
1463
|
if (typeof controlElement.scope === 'string') {
|
|
1419
1464
|
var ref = controlElement.scope;
|
|
1420
|
-
var label = ref.substr(ref.lastIndexOf('/') + 1);
|
|
1465
|
+
var label = decode(ref.substr(ref.lastIndexOf('/') + 1));
|
|
1421
1466
|
return startCase__default["default"](label);
|
|
1422
1467
|
}
|
|
1423
1468
|
return '';
|
|
@@ -1447,32 +1492,6 @@ var labelDescription = function (text, show) { return ({
|
|
|
1447
1492
|
show: show
|
|
1448
1493
|
}); };
|
|
1449
1494
|
|
|
1450
|
-
var createLabel = function (subSchema, subSchemaIndex, keyword) {
|
|
1451
|
-
if (subSchema.title) {
|
|
1452
|
-
return subSchema.title;
|
|
1453
|
-
}
|
|
1454
|
-
else {
|
|
1455
|
-
return keyword + '-' + subSchemaIndex;
|
|
1456
|
-
}
|
|
1457
|
-
};
|
|
1458
|
-
var resolveSubSchemas = function (schema, rootSchema, keyword) {
|
|
1459
|
-
var _a;
|
|
1460
|
-
var schemas = schema[keyword];
|
|
1461
|
-
if (schemas.findIndex(function (e) { return e.$ref !== undefined; }) !== -1) {
|
|
1462
|
-
return __assign(__assign({}, schema), (_a = {}, _a[keyword] = schema[keyword].map(function (e) {
|
|
1463
|
-
return e.$ref ? resolveSchema(rootSchema, e.$ref) : e;
|
|
1464
|
-
}), _a));
|
|
1465
|
-
}
|
|
1466
|
-
return schema;
|
|
1467
|
-
};
|
|
1468
|
-
var createCombinatorRenderInfos = function (combinatorSubSchemas, rootSchema, keyword, control, path, uischemas) {
|
|
1469
|
-
return combinatorSubSchemas.map(function (subSchema, subSchemaIndex) { return ({
|
|
1470
|
-
schema: subSchema,
|
|
1471
|
-
uischema: findUISchema(uischemas, subSchema, control.scope, path, undefined, control, rootSchema),
|
|
1472
|
-
label: createLabel(subSchema, subSchemaIndex, keyword)
|
|
1473
|
-
}); });
|
|
1474
|
-
};
|
|
1475
|
-
|
|
1476
1495
|
var isRequired = function (schema, schemaPath, rootSchema) {
|
|
1477
1496
|
var pathSegments = schemaPath.split('/');
|
|
1478
1497
|
var lastSegment = pathSegments[pathSegments.length - 1];
|
|
@@ -1570,8 +1589,8 @@ var mapStateToControlProps = function (state, ownProps) {
|
|
|
1570
1589
|
var schema = resolvedSchema !== null && resolvedSchema !== void 0 ? resolvedSchema : rootSchema;
|
|
1571
1590
|
var t = getTranslator()(state);
|
|
1572
1591
|
var te = getErrorTranslator()(state);
|
|
1573
|
-
var i18nLabel = t(getI18nKey(schema, uischema, path, 'label'), label);
|
|
1574
|
-
var i18nDescription = t(getI18nKey(schema, uischema, path, 'description'), description);
|
|
1592
|
+
var i18nLabel = t(getI18nKey(schema, uischema, path, 'label'), label, { schema: schema, uischema: uischema, path: path, errors: errors });
|
|
1593
|
+
var i18nDescription = t(getI18nKey(schema, uischema, path, 'description'), description, { schema: schema, uischema: uischema, path: path, errors: errors });
|
|
1575
1594
|
var i18nErrorMessage = getCombinedErrorMessage(errors, te, t, schema, uischema, path);
|
|
1576
1595
|
return {
|
|
1577
1596
|
data: data,
|
|
@@ -1735,13 +1754,13 @@ var mapStateToLayoutProps = function (state, ownProps) {
|
|
|
1735
1754
|
var enabled = isInherentlyEnabled(state, ownProps, uischema, undefined,
|
|
1736
1755
|
rootData, config);
|
|
1737
1756
|
return __assign(__assign({}, layoutDefaultProps), { renderers: ownProps.renderers || getRenderers(state), cells: ownProps.cells || getCells(state), visible: visible,
|
|
1738
|
-
enabled: enabled, path: ownProps.path, data: data, uischema: ownProps.uischema, schema: ownProps.schema, direction: (_a = ownProps.direction) !== null && _a !== void 0 ? _a : getDirection(uischema) });
|
|
1757
|
+
enabled: enabled, path: ownProps.path, data: data, uischema: ownProps.uischema, schema: ownProps.schema, direction: (_a = ownProps.direction) !== null && _a !== void 0 ? _a : getDirection(uischema), config: config });
|
|
1739
1758
|
};
|
|
1740
1759
|
var mapStateToJsonFormsRendererProps = function (state, ownProps) {
|
|
1741
1760
|
var uischema = ownProps.uischema;
|
|
1742
1761
|
if (uischema === undefined) {
|
|
1743
1762
|
if (ownProps.schema) {
|
|
1744
|
-
uischema = findUISchema(state.jsonforms.uischemas, ownProps.schema, undefined, ownProps.path);
|
|
1763
|
+
uischema = findUISchema(state.jsonforms.uischemas, ownProps.schema, undefined, ownProps.path, undefined, undefined, state.jsonforms.core.schema);
|
|
1745
1764
|
}
|
|
1746
1765
|
else {
|
|
1747
1766
|
uischema = getUiSchema(state);
|
|
@@ -1758,18 +1777,9 @@ var mapStateToJsonFormsRendererProps = function (state, ownProps) {
|
|
|
1758
1777
|
};
|
|
1759
1778
|
var controlDefaultProps = __assign(__assign({}, layoutDefaultProps), { errors: [] });
|
|
1760
1779
|
var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
|
|
1761
|
-
var
|
|
1762
|
-
var
|
|
1763
|
-
var rootSchema = getSchema(state);
|
|
1764
|
-
var resolvedSchema = Resolve.schema(ownProps.schema || rootSchema, uischema.scope, rootSchema);
|
|
1765
|
-
var visible = ownProps.visible === undefined || hasShowRule(uischema)
|
|
1766
|
-
? isVisible(uischema, getData(state), ownProps.path, getAjv(state))
|
|
1767
|
-
: ownProps.visible;
|
|
1768
|
-
var id = ownProps.id;
|
|
1769
|
-
var data = Resolve.data(getData(state), path);
|
|
1780
|
+
var _a;
|
|
1781
|
+
var _b = mapStateToControlProps(state, ownProps), data = _b.data, schema = _b.schema, props = __rest(_b, ["data", "schema"]);
|
|
1770
1782
|
var ajv = state.jsonforms.core.ajv;
|
|
1771
|
-
var schema = resolvedSchema || rootSchema;
|
|
1772
|
-
var _schema = resolveSubSchemas(schema, rootSchema, keyword);
|
|
1773
1783
|
var structuralKeywords = [
|
|
1774
1784
|
'required',
|
|
1775
1785
|
'additionalProperties',
|
|
@@ -1783,9 +1793,9 @@ var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
|
|
|
1783
1793
|
!errors.find(function (e) { return structuralKeywords.indexOf(e.keyword) !== -1; }));
|
|
1784
1794
|
};
|
|
1785
1795
|
var indexOfFittingSchema;
|
|
1786
|
-
for (var i = 0; i <
|
|
1796
|
+
for (var i = 0; i < ((_a = schema[keyword]) === null || _a === void 0 ? void 0 : _a.length); i++) {
|
|
1787
1797
|
try {
|
|
1788
|
-
var valFn = ajv.compile(
|
|
1798
|
+
var valFn = ajv.compile(schema[keyword][i]);
|
|
1789
1799
|
valFn(data);
|
|
1790
1800
|
if (dataIsValid(valFn.errors)) {
|
|
1791
1801
|
indexOfFittingSchema = i;
|
|
@@ -1796,17 +1806,8 @@ var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
|
|
|
1796
1806
|
console.debug("Combinator subschema is not self contained, can't hand it over to AJV");
|
|
1797
1807
|
}
|
|
1798
1808
|
}
|
|
1799
|
-
return {
|
|
1800
|
-
|
|
1801
|
-
path: path,
|
|
1802
|
-
schema: schema,
|
|
1803
|
-
rootSchema: rootSchema,
|
|
1804
|
-
visible: visible,
|
|
1805
|
-
id: id,
|
|
1806
|
-
indexOfFittingSchema: indexOfFittingSchema,
|
|
1807
|
-
uischemas: state.jsonforms.uischemas,
|
|
1808
|
-
uischema: uischema
|
|
1809
|
-
};
|
|
1809
|
+
return __assign(__assign({ data: data,
|
|
1810
|
+
schema: schema }, props), { indexOfFittingSchema: indexOfFittingSchema, uischemas: getUISchemas(state) });
|
|
1810
1811
|
};
|
|
1811
1812
|
var mapStateToAllOfProps = function (state, ownProps) {
|
|
1812
1813
|
return mapStateToCombinatorRendererProps(state, ownProps, 'allOf');
|
|
@@ -1899,6 +1900,25 @@ function (dispatch, ownProps) {
|
|
|
1899
1900
|
};
|
|
1900
1901
|
};
|
|
1901
1902
|
|
|
1903
|
+
var createLabel = function (subSchema, subSchemaIndex, keyword) {
|
|
1904
|
+
if (subSchema.title) {
|
|
1905
|
+
return subSchema.title;
|
|
1906
|
+
}
|
|
1907
|
+
else {
|
|
1908
|
+
return keyword + '-' + subSchemaIndex;
|
|
1909
|
+
}
|
|
1910
|
+
};
|
|
1911
|
+
var createCombinatorRenderInfos = function (combinatorSubSchemas, rootSchema, keyword, control, path, uischemas) {
|
|
1912
|
+
return combinatorSubSchemas.map(function (subSchema, subSchemaIndex) {
|
|
1913
|
+
var schema = subSchema.$ref ? Resolve.schema(rootSchema, subSchema.$ref, rootSchema) : subSchema;
|
|
1914
|
+
return {
|
|
1915
|
+
schema: schema,
|
|
1916
|
+
uischema: findUISchema(uischemas, schema, control.scope, path, undefined, control, rootSchema),
|
|
1917
|
+
label: createLabel(subSchema, subSchemaIndex, keyword)
|
|
1918
|
+
};
|
|
1919
|
+
});
|
|
1920
|
+
};
|
|
1921
|
+
|
|
1902
1922
|
var usedIds = new Set();
|
|
1903
1923
|
var makeId = function (idBase, iteration) {
|
|
1904
1924
|
return iteration <= 1 ? idBase : idBase + iteration.toString();
|
|
@@ -2002,7 +2022,7 @@ var isCombinator = function (jsonSchema) {
|
|
|
2002
2022
|
};
|
|
2003
2023
|
var generateUISchema = function (jsonSchema, schemaElements, currentRef, schemaName, layoutType, rootSchema) {
|
|
2004
2024
|
if (!isEmpty__default["default"](jsonSchema) && jsonSchema.$ref !== undefined) {
|
|
2005
|
-
return generateUISchema(resolveSchema(rootSchema, jsonSchema.$ref), schemaElements, currentRef, schemaName, layoutType, rootSchema);
|
|
2025
|
+
return generateUISchema(resolveSchema(rootSchema, jsonSchema.$ref, rootSchema), schemaElements, currentRef, schemaName, layoutType, rootSchema);
|
|
2006
2026
|
}
|
|
2007
2027
|
if (isCombinator(jsonSchema)) {
|
|
2008
2028
|
var controlObject = createControlElement(currentRef);
|
|
@@ -2028,9 +2048,9 @@ var generateUISchema = function (jsonSchema, schemaElements, currentRef, schemaN
|
|
|
2028
2048
|
var nextRef_1 = currentRef + '/properties';
|
|
2029
2049
|
Object.keys(jsonSchema.properties).map(function (propName) {
|
|
2030
2050
|
var value = jsonSchema.properties[propName];
|
|
2031
|
-
var ref = nextRef_1 + "/" + propName;
|
|
2051
|
+
var ref = nextRef_1 + "/" + encode(propName);
|
|
2032
2052
|
if (value.$ref !== undefined) {
|
|
2033
|
-
value = resolveSchema(rootSchema, value.$ref);
|
|
2053
|
+
value = resolveSchema(rootSchema, value.$ref, rootSchema);
|
|
2034
2054
|
}
|
|
2035
2055
|
generateUISchema(value, layout_1.elements, ref, propName, layoutType, rootSchema);
|
|
2036
2056
|
});
|
|
@@ -2288,6 +2308,7 @@ exports.createControlElement = createControlElement;
|
|
|
2288
2308
|
exports.createDefaultValue = createDefaultValue;
|
|
2289
2309
|
exports.createId = createId;
|
|
2290
2310
|
exports.createLabelDescriptionFrom = createLabelDescriptionFrom;
|
|
2311
|
+
exports.decode = decode;
|
|
2291
2312
|
exports.defaultDataReducer = defaultDataReducer;
|
|
2292
2313
|
exports.defaultErrorTranslator = defaultErrorTranslator;
|
|
2293
2314
|
exports.defaultJsonFormsI18nState = defaultJsonFormsI18nState;
|
|
@@ -2295,6 +2316,7 @@ exports.defaultMapDispatchToControlProps = defaultMapDispatchToControlProps;
|
|
|
2295
2316
|
exports.defaultMapStateToEnumCellProps = defaultMapStateToEnumCellProps;
|
|
2296
2317
|
exports.defaultTranslator = defaultTranslator;
|
|
2297
2318
|
exports.deriveTypes = deriveTypes;
|
|
2319
|
+
exports.encode = encode;
|
|
2298
2320
|
exports.enumToEnumOptionMapper = enumToEnumOptionMapper;
|
|
2299
2321
|
exports.errorAt = errorAt;
|
|
2300
2322
|
exports.errorsAt = errorsAt;
|
|
@@ -2356,6 +2378,7 @@ exports.isEnumControl = isEnumControl;
|
|
|
2356
2378
|
exports.isGroup = isGroup;
|
|
2357
2379
|
exports.isInherentlyEnabled = isInherentlyEnabled;
|
|
2358
2380
|
exports.isIntegerControl = isIntegerControl;
|
|
2381
|
+
exports.isInternationalized = isInternationalized;
|
|
2359
2382
|
exports.isLayout = isLayout;
|
|
2360
2383
|
exports.isMultiLineControl = isMultiLineControl;
|
|
2361
2384
|
exports.isNumberControl = isNumberControl;
|
|
@@ -2410,7 +2433,6 @@ exports.removeId = removeId;
|
|
|
2410
2433
|
exports.rendererReducer = rendererReducer;
|
|
2411
2434
|
exports.resolveData = resolveData;
|
|
2412
2435
|
exports.resolveSchema = resolveSchema;
|
|
2413
|
-
exports.resolveSubSchemas = resolveSubSchemas;
|
|
2414
2436
|
exports.schemaMatches = schemaMatches;
|
|
2415
2437
|
exports.schemaSubPathMatches = schemaSubPathMatches;
|
|
2416
2438
|
exports.schemaTypeIs = schemaTypeIs;
|