@jsonforms/core 3.0.0-beta.2 → 3.0.0-beta.5
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 +307 -89
- package/docs/index.html +47 -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/arraylayoutprops.html +2 -2
- package/docs/interfaces/categorization.html +24 -16
- package/docs/interfaces/category.html +24 -16
- package/docs/interfaces/combinatorrendererprops.html +6 -6
- package/docs/interfaces/composablecondition.html +2 -2
- package/docs/interfaces/condition.html +1 -1
- package/docs/interfaces/controlelement.html +38 -15
- package/docs/interfaces/grouplayout.html +24 -12
- package/docs/interfaces/horizontallayout.html +4 -4
- package/docs/interfaces/initactionoptions.html +14 -0
- package/docs/interfaces/internationalizable.html +158 -0
- package/docs/interfaces/jsonformscore.html +17 -3
- package/docs/interfaces/labeldescription.html +2 -2
- package/docs/interfaces/labeled.html +182 -0
- package/docs/interfaces/labelelement.html +4 -4
- package/docs/interfaces/lableable.html +184 -0
- package/docs/interfaces/layout.html +4 -4
- package/docs/interfaces/leafcondition.html +9 -8
- package/docs/interfaces/orcondition.html +2 -2
- 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/rule.html +2 -2
- package/docs/interfaces/schemabasedcondition.html +9 -8
- package/docs/interfaces/scopable.html +3 -9
- package/docs/interfaces/scoped.html +183 -0
- 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/statepropsofarraylayout.html +2 -2
- package/docs/interfaces/statepropsofcombinator.html +6 -6
- 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/lib/actions/actions.d.ts +1 -0
- package/lib/jsonforms-core.cjs.js +74 -31
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +60 -29
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/models/uischema.d.ts +40 -23
- package/lib/reducers/core.d.ts +1 -0
- package/lib/util/runtime.d.ts +1 -2
- package/lib/util/util.d.ts +6 -6
- package/package.json +2 -2
- package/src/actions/actions.ts +1 -0
- package/src/i18n/i18nUtil.ts +10 -7
- package/src/models/uischema.ts +59 -23
- package/src/reducers/core.ts +30 -3
- package/src/testers/testers.ts +10 -13
- package/src/util/path.ts +9 -5
- package/src/util/renderer.ts +6 -3
- package/src/util/runtime.ts +1 -1
- package/src/util/util.ts +8 -8
- package/stats.html +1 -1
- package/test/i18n/i18nUtil.test.ts +41 -1
- package/test/reducers/core.test.ts +203 -1
- package/test/util/renderer.test.ts +1 -1
|
@@ -328,12 +328,27 @@ 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
|
};
|
|
334
337
|
var isLayout = function (uischema) {
|
|
335
338
|
return uischema.elements !== undefined;
|
|
336
339
|
};
|
|
340
|
+
var isScopable = function (obj) {
|
|
341
|
+
return obj && typeof obj === 'object';
|
|
342
|
+
};
|
|
343
|
+
var isScoped = function (obj) {
|
|
344
|
+
return isScopable(obj) && typeof obj.scope === 'string';
|
|
345
|
+
};
|
|
346
|
+
var isLabelable = function (obj) {
|
|
347
|
+
return obj && typeof obj === 'object';
|
|
348
|
+
};
|
|
349
|
+
var isLabeled = function (obj) {
|
|
350
|
+
return isLabelable(obj) && ['string', 'object'].includes(typeof obj.label);
|
|
351
|
+
};
|
|
337
352
|
|
|
338
353
|
var move = function (array, index, delta) {
|
|
339
354
|
var newIndex = index + delta;
|
|
@@ -450,6 +465,7 @@ var initState = {
|
|
|
450
465
|
validator: undefined,
|
|
451
466
|
ajv: undefined,
|
|
452
467
|
validationMode: 'ValidateAndShow',
|
|
468
|
+
additionalErrors: []
|
|
453
469
|
};
|
|
454
470
|
var reuseAjvForSchema = function (ajv, schema) {
|
|
455
471
|
if (schema.hasOwnProperty('id') || schema.hasOwnProperty('$id')) {
|
|
@@ -493,6 +509,18 @@ var hasValidationModeOption = function (option) {
|
|
|
493
509
|
}
|
|
494
510
|
return false;
|
|
495
511
|
};
|
|
512
|
+
var hasAdditionalErrorsOption = function (option) {
|
|
513
|
+
if (option) {
|
|
514
|
+
return option.additionalErrors !== undefined;
|
|
515
|
+
}
|
|
516
|
+
return false;
|
|
517
|
+
};
|
|
518
|
+
var getAdditionalErrors = function (state, action) {
|
|
519
|
+
if (action && hasAdditionalErrorsOption(action.options)) {
|
|
520
|
+
return action.options.additionalErrors;
|
|
521
|
+
}
|
|
522
|
+
return state.additionalErrors;
|
|
523
|
+
};
|
|
496
524
|
var coreReducer = function (state, action) {
|
|
497
525
|
if (state === void 0) { state = initState; }
|
|
498
526
|
switch (action.type) {
|
|
@@ -501,7 +529,8 @@ var coreReducer = function (state, action) {
|
|
|
501
529
|
var validationMode = getValidationMode(state, action);
|
|
502
530
|
var v = validationMode === 'NoValidation' ? undefined : thisAjv.compile(action.schema);
|
|
503
531
|
var e = validate(v, action.data);
|
|
504
|
-
|
|
532
|
+
var additionalErrors = getAdditionalErrors(state, action);
|
|
533
|
+
return __assign(__assign({}, state), { data: action.data, schema: action.schema, uischema: action.uischema, additionalErrors: additionalErrors, errors: e, validator: v, ajv: thisAjv, validationMode: validationMode });
|
|
505
534
|
}
|
|
506
535
|
case UPDATE_CORE: {
|
|
507
536
|
var thisAjv = getOrCreateAjv(state, action);
|
|
@@ -520,15 +549,17 @@ var coreReducer = function (state, action) {
|
|
|
520
549
|
else if (state.data !== action.data) {
|
|
521
550
|
errors = validate(validator, action.data);
|
|
522
551
|
}
|
|
552
|
+
var additionalErrors = getAdditionalErrors(state, action);
|
|
523
553
|
var stateChanged = state.data !== action.data ||
|
|
524
554
|
state.schema !== action.schema ||
|
|
525
555
|
state.uischema !== action.uischema ||
|
|
526
556
|
state.ajv !== thisAjv ||
|
|
527
557
|
state.errors !== errors ||
|
|
528
558
|
state.validator !== validator ||
|
|
529
|
-
state.validationMode !== validationMode
|
|
559
|
+
state.validationMode !== validationMode ||
|
|
560
|
+
state.additionalErrors !== additionalErrors;
|
|
530
561
|
return stateChanged
|
|
531
|
-
? __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;
|
|
562
|
+
? __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;
|
|
532
563
|
}
|
|
533
564
|
case SET_AJV: {
|
|
534
565
|
var currentAjv = action.ajv;
|
|
@@ -638,7 +669,10 @@ var isObjectSchema$1 = function (schema) {
|
|
|
638
669
|
};
|
|
639
670
|
var filteredErrorKeywords = ['additionalProperties', 'allOf', 'anyOf', 'oneOf'];
|
|
640
671
|
var getErrorsAt = function (instancePath, schema, matchPath) { return function (state) {
|
|
641
|
-
|
|
672
|
+
var _a, _b;
|
|
673
|
+
var errors = (_a = state.errors) !== null && _a !== void 0 ? _a : [];
|
|
674
|
+
var additionalErrors = (_b = state.additionalErrors) !== null && _b !== void 0 ? _b : [];
|
|
675
|
+
return errorsAt(instancePath, schema, matchPath)(state.validationMode === 'ValidateAndHide' ? additionalErrors : __spreadArray(__spreadArray([], errors), additionalErrors));
|
|
642
676
|
}; };
|
|
643
677
|
var errorAt = function (instancePath, schema) {
|
|
644
678
|
return getErrorsAt(instancePath, schema, function (path) { return path === instancePath; });
|
|
@@ -663,8 +697,11 @@ var defaultDataReducer = function (state, action) {
|
|
|
663
697
|
var extractDefaultData = function (state) { return state; };
|
|
664
698
|
|
|
665
699
|
var getI18nKeyPrefixBySchema = function (schema, uischema) {
|
|
666
|
-
var _a
|
|
667
|
-
|
|
700
|
+
var _a;
|
|
701
|
+
if (isInternationalized(uischema)) {
|
|
702
|
+
return uischema.i18n;
|
|
703
|
+
}
|
|
704
|
+
return (_a = schema === null || schema === void 0 ? void 0 : schema.i18n) !== null && _a !== void 0 ? _a : undefined;
|
|
668
705
|
};
|
|
669
706
|
var transformPathToI18nPrefix = function (path) {
|
|
670
707
|
return ((path === null || path === void 0 ? void 0 : path.split('.').filter(function (segment) { return !/^\d+$/.test(segment); }).join('.')) || 'root');
|
|
@@ -680,27 +717,27 @@ var defaultTranslator = function (_id, defaultMessage) { return defaultMessage;
|
|
|
680
717
|
var defaultErrorTranslator = function (error, t, uischema) {
|
|
681
718
|
var _a;
|
|
682
719
|
var i18nKey = getI18nKey(error.parentSchema, uischema, getControlPath(error), "error." + error.keyword);
|
|
683
|
-
var specializedKeywordMessage = t(i18nKey, undefined);
|
|
720
|
+
var specializedKeywordMessage = t(i18nKey, undefined, { error: error });
|
|
684
721
|
if (specializedKeywordMessage !== undefined) {
|
|
685
722
|
return specializedKeywordMessage;
|
|
686
723
|
}
|
|
687
|
-
var genericKeywordMessage = t("error." + error.keyword, undefined);
|
|
724
|
+
var genericKeywordMessage = t("error." + error.keyword, undefined, { error: error });
|
|
688
725
|
if (genericKeywordMessage !== undefined) {
|
|
689
726
|
return genericKeywordMessage;
|
|
690
727
|
}
|
|
691
|
-
var messageCustomization = t(error.message, undefined);
|
|
728
|
+
var messageCustomization = t(error.message, undefined, { error: error });
|
|
692
729
|
if (messageCustomization !== undefined) {
|
|
693
730
|
return messageCustomization;
|
|
694
731
|
}
|
|
695
732
|
if (error.keyword === 'required' && ((_a = error.message) === null || _a === void 0 ? void 0 : _a.startsWith('must have required property'))) {
|
|
696
|
-
return t('is a required property', 'is a required property');
|
|
733
|
+
return t('is a required property', 'is a required property', { error: error });
|
|
697
734
|
}
|
|
698
735
|
return error.message;
|
|
699
736
|
};
|
|
700
737
|
var getCombinedErrorMessage = function (errors, et, t, schema, uischema, path) {
|
|
701
738
|
if (errors.length > 0 && t) {
|
|
702
739
|
var customErrorKey = getI18nKey(schema, uischema, path, 'error.custom');
|
|
703
|
-
var specializedErrorMessage = t(customErrorKey, undefined);
|
|
740
|
+
var specializedErrorMessage = t(customErrorKey, undefined, { schema: schema, uischema: uischema, path: path, errors: errors });
|
|
704
741
|
if (specializedErrorMessage !== undefined) {
|
|
705
742
|
return specializedErrorMessage;
|
|
706
743
|
}
|
|
@@ -817,7 +854,7 @@ var formatIs = function (expectedFormat) {
|
|
|
817
854
|
return schemaMatches(function (schema) {
|
|
818
855
|
return !isEmpty__default["default"](schema) &&
|
|
819
856
|
schema.format === expectedFormat &&
|
|
820
|
-
schema
|
|
857
|
+
hasType(schema, 'string');
|
|
821
858
|
});
|
|
822
859
|
};
|
|
823
860
|
var uiTypeIs = function (expected) { return function (uischema) { return !isEmpty__default["default"](uischema) && uischema.type === expected; }; };
|
|
@@ -921,10 +958,7 @@ var isObjectArrayWithNesting = function (uischema, schema, rootSchema) {
|
|
|
921
958
|
}
|
|
922
959
|
var schemaPath = uischema.scope;
|
|
923
960
|
var resolvedSchema = resolveSchema(schema, schemaPath, rootSchema !== null && rootSchema !== void 0 ? rootSchema : schema);
|
|
924
|
-
var
|
|
925
|
-
object: 2,
|
|
926
|
-
array: 1
|
|
927
|
-
};
|
|
961
|
+
var objectDepth = 0;
|
|
928
962
|
if (resolvedSchema !== undefined && resolvedSchema.items !== undefined) {
|
|
929
963
|
if (traverse(resolvedSchema.items, function (val) {
|
|
930
964
|
if (val === schema) {
|
|
@@ -933,15 +967,16 @@ var isObjectArrayWithNesting = function (uischema, schema, rootSchema) {
|
|
|
933
967
|
if (val.$ref !== undefined) {
|
|
934
968
|
return false;
|
|
935
969
|
}
|
|
936
|
-
if (
|
|
937
|
-
|
|
970
|
+
if (hasType(val, 'object')) {
|
|
971
|
+
objectDepth++;
|
|
972
|
+
if (objectDepth === 2) {
|
|
973
|
+
return true;
|
|
974
|
+
}
|
|
938
975
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
return false;
|
|
976
|
+
if (hasType(val, 'array')) {
|
|
977
|
+
return true;
|
|
942
978
|
}
|
|
943
|
-
|
|
944
|
-
return wantedNestingByType[val.type] === 0;
|
|
979
|
+
return false;
|
|
945
980
|
}, rootSchema)) {
|
|
946
981
|
return true;
|
|
947
982
|
}
|
|
@@ -1156,11 +1191,14 @@ var toDataPath = function (schemaPath) {
|
|
|
1156
1191
|
return toDataPathSegments(schemaPath).join('.');
|
|
1157
1192
|
};
|
|
1158
1193
|
var composeWithUi = function (scopableUi, path) {
|
|
1194
|
+
if (!isScoped(scopableUi)) {
|
|
1195
|
+
return path !== null && path !== void 0 ? path : '';
|
|
1196
|
+
}
|
|
1159
1197
|
var segments = toDataPathSegments(scopableUi.scope);
|
|
1160
|
-
if (isEmpty__default["default"](segments)
|
|
1161
|
-
return '';
|
|
1198
|
+
if (isEmpty__default["default"](segments)) {
|
|
1199
|
+
return path !== null && path !== void 0 ? path : '';
|
|
1162
1200
|
}
|
|
1163
|
-
return
|
|
1201
|
+
return compose(path, segments.join('.'));
|
|
1164
1202
|
};
|
|
1165
1203
|
var encode = function (segment) { return segment === null || segment === void 0 ? void 0 : segment.replace(/~/g, '~0').replace(/\//g, '~1'); };
|
|
1166
1204
|
var decode = function (pointerSegment) { return pointerSegment === null || pointerSegment === void 0 ? void 0 : pointerSegment.replace(/~1/g, '/').replace(/~0/, '~'); };
|
|
@@ -1415,12 +1453,12 @@ var Resolve = {
|
|
|
1415
1453
|
schema: resolveSchema,
|
|
1416
1454
|
data: resolveData
|
|
1417
1455
|
};
|
|
1418
|
-
var
|
|
1456
|
+
var fromScoped = function (scopable) {
|
|
1419
1457
|
return toDataPathSegments(scopable.scope).join('.');
|
|
1420
1458
|
};
|
|
1421
1459
|
var Paths = {
|
|
1422
1460
|
compose: compose,
|
|
1423
|
-
|
|
1461
|
+
fromScoped: fromScoped
|
|
1424
1462
|
};
|
|
1425
1463
|
var Runtime = {
|
|
1426
1464
|
isEnabled: function (uischema, data, ajv) {
|
|
@@ -1564,8 +1602,8 @@ var mapStateToControlProps = function (state, ownProps) {
|
|
|
1564
1602
|
var schema = resolvedSchema !== null && resolvedSchema !== void 0 ? resolvedSchema : rootSchema;
|
|
1565
1603
|
var t = getTranslator()(state);
|
|
1566
1604
|
var te = getErrorTranslator()(state);
|
|
1567
|
-
var i18nLabel = t(getI18nKey(schema, uischema, path, 'label'), label);
|
|
1568
|
-
var i18nDescription = t(getI18nKey(schema, uischema, path, 'description'), description);
|
|
1605
|
+
var i18nLabel = t(getI18nKey(schema, uischema, path, 'label'), label, { schema: schema, uischema: uischema, path: path, errors: errors });
|
|
1606
|
+
var i18nDescription = t(getI18nKey(schema, uischema, path, 'description'), description, { schema: schema, uischema: uischema, path: path, errors: errors });
|
|
1569
1607
|
var i18nErrorMessage = getCombinedErrorMessage(errors, te, t, schema, uischema, path);
|
|
1570
1608
|
return {
|
|
1571
1609
|
data: data,
|
|
@@ -1735,7 +1773,7 @@ var mapStateToJsonFormsRendererProps = function (state, ownProps) {
|
|
|
1735
1773
|
var uischema = ownProps.uischema;
|
|
1736
1774
|
if (uischema === undefined) {
|
|
1737
1775
|
if (ownProps.schema) {
|
|
1738
|
-
uischema = findUISchema(state.jsonforms.uischemas, ownProps.schema, undefined, ownProps.path);
|
|
1776
|
+
uischema = findUISchema(state.jsonforms.uischemas, ownProps.schema, undefined, ownProps.path, undefined, undefined, state.jsonforms.core.schema);
|
|
1739
1777
|
}
|
|
1740
1778
|
else {
|
|
1741
1779
|
uischema = getUiSchema(state);
|
|
@@ -2353,6 +2391,9 @@ exports.isEnumControl = isEnumControl;
|
|
|
2353
2391
|
exports.isGroup = isGroup;
|
|
2354
2392
|
exports.isInherentlyEnabled = isInherentlyEnabled;
|
|
2355
2393
|
exports.isIntegerControl = isIntegerControl;
|
|
2394
|
+
exports.isInternationalized = isInternationalized;
|
|
2395
|
+
exports.isLabelable = isLabelable;
|
|
2396
|
+
exports.isLabeled = isLabeled;
|
|
2356
2397
|
exports.isLayout = isLayout;
|
|
2357
2398
|
exports.isMultiLineControl = isMultiLineControl;
|
|
2358
2399
|
exports.isNumberControl = isNumberControl;
|
|
@@ -2365,6 +2406,8 @@ exports.isOneOfControl = isOneOfControl;
|
|
|
2365
2406
|
exports.isOneOfEnumControl = isOneOfEnumControl;
|
|
2366
2407
|
exports.isPrimitiveArrayControl = isPrimitiveArrayControl;
|
|
2367
2408
|
exports.isRangeControl = isRangeControl;
|
|
2409
|
+
exports.isScopable = isScopable;
|
|
2410
|
+
exports.isScoped = isScoped;
|
|
2368
2411
|
exports.isStringControl = isStringControl;
|
|
2369
2412
|
exports.isTimeControl = isTimeControl;
|
|
2370
2413
|
exports.isVisible = isVisible;
|