@jsonforms/core 3.0.0-beta.2 → 3.0.0-beta.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/docs/assets/js/search.json +1 -1
- package/docs/globals.html +122 -55
- package/docs/index.html +6 -0
- package/docs/interfaces/addcellrendereraction.html +3 -3
- package/docs/interfaces/addrendereraction.html +3 -3
- package/docs/interfaces/adduischemaaction.html +3 -3
- package/docs/interfaces/arraylayoutprops.html +2 -2
- package/docs/interfaces/combinatorrendererprops.html +6 -6
- package/docs/interfaces/initactionoptions.html +14 -0
- package/docs/interfaces/jsonformscore.html +17 -3
- 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/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/unregisterdefaultdataaction.html +2 -2
- package/docs/interfaces/updatei18naction.html +4 -4
- package/lib/actions/actions.d.ts +1 -0
- package/lib/jsonforms-core.cjs.js +31 -12
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +32 -10
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/reducers/core.d.ts +1 -0
- package/package.json +2 -2
- package/src/actions/actions.ts +1 -0
- package/src/i18n/i18nUtil.ts +5 -5
- package/src/reducers/core.ts +30 -3
- package/src/util/renderer.ts +6 -3
- package/stats.html +1 -1
- package/test/reducers/core.test.ts +203 -1
|
@@ -450,6 +450,7 @@ var initState = {
|
|
|
450
450
|
validator: undefined,
|
|
451
451
|
ajv: undefined,
|
|
452
452
|
validationMode: 'ValidateAndShow',
|
|
453
|
+
additionalErrors: []
|
|
453
454
|
};
|
|
454
455
|
var reuseAjvForSchema = function (ajv, schema) {
|
|
455
456
|
if (schema.hasOwnProperty('id') || schema.hasOwnProperty('$id')) {
|
|
@@ -493,6 +494,18 @@ var hasValidationModeOption = function (option) {
|
|
|
493
494
|
}
|
|
494
495
|
return false;
|
|
495
496
|
};
|
|
497
|
+
var hasAdditionalErrorsOption = function (option) {
|
|
498
|
+
if (option) {
|
|
499
|
+
return option.additionalErrors !== undefined;
|
|
500
|
+
}
|
|
501
|
+
return false;
|
|
502
|
+
};
|
|
503
|
+
var getAdditionalErrors = function (state, action) {
|
|
504
|
+
if (action && hasAdditionalErrorsOption(action.options)) {
|
|
505
|
+
return action.options.additionalErrors;
|
|
506
|
+
}
|
|
507
|
+
return state.additionalErrors;
|
|
508
|
+
};
|
|
496
509
|
var coreReducer = function (state, action) {
|
|
497
510
|
if (state === void 0) { state = initState; }
|
|
498
511
|
switch (action.type) {
|
|
@@ -501,7 +514,8 @@ var coreReducer = function (state, action) {
|
|
|
501
514
|
var validationMode = getValidationMode(state, action);
|
|
502
515
|
var v = validationMode === 'NoValidation' ? undefined : thisAjv.compile(action.schema);
|
|
503
516
|
var e = validate(v, action.data);
|
|
504
|
-
|
|
517
|
+
var additionalErrors = getAdditionalErrors(state, action);
|
|
518
|
+
return __assign(__assign({}, state), { data: action.data, schema: action.schema, uischema: action.uischema, additionalErrors: additionalErrors, errors: e, validator: v, ajv: thisAjv, validationMode: validationMode });
|
|
505
519
|
}
|
|
506
520
|
case UPDATE_CORE: {
|
|
507
521
|
var thisAjv = getOrCreateAjv(state, action);
|
|
@@ -520,15 +534,17 @@ var coreReducer = function (state, action) {
|
|
|
520
534
|
else if (state.data !== action.data) {
|
|
521
535
|
errors = validate(validator, action.data);
|
|
522
536
|
}
|
|
537
|
+
var additionalErrors = getAdditionalErrors(state, action);
|
|
523
538
|
var stateChanged = state.data !== action.data ||
|
|
524
539
|
state.schema !== action.schema ||
|
|
525
540
|
state.uischema !== action.uischema ||
|
|
526
541
|
state.ajv !== thisAjv ||
|
|
527
542
|
state.errors !== errors ||
|
|
528
543
|
state.validator !== validator ||
|
|
529
|
-
state.validationMode !== validationMode
|
|
544
|
+
state.validationMode !== validationMode ||
|
|
545
|
+
state.additionalErrors !== additionalErrors;
|
|
530
546
|
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;
|
|
547
|
+
? __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
548
|
}
|
|
533
549
|
case SET_AJV: {
|
|
534
550
|
var currentAjv = action.ajv;
|
|
@@ -638,7 +654,10 @@ var isObjectSchema$1 = function (schema) {
|
|
|
638
654
|
};
|
|
639
655
|
var filteredErrorKeywords = ['additionalProperties', 'allOf', 'anyOf', 'oneOf'];
|
|
640
656
|
var getErrorsAt = function (instancePath, schema, matchPath) { return function (state) {
|
|
641
|
-
|
|
657
|
+
var _a, _b;
|
|
658
|
+
var errors = (_a = state.errors) !== null && _a !== void 0 ? _a : [];
|
|
659
|
+
var additionalErrors = (_b = state.additionalErrors) !== null && _b !== void 0 ? _b : [];
|
|
660
|
+
return errorsAt(instancePath, schema, matchPath)(state.validationMode === 'ValidateAndHide' ? additionalErrors : __spreadArray(__spreadArray([], errors), additionalErrors));
|
|
642
661
|
}; };
|
|
643
662
|
var errorAt = function (instancePath, schema) {
|
|
644
663
|
return getErrorsAt(instancePath, schema, function (path) { return path === instancePath; });
|
|
@@ -680,27 +699,27 @@ var defaultTranslator = function (_id, defaultMessage) { return defaultMessage;
|
|
|
680
699
|
var defaultErrorTranslator = function (error, t, uischema) {
|
|
681
700
|
var _a;
|
|
682
701
|
var i18nKey = getI18nKey(error.parentSchema, uischema, getControlPath(error), "error." + error.keyword);
|
|
683
|
-
var specializedKeywordMessage = t(i18nKey, undefined);
|
|
702
|
+
var specializedKeywordMessage = t(i18nKey, undefined, { error: error });
|
|
684
703
|
if (specializedKeywordMessage !== undefined) {
|
|
685
704
|
return specializedKeywordMessage;
|
|
686
705
|
}
|
|
687
|
-
var genericKeywordMessage = t("error." + error.keyword, undefined);
|
|
706
|
+
var genericKeywordMessage = t("error." + error.keyword, undefined, { error: error });
|
|
688
707
|
if (genericKeywordMessage !== undefined) {
|
|
689
708
|
return genericKeywordMessage;
|
|
690
709
|
}
|
|
691
|
-
var messageCustomization = t(error.message, undefined);
|
|
710
|
+
var messageCustomization = t(error.message, undefined, { error: error });
|
|
692
711
|
if (messageCustomization !== undefined) {
|
|
693
712
|
return messageCustomization;
|
|
694
713
|
}
|
|
695
714
|
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');
|
|
715
|
+
return t('is a required property', 'is a required property', { error: error });
|
|
697
716
|
}
|
|
698
717
|
return error.message;
|
|
699
718
|
};
|
|
700
719
|
var getCombinedErrorMessage = function (errors, et, t, schema, uischema, path) {
|
|
701
720
|
if (errors.length > 0 && t) {
|
|
702
721
|
var customErrorKey = getI18nKey(schema, uischema, path, 'error.custom');
|
|
703
|
-
var specializedErrorMessage = t(customErrorKey, undefined);
|
|
722
|
+
var specializedErrorMessage = t(customErrorKey, undefined, { schema: schema, uischema: uischema, path: path, errors: errors });
|
|
704
723
|
if (specializedErrorMessage !== undefined) {
|
|
705
724
|
return specializedErrorMessage;
|
|
706
725
|
}
|
|
@@ -1564,8 +1583,8 @@ var mapStateToControlProps = function (state, ownProps) {
|
|
|
1564
1583
|
var schema = resolvedSchema !== null && resolvedSchema !== void 0 ? resolvedSchema : rootSchema;
|
|
1565
1584
|
var t = getTranslator()(state);
|
|
1566
1585
|
var te = getErrorTranslator()(state);
|
|
1567
|
-
var i18nLabel = t(getI18nKey(schema, uischema, path, 'label'), label);
|
|
1568
|
-
var i18nDescription = t(getI18nKey(schema, uischema, path, 'description'), description);
|
|
1586
|
+
var i18nLabel = t(getI18nKey(schema, uischema, path, 'label'), label, { schema: schema, uischema: uischema, path: path, errors: errors });
|
|
1587
|
+
var i18nDescription = t(getI18nKey(schema, uischema, path, 'description'), description, { schema: schema, uischema: uischema, path: path, errors: errors });
|
|
1569
1588
|
var i18nErrorMessage = getCombinedErrorMessage(errors, te, t, schema, uischema, path);
|
|
1570
1589
|
return {
|
|
1571
1590
|
data: data,
|
|
@@ -1735,7 +1754,7 @@ var mapStateToJsonFormsRendererProps = function (state, ownProps) {
|
|
|
1735
1754
|
var uischema = ownProps.uischema;
|
|
1736
1755
|
if (uischema === undefined) {
|
|
1737
1756
|
if (ownProps.schema) {
|
|
1738
|
-
uischema = findUISchema(state.jsonforms.uischemas, ownProps.schema, undefined, ownProps.path);
|
|
1757
|
+
uischema = findUISchema(state.jsonforms.uischemas, ownProps.schema, undefined, ownProps.path, undefined, undefined, state.jsonforms.core.schema);
|
|
1739
1758
|
}
|
|
1740
1759
|
else {
|
|
1741
1760
|
uischema = getUiSchema(state);
|