@rjsf/core 5.5.2 → 5.6.0
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/dist/core.cjs.development.js +40 -26
- package/dist/core.cjs.development.js.map +1 -1
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/core.cjs.production.min.js.map +1 -1
- package/dist/core.esm.js +40 -27
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +43 -30
- package/dist/core.umd.development.js.map +1 -1
- package/dist/core.umd.production.min.js +1 -1
- package/dist/core.umd.production.min.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +7 -7
|
@@ -13,6 +13,7 @@ var cloneDeep = require('lodash/cloneDeep');
|
|
|
13
13
|
var isObject = require('lodash/isObject');
|
|
14
14
|
var set = require('lodash/set');
|
|
15
15
|
var nanoid = require('nanoid');
|
|
16
|
+
var isString = require('lodash/isString');
|
|
16
17
|
var omit = require('lodash/omit');
|
|
17
18
|
var Markdown = require('markdown-to-jsx');
|
|
18
19
|
var has = require('lodash/has');
|
|
@@ -27,6 +28,7 @@ var _toPath__default = /*#__PURE__*/_interopDefaultLegacy(_toPath);
|
|
|
27
28
|
var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
|
|
28
29
|
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
29
30
|
var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
|
|
31
|
+
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
|
|
30
32
|
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
31
33
|
var Markdown__default = /*#__PURE__*/_interopDefaultLegacy(Markdown);
|
|
32
34
|
var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
|
|
@@ -1149,8 +1151,17 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1149
1151
|
* @return - The index of the `option` that best matches the `formData`
|
|
1150
1152
|
*/;
|
|
1151
1153
|
_proto.getMatchingOption = function getMatchingOption(selectedOption, formData, options) {
|
|
1152
|
-
var
|
|
1153
|
-
|
|
1154
|
+
var _this$props4 = this.props,
|
|
1155
|
+
schema = _this$props4.schema,
|
|
1156
|
+
schemaUtils = _this$props4.registry.schemaUtils;
|
|
1157
|
+
var discriminator;
|
|
1158
|
+
var maybeString = get__default["default"](schema, 'discriminator.propertyName', undefined);
|
|
1159
|
+
if (isString__default["default"](maybeString)) {
|
|
1160
|
+
discriminator = maybeString;
|
|
1161
|
+
} else if (maybeString !== undefined) {
|
|
1162
|
+
console.warn("Expecting discriminator to be a string, got \"" + typeof maybeString + "\" instead");
|
|
1163
|
+
}
|
|
1164
|
+
var option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
|
|
1154
1165
|
if (option > 0) {
|
|
1155
1166
|
return option;
|
|
1156
1167
|
}
|
|
@@ -1159,27 +1170,27 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1159
1170
|
return selectedOption || 0;
|
|
1160
1171
|
};
|
|
1161
1172
|
_proto.getFieldId = function getFieldId() {
|
|
1162
|
-
var _this$
|
|
1163
|
-
idSchema = _this$
|
|
1164
|
-
schema = _this$
|
|
1173
|
+
var _this$props5 = this.props,
|
|
1174
|
+
idSchema = _this$props5.idSchema,
|
|
1175
|
+
schema = _this$props5.schema;
|
|
1165
1176
|
return "" + idSchema.$id + (schema.oneOf ? '__oneof_select' : '__anyof_select');
|
|
1166
1177
|
}
|
|
1167
1178
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
1168
1179
|
*/;
|
|
1169
1180
|
_proto.render = function render() {
|
|
1170
|
-
var _this$
|
|
1171
|
-
name = _this$
|
|
1172
|
-
baseType = _this$
|
|
1173
|
-
_this$
|
|
1174
|
-
disabled = _this$
|
|
1175
|
-
_this$
|
|
1176
|
-
errorSchema = _this$
|
|
1177
|
-
formContext = _this$
|
|
1178
|
-
onBlur = _this$
|
|
1179
|
-
onFocus = _this$
|
|
1180
|
-
registry = _this$
|
|
1181
|
-
schema = _this$
|
|
1182
|
-
uiSchema = _this$
|
|
1181
|
+
var _this$props6 = this.props,
|
|
1182
|
+
name = _this$props6.name,
|
|
1183
|
+
baseType = _this$props6.baseType,
|
|
1184
|
+
_this$props6$disabled = _this$props6.disabled,
|
|
1185
|
+
disabled = _this$props6$disabled === void 0 ? false : _this$props6$disabled,
|
|
1186
|
+
_this$props6$errorSch = _this$props6.errorSchema,
|
|
1187
|
+
errorSchema = _this$props6$errorSch === void 0 ? {} : _this$props6$errorSch,
|
|
1188
|
+
formContext = _this$props6.formContext,
|
|
1189
|
+
onBlur = _this$props6.onBlur,
|
|
1190
|
+
onFocus = _this$props6.onFocus,
|
|
1191
|
+
registry = _this$props6.registry,
|
|
1192
|
+
schema = _this$props6.schema,
|
|
1193
|
+
uiSchema = _this$props6.uiSchema;
|
|
1183
1194
|
var widgets = registry.widgets,
|
|
1184
1195
|
fields = registry.fields,
|
|
1185
1196
|
translateString = registry.translateString,
|
|
@@ -1771,7 +1782,7 @@ function SchemaFieldRender(props) {
|
|
|
1771
1782
|
var description = uiOptions.description || props.schema.description || schema.description || '';
|
|
1772
1783
|
var help = uiOptions.help;
|
|
1773
1784
|
var hidden = uiOptions.widget === 'hidden';
|
|
1774
|
-
var classNames = ['form-group', 'field', "field-" + schema
|
|
1785
|
+
var classNames = ['form-group', 'field', "field-" + utils.getSchemaType(schema)];
|
|
1775
1786
|
if (!hideError && __errors && __errors.length > 0) {
|
|
1776
1787
|
classNames.push('field-error has-error has-danger');
|
|
1777
1788
|
}
|
|
@@ -3773,7 +3784,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3773
3784
|
var schemaValidationErrors = errors;
|
|
3774
3785
|
var schemaValidationErrorSchema = errorSchema;
|
|
3775
3786
|
if (extraErrors) {
|
|
3776
|
-
var merged =
|
|
3787
|
+
var merged = utils.validationDataMerge(schemaValidation, extraErrors);
|
|
3777
3788
|
errorSchema = merged.errorSchema;
|
|
3778
3789
|
errors = merged.errors;
|
|
3779
3790
|
}
|
|
@@ -3789,7 +3800,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3789
3800
|
state = {
|
|
3790
3801
|
formData: newFormData,
|
|
3791
3802
|
errorSchema: _errorSchema,
|
|
3792
|
-
errors:
|
|
3803
|
+
errors: utils.toErrorList(_errorSchema)
|
|
3793
3804
|
};
|
|
3794
3805
|
}
|
|
3795
3806
|
_this.setState(state, function () {
|
|
@@ -3874,7 +3885,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3874
3885
|
// There are no errors generated through schema validation.
|
|
3875
3886
|
// Check for user provided errors and update state accordingly.
|
|
3876
3887
|
var errorSchema = extraErrors || {};
|
|
3877
|
-
var errors = extraErrors ?
|
|
3888
|
+
var errors = extraErrors ? utils.toErrorList(extraErrors) : [];
|
|
3878
3889
|
_this.setState({
|
|
3879
3890
|
formData: newFormData,
|
|
3880
3891
|
errors: errors,
|
|
@@ -3970,7 +3981,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3970
3981
|
errorSchema = currentErrors.errorSchema;
|
|
3971
3982
|
}
|
|
3972
3983
|
if (props.extraErrors) {
|
|
3973
|
-
var merged =
|
|
3984
|
+
var merged = utils.validationDataMerge({
|
|
3974
3985
|
errorSchema: errorSchema,
|
|
3975
3986
|
errors: errors
|
|
3976
3987
|
}, props.extraErrors);
|
|
@@ -4124,7 +4135,6 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
4124
4135
|
focusOnFirstError = _this$props6.focusOnFirstError,
|
|
4125
4136
|
onError = _this$props6.onError;
|
|
4126
4137
|
var formData = this.state.formData;
|
|
4127
|
-
var schemaUtils = this.state.schemaUtils;
|
|
4128
4138
|
var schemaValidation = this.validate(formData);
|
|
4129
4139
|
var errors = schemaValidation.errors;
|
|
4130
4140
|
var errorSchema = schemaValidation.errorSchema;
|
|
@@ -4132,12 +4142,16 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
4132
4142
|
var schemaValidationErrorSchema = errorSchema;
|
|
4133
4143
|
if (errors.length > 0) {
|
|
4134
4144
|
if (extraErrors) {
|
|
4135
|
-
var merged =
|
|
4145
|
+
var merged = utils.validationDataMerge(schemaValidation, extraErrors);
|
|
4136
4146
|
errorSchema = merged.errorSchema;
|
|
4137
4147
|
errors = merged.errors;
|
|
4138
4148
|
}
|
|
4139
4149
|
if (focusOnFirstError) {
|
|
4140
|
-
|
|
4150
|
+
if (typeof focusOnFirstError === 'function') {
|
|
4151
|
+
focusOnFirstError(schemaValidation.errors[0]);
|
|
4152
|
+
} else {
|
|
4153
|
+
this.focusOnError(schemaValidation.errors[0]);
|
|
4154
|
+
}
|
|
4141
4155
|
}
|
|
4142
4156
|
this.setState({
|
|
4143
4157
|
errors: errors,
|