@rjsf/core 6.5.0 → 6.5.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.umd.js +14 -10
- package/dist/index.cjs +10 -6
- package/dist/index.cjs.map +2 -2
- package/dist/index.esm.js +10 -6
- package/dist/index.esm.js.map +2 -2
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +12 -6
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +3 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/components/Form.tsx +12 -6
- package/src/components/fields/ArrayField.tsx +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/core",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.2",
|
|
4
4
|
"description": "A simple React component capable of building HTML forms out of a JSON schema.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"compileReplacer": "tsc -p tsconfig.replacer.json && move-file lodashReplacer.js lodashReplacer.cjs",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"node": ">=20"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@rjsf/utils": "^6.
|
|
69
|
+
"@rjsf/utils": "^6.5.x",
|
|
70
70
|
"react": ">=18"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
@@ -76,9 +76,9 @@
|
|
|
76
76
|
"prop-types": "^15.8.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@rjsf/snapshot-tests": "6.5.
|
|
80
|
-
"@rjsf/utils": "6.5.
|
|
81
|
-
"@rjsf/validator-ajv8": "6.5.
|
|
79
|
+
"@rjsf/snapshot-tests": "6.5.2",
|
|
80
|
+
"@rjsf/utils": "6.5.2",
|
|
81
|
+
"@rjsf/validator-ajv8": "6.5.2",
|
|
82
82
|
"@testing-library/jest-dom": "^6.9.1",
|
|
83
83
|
"@testing-library/react": "^16.3.2",
|
|
84
84
|
"@testing-library/user-event": "^14.6.1",
|
package/src/components/Form.tsx
CHANGED
|
@@ -896,7 +896,11 @@ export default class Form<
|
|
|
896
896
|
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange, removeEmptyOptionalObjects } =
|
|
897
897
|
this.props;
|
|
898
898
|
const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
|
|
899
|
-
let { customErrors
|
|
899
|
+
let { customErrors } = this.state;
|
|
900
|
+
// Use the un-merged AJV-only schema as the base for re-merging extraErrors. Mirrors the
|
|
901
|
+
// pattern in getStateFromProps/getDerivedStateFromProps and avoids the duplication that
|
|
902
|
+
// happened when state.errorSchema (already containing merged extraErrors) was passed in.
|
|
903
|
+
let mergeBaseErrorSchema: ErrorSchema<T> = schemaValidationErrorSchema as ErrorSchema<T>;
|
|
900
904
|
const rootPathId = fieldPathId.path[0] || '';
|
|
901
905
|
|
|
902
906
|
const isRootPath = !path || path.length === 0 || (path.length === 1 && path[0] === rootPathId);
|
|
@@ -958,11 +962,13 @@ export default class Form<
|
|
|
958
962
|
const oldValidationError = !isRootPath ? _get(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
|
|
959
963
|
// If there is an old validation error for this path, assume we are updating it directly
|
|
960
964
|
if (!_isEmpty(oldValidationError)) {
|
|
961
|
-
//
|
|
965
|
+
// Apply the user-supplied newErrorSchema onto a clone of the AJV-only base, so that
|
|
966
|
+
// mergeErrors below sees the user's error at this path without mutating shared state.
|
|
962
967
|
if (!isRootPath) {
|
|
963
|
-
|
|
968
|
+
mergeBaseErrorSchema = _cloneDeep(schemaValidationErrorSchema) as ErrorSchema<T>;
|
|
969
|
+
_set(mergeBaseErrorSchema, path, newErrorSchema);
|
|
964
970
|
} else {
|
|
965
|
-
|
|
971
|
+
mergeBaseErrorSchema = newErrorSchema as ErrorSchema<T>;
|
|
966
972
|
}
|
|
967
973
|
} else {
|
|
968
974
|
if (!customErrors) {
|
|
@@ -987,7 +993,7 @@ export default class Form<
|
|
|
987
993
|
const liveValidation = this.liveValidate(
|
|
988
994
|
schema,
|
|
989
995
|
schemaUtils,
|
|
990
|
-
|
|
996
|
+
mergeBaseErrorSchema,
|
|
991
997
|
newFormData,
|
|
992
998
|
extraErrors,
|
|
993
999
|
customErrors,
|
|
@@ -996,7 +1002,7 @@ export default class Form<
|
|
|
996
1002
|
state = { formData: newFormData, ...liveValidation, customErrors };
|
|
997
1003
|
} else if (!noValidate && newErrorSchema) {
|
|
998
1004
|
// Merging 'newErrorSchema' into 'errorSchema' to display the custom raised errors.
|
|
999
|
-
const mergedErrors = this.mergeErrors({ errorSchema:
|
|
1005
|
+
const mergedErrors = this.mergeErrors({ errorSchema: mergeBaseErrorSchema, errors }, extraErrors, customErrors);
|
|
1000
1006
|
state = {
|
|
1001
1007
|
formData: newFormData,
|
|
1002
1008
|
...mergedErrors,
|
|
@@ -1028,10 +1028,12 @@ export default function ArrayField<T = any, S extends StrictRJSFSchema = RJSFSch
|
|
|
1028
1028
|
*/
|
|
1029
1029
|
const handleChange = useCallback(
|
|
1030
1030
|
(value: any, path: FieldPathList, newErrorSchema?: ErrorSchema<T>, id?: string) => {
|
|
1031
|
+
const lastPathIsItemIndex = typeof path.at(-1) === 'number';
|
|
1031
1032
|
onChange(
|
|
1032
1033
|
// We need to treat undefined items as nulls to have validation.
|
|
1033
1034
|
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
1034
|
-
|
|
1035
|
+
// Only set to null for array items, and not for object properties within array items
|
|
1036
|
+
lastPathIsItemIndex && value === undefined ? null : value,
|
|
1035
1037
|
path,
|
|
1036
1038
|
newErrorSchema as ErrorSchema<T[]>,
|
|
1037
1039
|
id,
|