@rjsf/core 5.5.2 → 5.6.2
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 +20 -19
package/dist/core.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { Component, useState, useCallback, useEffect, useReducer, useMemo, createRef, forwardRef } from 'react';
|
|
3
|
-
import { isFixedItems, allowAdditionalItems, getUiOptions, ITEMS_KEY, getTemplate, TranslatableString, isCustomWidget, getWidget, optionsList, deepEquals, ERRORS_KEY, asNumber, REF_KEY, orderProperties, PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ANY_OF_KEY, ONE_OF_KEY, mergeObjects, UI_OPTIONS_KEY,
|
|
3
|
+
import { isFixedItems, allowAdditionalItems, getUiOptions, ITEMS_KEY, getTemplate, TranslatableString, isCustomWidget, getWidget, optionsList, deepEquals, ERRORS_KEY, asNumber, REF_KEY, orderProperties, PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ANY_OF_KEY, ONE_OF_KEY, mergeObjects, UI_OPTIONS_KEY, getSchemaType, descriptionId, ID_KEY, hasWidget, titleId, getInputProps, examplesId, ariaDescribedByIds, getSubmitButtonOptions, errorId, helpId, canExpand, parseDateString, toDateString, pad, schemaRequiresTrueValue, labelValue, enumOptionsValueForIndex, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, utcToLocal, localToUTC, dataURItoBlob, enumOptionsIndexForValue, englishStringTranslator, createSchemaUtils, validationDataMerge, shouldRender, UI_GLOBAL_OPTIONS_KEY, SUBMIT_BTN_OPTIONS_KEY, isObject as isObject$1, toErrorList, RJSF_ADDITONAL_PROPERTIES_FLAG, NAME_KEY } from '@rjsf/utils';
|
|
4
4
|
import get from 'lodash-es/get';
|
|
5
5
|
import isEmpty from 'lodash-es/isEmpty';
|
|
6
6
|
import _pick from 'lodash-es/pick';
|
|
@@ -9,6 +9,7 @@ import cloneDeep from 'lodash-es/cloneDeep';
|
|
|
9
9
|
import isObject from 'lodash-es/isObject';
|
|
10
10
|
import set from 'lodash-es/set';
|
|
11
11
|
import { nanoid } from 'nanoid';
|
|
12
|
+
import isString from 'lodash-es/isString';
|
|
12
13
|
import omit from 'lodash-es/omit';
|
|
13
14
|
import Markdown from 'markdown-to-jsx';
|
|
14
15
|
import has from 'lodash-es/has';
|
|
@@ -1131,8 +1132,17 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1131
1132
|
* @return - The index of the `option` that best matches the `formData`
|
|
1132
1133
|
*/;
|
|
1133
1134
|
_proto.getMatchingOption = function getMatchingOption(selectedOption, formData, options) {
|
|
1134
|
-
var
|
|
1135
|
-
|
|
1135
|
+
var _this$props4 = this.props,
|
|
1136
|
+
schema = _this$props4.schema,
|
|
1137
|
+
schemaUtils = _this$props4.registry.schemaUtils;
|
|
1138
|
+
var discriminator;
|
|
1139
|
+
var maybeString = get(schema, 'discriminator.propertyName', undefined);
|
|
1140
|
+
if (isString(maybeString)) {
|
|
1141
|
+
discriminator = maybeString;
|
|
1142
|
+
} else if (maybeString !== undefined) {
|
|
1143
|
+
console.warn("Expecting discriminator to be a string, got \"" + typeof maybeString + "\" instead");
|
|
1144
|
+
}
|
|
1145
|
+
var option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
|
|
1136
1146
|
if (option > 0) {
|
|
1137
1147
|
return option;
|
|
1138
1148
|
}
|
|
@@ -1141,27 +1151,27 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1141
1151
|
return selectedOption || 0;
|
|
1142
1152
|
};
|
|
1143
1153
|
_proto.getFieldId = function getFieldId() {
|
|
1144
|
-
var _this$
|
|
1145
|
-
idSchema = _this$
|
|
1146
|
-
schema = _this$
|
|
1154
|
+
var _this$props5 = this.props,
|
|
1155
|
+
idSchema = _this$props5.idSchema,
|
|
1156
|
+
schema = _this$props5.schema;
|
|
1147
1157
|
return "" + idSchema.$id + (schema.oneOf ? '__oneof_select' : '__anyof_select');
|
|
1148
1158
|
}
|
|
1149
1159
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
1150
1160
|
*/;
|
|
1151
1161
|
_proto.render = function render() {
|
|
1152
|
-
var _this$
|
|
1153
|
-
name = _this$
|
|
1154
|
-
baseType = _this$
|
|
1155
|
-
_this$
|
|
1156
|
-
disabled = _this$
|
|
1157
|
-
_this$
|
|
1158
|
-
errorSchema = _this$
|
|
1159
|
-
formContext = _this$
|
|
1160
|
-
onBlur = _this$
|
|
1161
|
-
onFocus = _this$
|
|
1162
|
-
registry = _this$
|
|
1163
|
-
schema = _this$
|
|
1164
|
-
uiSchema = _this$
|
|
1162
|
+
var _this$props6 = this.props,
|
|
1163
|
+
name = _this$props6.name,
|
|
1164
|
+
baseType = _this$props6.baseType,
|
|
1165
|
+
_this$props6$disabled = _this$props6.disabled,
|
|
1166
|
+
disabled = _this$props6$disabled === void 0 ? false : _this$props6$disabled,
|
|
1167
|
+
_this$props6$errorSch = _this$props6.errorSchema,
|
|
1168
|
+
errorSchema = _this$props6$errorSch === void 0 ? {} : _this$props6$errorSch,
|
|
1169
|
+
formContext = _this$props6.formContext,
|
|
1170
|
+
onBlur = _this$props6.onBlur,
|
|
1171
|
+
onFocus = _this$props6.onFocus,
|
|
1172
|
+
registry = _this$props6.registry,
|
|
1173
|
+
schema = _this$props6.schema,
|
|
1174
|
+
uiSchema = _this$props6.uiSchema;
|
|
1165
1175
|
var widgets = registry.widgets,
|
|
1166
1176
|
fields = registry.fields,
|
|
1167
1177
|
translateString = registry.translateString,
|
|
@@ -1753,7 +1763,7 @@ function SchemaFieldRender(props) {
|
|
|
1753
1763
|
var description = uiOptions.description || props.schema.description || schema.description || '';
|
|
1754
1764
|
var help = uiOptions.help;
|
|
1755
1765
|
var hidden = uiOptions.widget === 'hidden';
|
|
1756
|
-
var classNames = ['form-group', 'field', "field-" + schema
|
|
1766
|
+
var classNames = ['form-group', 'field', "field-" + getSchemaType(schema)];
|
|
1757
1767
|
if (!hideError && __errors && __errors.length > 0) {
|
|
1758
1768
|
classNames.push('field-error has-error has-danger');
|
|
1759
1769
|
}
|
|
@@ -3755,7 +3765,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3755
3765
|
var schemaValidationErrors = errors;
|
|
3756
3766
|
var schemaValidationErrorSchema = errorSchema;
|
|
3757
3767
|
if (extraErrors) {
|
|
3758
|
-
var merged =
|
|
3768
|
+
var merged = validationDataMerge(schemaValidation, extraErrors);
|
|
3759
3769
|
errorSchema = merged.errorSchema;
|
|
3760
3770
|
errors = merged.errors;
|
|
3761
3771
|
}
|
|
@@ -3771,7 +3781,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3771
3781
|
state = {
|
|
3772
3782
|
formData: newFormData,
|
|
3773
3783
|
errorSchema: _errorSchema,
|
|
3774
|
-
errors:
|
|
3784
|
+
errors: toErrorList(_errorSchema)
|
|
3775
3785
|
};
|
|
3776
3786
|
}
|
|
3777
3787
|
_this.setState(state, function () {
|
|
@@ -3856,7 +3866,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3856
3866
|
// There are no errors generated through schema validation.
|
|
3857
3867
|
// Check for user provided errors and update state accordingly.
|
|
3858
3868
|
var errorSchema = extraErrors || {};
|
|
3859
|
-
var errors = extraErrors ?
|
|
3869
|
+
var errors = extraErrors ? toErrorList(extraErrors) : [];
|
|
3860
3870
|
_this.setState({
|
|
3861
3871
|
formData: newFormData,
|
|
3862
3872
|
errors: errors,
|
|
@@ -3952,7 +3962,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3952
3962
|
errorSchema = currentErrors.errorSchema;
|
|
3953
3963
|
}
|
|
3954
3964
|
if (props.extraErrors) {
|
|
3955
|
-
var merged =
|
|
3965
|
+
var merged = validationDataMerge({
|
|
3956
3966
|
errorSchema: errorSchema,
|
|
3957
3967
|
errors: errors
|
|
3958
3968
|
}, props.extraErrors);
|
|
@@ -4106,7 +4116,6 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
4106
4116
|
focusOnFirstError = _this$props6.focusOnFirstError,
|
|
4107
4117
|
onError = _this$props6.onError;
|
|
4108
4118
|
var formData = this.state.formData;
|
|
4109
|
-
var schemaUtils = this.state.schemaUtils;
|
|
4110
4119
|
var schemaValidation = this.validate(formData);
|
|
4111
4120
|
var errors = schemaValidation.errors;
|
|
4112
4121
|
var errorSchema = schemaValidation.errorSchema;
|
|
@@ -4114,12 +4123,16 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
4114
4123
|
var schemaValidationErrorSchema = errorSchema;
|
|
4115
4124
|
if (errors.length > 0) {
|
|
4116
4125
|
if (extraErrors) {
|
|
4117
|
-
var merged =
|
|
4126
|
+
var merged = validationDataMerge(schemaValidation, extraErrors);
|
|
4118
4127
|
errorSchema = merged.errorSchema;
|
|
4119
4128
|
errors = merged.errors;
|
|
4120
4129
|
}
|
|
4121
4130
|
if (focusOnFirstError) {
|
|
4122
|
-
|
|
4131
|
+
if (typeof focusOnFirstError === 'function') {
|
|
4132
|
+
focusOnFirstError(schemaValidation.errors[0]);
|
|
4133
|
+
} else {
|
|
4134
|
+
this.focusOnError(schemaValidation.errors[0]);
|
|
4135
|
+
}
|
|
4123
4136
|
}
|
|
4124
4137
|
this.setState({
|
|
4125
4138
|
errors: errors,
|