@rjsf/core 6.5.0 → 6.5.2

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
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/cloneDeep'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/pick'), require('lodash/set'), require('lodash/toPath'), require('lodash/unset'), require('lodash/isObject'), require('lodash/uniqueId'), require('react/jsx-runtime'), require('lodash/each'), require('lodash/flatten'), require('lodash/has'), require('lodash/includes'), require('lodash/intersection'), require('lodash/isFunction'), require('lodash/isEqual'), require('lodash/isPlainObject'), require('lodash/isString'), require('lodash/isUndefined'), require('lodash/last'), require('lodash/noop'), require('lodash/omit'), require('markdown-to-jsx'), require('@rjsf/validator-ajv8')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/cloneDeep', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/set', 'lodash/toPath', 'lodash/unset', 'lodash/isObject', 'lodash/uniqueId', 'react/jsx-runtime', 'lodash/each', 'lodash/flatten', 'lodash/has', 'lodash/includes', 'lodash/intersection', 'lodash/isFunction', 'lodash/isEqual', 'lodash/isPlainObject', 'lodash/isString', 'lodash/isUndefined', 'lodash/last', 'lodash/noop', 'lodash/omit', 'markdown-to-jsx', '@rjsf/validator-ajv8'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global.cloneDeep, global.get, global.isEmpty, global._pick, global.set, global._toPath, global._unset, global.isObject, global.uniqueId, global.jsxRuntime, global.each, global.flatten, global.has, global.includes, global.intersection, global.isFunction, global.isEqual, global.isPlainObject, global.isString, global.isUndefined, global.last, global.noop, global.omit3, global.Markdown, global.validator));
5
- })(this, (function (exports, react, utils, cloneDeep, get, isEmpty, _pick, set, _toPath, _unset, isObject, uniqueId, jsxRuntime, each, flatten, has, includes, intersection, isFunction, isEqual, isPlainObject, isString, isUndefined, last, noop, omit3, Markdown, validator) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global._cloneDeep, global.get, global.isEmpty, global._pick, global.set, global._toPath, global._unset, global.isObject, global.uniqueId, global.jsxRuntime, global.each, global.flatten, global.has, global.includes, global.intersection, global.isFunction, global.isEqual, global.isPlainObject, global.isString, global.isUndefined, global.last, global.noop, global.omit3, global.Markdown, global.validator));
5
+ })(this, (function (exports, react, utils, _cloneDeep, get, isEmpty, _pick, set, _toPath, _unset, isObject, uniqueId, jsxRuntime, each, flatten, has, includes, intersection, isFunction, isEqual, isPlainObject, isString, isUndefined, last, noop, omit3, Markdown, validator) { 'use strict';
6
6
 
7
7
  // src/components/Form.tsx
8
8
  function generateRowId() {
@@ -655,7 +655,7 @@
655
655
  }
656
656
  const newKeyedFormDataRow = {
657
657
  key: generateRowId(),
658
- item: cloneDeep(keyedFormData[index].item)
658
+ item: _cloneDeep(keyedFormData[index].item)
659
659
  };
660
660
  const newKeyedFormData = [...keyedFormData];
661
661
  if (index !== void 0) {
@@ -722,10 +722,12 @@
722
722
  );
723
723
  const handleChange = react.useCallback(
724
724
  (value, path, newErrorSchema, id) => {
725
+ const lastPathIsItemIndex = typeof path.at(-1) === "number";
725
726
  onChange(
726
727
  // We need to treat undefined items as nulls to have validation.
727
728
  // See https://github.com/tdegrunt/jsonschema/issues/206
728
- value === void 0 ? null : value,
729
+ // Only set to null for array items, and not for object properties within array items
730
+ lastPathIsItemIndex && value === void 0 ? null : value,
729
731
  path,
730
732
  newErrorSchema,
731
733
  id
@@ -4217,11 +4219,12 @@
4217
4219
  const { newErrorSchema } = this.pendingChanges[0];
4218
4220
  const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange, removeEmptyOptionalObjects } = this.props;
4219
4221
  const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
4220
- let { customErrors, errorSchema: originalErrorSchema } = this.state;
4222
+ let { customErrors } = this.state;
4223
+ let mergeBaseErrorSchema = schemaValidationErrorSchema;
4221
4224
  const rootPathId = fieldPathId.path[0] || "";
4222
4225
  const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
4223
4226
  let retrievedSchema = this.state.retrievedSchema;
4224
- let formData = isRootPath ? newValue : cloneDeep(oldFormData);
4227
+ let formData = isRootPath ? newValue : _cloneDeep(oldFormData);
4225
4228
  const hasOnlyUndefinedValues = utils.isObject(formData) && Object.keys(formData).length > 0 && Object.values(formData).every((v) => v === void 0);
4226
4229
  const wasPreviouslyNull = oldFormData === null || oldFormData === void 0;
4227
4230
  const inputForDefaults = hasOnlyUndefinedValues && wasPreviouslyNull ? void 0 : formData;
@@ -4260,9 +4263,10 @@
4260
4263
  const oldValidationError = !isRootPath ? get(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
4261
4264
  if (!isEmpty(oldValidationError)) {
4262
4265
  if (!isRootPath) {
4263
- set(originalErrorSchema, path, newErrorSchema);
4266
+ mergeBaseErrorSchema = _cloneDeep(schemaValidationErrorSchema);
4267
+ set(mergeBaseErrorSchema, path, newErrorSchema);
4264
4268
  } else {
4265
- originalErrorSchema = newErrorSchema;
4269
+ mergeBaseErrorSchema = newErrorSchema;
4266
4270
  }
4267
4271
  } else {
4268
4272
  if (!customErrors) {
@@ -4284,7 +4288,7 @@
4284
4288
  const liveValidation = this.liveValidate(
4285
4289
  schema,
4286
4290
  schemaUtils,
4287
- originalErrorSchema,
4291
+ mergeBaseErrorSchema,
4288
4292
  newFormData,
4289
4293
  extraErrors,
4290
4294
  customErrors,
@@ -4292,7 +4296,7 @@
4292
4296
  );
4293
4297
  state = { formData: newFormData, ...liveValidation, customErrors };
4294
4298
  } else if (!noValidate && newErrorSchema) {
4295
- const mergedErrors = this.mergeErrors({ errorSchema: originalErrorSchema, errors }, extraErrors, customErrors);
4299
+ const mergedErrors = this.mergeErrors({ errorSchema: mergeBaseErrorSchema, errors }, extraErrors, customErrors);
4296
4300
  state = {
4297
4301
  formData: newFormData,
4298
4302
  ...mergedErrors,
package/dist/index.cjs CHANGED
@@ -779,10 +779,12 @@ function ArrayField(props) {
779
779
  );
780
780
  const handleChange = (0, import_react.useCallback)(
781
781
  (value, path, newErrorSchema, id) => {
782
+ const lastPathIsItemIndex = typeof path.at(-1) === "number";
782
783
  onChange(
783
784
  // We need to treat undefined items as nulls to have validation.
784
785
  // See https://github.com/tdegrunt/jsonschema/issues/206
785
- value === void 0 ? null : value,
786
+ // Only set to null for array items, and not for object properties within array items
787
+ lastPathIsItemIndex && value === void 0 ? null : value,
786
788
  path,
787
789
  newErrorSchema,
788
790
  id
@@ -4563,7 +4565,8 @@ var Form = class extends import_react21.Component {
4563
4565
  const { newErrorSchema } = this.pendingChanges[0];
4564
4566
  const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange, removeEmptyOptionalObjects } = this.props;
4565
4567
  const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
4566
- let { customErrors, errorSchema: originalErrorSchema } = this.state;
4568
+ let { customErrors } = this.state;
4569
+ let mergeBaseErrorSchema = schemaValidationErrorSchema;
4567
4570
  const rootPathId = fieldPathId.path[0] || "";
4568
4571
  const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
4569
4572
  let retrievedSchema = this.state.retrievedSchema;
@@ -4606,9 +4609,10 @@ var Form = class extends import_react21.Component {
4606
4609
  const oldValidationError = !isRootPath ? (0, import_get5.default)(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
4607
4610
  if (!(0, import_isEmpty4.default)(oldValidationError)) {
4608
4611
  if (!isRootPath) {
4609
- (0, import_set5.default)(originalErrorSchema, path, newErrorSchema);
4612
+ mergeBaseErrorSchema = (0, import_cloneDeep2.default)(schemaValidationErrorSchema);
4613
+ (0, import_set5.default)(mergeBaseErrorSchema, path, newErrorSchema);
4610
4614
  } else {
4611
- originalErrorSchema = newErrorSchema;
4615
+ mergeBaseErrorSchema = newErrorSchema;
4612
4616
  }
4613
4617
  } else {
4614
4618
  if (!customErrors) {
@@ -4630,7 +4634,7 @@ var Form = class extends import_react21.Component {
4630
4634
  const liveValidation = this.liveValidate(
4631
4635
  schema,
4632
4636
  schemaUtils,
4633
- originalErrorSchema,
4637
+ mergeBaseErrorSchema,
4634
4638
  newFormData,
4635
4639
  extraErrors,
4636
4640
  customErrors,
@@ -4638,7 +4642,7 @@ var Form = class extends import_react21.Component {
4638
4642
  );
4639
4643
  state = { formData: newFormData, ...liveValidation, customErrors };
4640
4644
  } else if (!noValidate && newErrorSchema) {
4641
- const mergedErrors = this.mergeErrors({ errorSchema: originalErrorSchema, errors }, extraErrors, customErrors);
4645
+ const mergedErrors = this.mergeErrors({ errorSchema: mergeBaseErrorSchema, errors }, extraErrors, customErrors);
4642
4646
  state = {
4643
4647
  formData: newFormData,
4644
4648
  ...mergedErrors,