@rjsf/core 6.5.1 → 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 +14 -10
- package/dist/index.cjs +10 -6
- package/dist/index.cjs.map +2 -2
- package/dist/index.esm.js +10 -6
- package/dist/index.esm.js.map +2 -2
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +12 -6
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +3 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/components/Form.tsx +12 -6
- package/src/components/fields/ArrayField.tsx +3 -1
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.
|
|
5
|
-
})(this, (function (exports, react, utils,
|
|
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:
|
|
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
|
-
|
|
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
|
|
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 :
|
|
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
|
-
|
|
4266
|
+
mergeBaseErrorSchema = _cloneDeep(schemaValidationErrorSchema);
|
|
4267
|
+
set(mergeBaseErrorSchema, path, newErrorSchema);
|
|
4264
4268
|
} else {
|
|
4265
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
|
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,
|
|
4612
|
+
mergeBaseErrorSchema = (0, import_cloneDeep2.default)(schemaValidationErrorSchema);
|
|
4613
|
+
(0, import_set5.default)(mergeBaseErrorSchema, path, newErrorSchema);
|
|
4610
4614
|
} else {
|
|
4611
|
-
|
|
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
|
-
|
|
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:
|
|
4645
|
+
const mergedErrors = this.mergeErrors({ errorSchema: mergeBaseErrorSchema, errors }, extraErrors, customErrors);
|
|
4642
4646
|
state = {
|
|
4643
4647
|
formData: newFormData,
|
|
4644
4648
|
...mergedErrors,
|