@rjsf/core 5.21.1 → 5.22.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.
- package/dist/core.umd.js +34 -14
- package/dist/index.esm.js +31 -14
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +31 -14
- package/dist/index.js.map +3 -3
- package/lib/components/Form.d.ts +4 -1
- package/lib/components/Form.js +11 -11
- package/lib/components/Form.js.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +3 -2
- package/lib/components/fields/MultiSchemaField.js.map +1 -1
- package/lib/components/fields/ObjectField.js +6 -1
- package/lib/components/fields/ObjectField.js.map +1 -1
- package/lib/components/fields/SchemaField.js +2 -2
- package/lib/components/fields/SchemaField.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/components/Form.tsx +26 -11
- package/src/components/fields/MultiSchemaField.tsx +3 -2
- package/src/components/fields/ObjectField.tsx +5 -1
- package/src/components/fields/SchemaField.tsx +5 -1
package/dist/core.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/forEach'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/pick'), require('lodash/toPath'), require('lodash/cloneDeep'), require('lodash/isObject'), require('lodash/set'), require('nanoid'), require('react/jsx-runtime'), require('lodash/omit'), require('markdown-to-jsx'), require('lodash/has'), require('lodash/unset')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/forEach', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/toPath', 'lodash/cloneDeep', 'lodash/isObject', 'lodash/set', 'nanoid', 'react/jsx-runtime', 'lodash/omit', 'markdown-to-jsx', 'lodash/has', 'lodash/unset'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global._forEach, global.get3, global.isEmpty, global._pick, global._toPath, global.cloneDeep, global.isObject, global.set, global.nanoid, global.jsxRuntime, global.omit2, global.Markdown, global.has, global.unset));
|
|
5
|
-
})(this, (function (exports, react, utils, _forEach, get3, isEmpty, _pick, _toPath, cloneDeep, isObject, set, nanoid, jsxRuntime, omit2, Markdown, has, unset) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/forEach'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/isNil'), require('lodash/pick'), require('lodash/toPath'), require('lodash/cloneDeep'), require('lodash/isObject'), require('lodash/set'), require('nanoid'), require('react/jsx-runtime'), require('lodash/omit'), require('markdown-to-jsx'), require('lodash/has'), require('lodash/unset')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/forEach', 'lodash/get', 'lodash/isEmpty', 'lodash/isNil', 'lodash/pick', 'lodash/toPath', 'lodash/cloneDeep', 'lodash/isObject', 'lodash/set', 'nanoid', 'react/jsx-runtime', 'lodash/omit', 'markdown-to-jsx', 'lodash/has', 'lodash/unset'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global._forEach, global.get3, global.isEmpty, global._isNil, global._pick, global._toPath, global.cloneDeep, global.isObject, global.set, global.nanoid, global.jsxRuntime, global.omit2, global.Markdown, global.has, global.unset));
|
|
5
|
+
})(this, (function (exports, react, utils, _forEach, get3, isEmpty, _isNil, _pick, _toPath, cloneDeep, isObject, set, nanoid, jsxRuntime, omit2, Markdown, has, unset) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// src/components/Form.tsx
|
|
8
8
|
function generateRowId() {
|
|
@@ -897,8 +897,9 @@
|
|
|
897
897
|
if (newFormData && newOption) {
|
|
898
898
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
899
899
|
}
|
|
900
|
-
|
|
901
|
-
|
|
900
|
+
this.setState({ selectedOption: intOption }, () => {
|
|
901
|
+
onChange(newFormData, void 0, this.getFieldId());
|
|
902
|
+
});
|
|
902
903
|
};
|
|
903
904
|
const {
|
|
904
905
|
formData,
|
|
@@ -1186,15 +1187,18 @@
|
|
|
1186
1187
|
const { formData, onChange, registry } = this.props;
|
|
1187
1188
|
const newFormData = { ...formData };
|
|
1188
1189
|
let type = void 0;
|
|
1190
|
+
let constValue = void 0;
|
|
1189
1191
|
let defaultValue = void 0;
|
|
1190
1192
|
if (isObject(schema.additionalProperties)) {
|
|
1191
1193
|
type = schema.additionalProperties.type;
|
|
1194
|
+
constValue = schema.additionalProperties.const;
|
|
1192
1195
|
defaultValue = schema.additionalProperties.default;
|
|
1193
1196
|
let apSchema = schema.additionalProperties;
|
|
1194
1197
|
if (utils.REF_KEY in apSchema) {
|
|
1195
1198
|
const { schemaUtils } = registry;
|
|
1196
1199
|
apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[utils.REF_KEY] }, formData);
|
|
1197
1200
|
type = apSchema.type;
|
|
1201
|
+
constValue = apSchema.const;
|
|
1198
1202
|
defaultValue = apSchema.default;
|
|
1199
1203
|
}
|
|
1200
1204
|
if (!type && (utils.ANY_OF_KEY in apSchema || utils.ONE_OF_KEY in apSchema)) {
|
|
@@ -1202,7 +1206,8 @@
|
|
|
1202
1206
|
}
|
|
1203
1207
|
}
|
|
1204
1208
|
const newKey = this.getAvailableKey("newKey", newFormData);
|
|
1205
|
-
|
|
1209
|
+
const newValue = constValue ?? defaultValue ?? this.getDefaultValue(type);
|
|
1210
|
+
set(newFormData, newKey, newValue);
|
|
1206
1211
|
onChange(newFormData);
|
|
1207
1212
|
};
|
|
1208
1213
|
}
|
|
@@ -1423,7 +1428,9 @@
|
|
|
1423
1428
|
);
|
|
1424
1429
|
const FieldComponent = getFieldComponent(schema, uiOptions, idSchema, registry);
|
|
1425
1430
|
const disabled = Boolean(uiOptions.disabled ?? props.disabled);
|
|
1426
|
-
const readonly = Boolean(
|
|
1431
|
+
const readonly = Boolean(
|
|
1432
|
+
uiOptions.readonly ?? (props.readonly || props.schema.const || props.schema.readOnly || schema.readOnly)
|
|
1433
|
+
);
|
|
1427
1434
|
const uiSchemaHideError = uiOptions.hideError;
|
|
1428
1435
|
const hideError = uiSchemaHideError === void 0 ? props.hideError : Boolean(uiSchemaHideError);
|
|
1429
1436
|
const autofocus = Boolean(uiOptions.autofocus ?? props.autofocus);
|
|
@@ -1561,6 +1568,7 @@
|
|
|
1561
1568
|
(_schema2) => schemaUtils.retrieveSchema(isObject(_schema2) ? _schema2 : {}, formData)
|
|
1562
1569
|
),
|
|
1563
1570
|
registry,
|
|
1571
|
+
required,
|
|
1564
1572
|
schema,
|
|
1565
1573
|
uiSchema
|
|
1566
1574
|
}
|
|
@@ -1585,6 +1593,7 @@
|
|
|
1585
1593
|
(_schema2) => schemaUtils.retrieveSchema(isObject(_schema2) ? _schema2 : {}, formData)
|
|
1586
1594
|
),
|
|
1587
1595
|
registry,
|
|
1596
|
+
required,
|
|
1588
1597
|
schema,
|
|
1589
1598
|
uiSchema
|
|
1590
1599
|
}
|
|
@@ -3335,9 +3344,20 @@
|
|
|
3335
3344
|
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
3336
3345
|
const rootSchema = schema;
|
|
3337
3346
|
const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
|
|
3347
|
+
const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
|
|
3338
3348
|
let schemaUtils = state.schemaUtils;
|
|
3339
|
-
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
|
|
3340
|
-
|
|
3349
|
+
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
|
|
3350
|
+
props.validator,
|
|
3351
|
+
rootSchema,
|
|
3352
|
+
experimental_defaultFormStateBehavior,
|
|
3353
|
+
experimental_customMergeAllOf
|
|
3354
|
+
)) {
|
|
3355
|
+
schemaUtils = utils.createSchemaUtils(
|
|
3356
|
+
props.validator,
|
|
3357
|
+
rootSchema,
|
|
3358
|
+
experimental_defaultFormStateBehavior,
|
|
3359
|
+
experimental_customMergeAllOf
|
|
3360
|
+
);
|
|
3341
3361
|
}
|
|
3342
3362
|
const formData = schemaUtils.getDefaultFormState(schema, inputFormData);
|
|
3343
3363
|
const _retrievedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
|
|
@@ -3458,17 +3478,17 @@
|
|
|
3458
3478
|
if (resolvedSchema?.type !== "object" && resolvedSchema?.type !== "array") {
|
|
3459
3479
|
filteredErrors.__errors = schemaErrors.__errors;
|
|
3460
3480
|
}
|
|
3461
|
-
const
|
|
3481
|
+
const filterNilOrEmptyErrors = (errors) => {
|
|
3462
3482
|
_forEach(errors, (errorAtKey, errorKey) => {
|
|
3463
|
-
if (errorAtKey
|
|
3483
|
+
if (_isNil(errorAtKey)) {
|
|
3464
3484
|
delete errors[errorKey];
|
|
3465
3485
|
} else if (typeof errorAtKey === "object" && !Array.isArray(errorAtKey.__errors)) {
|
|
3466
|
-
|
|
3486
|
+
filterNilOrEmptyErrors(errorAtKey);
|
|
3467
3487
|
}
|
|
3468
3488
|
});
|
|
3469
3489
|
return errors;
|
|
3470
3490
|
};
|
|
3471
|
-
return
|
|
3491
|
+
return filterNilOrEmptyErrors(filteredErrors);
|
|
3472
3492
|
}
|
|
3473
3493
|
/** Returns the registry for the form */
|
|
3474
3494
|
getRegistry() {
|
package/dist/index.esm.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import _forEach from "lodash/forEach";
|
|
20
20
|
import _get from "lodash/get";
|
|
21
21
|
import _isEmpty from "lodash/isEmpty";
|
|
22
|
+
import _isNil from "lodash/isNil";
|
|
22
23
|
import _pick from "lodash/pick";
|
|
23
24
|
import _toPath from "lodash/toPath";
|
|
24
25
|
|
|
@@ -964,8 +965,9 @@ var AnyOfField = class extends Component2 {
|
|
|
964
965
|
if (newFormData && newOption) {
|
|
965
966
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
966
967
|
}
|
|
967
|
-
|
|
968
|
-
|
|
968
|
+
this.setState({ selectedOption: intOption }, () => {
|
|
969
|
+
onChange(newFormData, void 0, this.getFieldId());
|
|
970
|
+
});
|
|
969
971
|
};
|
|
970
972
|
const {
|
|
971
973
|
formData,
|
|
@@ -1279,15 +1281,18 @@ var ObjectField = class extends Component3 {
|
|
|
1279
1281
|
const { formData, onChange, registry } = this.props;
|
|
1280
1282
|
const newFormData = { ...formData };
|
|
1281
1283
|
let type = void 0;
|
|
1284
|
+
let constValue = void 0;
|
|
1282
1285
|
let defaultValue = void 0;
|
|
1283
1286
|
if (isObject3(schema.additionalProperties)) {
|
|
1284
1287
|
type = schema.additionalProperties.type;
|
|
1288
|
+
constValue = schema.additionalProperties.const;
|
|
1285
1289
|
defaultValue = schema.additionalProperties.default;
|
|
1286
1290
|
let apSchema = schema.additionalProperties;
|
|
1287
1291
|
if (REF_KEY in apSchema) {
|
|
1288
1292
|
const { schemaUtils } = registry;
|
|
1289
1293
|
apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[REF_KEY] }, formData);
|
|
1290
1294
|
type = apSchema.type;
|
|
1295
|
+
constValue = apSchema.const;
|
|
1291
1296
|
defaultValue = apSchema.default;
|
|
1292
1297
|
}
|
|
1293
1298
|
if (!type && (ANY_OF_KEY2 in apSchema || ONE_OF_KEY2 in apSchema)) {
|
|
@@ -1295,7 +1300,8 @@ var ObjectField = class extends Component3 {
|
|
|
1295
1300
|
}
|
|
1296
1301
|
}
|
|
1297
1302
|
const newKey = this.getAvailableKey("newKey", newFormData);
|
|
1298
|
-
|
|
1303
|
+
const newValue = constValue ?? defaultValue ?? this.getDefaultValue(type);
|
|
1304
|
+
set2(newFormData, newKey, newValue);
|
|
1299
1305
|
onChange(newFormData);
|
|
1300
1306
|
};
|
|
1301
1307
|
}
|
|
@@ -1535,7 +1541,9 @@ function SchemaFieldRender(props) {
|
|
|
1535
1541
|
);
|
|
1536
1542
|
const FieldComponent = getFieldComponent(schema, uiOptions, idSchema, registry);
|
|
1537
1543
|
const disabled = Boolean(uiOptions.disabled ?? props.disabled);
|
|
1538
|
-
const readonly = Boolean(
|
|
1544
|
+
const readonly = Boolean(
|
|
1545
|
+
uiOptions.readonly ?? (props.readonly || props.schema.const || props.schema.readOnly || schema.readOnly)
|
|
1546
|
+
);
|
|
1539
1547
|
const uiSchemaHideError = uiOptions.hideError;
|
|
1540
1548
|
const hideError = uiSchemaHideError === void 0 ? props.hideError : Boolean(uiSchemaHideError);
|
|
1541
1549
|
const autofocus = Boolean(uiOptions.autofocus ?? props.autofocus);
|
|
@@ -1673,6 +1681,7 @@ function SchemaFieldRender(props) {
|
|
|
1673
1681
|
(_schema2) => schemaUtils.retrieveSchema(isObject4(_schema2) ? _schema2 : {}, formData)
|
|
1674
1682
|
),
|
|
1675
1683
|
registry,
|
|
1684
|
+
required,
|
|
1676
1685
|
schema,
|
|
1677
1686
|
uiSchema
|
|
1678
1687
|
}
|
|
@@ -1697,6 +1706,7 @@ function SchemaFieldRender(props) {
|
|
|
1697
1706
|
(_schema2) => schemaUtils.retrieveSchema(isObject4(_schema2) ? _schema2 : {}, formData)
|
|
1698
1707
|
),
|
|
1699
1708
|
registry,
|
|
1709
|
+
required,
|
|
1700
1710
|
schema,
|
|
1701
1711
|
uiSchema
|
|
1702
1712
|
}
|
|
@@ -3414,7 +3424,6 @@ var Form = class extends Component5 {
|
|
|
3414
3424
|
const mustValidate = !noValidate && liveValidate;
|
|
3415
3425
|
let state = { formData, schema };
|
|
3416
3426
|
let newFormData = formData;
|
|
3417
|
-
let _retrievedSchema;
|
|
3418
3427
|
if (omitExtraData === true && liveOmit === true) {
|
|
3419
3428
|
newFormData = this.omitExtraData(formData);
|
|
3420
3429
|
state = {
|
|
@@ -3451,9 +3460,6 @@ var Form = class extends Component5 {
|
|
|
3451
3460
|
errors: toErrorList(errorSchema)
|
|
3452
3461
|
};
|
|
3453
3462
|
}
|
|
3454
|
-
if (_retrievedSchema) {
|
|
3455
|
-
state.retrievedSchema = _retrievedSchema;
|
|
3456
|
-
}
|
|
3457
3463
|
this.setState(state, () => onChange && onChange({ ...this.state, ...state }, id));
|
|
3458
3464
|
};
|
|
3459
3465
|
/**
|
|
@@ -3689,9 +3695,20 @@ var Form = class extends Component5 {
|
|
|
3689
3695
|
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
3690
3696
|
const rootSchema = schema;
|
|
3691
3697
|
const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
|
|
3698
|
+
const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
|
|
3692
3699
|
let schemaUtils = state.schemaUtils;
|
|
3693
|
-
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
|
|
3694
|
-
|
|
3700
|
+
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
|
|
3701
|
+
props.validator,
|
|
3702
|
+
rootSchema,
|
|
3703
|
+
experimental_defaultFormStateBehavior,
|
|
3704
|
+
experimental_customMergeAllOf
|
|
3705
|
+
)) {
|
|
3706
|
+
schemaUtils = createSchemaUtils(
|
|
3707
|
+
props.validator,
|
|
3708
|
+
rootSchema,
|
|
3709
|
+
experimental_defaultFormStateBehavior,
|
|
3710
|
+
experimental_customMergeAllOf
|
|
3711
|
+
);
|
|
3695
3712
|
}
|
|
3696
3713
|
const formData = schemaUtils.getDefaultFormState(schema, inputFormData);
|
|
3697
3714
|
const _retrievedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
|
|
@@ -3812,17 +3829,17 @@ var Form = class extends Component5 {
|
|
|
3812
3829
|
if (resolvedSchema?.type !== "object" && resolvedSchema?.type !== "array") {
|
|
3813
3830
|
filteredErrors.__errors = schemaErrors.__errors;
|
|
3814
3831
|
}
|
|
3815
|
-
const
|
|
3832
|
+
const filterNilOrEmptyErrors = (errors) => {
|
|
3816
3833
|
_forEach(errors, (errorAtKey, errorKey) => {
|
|
3817
|
-
if (errorAtKey
|
|
3834
|
+
if (_isNil(errorAtKey)) {
|
|
3818
3835
|
delete errors[errorKey];
|
|
3819
3836
|
} else if (typeof errorAtKey === "object" && !Array.isArray(errorAtKey.__errors)) {
|
|
3820
|
-
|
|
3837
|
+
filterNilOrEmptyErrors(errorAtKey);
|
|
3821
3838
|
}
|
|
3822
3839
|
});
|
|
3823
3840
|
return errors;
|
|
3824
3841
|
};
|
|
3825
|
-
return
|
|
3842
|
+
return filterNilOrEmptyErrors(filteredErrors);
|
|
3826
3843
|
}
|
|
3827
3844
|
/** Returns the registry for the form */
|
|
3828
3845
|
getRegistry() {
|