@rjsf/core 5.12.1 → 5.13.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.umd.js +17 -11
- package/dist/index.esm.js +21 -17
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +15 -10
- package/dist/index.js.map +3 -3
- package/lib/components/Form.js +12 -4
- package/lib/components/Form.js.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +4 -6
- package/lib/components/fields/MultiSchemaField.js.map +1 -1
- package/package.json +6 -6
- package/src/components/Form.tsx +11 -4
- package/src/components/fields/MultiSchemaField.tsx +3 -6
package/dist/core.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/pick'), require('lodash/toPath'), require('lodash/cloneDeep'), require('lodash/isObject'), require('lodash/set'), require('nanoid'), require('react/jsx-runtime'), require('lodash/omit'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/toPath', 'lodash/cloneDeep', 'lodash/isObject', 'lodash/set', 'nanoid', 'react/jsx-runtime', 'lodash/omit', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global.get3, global.isEmpty, global._pick, global._toPath, global.cloneDeep, global.isObject, global.set, global.nanoid, global.jsxRuntime, global.omit2, global.
|
|
5
|
-
})(this, (function (exports, react, utils, get3, isEmpty, _pick, _toPath, cloneDeep, isObject, set, nanoid, jsxRuntime, omit2,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/pick'), require('lodash/toPath'), require('lodash/cloneDeep'), require('lodash/isObject'), require('lodash/set'), require('nanoid'), require('react/jsx-runtime'), require('lodash/omit'), require('markdown-to-jsx'), require('lodash/has'), require('lodash/unset')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/toPath', 'lodash/cloneDeep', 'lodash/isObject', 'lodash/set', 'nanoid', 'react/jsx-runtime', 'lodash/omit', 'markdown-to-jsx', 'lodash/has', 'lodash/unset'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global.get3, global.isEmpty, global._pick, global._toPath, global.cloneDeep, global.isObject, global.set, global.nanoid, global.jsxRuntime, global.omit2, global.Markdown, global.has, global.unset));
|
|
5
|
+
})(this, (function (exports, react, utils, get3, isEmpty, _pick, _toPath, cloneDeep, isObject, set, nanoid, jsxRuntime, omit2, Markdown, has, unset) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// src/components/Form.tsx
|
|
8
8
|
function generateRowId() {
|
|
@@ -950,9 +950,8 @@
|
|
|
950
950
|
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
951
951
|
let optionSchema;
|
|
952
952
|
if (option) {
|
|
953
|
-
const {
|
|
954
|
-
|
|
955
|
-
optionSchema = !isEmpty(remaining) ? utils.mergeSchemas(remaining, option) : option;
|
|
953
|
+
const { required } = schema;
|
|
954
|
+
optionSchema = required ? utils.mergeSchemas({ required }, option) : option;
|
|
956
955
|
}
|
|
957
956
|
const translateEnum = title ? utils.TranslatableString.TitleOptionPrefix : utils.TranslatableString.OptionPrefix;
|
|
958
957
|
const translateParams = title ? [title] : [];
|
|
@@ -3305,13 +3304,14 @@
|
|
|
3305
3304
|
*/
|
|
3306
3305
|
validateForm() {
|
|
3307
3306
|
const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
|
|
3308
|
-
const { formData } = this.state;
|
|
3307
|
+
const { formData, errors: prevErrors } = this.state;
|
|
3309
3308
|
const schemaValidation = this.validate(formData);
|
|
3310
3309
|
let errors = schemaValidation.errors;
|
|
3311
3310
|
let errorSchema = schemaValidation.errorSchema;
|
|
3312
3311
|
const schemaValidationErrors = errors;
|
|
3313
3312
|
const schemaValidationErrorSchema = errorSchema;
|
|
3314
|
-
|
|
3313
|
+
const hasError = errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
|
|
3314
|
+
if (hasError) {
|
|
3315
3315
|
if (extraErrors) {
|
|
3316
3316
|
const merged = utils.validationDataMerge(schemaValidation, extraErrors);
|
|
3317
3317
|
errorSchema = merged.errorSchema;
|
|
@@ -3339,9 +3339,15 @@
|
|
|
3339
3339
|
}
|
|
3340
3340
|
}
|
|
3341
3341
|
);
|
|
3342
|
-
|
|
3342
|
+
} else if (prevErrors.length > 0) {
|
|
3343
|
+
this.setState({
|
|
3344
|
+
errors: [],
|
|
3345
|
+
errorSchema: {},
|
|
3346
|
+
schemaValidationErrors: [],
|
|
3347
|
+
schemaValidationErrorSchema: {}
|
|
3348
|
+
});
|
|
3343
3349
|
}
|
|
3344
|
-
return
|
|
3350
|
+
return !hasError;
|
|
3345
3351
|
}
|
|
3346
3352
|
/** Renders the `Form` fields inside the <form> | `tagName` or `_internalFormWrapper`, rendering any errors if
|
|
3347
3353
|
* needed along with the submit button or any children of the form.
|
package/dist/index.esm.js
CHANGED
|
@@ -884,9 +884,7 @@ import { Component as Component2 } from "react";
|
|
|
884
884
|
import get2 from "lodash/get";
|
|
885
885
|
import isEmpty from "lodash/isEmpty";
|
|
886
886
|
import omit from "lodash/omit";
|
|
887
|
-
import unset from "lodash/unset";
|
|
888
887
|
import {
|
|
889
|
-
ADDITIONAL_PROPERTY_FLAG,
|
|
890
888
|
deepEquals,
|
|
891
889
|
ERRORS_KEY,
|
|
892
890
|
getDiscriminatorFieldFromSchema,
|
|
@@ -1016,9 +1014,8 @@ var AnyOfField = class extends Component2 {
|
|
|
1016
1014
|
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1017
1015
|
let optionSchema;
|
|
1018
1016
|
if (option) {
|
|
1019
|
-
const {
|
|
1020
|
-
|
|
1021
|
-
optionSchema = !isEmpty(remaining) ? mergeSchemas(remaining, option) : option;
|
|
1017
|
+
const { required } = schema;
|
|
1018
|
+
optionSchema = required ? mergeSchemas({ required }, option) : option;
|
|
1022
1019
|
}
|
|
1023
1020
|
const translateEnum = title ? TranslatableString3.TitleOptionPrefix : TranslatableString3.OptionPrefix;
|
|
1024
1021
|
const translateParams = title ? [title] : [];
|
|
@@ -1096,7 +1093,7 @@ import {
|
|
|
1096
1093
|
getUiOptions as getUiOptions4,
|
|
1097
1094
|
orderProperties,
|
|
1098
1095
|
TranslatableString as TranslatableString4,
|
|
1099
|
-
ADDITIONAL_PROPERTY_FLAG
|
|
1096
|
+
ADDITIONAL_PROPERTY_FLAG,
|
|
1100
1097
|
PROPERTIES_KEY,
|
|
1101
1098
|
REF_KEY,
|
|
1102
1099
|
ANY_OF_KEY,
|
|
@@ -1107,7 +1104,7 @@ import get3 from "lodash/get";
|
|
|
1107
1104
|
import has from "lodash/has";
|
|
1108
1105
|
import isObject3 from "lodash/isObject";
|
|
1109
1106
|
import set2 from "lodash/set";
|
|
1110
|
-
import
|
|
1107
|
+
import unset from "lodash/unset";
|
|
1111
1108
|
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1112
1109
|
var ObjectField = class extends Component3 {
|
|
1113
1110
|
constructor() {
|
|
@@ -1153,7 +1150,7 @@ var ObjectField = class extends Component3 {
|
|
|
1153
1150
|
event.preventDefault();
|
|
1154
1151
|
const { onChange, formData } = this.props;
|
|
1155
1152
|
const copiedFormData = { ...formData };
|
|
1156
|
-
|
|
1153
|
+
unset(copiedFormData, key);
|
|
1157
1154
|
onChange(copiedFormData);
|
|
1158
1155
|
};
|
|
1159
1156
|
};
|
|
@@ -1311,7 +1308,7 @@ var ObjectField = class extends Component3 {
|
|
|
1311
1308
|
title: uiOptions.label === false ? "" : title,
|
|
1312
1309
|
description: uiOptions.label === false ? void 0 : description,
|
|
1313
1310
|
properties: orderedProperties.map((name2) => {
|
|
1314
|
-
const addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, name2,
|
|
1311
|
+
const addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, name2, ADDITIONAL_PROPERTY_FLAG]);
|
|
1315
1312
|
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name2];
|
|
1316
1313
|
const hidden = getUiOptions4(fieldUiSchema).widget === "hidden";
|
|
1317
1314
|
const fieldIdSchema = get3(idSchema, [name2], {});
|
|
@@ -1368,7 +1365,7 @@ var ObjectField_default = ObjectField;
|
|
|
1368
1365
|
// src/components/fields/SchemaField.tsx
|
|
1369
1366
|
import { useCallback as useCallback2, Component as Component4 } from "react";
|
|
1370
1367
|
import {
|
|
1371
|
-
ADDITIONAL_PROPERTY_FLAG as
|
|
1368
|
+
ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG2,
|
|
1372
1369
|
deepEquals as deepEquals2,
|
|
1373
1370
|
descriptionId,
|
|
1374
1371
|
getSchemaType,
|
|
@@ -1505,7 +1502,7 @@ function SchemaFieldRender(props) {
|
|
|
1505
1502
|
if (wasPropertyKeyModified) {
|
|
1506
1503
|
label = name;
|
|
1507
1504
|
} else {
|
|
1508
|
-
label =
|
|
1505
|
+
label = ADDITIONAL_PROPERTY_FLAG2 in schema ? name : uiOptions.title || props.schema.title || schema.title || name;
|
|
1509
1506
|
}
|
|
1510
1507
|
const description = uiOptions.description || props.schema.description || schema.description || "";
|
|
1511
1508
|
const richDescription = uiOptions.enableMarkdownInDescription ? /* @__PURE__ */ jsx6(Markdown2, { children: description }) : description;
|
|
@@ -2374,7 +2371,7 @@ var UnsupportedField_default = UnsupportedField;
|
|
|
2374
2371
|
|
|
2375
2372
|
// src/components/templates/WrapIfAdditionalTemplate.tsx
|
|
2376
2373
|
import {
|
|
2377
|
-
ADDITIONAL_PROPERTY_FLAG as
|
|
2374
|
+
ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG3,
|
|
2378
2375
|
TranslatableString as TranslatableString10
|
|
2379
2376
|
} from "@rjsf/utils";
|
|
2380
2377
|
import { jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
@@ -2397,7 +2394,7 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
2397
2394
|
const { templates: templates2, translateString } = registry;
|
|
2398
2395
|
const { RemoveButton: RemoveButton2 } = templates2.ButtonTemplates;
|
|
2399
2396
|
const keyLabel = translateString(TranslatableString10.KeyLabel, [label]);
|
|
2400
|
-
const additional =
|
|
2397
|
+
const additional = ADDITIONAL_PROPERTY_FLAG3 in schema;
|
|
2401
2398
|
if (!additional) {
|
|
2402
2399
|
return /* @__PURE__ */ jsx25("div", { className: classNames, style, children });
|
|
2403
2400
|
}
|
|
@@ -3653,13 +3650,14 @@ var Form = class extends Component5 {
|
|
|
3653
3650
|
*/
|
|
3654
3651
|
validateForm() {
|
|
3655
3652
|
const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
|
|
3656
|
-
const { formData } = this.state;
|
|
3653
|
+
const { formData, errors: prevErrors } = this.state;
|
|
3657
3654
|
const schemaValidation = this.validate(formData);
|
|
3658
3655
|
let errors = schemaValidation.errors;
|
|
3659
3656
|
let errorSchema = schemaValidation.errorSchema;
|
|
3660
3657
|
const schemaValidationErrors = errors;
|
|
3661
3658
|
const schemaValidationErrorSchema = errorSchema;
|
|
3662
|
-
|
|
3659
|
+
const hasError = errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
|
|
3660
|
+
if (hasError) {
|
|
3663
3661
|
if (extraErrors) {
|
|
3664
3662
|
const merged = validationDataMerge(schemaValidation, extraErrors);
|
|
3665
3663
|
errorSchema = merged.errorSchema;
|
|
@@ -3687,9 +3685,15 @@ var Form = class extends Component5 {
|
|
|
3687
3685
|
}
|
|
3688
3686
|
}
|
|
3689
3687
|
);
|
|
3690
|
-
|
|
3688
|
+
} else if (prevErrors.length > 0) {
|
|
3689
|
+
this.setState({
|
|
3690
|
+
errors: [],
|
|
3691
|
+
errorSchema: {},
|
|
3692
|
+
schemaValidationErrors: [],
|
|
3693
|
+
schemaValidationErrorSchema: {}
|
|
3694
|
+
});
|
|
3691
3695
|
}
|
|
3692
|
-
return
|
|
3696
|
+
return !hasError;
|
|
3693
3697
|
}
|
|
3694
3698
|
/** Renders the `Form` fields inside the <form> | `tagName` or `_internalFormWrapper`, rendering any errors if
|
|
3695
3699
|
* needed along with the submit button or any children of the form.
|