@rjsf/core 6.0.0-beta.11 → 6.0.0-beta.13

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 CHANGED
@@ -2291,7 +2291,8 @@
2291
2291
  }
2292
2292
  var SchemaField = class extends react.Component {
2293
2293
  shouldComponentUpdate(nextProps) {
2294
- return !utils.deepEquals(this.props, nextProps);
2294
+ const { experimental_componentUpdateStrategy = "customDeep" } = this.props.registry;
2295
+ return utils.shouldRender(this, nextProps, this.state, experimental_componentUpdateStrategy);
2295
2296
  }
2296
2297
  render() {
2297
2298
  return /* @__PURE__ */ jsxRuntime.jsx(SchemaFieldRender, { ...this.props });
@@ -3891,30 +3892,31 @@
3891
3892
  getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = []) {
3892
3893
  const state = this.state || {};
3893
3894
  const schema = "schema" in props ? props.schema : this.props.schema;
3895
+ const validator = "validator" in props ? props.validator : this.props.validator;
3894
3896
  const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
3895
3897
  const edit = typeof inputFormData !== "undefined";
3896
3898
  const liveValidate = "liveValidate" in props ? props.liveValidate : this.props.liveValidate;
3897
3899
  const mustValidate = edit && !props.noValidate && liveValidate;
3898
- const rootSchema = schema;
3899
3900
  const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
3900
3901
  const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
3901
3902
  let schemaUtils = state.schemaUtils;
3902
3903
  if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
3903
- props.validator,
3904
- rootSchema,
3904
+ validator,
3905
+ schema,
3905
3906
  experimental_defaultFormStateBehavior,
3906
3907
  experimental_customMergeAllOf
3907
3908
  )) {
3908
3909
  schemaUtils = utils.createSchemaUtils(
3909
- props.validator,
3910
- rootSchema,
3910
+ validator,
3911
+ schema,
3911
3912
  experimental_defaultFormStateBehavior,
3912
3913
  experimental_customMergeAllOf
3913
3914
  );
3914
3915
  }
3915
- const formData = schemaUtils.getDefaultFormState(schema, inputFormData);
3916
+ const rootSchema = schemaUtils.getRootSchema();
3917
+ const formData = schemaUtils.getDefaultFormState(rootSchema, inputFormData);
3916
3918
  const _retrievedSchema = this.updateRetrievedSchema(
3917
- retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData)
3919
+ retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData)
3918
3920
  );
3919
3921
  const getCurrentErrors = () => {
3920
3922
  if (props.noValidate || isSchemaChanged) {
@@ -3935,7 +3937,7 @@
3935
3937
  let schemaValidationErrors = state.schemaValidationErrors;
3936
3938
  let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
3937
3939
  if (mustValidate) {
3938
- const schemaValidation = this.validate(formData, schema, schemaUtils, _retrievedSchema);
3940
+ const schemaValidation = this.validate(formData, rootSchema, schemaUtils, _retrievedSchema);
3939
3941
  errors = schemaValidation.errors;
3940
3942
  if (retrievedSchema === void 0) {
3941
3943
  errorSchema = schemaValidation.errorSchema;
@@ -3981,7 +3983,7 @@
3981
3983
  );
3982
3984
  const nextState = {
3983
3985
  schemaUtils,
3984
- schema,
3986
+ schema: rootSchema,
3985
3987
  uiSchema,
3986
3988
  idSchema,
3987
3989
  formData,
@@ -4001,7 +4003,8 @@
4001
4003
  * @returns - True if the component should be updated, false otherwise
4002
4004
  */
4003
4005
  shouldComponentUpdate(nextProps, nextState) {
4004
- return utils.shouldRender(this, nextProps, nextState);
4006
+ const { experimental_componentUpdateStrategy = "customDeep" } = this.props;
4007
+ return utils.shouldRender(this, nextProps, nextState, experimental_componentUpdateStrategy);
4005
4008
  }
4006
4009
  /** Gets the previously raised customValidate errors.
4007
4010
  *
@@ -4025,7 +4028,7 @@
4025
4028
  * @param schema - The schema used to validate against
4026
4029
  * @param altSchemaUtils - The alternate schemaUtils to use for validation
4027
4030
  */
4028
- validate(formData, schema = this.props.schema, altSchemaUtils, retrievedSchema) {
4031
+ validate(formData, schema = this.state.schema, altSchemaUtils, retrievedSchema) {
4029
4032
  const schemaUtils = altSchemaUtils ? altSchemaUtils : this.state.schemaUtils;
4030
4033
  const { customValidate, transformErrors, uiSchema } = this.props;
4031
4034
  const resolvedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
@@ -4299,8 +4302,12 @@
4299
4302
  };
4300
4303
  /** Returns the registry for the form */
4301
4304
  getRegistry() {
4302
- const { translateString: customTranslateString, uiSchema = {} } = this.props;
4303
- const { schemaUtils } = this.state;
4305
+ const {
4306
+ translateString: customTranslateString,
4307
+ uiSchema = {},
4308
+ experimental_componentUpdateStrategy = "customDeep"
4309
+ } = this.props;
4310
+ const { schema, schemaUtils } = this.state;
4304
4311
  const { fields: fields2, templates: templates2, widgets: widgets2, formContext, translateString } = getDefaultRegistry();
4305
4312
  return {
4306
4313
  fields: { ...fields2, ...this.props.fields },
@@ -4313,11 +4320,12 @@
4313
4320
  }
4314
4321
  },
4315
4322
  widgets: { ...widgets2, ...this.props.widgets },
4316
- rootSchema: this.props.schema,
4323
+ rootSchema: schema,
4317
4324
  formContext: this.props.formContext || formContext,
4318
4325
  schemaUtils,
4319
4326
  translateString: customTranslateString || translateString,
4320
- globalUiOptions: uiSchema[utils.UI_GLOBAL_OPTIONS_KEY]
4327
+ globalUiOptions: uiSchema[utils.UI_GLOBAL_OPTIONS_KEY],
4328
+ experimental_componentUpdateStrategy
4321
4329
  };
4322
4330
  }
4323
4331
  /** Provides a function that can be used to programmatically submit the `Form` */
package/dist/index.esm.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Component as Component5, createRef } from "react";
3
3
  import {
4
4
  createSchemaUtils,
5
- deepEquals as deepEquals3,
5
+ deepEquals as deepEquals2,
6
6
  getChangedFields,
7
7
  getTemplate as getTemplate25,
8
8
  getUiOptions as getUiOptions17,
@@ -10,7 +10,7 @@ import {
10
10
  mergeObjects as mergeObjects3,
11
11
  NAME_KEY,
12
12
  RJSF_ADDITIONAL_PROPERTIES_FLAG,
13
- shouldRender,
13
+ shouldRender as shouldRender2,
14
14
  SUBMIT_BTN_OPTIONS_KEY,
15
15
  toErrorList,
16
16
  UI_GLOBAL_OPTIONS_KEY as UI_GLOBAL_OPTIONS_KEY2,
@@ -2214,13 +2214,13 @@ var ObjectField_default = ObjectField;
2214
2214
  import { useCallback as useCallback2, Component as Component4 } from "react";
2215
2215
  import {
2216
2216
  ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG2,
2217
- deepEquals as deepEquals2,
2218
2217
  descriptionId,
2219
2218
  getSchemaType,
2220
2219
  getTemplate as getTemplate7,
2221
2220
  getUiOptions as getUiOptions8,
2222
2221
  ID_KEY as ID_KEY3,
2223
2222
  mergeObjects as mergeObjects2,
2223
+ shouldRender,
2224
2224
  TranslatableString as TranslatableString5,
2225
2225
  UI_OPTIONS_KEY as UI_OPTIONS_KEY2
2226
2226
  } from "@rjsf/utils";
@@ -2477,7 +2477,8 @@ function SchemaFieldRender(props) {
2477
2477
  }
2478
2478
  var SchemaField = class extends Component4 {
2479
2479
  shouldComponentUpdate(nextProps) {
2480
- return !deepEquals2(this.props, nextProps);
2480
+ const { experimental_componentUpdateStrategy = "customDeep" } = this.props.registry;
2481
+ return shouldRender(this, nextProps, this.state, experimental_componentUpdateStrategy);
2481
2482
  }
2482
2483
  render() {
2483
2484
  return /* @__PURE__ */ jsx9(SchemaFieldRender, { ...this.props });
@@ -4269,7 +4270,7 @@ var Form = class extends Component5 {
4269
4270
  throw new Error("A validator is required for Form functionality to work");
4270
4271
  }
4271
4272
  this.state = this.getStateFromProps(props, props.formData);
4272
- if (this.props.onChange && !deepEquals3(this.state.formData, this.props.formData)) {
4273
+ if (this.props.onChange && !deepEquals2(this.state.formData, this.props.formData)) {
4273
4274
  this.props.onChange(this.state);
4274
4275
  }
4275
4276
  this.formElement = createRef();
@@ -4293,10 +4294,10 @@ var Form = class extends Component5 {
4293
4294
  * with a flag indicating that an update is not necessary.
4294
4295
  */
4295
4296
  getSnapshotBeforeUpdate(prevProps, prevState) {
4296
- if (!deepEquals3(this.props, prevProps)) {
4297
+ if (!deepEquals2(this.props, prevProps)) {
4297
4298
  const formDataChangedFields = getChangedFields(this.props.formData, prevProps.formData);
4298
- const isSchemaChanged = !deepEquals3(prevProps.schema, this.props.schema);
4299
- const isFormDataChanged = formDataChangedFields.length > 0 || !deepEquals3(prevProps.formData, this.props.formData);
4299
+ const isSchemaChanged = !deepEquals2(prevProps.schema, this.props.schema);
4300
+ const isFormDataChanged = formDataChangedFields.length > 0 || !deepEquals2(prevProps.formData, this.props.formData);
4300
4301
  const nextState = this.getStateFromProps(
4301
4302
  this.props,
4302
4303
  this.props.formData,
@@ -4307,7 +4308,7 @@ var Form = class extends Component5 {
4307
4308
  isSchemaChanged,
4308
4309
  formDataChangedFields
4309
4310
  );
4310
- const shouldUpdate = !deepEquals3(nextState, prevState);
4311
+ const shouldUpdate = !deepEquals2(nextState, prevState);
4311
4312
  return { nextState, shouldUpdate };
4312
4313
  }
4313
4314
  return { shouldUpdate: false };
@@ -4327,7 +4328,7 @@ var Form = class extends Component5 {
4327
4328
  componentDidUpdate(_, prevState, snapshot) {
4328
4329
  if (snapshot.shouldUpdate) {
4329
4330
  const { nextState } = snapshot;
4330
- if (!deepEquals3(nextState.formData, this.props.formData) && !deepEquals3(nextState.formData, prevState.formData) && this.props.onChange) {
4331
+ if (!deepEquals2(nextState.formData, this.props.formData) && !deepEquals2(nextState.formData, prevState.formData) && this.props.onChange) {
4331
4332
  this.props.onChange(nextState);
4332
4333
  }
4333
4334
  this.setState(nextState);
@@ -4347,30 +4348,31 @@ var Form = class extends Component5 {
4347
4348
  getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = []) {
4348
4349
  const state = this.state || {};
4349
4350
  const schema = "schema" in props ? props.schema : this.props.schema;
4351
+ const validator = "validator" in props ? props.validator : this.props.validator;
4350
4352
  const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
4351
4353
  const edit = typeof inputFormData !== "undefined";
4352
4354
  const liveValidate = "liveValidate" in props ? props.liveValidate : this.props.liveValidate;
4353
4355
  const mustValidate = edit && !props.noValidate && liveValidate;
4354
- const rootSchema = schema;
4355
4356
  const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
4356
4357
  const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
4357
4358
  let schemaUtils = state.schemaUtils;
4358
4359
  if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
4359
- props.validator,
4360
- rootSchema,
4360
+ validator,
4361
+ schema,
4361
4362
  experimental_defaultFormStateBehavior,
4362
4363
  experimental_customMergeAllOf
4363
4364
  )) {
4364
4365
  schemaUtils = createSchemaUtils(
4365
- props.validator,
4366
- rootSchema,
4366
+ validator,
4367
+ schema,
4367
4368
  experimental_defaultFormStateBehavior,
4368
4369
  experimental_customMergeAllOf
4369
4370
  );
4370
4371
  }
4371
- const formData = schemaUtils.getDefaultFormState(schema, inputFormData);
4372
+ const rootSchema = schemaUtils.getRootSchema();
4373
+ const formData = schemaUtils.getDefaultFormState(rootSchema, inputFormData);
4372
4374
  const _retrievedSchema = this.updateRetrievedSchema(
4373
- retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData)
4375
+ retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData)
4374
4376
  );
4375
4377
  const getCurrentErrors = () => {
4376
4378
  if (props.noValidate || isSchemaChanged) {
@@ -4391,7 +4393,7 @@ var Form = class extends Component5 {
4391
4393
  let schemaValidationErrors = state.schemaValidationErrors;
4392
4394
  let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
4393
4395
  if (mustValidate) {
4394
- const schemaValidation = this.validate(formData, schema, schemaUtils, _retrievedSchema);
4396
+ const schemaValidation = this.validate(formData, rootSchema, schemaUtils, _retrievedSchema);
4395
4397
  errors = schemaValidation.errors;
4396
4398
  if (retrievedSchema === void 0) {
4397
4399
  errorSchema = schemaValidation.errorSchema;
@@ -4437,7 +4439,7 @@ var Form = class extends Component5 {
4437
4439
  );
4438
4440
  const nextState = {
4439
4441
  schemaUtils,
4440
- schema,
4442
+ schema: rootSchema,
4441
4443
  uiSchema,
4442
4444
  idSchema,
4443
4445
  formData,
@@ -4457,7 +4459,8 @@ var Form = class extends Component5 {
4457
4459
  * @returns - True if the component should be updated, false otherwise
4458
4460
  */
4459
4461
  shouldComponentUpdate(nextProps, nextState) {
4460
- return shouldRender(this, nextProps, nextState);
4462
+ const { experimental_componentUpdateStrategy = "customDeep" } = this.props;
4463
+ return shouldRender2(this, nextProps, nextState, experimental_componentUpdateStrategy);
4461
4464
  }
4462
4465
  /** Gets the previously raised customValidate errors.
4463
4466
  *
@@ -4481,7 +4484,7 @@ var Form = class extends Component5 {
4481
4484
  * @param schema - The schema used to validate against
4482
4485
  * @param altSchemaUtils - The alternate schemaUtils to use for validation
4483
4486
  */
4484
- validate(formData, schema = this.props.schema, altSchemaUtils, retrievedSchema) {
4487
+ validate(formData, schema = this.state.schema, altSchemaUtils, retrievedSchema) {
4485
4488
  const schemaUtils = altSchemaUtils ? altSchemaUtils : this.state.schemaUtils;
4486
4489
  const { customValidate, transformErrors, uiSchema } = this.props;
4487
4490
  const resolvedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
@@ -4669,7 +4672,7 @@ var Form = class extends Component5 {
4669
4672
  * @returns The new retrieved schema if it has changed, else the old retrieved schema.
4670
4673
  */
4671
4674
  updateRetrievedSchema(retrievedSchema) {
4672
- const isTheSame = deepEquals3(retrievedSchema, this.state?.retrievedSchema);
4675
+ const isTheSame = deepEquals2(retrievedSchema, this.state?.retrievedSchema);
4673
4676
  return isTheSame ? this.state.retrievedSchema : retrievedSchema;
4674
4677
  }
4675
4678
  /**
@@ -4755,8 +4758,12 @@ var Form = class extends Component5 {
4755
4758
  };
4756
4759
  /** Returns the registry for the form */
4757
4760
  getRegistry() {
4758
- const { translateString: customTranslateString, uiSchema = {} } = this.props;
4759
- const { schemaUtils } = this.state;
4761
+ const {
4762
+ translateString: customTranslateString,
4763
+ uiSchema = {},
4764
+ experimental_componentUpdateStrategy = "customDeep"
4765
+ } = this.props;
4766
+ const { schema, schemaUtils } = this.state;
4760
4767
  const { fields: fields2, templates: templates2, widgets: widgets2, formContext, translateString } = getDefaultRegistry();
4761
4768
  return {
4762
4769
  fields: { ...fields2, ...this.props.fields },
@@ -4769,11 +4776,12 @@ var Form = class extends Component5 {
4769
4776
  }
4770
4777
  },
4771
4778
  widgets: { ...widgets2, ...this.props.widgets },
4772
- rootSchema: this.props.schema,
4779
+ rootSchema: schema,
4773
4780
  formContext: this.props.formContext || formContext,
4774
4781
  schemaUtils,
4775
4782
  translateString: customTranslateString || translateString,
4776
- globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY2]
4783
+ globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY2],
4784
+ experimental_componentUpdateStrategy
4777
4785
  };
4778
4786
  }
4779
4787
  /** Provides a function that can be used to programmatically submit the `Form` */