@rjsf/core 5.8.2 → 5.10.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.
@@ -14,9 +14,9 @@ var isObject = require('lodash/isObject');
14
14
  var set = require('lodash/set');
15
15
  var nanoid = require('nanoid');
16
16
  var omit = require('lodash/omit');
17
+ var unset = require('lodash/unset');
17
18
  var Markdown = require('markdown-to-jsx');
18
19
  var has = require('lodash/has');
19
- var unset = require('lodash/unset');
20
20
 
21
21
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
22
 
@@ -28,9 +28,9 @@ var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
28
28
  var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
29
29
  var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
30
30
  var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
31
+ var unset__default = /*#__PURE__*/_interopDefaultLegacy(unset);
31
32
  var Markdown__default = /*#__PURE__*/_interopDefaultLegacy(Markdown);
32
33
  var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
33
- var unset__default = /*#__PURE__*/_interopDefaultLegacy(unset);
34
34
 
35
35
  function _defineProperties(target, props) {
36
36
  for (var i = 0; i < props.length; i++) {
@@ -103,7 +103,7 @@ function _toPropertyKey(arg) {
103
103
  }
104
104
 
105
105
  var _excluded$9 = ["widget", "title"],
106
- _excluded2 = ["widget", "title"],
106
+ _excluded2$1 = ["widget", "title"],
107
107
  _excluded3 = ["widget", "title"];
108
108
  /** Used to generate a unique ID for an element in a row */
109
109
  function generateRowId() {
@@ -647,7 +647,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
647
647
  _getUiOptions3$widget = _getUiOptions3.widget,
648
648
  widget = _getUiOptions3$widget === void 0 ? 'select' : _getUiOptions3$widget,
649
649
  uiTitle = _getUiOptions3.title,
650
- options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
650
+ options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2$1);
651
651
  var Widget = utils.getWidget(schema, widget, widgets);
652
652
  var label = (_ref2 = uiTitle != null ? uiTitle : schema.title) != null ? _ref2 : name;
653
653
  var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
@@ -1041,7 +1041,8 @@ function BooleanField(props) {
1041
1041
  });
1042
1042
  }
1043
1043
 
1044
- var _excluded$7 = ["widget", "placeholder", "autofocus", "autocomplete", "title"];
1044
+ var _excluded$7 = ["widget", "placeholder", "autofocus", "autocomplete", "title"],
1045
+ _excluded2 = ["oneOf", "anyOf"];
1045
1046
  /** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
1046
1047
  * the currently selected option and cleans up any irrelevant data in `formData`.
1047
1048
  *
@@ -1167,7 +1168,6 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
1167
1168
  _proto.render = function render() {
1168
1169
  var _this$props6 = this.props,
1169
1170
  name = _this$props6.name,
1170
- baseType = _this$props6.baseType,
1171
1171
  _this$props6$disabled = _this$props6.disabled,
1172
1172
  disabled = _this$props6$disabled === void 0 ? false : _this$props6$disabled,
1173
1173
  _this$props6$errorSch = _this$props6.errorSchema,
@@ -1205,11 +1205,10 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
1205
1205
  var option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
1206
1206
  var optionSchema;
1207
1207
  if (option) {
1208
- // If the subschema doesn't declare a type, infer the type from the
1209
- // parent schema
1210
- optionSchema = option.type ? option : Object.assign({}, option, {
1211
- type: baseType
1212
- });
1208
+ var remaining = _objectWithoutPropertiesLoose(schema, _excluded2);
1209
+ // Merge in all the non-oneOf/anyOf properties and also skip the special ADDITIONAL_PROPERTY_FLAG property
1210
+ unset__default["default"](remaining, utils.ADDITIONAL_PROPERTY_FLAG);
1211
+ optionSchema = !isEmpty__default["default"](remaining) ? _extends({}, remaining, option) : option;
1213
1212
  }
1214
1213
  var translateEnum = title ? utils.TranslatableString.TitleOptionPrefix : utils.TranslatableString.OptionPrefix;
1215
1214
  var translateParams = title ? [title] : [];
@@ -1668,7 +1667,11 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
1668
1667
  }
1669
1668
  var schemaType = utils.getSchemaType(schema);
1670
1669
  var type = Array.isArray(schemaType) ? schemaType[0] : schemaType || '';
1670
+ var schemaId = schema.$id;
1671
1671
  var componentName = COMPONENT_TYPES[type];
1672
+ if (schemaId && schemaId in fields) {
1673
+ componentName = schemaId;
1674
+ }
1672
1675
  // If the type is not defined and the schema uses 'anyOf' or 'oneOf', don't
1673
1676
  // render a field and let the MultiSchemaField component handle the form display
1674
1677
  if (!componentName && (schema.anyOf || schema.oneOf)) {
@@ -1855,7 +1858,6 @@ function SchemaFieldRender(props) {
1855
1858
  options: schema.anyOf.map(function (_schema) {
1856
1859
  return schemaUtils.retrieveSchema(isObject__default["default"](_schema) ? _schema : {}, formData);
1857
1860
  }),
1858
- baseType: schema.type,
1859
1861
  registry: registry,
1860
1862
  schema: schema,
1861
1863
  uiSchema: uiSchema
@@ -1876,7 +1878,6 @@ function SchemaFieldRender(props) {
1876
1878
  options: schema.oneOf.map(function (_schema) {
1877
1879
  return schemaUtils.retrieveSchema(isObject__default["default"](_schema) ? _schema : {}, formData);
1878
1880
  }),
1879
- baseType: schema.type,
1880
1881
  registry: registry,
1881
1882
  schema: schema,
1882
1883
  uiSchema: uiSchema