@rjsf/core 5.17.0 → 5.18.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 +12 -3
- package/dist/index.esm.js +12 -3
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +12 -3
- package/dist/index.js.map +2 -2
- package/lib/components/Form.d.ts +3 -1
- package/lib/components/Form.js +12 -3
- package/lib/components/Form.js.map +1 -1
- package/lib/components/fields/ArrayField.js +1 -0
- package/lib/components/fields/ArrayField.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/components/Form.tsx +17 -3
- package/src/components/fields/ArrayField.tsx +1 -0
package/dist/core.umd.js
CHANGED
|
@@ -673,6 +673,7 @@
|
|
|
673
673
|
uiSchema,
|
|
674
674
|
title: fieldTitle,
|
|
675
675
|
formContext,
|
|
676
|
+
errorSchema,
|
|
676
677
|
rawErrors
|
|
677
678
|
};
|
|
678
679
|
const Template = utils.getTemplate("ArrayFieldTemplate", registry, uiOptions);
|
|
@@ -3210,10 +3211,16 @@
|
|
|
3210
3211
|
*/
|
|
3211
3212
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
3212
3213
|
if (!utils.deepEquals(this.props, prevProps)) {
|
|
3214
|
+
const isSchemaChanged = !utils.deepEquals(prevProps.schema, this.props.schema);
|
|
3215
|
+
const isFormDataChanged = !utils.deepEquals(prevProps.formData, this.props.formData);
|
|
3213
3216
|
const nextState = this.getStateFromProps(
|
|
3214
3217
|
this.props,
|
|
3215
3218
|
this.props.formData,
|
|
3216
|
-
|
|
3219
|
+
// If the `schema` has changed, we need to update the retrieved schema.
|
|
3220
|
+
// Or if the `formData` changes, for example in the case of a schema with dependencies that need to
|
|
3221
|
+
// match one of the subSchemas, the retrieved schema must be updated.
|
|
3222
|
+
isSchemaChanged || isFormDataChanged ? void 0 : this.state.retrievedSchema,
|
|
3223
|
+
isSchemaChanged
|
|
3217
3224
|
);
|
|
3218
3225
|
const shouldUpdate = !utils.deepEquals(nextState, prevState);
|
|
3219
3226
|
return { nextState, shouldUpdate };
|
|
@@ -3250,9 +3257,11 @@
|
|
|
3250
3257
|
*
|
|
3251
3258
|
* @param props - The props passed to the `Form`
|
|
3252
3259
|
* @param inputFormData - The new or current data for the `Form`
|
|
3260
|
+
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
3261
|
+
* @param isSchemaChanged - A flag indicating whether the schema has changed.
|
|
3253
3262
|
* @returns - The new state for the `Form`
|
|
3254
3263
|
*/
|
|
3255
|
-
getStateFromProps(props, inputFormData, retrievedSchema) {
|
|
3264
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false) {
|
|
3256
3265
|
const state = this.state || {};
|
|
3257
3266
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
3258
3267
|
const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
@@ -3268,7 +3277,7 @@
|
|
|
3268
3277
|
const formData = schemaUtils.getDefaultFormState(schema, inputFormData);
|
|
3269
3278
|
const _retrievedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
|
|
3270
3279
|
const getCurrentErrors = () => {
|
|
3271
|
-
if (props.noValidate) {
|
|
3280
|
+
if (props.noValidate || isSchemaChanged) {
|
|
3272
3281
|
return { errors: [], errorSchema: {} };
|
|
3273
3282
|
} else if (!props.liveValidate) {
|
|
3274
3283
|
return {
|
package/dist/index.esm.js
CHANGED
|
@@ -711,6 +711,7 @@ var ArrayField = class extends Component {
|
|
|
711
711
|
uiSchema,
|
|
712
712
|
title: fieldTitle,
|
|
713
713
|
formContext,
|
|
714
|
+
errorSchema,
|
|
714
715
|
rawErrors
|
|
715
716
|
};
|
|
716
717
|
const Template = getTemplate("ArrayFieldTemplate", registry, uiOptions);
|
|
@@ -3559,10 +3560,16 @@ var Form = class extends Component5 {
|
|
|
3559
3560
|
*/
|
|
3560
3561
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
3561
3562
|
if (!deepEquals3(this.props, prevProps)) {
|
|
3563
|
+
const isSchemaChanged = !deepEquals3(prevProps.schema, this.props.schema);
|
|
3564
|
+
const isFormDataChanged = !deepEquals3(prevProps.formData, this.props.formData);
|
|
3562
3565
|
const nextState = this.getStateFromProps(
|
|
3563
3566
|
this.props,
|
|
3564
3567
|
this.props.formData,
|
|
3565
|
-
|
|
3568
|
+
// If the `schema` has changed, we need to update the retrieved schema.
|
|
3569
|
+
// Or if the `formData` changes, for example in the case of a schema with dependencies that need to
|
|
3570
|
+
// match one of the subSchemas, the retrieved schema must be updated.
|
|
3571
|
+
isSchemaChanged || isFormDataChanged ? void 0 : this.state.retrievedSchema,
|
|
3572
|
+
isSchemaChanged
|
|
3566
3573
|
);
|
|
3567
3574
|
const shouldUpdate = !deepEquals3(nextState, prevState);
|
|
3568
3575
|
return { nextState, shouldUpdate };
|
|
@@ -3599,9 +3606,11 @@ var Form = class extends Component5 {
|
|
|
3599
3606
|
*
|
|
3600
3607
|
* @param props - The props passed to the `Form`
|
|
3601
3608
|
* @param inputFormData - The new or current data for the `Form`
|
|
3609
|
+
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
3610
|
+
* @param isSchemaChanged - A flag indicating whether the schema has changed.
|
|
3602
3611
|
* @returns - The new state for the `Form`
|
|
3603
3612
|
*/
|
|
3604
|
-
getStateFromProps(props, inputFormData, retrievedSchema) {
|
|
3613
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false) {
|
|
3605
3614
|
const state = this.state || {};
|
|
3606
3615
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
3607
3616
|
const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
@@ -3617,7 +3626,7 @@ var Form = class extends Component5 {
|
|
|
3617
3626
|
const formData = schemaUtils.getDefaultFormState(schema, inputFormData);
|
|
3618
3627
|
const _retrievedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
|
|
3619
3628
|
const getCurrentErrors = () => {
|
|
3620
|
-
if (props.noValidate) {
|
|
3629
|
+
if (props.noValidate || isSchemaChanged) {
|
|
3621
3630
|
return { errors: [], errorSchema: {} };
|
|
3622
3631
|
} else if (!props.liveValidate) {
|
|
3623
3632
|
return {
|