@rjsf/core 6.0.0-beta.14 → 6.0.0-beta.15
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 +11 -7
- package/dist/index.esm.js +11 -7
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +11 -7
- package/dist/index.js.map +2 -2
- package/lib/components/Form.d.ts +1 -1
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +14 -5
- package/lib/components/fields/ArrayField.js +3 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -6
- package/src/components/Form.tsx +14 -3
- package/src/components/fields/ArrayField.tsx +3 -3
package/dist/core.umd.js
CHANGED
|
@@ -327,8 +327,8 @@
|
|
|
327
327
|
};
|
|
328
328
|
/** Callback handler used to change the value for a checkbox */
|
|
329
329
|
onSelectChange = (value) => {
|
|
330
|
-
const {
|
|
331
|
-
onChange(value, [
|
|
330
|
+
const { onChange, idSchema } = this.props;
|
|
331
|
+
onChange(value, [], void 0, idSchema && idSchema.$id);
|
|
332
332
|
};
|
|
333
333
|
/** Helper method to compute item UI schema for both normal and fixed arrays
|
|
334
334
|
* Handles both static object and dynamic function cases
|
|
@@ -3916,8 +3916,10 @@
|
|
|
3916
3916
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
3917
3917
|
if (!utils.deepEquals(this.props, prevProps)) {
|
|
3918
3918
|
const formDataChangedFields = utils.getChangedFields(this.props.formData, prevProps.formData);
|
|
3919
|
+
const stateDataChangedFields = utils.getChangedFields(this.props.formData, this.state.formData);
|
|
3919
3920
|
const isSchemaChanged = !utils.deepEquals(prevProps.schema, this.props.schema);
|
|
3920
3921
|
const isFormDataChanged = formDataChangedFields.length > 0 || !utils.deepEquals(prevProps.formData, this.props.formData);
|
|
3922
|
+
const isStateDataChanged = stateDataChangedFields.length > 0 || !utils.deepEquals(this.state.formData, this.props.formData);
|
|
3921
3923
|
const nextState = this.getStateFromProps(
|
|
3922
3924
|
this.props,
|
|
3923
3925
|
this.props.formData,
|
|
@@ -3926,7 +3928,9 @@
|
|
|
3926
3928
|
// match one of the subSchemas, the retrieved schema must be updated.
|
|
3927
3929
|
isSchemaChanged || isFormDataChanged ? void 0 : this.state.retrievedSchema,
|
|
3928
3930
|
isSchemaChanged,
|
|
3929
|
-
formDataChangedFields
|
|
3931
|
+
formDataChangedFields,
|
|
3932
|
+
// Skip live validation for this request if no form data has changed from the last state
|
|
3933
|
+
!isStateDataChanged
|
|
3930
3934
|
);
|
|
3931
3935
|
const shouldUpdate = !utils.deepEquals(nextState, prevState);
|
|
3932
3936
|
return { nextState, shouldUpdate };
|
|
@@ -3965,14 +3969,14 @@
|
|
|
3965
3969
|
* @param formDataChangedFields - The changed fields of `formData`
|
|
3966
3970
|
* @returns - The new state for the `Form`
|
|
3967
3971
|
*/
|
|
3968
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = []) {
|
|
3972
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false) {
|
|
3969
3973
|
const state = this.state || {};
|
|
3970
3974
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
3971
3975
|
const validator = "validator" in props ? props.validator : this.props.validator;
|
|
3972
3976
|
const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
3973
3977
|
const edit = typeof inputFormData !== "undefined";
|
|
3974
3978
|
const liveValidate = "liveValidate" in props ? props.liveValidate : this.props.liveValidate;
|
|
3975
|
-
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
3979
|
+
const mustValidate = edit && !props.noValidate && liveValidate && !skipLiveValidate;
|
|
3976
3980
|
const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
|
|
3977
3981
|
const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
|
|
3978
3982
|
let schemaUtils = state.schemaUtils;
|
|
@@ -4264,7 +4268,7 @@
|
|
|
4264
4268
|
if (!isRootPath) {
|
|
4265
4269
|
set(formData, path, newValue);
|
|
4266
4270
|
}
|
|
4267
|
-
const newState = this.getStateFromProps(this.props, formData);
|
|
4271
|
+
const newState = this.getStateFromProps(this.props, formData, void 0, void 0, void 0, true);
|
|
4268
4272
|
formData = newState.formData;
|
|
4269
4273
|
retrievedSchema = newState.retrievedSchema;
|
|
4270
4274
|
}
|
|
@@ -4282,7 +4286,7 @@
|
|
|
4282
4286
|
set(errorSchemaCopy, path, newErrorSchema);
|
|
4283
4287
|
newErrorSchema = errorSchemaCopy;
|
|
4284
4288
|
}
|
|
4285
|
-
if (mustValidate) {
|
|
4289
|
+
if (mustValidate && this.pendingChanges.length === 1) {
|
|
4286
4290
|
const schemaValidation = this.validate(newFormData, schema, schemaUtils, retrievedSchema);
|
|
4287
4291
|
let errors = schemaValidation.errors;
|
|
4288
4292
|
let errorSchema2 = schemaValidation.errorSchema;
|
package/dist/index.esm.js
CHANGED
|
@@ -372,8 +372,8 @@ var ArrayField = class extends Component {
|
|
|
372
372
|
};
|
|
373
373
|
/** Callback handler used to change the value for a checkbox */
|
|
374
374
|
onSelectChange = (value) => {
|
|
375
|
-
const {
|
|
376
|
-
onChange(value, [
|
|
375
|
+
const { onChange, idSchema } = this.props;
|
|
376
|
+
onChange(value, [], void 0, idSchema && idSchema.$id);
|
|
377
377
|
};
|
|
378
378
|
/** Helper method to compute item UI schema for both normal and fixed arrays
|
|
379
379
|
* Handles both static object and dynamic function cases
|
|
@@ -4378,8 +4378,10 @@ var Form = class extends Component5 {
|
|
|
4378
4378
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
4379
4379
|
if (!deepEquals2(this.props, prevProps)) {
|
|
4380
4380
|
const formDataChangedFields = getChangedFields(this.props.formData, prevProps.formData);
|
|
4381
|
+
const stateDataChangedFields = getChangedFields(this.props.formData, this.state.formData);
|
|
4381
4382
|
const isSchemaChanged = !deepEquals2(prevProps.schema, this.props.schema);
|
|
4382
4383
|
const isFormDataChanged = formDataChangedFields.length > 0 || !deepEquals2(prevProps.formData, this.props.formData);
|
|
4384
|
+
const isStateDataChanged = stateDataChangedFields.length > 0 || !deepEquals2(this.state.formData, this.props.formData);
|
|
4383
4385
|
const nextState = this.getStateFromProps(
|
|
4384
4386
|
this.props,
|
|
4385
4387
|
this.props.formData,
|
|
@@ -4388,7 +4390,9 @@ var Form = class extends Component5 {
|
|
|
4388
4390
|
// match one of the subSchemas, the retrieved schema must be updated.
|
|
4389
4391
|
isSchemaChanged || isFormDataChanged ? void 0 : this.state.retrievedSchema,
|
|
4390
4392
|
isSchemaChanged,
|
|
4391
|
-
formDataChangedFields
|
|
4393
|
+
formDataChangedFields,
|
|
4394
|
+
// Skip live validation for this request if no form data has changed from the last state
|
|
4395
|
+
!isStateDataChanged
|
|
4392
4396
|
);
|
|
4393
4397
|
const shouldUpdate = !deepEquals2(nextState, prevState);
|
|
4394
4398
|
return { nextState, shouldUpdate };
|
|
@@ -4427,14 +4431,14 @@ var Form = class extends Component5 {
|
|
|
4427
4431
|
* @param formDataChangedFields - The changed fields of `formData`
|
|
4428
4432
|
* @returns - The new state for the `Form`
|
|
4429
4433
|
*/
|
|
4430
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = []) {
|
|
4434
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false) {
|
|
4431
4435
|
const state = this.state || {};
|
|
4432
4436
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
4433
4437
|
const validator = "validator" in props ? props.validator : this.props.validator;
|
|
4434
4438
|
const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
4435
4439
|
const edit = typeof inputFormData !== "undefined";
|
|
4436
4440
|
const liveValidate = "liveValidate" in props ? props.liveValidate : this.props.liveValidate;
|
|
4437
|
-
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
4441
|
+
const mustValidate = edit && !props.noValidate && liveValidate && !skipLiveValidate;
|
|
4438
4442
|
const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
|
|
4439
4443
|
const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
|
|
4440
4444
|
let schemaUtils = state.schemaUtils;
|
|
@@ -4726,7 +4730,7 @@ var Form = class extends Component5 {
|
|
|
4726
4730
|
if (!isRootPath) {
|
|
4727
4731
|
_set(formData, path, newValue);
|
|
4728
4732
|
}
|
|
4729
|
-
const newState = this.getStateFromProps(this.props, formData);
|
|
4733
|
+
const newState = this.getStateFromProps(this.props, formData, void 0, void 0, void 0, true);
|
|
4730
4734
|
formData = newState.formData;
|
|
4731
4735
|
retrievedSchema = newState.retrievedSchema;
|
|
4732
4736
|
}
|
|
@@ -4744,7 +4748,7 @@ var Form = class extends Component5 {
|
|
|
4744
4748
|
_set(errorSchemaCopy, path, newErrorSchema);
|
|
4745
4749
|
newErrorSchema = errorSchemaCopy;
|
|
4746
4750
|
}
|
|
4747
|
-
if (mustValidate) {
|
|
4751
|
+
if (mustValidate && this.pendingChanges.length === 1) {
|
|
4748
4752
|
const schemaValidation = this.validate(newFormData, schema, schemaUtils, retrievedSchema);
|
|
4749
4753
|
let errors = schemaValidation.errors;
|
|
4750
4754
|
let errorSchema2 = schemaValidation.errorSchema;
|