@rjsf/core 6.5.2 → 6.5.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/dist/core.umd.js +27 -3
- package/dist/index.cjs +27 -3
- package/dist/index.cjs.map +2 -2
- package/dist/index.esm.js +53 -26
- package/dist/index.esm.js.map +3 -3
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +28 -2
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +8 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/components/Form.tsx +29 -1
- package/src/components/fields/SchemaField.tsx +11 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/core",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.3",
|
|
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",
|
|
@@ -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.3",
|
|
80
|
+
"@rjsf/utils": "6.5.3",
|
|
81
|
+
"@rjsf/validator-ajv8": "6.5.3",
|
|
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
|
@@ -45,6 +45,8 @@ import {
|
|
|
45
45
|
NameGeneratorFunction,
|
|
46
46
|
getUsedFormData,
|
|
47
47
|
getFieldNames,
|
|
48
|
+
ANY_OF_KEY,
|
|
49
|
+
ONE_OF_KEY,
|
|
48
50
|
} from '@rjsf/utils';
|
|
49
51
|
import _cloneDeep from 'lodash/cloneDeep';
|
|
50
52
|
import _get from 'lodash/get';
|
|
@@ -924,7 +926,33 @@ export default class Form<
|
|
|
924
926
|
_unset(formData, path);
|
|
925
927
|
} else if (!isRootPath) {
|
|
926
928
|
// If the newValue is not on the root path, then set it into the form data
|
|
927
|
-
|
|
929
|
+
let unsetPath = false;
|
|
930
|
+
let valueForPath: T | null | undefined = newValue;
|
|
931
|
+
|
|
932
|
+
if (newValue === undefined) {
|
|
933
|
+
const lastSegment = path[path.length - 1];
|
|
934
|
+
if (typeof lastSegment === 'number') {
|
|
935
|
+
// Array items: match ArrayField `handleChange` — AJV needs `null`, not undefined.
|
|
936
|
+
valueForPath = null as unknown as T;
|
|
937
|
+
} else {
|
|
938
|
+
const { field } = schemaUtils.findFieldInSchema(schema, path, oldFormData);
|
|
939
|
+
const leaf = field as RJSFSchema | undefined;
|
|
940
|
+
const isOneOfOrAnyOfLeaf = leaf && (ONE_OF_KEY in leaf || ANY_OF_KEY in leaf);
|
|
941
|
+
// Plain leaves: omit the key instead of `{ key: undefined }`, which breaks `type: "string"` validation in
|
|
942
|
+
// AJV after clearing a text input (https://github.com/rjsf-team/react-jsonschema-form/issues/4518).
|
|
943
|
+
// oneOf/anyOf leaves and unresolved leaves: keep `valueForPath === newValue` (already `undefined`) so
|
|
944
|
+
// mergeDefaults does not immediately re-apply a branch default when clearing those widgets.
|
|
945
|
+
if (!isOneOfOrAnyOfLeaf && leaf !== undefined) {
|
|
946
|
+
unsetPath = true;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
if (unsetPath) {
|
|
952
|
+
_unset(formData, path);
|
|
953
|
+
} else {
|
|
954
|
+
_set(formData, path, valueForPath);
|
|
955
|
+
}
|
|
928
956
|
}
|
|
929
957
|
// Pass true to skip live validation in `getStateFromProps()` since we will do it a bit later
|
|
930
958
|
const newState = this.getStateFromProps(this.props, inputForDefaults, undefined, undefined, undefined, true);
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
shouldRenderOptionalField,
|
|
24
24
|
StrictRJSFSchema,
|
|
25
25
|
toFieldPathId,
|
|
26
|
+
TranslatableString,
|
|
26
27
|
UI_OPTIONS_KEY,
|
|
27
28
|
UIOptionsType,
|
|
28
29
|
} from '@rjsf/utils';
|
|
@@ -133,7 +134,11 @@ function SchemaFieldRender<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
133
134
|
);
|
|
134
135
|
|
|
135
136
|
const FieldComponent = getFieldComponent<T, S, F>(schema, uiOptions, registry);
|
|
136
|
-
|
|
137
|
+
|
|
138
|
+
const isDeprecated = Boolean(schema.deprecated);
|
|
139
|
+
const deprecatedHandling = isDeprecated ? (uiOptions.deprecatedHandling ?? 'label') : undefined;
|
|
140
|
+
|
|
141
|
+
const disabled = Boolean(uiOptions.disabled ?? props.disabled) || deprecatedHandling === 'disable';
|
|
137
142
|
const readonly = Boolean(uiOptions.readonly ?? (props.readonly || props.schema.readOnly || schema.readOnly));
|
|
138
143
|
const uiSchemaHideError = uiOptions.hideError;
|
|
139
144
|
// Set hideError to the value provided in the uiSchema, otherwise stick with the prop to propagate to children
|
|
@@ -214,9 +219,13 @@ function SchemaFieldRender<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
214
219
|
: uiOptions.title || props.schema.title || schema.title || props.title || name;
|
|
215
220
|
}
|
|
216
221
|
|
|
222
|
+
if (deprecatedHandling === 'label') {
|
|
223
|
+
label = registry.translateString(TranslatableString.DeprecatedLabel, [label]);
|
|
224
|
+
}
|
|
225
|
+
|
|
217
226
|
const description = uiOptions.description || props.schema.description || schema.description || '';
|
|
218
227
|
const help = uiOptions.help;
|
|
219
|
-
const hidden = uiOptions.widget === 'hidden';
|
|
228
|
+
const hidden = uiOptions.widget === 'hidden' || deprecatedHandling === 'hide';
|
|
220
229
|
|
|
221
230
|
const classNames = ['rjsf-field', `rjsf-field-${getSchemaType(schema)}`];
|
|
222
231
|
if (!hideError && __errors && __errors.length > 0) {
|