@rjsf/core 5.21.2 → 5.22.1

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/index.js CHANGED
@@ -963,8 +963,9 @@ var AnyOfField = class extends import_react2.Component {
963
963
  if (newFormData && newOption) {
964
964
  newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
965
965
  }
966
- onChange(newFormData, void 0, this.getFieldId());
967
- this.setState({ selectedOption: intOption });
966
+ this.setState({ selectedOption: intOption }, () => {
967
+ onChange(newFormData, void 0, this.getFieldId());
968
+ });
968
969
  };
969
970
  const {
970
971
  formData,
@@ -1268,15 +1269,18 @@ var ObjectField = class extends import_react4.Component {
1268
1269
  const { formData, onChange, registry } = this.props;
1269
1270
  const newFormData = { ...formData };
1270
1271
  let type = void 0;
1272
+ let constValue = void 0;
1271
1273
  let defaultValue = void 0;
1272
1274
  if ((0, import_isObject3.default)(schema.additionalProperties)) {
1273
1275
  type = schema.additionalProperties.type;
1276
+ constValue = schema.additionalProperties.const;
1274
1277
  defaultValue = schema.additionalProperties.default;
1275
1278
  let apSchema = schema.additionalProperties;
1276
1279
  if (import_utils5.REF_KEY in apSchema) {
1277
1280
  const { schemaUtils } = registry;
1278
1281
  apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[import_utils5.REF_KEY] }, formData);
1279
1282
  type = apSchema.type;
1283
+ constValue = apSchema.const;
1280
1284
  defaultValue = apSchema.default;
1281
1285
  }
1282
1286
  if (!type && (import_utils5.ANY_OF_KEY in apSchema || import_utils5.ONE_OF_KEY in apSchema)) {
@@ -1284,7 +1288,8 @@ var ObjectField = class extends import_react4.Component {
1284
1288
  }
1285
1289
  }
1286
1290
  const newKey = this.getAvailableKey("newKey", newFormData);
1287
- (0, import_set2.default)(newFormData, newKey, defaultValue ?? this.getDefaultValue(type));
1291
+ const newValue = constValue ?? defaultValue ?? this.getDefaultValue(type);
1292
+ (0, import_set2.default)(newFormData, newKey, newValue);
1288
1293
  onChange(newFormData);
1289
1294
  };
1290
1295
  }
@@ -1513,7 +1518,9 @@ function SchemaFieldRender(props) {
1513
1518
  );
1514
1519
  const FieldComponent = getFieldComponent(schema, uiOptions, idSchema, registry);
1515
1520
  const disabled = Boolean(uiOptions.disabled ?? props.disabled);
1516
- const readonly = Boolean(uiOptions.readonly ?? (props.readonly || props.schema.readOnly || schema.readOnly));
1521
+ const readonly = Boolean(
1522
+ uiOptions.readonly ?? (props.readonly || props.schema.const || props.schema.readOnly || schema.readOnly)
1523
+ );
1517
1524
  const uiSchemaHideError = uiOptions.hideError;
1518
1525
  const hideError = uiSchemaHideError === void 0 ? props.hideError : Boolean(uiSchemaHideError);
1519
1526
  const autofocus = Boolean(uiOptions.autofocus ?? props.autofocus);
@@ -3594,9 +3601,20 @@ var Form = class extends import_react17.Component {
3594
3601
  const mustValidate = edit && !props.noValidate && liveValidate;
3595
3602
  const rootSchema = schema;
3596
3603
  const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
3604
+ const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
3597
3605
  let schemaUtils = state.schemaUtils;
3598
- if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(props.validator, rootSchema, experimental_defaultFormStateBehavior)) {
3599
- schemaUtils = (0, import_utils39.createSchemaUtils)(props.validator, rootSchema, experimental_defaultFormStateBehavior);
3606
+ if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
3607
+ props.validator,
3608
+ rootSchema,
3609
+ experimental_defaultFormStateBehavior,
3610
+ experimental_customMergeAllOf
3611
+ )) {
3612
+ schemaUtils = (0, import_utils39.createSchemaUtils)(
3613
+ props.validator,
3614
+ rootSchema,
3615
+ experimental_defaultFormStateBehavior,
3616
+ experimental_customMergeAllOf
3617
+ );
3600
3618
  }
3601
3619
  const formData = schemaUtils.getDefaultFormState(schema, inputFormData);
3602
3620
  const _retrievedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);