@rjsf/core 6.4.1 → 6.5.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.
Files changed (30) hide show
  1. package/dist/core.umd.js +102 -38
  2. package/dist/index.cjs +102 -38
  3. package/dist/index.cjs.map +3 -3
  4. package/dist/index.esm.js +114 -44
  5. package/dist/index.esm.js.map +3 -3
  6. package/lib/components/Form.d.ts +6 -0
  7. package/lib/components/Form.d.ts.map +1 -1
  8. package/lib/components/Form.js +30 -14
  9. package/lib/components/fields/ArrayField.d.ts.map +1 -1
  10. package/lib/components/fields/ArrayField.js +5 -1
  11. package/lib/components/fields/ObjectField.d.ts.map +1 -1
  12. package/lib/components/fields/ObjectField.js +29 -5
  13. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -1
  14. package/lib/components/templates/WrapIfAdditionalTemplate.js +1 -1
  15. package/lib/components/widgets/CheckboxesWidget.d.ts +1 -1
  16. package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
  17. package/lib/components/widgets/CheckboxesWidget.js +7 -5
  18. package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
  19. package/lib/components/widgets/RadioWidget.js +5 -4
  20. package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
  21. package/lib/components/widgets/SelectWidget.js +11 -10
  22. package/lib/tsconfig.tsbuildinfo +1 -1
  23. package/package.json +7 -7
  24. package/src/components/Form.tsx +59 -15
  25. package/src/components/fields/ArrayField.tsx +6 -2
  26. package/src/components/fields/ObjectField.tsx +30 -5
  27. package/src/components/templates/WrapIfAdditionalTemplate.tsx +1 -0
  28. package/src/components/widgets/CheckboxesWidget.tsx +12 -7
  29. package/src/components/widgets/RadioWidget.tsx +9 -6
  30. package/src/components/widgets/SelectWidget.tsx +14 -11
package/dist/index.cjs CHANGED
@@ -139,7 +139,7 @@ function ArrayAsMultiSelect(props) {
139
139
  } = props;
140
140
  const { widgets: widgets2, schemaUtils, globalFormOptions, globalUiOptions } = registry;
141
141
  const itemsSchema = schemaUtils.retrieveSchema(schema.items, items);
142
- const itemsUiSchema = uiSchema?.items ?? {};
142
+ const itemsUiSchema = uiSchema?.items ?? uiSchema;
143
143
  const enumOptions = (0, import_utils.optionsList)(itemsSchema, itemsUiSchema);
144
144
  const { widget = "select", title: uiTitle, ...options } = (0, import_utils.getUiOptions)(uiSchema, globalUiOptions);
145
145
  const Widget = (0, import_utils.getWidget)(schema, widget, widgets2);
@@ -472,6 +472,7 @@ function NormalArray(props) {
472
472
  name: name && `${name}-${index}`,
473
473
  registry,
474
474
  uiOptions,
475
+ parentUiSchema: uiSchema,
475
476
  hideError,
476
477
  readonly,
477
478
  disabled,
@@ -589,6 +590,7 @@ function FixedArray(props) {
589
590
  name: name && `${name}-${index}`,
590
591
  registry,
591
592
  uiOptions,
593
+ parentUiSchema: uiSchema,
592
594
  hideError,
593
595
  readonly,
594
596
  disabled,
@@ -1986,10 +1988,13 @@ function ObjectField(props) {
1986
1988
  } = props;
1987
1989
  const { fields: fields2, schemaUtils, translateString, globalUiOptions } = registry;
1988
1990
  const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
1991
+ const formDataRef = (0, import_react8.useRef)(formData);
1992
+ formDataRef.current = formData;
1989
1993
  const schema = schemaUtils.retrieveSchema(rawSchema, formData, true);
1990
1994
  const uiOptions = (0, import_utils9.getUiOptions)(uiSchema, globalUiOptions);
1991
1995
  const { properties: schemaProperties = {} } = schema;
1992
1996
  const childFieldPathId = props.childFieldPathId ?? fieldPathId;
1997
+ const lastRenamedProperty = (0, import_react8.useRef)({ previousKey: "", currentKey: void 0 });
1993
1998
  const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
1994
1999
  const description = uiOptions.description ?? schema.description;
1995
2000
  const renderOptionalField = (0, import_utils9.shouldRenderOptionalField)(registry, schema, required, uiSchema);
@@ -2039,14 +2044,19 @@ function ObjectField(props) {
2039
2044
  const newValue = constValue ?? defaultValue ?? getDefaultValue(translateString2, type);
2040
2045
  (0, import_set4.default)(newFormData, newKey, newValue);
2041
2046
  }
2047
+ if (lastRenamedProperty.current.previousKey === newKey) {
2048
+ lastRenamedProperty.current.currentKey = newKey;
2049
+ lastRenamedProperty.current.previousKey = getAvailableKey(newKey, newFormData);
2050
+ }
2042
2051
  onChange(newFormData, childFieldPathId.path);
2043
2052
  }, [formData, onChange, registry, childFieldPathId, getAvailableKey, schema]);
2044
2053
  const handleKeyRename = (0, import_react8.useCallback)(
2045
2054
  (oldKey, newKey) => {
2046
2055
  if (oldKey !== newKey) {
2047
- const actualNewKey = getAvailableKey(newKey, formData);
2056
+ const currentFormData = formDataRef.current;
2057
+ const actualNewKey = getAvailableKey(newKey, currentFormData);
2048
2058
  const newFormData = {
2049
- ...formData
2059
+ ...currentFormData
2050
2060
  };
2051
2061
  const newKeys = { [oldKey]: actualNewKey };
2052
2062
  const keyValues = Object.keys(newFormData).map((key) => {
@@ -2054,10 +2064,15 @@ function ObjectField(props) {
2054
2064
  return { [newKey2]: newFormData[key] };
2055
2065
  });
2056
2066
  const renamedObj = Object.assign({}, ...keyValues);
2067
+ formDataRef.current = renamedObj;
2068
+ if (oldKey !== lastRenamedProperty.current.currentKey) {
2069
+ lastRenamedProperty.current.previousKey = oldKey;
2070
+ }
2071
+ lastRenamedProperty.current.currentKey = actualNewKey;
2057
2072
  onChange(renamedObj, childFieldPathId.path);
2058
2073
  }
2059
2074
  },
2060
- [formData, onChange, childFieldPathId, getAvailableKey]
2075
+ [onChange, childFieldPathId, getAvailableKey]
2061
2076
  );
2062
2077
  const handleRemoveProperty = (0, import_react8.useCallback)(
2063
2078
  (key) => {
@@ -2065,6 +2080,12 @@ function ObjectField(props) {
2065
2080
  },
2066
2081
  [onChange, childFieldPathId]
2067
2082
  );
2083
+ const getStableKey = (0, import_react8.useCallback)((property) => {
2084
+ if (lastRenamedProperty.current.currentKey === property) {
2085
+ return lastRenamedProperty.current.previousKey;
2086
+ }
2087
+ return property;
2088
+ }, []);
2068
2089
  if (!renderOptionalField || hasFormData) {
2069
2090
  try {
2070
2091
  const properties = Object.keys(schemaProperties);
@@ -2107,7 +2128,7 @@ function ObjectField(props) {
2107
2128
  readonly,
2108
2129
  hideError
2109
2130
  },
2110
- name2
2131
+ getStableKey(name2)
2111
2132
  );
2112
2133
  return {
2113
2134
  content,
@@ -3343,7 +3364,8 @@ function WrapIfAdditionalTemplate(props) {
3343
3364
  id: `${id}-key`,
3344
3365
  onBlur: onKeyRenameBlur,
3345
3366
  defaultValue: label
3346
- }
3367
+ },
3368
+ label
3347
3369
  )
3348
3370
  ] }) }),
3349
3371
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "form-additional form-group col-xs-5", children }),
@@ -3512,7 +3534,7 @@ var import_jsx_runtime42 = require("react/jsx-runtime");
3512
3534
  function CheckboxesWidget({
3513
3535
  id,
3514
3536
  disabled,
3515
- options: { inline = false, enumOptions, enumDisabled, emptyValue },
3537
+ options,
3516
3538
  value,
3517
3539
  autofocus = false,
3518
3540
  readonly,
@@ -3521,14 +3543,16 @@ function CheckboxesWidget({
3521
3543
  onFocus,
3522
3544
  htmlName
3523
3545
  }) {
3546
+ const { inline = false, enumOptions, enumDisabled, emptyValue } = options;
3547
+ const optionValueFormat = (0, import_utils35.getOptionValueFormat)(options);
3524
3548
  const checkboxesValues = Array.isArray(value) ? value : [value];
3525
3549
  const handleBlur = (0, import_react14.useCallback)(
3526
- ({ target }) => onBlur(id, (0, import_utils35.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
3527
- [onBlur, id, enumOptions, emptyValue]
3550
+ ({ target }) => onBlur(id, (0, import_utils35.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue)),
3551
+ [onBlur, id, enumOptions, emptyValue, optionValueFormat]
3528
3552
  );
3529
3553
  const handleFocus = (0, import_react14.useCallback)(
3530
- ({ target }) => onFocus(id, (0, import_utils35.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
3531
- [onFocus, id, enumOptions, emptyValue]
3554
+ ({ target }) => onFocus(id, (0, import_utils35.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue)),
3555
+ [onFocus, id, enumOptions, emptyValue, optionValueFormat]
3532
3556
  );
3533
3557
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
3534
3558
  const checked = (0, import_utils35.enumOptionsIsSelected)(option.value, checkboxesValues);
@@ -3549,7 +3573,7 @@ function CheckboxesWidget({
3549
3573
  id: (0, import_utils35.optionId)(id, index),
3550
3574
  name: htmlName || id,
3551
3575
  checked,
3552
- value: String(index),
3576
+ value: (0, import_utils35.enumOptionValueEncoder)(option.value, index, optionValueFormat),
3553
3577
  disabled: disabled || itemDisabled || readonly,
3554
3578
  autoFocus: autofocus && index === 0,
3555
3579
  onChange: handleChange,
@@ -3728,13 +3752,14 @@ function RadioWidget({
3728
3752
  htmlName
3729
3753
  }) {
3730
3754
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
3755
+ const optionValueFormat = (0, import_utils42.getOptionValueFormat)(options);
3731
3756
  const handleBlur = (0, import_react16.useCallback)(
3732
- ({ target }) => onBlur(id, (0, import_utils42.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
3733
- [onBlur, enumOptions, emptyValue, id]
3757
+ ({ target }) => onBlur(id, (0, import_utils42.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue)),
3758
+ [onBlur, enumOptions, emptyValue, id, optionValueFormat]
3734
3759
  );
3735
3760
  const handleFocus = (0, import_react16.useCallback)(
3736
- ({ target }) => onFocus(id, (0, import_utils42.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
3737
- [onFocus, enumOptions, emptyValue, id]
3761
+ ({ target }) => onFocus(id, (0, import_utils42.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue)),
3762
+ [onFocus, enumOptions, emptyValue, id, optionValueFormat]
3738
3763
  );
3739
3764
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "field-radio-group", id, role: "radiogroup", children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
3740
3765
  const checked = (0, import_utils42.enumOptionsIsSelected)(option.value, value);
@@ -3750,7 +3775,7 @@ function RadioWidget({
3750
3775
  checked,
3751
3776
  name: htmlName || id,
3752
3777
  required,
3753
- value: String(i),
3778
+ value: (0, import_utils42.enumOptionValueEncoder)(option.value, i, optionValueFormat),
3754
3779
  disabled: disabled || itemDisabled || readonly,
3755
3780
  autoFocus: autofocus && i === 0,
3756
3781
  onChange: handleChange,
@@ -3913,28 +3938,29 @@ function SelectWidget({
3913
3938
  }) {
3914
3939
  const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
3915
3940
  const emptyValue = multiple ? [] : "";
3941
+ const optionValueFormat = (0, import_utils43.getOptionValueFormat)(options);
3916
3942
  const handleFocus = (0, import_react18.useCallback)(
3917
3943
  (event) => {
3918
3944
  const newValue = getValue(event, multiple);
3919
- return onFocus(id, (0, import_utils43.enumOptionsValueForIndex)(newValue, enumOptions, optEmptyVal));
3945
+ return onFocus(id, (0, import_utils43.enumOptionValueDecoder)(newValue, enumOptions, optionValueFormat, optEmptyVal));
3920
3946
  },
3921
- [onFocus, id, multiple, enumOptions, optEmptyVal]
3947
+ [onFocus, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
3922
3948
  );
3923
3949
  const handleBlur = (0, import_react18.useCallback)(
3924
3950
  (event) => {
3925
3951
  const newValue = getValue(event, multiple);
3926
- return onBlur(id, (0, import_utils43.enumOptionsValueForIndex)(newValue, enumOptions, optEmptyVal));
3952
+ return onBlur(id, (0, import_utils43.enumOptionValueDecoder)(newValue, enumOptions, optionValueFormat, optEmptyVal));
3927
3953
  },
3928
- [onBlur, id, multiple, enumOptions, optEmptyVal]
3954
+ [onBlur, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
3929
3955
  );
3930
3956
  const handleChange = (0, import_react18.useCallback)(
3931
3957
  (event) => {
3932
3958
  const newValue = getValue(event, multiple);
3933
- return onChange((0, import_utils43.enumOptionsValueForIndex)(newValue, enumOptions, optEmptyVal));
3959
+ return onChange((0, import_utils43.enumOptionValueDecoder)(newValue, enumOptions, optionValueFormat, optEmptyVal));
3934
3960
  },
3935
- [onChange, multiple, enumOptions, optEmptyVal]
3961
+ [onChange, multiple, enumOptions, optEmptyVal, optionValueFormat]
3936
3962
  );
3937
- const selectedIndexes = (0, import_utils43.enumOptionsIndexForValue)(value, enumOptions, multiple);
3963
+ const selectValue = (0, import_utils43.enumOptionSelectedValue)(value, enumOptions, multiple, optionValueFormat, emptyValue);
3938
3964
  const showPlaceholderOption = !multiple && schema.default === void 0;
3939
3965
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
3940
3966
  "select",
@@ -3944,7 +3970,7 @@ function SelectWidget({
3944
3970
  multiple,
3945
3971
  role: "combobox",
3946
3972
  className: "form-control",
3947
- value: typeof selectedIndexes === "undefined" ? emptyValue : selectedIndexes,
3973
+ value: selectValue,
3948
3974
  required,
3949
3975
  disabled: disabled || readonly,
3950
3976
  autoFocus: autofocus,
@@ -3956,7 +3982,7 @@ function SelectWidget({
3956
3982
  showPlaceholderOption && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("option", { value: "", children: placeholder }),
3957
3983
  Array.isArray(enumOptions) && enumOptions.map(({ value: value2, label }, i) => {
3958
3984
  const disabled2 = enumDisabled && enumDisabled.indexOf(value2) !== -1;
3959
- return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("option", { value: String(i), disabled: disabled2, children: label }, i);
3985
+ return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("option", { value: (0, import_utils43.enumOptionValueEncoder)(value2, i, optionValueFormat), disabled: disabled2, children: label }, i);
3960
3986
  })
3961
3987
  ]
3962
3988
  }
@@ -4349,12 +4375,11 @@ var Form = class extends import_react21.Component {
4349
4375
  }
4350
4376
  const newRegistry = this.getRegistry(props, rootSchema, schemaUtils);
4351
4377
  const registry = (0, import_utils50.deepEquals)(state.registry, newRegistry) ? state.registry : newRegistry;
4352
- const expandedUiSchema = registry.uiSchemaDefinitions ? (0, import_utils50.expandUiSchemaDefinitions)(rootSchema, uiSchema, registry) : uiSchema;
4353
4378
  const fieldPathId = state.fieldPathId && state.fieldPathId?.[import_utils50.ID_KEY] === registry.globalFormOptions.idPrefix ? state.fieldPathId : (0, import_utils50.toFieldPathId)("", registry.globalFormOptions);
4354
4379
  const nextState = {
4355
4380
  schemaUtils,
4356
4381
  schema: rootSchema,
4357
- uiSchema: expandedUiSchema,
4382
+ uiSchema,
4358
4383
  fieldPathId,
4359
4384
  formData,
4360
4385
  edit,
@@ -4428,7 +4453,7 @@ var Form = class extends import_react21.Component {
4428
4453
  errors = merged.errors;
4429
4454
  }
4430
4455
  if (customErrors) {
4431
- const merged = (0, import_utils50.validationDataMerge)(schemaValidation, customErrors.ErrorSchema, true);
4456
+ const merged = (0, import_utils50.validationDataMerge)({ errors, errorSchema }, customErrors.ErrorSchema, true);
4432
4457
  errorSchema = merged.errorSchema;
4433
4458
  errors = merged.errors;
4434
4459
  }
@@ -4536,7 +4561,7 @@ var Form = class extends import_react21.Component {
4536
4561
  this._isProcessingUserChange = true;
4537
4562
  const { newValue, path, id } = this.pendingChanges[0];
4538
4563
  const { newErrorSchema } = this.pendingChanges[0];
4539
- const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
4564
+ const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange, removeEmptyOptionalObjects } = this.props;
4540
4565
  const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
4541
4566
  let { customErrors, errorSchema: originalErrorSchema } = this.state;
4542
4567
  const rootPathId = fieldPathId.path[0] || "";
@@ -4565,6 +4590,18 @@ var Form = class extends import_react21.Component {
4565
4590
  formData: newFormData
4566
4591
  };
4567
4592
  }
4593
+ if (removeEmptyOptionalObjects) {
4594
+ newFormData = (0, import_utils50.removeOptionalEmptyObjects)(
4595
+ schemaUtils.getValidator(),
4596
+ schema,
4597
+ schemaUtils.getRootSchema(),
4598
+ newFormData
4599
+ );
4600
+ state = {
4601
+ ...state,
4602
+ formData: newFormData
4603
+ };
4604
+ }
4568
4605
  if (newErrorSchema) {
4569
4606
  const oldValidationError = !isRootPath ? (0, import_get5.default)(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
4570
4607
  if (!(0, import_isEmpty4.default)(oldValidationError)) {
@@ -4665,24 +4702,33 @@ var Form = class extends import_react21.Component {
4665
4702
  * @param data - The data associated with the field that was blurred
4666
4703
  */
4667
4704
  onBlur = (id, data) => {
4668
- const { onBlur, omitExtraData, liveOmit, liveValidate } = this.props;
4705
+ const { onBlur, omitExtraData, liveOmit, liveValidate, removeEmptyOptionalObjects } = this.props;
4669
4706
  if (onBlur) {
4670
4707
  onBlur(id, data);
4671
4708
  }
4672
4709
  if (omitExtraData === true && liveOmit === "onBlur" || liveValidate === "onBlur") {
4673
4710
  const { onChange, extraErrors } = this.props;
4674
- const { formData } = this.state;
4711
+ const { formData, schemaUtils, schema } = this.state;
4675
4712
  let newFormData = formData;
4676
4713
  let state = { formData: newFormData };
4677
4714
  if (omitExtraData === true && liveOmit === "onBlur") {
4678
4715
  newFormData = this.omitExtraData(formData);
4679
4716
  state = { formData: newFormData };
4680
4717
  }
4718
+ if (removeEmptyOptionalObjects) {
4719
+ newFormData = (0, import_utils50.removeOptionalEmptyObjects)(
4720
+ schemaUtils.getValidator(),
4721
+ schema,
4722
+ schemaUtils.getRootSchema(),
4723
+ newFormData
4724
+ );
4725
+ state = { ...state, formData: newFormData };
4726
+ }
4681
4727
  if (liveValidate === "onBlur") {
4682
- const { schema, schemaUtils, errorSchema, customErrors, retrievedSchema } = this.state;
4728
+ const { schema: schema2, schemaUtils: schemaUtils2, errorSchema, customErrors, retrievedSchema } = this.state;
4683
4729
  const liveValidation = this.liveValidate(
4684
- schema,
4685
- schemaUtils,
4730
+ schema2,
4731
+ schemaUtils2,
4686
4732
  errorSchema,
4687
4733
  newFormData,
4688
4734
  extraErrors,
@@ -4729,11 +4775,20 @@ var Form = class extends import_react21.Component {
4729
4775
  return;
4730
4776
  }
4731
4777
  event.persist();
4732
- const { omitExtraData, extraErrors, noValidate, onSubmit } = this.props;
4778
+ const { omitExtraData, extraErrors, noValidate, onSubmit, removeEmptyOptionalObjects } = this.props;
4733
4779
  let { formData: newFormData } = this.state;
4734
4780
  if (omitExtraData === true) {
4735
4781
  newFormData = this.omitExtraData(newFormData);
4736
4782
  }
4783
+ if (removeEmptyOptionalObjects) {
4784
+ const { schemaUtils, schema } = this.state;
4785
+ newFormData = (0, import_utils50.removeOptionalEmptyObjects)(
4786
+ schemaUtils.getValidator(),
4787
+ schema,
4788
+ schemaUtils.getRootSchema(),
4789
+ newFormData
4790
+ );
4791
+ }
4737
4792
  if (noValidate || this.validateFormWithFormData(newFormData)) {
4738
4793
  const errorSchema = extraErrors || {};
4739
4794
  const errors = extraErrors ? (0, import_utils50.toErrorList)(extraErrors) : [];
@@ -4830,7 +4885,7 @@ var Form = class extends import_react21.Component {
4830
4885
  const elementId = path.join(idSeparator);
4831
4886
  let field = this.formElement.current.elements[elementId];
4832
4887
  if (!field) {
4833
- field = this.formElement.current.querySelector(`input[id^="${elementId}"`);
4888
+ field = this.formElement.current.querySelector(`input[id^="${elementId}"], button[id^="${elementId}"]`);
4834
4889
  }
4835
4890
  if (field && field.length) {
4836
4891
  field = field[0];
@@ -4898,11 +4953,20 @@ var Form = class extends import_react21.Component {
4898
4953
  * @returns - True if the form is valid, false otherwise.
4899
4954
  */
4900
4955
  validateForm() {
4901
- const { omitExtraData } = this.props;
4956
+ const { omitExtraData, removeEmptyOptionalObjects } = this.props;
4902
4957
  let { formData: newFormData } = this.state;
4903
4958
  if (omitExtraData === true) {
4904
4959
  newFormData = this.omitExtraData(newFormData);
4905
4960
  }
4961
+ if (removeEmptyOptionalObjects) {
4962
+ const { schemaUtils, schema } = this.state;
4963
+ newFormData = (0, import_utils50.removeOptionalEmptyObjects)(
4964
+ schemaUtils.getValidator(),
4965
+ schema,
4966
+ schemaUtils.getRootSchema(),
4967
+ newFormData
4968
+ );
4969
+ }
4906
4970
  return this.validateFormWithFormData(newFormData);
4907
4971
  }
4908
4972
  /** Renders the `Form` fields inside the <form> | `tagName` or `_internalFormWrapper`, rendering any errors if