@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.
package/dist/core.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { Component, useState, useCallback, useEffect, useReducer, createRef, forwardRef } from 'react';
3
- import { isFixedItems, allowAdditionalItems, getUiOptions, ITEMS_KEY, getTemplate, TranslatableString, isCustomWidget, getWidget, optionsList, deepEquals, getDiscriminatorFieldFromSchema, ERRORS_KEY, asNumber, REF_KEY, orderProperties, PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ANY_OF_KEY, ONE_OF_KEY, mergeObjects, UI_OPTIONS_KEY, getSchemaType, descriptionId, ID_KEY, hasWidget, titleId, getInputProps, examplesId, ariaDescribedByIds, getSubmitButtonOptions, errorId, helpId, canExpand, parseDateString, toDateString, pad, schemaRequiresTrueValue, labelValue, enumOptionsValueForIndex, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, utcToLocal, localToUTC, dataURItoBlob, enumOptionsIndexForValue, englishStringTranslator, createSchemaUtils, validationDataMerge, shouldRender, UI_GLOBAL_OPTIONS_KEY, SUBMIT_BTN_OPTIONS_KEY, isObject as isObject$1, toErrorList, RJSF_ADDITONAL_PROPERTIES_FLAG, NAME_KEY } from '@rjsf/utils';
3
+ import { isFixedItems, allowAdditionalItems, getUiOptions, ITEMS_KEY, getTemplate, TranslatableString, isCustomWidget, getWidget, optionsList, deepEquals, getDiscriminatorFieldFromSchema, ERRORS_KEY, ADDITIONAL_PROPERTY_FLAG, asNumber, REF_KEY, orderProperties, PROPERTIES_KEY, ANY_OF_KEY, ONE_OF_KEY, mergeObjects, UI_OPTIONS_KEY, getSchemaType, descriptionId, ID_KEY, hasWidget, titleId, getInputProps, examplesId, ariaDescribedByIds, getSubmitButtonOptions, errorId, helpId, canExpand, parseDateString, toDateString, pad, schemaRequiresTrueValue, labelValue, enumOptionsValueForIndex, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, utcToLocal, localToUTC, dataURItoBlob, enumOptionsIndexForValue, englishStringTranslator, createSchemaUtils, validationDataMerge, shouldRender, UI_GLOBAL_OPTIONS_KEY, SUBMIT_BTN_OPTIONS_KEY, isObject as isObject$1, toErrorList, RJSF_ADDITONAL_PROPERTIES_FLAG, NAME_KEY } from '@rjsf/utils';
4
4
  import get from 'lodash-es/get';
5
5
  import isEmpty from 'lodash-es/isEmpty';
6
6
  import _pick from 'lodash-es/pick';
@@ -10,9 +10,9 @@ import isObject from 'lodash-es/isObject';
10
10
  import set from 'lodash-es/set';
11
11
  import { nanoid } from 'nanoid';
12
12
  import omit from 'lodash-es/omit';
13
+ import unset from 'lodash-es/unset';
13
14
  import Markdown from 'markdown-to-jsx';
14
15
  import has from 'lodash-es/has';
15
- import unset from 'lodash-es/unset';
16
16
 
17
17
  function _defineProperties(target, props) {
18
18
  for (var i = 0; i < props.length; i++) {
@@ -85,7 +85,7 @@ function _toPropertyKey(arg) {
85
85
  }
86
86
 
87
87
  var _excluded$9 = ["widget", "title"],
88
- _excluded2 = ["widget", "title"],
88
+ _excluded2$1 = ["widget", "title"],
89
89
  _excluded3 = ["widget", "title"];
90
90
  /** Used to generate a unique ID for an element in a row */
91
91
  function generateRowId() {
@@ -629,7 +629,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
629
629
  _getUiOptions3$widget = _getUiOptions3.widget,
630
630
  widget = _getUiOptions3$widget === void 0 ? 'select' : _getUiOptions3$widget,
631
631
  uiTitle = _getUiOptions3.title,
632
- options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
632
+ options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2$1);
633
633
  var Widget = getWidget(schema, widget, widgets);
634
634
  var label = (_ref2 = uiTitle != null ? uiTitle : schema.title) != null ? _ref2 : name;
635
635
  var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
@@ -1023,7 +1023,8 @@ function BooleanField(props) {
1023
1023
  });
1024
1024
  }
1025
1025
 
1026
- var _excluded$7 = ["widget", "placeholder", "autofocus", "autocomplete", "title"];
1026
+ var _excluded$7 = ["widget", "placeholder", "autofocus", "autocomplete", "title"],
1027
+ _excluded2 = ["oneOf", "anyOf"];
1027
1028
  /** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
1028
1029
  * the currently selected option and cleans up any irrelevant data in `formData`.
1029
1030
  *
@@ -1149,7 +1150,6 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
1149
1150
  _proto.render = function render() {
1150
1151
  var _this$props6 = this.props,
1151
1152
  name = _this$props6.name,
1152
- baseType = _this$props6.baseType,
1153
1153
  _this$props6$disabled = _this$props6.disabled,
1154
1154
  disabled = _this$props6$disabled === void 0 ? false : _this$props6$disabled,
1155
1155
  _this$props6$errorSch = _this$props6.errorSchema,
@@ -1187,11 +1187,10 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
1187
1187
  var option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
1188
1188
  var optionSchema;
1189
1189
  if (option) {
1190
- // If the subschema doesn't declare a type, infer the type from the
1191
- // parent schema
1192
- optionSchema = option.type ? option : Object.assign({}, option, {
1193
- type: baseType
1194
- });
1190
+ var remaining = _objectWithoutPropertiesLoose(schema, _excluded2);
1191
+ // Merge in all the non-oneOf/anyOf properties and also skip the special ADDITIONAL_PROPERTY_FLAG property
1192
+ unset(remaining, ADDITIONAL_PROPERTY_FLAG);
1193
+ optionSchema = !isEmpty(remaining) ? _extends({}, remaining, option) : option;
1195
1194
  }
1196
1195
  var translateEnum = title ? TranslatableString.TitleOptionPrefix : TranslatableString.OptionPrefix;
1197
1196
  var translateParams = title ? [title] : [];
@@ -1650,7 +1649,11 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
1650
1649
  }
1651
1650
  var schemaType = getSchemaType(schema);
1652
1651
  var type = Array.isArray(schemaType) ? schemaType[0] : schemaType || '';
1652
+ var schemaId = schema.$id;
1653
1653
  var componentName = COMPONENT_TYPES[type];
1654
+ if (schemaId && schemaId in fields) {
1655
+ componentName = schemaId;
1656
+ }
1654
1657
  // If the type is not defined and the schema uses 'anyOf' or 'oneOf', don't
1655
1658
  // render a field and let the MultiSchemaField component handle the form display
1656
1659
  if (!componentName && (schema.anyOf || schema.oneOf)) {
@@ -1837,7 +1840,6 @@ function SchemaFieldRender(props) {
1837
1840
  options: schema.anyOf.map(function (_schema) {
1838
1841
  return schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData);
1839
1842
  }),
1840
- baseType: schema.type,
1841
1843
  registry: registry,
1842
1844
  schema: schema,
1843
1845
  uiSchema: uiSchema
@@ -1858,7 +1860,6 @@ function SchemaFieldRender(props) {
1858
1860
  options: schema.oneOf.map(function (_schema) {
1859
1861
  return schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData);
1860
1862
  }),
1861
- baseType: schema.type,
1862
1863
  registry: registry,
1863
1864
  schema: schema,
1864
1865
  uiSchema: uiSchema